diff options
| author | 2024-03-29 23:45:25 +0000 | |
|---|---|---|
| committer | 2024-03-29 23:45:25 +0000 | |
| commit | eff2d0fdc1d1fbddacfdb6f0c7c212ac73c8c6ec (patch) | |
| tree | 634da68d518786bbfbff3fd1e720fd6648ee8c73 | |
| parent | f92ac50143c6e1b88086efa7289ce050e0c764f0 (diff) | |
| parent | ffe84900627d259ec1fac2397ab4debdc261a3ff (diff) | |
Merge "[Mobile] Make sure we +1 the reported level if INFLATE_SIGNAL_STRENGTH is true" into main
10 files changed, 92 insertions, 12 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 8f00b43e79f8..317c0634a364 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 af34a57c7242..90cdfeb05d4e 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) @@ -226,8 +247,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 @@ -258,7 +278,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 2bc3bcbc8bf5..cb99d11e79b7 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 b085d8046b12..bb0af775f820 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 5ab2ae899370..2cbe965b0ea9 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 9d194cfca350..cbebfd0587ab 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 @@ -367,8 +367,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 c13e830afac7..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 @@ -99,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 @@ -680,10 +684,6 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() { telephonyManager: TelephonyManager, ): MobileConnectionRepositoryImpl { whenever(telephonyManager.subscriptionId).thenReturn(SUB_ID) - val systemUiCarrierConfigMock: SystemUiCarrierConfig = mock() - whenever(systemUiCarrierConfigMock.satelliteConnectionHysteresisSeconds) - .thenReturn(MutableStateFlow(0)) - val realRepo = MobileConnectionRepositoryImpl( SUB_ID, @@ -693,7 +693,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() { SEP, connectivityManager, telephonyManager, - systemUiCarrierConfig = systemUiCarrierConfigMock, + 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 c49fcf88ecaa..f9ab25e9306a 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 @@ -181,6 +181,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/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 2d5a3612ff6a..8109b60a9ef0 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) |