summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractor.kt8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt16
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconInteractor.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractorTest.kt17
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt26
5 files changed, 64 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractor.kt
index e6686dce7bbc..675760533d97 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractor.kt
@@ -48,6 +48,9 @@ interface MobileIconInteractor {
/** True when telephony tells us that the data state is CONNECTED */
val isDataConnected: StateFlow<Boolean>
+ /** True if we consider this connection to be in service, i.e. can make calls */
+ val isInService: StateFlow<Boolean>
+
// TODO(b/256839546): clarify naming of default vs active
/** True if we want to consider the data connection enabled */
val isDefaultDataEnabled: StateFlow<Boolean>
@@ -175,4 +178,9 @@ class MobileIconInteractorImpl(
connectionInfo
.mapLatest { connection -> connection.dataConnectionState == Connected }
.stateIn(scope, SharingStarted.WhileSubscribed(), false)
+
+ override val isInService =
+ connectionRepository.connectionInfo
+ .mapLatest { it.isInService }
+ .stateIn(scope, SharingStarted.WhileSubscribed(), false)
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt
index 2d6ac4efd512..a2117c7df188 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt
@@ -80,11 +80,17 @@ constructor(
override val iconId: Flow<Int> = run {
val initial = SignalDrawable.getEmptyState(iconInteractor.numberOfLevels.value)
- combine(iconInteractor.level, iconInteractor.numberOfLevels, showExclamationMark) {
- level,
- numberOfLevels,
- showExclamationMark ->
- SignalDrawable.getState(level, numberOfLevels, showExclamationMark)
+ combine(
+ iconInteractor.level,
+ iconInteractor.numberOfLevels,
+ showExclamationMark,
+ iconInteractor.isInService,
+ ) { level, numberOfLevels, showExclamationMark, isInService ->
+ if (!isInService) {
+ SignalDrawable.getEmptyState(numberOfLevels)
+ } else {
+ SignalDrawable.getState(level, numberOfLevels, showExclamationMark)
+ }
}
.distinctUntilChanged()
.logDiffsForTable(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconInteractor.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconInteractor.kt
index c49458909c78..5889ec885e1f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconInteractor.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconInteractor.kt
@@ -52,6 +52,8 @@ class FakeMobileIconInteractor(
override val isDataConnected = MutableStateFlow(true)
+ override val isInService = MutableStateFlow(true)
+
private val _isDataEnabled = MutableStateFlow(true)
override val isDataEnabled = _isDataEnabled
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractorTest.kt
index 83c5055a6eda..cb2ee9940c38 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractorTest.kt
@@ -300,6 +300,23 @@ class MobileIconInteractorTest : SysuiTestCase() {
}
@Test
+ fun `isInService - uses repository value`() =
+ runBlocking(IMMEDIATE) {
+ var latest: Boolean? = null
+ val job = underTest.isInService.onEach { latest = it }.launchIn(this)
+
+ connectionRepository.setConnectionInfo(MobileConnectionModel(isInService = true))
+
+ assertThat(latest).isTrue()
+
+ connectionRepository.setConnectionInfo(MobileConnectionModel(isInService = false))
+
+ assertThat(latest).isFalse()
+
+ job.cancel()
+ }
+
+ @Test
fun `roaming - is gsm - uses connection model`() =
runBlocking(IMMEDIATE) {
var latest: Boolean? = null
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt
index 50221bc97bad..2a8d42ff6997 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt
@@ -98,6 +98,30 @@ class MobileIconViewModelTest : SysuiTestCase() {
}
@Test
+ fun `icon - uses empty state - when not in service`() =
+ testScope.runTest {
+ var latest: Int? = null
+ val job = underTest.iconId.onEach { latest = it }.launchIn(this)
+
+ interactor.isInService.value = false
+
+ var expected = emptySignal()
+
+ assertThat(latest).isEqualTo(expected)
+
+ // Changing the level doesn't overwrite the disabled state
+ interactor.level.value = 2
+ assertThat(latest).isEqualTo(expected)
+
+ // Once back in service, the regular icon appears
+ interactor.isInService.value = true
+ expected = defaultSignal(level = 2)
+ assertThat(latest).isEqualTo(expected)
+
+ job.cancel()
+ }
+
+ @Test
fun networkType_dataEnabled_groupIsRepresented() =
testScope.runTest {
val expected =
@@ -375,5 +399,7 @@ class MobileIconViewModelTest : SysuiTestCase() {
): Int {
return SignalDrawable.getState(level, /* numLevels */ 4, !connected)
}
+
+ fun emptySignal(): Int = SignalDrawable.getEmptyState(4)
}
}