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

Commit 48d71e01 authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Fix issues with transitions from AOD and GONE.

1) Consolidate starting AOD -> GONE (wake and unlock) into KeyguardTransitionInteractor#startDismissKeyguardTransition. We were previously getting duplicate calls to start AOD -> GONE. Using the KeyguardSecurityContainerController signal for all of LS/BOUNCER/AOD -> GONE fixes that and is simpler to reason about.
2) Check currentState instead of startedState in listenForGoneToLockscreenOrHub. This can otherwise cause an incorrect transition to LOCKSCREEN during a transition to GONE that started after an interrupted transition. The logic we want here is 'if we're in GONE, and lockdown occurs, transition to LOCKSCREEN', so currentState makes more sense than startedState.

Also, add a Subject for KeyguardTransitionRepository so we can assert things about it without having to search for the argument captor syntax every time. This can now be easily extended for other transition test use cases!

Bug: 27808636
Flag: ACONFIG com.android.systemui.keyguard_wm_state_refactor DEVELOPMENT
Test: atest FromGoneTransitionInteractorTest
Test: atest SystemUITests
Change-Id: I70d7f42bc41e2223f08463d433bf827ea6788469
parent ec621683
Loading
Loading
Loading
Loading
+25 −10
Original line number Diff line number Diff line
@@ -21,18 +21,18 @@ import com.android.app.animation.Interpolators
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.KeyguardWmStateRefactor
import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository
import com.android.systemui.keyguard.shared.model.BiometricUnlockModel.Companion.isWakeAndUnlock
import com.android.systemui.keyguard.shared.model.DozeStateModel
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionModeOnCanceled
import com.android.systemui.util.kotlin.Utils.Companion.toTriple
import com.android.systemui.util.kotlin.Utils.Companion.sample
import com.android.systemui.util.kotlin.sample
import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch

@SysUISingleton
@@ -85,15 +85,16 @@ constructor(
            keyguardInteractor
                .dozeTransitionTo(DozeStateModel.FINISH)
                .sample(
                    combine(
                    startedKeyguardTransitionStep,
                    keyguardInteractor.isKeyguardOccluded,
                        ::Pair
                    ),
                    ::toTriple
                    keyguardInteractor.biometricUnlockState,
                )
                .collect { (_, lastStartedStep, occluded) ->
                    if (lastStartedStep.to == KeyguardState.AOD && !occluded) {
                .collect { (_, lastStartedStep, occluded, biometricUnlockState) ->
                    if (
                        lastStartedStep.to == KeyguardState.AOD &&
                            !occluded &&
                            !isWakeAndUnlock(biometricUnlockState)
                    ) {
                        val modeOnCanceled =
                            if (lastStartedStep.from == KeyguardState.LOCKSCREEN) {
                                TransitionModeOnCanceled.REVERSE
@@ -126,15 +127,29 @@ constructor(
    }

    private fun listenForAodToGone() {
        if (KeyguardWmStateRefactor.isEnabled) {
            return
        }

        scope.launch {
            keyguardInteractor.biometricUnlockState.sample(finishedKeyguardState, ::Pair).collect {
                (biometricUnlockState, keyguardState) ->
                KeyguardWmStateRefactor.assertInLegacyMode()
                if (keyguardState == KeyguardState.AOD && isWakeAndUnlock(biometricUnlockState)) {
                    startTransitionTo(KeyguardState.GONE)
                }
            }
        }
    }

    /**
     * Dismisses AOD and transitions to GONE. This is called whenever authentication occurs while on
     * AOD.
     */
    fun dismissAod() {
        scope.launch { startTransitionTo(KeyguardState.GONE) }
    }

    override fun getDefaultAnimatorForTransitionsToState(toState: KeyguardState): ValueAnimator {
        return ValueAnimator().apply {
            interpolator = Interpolators.LINEAR
+3 −3
Original line number Diff line number Diff line
@@ -68,11 +68,11 @@ constructor(
        scope.launch {
            keyguardInteractor.isKeyguardShowing
                .sample(
                    startedKeyguardTransitionStep,
                    currentKeyguardState,
                    communalInteractor.isIdleOnCommunal,
                )
                .collect { (isKeyguardShowing, lastStartedStep, isIdleOnCommunal) ->
                    if (isKeyguardShowing && lastStartedStep.to == KeyguardState.GONE) {
                .collect { (isKeyguardShowing, currentState, isIdleOnCommunal) ->
                    if (isKeyguardShowing && currentState == KeyguardState.GONE) {
                        val to =
                            if (isIdleOnCommunal) {
                                KeyguardState.GLANCEABLE_HUB
+2 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ constructor(
    private val fromLockscreenTransitionInteractor: dagger.Lazy<FromLockscreenTransitionInteractor>,
    private val fromPrimaryBouncerTransitionInteractor:
        dagger.Lazy<FromPrimaryBouncerTransitionInteractor>,
    private val fromAodTransitionInteractor: dagger.Lazy<FromAodTransitionInteractor>,
) {
    private val TAG = this::class.simpleName

@@ -346,6 +347,7 @@ constructor(
        when (val startedState = startedKeyguardState.replayCache.last()) {
            LOCKSCREEN -> fromLockscreenTransitionInteractor.get().dismissKeyguard()
            PRIMARY_BOUNCER -> fromPrimaryBouncerTransitionInteractor.get().dismissPrimaryBouncer()
            AOD -> fromAodTransitionInteractor.get().dismissAod()
            else ->
                Log.e(
                    "KeyguardTransitionInteractor",
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ sealed class TransitionInteractor(
    // The following are MutableSharedFlows, and do not require flowOn
    val startedKeyguardState = transitionInteractor.startedKeyguardState
    val finishedKeyguardState = transitionInteractor.finishedKeyguardState
    val currentKeyguardState = transitionInteractor.currentKeyguardState

    suspend fun startTransitionTo(
        toState: KeyguardState,
+0 −4
Original line number Diff line number Diff line
@@ -1442,10 +1442,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            hideAlternateBouncer(false);
            executeAfterKeyguardGoneAction();
        }

        if (KeyguardWmStateRefactor.isEnabled()) {
            mKeyguardTransitionInteractor.startDismissKeyguardTransition();
        }
    }

    /** Display security message to relevant KeyguardMessageArea. */
Loading