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

Commit a2271189 authored by Austin Delgado's avatar Austin Delgado Committed by Android (Google) Code Review
Browse files

Merge "Remove soft lockout from ultrasonic fingerprint devices" into main

parents d9f93c13 cff994ee
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -121,15 +121,20 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna

    /**
     * Returns if sensor type is ultrasonic Udfps
     * @return true if sensor is ultrasonic Udfps, false otherwise
     */
    public boolean isUltrasonicUdfps() {
        return sensorType == TYPE_UDFPS_ULTRASONIC;
    }

    /**
     * Returns if sensor type is optical Udfps
     */
    public boolean isOpticalUdfps() {
        return sensorType == TYPE_UDFPS_OPTICAL;
    }

    /**
     * Returns if sensor type is side-FPS
     * @return true if sensor is side-fps, false otherwise
     */
    public boolean isAnySidefpsType() {
        switch (sensorType) {
+23 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.hardware.biometrics.BiometricSourceType;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Handler;
import android.os.PowerManager;
import android.os.UserHandle;
@@ -431,9 +432,9 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
    }

    @Test
    public void onUdfpsConsecutivelyFailedThreeTimes_showPrimaryBouncer() {
        // GIVEN UDFPS is supported
        when(mUpdateMonitor.isUdfpsSupported()).thenReturn(true);
    public void onOpticalUdfpsConsecutivelyFailedThreeTimes_showPrimaryBouncer() {
        // GIVEN optical UDFPS is supported
        when(mUpdateMonitor.isOpticalUdfpsSupported()).thenReturn(true);

        // WHEN udfps fails once - then don't show the bouncer yet
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);
@@ -450,6 +451,25 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(true);
    }

    @Test
    public void onUltrasonicUdfpsLockout_showPrimaryBouncer() {
        // GIVEN ultrasonic UDFPS is supported
        when(mUpdateMonitor.isOpticalUdfpsSupported()).thenReturn(false);

        // WHEN udfps fails three times, don't show bouncer
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);
        mBiometricUnlockController.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);
        verify(mStatusBarKeyguardViewManager, never()).showPrimaryBouncer(anyBoolean());

        // WHEN lockout is received
        mBiometricUnlockController.onBiometricError(FingerprintManager.FINGERPRINT_ERROR_LOCKOUT,
                "Lockout", BiometricSourceType.FINGERPRINT);

        // THEN show bouncer
        verify(mStatusBarKeyguardViewManager).showPrimaryBouncer(true);
    }

    @Test
    public void onFinishedGoingToSleep_authenticatesWhenPending() {
        when(mUpdateMonitor.isGoingToSleep()).thenReturn(true);
+9 −0
Original line number Diff line number Diff line
@@ -2590,6 +2590,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        return mAuthController.isUdfpsSupported();
    }

    /**
     * @return true if optical udfps HW is supported on this device. Can return true even if the
     * user has not enrolled udfps. This may be false if called before
     * onAllAuthenticatorsRegistered.
     */
    public boolean isOpticalUdfpsSupported() {
        return mAuthController.isOpticalUdfpsSupported();
    }

    /**
     * @return true if there's at least one sfps enrollment for the current user.
     */
+10 −0
Original line number Diff line number Diff line
@@ -1010,6 +1010,16 @@ public class AuthController implements
        return getUdfpsProps() != null && !getUdfpsProps().isEmpty();
    }

    /**
     * @return true if optical udfps HW is supported on this device. Can return true even if
     * the user has not enrolled udfps. This may be false if called before
     * onAllAuthenticatorsRegistered.
     */
    public boolean isOpticalUdfpsSupported() {
        return getUdfpsProps() != null && !getUdfpsProps().isEmpty() && getUdfpsProps()
                .get(0).isOpticalUdfps();
    }

    /**
     * @return true if ultrasonic udfps HW is supported on this device. Can return true even if
     * the user has not enrolled udfps. This may be false if called before
+1 −1
Original line number Diff line number Diff line
@@ -750,7 +750,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
                    BiometricUnlockSource.Companion.fromBiometricSourceType(biometricSourceType)
            );
        } else if (biometricSourceType == BiometricSourceType.FINGERPRINT
                && mUpdateMonitor.isUdfpsSupported()) {
                && mUpdateMonitor.isOpticalUdfpsSupported()) {
            long currUptimeMillis = mSystemClock.uptimeMillis();
            if (currUptimeMillis - mLastFpFailureUptimeMillis < mConsecutiveFpFailureThreshold) {
                mNumConsecutiveFpFailures += 1;