From 2aaf94484ebfd7a19a22b490b42925ee7d916795 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Tue, 20 Nov 2018 16:57:33 +0100 Subject: [PATCH] Keyguard: Fix leaking fingerprint registration Fixes an issue where the fingerprint registration could leak for the following sequence of requests: - shouldListen becomes true - updateListening (STOPPED -> RUNNING) - shouldListen becomes false - updateListening (RUNNING -> CANCELLING) - shouldListen becomes true - updateListening (CANCELLING -> RESTARTING) - shouldListen becomes false - updateListening (nop, because RESTARTING is not considered a running state) - handleFingerprintError(reason=CANCELLED) wrongly restarts listening Bug: 119813074 Test: Verify fingerprint unlocking still works. Verify fingerprint listening does not get stuck after unlocking via bouncer. Change-Id: Ibd1bf3a161164586466d2b1d965e53a648c7038b --- .../com/android/keyguard/KeyguardUpdateMonitor.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 6b0a7a95bba33..b55aa5c8897d2 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -1531,10 +1531,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } mHandler.removeCallbacks(mRetryFingerprintAuthentication); boolean shouldListenForFingerprint = shouldListenForFingerprint(); - if (mFingerprintRunningState == BIOMETRIC_STATE_RUNNING && !shouldListenForFingerprint) { + boolean runningOrRestarting = mFingerprintRunningState == BIOMETRIC_STATE_RUNNING + || mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING; + if (runningOrRestarting && !shouldListenForFingerprint) { stopListeningForFingerprint(); - } else if (mFingerprintRunningState != BIOMETRIC_STATE_RUNNING - && shouldListenForFingerprint) { + } else if (!runningOrRestarting && shouldListenForFingerprint) { startListeningForFingerprint(); } } @@ -1589,6 +1590,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { setFingerprintRunningState(BIOMETRIC_STATE_CANCELLING_RESTARTING); return; } + if (mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING) { + // Waiting for restart via handleFingerprintError(). + return; + } if (DEBUG) Log.v(TAG, "startListeningForFingerprint()"); int userId = ActivityManager.getCurrentUser(); if (isUnlockWithFingerprintPossible(userId)) { @@ -2418,6 +2423,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { + getStrongAuthTracker().hasUserAuthenticatedSinceBoot()); pw.println(" disabled(DPM)=" + isFingerprintDisabled(userId)); pw.println(" possible=" + isUnlockWithFingerprintPossible(userId)); + pw.println(" listening: actual=" + mFingerprintRunningState + + " expected=" + (shouldListenForFingerprint() ? 1 : 0)); pw.println(" strongAuthFlags=" + Integer.toHexString(strongAuthFlags)); pw.println(" trustManaged=" + getUserTrustIsManaged(userId)); }