Loading packages/SystemUI/src/com/android/systemui/flags/Flags.kt +4 −0 Original line number Diff line number Diff line Loading @@ -388,6 +388,10 @@ object Flags { // TODO(b/280426085): Tracking Bug @JvmField val NEW_BLUETOOTH_REPOSITORY = releasedFlag("new_bluetooth_repository") // TODO(b/311222557): Tracking bug val ROAMING_INDICATOR_VIA_DISPLAY_INFO = releasedFlag("roaming_indicator_via_display_info") // TODO(b/292533677): Tracking Bug val WIFI_TRACKER_LIB_FOR_WIFI_ICON = unreleasedFlag("wifi_tracker_lib_for_wifi_icon", teamfood = true) Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/MobileInputLogger.kt +2 −1 Original line number Diff line number Diff line Loading @@ -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" }, ) } Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt +14 −3 Original line number Diff line number Diff line Loading @@ -41,6 +41,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.FeatureFlags 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 Loading Loading @@ -97,6 +99,7 @@ class MobileConnectionRepositoryImpl( bgDispatcher: CoroutineDispatcher, logger: MobileInputLogger, override val tableLogBuffer: TableLogBuffer, flags: FeatureFlags, scope: CoroutineScope, ) : MobileConnectionRepository { init { Loading Loading @@ -192,9 +195,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 = Loading Loading @@ -380,6 +389,7 @@ class MobileConnectionRepositoryImpl( private val logger: MobileInputLogger, private val carrierConfigRepository: CarrierConfigRepository, private val mobileMappingsProxy: MobileMappingsProxy, private val flags: FeatureFlags, @Background private val bgDispatcher: CoroutineDispatcher, @Application private val scope: CoroutineScope, ) { Loading @@ -403,6 +413,7 @@ class MobileConnectionRepositoryImpl( bgDispatcher, logger, mobileLogger, flags, scope, ) } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt +5 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,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.FakeFeatureFlags 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 Loading Loading @@ -66,6 +68,8 @@ import org.mockito.Mockito.verify class FullMobileConnectionRepositoryTest : SysuiTestCase() { private lateinit var underTest: FullMobileConnectionRepository private val flags = FakeFeatureFlags().also { it.set(ROAMING_INDICATOR_VIA_DISPLAY_INFO, true) } private val systemClock = FakeSystemClock() private val testDispatcher = UnconfinedTestDispatcher() private val testScope = TestScope(testDispatcher) Loading Loading @@ -685,6 +689,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() { testDispatcher, logger = mock(), tableLogBuffer, flags, testScope.backgroundScope, ) whenever( Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryTest.kt +78 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,9 @@ import android.telephony.ServiceState.STATE_OUT_OF_SERVICE import android.telephony.SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX 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 Loading Loading @@ -58,6 +60,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.FakeFeatureFlags 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 Loading Loading @@ -103,6 +107,8 @@ class MobileConnectionRepositoryTest : SysuiTestCase() { private lateinit var underTest: MobileConnectionRepositoryImpl private lateinit var connectionsRepo: FakeMobileConnectionsRepository private val flags = FakeFeatureFlags().also { it.set(ROAMING_INDICATOR_VIA_DISPLAY_INFO, true) } @Mock private lateinit var telephonyManager: TelephonyManager @Mock private lateinit var logger: MobileInputLogger @Mock private lateinit var tableLogger: TableLogBuffer Loading Loading @@ -147,6 +153,7 @@ class MobileConnectionRepositoryTest : SysuiTestCase() { testDispatcher, logger, tableLogger, flags, testScope.backgroundScope, ) } Loading Loading @@ -599,8 +606,78 @@ 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, 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, telephonyManager, systemUiCarrierConfig, fakeBroadcastDispatcher, mobileMappings, testDispatcher, logger, tableLogger, flags, testScope.backgroundScope, ) var latest: Boolean? = null val job = underTest.isRoaming.onEach { latest = it }.launchIn(this) Loading Loading
packages/SystemUI/src/com/android/systemui/flags/Flags.kt +4 −0 Original line number Diff line number Diff line Loading @@ -388,6 +388,10 @@ object Flags { // TODO(b/280426085): Tracking Bug @JvmField val NEW_BLUETOOTH_REPOSITORY = releasedFlag("new_bluetooth_repository") // TODO(b/311222557): Tracking bug val ROAMING_INDICATOR_VIA_DISPLAY_INFO = releasedFlag("roaming_indicator_via_display_info") // TODO(b/292533677): Tracking Bug val WIFI_TRACKER_LIB_FOR_WIFI_ICON = unreleasedFlag("wifi_tracker_lib_for_wifi_icon", teamfood = true) Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/MobileInputLogger.kt +2 −1 Original line number Diff line number Diff line Loading @@ -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" }, ) } Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt +14 −3 Original line number Diff line number Diff line Loading @@ -41,6 +41,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.FeatureFlags 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 Loading Loading @@ -97,6 +99,7 @@ class MobileConnectionRepositoryImpl( bgDispatcher: CoroutineDispatcher, logger: MobileInputLogger, override val tableLogBuffer: TableLogBuffer, flags: FeatureFlags, scope: CoroutineScope, ) : MobileConnectionRepository { init { Loading Loading @@ -192,9 +195,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 = Loading Loading @@ -380,6 +389,7 @@ class MobileConnectionRepositoryImpl( private val logger: MobileInputLogger, private val carrierConfigRepository: CarrierConfigRepository, private val mobileMappingsProxy: MobileMappingsProxy, private val flags: FeatureFlags, @Background private val bgDispatcher: CoroutineDispatcher, @Application private val scope: CoroutineScope, ) { Loading @@ -403,6 +413,7 @@ class MobileConnectionRepositoryImpl( bgDispatcher, logger, mobileLogger, flags, scope, ) } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt +5 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,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.FakeFeatureFlags 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 Loading Loading @@ -66,6 +68,8 @@ import org.mockito.Mockito.verify class FullMobileConnectionRepositoryTest : SysuiTestCase() { private lateinit var underTest: FullMobileConnectionRepository private val flags = FakeFeatureFlags().also { it.set(ROAMING_INDICATOR_VIA_DISPLAY_INFO, true) } private val systemClock = FakeSystemClock() private val testDispatcher = UnconfinedTestDispatcher() private val testScope = TestScope(testDispatcher) Loading Loading @@ -685,6 +689,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() { testDispatcher, logger = mock(), tableLogBuffer, flags, testScope.backgroundScope, ) whenever( Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryTest.kt +78 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,9 @@ import android.telephony.ServiceState.STATE_OUT_OF_SERVICE import android.telephony.SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX 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 Loading Loading @@ -58,6 +60,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.FakeFeatureFlags 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 Loading Loading @@ -103,6 +107,8 @@ class MobileConnectionRepositoryTest : SysuiTestCase() { private lateinit var underTest: MobileConnectionRepositoryImpl private lateinit var connectionsRepo: FakeMobileConnectionsRepository private val flags = FakeFeatureFlags().also { it.set(ROAMING_INDICATOR_VIA_DISPLAY_INFO, true) } @Mock private lateinit var telephonyManager: TelephonyManager @Mock private lateinit var logger: MobileInputLogger @Mock private lateinit var tableLogger: TableLogBuffer Loading Loading @@ -147,6 +153,7 @@ class MobileConnectionRepositoryTest : SysuiTestCase() { testDispatcher, logger, tableLogger, flags, testScope.backgroundScope, ) } Loading Loading @@ -599,8 +606,78 @@ 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, 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, telephonyManager, systemUiCarrierConfig, fakeBroadcastDispatcher, mobileMappings, testDispatcher, logger, tableLogger, flags, testScope.backgroundScope, ) var latest: Boolean? = null val job = underTest.isRoaming.onEach { latest = it }.launchIn(this) Loading