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

Commit a2094009 authored by Curtis Belmonte's avatar Curtis Belmonte
Browse files

Add config to override face unlock bypass setting

Introduces a config parameter that can be used to override the setting
for whether successfully authenticating with face auth should dismiss
keyguard. This is intended for testing only.

Test: For each config setting (0, 1, 2), do the following:
1. Toggle on "Settings > Security > Face unlock > Skip lock screen"
2. Lock the device and authenticate using face
3. Repeat steps with "Skip lock screen" toggled off

Bug: 184995230
Change-Id: I95697d3a611f134efe36330291570e5e5b10ff12
parent f5195618
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -656,4 +656,10 @@
        <!-- Y -->
        <!-- radius -->
    </integer-array>

    <!-- Overrides the behavior of the face unlock keyguard bypass setting:
         0 - Don't override the setting (default)
         1 - Override the setting to always bypass keyguard
         2 - Override the setting to never bypass keyguard -->
    <integer name="config_face_unlock_bypass_override">0</integer>
</resources>
+25 −1
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@

package com.android.systemui.statusbar.phone

import android.annotation.IntDef
import android.content.Context
import android.content.pm.PackageManager
import android.hardware.biometrics.BiometricSourceType
import android.provider.Settings
import com.android.systemui.Dumpable
import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
import com.android.systemui.plugins.statusbar.StatusBarStateController
@@ -37,9 +39,18 @@ open class KeyguardBypassController : Dumpable {

    private val mKeyguardStateController: KeyguardStateController
    private val statusBarStateController: StatusBarStateController
    @BypassOverride private val bypassOverride: Int
    private var hasFaceFeature: Boolean
    private var pendingUnlock: PendingUnlock? = null

    @IntDef(
        FACE_UNLOCK_BYPASS_NO_OVERRIDE,
        FACE_UNLOCK_BYPASS_ALWAYS,
        FACE_UNLOCK_BYPASS_NEVER
    )
    @Retention(AnnotationRetention.SOURCE)
    private annotation class BypassOverride

    /**
     * Pending unlock info:
     *
@@ -60,7 +71,14 @@ open class KeyguardBypassController : Dumpable {
     * If face unlock dismisses the lock screen or keeps user on keyguard for the current user.
     */
    var bypassEnabled: Boolean = false
        get() = field && mKeyguardStateController.isFaceAuthEnabled
        get() {
            val enabled = when (bypassOverride) {
                FACE_UNLOCK_BYPASS_ALWAYS -> true
                FACE_UNLOCK_BYPASS_NEVER -> false
                else -> field
            }
            return enabled && mKeyguardStateController.isFaceAuthEnabled
        }
        private set

    var bouncerShowing: Boolean = false
@@ -86,6 +104,8 @@ open class KeyguardBypassController : Dumpable {
        this.mKeyguardStateController = keyguardStateController
        this.statusBarStateController = statusBarStateController

        bypassOverride = context.resources.getInteger(R.integer.config_face_unlock_bypass_override)

        hasFaceFeature = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)
        if (!hasFaceFeature) {
            return
@@ -198,5 +218,9 @@ open class KeyguardBypassController : Dumpable {

    companion object {
        const val BYPASS_PANEL_FADE_DURATION = 67

        private const val FACE_UNLOCK_BYPASS_NO_OVERRIDE = 0
        private const val FACE_UNLOCK_BYPASS_ALWAYS = 1
        private const val FACE_UNLOCK_BYPASS_NEVER = 2
    }
}