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

Commit 01648902 authored by Michael Bestas's avatar Michael Bestas Committed by Michael Bestas
Browse files

Keyguard: Allow user configurable fingerprint wake-and-unlock

Based on:
I471908cfa27a54e0075394eed348cb15386f62ce
I50c0a857daba92c17470d8089aca94099c792956
and modified to use the new AOSP performant auth setting.

Change-Id: I79602ae0039b72f859890340443c951fbced3afe
parent 0a269dfe
Loading
Loading
Loading
Loading
+44 −1
Original line number Diff line number Diff line
@@ -335,6 +335,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            mCallbacks = Lists.newArrayList();
    private ContentObserver mDeviceProvisionedObserver;
    private final ContentObserver mTimeFormatChangeObserver;
    private ContentObserver mSettingsChangeObserver;

    private boolean mSwitchingUser;

@@ -376,6 +377,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private int mPostureState = DEVICE_POSTURE_UNKNOWN;
    private FingerprintInteractiveToAuthProvider mFingerprintInteractiveToAuthProvider;

    private boolean mFingerprintWakeAndUnlock;

    /**
     * Short delay before restarting fingerprint authentication after a successful try. This should
     * be slightly longer than the time between onFingerprintAuthenticated and
@@ -2183,6 +2186,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                R.integer.config_face_auth_supported_posture);
        mFaceWakeUpTriggersConfig = faceWakeUpTriggersConfig;

        updateFingerprintSettings();

        mHandler = new Handler(mainLooper) {
            @Override
            public void handleMessage(Message msg) {
@@ -2408,6 +2413,28 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                false, mTimeFormatChangeObserver, UserHandle.USER_ALL);

        mFingerprintInteractiveToAuthProvider = interactiveToAuthProvider.orElse(null);

        mSettingsChangeObserver = new ContentObserver(mHandler) {
            @Override
            public void onChange(boolean selfChange) {
                updateFingerprintSettings();
            }
        };
        mContext.getContentResolver().registerContentObserver(
                Settings.Secure.getUriFor(Settings.Secure.SFPS_PERFORMANT_AUTH_ENABLED),
                false, mSettingsChangeObserver, UserHandle.USER_ALL);
    }

    private void updateFingerprintSettings() {
        boolean defFingerprintSettings = mContext.getResources().getBoolean(
                org.lineageos.platform.internal.R.bool.config_fingerprintWakeAndUnlock);
        if (defFingerprintSettings) {
            mFingerprintWakeAndUnlock = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                    Settings.Secure.SFPS_PERFORMANT_AUTH_ENABLED,
                    1, UserHandle.USER_CURRENT) == 1;
        } else {
            mFingerprintWakeAndUnlock = defFingerprintSettings;
        }
    }

    private void initializeSimState() {
@@ -2805,7 +2832,18 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        final int user = getCurrentUser();
        final boolean userDoesNotHaveTrust = !getUserHasTrust(user);
        final boolean shouldListenForFingerprintAssistant = shouldListenForFingerprintAssistant();
        final boolean shouldListenKeyguardState =
        final boolean shouldListenKeyguardState;
        if (!mFingerprintWakeAndUnlock) {
            shouldListenKeyguardState =
                (isKeyguardVisible()
                        || mPrimaryBouncerIsOrWillBeShowing
                        || shouldListenForFingerprintAssistant
                        || (mKeyguardOccluded && mIsDreaming))
                        && mDeviceInteractive && !mGoingToSleep && !mKeyguardGoingAway
                        || (mKeyguardOccluded && userDoesNotHaveTrust
                            && (mOccludingAppRequestingFp || isUdfps || mAlternateBouncerShowing));
        } else {
            shouldListenKeyguardState =
                isKeyguardVisible()
                        || !mDeviceInteractive
                        || (mPrimaryBouncerIsOrWillBeShowing && !mKeyguardGoingAway)
@@ -2814,6 +2852,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                        || (mKeyguardOccluded && mIsDreaming)
                        || (mKeyguardOccluded && userDoesNotHaveTrust
                            && (mOccludingAppRequestingFp || isUdfps || mAlternateBouncerShowing));
        }

        // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
        // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
@@ -4022,6 +4061,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            mContext.getContentResolver().unregisterContentObserver(mTimeFormatChangeObserver);
        }

        if (mSettingsChangeObserver != null) {
            mContext.getContentResolver().unregisterContentObserver(mSettingsChangeObserver);
        }

        mUserTracker.removeCallback(mUserChangedCallback);

        TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);