[Sb refactor] Support NOT_DEFAULT_DATA network type

In the old pipeline (and now here), we track the default data
subscription id, and any mobile network which is NOT that subscription
(i.e., every non-default) gets a specific network icon group (per
MobileMappings) which encodes a null RAT icon and a proper content
description.

This CL builds upon the revert and uses the default data subId to
implement this icon group.

Test: MobileIconInteractorTest
Bug: 264683083
Bug: 238425913
Change-Id: I06365d1923714f7855ea4b179bd4bdc20d9d54ba
This commit is contained in:
Evan Laird
2023-01-10 17:40:32 -05:00
parent 08fc0a67c5
commit 5c87aeada1
4 changed files with 51 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.pipeline.mobile.domain.interactor
import android.telephony.CarrierConfigManager
import com.android.settingslib.SignalIcon.MobileIconGroup
import com.android.settingslib.mobile.TelephonyIcons.NOT_DEFAULT_DATA
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionState.Connected
@@ -121,6 +122,7 @@ class MobileIconInteractorImpl(
defaultMobileConnectivity: StateFlow<MobileConnectivityModel>,
defaultMobileIconMapping: StateFlow<Map<String, MobileIconGroup>>,
defaultMobileIconGroup: StateFlow<MobileIconGroup>,
defaultDataSubId: StateFlow<Int>,
override val isDefaultConnectionFailed: StateFlow<Boolean>,
connectionRepository: MobileConnectionRepository,
) : MobileIconInteractor {
@@ -134,6 +136,15 @@ class MobileIconInteractorImpl(
override val isDataEnabled: StateFlow<Boolean> = connectionRepository.dataEnabled
private val isDefault =
defaultDataSubId
.mapLatest { connectionRepository.subId == it }
.stateIn(
scope,
SharingStarted.WhileSubscribed(),
connectionRepository.subId == defaultDataSubId.value
)
override val isDefaultDataEnabled = defaultSubscriptionHasDataEnabled
override val networkName =
@@ -158,7 +169,12 @@ class MobileIconInteractorImpl(
connectionInfo,
defaultMobileIconMapping,
defaultMobileIconGroup,
) { info, mapping, defaultGroup ->
isDefault,
) { info, mapping, defaultGroup, isDefault ->
if (!isDefault) {
return@combine NOT_DEFAULT_DATA
}
when (info.resolvedNetworkType) {
is ResolvedNetworkType.CarrierMergedNetworkType ->
info.resolvedNetworkType.iconGroupOverride

View File

@@ -66,6 +66,9 @@ interface MobileIconsInteractor {
/** True if the CDMA level should be preferred over the primary level. */
val alwaysUseCdmaLevel: StateFlow<Boolean>
/** Tracks the subscriptionId set as the default for data connections */
val defaultDataSubId: StateFlow<Int>
/**
* The connectivity of the default mobile network. Note that this can differ from what is
* reported from [MobileConnectionsRepository] in some cases. E.g., when the active subscription
@@ -166,6 +169,8 @@ constructor(
}
}
override val defaultDataSubId = mobileConnectionsRepo.defaultDataSubId
/**
* Copied from the old pipeline. We maintain a 2s period of time where we will keep the
* validated bit from the old active network (A) while data is changing to the new one (B).
@@ -262,6 +267,7 @@ constructor(
defaultMobileNetworkConnectivity,
defaultMobileIconMapping,
defaultMobileIconGroup,
defaultDataSubId,
isDefaultConnectionFailed,
mobileConnectionsRepo.getRepoForSubId(subId),
)

View File

@@ -60,6 +60,7 @@ class FakeMobileIconsInteractor(
override val alwaysShowDataRatIcon = MutableStateFlow(false)
override val alwaysUseCdmaLevel = MutableStateFlow(false)
override val defaultDataSubId = MutableStateFlow(DEFAULT_DATA_SUB_ID)
override val defaultMobileNetworkConnectivity = MutableStateFlow(MobileConnectivityModel())
@@ -80,6 +81,8 @@ class FakeMobileIconsInteractor(
companion object {
val DEFAULT_ICON = TelephonyIcons.G
const val DEFAULT_DATA_SUB_ID = 1
// Use [MobileMappings] to define some simple definitions
const val THREE_G = NETWORK_TYPE_GSM
const val LTE = NETWORK_TYPE_LTE

View File

@@ -64,6 +64,7 @@ class MobileIconInteractorTest : SysuiTestCase() {
mobileIconsInteractor.defaultMobileNetworkConnectivity,
mobileIconsInteractor.defaultMobileIconMapping,
mobileIconsInteractor.defaultMobileIconGroup,
mobileIconsInteractor.defaultDataSubId,
mobileIconsInteractor.isDefaultConnectionFailed,
connectionRepository,
)
@@ -289,6 +290,30 @@ class MobileIconInteractorTest : SysuiTestCase() {
job.cancel()
}
@Test
fun `icon group - checks default data`() =
runBlocking(IMMEDIATE) {
mobileIconsInteractor.defaultDataSubId.value = SUB_1_ID
connectionRepository.setConnectionInfo(
MobileConnectionModel(
resolvedNetworkType = DefaultNetworkType(mobileMappingsProxy.toIconKey(THREE_G))
),
)
var latest: MobileIconGroup? = null
val job = underTest.networkTypeIconGroup.onEach { latest = it }.launchIn(this)
assertThat(latest).isEqualTo(TelephonyIcons.THREE_G)
// Default data sub id changes to something else
mobileIconsInteractor.defaultDataSubId.value = 123
yield()
assertThat(latest).isEqualTo(TelephonyIcons.NOT_DEFAULT_DATA)
job.cancel()
}
@Test
fun alwaysShowDataRatIcon_matchesParent() =
runBlocking(IMMEDIATE) {