am 45fcaa54: Merge "Don\'t wipe device because of short PIN, patterns or passwords" into mnc-dev

* commit '45fcaa547dc5b9eb2c20879b290415daa1446004':
  Don't wipe device because of short PIN, patterns or passwords
This commit is contained in:
Jim Miller
2015-08-03 20:33:00 +00:00
committed by Android Git Automerger
2 changed files with 42 additions and 25 deletions

View File

@@ -53,15 +53,18 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
super(context, attrs);
}
@Override
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
mCallback = callback;
}
@Override
public void setLockPatternUtils(LockPatternUtils utils) {
mLockPatternUtils = utils;
mEnableHaptics = mLockPatternUtils.isTactileFeedbackEnabled();
}
@Override
public void reset() {
// start fresh
resetPasswordText(false /* animate */);
@@ -95,6 +98,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
}
}
@Override
public void onEmergencyButtonClickedWhenInCall() {
mCallback.reset();
}
@@ -115,11 +119,11 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
mPendingLockCheck.cancel(false);
}
if (entry.length() < MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT) {
if (entry.length() <= MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT) {
// to avoid accidental lockout, only count attempts that are long enough to be a
// real password. This may require some tweaking.
setPasswordEntryInputEnabled(true);
onPasswordChecked(entry, false, 0);
onPasswordChecked(false /* matched */, 0, false /* not valid - too short */);
return;
}
@@ -132,24 +136,27 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
public void onChecked(boolean matched, int timeoutMs) {
setPasswordEntryInputEnabled(true);
mPendingLockCheck = null;
onPasswordChecked(entry, matched, timeoutMs);
onPasswordChecked(matched, timeoutMs, true /* isValidPassword */);
}
});
}
private void onPasswordChecked(String entry, boolean matched, int timeoutMs) {
private void onPasswordChecked(boolean matched, int timeoutMs, boolean isValidPassword) {
if (matched) {
mCallback.reportUnlockAttempt(true, 0);
mCallback.dismiss(true);
} else {
mCallback.reportUnlockAttempt(false, timeoutMs);
int attempts = KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts();
if (timeoutMs > 0) {
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
KeyguardUpdateMonitor.getCurrentUser(), timeoutMs);
handleAttemptLockout(deadline);
if (isValidPassword) {
mCallback.reportUnlockAttempt(false, timeoutMs);
if (timeoutMs > 0) {
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
KeyguardUpdateMonitor.getCurrentUser(), timeoutMs);
handleAttemptLockout(deadline);
}
}
if (timeoutMs == 0) {
mSecurityMessageDisplay.setMessage(getWrongPasswordStringId(), true);
}
mSecurityMessageDisplay.setMessage(getWrongPasswordStringId(), true);
}
resetPasswordText(true /* animate */);
}

View File

@@ -82,6 +82,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
* Useful for clearing out the wrong pattern after a delay
*/
private Runnable mCancelPatternRunnable = new Runnable() {
@Override
public void run() {
mLockPatternView.clearPattern();
}
@@ -117,10 +118,12 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
R.dimen.disappear_y_translation);
}
@Override
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
mCallback = callback;
}
@Override
public void setLockPatternUtils(LockPatternUtils utils) {
mLockPatternUtils = utils;
}
@@ -153,6 +156,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
}
}
@Override
public void onEmergencyButtonClickedWhenInCall() {
mCallback.reset();
}
@@ -174,6 +178,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
return result;
}
@Override
public void reset() {
// reset lock pattern
mLockPatternView.enableInput();
@@ -207,18 +212,22 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
private class UnlockPatternListener implements LockPatternView.OnPatternListener {
@Override
public void onPatternStart() {
mLockPatternView.removeCallbacks(mCancelPatternRunnable);
mSecurityMessageDisplay.setMessage("", false);
}
@Override
public void onPatternCleared() {
}
@Override
public void onPatternCellAdded(List<LockPatternView.Cell> pattern) {
mCallback.userActivity();
}
@Override
public void onPatternDetected(final List<LockPatternView.Cell> pattern) {
mLockPatternView.disableInput();
if (mPendingLockCheck != null) {
@@ -227,7 +236,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
if (pattern.size() < LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
mLockPatternView.enableInput();
onPatternChecked(pattern, false, 0);
onPatternChecked(false, 0, false /* not valid - too short */);
return;
}
@@ -240,29 +249,30 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
public void onChecked(boolean matched, int timeoutMs) {
mLockPatternView.enableInput();
mPendingLockCheck = null;
onPatternChecked(pattern, matched, timeoutMs);
onPatternChecked(matched, timeoutMs, true);
}
});
if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
mCallback.userActivity();
}
}
private void onPatternChecked(List<LockPatternView.Cell> pattern, boolean matched,
int timeoutMs) {
private void onPatternChecked(boolean matched, int timeoutMs, boolean isValidPattern) {
if (matched) {
mCallback.reportUnlockAttempt(true, 0);
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
mCallback.dismiss(true);
} else {
if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
mCallback.userActivity();
}
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
mCallback.reportUnlockAttempt(false, timeoutMs);
int attempts = mKeyguardUpdateMonitor.getFailedUnlockAttempts();
if (timeoutMs > 0) {
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
KeyguardUpdateMonitor.getCurrentUser(), timeoutMs);
handleAttemptLockout(deadline);
} else {
if (isValidPattern) {
mCallback.reportUnlockAttempt(false, timeoutMs);
if (timeoutMs > 0) {
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
KeyguardUpdateMonitor.getCurrentUser(), timeoutMs);
handleAttemptLockout(deadline);
}
}
if (timeoutMs == 0) {
mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern, true);
mLockPatternView.postDelayed(mCancelPatternRunnable, PATTERN_CLEAR_TIMEOUT_MS);
}