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

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

Merge changes I830b9f72,Iac0daffd,I604f1fb0

* changes:
  34/n: Rename several trackers to dispatchers
  33/n: Do not upload logs if any fields are unknown
  32/n: Move Face1.0 into its own wrapper
parents 64543cfb 4c9294fe
Loading
Loading
Loading
Loading
+6 −0
Original line number 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.CREDENTIAL_NOT_ENROLLED;

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

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

public class Utils {

@@ -395,4 +397,8 @@ public class Utils {
                ? keyguardComponent.getPackageName() : null;
        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 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 VibrationEffect mSuccessVibrationEffect;
    private final VibrationEffect mErrorVibrationEffect;
    private boolean mErrorAlreadySent;
    private boolean mShouldSendErrorToClient;

    /**
     * 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
        // that do not handle lockout under the HAL. In these cases, ensure that the framework only
        // sends errors once per ClientMonitor.
        if (!mErrorAlreadySent) {
        if (!mShouldSendErrorToClient) {
            logOnError(getContext(), errorCode, vendorCode, getTargetUserId());
            try {
                if (getListener() != null) {
                    mErrorAlreadySent = true;
                    mShouldSendErrorToClient = true;
                    getListener().onError(getSensorId(), getCookie(), errorCode, vendorCode);
                }
            } catch (RemoteException e) {
+21 −14
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.biometrics.sensors;

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

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

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

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

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

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

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

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

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

+26 −17
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Slog;

import com.android.server.biometrics.sensors.fingerprint.GestureAvailabilityTracker;
import com.android.server.biometrics.sensors.fingerprint.GestureAvailabilityDispatcher;

import java.io.PrintWriter;
import java.lang.annotation.Retention;
@@ -37,7 +37,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Queue;
@@ -133,7 +132,7 @@ public class BiometricScheduler {
        @Override
        public void run() {
            if (operation.state != Operation.STATE_FINISHED) {
                Slog.e(tag, "[Watchdog] Running for: " + operation);
                Slog.e(tag, "[Watchdog Triggered]: " + operation);
                operation.clientMonitor.mFinishCallback
                        .onClientFinished(operation.clientMonitor, false /* success */);
            }
@@ -173,7 +172,7 @@ public class BiometricScheduler {
    }

    @NonNull private final String mBiometricTag;
    @Nullable private final GestureAvailabilityTracker mGestureAvailabilityTracker;
    @Nullable private final GestureAvailabilityDispatcher mGestureAvailabilityDispatcher;
    @NonNull private final IBiometricService mBiometricService;
    @NonNull private final Handler mHandler = new Handler(Looper.getMainLooper());
    @NonNull private final InternalFinishCallback mInternalFinishCallback;
@@ -195,6 +194,8 @@ public class BiometricScheduler {
                    return;
                }

                mCurrentOperation.state = Operation.STATE_FINISHED;

                if (mCurrentOperation.clientFinishCallback != null) {
                    mCurrentOperation.clientFinishCallback.onClientFinished(clientMonitor, success);
                }
@@ -206,12 +207,11 @@ public class BiometricScheduler {
                }

                Slog.d(getTag(), "[Finished] " + clientMonitor + ", success: " + success);
                if (mGestureAvailabilityTracker != null) {
                    mGestureAvailabilityTracker.markSensorActive(
                if (mGestureAvailabilityDispatcher != null) {
                    mGestureAvailabilityDispatcher.markSensorActive(
                            mCurrentOperation.clientMonitor.getSensorId(), false /* active */);
                }

                mCurrentOperation.state = Operation.STATE_FINISHED;
                mCurrentOperation = null;
                startNextOperationIfIdle();
            });
@@ -221,15 +221,15 @@ public class BiometricScheduler {
    /**
     * Creates a new scheduler.
     * @param tag for the specific instance of the scheduler. Should be unique.
     * @param gestureAvailabilityTracker may be null if the sensor does not support gestures (such
     *                                   as fingerprint swipe).
     * @param gestureAvailabilityDispatcher may be null if the sensor does not support gestures
     *                                      (such as fingerprint swipe).
     */
    public BiometricScheduler(@NonNull String tag,
            @Nullable GestureAvailabilityTracker gestureAvailabilityTracker) {
            @Nullable GestureAvailabilityDispatcher gestureAvailabilityDispatcher) {
        mBiometricTag = tag;
        mInternalFinishCallback = new InternalFinishCallback();
        mGestureAvailabilityTracker = gestureAvailabilityTracker;
        mPendingOperations = new LinkedList<>();
        mGestureAvailabilityDispatcher = gestureAvailabilityDispatcher;
        mPendingOperations = new ArrayDeque<>();
        mBiometricService = IBiometricService.Stub.asInterface(
                ServiceManager.getService(Context.BIOMETRIC_SERVICE));
        mCrashStates = new ArrayDeque<>();
@@ -268,9 +268,9 @@ public class BiometricScheduler {
            return;
        }

        if (mGestureAvailabilityTracker != null
        if (mGestureAvailabilityDispatcher != null
                && mCurrentOperation.clientMonitor instanceof AcquisitionClient) {
            mGestureAvailabilityTracker.markSensorActive(
            mGestureAvailabilityDispatcher.markSensorActive(
                    mCurrentOperation.clientMonitor.getSensorId(),
                    true /* active */);
        }
@@ -297,15 +297,23 @@ public class BiometricScheduler {
     * Starts the {@link #mCurrentOperation} if
     * 1) its state is {@link Operation#STATE_WAITING_FOR_COOKIE} and
     * 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
     */
    public void startPreparedClient(int cookie) {
        if (mCurrentOperation == null) {
            Slog.e(getTag(), "Current operation null");
            Slog.e(getTag(), "Current operation is null");
            return;
        }
        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;
        }
        if (mCurrentOperation.clientMonitor.getCookie() != cookie) {
@@ -354,7 +362,8 @@ public class BiometricScheduler {

        // If the current operation is cancellable, start the cancellation process.
        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);
        }

Loading