summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Olivier St-Onge <ostonge@google.com> 2024-04-12 16:13:03 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-04-12 16:13:03 +0000
commit43cfafb8f98b74f059043e4e66476e2fe5cfe2f7 (patch)
treed3de7c7cb1875e1a190a5f96ee0c93475d49c3a5
parentcbdf205d56c61fb37fef39b26b3af5965f7eed51 (diff)
parent4f7f6f1f649c2cb121e74321d74de3e2dea15acf (diff)
Merge "Revert "Add hysteresis to satellite icon when losing connection."" into main
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfig.kt41
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionRepository.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionRepository.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepository.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepository.kt9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractor.kt46
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/MobileIconInteractorTest.kt29
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionRepository.kt2
9 files changed, 7 insertions, 131 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 3b2930f78d19..f4e3eab8593d 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,7 +18,6 @@ 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_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT
import android.telephony.CarrierConfigManager.KEY_SHOW_OPERATOR_NAME_IN_STATUSBAR_BOOL
import androidx.annotation.VisibleForTesting
import kotlinx.coroutines.flow.MutableStateFlow
@@ -43,11 +42,10 @@ import kotlinx.coroutines.flow.asStateFlow
* using the default config for logging purposes.
*
* NOTE to add new keys to be tracked:
- * 1. Define a new `private val` wrapping the key using [BooleanCarrierConfig] or [IntCarrierConfig]
- * 2. Define a public `val` exposing the wrapped flow using [BooleanCarrierConfig.config] or
- * [IntCarrierConfig.config]
- * 3. Add the new wrapped public flow to the list of tracked configs, so they are properly updated
- * when a new carrier config comes down
+ * 1. Define a new `private val` wrapping the key using [BooleanCarrierConfig]
+ * 2. Define a public `val` exposing the wrapped flow using [BooleanCarrierConfig.config]
+ * 3. Add the new [BooleanCarrierConfig] to the list of tracked configs, so they are properly
+ * updated when a new carrier config comes down
*/
class SystemUiCarrierConfig
internal constructor(
@@ -68,16 +66,10 @@ internal constructor(
/** Flow tracking the [KEY_SHOW_OPERATOR_NAME_IN_STATUSBAR_BOOL] config */
val showOperatorNameInStatusBar: StateFlow<Boolean> = showOperatorName.config
- private val satelliteHysteresisSeconds =
- IntCarrierConfig(KEY_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT, defaultConfig)
- /** Flow tracking the [KEY_SATELLITE_CONNECTION_HYSTERESIS_SEC_INT] config */
- val satelliteConnectionHysteresisSeconds: StateFlow<Int> = satelliteHysteresisSeconds.config
-
private val trackedConfigs =
listOf(
inflateSignalStrength,
showOperatorName,
- satelliteHysteresisSeconds,
)
/** Ingest a new carrier config, and switch all of the tracked keys over to the new values */
@@ -98,19 +90,15 @@ internal constructor(
override fun toString(): String = trackedConfigs.joinToString { it.toString() }
}
-interface CarrierConfig {
- fun update(config: PersistableBundle)
-}
-
/** Extracts [key] from the carrier config, and stores it in a flow */
private class BooleanCarrierConfig(
val key: String,
defaultConfig: PersistableBundle,
-) : CarrierConfig {
+) {
private val _configValue = MutableStateFlow(defaultConfig.getBoolean(key))
val config = _configValue.asStateFlow()
- override fun update(config: PersistableBundle) {
+ fun update(config: PersistableBundle) {
_configValue.value = config.getBoolean(key)
}
@@ -118,20 +106,3 @@ private class BooleanCarrierConfig(
return "$key=${config.value}"
}
}
-
-/** Extracts [key] from the carrier config, and stores it in a flow */
-private class IntCarrierConfig(
- val key: String,
- defaultConfig: PersistableBundle,
-) : CarrierConfig {
- private val _configValue = MutableStateFlow(defaultConfig.getInt(key))
- val config = _configValue.asStateFlow()
-
- override fun update(config: PersistableBundle) {
- _configValue.value = config.getInt(key)
- }
-
- override fun toString(): String {
- return "$key=${config.value}"
- }
-}
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 317c0634a364..22785979f3ae 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
@@ -144,9 +144,6 @@ interface MobileConnectionRepository {
*/
val hasPrioritizedNetworkCapabilities: StateFlow<Boolean>
- /** Duration in seconds of the hysteresis to use when losing satellite connection. */
- val satelliteConnectionHysteresisSeconds: StateFlow<Int>
-
/**
* True if this connection is in emergency callback mode.
*
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 90cdfeb05d4e..83d5f2b5d325 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
@@ -227,8 +227,6 @@ class DemoMobileConnectionRepository(
override val hasPrioritizedNetworkCapabilities = MutableStateFlow(false)
- override val satelliteConnectionHysteresisSeconds = MutableStateFlow(0)
-
override suspend fun isInEcmMode(): Boolean = false
/**
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 cb99d11e79b7..a532e6227451 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
@@ -187,9 +187,6 @@ class CarrierMergedConnectionRepository(
*/
override val hasPrioritizedNetworkCapabilities = MutableStateFlow(false).asStateFlow()
- /** Non-applicable to carrier merged connections. */
- override val satelliteConnectionHysteresisSeconds = MutableStateFlow(0).asStateFlow()
-
override val dataEnabled: StateFlow<Boolean> = wifiRepository.isWifiEnabled
override suspend fun isInEcmMode(): Boolean =
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 b7de4146a790..41559b2c1455 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
@@ -351,15 +351,6 @@ class FullMobileConnectionRepository(
activeRepo.value.hasPrioritizedNetworkCapabilities.value,
)
- override val satelliteConnectionHysteresisSeconds =
- activeRepo
- .flatMapLatest { it.satelliteConnectionHysteresisSeconds }
- .stateIn(
- scope,
- SharingStarted.WhileSubscribed(),
- activeRepo.value.satelliteConnectionHysteresisSeconds.value
- )
-
override suspend fun isInEcmMode(): Boolean = activeRepo.value.isInEcmMode()
fun dump(pw: PrintWriter) {
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 2cbe965b0ea9..b3885d247949 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
@@ -450,9 +450,6 @@ class MobileConnectionRepositoryImpl(
.flowOn(bgDispatcher)
.stateIn(scope, SharingStarted.WhileSubscribed(), false)
- override val satelliteConnectionHysteresisSeconds: StateFlow<Int> =
- systemUiCarrierConfig.satelliteConnectionHysteresisSeconds
-
class Factory
@Inject
constructor(
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 cbebfd0587ab..ed9e4056535f 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
@@ -35,25 +35,18 @@ import com.android.systemui.statusbar.pipeline.mobile.domain.model.NetworkTypeIc
import com.android.systemui.statusbar.pipeline.mobile.domain.model.SignalIconModel
import com.android.systemui.statusbar.pipeline.satellite.ui.model.SatelliteIconModel
import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel
-import com.android.systemui.util.kotlin.pairwiseBy
-import kotlin.time.DurationUnit
-import kotlin.time.toDuration
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
-import kotlinx.coroutines.flow.collect
-import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
-import kotlinx.coroutines.launch
interface MobileIconInteractor {
/** The table log created for this connection */
@@ -269,43 +262,6 @@ class MobileIconInteractorImpl(
MutableStateFlow(false).asStateFlow()
}
- private val hysteresisActive = MutableStateFlow(false)
-
- private val isNonTerrestrialWithHysteresis: StateFlow<Boolean> =
- combine(isNonTerrestrial, hysteresisActive) { isNonTerrestrial, hysteresisActive ->
- if (hysteresisActive) {
- true
- } else {
- isNonTerrestrial
- }
- }
- .logDiffsForTable(
- tableLogBuffer = tableLogBuffer,
- columnName = "isNonTerrestrialWithHysteresis",
- columnPrefix = "",
- initialValue = Flags.carrierEnabledSatelliteFlag(),
- )
- .stateIn(scope, SharingStarted.Eagerly, Flags.carrierEnabledSatelliteFlag())
-
- private val lostSatelliteConnection =
- isNonTerrestrial.pairwiseBy { old, new -> hysteresisActive.value = old && !new }
-
- init {
- scope.launch { lostSatelliteConnection.collect() }
- scope.launch {
- hysteresisActive.collectLatest {
- if (it) {
- delay(
- connectionRepository.satelliteConnectionHysteresisSeconds.value.toDuration(
- DurationUnit.SECONDS
- )
- )
- hysteresisActive.value = false
- }
- }
- }
- }
-
override val isRoaming: StateFlow<Boolean> =
combine(
connectionRepository.carrierNetworkChangeActive,
@@ -407,7 +363,7 @@ class MobileIconInteractorImpl(
showExclamationMark.value,
carrierNetworkChangeActive.value,
)
- isNonTerrestrialWithHysteresis
+ isNonTerrestrial
.flatMapLatest { ntn ->
if (ntn) {
satelliteIcon
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 f9ab25e9306a..dfe80233918a 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
@@ -43,15 +43,12 @@ import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
-import kotlin.time.Duration.Companion.seconds
-import kotlin.time.DurationUnit
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.UnconfinedTestDispatcher
-import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
@@ -694,32 +691,6 @@ class MobileIconInteractorTest : SysuiTestCase() {
assertThat(latest).isInstanceOf(SignalIconModel.Satellite::class.java)
}
- @EnableFlags(com.android.internal.telephony.flags.Flags.FLAG_CARRIER_ENABLED_SATELLITE_FLAG)
- @Test
- fun satBasedIcon_hasHysteresisWhenDisabled() =
- testScope.runTest {
- val latest by collectLastValue(underTest.signalLevelIcon)
-
- val hysteresisDuration = 5.seconds
- connectionRepository.satelliteConnectionHysteresisSeconds.value =
- hysteresisDuration.toInt(DurationUnit.SECONDS)
-
- connectionRepository.isNonTerrestrial.value = true
-
- assertThat(latest).isInstanceOf(SignalIconModel.Satellite::class.java)
-
- // Disable satellite
- connectionRepository.isNonTerrestrial.value = false
-
- // Satellite icon should still be visible
- assertThat(latest).isInstanceOf(SignalIconModel.Satellite::class.java)
-
- // Wait for the icon to change
- advanceTimeBy(hysteresisDuration)
-
- assertThat(latest).isInstanceOf(SignalIconModel.Cellular::class.java)
- }
-
private fun createInteractor(
overrides: MobileIconCarrierIdOverrides = MobileIconCarrierIdOverridesImpl()
) =
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 8109b60a9ef0..eb2d6c0f5405 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
@@ -64,8 +64,6 @@ class FakeMobileConnectionRepository(
override val hasPrioritizedNetworkCapabilities = MutableStateFlow(false)
- override val satelliteConnectionHysteresisSeconds = MutableStateFlow(0)
-
private var isInEcmMode: Boolean = false
override suspend fun isInEcmMode(): Boolean = isInEcmMode