Merge "[SB Refactor] Migrate alwaysShowCdmaRssi to the new pipeline." into tm-qpr-dev am: e878d24b0b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20748766 Change-Id: I0969b661daae6bb9d1323f0e58f149210b4ed82d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -61,6 +61,9 @@ interface MobileIconInteractor {
|
|||||||
/** True if the RAT icon should always be displayed and false otherwise. */
|
/** True if the RAT icon should always be displayed and false otherwise. */
|
||||||
val alwaysShowDataRatIcon: StateFlow<Boolean>
|
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 */
|
/** Observable for RAT type (network type) indicator */
|
||||||
val networkTypeIconGroup: StateFlow<MobileIconGroup>
|
val networkTypeIconGroup: StateFlow<MobileIconGroup>
|
||||||
|
|
||||||
@@ -97,6 +100,7 @@ class MobileIconInteractorImpl(
|
|||||||
@Application scope: CoroutineScope,
|
@Application scope: CoroutineScope,
|
||||||
defaultSubscriptionHasDataEnabled: StateFlow<Boolean>,
|
defaultSubscriptionHasDataEnabled: StateFlow<Boolean>,
|
||||||
override val alwaysShowDataRatIcon: StateFlow<Boolean>,
|
override val alwaysShowDataRatIcon: StateFlow<Boolean>,
|
||||||
|
override val alwaysUseCdmaLevel: StateFlow<Boolean>,
|
||||||
defaultMobileIconMapping: StateFlow<Map<String, MobileIconGroup>>,
|
defaultMobileIconMapping: StateFlow<Map<String, MobileIconGroup>>,
|
||||||
defaultMobileIconGroup: StateFlow<MobileIconGroup>,
|
defaultMobileIconGroup: StateFlow<MobileIconGroup>,
|
||||||
override val isDefaultConnectionFailed: StateFlow<Boolean>,
|
override val isDefaultConnectionFailed: StateFlow<Boolean>,
|
||||||
@@ -157,13 +161,12 @@ class MobileIconInteractorImpl(
|
|||||||
.stateIn(scope, SharingStarted.WhileSubscribed(), false)
|
.stateIn(scope, SharingStarted.WhileSubscribed(), false)
|
||||||
|
|
||||||
override val level: StateFlow<Int> =
|
override val level: StateFlow<Int> =
|
||||||
connectionInfo
|
combine(connectionInfo, alwaysUseCdmaLevel) { connection, alwaysUseCdmaLevel ->
|
||||||
.mapLatest { connection ->
|
when {
|
||||||
// TODO: incorporate [MobileMappings.Config.alwaysShowCdmaRssi]
|
// GSM connections should never use the CDMA level
|
||||||
if (connection.isGsm) {
|
connection.isGsm -> connection.primaryLevel
|
||||||
connection.primaryLevel
|
alwaysUseCdmaLevel -> connection.cdmaLevel
|
||||||
} else {
|
else -> connection.primaryLevel
|
||||||
connection.cdmaLevel
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.stateIn(scope, SharingStarted.WhileSubscribed(), 0)
|
.stateIn(scope, SharingStarted.WhileSubscribed(), 0)
|
||||||
|
|||||||
@@ -55,8 +55,13 @@ interface MobileIconsInteractor {
|
|||||||
val filteredSubscriptions: Flow<List<SubscriptionModel>>
|
val filteredSubscriptions: Flow<List<SubscriptionModel>>
|
||||||
/** True if the active mobile data subscription has data enabled */
|
/** True if the active mobile data subscription has data enabled */
|
||||||
val activeDataConnectionHasDataEnabled: StateFlow<Boolean>
|
val activeDataConnectionHasDataEnabled: StateFlow<Boolean>
|
||||||
|
|
||||||
/** True if the RAT icon should always be displayed and false otherwise. */
|
/** True if the RAT icon should always be displayed and false otherwise. */
|
||||||
val alwaysShowDataRatIcon: StateFlow<Boolean>
|
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 */
|
/** The icon mapping from network type to [MobileIconGroup] for the default subscription */
|
||||||
val defaultMobileIconMapping: StateFlow<Map<String, MobileIconGroup>>
|
val defaultMobileIconMapping: StateFlow<Map<String, MobileIconGroup>>
|
||||||
/** Fallback [MobileIconGroup] in the case where there is no icon in the mapping */
|
/** Fallback [MobileIconGroup] in the case where there is no icon in the mapping */
|
||||||
@@ -165,6 +170,11 @@ constructor(
|
|||||||
.mapLatest { it.alwaysShowDataRatIcon }
|
.mapLatest { it.alwaysShowDataRatIcon }
|
||||||
.stateIn(scope, SharingStarted.WhileSubscribed(), false)
|
.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 */
|
/** If there is no mapping in [defaultMobileIconMapping], then use this default icon group */
|
||||||
override val defaultMobileIconGroup: StateFlow<MobileIconGroup> =
|
override val defaultMobileIconGroup: StateFlow<MobileIconGroup> =
|
||||||
mobileConnectionsRepo.defaultMobileIconGroup.stateIn(
|
mobileConnectionsRepo.defaultMobileIconGroup.stateIn(
|
||||||
@@ -196,6 +206,7 @@ constructor(
|
|||||||
scope,
|
scope,
|
||||||
activeDataConnectionHasDataEnabled,
|
activeDataConnectionHasDataEnabled,
|
||||||
alwaysShowDataRatIcon,
|
alwaysShowDataRatIcon,
|
||||||
|
alwaysUseCdmaLevel,
|
||||||
defaultMobileIconMapping,
|
defaultMobileIconMapping,
|
||||||
defaultMobileIconGroup,
|
defaultMobileIconGroup,
|
||||||
isDefaultConnectionFailed,
|
isDefaultConnectionFailed,
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class FakeMobileIconInteractor(
|
|||||||
) : MobileIconInteractor {
|
) : MobileIconInteractor {
|
||||||
override val alwaysShowDataRatIcon = MutableStateFlow(false)
|
override val alwaysShowDataRatIcon = MutableStateFlow(false)
|
||||||
|
|
||||||
|
override val alwaysUseCdmaLevel = MutableStateFlow(false)
|
||||||
|
|
||||||
override val activity =
|
override val activity =
|
||||||
MutableStateFlow(
|
MutableStateFlow(
|
||||||
DataActivityModel(
|
DataActivityModel(
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ class FakeMobileIconsInteractor(
|
|||||||
|
|
||||||
override val alwaysShowDataRatIcon = MutableStateFlow(false)
|
override val alwaysShowDataRatIcon = MutableStateFlow(false)
|
||||||
|
|
||||||
|
override val alwaysUseCdmaLevel = MutableStateFlow(false)
|
||||||
|
|
||||||
private val _defaultMobileIconMapping = MutableStateFlow(TEST_MAPPING)
|
private val _defaultMobileIconMapping = MutableStateFlow(TEST_MAPPING)
|
||||||
override val defaultMobileIconMapping = _defaultMobileIconMapping
|
override val defaultMobileIconMapping = _defaultMobileIconMapping
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class MobileIconInteractorTest : SysuiTestCase() {
|
|||||||
scope,
|
scope,
|
||||||
mobileIconsInteractor.activeDataConnectionHasDataEnabled,
|
mobileIconsInteractor.activeDataConnectionHasDataEnabled,
|
||||||
mobileIconsInteractor.alwaysShowDataRatIcon,
|
mobileIconsInteractor.alwaysShowDataRatIcon,
|
||||||
|
mobileIconsInteractor.alwaysUseCdmaLevel,
|
||||||
mobileIconsInteractor.defaultMobileIconMapping,
|
mobileIconsInteractor.defaultMobileIconMapping,
|
||||||
mobileIconsInteractor.defaultMobileIconGroup,
|
mobileIconsInteractor.defaultMobileIconGroup,
|
||||||
mobileIconsInteractor.isDefaultConnectionFailed,
|
mobileIconsInteractor.isDefaultConnectionFailed,
|
||||||
@@ -103,7 +104,27 @@ class MobileIconInteractorTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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) {
|
runBlocking(IMMEDIATE) {
|
||||||
connectionRepository.setConnectionInfo(
|
connectionRepository.setConnectionInfo(
|
||||||
MobileConnectionModel(isGsm = false),
|
MobileConnectionModel(isGsm = false),
|
||||||
@@ -117,7 +138,7 @@ class MobileIconInteractorTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun cdma_usesCdmaLevel() =
|
fun notGsm_alwaysShowCdmaTrue_usesCdmaLevel() =
|
||||||
runBlocking(IMMEDIATE) {
|
runBlocking(IMMEDIATE) {
|
||||||
connectionRepository.setConnectionInfo(
|
connectionRepository.setConnectionInfo(
|
||||||
MobileConnectionModel(
|
MobileConnectionModel(
|
||||||
@@ -126,6 +147,7 @@ class MobileIconInteractorTest : SysuiTestCase() {
|
|||||||
cdmaLevel = CDMA_LEVEL
|
cdmaLevel = CDMA_LEVEL
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
mobileIconsInteractor.alwaysUseCdmaLevel.value = true
|
||||||
|
|
||||||
var latest: Int? = null
|
var latest: Int? = null
|
||||||
val job = underTest.level.onEach { latest = it }.launchIn(this)
|
val job = underTest.level.onEach { latest = it }.launchIn(this)
|
||||||
@@ -135,6 +157,26 @@ class MobileIconInteractorTest : SysuiTestCase() {
|
|||||||
job.cancel()
|
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
|
@Test
|
||||||
fun iconGroup_three_g() =
|
fun iconGroup_three_g() =
|
||||||
runBlocking(IMMEDIATE) {
|
runBlocking(IMMEDIATE) {
|
||||||
@@ -239,6 +281,21 @@ class MobileIconInteractorTest : SysuiTestCase() {
|
|||||||
job.cancel()
|
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
|
@Test
|
||||||
fun test_isDefaultDataEnabled_matchesParent() =
|
fun test_isDefaultDataEnabled_matchesParent() =
|
||||||
runBlocking(IMMEDIATE) {
|
runBlocking(IMMEDIATE) {
|
||||||
|
|||||||
@@ -291,6 +291,38 @@ class MobileIconsInteractorTest : SysuiTestCase() {
|
|||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun alwaysUseCdmaLevel_configHasTrue() =
|
||||||
|
runBlocking(IMMEDIATE) {
|
||||||
|
var latest: Boolean? = null
|
||||||
|
val job = underTest.alwaysUseCdmaLevel.onEach { latest = it }.launchIn(this)
|
||||||
|
|
||||||
|
val config = MobileMappings.Config()
|
||||||
|
config.alwaysShowCdmaRssi = true
|
||||||
|
connectionsRepository.defaultDataSubRatConfig.value = config
|
||||||
|
yield()
|
||||||
|
|
||||||
|
assertThat(latest).isTrue()
|
||||||
|
|
||||||
|
job.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun alwaysUseCdmaLevel_configHasFalse() =
|
||||||
|
runBlocking(IMMEDIATE) {
|
||||||
|
var latest: Boolean? = null
|
||||||
|
val job = underTest.alwaysUseCdmaLevel.onEach { latest = it }.launchIn(this)
|
||||||
|
|
||||||
|
val config = MobileMappings.Config()
|
||||||
|
config.alwaysShowCdmaRssi = false
|
||||||
|
connectionsRepository.defaultDataSubRatConfig.value = config
|
||||||
|
yield()
|
||||||
|
|
||||||
|
assertThat(latest).isFalse()
|
||||||
|
|
||||||
|
job.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val IMMEDIATE = Dispatchers.Main.immediate
|
private val IMMEDIATE = Dispatchers.Main.immediate
|
||||||
private val tableLogBuffer =
|
private val tableLogBuffer =
|
||||||
|
|||||||
Reference in New Issue
Block a user