diff options
author | Jim Miller <jaggies@google.com> | 2010-03-18 00:50:07 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-03-18 00:50:07 -0700 |
commit | e78fab5a2e386a80f981b185f335415a9bd4e7dd (patch) | |
tree | b012c1d039094dc538c24d996849301036e4cab9 /policy | |
parent | 0060a9b544e0a64ba2a7cd6f0025b6600e08f372 (diff) | |
parent | f1818ffd82ad288f52e81dae8eccc44db10c6564 (diff) | |
download | frameworks_base-e78fab5a2e386a80f981b185f335415a9bd4e7dd.zip frameworks_base-e78fab5a2e386a80f981b185f335415a9bd4e7dd.tar.gz frameworks_base-e78fab5a2e386a80f981b185f335415a9bd4e7dd.tar.bz2 |
Merge "Fix 2520598: Disable password entry in keyguard while in lockout"
Diffstat (limited to 'policy')
-rw-r--r-- | policy/com/android/internal/policy/impl/LockPatternKeyguardView.java | 6 | ||||
-rw-r--r-- | policy/com/android/internal/policy/impl/PasswordUnlockScreen.java | 43 |
2 files changed, 47 insertions, 2 deletions
diff --git a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java index 8ec1e74..3deee6f 100644 --- a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java +++ b/policy/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/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java index 0bbab3e..e08fe4f 100644 --- a/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java +++ b/policy/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(); |