Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9014672c authored by Evan Laird's avatar Evan Laird
Browse files

Rename MobileSubscriptionModel to MobileConnectionModel

Also rename `subscriptionModelFlow` to `connectionInfo`, which is more
clear given that `MobileConnectionRepository` is the provider of that
information.

This paves the way to remove `SubscriptionInfo` from our internal
representation in lieu of a `SubscriptionModel` based off of it

Test: tests in tests/src/com/android/systemui/statusbar/pipeline/mobile/*
Bug: 261029387
Change-Id: If4bd3e31d2f8a7400e31e4acd8776750eee22ad6
parent f58969d7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionS
 * any new field that needs to be tracked should be copied into this data class rather than
 * threading complex system objects through the pipeline.
 */
data class MobileSubscriptionModel(
data class MobileConnectionModel(
    /** From [ServiceStateListener.onServiceStateChanged] */
    val isEmergencyOnly: Boolean = false,

+2 −2
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import android.telephony.SubscriptionInfo
import android.telephony.SubscriptionManager
import android.telephony.TelephonyCallback
import android.telephony.TelephonyManager
import com.android.systemui.statusbar.pipeline.mobile.data.model.MobileSubscriptionModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.MobileConnectionModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow

@@ -42,7 +42,7 @@ interface MobileConnectionRepository {
     * A flow that aggregates all necessary callbacks from [TelephonyCallback] into a single
     * listener + model.
     */
    val subscriptionModelFlow: Flow<MobileSubscriptionModel>
    val connectionInfo: Flow<MobileConnectionModel>
    /** Observable tracking [TelephonyManager.isDataConnectionAllowed] */
    val dataEnabled: StateFlow<Boolean>
    /**
+5 −5
Original line number Diff line number Diff line
@@ -25,8 +25,8 @@ import com.android.settingslib.mobile.MobileMappings
import com.android.settingslib.mobile.TelephonyIcons
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionState
import com.android.systemui.statusbar.pipeline.mobile.data.model.MobileConnectionModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.MobileConnectivityModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.MobileSubscriptionModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType
import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType.DefaultNetworkType
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionRepository
@@ -206,7 +206,7 @@ constructor(
        connection.dataEnabled.value = true
        connection.isDefaultDataSubscription.value = state.dataType != null

        connection.subscriptionModelFlow.value = state.toMobileSubscriptionModel()
        connection.connectionInfo.value = state.toMobileConnectionModel()
    }

    private fun processDisabledMobileState(state: MobileDisabled) {
@@ -246,8 +246,8 @@ constructor(
    private fun subIdsString(): String =
        _subscriptions.value.joinToString(",") { it.subscriptionId.toString() }

    private fun Mobile.toMobileSubscriptionModel(): MobileSubscriptionModel {
        return MobileSubscriptionModel(
    private fun Mobile.toMobileConnectionModel(): MobileConnectionModel {
        return MobileConnectionModel(
            isEmergencyOnly = false, // TODO(b/261029387): not yet supported
            isGsm = false, // TODO(b/261029387): not yet supported
            cdmaLevel = level ?: 0,
@@ -275,7 +275,7 @@ constructor(
}

class DemoMobileConnectionRepository(override val subId: Int) : MobileConnectionRepository {
    override val subscriptionModelFlow = MutableStateFlow(MobileSubscriptionModel())
    override val connectionInfo = MutableStateFlow(MobileConnectionModel())

    override val dataEnabled = MutableStateFlow(true)

+3 −3
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.statusbar.pipeline.mobile.data.model.MobileSubscriptionModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.MobileConnectionModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType.DefaultNetworkType
import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType.OverrideNetworkType
import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType.UnknownNetworkType
@@ -81,8 +81,8 @@ class MobileConnectionRepositoryImpl(

    private val telephonyCallbackEvent = MutableSharedFlow<Unit>(extraBufferCapacity = 1)

    override val subscriptionModelFlow: StateFlow<MobileSubscriptionModel> = run {
        var state = MobileSubscriptionModel()
    override val connectionInfo: StateFlow<MobileConnectionModel> = run {
        var state = MobileConnectionModel()
        conflatedCallbackFlow {
                // TODO (b/240569788): log all of these into the connectivity logger
                val callback =
+10 −10
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ class MobileIconInteractorImpl(
    override val isDefaultConnectionFailed: StateFlow<Boolean>,
    connectionRepository: MobileConnectionRepository,
) : MobileIconInteractor {
    private val mobileStatusInfo = connectionRepository.subscriptionModelFlow
    private val connectionInfo = connectionRepository.connectionInfo

    override val isDataEnabled: StateFlow<Boolean> = connectionRepository.dataEnabled

@@ -78,7 +78,7 @@ class MobileIconInteractorImpl(
    /** Observable for the current RAT indicator icon ([MobileIconGroup]) */
    override val networkTypeIconGroup: StateFlow<MobileIconGroup> =
        combine(
                mobileStatusInfo,
                connectionInfo,
                defaultMobileIconMapping,
                defaultMobileIconGroup,
            ) { info, mapping, defaultGroup ->
@@ -87,18 +87,18 @@ class MobileIconInteractorImpl(
            .stateIn(scope, SharingStarted.WhileSubscribed(), defaultMobileIconGroup.value)

    override val isEmergencyOnly: StateFlow<Boolean> =
        mobileStatusInfo
        connectionInfo
            .mapLatest { it.isEmergencyOnly }
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)

    override val level: StateFlow<Int> =
        mobileStatusInfo
            .mapLatest { mobileModel ->
        connectionInfo
            .mapLatest { connection ->
                // TODO: incorporate [MobileMappings.Config.alwaysShowCdmaRssi]
                if (mobileModel.isGsm) {
                    mobileModel.primaryLevel
                if (connection.isGsm) {
                    connection.primaryLevel
                } else {
                    mobileModel.cdmaLevel
                    connection.cdmaLevel
                }
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), 0)
@@ -110,7 +110,7 @@ class MobileIconInteractorImpl(
    override val numberOfLevels: StateFlow<Int> = MutableStateFlow(4)

    override val isDataConnected: StateFlow<Boolean> =
        mobileStatusInfo
            .mapLatest { subscriptionModel -> subscriptionModel.dataConnectionState == Connected }
        connectionInfo
            .mapLatest { connection -> connection.dataConnectionState == Connected }
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)
}
Loading