From a4e23375663ac3a2b6115da71e6711282f03492d Mon Sep 17 00:00:00 2001 From: Andres Morales Date: Tue, 8 Sep 2015 13:17:37 -0700 Subject: 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 --- .../java/com/android/internal/widget/LockPatternUtils.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 86d11be78b0a..61ba4edd6650 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -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; } -- cgit v1.2.3-59-g8ed1b