Merge "Add sensorId to IBiometricAuthenticator methods"
This commit is contained in:
@@ -577,9 +577,17 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
|
||||
*/
|
||||
@RequiresPermission(MANAGE_BIOMETRIC)
|
||||
public List<Face> getEnrolledFaces(int userId) {
|
||||
final List<FaceSensorPropertiesInternal> faceSensorProperties =
|
||||
getSensorPropertiesInternal();
|
||||
if (faceSensorProperties.isEmpty()) {
|
||||
Slog.e(TAG, "No sensors");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
if (mService != null) {
|
||||
try {
|
||||
return mService.getEnrolledFaces(userId, mContext.getOpPackageName());
|
||||
return mService.getEnrolledFaces(faceSensorProperties.get(0).sensorId, userId,
|
||||
mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -606,15 +614,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
|
||||
*/
|
||||
@RequiresPermission(USE_BIOMETRIC_INTERNAL)
|
||||
public boolean hasEnrolledTemplates() {
|
||||
if (mService != null) {
|
||||
try {
|
||||
return mService.hasEnrolledFaces(
|
||||
UserHandle.myUserId(), mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return hasEnrolledTemplates(UserHandle.myUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -624,9 +624,17 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
|
||||
USE_BIOMETRIC_INTERNAL,
|
||||
INTERACT_ACROSS_USERS})
|
||||
public boolean hasEnrolledTemplates(int userId) {
|
||||
final List<FaceSensorPropertiesInternal> faceSensorProperties =
|
||||
getSensorPropertiesInternal();
|
||||
if (faceSensorProperties.isEmpty()) {
|
||||
Slog.e(TAG, "No sensors");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mService != null) {
|
||||
try {
|
||||
return mService.hasEnrolledFaces(userId, mContext.getOpPackageName());
|
||||
return mService.hasEnrolledFaces(faceSensorProperties.get(0).sensorId, userId,
|
||||
mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -642,9 +650,17 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
|
||||
*/
|
||||
@RequiresPermission(USE_BIOMETRIC_INTERNAL)
|
||||
public boolean isHardwareDetected() {
|
||||
final List<FaceSensorPropertiesInternal> faceSensorProperties =
|
||||
getSensorPropertiesInternal();
|
||||
if (faceSensorProperties.isEmpty()) {
|
||||
Slog.e(TAG, "No sensors");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mService != null) {
|
||||
try {
|
||||
return mService.isHardwareDetected(mContext.getOpPackageName());
|
||||
return mService.isHardwareDetected(faceSensorProperties.get(0).sensorId,
|
||||
mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -677,7 +693,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
|
||||
@NonNull
|
||||
public List<FaceSensorPropertiesInternal> getSensorPropertiesInternal() {
|
||||
try {
|
||||
if (mService == null || !mService.isHardwareDetected(mContext.getOpPackageName())) {
|
||||
if (mService == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return mService.getSensorPropertiesInternal(mContext.getOpPackageName());
|
||||
|
||||
@@ -44,12 +44,12 @@ interface IFaceService {
|
||||
// called from BiometricService. The additional uid, pid, userId arguments should be determined
|
||||
// by BiometricService. To start authentication after the clients are ready, use
|
||||
// startPreparedClient().
|
||||
void prepareForAuthentication(boolean requireConfirmation, IBinder token, long operationId,
|
||||
void prepareForAuthentication(int sensorId, boolean requireConfirmation, IBinder token, long operationId,
|
||||
int userId, IBiometricSensorReceiver sensorReceiver, String opPackageName,
|
||||
int cookie, int callingUid, int callingPid, int callingUserId);
|
||||
|
||||
// Starts authentication with the previously prepared client.
|
||||
void startPreparedClient(int cookie);
|
||||
void startPreparedClient(int sensorId, int cookie);
|
||||
|
||||
// Cancel authentication for the given sessionId
|
||||
void cancelAuthentication(IBinder token, String opPackageName);
|
||||
@@ -58,7 +58,7 @@ interface IFaceService {
|
||||
void cancelFaceDetect(IBinder token, String opPackageName);
|
||||
|
||||
// Same as above, with extra arguments.
|
||||
void cancelAuthenticationFromService(IBinder token, String opPackageName,
|
||||
void cancelAuthenticationFromService(int sensorId, IBinder token, String opPackageName,
|
||||
int callingUid, int callingPid, int callingUserId);
|
||||
|
||||
// Start face enrollment
|
||||
@@ -77,10 +77,10 @@ interface IFaceService {
|
||||
String opPackageName);
|
||||
|
||||
// Get the enrolled face for user.
|
||||
List<Face> getEnrolledFaces(int userId, String opPackageName);
|
||||
List<Face> getEnrolledFaces(int sensorId, int userId, String opPackageName);
|
||||
|
||||
// Determine if HAL is loaded and ready
|
||||
boolean isHardwareDetected(String opPackageName);
|
||||
boolean isHardwareDetected(int sensorId, String opPackageName);
|
||||
|
||||
// Get a pre-enrollment authentication token
|
||||
void generateChallenge(IBinder token, int sensorId, int userId, IFaceServiceReceiver receiver, String opPackageName);
|
||||
@@ -89,13 +89,13 @@ interface IFaceService {
|
||||
void revokeChallenge(IBinder token, int sensorId, int userId, String opPackageName, long challenge);
|
||||
|
||||
// Determine if a user has at least one enrolled face
|
||||
boolean hasEnrolledFaces(int userId, String opPackageName);
|
||||
boolean hasEnrolledFaces(int sensorId, int userId, String opPackageName);
|
||||
|
||||
// Return the LockoutTracker status for the specified user
|
||||
int getLockoutModeForUser(int userId);
|
||||
int getLockoutModeForUser(int sensorId, int userId);
|
||||
|
||||
// Gets the authenticator ID for face
|
||||
long getAuthenticatorId(int callingUserId);
|
||||
long getAuthenticatorId(int sensorId, int callingUserId);
|
||||
|
||||
// Reset the lockout when user authenticates with strong auth (e.g. PIN, pattern or password)
|
||||
void resetLockout(IBinder token, int sensorId, int userId, in byte [] hardwareAuthToken, String opPackageName);
|
||||
|
||||
@@ -846,13 +846,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
@Deprecated
|
||||
@RequiresPermission(USE_FINGERPRINT)
|
||||
public boolean hasEnrolledFingerprints() {
|
||||
if (mService != null) try {
|
||||
return mService.hasEnrolledFingerprints(
|
||||
mContext.getUserId(), mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
return false;
|
||||
return hasEnrolledFingerprints(UserHandle.myUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -863,7 +857,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
INTERACT_ACROSS_USERS})
|
||||
public boolean hasEnrolledFingerprints(int userId) {
|
||||
if (mService != null) try {
|
||||
return mService.hasEnrolledFingerprints(userId, mContext.getOpPackageName());
|
||||
return mService.hasEnrolledFingerprintsDeprecated(userId, mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -882,7 +876,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
public boolean isHardwareDetected() {
|
||||
if (mService != null) {
|
||||
try {
|
||||
return mService.isHardwareDetected(mContext.getOpPackageName());
|
||||
return mService.isHardwareDetectedDeprecated(mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -900,7 +894,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
@NonNull
|
||||
public List<FingerprintSensorPropertiesInternal> getSensorPropertiesInternal() {
|
||||
try {
|
||||
if (mService == null || !mService.isHardwareDetected(mContext.getOpPackageName())) {
|
||||
if (mService == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return mService.getSensorPropertiesInternal(mContext.getOpPackageName());
|
||||
|
||||
@@ -53,12 +53,12 @@ interface IFingerprintService {
|
||||
// called from BiometricService. The additional uid, pid, userId arguments should be determined
|
||||
// by BiometricService. To start authentication after the clients are ready, use
|
||||
// startPreparedClient().
|
||||
void prepareForAuthentication(IBinder token, long operationId, int userId,
|
||||
void prepareForAuthentication(int sensorId, IBinder token, long operationId, int userId,
|
||||
IBiometricSensorReceiver sensorReceiver, String opPackageName, int cookie,
|
||||
int callingUid, int callingPid, int callingUserId);
|
||||
|
||||
// Starts authentication with the previously prepared client.
|
||||
void startPreparedClient(int cookie);
|
||||
void startPreparedClient(int sensorId, int cookie);
|
||||
|
||||
// Cancel authentication for the given sessionId
|
||||
void cancelAuthentication(IBinder token, String opPackageName);
|
||||
@@ -68,7 +68,7 @@ interface IFingerprintService {
|
||||
|
||||
// Same as above, except this is protected by the MANAGE_BIOMETRIC signature permission. Takes
|
||||
// an additional uid, pid, userid.
|
||||
void cancelAuthenticationFromService(IBinder token, String opPackageName,
|
||||
void cancelAuthenticationFromService(int sensorId, IBinder token, String opPackageName,
|
||||
int callingUid, int callingPid, int callingUserId);
|
||||
|
||||
// Start fingerprint enrollment
|
||||
@@ -88,8 +88,11 @@ interface IFingerprintService {
|
||||
// Get a list of enrolled fingerprints in the given userId.
|
||||
List<Fingerprint> getEnrolledFingerprints(int userId, String opPackageName);
|
||||
|
||||
// Determine if HAL is loaded and ready
|
||||
boolean isHardwareDetected(String opPackageName);
|
||||
// Determine if the HAL is loaded and ready. Meant to support the deprecated FingerprintManager APIs
|
||||
boolean isHardwareDetectedDeprecated(String opPackageName);
|
||||
|
||||
// Determine if the specified HAL is loaded and ready
|
||||
boolean isHardwareDetected(int sensorId, String opPackageName);
|
||||
|
||||
// Get a pre-enrollment authentication token
|
||||
void generateChallenge(IBinder token, int sensorId, int userId, IFingerprintServiceReceiver receiver, String opPackageName);
|
||||
@@ -97,17 +100,20 @@ interface IFingerprintService {
|
||||
// Finish an enrollment sequence and invalidate the authentication token
|
||||
void revokeChallenge(IBinder token, int sensorId, int userId, String opPackageName, long challenge);
|
||||
|
||||
// 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. Meant to support the deprecated FingerprintManager APIs
|
||||
boolean hasEnrolledFingerprintsDeprecated(int userId, String opPackageName);
|
||||
|
||||
// Determine if a user has at least one enrolled fingerprint.
|
||||
boolean hasEnrolledFingerprints(int sensorId, 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);
|
||||
int getLockoutModeForUser(int sensorId, int userId);
|
||||
|
||||
// Gets the authenticator ID for fingerprint
|
||||
long getAuthenticatorId(int callingUserId);
|
||||
long getAuthenticatorId(int sensorId, int callingUserId);
|
||||
|
||||
// Reset the timeout when user authenticates with strong auth (e.g. PIN, pattern or password)
|
||||
void resetLockout(IBinder token, int sensorId, int userId, in byte[] hardwareAuthToken, String opPackageNAame);
|
||||
|
||||
@@ -329,6 +329,10 @@ public class AuthService extends SystemService {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize this outside of FingerprintAuthenticator. Only HIDL HALs require
|
||||
// initialization from here. AIDL HALs are initialized by FingerprintService since
|
||||
// the HAL interface provides ID, strength, and other configuration information.
|
||||
fingerprintService.initializeConfiguration(config.id, config.strength);
|
||||
authenticator = new FingerprintAuthenticator(fingerprintService, config);
|
||||
break;
|
||||
|
||||
@@ -340,6 +344,10 @@ public class AuthService extends SystemService {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize this outside of FingerprintAuthenticator. Only HIDL HALs require
|
||||
// initialization from here. AIDL HALs are initialized by FaceService since
|
||||
// the HAL interface provides ID, strength, and other configuration information.
|
||||
faceService.initializeConfiguration(config.id, config.strength);
|
||||
authenticator = new FaceAuthenticator(faceService, config);
|
||||
break;
|
||||
|
||||
|
||||
@@ -30,11 +30,12 @@ import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
*/
|
||||
public final class FaceAuthenticator extends IBiometricAuthenticator.Stub {
|
||||
private final IFaceService mFaceService;
|
||||
private final int mSensorId;
|
||||
|
||||
public FaceAuthenticator(IFaceService faceService, SensorConfig config)
|
||||
throws RemoteException {
|
||||
mFaceService = faceService;
|
||||
mFaceService.initializeConfiguration(config.id, config.strength);
|
||||
mSensorId = config.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,40 +43,41 @@ public final class FaceAuthenticator extends IBiometricAuthenticator.Stub {
|
||||
long operationId, int userId, IBiometricSensorReceiver sensorReceiver,
|
||||
String opPackageName, int cookie, int callingUid, int callingPid, int callingUserId)
|
||||
throws RemoteException {
|
||||
mFaceService.prepareForAuthentication(requireConfirmation, token, operationId, userId,
|
||||
sensorReceiver, opPackageName, cookie, callingUid, callingPid, callingUserId);
|
||||
mFaceService.prepareForAuthentication(mSensorId, requireConfirmation, token, operationId,
|
||||
userId, sensorReceiver, opPackageName, cookie, callingUid, callingPid,
|
||||
callingUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPreparedClient(int cookie) throws RemoteException {
|
||||
mFaceService.startPreparedClient(cookie);
|
||||
mFaceService.startPreparedClient(mSensorId, cookie);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelAuthenticationFromService(IBinder token, String opPackageName, int callingUid,
|
||||
int callingPid, int callingUserId) throws RemoteException {
|
||||
mFaceService.cancelAuthenticationFromService(token, opPackageName, callingUid, callingPid,
|
||||
callingUserId);
|
||||
mFaceService.cancelAuthenticationFromService(mSensorId, token, opPackageName, callingUid,
|
||||
callingPid, callingUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHardwareDetected(String opPackageName) throws RemoteException {
|
||||
return mFaceService.isHardwareDetected(opPackageName);
|
||||
return mFaceService.isHardwareDetected(mSensorId, opPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEnrolledTemplates(int userId, String opPackageName) throws RemoteException {
|
||||
return mFaceService.hasEnrolledFaces(userId, opPackageName);
|
||||
return mFaceService.hasEnrolledFaces(mSensorId, userId, opPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @LockoutTracker.LockoutMode int getLockoutModeForUser(int userId)
|
||||
throws RemoteException {
|
||||
return mFaceService.getLockoutModeForUser(userId);
|
||||
return mFaceService.getLockoutModeForUser(mSensorId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAuthenticatorId(int callingUserId) throws RemoteException {
|
||||
return mFaceService.getAuthenticatorId(callingUserId);
|
||||
return mFaceService.getAuthenticatorId(mSensorId, callingUserId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,35 +255,35 @@ public class FaceService extends SystemService {
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void prepareForAuthentication(boolean requireConfirmation, IBinder token,
|
||||
long operationId, int userId, IBiometricSensorReceiver sensorReceiver,
|
||||
String opPackageName, int cookie, int callingUid, int callingPid,
|
||||
int callingUserId) {
|
||||
public void prepareForAuthentication(int sensorId, boolean requireConfirmation,
|
||||
IBinder token, long operationId, int userId,
|
||||
IBiometricSensorReceiver sensorReceiver, String opPackageName, int cookie,
|
||||
int callingUid, int callingPid, int callingUserId) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for prepareForAuthentication");
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean restricted = true; // BiometricPrompt is always restricted
|
||||
provider.second.scheduleAuthenticate(provider.first, token, operationId, userId, cookie,
|
||||
provider.scheduleAuthenticate(sensorId, token, operationId, userId, cookie,
|
||||
new ClientMonitorCallbackConverter(sensorReceiver), opPackageName, restricted,
|
||||
BiometricsProtoEnums.CLIENT_BIOMETRIC_PROMPT, false /* isKeyguard */);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void startPreparedClient(int cookie) {
|
||||
public void startPreparedClient(int sensorId, int cookie) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for startPreparedClient");
|
||||
return;
|
||||
}
|
||||
|
||||
provider.second.startPreparedClient(provider.first, cookie);
|
||||
provider.startPreparedClient(sensorId, cookie);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
@@ -312,17 +312,17 @@ public class FaceService extends SystemService {
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void cancelAuthenticationFromService(final IBinder token, final String opPackageName,
|
||||
int callingUid, int callingPid, int callingUserId) {
|
||||
public void cancelAuthenticationFromService(int sensorId, final IBinder token,
|
||||
final String opPackageName, int callingUid, int callingPid, int callingUserId) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for cancelAuthenticationFromService");
|
||||
return;
|
||||
}
|
||||
|
||||
provider.second.cancelAuthentication(provider.first, token);
|
||||
provider.cancelAuthentication(sensorId, token);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
@@ -384,24 +384,24 @@ public class FaceService extends SystemService {
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public boolean isHardwareDetected(String opPackageName) {
|
||||
public boolean isHardwareDetected(int sensorId, String opPackageName) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for isHardwareDetected, caller: " + opPackageName);
|
||||
return false;
|
||||
}
|
||||
return provider.second.isHardwareDetected(provider.first);
|
||||
return provider.isHardwareDetected(sensorId);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public List<Face> getEnrolledFaces(int userId, String opPackageName) {
|
||||
public List<Face> getEnrolledFaces(int sensorId, int userId, String opPackageName) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
if (userId != UserHandle.getCallingUserId()) {
|
||||
@@ -412,7 +412,7 @@ public class FaceService extends SystemService {
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public boolean hasEnrolledFaces(int userId, String opPackageName) {
|
||||
public boolean hasEnrolledFaces(int sensorId, int userId, String opPackageName) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
if (userId != UserHandle.getCallingUserId()) {
|
||||
@@ -423,30 +423,29 @@ public class FaceService extends SystemService {
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
@LockoutTracker.LockoutMode
|
||||
public int getLockoutModeForUser(int userId) {
|
||||
public @LockoutTracker.LockoutMode int getLockoutModeForUser(int sensorId, int userId) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for getLockoutModeForUser");
|
||||
return LockoutTracker.LOCKOUT_NONE;
|
||||
}
|
||||
|
||||
return provider.second.getLockoutModeForUser(provider.first, userId);
|
||||
return provider.getLockoutModeForUser(sensorId, userId);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public long getAuthenticatorId(int userId) {
|
||||
public long getAuthenticatorId(int sensorId, int userId) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for getAuthenticatorId");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return provider.second.getAuthenticatorId(provider.first, userId);
|
||||
return provider.getAuthenticatorId(sensorId, userId);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
@@ -454,13 +453,13 @@ public class FaceService extends SystemService {
|
||||
String opPackageName) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for resetLockout, caller: " + opPackageName);
|
||||
return;
|
||||
}
|
||||
|
||||
provider.second.scheduleResetLockout(provider.first, userId, hardwareAuthToken);
|
||||
provider.scheduleResetLockout(sensorId, userId, hardwareAuthToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,11 +30,12 @@ import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
*/
|
||||
public final class FingerprintAuthenticator extends IBiometricAuthenticator.Stub {
|
||||
private final IFingerprintService mFingerprintService;
|
||||
private final int mSensorId;
|
||||
|
||||
public FingerprintAuthenticator(IFingerprintService fingerprintService, SensorConfig config)
|
||||
throws RemoteException {
|
||||
mFingerprintService = fingerprintService;
|
||||
mFingerprintService.initializeConfiguration(config.id, config.strength);
|
||||
mSensorId = config.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,40 +43,40 @@ public final class FingerprintAuthenticator extends IBiometricAuthenticator.Stub
|
||||
long operationId, int userId, IBiometricSensorReceiver sensorReceiver,
|
||||
String opPackageName, int cookie, int callingUid, int callingPid, int callingUserId)
|
||||
throws RemoteException {
|
||||
mFingerprintService.prepareForAuthentication(token, operationId, userId, sensorReceiver,
|
||||
opPackageName, cookie, callingUid, callingPid, callingUserId);
|
||||
mFingerprintService.prepareForAuthentication(mSensorId, token, operationId, userId,
|
||||
sensorReceiver, opPackageName, cookie, callingUid, callingPid, callingUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPreparedClient(int cookie) throws RemoteException {
|
||||
mFingerprintService.startPreparedClient(cookie);
|
||||
mFingerprintService.startPreparedClient(mSensorId, cookie);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelAuthenticationFromService(IBinder token, String opPackageName, int callingUid,
|
||||
int callingPid, int callingUserId) throws RemoteException {
|
||||
mFingerprintService.cancelAuthenticationFromService(token, opPackageName, callingUid,
|
||||
callingPid, callingUserId);
|
||||
mFingerprintService.cancelAuthenticationFromService(mSensorId, token, opPackageName,
|
||||
callingUid, callingPid, callingUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHardwareDetected(String opPackageName) throws RemoteException {
|
||||
return mFingerprintService.isHardwareDetected(opPackageName);
|
||||
return mFingerprintService.isHardwareDetected(mSensorId, opPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEnrolledTemplates(int userId, String opPackageName) throws RemoteException {
|
||||
return mFingerprintService.hasEnrolledFingerprints(userId, opPackageName);
|
||||
return mFingerprintService.hasEnrolledFingerprints(mSensorId, userId, opPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @LockoutTracker.LockoutMode int getLockoutModeForUser(int userId)
|
||||
throws RemoteException {
|
||||
return mFingerprintService.getLockoutModeForUser(userId);
|
||||
return mFingerprintService.getLockoutModeForUser(mSensorId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAuthenticatorId(int callingUserId) throws RemoteException {
|
||||
return mFingerprintService.getAuthenticatorId(callingUserId);
|
||||
return mFingerprintService.getAuthenticatorId(mSensorId, callingUserId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,34 +255,34 @@ public class FingerprintService extends SystemService {
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void prepareForAuthentication(IBinder token, long operationId, int userId,
|
||||
IBiometricSensorReceiver sensorReceiver, String opPackageName,
|
||||
public void prepareForAuthentication(int sensorId, IBinder token, long operationId,
|
||||
int userId, IBiometricSensorReceiver sensorReceiver, String opPackageName,
|
||||
int cookie, int callingUid, int callingPid, int callingUserId) {
|
||||
Utils.checkPermission(getContext(), MANAGE_BIOMETRIC);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for prepareForAuthentication");
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean restricted = true; // BiometricPrompt is always restricted
|
||||
provider.second.scheduleAuthenticate(provider.first, token, operationId, userId, cookie,
|
||||
provider.scheduleAuthenticate(sensorId, token, operationId, userId, cookie,
|
||||
new ClientMonitorCallbackConverter(sensorReceiver), opPackageName, restricted,
|
||||
BiometricsProtoEnums.CLIENT_BIOMETRIC_PROMPT, false /* isKeyguard */);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void startPreparedClient(int cookie) {
|
||||
public void startPreparedClient(int sensorId, int cookie) {
|
||||
Utils.checkPermission(getContext(), MANAGE_BIOMETRIC);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for startPreparedClient");
|
||||
return;
|
||||
}
|
||||
|
||||
provider.second.startPreparedClient(provider.first, cookie);
|
||||
provider.startPreparedClient(sensorId, cookie);
|
||||
}
|
||||
|
||||
|
||||
@@ -328,17 +328,17 @@ public class FingerprintService extends SystemService {
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void cancelAuthenticationFromService(final IBinder token, final String opPackageName,
|
||||
int callingUid, int callingPid, int callingUserId) {
|
||||
public void cancelAuthenticationFromService(final int sensorId, final IBinder token,
|
||||
final String opPackageName, int callingUid, int callingPid, int callingUserId) {
|
||||
Utils.checkPermission(getContext(), MANAGE_BIOMETRIC);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for cancelAuthenticationFromService");
|
||||
return;
|
||||
}
|
||||
|
||||
provider.second.cancelAuthentication(provider.first, token);
|
||||
provider.cancelAuthentication(sensorId, token);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
@@ -402,7 +402,7 @@ public class FingerprintService extends SystemService {
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public boolean isHardwareDetected(String opPackageName) {
|
||||
public boolean isHardwareDetectedDeprecated(String opPackageName) {
|
||||
if (!canUseFingerprint(opPackageName, false /* foregroundOnly */,
|
||||
Binder.getCallingUid(), Binder.getCallingPid(),
|
||||
UserHandle.getCallingUserId())) {
|
||||
@@ -413,7 +413,8 @@ public class FingerprintService extends SystemService {
|
||||
try {
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for isHardwareDetected, caller: " + opPackageName);
|
||||
Slog.w(TAG, "Null provider for isHardwareDetectedDeprecated, caller: "
|
||||
+ opPackageName);
|
||||
return false;
|
||||
}
|
||||
return provider.second.isHardwareDetected(provider.first);
|
||||
@@ -422,6 +423,19 @@ public class FingerprintService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public boolean isHardwareDetected(int sensorId, String opPackageName) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for isHardwareDetected, caller: " + opPackageName);
|
||||
return false;
|
||||
}
|
||||
|
||||
return provider.isHardwareDetected(sensorId);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void rename(final int fingerId, final int userId, final String name) {
|
||||
Utils.checkPermission(getContext(), MANAGE_FINGERPRINT);
|
||||
@@ -450,11 +464,11 @@ public class FingerprintService extends SystemService {
|
||||
Utils.checkPermission(getContext(), INTERACT_ACROSS_USERS);
|
||||
}
|
||||
|
||||
return FingerprintService.this.getEnrolledFingerprints(userId, opPackageName);
|
||||
return FingerprintService.this.getEnrolledFingerprintsDeprecated(userId, opPackageName);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public boolean hasEnrolledFingerprints(int userId, String opPackageName) {
|
||||
public boolean hasEnrolledFingerprintsDeprecated(int userId, String opPackageName) {
|
||||
if (!canUseFingerprint(opPackageName, false /* foregroundOnly */,
|
||||
Binder.getCallingUid(), Binder.getCallingPid(),
|
||||
UserHandle.getCallingUserId())) {
|
||||
@@ -464,7 +478,7 @@ public class FingerprintService extends SystemService {
|
||||
if (userId != UserHandle.getCallingUserId()) {
|
||||
Utils.checkPermission(getContext(), INTERACT_ACROSS_USERS);
|
||||
}
|
||||
return !FingerprintService.this.getEnrolledFingerprints(userId, opPackageName)
|
||||
return !FingerprintService.this.getEnrolledFingerprintsDeprecated(userId, opPackageName)
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@@ -489,28 +503,40 @@ public class FingerprintService extends SystemService {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public @LockoutTracker.LockoutMode int getLockoutModeForUser(int userId) {
|
||||
public boolean hasEnrolledFingerprints(int sensorId, int userId, String opPackageName) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for hasEnrolledFingerprints, caller: " + opPackageName);
|
||||
return false;
|
||||
}
|
||||
|
||||
return provider.getEnrolledFingerprints(sensorId, userId).size() > 0;
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public @LockoutTracker.LockoutMode int getLockoutModeForUser(int sensorId, int userId) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for getLockoutModeForUser");
|
||||
return LockoutTracker.LOCKOUT_NONE;
|
||||
}
|
||||
return provider.second.getLockoutModeForUser(provider.first, userId);
|
||||
return provider.getLockoutModeForUser(sensorId, userId);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public long getAuthenticatorId(int userId) {
|
||||
public long getAuthenticatorId(int sensorId, int userId) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for getAuthenticatorId");
|
||||
return 0;
|
||||
}
|
||||
return provider.second.getAuthenticatorId(provider.first, userId);
|
||||
return provider.getAuthenticatorId(sensorId, userId);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
@@ -691,10 +717,11 @@ public class FingerprintService extends SystemService {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private List<Fingerprint> getEnrolledFingerprints(int userId, String opPackageName) {
|
||||
private List<Fingerprint> getEnrolledFingerprintsDeprecated(int userId, String opPackageName) {
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for getEnrolledFingerprints, caller: " + opPackageName);
|
||||
Slog.w(TAG, "Null provider for getEnrolledFingerprintsDeprecated, caller: "
|
||||
+ opPackageName);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user