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

Commit af416e39 authored by Roman Birg's avatar Roman Birg Committed by Gerrit Code Review
Browse files

fingerprint improvements



- Add a 15s timeout to reset fingerprint attempts when max limit is
  reached
- decrease fingerprint delay between failed attempts to 800ms
- Add warning string to notify when fingerprint attempts maxed out
- Don't turn screen on every failed attempt
- Increase fingerprint attempts to 5

Ref: SAMBAR-1243

Change-Id: I677a8cce2849fc90e886c3a4c8497fe7e1778130
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent d92368fc
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private static final boolean DEBUG = KeyguardConstants.DEBUG;
    private static final boolean DEBUG_SIM_STATES = DEBUG || false;
    private static final int FAILED_BIOMETRIC_UNLOCK_ATTEMPTS_BEFORE_BACKUP = 3;
    private static final int FAILED_FINGERPRINT_UNLOCK_ATTEMPTS_BEFORE_BACKUP = 3;
    private static final int FAILED_FINGERPRINT_UNLOCK_ATTEMPTS_BEFORE_BACKUP = 5;
    private static final int LOW_BATTERY_THRESHOLD = 20;

    private static final String ACTION_FACE_UNLOCK_STARTED
@@ -386,6 +386,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }

    private void onFingerprintAttemptFailed(boolean error, int errorCode) {
        if (isMaxFingerprintAttemptsReached() && !error) {
            Log.d(TAG, "maximum fingerprint attempts reached.");
            return;
        }
        if (!error) mFailedFingerprintAttempts++;
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
@@ -1321,7 +1325,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        mFailedAttempts = 0;
        mFailedBiometricUnlockAttempts = 0;
        if (clearFingers) {
            mFailedFingerprintAttempts = 0;
            clearFailedFingerprintAttempts();
        }
    }

@@ -1361,6 +1365,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        return mFailedFingerprintAttempts == FAILED_FINGERPRINT_UNLOCK_ATTEMPTS_BEFORE_BACKUP;
    }

    public void clearFailedFingerprintAttempts() {
        mFailedFingerprintAttempts = 0;
    }

    public boolean isAlternateUnlockEnabled() {
        return mAlternateUnlockEnabled;
    }
+1 −0
Original line number Diff line number Diff line
@@ -327,6 +327,7 @@

   <!-- Fingerprint -->
   <string name="fingerprint_try_again_hint">Please scan again</string>
   <string name="fingerprint_try_again_hint_too_many">Too many fingerprint attempts. Try again later.</string>

    <!-- Content description of the dock battery level icon for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_dock_battery_level">Dock battery <xliff:g id="number">%d</xliff:g> percent.</string>
+24 −4
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ public class KeyguardViewMediator extends SystemUI {
    private static final int ON_ACTIVITY_DRAWN = 19;
    private static final int KEYGUARD_DONE_PENDING_TIMEOUT = 20;
    private static final int KEYGUARD_FINGERPRINT_AUTH = 21;
    private static final int KEYGUARD_FINGERPRINT_TIMEOUT = 22;

    /**
     * The default amount of time we stay awake (used for all key input)
@@ -207,7 +208,12 @@ public class KeyguardViewMediator extends SystemUI {
     * listening for new fingerprints. Buffer useful to not process two reported attempts
     * before the user has a change to lift their finger off the sensor (if it is sensitive).
     */
    private static final int FINGERPRINT_FAILED_RESTART_DELAY = 1000;
    private static final int FINGERPRINT_FAILED_RESTART_DELAY = 800;

    /**
     * How long to wait before resetting failed fingerprint attempts.
     */
    private static final int FINGERPRINT_TIMEOUT_DELAY = 15000;

    /**
     * Secure setting whether analytics are collected on the keyguard.
@@ -602,10 +608,14 @@ public class KeyguardViewMediator extends SystemUI {
                            || mUpdateMonitor.isOnLastFingerprintAttempt()) {
                        vibrateFingerprintFailure(mUpdateMonitor.isMaxFingerprintAttemptsReached());

                        mSkipToBouncer = true;
                        mPM.wakeUp(SystemClock.uptimeMillis());
                        if (mUpdateMonitor.isOnLastFingerprintAttempt()) {
                            mHandler.sendEmptyMessageDelayed(KEYGUARD_FINGERPRINT_TIMEOUT,
                                    FINGERPRINT_TIMEOUT_DELAY);
                            mHandler.sendMessageDelayed(
                                    mHandler.obtainMessage(KEYGUARD_FINGERPRINT_AUTH, 1, 0),
                                    FINGERPRINT_TIMEOUT_DELAY);
                        }
                    }

                } else if (mUpdateMonitor.isMaxFingerprintAttemptsReached()) {
                    if (DBG_FINGERPRINT) {
                        Log.i(TAG, "onFingerprintAttemptFailed() LIMIT REACHED and screen is on");
@@ -617,6 +627,13 @@ public class KeyguardViewMediator extends SystemUI {
                        if (!mStatusBarKeyguardViewManager.isBouncerShowing() && !mSkipToBouncer) {
                            mStatusBarKeyguardViewManager.showBouncerHideNotifications();
                        }

                        mHandler.sendEmptyMessageDelayed(KEYGUARD_FINGERPRINT_TIMEOUT,
                                FINGERPRINT_TIMEOUT_DELAY);
                        mHandler.sendMessageDelayed(
                                mHandler.obtainMessage(KEYGUARD_FINGERPRINT_AUTH, 1, 0),
                                FINGERPRINT_TIMEOUT_DELAY);

                    }
                } else {
                    // screen on state, restart fingerprint auth
@@ -1643,6 +1660,9 @@ public class KeyguardViewMediator extends SystemUI {
                        stopAuthenticatingFingerprint();
                    }
                    break;
                case KEYGUARD_FINGERPRINT_TIMEOUT:
                    mUpdateMonitor.clearFailedFingerprintAttempts();
                    break;
            }
        }
    };
+8 −0
Original line number Diff line number Diff line
@@ -131,6 +131,9 @@ public class KeyguardIndicationController {
        if (!TextUtils.isEmpty(mTransientIndication)) {
            return mTransientIndication;
        }
        if (KeyguardUpdateMonitor.getInstance(mContext).isMaxFingerprintAttemptsReached()) {
            return mContext.getString(R.string.fingerprint_try_again_hint_too_many);
        }
        if (mPowerPluggedIn) {
            return computePowerIndication();
        }
@@ -168,6 +171,11 @@ public class KeyguardIndicationController {
            mPowerCharged = status.isCharged();
            updateIndication();
        }

        @Override
        public void onScreenTurnedOn() {
            updateIndication();
        }
    };

    BroadcastReceiver mReceiver = new BroadcastReceiver() {