Merge "Don't wipe device because of short PIN, patterns or passwords" into mnc-dev
This commit is contained in:
@@ -53,15 +53,18 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
|||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setLockPatternUtils(LockPatternUtils utils) {
|
public void setLockPatternUtils(LockPatternUtils utils) {
|
||||||
mLockPatternUtils = utils;
|
mLockPatternUtils = utils;
|
||||||
mEnableHaptics = mLockPatternUtils.isTactileFeedbackEnabled();
|
mEnableHaptics = mLockPatternUtils.isTactileFeedbackEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
// start fresh
|
// start fresh
|
||||||
resetPasswordText(false /* animate */);
|
resetPasswordText(false /* animate */);
|
||||||
@@ -95,6 +98,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEmergencyButtonClickedWhenInCall() {
|
public void onEmergencyButtonClickedWhenInCall() {
|
||||||
mCallback.reset();
|
mCallback.reset();
|
||||||
}
|
}
|
||||||
@@ -115,11 +119,11 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
|||||||
mPendingLockCheck.cancel(false);
|
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
|
// to avoid accidental lockout, only count attempts that are long enough to be a
|
||||||
// real password. This may require some tweaking.
|
// real password. This may require some tweaking.
|
||||||
setPasswordEntryInputEnabled(true);
|
setPasswordEntryInputEnabled(true);
|
||||||
onPasswordChecked(entry, false, 0);
|
onPasswordChecked(false /* matched */, 0, false /* not valid - too short */);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,24 +136,27 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
|||||||
public void onChecked(boolean matched, int timeoutMs) {
|
public void onChecked(boolean matched, int timeoutMs) {
|
||||||
setPasswordEntryInputEnabled(true);
|
setPasswordEntryInputEnabled(true);
|
||||||
mPendingLockCheck = null;
|
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) {
|
if (matched) {
|
||||||
mCallback.reportUnlockAttempt(true, 0);
|
mCallback.reportUnlockAttempt(true, 0);
|
||||||
mCallback.dismiss(true);
|
mCallback.dismiss(true);
|
||||||
} else {
|
} else {
|
||||||
mCallback.reportUnlockAttempt(false, timeoutMs);
|
if (isValidPassword) {
|
||||||
int attempts = KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts();
|
mCallback.reportUnlockAttempt(false, timeoutMs);
|
||||||
if (timeoutMs > 0) {
|
if (timeoutMs > 0) {
|
||||||
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
|
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
|
||||||
KeyguardUpdateMonitor.getCurrentUser(), timeoutMs);
|
KeyguardUpdateMonitor.getCurrentUser(), timeoutMs);
|
||||||
handleAttemptLockout(deadline);
|
handleAttemptLockout(deadline);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (timeoutMs == 0) {
|
||||||
|
mSecurityMessageDisplay.setMessage(getWrongPasswordStringId(), true);
|
||||||
}
|
}
|
||||||
mSecurityMessageDisplay.setMessage(getWrongPasswordStringId(), true);
|
|
||||||
}
|
}
|
||||||
resetPasswordText(true /* animate */);
|
resetPasswordText(true /* animate */);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
* Useful for clearing out the wrong pattern after a delay
|
* Useful for clearing out the wrong pattern after a delay
|
||||||
*/
|
*/
|
||||||
private Runnable mCancelPatternRunnable = new Runnable() {
|
private Runnable mCancelPatternRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mLockPatternView.clearPattern();
|
mLockPatternView.clearPattern();
|
||||||
}
|
}
|
||||||
@@ -117,10 +118,12 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
R.dimen.disappear_y_translation);
|
R.dimen.disappear_y_translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setLockPatternUtils(LockPatternUtils utils) {
|
public void setLockPatternUtils(LockPatternUtils utils) {
|
||||||
mLockPatternUtils = utils;
|
mLockPatternUtils = utils;
|
||||||
}
|
}
|
||||||
@@ -153,6 +156,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onEmergencyButtonClickedWhenInCall() {
|
public void onEmergencyButtonClickedWhenInCall() {
|
||||||
mCallback.reset();
|
mCallback.reset();
|
||||||
}
|
}
|
||||||
@@ -174,6 +178,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
// reset lock pattern
|
// reset lock pattern
|
||||||
mLockPatternView.enableInput();
|
mLockPatternView.enableInput();
|
||||||
@@ -207,18 +212,22 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
|
|
||||||
private class UnlockPatternListener implements LockPatternView.OnPatternListener {
|
private class UnlockPatternListener implements LockPatternView.OnPatternListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onPatternStart() {
|
public void onPatternStart() {
|
||||||
mLockPatternView.removeCallbacks(mCancelPatternRunnable);
|
mLockPatternView.removeCallbacks(mCancelPatternRunnable);
|
||||||
mSecurityMessageDisplay.setMessage("", false);
|
mSecurityMessageDisplay.setMessage("", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onPatternCleared() {
|
public void onPatternCleared() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onPatternCellAdded(List<LockPatternView.Cell> pattern) {
|
public void onPatternCellAdded(List<LockPatternView.Cell> pattern) {
|
||||||
mCallback.userActivity();
|
mCallback.userActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onPatternDetected(final List<LockPatternView.Cell> pattern) {
|
public void onPatternDetected(final List<LockPatternView.Cell> pattern) {
|
||||||
mLockPatternView.disableInput();
|
mLockPatternView.disableInput();
|
||||||
if (mPendingLockCheck != null) {
|
if (mPendingLockCheck != null) {
|
||||||
@@ -227,7 +236,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
|
|
||||||
if (pattern.size() < LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
|
if (pattern.size() < LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
|
||||||
mLockPatternView.enableInput();
|
mLockPatternView.enableInput();
|
||||||
onPatternChecked(pattern, false, 0);
|
onPatternChecked(false, 0, false /* not valid - too short */);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,29 +249,30 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
public void onChecked(boolean matched, int timeoutMs) {
|
public void onChecked(boolean matched, int timeoutMs) {
|
||||||
mLockPatternView.enableInput();
|
mLockPatternView.enableInput();
|
||||||
mPendingLockCheck = null;
|
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,
|
private void onPatternChecked(boolean matched, int timeoutMs, boolean isValidPattern) {
|
||||||
int timeoutMs) {
|
|
||||||
if (matched) {
|
if (matched) {
|
||||||
mCallback.reportUnlockAttempt(true, 0);
|
mCallback.reportUnlockAttempt(true, 0);
|
||||||
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
|
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
|
||||||
mCallback.dismiss(true);
|
mCallback.dismiss(true);
|
||||||
} else {
|
} else {
|
||||||
if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
|
|
||||||
mCallback.userActivity();
|
|
||||||
}
|
|
||||||
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
|
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
|
||||||
mCallback.reportUnlockAttempt(false, timeoutMs);
|
if (isValidPattern) {
|
||||||
int attempts = mKeyguardUpdateMonitor.getFailedUnlockAttempts();
|
mCallback.reportUnlockAttempt(false, timeoutMs);
|
||||||
if (timeoutMs > 0) {
|
if (timeoutMs > 0) {
|
||||||
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
|
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
|
||||||
KeyguardUpdateMonitor.getCurrentUser(), timeoutMs);
|
KeyguardUpdateMonitor.getCurrentUser(), timeoutMs);
|
||||||
handleAttemptLockout(deadline);
|
handleAttemptLockout(deadline);
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
if (timeoutMs == 0) {
|
||||||
mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern, true);
|
mSecurityMessageDisplay.setMessage(R.string.kg_wrong_pattern, true);
|
||||||
mLockPatternView.postDelayed(mCancelPatternRunnable, PATTERN_CLEAR_TIMEOUT_MS);
|
mLockPatternView.postDelayed(mCancelPatternRunnable, PATTERN_CLEAR_TIMEOUT_MS);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user