@Override public void onChecked(boolean matched, int timeoutMs) { mLatencyTracker.onActionEnd(ACTION_CHECK_CREDENTIAL_UNLOCKED); mView.setPasswordEntryInputEnabled(true); mPendingLockCheck = null; if (!matched) { onPasswordChecked(userId, false /* matched */, timeoutMs, true /* isValidPassword */); } password.zeroize(); }
@Override public void onCancelled() { // We already got dismissed with the early matched callback, so we cancelled // the check. However, we still need to note down the latency. mLatencyTracker.onActionEnd(ACTION_CHECK_CREDENTIAL_UNLOCKED); password.zeroize(); } }
/** * Set and store the lockout deadline, meaning the user can't attempt their unlock * pattern until the deadline has passed. * @return the chosen deadline. */ @UnsupportedAppUsage public long setLockoutAttemptDeadline(int userId, int timeoutMs) { final long deadline = SystemClock.elapsedRealtime() + timeoutMs; if (userId == USER_FRP) { // For secure password storage (that is required for FRP), the underlying storage also // enforces the deadline. Since we cannot store settings for the FRP user, don't. return deadline; } mLockoutDeadlines.put(userId, deadline); return deadline; }
/** * @return The elapsed time in millis in the future when the user is allowed to * attempt to enter their lock pattern, or 0 if the user is welcome to * enter a pattern. */ public long getLockoutAttemptDeadline(int userId) { final long deadline = mLockoutDeadlines.get(userId, 0L); final long now = SystemClock.elapsedRealtime(); if (deadline < now && deadline != 0) { // timeout expired 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); }
/** * Set and store the lockout deadline by SystemCurrentTime, meaning the user can't attempt his/her unlock * pattern until the deadline has passed. * @return the chosen deadline. */ public long setLockoutAttemptDeadlineBySystemCurrentTime(int userId, int timeoutMs) { final long deadline = System.currentTimeMillis() + timeoutMs; setLong(LOCKOUT_ATTEMPT_DEADLINE_CURRENTTIME, deadline, userId); setLong(LOCKOUT_ATTEMPT_TIMEOUT_MS, timeoutMs, userId); return deadline; }
/** * @return The SystemCurrentTime in millis in the future when the user is allowed to * attempt to enter his/her lock pattern, or 0 if the user is welcome to * enter a pattern. */ public long getLockoutAttemptDeadlineBySystemCurrentTime(int userId) { long deadline = getLong(LOCKOUT_ATTEMPT_DEADLINE_CURRENTTIME, 0L, userId); final long now = System.currentTimeMillis(); if (deadline < now && deadline != 0) { // timeout expired setLong(LOCKOUT_ATTEMPT_DEADLINE_CURRENTTIME, 0, userId); setLong(LOCKOUT_ATTEMPT_TIMEOUT_MS, 0, userId); return 0L; } return deadline; }