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

Commit a7daa25a authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Diya Bera
Browse files

Merge "Merge "Prioritize strength error over hardware error" into...

Merge "Merge "Prioritize strength error over hardware error" into android15-tests-dev am: 4998bb62" into main am: a592e668

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3357080



Change-Id: I6284403fb9f7c5cb0cda294a0e8ec785caca88c8
Merged-In: I911fc76d14837e277354cb4c0e2e56ee486fcfd9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2cf32606 a592e668
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -216,10 +216,6 @@ class PreAuthInfo {
            return BIOMETRIC_NO_HARDWARE;
        }

        if (sensor.modality == TYPE_FACE && biometricCameraManager.isAnyCameraUnavailable()) {
            return BIOMETRIC_HARDWARE_NOT_DETECTED;
        }

        final boolean wasStrongEnough =
                Utils.isAtLeastStrength(sensor.oemStrength, requestedStrength);
        final boolean isStrongEnough =
@@ -231,6 +227,10 @@ class PreAuthInfo {
            return BIOMETRIC_INSUFFICIENT_STRENGTH;
        }

        if (sensor.modality == TYPE_FACE && biometricCameraManager.isAnyCameraUnavailable()) {
            return BIOMETRIC_HARDWARE_NOT_DETECTED;
        }

        try {
            if (!sensor.impl.isHardwareDetected(opPackageName)) {
                return BIOMETRIC_HARDWARE_NOT_DETECTED;
+23 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import static android.hardware.biometrics.BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE;
import static android.hardware.biometrics.BiometricManager.BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS;
import static android.hardware.biometrics.BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE;

import static com.android.server.biometrics.sensors.LockoutTracker.LOCKOUT_NONE;

@@ -64,6 +65,7 @@ public class PreAuthInfoTest {
    public final CheckFlagsRule mCheckFlagsRule =
            DeviceFlagsValueProvider.createCheckFlagsRule();

    private static final int USER_ID = 0;
    private static final int SENSOR_ID_FINGERPRINT = 0;
    private static final int SENSOR_ID_FACE = 1;
    private static final String TEST_PACKAGE_NAME = "PreAuthInfoTestPackage";
@@ -304,6 +306,20 @@ public class PreAuthInfoTest {
        assertThat(promptInfo.getNegativeButtonText()).isEqualTo(TEST_PACKAGE_NAME);
    }

    @Test
    public void prioritizeStrengthErrorBeforeCameraUnavailableError() throws Exception {
        final BiometricSensor sensor = getFaceSensorWithStrength(
                BiometricManager.Authenticators.BIOMETRIC_WEAK);
        final PromptInfo promptInfo = new PromptInfo();
        promptInfo.setAuthenticators(BiometricManager.Authenticators.BIOMETRIC_STRONG);
        promptInfo.setNegativeButtonText(TEST_PACKAGE_NAME);
        final PreAuthInfo preAuthInfo = PreAuthInfo.create(mTrustManager, mDevicePolicyManager,
                mSettingObserver, List.of(sensor), USER_ID , promptInfo, TEST_PACKAGE_NAME,
                false /* checkDevicePolicyManager */, mContext, mBiometricCameraManager);

        assertThat(preAuthInfo.getCanAuthenticateResult()).isEqualTo(BIOMETRIC_ERROR_NO_HARDWARE);
    }

    private BiometricSensor getFingerprintSensor() {
        BiometricSensor sensor = new BiometricSensor(mContext, SENSOR_ID_FINGERPRINT,
                TYPE_FINGERPRINT, BiometricManager.Authenticators.BIOMETRIC_STRONG,
@@ -322,9 +338,10 @@ public class PreAuthInfoTest {
        return sensor;
    }

    private BiometricSensor getFaceSensor() {
    private BiometricSensor getFaceSensorWithStrength(
            @BiometricManager.Authenticators.Types int sensorStrength) {
        BiometricSensor sensor = new BiometricSensor(mContext, SENSOR_ID_FACE, TYPE_FACE,
                BiometricManager.Authenticators.BIOMETRIC_STRONG, mFaceAuthenticator) {
                sensorStrength, mFaceAuthenticator) {
            @Override
            boolean confirmationAlwaysRequired(int userId) {
                return false;
@@ -338,4 +355,8 @@ public class PreAuthInfoTest {

        return sensor;
    }

    private BiometricSensor getFaceSensor() {
        return getFaceSensorWithStrength(BiometricManager.Authenticators.BIOMETRIC_STRONG);
    }
}