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

Commit a3e5582f authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Don't store lockout deadline in lockSettings

The deadline is enforced in gatekeeper, which persists after reboot.
Users should not see the lockout timer after rebooting the device if it
was previously in lockout, until an unlock attempt occurs.

Fixes: 66443036

Test: 1) fail pattern five times
2) reboot device
3) go to bouncer, lockout timer should not show
4) upon entering pattern, timeout should show (if done fast enough)

Change-Id: Ie07945b40c2f482fd1df7102ba96283ae9d98d75
parent 292d895f
Loading
Loading
Loading
Loading
+5 −15
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseIntArray;
import android.util.SparseLongArray;

import com.android.internal.annotations.VisibleForTesting;
import com.google.android.collect.Lists;
@@ -120,8 +121,6 @@ public class LockPatternUtils {

    @Deprecated
    public final static String LOCKOUT_PERMANENT_KEY = "lockscreen.lockedoutpermanently";
    public final static String LOCKOUT_ATTEMPT_DEADLINE = "lockscreen.lockoutattemptdeadline";
    public final static String LOCKOUT_ATTEMPT_TIMEOUT_MS = "lockscreen.lockoutattempttimeoutmss";
    public final static String PATTERN_EVER_CHOSEN_KEY = "lockscreen.patterneverchosen";
    public final static String PASSWORD_TYPE_KEY = "lockscreen.password_type";
    @Deprecated
@@ -164,6 +163,7 @@ public class LockPatternUtils {
    private ILockSettings mLockSettingsService;
    private UserManager mUserManager;
    private final Handler mHandler;
    private final SparseLongArray mLockoutDeadlines = new SparseLongArray();

    /**
     * Use {@link TrustManager#isTrustUsuallyManaged(int)}.
@@ -1237,8 +1237,7 @@ public class LockPatternUtils {
            // enforces the deadline. Since we cannot store settings for the FRP user, don't.
            return deadline;
        }
        setLong(LOCKOUT_ATTEMPT_DEADLINE, deadline, userId);
        setLong(LOCKOUT_ATTEMPT_TIMEOUT_MS, timeoutMs, userId);
        mLockoutDeadlines.put(userId, deadline);
        return deadline;
    }

@@ -1248,22 +1247,13 @@ public class LockPatternUtils {
     *   enter a pattern.
     */
    public long getLockoutAttemptDeadline(int userId) {
        long deadline = getLong(LOCKOUT_ATTEMPT_DEADLINE, 0L, userId);
        final long timeoutMs = getLong(LOCKOUT_ATTEMPT_TIMEOUT_MS, 0L, userId);
        final long deadline = mLockoutDeadlines.get(userId, 0L);
        final long now = SystemClock.elapsedRealtime();
        if (deadline < now && deadline != 0) {
            // timeout expired
            setLong(LOCKOUT_ATTEMPT_DEADLINE, 0, userId);
            setLong(LOCKOUT_ATTEMPT_TIMEOUT_MS, 0, userId);
            mLockoutDeadlines.put(userId, 0);
            return 0L;
        }

        if (deadline > (now + timeoutMs)) {
            // device was rebooted, set new deadline
            deadline = now + timeoutMs;
            setLong(LOCKOUT_ATTEMPT_DEADLINE, deadline, userId);
        }

        return deadline;
    }

+0 −1
Original line number Diff line number Diff line
@@ -2098,7 +2098,6 @@ public class LockSettingsService extends ILockSettings.Stub {

    private static final String[] VALID_SETTINGS = new String[] {
            LockPatternUtils.LOCKOUT_PERMANENT_KEY,
            LockPatternUtils.LOCKOUT_ATTEMPT_DEADLINE,
            LockPatternUtils.PATTERN_EVER_CHOSEN_KEY,
            LockPatternUtils.PASSWORD_TYPE_KEY,
            LockPatternUtils.PASSWORD_TYPE_ALTERNATE_KEY,