From 200475be8ecef2e711724b71e707fe25b6a884d1 Mon Sep 17 00:00:00 2001 From: Brian Colonna Date: Thu, 15 May 2014 11:42:54 -0400 Subject: Fix 14988763: FUL only shows on bouncer now FUL used to show on the notification shade when returning from something that was occluding keyguard such as navigation or secure camera. This fix makes FUL only display on the bouncer, never on the notification shade. Change-Id: I6b6dc1453a167161330132c1e2703c296050bf0e --- .../android/keyguard/KeyguardFaceUnlockView.java | 85 +++++++++++++++------- 1 file changed, 57 insertions(+), 28 deletions(-) (limited to 'packages') diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardFaceUnlockView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardFaceUnlockView.java index 900d16e..701d15f 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardFaceUnlockView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardFaceUnlockView.java @@ -46,8 +46,8 @@ public class KeyguardFaceUnlockView extends LinearLayout implements KeyguardSecu private View mEcaView; private Drawable mBouncerFrame; - private boolean mIsShowing = false; - private final Object mIsShowingLock = new Object(); + private boolean mIsBouncerVisibleToUser = false; + private final Object mIsBouncerVisibleToUserLock = new Object(); private int mLastRotation; private boolean mWatchingRotation; @@ -149,9 +149,8 @@ public class KeyguardFaceUnlockView extends LinearLayout implements KeyguardSecu @Override public void onResume(int reason) { if (DEBUG) Log.d(TAG, "onResume()"); - mIsShowing = KeyguardUpdateMonitor.getInstance(mContext).isKeyguardVisible(); - if (!KeyguardUpdateMonitor.getInstance(mContext).isSwitchingUser()) { - maybeStartBiometricUnlock(); + synchronized (mIsBouncerVisibleToUserLock) { + mIsBouncerVisibleToUser = isBouncerVisibleToUser(); } KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateCallback); @@ -213,18 +212,15 @@ public class KeyguardFaceUnlockView extends LinearLayout implements KeyguardSecu final boolean backupIsTimedOut = ( monitor.getFailedUnlockAttempts() >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT); - PowerManager powerManager = (PowerManager) mContext.getSystemService( - Context.POWER_SERVICE); - boolean isShowing; - synchronized(mIsShowingLock) { - isShowing = mIsShowing; + boolean isBouncerVisibleToUser; + synchronized(mIsBouncerVisibleToUserLock) { + isBouncerVisibleToUser = mIsBouncerVisibleToUser; } - // Don't start it if the screen is off or if it's not showing, but keep this view up - // because we want it here and ready for when the screen turns on or when it does start - // showing. - if (!powerManager.isScreenOn() || !isShowing) { + // Don't start it if the bouncer is not showing, but keep this view up because we want + // it here and ready for when the bouncer does show. + if (!isBouncerVisibleToUser) { mBiometricUnlock.stop(); // It shouldn't be running but calling this can't hurt. return; } @@ -247,6 +243,34 @@ public class KeyguardFaceUnlockView extends LinearLayout implements KeyguardSecu } } + // Returns true if the device is currently in a state where the user is seeing the bouncer. + // This requires isKeyguardBouncer() to be true, but that doesn't imply that the screen is on or + // the keyguard visibility is set to true, so we must check those conditions as well. + private boolean isBouncerVisibleToUser() { + KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); + return updateMonitor.isKeyguardBouncer() && updateMonitor.isKeyguardVisible() && + updateMonitor.isScreenOn(); + } + + // Starts the biometric unlock if the bouncer was not previously visible to the user, but is now + // visibile to the user. Stops the biometric unlock if the bouncer was previously visible to + // the user, but is no longer visible to the user. + private void handleBouncerUserVisibilityChanged() { + boolean wasBouncerVisibleToUser; + synchronized(mIsBouncerVisibleToUserLock) { + wasBouncerVisibleToUser = mIsBouncerVisibleToUser; + mIsBouncerVisibleToUser = isBouncerVisibleToUser(); + } + + if (mBiometricUnlock != null) { + if (wasBouncerVisibleToUser && !mIsBouncerVisibleToUser) { + mBiometricUnlock.stop(); + } else if (!wasBouncerVisibleToUser && mIsBouncerVisibleToUser) { + maybeStartBiometricUnlock(); + } + } + } + KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { // We need to stop the biometric unlock when a phone call comes in @Override @@ -280,20 +304,25 @@ public class KeyguardFaceUnlockView extends LinearLayout implements KeyguardSecu @Override public void onKeyguardVisibilityChanged(boolean showing) { if (DEBUG) Log.d(TAG, "onKeyguardVisibilityChanged(" + showing + ")"); - boolean wasShowing = false; - synchronized(mIsShowingLock) { - wasShowing = mIsShowing; - mIsShowing = showing; - } - PowerManager powerManager = (PowerManager) mContext.getSystemService( - Context.POWER_SERVICE); - if (mBiometricUnlock != null) { - if (!showing && wasShowing) { - mBiometricUnlock.stop(); - } else if (showing && powerManager.isScreenOn() && !wasShowing) { - maybeStartBiometricUnlock(); - } - } + handleBouncerUserVisibilityChanged(); + } + + @Override + public void onKeyguardBouncerChanged(boolean bouncer) { + if (DEBUG) Log.d(TAG, "onKeyguardBouncerChanged(" + bouncer + ")"); + handleBouncerUserVisibilityChanged(); + } + + @Override + public void onScreenTurnedOn() { + if (DEBUG) Log.d(TAG, "onScreenTurnedOn()"); + handleBouncerUserVisibilityChanged(); + } + + @Override + public void onScreenTurnedOff(int why) { + if (DEBUG) Log.d(TAG, "onScreenTurnedOff()"); + handleBouncerUserVisibilityChanged(); } @Override -- cgit v1.1