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

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

Merge "Make fingerprint enroll/authenticate haptic feedback part of framework."

parents 217f93a1 af281ca0
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package android.hardware.fingerprint;

import android.content.ContentResolver;
import android.content.Context;
import android.os.Vibrator;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
@@ -35,6 +37,8 @@ public
class FingerprintUtils {
    private static final boolean DEBUG = true;
    private static final String TAG = "FingerprintUtils";
    private static final long[] FP_ERROR_VIBRATE_PATTERN = new long[] {0, 30, 100, 30};
    private static final long[] FP_SUCCESS_VIBRATE_PATTERN = new long[] {0, 30};

    private static int[] toIntArray(List<Integer> list) {
        if (list == null) {
@@ -104,5 +108,19 @@ class FingerprintUtils {
        return false;
    }

    public static void vibrateFingerprintError(Context context) {
        Vibrator vibrator = context.getSystemService(Vibrator.class);
        if (vibrator != null) {
            vibrator.vibrate(FP_ERROR_VIBRATE_PATTERN, -1);
        }
    }

    public static void vibrateFingerprintSuccess(Context context) {
        Vibrator vibrator = context.getSystemService(Vibrator.class);
        if (vibrator != null) {
            vibrator.vibrate(FP_SUCCESS_VIBRATE_PATTERN, -1);
        }
    }

};
+0 −12
Original line number Diff line number Diff line
@@ -83,8 +83,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private static final int DOZE_ANIMATION_STAGGER_DELAY = 48;
    private static final int DOZE_ANIMATION_ELEMENT_DURATION = 250;
    private static final long TRANSIENT_FP_ERROR_TIMEOUT = 1300;
    private static final long[] FP_ERROR_VIBRATE_PATTERN = new long[] {0, 30, 100, 30};
    private static final long[] FP_SUCCESS_VIBRATE_PATTERN = new long[] {0, 30};

    private KeyguardAffordanceView mCameraImageView;
    private KeyguardAffordanceView mPhoneImageView;
@@ -551,14 +549,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
                .setDuration(DOZE_ANIMATION_ELEMENT_DURATION);
    }

    private void vibrateFingerprintError() {
        mContext.getSystemService(Vibrator.class).vibrate(FP_ERROR_VIBRATE_PATTERN, -1);
    }

    private void vibrateFingerprintSuccess() {
        mContext.getSystemService(Vibrator.class).vibrate(FP_SUCCESS_VIBRATE_PATTERN, -1);
    }

    private final BroadcastReceiver mDevicePolicyReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            post(new Runnable() {
@@ -603,7 +593,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL

        @Override
        public void onFingerprintAuthenticated(int userId) {
            vibrateFingerprintSuccess();
        }

        @Override
@@ -613,7 +602,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL

        @Override
        public void onFingerprintHelp(int msgId, String helpString) {
            vibrateFingerprintError();
            mTransientFpError = true;
            mIndicationController.showTransientIndication(helpString,
                    getResources().getColor(R.color.system_warning_color, null));
+6 −8
Original line number Diff line number Diff line
@@ -67,6 +67,9 @@ public class FingerprintService extends SystemService {
    private static final int FINGERPRINT_TEMPLATE_ENROLLING = 3;
    private static final int FINGERPRINT_TEMPLATE_REMOVED = 4;
    private static final int FINGERPRINT_AUTHENTICATED = 5;
    private static final long MS_PER_SEC = 1000;
    private static final long FAIL_LOCKOUT_TIMEOUT_MS = 30*1000;
    private static final int MAX_FAILED_ATTEMPTS = 5;

    Handler mHandler = new Handler() {
        public void handleMessage(android.os.Message msg) {
@@ -91,14 +94,6 @@ public class FingerprintService extends SystemService {
        }
    };

    private static final int STATE_IDLE = 0;
    private static final int STATE_AUTHENTICATING = 1;
    private static final int STATE_ENROLLING = 2;
    private static final int STATE_REMOVING = 3;
    private static final long MS_PER_SEC = 1000;
    private static final long FAIL_LOCKOUT_TIMEOUT_MS = 30*1000;
    private static final int MAX_FAILED_ATTEMPTS = 5;

    public FingerprintService(Context context) {
        super(context);
        mContext = context;
@@ -427,6 +422,7 @@ public class FingerprintService extends SystemService {
        private boolean sendEnrollResult(int fpId, int groupId, int remaining) {
            IFingerprintServiceReceiver rx = receiver.get();
            if (rx == null) return true; // client not listening
            FingerprintUtils.vibrateFingerprintSuccess(getContext());
            try {
                rx.onEnrollResult(mHalDeviceId, fpId, groupId, remaining);
                return remaining == 0;
@@ -453,8 +449,10 @@ public class FingerprintService extends SystemService {
                result = true; // client not listening
            }
            if (fpId <= 0) {
                FingerprintUtils.vibrateFingerprintError(getContext());
                result |= handleFailedAttempt(this);
            } else {
                FingerprintUtils.vibrateFingerprintSuccess(getContext());
                result |= true; // we have a valid fingerprint
                mLockoutReset.run();
            }