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

Commit 21a25876 authored by Evan Laird's avatar Evan Laird
Browse files

[Sb refactor] Add carrierId to the new pipeline

Adds carrierId to the mobile connection repo, and upgrades the mobile
icon group type to a NetworkTypeIconModel so that we can do fancy stuff
like override it.

We add support for checking MobileIconCarrierIdOverrides for an override
entry whenever the carrierId changes. If an override entry exists, then
we check for an asset override whenever the network changes.

Also can be tested using Demo mode:
```
$ # MCC/MNC 311/480 overrides the icon to use 5GUC -- no carrierId
$ # override for 1234
$ adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e level 2 -e datatype 5g+ -e mccmnc 311480 -e carrierid 1234
$ # carrierid 2032 contains an icon override, pointing back to the
$ # default 5G+ icon
$ adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e level 2 -e datatype 5g+ -e mccmnc 311480 -e carrierid 2032
```

Test: MobileConnectionsRepositoryTest
Test: MobileIconInteractorTest
Bug: 272099695
Change-Id: Ia71831d481d84c2508d8cbe08755644eed2f9ff5
parent 82e4659d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -558,8 +558,10 @@ public interface StatusBarIconController {
            mGroup.addView(view, index, onCreateLayoutParams());

            if (mIsInDemoMode) {
                Context mobileContext = mMobileContextProvider
                        .getMobileContextForSub(subId, mContext);
                mDemoStatusIcons.addModernMobileView(
                        mContext,
                        mobileContext,
                        mMobileIconsViewModel.getLogger(),
                        subId);
            }
+3 −0
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@ interface MobileConnectionRepository {
    /** The subscriptionId that this connection represents */
    val subId: Int

    /** The carrierId for this connection. See [TelephonyManager.getSimCarrierId] */
    val carrierId: StateFlow<Int>

    /**
     * The table log buffer created for this connection. Will have the name "MobileConnectionLog
     * [subId]"
+17 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.pipeline.mobile.data.repository.demo

import android.telephony.CellSignalStrength
import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID
import android.telephony.TelephonyManager
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.logDiffsForTable
@@ -25,6 +26,7 @@ import com.android.systemui.statusbar.pipeline.mobile.data.model.NetworkNameMode
import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.demo.model.FakeNetworkEventModel
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_CARRIER_ID
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_CARRIER_NETWORK_CHANGE
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_CDMA_LEVEL
import com.android.systemui.statusbar.pipeline.mobile.data.repository.prod.FullMobileConnectionRepository.Companion.COL_EMERGENCY
@@ -52,6 +54,17 @@ class DemoMobileConnectionRepository(
    override val tableLogBuffer: TableLogBuffer,
    val scope: CoroutineScope,
) : MobileConnectionRepository {
    private val _carrierId = MutableStateFlow(INVALID_SUBSCRIPTION_ID)
    override val carrierId =
        _carrierId
            .logDiffsForTable(
                tableLogBuffer,
                columnPrefix = "",
                columnName = COL_CARRIER_ID,
                _carrierId.value,
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), _carrierId.value)

    private val _isEmergencyOnly = MutableStateFlow(false)
    override val isEmergencyOnly =
        _isEmergencyOnly
@@ -186,6 +199,8 @@ class DemoMobileConnectionRepository(
        dataEnabled.value = true
        networkName.value = NetworkNameModel.IntentDerived(event.name)

        _carrierId.value = event.carrierId ?: INVALID_SUBSCRIPTION_ID

        cdmaRoaming.value = event.roaming
        _isRoaming.value = event.roaming
        // TODO(b/261029387): not yet supported
@@ -208,6 +223,8 @@ class DemoMobileConnectionRepository(
        // This is always true here, because we split out disabled states at the data-source level
        dataEnabled.value = true
        networkName.value = NetworkNameModel.IntentDerived(CARRIER_MERGED_NAME)
        // TODO(b/276943904): is carrierId a thing with carrier merged networks?
        _carrierId.value = INVALID_SUBSCRIPTION_ID
        numberOfLevels.value = event.numberOfLevels
        cdmaRoaming.value = false
        _primaryLevel.value = event.level
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.pipeline.mobile.data.repository.prod

import android.telephony.CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN
import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID
import android.telephony.TelephonyManager
import android.util.Log
import com.android.systemui.dagger.SysUISingleton
@@ -157,6 +158,7 @@ class CarrierMergedConnectionRepository(
            .stateIn(scope, SharingStarted.WhileSubscribed(), DataConnectionState.Disconnected)

    override val isRoaming = MutableStateFlow(false).asStateFlow()
    override val carrierId = MutableStateFlow(INVALID_SUBSCRIPTION_ID).asStateFlow()
    override val isEmergencyOnly = MutableStateFlow(false).asStateFlow()
    override val operatorAlphaShort = MutableStateFlow(null).asStateFlow()
    override val isInService = MutableStateFlow(true).asStateFlow()
+11 −5
Original line number Diff line number Diff line
@@ -109,6 +109,11 @@ class FullMobileConnectionRepository(
            .stateIn(scope, SharingStarted.WhileSubscribed(), initial)
    }

    override val carrierId =
        activeRepo
            .flatMapLatest { it.carrierId }
            .stateIn(scope, SharingStarted.WhileSubscribed(), activeRepo.value.carrierId.value)

    override val cdmaRoaming =
        activeRepo
            .flatMapLatest { it.cdmaRoaming }
@@ -321,13 +326,14 @@ class FullMobileConnectionRepository(
    }

    companion object {
        const val COL_CARRIER_ID = "carrierId"
        const val COL_CARRIER_NETWORK_CHANGE = "carrierNetworkChangeActive"
        const val COL_CDMA_LEVEL = "cdmaLevel"
        const val COL_EMERGENCY = "emergencyOnly"
        const val COL_ROAMING = "roaming"
        const val COL_OPERATOR = "operatorName"
        const val COL_IS_IN_SERVICE = "isInService"
        const val COL_IS_GSM = "isGsm"
        const val COL_CDMA_LEVEL = "cdmaLevel"
        const val COL_IS_IN_SERVICE = "isInService"
        const val COL_OPERATOR = "operatorName"
        const val COL_PRIMARY_LEVEL = "primaryLevel"
        const val COL_CARRIER_NETWORK_CHANGE = "carrierNetworkChangeActive"
        const val COL_ROAMING = "roaming"
    }
}
Loading