Merge "Fix bug where fingerprint for wrong userId was attempted to be removed." into nyc-dev
This commit is contained in:
@@ -590,7 +590,7 @@ public class FingerprintManager {
|
|||||||
if (mService != null) try {
|
if (mService != null) try {
|
||||||
mRemovalCallback = callback;
|
mRemovalCallback = callback;
|
||||||
mRemovalFingerprint = fp;
|
mRemovalFingerprint = fp;
|
||||||
mService.remove(mToken, fp.getFingerId(), userId, mServiceReceiver);
|
mService.remove(mToken, fp.getFingerId(), fp.getGroupId(), userId, mServiceReceiver);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.w(TAG, "Remote exception in remove: ", e);
|
Log.w(TAG, "Remote exception in remove: ", e);
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
@@ -810,11 +810,13 @@ public class FingerprintManager {
|
|||||||
if (mRemovalCallback != null) {
|
if (mRemovalCallback != null) {
|
||||||
int reqFingerId = mRemovalFingerprint.getFingerId();
|
int reqFingerId = mRemovalFingerprint.getFingerId();
|
||||||
int reqGroupId = mRemovalFingerprint.getGroupId();
|
int reqGroupId = mRemovalFingerprint.getGroupId();
|
||||||
if (reqFingerId != 0 && fingerId != reqFingerId) {
|
if (reqFingerId != 0 && fingerId != 0 && fingerId != reqFingerId) {
|
||||||
Log.w(TAG, "Finger id didn't match: " + fingerId + " != " + reqFingerId);
|
Log.w(TAG, "Finger id didn't match: " + fingerId + " != " + reqFingerId);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (groupId != reqGroupId) {
|
if (groupId != reqGroupId) {
|
||||||
Log.w(TAG, "Group id didn't match: " + groupId + " != " + reqGroupId);
|
Log.w(TAG, "Group id didn't match: " + groupId + " != " + reqGroupId);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
mRemovalCallback.onRemovalSucceeded(new Fingerprint(null, groupId, fingerId,
|
mRemovalCallback.onRemovalSucceeded(new Fingerprint(null, groupId, fingerId,
|
||||||
deviceId));
|
deviceId));
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ interface IFingerprintService {
|
|||||||
void cancelEnrollment(IBinder token);
|
void cancelEnrollment(IBinder token);
|
||||||
|
|
||||||
// Any errors resulting from this call will be returned to the listener
|
// Any errors resulting from this call will be returned to the listener
|
||||||
void remove(IBinder token, int fingerId, int groupId, IFingerprintServiceReceiver receiver);
|
void remove(IBinder token, int fingerId, int groupId, int userId,
|
||||||
|
IFingerprintServiceReceiver receiver);
|
||||||
|
|
||||||
// Rename the fingerprint specified by fingerId and groupId to the given name
|
// Rename the fingerprint specified by fingerId and groupId to the given name
|
||||||
void rename(int fingerId, int groupId, String name);
|
void rename(int fingerId, int groupId, String name);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public abstract class ClientMonitor implements IBinder.DeathRecipient {
|
|||||||
protected static final boolean DEBUG = FingerprintService.DEBUG;
|
protected static final boolean DEBUG = FingerprintService.DEBUG;
|
||||||
private IBinder mToken;
|
private IBinder mToken;
|
||||||
private IFingerprintServiceReceiver mReceiver;
|
private IFingerprintServiceReceiver mReceiver;
|
||||||
private int mCallingUserId;
|
private int mTargetUserId;
|
||||||
private int mGroupId;
|
private int mGroupId;
|
||||||
private boolean mIsRestricted; // True if client does not have MANAGE_FINGERPRINT permission
|
private boolean mIsRestricted; // True if client does not have MANAGE_FINGERPRINT permission
|
||||||
private String mOwner;
|
private String mOwner;
|
||||||
@@ -50,20 +50,20 @@ public abstract class ClientMonitor implements IBinder.DeathRecipient {
|
|||||||
* @param halDeviceId the HAL device ID of the associated fingerprint hardware
|
* @param halDeviceId the HAL device ID of the associated fingerprint hardware
|
||||||
* @param token a unique token for the client
|
* @param token a unique token for the client
|
||||||
* @param receiver recipient of related events (e.g. authentication)
|
* @param receiver recipient of related events (e.g. authentication)
|
||||||
* @param callingUserId user id of calling user
|
* @param userId target user id for operation
|
||||||
* @param groupId groupId for the fingerprint set
|
* @param groupId groupId for the fingerprint set
|
||||||
* @param restricted whether or not client has the {@link Manifest#MANAGE_FINGERPRINT}
|
* @param restricted whether or not client has the {@link Manifest#MANAGE_FINGERPRINT}
|
||||||
* permission
|
* permission
|
||||||
* @param owner name of the client that owns this
|
* @param owner name of the client that owns this
|
||||||
*/
|
*/
|
||||||
public ClientMonitor(Context context, long halDeviceId, IBinder token,
|
public ClientMonitor(Context context, long halDeviceId, IBinder token,
|
||||||
IFingerprintServiceReceiver receiver, int callingUserId, int groupId,boolean restricted,
|
IFingerprintServiceReceiver receiver, int userId, int groupId,boolean restricted,
|
||||||
String owner) {
|
String owner) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mHalDeviceId = halDeviceId;
|
mHalDeviceId = halDeviceId;
|
||||||
mToken = token;
|
mToken = token;
|
||||||
mReceiver = receiver;
|
mReceiver = receiver;
|
||||||
mCallingUserId = callingUserId;
|
mTargetUserId = userId;
|
||||||
mGroupId = groupId;
|
mGroupId = groupId;
|
||||||
mIsRestricted = restricted;
|
mIsRestricted = restricted;
|
||||||
mOwner = owner;
|
mOwner = owner;
|
||||||
@@ -197,8 +197,8 @@ public abstract class ClientMonitor implements IBinder.DeathRecipient {
|
|||||||
return mIsRestricted;
|
return mIsRestricted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getCallingUserId() {
|
public final int getTargetUserId() {
|
||||||
return mCallingUserId;
|
return mTargetUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getGroupId() {
|
public final int getGroupId() {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public abstract class EnumerateClient extends ClientMonitor {
|
|||||||
try {
|
try {
|
||||||
final int result = daemon.enumerate();
|
final int result = daemon.enumerate();
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
Slog.w(TAG, "start enumerate for user " + getCallingUserId()
|
Slog.w(TAG, "start enumerate for user " + getTargetUserId()
|
||||||
+ " failed, result=" + result);
|
+ " failed, result=" + result);
|
||||||
onError(FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE);
|
onError(FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startRemove(IBinder token, int fingerId, int callingUserId, int groupId,
|
void startRemove(IBinder token, int fingerId, int groupId, int userId,
|
||||||
IFingerprintServiceReceiver receiver, boolean restricted) {
|
IFingerprintServiceReceiver receiver, boolean restricted) {
|
||||||
IFingerprintDaemon daemon = getFingerprintDaemon();
|
IFingerprintDaemon daemon = getFingerprintDaemon();
|
||||||
if (daemon == null) {
|
if (daemon == null) {
|
||||||
@@ -364,7 +364,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RemovalClient client = new RemovalClient(getContext(), mHalDeviceId, token,
|
RemovalClient client = new RemovalClient(getContext(), mHalDeviceId, token,
|
||||||
receiver, callingUserId, groupId, fingerId, restricted, token.toString()) {
|
receiver, fingerId, groupId, userId, restricted, token.toString()) {
|
||||||
@Override
|
@Override
|
||||||
public void notifyUserActivity() {
|
public void notifyUserActivity() {
|
||||||
FingerprintService.this.userActivity();
|
FingerprintService.this.userActivity();
|
||||||
@@ -794,14 +794,13 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
|
|||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public void remove(final IBinder token, final int fingerId, final int groupId,
|
public void remove(final IBinder token, final int fingerId, final int groupId,
|
||||||
final IFingerprintServiceReceiver receiver) {
|
final int userId, 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();
|
||||||
final int callingUserId = UserHandle.getCallingUserId();
|
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
startRemove(token, fingerId, callingUserId, groupId, receiver, restricted);
|
startRemove(token, fingerId, groupId, userId, receiver, restricted);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -30,14 +30,12 @@ import android.util.Slog;
|
|||||||
*/
|
*/
|
||||||
public abstract class RemovalClient extends ClientMonitor {
|
public abstract class RemovalClient extends ClientMonitor {
|
||||||
private int mFingerId;
|
private int mFingerId;
|
||||||
private int mUserIdForRemove;
|
|
||||||
|
|
||||||
public RemovalClient(Context context, long halDeviceId, IBinder token,
|
public RemovalClient(Context context, long halDeviceId, IBinder token,
|
||||||
IFingerprintServiceReceiver receiver, int userId, int groupId, int fingerId,
|
IFingerprintServiceReceiver receiver, int fingerId, int groupId, int userId,
|
||||||
boolean restricted, String owner) {
|
boolean restricted, String owner) {
|
||||||
super(context, halDeviceId, token, receiver, userId, groupId, restricted, owner);
|
super(context, halDeviceId, token, receiver, userId, groupId, restricted, owner);
|
||||||
mFingerId = fingerId;
|
mFingerId = fingerId;
|
||||||
mUserIdForRemove = userId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,25 +70,21 @@ public abstract class RemovalClient extends ClientMonitor {
|
|||||||
*/
|
*/
|
||||||
private boolean sendRemoved(int fingerId, int groupId) {
|
private boolean sendRemoved(int fingerId, int groupId) {
|
||||||
IFingerprintServiceReceiver receiver = getReceiver();
|
IFingerprintServiceReceiver receiver = getReceiver();
|
||||||
if (receiver == null)
|
|
||||||
return true; // client not listening
|
|
||||||
try {
|
try {
|
||||||
receiver.onRemoved(getHalDeviceId(), fingerId, groupId);
|
if (receiver != null) {
|
||||||
return fingerId == 0;
|
receiver.onRemoved(getHalDeviceId(), fingerId, groupId);
|
||||||
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "Failed to notify Removed:", e);
|
Slog.w(TAG, "Failed to notify Removed:", e);
|
||||||
}
|
}
|
||||||
return false;
|
return fingerId == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onRemoved(int fingerId, int groupId) {
|
public boolean onRemoved(int fingerId, int groupId) {
|
||||||
if (fingerId != 0) {
|
if (fingerId != 0) {
|
||||||
if (fingerId != mFingerId)
|
|
||||||
FingerprintUtils.getInstance().removeFingerprintIdForUser(getContext(), fingerId,
|
FingerprintUtils.getInstance().removeFingerprintIdForUser(getContext(), fingerId,
|
||||||
mUserIdForRemove);
|
getTargetUserId());
|
||||||
} else {
|
|
||||||
mUserIdForRemove = UserHandle.USER_NULL;
|
|
||||||
}
|
}
|
||||||
return sendRemoved(fingerId, getGroupId());
|
return sendRemoved(fingerId, getGroupId());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user