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

Commit 1652749e authored by Joe Bolinger's avatar Joe Bolinger
Browse files

Cache challenge response in Face10 implementation.

Prevents operations that happen in rapid succession from failing.

Fix: 185969412
Test: atest com.android.server.biometrics
Test: manual enroll/delete multiple times on device
Change-Id: I20f19c13ec545884c3ed0c91e103f27927413737
parent ebad1be9
Loading
Loading
Loading
Loading
+0 −45
Original line number Diff line number Diff line
@@ -69,8 +69,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
    private static final int MSG_SET_FEATURE_COMPLETED = 107;
    private static final int MSG_CHALLENGE_GENERATED = 108;
    private static final int MSG_FACE_DETECTED = 109;
    private static final int MSG_CHALLENGE_INTERRUPTED = 110;
    private static final int MSG_CHALLENGE_INTERRUPT_FINISHED = 111;
    private static final int MSG_AUTHENTICATION_FRAME = 112;
    private static final int MSG_ENROLLMENT_FRAME = 113;

@@ -147,16 +145,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
                    .sendToTarget();
        }

        @Override
        public void onChallengeInterrupted(int sensorId) {
            mHandler.obtainMessage(MSG_CHALLENGE_INTERRUPTED, sensorId).sendToTarget();
        }

        @Override
        public void onChallengeInterruptFinished(int sensorId) {
            mHandler.obtainMessage(MSG_CHALLENGE_INTERRUPT_FINISHED, sensorId).sendToTarget();
        }

        @Override
        public void onAuthenticationFrame(FaceAuthenticationFrame frame) {
            mHandler.obtainMessage(MSG_AUTHENTICATION_FRAME, frame).sendToTarget();
@@ -1128,17 +1116,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
         * Invoked when a challenge has been generated.
         */
        void onGenerateChallengeResult(int sensorId, long challenge);

        /**
         * Invoked if the challenge has not been revoked and a subsequent caller/owner invokes
         * {@link #generateChallenge(int, GenerateChallengeCallback)}, but
         */
        default void onChallengeInterrupted(int sensorId) {}

        /**
         * Invoked when the interrupting client has finished (e.g. revoked its challenge).
         */
        default void onChallengeInterruptFinished(int sensorId) {}
    }

    private class OnEnrollCancelListener implements OnCancelListener {
@@ -1218,12 +1195,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
                    sendFaceDetected(msg.arg1 /* sensorId */, msg.arg2 /* userId */,
                            (boolean) msg.obj /* isStrongBiometric */);
                    break;
                case MSG_CHALLENGE_INTERRUPTED:
                    sendChallengeInterrupted((int) msg.obj /* sensorId */);
                    break;
                case MSG_CHALLENGE_INTERRUPT_FINISHED:
                    sendChallengeInterruptFinished((int) msg.obj /* sensorId */);
                    break;
                case MSG_AUTHENTICATION_FRAME:
                    sendAuthenticationFrame((FaceAuthenticationFrame) msg.obj /* frame */);
                    break;
@@ -1266,22 +1237,6 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
        mFaceDetectionCallback.onFaceDetected(sensorId, userId, isStrongBiometric);
    }

    private void sendChallengeInterrupted(int sensorId) {
        if (mGenerateChallengeCallback == null) {
            Slog.e(TAG, "sendChallengeInterrupted, callback null");
            return;
        }
        mGenerateChallengeCallback.onChallengeInterrupted(sensorId);
    }

    private void sendChallengeInterruptFinished(int sensorId) {
        if (mGenerateChallengeCallback == null) {
            Slog.e(TAG, "sendChallengeInterruptFinished, callback null");
            return;
        }
        mGenerateChallengeCallback.onChallengeInterruptFinished(sensorId);
    }

    private void sendRemovedResult(Face face, int remaining) {
        if (mRemovalCallback == null) {
            return;
+0 −10
Original line number Diff line number Diff line
@@ -76,16 +76,6 @@ public class FaceServiceReceiver extends IFaceServiceReceiver.Stub {

    }

    @Override
    public void onChallengeInterrupted(int sensorId) throws RemoteException {

    }

    @Override
    public void onChallengeInterruptFinished(int sensorId) throws RemoteException {

    }

    @Override
    public void onAuthenticationFrame(FaceAuthenticationFrame frame) throws RemoteException {

+0 −2
Original line number Diff line number Diff line
@@ -34,8 +34,6 @@ oneway interface IFaceServiceReceiver {
    void onFeatureSet(boolean success, int feature);
    void onFeatureGet(boolean success, in int[] features, in boolean[] featureState);
    void onChallengeGenerated(int sensorId, long challenge);
    void onChallengeInterrupted(int sensorId);
    void onChallengeInterruptFinished(int sensorId);
    void onAuthenticationFrame(in FaceAuthenticationFrame frame);
    void onEnrollmentFrame(in FaceEnrollFrame frame);
}
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public abstract class BaseClientMonitor extends LoggableMonitor
     * Interface that ClientMonitor holders should use to receive callbacks.
     */
    public interface Callback {

        /**
         * Invoked when the ClientMonitor operation has been started (e.g. reached the head of
         * the queue and becomes the current operation).
+0 −12
Original line number Diff line number Diff line
@@ -153,18 +153,6 @@ public class ClientMonitorCallbackConverter {
        }
    }

    public void onChallengeInterrupted(int sensorId) throws RemoteException {
        if (mFaceServiceReceiver != null) {
            mFaceServiceReceiver.onChallengeInterrupted(sensorId);
        }
    }

    public void onChallengeInterruptFinished(int sensorId) throws RemoteException {
        if (mFaceServiceReceiver != null) {
            mFaceServiceReceiver.onChallengeInterruptFinished(sensorId);
        }
    }

    // Fingerprint-specific callbacks for FingerprintManager only

    public void onUdfpsPointerDown(int sensorId) throws RemoteException {
Loading