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

Commit 1685e6b9 authored by Shawn Lee's avatar Shawn Lee
Browse files

[1/2] Update new status bar data pipeline to support names for multiple sims

Updates the carrier name to use SubscriptionInfo instead of the ACTION_SERVICE_PROVIDERS_UPDATED intent as its source in order to support names for multiple subscriptions. Split from ag/24012407

Bug: 288631206
Test: Added/updated unit tests
Change-Id: Ib40dcf0a14e267c40a69dc4817761dab0e25142c
parent 7e01e3c5
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -60,6 +60,19 @@ sealed interface NetworkNameModel : Diffable<NetworkNameModel> {
        }
    }

    /** This name has been derived from SubscriptionModel. see [SubscriptionModel] */
    data class SubscriptionDerived(override val name: String) : NetworkNameModel {
        override fun logDiffs(prevVal: NetworkNameModel, row: TableRowLogger) {
            if (prevVal !is SubscriptionDerived || prevVal.name != name) {
                row.logChange(COL_NETWORK_NAME, "SubscriptionDerived($name)")
            }
        }

        override fun logFull(row: TableRowLogger) {
            row.logChange(COL_NETWORK_NAME, "SubscriptionDerived($name)")
        }
    }

    /**
     * This name has been derived from the sim via
     * [android.telephony.TelephonyManager.getSimOperatorName].
+3 −0
Original line number Diff line number Diff line
@@ -34,4 +34,7 @@ data class SubscriptionModel(

    /** Subscriptions in the same group may be filtered or treated as a single subscription */
    val groupUuid: ParcelUuid? = null,

    /** Text representing the name for this connection */
    val carrierName: String,
)
+9 −1
Original line number Diff line number Diff line
@@ -115,9 +115,17 @@ interface MobileConnectionRepository {
     */
    val cdmaRoaming: StateFlow<Boolean>

    /** The service provider name for this network connection, or the default name */
    /** The service provider name for this network connection, or the default name. */
    val networkName: StateFlow<NetworkNameModel>

    /**
     * The service provider name for this network connection, or the default name.
     *
     * TODO(b/296600321): De-duplicate this field with [networkName] after determining the data
     *   provided is identical
     */
    val carrierName: StateFlow<NetworkNameModel>

    /**
     * True if this type of connection is allowed while airplane mode is on, and false otherwise.
     */
+7 −1
Original line number Diff line number Diff line
@@ -184,7 +184,10 @@ class DemoMobileConnectionRepository(

    override val cdmaRoaming = MutableStateFlow(false)

    override val networkName = MutableStateFlow(NetworkNameModel.IntentDerived("demo network"))
    override val networkName = MutableStateFlow(NetworkNameModel.IntentDerived(DEMO_CARRIER_NAME))

    override val carrierName =
        MutableStateFlow(NetworkNameModel.SubscriptionDerived(DEMO_CARRIER_NAME))

    override val isAllowedDuringAirplaneMode = MutableStateFlow(false)

@@ -200,6 +203,7 @@ 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(event.name)
        carrierName.value = NetworkNameModel.SubscriptionDerived("${event.name} ${event.subId}")

        _carrierId.value = event.carrierId ?: INVALID_SUBSCRIPTION_ID

@@ -227,6 +231,7 @@ 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)
        carrierName.value = NetworkNameModel.SubscriptionDerived(CARRIER_MERGED_NAME)
        // TODO(b/276943904): is carrierId a thing with carrier merged networks?
        _carrierId.value = INVALID_SUBSCRIPTION_ID
        numberOfLevels.value = event.numberOfLevels
@@ -248,6 +253,7 @@ class DemoMobileConnectionRepository(
    }

    companion object {
        private const val DEMO_CARRIER_NAME = "Demo Carrier"
        private const val CARRIER_MERGED_NAME = "Carrier Merged Network"
    }
}
+7 −3
Original line number Diff line number Diff line
@@ -92,9 +92,12 @@ constructor(

    private fun maybeCreateSubscription(subId: Int) {
        if (!subscriptionInfoCache.containsKey(subId)) {
            SubscriptionModel(subscriptionId = subId, isOpportunistic = false).also {
                subscriptionInfoCache[subId] = it
            }
            SubscriptionModel(
                    subscriptionId = subId,
                    isOpportunistic = false,
                    carrierName = DEFAULT_CARRIER_NAME,
                )
                .also { subscriptionInfoCache[subId] = it }

            _subscriptions.value = subscriptionInfoCache.values.toList()
        }
@@ -327,6 +330,7 @@ constructor(
        private const val TAG = "DemoMobileConnectionsRepo"

        private const val DEFAULT_SUB_ID = 1
        private const val DEFAULT_CARRIER_NAME = "demo carrier"
    }
}

Loading