diff options
2 files changed, 36 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt index b0bc2a571b19..79e5b3eba4a8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt @@ -245,20 +245,18 @@ class MobileConnectionRepositoryImpl( callbackEvents .filterIsInstance<CallbackEvent.OnDisplayInfoChanged>() .map { - if (it.telephonyDisplayInfo.networkType == NETWORK_TYPE_UNKNOWN) { - UnknownNetworkType - } else if ( - it.telephonyDisplayInfo.overrideNetworkType == OVERRIDE_NETWORK_TYPE_NONE - ) { - DefaultNetworkType( - mobileMappingsProxy.toIconKey(it.telephonyDisplayInfo.networkType) - ) - } else { + if (it.telephonyDisplayInfo.overrideNetworkType != OVERRIDE_NETWORK_TYPE_NONE) { OverrideNetworkType( mobileMappingsProxy.toIconKeyOverride( it.telephonyDisplayInfo.overrideNetworkType ) ) + } else if (it.telephonyDisplayInfo.networkType != NETWORK_TYPE_UNKNOWN) { + DefaultNetworkType( + mobileMappingsProxy.toIconKey(it.telephonyDisplayInfo.networkType) + ) + } else { + UnknownNetworkType } } .stateIn(scope, SharingStarted.WhileSubscribed(), UnknownNetworkType) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryTest.kt index 4ce422685dfa..90d602145223 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryTest.kt @@ -29,6 +29,7 @@ import android.telephony.TelephonyCallback.DataActivityListener import android.telephony.TelephonyCallback.ServiceStateListener import android.telephony.TelephonyDisplayInfo import android.telephony.TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA +import android.telephony.TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE import android.telephony.TelephonyManager import android.telephony.TelephonyManager.DATA_ACTIVITY_DORMANT import android.telephony.TelephonyManager.DATA_ACTIVITY_IN @@ -414,9 +415,14 @@ class MobileConnectionRepositoryTest : SysuiTestCase() { val job = underTest.resolvedNetworkType.onEach { latest = it }.launchIn(this) val callback = getTelephonyCallbackForType<TelephonyCallback.DisplayInfoListener>() + val overrideType = OVERRIDE_NETWORK_TYPE_NONE val type = NETWORK_TYPE_LTE val expected = DefaultNetworkType(mobileMappings.toIconKey(type)) - val ti = mock<TelephonyDisplayInfo>().also { whenever(it.networkType).thenReturn(type) } + val ti = + mock<TelephonyDisplayInfo>().also { + whenever(it.overrideNetworkType).thenReturn(overrideType) + whenever(it.networkType).thenReturn(type) + } callback.onDisplayInfoChanged(ti) assertThat(latest).isEqualTo(expected) @@ -446,6 +452,28 @@ class MobileConnectionRepositoryTest : SysuiTestCase() { } @Test + fun networkType_unknownNetworkWithOverride_usesOverrideKey() = + testScope.runTest { + var latest: ResolvedNetworkType? = null + val job = underTest.resolvedNetworkType.onEach { latest = it }.launchIn(this) + + val callback = getTelephonyCallbackForType<TelephonyCallback.DisplayInfoListener>() + val unknown = NETWORK_TYPE_UNKNOWN + val type = OVERRIDE_NETWORK_TYPE_LTE_CA + val expected = OverrideNetworkType(mobileMappings.toIconKeyOverride(type)) + val ti = + mock<TelephonyDisplayInfo>().also { + whenever(it.networkType).thenReturn(unknown) + whenever(it.overrideNetworkType).thenReturn(type) + } + callback.onDisplayInfoChanged(ti) + + assertThat(latest).isEqualTo(expected) + + job.cancel() + } + + @Test fun dataEnabled_initial_false() = testScope.runTest { whenever(telephonyManager.isDataConnectionAllowed).thenReturn(false) |