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

Commit 858de7a4 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

32/n: Move Face1.0 into its own wrapper

This change removes BiometricServiceBase. At this point, the framework
is able to support multiple HIDLs for each sensor type.

Also re-adds some things that were forgotten, e.g.
1) Enrollment limit
2) Update authenticatorId after enroll

Bug: 157790417
Test: enroll, authenticate using face
Change-Id: I604f1fb0ca6dfdf1d5c8dd8d1131179daf93d31d
parent dda9f6c2
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import static com.android.server.biometrics.PreAuthInfo.BIOMETRIC_NOT_ENROLLED;
import static com.android.server.biometrics.PreAuthInfo.BIOMETRIC_NO_HARDWARE;
import static com.android.server.biometrics.PreAuthInfo.BIOMETRIC_NO_HARDWARE;
import static com.android.server.biometrics.PreAuthInfo.CREDENTIAL_NOT_ENROLLED;
import static com.android.server.biometrics.PreAuthInfo.CREDENTIAL_NOT_ENROLLED;


import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
@@ -52,6 +53,7 @@ import android.provider.Settings;
import android.util.Slog;
import android.util.Slog;


import com.android.internal.R;
import com.android.internal.R;
import com.android.server.biometrics.sensors.ClientMonitor;


public class Utils {
public class Utils {


@@ -395,4 +397,8 @@ public class Utils {
                ? keyguardComponent.getPackageName() : null;
                ? keyguardComponent.getPackageName() : null;
        return hasPermission && keyguardPackage != null && keyguardPackage.equals(clientPackage);
        return hasPermission && keyguardPackage != null && keyguardPackage.equals(clientPackage);
    }
    }

    public static String getClientName(@Nullable ClientMonitor<?> client) {
        return client != null ? client.getClass().getSimpleName() : "null";
    }
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -45,7 +45,7 @@ public abstract class AcquisitionClient<T> extends ClientMonitor<T> implements I
    private final PowerManager mPowerManager;
    private final PowerManager mPowerManager;
    private final VibrationEffect mSuccessVibrationEffect;
    private final VibrationEffect mSuccessVibrationEffect;
    private final VibrationEffect mErrorVibrationEffect;
    private final VibrationEffect mErrorVibrationEffect;
    private boolean mErrorAlreadySent;
    private boolean mShouldSendErrorToClient;


