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

Commit 8b96d8b7 authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Fixes destinationScene-related crash when swiping." into main

parents 9820a62b 991d4df1
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -37,8 +37,6 @@ import androidx.compose.ui.input.pointer.pointerInput
import com.android.compose.animation.scene.MutableSceneTransitionLayoutState
import com.android.compose.animation.scene.SceneKey
import com.android.compose.animation.scene.SceneTransitionLayout
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
import com.android.compose.animation.scene.observableTransitionState
import com.android.systemui.ribbon.ui.composable.BottomRightCornerRibbon
import com.android.systemui.scene.shared.model.SceneDataSourceDelegator
@@ -71,9 +69,7 @@ fun SceneContainer(
) {
    val coroutineScope = rememberCoroutineScope()
    val currentSceneKey: SceneKey by viewModel.currentScene.collectAsState()
    val currentScene = checkNotNull(sceneByKey[currentSceneKey])
    val currentDestinations: Map<UserAction, UserActionResult> by
        currentScene.destinationScenes.collectAsState()
    val currentDestinations by viewModel.currentDestinationScenes(coroutineScope).collectAsState()
    val state: MutableSceneTransitionLayoutState = remember {
        MutableSceneTransitionLayoutState(
            initialScene = currentSceneKey,
+4 −1
Original line number Diff line number Diff line
@@ -59,7 +59,10 @@ internal class Scene(
    ): Map<UserAction, UserActionResult> {
        userActions.forEach { (action, result) ->
            if (key == result.toScene) {
                error("Transition to the same scene is not supported. Scene $key, action $action")
                error(
                    "Transition to the same scene is not supported. Scene $key, action $action," +
                        " result $result"
                )
            }
        }
        return userActions
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ class QuickSettingsSceneViewModelTest : SysuiTestCase() {
            val destinations by collectLastValue(underTest.destinationScenes)

            val currentScene by collectLastValue(sceneInteractor.currentScene)
            val previousScene by collectLastValue(sceneInteractor.previousScene)
            val previousScene by collectLastValue(sceneInteractor.previousScene())
            sceneInteractor.changeScene(Scenes.Lockscreen, "reason")
            sceneInteractor.changeScene(Scenes.QuickSettings, "reason")
            assertThat(currentScene).isEqualTo(Scenes.QuickSettings)
+1 −0
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ class SceneFrameworkIntegrationTest : SysuiTestCase() {
                sceneInteractor = sceneInteractor,
                falsingInteractor = kosmos.falsingInteractor,
                powerInteractor = kosmos.powerInteractor,
                scenes = kosmos.scenes,
            )
            .apply { setTransitionState(transitionState) }
    }
+16 −1
Original line number Diff line number Diff line
@@ -296,7 +296,7 @@ class SceneInteractorTest : SysuiTestCase() {
    fun previousScene() =
        testScope.runTest {
            val currentScene by collectLastValue(underTest.currentScene)
            val previousScene by collectLastValue(underTest.previousScene)
            val previousScene by collectLastValue(underTest.previousScene())
            assertThat(previousScene).isNull()

            val firstScene = currentScene
@@ -306,4 +306,19 @@ class SceneInteractorTest : SysuiTestCase() {
            underTest.changeScene(toScene = Scenes.QuickSettings, "reason")
            assertThat(previousScene).isEqualTo(Scenes.Shade)
        }

    @Test
    fun previousScene_withIgnoredScene() =
        testScope.runTest {
            val currentScene by collectLastValue(underTest.currentScene)
            val previousScene by collectLastValue(underTest.previousScene(ignored = Scenes.Shade))
            assertThat(previousScene).isNull()

            val firstScene = currentScene
            underTest.changeScene(toScene = Scenes.Shade, "reason")
            assertThat(previousScene).isEqualTo(firstScene)

            underTest.changeScene(toScene = Scenes.QuickSettings, "reason")
            assertThat(previousScene).isNull()
        }
}
Loading