diff options
| author | 2023-09-26 17:04:23 +0000 | |
|---|---|---|
| committer | 2023-09-26 17:04:23 +0000 | |
| commit | 8cf34a88f5c3a8f5dcbb49aa5d2e47d55be8fac8 (patch) | |
| tree | bd82eb159150a707b3533f0d9e69a8db6f4709ea | |
| parent | 8332b3c06f18a4d5c44468261aea317ad2533974 (diff) | |
| parent | e702a34a01d82d9e8183d9b7308406575aa434d4 (diff) | |
Merge "[Sb] flowOn(bgDispatcher) to IPC calls" into main
2 files changed, 20 insertions, 14 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt index cd6862113ee9..dc50990d002a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionRepositoryImpl.kt @@ -71,6 +71,7 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.flow.mapNotNull @@ -181,6 +182,7 @@ class MobileConnectionRepositoryImpl( telephonyManager.registerTelephonyCallback(bgDispatcher.asExecutor(), callback) awaitClose { telephonyManager.unregisterTelephonyCallback(callback) } } + .flowOn(bgDispatcher) .scan(initial = initial) { state, event -> state.applyEvent(event) } .stateIn(scope = scope, started = SharingStarted.WhileSubscribed(), initial) } @@ -358,6 +360,7 @@ class MobileConnectionRepositoryImpl( awaitClose { context.unregisterReceiver(receiver) } } + .flowOn(bgDispatcher) .stateIn(scope, SharingStarted.WhileSubscribed(), defaultNetworkName) override val dataEnabled = run { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt index 74a849a8c01f..ec54f08c9d7e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/MobileConnectionsRepositoryImpl.kt @@ -134,22 +134,24 @@ constructor( ) .stateIn(scope, started = SharingStarted.WhileSubscribed(), null) - private val mobileSubscriptionsChangeEvent: Flow<Unit> = conflatedCallbackFlow { - val callback = - object : SubscriptionManager.OnSubscriptionsChangedListener() { - override fun onSubscriptionsChanged() { - logger.logOnSubscriptionsChanged() - trySend(Unit) - } - } + private val mobileSubscriptionsChangeEvent: Flow<Unit> = + conflatedCallbackFlow { + val callback = + object : SubscriptionManager.OnSubscriptionsChangedListener() { + override fun onSubscriptionsChanged() { + logger.logOnSubscriptionsChanged() + trySend(Unit) + } + } - subscriptionManager.addOnSubscriptionsChangedListener( - bgDispatcher.asExecutor(), - callback, - ) + subscriptionManager.addOnSubscriptionsChangedListener( + bgDispatcher.asExecutor(), + callback, + ) - awaitClose { subscriptionManager.removeOnSubscriptionsChangedListener(callback) } - } + awaitClose { subscriptionManager.removeOnSubscriptionsChangedListener(callback) } + } + .flowOn(bgDispatcher) /** * State flow that emits the set of mobile data subscriptions, each represented by its own @@ -184,6 +186,7 @@ constructor( telephonyManager.registerTelephonyCallback(bgDispatcher.asExecutor(), callback) awaitClose { telephonyManager.unregisterTelephonyCallback(callback) } } + .flowOn(bgDispatcher) .distinctUntilChanged() .logDiffsForTable( tableLogger, |