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

Commit 8058a254 authored by Diya Bera's avatar Diya Bera
Browse files

Use credential owner user id for identity check

Bug: 378549994
Test: atest PreAuthInfoTest
Flag: EXEMPT bug fix

Change-Id: I2070006e3f0be1753080749c19f173db6c36f4f3
parent e431db0d
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,