diff options
| author | Kevin Chyn <kchyn@google.com> | 2020-11-02 18:09:46 -0800 |
|---|---|---|
| committer | Kevin Chyn <kchyn@google.com> | 2020-11-13 20:05:16 -0800 |
| commit | 3eb5c9c2d787605c0419dad5716aaeaeb6815af6 (patch) | |
| tree | 4ee0439737fe0732e3b04021cdde7f94e1c32703 /core/java | |
| parent | ef4cd62246a2d72c06703c7817ecb84cd930bfa5 (diff) | |
Initial implementation of BiometricManager TestApis
1) Finishes Face10 test implementation
2) Adds createTestSession and getSensorProperties to
IBiometricAuthenticator. This way, BiometricService, which
is the source of truth for all sensors is able to implement or
forward TestApi requests as appropriate.
3) Removes a few unused parameters (callingUid, callingPid,
callingUserId)
4) Moves proto def to a biometric proto. This is basically the
common TestApi equivalent for getting states of _any_ sensor
service (FingerprintService, FaceService, etc)
5) Moves AuthSession states to biometric.proto
6) Updates SysUI components to use separate positive buttons
for better readability and testing
Bug: 171357779
Test: atest CtsBiometricsTestCases on fingerprint/face devices
Test: atest com.android.server.biometrics
Change-Id: I5d884d4a9f4afa3f947eb4587e869bacd6b2f805
Diffstat (limited to 'core/java')
7 files changed, 77 insertions, 16 deletions
diff --git a/core/java/android/hardware/biometrics/BiometricManager.java b/core/java/android/hardware/biometrics/BiometricManager.java index 3b56dde69704..987d790601b4 100644 --- a/core/java/android/hardware/biometrics/BiometricManager.java +++ b/core/java/android/hardware/biometrics/BiometricManager.java @@ -208,7 +208,17 @@ public class BiometricManager { @NonNull @RequiresPermission(TEST_BIOMETRIC) public List<SensorProperties> getSensorProperties() { - return new ArrayList<>(); // TODO(169459906) + try { + final List<SensorPropertiesInternal> internalProperties = + mService.getSensorProperties(mContext.getOpPackageName()); + final List<SensorProperties> properties = new ArrayList<>(); + for (SensorPropertiesInternal internalProp : internalProperties) { + properties.add(SensorProperties.from(internalProp)); + } + return properties; + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } /** @@ -219,7 +229,12 @@ public class BiometricManager { @NonNull @RequiresPermission(TEST_BIOMETRIC) public BiometricTestSession createTestSession(int sensorId) { - return null; // TODO(169459906) + try { + return new BiometricTestSession(mContext, + mService.createTestSession(sensorId, mContext.getOpPackageName())); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } } /** diff --git a/core/java/android/hardware/biometrics/IAuthService.aidl b/core/java/android/hardware/biometrics/IAuthService.aidl index b44327678ad4..8e7f5ce8a85d 100644 --- a/core/java/android/hardware/biometrics/IAuthService.aidl +++ b/core/java/android/hardware/biometrics/IAuthService.aidl @@ -18,7 +18,9 @@ package android.hardware.biometrics; import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback; import android.hardware.biometrics.IBiometricServiceReceiver; +import android.hardware.biometrics.ITestSession; import android.hardware.biometrics.PromptInfo; +import android.hardware.biometrics.SensorPropertiesInternal; /** * Communication channel from BiometricPrompt and BiometricManager to AuthService. The @@ -28,6 +30,12 @@ import android.hardware.biometrics.PromptInfo; * @hide */ interface IAuthService { + // Creates a test session with the specified sensorId + ITestSession createTestSession(int sensorId, String opPackageName); + + // Retrieve static sensor properties for all biometric sensors + List<SensorPropertiesInternal> getSensorProperties(String opPackageName); + // Retrieve the package where BIometricOrompt's UI is implemented String getUiPackage(); diff --git a/core/java/android/hardware/biometrics/IBiometricAuthenticator.aidl b/core/java/android/hardware/biometrics/IBiometricAuthenticator.aidl index 5e6fe6885f9d..cb43943f4864 100644 --- a/core/java/android/hardware/biometrics/IBiometricAuthenticator.aidl +++ b/core/java/android/hardware/biometrics/IBiometricAuthenticator.aidl @@ -18,6 +18,8 @@ package android.hardware.biometrics; import android.hardware.biometrics.IBiometricSensorReceiver; import android.hardware.biometrics.IBiometricServiceLockoutResetCallback; +import android.hardware.biometrics.ITestSession; +import android.hardware.biometrics.SensorPropertiesInternal; import android.hardware.face.IFaceServiceReceiver; import android.hardware.face.Face; @@ -28,6 +30,15 @@ import android.hardware.face.Face; */ interface IBiometricAuthenticator { + // Creates a test session + ITestSession createTestSession(String opPackageName); + + // Retrieve static sensor properties + SensorPropertiesInternal getSensorProperties(String opPackageName); + + // Requests a proto dump of the service. See biometrics.proto + byte[] dumpSensorServiceStateProto(); + // This method prepares the service to start authenticating, but doesn't start authentication. // This is protected by the MANAGE_BIOMETRIC signature permission. This method should only be // called from BiometricService. The additional uid, pid, userId arguments should be determined @@ -35,14 +46,13 @@ interface IBiometricAuthenticator { // startPreparedClient(). void prepareForAuthentication(boolean requireConfirmation, IBinder token, long operationId, int userId, IBiometricSensorReceiver sensorReceiver, String opPackageName, - int cookie, int callingUid, int callingPid, int callingUserId); + int cookie); // Starts authentication with the previously prepared client. void startPreparedClient(int cookie); // Cancels authentication. - void cancelAuthenticationFromService(IBinder token, String opPackageName, - int callingUid, int callingPid, int callingUserId); + void cancelAuthenticationFromService(IBinder token, String opPackageName); // Determine if HAL is loaded and ready boolean isHardwareDetected(String opPackageName); diff --git a/core/java/android/hardware/biometrics/IBiometricService.aidl b/core/java/android/hardware/biometrics/IBiometricService.aidl index 005ed324da77..6f7bcb68cc8d 100644 --- a/core/java/android/hardware/biometrics/IBiometricService.aidl +++ b/core/java/android/hardware/biometrics/IBiometricService.aidl @@ -19,22 +19,28 @@ package android.hardware.biometrics; import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback; import android.hardware.biometrics.IBiometricServiceReceiver; import android.hardware.biometrics.IBiometricAuthenticator; +import android.hardware.biometrics.ITestSession; import android.hardware.biometrics.PromptInfo; +import android.hardware.biometrics.SensorPropertiesInternal; /** * Communication channel from AuthService to BiometricService. * @hide */ interface IBiometricService { + // Creates a test session with the specified sensorId + ITestSession createTestSession(int sensorId, String opPackageName); + + // Retrieve static sensor properties for all biometric sensors + List<SensorPropertiesInternal> getSensorProperties(String opPackageName); + // Requests authentication. The service choose the appropriate biometric to use, and show // the corresponding BiometricDialog. void authenticate(IBinder token, long operationId, int userId, - IBiometricServiceReceiver receiver, String opPackageName, in PromptInfo promptInfo, - int callingUid, int callingPid, int callingUserId); + IBiometricServiceReceiver receiver, String opPackageName, in PromptInfo promptInfo); // Cancel authentication for the given session. - void cancelAuthentication(IBinder token, String opPackageName, int callingUid, int callingPid, - int callingUserId); + void cancelAuthentication(IBinder token, String opPackageName); // Checks if biometrics can be used. int canAuthenticate(String opPackageName, int userId, int callingUserId, int authenticators); diff --git a/core/java/android/hardware/biometrics/SensorProperties.java b/core/java/android/hardware/biometrics/SensorProperties.java index 5b1b5e612c73..360f138815c0 100644 --- a/core/java/android/hardware/biometrics/SensorProperties.java +++ b/core/java/android/hardware/biometrics/SensorProperties.java @@ -81,4 +81,12 @@ public class SensorProperties { public int getSensorStrength() { return mSensorStrength; } + + /** + * Constructs a {@link SensorProperties} from the internal parcelable representation. + * @hide + */ + public static SensorProperties from(SensorPropertiesInternal internalProp) { + return new SensorProperties(internalProp.sensorId, internalProp.sensorStrength); + } } diff --git a/core/java/android/hardware/face/IFaceService.aidl b/core/java/android/hardware/face/IFaceService.aidl index 27cdda7b0723..c5c51e4661c5 100644 --- a/core/java/android/hardware/face/IFaceService.aidl +++ b/core/java/android/hardware/face/IFaceService.aidl @@ -17,6 +17,7 @@ package android.hardware.face; import android.hardware.biometrics.IBiometricSensorReceiver; import android.hardware.biometrics.IBiometricServiceLockoutResetCallback; +import android.hardware.biometrics.ITestSession; import android.hardware.face.IFaceServiceReceiver; import android.hardware.face.Face; import android.hardware.face.FaceSensorPropertiesInternal; @@ -28,9 +29,19 @@ import android.view.Surface; * @hide */ interface IFaceService { + + // Creates a test session with the specified sensorId + ITestSession createTestSession(int sensorId, String opPackageName); + + // Requests a proto dump of the service to the specified fd + byte[] dumpSensorServiceStateProto(); + // Retrieve static sensor properties for all face sensors List<FaceSensorPropertiesInternal> getSensorPropertiesInternal(String opPackageName); + // Retrieve static sensor properties for the specified sensor + FaceSensorPropertiesInternal getSensorProperties(int sensorId, String opPackageName); + // Authenticate the given sessionId with a face void authenticate(IBinder token, long operationId, int userId, IFaceServiceReceiver receiver, String opPackageName); @@ -46,7 +57,7 @@ interface IFaceService { // startPreparedClient(). void prepareForAuthentication(int sensorId, boolean requireConfirmation, IBinder token, long operationId, int userId, IBiometricSensorReceiver sensorReceiver, String opPackageName, - int cookie, int callingUid, int callingPid, int callingUserId); + int cookie); // Starts authentication with the previously prepared client. void startPreparedClient(int sensorId, int cookie); @@ -58,8 +69,7 @@ interface IFaceService { void cancelFaceDetect(IBinder token, String opPackageName); // Same as above, with extra arguments. - void cancelAuthenticationFromService(int sensorId, IBinder token, String opPackageName, - int callingUid, int callingPid, int callingUserId); + void cancelAuthenticationFromService(int sensorId, IBinder token, String opPackageName); // Start face enrollment void enroll(int userId, IBinder token, in byte [] hardwareAuthToken, IFaceServiceReceiver receiver, diff --git a/core/java/android/hardware/fingerprint/IFingerprintService.aidl b/core/java/android/hardware/fingerprint/IFingerprintService.aidl index 2128d67f80ae..9248b08f260d 100644 --- a/core/java/android/hardware/fingerprint/IFingerprintService.aidl +++ b/core/java/android/hardware/fingerprint/IFingerprintService.aidl @@ -34,9 +34,15 @@ interface IFingerprintService { // Creates a test session with the specified sensorId ITestSession createTestSession(int sensorId, String opPackageName); + // Requests a proto dump of the service to the specified fd + byte[] dumpSensorServiceStateProto(); + // Retrieve static sensor properties for all fingerprint sensors List<FingerprintSensorPropertiesInternal> getSensorPropertiesInternal(String opPackageName); + // Retrieve static sensor properties for the specified sensor + FingerprintSensorPropertiesInternal getSensorProperties(int sensorId, String opPackageName); + // Authenticate the given sessionId with a fingerprint. This is protected by // USE_FINGERPRINT/USE_BIOMETRIC permission. This is effectively deprecated, since it only comes // through FingerprintManager now. @@ -54,8 +60,7 @@ interface IFingerprintService { // by BiometricService. To start authentication after the clients are ready, use // startPreparedClient(). void prepareForAuthentication(int sensorId, IBinder token, long operationId, int userId, - IBiometricSensorReceiver sensorReceiver, String opPackageName, int cookie, - int callingUid, int callingPid, int callingUserId); + IBiometricSensorReceiver sensorReceiver, String opPackageName, int cookie); // Starts authentication with the previously prepared client. void startPreparedClient(int sensorId, int cookie); @@ -68,8 +73,7 @@ interface IFingerprintService { // Same as above, except this is protected by the MANAGE_BIOMETRIC signature permission. Takes // an additional uid, pid, userid. - void cancelAuthenticationFromService(int sensorId, IBinder token, String opPackageName, - int callingUid, int callingPid, int callingUserId); + void cancelAuthenticationFromService(int sensorId, IBinder token, String opPackageName); // Start fingerprint enrollment void enroll(IBinder token, in byte [] hardwareAuthToken, int userId, IFingerprintServiceReceiver receiver, |
