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 40e9ba1a46c73..3cc8ddfb7aa5a 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 @@ -17,7 +17,6 @@ package com.android.systemui.statusbar.pipeline.mobile.data.repository import android.telephony.SubscriptionInfo -import android.telephony.SubscriptionManager import android.telephony.TelephonyCallback import android.telephony.TelephonyManager import com.android.systemui.log.table.TableLogBuffer @@ -54,11 +53,6 @@ interface MobileConnectionRepository { val connectionInfo: Flow /** Observable tracking [TelephonyManager.isDataConnectionAllowed] */ val dataEnabled: StateFlow - /** - * True if this connection represents the default subscription per - * [SubscriptionManager.getDefaultDataSubscriptionId] - */ - val isDefaultDataSubscription: StateFlow /** * See [TelephonyManager.getCdmaEnhancedRoamingIndicatorDisplayNumber]. This bit only matters if diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionsRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionsRepository.kt index 498c0b93fce88..97b4c2cadbe58 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionsRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileConnectionsRepository.kt @@ -18,7 +18,6 @@ package com.android.systemui.statusbar.pipeline.mobile.data.repository import android.provider.Settings import android.telephony.CarrierConfigManager -import android.telephony.SubscriptionManager import com.android.settingslib.SignalIcon.MobileIconGroup import com.android.settingslib.mobile.MobileMappings import com.android.settingslib.mobile.MobileMappings.Config @@ -38,9 +37,6 @@ interface MobileConnectionsRepository { /** Observable for the subscriptionId of the current mobile data connection */ val activeMobileDataSubscriptionId: StateFlow - /** Tracks [SubscriptionManager.getDefaultDataSubscriptionId] */ - val defaultDataSubId: StateFlow - /** The current connectivity status for the default mobile network connection */ val defaultMobileNetworkConnectivity: StateFlow diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileRepositorySwitcher.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileRepositorySwitcher.kt index db9d24ff7abad..0c8593d60cf5a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileRepositorySwitcher.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/MobileRepositorySwitcher.kt @@ -139,11 +139,6 @@ constructor( override val defaultMobileIconGroup: Flow = activeRepo.flatMapLatest { it.defaultMobileIconGroup } - override val defaultDataSubId: StateFlow = - activeRepo - .flatMapLatest { it.defaultDataSubId } - .stateIn(scope, SharingStarted.WhileSubscribed(), realRepository.defaultDataSubId.value) - override val defaultMobileNetworkConnectivity: StateFlow = activeRepo .flatMapLatest { it.defaultMobileNetworkConnectivity } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionsRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionsRepository.kt index 0b5f9d5ae59e8..bdb1112f06b06 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionsRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionsRepository.kt @@ -139,14 +139,6 @@ constructor( private fun Map.reverse() = entries.associateBy({ it.value }) { it.key } - // TODO(b/261029387): add a command for this value - override val defaultDataSubId = - activeMobileDataSubscriptionId.stateIn( - scope, - SharingStarted.WhileSubscribed(), - INVALID_SUBSCRIPTION_ID - ) - // TODO(b/261029387): not yet supported override val defaultMobileNetworkConnectivity = MutableStateFlow(MobileConnectivityModel()) @@ -199,7 +191,6 @@ constructor( val connection = getRepoForSubId(subId) // This is always true here, because we split out disabled states at the data-source level connection.dataEnabled.value = true - connection.isDefaultDataSubscription.value = state.dataType != null connection.networkName.value = NetworkNameModel.Derived(state.name) connection.cdmaRoaming.value = state.roaming @@ -281,8 +272,6 @@ class DemoMobileConnectionRepository( override val dataEnabled = MutableStateFlow(true) - override val isDefaultDataSubscription = MutableStateFlow(true) - override val cdmaRoaming = MutableStateFlow(false) override val networkName = MutableStateFlow(NetworkNameModel.Derived("demo network")) 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 5cfff82253c5a..d27d91bb73b54 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 @@ -78,7 +78,6 @@ class MobileConnectionRepositoryImpl( private val telephonyManager: TelephonyManager, private val globalSettings: GlobalSettings, broadcastDispatcher: BroadcastDispatcher, - defaultDataSubId: StateFlow, globalMobileDataSettingChangedEvent: Flow, mobileMappingsProxy: MobileMappingsProxy, bgDispatcher: CoroutineDispatcher, @@ -284,20 +283,6 @@ class MobileConnectionRepositoryImpl( private fun dataConnectionAllowed(): Boolean = telephonyManager.isDataConnectionAllowed - override val isDefaultDataSubscription: StateFlow = run { - val initialValue = defaultDataSubId.value == subId - defaultDataSubId - .mapLatest { it == subId } - .distinctUntilChanged() - .logDiffsForTable( - mobileLogger, - columnPrefix = "", - columnName = "isDefaultDataSub", - initialValue = initialValue, - ) - .stateIn(scope, SharingStarted.WhileSubscribed(), initialValue) - } - class Factory @Inject constructor( @@ -315,7 +300,6 @@ class MobileConnectionRepositoryImpl( subId: Int, defaultNetworkName: NetworkNameModel, networkNameSeparator: String, - defaultDataSubId: StateFlow, globalMobileDataSettingChangedEvent: Flow, ): MobileConnectionRepository { val mobileLogger = logFactory.create(tableBufferLogName(subId), 100) @@ -328,7 +312,6 @@ class MobileConnectionRepositoryImpl( telephonyManager.createForSubscriptionId(subId), globalSettings, broadcastDispatcher, - defaultDataSubId, globalMobileDataSettingChangedEvent, mobileMappingsProxy, bgDispatcher, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt index d407abeb23150..c88c70064238c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt @@ -35,7 +35,6 @@ import android.telephony.TelephonyCallback import android.telephony.TelephonyCallback.ActiveDataSubscriptionIdListener import android.telephony.TelephonyManager import androidx.annotation.VisibleForTesting -import com.android.internal.telephony.PhoneConstants import com.android.settingslib.SignalIcon.MobileIconGroup import com.android.settingslib.mobile.MobileMappings.Config import com.android.systemui.R @@ -60,7 +59,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.asExecutor import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.distinctUntilChanged @@ -142,24 +140,10 @@ constructor( .logInputChange(logger, "onActiveDataSubscriptionIdChanged") .stateIn(scope, started = SharingStarted.WhileSubscribed(), INVALID_SUBSCRIPTION_ID) - private val defaultDataSubIdChangeEvent: MutableSharedFlow = - MutableSharedFlow(extraBufferCapacity = 1) - - override val defaultDataSubId: StateFlow = + private val defaultDataSubIdChangedEvent = broadcastDispatcher - .broadcastFlow( - IntentFilter(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED) - ) { intent, _ -> - intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, INVALID_SUBSCRIPTION_ID) - } - .distinctUntilChanged() + .broadcastFlow(IntentFilter(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED)) .logInputChange(logger, "ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED") - .onEach { defaultDataSubIdChangeEvent.tryEmit(Unit) } - .stateIn( - scope, - SharingStarted.WhileSubscribed(), - SubscriptionManager.getDefaultDataSubscriptionId() - ) private val carrierConfigChangedEvent = broadcastDispatcher @@ -167,7 +151,7 @@ constructor( .logInputChange(logger, "ACTION_CARRIER_CONFIG_CHANGED") override val defaultDataSubRatConfig: StateFlow = - merge(defaultDataSubIdChangeEvent, carrierConfigChangedEvent) + merge(defaultDataSubIdChangedEvent, carrierConfigChangedEvent) .mapLatest { Config.readConfig(context) } .distinctUntilChanged() .logInputChange(logger, "defaultDataSubRatConfig") @@ -272,7 +256,6 @@ constructor( subId, defaultNetworkName, networkNameSeparator, - defaultDataSubId, globalMobileDataSettingChangedEvent, ) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionRepository.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionRepository.kt index d6a9ee325b2e0..9f347610cfdb5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionRepository.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionRepository.kt @@ -32,9 +32,6 @@ class FakeMobileConnectionRepository( private val _dataEnabled = MutableStateFlow(true) override val dataEnabled = _dataEnabled - private val _isDefaultDataSubscription = MutableStateFlow(true) - override val isDefaultDataSubscription = _isDefaultDataSubscription - override val cdmaRoaming = MutableStateFlow(false) override val networkName = @@ -47,8 +44,4 @@ class FakeMobileConnectionRepository( fun setDataEnabled(enabled: Boolean) { _dataEnabled.value = enabled } - - fun setIsDefaultDataSubscription(isDefault: Boolean) { - _isDefaultDataSubscription.value = isDefault - } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionsRepository.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionsRepository.kt index 7f93328ee95e1..49d4bdc88c828 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionsRepository.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/FakeMobileConnectionsRepository.kt @@ -57,9 +57,6 @@ class FakeMobileConnectionsRepository( private val _activeMobileDataSubscriptionId = MutableStateFlow(INVALID_SUBSCRIPTION_ID) override val activeMobileDataSubscriptionId = _activeMobileDataSubscriptionId - private val _defaultDataSubId = MutableStateFlow(INVALID_SUBSCRIPTION_ID) - override val defaultDataSubId = _defaultDataSubId - private val _mobileConnectivity = MutableStateFlow(MobileConnectivityModel()) override val defaultMobileNetworkConnectivity = _mobileConnectivity @@ -84,10 +81,6 @@ class FakeMobileConnectionsRepository( _subscriptions.value = subs } - fun setDefaultDataSubId(id: Int) { - _defaultDataSubId.value = id - } - fun setMobileConnectivity(model: MobileConnectivityModel) { _mobileConnectivity.value = model } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryTest.kt index c63dd2a2318c8..cb642624c7c63 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryTest.kt @@ -117,7 +117,6 @@ class MobileConnectionRepositoryTest : SysuiTestCase() { telephonyManager, globalSettings, fakeBroadcastDispatcher, - connectionsRepo.defaultDataSubId, connectionsRepo.globalMobileDataSettingChangedEvent, mobileMappings, IMMEDIATE, @@ -379,33 +378,6 @@ class MobileConnectionRepositoryTest : SysuiTestCase() { job.cancel() } - @Test - fun isDefaultDataSubscription_isDefault() = - runBlocking(IMMEDIATE) { - connectionsRepo.setDefaultDataSubId(SUB_1_ID) - - var latest: Boolean? = null - val job = underTest.isDefaultDataSubscription.onEach { latest = it }.launchIn(this) - - assertThat(latest).isTrue() - - job.cancel() - } - - @Test - fun isDefaultDataSubscription_isNotDefault() = - runBlocking(IMMEDIATE) { - // Our subId is SUB_1_ID - connectionsRepo.setDefaultDataSubId(123) - - var latest: Boolean? = null - val job = underTest.isDefaultDataSubscription.onEach { latest = it }.launchIn(this) - - assertThat(latest).isFalse() - - job.cancel() - } - @Test fun isDataConnectionAllowed_subIdSettingUpdate_valueUpdated() = runBlocking(IMMEDIATE) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryTest.kt index b8cd7a4f6e0a0..0da15e2399323 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryTest.kt @@ -306,35 +306,6 @@ class MobileConnectionsRepositoryTest : SysuiTestCase() { job.cancel() } - @Test - fun testDefaultDataSubId_updatesOnBroadcast() = - runBlocking(IMMEDIATE) { - var latest: Int? = null - val job = underTest.defaultDataSubId.onEach { latest = it }.launchIn(this) - - fakeBroadcastDispatcher.registeredReceivers.forEach { receiver -> - receiver.onReceive( - context, - Intent(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED) - .putExtra(PhoneConstants.SUBSCRIPTION_KEY, SUB_2_ID) - ) - } - - assertThat(latest).isEqualTo(SUB_2_ID) - - fakeBroadcastDispatcher.registeredReceivers.forEach { receiver -> - receiver.onReceive( - context, - Intent(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED) - .putExtra(PhoneConstants.SUBSCRIPTION_KEY, SUB_1_ID) - ) - } - - assertThat(latest).isEqualTo(SUB_1_ID) - - job.cancel() - } - @Test fun mobileConnectivity_default() { assertThat(underTest.defaultMobileNetworkConnectivity.value)