    /**
    /**
     * Stops the HAL operation specific to the ClientMonitor subclass.
     * Stops the HAL operation specific to the ClientMonitor subclass.
@@ -84,11 +84,11 @@ public abstract class AcquisitionClient<T> extends ClientMonitor<T> implements I
        // case (success, failure, or error) is received from the HAL (e.g. versions of fingerprint
        // case (success, failure, or error) is received from the HAL (e.g. versions of fingerprint
        // that do not handle lockout under the HAL. In these cases, ensure that the framework only
        // that do not handle lockout under the HAL. In these cases, ensure that the framework only
        // sends errors once per ClientMonitor.
        // sends errors once per ClientMonitor.
        if (!mErrorAlreadySent) {
        if (!mShouldSendErrorToClient) {
            logOnError(getContext(), errorCode, vendorCode, getTargetUserId());
            logOnError(getContext(), errorCode, vendorCode, getTargetUserId());
            try {
            try {
                if (getListener() != null) {
                if (getListener() != null) {
                    mErrorAlreadySent = true;
                    mShouldSendErrorToClient = true;
                    getListener().onError(getSensorId(), getCookie(), errorCode, vendorCode);
                    getListener().onError(getSensorId(), getCookie(), errorCode, vendorCode);
                }
                }
            } catch (RemoteException e) {
            } catch (RemoteException e) {
+21 −14
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.biometrics.sensors;
package com.android.server.biometrics.sensors;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager;
import android.app.IActivityTaskManager;
import android.app.IActivityTaskManager;
import android.app.TaskStackListener;
import android.app.TaskStackListener;
@@ -41,7 +42,7 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T> {
    private final boolean mIsStrongBiometric;
    private final boolean mIsStrongBiometric;
    private final boolean mRequireConfirmation;
    private final boolean mRequireConfirmation;
    private final IActivityTaskManager mActivityTaskManager;
    private final IActivityTaskManager mActivityTaskManager;
    private final TaskStackListener mTaskStackListener;
    @Nullable private final TaskStackListener mTaskStackListener;
    private final LockoutTracker mLockoutTracker;
    private final LockoutTracker mLockoutTracker;
    private final boolean mIsRestricted;
    private final boolean mIsRestricted;


@@ -56,7 +57,7 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T> {
            @NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener,
            @NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener,
            int targetUserId, long operationId, boolean restricted, @NonNull String owner,
            int targetUserId, long operationId, boolean restricted, @NonNull String owner,
            int cookie, boolean requireConfirmation, int sensorId, boolean isStrongBiometric,
            int cookie, boolean requireConfirmation, int sensorId, boolean isStrongBiometric,
            int statsModality, int statsClient, @NonNull TaskStackListener taskStackListener,
            int statsModality, int statsClient, @Nullable TaskStackListener taskStackListener,
            @NonNull LockoutTracker lockoutTracker) {
            @NonNull LockoutTracker lockoutTracker) {
        super(context, lazyDaemon, token, listener, targetUserId, owner, cookie, sensorId,
        super(context, lazyDaemon, token, listener, targetUserId, owner, cookie, sensorId,
                statsModality, BiometricsProtoEnums.ACTION_AUTHENTICATE, statsClient);
                statsModality, BiometricsProtoEnums.ACTION_AUTHENTICATE, statsClient);
@@ -133,11 +134,13 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T> {
                    vibrateSuccess();
                    vibrateSuccess();
                }
                }


                if (mTaskStackListener != null) {
                    try {
                    try {
                        mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
                        mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
                    } catch (RemoteException e) {
                    } catch (RemoteException e) {
                        Slog.e(TAG, "Could not unregister task stack listener", e);
                        Slog.e(TAG, "Could not unregister task stack listener", e);
                    }
                    }
                }


                final byte[] byteToken = new byte[hardwareAuthToken.size()];
                final byte[] byteToken = new byte[hardwareAuthToken.size()];
                for (int i = 0; i < hardwareAuthToken.size(); i++) {
                for (int i = 0; i < hardwareAuthToken.size(); i++) {
@@ -221,11 +224,13 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T> {
            return;
            return;
        }
        }


        if (mTaskStackListener != null) {
            try {
            try {
                mActivityTaskManager.registerTaskStackListener(mTaskStackListener);
                mActivityTaskManager.registerTaskStackListener(mTaskStackListener);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Slog.e(TAG, "Could not register task stack listener", e);
                Slog.e(TAG, "Could not register task stack listener", e);
            }
            }
        }


        if (DEBUG) Slog.w(TAG, "Requesting auth for " + getOwnerString());
        if (DEBUG) Slog.w(TAG, "Requesting auth for " + getOwnerString());


@@ -241,11 +246,13 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T> {
            return;
            return;
        }
        }


        if (mTaskStackListener != null) {
            try {
            try {
                mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
                mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Slog.e(TAG, "Could not unregister task stack listener", e);
                Slog.e(TAG, "Could not unregister task stack listener", e);
            }
            }
        }


        if (DEBUG) Slog.w(TAG, "Requesting cancel for " + getOwnerString());
        if (DEBUG) Slog.w(TAG, "Requesting cancel for " + getOwnerString());


+16 −7
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayDeque;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Date;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.List;
import java.util.Locale;
import java.util.Locale;
import java.util.Queue;
import java.util.Queue;
@@ -133,7 +132,7 @@ public class BiometricScheduler {
        @Override
        @Override
        public void run() {
        public void run() {
            if (operation.state != Operation.STATE_FINISHED) {
            if (operation.state != Operation.STATE_FINISHED) {
                Slog.e(tag, "[Watchdog] Running for: " + operation);
                Slog.e(tag, "[Watchdog Triggered]: " + operation);
                operation.clientMonitor.mFinishCallback
                operation.clientMonitor.mFinishCallback
                        .onClientFinished(operation.clientMonitor, false /* success */);
                        .onClientFinished(operation.clientMonitor, false /* success */);
            }
            }
