From 7a5e4c9161396805fefb15ffcf1f09b019daf35b Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Mon, 31 Jul 2017 16:40:19 +0200 Subject: [PATCH] WakeAndUnlock: Make sure to wait for screen turning on Fixes an issue where instead of waiting for screen on we start the unlock transition immediately when the screen is already on. Instead, we have to wait for it to turn off and then on again. Change-Id: Ib1f66edc6ad2d3e71c4bf928b4b0e7531babf6e0 Fixes: 64080116 Test: Unlock via fingerprint a lot. Verify the status bar does not flicker. --- .../phone/FingerprintUnlockController.java | 17 +++++++++++++++++ .../phone/StatusBarKeyguardViewManager.java | 9 ++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java index 02202cf26c38a..fdfd8e88b4465 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java @@ -29,6 +29,7 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.LatencyTracker; import com.android.systemui.Dependency; import com.android.systemui.keyguard.KeyguardViewMediator; +import com.android.systemui.keyguard.ScreenLifecycle; import com.android.systemui.keyguard.WakefulnessLifecycle; /** @@ -101,6 +102,7 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback { private final Context mContext; private int mPendingAuthenticatedUserId = -1; private boolean mPendingShowBouncer; + private boolean mHasScreenTurnedOnSinceAuthenticating; public FingerprintUnlockController(Context context, DozeScrimController dozeScrimController, @@ -113,6 +115,7 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback { mUpdateMonitor = KeyguardUpdateMonitor.getInstance(context); mUpdateMonitor.registerCallback(this); Dependency.get(WakefulnessLifecycle.class).addObserver(mWakefulnessObserver); + Dependency.get(ScreenLifecycle.class).addObserver(mScreenObserver); mStatusBarWindowManager = Dependency.get(StatusBarWindowManager.class); mDozeScrimController = dozeScrimController; mKeyguardViewMediator = keyguardViewMediator; @@ -186,6 +189,7 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback { } boolean wasDeviceInteractive = mUpdateMonitor.isDeviceInteractive(); mMode = calculateMode(); + mHasScreenTurnedOnSinceAuthenticating = false; if (mMode == MODE_WAKE_AND_UNLOCK_PULSING && pulsingOrAod()) { // If we are waking the device up while we are pulsing the clock and the // notifications would light up first, creating an unpleasant animation. @@ -228,6 +232,7 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback { true /* allowEnterAnimation */); } else { Trace.beginSection("MODE_WAKE_AND_UNLOCK"); + mDozeScrimController.abortDoze(); } mStatusBarWindowManager.setStatusBarFocusable(false); @@ -354,4 +359,16 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback { } } }; + + private final ScreenLifecycle.Observer mScreenObserver = + new ScreenLifecycle.Observer() { + @Override + public void onScreenTurnedOn() { + mHasScreenTurnedOnSinceAuthenticating = true; + } + }; + + public boolean hasScreenTurnedOnSinceAuthenticating() { + return mHasScreenTurnedOnSinceAuthenticating; + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 252df17928453..8c23a45bd8756 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -71,6 +71,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb protected final Context mContext; private final StatusBarWindowManager mStatusBarWindowManager; + private final boolean mDisplayBlanksAfterDoze; protected LockPatternUtils mLockPatternUtils; protected ViewMediatorCallback mViewMediatorCallback; @@ -121,6 +122,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mLockPatternUtils = lockPatternUtils; mStatusBarWindowManager = Dependency.get(StatusBarWindowManager.class); KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitorCallback); + mDisplayBlanksAfterDoze = context.getResources().getBoolean( + com.android.internal.R.bool.config_displayBlanksAfterDoze); } public void registerStatusBar(StatusBar statusBar, @@ -373,7 +376,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb if (!staying) { mStatusBarWindowManager.setKeyguardFadingAway(true); if (mFingerprintUnlockController.getMode() == MODE_WAKE_AND_UNLOCK) { - if (!mScreenTurnedOn) { + boolean turnedOnSinceAuth = + mFingerprintUnlockController.hasScreenTurnedOnSinceAuthenticating(); + if (!mScreenTurnedOn || mDisplayBlanksAfterDoze && !turnedOnSinceAuth) { + // Not ready to animate yet; either because the screen is not on yet, + // or it is on but will turn off before waking out of doze. mDeferScrimFadeOut = true; } else {