Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractor.kt +10 −7 Original line number Diff line number Diff line Loading @@ -61,6 +61,9 @@ interface MobileIconInteractor { /** True if the RAT icon should always be displayed and false otherwise. */ val alwaysShowDataRatIcon: StateFlow<Boolean> /** True if the CDMA level should be preferred over the primary level. */ val alwaysUseCdmaLevel: StateFlow<Boolean> /** Observable for RAT type (network type) indicator */ val networkTypeIconGroup: StateFlow<MobileIconGroup> Loading Loading @@ -97,6 +100,7 @@ class MobileIconInteractorImpl( @Application scope: CoroutineScope, defaultSubscriptionHasDataEnabled: StateFlow<Boolean>, override val alwaysShowDataRatIcon: StateFlow<Boolean>, override val alwaysUseCdmaLevel: StateFlow<Boolean>, defaultMobileIconMapping: StateFlow<Map<String, MobileIconGroup>>, defaultMobileIconGroup: StateFlow<MobileIconGroup>, override val isDefaultConnectionFailed: StateFlow<Boolean>, Loading Loading @@ -157,13 +161,12 @@ class MobileIconInteractorImpl( .stateIn(scope, SharingStarted.WhileSubscribed(), false) override val level: StateFlow<Int> = connectionInfo .mapLatest { connection -> // TODO: incorporate [MobileMappings.Config.alwaysShowCdmaRssi] if (connection.isGsm) { connection.primaryLevel } else { connection.cdmaLevel combine(connectionInfo, alwaysUseCdmaLevel) { connection, alwaysUseCdmaLevel -> when { // GSM connections should never use the CDMA level connection.isGsm -> connection.primaryLevel alwaysUseCdmaLevel -> connection.cdmaLevel else -> connection.primaryLevel } } .stateIn(scope, SharingStarted.WhileSubscribed(), 0) Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt +11 −0 Original line number Diff line number Diff line Loading @@ -55,8 +55,13 @@ interface MobileIconsInteractor { val filteredSubscriptions: Flow<List<SubscriptionModel>> /** True if the active mobile data subscription has data enabled */ val activeDataConnectionHasDataEnabled: StateFlow<Boolean> /** True if the RAT icon should always be displayed and false otherwise. */ val alwaysShowDataRatIcon: StateFlow<Boolean> /** True if the CDMA level should be preferred over the primary level. */ val alwaysUseCdmaLevel: StateFlow<Boolean> /** The icon mapping from network type to [MobileIconGroup] for the default subscription */ val defaultMobileIconMapping: StateFlow<Map<String, MobileIconGroup>> /** Fallback [MobileIconGroup] in the case where there is no icon in the mapping */ Loading Loading @@ -165,6 +170,11 @@ constructor( .mapLatest { it.alwaysShowDataRatIcon } .stateIn(scope, SharingStarted.WhileSubscribed(), false) override val alwaysUseCdmaLevel: StateFlow<Boolean> = mobileConnectionsRepo.defaultDataSubRatConfig .mapLatest { it.alwaysShowCdmaRssi } .stateIn(scope, SharingStarted.WhileSubscribed(), false) /** If there is no mapping in [defaultMobileIconMapping], then use this default icon group */ override val defaultMobileIconGroup: StateFlow<MobileIconGroup> = mobileConnectionsRepo.defaultMobileIconGroup.stateIn( Loading Loading @@ -196,6 +206,7 @@ constructor( scope, activeDataConnectionHasDataEnabled, alwaysShowDataRatIcon, alwaysUseCdmaLevel, defaultMobileIconMapping, defaultMobileIconGroup, isDefaultConnectionFailed, Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconInteractor.kt +2 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ class FakeMobileIconInteractor( ) : MobileIconInteractor { override val alwaysShowDataRatIcon = MutableStateFlow(false) override val alwaysUseCdmaLevel = MutableStateFlow(false) override val activity = MutableStateFlow( DataActivityModel( Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconsInteractor.kt +2 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ class FakeMobileIconsInteractor( override val alwaysShowDataRatIcon = MutableStateFlow(false) override val alwaysUseCdmaLevel = MutableStateFlow(false) private val _defaultMobileIconMapping = MutableStateFlow(TEST_MAPPING) override val defaultMobileIconMapping = _defaultMobileIconMapping Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractorTest.kt +59 −2 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ class MobileIconInteractorTest : SysuiTestCase() { scope, mobileIconsInteractor.activeDataConnectionHasDataEnabled, mobileIconsInteractor.alwaysShowDataRatIcon, mobileIconsInteractor.alwaysUseCdmaLevel, mobileIconsInteractor.defaultMobileIconMapping, mobileIconsInteractor.defaultMobileIconGroup, mobileIconsInteractor.isDefaultConnectionFailed, Loading Loading @@ -103,7 +104,27 @@ class MobileIconInteractorTest : SysuiTestCase() { } @Test fun cdma_level_default_unknown() = fun gsm_alwaysShowCdmaTrue_stillUsesGsmLevel() = runBlocking(IMMEDIATE) { connectionRepository.setConnectionInfo( MobileConnectionModel( isGsm = true, primaryLevel = GSM_LEVEL, cdmaLevel = CDMA_LEVEL, ), ) mobileIconsInteractor.alwaysUseCdmaLevel.value = true var latest: Int? = null val job = underTest.level.onEach { latest = it }.launchIn(this) assertThat(latest).isEqualTo(GSM_LEVEL) job.cancel() } @Test fun notGsm_level_default_unknown() = runBlocking(IMMEDIATE) { connectionRepository.setConnectionInfo( MobileConnectionModel(isGsm = false), Loading @@ -117,7 +138,7 @@ class MobileIconInteractorTest : SysuiTestCase() { } @Test fun cdma_usesCdmaLevel() = fun notGsm_alwaysShowCdmaTrue_usesCdmaLevel() = runBlocking(IMMEDIATE) { connectionRepository.setConnectionInfo( MobileConnectionModel( Loading @@ -126,6 +147,7 @@ class MobileIconInteractorTest : SysuiTestCase() { cdmaLevel = CDMA_LEVEL ), ) mobileIconsInteractor.alwaysUseCdmaLevel.value = true var latest: Int? = null val job = underTest.level.onEach { latest = it }.launchIn(this) Loading @@ -135,6 +157,26 @@ class MobileIconInteractorTest : SysuiTestCase() { job.cancel() } @Test fun notGsm_alwaysShowCdmaFalse_usesPrimaryLevel() = runBlocking(IMMEDIATE) { connectionRepository.setConnectionInfo( MobileConnectionModel( isGsm = false, primaryLevel = GSM_LEVEL, cdmaLevel = CDMA_LEVEL, ), ) mobileIconsInteractor.alwaysUseCdmaLevel.value = false var latest: Int? = null val job = underTest.level.onEach { latest = it }.launchIn(this) assertThat(latest).isEqualTo(GSM_LEVEL) job.cancel() } @Test fun iconGroup_three_g() = runBlocking(IMMEDIATE) { Loading Loading @@ -239,6 +281,21 @@ class MobileIconInteractorTest : SysuiTestCase() { job.cancel() } @Test fun alwaysUseCdmaLevel_matchesParent() = runBlocking(IMMEDIATE) { var latest: Boolean? = null val job = underTest.alwaysUseCdmaLevel.onEach { latest = it }.launchIn(this) mobileIconsInteractor.alwaysUseCdmaLevel.value = true assertThat(latest).isTrue() mobileIconsInteractor.alwaysUseCdmaLevel.value = false assertThat(latest).isFalse() job.cancel() } @Test fun test_isDefaultDataEnabled_matchesParent() = runBlocking(IMMEDIATE) { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractor.kt +10 −7 Original line number Diff line number Diff line Loading @@ -61,6 +61,9 @@ interface MobileIconInteractor { /** True if the RAT icon should always be displayed and false otherwise. */ val alwaysShowDataRatIcon: StateFlow<Boolean> /** True if the CDMA level should be preferred over the primary level. */ val alwaysUseCdmaLevel: StateFlow<Boolean> /** Observable for RAT type (network type) indicator */ val networkTypeIconGroup: StateFlow<MobileIconGroup> Loading Loading @@ -97,6 +100,7 @@ class MobileIconInteractorImpl( @Application scope: CoroutineScope, defaultSubscriptionHasDataEnabled: StateFlow<Boolean>, override val alwaysShowDataRatIcon: StateFlow<Boolean>, override val alwaysUseCdmaLevel: StateFlow<Boolean>, defaultMobileIconMapping: StateFlow<Map<String, MobileIconGroup>>, defaultMobileIconGroup: StateFlow<MobileIconGroup>, override val isDefaultConnectionFailed: StateFlow<Boolean>, Loading Loading @@ -157,13 +161,12 @@ class MobileIconInteractorImpl( .stateIn(scope, SharingStarted.WhileSubscribed(), false) override val level: StateFlow<Int> = connectionInfo .mapLatest { connection -> // TODO: incorporate [MobileMappings.Config.alwaysShowCdmaRssi] if (connection.isGsm) { connection.primaryLevel } else { connection.cdmaLevel combine(connectionInfo, alwaysUseCdmaLevel) { connection, alwaysUseCdmaLevel -> when { // GSM connections should never use the CDMA level connection.isGsm -> connection.primaryLevel alwaysUseCdmaLevel -> connection.cdmaLevel else -> connection.primaryLevel } } .stateIn(scope, SharingStarted.WhileSubscribed(), 0) Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconsInteractor.kt +11 −0 Original line number Diff line number Diff line Loading @@ -55,8 +55,13 @@ interface MobileIconsInteractor { val filteredSubscriptions: Flow<List<SubscriptionModel>> /** True if the active mobile data subscription has data enabled */ val activeDataConnectionHasDataEnabled: StateFlow<Boolean> /** True if the RAT icon should always be displayed and false otherwise. */ val alwaysShowDataRatIcon: StateFlow<Boolean> /** True if the CDMA level should be preferred over the primary level. */ val alwaysUseCdmaLevel: StateFlow<Boolean> /** The icon mapping from network type to [MobileIconGroup] for the default subscription */ val defaultMobileIconMapping: StateFlow<Map<String, MobileIconGroup>> /** Fallback [MobileIconGroup] in the case where there is no icon in the mapping */ Loading Loading @@ -165,6 +170,11 @@ constructor( .mapLatest { it.alwaysShowDataRatIcon } .stateIn(scope, SharingStarted.WhileSubscribed(), false) override val alwaysUseCdmaLevel: StateFlow<Boolean> = mobileConnectionsRepo.defaultDataSubRatConfig .mapLatest { it.alwaysShowCdmaRssi } .stateIn(scope, SharingStarted.WhileSubscribed(), false) /** If there is no mapping in [defaultMobileIconMapping], then use this default icon group */ override val defaultMobileIconGroup: StateFlow<MobileIconGroup> = mobileConnectionsRepo.defaultMobileIconGroup.stateIn( Loading Loading @@ -196,6 +206,7 @@ constructor( scope, activeDataConnectionHasDataEnabled, alwaysShowDataRatIcon, alwaysUseCdmaLevel, defaultMobileIconMapping, defaultMobileIconGroup, isDefaultConnectionFailed, Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconInteractor.kt +2 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ class FakeMobileIconInteractor( ) : MobileIconInteractor { override val alwaysShowDataRatIcon = MutableStateFlow(false) override val alwaysUseCdmaLevel = MutableStateFlow(false) override val activity = MutableStateFlow( DataActivityModel( Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconsInteractor.kt +2 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ class FakeMobileIconsInteractor( override val alwaysShowDataRatIcon = MutableStateFlow(false) override val alwaysUseCdmaLevel = MutableStateFlow(false) private val _defaultMobileIconMapping = MutableStateFlow(TEST_MAPPING) override val defaultMobileIconMapping = _defaultMobileIconMapping Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractorTest.kt +59 −2 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ class MobileIconInteractorTest : SysuiTestCase() { scope, mobileIconsInteractor.activeDataConnectionHasDataEnabled, mobileIconsInteractor.alwaysShowDataRatIcon, mobileIconsInteractor.alwaysUseCdmaLevel, mobileIconsInteractor.defaultMobileIconMapping, mobileIconsInteractor.defaultMobileIconGroup, mobileIconsInteractor.isDefaultConnectionFailed, Loading Loading @@ -103,7 +104,27 @@ class MobileIconInteractorTest : SysuiTestCase() { } @Test fun cdma_level_default_unknown() = fun gsm_alwaysShowCdmaTrue_stillUsesGsmLevel() = runBlocking(IMMEDIATE) { connectionRepository.setConnectionInfo( MobileConnectionModel( isGsm = true, primaryLevel = GSM_LEVEL, cdmaLevel = CDMA_LEVEL, ), ) mobileIconsInteractor.alwaysUseCdmaLevel.value = true var latest: Int? = null val job = underTest.level.onEach { latest = it }.launchIn(this) assertThat(latest).isEqualTo(GSM_LEVEL) job.cancel() } @Test fun notGsm_level_default_unknown() = runBlocking(IMMEDIATE) { connectionRepository.setConnectionInfo( MobileConnectionModel(isGsm = false), Loading @@ -117,7 +138,7 @@ class MobileIconInteractorTest : SysuiTestCase() { } @Test fun cdma_usesCdmaLevel() = fun notGsm_alwaysShowCdmaTrue_usesCdmaLevel() = runBlocking(IMMEDIATE) { connectionRepository.setConnectionInfo( MobileConnectionModel( Loading @@ -126,6 +147,7 @@ class MobileIconInteractorTest : SysuiTestCase() { cdmaLevel = CDMA_LEVEL ), ) mobileIconsInteractor.alwaysUseCdmaLevel.value = true var latest: Int? = null val job = underTest.level.onEach { latest = it }.launchIn(this) Loading @@ -135,6 +157,26 @@ class MobileIconInteractorTest : SysuiTestCase() { job.cancel() } @Test fun notGsm_alwaysShowCdmaFalse_usesPrimaryLevel() = runBlocking(IMMEDIATE) { connectionRepository.setConnectionInfo( MobileConnectionModel( isGsm = false, primaryLevel = GSM_LEVEL, cdmaLevel = CDMA_LEVEL, ), ) mobileIconsInteractor.alwaysUseCdmaLevel.value = false var latest: Int? = null val job = underTest.level.onEach { latest = it }.launchIn(this) assertThat(latest).isEqualTo(GSM_LEVEL) job.cancel() } @Test fun iconGroup_three_g() = runBlocking(IMMEDIATE) { Loading Loading @@ -239,6 +281,21 @@ class MobileIconInteractorTest : SysuiTestCase() { job.cancel() } @Test fun alwaysUseCdmaLevel_matchesParent() = runBlocking(IMMEDIATE) { var latest: Boolean? = null val job = underTest.alwaysUseCdmaLevel.onEach { latest = it }.launchIn(this) mobileIconsInteractor.alwaysUseCdmaLevel.value = true assertThat(latest).isTrue() mobileIconsInteractor.alwaysUseCdmaLevel.value = false assertThat(latest).isFalse() job.cancel() } @Test fun test_isDefaultDataEnabled_matchesParent() = runBlocking(IMMEDIATE) { Loading