From 71448a70036e8f95a4f7f3b0f6252bd3344976bb Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Tue, 18 Aug 2015 19:49:04 -0700 Subject: [PATCH 1/2] Don't call authenticate immediately after getting valid fingerprint After gettin a callback onAuthenticationSucceded we set the fingerprint listening state to false. However, when waking up, we immediately started listening again because the state was false. Protect against that by only calling authenticate only once, except when the unlock doesn't go through because unlocking with fingerprint is not allowed. Also fixes some animation "jank" because of the state messup. Bug: 23304421 Change-Id: Ic83ac0f1590dd4f8017bb55dca9e19a60cfdf99f --- .../keyguard/KeyguardUpdateMonitor.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index 4eb6f881afb89..40dcd0d86dc1c 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -147,6 +147,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private int mRingMode; private int mPhoneState; private boolean mKeyguardIsVisible; + + /** + * If true, fingerprint was already authenticated and we don't need to start listening again + * until the Keyguard has been dismissed. + */ + private boolean mFingerprintAlreadyAuthenticated; private boolean mBouncer; private boolean mBootCompleted; private boolean mUserHasAuthenticatedSinceBoot; @@ -373,6 +379,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private void onFingerprintAuthenticated(int userId) { mUserFingerprintAuthenticated.put(userId, true); + + // If fingerprint unlocking is allowed, this event will lead to a Keyguard dismiss or to a + // wake-up (if Keyguard is not showing), so we don't need to listen until Keyguard is + // fully gone. + mFingerprintAlreadyAuthenticated = isUnlockingWithFingerprintAllowed(); for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { @@ -818,6 +829,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { cb.onFinishedGoingToSleep(arg1); } } + mFingerprintAlreadyAuthenticated = false; updateFingerprintListeningState(); } @@ -951,13 +963,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } private boolean shouldListenForFingerprint() { - return (mKeyguardIsVisible || !mDeviceInteractive) && !mSwitchingUser; + return (mKeyguardIsVisible || !mDeviceInteractive) && !mSwitchingUser + && !mFingerprintAlreadyAuthenticated; } private void startListeningForFingerprint() { if (DEBUG) Log.v(TAG, "startListeningForFingerprint()"); int userId = ActivityManager.getCurrentUser(); - if (!mFingerprintDetectionRunning && isUnlockWithFingerprintPossible(userId)) { + if (isUnlockWithFingerprintPossible(userId)) { mUserHasAuthenticatedSinceBoot = mTrustManager.hasUserAuthenticatedSinceBoot( ActivityManager.getCurrentUser()); if (mFingerprintCancelSignal != null) { @@ -1249,6 +1262,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { cb.onKeyguardVisibilityChangedRaw(isShowing); } } + if (!isShowing) { + mFingerprintAlreadyAuthenticated = false; + } updateFingerprintListeningState(); } From 909788500bbe54b14017be3c1f2b4fee7945c63d Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Tue, 18 Aug 2015 19:55:53 -0700 Subject: [PATCH 2/2] Fix jank in wake-and-unlock while pulsing - Don't hide keyguard after the animation is done, because this would cause a measure in the middle of the fade animation. - Don't use a layer for the notification panel in this case - we don't need it and it only adds latency. - Speed up the whole thing a bit because the animation is now smoother. Bug: 23225107 Change-Id: Ie8264c4d0e62bd6a78227e04b9900b4348ddd649 --- .../statusbar/phone/NotificationPanelView.java | 5 +++++ .../statusbar/phone/PhoneStatusBar.java | 14 +++----------- .../phone/StatusBarKeyguardViewManager.java | 17 +++++++++++++++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index a77b8d1f31b6c..5be768d0df48b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -2388,4 +2388,9 @@ public class NotificationPanelView extends PanelView implements protected boolean isPanelVisibleBecauseOfHeadsUp() { return mHeadsUpManager.hasPinnedHeadsUp() || mHeadsUpAnimatingAway; } + + @Override + public boolean hasOverlappingRendering() { + return !mDozing; + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index b277cc1657015..b0a01dcacfd11 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -231,7 +231,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, public static final int FADE_KEYGUARD_START_DELAY = 100; public static final int FADE_KEYGUARD_DURATION = 300; - public static final int FADE_KEYGUARD_DURATION_PULSING = 120; + public static final int FADE_KEYGUARD_DURATION_PULSING = 96; /** Allow some time inbetween the long press for back and recents. */ private static final int LOCK_TO_APP_GESTURE_TOLERENCE = 200; @@ -3440,16 +3440,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, .alpha(0f) .setStartDelay(0) .setDuration(FADE_KEYGUARD_DURATION_PULSING) - .setInterpolator(ScrimController.KEYGUARD_FADE_OUT_INTERPOLATOR) - .withLayer() - .withEndAction(new Runnable() { - @Override - public void run() { - mNotificationPanel.setAlpha(1f); - hideKeyguard(); - } - }) - .start(); + .setInterpolator(ScrimController.KEYGUARD_FADE_OUT_INTERPOLATOR); } /** @@ -3502,6 +3493,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mQSPanel.refreshAllTiles(); } mHandler.removeMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); + mNotificationPanel.setAlpha(1f); return staying; } 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 448f16dac5ac1..7e83f26709865 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -279,10 +279,15 @@ public class StatusBarKeyguardViewManager { if (mFingerprintUnlockController.getMode() == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING) { mFingerprintUnlockController.startKeyguardFadingAway(); - mPhoneStatusBar.setKeyguardFadingAway(startTime, 0, 250); + mPhoneStatusBar.setKeyguardFadingAway(startTime, 0, 240); mStatusBarWindowManager.setKeyguardFadingAway(true); mPhoneStatusBar.fadeKeyguardWhilePulsing(); - animateScrimControllerKeyguardFadingOut(0, 250); + animateScrimControllerKeyguardFadingOut(0, 240, new Runnable() { + @Override + public void run() { + mPhoneStatusBar.hideKeyguard(); + } + }); } else { mFingerprintUnlockController.startKeyguardFadingAway(); mPhoneStatusBar.setKeyguardFadingAway(startTime, delay, fadeoutDuration); @@ -316,10 +321,18 @@ public class StatusBarKeyguardViewManager { } private void animateScrimControllerKeyguardFadingOut(long delay, long duration) { + animateScrimControllerKeyguardFadingOut(delay, duration, null /* endRunnable */); + } + + private void animateScrimControllerKeyguardFadingOut(long delay, long duration, + final Runnable endRunnable) { Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW, "Fading out", 0); mScrimController.animateKeyguardFadingOut(delay, duration, new Runnable() { @Override public void run() { + if (endRunnable != null) { + endRunnable.run(); + } mStatusBarWindowManager.setKeyguardFadingAway(false); mPhoneStatusBar.finishKeyguardFadingAway(); mFingerprintUnlockController.finishKeyguardFadingAway();