From df98c5247bcd2fa454da3d52ff60e60f69d9922b Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Mon, 29 Mar 2021 14:21:06 -0700 Subject: [PATCH] Only request resetLockout if enrollments exist If a race condition occurs, at least we limit it to when enrollments exists. After this fix, at least when users exit settings and re-enter face settings, things should work again Bug: 183906260 Test: enroll, exit settings, enter face settings, enroll Change-Id: I6d5ebf2d19eda43b8efe589d96c3bcc216078f48 --- .../locksettings/BiometricDeferredQueue.java | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java b/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java index 6201b9414aaf2..5abc438579e8f 100644 --- a/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java +++ b/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java @@ -52,7 +52,8 @@ public class BiometricDeferredQueue { // Entries added by LockSettingsService once a user's synthetic password is known. At this point // things are still keyed by userId. - @NonNull private final ArrayList mPendingResetLockouts; + @NonNull private final ArrayList mPendingResetLockoutsForFingerprint; + @NonNull private final ArrayList mPendingResetLockoutsForFace; /** * Authentication info for a successful user unlock via Synthetic Password. This can be used to @@ -151,7 +152,8 @@ public class BiometricDeferredQueue { mContext = context; mSpManager = spManager; mHandler = handler; - mPendingResetLockouts = new ArrayList<>(); + mPendingResetLockoutsForFingerprint = new ArrayList<>(); + mPendingResetLockoutsForFace = new ArrayList<>(); } public void systemReady(@Nullable FingerprintManager fingerprintManager, @@ -173,17 +175,34 @@ public class BiometricDeferredQueue { */ void addPendingLockoutResetForUser(int userId, @NonNull byte[] gatekeeperPassword) { mHandler.post(() -> { - Slog.d(TAG, "addPendingLockoutResetForUser: " + userId); - mPendingResetLockouts.add(new UserAuthInfo(userId, gatekeeperPassword)); + if (mFaceManager != null && mFaceManager.hasEnrolledTemplates(userId)) { + Slog.d(TAG, "Face addPendingLockoutResetForUser: " + userId); + mPendingResetLockoutsForFace.add(new UserAuthInfo(userId, gatekeeperPassword)); + } + + if (mFingerprintManager != null + && mFingerprintManager.hasEnrolledFingerprints(userId)) { + Slog.d(TAG, "Fingerprint addPendingLockoutResetForUser: " + userId); + mPendingResetLockoutsForFingerprint.add(new UserAuthInfo(userId, + gatekeeperPassword)); + } }); } void processPendingLockoutResets() { mHandler.post(() -> { - Slog.d(TAG, "processPendingLockoutResets: " + mPendingResetLockouts.size()); - processPendingLockoutsForFingerprint(new ArrayList<>(mPendingResetLockouts)); - processPendingLockoutsForFace(new ArrayList<>(mPendingResetLockouts)); - mPendingResetLockouts.clear(); + if (!mPendingResetLockoutsForFace.isEmpty()) { + Slog.d(TAG, "Processing pending resetLockout for face"); + processPendingLockoutsForFace(new ArrayList<>(mPendingResetLockoutsForFace)); + mPendingResetLockoutsForFace.clear(); + } + + if (!mPendingResetLockoutsForFingerprint.isEmpty()) { + Slog.d(TAG, "Processing pending resetLockout for fingerprint"); + processPendingLockoutsForFingerprint( + new ArrayList<>(mPendingResetLockoutsForFingerprint)); + mPendingResetLockoutsForFingerprint.clear(); + } }); }