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

Commit 625a0140 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Keyguard should authenticate with FP even after getting valid FP

There may be strange states where the user is already authenticated
but still on the lockscreen. The user should be able to dismiss
keyguard in that state.

Fixes: 29306222

Test: unlock phone
go back to keyguard
swipe up screen half way
touch fingerprint sensor (icon should change to unlocked)
then touch fingerprint sensor again (keyguard should be dismissed)

Test: unlock phone and go to settings -> Pixel Imprint
lock phone, unlock phone with fingerprint
touch sensor again and make sure Pixel Imprint page also responds to FP
do this test at least 10 times

Change-Id: I86acd520a06a68fab3548dd4cf6153a7833114fe
parent 5cd4797c
Loading
Loading
Loading
Loading
+3 −16
Original line number Diff line number Diff line
@@ -165,11 +165,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private int mPhoneState;
    private boolean mKeyguardIsVisible;

    /**
     * If true, fingerprint was already authenticated and we don't need to start listening again
     * until the Keyguard has been dismissed.
     */
    private boolean mFingerprintAlreadyAuthenticated;
    private boolean mGoingToSleep;
    private boolean mBouncer;
    private boolean mBootCompleted;
@@ -409,11 +404,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private void onFingerprintAuthenticated(int userId) {
        Trace.beginSection("KeyGuardUpdateMonitor#onFingerPrintAuthenticated");
        mUserFingerprintAuthenticated.put(userId, true);

        // If fingerprint unlocking is allowed, this event will lead to a Keyguard dismiss or to a
        // wake-up (if Keyguard is not showing), so we don't need to listen until Keyguard is
        // fully gone.
        mFingerprintAlreadyAuthenticated = isUnlockingWithFingerprintAllowed();
        // Don't send cancel if authentication succeeds
        mFingerprintCancelSignal = null;
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
@@ -922,7 +914,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            }
        }
        mGoingToSleep = true;
        mFingerprintAlreadyAuthenticated = false;
        updateFingerprintListeningState();
    }

@@ -1092,8 +1083,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {

    private boolean shouldListenForFingerprint() {
        return (mKeyguardIsVisible || !mDeviceInteractive || mBouncer || mGoingToSleep)
                && !mSwitchingUser && !mFingerprintAlreadyAuthenticated
                && !isFingerprintDisabled(getCurrentUser());
                && !mSwitchingUser && !isFingerprintDisabled(getCurrentUser());
    }

    private void startListeningForFingerprint() {
@@ -1416,9 +1406,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                cb.onKeyguardVisibilityChangedRaw(showing);
            }
        }
        if (!showing) {
            mFingerprintAlreadyAuthenticated = false;
        }
        updateFingerprintListeningState();
    }

+6 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ public abstract class AuthenticationClient extends ClientMonitor {

    public abstract boolean handleFailedAttempt();
    public abstract void resetFailedAttempts();
    private boolean mAlreadyCancelled;

    public AuthenticationClient(Context context, long halDeviceId, IBinder token,
            IFingerprintServiceReceiver receiver, int targetUserId, int groupId, long opId,
@@ -129,6 +130,10 @@ public abstract class AuthenticationClient extends ClientMonitor {

    @Override
    public int stop(boolean initiatedByClient) {
        if (mAlreadyCancelled) {
            Slog.w(TAG, "stopAuthentication: already cancelled!");
            return 0;
        }
        IBiometricsFingerprint daemon = getFingerprintDaemon();
        if (daemon == null) {
            Slog.w(TAG, "stopAuthentication: no fingerprint HAL!");
@@ -145,6 +150,7 @@ public abstract class AuthenticationClient extends ClientMonitor {
            Slog.e(TAG, "stopAuthentication failed", e);
            return ERROR_ESRCH;
        }
        mAlreadyCancelled = true;
        return 0; // success
    }