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

Commit 41f6ed8a authored by Diya Bera's avatar Diya Bera
Browse files

[Identity Check] Replace negative text in bp if null

Flag: android.hardware.biometrics.flag.mandatory_biometrics
Fixes: 339910180
Test: atest PreAuthInfoTest
Change-Id: Ic9916595bf7bb87c93004f21eed337497fccd8c6
parent a2f3b683
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -120,8 +120,10 @@ class PreAuthInfo {
                        userId), trustManager)) {
                        userId), trustManager)) {
            isMandatoryBiometricsAuthentication = true;
            isMandatoryBiometricsAuthentication = true;
            promptInfo.setAuthenticators(BiometricManager.Authenticators.BIOMETRIC_STRONG);
            promptInfo.setAuthenticators(BiometricManager.Authenticators.BIOMETRIC_STRONG);
            if (promptInfo.getNegativeButtonText() == null) {
                promptInfo.setNegativeButtonText(context.getString(R.string.cancel));
                promptInfo.setNegativeButtonText(context.getString(R.string.cancel));
            }
            }
        }


        final boolean biometricRequested = Utils.isBiometricRequested(promptInfo);
        final boolean biometricRequested = Utils.isBiometricRequested(promptInfo);
        final int requestedStrength = Utils.getPublicBiometricStrength(promptInfo);
        final int requestedStrength = Utils.getPublicBiometricStrength(promptInfo);
+16 −0
Original line number Original line Diff line number Diff line
@@ -264,6 +264,22 @@ public class PreAuthInfoTest {
        assertThat(preAuthInfo.eligibleSensors).hasSize(0);
        assertThat(preAuthInfo.eligibleSensors).hasSize(0);
    }
    }


    @Test
    @RequiresFlagsEnabled(Flags.FLAG_MANDATORY_BIOMETRICS)
    public void testMandatoryBiometricsNegativeButtonText_whenSet()
            throws Exception {
        when(mTrustManager.isInSignificantPlace()).thenReturn(false);

        final BiometricSensor sensor = getFaceSensor();
        final PromptInfo promptInfo = new PromptInfo();
        promptInfo.setAuthenticators(BiometricManager.Authenticators.MANDATORY_BIOMETRICS);
        promptInfo.setNegativeButtonText(TEST_PACKAGE_NAME);
        final PreAuthInfo preAuthInfo = PreAuthInfo.create(mTrustManager, mDevicePolicyManager,
                mSettingObserver, List.of(sensor), 0 /* userId */, promptInfo, TEST_PACKAGE_NAME,
                false /* checkDevicePolicyManager */, mContext, mBiometricCameraManager);
        assertThat(promptInfo.getNegativeButtonText()).isEqualTo(TEST_PACKAGE_NAME);
    }

    private BiometricSensor getFingerprintSensor() {
    private BiometricSensor getFingerprintSensor() {
        BiometricSensor sensor = new BiometricSensor(mContext, SENSOR_ID_FINGERPRINT,
        BiometricSensor sensor = new BiometricSensor(mContext, SENSOR_ID_FINGERPRINT,
                TYPE_FINGERPRINT, BiometricManager.Authenticators.BIOMETRIC_STRONG,
                TYPE_FINGERPRINT, BiometricManager.Authenticators.BIOMETRIC_STRONG,