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

Commit 556ef551 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Support occluded -> primary bouncer transition

Test: atest KeyguardTransitionScenariosTest
Bug: 268240415
Change-Id: Iabb60260dca213f8e15390f8aaac5a537f505cef
parent c752d081
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -50,14 +50,28 @@ constructor(
        listenForOccludedToAodOrDozing()
        listenForOccludedToGone()
        listenForOccludedToAlternateBouncer()
        listenForOccludedToPrimaryBouncer()
    }

    private fun listenForOccludedToPrimaryBouncer() {
        scope.launch {
            keyguardInteractor.primaryBouncerShowing
                .sample(transitionInteractor.startedKeyguardTransitionStep, ::Pair)
                .collect { (isBouncerShowing, lastStartedTransitionStep) ->
                    if (
                        isBouncerShowing && lastStartedTransitionStep.to == KeyguardState.OCCLUDED
                    ) {
                        startTransitionTo(KeyguardState.PRIMARY_BOUNCER)
                    }
                }
        }
    }

    private fun listenForOccludedToDreaming() {
        scope.launch {
            keyguardInteractor.isAbleToDream
                .sample(transitionInteractor.finishedKeyguardState, ::Pair)
                .collect { pair ->
                    val (isAbleToDream, keyguardState) = pair
                .collect { (isAbleToDream, keyguardState) ->
                    if (isAbleToDream && keyguardState == KeyguardState.OCCLUDED) {
                        startTransitionTo(KeyguardState.DREAMING)
                    }
+25 −1
Original line number Diff line number Diff line
@@ -1049,7 +1049,6 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() {
    @Test
    fun occludedToAlternateBouncer() =
        testScope.runTest {

            // GIVEN a prior transition has run to OCCLUDED
            runTransition(KeyguardState.LOCKSCREEN, KeyguardState.OCCLUDED)
            keyguardRepository.setKeyguardOccluded(true)
@@ -1072,6 +1071,31 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() {
            coroutineContext.cancelChildren()
        }

    @Test
    fun occludedToPrimaryBouncer() =
        testScope.runTest {
            // GIVEN a prior transition has run to OCCLUDED
            runTransition(KeyguardState.LOCKSCREEN, KeyguardState.OCCLUDED)
            keyguardRepository.setKeyguardOccluded(true)
            runCurrent()

            // WHEN primary bouncer shows
            bouncerRepository.setPrimaryShow(true) // beverlyt
            runCurrent()

            val info =
                withArgCaptor<TransitionInfo> {
                    verify(transitionRepository).startTransition(capture(), anyBoolean())
                }
            // THEN a transition to AlternateBouncer should occur
            assertThat(info.ownerName).isEqualTo("FromOccludedTransitionInteractor")
            assertThat(info.from).isEqualTo(KeyguardState.OCCLUDED)
            assertThat(info.to).isEqualTo(KeyguardState.PRIMARY_BOUNCER)
            assertThat(info.animator).isNotNull()

            coroutineContext.cancelChildren()
        }

    @Test
    fun primaryBouncerToOccluded() =
        testScope.runTest {