diff options
| author | 2022-02-24 15:20:58 -0500 | |
|---|---|---|
| committer | 2022-02-25 16:29:49 -0500 | |
| commit | 7172089cfd22ae5a0a4d13dbb96f58654e8b35e8 (patch) | |
| tree | f57545d064277dbaa1290e98db1d77f7a4065b52 | |
| parent | 16853e9b84be27f21959e8e12e03f2a232727c1a (diff) | |
Fix sleep during launch animation resulting in a unlocked device.
Fixes: 220907477
Test: lock during activity launch
Change-Id: Icd6c0a1bbb7eba3925ec491d9c666525383ca1fb
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index ae7147ecae03..d3d11f2ee1ca 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -1667,11 +1667,16 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, return; } - // if the keyguard is already showing, don't bother. check flags in both files - // to account for the hiding animation which results in a delay and discrepancy - // between flags - if (mShowing && mKeyguardViewControllerLazy.get().isShowing()) { - if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing"); + // If the keyguard is already showing, don't bother unless it was in the process of going + // away. If it was going away, keyguard state may be out of sync and we should make sure to + // re-show it explicitly. Check flags in both files to account for the hiding animation + // which results in a delay and discrepancy between flags. + if ((mShowing && mKeyguardViewControllerLazy.get().isShowing()) + && !mKeyguardStateController.isKeyguardGoingAway()) { + if (DEBUG) { + Log.d(TAG, "doKeyguard: not showing " + + "because it is already showing and not going away"); + } resetStateLocked(); return; } @@ -2186,7 +2191,14 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, mKeyguardExitAnimationRunner = null; mScreenOnCoordinator.setWakeAndUnlocking(false); mPendingLock = false; - setShowingLocked(true); + + // If we're asked to re-show while the keyguard is going away, force callbacks to ensure + // that state is re-set correctly. Otherwise, we might short circuit since mShowing is + // true during the keyguard going away process, despite having partially set some state + // to unlocked. + setShowingLocked( + true, mKeyguardStateController.isKeyguardGoingAway() /* forceCallbacks */); + mKeyguardViewControllerLazy.get().show(options); resetKeyguardDonePendingLocked(); mHideAnimationRun = false; @@ -2356,14 +2368,28 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, @Override public void onAnimationFinished() throws RemoteException { try { + // WindowManager always needs to know that this animation + // finished so it does not wait the 10s until timeout. finishedCallback.onAnimationFinished(); } catch (RemoteException e) { Slog.w(TAG, "Failed to call onAnimationFinished", e); } - onKeyguardExitFinished(); - mKeyguardViewControllerLazy.get().hide(0 /* startTime */, - 0 /* fadeoutDuration */); - mInteractionJankMonitor.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION); + + // If we're not interactive, it means the device is going back to + // sleep. This happens if the power button is pressed during the + // activity launch. If we're going back to sleep, we should *not* + // run keyguard exit finished callbacks and hide the keyguard, since + // we are in the process of locking again and this might result in + // the device staying unlocked when it shouldn't. + // We need to directly query isInteractive rather than mGoingToSleep + // because mGoingToSleep is set in onStartedGoingToSleep, which is + // dispatched asynchronously. + if (mPM.isInteractive()) { + onKeyguardExitFinished(); + mKeyguardViewControllerLazy.get().hide(0 /* startTime */, + 0 /* fadeoutDuration */); + mInteractionJankMonitor.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION); + } } @Override |