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

Commit 2aaf9448 authored by Adrian Roos's avatar Adrian Roos Committed by Lucas Dupin
Browse files

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
parent 211af382
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -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));
        }