am ecba937b: DO NOT MERGE - Fix keyguard pattern lockout bug

* commit 'ecba937b005b07d72eadfaf93a200e0b14af2980':
  DO NOT MERGE - Fix keyguard pattern lockout bug
This commit is contained in:
Adrian Roos
2014-03-18 13:17:12 -07:00
committed by Android Git Automerger

View File

@ -59,8 +59,8 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
// how many cells the user has to cross before we poke the wakelock // how many cells the user has to cross before we poke the wakelock
private static final int MIN_PATTERN_BEFORE_POKE_WAKELOCK = 2; private static final int MIN_PATTERN_BEFORE_POKE_WAKELOCK = 2;
private int mFailedPatternAttemptsSinceLastTimeout = 0; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private int mTotalFailedPatternAttempts = 0;
private CountDownTimer mCountdownTimer = null; private CountDownTimer mCountdownTimer = null;
private LockPatternUtils mLockPatternUtils; private LockPatternUtils mLockPatternUtils;
private LockPatternView mLockPatternView; private LockPatternView mLockPatternView;
@ -101,6 +101,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
public KeyguardPatternView(Context context, AttributeSet attrs) { public KeyguardPatternView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
} }
public void setKeyguardCallback(KeyguardSecurityCallback callback) { public void setKeyguardCallback(KeyguardSecurityCallback callback) {
@ -203,7 +204,8 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
if (mCallback.isVerifyUnlockOnly()) { if (mCallback.isVerifyUnlockOnly()) {
updateFooter(FooterMode.VerifyUnlocked); updateFooter(FooterMode.VerifyUnlocked);
} else if (mEnableFallback && } else if (mEnableFallback &&
(mTotalFailedPatternAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) { (mKeyguardUpdateMonitor.getFailedUnlockAttempts()
>= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
updateFooter(FooterMode.ForgotLockPattern); updateFooter(FooterMode.ForgotLockPattern);
} else { } else {
updateFooter(FooterMode.Normal); updateFooter(FooterMode.Normal);
@ -212,7 +214,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
} }
private void displayDefaultSecurityMessage() { private void displayDefaultSecurityMessage() {
if (KeyguardUpdateMonitor.getInstance(mContext).getMaxBiometricUnlockAttemptsReached()) { if (mKeyguardUpdateMonitor.getMaxBiometricUnlockAttemptsReached()) {
mSecurityMessageDisplay.setMessage(R.string.faceunlock_multiple_failures, true); mSecurityMessageDisplay.setMessage(R.string.faceunlock_multiple_failures, true);
} else { } else {
mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions, false); mSecurityMessageDisplay.setMessage(R.string.kg_pattern_instructions, false);
@ -263,20 +265,20 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
if (mLockPatternUtils.checkPattern(pattern)) { if (mLockPatternUtils.checkPattern(pattern)) {
mCallback.reportSuccessfulUnlockAttempt(); mCallback.reportSuccessfulUnlockAttempt();
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct); mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
mTotalFailedPatternAttempts = 0;
mCallback.dismiss(true); mCallback.dismiss(true);
} else { } else {
if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) { if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS); mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
} }
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong); mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) { boolean registeredAttempt =
mTotalFailedPatternAttempts++; pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL;
mFailedPatternAttemptsSinceLastTimeout++; if (registeredAttempt) {
mCallback.reportFailedUnlockAttempt(); mCallback.reportFailedUnlockAttempt();
} }
if (mFailedPatternAttemptsSinceLastTimeout int attempts = mKeyguardUpdateMonitor.getFailedUnlockAttempts();
>= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) { if (registeredAttempt &&
0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(); long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
handleAttemptLockout(deadline); handleAttemptLockout(deadline);
} else { } else {
@ -364,7 +366,6 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
mLockPatternView.setEnabled(true); mLockPatternView.setEnabled(true);
displayDefaultSecurityMessage(); displayDefaultSecurityMessage();
// TODO mUnlockIcon.setVisibility(View.VISIBLE); // TODO mUnlockIcon.setVisibility(View.VISIBLE);
mFailedPatternAttemptsSinceLastTimeout = 0;
if (mEnableFallback) { if (mEnableFallback) {
updateFooter(FooterMode.ForgotLockPattern); updateFooter(FooterMode.ForgotLockPattern);
} else { } else {