@@ -195,6 +194,8 @@ public class BiometricScheduler {
                    return;
                    return;
                }
                }


                mCurrentOperation.state = Operation.STATE_FINISHED;

                if (mCurrentOperation.clientFinishCallback != null) {
                if (mCurrentOperation.clientFinishCallback != null) {
                    mCurrentOperation.clientFinishCallback.onClientFinished(clientMonitor, success);
                    mCurrentOperation.clientFinishCallback.onClientFinished(clientMonitor, success);
                }
                }
@@ -211,7 +212,6 @@ public class BiometricScheduler {
                            mCurrentOperation.clientMonitor.getSensorId(), false /* active */);
                            mCurrentOperation.clientMonitor.getSensorId(), false /* active */);
                }
                }


                mCurrentOperation.state = Operation.STATE_FINISHED;
                mCurrentOperation = null;
                mCurrentOperation = null;
                startNextOperationIfIdle();
                startNextOperationIfIdle();
            });
            });
@@ -229,7 +229,7 @@ public class BiometricScheduler {
        mBiometricTag = tag;
        mBiometricTag = tag;
        mInternalFinishCallback = new InternalFinishCallback();
        mInternalFinishCallback = new InternalFinishCallback();
        mGestureAvailabilityTracker = gestureAvailabilityTracker;
        mGestureAvailabilityTracker = gestureAvailabilityTracker;
        mPendingOperations = new LinkedList<>();
        mPendingOperations = new ArrayDeque<>();
        mBiometricService = IBiometricService.Stub.asInterface(
        mBiometricService = IBiometricService.Stub.asInterface(
                ServiceManager.getService(Context.BIOMETRIC_SERVICE));
                ServiceManager.getService(Context.BIOMETRIC_SERVICE));
        mCrashStates = new ArrayDeque<>();
        mCrashStates = new ArrayDeque<>();
@@ -297,15 +297,23 @@ public class BiometricScheduler {
     * Starts the {@link #mCurrentOperation} if
     * Starts the {@link #mCurrentOperation} if
     * 1) its state is {@link Operation#STATE_WAITING_FOR_COOKIE} and
     * 1) its state is {@link Operation#STATE_WAITING_FOR_COOKIE} and
     * 2) its cookie matches this cookie
     * 2) its cookie matches this cookie
     *
     * This is currently only used by {@link com.android.server.biometrics.BiometricService}, which
     * requests sensors to prepare for authentication with a cookie. Once sensor(s) are ready (e.g.
     * the BiometricService client becomes the current client in the scheduler), the cookie is
     * returned to BiometricService. Once BiometricService decides that authentication can start,
     * it invokes this code path.
     *
     * @param cookie of the operation to be started
     * @param cookie of the operation to be started
     */
     */
    public void startPreparedClient(int cookie) {
    public void startPreparedClient(int cookie) {
        if (mCurrentOperation == null) {
        if (mCurrentOperation == null) {
            Slog.e(getTag(), "Current operation null");
            Slog.e(getTag(), "Current operation is null");
            return;
            return;
        }
        }
        if (mCurrentOperation.state != Operation.STATE_WAITING_FOR_COOKIE) {
        if (mCurrentOperation.state != Operation.STATE_WAITING_FOR_COOKIE) {
            Slog.e(getTag(), "Operation in wrong state: " + mCurrentOperation);
            Slog.e(getTag(), "Operation is in the wrong state: " + mCurrentOperation
                    + ", expected STATE_WAITING_FOR_COOKIE");
            return;
            return;
        }
        }
        if (mCurrentOperation.clientMonitor.getCookie() != cookie) {
        if (mCurrentOperation.clientMonitor.getCookie() != cookie) {
@@ -354,7 +362,8 @@ public class BiometricScheduler {


        // If the current operation is cancellable, start the cancellation process.
        // If the current operation is cancellable, start the cancellation process.
        if (mCurrentOperation != null && mCurrentOperation.clientMonitor instanceof Interruptable
        if (mCurrentOperation != null && mCurrentOperation.clientMonitor instanceof Interruptable
                && mCurrentOperation.state != Operation.STATE_STARTED_CANCELING) {
                && mCurrentOperation.state == Operation.STATE_STARTED) {
            Slog.d(getTag(), "[Cancelling Interruptable]: " + mCurrentOperation);
            cancelInternal(mCurrentOperation);
            cancelInternal(mCurrentOperation);
        }
        }


+0 −681

File deleted.

Preview size limit exceeded, changes collapsed.

Loading