Merge "Fix 2385283,2379269: report unlock attempt success/fail to DevicePolicyManager Reports success/fail for password, pattern and account unlock. Tweak pattern timeout a bit to avoid timeouts."
This commit is contained in:
@@ -177,12 +177,14 @@ public class AccountUnlockScreen extends RelativeLayout implements KeyguardScree
|
||||
intent.setClassName(LOCK_PATTERN_PACKAGE, LOCK_PATTERN_CLASS);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
mCallback.reportSuccessfulUnlockAttempt();
|
||||
|
||||
// close the keyguard
|
||||
mCallback.keyguardDone(true);
|
||||
} else {
|
||||
mInstructions.setText(R.string.lockscreen_glogin_invalid_input);
|
||||
mPassword.setText("");
|
||||
mCallback.reportFailedUnlockAttempt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,13 +63,18 @@ public interface KeyguardScreenCallback extends KeyguardViewCallback {
|
||||
void takeEmergencyCallAction();
|
||||
|
||||
/**
|
||||
* Report that the user had a failed attempt unlocking via the pattern.
|
||||
* Report that the user had a failed attempt to unlock with password or pattern.
|
||||
*/
|
||||
void reportFailedPatternAttempt();
|
||||
void reportFailedUnlockAttempt();
|
||||
|
||||
/**
|
||||
* Report that the user successfully entered their password or pattern.
|
||||
*/
|
||||
void reportSuccessfulUnlockAttempt();
|
||||
|
||||
/**
|
||||
* Report whether we there's another way to unlock the device.
|
||||
* @return true
|
||||
* @return true
|
||||
*/
|
||||
boolean doesFallbackUnlockScreenExist();
|
||||
}
|
||||
|
||||
@@ -293,6 +293,14 @@ public class LockPatternKeyguardView extends KeyguardViewBase
|
||||
public boolean doesFallbackUnlockScreenExist() {
|
||||
return mEnableFallback;
|
||||
}
|
||||
|
||||
public void reportFailedUnlockAttempt() {
|
||||
mLockPatternUtils.reportFailedPasswordAttempt();
|
||||
}
|
||||
|
||||
public void reportSuccessfulUnlockAttempt() {
|
||||
mLockPatternUtils.reportSuccessfulPasswordAttempt();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,11 +51,13 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
|
||||
private TextView mCarrier;
|
||||
private LockPatternUtils mLockPatternUtils;
|
||||
private Button mCancelButton;
|
||||
private int mPasswordAttempts = 0;
|
||||
private int mMinimumPasswordLength = 4; // TODO: get from policy store
|
||||
|
||||
private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
|
||||
|
||||
// To avoid accidental lockout due to events while the device in in the pocket, ignore
|
||||
// any passwords with length less than or equal to this length.
|
||||
private static final int MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT = 3;
|
||||
|
||||
public PasswordUnlockScreen(Context context, LockPatternUtils lockPatternUtils,
|
||||
KeyguardUpdateMonitor updateMonitor, KeyguardScreenCallback callback) {
|
||||
super(context);
|
||||
@@ -142,12 +144,12 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
|
||||
private void verifyPasswordAndUnlock() {
|
||||
String entry = mPasswordTextView.getText().toString();
|
||||
if (mLockPatternUtils.checkPassword(entry)) {
|
||||
mPasswordAttempts = 0;
|
||||
mCallback.keyguardDone(true);
|
||||
} else if (entry.length() >= mMinimumPasswordLength ) {
|
||||
mCallback.reportSuccessfulUnlockAttempt();
|
||||
} else 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.
|
||||
mPasswordAttempts++;
|
||||
mCallback.reportFailedUnlockAttempt();
|
||||
}
|
||||
mPasswordTextView.setText("");
|
||||
}
|
||||
|
||||
@@ -52,12 +52,20 @@ class UnlockScreen extends LinearLayoutWithDefaultTouchRecepient
|
||||
// how long before we clear the wrong pattern
|
||||
private static final int PATTERN_CLEAR_TIMEOUT_MS = 2000;
|
||||
|
||||
// how long we stay awake once the user is ready to enter a pattern
|
||||
// how long we stay awake after each key beyond MIN_PATTERN_BEFORE_POKE_WAKELOCK
|
||||
private static final int UNLOCK_PATTERN_WAKE_INTERVAL_MS = 7000;
|
||||
|
||||
// how long we stay awake after the user hits the first dot.
|
||||
private static final int UNLOCK_PATTERN_WAKE_INTERVAL_FIRST_DOTS_MS = 2000;
|
||||
|
||||
// how many cells the user has to cross before we poke the wakelock
|
||||
private static final int MIN_PATTERN_BEFORE_POKE_WAKELOCK = 2;
|
||||
|
||||
// This dictates how long a pattern should be before we count it as an attempt.
|
||||
// This should be long enough to avoid false triggers while the device is in a pocket,
|
||||
// as this can lead to a wiped device if a {@link DeviceAdmin} is active and has it enabled.
|
||||
private static final int MIN_PATTERN_BEFORE_REPORT = 3;
|
||||
|
||||
private int mFailedPatternAttemptsSinceLastTimeout = 0;
|
||||
private int mTotalFailedPatternAttempts = 0;
|
||||
private CountDownTimer mCountdownTimer = null;
|
||||
@@ -466,6 +474,9 @@ class UnlockScreen extends LinearLayoutWithDefaultTouchRecepient
|
||||
// the user actually trying to draw a pattern of some minimal length.
|
||||
if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
|
||||
mCallback.pokeWakelock(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
|
||||
} else {
|
||||
// Give just a little extra time if they hit one of the first few dots
|
||||
mCallback.pokeWakelock(UNLOCK_PATTERN_WAKE_INTERVAL_FIRST_DOTS_MS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,6 +487,7 @@ class UnlockScreen extends LinearLayoutWithDefaultTouchRecepient
|
||||
mInstructions = "";
|
||||
updateStatusLines();
|
||||
mCallback.keyguardDone(true);
|
||||
mCallback.reportSuccessfulUnlockAttempt();
|
||||
} else {
|
||||
if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
|
||||
mCallback.pokeWakelock(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
|
||||
@@ -484,19 +496,21 @@ class UnlockScreen extends LinearLayoutWithDefaultTouchRecepient
|
||||
if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
|
||||
mTotalFailedPatternAttempts++;
|
||||
mFailedPatternAttemptsSinceLastTimeout++;
|
||||
mCallback.reportFailedPatternAttempt();
|
||||
}
|
||||
if (mFailedPatternAttemptsSinceLastTimeout >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
|
||||
long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
|
||||
handleAttemptLockout(deadline);
|
||||
return;
|
||||
} else {
|
||||
// TODO mUnlockIcon.setVisibility(View.VISIBLE);
|
||||
mInstructions = getContext().getString(R.string.lockscreen_pattern_wrong);
|
||||
updateStatusLines();
|
||||
mLockPatternView.postDelayed(
|
||||
mCancelPatternRunnable,
|
||||
PATTERN_CLEAR_TIMEOUT_MS);
|
||||
}
|
||||
if (pattern.size() > MIN_PATTERN_BEFORE_REPORT) {
|
||||
mCallback.reportFailedUnlockAttempt();
|
||||
}
|
||||
// TODO mUnlockIcon.setVisibility(View.VISIBLE);
|
||||
mInstructions = getContext().getString(R.string.lockscreen_pattern_wrong);
|
||||
updateStatusLines();
|
||||
mLockPatternView.postDelayed(
|
||||
mCancelPatternRunnable,
|
||||
PATTERN_CLEAR_TIMEOUT_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user