diff options
author | 2024-06-13 19:27:28 +0000 | |
---|---|---|
committer | 2024-06-13 19:27:28 +0000 | |
commit | 0349d538c3a6aa62876b9649b67e1ffe15395bc3 (patch) | |
tree | 8122b8f50d55a5e19e3c8b4eec08d70f881ef7b7 | |
parent | 77e2912530d2b0a8ece118686c13475ddb62dfa4 (diff) | |
parent | 690298c56f3418a6acba853b07838069873d46e5 (diff) |
Merge "[Mobile] Add support for KEY_SHOW_5G_SLICE_ICON_BOOL carrier config" into main
11 files changed, 111 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfig.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfig.kt index f4e3eab8593d..0871c8637652 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfig.kt @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.pipeline.mobile.data.model import android.os.PersistableBundle import android.telephony.CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL +import android.telephony.CarrierConfigManager.KEY_SHOW_5G_SLICE_ICON_BOOL import android.telephony.CarrierConfigManager.KEY_SHOW_OPERATOR_NAME_IN_STATUSBAR_BOOL import androidx.annotation.VisibleForTesting import kotlinx.coroutines.flow.MutableStateFlow @@ -66,10 +67,16 @@ internal constructor( /** Flow tracking the [KEY_SHOW_OPERATOR_NAME_IN_STATUSBAR_BOOL] config */ val showOperatorNameInStatusBar: StateFlow<Boolean> = showOperatorName.config + private val showNetworkSlice = + BooleanCarrierConfig(KEY_SHOW_5G_SLICE_ICON_BOOL, defaultConfig) + /** Flow tracking the [KEY_SHOW_5G_SLICE_ICON_BOOL] config */ + val allowNetworkSliceIndicator: StateFlow<Boolean> = showNetworkSlice.config + private val trackedConfigs = listOf( inflateSignalStrength, showOperatorName, + showNetworkSlice, ) /** Ingest a new carrier config, and switch all of the tracked keys over to the new values */ 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 425c58b0074b..205205eac210 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 @@ -48,6 +48,9 @@ interface MobileConnectionRepository { /** Reflects the value from the carrier config INFLATE_SIGNAL_STRENGTH for this connection */ val inflateSignalStrength: StateFlow<Boolean> + /** Carrier config KEY_SHOW_5G_SLICE_ICON_BOOL for this connection */ + val allowNetworkSliceIndicator: 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 83d5f2b5d325..3261b71ece3c 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 @@ -79,6 +79,9 @@ class DemoMobileConnectionRepository( ) .stateIn(scope, SharingStarted.WhileSubscribed(), _inflateSignalStrength.value) + // I don't see a reason why we would turn the config off for demo mode. + override val allowNetworkSliceIndicator = MutableStateFlow(true) + private val _isEmergencyOnly = MutableStateFlow(false) override val isEmergencyOnly = _isEmergencyOnly 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 a532e6227451..2e4767893c3d 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 @@ -166,6 +166,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 allowNetworkSliceIndicator = 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 41559b2c1455..a5e47a6e68cd 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 @@ -308,6 +308,21 @@ class FullMobileConnectionRepository( activeRepo.value.inflateSignalStrength.value ) + override val allowNetworkSliceIndicator = + activeRepo + .flatMapLatest { it.allowNetworkSliceIndicator } + .logDiffsForTable( + tableLogBuffer, + columnPrefix = "", + columnName = "allowSlice", + initialValue = activeRepo.value.allowNetworkSliceIndicator.value, + ) + .stateIn( + scope, + SharingStarted.WhileSubscribed(), + activeRepo.value.allowNetworkSliceIndicator.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 6803a9dc06fd..944965950dce 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 @@ -310,6 +310,7 @@ class MobileConnectionRepositoryImpl( .stateIn(scope, SharingStarted.WhileSubscribed(), UnknownNetworkType) override val inflateSignalStrength = systemUiCarrierConfig.shouldInflateSignalStrength + override val allowNetworkSliceIndicator = systemUiCarrierConfig.allowNetworkSliceIndicator override val numberOfLevels = inflateSignalStrength 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 ed9e4056535f..507759c037ba 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 @@ -253,7 +253,13 @@ class MobileIconInteractorImpl( ) override val showSliceAttribution: StateFlow<Boolean> = - connectionRepository.hasPrioritizedNetworkCapabilities + combine( + connectionRepository.allowNetworkSliceIndicator, + connectionRepository.hasPrioritizedNetworkCapabilities, + ) { allowed, hasPrioritizedNetworkCapabilities -> + allowed && hasPrioritizedNetworkCapabilities + } + .stateIn(scope, SharingStarted.WhileSubscribed(), false) override val isNonTerrestrial: StateFlow<Boolean> = if (Flags.carrierEnabledSatelliteFlag()) { @@ -350,7 +356,8 @@ class MobileIconInteractorImpl( shownLevel.map { SignalIconModel.Satellite( level = it, - icon = SatelliteIconModel.fromSignalStrength(it) + icon = + SatelliteIconModel.fromSignalStrength(it) ?: SatelliteIconModel.fromSignalStrength(0)!! ) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfigTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfigTest.kt index 95b132d603dc..3de50c97a258 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfigTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfigTest.kt @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.pipeline.mobile.data.model import android.os.PersistableBundle import android.telephony.CarrierConfigManager import android.telephony.CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL +import android.telephony.CarrierConfigManager.KEY_SHOW_5G_SLICE_ICON_BOOL import android.telephony.CarrierConfigManager.KEY_SHOW_OPERATOR_NAME_IN_STATUSBAR_BOOL import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase @@ -53,16 +54,19 @@ class SystemUiCarrierConfigTest : SysuiTestCase() { fun processNewConfig_updatesAllFlows() { assertThat(underTest.shouldInflateSignalStrength.value).isFalse() assertThat(underTest.showOperatorNameInStatusBar.value).isFalse() + assertThat(underTest.allowNetworkSliceIndicator.value).isTrue() underTest.processNewCarrierConfig( configWithOverrides( KEY_INFLATE_SIGNAL_STRENGTH_BOOL to true, KEY_SHOW_OPERATOR_NAME_IN_STATUSBAR_BOOL to true, + KEY_SHOW_5G_SLICE_ICON_BOOL to false, ) ) assertThat(underTest.shouldInflateSignalStrength.value).isTrue() assertThat(underTest.showOperatorNameInStatusBar.value).isTrue() + assertThat(underTest.allowNetworkSliceIndicator.value).isFalse() } @Test @@ -79,12 +83,14 @@ class SystemUiCarrierConfigTest : SysuiTestCase() { configWithOverrides( KEY_INFLATE_SIGNAL_STRENGTH_BOOL to true, KEY_SHOW_OPERATOR_NAME_IN_STATUSBAR_BOOL to true, + KEY_SHOW_5G_SLICE_ICON_BOOL to true, ) ) assertThat(underTest.isUsingDefault).isTrue() assertThat(underTest.shouldInflateSignalStrength.value).isTrue() assertThat(underTest.showOperatorNameInStatusBar.value).isTrue() + assertThat(underTest.allowNetworkSliceIndicator.value).isTrue() // Process a new config with no keys underTest.processNewCarrierConfig(PersistableBundle()) @@ -92,6 +98,7 @@ class SystemUiCarrierConfigTest : SysuiTestCase() { assertThat(underTest.isUsingDefault).isFalse() assertThat(underTest.shouldInflateSignalStrength.value).isFalse() assertThat(underTest.showOperatorNameInStatusBar.value).isFalse() + assertThat(underTest.allowNetworkSliceIndicator.value).isFalse() } companion object { @@ -105,6 +112,7 @@ class SystemUiCarrierConfigTest : SysuiTestCase() { PersistableBundle().also { it.putBoolean(CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL, false) it.putBoolean(CarrierConfigManager.KEY_SHOW_OPERATOR_NAME_IN_STATUSBAR_BOOL, false) + it.putBoolean(CarrierConfigManager.KEY_SHOW_5G_SLICE_ICON_BOOL, true) } /** Override the default config with the given (key, value) pair */ 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 3695d8c151a2..6d8bf55d489b 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 @@ -25,6 +25,7 @@ import android.platform.test.annotations.EnableFlags import android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WLAN import android.telephony.AccessNetworkConstants.TRANSPORT_TYPE_WWAN import android.telephony.CarrierConfigManager.KEY_INFLATE_SIGNAL_STRENGTH_BOOL +import android.telephony.CarrierConfigManager.KEY_SHOW_5G_SLICE_ICON_BOOL import android.telephony.NetworkRegistrationInfo import android.telephony.NetworkRegistrationInfo.DOMAIN_PS import android.telephony.NetworkRegistrationInfo.REGISTRATION_STATE_DENIED @@ -1044,6 +1045,24 @@ class MobileConnectionRepositoryTest : SysuiTestCase() { } @Test + fun allowNetworkSliceIndicator_exposesCarrierConfigValue() = + testScope.runTest { + val latest by collectLastValue(underTest.allowNetworkSliceIndicator) + + systemUiCarrierConfig.processNewCarrierConfig( + configWithOverride(KEY_SHOW_5G_SLICE_ICON_BOOL, true) + ) + + assertThat(latest).isTrue() + + systemUiCarrierConfig.processNewCarrierConfig( + configWithOverride(KEY_SHOW_5G_SLICE_ICON_BOOL, false) + ) + + assertThat(latest).isFalse() + } + + @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 dfe80233918a..14884182d656 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 @@ -194,6 +194,50 @@ class MobileIconInteractorTest : SysuiTestCase() { } @Test + fun networkSlice_configOn_hasPrioritizedCaps_showsSlice() = + testScope.runTest { + connectionRepository.allowNetworkSliceIndicator.value = true + val latest by collectLastValue(underTest.showSliceAttribution) + + connectionRepository.hasPrioritizedNetworkCapabilities.value = true + + assertThat(latest).isTrue() + } + + @Test + fun networkSlice_configOn_noPrioritizedCaps_noSlice() = + testScope.runTest { + connectionRepository.allowNetworkSliceIndicator.value = true + val latest by collectLastValue(underTest.showSliceAttribution) + + connectionRepository.hasPrioritizedNetworkCapabilities.value = false + + assertThat(latest).isFalse() + } + + @Test + fun networkSlice_configOff_hasPrioritizedCaps_noSlice() = + testScope.runTest { + connectionRepository.allowNetworkSliceIndicator.value = false + val latest by collectLastValue(underTest.showSliceAttribution) + + connectionRepository.hasPrioritizedNetworkCapabilities.value = true + + assertThat(latest).isFalse() + } + + @Test + fun networkSlice_configOff_noPrioritizedCaps_noSlice() = + testScope.runTest { + connectionRepository.allowNetworkSliceIndicator.value = false + val latest by collectLastValue(underTest.showSliceAttribution) + + connectionRepository.hasPrioritizedNetworkCapabilities.value = false + + assertThat(latest).isFalse() + } + + @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 eb2d6c0f5405..c3c3cce5cf68 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 @@ -32,6 +32,7 @@ class FakeMobileConnectionRepository( ) : MobileConnectionRepository { override val carrierId = MutableStateFlow(UNKNOWN_CARRIER_ID) override val inflateSignalStrength: MutableStateFlow<Boolean> = MutableStateFlow(false) + override val allowNetworkSliceIndicator: MutableStateFlow<Boolean> = MutableStateFlow(true) override val isEmergencyOnly = MutableStateFlow(false) override val isRoaming = MutableStateFlow(false) override val operatorAlphaShort: MutableStateFlow<String?> = MutableStateFlow(null) |