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

Commit a8b57efe authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Update BiometricManager constants

Fixes: 117822032

Test: atest BiometricManagerTest
Change-Id: I9a384a94138e188d870dc3f224f6c21b7de1b82c
parent da3b55a1
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -16068,10 +16068,10 @@ package android.hardware.biometrics {
  public class BiometricManager {
    method public int canAuthenticate();
    field public static final int ERROR_NONE = 0; // 0x0
    field public static final int ERROR_NO_BIOMETRICS = 11; // 0xb
    field public static final int ERROR_NO_HARDWARE = 12; // 0xc
    field public static final int ERROR_UNAVAILABLE = 1; // 0x1
    field public static final int BIOMETRIC_ERROR_NO_BIOMETRICS = 11; // 0xb
    field public static final int BIOMETRIC_ERROR_NO_HARDWARE = 12; // 0xc
    field public static final int BIOMETRIC_ERROR_UNAVAILABLE = 1; // 0x1
    field public static final int BIOMETRIC_SUCCESS = 0; // 0x0
  }
  public class BiometricPrompt {
+1 −1
Original line number Diff line number Diff line
@@ -987,8 +987,8 @@ package android.content {
    field public static final java.lang.String ACTION_PRE_BOOT_COMPLETED = "android.intent.action.PRE_BOOT_COMPLETED";
    field public static final java.lang.String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
    field public static final java.lang.String ACTION_RESOLVE_INSTANT_APP_PACKAGE = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
    field public static final java.lang.String ACTION_REVIEW_PERMISSION_USAGE = "android.intent.action.REVIEW_PERMISSION_USAGE";
    field public static final java.lang.String ACTION_REVIEW_PERMISSIONS = "android.intent.action.REVIEW_PERMISSIONS";
    field public static final java.lang.String ACTION_REVIEW_PERMISSION_USAGE = "android.intent.action.REVIEW_PERMISSION_USAGE";
    field public static final java.lang.String ACTION_SHOW_SUSPENDED_APP_DETAILS = "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
    field public static final deprecated java.lang.String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
    field public static final java.lang.String ACTION_SPLIT_CONFIGURATION_CHANGED = "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public interface BiometricConstants {
     * BiometricManager.
     * @hide
     */
    int BIOMETRIC_ERROR_NONE = 0;
    int BIOMETRIC_SUCCESS = 0;

    /**
     * The hardware is unavailable. Try again later.
+17 −9
Original line number Diff line number Diff line
@@ -35,24 +35,31 @@ public class BiometricManager {
    /**
     * No error detected.
     */
    public static final int ERROR_NONE = BiometricConstants.BIOMETRIC_ERROR_NONE;
    public static final int BIOMETRIC_SUCCESS =
            BiometricConstants.BIOMETRIC_SUCCESS;

    /**
     * The hardware is unavailable. Try again later.
     */
    public static final int ERROR_UNAVAILABLE = BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE;
    public static final int BIOMETRIC_ERROR_UNAVAILABLE =
            BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE;

    /**
     * The user does not have any biometrics enrolled.
     */
    public static final int ERROR_NO_BIOMETRICS = BiometricConstants.BIOMETRIC_ERROR_NO_BIOMETRICS;
    public static final int BIOMETRIC_ERROR_NO_BIOMETRICS =
            BiometricConstants.BIOMETRIC_ERROR_NO_BIOMETRICS;

    /**
     * There is no biometric hardware.
     */
    public static final int ERROR_NO_HARDWARE = BiometricConstants.BIOMETRIC_ERROR_HW_NOT_PRESENT;
    public static final int BIOMETRIC_ERROR_NO_HARDWARE =
            BiometricConstants.BIOMETRIC_ERROR_HW_NOT_PRESENT;

    @IntDef({ERROR_NONE, ERROR_UNAVAILABLE, ERROR_NO_BIOMETRICS, ERROR_NO_HARDWARE})
    @IntDef({BIOMETRIC_SUCCESS,
            BIOMETRIC_ERROR_UNAVAILABLE,
            BIOMETRIC_ERROR_NO_BIOMETRICS,
            BIOMETRIC_ERROR_NO_HARDWARE})
    @interface BiometricError {}

    private final Context mContext;
@@ -72,9 +79,10 @@ public class BiometricManager {
     * Determine if biometrics can be used. In other words, determine if {@link BiometricPrompt}
     * can be expected to be shown (hardware available, templates enrolled, user-enabled).
     *
     * @return Returns {@link #ERROR_NO_BIOMETRICS} if the user does not have any enrolled, or
     *     {@link #ERROR_UNAVAILABLE} if none are currently supported/enabled. Returns
     *     {@link #ERROR_NONE} if a biometric can currently be used (enrolled and available).
     * @return Returns {@link #BIOMETRIC_ERROR_NO_BIOMETRICS} if the user does not have any
     *     enrolled, or {@link #BIOMETRIC_ERROR_UNAVAILABLE} if none are currently
     *     supported/enabled. Returns {@link #BIOMETRIC_SUCCESS} if a biometric can currently be
     *     used (enrolled and available).
     */
    @RequiresPermission(USE_BIOMETRIC)
    public @BiometricError int canAuthenticate() {
@@ -86,7 +94,7 @@ public class BiometricManager {
            }
        } else {
            Slog.w(TAG, "hasEnrolledBiometrics(): Service not connected");
            return ERROR_UNAVAILABLE;
            return BIOMETRIC_ERROR_UNAVAILABLE;
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -272,7 +272,7 @@ public class BiometricService extends SystemService {
                final int error = result.second;

                // Check for errors, notify callback, and return
                if (error != BiometricConstants.BIOMETRIC_ERROR_NONE) {
                if (error != BiometricConstants.BIOMETRIC_SUCCESS) {
                    try {
                        final String hardwareUnavailable =
                                getContext().getString(R.string.biometric_error_hw_unavailable);
@@ -540,7 +540,7 @@ public class BiometricService extends SystemService {
            return new Pair<>(BIOMETRIC_NONE, BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE);
        }

        return new Pair<>(modality, BiometricConstants.BIOMETRIC_ERROR_NONE);
        return new Pair<>(modality, BiometricConstants.BIOMETRIC_SUCCESS);
    }

    private boolean isEnabledForApp(int modality) {