protected static final boolean DEBUG = FingerprintService.DEBUG;
private IBinder mToken;
private IFingerprintServiceReceiver mReceiver;
- private int mUserId;
+ private int mCallingUserId;
private int mGroupId;
private boolean mIsRestricted; // True if client does not have MANAGE_FINGERPRINT permission
private String mOwner;
* @param halDeviceId the HAL device ID of the associated fingerprint hardware
* @param token a unique token for the client
* @param receiver recipient of related events (e.g. authentication)
- * @param userId userId for the fingerprint set
+ * @param callingUserId user id of calling user
* @param groupId groupId for the fingerprint set
* @param restricted whether or not client has the {@link Manifest#MANAGE_FINGERPRINT}
* permission
* @param owner name of the client that owns this
*/
public ClientMonitor(Context context, long halDeviceId, IBinder token,
- IFingerprintServiceReceiver receiver, int userId, int groupId,boolean restricted,
+ IFingerprintServiceReceiver receiver, int callingUserId, int groupId,boolean restricted,
String owner) {
mContext = context;
mHalDeviceId = halDeviceId;
mToken = token;
mReceiver = receiver;
- mUserId = userId;
+ mCallingUserId = callingUserId;
mGroupId = groupId;
mIsRestricted = restricted;
mOwner = owner;
return mIsRestricted;
}
- public final int getUserId() {
- return mUserId;
+ public final int getCallingUserId() {
+ return mCallingUserId;
}
public final int getGroupId() {
}
}
- void startRemove(IBinder token, int fingerId, int userId, int groupId,
+ void startRemove(IBinder token, int fingerId, int callingUserId, int groupId,
IFingerprintServiceReceiver receiver, boolean restricted) {
IFingerprintDaemon daemon = getFingerprintDaemon();
if (daemon == null) {
return;
}
RemovalClient client = new RemovalClient(getContext(), mHalDeviceId, token,
- receiver, userId, groupId, fingerId, restricted, token.toString()) {
+ receiver, callingUserId, groupId, fingerId, restricted, token.toString()) {
@Override
public void notifyUserActivity() {
FingerprintService.this.userActivity();
@Override
public IFingerprintDaemon getFingerprintDaemon() {
- FingerprintService.this.getFingerprintDaemon();
- return null;
+ return FingerprintService.this.getFingerprintDaemon();
}
};
startClient(client, true);
}
}
- private void startAuthentication(IBinder token, long opId, int realUserId, int groupId,
+ private void startAuthentication(IBinder token, long opId, int callingUserId, int groupId,
IFingerprintServiceReceiver receiver, int flags, boolean restricted,
String opPackageName) {
updateActiveGroup(groupId, opPackageName);
if (DEBUG) Slog.v(TAG, "startAuthentication(" + opPackageName + ")");
AuthenticationClient client = new AuthenticationClient(getContext(), mHalDeviceId, token,
- receiver, realUserId, groupId, opId, restricted, opPackageName) {
+ receiver, callingUserId, groupId, opId, restricted, opPackageName) {
@Override
public boolean handleFailedAttempt() {
mFailedAttempts++;
startClient(client, true /* initiatedByClient */);
}
- private void startEnrollment(IBinder token, byte [] cryptoToken, int userId, int groupId,
+ private void startEnrollment(IBinder token, byte [] cryptoToken, int callingUserId, int groupId,
IFingerprintServiceReceiver receiver, int flags, boolean restricted,
String opPackageName) {
updateActiveGroup(groupId, opPackageName);
EnrollClient client = new EnrollClient(getContext(), mHalDeviceId, token, receiver,
- userId, groupId, cryptoToken, restricted, opPackageName) {
+ callingUserId, groupId, cryptoToken, restricted, opPackageName) {
@Override
public IFingerprintDaemon getFingerprintDaemon() {
checkPermission(MANAGE_FINGERPRINT);
final int limit = mContext.getResources().getInteger(
com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
- final int callingUid = Binder.getCallingUid();
- final int userId = UserHandle.getUserId(callingUid);
- final int enrolled = FingerprintService.this.getEnrolledFingerprints(userId).size();
+ final int callingUserId = UserHandle.getCallingUserId();
+ final int enrolled = FingerprintService.this.
+ getEnrolledFingerprints(callingUserId).size();
if (enrolled >= limit) {
Slog.w(TAG, "Too many fingerprints registered");
return;
mHandler.post(new Runnable() {
@Override
public void run() {
- startEnrollment(token, cryptoToken, userId, groupId, receiver, flags,
+ startEnrollment(token, cryptoToken, callingUserId, groupId, receiver, flags,
restricted, opPackageName);
}
});
public void authenticate(final IBinder token, final long opId, final int groupId,
final IFingerprintServiceReceiver receiver, final int flags,
final String opPackageName) {
- final int realUserId = Binder.getCallingUid();
+ final int callingUid = Binder.getCallingUid();
+ final int callingUserId = UserHandle.getCallingUserId();
final int pid = Binder.getCallingPid();
final boolean restricted = isRestricted();
mHandler.post(new Runnable() {
public void run() {
MetricsLogger.histogram(mContext, "fingerprint_token", opId != 0L ? 1 : 0);
if (!canUseFingerprint(opPackageName, true /* foregroundOnly */,
- realUserId, pid)) {
+ callingUid, pid)) {
if (DEBUG) Slog.v(TAG, "authenticate(): reject " + opPackageName);
return;
}
- startAuthentication(token, opId, realUserId, groupId, receiver,
+ startAuthentication(token, opId, callingUserId, groupId, receiver,
flags, restricted, opPackageName);
}
});
final IFingerprintServiceReceiver receiver) {
checkPermission(MANAGE_FINGERPRINT); // TODO: Maybe have another permission
final boolean restricted = isRestricted();
- final int realUserId = Binder.getCallingUid();
+ final int callingUserId = UserHandle.getCallingUserId();
mHandler.post(new Runnable() {
@Override
public void run() {
- startRemove(token, fingerId, realUserId, groupId, receiver, restricted);
+ startRemove(token, fingerId, callingUserId, groupId, receiver, restricted);
}
});