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

Commit 1b9602d1 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Support direct DOZING->PRIMARY_BOUNCER" into main

parents 3ad0f373 770ce4c1
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -93,14 +93,22 @@ constructor(
                    startedKeyguardTransitionStep,
                    keyguardInteractor.isKeyguardOccluded,
                    keyguardInteractor.biometricUnlockState,
                    keyguardInteractor.primaryBouncerShowing,
                )
                .collect { (_, isKeyguardShowing, lastStartedStep, occluded, biometricUnlockState)
                    ->
                .collect {
                    (
                        _,
                        isKeyguardShowing,
                        lastStartedStep,
                        occluded,
                        biometricUnlockState,
                        primaryBouncerShowing) ->
                    if (
                        lastStartedStep.to == KeyguardState.AOD &&
                            !occluded &&
                            !isWakeAndUnlock(biometricUnlockState) &&
                            isKeyguardShowing
                            isKeyguardShowing &&
                            !primaryBouncerShowing
                    ) {
                        val modeOnCanceled =
                            if (lastStartedStep.from == KeyguardState.LOCKSCREEN) {
+17 −5
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.launch

@@ -59,6 +61,14 @@ constructor(
        listenForTransitionToCamera(scope, keyguardInteractor)
    }

    private val canDismissLockScreen: Flow<Boolean> =
        combine(
            keyguardInteractor.isKeyguardShowing,
            keyguardInteractor.isKeyguardDismissible,
        ) { isKeyguardShowing, isKeyguardDismissible ->
            isKeyguardDismissible && !isKeyguardShowing
        }

    private fun listenForDozingToAny() {
        scope.launch {
            powerInteractor.isAwake
@@ -68,8 +78,8 @@ constructor(
                    startedKeyguardTransitionStep,
                    keyguardInteractor.isKeyguardOccluded,
                    communalInteractor.isIdleOnCommunal,
                    keyguardInteractor.isKeyguardShowing,
                    keyguardInteractor.isKeyguardDismissible,
                    canDismissLockScreen,
                    keyguardInteractor.primaryBouncerShowing,
                )
                .collect {
                    (
@@ -78,16 +88,18 @@ constructor(
                        lastStartedTransition,
                        occluded,
                        isIdleOnCommunal,
                        isKeyguardShowing,
                        isKeyguardDismissible) ->
                        canDismissLockScreen,
                        primaryBouncerShowing) ->
                    if (!(isAwake && lastStartedTransition.to == KeyguardState.DOZING)) {
                        return@collect
                    }
                    startTransitionTo(
                        if (isWakeAndUnlock(biometricUnlockState)) {
                            KeyguardState.GONE
                        } else if (isKeyguardDismissible && !isKeyguardShowing) {
                        } else if (canDismissLockScreen) {
                            KeyguardState.GONE
                        } else if (primaryBouncerShowing) {
                            KeyguardState.PRIMARY_BOUNCER
                        } else if (occluded) {
                            KeyguardState.OCCLUDED
                        } else if (isIdleOnCommunal) {
+24 −0
Original line number Diff line number Diff line
@@ -654,6 +654,30 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() {
            coroutineContext.cancelChildren()
        }

    @Test
    fun dozingToPrimaryBouncer() =
        testScope.runTest {
            // GIVEN a prior transition has run to DOZING
            runTransitionAndSetWakefulness(KeyguardState.LOCKSCREEN, KeyguardState.DOZING)
            runCurrent()

            // WHEN awaked by a request to show the primary bouncer, as can happen if SPFS is
            // touched after boot
            powerInteractor.setAwakeForTest()
            bouncerRepository.setPrimaryShow(true)
            advanceTimeBy(60L)

            assertThat(transitionRepository)
                .startedTransition(
                    to = KeyguardState.PRIMARY_BOUNCER,
                    from = KeyguardState.DOZING,
                    ownerName = "FromDozingTransitionInteractor",
                    animatorAssertion = { it.isNotNull() }
                )

            coroutineContext.cancelChildren()
        }

    /** This handles security method NONE and screen off with lock timeout */
    @Test
    fun dozingToGoneWithKeyguardNotShowing() =