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

Commit 6ca4c0d2 authored by Hao Dong's avatar Hao Dong
Browse files

Add a placeholder for BIOMETRIC_ERROR_CONTENT_VIEW_MORE_OPTIONS_BUTTON

This is for the previously added content view with more options button, a placeholder in BiometricConstants in the framework should be added even though it is not used, so that AndroidX constants could keep consistent with the framework. Simlar to BIOMETRIC_ERROR_NEGATIVE_BUTTON.

Bug: 328843028
Test: atest AuthSessionTest
Flag: EXEMPT bug fix - add an internal error code

Change-Id: Ica24caf61d02dfdd111c741795c43ed936508c92
parent 764efad9
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -178,6 +178,15 @@ public interface BiometricConstants {
    @FlaggedApi(Flags.FLAG_IDENTITY_CHECK_API)
    int BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS = 21;


    /**
     * The user pressed the more options button on prompt content. This is a placeholder that is
     * currently only used by the support library.
     *
     * @hide
     */
    int BIOMETRIC_ERROR_CONTENT_VIEW_MORE_OPTIONS_BUTTON = 22;

    /**
     * This constant is only used by SystemUI. It notifies SystemUI that authentication was paused
     * because the authentication attempt was unsuccessful.
@@ -209,6 +218,7 @@ public interface BiometricConstants {
            BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED,
            BIOMETRIC_ERROR_IDENTITY_CHECK_NOT_ACTIVE,
            BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS,
            BIOMETRIC_ERROR_CONTENT_VIEW_MORE_OPTIONS_BUTTON,
            BIOMETRIC_PAUSED_REJECTED})
    @Retention(RetentionPolicy.SOURCE)
    @interface Errors {}
+3 −0
Original line number Diff line number Diff line
@@ -803,6 +803,9 @@ public final class AuthSession implements IBinder.DeathRecipient {
                case BiometricPrompt.DISMISSED_REASON_USER_CANCEL:
                    error = BiometricConstants.BIOMETRIC_ERROR_USER_CANCELED;
                    break;
                case BiometricPrompt.DISMISSED_REASON_CONTENT_VIEW_MORE_OPTIONS:
                    error = BiometricConstants.BIOMETRIC_ERROR_CONTENT_VIEW_MORE_OPTIONS_BUTTON;
                    break;
                default:
            }

+30 −1
Original line number Diff line number Diff line
@@ -18,9 +18,11 @@ package com.android.server.biometrics;

import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_CONTENT_VIEW_MORE_OPTIONS_BUTTON;
import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_NEGATIVE_BUTTON;
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRMED;
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRM_NOT_REQUIRED;
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_CONTENT_VIEW_MORE_OPTIONS;
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_NEGATIVE;
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_USER_CANCEL;

@@ -588,7 +590,7 @@ public class AuthSessionTest {
    }

    @Test
    public void testLogOnDialogDismissed_error() throws RemoteException {
    public void testLogOnDialogDismissed_negativeButton() throws RemoteException {
        final IBiometricAuthenticator faceAuthenticator = mock(IBiometricAuthenticator.class);

        setupFace(0 /* id */, false /* confirmationAlwaysRequired */, faceAuthenticator);
@@ -614,6 +616,33 @@ public class AuthSessionTest {
                eq(0) /* userId */);
    }

    @Test
    public void testLogOnDialogDismissed_contentViewMoreOptionsButton() throws RemoteException {
        final IBiometricAuthenticator faceAuthenticator = mock(IBiometricAuthenticator.class);

        setupFace(0 /* id */, false /* confirmationAlwaysRequired */, faceAuthenticator);
        final AuthSession session = createAuthSession(mSensors,
                false /* checkDevicePolicyManager */,
                Authenticators.BIOMETRIC_STRONG,
                TEST_REQUEST_ID,
                0 /* operationId */,
                0 /* userId */);
        session.goToInitialState();
        assertEquals(STATE_AUTH_CALLED, session.getState());

        session.onDialogDismissed(DISMISSED_REASON_CONTENT_VIEW_MORE_OPTIONS, null);
        verify(mBiometricFrameworkStatsLogger, times(1)).error(
                (OperationContextExt) anyObject(),
                eq(BiometricsProtoEnums.MODALITY_FACE),
                eq(BiometricsProtoEnums.ACTION_AUTHENTICATE),
                eq(BiometricsProtoEnums.CLIENT_BIOMETRIC_PROMPT),
                eq(false),
                anyLong(),
                eq(BIOMETRIC_ERROR_CONTENT_VIEW_MORE_OPTIONS_BUTTON),
                eq(0) /* vendorCode */,
                eq(0) /* userId */);
    }

    @Test
    public void onErrorReceivedAfterOnTryAgainPressedWhenSensorsAuthenticating() throws Exception {
        setupFingerprint(0 /* id */, FingerprintSensorProperties.TYPE_UDFPS_OPTICAL);