summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Caitlin Shkuratov <caitlinshk@google.com> 2023-04-05 14:02:26 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-04-05 14:02:26 +0000
commite05e51d3808d78aed17b3dd75007f8ff70868788 (patch)
treed7c6413128395310d63f12168082c10a6aee4548
parent33a3e4135a1fc9ced1c0240ad7bc6288b73bb723 (diff)
parentbd2eb04ed6016f356ec84ca0535f4d9d0f56c2b3 (diff)
Merge "[SB Refactor] Don't show RAT icon if the resource ID is invalid." into udc-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt18
2 files changed, 21 insertions, 2 deletions
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 0fd007cf40ef..62bc27f9dd4e 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
@@ -170,7 +170,10 @@ constructor(
if (networkTypeIconGroup.dataContentDescription != 0)
ContentDescription.Resource(networkTypeIconGroup.dataContentDescription)
else null
- val icon = Icon.Resource(networkTypeIconGroup.dataType, desc)
+ val icon =
+ if (networkTypeIconGroup.dataType != 0)
+ Icon.Resource(networkTypeIconGroup.dataType, desc)
+ else null
return@combine when {
!shouldShow -> null
else -> icon
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 8ea8f87e6aff..1593e5c735a5 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
@@ -20,6 +20,7 @@ import androidx.test.filters.SmallTest
import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH
import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH_NONE
import com.android.settingslib.mobile.TelephonyIcons.THREE_G
+import com.android.settingslib.mobile.TelephonyIcons.UNKNOWN
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.common.shared.model.Icon
@@ -343,7 +344,7 @@ class MobileIconViewModelTest : SysuiTestCase() {
fun networkType_alwaysShow_shownEvenWhenDisabled() =
testScope.runTest {
interactor.setIconGroup(THREE_G)
- interactor.setIsDataEnabled(true)
+ interactor.setIsDataEnabled(false)
interactor.alwaysShowDataRatIcon.value = true
var latest: Icon? = null
@@ -400,6 +401,21 @@ class MobileIconViewModelTest : SysuiTestCase() {
}
@Test
+ fun networkType_alwaysShow_notShownWhenInvalidDataTypeIcon() =
+ testScope.runTest {
+ // The UNKNOWN icon group doesn't have a valid data type icon ID
+ interactor.setIconGroup(UNKNOWN)
+ interactor.alwaysShowDataRatIcon.value = true
+
+ var latest: Icon? = null
+ val job = underTest.networkTypeIcon.onEach { latest = it }.launchIn(this)
+
+ assertThat(latest).isNull()
+
+ job.cancel()
+ }
+
+ @Test
fun `network type - alwaysShow - shown when not default`() =
testScope.runTest {
interactor.setIconGroup(THREE_G)