reset lockout deadline on device reboot

Gatekeeper retains lockouts after reboot, but framework
doesn't. This causes odd behavior on a reboot after a lockout
as gatekeeper refuses to check the password and the framework
thinks it's an invalid attempt. Reset the lockout deadline
if we notice the clock reset in the framework.

Bug: 23681267

Change-Id: I3127ccd8f205494af5a8ed2b44d4370c37cc2f8f
This commit is contained in:
Andres Morales
2015-09-08 13:17:37 -07:00
parent 5bba07eb01
commit a4e2337566

View File

@@ -1067,12 +1067,22 @@ public class LockPatternUtils {
* enter a pattern.
*/
public long getLockoutAttemptDeadline(int userId) {
final long deadline = getLong(LOCKOUT_ATTEMPT_DEADLINE, 0L, userId);
long deadline = getLong(LOCKOUT_ATTEMPT_DEADLINE, 0L, userId);
final long timeoutMs = getLong(LOCKOUT_ATTEMPT_TIMEOUT_MS, 0L, userId);
final long now = SystemClock.elapsedRealtime();
if (deadline < now || deadline > (now + timeoutMs)) {
if (deadline < now) {
// timeout expired
setLong(LOCKOUT_ATTEMPT_DEADLINE, 0, userId);
setLong(LOCKOUT_ATTEMPT_TIMEOUT_MS, 0, userId);
return 0L;
}
if (deadline > (now + timeoutMs)) {
// device was rebooted, set new deadline
deadline = now + timeoutMs;
setLong(LOCKOUT_ATTEMPT_DEADLINE, deadline, userId);
}
return deadline;
}