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

Commit 82c193fe authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Remove all pending keyguard exits on SHOW" into udc-dev am: ebd031e2

parents b6f2c493 ebd031e2
Loading
Loading
Loading
Loading
+40 −5
Original line number Original line Diff line number Diff line
@@ -447,6 +447,13 @@ public class KeyguardViewMediator implements CoreStartable, 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.
     */
     */
@@ -1977,6 +1984,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                mNeedToReshowWhenReenabled = false;
                mNeedToReshowWhenReenabled = false;
                updateInputRestrictedLocked();
                updateInputRestrictedLocked();


                mHandler.removeMessages(HIDE);
                mHandler.removeMessages(START_KEYGUARD_EXIT_ANIM);
                showLocked(null);
                showLocked(null);


                // block until we know the keyguard is done drawing (and post a message
                // block until we know the keyguard is done drawing (and post a message
@@ -2347,6 +2356,7 @@ public class KeyguardViewMediator implements CoreStartable, 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
@@ -2359,7 +2369,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
     * Send message to keyguard telling it to hide itself
     * Send message to keyguard telling it to hide itself
     * @see #handleHide()
     * @see #handleHide()
     */
     */
    private void hideLocked() {
    @VisibleForTesting
    void hideLocked() {
        Trace.beginSection("KeyguardViewMediator#hideLocked");
        Trace.beginSection("KeyguardViewMediator#hideLocked");
        if (DEBUG) Log.d(TAG, "hideLocked");
        if (DEBUG) Log.d(TAG, "hideLocked");
        Message msg = mHandler.obtainMessage(HIDE);
        Message msg = mHandler.obtainMessage(HIDE);
@@ -2777,7 +2788,17 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
            }
            }
            mHiding = false;
            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);
            mShadeController.get().instantCollapseShade();
            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();
@@ -2945,7 +2966,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
            if (DEBUG) Log.d(TAG, "handleHide");
            if (DEBUG) Log.d(TAG, "handleHide");


            mHiding = true;
            mHiding = true;

            mLastHideRequest = mLastShowRequest;
            // If waking and unlocking, waking from dream has been set properly.
            // If waking and unlocking, waking from dream has been set properly.
            if (!mWakeAndUnlocking) {
            if (!mWakeAndUnlocking) {
                setUnlockAndWakeFromDream(mStatusBarStateController.isDreaming()
                setUnlockAndWakeFromDream(mStatusBarStateController.isDreaming()
@@ -2958,6 +2979,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                }
                }
                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(
@@ -2984,11 +3006,22 @@ public class KeyguardViewMediator implements CoreStartable, 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 handleStartKeyguardExitAnimationInner() due to userId "
            error = "Not executing handleStartKeyguardExitAnimationInner() 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.
@@ -3333,6 +3366,8 @@ public class KeyguardViewMediator implements CoreStartable, 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;


            mGoingAwayRequestedForUserId = KeyguardUpdateMonitor.getCurrentUser();
            mGoingAwayRequestedForUserId = KeyguardUpdateMonitor.getCurrentUser();
            Log.d(TAG, "keyguardGoingAway requested for userId: "
            Log.d(TAG, "keyguardGoingAway requested for userId: "
+3 −1
Original line number Original line Diff line number Diff line
@@ -647,7 +647,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        IRemoteAnimationFinishedCallback callback = mock(IRemoteAnimationFinishedCallback.class);
        IRemoteAnimationFinishedCallback callback = mock(IRemoteAnimationFinishedCallback.class);


        when(mKeyguardStateController.isKeyguardGoingAway()).thenReturn(true);
        when(mKeyguardStateController.isKeyguardGoingAway()).thenReturn(true);
        mViewMediator.mKeyguardGoingAwayRunnable.run();
        mViewMediator.hideLocked();
        processAllMessagesAndBgExecutorMessages();
        mViewMediator.startKeyguardExitAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY, apps, wallpapers,
        mViewMediator.startKeyguardExitAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY, apps, wallpapers,
                null, callback);
                null, callback);
        processAllMessagesAndBgExecutorMessages();
        processAllMessagesAndBgExecutorMessages();
@@ -961,6 +962,7 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
        mViewMediator.getViewMediatorCallback().onBouncerSwipeDown();
        mViewMediator.getViewMediatorCallback().onBouncerSwipeDown();
        verify(mStatusBarKeyguardViewManager).reset(true);
        verify(mStatusBarKeyguardViewManager).reset(true);
    }
    }

    private void createAndStartViewMediator() {
    private void createAndStartViewMediator() {
        createAndStartViewMediator(false);
        createAndStartViewMediator(false);
    }
    }