Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4e23375 authored by Andres Morales's avatar Andres Morales
Browse files

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
parent 5bba07eb
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -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;
    }