summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/CustomizationProviderClient.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/animation/data/repository/AnimationStatusRepository.kt38
2 files changed, 22 insertions, 18 deletions
diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/CustomizationProviderClient.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/CustomizationProviderClient.kt
index e0506046ee54..34c4dfb4bc54 100644
--- a/packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/CustomizationProviderClient.kt
+++ b/packages/SystemUI/customization/src/com/android/systemui/shared/customization/data/content/CustomizationProviderClient.kt
@@ -33,6 +33,7 @@ import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
+import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.withContext
@@ -518,6 +519,7 @@ class CustomizationProviderClientImpl(
awaitClose { context.contentResolver.unregisterContentObserver(observer) }
}
.onStart { emit(Unit) }
+ .flowOn(backgroundDispatcher)
}
private fun String.toIntent(
diff --git a/packages/SystemUI/src/com/android/systemui/util/animation/data/repository/AnimationStatusRepository.kt b/packages/SystemUI/src/com/android/systemui/util/animation/data/repository/AnimationStatusRepository.kt
index adae782eeb98..31a8d864de95 100644
--- a/packages/SystemUI/src/com/android/systemui/util/animation/data/repository/AnimationStatusRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/animation/data/repository/AnimationStatusRepository.kt
@@ -26,7 +26,7 @@ import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.flow.flowOn
/** Utility class that could give information about if animation are enabled in the system */
interface AnimationStatusRepository {
@@ -45,24 +45,26 @@ constructor(
* Emits true if animations are enabled in the system, after subscribing it immediately emits
* the current state
*/
- override fun areAnimationsEnabled(): Flow<Boolean> = conflatedCallbackFlow {
- val initialValue = withContext(backgroundDispatcher) { resolver.areAnimationsEnabled() }
- trySend(initialValue)
+ override fun areAnimationsEnabled(): Flow<Boolean> =
+ conflatedCallbackFlow {
+ val initialValue = resolver.areAnimationsEnabled()
+ trySend(initialValue)
- val observer =
- object : ContentObserver(backgroundHandler) {
- override fun onChange(selfChange: Boolean) {
- val updatedValue = resolver.areAnimationsEnabled()
- trySend(updatedValue)
- }
- }
+ val observer =
+ object : ContentObserver(backgroundHandler) {
+ override fun onChange(selfChange: Boolean) {
+ val updatedValue = resolver.areAnimationsEnabled()
+ trySend(updatedValue)
+ }
+ }
- resolver.registerContentObserver(
- Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE),
- /* notifyForDescendants= */ false,
- observer
- )
+ resolver.registerContentObserver(
+ Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE),
+ /* notifyForDescendants= */ false,
+ observer
+ )
- awaitClose { resolver.unregisterContentObserver(observer) }
- }
+ awaitClose { resolver.unregisterContentObserver(observer) }
+ }
+ .flowOn(backgroundDispatcher)
}