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

Commit 6bc48bdc authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Fix issues with OCCLUDED -> GONE behind keyguard_wm_state_refactor.

We previously thought OCCLUDED -> GONE was not possible without transiting a *_BOUNCER state. However, apps can launch over an insecure keyguard without dismissing it using an intent flag. Once launched over an insecure keyguard (OCCLUDED), apps can then request dismissing the keyguard behind the app, which requires us to transition invisibly from OCCLUDED -> GONE.

This requires several changes:
- Listen to dismiss requests from OCCLUDED and start the transition.
- Hide lockscreen invisibly, behind the app, without triggering the going-away animation we usually start for * -> GONE.
- Cancel KeyguardViewMediator's doKeyguardLocked callback when dismissing. This is a temporary workaround for the fact that some KVM methods are still being called until we can fully migrate that class.

Bug: 278086361
Flag: com.android.systemui.keyguard_wm_state_refactor
Test: presubmit literally one hundred times (this causes hundreds of CTS test failures)
Change-Id: I9ef587aac4fafe368641d5f922b2af896662d6c2
parent d9deb875
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2399,6 +2399,16 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
     */
    private void handleDismiss(IKeyguardDismissCallback callback, CharSequence message) {
        if (mShowing) {
            if (KeyguardWmStateRefactor.isEnabled()) {
                Log.d(TAG, "Dismissing keyguard with keyguard_wm_refactor_enabled: "
                        + "cancelDoKeyguardLaterLocked");

                // This won't get canceled in onKeyguardExitFinished() if the refactor is enabled,
                // which can lead to the keyguard re-showing. Cancel here for now; this can be
                // removed once we migrate the logic that posts doKeyguardLater in the first place.
                cancelDoKeyguardLaterLocked();
            }

            if (callback != null) {
                mDismissCallbackRegistry.addCallback(callback);
            }
+7 −0
Original line number Diff line number Diff line
@@ -157,6 +157,13 @@ constructor(
        }
    }

    /** Starts a transition to dismiss the keyguard from the OCCLUDED state. */
    fun dismissFromOccluded() {
        scope.launch {
            startTransitionTo(KeyguardState.GONE, ownerReason = "Dismiss from occluded")
        }
    }

    private fun listenForOccludedToGone() {
        if (KeyguardWmStateRefactor.isEnabled) {
            // We don't think OCCLUDED to GONE is possible. You should always have to go via a
+2 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ constructor(
    private val fromAlternateBouncerTransitionInteractor:
        dagger.Lazy<FromAlternateBouncerTransitionInteractor>,
    private val fromDozingTransitionInteractor: dagger.Lazy<FromDozingTransitionInteractor>,
    private val fromOccludedTransitionInteractor: dagger.Lazy<FromOccludedTransitionInteractor>,
    private val sceneInteractor: SceneInteractor,
) {
    private val transitionMap = mutableMapOf<Edge.StateToState, MutableSharedFlow<TransitionStep>>()
@@ -418,6 +419,7 @@ constructor(
                fromAlternateBouncerTransitionInteractor.get().dismissAlternateBouncer()
            AOD -> fromAodTransitionInteractor.get().dismissAod()
            DOZING -> fromDozingTransitionInteractor.get().dismissFromDozing()
            KeyguardState.OCCLUDED -> fromOccludedTransitionInteractor.get().dismissFromOccluded()
            KeyguardState.GONE ->
                Log.i(
                    TAG,
+20 −0
Original line number Diff line number Diff line
@@ -93,6 +93,14 @@ constructor(
                    KeyguardState.ALTERNATE_BOUNCER -> {
                        fromAlternateBouncerInteractor.surfaceBehindVisibility
                    }
                    KeyguardState.OCCLUDED -> {
                        // OCCLUDED -> GONE occurs when an app is on top of the keyguard, and then
                        // requests manual dismissal of the keyguard in the background. The app will
                        // remain visible on top of the stack throughout this transition, so we
                        // should not trigger the keyguard going away animation by returning
                        // surfaceBehindVisibility = true.
                        flowOf(false)
                    }
                    else -> flowOf(null)
                }
            }
@@ -253,6 +261,18 @@ constructor(
                    ) {
                        // Dreams dismiss keyguard and return to GONE if they can.
                        false
                    } else if (
                        startedWithPrev.newValue.from == KeyguardState.OCCLUDED &&
                            startedWithPrev.newValue.to == KeyguardState.GONE
                    ) {
                        // OCCLUDED -> GONE directly, without transiting a *_BOUNCER state, occurs
                        // when an app uses intent flags to launch over an insecure keyguard without
                        // dismissing it, and then manually requests keyguard dismissal while
                        // OCCLUDED. This transition is not user-visible; the device unlocks in the
                        // background and the app remains on top, while we're now GONE. In this case
                        // we should simply tell WM that the lockscreen is no longer visible, and
                        // *not* play the going away animation or related animations.
                        false
                    } else {
                        // Otherwise, use the visibility of the current state.
                        KeyguardState.lockscreenVisibleInState(currentState)
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ val Kosmos.keyguardTransitionInteractor: KeyguardTransitionInteractor by
            fromAodTransitionInteractor = { fromAodTransitionInteractor },
            fromAlternateBouncerTransitionInteractor = { fromAlternateBouncerTransitionInteractor },
            fromDozingTransitionInteractor = { fromDozingTransitionInteractor },
            fromOccludedTransitionInteractor = { fromOccludedTransitionInteractor },
            sceneInteractor = sceneInteractor
        )
    }