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

Commit a4999f98 authored by Diya Bera's avatar Diya Bera Committed by Android (Google) Code Review
Browse files

Merge "Use credential owner user id for identity check" into main

parents ae45633f 8058a254
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -119,9 +119,16 @@ class PreAuthInfo {
                == BiometricManager.Authenticators.IDENTITY_CHECK;
        boolean isMandatoryBiometricsAuthentication = false;

        final int effectiveUserId;
        if (Flags.effectiveUserBp()) {
            effectiveUserId = userManager.getCredentialOwnerProfile(userId);
        } else {
            effectiveUserId = userId;
        }

        if (dropCredentialFallback(promptInfo.getAuthenticators(),
                settingObserver.getMandatoryBiometricsEnabledAndRequirementsSatisfiedForUser(
                        userId), trustManager)) {
                        effectiveUserId), trustManager)) {
            isMandatoryBiometricsAuthentication = true;
            promptInfo.setAuthenticators(BiometricManager.Authenticators.BIOMETRIC_STRONG);
            if (promptInfo.getNegativeButtonText() == null) {
@@ -145,13 +152,6 @@ class PreAuthInfo {
        final List<BiometricSensor> eligibleSensors = new ArrayList<>();
        final List<Pair<BiometricSensor, Integer>> ineligibleSensors = new ArrayList<>();

        final int effectiveUserId;
        if (Flags.effectiveUserBp()) {
            effectiveUserId = userManager.getCredentialOwnerProfile(userId);
        } else {
            effectiveUserId = userId;
        }

        if (biometricRequested) {
            for (BiometricSensor sensor : sensors) {

+22 −0
Original line number Diff line number Diff line
@@ -332,6 +332,28 @@ public class PreAuthInfoTest {
        assertThat(preAuthInfo.callingUserId).isEqualTo(USER_ID);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_EFFECTIVE_USER_BP)
    public void testCredentialOwnerIdAsUserId_forMandatoryBiometrics() throws Exception {
        when(mUserManager.getCredentialOwnerProfile(USER_ID)).thenReturn(OWNER_ID);
        when(mSettingObserver.getMandatoryBiometricsEnabledAndRequirementsSatisfiedForUser(
                OWNER_ID)).thenReturn(true);
        when(mSettingObserver.getMandatoryBiometricsEnabledAndRequirementsSatisfiedForUser(
                USER_ID)).thenReturn(false);
        when(mTrustManager.isInSignificantPlace()).thenReturn(false);

        final BiometricSensor sensor = getFaceSensor();
        final PromptInfo promptInfo = new PromptInfo();
        promptInfo.setAuthenticators(BiometricManager.Authenticators.IDENTITY_CHECK);
        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,
                mUserManager);

        assertThat(preAuthInfo.getIsMandatoryBiometricsAuthentication()).isTrue();
    }

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