Display max retry lockout message on backup lock fixes 5462647
Change-Id: I75e51f45f821542ae380e4ec4e3232b3fbe660f4
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 286e549d..5219fcc 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/assets/res/any/strings.xml
**
@@ -1787,6 +1787,8 @@
<string name="lockscreen_pattern_wrong">Try again</string>
<!-- On the unlock password screen, shown when the user enters the wrong lock password and must try again. -->
<string name="lockscreen_password_wrong">Try again</string>
+ <!-- Shown when face unlock failed multiple times so we're just using the backup -->
+ <string name="faceunlock_multiple_failures">Maximum Face Unlock attempts exceeded</string>
<!-- When the lock screen is showing and the phone plugged in, and the battery
is not fully charged, show the current charge %. -->
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
index ee54de1..dbdfb98 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
@@ -293,6 +293,10 @@
mUpdateMonitor.registerInfoCallback(mInfoCallback);
mUpdateMonitor.registerSimStateCallback(mSimStateCallback);
resetStatusInfo();
+ //Issue the faceunlock failure message in a centralized place
+ if (mUpdateMonitor.getMaxFaceUnlockAttemptsReached()) {
+ setInstructionText(getContext().getString(R.string.faceunlock_multiple_failures));
+ }
}
void resetStatusInfo() {
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
index b4b82aa..1d6f39a 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
@@ -81,6 +81,8 @@
private CharSequence mTelephonySpn;
private int mFailedAttempts = 0;
+ private int mFailedFaceUnlockAttempts = 0;
+ private static final int FAILED_FACE_UNLOCK_ATTEMPTS_BEFORE_BACKUP = 15;
private boolean mClockVisible;
@@ -630,6 +632,7 @@
public void clearFailedAttempts() {
mFailedAttempts = 0;
+ mFailedFaceUnlockAttempts = 0;
}
public void reportFailedAttempt() {
@@ -643,4 +646,12 @@
public int getPhoneState() {
return mPhoneState;
}
+
+ public void reportFailedFaceUnlockAttempt() {
+ mFailedFaceUnlockAttempts++;
+ }
+
+ public boolean getMaxFaceUnlockAttemptsReached() {
+ return mFailedFaceUnlockAttempts >= FAILED_FACE_UNLOCK_ATTEMPTS_BEFORE_BACKUP;
+ }
}
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 11da17c5..7e48357c 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -132,10 +132,6 @@
// So the user has a consistent amount of time when brought to the backup method from FaceLock
private final int BACKUP_LOCK_TIMEOUT = 5000;
- // Needed to keep track of failed FaceUnlock attempts
- private int mFailedFaceUnlockAttempts = 0;
- private static final int FAILED_FACE_UNLOCK_ATTEMPTS_BEFORE_BACKUP = 15;
-
/**
* The current {@link KeyguardScreen} will use this to communicate back to us.
*/
@@ -464,7 +460,6 @@
}
public void reportSuccessfulUnlockAttempt() {
- mFailedFaceUnlockAttempts = 0;
mLockPatternUtils.reportSuccessfulPasswordAttempt();
}
};
@@ -583,8 +578,7 @@
* FaceLock, but only if we're not dealing with a call
*/
private void activateFaceLockIfAble() {
- final boolean tooManyFaceUnlockTries =
- (mFailedFaceUnlockAttempts >= FAILED_FACE_UNLOCK_ATTEMPTS_BEFORE_BACKUP);
+ final boolean tooManyFaceUnlockTries = mUpdateMonitor.getMaxFaceUnlockAttemptsReached();
final int failedBackupAttempts = mUpdateMonitor.getFailedAttempts();
final boolean backupIsTimedOut =
(failedBackupAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT);
@@ -1398,7 +1392,7 @@
@Override
public void reportFailedAttempt() {
if (DEBUG) Log.d(TAG, "FaceLock reportFailedAttempt()");
- mFailedFaceUnlockAttempts++;
+ mUpdateMonitor.reportFailedFaceUnlockAttempt();
hideFaceLockArea(); // Expose fallback
stopFaceLock();
mKeyguardScreenCallback.pokeWakelock(BACKUP_LOCK_TIMEOUT);