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

Commit 1a3550c1 authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge "Update BiometricManager constants"

parents 985e9a7c a8b57efe
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -16074,10 +16074,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
@@ -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) {