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

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

Merge changes from topic "clientmonitor-cleanup"

* changes:
  11/n: Remove unnecessary things from BiometricAuthenticator
  10/n: Split ClientMonitor functionality into appropriate subclasses
  9/n: Remove MetricsLogger and Constants from biometrics
  8/n: Move acquire message ignoring to face subclasses
  7/n: Move Fingerprint/Face AuthenticationClients to their own file
  6/n: Decouple remainder of lockout stuff
  5/n: Virtualize biometric performance stats
  4/n: Start moving fingerprint lockout to its own class
  3/n: Move internal cleanup to its own ClientMonitor subclass
  2/n: Clean up ClientMonitor
  1/n: Move modality-specific files into new subdirectory
parents f7065ed7 c2d34d4d
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 {
+0 −4
Original line number Diff line number Diff line
@@ -4465,10 +4465,6 @@
    <permission android:name="android.permission.MANAGE_BIOMETRIC_DIALOG"
        android:protectionLevel="signature" />

    <!-- Allows an app to reset face authentication attempt counter. Reserved for the system. @hide -->
    <permission android:name="android.permission.RESET_FACE_LOCKOUT"
        android:protectionLevel="signature" />

    <!-- Allows an application to control keyguard.  Only allowed for system processes.
        @hide -->
    <permission android:name="android.permission.CONTROL_KEYGUARD"
+3 −3
Original line number Diff line number Diff line
@@ -49,9 +49,9 @@ import android.util.Slog;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.SystemService;
import com.android.server.biometrics.face.FaceAuthenticator;
import com.android.server.biometrics.fingerprint.FingerprintAuthenticator;
import com.android.server.biometrics.iris.IrisAuthenticator;
import com.android.server.biometrics.sensors.face.FaceAuthenticator;
import com.android.server.biometrics.sensors.fingerprint.FingerprintAuthenticator;
import com.android.server.biometrics.sensors.iris.IrisAuthenticator;

/**
 * System service that provides an interface for authenticating with biometrics and
Loading