From f9a166ab8236b5824049f5103c4365e12b52b4ac Mon Sep 17 00:00:00 2001 From: Konstantin Lopyrev Date: Tue, 1 Jun 2010 16:47:05 -0700 Subject: [PATCH] Fix 2571872: Showing an error message on wrong password/pin entered. Change-Id: I78463112326ebd1ac7d43d083e22d506518e84fd --- core/res/res/values/strings.xml | 2 ++ .../policy/impl/PasswordUnlockScreen.java | 30 +++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 61af22dd08498..5ef7b318bda95 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1470,6 +1470,8 @@ Correct! Sorry, try again + + Sorry, try again diff --git a/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java index 8fdff92c551bb..60cd56cec48c6 100644 --- a/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java +++ b/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java @@ -53,6 +53,8 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen private final KeyguardUpdateMonitor mUpdateMonitor; private final KeyguardScreenCallback mCallback; + private boolean mIsAlpha; + private EditText mPasswordEntry; private Button mEmergencyCallButton; private LockPatternUtils mLockPatternUtils; @@ -87,7 +89,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen } final int quality = lockPatternUtils.getKeyguardStoredPasswordQuality(); - final boolean isAlpha = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == quality + mIsAlpha = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == quality || DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == quality || DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == quality; @@ -100,7 +102,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen mTitle = (TextView) findViewById(R.id.enter_password_label); mKeyboardHelper = new PasswordEntryKeyboardHelper(context, mKeyboardView, this); - mKeyboardHelper.setKeyboardMode(isAlpha ? PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA + mKeyboardHelper.setKeyboardMode(mIsAlpha ? PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA : PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC); mKeyboardView.setVisibility(mCreationHardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO @@ -109,7 +111,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen // This allows keyboards with overlapping qwerty/numeric keys to choose just the // numeric keys. - if (isAlpha) { + if (mIsAlpha) { mPasswordEntry.setKeyListener(TextKeyListener.getInstance()); } else { mPasswordEntry.setKeyListener(DigitsKeyListener.getInstance()); @@ -140,6 +142,7 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen public void onResume() { // start fresh mPasswordEntry.setText(""); + resetStatusInfo(); mPasswordEntry.requestFocus(); mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton); @@ -176,6 +179,9 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen long deadline = mLockPatternUtils.setLockoutAttemptDeadline(); handleAttemptLockout(deadline); } + mTitle.setText(R.string.lockscreen_password_wrong); + } else if (entry.length() > 0) { + mTitle.setText(R.string.lockscreen_password_wrong); } mPasswordEntry.setText(""); } @@ -199,16 +205,8 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen @Override public void onFinish() { mPasswordEntry.setEnabled(true); - final int quality = mLockPatternUtils.getKeyguardStoredPasswordQuality(); - final boolean isAlpha = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == quality - || DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == quality - || DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == quality; - if(isAlpha) { - mTitle.setText(R.string.keyguard_password_enter_password_code); - } else { - mTitle.setText(R.string.keyguard_password_enter_pin_password_code); - } mKeyboardView.setEnabled(true); + resetStatusInfo(); } }.start(); } @@ -274,4 +272,12 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen } + private void resetStatusInfo() { + if(mIsAlpha) { + mTitle.setText(R.string.keyguard_password_enter_password_code); + } else { + mTitle.setText(R.string.keyguard_password_enter_pin_password_code); + } + } + }