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

Commit ec672943 authored by Evan Laird's avatar Evan Laird Committed by Android (Google) Code Review
Browse files

Merge changes I02f84f73,I61d6f01c,I6ed7a94b into main

* changes:
  [Networking] Filter out PROFILE_CLASS_PROVISIONING subscriptions
  [Networking] Define FILTER_PRIVISIONING_NETWORK_SUBSCRIPTIONS flag
  [Networking] Add [SubscriptionModel.provisioningClass] field for tracking
parents 0e92f892 08e09b9e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -406,6 +406,10 @@ object Flags {
    // TODO(b/301610137): Tracking bug
    @JvmField val NEW_NETWORK_SLICE_UI = unreleasedFlag("new_network_slice_ui", teamfood = true)

    // TODO(b/308138154): Tracking bug
    val FILTER_PROVISIONING_NETWORK_SUBSCRIPTIONS =
        releasedFlag("filter_provisioning_network_subscriptions")

    // TODO(b/265892345): Tracking Bug
    val PLUG_IN_STATUS_BAR_CHIP = releasedFlag("plug_in_status_bar_chip")

+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.pipeline.mobile.data.model

import android.os.ParcelUuid
import android.telephony.SubscriptionManager.ProfileClass

/**
 * SystemUI representation of [SubscriptionInfo]. Currently we only use two fields on the
@@ -37,4 +38,7 @@ data class SubscriptionModel(

    /** Text representing the name for this connection */
    val carrierName: String,

    /** Allow us to filter out PROVISIONING profiles. See [SubscriptionInfo.getProfileClass] */
    @ProfileClass val profileClass: Int
)
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.pipeline.mobile.data.repository.demo

import android.content.Context
import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID
import android.telephony.SubscriptionManager.PROFILE_CLASS_UNSET
import android.util.Log
import com.android.settingslib.SignalIcon
import com.android.settingslib.mobile.MobileMappings
@@ -96,6 +97,7 @@ constructor(
                    subscriptionId = subId,
                    isOpportunistic = false,
                    carrierName = DEFAULT_CARRIER_NAME,
                    profileClass = PROFILE_CLASS_UNSET,
                )
                .also { subscriptionInfoCache[subId] = it }

+1 −0
Original line number Diff line number Diff line
@@ -408,6 +408,7 @@ constructor(
            isOpportunistic = isOpportunistic,
            groupUuid = groupUuid,
            carrierName = carrierName.toString(),
            profileClass = profileClass,
        )

    companion object {
+69 −39
Original line number Diff line number Diff line
@@ -19,10 +19,13 @@ package com.android.systemui.statusbar.pipeline.mobile.domain.interactor
import android.content.Context
import android.telephony.CarrierConfigManager
import android.telephony.SubscriptionManager
import android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING
import com.android.settingslib.SignalIcon.MobileIconGroup
import com.android.settingslib.mobile.TelephonyIcons
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags.FILTER_PROVISIONING_NETWORK_SUBSCRIPTIONS
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.logDiffsForTable
import com.android.systemui.statusbar.pipeline.dagger.MobileSummaryLog
@@ -121,6 +124,7 @@ constructor(
    userSetupRepo: UserSetupRepository,
    @Application private val scope: CoroutineScope,
    private val context: Context,
    private val featureFlagsClassic: FeatureFlagsClassic,
) : MobileIconsInteractor {

    // Weak reference lookup for created interactors
@@ -162,6 +166,20 @@ constructor(
    private val unfilteredSubscriptions: Flow<List<SubscriptionModel>> =
        mobileConnectionsRepo.subscriptions

    /**
     * Any filtering that we can do based purely on the info of each subscription. Currently this
     * only applies the ProfileClass-based filter, but if we need other they can go here
     */
    private val subscriptionsBasedFilteredSubs =
        unfilteredSubscriptions.map { subs -> applyProvisioningFilter(subs) }.distinctUntilChanged()

    private fun applyProvisioningFilter(subs: List<SubscriptionModel>): List<SubscriptionModel> =
        if (!featureFlagsClassic.isEnabled(FILTER_PROVISIONING_NETWORK_SUBSCRIPTIONS)) {
            subs
        } else {
            subs.filter { it.profileClass != PROFILE_CLASS_PROVISIONING }
        }

    /**
     * Generally, SystemUI wants to show iconography for each subscription that is listed by
     * [SubscriptionManager]. However, in the case of opportunistic subscriptions, we want to only
@@ -177,26 +195,46 @@ constructor(
     */
    override val filteredSubscriptions: Flow<List<SubscriptionModel>> =
        combine(
                unfilteredSubscriptions,
                subscriptionsBasedFilteredSubs,
                mobileConnectionsRepo.activeMobileDataSubscriptionId,
                connectivityRepository.vcnSubId,
            ) { unfilteredSubs, activeId, vcnSubId ->
                filterSubsBasedOnOpportunistic(
                    unfilteredSubs,
                    activeId,
                    vcnSubId,
                )
            }
            .distinctUntilChanged()
            .logDiffsForTable(
                tableLogger,
                LOGGING_PREFIX,
                columnName = "filteredSubscriptions",
                initialValue = listOf(),
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), listOf())

    private fun filterSubsBasedOnOpportunistic(
        subList: List<SubscriptionModel>,
        activeId: Int?,
        vcnSubId: Int?,
    ): List<SubscriptionModel> {
        // Based on the old logic,
                if (unfilteredSubs.size != 2) {
                    return@combine unfilteredSubs
        if (subList.size != 2) {
            return subList
        }

                val info1 = unfilteredSubs[0]
                val info2 = unfilteredSubs[1]
        val info1 = subList[0]
        val info2 = subList[1]

        // Filtering only applies to subscriptions in the same group
        if (info1.groupUuid == null || info1.groupUuid != info2.groupUuid) {
                    return@combine unfilteredSubs
            return subList
        }

        // If both subscriptions are primary, show both
        if (!info1.isOpportunistic && !info2.isOpportunistic) {
                    return@combine unfilteredSubs
            return subList
        }

        // NOTE: at this point, we are now returning a single SubscriptionInfo
@@ -205,7 +243,7 @@ constructor(
        // Otherwise, show whichever subscription is currently active for internet.
        if (carrierConfigTracker.alwaysShowPrimarySignalBarInOpportunisticNetworkDefault) {
            // return the non-opportunistic info
                    return@combine if (info1.isOpportunistic) listOf(info2) else listOf(info1)
            return if (info1.isOpportunistic) listOf(info2) else listOf(info1)
        } else {
            // It's possible for the subId of the VCN to disagree with the active subId in
            // cases where the system has tried to switch but found no connection. In these
@@ -213,21 +251,13 @@ constructor(
            // value instead of the activeId reported by telephony
            val subIdToKeep = vcnSubId ?: activeId

                    return@combine if (info1.subscriptionId == subIdToKeep) {
            return if (info1.subscriptionId == subIdToKeep) {
                listOf(info1)
            } else {
                listOf(info2)
            }
        }
    }
            .distinctUntilChanged()
            .logDiffsForTable(
                tableLogger,
                LOGGING_PREFIX,
                columnName = "filteredSubscriptions",
                initialValue = listOf(),
            )
            .stateIn(scope, SharingStarted.WhileSubscribed(), listOf())

    /**
     * Copied from the old pipeline. We maintain a 2s period of time where we will keep the
Loading