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

Commit c80c0cc6 authored by Matt Pietal's avatar Matt Pietal
Browse files

Ensure camera launch notif alpha is correct

The camera gesture begins to turn the phone off, but the
2nd button press is recognized as the camera gesture, which
then immediately wakes the device back up. This is recognized
as a GONE->AOD(canceled)->GONE transition. Make sure this
is captured correctly

Test: atest FromAodTransitionInteractorTest
Fixes: 337632914
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint
TEAMFOOD

Change-Id: I6a6bb5fda79566a09f85fc0fd002a65e33a445c3
parent 1a6df668
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
package com.android.systemui.keyguard.domain.interactor

import android.os.PowerManager
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -46,6 +47,7 @@ import com.android.systemui.keyguard.data.repository.keyguardRepository
import com.android.systemui.keyguard.shared.model.BiometricUnlockModel
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.keyguard.util.KeyguardTransitionRepositorySpySubject.Companion.assertThat
import com.android.systemui.kosmos.testScope
import com.android.systemui.power.domain.interactor.PowerInteractor
@@ -316,6 +318,51 @@ class FromAodTransitionInteractorTest : SysuiTestCase() {
                .startedTransition(from = KeyguardState.AOD, to = KeyguardState.GONE)
        }

    @Test
    @DisableFlags(Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR)
    fun testTransitionToGone_onWakeUp_ifPowerButtonGestureDetectedInAod_fromGone() =
        testScope.runTest {
            powerInteractor.setAwakeForTest()
            transitionRepository.sendTransitionSteps(
                from = KeyguardState.AOD,
                to = KeyguardState.GONE,
                testScope,
            )
            runCurrent()

            // Make sure we're GONE.
            assertEquals(KeyguardState.GONE, kosmos.keyguardTransitionInteractor.getFinishedState())

            // Start going to AOD on first button push
            powerInteractor.onStartedGoingToSleep(PowerManager.GO_TO_SLEEP_REASON_MIN)
            transitionRepository.sendTransitionSteps(
                listOf(
                    TransitionStep(
                        from = KeyguardState.GONE,
                        to = KeyguardState.AOD,
                        transitionState = TransitionState.STARTED,
                        value = 0f
                    ),
                    TransitionStep(
                        from = KeyguardState.GONE,
                        to = KeyguardState.AOD,
                        transitionState = TransitionState.RUNNING,
                        value = 0.1f
                    ),
                ),
                testScope = testScope,
            )

            // Detect a power gesture and then wake up.
            reset(transitionRepository)
            powerInteractor.onCameraLaunchGestureDetected()
            powerInteractor.setAwakeForTest()
            advanceTimeBy(100) // account for debouncing

            assertThat(transitionRepository)
                .startedTransition(from = KeyguardState.AOD, to = KeyguardState.GONE)
        }

    @Test
    fun testTransitionToLockscreen_onWakeUpFromAod_dismissibleKeyguard_securitySwipe() =
        testScope.runTest {
+7 −5
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ constructor(
            keyguardInteractor.isKeyguardOccluded
                .filterRelevantKeyguardStateAnd { isOccluded -> isOccluded }
                .collect {
                    if (!maybeHandleInsecurePowerGesture()) {
                        startTransitionTo(
                            toState = KeyguardState.OCCLUDED,
                            modeOnCanceled = TransitionModeOnCanceled.RESET,
@@ -176,6 +177,7 @@ constructor(
                    }
                }
        }
    }

    /**
     * If there is a biometric lockout and FPS is tapped while on AOD, it should go directly to the
+3 −1
Original line number Diff line number Diff line
@@ -77,7 +77,9 @@ constructor(
        // transition, to ensure we don't transition while moving between, for example,
        // *_BOUNCER -> LOCKSCREEN.
        return powerInteractor.detailedWakefulness.value.powerButtonLaunchGestureTriggered &&
            KeyguardState.deviceIsAsleepInState(transitionInteractor.getStartedState())
            KeyguardState.deviceIsAsleepInState(
                transitionInteractor.currentTransitionInfoInternal.value.to
            )
    }

    /**
+6 −4
Original line number Diff line number Diff line
@@ -225,6 +225,7 @@ sealed class TransitionInteractor(
        if (!KeyguardWmStateRefactor.isEnabled) {
            scope.launch {
                keyguardInteractor.onCameraLaunchDetected.filterRelevantKeyguardState().collect {
                    if (!maybeHandleInsecurePowerGesture()) {
                        startTransitionTo(
                            toState = KeyguardState.OCCLUDED,
                            modeOnCanceled = TransitionModeOnCanceled.RESET,
@@ -233,6 +234,7 @@ sealed class TransitionInteractor(
                }
            }
        }
    }

    /**
     * Whether we're in the KeyguardState relevant to this From*TransitionInteractor (which we know
+10 −0
Original line number Diff line number Diff line
@@ -57,5 +57,15 @@ constructor(
        )
    }

    fun notificationAlpha(viewState: ViewStateAccessor): Flow<Float> {
        var startAlpha = 1f
        return transitionAnimation.sharedFlow(
            duration = 200.milliseconds,
            onStart = { startAlpha = viewState.alpha() },
            onStep = { startAlpha },
            onFinish = { 1f },
        )
    }

    override val deviceEntryParentViewAlpha = transitionAnimation.immediatelyTransitionTo(0f)
}
Loading