Merge "Revert "Add ComponentInfo in sensor properties into dumpsys"" into udc-dev am: 2e637bb64b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23149557

Change-Id: I33551e35795cee47c9bb4b623ee183af36cf1211
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Haining Chen
2023-05-12 06:16:54 +00:00
committed by Automerger Merge Worker
14 changed files with 131 additions and 219 deletions

View File

@@ -19,8 +19,6 @@ package android.hardware.biometrics;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.text.TextUtils;
import android.util.IndentingPrintWriter;
/** /**
* The internal class for storing the component info for a subsystem of the biometric sensor, * The internal class for storing the component info for a subsystem of the biometric sensor,
@@ -92,19 +90,12 @@ public class ComponentInfoInternal implements Parcelable {
dest.writeString(softwareVersion); dest.writeString(softwareVersion);
} }
/** @Override
* Print the component info into the given stream. public String toString() {
* return "ComponentId: " + componentId
* @param pw The stream to dump the info into. + ", HardwareVersion: " + hardwareVersion
* @hide + ", FirmwareVersion: " + firmwareVersion
*/ + ", SerialNumber " + serialNumber
public void dump(@NonNull IndentingPrintWriter pw) { + ", SoftwareVersion: " + softwareVersion;
pw.println(TextUtils.formatSimple("componentId: %s", componentId));
pw.increaseIndent();
pw.println(TextUtils.formatSimple("hardwareVersion: %s", hardwareVersion));
pw.println(TextUtils.formatSimple("firmwareVersion: %s", firmwareVersion));
pw.println(TextUtils.formatSimple("serialNumber: %s", serialNumber));
pw.println(TextUtils.formatSimple("softwareVersion: %s", softwareVersion));
pw.decreaseIndent();
} }
} }

View File

@@ -58,10 +58,10 @@ interface IBiometricService {
boolean hasEnrolledBiometrics(int userId, String opPackageName); boolean hasEnrolledBiometrics(int userId, String opPackageName);
// Registers an authenticator (e.g. face, fingerprint, iris). // Registers an authenticator (e.g. face, fingerprint, iris).
// Sensor Id in sensor props must be unique, whereas modality doesn't need to be. // Id must be unique, whereas strength and modality don't need to be.
// TODO(b/123321528): Turn strength and modality into enums. // TODO(b/123321528): Turn strength and modality into enums.
@EnforcePermission("USE_BIOMETRIC_INTERNAL") @EnforcePermission("USE_BIOMETRIC_INTERNAL")
void registerAuthenticator(int modality, in SensorPropertiesInternal props, void registerAuthenticator(int id, int modality, int strength,
IBiometricAuthenticator authenticator); IBiometricAuthenticator authenticator);
// Register callback for when keyguard biometric eligibility changes. // Register callback for when keyguard biometric eligibility changes.

View File

@@ -22,20 +22,14 @@ import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.content.Context; import android.content.Context;
import android.hardware.biometrics.BiometricConstants; import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.ComponentInfoInternal;
import android.hardware.biometrics.IBiometricAuthenticator; import android.hardware.biometrics.IBiometricAuthenticator;
import android.hardware.biometrics.IBiometricSensorReceiver; import android.hardware.biometrics.IBiometricSensorReceiver;
import android.hardware.biometrics.SensorPropertiesInternal;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
import android.text.TextUtils;
import android.util.IndentingPrintWriter;
import android.util.Slog; import android.util.Slog;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.util.Collections;
import java.util.List;
/** /**
* Wraps IBiometricAuthenticator implementation and stores information about the authenticator, * Wraps IBiometricAuthenticator implementation and stores information about the authenticator,
@@ -73,7 +67,6 @@ public abstract class BiometricSensor {
public final int id; public final int id;
public final @Authenticators.Types int oemStrength; // strength as configured by the OEM public final @Authenticators.Types int oemStrength; // strength as configured by the OEM
public final int modality; public final int modality;
@NonNull public final List<ComponentInfoInternal> componentInfo;
public final IBiometricAuthenticator impl; public final IBiometricAuthenticator impl;
private @Authenticators.Types int mUpdatedStrength; // updated by BiometricStrengthController private @Authenticators.Types int mUpdatedStrength; // updated by BiometricStrengthController
@@ -93,16 +86,15 @@ public abstract class BiometricSensor {
*/ */
abstract boolean confirmationSupported(); abstract boolean confirmationSupported();
BiometricSensor(@NonNull Context context, int modality, @NonNull SensorPropertiesInternal props, BiometricSensor(@NonNull Context context, int id, int modality,
IBiometricAuthenticator impl) { @Authenticators.Types int strength, IBiometricAuthenticator impl) {
this.mContext = context; this.mContext = context;
this.id = props.sensorId; this.id = id;
this.modality = modality; this.modality = modality;
this.oemStrength = Utils.propertyStrengthToAuthenticatorStrength(props.sensorStrength); this.oemStrength = strength;
this.componentInfo = Collections.unmodifiableList(props.componentInfo);
this.impl = impl; this.impl = impl;
mUpdatedStrength = oemStrength; mUpdatedStrength = strength;
goToStateUnknown(); goToStateUnknown();
} }
@@ -186,25 +178,8 @@ public abstract class BiometricSensor {
return "ID(" + id + ")" return "ID(" + id + ")"
+ ", oemStrength: " + oemStrength + ", oemStrength: " + oemStrength
+ ", updatedStrength: " + mUpdatedStrength + ", updatedStrength: " + mUpdatedStrength
+ ", modality: " + modality + ", modality " + modality
+ ", state: " + mSensorState + ", state: " + mSensorState
+ ", cookie: " + mCookie; + ", cookie: " + mCookie;
} }
protected void dump(@NonNull IndentingPrintWriter pw) {
pw.println(TextUtils.formatSimple("ID: %d", id));
pw.increaseIndent();
pw.println(TextUtils.formatSimple("oemStrength: %d", oemStrength));
pw.println(TextUtils.formatSimple("updatedStrength: %d", mUpdatedStrength));
pw.println(TextUtils.formatSimple("modality: %d", modality));
pw.println("componentInfo:");
for (ComponentInfoInternal info : componentInfo) {
pw.increaseIndent();
info.dump(pw);
pw.decreaseIndent();
}
pw.println(TextUtils.formatSimple("state: %d", mSensorState));
pw.println(TextUtils.formatSimple("cookie: %d", mCookie));
pw.decreaseIndent();
}
} }

