Skip to content

Commit 08b2b6b

Browse files
author
Jim Miller
committed
Fix keyguard timeout dialog messages
This fixes an issue where the attempt count was incorrect. We now show the dialog *after* reporting the failed attempt. This also fixes an issue where the text wasn't being reset in the password dialog of keyguard. Fixes bugs 7170545 and 7120895 Change-Id: Iba2009705373758acca6e10bd670eb34744bece9
1 parent 8b681cb commit 08b2b6b

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ private void reportFailedUnlockAttempt() {
348348
(failedAttemptsBeforeWipe - failedAttempts)
349349
: Integer.MAX_VALUE; // because DPM returns 0 if no restriction
350350

351+
boolean showTimeout = false;
351352
if (remainingBeforeWipe < LockPatternUtils.FAILED_ATTEMPTS_BEFORE_WIPE_GRACE) {
352353
// If we reach this code, it means the user has installed a DevicePolicyManager
353354
// that requests device wipe after N attempts. Once we get below the grace
@@ -361,7 +362,7 @@ private void reportFailedUnlockAttempt() {
361362
showWipeDialog(failedAttempts);
362363
}
363364
} else {
364-
boolean showTimeout =
365+
showTimeout =
365366
(failedAttempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) == 0;
366367
if (usingPattern && mEnableFallback) {
367368
if (failedAttempts == failedAttemptWarning) {
@@ -374,12 +375,12 @@ private void reportFailedUnlockAttempt() {
374375
showTimeout = false;
375376
}
376377
}
377-
if (showTimeout) {
378-
showTimeoutDialog();
379-
}
380378
}
381379
monitor.reportFailedUnlockAttempt();
382380
mLockPatternUtils.reportFailedPasswordAttempt();
381+
if (showTimeout) {
382+
showTimeoutDialog();
383+
}
383384
}
384385

385386
/**

policy/src/com/android/internal/policy/impl/keyguard/KeyguardPasswordView.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,17 @@ public void reset() {
9797
if (deadline != 0) {
9898
handleAttemptLockout(deadline);
9999
} else {
100-
mNavigationManager.setMessage(
101-
mIsAlpha ? R.string.kg_password_instructions : R.string.kg_pin_instructions);
100+
resetState();
102101
}
103102
}
104103

104+
private void resetState() {
105+
mNavigationManager.setMessage(
106+
mIsAlpha ? R.string.kg_password_instructions : R.string.kg_pin_instructions);
107+
mPasswordEntry.setEnabled(true);
108+
mKeyboardView.setEnabled(true);
109+
}
110+
105111
@Override
106112
protected void onFinishInflate() {
107113
mLockPatternUtils = new LockPatternUtils(mContext); // TODO: use common one
@@ -297,8 +303,7 @@ public void onTick(long millisUntilFinished) {
297303

298304
@Override
299305
public void onFinish() {
300-
mPasswordEntry.setEnabled(true);
301-
mKeyboardView.setEnabled(true);
306+
resetState();
302307
}
303308
}.start();
304309
}

policy/src/com/android/internal/policy/impl/keyguard/KeyguardStatusViewManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class KeyguardStatusViewManager {
5454
private static final int BATTERY_INFO = 15;
5555

5656
private StatusMode mStatus;
57-
private String mDateFormatString;
57+
private CharSequence mDateFormatString;
5858

5959
// Views that this class controls.
6060
// NOTE: These may be null in some LockScreen screens and should protect from NPE
@@ -101,7 +101,8 @@ class KeyguardStatusViewManager {
101101
public KeyguardStatusViewManager(View view) {
102102
if (DEBUG) Log.v(TAG, "KeyguardStatusViewManager()");
103103
mContainer = view;
104-
mDateFormatString = getContext().getString(R.string.abbrev_wday_month_day_no_year);
104+
mDateFormatString = getContext().getResources()
105+
.getText(R.string.abbrev_wday_month_day_no_year);
105106
mLockPatternUtils = new LockPatternUtils(view.getContext());
106107
mUpdateMonitor = KeyguardUpdateMonitor.getInstance(view.getContext());
107108

0 commit comments

Comments
 (0)