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

Commit 3d261596 authored by d34d's avatar d34d Committed by Gerrit Code Review
Browse files

Fingerprint: Allow disabling of vibration

Allows apps, such as Camera, that use the fingerprint authentication
to disable vibration.

Change-Id: Ic7b97cf678ec4e6eefbebf36750e1e31f7d20c2f
REF: CYNGNOS-755
parent 45570532
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -164,16 +164,23 @@ public class FingerprintManager {

    /**
     * Start the authentication process.
     *
     * @param timeout
     */
    public void authenticate() {
        authenticate(false);
    }

    /**
     * Start the authentication process.
     *
     * @param disableVibration True to disable vibration when print scanned
     */
    public void authenticate(boolean disableVibration) {
        if (mServiceReceiver == null) {
            sendError(FINGERPRINT_ERROR_NO_RECEIVER, 0, 0);
            return;
        }
        if (mService != null) try {
            mService.authenticate(mToken, getCurrentUserId());
            mService.authenticate(mToken, getCurrentUserId(), disableVibration);
        } catch (RemoteException e) {
            Log.v(TAG, "Remote exception while enrolling: ", e);
            sendError(FINGERPRINT_ERROR_HW_UNAVAILABLE, 0, 0);
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import android.service.fingerprint.IFingerprintServiceReceiver;
 */
interface IFingerprintService {
    // Any errors resulting from this call will be returned to the listener
    oneway void authenticate(IBinder token, int userId);
    oneway void authenticate(IBinder token, int userId, boolean disableVibration);

    // Any errors resulting from this call will be returned to the listener
    oneway void enroll(IBinder token, long timeout, int userId);
+8 −4
Original line number Diff line number Diff line
@@ -98,6 +98,8 @@ public class FingerprintService extends SystemService {

    private long mHal;

    private boolean mDisableVibration = false;

    private static final class ClientData {
        public IFingerprintServiceReceiver receiver;
        int userId;
@@ -260,7 +262,7 @@ public class FingerprintService extends SystemService {
    }

    private void vibrateDeviceIfSupported() {
        if (mVibrator != null) {
        if (mVibrator != null && !mDisableVibration) {
            mVibrator.vibrate(FINGERPRINT_EVENT_VIBRATE_DURATION);
        }
    }
@@ -280,7 +282,7 @@ public class FingerprintService extends SystemService {
        }
    }

    void startAuthentication(IBinder token, int userId) {
    void startAuthentication(IBinder token, int userId, boolean disableVibration) {
        ClientData clientData = mClients.get(token);
        if (clientData != null) {
            if (clientData.userId != userId) throw new IllegalStateException("Bad user");
@@ -288,6 +290,7 @@ public class FingerprintService extends SystemService {
                Slog.i(TAG, "fingerprint is in use");
                return;
            }
            mDisableVibration = disableVibration;
            nativeAuthenticate();
            changeState(STATE_AUTHENTICATING);
        } else {
@@ -299,6 +302,7 @@ public class FingerprintService extends SystemService {
        ClientData clientData = mClients.get(token);
        if (clientData != null) {
            if (clientData.userId != userId) throw new IllegalStateException("Bad user");
            mDisableVibration = false;
            if (mState == STATE_IDLE) return;
            changeState(STATE_IDLE);
            nativeCancel();
@@ -504,10 +508,10 @@ public class FingerprintService extends SystemService {
        private final static String DUMP_CMD_GET_NUM_ENROLLMENT_STEPS = "getNumEnrollmentSteps";

        @Override // Binder call
        public void authenticate(IBinder token, int userId) {
        public void authenticate(IBinder token, int userId, boolean disableVibration) {
            checkPermission();
            throwIfNoFingerprint();
            startAuthentication(token, userId);
            startAuthentication(token, userId, disableVibration);
        }

        @Override // Binder call