[SB Refactor] Don't show RAT icon if the resource ID is invalid.

Fixes: 275356714
Test: force alwaysShowDataRatIcon to true and have an invalid
subscription -> verify no extra space between wifi and mobile triangle
Test: atest MobileIconViewModelTest

Change-Id: I2c6792c37dc50244428b8d5416604e2f8427ee49
This commit is contained in:
Caitlin Shkuratov
2023-03-27 16:27:01 +00:00
parent 0abe80aa7b
commit bd2eb04ed6
2 changed files with 21 additions and 2 deletions

View File

@@ -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

View File

@@ -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
@@ -399,6 +400,21 @@ class MobileIconViewModelTest : SysuiTestCase() {
job.cancel()
}
@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 {