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

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

Merge changes I4ea75eeb,Ifbbd7eee into main

* changes:
  [Status bar] Move to TelephonyDisplayInfo.isRoaming
  [Status bar] Define flag for migrating to TelephonyDisplayInfo.isRoaming()
parents 302a5ca5 0d1ae2d3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -326,6 +326,10 @@ object Flags {
    // TODO(b/301610137): Tracking bug
    @JvmField val NEW_NETWORK_SLICE_UI = releasedFlag("new_network_slice_ui")

    // TODO(b/311222557): Tracking bug
    val ROAMING_INDICATOR_VIA_DISPLAY_INFO =
        releasedFlag("roaming_indicator_via_display_info")

    // TODO(b/308138154): Tracking bug
    val FILTER_PROVISIONING_NETWORK_SUBSCRIPTIONS =
        releasedFlag("filter_provisioning_network_subscriptions")
+2 −1
Original line number Diff line number Diff line
@@ -109,8 +109,9 @@ constructor(
            {
                int1 = subId
                str1 = displayInfo.toString()
                bool1 = displayInfo.isRoaming
            },
            { "onDisplayInfoChanged: subId=$int1 displayInfo=$str1" },
            { "onDisplayInfoChanged: subId=$int1 displayInfo=$str1 isRoaming=$bool1" },
        )
    }

