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

Commit 1d6243a7 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Add activeUnlock config to force dismissKeyguard"

parents b9f04e06 bfe68c86
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -10323,7 +10323,7 @@ public final class Settings {
        /**
        /**
         * If active unlock triggers on unlock intents, then also request active unlock on
         * If active unlock triggers on unlock intents, then also request active unlock on
         * these wake-up reasons. See PowerManager.WakeReason for value mappings.
         * these wake-up reasons. See {@link PowerManager.WakeReason} for value mappings.
         * WakeReasons should be separated by a pipe. For example: "0|3" or "0". If this
         * WakeReasons should be separated by a pipe. For example: "0|3" or "0". If this
         * setting should be disabled, then this should be set to an empty string. A null value
         * setting should be disabled, then this should be set to an empty string. A null value
         * will use the system default value (WAKE_REASON_UNFOLD_DEVICE).
         * will use the system default value (WAKE_REASON_UNFOLD_DEVICE).
@@ -10332,6 +10332,17 @@ public final class Settings {
        public static final String ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS =
        public static final String ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS =
                "active_unlock_wakeups_considered_unlock_intents";
                "active_unlock_wakeups_considered_unlock_intents";
        /**
         * If active unlock triggers and succeeds on these wakeups, force dismiss keyguard on
         * these wake reasons. See {@link PowerManager#WakeReason} for value mappings.
         * WakeReasons should be separated by a pipe. For example: "0|3" or "0". If this
         * setting should be disabled, then this should be set to an empty string. A null value
         * will use the system default value (WAKE_REASON_UNFOLD_DEVICE).
         * @hide
         */
        public static final String ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD =
                "active_unlock_wakeups_to_force_dismiss_keyguard";
        /**
        /**
         * Whether the assist gesture should be enabled.
         * Whether the assist gesture should be enabled.
         *
         *
+1 −0
Original line number Original line Diff line number Diff line
@@ -131,6 +131,7 @@ public class SecureSettings {
        Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO,
        Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO,
        Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED,
        Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED,
        Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS,
        Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS,
        Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD,
        Settings.Secure.VR_DISPLAY_MODE,
        Settings.Secure.VR_DISPLAY_MODE,
        Settings.Secure.NOTIFICATION_BADGING,
        Settings.Secure.NOTIFICATION_BADGING,
        Settings.Secure.NOTIFICATION_DISMISS_RTL,
        Settings.Secure.NOTIFICATION_DISMISS_RTL,
+2 −0
Original line number Original line Diff line number Diff line
@@ -191,6 +191,8 @@ public class SecureSettingsValidators {
                ANY_STRING_VALIDATOR);
                ANY_STRING_VALIDATOR);
        VALIDATORS.put(Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS,
        VALIDATORS.put(Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS,
                ANY_STRING_VALIDATOR);
                ANY_STRING_VALIDATOR);
        VALIDATORS.put(Secure.ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD,
                ANY_STRING_VALIDATOR);
        VALIDATORS.put(Secure.ASSIST_GESTURE_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ASSIST_GESTURE_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ASSIST_GESTURE_WAKE_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ASSIST_GESTURE_WAKE_ENABLED, BOOLEAN_VALIDATOR);
+44 −1
Original line number Original line Diff line number Diff line
@@ -29,8 +29,9 @@ import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ACQUIRE_INFO
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ERRORS
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_FACE_ERRORS
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED
import android.provider.Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_WAKE
import android.provider.Settings.Secure.ACTIVE_UNLOCK_ON_WAKE
import android.provider.Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS
import android.provider.Settings.Secure.ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD
import android.util.Log
import android.util.Log
import com.android.keyguard.KeyguardUpdateMonitor.getCurrentUser
import com.android.keyguard.KeyguardUpdateMonitor.getCurrentUser
import com.android.systemui.Dumpable
import com.android.systemui.Dumpable
@@ -60,9 +61,27 @@ class ActiveUnlockConfig @Inject constructor(
     * Indicates the origin for an active unlock request.
     * Indicates the origin for an active unlock request.
     */
     */
    enum class ActiveUnlockRequestOrigin {
    enum class ActiveUnlockRequestOrigin {
        /**
         * Trigger ActiveUnlock on wake ups that'd trigger FaceAuth, see [FaceWakeUpTriggersConfig]
         */
        WAKE,
        WAKE,

        /**
         * Trigger ActiveUnlock on unlock intents. This includes the bouncer showing or tapping on
         * a notification. May also include wakeups: [wakeupsConsideredUnlockIntents].
         */
        UNLOCK_INTENT,
        UNLOCK_INTENT,

        /**
         * Trigger ActiveUnlock on biometric failures. This may include soft errors depending on
         * the other settings. See: [faceErrorsToTriggerBiometricFailOn],
         * [faceAcquireInfoToTriggerBiometricFailOn].
         */
        BIOMETRIC_FAIL,
        BIOMETRIC_FAIL,

        /**
         * Trigger ActiveUnlock when the assistant is triggered.
         */
        ASSISTANT,
        ASSISTANT,
    }
    }


@@ -85,6 +104,7 @@ class ActiveUnlockConfig @Inject constructor(
    private var faceAcquireInfoToTriggerBiometricFailOn = mutableSetOf<Int>()
    private var faceAcquireInfoToTriggerBiometricFailOn = mutableSetOf<Int>()
    private var onUnlockIntentWhenBiometricEnrolled = mutableSetOf<Int>()
    private var onUnlockIntentWhenBiometricEnrolled = mutableSetOf<Int>()
    private var wakeupsConsideredUnlockIntents = mutableSetOf<Int>()
    private var wakeupsConsideredUnlockIntents = mutableSetOf<Int>()
    private var wakeupsToForceDismissKeyguard = mutableSetOf<Int>()


    private val settingsObserver = object : ContentObserver(handler) {
    private val settingsObserver = object : ContentObserver(handler) {
        private val wakeUri = secureSettings.getUriFor(ACTIVE_UNLOCK_ON_WAKE)
        private val wakeUri = secureSettings.getUriFor(ACTIVE_UNLOCK_ON_WAKE)
@@ -97,6 +117,8 @@ class ActiveUnlockConfig @Inject constructor(
                secureSettings.getUriFor(ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED)
                secureSettings.getUriFor(ACTIVE_UNLOCK_ON_UNLOCK_INTENT_WHEN_BIOMETRIC_ENROLLED)
        private val wakeupsConsideredUnlockIntentsUri =
        private val wakeupsConsideredUnlockIntentsUri =
            secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS)
            secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_CONSIDERED_UNLOCK_INTENTS)
        private val wakeupsToForceDismissKeyguardUri =
            secureSettings.getUriFor(ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD)


        fun register() {
        fun register() {
            registerUri(
            registerUri(
@@ -108,6 +130,7 @@ class ActiveUnlockConfig @Inject constructor(
                        faceAcquireInfoUri,
                        faceAcquireInfoUri,
                        unlockIntentWhenBiometricEnrolledUri,
                        unlockIntentWhenBiometricEnrolledUri,
                        wakeupsConsideredUnlockIntentsUri,
                        wakeupsConsideredUnlockIntentsUri,
                        wakeupsToForceDismissKeyguardUri,
                    )
                    )
            )
            )


@@ -182,6 +205,15 @@ class ActiveUnlockConfig @Inject constructor(
                    wakeupsConsideredUnlockIntents,
                    wakeupsConsideredUnlockIntents,
                    setOf(WAKE_REASON_UNFOLD_DEVICE))
                    setOf(WAKE_REASON_UNFOLD_DEVICE))
            }
            }

            if (selfChange || uris.contains(wakeupsToForceDismissKeyguardUri)) {
                processStringArray(
                    secureSettings.getStringForUser(
                        ACTIVE_UNLOCK_WAKEUPS_TO_FORCE_DISMISS_KEYGUARD,
                        getCurrentUser()),
                    wakeupsToForceDismissKeyguard,
                    setOf(WAKE_REASON_UNFOLD_DEVICE))
            }
        }
        }


        /**
        /**
@@ -248,6 +280,14 @@ class ActiveUnlockConfig @Inject constructor(
        return wakeupsConsideredUnlockIntents.contains(pmWakeReason)
        return wakeupsConsideredUnlockIntents.contains(pmWakeReason)
    }
    }


    /**
     * Whether the PowerManager wake reason should force dismiss the keyguard if active
     * unlock is successful.
     */
    fun shouldWakeupForceDismissKeyguard(pmWakeReason: Int): Boolean {
        return wakeupsToForceDismissKeyguard.contains(pmWakeReason)
    }

    /**
    /**
     * Whether to trigger active unlock based on where the request is coming from and
     * Whether to trigger active unlock based on where the request is coming from and
     * the current settings.
     * the current settings.
@@ -321,6 +361,9 @@ class ActiveUnlockConfig @Inject constructor(
        pw.println("   activeUnlockWakeupsConsideredUnlockIntents=${
        pw.println("   activeUnlockWakeupsConsideredUnlockIntents=${
            wakeupsConsideredUnlockIntents.map { PowerManager.wakeReasonToString(it) }
            wakeupsConsideredUnlockIntents.map { PowerManager.wakeReasonToString(it) }
        }")
        }")
        pw.println("   activeUnlockFromWakeupsToAlwaysDismissKeyguard=${
            wakeupsToForceDismissKeyguard.map { PowerManager.wakeReasonToString(it) }
        }")


        pw.println("Current state:")
        pw.println("Current state:")
        keyguardUpdateMonitor?.let {
        keyguardUpdateMonitor?.let {
+1 −1
Original line number Original line Diff line number Diff line
@@ -29,7 +29,7 @@ import java.io.PrintWriter
import java.util.stream.Collectors
import java.util.stream.Collectors
import javax.inject.Inject
import javax.inject.Inject


/** Determines which device wake-ups should trigger face authentication. */
/** Determines which device wake-ups should trigger passive authentication. */
@SysUISingleton
@SysUISingleton
class FaceWakeUpTriggersConfig
class FaceWakeUpTriggersConfig
@Inject
@Inject
Loading