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

Commit 3eb5c9c2 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

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
parent ef4cd622
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -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();
        }
    }

    /**
+8 −0
Original line number Diff line number Diff line
@@ -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();

+13 −3
Original line number Diff line number Diff line
@@ -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);
+10 −4
Original line number Diff line number Diff line
@@ -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);
+8 −0
Original line number Diff line number Diff line
@@ -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);
    }
}
Loading