View File

@@ -64,7 +64,6 @@ import android.provider.Settings;
import android.security.KeyStore; import android.security.KeyStore;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.ArraySet; import android.util.ArraySet;
import android.util.IndentingPrintWriter;
import android.util.Pair; import android.util.Pair;
import android.util.Slog; import android.util.Slog;
import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream;
@@ -642,16 +641,13 @@ public class BiometricService extends SystemService {
@android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL) @android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL)
@Override @Override
public synchronized void registerAuthenticator(int modality, public synchronized void registerAuthenticator(int id, int modality,
@NonNull SensorPropertiesInternal props, @Authenticators.Types int strength,
@NonNull IBiometricAuthenticator authenticator) { @NonNull IBiometricAuthenticator authenticator) {
super.registerAuthenticator_enforcePermission(); super.registerAuthenticator_enforcePermission();
@Authenticators.Types final int strength = Slog.d(TAG, "Registering ID: " + id
Utils.propertyStrengthToAuthenticatorStrength(props.sensorStrength);
Slog.d(TAG, "Registering ID: " + props.sensorId
+ " Modality: " + modality + " Modality: " + modality
+ " Strength: " + strength); + " Strength: " + strength);
@@ -672,12 +668,12 @@ public class BiometricService extends SystemService {
} }
for (BiometricSensor sensor : mSensors) { for (BiometricSensor sensor : mSensors) {
if (sensor.id == props.sensorId) { if (sensor.id == id) {
throw new IllegalStateException("Cannot register duplicate authenticator"); throw new IllegalStateException("Cannot register duplicate authenticator");
} }
} }
mSensors.add(new BiometricSensor(getContext(), modality, props, authenticator) { mSensors.add(new BiometricSensor(getContext(), id, modality, strength, authenticator) {
@Override @Override
boolean confirmationAlwaysRequired(int userId) { boolean confirmationAlwaysRequired(int userId) {
return mSettingObserver.getConfirmationAlwaysRequired(modality, userId); return mSettingObserver.getConfirmationAlwaysRequired(modality, userId);
@@ -1376,17 +1372,13 @@ public class BiometricService extends SystemService {
return null; return null;
} }
private void dumpInternal(PrintWriter printWriter) { private void dumpInternal(PrintWriter pw) {
IndentingPrintWriter pw = new IndentingPrintWriter(printWriter);
pw.println("Legacy Settings: " + mSettingObserver.mUseLegacyFaceOnlySettings); pw.println("Legacy Settings: " + mSettingObserver.mUseLegacyFaceOnlySettings);
pw.println(); pw.println();
pw.println("Sensors:"); pw.println("Sensors:");
for (BiometricSensor sensor : mSensors) { for (BiometricSensor sensor : mSensors) {
pw.increaseIndent(); pw.println(" " + sensor);
sensor.dump(pw);
pw.decreaseIndent();
} }
pw.println(); pw.println();
pw.println("CurrentSession: " + mAuthSession); pw.println("CurrentSession: " + mAuthSession);

View File

@@ -20,6 +20,7 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.IBiometricService; import android.hardware.biometrics.IBiometricService;
import android.hardware.face.FaceSensorPropertiesInternal; import android.hardware.face.FaceSensorPropertiesInternal;
import android.hardware.face.IFaceAuthenticatorsRegisteredCallback; import android.hardware.face.IFaceAuthenticatorsRegisteredCallback;
@@ -27,6 +28,7 @@ import android.hardware.face.IFaceService;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Slog; import android.util.Slog;
import com.android.server.biometrics.Utils;
import com.android.server.biometrics.sensors.BiometricServiceRegistry; import com.android.server.biometrics.sensors.BiometricServiceRegistry;
import java.util.List; import java.util.List;
@@ -51,8 +53,10 @@ public class FaceServiceRegistry extends BiometricServiceRegistry<ServiceProvide
@Override @Override
protected void registerService(@NonNull IBiometricService service, protected void registerService(@NonNull IBiometricService service,
@NonNull FaceSensorPropertiesInternal props) { @NonNull FaceSensorPropertiesInternal props) {
@BiometricManager.Authenticators.Types final int strength =
Utils.propertyStrengthToAuthenticatorStrength(props.sensorStrength);
try { try {
service.registerAuthenticator(TYPE_FACE, props, service.registerAuthenticator(props.sensorId, TYPE_FACE, strength,
new FaceAuthenticator(mService, props.sensorId)); new FaceAuthenticator(mService, props.sensorId));
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Remote exception when registering sensorId: " + props.sensorId); Slog.e(TAG, "Remote exception when registering sensorId: " + props.sensorId);

View File

@@ -20,6 +20,7 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRIN
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.IBiometricService; import android.hardware.biometrics.IBiometricService;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback; import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback;
@@ -27,6 +28,7 @@ import android.hardware.fingerprint.IFingerprintService;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Slog; import android.util.Slog;
import com.android.server.biometrics.Utils;
import com.android.server.biometrics.sensors.BiometricServiceRegistry; import com.android.server.biometrics.sensors.BiometricServiceRegistry;
import java.util.List; import java.util.List;
@@ -51,8 +53,10 @@ public class FingerprintServiceRegistry extends BiometricServiceRegistry<Service
@Override @Override
protected void registerService(@NonNull IBiometricService service, protected void registerService(@NonNull IBiometricService service,
@NonNull FingerprintSensorPropertiesInternal props) { @NonNull FingerprintSensorPropertiesInternal props) {
@BiometricManager.Authenticators.Types final int strength =
Utils.propertyStrengthToAuthenticatorStrength(props.sensorStrength);
try { try {
service.registerAuthenticator(TYPE_FINGERPRINT, props, service.registerAuthenticator(props.sensorId, TYPE_FINGERPRINT, strength,
new FingerprintAuthenticator(mService, props.sensorId)); new FingerprintAuthenticator(mService, props.sensorId));
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Remote exception when registering sensorId: " + props.sensorId); Slog.e(TAG, "Remote exception when registering sensorId: " + props.sensorId);

View File

@@ -16,10 +16,12 @@
package com.android.server.biometrics.sensors.iris; package com.android.server.biometrics.sensors.iris;
import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_IRIS; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_IRIS;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.content.Context; import android.content.Context;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.IBiometricService; import android.hardware.biometrics.IBiometricService;
import android.hardware.biometrics.SensorPropertiesInternal; import android.hardware.biometrics.SensorPropertiesInternal;
import android.hardware.iris.IIrisService; import android.hardware.iris.IIrisService;
@@ -31,6 +33,7 @@ import android.util.Slog;
import com.android.server.ServiceThread; import com.android.server.ServiceThread;
import com.android.server.SystemService; import com.android.server.SystemService;
import com.android.server.biometrics.Utils;
import java.util.List; import java.util.List;
@@ -72,12 +75,17 @@ public class IrisService extends SystemService {
ServiceManager.getService(Context.BIOMETRIC_SERVICE)); ServiceManager.getService(Context.BIOMETRIC_SERVICE));
for (SensorPropertiesInternal hidlSensor : hidlSensors) { for (SensorPropertiesInternal hidlSensor : hidlSensors) {
final int sensorId = hidlSensor.sensorId;
final @BiometricManager.Authenticators.Types int strength =
Utils.propertyStrengthToAuthenticatorStrength(
hidlSensor.sensorStrength);
final IrisAuthenticator authenticator = new IrisAuthenticator(mServiceWrapper,
sensorId);
try { try {
biometricService.registerAuthenticator(TYPE_IRIS, hidlSensor, biometricService.registerAuthenticator(sensorId, TYPE_IRIS, strength,
new IrisAuthenticator(mServiceWrapper, hidlSensor.sensorId)); authenticator);
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Remote exception when registering sensorId: " Slog.e(TAG, "Remote exception when registering sensorId: " + sensorId);
+ hidlSensor.sensorId);
} }
} }
}); });

View File

@@ -158,7 +158,8 @@ public class AuthServiceTest {
verify(mBiometricService, never()).registerAuthenticator( verify(mBiometricService, never()).registerAuthenticator(
anyInt(), anyInt(),
any(), anyInt(),
anyInt(),
any()); any());
} }

View File

@@ -45,14 +45,13 @@ import android.app.trust.ITrustManager;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.hardware.biometrics.BiometricManager.Authenticators; import android.hardware.biometrics.BiometricManager.Authenticators;
import android.hardware.biometrics.ComponentInfoInternal;
import android.hardware.biometrics.IBiometricAuthenticator; import android.hardware.biometrics.IBiometricAuthenticator;
import android.hardware.biometrics.IBiometricSensorReceiver; import android.hardware.biometrics.IBiometricSensorReceiver;
import android.hardware.biometrics.IBiometricServiceReceiver; import android.hardware.biometrics.IBiometricServiceReceiver;
import android.hardware.biometrics.IBiometricSysuiReceiver; import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo; import android.hardware.biometrics.PromptInfo;
import android.hardware.biometrics.SensorProperties; import android.hardware.biometrics.SensorProperties;
import android.hardware.face.FaceSensorProperties;
import android.hardware.face.FaceSensorPropertiesInternal;
import android.hardware.fingerprint.FingerprintManager; import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorProperties; import android.hardware.fingerprint.FingerprintSensorProperties;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
@@ -490,16 +489,9 @@ public class AuthSessionTest {
IBiometricAuthenticator fingerprintAuthenticator = mock(IBiometricAuthenticator.class); IBiometricAuthenticator fingerprintAuthenticator = mock(IBiometricAuthenticator.class);
when(fingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true); when(fingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true);
when(fingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true); when(fingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
mSensors.add(new BiometricSensor(mContext, id,
final FingerprintSensorPropertiesInternal props = new FingerprintSensorPropertiesInternal(
id, SensorProperties.STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */, type,
false /* resetLockoutRequiresHardwareAuthToken */);
mFingerprintSensorProps.add(props);
mSensors.add(new BiometricSensor(mContext,
TYPE_FINGERPRINT /* modality */, TYPE_FINGERPRINT /* modality */,
props, Authenticators.BIOMETRIC_STRONG /* strength */,
fingerprintAuthenticator) { fingerprintAuthenticator) {
@Override @Override
boolean confirmationAlwaysRequired(int userId) { boolean confirmationAlwaysRequired(int userId) {
@@ -512,6 +504,21 @@ public class AuthSessionTest {
} }
}); });
final List<ComponentInfoInternal> componentInfo = new ArrayList<>();
componentInfo.add(new ComponentInfoInternal("faceSensor" /* componentId */,
"vendor/model/revision" /* hardwareVersion */, "1.01" /* firmwareVersion */,
"00000001" /* serialNumber */, "" /* softwareVersion */));
componentInfo.add(new ComponentInfoInternal("matchingAlgorithm" /* componentId */,
"" /* hardwareVersion */, "" /* firmwareVersion */, "" /* serialNumber */,
"vendor/version/revision" /* softwareVersion */));
mFingerprintSensorProps.add(new FingerprintSensorPropertiesInternal(id,
SensorProperties.STRENGTH_STRONG,
5 /* maxEnrollmentsPerUser */,
componentInfo,
type,
false /* resetLockoutRequiresHardwareAuthToken */));
when(mSettingObserver.getEnabledForApps(anyInt())).thenReturn(true); when(mSettingObserver.getEnabledForApps(anyInt())).thenReturn(true);
} }
@@ -519,13 +526,9 @@ public class AuthSessionTest {
IBiometricAuthenticator authenticator) throws RemoteException { IBiometricAuthenticator authenticator) throws RemoteException {
when(authenticator.isHardwareDetected(any())).thenReturn(true); when(authenticator.isHardwareDetected(any())).thenReturn(true);
when(authenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true); when(authenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
mSensors.add(new BiometricSensor(mContext, mSensors.add(new BiometricSensor(mContext, id,
TYPE_FACE /* modality */, TYPE_FACE /* modality */,
new FaceSensorPropertiesInternal(id, Authenticators.BIOMETRIC_STRONG /* strength */,
SensorProperties.STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */, FaceSensorProperties.TYPE_UNKNOWN,
true /* supportsFace Detection */, true /* supportsSelfIllumination */,
false /* resetLockoutRequiresHardwareAuthToken */),
authenticator) { authenticator) {
@Override @Override
boolean confirmationAlwaysRequired(int userId) { boolean confirmationAlwaysRequired(int userId) {

View File

@@ -19,7 +19,6 @@ package com.android.server.biometrics;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import static android.hardware.biometrics.BiometricManager.Authenticators; import static android.hardware.biometrics.BiometricManager.Authenticators;
import static android.hardware.biometrics.BiometricManager.BIOMETRIC_MULTI_SENSOR_DEFAULT; import static android.hardware.biometrics.BiometricManager.BIOMETRIC_MULTI_SENSOR_DEFAULT;
import static android.hardware.biometrics.SensorProperties.STRENGTH_STRONG;
import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS; import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS;
import static com.android.server.biometrics.BiometricServiceStateProto.STATE_AUTHENTICATED_PENDING_SYSUI; import static com.android.server.biometrics.BiometricServiceStateProto.STATE_AUTHENTICATED_PENDING_SYSUI;
@@ -70,11 +69,7 @@ import android.hardware.biometrics.IBiometricServiceReceiver;
import android.hardware.biometrics.IBiometricSysuiReceiver; import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo; import android.hardware.biometrics.PromptInfo;
import android.hardware.display.DisplayManagerGlobal; import android.hardware.display.DisplayManagerGlobal;
import android.hardware.face.FaceSensorProperties;
import android.hardware.face.FaceSensorPropertiesInternal;
import android.hardware.fingerprint.FingerprintManager; import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorProperties;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.os.Binder; import android.os.Binder;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
@@ -124,7 +119,6 @@ public class BiometricServiceTest {
private static final int SENSOR_ID_FINGERPRINT = 0; private static final int SENSOR_ID_FINGERPRINT = 0;
private static final int SENSOR_ID_FACE = 1; private static final int SENSOR_ID_FACE = 1;
private FingerprintSensorPropertiesInternal mFingerprintProps;
private BiometricService mBiometricService; private BiometricService mBiometricService;
@@ -207,11 +201,6 @@ public class BiometricServiceTest {
}; };
when(mInjector.getConfiguration(any())).thenReturn(config); when(mInjector.getConfiguration(any())).thenReturn(config);
mFingerprintProps = new FingerprintSensorPropertiesInternal(SENSOR_ID_FINGERPRINT,
STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */, List.of() /* componentInfo */,
FingerprintSensorProperties.TYPE_UNKNOWN,
false /* resetLockoutRequiresHardwareAuthToken */);
} }
@Test @Test
@@ -347,7 +336,8 @@ public class BiometricServiceTest {
mBiometricService = new BiometricService(mContext, mInjector); mBiometricService = new BiometricService(mContext, mInjector);
mBiometricService.onStart(); mBiometricService.onStart();
mBiometricService.mImpl.registerAuthenticator(TYPE_FINGERPRINT, mFingerprintProps, mBiometricService.mImpl.registerAuthenticator(0 /* id */,
TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG,
mFingerprintAuthenticator); mFingerprintAuthenticator);
invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */, invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
@@ -419,7 +409,8 @@ public class BiometricServiceTest {
mBiometricService = new BiometricService(mContext, mInjector); mBiometricService = new BiometricService(mContext, mInjector);
mBiometricService.onStart(); mBiometricService.onStart();
mBiometricService.mImpl.registerAuthenticator(TYPE_FINGERPRINT, mFingerprintProps, mBiometricService.mImpl.registerAuthenticator(0 /* id */,
TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG,
mFingerprintAuthenticator); mFingerprintAuthenticator);
invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */, invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
@@ -1351,13 +1342,9 @@ public class BiometricServiceTest {
for (int i = 0; i < testCases.length; i++) { for (int i = 0; i < testCases.length; i++) {
final BiometricSensor sensor = final BiometricSensor sensor =
new BiometricSensor(mContext, new BiometricSensor(mContext, 0 /* id */,
TYPE_FINGERPRINT, TYPE_FINGERPRINT,
new FingerprintSensorPropertiesInternal(i /* id */, testCases[i][0],
Utils.authenticatorStrengthToPropertyStrength(testCases[i][0]),
5 /* maxEnrollmentsPerUser */, List.of() /* componentInfo */,
FingerprintSensorProperties.TYPE_UNKNOWN,
false /* resetLockoutRequiresHardwareAuthToken */),
mock(IBiometricAuthenticator.class)) { mock(IBiometricAuthenticator.class)) {
@Override @Override
boolean confirmationAlwaysRequired(int userId) { boolean confirmationAlwaysRequired(int userId) {
@@ -1385,7 +1372,8 @@ public class BiometricServiceTest {
when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any())) when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any()))
.thenReturn(true); .thenReturn(true);
when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true); when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true);
mBiometricService.mImpl.registerAuthenticator(TYPE_FINGERPRINT, mFingerprintProps, mBiometricService.mImpl.registerAuthenticator(0 /* testId */,
TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG,
mFingerprintAuthenticator); mFingerprintAuthenticator);
verify(mBiometricService.mBiometricStrengthController).updateStrengths(); verify(mBiometricService.mBiometricStrengthController).updateStrengths();
@@ -1396,14 +1384,15 @@ public class BiometricServiceTest {
mBiometricService = new BiometricService(mContext, mInjector); mBiometricService = new BiometricService(mContext, mInjector);
mBiometricService.onStart(); mBiometricService.onStart();
final int testId = 0;
when(mBiometricService.mSettingObserver.getEnabledForApps(anyInt())).thenReturn(true); when(mBiometricService.mSettingObserver.getEnabledForApps(anyInt())).thenReturn(true);
when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any())) when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any()))
.thenReturn(true); .thenReturn(true);
when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true); when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true);
mBiometricService.mImpl.registerAuthenticator(testId /* id */,
final int testId = SENSOR_ID_FINGERPRINT; TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG,
mBiometricService.mImpl.registerAuthenticator(TYPE_FINGERPRINT, mFingerprintProps,
mFingerprintAuthenticator); mFingerprintAuthenticator);
// Downgrade the authenticator // Downgrade the authenticator
@@ -1503,9 +1492,11 @@ public class BiometricServiceTest {
mBiometricService.onStart(); mBiometricService.onStart();
mBiometricService.mImpl.registerAuthenticator( mBiometricService.mImpl.registerAuthenticator(
2 /* modality */, mFingerprintProps, mFingerprintAuthenticator); 0 /* id */, 2 /* modality */, 15 /* strength */,
mFingerprintAuthenticator);
mBiometricService.mImpl.registerAuthenticator( mBiometricService.mImpl.registerAuthenticator(
2 /* modality */, mFingerprintProps, mFingerprintAuthenticator); 0 /* id */, 2 /* modality */, 15 /* strength */,
mFingerprintAuthenticator);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@@ -1515,7 +1506,9 @@ public class BiometricServiceTest {
mBiometricService.onStart(); mBiometricService.onStart();
mBiometricService.mImpl.registerAuthenticator( mBiometricService.mImpl.registerAuthenticator(
2 /* modality */, mFingerprintProps, null /* authenticator */); 0 /* id */, 2 /* modality */,
Authenticators.BIOMETRIC_STRONG /* strength */,
null /* authenticator */);
} }
@Test @Test
@@ -1526,13 +1519,8 @@ public class BiometricServiceTest {
for (String s : mInjector.getConfiguration(null)) { for (String s : mInjector.getConfiguration(null)) {
SensorConfig config = new SensorConfig(s); SensorConfig config = new SensorConfig(s);
mBiometricService.mImpl.registerAuthenticator(config.modality, mBiometricService.mImpl.registerAuthenticator(config.id, config.modality,
new FingerprintSensorPropertiesInternal(config.id, config.strength, mFingerprintAuthenticator);
Utils.authenticatorStrengthToPropertyStrength(config.strength),
5 /* maxEnrollmentsPerUser */, List.of() /* componentInfo */,
FingerprintSensorProperties.TYPE_UNKNOWN,
false /* resetLockoutRequiresHardwareAuthToken */),
mFingerprintAuthenticator);
} }
} }
@@ -1656,12 +1644,7 @@ public class BiometricServiceTest {
when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true); when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true);
when(mFingerprintAuthenticator.getLockoutModeForUser(anyInt())) when(mFingerprintAuthenticator.getLockoutModeForUser(anyInt()))
.thenReturn(LockoutTracker.LOCKOUT_NONE); .thenReturn(LockoutTracker.LOCKOUT_NONE);
mBiometricService.mImpl.registerAuthenticator(modality, mBiometricService.mImpl.registerAuthenticator(SENSOR_ID_FINGERPRINT, modality, strength,
new FingerprintSensorPropertiesInternal(SENSOR_ID_FINGERPRINT,
Utils.authenticatorStrengthToPropertyStrength(strength),
5 /* maxEnrollmentsPerUser */, List.of() /* componentInfo */,
FingerprintSensorProperties.TYPE_UNKNOWN,
false /* resetLockoutRequiresHardwareAuthToken */),
mFingerprintAuthenticator); mFingerprintAuthenticator);
} }
@@ -1670,13 +1653,7 @@ public class BiometricServiceTest {
when(mFaceAuthenticator.isHardwareDetected(any())).thenReturn(true); when(mFaceAuthenticator.isHardwareDetected(any())).thenReturn(true);
when(mFaceAuthenticator.getLockoutModeForUser(anyInt())) when(mFaceAuthenticator.getLockoutModeForUser(anyInt()))
.thenReturn(LockoutTracker.LOCKOUT_NONE); .thenReturn(LockoutTracker.LOCKOUT_NONE);
mBiometricService.mImpl.registerAuthenticator(modality, mBiometricService.mImpl.registerAuthenticator(SENSOR_ID_FACE, modality, strength,
new FaceSensorPropertiesInternal(SENSOR_ID_FACE,
Utils.authenticatorStrengthToPropertyStrength(strength),
5 /* maxEnrollmentsPerUser */, List.of() /* componentInfo */,
FaceSensorProperties.TYPE_UNKNOWN, true /* supportsFace Detection */,
true /* supportsSelfIllumination */,
false /* resetLockoutRequiresHardwareAuthToken */),
mFaceAuthenticator); mFaceAuthenticator);
} }
} }
@@ -1699,27 +1676,15 @@ public class BiometricServiceTest {
when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any())) when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any()))
.thenReturn(true); .thenReturn(true);
when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true); when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true);
mBiometricService.mImpl.registerAuthenticator(modality, mBiometricService.mImpl.registerAuthenticator(SENSOR_ID_FINGERPRINT, modality,
new FingerprintSensorPropertiesInternal(SENSOR_ID_FINGERPRINT, strength, mFingerprintAuthenticator);
Utils.authenticatorStrengthToPropertyStrength(strength),
5 /* maxEnrollmentsPerUser */, List.of() /* componentInfo */,
FingerprintSensorProperties.TYPE_UNKNOWN,
false /* resetLockoutRequiresHardwareAuthToken */),
mFingerprintAuthenticator);
} }
if ((modality & BiometricAuthenticator.TYPE_FACE) != 0) { if ((modality & BiometricAuthenticator.TYPE_FACE) != 0) {
when(mFaceAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true); when(mFaceAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
when(mFaceAuthenticator.isHardwareDetected(any())).thenReturn(true); when(mFaceAuthenticator.isHardwareDetected(any())).thenReturn(true);
mBiometricService.mImpl.registerAuthenticator(modality, mBiometricService.mImpl.registerAuthenticator(SENSOR_ID_FACE, modality,
new FaceSensorPropertiesInternal(SENSOR_ID_FACE, strength, mFaceAuthenticator);
Utils.authenticatorStrengthToPropertyStrength(strength),
5 /* maxEnrollmentsPerUser */, List.of() /* componentInfo */,
FaceSensorProperties.TYPE_UNKNOWN,
true /* supportsFace Detection */,
true /* supportsSelfIllumination */,
false /* resetLockoutRequiresHardwareAuthToken */),
mFaceAuthenticator);
} }
} }
} }

