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

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

Merge "Add logging to biometric test path" into sc-dev

parents b9137796 630229f0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ public class BiometricManager {
    @RequiresPermission(TEST_BIOMETRIC)
    public BiometricTestSession createTestSession(int sensorId) {
        try {
            return new BiometricTestSession(mContext,
            return new BiometricTestSession(mContext, sensorId,
                    mService.createTestSession(sensorId, mContext.getOpPackageName()));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
+8 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.Context;
import android.hardware.fingerprint.FingerprintManager;
import android.os.RemoteException;
import android.util.ArraySet;
import android.util.Log;

/**
 * Common set of interfaces to test biometric-related APIs, including {@link BiometricPrompt} and
@@ -33,7 +34,10 @@ import android.util.ArraySet;
 */
@TestApi
public class BiometricTestSession implements AutoCloseable {
    private static final String TAG = "BiometricTestSession";

    private final Context mContext;
    private final int mSensorId;
    private final ITestSession mTestSession;

    // Keep track of users that were tested, which need to be cleaned up when finishing.
@@ -42,8 +46,10 @@ public class BiometricTestSession implements AutoCloseable {
    /**
     * @hide
     */
    public BiometricTestSession(@NonNull Context context, @NonNull ITestSession testSession) {
    public BiometricTestSession(@NonNull Context context, int sensorId,
            @NonNull ITestSession testSession) {
        mContext = context;
        mSensorId = sensorId;
        mTestSession = testSession;
        mTestedUsers = new ArraySet<>();
        setTestHalEnabled(true);
@@ -61,6 +67,7 @@ public class BiometricTestSession implements AutoCloseable {
    @RequiresPermission(TEST_BIOMETRIC)
    private void setTestHalEnabled(boolean enabled) {
        try {
            Log.w(TAG, "setTestHalEnabled, sensor: " + mSensorId + " enabled: " + enabled);
            mTestSession.setTestHalEnabled(enabled);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
+1 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
    @RequiresPermission(TEST_BIOMETRIC)
    public BiometricTestSession createTestSession(int sensorId) {
        try {
            return new BiometricTestSession(mContext,
            return new BiometricTestSession(mContext, sensorId,
                    mService.createTestSession(sensorId, mContext.getOpPackageName()));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
+1 −0
Original line number Diff line number Diff line
@@ -496,6 +496,7 @@ public class Sensor {
    }

    void setTestHalEnabled(boolean enabled) {
        Slog.w(mTag, "setTestHalEnabled: " + enabled);
        mTestHalEnabled = enabled;
    }

+16 −17
Original line number Diff line number Diff line
@@ -23,86 +23,85 @@ import android.hardware.biometrics.face.ISessionCallback;
import android.hardware.biometrics.face.SensorProps;
import android.hardware.common.NativeHandle;
import android.hardware.keymaster.HardwareAuthToken;
import android.os.Binder;
import android.os.IBinder;
import android.util.Slog;

/**
 * Test HAL that provides only no-ops.
 */
public class TestHal extends IFace.Stub {
    private static final String TAG = "face.aidl.TestHal";
    @Override
    public SensorProps[] getSensorProps() {
        Slog.w(TAG, "getSensorProps");
        return new SensorProps[0];
    }

    @Override
    public ISession createSession(int sensorId, int userId, ISessionCallback cb) {
        return new ISession() {
        return new ISession.Stub() {
            @Override
            public void generateChallenge(int cookie, int timeoutSec) {

                Slog.w(TAG, "generateChallenge, cookie: " + cookie);
            }

            @Override
            public void revokeChallenge(int cookie, long challenge) {

                Slog.w(TAG, "revokeChallenge: " + challenge + ", cookie: " + cookie);
            }

            @Override
            public ICancellationSignal enroll(int cookie, HardwareAuthToken hat,
                    byte enrollmentType, byte[] features, NativeHandle previewSurface) {
                Slog.w(TAG, "enroll, cookie: " + cookie);
                return null;
            }

            @Override
            public ICancellationSignal authenticate(int cookie, long operationId) {
                Slog.w(TAG, "authenticate, cookie: " + cookie);
                return null;
            }

            @Override
            public ICancellationSignal detectInteraction(int cookie) {
                Slog.w(TAG, "detectInteraction, cookie: " + cookie);
                return null;
            }

            @Override
            public void enumerateEnrollments(int cookie) {

                Slog.w(TAG, "enumerateEnrollments, cookie: " + cookie);
            }

            @Override
            public void removeEnrollments(int cookie, int[] enrollmentIds) {

                Slog.w(TAG, "removeEnrollments, cookie: " + cookie);
            }

            @Override
            public void getFeatures(int cookie, int enrollmentId) {

                Slog.w(TAG, "getFeatures, cookie: " + cookie);
            }

            @Override
            public void setFeature(int cookie, HardwareAuthToken hat, int enrollmentId,
                    byte feature, boolean enabled) {

                Slog.w(TAG, "setFeature, cookie: " + cookie);
            }

            @Override
            public void getAuthenticatorId(int cookie) {

                Slog.w(TAG, "getAuthenticatorId, cookie: " + cookie);
            }

            @Override
            public void invalidateAuthenticatorId(int cookie) {

                Slog.w(TAG, "invalidateAuthenticatorId, cookie: " + cookie);
            }

            @Override
            public void resetLockout(int cookie, HardwareAuthToken hat) {

            }

            @Override
            public IBinder asBinder() {
                return new Binder();
                Slog.w(TAG, "resetLockout, cookie: " + cookie);
            }
        };
    }
Loading