+14 −3
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ import com.android.systemui.broadcast.BroadcastDispatcher
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.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags.ROAMING_INDICATOR_VIA_DISPLAY_INFO
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.statusbar.pipeline.mobile.data.MobileInputLogger
import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionState.Disconnected
@@ -105,6 +107,7 @@ class MobileConnectionRepositoryImpl(
    private val bgDispatcher: CoroutineDispatcher,
    logger: MobileInputLogger,
    override val tableLogBuffer: TableLogBuffer,
    flags: FeatureFlagsClassic,
    scope: CoroutineScope,
) : MobileConnectionRepository {
    init {
@@ -201,9 +204,15 @@ class MobileConnectionRepositoryImpl(
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)

    override val isRoaming =
        if (flags.isEnabled(ROAMING_INDICATOR_VIA_DISPLAY_INFO)) {
                callbackEvents
                    .mapNotNull { it.onDisplayInfoChanged }
                    .map { it.telephonyDisplayInfo.isRoaming }
            } else {
                callbackEvents
                    .mapNotNull { it.onServiceStateChanged }
                    .map { it.serviceState.roaming }
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)

    override val operatorAlphaShort =
@@ -432,6 +441,7 @@ class MobileConnectionRepositoryImpl(
        private val logger: MobileInputLogger,
        private val carrierConfigRepository: CarrierConfigRepository,
        private val mobileMappingsProxy: MobileMappingsProxy,
        private val flags: FeatureFlagsClassic,
        @Background private val bgDispatcher: CoroutineDispatcher,
        @Application private val scope: CoroutineScope,
    ) {
@@ -456,6 +466,7 @@ class MobileConnectionRepositoryImpl(
                bgDispatcher,
                logger,
                mobileLogger,
                flags,
                scope,
            )
        }
+6 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.telephony.TelephonyManager
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.android.systemui.flags.Flags.ROAMING_INDICATOR_VIA_DISPLAY_INFO
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.TableLogBufferFactory
import com.android.systemui.statusbar.pipeline.mobile.data.model.NetworkNameModel
@@ -68,6 +70,9 @@ import org.mockito.Mockito.verify
class FullMobileConnectionRepositoryTest : SysuiTestCase() {
    private lateinit var underTest: FullMobileConnectionRepository

    private val flags =
        FakeFeatureFlagsClassic().also { it.set(ROAMING_INDICATOR_VIA_DISPLAY_INFO, true) }

    private val systemClock = FakeSystemClock()
    private val testDispatcher = UnconfinedTestDispatcher()
    private val testScope = TestScope(testDispatcher)
@@ -690,6 +695,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() {
                testDispatcher,
                logger = mock(),
                tableLogBuffer,
                flags,
                testScope.backgroundScope,
            )
        whenever(
+81 −1
Original line number Diff line number Diff line
@@ -35,7 +35,9 @@ import android.telephony.SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX
import android.telephony.SubscriptionManager.PROFILE_CLASS_UNSET
import android.telephony.TelephonyCallback
import android.telephony.TelephonyCallback.DataActivityListener
import android.telephony.TelephonyCallback.DisplayInfoListener
import android.telephony.TelephonyCallback.ServiceStateListener
import android.telephony.TelephonyDisplayInfo
import android.telephony.TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA
import android.telephony.TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE
import android.telephony.TelephonyManager
@@ -65,6 +67,8 @@ import androidx.test.filters.SmallTest
import com.android.settingslib.mobile.MobileMappings
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.android.systemui.flags.Flags.ROAMING_INDICATOR_VIA_DISPLAY_INFO
import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.statusbar.pipeline.mobile.data.MobileInputLogger
import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionState
@@ -111,6 +115,9 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
    private lateinit var underTest: MobileConnectionRepositoryImpl
    private lateinit var connectionsRepo: FakeMobileConnectionsRepository

    private val flags =
        FakeFeatureFlagsClassic().also { it.set(ROAMING_INDICATOR_VIA_DISPLAY_INFO, true) }

    @Mock private lateinit var connectivityManager: ConnectivityManager
    @Mock private lateinit var telephonyManager: TelephonyManager
    @Mock private lateinit var logger: MobileInputLogger
@@ -158,6 +165,7 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
                testDispatcher,
                logger,
                tableLogger,
                flags,
                testScope.backgroundScope,
            )
    }
@@ -610,8 +618,80 @@ class MobileConnectionRepositoryTest : SysuiTestCase() {
        }

    @Test
    fun roaming_gsm_queriesServiceState() =
    fun roaming_gsm_queriesDisplayInfo_viaDisplayInfo() =
        testScope.runTest {
            // GIVEN flag is true
            flags.set(ROAMING_INDICATOR_VIA_DISPLAY_INFO, true)

            // Re-create the repository, because the flag is read at init
            underTest =
                MobileConnectionRepositoryImpl(
                    SUB_1_ID,
                    context,
                    subscriptionModel,
                    DEFAULT_NAME_MODEL,
                    SEP,
                    connectivityManager,
                    telephonyManager,
                    systemUiCarrierConfig,
                    fakeBroadcastDispatcher,
                    mobileMappings,
                    testDispatcher,
                    logger,
                    tableLogger,
                    flags,
                    testScope.backgroundScope,
                )

            var latest: Boolean? = null
            val job = underTest.isRoaming.onEach { latest = it }.launchIn(this)

            val cb = getTelephonyCallbackForType<DisplayInfoListener>()

            // CDMA roaming is off, GSM roaming is off
            whenever(telephonyManager.cdmaEnhancedRoamingIndicatorDisplayNumber).thenReturn(ERI_OFF)
            cb.onDisplayInfoChanged(
                TelephonyDisplayInfo(NETWORK_TYPE_LTE, NETWORK_TYPE_UNKNOWN, false)
            )

            assertThat(latest).isFalse()

            // CDMA roaming is off, GSM roaming is on
            cb.onDisplayInfoChanged(
                TelephonyDisplayInfo(NETWORK_TYPE_LTE, NETWORK_TYPE_UNKNOWN, true)
            )

            assertThat(latest).isTrue()

            job.cancel()
        }

    @Test
    fun roaming_gsm_queriesDisplayInfo_viaServiceState() =
        testScope.runTest {
            // GIVEN flag is false
            flags.set(ROAMING_INDICATOR_VIA_DISPLAY_INFO, false)

            // Re-create the repository, because the flag is read at init
            underTest =
                MobileConnectionRepositoryImpl(
                    SUB_1_ID,
                    context,
                    subscriptionModel,
                    DEFAULT_NAME_MODEL,
                    SEP,
                    connectivityManager,
                    telephonyManager,
                    systemUiCarrierConfig,
                    fakeBroadcastDispatcher,
                    mobileMappings,
                    testDispatcher,
                    logger,
                    tableLogger,
                    flags,
                    testScope.backgroundScope,
                )

            var latest: Boolean? = null
            val job = underTest.isRoaming.onEach { latest = it }.launchIn(this)

Loading