View File

@@ -16,9 +16,6 @@
package com.android.server.biometrics; package com.android.server.biometrics;
import static android.hardware.biometrics.SensorProperties.STRENGTH_STRONG;
import static android.hardware.biometrics.SensorProperties.STRENGTH_WEAK;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
@@ -30,13 +27,9 @@ import static org.mockito.Mockito.when;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.content.Context; import android.content.Context;
import android.hardware.biometrics.BiometricAuthenticator; import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.biometrics.BiometricManager.Authenticators;
import android.hardware.biometrics.IBiometricAuthenticator; import android.hardware.biometrics.IBiometricAuthenticator;
import android.hardware.biometrics.IInvalidationCallback; import android.hardware.biometrics.IInvalidationCallback;
import android.hardware.biometrics.SensorPropertiesInternal;
import android.hardware.face.FaceSensorProperties;
import android.hardware.face.FaceSensorPropertiesInternal;
import android.hardware.fingerprint.FingerprintSensorProperties;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.platform.test.annotations.Presubmit; import android.platform.test.annotations.Presubmit;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
@@ -49,7 +42,6 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
@Presubmit @Presubmit
@SmallTest @SmallTest
@@ -67,54 +59,26 @@ public class InvalidationTrackerTest {
public void testCallbackReceived_whenAllStrongSensorsInvalidated() throws Exception { public void testCallbackReceived_whenAllStrongSensorsInvalidated() throws Exception {
final IBiometricAuthenticator authenticator1 = mock(IBiometricAuthenticator.class); final IBiometricAuthenticator authenticator1 = mock(IBiometricAuthenticator.class);
when(authenticator1.hasEnrolledTemplates(anyInt(), any())).thenReturn(true); when(authenticator1.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
final TestSensor sensor1 = new TestSensor(mContext, final TestSensor sensor1 = new TestSensor(mContext, 0 /* id */,
BiometricAuthenticator.TYPE_FINGERPRINT, BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG,
new FingerprintSensorPropertiesInternal(0 /* id */,
STRENGTH_STRONG,
5 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */,
FingerprintSensorProperties.TYPE_UDFPS_OPTICAL,
false /* resetLockoutRequiresHardwareAuthToken */),
authenticator1); authenticator1);
final IBiometricAuthenticator authenticator2 = mock(IBiometricAuthenticator.class); final IBiometricAuthenticator authenticator2 = mock(IBiometricAuthenticator.class);
when(authenticator2.hasEnrolledTemplates(anyInt(), any())).thenReturn(true); when(authenticator2.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
final TestSensor sensor2 = new TestSensor(mContext, final TestSensor sensor2 = new TestSensor(mContext, 1 /* id */,
BiometricAuthenticator.TYPE_FINGERPRINT, BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG,
new FingerprintSensorPropertiesInternal(1 /* id */,
STRENGTH_STRONG,
5 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */,
FingerprintSensorProperties.TYPE_REAR,
false /* resetLockoutRequiresHardwareAuthToken */),
authenticator2); authenticator2);
final IBiometricAuthenticator authenticator3 = mock(IBiometricAuthenticator.class); final IBiometricAuthenticator authenticator3 = mock(IBiometricAuthenticator.class);
when(authenticator3.hasEnrolledTemplates(anyInt(), any())).thenReturn(true); when(authenticator3.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
final TestSensor sensor3 = new TestSensor(mContext, final TestSensor sensor3 = new TestSensor(mContext, 2 /* id */,
BiometricAuthenticator.TYPE_FACE, BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG,
new FaceSensorPropertiesInternal(2 /* id */,
STRENGTH_STRONG,
5 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */,
FaceSensorProperties.TYPE_RGB,
true /* supportsFace Detection */,
true /* supportsSelfIllumination */,
false /* resetLockoutRequiresHardwareAuthToken */),
authenticator3); authenticator3);
final IBiometricAuthenticator authenticator4 = mock(IBiometricAuthenticator.class); final IBiometricAuthenticator authenticator4 = mock(IBiometricAuthenticator.class);
when(authenticator4.hasEnrolledTemplates(anyInt(), any())).thenReturn(true); when(authenticator4.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
final TestSensor sensor4 = new TestSensor(mContext, final TestSensor sensor4 = new TestSensor(mContext, 3 /* id */,
BiometricAuthenticator.TYPE_FACE, BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_WEAK,
new FaceSensorPropertiesInternal(3 /* id */,
STRENGTH_WEAK,
5 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */,
FaceSensorProperties.TYPE_IR,
true /* supportsFace Detection */,
true /* supportsSelfIllumination */,
false /* resetLockoutRequiresHardwareAuthToken */),
authenticator4); authenticator4);
final ArrayList<BiometricSensor> sensors = new ArrayList<>(); final ArrayList<BiometricSensor> sensors = new ArrayList<>();
@@ -149,9 +113,9 @@ public class InvalidationTrackerTest {
private static class TestSensor extends BiometricSensor { private static class TestSensor extends BiometricSensor {
TestSensor(@NonNull Context context, int modality, @NonNull SensorPropertiesInternal props, TestSensor(@NonNull Context context, int id, int modality, int strength,
@NonNull IBiometricAuthenticator impl) { @NonNull IBiometricAuthenticator impl) {
super(context, modality, props, impl); super(context, id, modality, strength, impl);
} }
@Override @Override

View File

@@ -17,6 +17,8 @@
package com.android.server.biometrics.sensors.face; package com.android.server.biometrics.sensors.face;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import static android.hardware.biometrics.BiometricManager.Authenticators.BIOMETRIC_STRONG;
import static android.hardware.biometrics.BiometricManager.Authenticators.BIOMETRIC_WEAK;
import static android.hardware.biometrics.SensorProperties.STRENGTH_STRONG; import static android.hardware.biometrics.SensorProperties.STRENGTH_STRONG;
import static android.hardware.biometrics.SensorProperties.STRENGTH_WEAK; import static android.hardware.biometrics.SensorProperties.STRENGTH_WEAK;
@@ -68,7 +70,9 @@ public class FaceServiceRegistryTest {
@Mock @Mock
private ServiceProvider mProvider2; private ServiceProvider mProvider2;
@Captor @Captor
private ArgumentCaptor<FaceSensorPropertiesInternal> mPropsCaptor; private ArgumentCaptor<Integer> mIdCaptor;
@Captor
private ArgumentCaptor<Integer> mStrengthCaptor;
private FaceSensorPropertiesInternal mProvider1Props; private FaceSensorPropertiesInternal mProvider1Props;
private FaceSensorPropertiesInternal mProvider2Props; private FaceSensorPropertiesInternal mProvider2Props;
@@ -78,13 +82,13 @@ public class FaceServiceRegistryTest {
public void setup() { public void setup() {
mProvider1Props = new FaceSensorPropertiesInternal(SENSOR_ID_1, mProvider1Props = new FaceSensorPropertiesInternal(SENSOR_ID_1,
STRENGTH_WEAK, 5 /* maxEnrollmentsPerUser */, STRENGTH_WEAK, 5 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */, FaceSensorProperties.TYPE_RGB, List.of(), FaceSensorProperties.TYPE_RGB,
true /* supportsFace Detection */, true /* supportsFace Detection */,
true /* supportsSelfIllumination */, true /* supportsSelfIllumination */,
false /* resetLockoutRequiresHardwareAuthToken */); false /* resetLockoutRequiresHardwareAuthToken */);
mProvider2Props = new FaceSensorPropertiesInternal(SENSOR_ID_2, mProvider2Props = new FaceSensorPropertiesInternal(SENSOR_ID_2,
STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */, STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */, FaceSensorProperties.TYPE_IR, List.of(), FaceSensorProperties.TYPE_IR,
true /* supportsFace Detection */, true /* supportsFace Detection */,
true /* supportsSelfIllumination */, true /* supportsSelfIllumination */,
false /* resetLockoutRequiresHardwareAuthToken */); false /* resetLockoutRequiresHardwareAuthToken */);
@@ -103,9 +107,10 @@ public class FaceServiceRegistryTest {
assertThat(mRegistry.getProviders()).containsExactly(mProvider1, mProvider2); assertThat(mRegistry.getProviders()).containsExactly(mProvider1, mProvider2);
assertThat(mRegistry.getAllProperties()).containsExactly(mProvider1Props, mProvider2Props); assertThat(mRegistry.getAllProperties()).containsExactly(mProvider1Props, mProvider2Props);
verify(mBiometricService, times(2)).registerAuthenticator( verify(mBiometricService, times(2)).registerAuthenticator(
eq(TYPE_FACE), mPropsCaptor.capture(), any()); mIdCaptor.capture(), eq(TYPE_FACE), mStrengthCaptor.capture(), any());
assertThat(mPropsCaptor.getAllValues()) assertThat(mIdCaptor.getAllValues()).containsExactly(SENSOR_ID_1, SENSOR_ID_2);
.containsExactly(mProvider1Props, mProvider2Props); assertThat(mStrengthCaptor.getAllValues())
.containsExactly(BIOMETRIC_WEAK, BIOMETRIC_STRONG);
} }
@Test @Test

View File

@@ -17,6 +17,8 @@
package com.android.server.biometrics.sensors.fingerprint; package com.android.server.biometrics.sensors.fingerprint;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT; import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import static android.hardware.biometrics.BiometricManager.Authenticators.BIOMETRIC_STRONG;
import static android.hardware.biometrics.BiometricManager.Authenticators.BIOMETRIC_WEAK;
import static android.hardware.biometrics.SensorProperties.STRENGTH_STRONG; import static android.hardware.biometrics.SensorProperties.STRENGTH_STRONG;
import static android.hardware.biometrics.SensorProperties.STRENGTH_WEAK; import static android.hardware.biometrics.SensorProperties.STRENGTH_WEAK;
@@ -68,7 +70,9 @@ public class FingerprintServiceRegistryTest {
@Mock @Mock
private ServiceProvider mProvider2; private ServiceProvider mProvider2;
@Captor @Captor
private ArgumentCaptor<FingerprintSensorPropertiesInternal> mPropsCaptor; private ArgumentCaptor<Integer> mIdCaptor;
@Captor
private ArgumentCaptor<Integer> mStrengthCaptor;
private FingerprintSensorPropertiesInternal mProvider1Props; private FingerprintSensorPropertiesInternal mProvider1Props;
private FingerprintSensorPropertiesInternal mProvider2Props; private FingerprintSensorPropertiesInternal mProvider2Props;
@@ -78,11 +82,11 @@ public class FingerprintServiceRegistryTest {
public void setup() { public void setup() {
mProvider1Props = new FingerprintSensorPropertiesInternal(SENSOR_ID_1, mProvider1Props = new FingerprintSensorPropertiesInternal(SENSOR_ID_1,
STRENGTH_WEAK, 5 /* maxEnrollmentsPerUser */, STRENGTH_WEAK, 5 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */, FingerprintSensorProperties.TYPE_UDFPS_OPTICAL, List.of(), FingerprintSensorProperties.TYPE_UDFPS_OPTICAL,
false /* resetLockoutRequiresHardwareAuthToken */); false /* resetLockoutRequiresHardwareAuthToken */);
mProvider2Props = new FingerprintSensorPropertiesInternal(SENSOR_ID_2, mProvider2Props = new FingerprintSensorPropertiesInternal(SENSOR_ID_2,
STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */, STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */, FingerprintSensorProperties.TYPE_UNKNOWN, List.of(), FingerprintSensorProperties.TYPE_UNKNOWN,
false /* resetLockoutRequiresHardwareAuthToken */); false /* resetLockoutRequiresHardwareAuthToken */);
when(mProvider1.getSensorProperties()).thenReturn(List.of(mProvider1Props)); when(mProvider1.getSensorProperties()).thenReturn(List.of(mProvider1Props));
@@ -99,9 +103,10 @@ public class FingerprintServiceRegistryTest {
assertThat(mRegistry.getProviders()).containsExactly(mProvider1, mProvider2); assertThat(mRegistry.getProviders()).containsExactly(mProvider1, mProvider2);
assertThat(mRegistry.getAllProperties()).containsExactly(mProvider1Props, mProvider2Props); assertThat(mRegistry.getAllProperties()).containsExactly(mProvider1Props, mProvider2Props);
verify(mBiometricService, times(2)).registerAuthenticator( verify(mBiometricService, times(2)).registerAuthenticator(
eq(TYPE_FINGERPRINT), mPropsCaptor.capture(), any()); mIdCaptor.capture(), eq(TYPE_FINGERPRINT), mStrengthCaptor.capture(), any());
assertThat(mPropsCaptor.getAllValues()) assertThat(mIdCaptor.getAllValues()).containsExactly(SENSOR_ID_1, SENSOR_ID_2);
.containsExactly(mProvider1Props, mProvider2Props); assertThat(mStrengthCaptor.getAllValues())
.containsExactly(BIOMETRIC_WEAK, BIOMETRIC_STRONG);
} }
@Test @Test

View File

@@ -117,17 +117,15 @@ public class FingerprintServiceTest {
private final FingerprintSensorPropertiesInternal mSensorPropsDefault = private final FingerprintSensorPropertiesInternal mSensorPropsDefault =
new FingerprintSensorPropertiesInternal(ID_DEFAULT, STRENGTH_STRONG, new FingerprintSensorPropertiesInternal(ID_DEFAULT, STRENGTH_STRONG,
2 /* maxEnrollmentsPerUser */, 2 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */, List.of(),
TYPE_REAR, TYPE_REAR,
false /* resetLockoutRequiresHardwareAuthToken */); false /* resetLockoutRequiresHardwareAuthToken */);
private final FingerprintSensorPropertiesInternal mSensorPropsVirtual = private final FingerprintSensorPropertiesInternal mSensorPropsVirtual =
new FingerprintSensorPropertiesInternal(ID_VIRTUAL, STRENGTH_STRONG, new FingerprintSensorPropertiesInternal(ID_VIRTUAL, STRENGTH_STRONG,
2 /* maxEnrollmentsPerUser */, 2 /* maxEnrollmentsPerUser */,
List.of() /* componentInfo */, List.of(),
TYPE_UDFPS_OPTICAL, TYPE_UDFPS_OPTICAL,
false /* resetLockoutRequiresHardwareAuthToken */); false /* resetLockoutRequiresHardwareAuthToken */);
@Captor
private ArgumentCaptor<FingerprintSensorPropertiesInternal> mPropsCaptor;
private FingerprintService mService; private FingerprintService mService;
@Before @Before
@@ -178,8 +176,7 @@ public class FingerprintServiceTest {
mService.mServiceWrapper.registerAuthenticators(HIDL_AUTHENTICATORS); mService.mServiceWrapper.registerAuthenticators(HIDL_AUTHENTICATORS);
waitForRegistration(); waitForRegistration();
verify(mIBiometricService).registerAuthenticator(anyInt(), mPropsCaptor.capture(), any()); verify(mIBiometricService).registerAuthenticator(eq(ID_DEFAULT), anyInt(), anyInt(), any());
assertThat(mPropsCaptor.getAllValues()).containsExactly(mSensorPropsDefault);
} }
@Test @Test
@@ -191,8 +188,7 @@ public class FingerprintServiceTest {
mService.mServiceWrapper.registerAuthenticators(HIDL_AUTHENTICATORS); mService.mServiceWrapper.registerAuthenticators(HIDL_AUTHENTICATORS);
waitForRegistration(); waitForRegistration();
verify(mIBiometricService).registerAuthenticator(anyInt(), mPropsCaptor.capture(), any()); verify(mIBiometricService).registerAuthenticator(eq(ID_VIRTUAL), anyInt(), anyInt(), any());
assertThat(mPropsCaptor.getAllValues()).containsExactly(mSensorPropsVirtual);
} }
@Test @Test
@@ -202,8 +198,7 @@ public class FingerprintServiceTest {
mService.mServiceWrapper.registerAuthenticators(HIDL_AUTHENTICATORS); mService.mServiceWrapper.registerAuthenticators(HIDL_AUTHENTICATORS);
waitForRegistration(); waitForRegistration();
verify(mIBiometricService).registerAuthenticator(anyInt(), mPropsCaptor.capture(), any()); verify(mIBiometricService).registerAuthenticator(eq(ID_VIRTUAL), anyInt(), anyInt(), any());
assertThat(mPropsCaptor.getAllValues()).containsExactly(mSensorPropsVirtual);
} }
private void waitForRegistration() throws Exception { private void waitForRegistration() throws Exception {