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

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

11/n: Remove unnecessary things from BiometricAuthenticator

This interface was created before the existence of BiometricService.
Since the sensor registration, arbitration, etc all exist in
BiometricService layer, most of the things here can be removed and
split into separate classes.

Bug: 157790417
Test: Builds

Change-Id: I91ebc13959943b86b93d4fff46ee99050f2cb7bc
parent cddbe9fe
Loading
Loading
Loading
Loading
+0 −82
Original line number Diff line number Diff line
@@ -16,9 +16,7 @@

package android.hardware.biometrics;

import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.hardware.biometrics.BiometricPrompt.AuthenticationResultType;
import android.os.CancellationSignal;
import android.os.Parcelable;
@@ -227,85 +225,5 @@ public interface BiometricAuthenticator {
         * @hide
         */
        public void onAuthenticationAcquired(int acquireInfo) {}
    };

    /**
     * @return true if the biometric hardware is detected.
     */
    default boolean isHardwareDetected() {
        throw new UnsupportedOperationException("Stub!");
    }

    /**
     * @return true if the user has enrolled templates for this biometric.
     */
    default boolean hasEnrolledTemplates() {
        throw new UnsupportedOperationException("Stub!");
    }

    /**
     * @return true if the user has enrolled templates for this biometric.
     */
    default boolean hasEnrolledTemplates(int userId) {
        throw new UnsupportedOperationException("Stub!");
    }

    /**
     * Sets the active user. This is meant to be used to select the current profile
     * to allow separate templates for work profile.
     */
    default void setActiveUser(int userId) {
        throw new UnsupportedOperationException("Stub!");
    }

    /**
     * This call warms up the hardware and starts scanning for valid biometrics. It terminates
     * when {@link AuthenticationCallback#onAuthenticationError(int,
     * CharSequence)} is called or when {@link AuthenticationCallback#onAuthenticationSucceeded(
     * AuthenticationResult)} is called, at which point the crypto object becomes invalid. This
     * operation can be canceled by using the provided cancel object. The application wil receive
     * authentication errors through {@link AuthenticationCallback}. Calling
     * {@link BiometricAuthenticator#authenticate(CryptoObject, CancellationSignal, Executor,
     * AuthenticationCallback)} while an existing authentication attempt is occurring will stop
     * the previous client and start a new authentication. The interrupted client will receive a
     * cancelled notification through {@link AuthenticationCallback#onAuthenticationError(int,
     * CharSequence)}.
     *
     * @throws IllegalArgumentException If any of the arguments are null
     *
     * @param crypto Object associated with the call
     * @param cancel An object that can be used to cancel authentication
     * @param executor An executor to handle callback events
     * @param callback An object to receive authentication events
     */
    default void authenticate(@NonNull CryptoObject crypto,
            @NonNull CancellationSignal cancel,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AuthenticationCallback callback) {
        throw new UnsupportedOperationException("Stub!");
    }

    /**
     * This call warms up the hardware and starts scanning for valid biometrics. It terminates
     * when {@link AuthenticationCallback#onAuthenticationError(int,
     * CharSequence)} is called or when {@link AuthenticationCallback#onAuthenticationSucceeded(
     * AuthenticationResult)} is called. This operation can be canceled by using the provided cancel
     * object. The application wil receive authentication errors through
     * {@link AuthenticationCallback}. Calling {@link BiometricAuthenticator#authenticate(
     * CryptoObject, CancellationSignal, Executor, AuthenticationCallback)} while an existing
     * authentication attempt is occurring will stop the previous client and start a new
     * authentication. The interrupted client will receive a cancelled notification through
     * {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)}.
     *
     * @throws IllegalArgumentException If any of the arguments are null
     *
     * @param cancel An object that can be used to cancel authentication
     * @param executor An executor to handle callback events
     * @param callback An object to receive authentication events
     */
    default void authenticate(@NonNull CancellationSignal cancel,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AuthenticationCallback callback) {
        throw new UnsupportedOperationException("Stub!");
    }
}
+0 −12
Original line number Diff line number Diff line
@@ -448,7 +448,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @hide
     */
    @RequiresPermission(MANAGE_BIOMETRIC)
    @Override
    public void setActiveUser(int userId) {
        if (mService != null) {
            try {
@@ -522,7 +521,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @return true if a face is enrolled, false otherwise
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    @Override
    public boolean hasEnrolledTemplates() {
        if (mService != null) {
            try {
@@ -541,7 +539,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
    @RequiresPermission(allOf = {
            USE_BIOMETRIC_INTERNAL,
            INTERACT_ACROSS_USERS})
    @Override
    public boolean hasEnrolledTemplates(int userId) {
        if (mService != null) {
            try {
@@ -559,7 +556,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @return true if hardware is present and functional, false otherwise.
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    @Override
    public boolean isHardwareDetected() {
        if (mService != null) {
            try {
@@ -612,14 +608,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
        }
    }

    private int getCurrentUserId() {
        try {
            return ActivityManager.getService().getCurrentUser().id;
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    private void cancelEnrollment() {
        if (mService != null) {
            try {
+0 −4
Original line number Diff line number Diff line
@@ -551,7 +551,6 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
     * @hide
     */
    @RequiresPermission(MANAGE_FINGERPRINT)
    @Override
    public void setActiveUser(int userId) {
        if (mService != null) try {
            mService.setActiveUser(userId);
@@ -639,7 +638,6 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
    /**
     * @hide
     */
    @Override
    public boolean hasEnrolledTemplates() {
        return hasEnrolledFingerprints();
    }
@@ -647,7 +645,6 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
    /**
     * @hide
     */
    @Override
    public boolean hasEnrolledTemplates(int userId) {
        return hasEnrolledFingerprints(userId);
    }
@@ -695,7 +692,6 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
     */
    @Deprecated
    @RequiresPermission(USE_FINGERPRINT)
    @Override
    public boolean isHardwareDetected() {
        if (mService != null) {
            try {