Merge "Add logging to biometric test path" into sc-dev
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -496,6 +496,7 @@ public class Sensor {
|
||||
}
|
||||
|
||||
void setTestHalEnabled(boolean enabled) {
|
||||
Slog.w(mTag, "setTestHalEnabled: " + enabled);
|
||||
mTestHalEnabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,10 +25,12 @@ import android.hardware.biometrics.face.V1_0.Status;
|
||||
import android.hardware.biometrics.face.V1_1.IBiometricsFace;
|
||||
import android.os.NativeHandle;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TestHal extends IBiometricsFace.Stub {
|
||||
private static final String TAG = "face.hidl.TestHal";
|
||||
@Nullable
|
||||
private IBiometricsFaceClientCallback mCallback;
|
||||
|
||||
@@ -47,6 +49,7 @@ public class TestHal extends IBiometricsFace.Stub {
|
||||
|
||||
@Override
|
||||
public OptionalUint64 generateChallenge(int challengeTimeoutSec) {
|
||||
Slog.w(TAG, "generateChallenge");
|
||||
final OptionalUint64 result = new OptionalUint64();
|
||||
result.status = Status.OK;
|
||||
result.value = 0;
|
||||
@@ -55,6 +58,7 @@ public class TestHal extends IBiometricsFace.Stub {
|
||||
|
||||
@Override
|
||||
public int enroll(ArrayList<Byte> hat, int timeoutSec, ArrayList<Integer> disabledFeatures) {
|
||||
Slog.w(TAG, "enroll");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -95,16 +99,19 @@ public class TestHal extends IBiometricsFace.Stub {
|
||||
|
||||
@Override
|
||||
public int enumerate() {
|
||||
Slog.w(TAG, "enumerate");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(int faceId) {
|
||||
Slog.w(TAG, "remove");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int authenticate(long operationId) {
|
||||
Slog.w(TAG, "authenticate");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -115,6 +122,7 @@ public class TestHal extends IBiometricsFace.Stub {
|
||||
|
||||
@Override
|
||||
public int resetLockout(ArrayList<Byte> hat) {
|
||||
Slog.w(TAG, "resetLockout");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -476,6 +476,7 @@ class Sensor {
|
||||
}
|
||||
|
||||
void setTestHalEnabled(boolean enabled) {
|
||||
Slog.w(mTag, "setTestHalEnabled, enabled");
|
||||
mTestHalEnabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,89 +22,89 @@ import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.biometrics.fingerprint.ISessionCallback;
|
||||
import android.hardware.biometrics.fingerprint.SensorProps;
|
||||
import android.hardware.keymaster.HardwareAuthToken;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.util.Slog;
|
||||
|
||||
/**
|
||||
* Test HAL that provides only provides no-ops.
|
||||
*/
|
||||
public class TestHal extends IFingerprint.Stub {
|
||||
private static final String TAG = "fingerprint.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) {
|
||||
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 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) {
|
||||
|
||||
Slog.w(TAG, "resetLockout, cookie: " + cookie);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPointerDown(int pointerId, int x, int y, float minor, float major) {
|
||||
|
||||
Slog.w(TAG, "onPointerDown");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPointerUp(int pointerId) {
|
||||
|
||||
Slog.w(TAG, "onPointerUp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUiReady() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder asBinder() {
|
||||
return new Binder();
|
||||
Slog.w(TAG, "onUiReady");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,11 +21,14 @@ import android.hardware.biometrics.fingerprint.V2_1.FingerprintError;
|
||||
import android.hardware.biometrics.fingerprint.V2_1.IBiometricsFingerprintClientCallback;
|
||||
import android.hardware.biometrics.fingerprint.V2_3.IBiometricsFingerprint;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
/**
|
||||
* Test HAL that provides only provides no-ops.
|
||||
*/
|
||||
public class TestHal extends IBiometricsFingerprint.Stub {
|
||||
private static final String TAG = "fingerprint.hidl.TestHal";
|
||||
|
||||
@Nullable
|
||||
private IBiometricsFingerprintClientCallback mCallback;
|
||||
|
||||
@@ -57,6 +60,7 @@ public class TestHal extends IBiometricsFingerprint.Stub {
|
||||
|
||||
@Override
|
||||
public int enroll(byte[] hat, int gid, int timeoutSec) {
|
||||
Slog.w(TAG, "enroll");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -80,11 +84,13 @@ public class TestHal extends IBiometricsFingerprint.Stub {
|
||||
|
||||
@Override
|
||||
public int enumerate() {
|
||||
Slog.w(TAG, "Enumerate");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(int gid, int fid) {
|
||||
Slog.w(TAG, "Remove");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -95,6 +101,7 @@ public class TestHal extends IBiometricsFingerprint.Stub {
|
||||
|
||||
@Override
|
||||
public int authenticate(long operationId, int gid) {
|
||||
Slog.w(TAG, "Authenticate");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user