Merge "Send callingUserId from AuthService -> BiometricServiceBase" into rvc-dev

This commit is contained in:
Kevin Chyn
2020-06-01 15:57:00 +00:00
committed by Android (Google) Code Review
12 changed files with 19 additions and 19 deletions

View File

@@ -57,5 +57,5 @@ interface IBiometricAuthenticator {
void setActiveUser(int uid);
// Gets the authenticator ID representing the current set of enrolled templates
long getAuthenticatorId();
long getAuthenticatorId(int callingUserId);
}

View File

@@ -65,5 +65,5 @@ interface IBiometricService {
// Get a list of AuthenticatorIDs for authenticators which have enrolled templates and meet
// the requirements for integrating with Keystore. The AuthenticatorID are known in Keystore
// land as SIDs, and are used during key generation.
long[] getAuthenticatorIds();
long[] getAuthenticatorIds(int callingUserId);
}

View File

@@ -85,7 +85,7 @@ interface IFaceService {
// long getHardwareDevice(int i);
// Gets the authenticator ID for face
long getAuthenticatorId();
long getAuthenticatorId(int callingUserId);
// Reset the lockout when user authenticates with strong auth (e.g. PIN, pattern or password)
void resetLockout(in byte [] token);

View File

@@ -89,7 +89,7 @@ interface IFingerprintService {
// long getHardwareDevice(int i);
// Gets the authenticator ID for fingerprint
long getAuthenticatorId();
long getAuthenticatorId(int callingUserId);
// Reset the timeout when user authenticates with strong auth (e.g. PIN, pattern or password)
void resetTimeout(in byte [] cryptoToken);

View File

@@ -290,9 +290,10 @@ public class AuthService extends SystemService {
// The permission check should be restored once Android Keystore no longer invokes this
// method from inside app processes.
final int callingUserId = UserHandle.getCallingUserId();
final long identity = Binder.clearCallingIdentity();
try {
return mBiometricService.getAuthenticatorIds();
return mBiometricService.getAuthenticatorIds(callingUserId);
} finally {
Binder.restoreCallingIdentity(identity);
}

View File

@@ -879,13 +879,13 @@ public class BiometricService extends SystemService {
}
@Override // Binder call
public long[] getAuthenticatorIds() {
public long[] getAuthenticatorIds(int callingUserId) {
checkInternalPermission();
final List<Long> ids = new ArrayList<>();
for (AuthenticatorWrapper authenticator : mAuthenticators) {
try {
final long id = authenticator.impl.getAuthenticatorId();
final long id = authenticator.impl.getAuthenticatorId(callingUserId);
if (Utils.isAtLeastStrength(authenticator.getActualStrength(),
Authenticators.BIOMETRIC_STRONG) && id != 0) {
ids.add(id);

View File

@@ -1250,9 +1250,8 @@ public abstract class BiometricServiceBase extends SystemService
/***
* @return authenticator id for the calling user
*/
protected long getAuthenticatorId() {
final int userId = getUserOrWorkProfileId(null /* clientPackage */,
UserHandle.getCallingUserId());
protected long getAuthenticatorId(int callingUserId) {
final int userId = getUserOrWorkProfileId(null /* clientPackage */, callingUserId);
return mAuthenticatorIds.getOrDefault(userId, 0L);
}

View File

@@ -74,7 +74,7 @@ public final class FaceAuthenticator extends IBiometricAuthenticator.Stub {
}
@Override
public long getAuthenticatorId() throws RemoteException {
return mFaceService.getAuthenticatorId();
public long getAuthenticatorId(int callingUserId) throws RemoteException {
return mFaceService.getAuthenticatorId(callingUserId);
}
}

View File

@@ -608,9 +608,9 @@ public class FaceService extends BiometricServiceBase {
}
@Override // Binder call
public long getAuthenticatorId() {
public long getAuthenticatorId(int callingUserId) {
checkPermission(USE_BIOMETRIC_INTERNAL);
return FaceService.this.getAuthenticatorId();
return FaceService.this.getAuthenticatorId(callingUserId);
}
@Override // Binder call

View File

@@ -74,7 +74,7 @@ public final class FingerprintAuthenticator extends IBiometricAuthenticator.Stub
}
@Override
public long getAuthenticatorId() throws RemoteException {
return mFingerprintService.getAuthenticatorId();
public long getAuthenticatorId(int callingUserId) throws RemoteException {
return mFingerprintService.getAuthenticatorId(callingUserId);
}
}

View File

@@ -412,9 +412,9 @@ public class FingerprintService extends BiometricServiceBase {
}
@Override // Binder call
public long getAuthenticatorId() {
public long getAuthenticatorId(int callingUserId) {
checkPermission(USE_BIOMETRIC_INTERNAL);
return FingerprintService.this.getAuthenticatorId();
return FingerprintService.this.getAuthenticatorId(callingUserId);
}
@Override // Binder call

View File

@@ -67,7 +67,7 @@ public final class IrisAuthenticator extends IBiometricAuthenticator.Stub {
}
@Override
public long getAuthenticatorId() throws RemoteException {
public long getAuthenticatorId(int callingUserId) throws RemoteException {
return 0;
}
}