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

Commit 0d9eccf8 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Don't cache lockout state in KeyguardUpdateMonitor

Partial revert of ag/5369172 - caching the state makes it too complicated
in SystemUI. Issues are as follows

1) SystemUI did not track lockout per-user
2) SystemUI would not show lockout after the initial error

The bug (b/118235602) is already fixed by calling update*ListeningState
instead of startListening.

Test: 1) Enroll multiple users and set up FP
      2) Lockout one user
      3) Switch to second user
      4) Switch back to first user - lockout message is shown

Test: 1) Lockout user
      2) Unlock with pin/pattern/pass
      3) Look at FingerprintService logs - SysUI does not authenticate
         when the user is already unlocked

Bug: 118235602
Fixes: 126926000



Change-Id: Ia8dd44b0dda4246bd94e5f72bf3b0a72ff20eb13
parent 8c7968a8
Loading
Loading
Loading
Loading
+3 −18
Original line number Diff line number Diff line
@@ -243,8 +243,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private boolean mIsDreaming;
    private final DevicePolicyManager mDevicePolicyManager;
    private boolean mLogoutEnabled;
    private boolean mFingerprintLockedOut;
    private boolean mFaceLockedOut;

    /**
     * Short delay before restarting biometric authentication after a successful try
@@ -649,11 +647,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            }
        }

        if (msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT
                || msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT_PERMANENT) {
            mFingerprintLockedOut = true;
        }

        if (msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT_PERMANENT) {
            mLockPatternUtils.requireStrongAuth(
                    LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT,
@@ -669,7 +662,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }

    private void handleFingerprintLockoutReset() {
        mFingerprintLockedOut = false;
        updateFingerprintListeningState();
    }

@@ -807,11 +799,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            }
        }

        if (msgId == FaceManager.FACE_ERROR_LOCKOUT
                || msgId == FaceManager.FACE_ERROR_LOCKOUT_PERMANENT) {
            mFaceLockedOut = true;
        }

        if (msgId == FaceManager.FACE_ERROR_LOCKOUT_PERMANENT) {
            mLockPatternUtils.requireStrongAuth(
                    LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT,
@@ -828,7 +815,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }

    private void handleFaceLockoutReset() {
        mFaceLockedOut = false;
        updateFaceListeningState();
    }

@@ -1616,7 +1602,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                (mBouncer && !mKeyguardGoingAway) || mGoingToSleep ||
                shouldListenForFingerprintAssistant() || (mKeyguardOccluded && mIsDreaming))
                && !mSwitchingUser && !isFingerprintDisabled(getCurrentUser())
                && !mKeyguardGoingAway && !mFingerprintLockedOut && mIsPrimaryUser;
                && !mKeyguardGoingAway && mIsPrimaryUser;
        return shouldListen;
    }

@@ -1627,9 +1613,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
        return (mBouncer || mAuthInterruptActive || awakeKeyguard || shouldListenForFaceAssistant())
                && !mSwitchingUser && !getUserCanSkipBouncer(user) && !isFaceDisabled(user)
                && !mKeyguardGoingAway && !mFaceLockedOut && mFaceSettingEnabledForUser
                && mUserManager.isUserUnlocked(user)
                && mIsPrimaryUser;
                && !mKeyguardGoingAway && mFaceSettingEnabledForUser
                && mUserManager.isUserUnlocked(user) && mIsPrimaryUser;
    }


+0 −10
Original line number Diff line number Diff line
@@ -320,16 +320,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        verify(mFaceManager).authenticate(any(), any(), anyInt(), any(), any());
    }

    @Test
    public void testNeverAuthenticates_whenFaceLockout() {
        mKeyguardUpdateMonitor.mFaceAuthenticationCallback
                .onAuthenticationError(FaceManager.FACE_ERROR_LOCKOUT, "lockout");
        mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(true);
        mTestableLooper.processAllMessages();

        verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any());
    }

    @Test
    public void testOnFaceAuthenticated_skipsFaceWhenAuthenticated() {
        mKeyguardUpdateMonitor.onFaceAuthenticated(KeyguardUpdateMonitor.getCurrentUser());