Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54c4374b authored by Jim Miller's avatar Jim Miller Committed by Android (Google) Code Review
Browse files

Merge "Fix bug where fingerprint for wrong userId was attempted to be removed." into nyc-dev

parents 2faac0d7 8f2aca0e
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -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));
+2 −1
Original line number Original line Diff line number Diff line
@@ -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);
+6 −6
Original line number Original line Diff line number Diff line
@@ -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() {
+1 −1
Original line number Original line Diff line number Diff line
@@ -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;
+4 −5
Original line number Original line Diff line number Diff line
@@ -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);
                }
                }
            });
            });


Loading