summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2010-03-17 19:14:18 -0700
committerJim Miller <jaggies@google.com>2010-03-17 19:17:55 -0700
commit33579677979941a5a2fae93498e76829d2600f56 (patch)
tree3c492787bb193366974459c32101b9a558d368b9
parent95da65e172b846515b9245e4a01c3dc260177d68 (diff)
downloadbase-33579677979941a5a2fae93498e76829d2600f56.tar.gz
Fix 2520598: Disable password entry in keyguard while in lockout
The password unlock wasn't abiding by the 30s lockout rule. This change adds the necessary logic and countdown timer to disable text entry while in lockout mode. After 30s, text entry is re-enabled until the next lockout count is reached. Change-Id: I4d860565cad91cb88c36615b40d1837a5d97fe21
-rw-r--r--phone/com/android/internal/policy/impl/LockPatternKeyguardView.java6
-rw-r--r--phone/com/android/internal/policy/impl/PasswordUnlockScreen.java43
2 files changed, 47 insertions, 2 deletions
diff --git a/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java b/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 8ec1e74..3deee6f 100644
--- a/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/phone/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -300,11 +300,13 @@ public class LockPatternKeyguardView extends KeyguardViewBase
if (DEBUG) Log.d(TAG,
"reportFailedPatternAttempt: #" + failedAttempts +
" (enableFallback=" + mEnableFallback + ")");
- if (mEnableFallback && failedAttempts ==
+ final boolean usingLockPattern = mLockPatternUtils.getPasswordMode()
+ == LockPatternUtils.MODE_PATTERN;
+ if (usingLockPattern && mEnableFallback && failedAttempts ==
(LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET
- LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
showAlmostAtAccountLoginDialog();
- } else if (mEnableFallback
+ } else if (usingLockPattern && mEnableFallback
&& failedAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET) {
mLockPatternUtils.setPermanentlyLocked(true);
updateScreen(mMode);
diff --git a/phone/com/android/internal/policy/impl/PasswordUnlockScreen.java b/phone/com/android/internal/policy/impl/PasswordUnlockScreen.java
index 0bbab3e..e08fe4f 100644
--- a/phone/com/android/internal/policy/impl/PasswordUnlockScreen.java
+++ b/phone/com/android/internal/policy/impl/PasswordUnlockScreen.java
@@ -20,9 +20,12 @@ import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
+import com.android.internal.policy.impl.PatternUnlockScreen.FooterMode;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.PasswordEntryKeyboardView;
+import android.os.CountDownTimer;
+import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.text.method.DigitsKeyListener;
import android.text.method.TextKeyListener;
@@ -57,6 +60,8 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
private int mCreationOrientation;
private int mKeyboardHidden;
+ private CountDownTimer mCountdownTimer;
+ private TextView mTitle;
// To avoid accidental lockout due to events while the device in in the pocket, ignore
// any passwords with length less than or equal to this length.
@@ -87,6 +92,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
mEmergencyCallButton = (Button) findViewById(R.id.emergencyCall);
mEmergencyCallButton.setOnClickListener(this);
mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
+ mTitle = (TextView) findViewById(R.id.enter_password_label);
mKeyboardHelper = new PasswordEntryKeyboardHelper(context, mKeyboardView, this);
mKeyboardHelper.setKeyboardMode(isAlpha ? PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
@@ -130,6 +136,12 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
mPasswordEntry.setText("");
mPasswordEntry.requestFocus();
mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
+
+ // if the user is currently locked out, enforce it.
+ long deadline = mLockPatternUtils.getLockoutAttemptDeadline();
+ if (deadline != 0) {
+ handleAttemptLockout(deadline);
+ }
}
/** {@inheritDoc} */
@@ -153,10 +165,41 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
// to avoid accidental lockout, only count attempts that are long enough to be a
// real password. This may require some tweaking.
mCallback.reportFailedUnlockAttempt();
+ if (0 == (mUpdateMonitor.getFailedAttempts()
+ % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
+ long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
+ handleAttemptLockout(deadline);
+ }
}
mPasswordEntry.setText("");
}
+ // Prevent user from using the PIN/Password entry until scheduled deadline.
+ private void handleAttemptLockout(long elapsedRealtimeDeadline) {
+ mPasswordEntry.setEnabled(false);
+ mKeyboardView.setEnabled(false);
+ long elapsedRealtime = SystemClock.elapsedRealtime();
+ mCountdownTimer = new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime, 1000) {
+
+ @Override
+ public void onTick(long millisUntilFinished) {
+ int secondsRemaining = (int) (millisUntilFinished / 1000);
+ String instructions = getContext().getString(
+ R.string.lockscreen_too_many_failed_attempts_countdown,
+ secondsRemaining);
+ mTitle.setText(instructions);
+ }
+
+ @Override
+ public void onFinish() {
+ mPasswordEntry.setEnabled(true);
+ mTitle.setText(R.string.keyguard_password_enter_password_code);
+ mKeyboardView.setEnabled(true);
+ }
+ }.start();
+ }
+
+
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
mCallback.pokeWakelock();