Loading core/java/android/hardware/biometrics/BiometricTestSession.java +8 −6 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class BiometricTestSession implements AutoCloseable { mContext = context; mTestSession = testSession; mTestedUsers = new ArraySet<>(); enableTestHal(true); setTestHalEnabled(true); } /** Loading @@ -56,12 +56,12 @@ public class BiometricTestSession implements AutoCloseable { * secure pathways such as HAT/Keystore are not testable, since they depend on the TEE or its * equivalent for the secret key. * * @param enableTestHal If true, enable testing with a fake HAL instead of the real HAL. * @param enabled If true, enable testing with a fake HAL instead of the real HAL. */ @RequiresPermission(TEST_BIOMETRIC) private void enableTestHal(boolean enableTestHal) { private void setTestHalEnabled(boolean enabled) { try { mTestSession.enableTestHal(enableTestHal); mTestSession.setTestHalEnabled(enabled); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -178,10 +178,12 @@ public class BiometricTestSession implements AutoCloseable { @Override @RequiresPermission(TEST_BIOMETRIC) public void close() { // Disable the test HAL first, so that enumerate is run on the real HAL, which should have // no enrollments. Test-only framework enrollments will be deleted. setTestHalEnabled(false); for (int user : mTestedUsers) { cleanupInternalState(user); } enableTestHal(false); } } core/java/android/hardware/biometrics/ITestSession.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ interface ITestSession { // portion of the framework code that would otherwise require human interaction. Note that // secure pathways such as HAT/Keystore are not testable, since they depend on the TEE or its // equivalent for the secret key. void enableTestHal(boolean enableTestHal); void setTestHalEnabled(boolean enableTestHal); // Starts the enrollment process. This should generally be used when the test HAL is enabled. void startEnroll(int userId); Loading core/proto/android/server/fingerprint.proto +33 −0 Original line number Diff line number Diff line Loading @@ -66,3 +66,36 @@ message PerformanceStatsProto { // Total number of permanent lockouts. optional int32 permanent_lockout = 5; } // Internal FingerprintService states. The above messages (FingerprintServiceDumpProto, etc) // are used for legacy metrics and should not be modified. message FingerprintServiceStateProto { option (.android.msg_privacy).dest = DEST_AUTOMATIC; repeated SensorStateProto sensor_states = 1; } // State of a single sensor. message SensorStateProto { option (.android.msg_privacy).dest = DEST_AUTOMATIC; // Unique sensorId optional int32 sensor_id = 1; // State of the sensor's scheduler. True if currently handling an operation, false if idle. optional bool is_busy = 2; // User states for this sensor. repeated UserStateProto user_states = 3; } // State of a specific user for a specific sensor. message UserStateProto { option (.android.msg_privacy).dest = DEST_AUTOMATIC; // Android user ID optional int32 user_id = 1; // Number of fingerprints enrolled optional int32 num_enrolled = 2; } No newline at end of file services/core/java/com/android/server/biometrics/TEST_MAPPING 0 → 100644 +7 −0 Original line number Diff line number Diff line { "presubmit": [ { "name": "CtsBiometricsTestCases" } ] } No newline at end of file services/core/java/com/android/server/biometrics/sensors/fingerprint/FingerprintService.java +33 −66 Original line number Diff line number Diff line Loading @@ -52,11 +52,10 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.provider.Settings; import android.util.ArrayMap; import android.util.ArraySet; import android.util.EventLog; import android.util.Pair; import android.util.Slog; import android.util.proto.ProtoOutputStream; import android.view.Surface; import com.android.internal.R; Loading Loading @@ -92,55 +91,6 @@ public class FingerprintService extends SystemService { private final GestureAvailabilityDispatcher mGestureAvailabilityDispatcher; private final LockPatternUtils mLockPatternUtils; @NonNull private List<ServiceProvider> mServiceProviders; @NonNull private final ArrayMap<Integer, TestSession> mTestSessions; private final class TestSession extends ITestSession.Stub { private final int mSensorId; TestSession(int sensorId) { mSensorId = sensorId; } @Override public void enableTestHal(boolean enableTestHal) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void startEnroll(int userId) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void finishEnroll(int userId) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void acceptAuthentication(int userId) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void rejectAuthentication(int userId) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void notifyAcquired(int userId, int acquireInfo) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void notifyError(int userId, int errorCode) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void cleanupInternalState(int userId) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } } /** * Receives the incoming binder calls from FingerprintManager. Loading @@ -150,20 +100,22 @@ public class FingerprintService extends SystemService { public ITestSession createTestSession(int sensorId, String opPackageName) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); final TestSession session; synchronized (mTestSessions) { if (!mTestSessions.containsKey(sensorId)) { mTestSessions.put(sensorId, new TestSession(sensorId)); for (ServiceProvider provider : mServiceProviders) { if (provider.containsSensor(sensorId)) { return provider.createTestSession(sensorId, opPackageName); } session = mTestSessions.get(sensorId); } return session; return null; } @Override // Binder call public List<FingerprintSensorPropertiesInternal> getSensorPropertiesInternal( String opPackageName) { Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL); if (getContext().checkCallingOrSelfPermission(USE_BIOMETRIC_INTERNAL) != PackageManager.PERMISSION_GRANTED) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } final List<FingerprintSensorPropertiesInternal> properties = FingerprintService.this.getSensorProperties(); Loading Loading @@ -424,12 +376,28 @@ public class FingerprintService extends SystemService { final long ident = Binder.clearCallingIdentity(); try { if (args.length > 1 && "--proto".equals(args[0]) && "--state".equals(args[1])) { final ProtoOutputStream proto = new ProtoOutputStream(fd); for (ServiceProvider provider : mServiceProviders) { for (FingerprintSensorPropertiesInternal props : provider.getSensorProperties()) { if (args.length > 0 && "--proto".equals(args[0])) { provider.dumpProto(props.sensorId, fd); for (FingerprintSensorPropertiesInternal props : provider.getSensorProperties()) { provider.dumpProtoState(props.sensorId, proto); } } proto.flush(); } else if (args.length > 0 && "--proto".equals(args[0])) { for (ServiceProvider provider : mServiceProviders) { for (FingerprintSensorPropertiesInternal props : provider.getSensorProperties()) { provider.dumpProtoMetrics(props.sensorId, fd); } } } else { for (ServiceProvider provider : mServiceProviders) { for (FingerprintSensorPropertiesInternal props : provider.getSensorProperties()) { pw.println("Dumping for sensorId: " + props.sensorId + ", provider: " + provider.getClass().getSimpleName()); provider.dumpInternal(props.sensorId, pw); } } Loading Loading @@ -622,7 +590,6 @@ public class FingerprintService extends SystemService { mLockoutResetDispatcher = new LockoutResetDispatcher(context); mLockPatternUtils = new LockPatternUtils(context); mServiceProviders = new ArrayList<>(); mTestSessions = new ArrayMap<>(); initializeAidlHals(); } Loading @@ -648,7 +615,7 @@ public class FingerprintService extends SystemService { try { final SensorProps[] props = fp.getSensorProps(); final FingerprintProvider provider = new FingerprintProvider(getContext(), props, fqName, new FingerprintProvider(getContext(), props, instance, mLockoutResetDispatcher, mGestureAvailabilityDispatcher); mServiceProviders.add(provider); } catch (RemoteException e) { Loading Loading
core/java/android/hardware/biometrics/BiometricTestSession.java +8 −6 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class BiometricTestSession implements AutoCloseable { mContext = context; mTestSession = testSession; mTestedUsers = new ArraySet<>(); enableTestHal(true); setTestHalEnabled(true); } /** Loading @@ -56,12 +56,12 @@ public class BiometricTestSession implements AutoCloseable { * secure pathways such as HAT/Keystore are not testable, since they depend on the TEE or its * equivalent for the secret key. * * @param enableTestHal If true, enable testing with a fake HAL instead of the real HAL. * @param enabled If true, enable testing with a fake HAL instead of the real HAL. */ @RequiresPermission(TEST_BIOMETRIC) private void enableTestHal(boolean enableTestHal) { private void setTestHalEnabled(boolean enabled) { try { mTestSession.enableTestHal(enableTestHal); mTestSession.setTestHalEnabled(enabled); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -178,10 +178,12 @@ public class BiometricTestSession implements AutoCloseable { @Override @RequiresPermission(TEST_BIOMETRIC) public void close() { // Disable the test HAL first, so that enumerate is run on the real HAL, which should have // no enrollments. Test-only framework enrollments will be deleted. setTestHalEnabled(false); for (int user : mTestedUsers) { cleanupInternalState(user); } enableTestHal(false); } }
core/java/android/hardware/biometrics/ITestSession.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ interface ITestSession { // portion of the framework code that would otherwise require human interaction. Note that // secure pathways such as HAT/Keystore are not testable, since they depend on the TEE or its // equivalent for the secret key. void enableTestHal(boolean enableTestHal); void setTestHalEnabled(boolean enableTestHal); // Starts the enrollment process. This should generally be used when the test HAL is enabled. void startEnroll(int userId); Loading
core/proto/android/server/fingerprint.proto +33 −0 Original line number Diff line number Diff line Loading @@ -66,3 +66,36 @@ message PerformanceStatsProto { // Total number of permanent lockouts. optional int32 permanent_lockout = 5; } // Internal FingerprintService states. The above messages (FingerprintServiceDumpProto, etc) // are used for legacy metrics and should not be modified. message FingerprintServiceStateProto { option (.android.msg_privacy).dest = DEST_AUTOMATIC; repeated SensorStateProto sensor_states = 1; } // State of a single sensor. message SensorStateProto { option (.android.msg_privacy).dest = DEST_AUTOMATIC; // Unique sensorId optional int32 sensor_id = 1; // State of the sensor's scheduler. True if currently handling an operation, false if idle. optional bool is_busy = 2; // User states for this sensor. repeated UserStateProto user_states = 3; } // State of a specific user for a specific sensor. message UserStateProto { option (.android.msg_privacy).dest = DEST_AUTOMATIC; // Android user ID optional int32 user_id = 1; // Number of fingerprints enrolled optional int32 num_enrolled = 2; } No newline at end of file
services/core/java/com/android/server/biometrics/TEST_MAPPING 0 → 100644 +7 −0 Original line number Diff line number Diff line { "presubmit": [ { "name": "CtsBiometricsTestCases" } ] } No newline at end of file
services/core/java/com/android/server/biometrics/sensors/fingerprint/FingerprintService.java +33 −66 Original line number Diff line number Diff line Loading @@ -52,11 +52,10 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.provider.Settings; import android.util.ArrayMap; import android.util.ArraySet; import android.util.EventLog; import android.util.Pair; import android.util.Slog; import android.util.proto.ProtoOutputStream; import android.view.Surface; import com.android.internal.R; Loading Loading @@ -92,55 +91,6 @@ public class FingerprintService extends SystemService { private final GestureAvailabilityDispatcher mGestureAvailabilityDispatcher; private final LockPatternUtils mLockPatternUtils; @NonNull private List<ServiceProvider> mServiceProviders; @NonNull private final ArrayMap<Integer, TestSession> mTestSessions; private final class TestSession extends ITestSession.Stub { private final int mSensorId; TestSession(int sensorId) { mSensorId = sensorId; } @Override public void enableTestHal(boolean enableTestHal) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void startEnroll(int userId) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void finishEnroll(int userId) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void acceptAuthentication(int userId) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void rejectAuthentication(int userId) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void notifyAcquired(int userId, int acquireInfo) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void notifyError(int userId, int errorCode) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } @Override public void cleanupInternalState(int userId) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } } /** * Receives the incoming binder calls from FingerprintManager. Loading @@ -150,20 +100,22 @@ public class FingerprintService extends SystemService { public ITestSession createTestSession(int sensorId, String opPackageName) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); final TestSession session; synchronized (mTestSessions) { if (!mTestSessions.containsKey(sensorId)) { mTestSessions.put(sensorId, new TestSession(sensorId)); for (ServiceProvider provider : mServiceProviders) { if (provider.containsSensor(sensorId)) { return provider.createTestSession(sensorId, opPackageName); } session = mTestSessions.get(sensorId); } return session; return null; } @Override // Binder call public List<FingerprintSensorPropertiesInternal> getSensorPropertiesInternal( String opPackageName) { Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL); if (getContext().checkCallingOrSelfPermission(USE_BIOMETRIC_INTERNAL) != PackageManager.PERMISSION_GRANTED) { Utils.checkPermission(getContext(), TEST_BIOMETRIC); } final List<FingerprintSensorPropertiesInternal> properties = FingerprintService.this.getSensorProperties(); Loading Loading @@ -424,12 +376,28 @@ public class FingerprintService extends SystemService { final long ident = Binder.clearCallingIdentity(); try { if (args.length > 1 && "--proto".equals(args[0]) && "--state".equals(args[1])) { final ProtoOutputStream proto = new ProtoOutputStream(fd); for (ServiceProvider provider : mServiceProviders) { for (FingerprintSensorPropertiesInternal props : provider.getSensorProperties()) { if (args.length > 0 && "--proto".equals(args[0])) { provider.dumpProto(props.sensorId, fd); for (FingerprintSensorPropertiesInternal props : provider.getSensorProperties()) { provider.dumpProtoState(props.sensorId, proto); } } proto.flush(); } else if (args.length > 0 && "--proto".equals(args[0])) { for (ServiceProvider provider : mServiceProviders) { for (FingerprintSensorPropertiesInternal props : provider.getSensorProperties()) { provider.dumpProtoMetrics(props.sensorId, fd); } } } else { for (ServiceProvider provider : mServiceProviders) { for (FingerprintSensorPropertiesInternal props : provider.getSensorProperties()) { pw.println("Dumping for sensorId: " + props.sensorId + ", provider: " + provider.getClass().getSimpleName()); provider.dumpInternal(props.sensorId, pw); } } Loading Loading @@ -622,7 +590,6 @@ public class FingerprintService extends SystemService { mLockoutResetDispatcher = new LockoutResetDispatcher(context); mLockPatternUtils = new LockPatternUtils(context); mServiceProviders = new ArrayList<>(); mTestSessions = new ArrayMap<>(); initializeAidlHals(); } Loading @@ -648,7 +615,7 @@ public class FingerprintService extends SystemService { try { final SensorProps[] props = fp.getSensorProps(); final FingerprintProvider provider = new FingerprintProvider(getContext(), props, fqName, new FingerprintProvider(getContext(), props, instance, mLockoutResetDispatcher, mGestureAvailabilityDispatcher); mServiceProviders.add(provider); } catch (RemoteException e) { Loading