diff options
| author | 2024-04-22 17:10:32 +0000 | |
|---|---|---|
| committer | 2024-04-22 17:10:32 +0000 | |
| commit | 8ff457cd16b393e94fcc28e02cb1343b145d1a52 (patch) | |
| tree | 737a3388db277462360d7d26f38758ab710ca417 | |
| parent | 1d17d17f78f2a119bf17e706b4a3bf16bfbbb9ae (diff) | |
| parent | caa2b71e4ad9e90386ddbeaf4d4e071a222a20ea (diff) | |
Merge "Revert^2 [Mobile] Make sure we +1 the reported level if INFLATE_SIGNAL_STRENGTH is true" into 24D1-dev
11 files changed, 130 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionRepository.kt index 8f3b0e788dae..22785979f3ae 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionRepository.kt @@ -44,6 +44,9 @@ interface MobileConnectionRepository { /** The carrierId for this connection. See [TelephonyManager.getSimCarrierId] */ val carrierId: StateFlow<Int> + /** Reflects the value from the carrier config INFLATE_SIGNAL_STRENGTH for this connection */ + val inflateSignalStrength: StateFlow<Boolean> + /** * The table log buffer created for this connection. Will have the name "MobileConnectionLog * [subId]" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionRepository.kt index 3cb138bd75a9..83d5f2b5d325 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionRepository.kt @@ -43,6 +43,7 @@ import com.android.systemui.statusbar.pipeline.wifi.data.repository.demo.model.F import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn /** @@ -67,6 +68,17 @@ class DemoMobileConnectionRepository( ) .stateIn(scope, SharingStarted.WhileSubscribed(), _carrierId.value) + private val _inflateSignalStrength: MutableStateFlow<Boolean> = MutableStateFlow(false) + override val inflateSignalStrength = + _inflateSignalStrength + .logDiffsForTable( + tableLogBuffer, + columnPrefix = "", + columnName = "inflate", + _inflateSignalStrength.value + ) + .stateIn(scope, SharingStarted.WhileSubscribed(), _inflateSignalStrength.value) + private val _isEmergencyOnly = MutableStateFlow(false) override val isEmergencyOnly = _isEmergencyOnly @@ -191,7 +203,16 @@ class DemoMobileConnectionRepository( .logDiffsForTable(tableLogBuffer, columnPrefix = "", _resolvedNetworkType.value) .stateIn(scope, SharingStarted.WhileSubscribed(), _resolvedNetworkType.value) - override val numberOfLevels = MutableStateFlow(MobileConnectionRepository.DEFAULT_NUM_LEVELS) + override val numberOfLevels = + _inflateSignalStrength + .map { shouldInflate -> + if (shouldInflate) { + DEFAULT_NUM_LEVELS + 1 + } else { + DEFAULT_NUM_LEVELS + } + } + .stateIn(scope, SharingStarted.WhileSubscribed(), DEFAULT_NUM_LEVELS) override val dataEnabled = MutableStateFlow(true) @@ -224,8 +245,7 @@ class DemoMobileConnectionRepository( _carrierId.value = event.carrierId ?: INVALID_SUBSCRIPTION_ID - numberOfLevels.value = - if (event.inflateStrength) DEFAULT_NUM_LEVELS + 1 else DEFAULT_NUM_LEVELS + _inflateSignalStrength.value = event.inflateStrength cdmaRoaming.value = event.roaming _isRoaming.value = event.roaming @@ -256,7 +276,6 @@ class DemoMobileConnectionRepository( carrierName.value = NetworkNameModel.SubscriptionDerived(CARRIER_MERGED_NAME) // TODO(b/276943904): is carrierId a thing with carrier merged networks? _carrierId.value = INVALID_SUBSCRIPTION_ID - numberOfLevels.value = event.numberOfLevels cdmaRoaming.value = false _primaryLevel.value = event.level _cdmaLevel.value = event.level diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepository.kt index f8858c5037ab..a532e6227451 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepository.kt @@ -165,6 +165,7 @@ class CarrierMergedConnectionRepository( override val isRoaming = MutableStateFlow(false).asStateFlow() override val carrierId = MutableStateFlow(INVALID_SUBSCRIPTION_ID).asStateFlow() + override val inflateSignalStrength = MutableStateFlow(false).asStateFlow() override val isEmergencyOnly = MutableStateFlow(false).asStateFlow() override val operatorAlphaShort = MutableStateFlow(null).asStateFlow() override val isInService = MutableStateFlow(true).asStateFlow() diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepository.kt index cc72a1e3f842..66b766a88747 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepository.kt @@ -291,6 +291,21 @@ class FullMobileConnectionRepository( ) .stateIn(scope, SharingStarted.WhileSubscribed(), activeRepo.value.dataEnabled.value) + override val inflateSignalStrength = + activeRepo + .flatMapLatest { it.inflateSignalStrength } + .logDiffsForTable( + tableLogBuffer, + columnPrefix = "", + columnName = "inflate", + initialValue = activeRepo.value.inflateSignalStrength.value, + ) + .stateIn( + scope, + SharingStarted.WhileSubscribed(), + activeRepo.value.inflateSignalStrength.value + ) + override val numberOfLevels = activeRepo .flatMapLatest { it.numberOfLevels } 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 e4a2a6820d5b..b3885d247949 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 @@ -302,8 +302,10 @@ class MobileConnectionRepositoryImpl( } .stateIn(scope, SharingStarted.WhileSubscribed(), UnknownNetworkType) + override val inflateSignalStrength = systemUiCarrierConfig.shouldInflateSignalStrength + override val numberOfLevels = - systemUiCarrierConfig.shouldInflateSignalStrength + inflateSignalStrength .map { shouldInflate -> if (shouldInflate) { DEFAULT_NUM_LEVELS + 1 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 adcf736bba01..ed9e4056535f 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 @@ -323,8 +323,11 @@ class MobileIconInteractorImpl( combine( level, isInService, - ) { level, isInService -> - if (isInService) level else 0 + connectionRepository.inflateSignalStrength, + ) { level, isInService, inflate -> + if (isInService) { + if (inflate) level + 1 else level + } else 0 } .stateIn(scope, SharingStarted.WhileSubscribed(), 0) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt index 1fb6e2c7a232..3c13906dbd43 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.pipeline.mobile.data.repository.prod import android.net.ConnectivityManager +import android.os.PersistableBundle import android.telephony.ServiceState import android.telephony.SignalStrength import android.telephony.SubscriptionManager.PROFILE_CLASS_UNSET @@ -31,6 +32,7 @@ import com.android.systemui.log.table.TableLogBuffer import com.android.systemui.log.table.TableLogBufferFactory import com.android.systemui.statusbar.pipeline.mobile.data.model.NetworkNameModel import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel +import com.android.systemui.statusbar.pipeline.mobile.data.model.SystemUiCarrierConfig import com.android.systemui.statusbar.pipeline.mobile.data.repository.FakeMobileConnectionRepository import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionRepository import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_EMERGENCY @@ -98,6 +100,9 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() { ) ) + // Use a real config, with no overrides + private val systemUiCarrierConfig = SystemUiCarrierConfig(SUB_ID, PersistableBundle()) + private lateinit var mobileRepo: FakeMobileConnectionRepository private lateinit var carrierMergedRepo: FakeMobileConnectionRepository @@ -679,7 +684,6 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() { telephonyManager: TelephonyManager, ): MobileConnectionRepositoryImpl { whenever(telephonyManager.subscriptionId).thenReturn(SUB_ID) - val realRepo = MobileConnectionRepositoryImpl( SUB_ID, @@ -689,7 +693,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() { SEP, connectivityManager, telephonyManager, - systemUiCarrierConfig = mock(), + systemUiCarrierConfig = systemUiCarrierConfig, fakeBroadcastDispatcher, mobileMappingsProxy = mock(), testDispatcher, 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 f761bcfe63d6..9d1411625a8f 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 @@ -1030,6 +1030,26 @@ class MobileConnectionRepositoryTest : SysuiTestCase() { } @Test + fun inflateSignalStrength_usesCarrierConfig() = + testScope.runTest { + val latest by collectLastValue(underTest.inflateSignalStrength) + + assertThat(latest).isEqualTo(false) + + systemUiCarrierConfig.processNewCarrierConfig( + configWithOverride(KEY_INFLATE_SIGNAL_STRENGTH_BOOL, true) + ) + + assertThat(latest).isEqualTo(true) + + systemUiCarrierConfig.processNewCarrierConfig( + configWithOverride(KEY_INFLATE_SIGNAL_STRENGTH_BOOL, false) + ) + + assertThat(latest).isEqualTo(false) + } + + @Test fun isAllowedDuringAirplaneMode_alwaysFalse() = testScope.runTest { val latest by collectLastValue(underTest.isAllowedDuringAirplaneMode) 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 49953a1176fd..dfe80233918a 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 @@ -178,6 +178,22 @@ class MobileIconInteractorTest : SysuiTestCase() { } @Test + fun inflateSignalStrength_arbitrarilyAddsOneToTheReportedLevel() = + testScope.runTest { + connectionRepository.inflateSignalStrength.value = false + val latest by collectLastValue(underTest.signalLevelIcon) + + connectionRepository.primaryLevel.value = 4 + assertThat(latest!!.level).isEqualTo(4) + + connectionRepository.inflateSignalStrength.value = true + connectionRepository.primaryLevel.value = 4 + + // when INFLATE_SIGNAL_STRENGTH is true, we add 1 to the reported signal level + assertThat(latest!!.level).isEqualTo(5) + } + + @Test fun iconGroup_three_g() = testScope.runTest { connectionRepository.resolvedNetworkType.value = 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 af49fd1753b6..cec41557f344 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 @@ -284,6 +284,7 @@ class MobileIconViewModelTest : SysuiTestCase() { testScope.runTest { val latest by collectLastValue(underTest.contentDescription) + repository.inflateSignalStrength.value = false repository.setAllLevels(-1) assertThat(latest).isNull() @@ -292,10 +293,25 @@ class MobileIconViewModelTest : SysuiTestCase() { } @Test + fun contentDescription_inflated_invalidLevelIsNull() = + testScope.runTest { + val latest by collectLastValue(underTest.contentDescription) + + repository.inflateSignalStrength.value = true + repository.numberOfLevels.value = 6 + repository.setAllLevels(-2) + assertThat(latest).isNull() + + repository.setAllLevels(100) + assertThat(latest).isNull() + } + + @Test fun contentDescription_nonInflated_testABunchOfLevelsForNull() = testScope.runTest { val latest by collectLastValue(underTest.contentDescription) + repository.inflateSignalStrength.value = false repository.numberOfLevels.value = 5 // -1 and 5 are out of the bounds for non-inflated content descriptions @@ -313,6 +329,27 @@ class MobileIconViewModelTest : SysuiTestCase() { } @Test + fun contentDescription_inflated_testABunchOfLevelsForNull() = + testScope.runTest { + val latest by collectLastValue(underTest.contentDescription) + repository.inflateSignalStrength.value = true + repository.numberOfLevels.value = 6 + // -1 and 6 are out of the bounds for inflated content descriptions + // Note that the interactor adds 1 to the reported level, hence the -2 to 5 range + for (i in -2..5) { + repository.setAllLevels(i) + when (i) { + -2, + 5 -> assertWithMessage("Level $i is expected to be null").that(latest).isNull() + else -> + assertWithMessage("Level $i is not expected to be null") + .that(latest) + .isNotNull() + } + } + } + + @Test fun networkType_dataEnabled_groupIsRepresented() = testScope.runTest { val expected = diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionRepository.kt index 32d572ef9dee..eb2d6c0f5405 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionRepository.kt @@ -31,6 +31,7 @@ class FakeMobileConnectionRepository( override val tableLogBuffer: TableLogBuffer, ) : MobileConnectionRepository { override val carrierId = MutableStateFlow(UNKNOWN_CARRIER_ID) + override val inflateSignalStrength: MutableStateFlow<Boolean> = MutableStateFlow(false) override val isEmergencyOnly = MutableStateFlow(false) override val isRoaming = MutableStateFlow(false) override val operatorAlphaShort: MutableStateFlow<String?> = MutableStateFlow(null) |