Skip to content

Commit eb7f157

Browse files
Brian ColonnaAndroid (Google) Code Review
authored andcommitted
Merge "FUL fallback is no longer account login - fix b/7280196" into jb-mr1-dev
2 parents 0c9b535 + 9ded0e1 commit eb7f157

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)