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

Commit deb10ee8 authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge changes from topic "biometric-keyguard-bugs"

* changes:
  Don't cache lockout state in KeyguardUpdateMonitor
  Fix keyguardGoingAway state in KeyguardUpdateMonitor
  Only control fingerprint from primary KeyguardUpdateMonitor
parents 06eb50d0 0d9eccf8
Loading
Loading
Loading
Loading
+11 −19
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private static KeyguardUpdateMonitor sInstance;

    private final Context mContext;
    private final boolean mIsPrimaryUser;
    HashMap<Integer, SimData> mSimDatas = new HashMap<Integer, SimData>();
    HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>();

@@ -242,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
@@ -648,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,
@@ -668,7 +662,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }

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

@@ -806,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,
@@ -827,7 +815,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }

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

@@ -1530,6 +1517,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {

        ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
        mUserManager = context.getSystemService(UserManager.class);
        mIsPrimaryUser = mUserManager.isPrimaryUser();
        mDevicePolicyManager = context.getSystemService(DevicePolicyManager.class);
        mLogoutEnabled = mDevicePolicyManager.isLogoutEnabled();
        updateAirplaneModeState();
@@ -1608,21 +1596,25 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }

    private boolean shouldListenForFingerprint() {
        return (mKeyguardIsVisible || !mDeviceInteractive ||
        // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
        // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
        final boolean shouldListen = (mKeyguardIsVisible || !mDeviceInteractive ||
                (mBouncer && !mKeyguardGoingAway) || mGoingToSleep ||
                shouldListenForFingerprintAssistant() || (mKeyguardOccluded && mIsDreaming))
                && !mSwitchingUser && !isFingerprintDisabled(getCurrentUser())
                && !mKeyguardGoingAway && !mFingerprintLockedOut;
                && !mKeyguardGoingAway && mIsPrimaryUser;
        return shouldListen;
    }

    private boolean shouldListenForFace() {
        final boolean awakeKeyguard = mKeyguardIsVisible && mDeviceInteractive && !mGoingToSleep;
        final int user = getCurrentUser();

        // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
        // 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);
                && !mKeyguardGoingAway && mFaceSettingEnabledForUser
                && mUserManager.isUserUnlocked(user) && mIsPrimaryUser;
    }


+1 −1
Original line number Diff line number Diff line
@@ -1787,6 +1787,7 @@ public class KeyguardViewMediator extends SystemUI {
            mHideAnimationRun = false;
            adjustStatusBarLocked();
            userActivity();
            mUpdateMonitor.setKeyguardGoingAway(false /* away */);
            mShowKeyguardWakeLock.release();
        }
        mKeyguardDisplayManager.show();
@@ -1907,7 +1908,6 @@ public class KeyguardViewMediator extends SystemUI {
            mHideAnimationRun = false;
            adjustStatusBarLocked();
            sendUserPresentBroadcast();
            mUpdateMonitor.setKeyguardGoingAway(false /* goingAway */);
        }
        Trace.endSection();
    }
+1 −10
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        when(mFaceManager.hasEnrolledTemplates()).thenReturn(true);
        when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(true);
        when(mUserManager.isUserUnlocked(anyInt())).thenReturn(true);
        when(mUserManager.isPrimaryUser()).thenReturn(true);
        when(mStrongAuthTracker.isUnlockingWithBiometricAllowed()).thenReturn(true);
        context.addMockSystemService(TrustManager.class, mTrustManager);
        context.addMockSystemService(FingerprintManager.class, mFingerprintManager);
@@ -319,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());