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

Commit 06fefe18 authored by Devarshi Bhatt's avatar Devarshi Bhatt
Browse files

Run kotlin CallbackFlow on background dispatcher.

Test: manually monitor APC once change is merged
Bug: 316127933
Flag: NONE
Change-Id: Ic13c240947fd04fa39f8427d533b9ea769500b05
parent 45309ae3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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(
+20 −18
Original line number Diff line number Diff line
@@ -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,8 +45,9 @@ 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() }
    override fun areAnimationsEnabled(): Flow<Boolean> =
        conflatedCallbackFlow {
                val initialValue = resolver.areAnimationsEnabled()
                trySend(initialValue)

                val observer =
@@ -65,4 +66,5 @@ constructor(

                awaitClose { resolver.unregisterContentObserver(observer) }
            }
            .flowOn(backgroundDispatcher)
}