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

Commit 01f4dc5a authored by Andreas Miko's avatar Andreas Miko
Browse files

[Flexiglass] Fix KTF filter for instant reversed transitions

When in STL A -> B settles in A we can't do the same in KTF as KTF
requires us to start B -> A to get back to A.
[LockscreenSceneTransitionInteractor] will emit these steps but because
STL is Idle(A) at this point (and never even started a B -> A in the
first place) [isTransitioningBetweenDesiredScenes] will not be satisfied
. We need this condition to not filter out the STARTED and FINISHED step
 of the "artificially" reversed B -> A transition.

Test: tested manually cancelling the LS -> Bouncer transition
Bug: 379845752
Flag: com.android.systemui.scene_container
Change-Id: I289ae405ec792e3d31fd9d303acb8dc4fc85df28
parent bee9f829
Loading
Loading
Loading
Loading
+60 −3
Original line number Diff line number Diff line
@@ -995,12 +995,12 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {

            kosmos.setSceneTransition(Transition(Scenes.Gone, Scenes.Lockscreen))
            val sendStep1 = TransitionStep(LOCKSCREEN, UNDEFINED, 0f, STARTED)
            sendSteps(sendStep1)
            kosmos.setSceneTransition(Idle(Scenes.Gone))
            val sendStep2 = TransitionStep(LOCKSCREEN, UNDEFINED, 1f, FINISHED)
            sendSteps(sendStep1, sendStep2)
            kosmos.setSceneTransition(Idle(Scenes.Gone))
            val sendStep3 = TransitionStep(UNDEFINED, AOD, 0f, STARTED)
            val sendStep4 = TransitionStep(AOD, LOCKSCREEN, 0f, STARTED)
            sendSteps(sendStep2, sendStep3, sendStep4)
            sendSteps(sendStep3, sendStep4)

            assertEquals(listOf<TransitionStep>(), currentStatesMapped)
        }
@@ -1134,6 +1134,63 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {
            )
        }

    @Test
    @EnableSceneContainer
    fun transition_filter_on_belongsToInstantReversedTransition_out_of_lockscreen_scene() =
        testScope.runTest {
            val currentStatesMapped by
                collectValues(underTest.transition(Edge.create(LOCKSCREEN, Scenes.Gone)))

            kosmos.setSceneTransition(Transition(Scenes.Gone, Scenes.Lockscreen))
            val sendStep1 = TransitionStep(UNDEFINED, LOCKSCREEN, 0f, STARTED)
            kosmos.setSceneTransition(Idle(Scenes.Gone))
            val sendStep2 = TransitionStep(UNDEFINED, LOCKSCREEN, 0.6f, CANCELED)
            sendSteps(sendStep1, sendStep2)
            val sendStep3 = TransitionStep(LOCKSCREEN, UNDEFINED, 0f, STARTED)
            val sendStep4 = TransitionStep(LOCKSCREEN, UNDEFINED, 1f, FINISHED)
            sendSteps(sendStep3, sendStep4)

            assertEquals(listOf(sendStep3, sendStep4), currentStatesMapped)
        }

    @Test
    @EnableSceneContainer
    fun transition_filter_on_belongsToInstantReversedTransition_into_lockscreen_scene() =
        testScope.runTest {
            val currentStatesMapped by
                collectValues(underTest.transition(Edge.create(Scenes.Gone, LOCKSCREEN)))

            kosmos.setSceneTransition(Transition(Scenes.Lockscreen, Scenes.Gone))
            val sendStep1 = TransitionStep(LOCKSCREEN, UNDEFINED, 0f, STARTED)
            kosmos.setSceneTransition(Idle(Scenes.Lockscreen))
            val sendStep2 = TransitionStep(LOCKSCREEN, UNDEFINED, 0.6f, CANCELED)
            sendSteps(sendStep1, sendStep2)
            val sendStep3 = TransitionStep(UNDEFINED, LOCKSCREEN, 0f, STARTED)
            val sendStep4 = TransitionStep(UNDEFINED, LOCKSCREEN, 1f, FINISHED)
            sendSteps(sendStep3, sendStep4)

            assertEquals(listOf(sendStep3, sendStep4), currentStatesMapped)
        }

    @Test
    @EnableSceneContainer
    fun transition_filter_on_belongsToInstantReversedTransition_out_of_ls_with_wildcard() =
        testScope.runTest {
            val currentStatesMapped by
                collectValues(underTest.transition(Edge.create(to = LOCKSCREEN)))

            kosmos.setSceneTransition(Transition(Scenes.Lockscreen, Scenes.Gone))
            val sendStep1 = TransitionStep(LOCKSCREEN, UNDEFINED, 0f, STARTED)
            kosmos.setSceneTransition(Idle(Scenes.Lockscreen))
            val sendStep2 = TransitionStep(LOCKSCREEN, UNDEFINED, 0.6f, CANCELED)
            sendSteps(sendStep1, sendStep2)
            val sendStep3 = TransitionStep(UNDEFINED, LOCKSCREEN, 0f, STARTED)
            val sendStep4 = TransitionStep(UNDEFINED, LOCKSCREEN, 1f, FINISHED)
            sendSteps(sendStep3, sendStep4)

            assertEquals(listOf(sendStep3, sendStep4), currentStatesMapped)
        }

    private suspend fun sendSteps(vararg steps: TransitionStep) {
        steps.forEach {
            repository.sendTransitionStep(it)
+12 −1
Original line number Diff line number Diff line
@@ -256,6 +256,16 @@ constructor(
            val isTransitioningBetweenDesiredScenes =
                sceneInteractor.transitionState.value.isTransitioning(fromScene, toScene)

            // When in STL A -> B settles in A we can't do the same in KTF as KTF requires us to
            // start B -> A to get back to A. [LockscreenSceneTransitionInteractor] will emit these
            // steps but because STL is Idle(A) at this point (and never even started a B -> A in
            // the first place) [isTransitioningBetweenDesiredScenes] will not be satisfied. We need
            // this condition to not filter out the STARTED and FINISHED step of the "artificially"
            // reversed B -> A transition.
            val belongsToInstantReversedTransition =
                sceneInteractor.transitionState.value.isIdle(toScene) &&
                    sceneTransitionPair.value.previousValue.isTransitioning(toScene, fromScene)

            // We can't compare the terminal step with the current sceneTransition because
            // a) STL has no guarantee that it will settle in Idle() when finished/canceled
            // b) Comparing to Idle(toScene) would make any other FINISHED step settling in
@@ -267,7 +277,8 @@ constructor(

            return@filter isTransitioningBetweenLockscreenStates ||
                isTransitioningBetweenDesiredScenes ||
                terminalStepBelongsToPreviousTransition
                terminalStepBelongsToPreviousTransition ||
                belongsToInstantReversedTransition
        }
    }