summaryrefslogtreecommitdiffstats
path: root/packages/Keyguard
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Keyguard')
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java33
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java26
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardSecurityCallback.java4
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java28
4 files changed, 44 insertions, 47 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
index 6295de4..4edc1c9 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
@@ -114,35 +114,40 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
if (mPendingLockCheck != null) {
mPendingLockCheck.cancel(false);
}
+
+ if (entry.length() < MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT) {
+ // to avoid accidental lockout, only count attempts that are long enough to be a
+ // real password. This may require some tweaking.
+ setPasswordEntryInputEnabled(true);
+ onPasswordChecked(entry, false, 0);
+ return;
+ }
+
mPendingLockCheck = LockPatternChecker.checkPassword(
mLockPatternUtils,
entry,
KeyguardUpdateMonitor.getCurrentUser(),
new LockPatternChecker.OnCheckCallback() {
@Override
- public void onChecked(boolean matched) {
+ public void onChecked(boolean matched, int timeoutMs) {
setPasswordEntryInputEnabled(true);
mPendingLockCheck = null;
- onPasswordChecked(entry, matched);
+ onPasswordChecked(entry, matched, timeoutMs);
}
});
}
- private void onPasswordChecked(String entry, boolean matched) {
+ private void onPasswordChecked(String entry, boolean matched, int timeoutMs) {
if (matched) {
- mCallback.reportUnlockAttempt(true);
+ mCallback.reportUnlockAttempt(true, 0);
mCallback.dismiss(true);
} else {
- if (entry.length() > MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT ) {
- // to avoid accidental lockout, only count attempts that are long enough to be a
- // real password. This may require some tweaking.
- mCallback.reportUnlockAttempt(false);
- int attempts = KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts();
- if (0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
- long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
- KeyguardUpdateMonitor.getCurrentUser());
- handleAttemptLockout(deadline);
- }
+ mCallback.reportUnlockAttempt(false, timeoutMs);
+ int attempts = KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts();
+ if (timeoutMs > 0) {
+ long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
+ KeyguardUpdateMonitor.getCurrentUser(), timeoutMs);
+ handleAttemptLockout(deadline);
}
mSecurityMessageDisplay.setMessage(getWrongPasswordStringId(), true);
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
index 35c6873..ed595c0 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
@@ -224,23 +224,30 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
mPendingLockCheck.cancel(false);
}
+ if (pattern.size() < LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
+ mLockPatternView.enableInput();
+ onPatternChecked(pattern, false, 0);
+ return;
+ }
+
mPendingLockCheck = LockPatternChecker.checkPattern(
mLockPatternUtils,
pattern,
KeyguardUpdateMonitor.getCurrentUser(),
new LockPatternChecker.OnCheckCallback() {
@Override
- public void onChecked(boolean matched) {
+ public void onChecked(boolean matched, int timeoutMs) {
mLockPatternView.enableInput();
mPendingLockCheck = null;
- onPatternChecked(pattern, matched);
+ onPatternChecked(pattern, matched, timeoutMs);
}
});
}
- private void onPatternChecked(List<LockPatternView.Cell> pattern, boolean matched) {
+ private void onPatternChecked(List<LockPatternView.Cell> pattern, boolean matched,
+ int timeoutMs) {
if (matched) {
- mCallback.reportUnlockAttempt(true);
+ mCallback.reportUnlockAttempt(true, 0);
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
mCallback.dismiss(true);
} else {
@@ -248,16 +255,11 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
mCallback.userActivity();
}
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
- boolean registeredAttempt =
- pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL;
- if (registeredAttempt) {
- mCallback.reportUnlockAttempt(false);
- }
+ mCallback.reportUnlockAttempt(false, timeoutMs);
int attempts = mKeyguardUpdateMonitor.getFailedUnlockAttempts();
- if (registeredAttempt &&
- 0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
+ if (timeoutMs > 0) {
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
- KeyguardUpdateMonitor.getCurrentUser());
+ KeyguardUpdateMonitor.getCurrentUser(), timeoutMs);
handleAttemptLockout(deadline);
} else {
mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern, true);
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityCallback.java
index 5877bc8..836c195 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityCallback.java
@@ -37,8 +37,10 @@ public interface KeyguardSecurityCallback {
/**
* Call to report an unlock attempt.
* @param success set to 'true' if user correctly entered security credentials.
+ * @param timeoutMs timeout in milliseconds to wait before reattempting an unlock.
+ * Only nonzero if 'success' is false
*/
- void reportUnlockAttempt(boolean success);
+ void reportUnlockAttempt(boolean success, int timeoutMs);
/**
* Resets the keyguard view.
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
index 4d89a8d..d17b25a 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -176,8 +176,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
dialog.show();
}
- private void showTimeoutDialog() {
- int timeoutInSeconds = (int) LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS / 1000;
+ private void showTimeoutDialog(int timeoutMs) {
+ int timeoutInSeconds = (int) timeoutMs / 1000;
int messageId = 0;
switch (mSecurityModel.getSecurityMode()) {
@@ -244,16 +244,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
showDialog(null, message);
}
- private void showAlmostAtAccountLoginDialog() {
- final int timeoutInSeconds = (int) LockPatternUtils.FAILED_ATTEMPT_TIMEOUT_MS / 1000;
- final int count = LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET
- - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT;
- String message = mContext.getString(R.string.kg_failed_attempts_almost_at_login,
- count, LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT, timeoutInSeconds);
- showDialog(null, message);
- }
-
- private void reportFailedUnlockAttempt() {
+ private void reportFailedUnlockAttempt(int timeoutMs) {
final KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
final int failedAttempts = monitor.getFailedUnlockAttempts() + 1; // +1 for this time
@@ -290,14 +281,11 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
Slog.i(TAG, "Too many unlock attempts; user " + expiringUser + " will be wiped!");
showWipeDialog(failedAttempts, userType);
}
- } else {
- showTimeout =
- (failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) == 0;
}
monitor.reportFailedUnlockAttempt();
mLockPatternUtils.reportFailedPasswordAttempt(KeyguardUpdateMonitor.getCurrentUser());
- if (showTimeout) {
- showTimeoutDialog();
+ if (timeoutMs > 0) {
+ showTimeoutDialog(timeoutMs);
}
}
@@ -425,14 +413,14 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
return mIsVerifyUnlockOnly;
}
- public void reportUnlockAttempt(boolean success) {
+ public void reportUnlockAttempt(boolean success, int timeoutMs) {
KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
if (success) {
monitor.clearFailedUnlockAttempts();
mLockPatternUtils.reportSuccessfulPasswordAttempt(
KeyguardUpdateMonitor.getCurrentUser());
} else {
- KeyguardSecurityContainer.this.reportFailedUnlockAttempt();
+ KeyguardSecurityContainer.this.reportFailedUnlockAttempt(timeoutMs);
}
}
@@ -448,7 +436,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
@Override
public void userActivity() { }
@Override
- public void reportUnlockAttempt(boolean success) { }
+ public void reportUnlockAttempt(boolean success, int timeoutMs) { }
@Override
public boolean isVerifyUnlockOnly() { return false; }
@Override