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

Commit 494ef026 authored by Joshua McCloskey's avatar Joshua McCloskey
Browse files

Fix keyguard logic for listening to sfps

Test: atest KeyguardUpdateMonitorTest
Test: manual
Bug: 245343077O
Change-Id: Ic71c82cf9f07fbb3e57039bcff197616b8ddb3cf
parent 1eaa038b
Loading
Loading
Loading
Loading
+25 −30
Original line number Diff line number Diff line
@@ -384,6 +384,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    protected Handler getHandler() {
        return mHandler;
    }

    private final Handler mHandler;

    private final IBiometricEnabledOnKeyguardCallback mBiometricEnabledCallback =
@@ -708,6 +709,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab

    /**
     * Request to listen for face authentication when an app is occluding keyguard.
     *
     * @param request if true and mKeyguardOccluded, request face auth listening, else default
     *                to normal behavior.
     *                See {@link KeyguardUpdateMonitor#shouldListenForFace()}
@@ -720,6 +722,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab

    /**
     * Request to listen for fingerprint when an app is occluding keyguard.
     *
     * @param request if true and mKeyguardOccluded, request fingerprint listening, else default
     *                to normal behavior.
     *                See {@link KeyguardUpdateMonitor#shouldListenForFingerprint(boolean)}
@@ -2225,7 +2228,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                Settings.System.getUriFor(Settings.System.TIME_12_24),
                false, mTimeFormatChangeObserver, UserHandle.USER_ALL);

        if (isSfpsSupported() && isSfpsEnrolled()) {
        updateSfpsRequireScreenOnToAuthPref();
        mSfpsRequireScreenOnToAuthPrefObserver = new ContentObserver(mHandler) {
            @Override
@@ -2241,7 +2243,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                mSfpsRequireScreenOnToAuthPrefObserver,
                getCurrentUser());
    }
    }

    protected void updateSfpsRequireScreenOnToAuthPref() {
        final int defaultSfpsRequireScreenOnToAuthValue =
@@ -2635,27 +2636,21 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                !(mFingerprintLockedOut && mBouncerIsOrWillBeShowing && mCredentialAttempted);

        final boolean isEncryptedOrLockdownForUser = isEncryptedOrLockdown(user);

        final boolean shouldListenUdfpsState = !isUdfps
                || (!userCanSkipBouncer
                && !isEncryptedOrLockdownForUser
                && userDoesNotHaveTrust);

        boolean shouldListenSfpsState = true;
        // If mSfpsRequireScreenOnToAuthPrefEnabled, require screen on to listen to SFPS
        if (isSfpsSupported() && isSfpsEnrolled() && mSfpsRequireScreenOnToAuthPrefEnabled) {
            shouldListenSfpsState = isDeviceInteractive();
        boolean shouldListenSideFpsState = true;
        if (isSfpsSupported() && isSfpsEnrolled()) {
            shouldListenSideFpsState =
                    mSfpsRequireScreenOnToAuthPrefEnabled ? isDeviceInteractive() : true;
        }

        boolean shouldListen = shouldListenKeyguardState && shouldListenUserState
                && shouldListenBouncerState && !isFingerprintLockedOut();

        if (isUdfpsSupported()) {
            shouldListen = shouldListen && shouldListenUdfpsState;
        }

        if (isSfpsSupported()) {
            shouldListen = shouldListen && shouldListenSfpsState;
        }
                && shouldListenBouncerState && shouldListenUdfpsState && !isFingerprintLockedOut()
                && shouldListenSideFpsState;

        maybeLogListenerModelData(
                new KeyguardFingerprintListenModel(
@@ -2677,7 +2672,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    mKeyguardOccluded,
                    mOccludingAppRequestingFp,
                    mIsPrimaryUser,
                    shouldListenSfpsState,
                    shouldListenSideFpsState,
                    shouldListenForFingerprintAssistant,
                    mSwitchingUser,
                    isUdfps,
+4 −8
Original line number Diff line number Diff line
@@ -1162,7 +1162,10 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    public void testStartsListeningForSfps_whenKeyguardIsVisible_ifRequireScreenOnToAuthEnabled()
            throws RemoteException {
        // SFPS supported and enrolled
        setup_SfpsProps();
        final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
        props.add(newFingerprintSensorPropertiesInternal(TYPE_POWER_BUTTON));
        when(mAuthController.getSfpsProps()).thenReturn(props);
        when(mAuthController.isSfpsEnrolled(anyInt())).thenReturn(true);

        // WHEN require screen on to auth is disabled, and keyguard is not awake
        when(mSecureSettings.getIntForUser(anyString(), anyInt(), anyInt())).thenReturn(0);
@@ -1201,13 +1204,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(false)).isTrue();
    }

    private void setup_SfpsProps() {
        final ArrayList<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
        props.add(newFingerprintSensorPropertiesInternal(TYPE_POWER_BUTTON));
        when(mAuthController.getSfpsProps()).thenReturn(props);
        when(mAuthController.isSfpsEnrolled(anyInt())).thenReturn(true);
    }

    private FingerprintSensorPropertiesInternal newFingerprintSensorPropertiesInternal(
            @FingerprintSensorProperties.SensorType int sensorType) {
        return new FingerprintSensorPropertiesInternal(