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

Commit 1b326190 authored by Jim Miller's avatar Jim Miller Committed by android-build-merger
Browse files

Bind fingerprint when we start authentication am: 837fa7e5

am: 3871272f

Change-Id: I950703c466265ec5e164f6e75772800745579d34
parents 6cee0087 3871272f
Loading
Loading
Loading
Loading
+15 −6
Original line number Original line Diff line number Diff line
@@ -259,6 +259,7 @@ public class FingerprintManager {
    public static class AuthenticationResult {
    public static class AuthenticationResult {
        private Fingerprint mFingerprint;
        private Fingerprint mFingerprint;
        private CryptoObject mCryptoObject;
        private CryptoObject mCryptoObject;
        private int mUserId;


        /**
        /**
         * Authentication result
         * Authentication result
@@ -267,9 +268,10 @@ public class FingerprintManager {
         * @param fingerprint the recognized fingerprint data, if allowed.
         * @param fingerprint the recognized fingerprint data, if allowed.
         * @hide
         * @hide
         */
         */
        public AuthenticationResult(CryptoObject crypto, Fingerprint fingerprint) {
        public AuthenticationResult(CryptoObject crypto, Fingerprint fingerprint, int userId) {
            mCryptoObject = crypto;
            mCryptoObject = crypto;
            mFingerprint = fingerprint;
            mFingerprint = fingerprint;
            mUserId = userId;
        }
        }


        /**
        /**
@@ -286,6 +288,12 @@ public class FingerprintManager {
         * @hide
         * @hide
         */
         */
        public Fingerprint getFingerprint() { return mFingerprint; }
        public Fingerprint getFingerprint() { return mFingerprint; }

        /**
         * Obtain the userId for which this fingerprint was authenticated.
         * @hide
         */
        public int getUserId() { return mUserId; }
    };
    };


    /**
    /**
@@ -792,7 +800,7 @@ public class FingerprintManager {
                    sendAcquiredResult((Long) msg.obj /* deviceId */, msg.arg1 /* acquire info */);
                    sendAcquiredResult((Long) msg.obj /* deviceId */, msg.arg1 /* acquire info */);
                    break;
                    break;
                case MSG_AUTHENTICATION_SUCCEEDED:
                case MSG_AUTHENTICATION_SUCCEEDED:
                    sendAuthenticatedSucceeded((Fingerprint) msg.obj);
                    sendAuthenticatedSucceeded((Fingerprint) msg.obj, msg.arg1 /* userId */);
                    break;
                    break;
                case MSG_AUTHENTICATION_FAILED:
                case MSG_AUTHENTICATION_FAILED:
                    sendAuthenticatedFailed();
                    sendAuthenticatedFailed();
@@ -840,9 +848,10 @@ public class FingerprintManager {
            }
            }
        }
        }


        private void sendAuthenticatedSucceeded(Fingerprint fp) {
        private void sendAuthenticatedSucceeded(Fingerprint fp, int userId) {
            if (mAuthenticationCallback != null) {
            if (mAuthenticationCallback != null) {
                final AuthenticationResult result = new AuthenticationResult(mCryptoObject, fp);
                final AuthenticationResult result =
                        new AuthenticationResult(mCryptoObject, fp, userId);
                mAuthenticationCallback.onAuthenticationSucceeded(result);
                mAuthenticationCallback.onAuthenticationSucceeded(result);
            }
            }
        }
        }
@@ -981,8 +990,8 @@ public class FingerprintManager {
        }
        }


        @Override // binder call
        @Override // binder call
        public void onAuthenticationSucceeded(long deviceId, Fingerprint fp) {
        public void onAuthenticationSucceeded(long deviceId, Fingerprint fp, int userId) {
            mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, fp).sendToTarget();
            mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, userId, 0, fp).sendToTarget();
        }
        }


        @Override // binder call
        @Override // binder call
