Add FingerprintManager#hasEnrolledTemplatesForAnySensor

Also fixes places where "e.rethrowFromSystemServer()" wasn't actually
throwing the exception

Bug: 171420675
Test: Builds

Change-Id: I8a077a9184d6efaeb39ed66652a7f44fa9f8ddb6
This commit is contained in:
Kevin Chyn
2020-10-30 14:18:18 -07:00
parent 0583d29f13
commit 1f57d49356
3 changed files with 48 additions and 5 deletions

View File

@@ -797,6 +797,26 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
return hasEnrolledFingerprints(userId);
}
/**
* Checks if the specified user has enrollments in any of the specified sensors.
* @hide
*/
@RequiresPermission(USE_BIOMETRIC_INTERNAL)
public boolean hasEnrolledTemplatesForAnySensor(int userId,
@NonNull List<FingerprintSensorPropertiesInternal> sensors) {
if (mService == null) {
Slog.w(TAG, "hasEnrolledTemplatesForAnySensor: no fingerprint service");
return false;
}
try {
return mService.hasEnrolledTemplatesForAnySensor(userId, sensors,
mContext.getOpPackageName());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* @hide
*/
@@ -810,7 +830,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
try {
mService.setUdfpsOverlayController(controller);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
throw e.rethrowFromSystemServer();
}
}
@@ -827,7 +847,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
try {
mService.onPointerDown(sensorId, x, y, minor, major);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
throw e.rethrowFromSystemServer();
}
}
@@ -844,7 +864,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
try {
mService.onPointerUp(sensorId);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
throw e.rethrowFromSystemServer();
}
}
@@ -917,9 +937,8 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
}
return mService.getSensorPropertiesInternal(mContext.getOpPackageName());
} catch (RemoteException e) {
e.rethrowFromSystemServer();
throw e.rethrowFromSystemServer();
}
return new ArrayList<>();
}
/**

View File

@@ -101,6 +101,9 @@ interface IFingerprintService {
// Determine if a user has at least one enrolled fingerprint
boolean hasEnrolledFingerprints(int userId, String opPackageName);
// Determine if a user has at least one enrolled fingerprint in any of the specified sensors
boolean hasEnrolledTemplatesForAnySensor(int userId, in List<FingerprintSensorPropertiesInternal> sensors, String opPackageName);
// Return the LockoutTracker status for the specified user
int getLockoutModeForUser(int userId);

View File

@@ -506,6 +506,27 @@ public class FingerprintService extends SystemService {
.isEmpty();
}
@Override // Binder call
public boolean hasEnrolledTemplatesForAnySensor(int userId,
@NonNull List<FingerprintSensorPropertiesInternal> sensors,
@NonNull String opPackageName) {
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
for (FingerprintSensorPropertiesInternal prop : sensors) {
final ServiceProvider provider = getProviderForSensor(prop.sensorId);
if (provider == null) {
Slog.w(TAG, "Null provider for sensorId: " + prop.sensorId
+ ", caller: " + opPackageName);
continue;
}
if (!provider.getEnrolledFingerprints(prop.sensorId, userId).isEmpty()) {
return true;
}
}
return false;
}
@Override // Binder call
public @LockoutTracker.LockoutMode int getLockoutModeForUser(int userId) {
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);