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

Commit af35c768 authored by Kevin Chyn's avatar Kevin Chyn Committed by android-build-merger
Browse files

Merge "Keyguard should wait before restarting FP auth after successful FP auth" into oc-dr1-dev

am: 192e7ccf

Change-Id: I22f3e2968a724bd6c63b5f9696d1115d571efaf8
parents 89c25461 192e7ccf
Loading
Loading
Loading
Loading
+23 −4
Original line number Original line Diff line number Diff line
@@ -132,6 +132,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private static final int MSG_DREAMING_STATE_CHANGED = 333;
    private static final int MSG_DREAMING_STATE_CHANGED = 333;
    private static final int MSG_USER_UNLOCKED = 334;
    private static final int MSG_USER_UNLOCKED = 334;
    private static final int MSG_ASSISTANT_STACK_CHANGED = 335;
    private static final int MSG_ASSISTANT_STACK_CHANGED = 335;
    private static final int MSG_FINGERPRINT_AUTHENTICATION_CONTINUE = 336;


    /** Fingerprint state: Not listening to fingerprint. */
    /** Fingerprint state: Not listening to fingerprint. */
    private static final int FINGERPRINT_STATE_STOPPED = 0;
    private static final int FINGERPRINT_STATE_STOPPED = 0;
@@ -200,6 +201,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private int mFingerprintRunningState = FINGERPRINT_STATE_STOPPED;
    private int mFingerprintRunningState = FINGERPRINT_STATE_STOPPED;
    private LockPatternUtils mLockPatternUtils;
    private LockPatternUtils mLockPatternUtils;


    /**
     * Short delay before restarting fingerprint authentication after a successful try
     * This should be slightly longer than the time between onFingerprintAuthenticated and
     * setKeyguardGoingAway(true).
     */
    private static final int FINGERPRINT_CONTINUE_DELAY_MS = 500;

    // If FP daemon dies, keyguard should retry after a short delay
    // If FP daemon dies, keyguard should retry after a short delay
    private int mHardwareUnavailableRetryCount = 0;
    private int mHardwareUnavailableRetryCount = 0;
    private static final int HW_UNAVAILABLE_TIMEOUT = 3000; // ms
    private static final int HW_UNAVAILABLE_TIMEOUT = 3000; // ms
@@ -294,6 +302,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                    mAssistantVisible = (boolean)msg.obj;
                    mAssistantVisible = (boolean)msg.obj;
                    updateFingerprintListeningState();
                    updateFingerprintListeningState();
                    break;
                    break;
                case MSG_FINGERPRINT_AUTHENTICATION_CONTINUE:
                    updateFingerprintListeningState();
                    break;
            }
            }
        }
        }
    };
    };
@@ -446,9 +457,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            }
            }
        }
        }


        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_FINGERPRINT_AUTHENTICATION_CONTINUE),
                FINGERPRINT_CONTINUE_DELAY_MS);

        // Only authenticate fingerprint once when assistant is visible
        // Only authenticate fingerprint once when assistant is visible
        mAssistantVisible = false;
        mAssistantVisible = false;
        updateFingerprintListeningState();


        Trace.endSection();
        Trace.endSection();
    }
    }
@@ -1136,6 +1149,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }
    }


    private void updateFingerprintListeningState() {
    private void updateFingerprintListeningState() {
        // If this message exists, we should not authenticate again until this message is
        // consumed by the handler
        if (mHandler.hasMessages(MSG_FINGERPRINT_AUTHENTICATION_CONTINUE)) {
            return;
        }
        mHandler.removeCallbacks(mRetryFingerprintAuthentication);
        mHandler.removeCallbacks(mRetryFingerprintAuthentication);
        boolean shouldListenForFingerprint = shouldListenForFingerprint();
        boolean shouldListenForFingerprint = shouldListenForFingerprint();
        if (mFingerprintRunningState == FINGERPRINT_STATE_RUNNING && !shouldListenForFingerprint) {
        if (mFingerprintRunningState == FINGERPRINT_STATE_RUNNING && !shouldListenForFingerprint) {
@@ -1150,7 +1168,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        return (mKeyguardIsVisible || !mDeviceInteractive ||
        return (mKeyguardIsVisible || !mDeviceInteractive ||
                (mBouncer && !mKeyguardGoingAway) || mGoingToSleep ||
                (mBouncer && !mKeyguardGoingAway) || mGoingToSleep ||
                (mAssistantVisible && mKeyguardOccluded))
                (mAssistantVisible && mKeyguardOccluded))
                && !mSwitchingUser && !isFingerprintDisabled(getCurrentUser());
                && !mSwitchingUser && !isFingerprintDisabled(getCurrentUser())
                && !mKeyguardGoingAway;
    }
    }


    private void startListeningForFingerprint() {
    private void startListeningForFingerprint() {