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

Commit 13aea129 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "cherrypicker-L47300030003679955:N39400030059667042" into 24D1-dev

* changes:
  [SB][Sat] Never show icons for NTN-only subscriptions.
  [SB][Tech Debt] Refactor MobileIconsInteractorTest to better flow APIs.
parents 4d228b1c cc949afe
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -33,6 +33,18 @@ data class SubscriptionModel(
     */
    val isOpportunistic: Boolean = false,

    /**
     * True if this subscription **only** supports non-terrestrial networks (NTN) and false
     * otherwise. (non-terrestrial == satellite)
     *
     * Note that we intend to filter these subscriptions out, because these connections are actually
     * supported by
     * [com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository]. See
     * [com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor] for
     * the filtering.
     */
    val isExclusivelyNonTerrestrial: Boolean = false,

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

+12 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionState
import com.android.systemui.statusbar.pipeline.mobile.data.model.NetworkNameModel
import com.android.systemui.statusbar.pipeline.mobile.data.model.ResolvedNetworkType
import com.android.systemui.statusbar.pipeline.mobile.data.model.SubscriptionModel
import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel
import kotlinx.coroutines.flow.StateFlow

@@ -76,7 +77,17 @@ interface MobileConnectionRepository {
     */
    val isInService: StateFlow<Boolean>

    /** Reflects [android.telephony.ServiceState.isUsingNonTerrestrialNetwork] */
    /**
     * True if this subscription is actively connected to a non-terrestrial network and false
     * otherwise. Reflects [android.telephony.ServiceState.isUsingNonTerrestrialNetwork].
     *
     * Notably: This value reflects that this subscription is **currently** using a non-terrestrial
     * network, because some subscriptions can switch between terrestrial and non-terrestrial
     * networks. [SubscriptionModel.isExclusivelyNonTerrestrial] reflects whether a subscription is
     * configured to exclusively connect to non-terrestrial networks. [isNonTerrestrial] can change
     * during the lifetime of a subscription but [SubscriptionModel.isExclusivelyNonTerrestrial]
     * will stay constant.
     */
    val isNonTerrestrial: StateFlow<Boolean>

    /** True if [android.telephony.SignalStrength] told us that this connection is using GSM */
+1 −0
Original line number Diff line number Diff line
@@ -417,6 +417,7 @@ constructor(
        SubscriptionModel(
            subscriptionId = subscriptionId,
            isOpportunistic = isOpportunistic,
            isExclusivelyNonTerrestrial = isOnlyNonTerrestrialNetwork,
            groupUuid = groupUuid,
            carrierName = carrierName.toString(),
            profileClass = profileClass,
+22 −14
Original line number Diff line number Diff line
@@ -172,18 +172,30 @@ 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
     */
    /** Any filtering that we can do based purely on the info of each subscription individually. */
    private val subscriptionsBasedFilteredSubs =
        unfilteredSubscriptions.map { subs -> applyProvisioningFilter(subs) }.distinctUntilChanged()
        unfilteredSubscriptions
            .map { it.filterBasedOnProvisioning().filterBasedOnNtn() }
            .distinctUntilChanged()

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

    /**
     * Subscriptions that exclusively support non-terrestrial networks should **never** directly
     * show any iconography in the status bar. These subscriptions only exist to provide a backing
     * for the device-based satellite connections, and the iconography for those connections are
     * already being handled in
     * [com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository]. We
     * need to filter out those subscriptions here so we guarantee the subscription never turns into
     * an icon. See b/336881301.
     */
    private fun List<SubscriptionModel>.filterBasedOnNtn(): List<SubscriptionModel> {
        return this.filter { !it.isExclusivelyNonTerrestrial }
    }

    /**
@@ -204,12 +216,8 @@ constructor(
                subscriptionsBasedFilteredSubs,
                mobileConnectionsRepo.activeMobileDataSubscriptionId,
                connectivityRepository.vcnSubId,
            ) { unfilteredSubs, activeId, vcnSubId ->
                filterSubsBasedOnOpportunistic(
                    unfilteredSubs,
                    activeId,
                    vcnSubId,
                )
            ) { preFilteredSubs, activeId, vcnSubId ->
                filterSubsBasedOnOpportunistic(preFilteredSubs, activeId, vcnSubId)
            }
            .distinctUntilChanged()
            .logDiffsForTable(
+44 −0
Original line number Diff line number Diff line
@@ -271,6 +271,50 @@ class MobileConnectionsRepositoryTest : SysuiTestCase() {
            assertThat(latest).isEqualTo(listOf(MODEL_2))
        }

    @Test
    fun subscriptions_subIsOnlyNtn_modelHasExclusivelyNtnTrue() =
        testScope.runTest {
            val latest by collectLastValue(underTest.subscriptions)

            val onlyNtnSub =
                mock<SubscriptionInfo>().also {
                    whenever(it.isOnlyNonTerrestrialNetwork).thenReturn(true)
                    whenever(it.subscriptionId).thenReturn(45)
                    whenever(it.groupUuid).thenReturn(GROUP_1)
                    whenever(it.carrierName).thenReturn("NTN only")
                    whenever(it.profileClass).thenReturn(PROFILE_CLASS_UNSET)
                }

            whenever(subscriptionManager.completeActiveSubscriptionInfoList)
                .thenReturn(listOf(onlyNtnSub))
            getSubscriptionCallback().onSubscriptionsChanged()

            assertThat(latest).hasSize(1)
            assertThat(latest!![0].isExclusivelyNonTerrestrial).isTrue()
        }

    @Test
    fun subscriptions_subIsNotOnlyNtn_modelHasExclusivelyNtnFalse() =
        testScope.runTest {
            val latest by collectLastValue(underTest.subscriptions)

            val notOnlyNtnSub =
                mock<SubscriptionInfo>().also {
                    whenever(it.isOnlyNonTerrestrialNetwork).thenReturn(false)
                    whenever(it.subscriptionId).thenReturn(45)
                    whenever(it.groupUuid).thenReturn(GROUP_1)
                    whenever(it.carrierName).thenReturn("NTN only")
                    whenever(it.profileClass).thenReturn(PROFILE_CLASS_UNSET)
                }

            whenever(subscriptionManager.completeActiveSubscriptionInfoList)
                .thenReturn(listOf(notOnlyNtnSub))
            getSubscriptionCallback().onSubscriptionsChanged()

            assertThat(latest).hasSize(1)
            assertThat(latest!![0].isExclusivelyNonTerrestrial).isFalse()
        }

    @Test
    fun testSubscriptions_carrierMergedOnly_listHasCarrierMerged() =
        testScope.runTest {
Loading