Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/model/NetworkNameModel.kt +21 −5 Original line number Diff line number Diff line Loading @@ -48,15 +48,31 @@ sealed interface NetworkNameModel : Diffable<NetworkNameModel> { * This name has been derived from telephony intents. see * [android.telephony.TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED] */ data class Derived(override val name: String) : NetworkNameModel { data class IntentDerived(override val name: String) : NetworkNameModel { override fun logDiffs(prevVal: NetworkNameModel, row: TableRowLogger) { if (prevVal !is Derived || prevVal.name != name) { row.logChange(COL_NETWORK_NAME, "Derived($name)") if (prevVal !is IntentDerived || prevVal.name != name) { row.logChange(COL_NETWORK_NAME, "IntentDerived($name)") } } override fun logFull(row: TableRowLogger) { row.logChange(COL_NETWORK_NAME, "Derived($name)") row.logChange(COL_NETWORK_NAME, "IntentDerived($name)") } } /** * This name has been derived from the sim via * [android.telephony.TelephonyManager.getSimOperatorName]. */ data class SimDerived(override val name: String) : NetworkNameModel { override fun logDiffs(prevVal: NetworkNameModel, row: TableRowLogger) { if (prevVal !is SimDerived || prevVal.name != name) { row.logChange(COL_NETWORK_NAME, "SimDerived($name)") } } override fun logFull(row: TableRowLogger) { row.logChange(COL_NETWORK_NAME, "SimDerived($name)") } } Loading Loading @@ -84,5 +100,5 @@ fun Intent.toNetworkNameModel(separator: String): NetworkNameModel? { str.append(spn) } return if (str.isNotEmpty()) NetworkNameModel.Derived(str.toString()) else null return if (str.isNotEmpty()) NetworkNameModel.IntentDerived(str.toString()) else null } packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionsRepository.kt +3 −3 Original line number Diff line number Diff line Loading @@ -240,7 +240,7 @@ constructor( // This is always true here, because we split out disabled states at the data-source level connection.dataEnabled.value = true connection.networkName.value = NetworkNameModel.Derived(state.name) connection.networkName.value = NetworkNameModel.IntentDerived(state.name) connection.cdmaRoaming.value = state.roaming connection.connectionInfo.value = state.toMobileConnectionModel() Loading @@ -264,7 +264,7 @@ constructor( val connection = getRepoForSubId(subId) // This is always true here, because we split out disabled states at the data-source level connection.dataEnabled.value = true connection.networkName.value = NetworkNameModel.Derived(CARRIER_MERGED_NAME) connection.networkName.value = NetworkNameModel.IntentDerived(CARRIER_MERGED_NAME) connection.numberOfLevels.value = event.numberOfLevels connection.cdmaRoaming.value = false connection.connectionInfo.value = event.toMobileConnectionModel() Loading Loading @@ -377,5 +377,5 @@ class DemoMobileConnectionRepository( override val cdmaRoaming = MutableStateFlow(false) override val networkName = MutableStateFlow(NetworkNameModel.Derived("demo network")) override val networkName = MutableStateFlow(NetworkNameModel.IntentDerived("demo network")) } packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepository.kt +22 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.pipeline.mobile.data.repository.prod import android.telephony.TelephonyManager import android.util.Log import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application Loading @@ -37,7 +38,6 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn Loading @@ -54,10 +54,18 @@ import kotlinx.coroutines.flow.stateIn class CarrierMergedConnectionRepository( override val subId: Int, override val tableLogBuffer: TableLogBuffer, defaultNetworkName: NetworkNameModel, private val telephonyManager: TelephonyManager, @Application private val scope: CoroutineScope, val wifiRepository: WifiRepository, ) : MobileConnectionRepository { init { if (telephonyManager.subscriptionId != subId) { throw IllegalStateException( "CarrierMergedRepo: TelephonyManager should be created with subId($subId). " + "Found ${telephonyManager.subscriptionId} instead." ) } } /** * Outputs the carrier merged network to use, or null if we don't have a valid carrier merged Loading Loading @@ -98,10 +106,17 @@ class CarrierMergedConnectionRepository( override val cdmaRoaming: StateFlow<Boolean> = MutableStateFlow(ROAMING).asStateFlow() // TODO(b/238425913): Fetch the carrier merged network name. override val networkName: StateFlow<NetworkNameModel> = flowOf(defaultNetworkName) .stateIn(scope, SharingStarted.WhileSubscribed(), defaultNetworkName) network // The SIM operator name should be the same throughout the lifetime of a subId, **but** // it may not be available when this repo is created because it takes time to load. To // be safe, we re-fetch it each time the network has changed. .map { NetworkNameModel.SimDerived(telephonyManager.simOperatorName) } .stateIn( scope, SharingStarted.WhileSubscribed(), NetworkNameModel.SimDerived(telephonyManager.simOperatorName), ) override val numberOfLevels: StateFlow<Int> = wifiRepository.wifiNetwork Loading Loading @@ -150,18 +165,18 @@ class CarrierMergedConnectionRepository( class Factory @Inject constructor( private val telephonyManager: TelephonyManager, @Application private val scope: CoroutineScope, private val wifiRepository: WifiRepository, ) { fun build( subId: Int, mobileLogger: TableLogBuffer, defaultNetworkName: NetworkNameModel, ): MobileConnectionRepository { return CarrierMergedConnectionRepository( subId, mobileLogger, defaultNetworkName, telephonyManager.createForSubscriptionId(subId), scope, wifiRepository, ) Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ class FullMobileConnectionRepository( } private val carrierMergedRepo: MobileConnectionRepository by lazy { carrierMergedRepoFactory.build(subId, tableLogBuffer, defaultNetworkName) carrierMergedRepoFactory.build(subId, tableLogBuffer) } @VisibleForTesting Loading packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ class MobileConnectionRepositoryImpl( init { if (telephonyManager.subscriptionId != subId) { throw IllegalStateException( "TelephonyManager should be created with subId($subId). " + "MobileRepo: TelephonyManager should be created with subId($subId). " + "Found ${telephonyManager.subscriptionId} instead." ) } Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/model/NetworkNameModel.kt +21 −5 Original line number Diff line number Diff line Loading @@ -48,15 +48,31 @@ sealed interface NetworkNameModel : Diffable<NetworkNameModel> { * This name has been derived from telephony intents. see * [android.telephony.TelephonyManager.ACTION_SERVICE_PROVIDERS_UPDATED] */ data class Derived(override val name: String) : NetworkNameModel { data class IntentDerived(override val name: String) : NetworkNameModel { override fun logDiffs(prevVal: NetworkNameModel, row: TableRowLogger) { if (prevVal !is Derived || prevVal.name != name) { row.logChange(COL_NETWORK_NAME, "Derived($name)") if (prevVal !is IntentDerived || prevVal.name != name) { row.logChange(COL_NETWORK_NAME, "IntentDerived($name)") } } override fun logFull(row: TableRowLogger) { row.logChange(COL_NETWORK_NAME, "Derived($name)") row.logChange(COL_NETWORK_NAME, "IntentDerived($name)") } } /** * This name has been derived from the sim via * [android.telephony.TelephonyManager.getSimOperatorName]. */ data class SimDerived(override val name: String) : NetworkNameModel { override fun logDiffs(prevVal: NetworkNameModel, row: TableRowLogger) { if (prevVal !is SimDerived || prevVal.name != name) { row.logChange(COL_NETWORK_NAME, "SimDerived($name)") } } override fun logFull(row: TableRowLogger) { row.logChange(COL_NETWORK_NAME, "SimDerived($name)") } } Loading Loading @@ -84,5 +100,5 @@ fun Intent.toNetworkNameModel(separator: String): NetworkNameModel? { str.append(spn) } return if (str.isNotEmpty()) NetworkNameModel.Derived(str.toString()) else null return if (str.isNotEmpty()) NetworkNameModel.IntentDerived(str.toString()) else null }
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/demo/DemoMobileConnectionsRepository.kt +3 −3 Original line number Diff line number Diff line Loading @@ -240,7 +240,7 @@ constructor( // This is always true here, because we split out disabled states at the data-source level connection.dataEnabled.value = true connection.networkName.value = NetworkNameModel.Derived(state.name) connection.networkName.value = NetworkNameModel.IntentDerived(state.name) connection.cdmaRoaming.value = state.roaming connection.connectionInfo.value = state.toMobileConnectionModel() Loading @@ -264,7 +264,7 @@ constructor( val connection = getRepoForSubId(subId) // This is always true here, because we split out disabled states at the data-source level connection.dataEnabled.value = true connection.networkName.value = NetworkNameModel.Derived(CARRIER_MERGED_NAME) connection.networkName.value = NetworkNameModel.IntentDerived(CARRIER_MERGED_NAME) connection.numberOfLevels.value = event.numberOfLevels connection.cdmaRoaming.value = false connection.connectionInfo.value = event.toMobileConnectionModel() Loading Loading @@ -377,5 +377,5 @@ class DemoMobileConnectionRepository( override val cdmaRoaming = MutableStateFlow(false) override val networkName = MutableStateFlow(NetworkNameModel.Derived("demo network")) override val networkName = MutableStateFlow(NetworkNameModel.IntentDerived("demo network")) }
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepository.kt +22 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.pipeline.mobile.data.repository.prod import android.telephony.TelephonyManager import android.util.Log import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application Loading @@ -37,7 +38,6 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn Loading @@ -54,10 +54,18 @@ import kotlinx.coroutines.flow.stateIn class CarrierMergedConnectionRepository( override val subId: Int, override val tableLogBuffer: TableLogBuffer, defaultNetworkName: NetworkNameModel, private val telephonyManager: TelephonyManager, @Application private val scope: CoroutineScope, val wifiRepository: WifiRepository, ) : MobileConnectionRepository { init { if (telephonyManager.subscriptionId != subId) { throw IllegalStateException( "CarrierMergedRepo: TelephonyManager should be created with subId($subId). " + "Found ${telephonyManager.subscriptionId} instead." ) } } /** * Outputs the carrier merged network to use, or null if we don't have a valid carrier merged Loading Loading @@ -98,10 +106,17 @@ class CarrierMergedConnectionRepository( override val cdmaRoaming: StateFlow<Boolean> = MutableStateFlow(ROAMING).asStateFlow() // TODO(b/238425913): Fetch the carrier merged network name. override val networkName: StateFlow<NetworkNameModel> = flowOf(defaultNetworkName) .stateIn(scope, SharingStarted.WhileSubscribed(), defaultNetworkName) network // The SIM operator name should be the same throughout the lifetime of a subId, **but** // it may not be available when this repo is created because it takes time to load. To // be safe, we re-fetch it each time the network has changed. .map { NetworkNameModel.SimDerived(telephonyManager.simOperatorName) } .stateIn( scope, SharingStarted.WhileSubscribed(), NetworkNameModel.SimDerived(telephonyManager.simOperatorName), ) override val numberOfLevels: StateFlow<Int> = wifiRepository.wifiNetwork Loading Loading @@ -150,18 +165,18 @@ class CarrierMergedConnectionRepository( class Factory @Inject constructor( private val telephonyManager: TelephonyManager, @Application private val scope: CoroutineScope, private val wifiRepository: WifiRepository, ) { fun build( subId: Int, mobileLogger: TableLogBuffer, defaultNetworkName: NetworkNameModel, ): MobileConnectionRepository { return CarrierMergedConnectionRepository( subId, mobileLogger, defaultNetworkName, telephonyManager.createForSubscriptionId(subId), scope, wifiRepository, ) Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ class FullMobileConnectionRepository( } private val carrierMergedRepo: MobileConnectionRepository by lazy { carrierMergedRepoFactory.build(subId, tableLogBuffer, defaultNetworkName) carrierMergedRepoFactory.build(subId, tableLogBuffer) } @VisibleForTesting Loading
packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ class MobileConnectionRepositoryImpl( init { if (telephonyManager.subscriptionId != subId) { throw IllegalStateException( "TelephonyManager should be created with subId($subId). " + "MobileRepo: TelephonyManager should be created with subId($subId). " + "Found ${telephonyManager.subscriptionId} instead." ) } Loading