Loading packages/Keyguard/src/com/android/keyguard/KeyguardFaceUnlockView.java +57 −28 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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; } Loading @@ -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 Loading Loading @@ -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; handleBouncerUserVisibilityChanged(); } PowerManager powerManager = (PowerManager) mContext.getSystemService( Context.POWER_SERVICE); if (mBiometricUnlock != null) { if (!showing && wasShowing) { mBiometricUnlock.stop(); } else if (showing && powerManager.isScreenOn() && !wasShowing) { maybeStartBiometricUnlock(); @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 Loading Loading
packages/Keyguard/src/com/android/keyguard/KeyguardFaceUnlockView.java +57 −28 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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; } Loading @@ -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 Loading Loading @@ -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; handleBouncerUserVisibilityChanged(); } PowerManager powerManager = (PowerManager) mContext.getSystemService( Context.POWER_SERVICE); if (mBiometricUnlock != null) { if (!showing && wasShowing) { mBiometricUnlock.stop(); } else if (showing && powerManager.isScreenOn() && !wasShowing) { maybeStartBiometricUnlock(); @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 Loading