diff options
2 files changed, 14 insertions, 2 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalRepositoryImplTest.kt index 45e7d8a43c2a..fd0bf4dae198 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalRepositoryImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalRepositoryImplTest.kt @@ -41,6 +41,7 @@ class CommunalRepositoryImplTest : SysuiTestCase() { private val underTest by lazy { CommunalSceneRepositoryImpl( kosmos.applicationCoroutineScope, + kosmos.applicationCoroutineScope, kosmos.sceneDataSource, ) } diff --git a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt index d6d08b4f1208..260dcbad6201 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt @@ -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,11 +85,19 @@ constructor( ) override fun changeScene(toScene: SceneKey, transitionKey: TransitionKey?) { - sceneDataSource.changeScene(toScene, 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) { - sceneDataSource.snapToScene(toScene) + applicationScope.launch { + // SceneTransitionLayout state updates must be triggered on the thread the STL was + // created on. + sceneDataSource.snapToScene(toScene) + } } /** |