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

Commit 71344f9b authored by Matt Pietal's avatar Matt Pietal Committed by Automerger Merge Worker
Browse files

Remove all pending keyguard exits on SHOW am: 7ffdcf81

parents ddb7e2f1 7ffdcf81
Loading
Loading
Loading
Loading
+48 −6
Original line number Original line Diff line number Diff line
@@ -385,6 +385,13 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
     * */
     * */
    private boolean mHiding;
    private boolean mHiding;


    /**
     * Tracks SHOW/HIDE requests, in order to determine if a HIDE request show be completed after a
     * series of binder calls returns from WM.
     */
    private int mLastShowRequest = 0;
    private int mLastHideRequest = 0;

    /**
    /**
     * we send this intent when the keyguard is dismissed.
     * we send this intent when the keyguard is dismissed.
     */
     */
@@ -1580,6 +1587,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
                        + "status bar expansion");
                        + "status bar expansion");
                mNeedToReshowWhenReenabled = false;
                mNeedToReshowWhenReenabled = false;
                updateInputRestrictedLocked();
                updateInputRestrictedLocked();
                mHandler.removeMessages(HIDE);
                mHandler.removeMessages(START_KEYGUARD_EXIT_ANIM);


                if (mExitSecureCallback != null) {
                if (mExitSecureCallback != null) {
                    if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting");
                    if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting");
@@ -1954,6 +1963,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
        if (DEBUG) Log.d(TAG, "showLocked");
        if (DEBUG) Log.d(TAG, "showLocked");
        // ensure we stay awake until we are finished displaying the keyguard
        // ensure we stay awake until we are finished displaying the keyguard
        mShowKeyguardWakeLock.acquire();
        mShowKeyguardWakeLock.acquire();
        mLastShowRequest++;
        Message msg = mHandler.obtainMessage(SHOW, options);
        Message msg = mHandler.obtainMessage(SHOW, options);
        // Treat these messages with priority - This call can originate from #doKeyguardTimeout,
        // Treat these messages with priority - This call can originate from #doKeyguardTimeout,
        // meaning the device should lock as soon as possible and not wait for other messages on
        // meaning the device should lock as soon as possible and not wait for other messages on
@@ -2385,12 +2395,30 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
                if (DEBUG) Log.d(TAG, "handleShow");
                if (DEBUG) Log.d(TAG, "handleShow");
            }
            }


            mHiding = false;
            mKeyguardExitAnimationRunner = null;
            mKeyguardExitAnimationRunner = null;
            mWakeAndUnlocking = false;
            mWakeAndUnlocking = false;
            setPendingLock(false);
            setPendingLock(false);
            setShowingLocked(true);

            // Force if we we're showing in the middle of hiding, to ensure we end up in the correct
            // state.
            setShowingLocked(true, mHiding /* force */);
            if (mHiding) {
                Log.d(TAG, "Forcing setShowingLocked because mHiding=true, which means we're "
                        + "showing in the middle of hiding.");
            }
            mHiding = false;

            // Any valid exit animation will set this to false before proceeding
            mIsKeyguardExitAnimationCanceled = true;
            // Make sure to remove any pending exit animation requests that would override a SHOW
            mHandler.removeMessages(START_KEYGUARD_EXIT_ANIM);
            mHandler.removeMessages(HIDE);
            mCentralSurfaces.instantCollapseNotificationPanel();
            mKeyguardStateController.notifyKeyguardGoingAway(false);

            // Handled directly in StatusBarKeyguardViewManager if enabled.
            mKeyguardViewControllerLazy.get().show(options);
            mKeyguardViewControllerLazy.get().show(options);

            resetKeyguardDonePendingLocked();
            resetKeyguardDonePendingLocked();
            mHideAnimationRun = false;
            mHideAnimationRun = false;
            adjustStatusBarLocked();
            adjustStatusBarLocked();
@@ -2504,10 +2532,12 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
                return;
                return;
            }
            }
            mHiding = true;
            mHiding = true;
            mLastHideRequest = mLastShowRequest;


            if (mShowing && !mOccluded) {
            if (mShowing && !mOccluded) {
                mKeyguardGoingAwayRunnable.run();
                mKeyguardGoingAwayRunnable.run();
            } else {
            } else {
                mGoingAwayRequestedForUserId = KeyguardUpdateMonitor.getCurrentUser();
                // TODO(bc-unlock): Fill parameters
                // TODO(bc-unlock): Fill parameters
                mNotificationShadeWindowControllerLazy.get().batchApplyWindowLayoutParams(() -> {
                mNotificationShadeWindowControllerLazy.get().batchApplyWindowLayoutParams(() -> {
                    handleStartKeyguardExitAnimation(
                    handleStartKeyguardExitAnimation(
@@ -2527,11 +2557,22 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
        Log.d(TAG, "handleStartKeyguardExitAnimation startTime=" + startTime
        Log.d(TAG, "handleStartKeyguardExitAnimation startTime=" + startTime
                + " fadeoutDuration=" + fadeoutDuration);
                + " fadeoutDuration=" + fadeoutDuration);
        int currentUserId = KeyguardUpdateMonitor.getCurrentUser();
        int currentUserId = KeyguardUpdateMonitor.getCurrentUser();

        // Requests to exit directly from WM are valid if the lockscreen can be dismissed
        if (mKeyguardStateController.canDismissLockScreen()) {
            mLastHideRequest = mLastShowRequest;
        }

        String error = null;
        if (mGoingAwayRequestedForUserId != currentUserId) {
        if (mGoingAwayRequestedForUserId != currentUserId) {
            Log.e(TAG, "Not executing handleStartKeyguardExitAnimation() due to userId "
            error = "Not executing handleStartKeyguardExitAnimation() due to userId "
                    + "mismatch. Requested: " + mGoingAwayRequestedForUserId + ", current: "
                    + "mismatch. Requested: " + mGoingAwayRequestedForUserId + ", current: "
                    + currentUserId);
                    + currentUserId;
            mIsKeyguardExitAnimationCanceled = true;
        } else if (mLastHideRequest != mLastShowRequest) {
            error = "Show requested after hide, cancel animation";
        }
        if (error != null) {
            Log.e(TAG, error);
            if (finishedCallback != null) {
            if (finishedCallback != null) {
                // There will not execute animation, send a finish callback to ensure the remote
                // There will not execute animation, send a finish callback to ensure the remote
                // animation won't hang there.
                // animation won't hang there.
@@ -2854,7 +2895,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
        if (KeyguardUnlockAnimationController.Companion.isNexusLauncherUnderneath()) {
        if (KeyguardUnlockAnimationController.Companion.isNexusLauncherUnderneath()) {
            flags |= KEYGUARD_GOING_AWAY_FLAG_TO_LAUNCHER_CLEAR_SNAPSHOT;
            flags |= KEYGUARD_GOING_AWAY_FLAG_TO_LAUNCHER_CLEAR_SNAPSHOT;
        }
        }

        mLastHideRequest = mLastShowRequest;
        mIsKeyguardExitAnimationCanceled = false;
        mKeyguardStateController.notifyKeyguardGoingAway(true);
        mKeyguardStateController.notifyKeyguardGoingAway(true);


        mGoingAwayRequestedForUserId = KeyguardUpdateMonitor.getCurrentUser();
        mGoingAwayRequestedForUserId = KeyguardUpdateMonitor.getCurrentUser();