Skip to content

Commit 9ded0e1

Browse files
author
Brian Colonna
committed
FUL fallback is no longer account login - fix b/7280196
When Face Unlock failed the maximum number of times (3), it was asking for account login when it should have been asking for the backup lock that the user chose when setting up Face Unlock. This change splits the isBiometricUnlockEnabled() function into two. One of them strictly checks whether it exists and is selected. The other one checks whether too many attempts have occurred. When deciding which backup to choose, the decision is now based only on whether Face Unlock is enabled. Checking whether too many attempts had occurred caused the bug because the check indicated it had already 'fallen back' to pattern, and the backup for pattern was being selected instead of the backup for biometric unlock. Change-Id: I6b9cf2c5155e8c14933cbfc8f5d58ebc007e53cb
1 parent 0e2aade commit 9ded0e1

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ private void reportFailedUnlockAttempt() {
403403
* account unlock screen and biometric unlock to show the user's normal unlock.
404404
*/
405405
private void showBackupSecurity() {
406-
SecurityMode currentMode = mSecurityModel.getAlternateFor(mSecurityModel.getSecurityMode());
407-
showSecurityScreen(mSecurityModel.getBackupFor(currentMode));
406+
showSecurityScreen(mSecurityModel.getBackupSecurityMode());
408407
}
409408

410409
public boolean showNextSecurityScreenIfPresent() {

policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityModel.java

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,23 @@ void setLockPatternUtils(LockPatternUtils utils) {
4949
}
5050

5151
/**
52-
* This returns false if there is any condition that indicates that the biometric unlock should
53-
* not be used before the next time the unlock screen is recreated. In other words, if this
54-
* returns false there is no need to even construct the biometric unlock.
52+
* Returns true if biometric unlock is installed and selected. If this returns false there is
53+
* no need to even construct the biometric unlock.
5554
*/
5655
private boolean isBiometricUnlockEnabled() {
57-
KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
58-
final boolean backupIsTimedOut =
59-
monitor.getFailedUnlockAttempts() >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT;
6056
return mLockPatternUtils.usingBiometricWeak()
61-
&& mLockPatternUtils.isBiometricWeakInstalled()
62-
&& !monitor.getMaxBiometricUnlockAttemptsReached()
63-
&& !backupIsTimedOut;
57+
&& mLockPatternUtils.isBiometricWeakInstalled();
58+
}
59+
60+
/**
61+
* Returns true if a condition is currently suppressing the biometric unlock. If this returns
62+
* true there is no need to even construct the biometric unlock.
63+
*/
64+
private boolean isBiometricUnlockSuppressed() {
65+
KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
66+
final boolean backupIsTimedOut = monitor.getFailedUnlockAttempts() >=
67+
LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT;
68+
return monitor.getMaxBiometricUnlockAttemptsReached() || backupIsTimedOut;
6469
}
6570

6671
SecurityMode getSecurityMode() {
@@ -107,7 +112,7 @@ SecurityMode getSecurityMode() {
107112
* @return alternate or the given mode
108113
*/
109114
SecurityMode getAlternateFor(SecurityMode mode) {
110-
if (isBiometricUnlockEnabled()
115+
if (isBiometricUnlockEnabled() && !isBiometricUnlockSuppressed()
111116
&& (mode == SecurityMode.Password || mode == SecurityMode.Pattern)) {
112117
return SecurityMode.Biometric;
113118
}
@@ -118,16 +123,23 @@ SecurityMode getAlternateFor(SecurityMode mode) {
118123
* Some unlock methods can have a backup which gives the user another way to get into
119124
* the device. This is currently only supported for Biometric and Pattern unlock.
120125
*
121-
* @param mode the mode we want the backup for
122-
* @return backup method or given mode
126+
* @return backup method or current security mode
123127
*/
124-
SecurityMode getBackupFor(SecurityMode mode) {
128+
SecurityMode getBackupSecurityMode() {
129+
SecurityMode mode = getSecurityMode();
130+
131+
// Note that getAlternateFor() cannot be called here because we want to get the backup for
132+
// biometric unlock even if it's suppressed; it just has to be enabled.
133+
if (isBiometricUnlockEnabled()
134+
&& (mode == SecurityMode.Password || mode == SecurityMode.Pattern)) {
135+
mode = SecurityMode.Biometric;
136+
}
125137
switch(mode) {
126138
case Biometric:
127139
return getSecurityMode();
128140
case Pattern:
129141
return SecurityMode.Account;
130142
}
131-
return mode; // no backup, return what was given
143+
return mode; // no backup, return current security mode
132144
}
133145
}

0 commit comments

Comments
 (0)