Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfig.kt +35 −6 Original line number Diff line number Diff line Loading @@ -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_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 Loading @@ -42,10 +43,11 @@ 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] * 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 * 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 */ class SystemUiCarrierConfig internal constructor( Loading @@ -66,10 +68,16 @@ 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 */ Loading @@ -90,15 +98,19 @@ 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() fun update(config: PersistableBundle) { override fun update(config: PersistableBundle) { _configValue.value = config.getBoolean(key) } Loading @@ -106,3 +118,20 @@ 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}" } } packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,9 @@ 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. * Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionRepository.kt +2 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,8 @@ class DemoMobileConnectionRepository( override val hasPrioritizedNetworkCapabilities = MutableStateFlow(false) override val satelliteConnectionHysteresisSeconds = MutableStateFlow(0) override suspend fun isInEcmMode(): Boolean = false /** Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,9 @@ 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 = Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepository.kt +9 −0 Original line number Diff line number Diff line Loading @@ -334,6 +334,15 @@ 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() class Factory Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/model/SystemUiCarrierConfig.kt +35 −6 Original line number Diff line number Diff line Loading @@ -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_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 Loading @@ -42,10 +43,11 @@ 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] * 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 * 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 */ class SystemUiCarrierConfig internal constructor( Loading @@ -66,10 +68,16 @@ 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 */ Loading @@ -90,15 +98,19 @@ 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() fun update(config: PersistableBundle) { override fun update(config: PersistableBundle) { _configValue.value = config.getBoolean(key) } Loading @@ -106,3 +118,20 @@ 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}" } }
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,9 @@ 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. * Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionRepository.kt +2 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,8 @@ class DemoMobileConnectionRepository( override val hasPrioritizedNetworkCapabilities = MutableStateFlow(false) override val satelliteConnectionHysteresisSeconds = MutableStateFlow(0) override suspend fun isInEcmMode(): Boolean = false /** Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,9 @@ 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 = Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepository.kt +9 −0 Original line number Diff line number Diff line Loading @@ -334,6 +334,15 @@ 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() class Factory Loading