am dd7bc4ae: am 494d6e9b: [fingerprint] use credential owner in FingerprintService

* commit 'dd7bc4aec916e7823ec20aa243f1d5ebc197887c':
  [fingerprint] use credential owner in FingerprintService
This commit is contained in:
Andres Morales
2015-08-11 23:43:54 +00:00
committed by Android Git Automerger

View File

@@ -454,6 +454,18 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
"Must have " + permission + " permission."); "Must have " + permission + " permission.");
} }
int getEffectiveUserId(int userId) {
UserManager um = UserManager.get(mContext);
if (um != null) {
final long callingIdentity = Binder.clearCallingIdentity();
userId = um.getCredentialOwnerProfile(userId);
Binder.restoreCallingIdentity(callingIdentity);
} else {
Slog.e(TAG, "Unable to acquire UserManager");
}
return userId;
}
boolean isCurrentUserOrProfile(int userId) { boolean isCurrentUserOrProfile(int userId) {
UserManager um = UserManager.get(mContext); UserManager um = UserManager.get(mContext);
@@ -686,11 +698,15 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
} }
final byte [] cryptoClone = Arrays.copyOf(cryptoToken, cryptoToken.length); final byte [] cryptoClone = Arrays.copyOf(cryptoToken, cryptoToken.length);
// Group ID is arbitrarily set to parent profile user ID. It just represents
// the default fingerprints for the user.
final int effectiveGroupId = getEffectiveUserId(groupId);
final boolean restricted = isRestricted(); final boolean restricted = isRestricted();
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
startEnrollment(token, cryptoClone, groupId, receiver, flags, restricted); startEnrollment(token, cryptoClone, effectiveGroupId, receiver, flags, restricted);
} }
}); });
} }
@@ -724,11 +740,16 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
Slog.w(TAG, "Calling not granted permission to use fingerprint"); Slog.w(TAG, "Calling not granted permission to use fingerprint");
return; return;
} }
// Group ID is arbitrarily set to parent profile user ID. It just represents
// the default fingerprints for the user.
final int effectiveGroupId = getEffectiveUserId(groupId);
final boolean restricted = isRestricted(); final boolean restricted = isRestricted();
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
startAuthentication(token, opId, groupId, receiver, flags, restricted); startAuthentication(token, opId, effectiveGroupId, receiver, flags, restricted);
} }
}); });
} }
@@ -751,10 +772,14 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
final IFingerprintServiceReceiver receiver) { final IFingerprintServiceReceiver receiver) {
checkPermission(MANAGE_FINGERPRINT); // TODO: Maybe have another permission checkPermission(MANAGE_FINGERPRINT); // TODO: Maybe have another permission
final boolean restricted = isRestricted(); final boolean restricted = isRestricted();
// Group ID is arbitrarily set to parent profile user ID. It just represents
// the default fingerprints for the user.
final int effectiveGroupId = getEffectiveUserId(groupId);
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
startRemove(token, fingerId, groupId, receiver, restricted); startRemove(token, fingerId, effectiveGroupId, receiver, restricted);
} }
}); });
@@ -771,10 +796,15 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
@Override // Binder call @Override // Binder call
public void rename(final int fingerId, final int groupId, final String name) { public void rename(final int fingerId, final int groupId, final String name) {
checkPermission(MANAGE_FINGERPRINT); checkPermission(MANAGE_FINGERPRINT);
// Group ID is arbitrarily set to parent profile user ID. It just represents
// the default fingerprints for the user.
final int effectiveGroupId = getEffectiveUserId(groupId);
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
mFingerprintUtils.renameFingerprintForUser(mContext, fingerId, groupId, name); mFingerprintUtils.renameFingerprintForUser(mContext, fingerId,
effectiveGroupId, name);
} }
}); });
} }
@@ -784,15 +814,19 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
if (!canUseFingerprint(opPackageName)) { if (!canUseFingerprint(opPackageName)) {
return Collections.emptyList(); return Collections.emptyList();
} }
return FingerprintService.this.getEnrolledFingerprints(userId); int effectiveUserId = getEffectiveUserId(userId);
return FingerprintService.this.getEnrolledFingerprints(effectiveUserId);
} }
@Override // Binder call @Override // Binder call
public boolean hasEnrolledFingerprints(int groupId, String opPackageName) { public boolean hasEnrolledFingerprints(int userId, String opPackageName) {
if (!canUseFingerprint(opPackageName)) { if (!canUseFingerprint(opPackageName)) {
return false; return false;
} }
return FingerprintService.this.hasEnrolledFingerprints(groupId);
int effectiveUserId = getEffectiveUserId(userId);
return FingerprintService.this.hasEnrolledFingerprints(effectiveUserId);
} }
@Override // Binder call @Override // Binder call
@@ -829,8 +863,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
IFingerprintDaemon daemon = getFingerprintDaemon(); IFingerprintDaemon daemon = getFingerprintDaemon();
if (daemon != null) { if (daemon != null) {
try { try {
// TODO: if this is a managed profile, use the profile parent's directory for userId = getEffectiveUserId(userId);
// storage.
final File systemDir = Environment.getUserSystemDirectory(userId); final File systemDir = Environment.getUserSystemDirectory(userId);
final File fpDir = new File(systemDir, FP_DATA_DIR); final File fpDir = new File(systemDir, FP_DATA_DIR);
if (!fpDir.exists()) { if (!fpDir.exists()) {