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

Commit 3c86dbb6 authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge "Move changeScene calls to the application scope" into main

parents 90eefa68 3cb501f2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ class CommunalRepositoryImplTest : SysuiTestCase() {
    private val testScope = kosmos.testScope
    private val underTest by lazy {
        CommunalSceneRepositoryImpl(
            kosmos.applicationCoroutineScope,
            kosmos.applicationCoroutineScope,
            kosmos.sceneDataSource,
        )
+13 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.android.compose.animation.scene.TransitionKey
import com.android.systemui.communal.dagger.Communal
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.scene.shared.model.SceneDataSource
import javax.inject.Inject
@@ -34,6 +35,7 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch

/** Encapsulates the state of communal mode. */
interface CommunalSceneRepository {
@@ -64,6 +66,7 @@ interface CommunalSceneRepository {
class CommunalSceneRepositoryImpl
@Inject
constructor(
    @Application private val applicationScope: CoroutineScope,
    @Background backgroundScope: CoroutineScope,
    @Communal private val sceneDataSource: SceneDataSource,
) : CommunalSceneRepository {
@@ -82,12 +85,20 @@ constructor(
            )

    override fun changeScene(toScene: SceneKey, transitionKey: TransitionKey?) {
        applicationScope.launch {
            // SceneTransitionLayout state updates must be triggered on the thread the STL was
            // created on.
            sceneDataSource.changeScene(toScene, transitionKey)
        }
    }

    override fun snapToScene(toScene: SceneKey) {
        applicationScope.launch {
            // SceneTransitionLayout state updates must be triggered on the thread the STL was
            // created on.
            sceneDataSource.snapToScene(toScene)
        }
    }

    /**
     * Updates the transition state of the hub [SceneTransitionLayout].