+1 −1
Original line number Original line Diff line number Diff line
@@ -26,7 +26,7 @@ import android.os.UserHandle;
oneway interface IFingerprintServiceReceiver {
oneway interface IFingerprintServiceReceiver {
    void onEnrollResult(long deviceId, int fingerId, int groupId, int remaining);
    void onEnrollResult(long deviceId, int fingerId, int groupId, int remaining);
    void onAcquired(long deviceId, int acquiredInfo);
    void onAcquired(long deviceId, int acquiredInfo);
    void onAuthenticationSucceeded(long deviceId, in Fingerprint fp);
    void onAuthenticationSucceeded(long deviceId, in Fingerprint fp, int userId);
    void onAuthenticationFailed(long deviceId);
    void onAuthenticationFailed(long deviceId);
    void onError(long deviceId, int error);
    void onError(long deviceId, int error);
    void onRemoved(long deviceId, int fingerId, int groupId);
    void onRemoved(long deviceId, int fingerId, int groupId);
+6 −2
Original line number Original line Diff line number Diff line
@@ -444,7 +444,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        }
        }
    }
    }


    private void handleFingerprintAuthenticated() {
    private void handleFingerprintAuthenticated(int authUserId) {
        Trace.beginSection("KeyGuardUpdateMonitor#handlerFingerPrintAuthenticated");
        Trace.beginSection("KeyGuardUpdateMonitor#handlerFingerPrintAuthenticated");
        try {
        try {
            final int userId;
            final int userId;
@@ -454,6 +454,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                Log.e(TAG, "Failed to get current user id: ", e);
                Log.e(TAG, "Failed to get current user id: ", e);
                return;
                return;
            }
            }
            if (userId != authUserId) {
                Log.d(TAG, "Fingerprint authenticated for wrong user: " + authUserId);
                return;
            }
            if (isFingerprintDisabled(userId)) {
            if (isFingerprintDisabled(userId)) {
                Log.d(TAG, "Fingerprint disabled by DPM for userId: " + userId);
                Log.d(TAG, "Fingerprint disabled by DPM for userId: " + userId);
                return;
                return;
@@ -745,7 +749,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        @Override
        @Override
        public void onAuthenticationSucceeded(AuthenticationResult result) {
        public void onAuthenticationSucceeded(AuthenticationResult result) {
            Trace.beginSection("KeyguardUpdateMonitor#onAuthenticationSucceeded");
            Trace.beginSection("KeyguardUpdateMonitor#onAuthenticationSucceeded");
            handleFingerprintAuthenticated();
            handleFingerprintAuthenticated(result.getUserId());
            Trace.endSection();
            Trace.endSection();
        }
        }


+3 −3
Original line number Original line Diff line number Diff line
@@ -39,9 +39,9 @@ public abstract class AuthenticationClient extends ClientMonitor {
    public abstract void resetFailedAttempts();
    public abstract void resetFailedAttempts();


    public AuthenticationClient(Context context, long halDeviceId, IBinder token,
    public AuthenticationClient(Context context, long halDeviceId, IBinder token,
            IFingerprintServiceReceiver receiver, int callingUserId, int groupId, long opId,
            IFingerprintServiceReceiver receiver, int targetUserId, int groupId, long opId,
            boolean restricted, String owner) {
            boolean restricted, String owner) {
        super(context, halDeviceId, token, receiver, callingUserId, groupId, restricted, owner);
        super(context, halDeviceId, token, receiver, targetUserId, groupId, restricted, owner);
        mOpId = opId;
        mOpId = opId;
    }
    }


@@ -65,7 +65,7 @@ public abstract class AuthenticationClient extends ClientMonitor {
                    Fingerprint fp = !getIsRestricted()
                    Fingerprint fp = !getIsRestricted()
                            ? new Fingerprint("" /* TODO */, groupId, fingerId, getHalDeviceId())
                            ? new Fingerprint("" /* TODO */, groupId, fingerId, getHalDeviceId())
                            : null;
                            : null;
                    receiver.onAuthenticationSucceeded(getHalDeviceId(), fp);
                    receiver.onAuthenticationSucceeded(getHalDeviceId(), fp, getTargetUserId());
                }
                }
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Slog.w(TAG, "Failed to notify Authenticated:", e);
                Slog.w(TAG, "Failed to notify Authenticated:", e);
+1 −1
Original line number Original line Diff line number Diff line
@@ -536,7 +536,7 @@ public class FingerprintService extends SystemService implements IBinder.DeathRe
        if (DEBUG) Slog.v(TAG, "startAuthentication(" + opPackageName + ")");
        if (DEBUG) Slog.v(TAG, "startAuthentication(" + opPackageName + ")");


        AuthenticationClient client = new AuthenticationClient(getContext(), mHalDeviceId, token,
        AuthenticationClient client = new AuthenticationClient(getContext(), mHalDeviceId, token,
                receiver, callingUserId, groupId, opId, restricted, opPackageName) {
                receiver, mCurrentUserId, groupId, opId, restricted, opPackageName) {
            @Override
            @Override
            public boolean handleFailedAttempt() {
            public boolean handleFailedAttempt() {
                mFailedAttempts++;
                mFailedAttempts++;