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

Commit 5b3775e2 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Add keyguardStateToCamera transition

The camera occluding activity can be launched
by double pressing the power button. When this happens, the first
power button press may immediately start a keyguard transition [1].
Then, the second power button press will launch the camera (an
occluding activity).

The desired behavior is to transition from the original state (before
any power button presses), rather than the started keyguard transition
from the first power button press [1]. Therefore, we use the 'from'
keyguardState of the last *finished* keyguard state rather than
the current running 'to' keyguard state.

Test: atest KeyguardTransitionInteractorTest
Fixes: 292506244
Change-Id: I50688200bb58515aa437747b9229e794f3d3a93c
parent 87a1f6a8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ constructor(
        listenForAlternateBouncerToGone()
        listenForAlternateBouncerToLockscreenAodOrDozing()
        listenForAlternateBouncerToPrimaryBouncer()
        listenForTransitionToCamera(scope, keyguardInteractor)
    }

    private fun listenForAlternateBouncerToLockscreenAodOrDozing() {
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ constructor(
    override fun start() {
        listenForAodToLockscreenOrOccluded()
        listenForAodToGone()
        listenForTransitionToCamera(scope, keyguardInteractor)
    }

    private fun listenForAodToLockscreenOrOccluded() {
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ constructor(
    override fun start() {
        listenForDozingToLockscreenOrOccluded()
        listenForDozingToGone()
        listenForTransitionToCamera(scope, keyguardInteractor)
    }

    private fun listenForDozingToLockscreenOrOccluded() {
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ constructor(
        listenForDreamingToOccluded()
        listenForDreamingToGone()
        listenForDreamingToDozing()
        listenForTransitionToCamera(scope, keyguardInteractor)
    }

    fun startToLockscreenTransition() {
+6 −23
Original line number Diff line number Diff line
@@ -63,12 +63,12 @@ constructor(
        listenForLockscreenToGone()
        listenForLockscreenToGoneDragging()
        listenForLockscreenToOccluded()
        listenForLockscreenToCamera()
        listenForLockscreenToAodOrDozing()
        listenForLockscreenToPrimaryBouncer()
        listenForLockscreenToDreaming()
        listenForLockscreenToPrimaryBouncerDragging()
        listenForLockscreenToAlternateBouncer()
        listenForLockscreenTransitionToCamera()
    }

    /**
@@ -128,6 +128,10 @@ constructor(
            }
            .distinctUntilChanged()

    private fun listenForLockscreenTransitionToCamera() {
        listenForTransitionToCamera(scope, keyguardInteractor)
    }

    private fun listenForLockscreenToDreaming() {
        val invalidFromStates = setOf(KeyguardState.AOD, KeyguardState.DOZING)
        scope.launch {
@@ -311,7 +315,7 @@ constructor(
            keyguardInteractor.isKeyguardOccluded
                .sample(
                    combine(
                        transitionInteractor.finishedKeyguardState,
                        transitionInteractor.startedKeyguardState,
                        keyguardInteractor.isDreaming,
                        ::Pair
                    ),
@@ -325,27 +329,6 @@ constructor(
        }
    }

    /** This signal may come in before the occlusion signal, and can provide a custom transition */
    private fun listenForLockscreenToCamera() {
        scope.launch {
            keyguardInteractor.onCameraLaunchDetected
                .sample(transitionInteractor.startedKeyguardTransitionStep, ::Pair)
                .collect { (_, lastStartedStep) ->
                    // DREAMING/AOD/OFF may trigger on the first power button push, so include this
                    // state in order to cancel and correct the transition
                    if (
                        lastStartedStep.to == KeyguardState.LOCKSCREEN ||
                            lastStartedStep.to == KeyguardState.DREAMING ||
                            lastStartedStep.to == KeyguardState.DOZING ||
                            lastStartedStep.to == KeyguardState.AOD ||
                            lastStartedStep.to == KeyguardState.OFF
                    ) {
                        startTransitionTo(KeyguardState.OCCLUDED)
                    }
                }
        }
    }

    private fun listenForLockscreenToAodOrDozing() {
        scope.launch {
            keyguardInteractor.wakefulnessModel
Loading