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

Commit 51c6d52b authored by Chandru S's avatar Chandru S Committed by Android (Google) Code Review
Browse files

Merge changes from topic "remove-old-face-auth-code" into main

* changes:
  Remove all old face auth code.
  Update isAuthenticated before authentication event is emitted
parents 975daf26 96ee70b2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -317,7 +317,7 @@ class ActiveUnlockConfig @Inject constructor(
        }

        keyguardUpdateMonitor?.let {
            val anyFaceEnrolled = it.isFaceEnrolled
            val anyFaceEnrolled = it.isFaceEnabledAndEnrolled
            val anyFingerprintEnrolled = it.isUnlockWithFingerprintPossible(
                    selectedUserInteractor.getSelectedUserId())
            val udfpsEnrolled = it.isUdfpsEnrolled
@@ -372,7 +372,7 @@ class ActiveUnlockConfig @Inject constructor(
        keyguardUpdateMonitor?.let {
            pw.println("   shouldRequestActiveUnlockOnUnlockIntentFromBiometricEnrollment=" +
                    "${shouldRequestActiveUnlockOnUnlockIntentFromBiometricEnrollment()}")
            pw.println("   faceEnrolled=${it.isFaceEnrolled}")
            pw.println("   isFaceEnabledAndEnrolled=${it.isFaceEnabledAndEnrolled}")
            pw.println("   fpUnlockPossible=${
                it.isUnlockWithFingerprintPossible(selectedUserInteractor.getSelectedUserId())}")
            pw.println("   udfpsEnrolled=${it.isUdfpsEnrolled}")
+0 −169
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.keyguard

import android.annotation.CurrentTimeMillisLong
import com.android.systemui.common.buffer.RingBuffer
import com.android.systemui.dump.DumpsysTableLogger
import com.android.systemui.dump.Row

/** Verbose debug information associated. */
data class KeyguardFaceListenModel(
    @CurrentTimeMillisLong override var timeMillis: Long = 0L,
    override var userId: Int = 0,
    override var listening: Boolean = false,
    // keep sorted
    var allowedDisplayStateWhileAwake: Boolean = false,
    var alternateBouncerShowing: Boolean = false,
    var authInterruptActive: Boolean = false,
    var biometricSettingEnabledForUser: Boolean = false,
    var bouncerFullyShown: Boolean = false,
    var faceAndFpNotAuthenticated: Boolean = false,
    var faceAuthAllowed: Boolean = false,
    var faceDisabled: Boolean = false,
    var faceLockedOut: Boolean = false,
    var goingToSleep: Boolean = false,
    var keyguardAwake: Boolean = false,
    var keyguardGoingAway: Boolean = false,
    var listeningForFaceAssistant: Boolean = false,
    var occludingAppRequestingFaceAuth: Boolean = false,
    var postureAllowsListening: Boolean = false,
    var secureCameraLaunched: Boolean = false,
    var supportsDetect: Boolean = false,
    var switchingUser: Boolean = false,
    var systemUser: Boolean = false,
    var udfpsFingerDown: Boolean = false,
    var userNotTrustedOrDetectionIsNeeded: Boolean = false,
) : KeyguardListenModel() {

    /** List of [String] to be used as a [Row] with [DumpsysTableLogger]. */
    val asStringList: List<String> by lazy {
        listOf(
            DATE_FORMAT.format(timeMillis),
            timeMillis.toString(),
            userId.toString(),
            listening.toString(),
            // keep sorted
            allowedDisplayStateWhileAwake.toString(),
            alternateBouncerShowing.toString(),
            authInterruptActive.toString(),
            biometricSettingEnabledForUser.toString(),
            bouncerFullyShown.toString(),
            faceAndFpNotAuthenticated.toString(),
            faceAuthAllowed.toString(),
            faceDisabled.toString(),
            faceLockedOut.toString(),
            goingToSleep.toString(),
            keyguardAwake.toString(),
            keyguardGoingAway.toString(),
            listeningForFaceAssistant.toString(),
            occludingAppRequestingFaceAuth.toString(),
            postureAllowsListening.toString(),
            secureCameraLaunched.toString(),
            supportsDetect.toString(),
            switchingUser.toString(),
            systemUser.toString(),
            udfpsFingerDown.toString(),
            userNotTrustedOrDetectionIsNeeded.toString(),
        )
    }

    /**
     * [RingBuffer] to store [KeyguardFaceListenModel]. After the buffer is full, it will recycle
     * old events.
     *
     * Do not use [append] to add new elements. Instead use [insert], as it will recycle if
     * necessary.
     */
    class Buffer {
        private val buffer = RingBuffer(CAPACITY) { KeyguardFaceListenModel() }

        fun insert(model: KeyguardFaceListenModel) {
            buffer.advance().apply {
                timeMillis = model.timeMillis
                userId = model.userId
                listening = model.listening
                // keep sorted
                allowedDisplayStateWhileAwake = model.allowedDisplayStateWhileAwake
                alternateBouncerShowing = model.alternateBouncerShowing
                authInterruptActive = model.authInterruptActive
                biometricSettingEnabledForUser = model.biometricSettingEnabledForUser
                bouncerFullyShown = model.bouncerFullyShown
                faceAndFpNotAuthenticated = model.faceAndFpNotAuthenticated
                faceAuthAllowed = model.faceAuthAllowed
                faceDisabled = model.faceDisabled
                faceLockedOut = model.faceLockedOut
                goingToSleep = model.goingToSleep
                keyguardAwake = model.keyguardAwake
                keyguardGoingAway = model.keyguardGoingAway
                listeningForFaceAssistant = model.listeningForFaceAssistant
                occludingAppRequestingFaceAuth = model.occludingAppRequestingFaceAuth
                postureAllowsListening = model.postureAllowsListening
                secureCameraLaunched = model.secureCameraLaunched
                supportsDetect = model.supportsDetect
                switchingUser = model.switchingUser
                systemUser = model.systemUser
                udfpsFingerDown = model.udfpsFingerDown
                userNotTrustedOrDetectionIsNeeded = model.userNotTrustedOrDetectionIsNeeded
            }
        }
        /**
         * Returns the content of the buffer (sorted from latest to newest).
         *
         * @see KeyguardFingerprintListenModel.asStringList
         */
        fun toList(): List<Row> {
            return buffer.asSequence().map { it.asStringList }.toList()
        }
    }

    companion object {
        const val CAPACITY = 40 // number of logs to retain

        /** Headers for dumping a table using [DumpsysTableLogger]. */
        @JvmField
        val TABLE_HEADERS =
            listOf(
                "timestamp",
                "time_millis",
                "userId",
                "listening",
                // keep sorted
                "allowedDisplayStateWhileAwake",
                "alternateBouncerShowing",
                "authInterruptActive",
                "biometricSettingEnabledForUser",
                "bouncerFullyShown",
                "faceAndFpNotAuthenticated",
                "faceAuthAllowed",
                "faceDisabled",
                "faceLockedOut",
                "goingToSleep",
                "keyguardAwake",
                "keyguardGoingAway",
                "listeningForFaceAssistant",
                "occludingAppRequestingFaceAuth",
                "postureAllowsListening",
                "secureCameraLaunched",
                "supportsDetect",
                "switchingUser",
                "systemUser",
                "udfpsFingerDown",
                "userNotTrustedOrDetectionIsNeeded",
            )
    }
}
+4 −10
Original line number Diff line number Diff line
@@ -214,7 +214,6 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
        public void onUserInput() {
            mBouncerMessageInteractor.onPrimaryBouncerUserInput();
            mKeyguardFaceAuthInteractor.onPrimaryBouncerUserInput();
            mUpdateMonitor.cancelFaceAuth();
        }

        @Override
@@ -340,16 +339,11 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
    private final SwipeListener mSwipeListener = new SwipeListener() {
        @Override
        public void onSwipeUp() {
            if (!mUpdateMonitor.isFaceDetectionRunning()) {
                mKeyguardFaceAuthInteractor.onSwipeUpOnBouncer();
                boolean didFaceAuthRun = mUpdateMonitor.requestFaceAuth(
                        FaceAuthApiRequestReason.SWIPE_UP_ON_BOUNCER);
            if (mKeyguardFaceAuthInteractor.canFaceAuthRun()) {
                mKeyguardSecurityCallback.userActivity();
                if (didFaceAuthRun) {
                    showMessage(/* message= */ null, /* colorState= */ null, /* animated= */ true);
                }
            }
            if (mUpdateMonitor.isFaceEnrolled()) {
            mKeyguardFaceAuthInteractor.onSwipeUpOnBouncer();
            if (mKeyguardFaceAuthInteractor.isFaceAuthEnabledAndEnrolled()) {
                mUpdateMonitor.requestActiveUnlock(
                        ActiveUnlockConfig.ActiveUnlockRequestOrigin.UNLOCK_INTENT,
                        "swipeUpOnBouncer");
@@ -755,7 +749,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
        }
        mView.onResume(
                mSecurityModel.getSecurityMode(mSelectedUserInteractor.getSelectedUserId()),
                mKeyguardStateController.isFaceEnrolled());
                mKeyguardStateController.isFaceEnrolledAndEnabled());
    }

    /** Sets an initial message that would override the default message */
+121 −764

File changed.

Preview size limit exceeded, changes collapsed.

+0 −126
Original line number Diff line number Diff line
@@ -20,14 +20,12 @@ import android.content.Intent
import android.hardware.biometrics.BiometricConstants.LockoutMode
import android.hardware.biometrics.BiometricSourceType
import android.os.PowerManager
import android.os.PowerManager.WakeReason
import android.telephony.ServiceState
import android.telephony.SubscriptionInfo
import android.telephony.SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX
import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID
import android.telephony.TelephonyManager
import com.android.keyguard.ActiveUnlockConfig
import com.android.keyguard.FaceAuthUiEvent
import com.android.keyguard.KeyguardListenModel
import com.android.keyguard.KeyguardUpdateMonitorCallback
import com.android.keyguard.TrustGrantFlags
@@ -102,14 +100,6 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        logBuffer.log(TAG, ERROR, {}, { logMsg }, exception = ex)
    }

    fun logFaceAuthDisabledForUser(userId: Int) {
        logBuffer.log(
            TAG,
            DEBUG,
            { int1 = userId },
            { "Face authentication disabled by DPM for userId: $int1" }
        )
    }
    fun logFaceAuthError(msgId: Int, originalErrMsg: String) {
        logBuffer.log(
            TAG,
@@ -131,31 +121,10 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        )
    }

    fun logFaceAuthRequested(reason: String?) {
        logBuffer.log(TAG, DEBUG, { str1 = reason }, { "requestFaceAuth() reason=$str1" })
    }

    fun logFaceAuthSuccess(userId: Int) {
        logBuffer.log(TAG, DEBUG, { int1 = userId }, { "Face auth succeeded for user $int1" })
    }

    fun logFaceLockoutReset(@LockoutMode mode: Int) {
        logBuffer.log(TAG, DEBUG, { int1 = mode }, { "handleFaceLockoutReset: $int1" })
    }

    fun logFaceRunningState(faceRunningState: Int) {
        logBuffer.log(TAG, DEBUG, { int1 = faceRunningState }, { "faceRunningState: $int1" })
    }

    fun logFaceUnlockPossible(isFaceUnlockPossible: Boolean) {
        logBuffer.log(
            TAG,
            DEBUG,
            { bool1 = isFaceUnlockPossible },
            { "isUnlockWithFacePossible: $bool1" }
        )
    }

    fun logFingerprintAuthForWrongUser(authUserId: Int) {
        logBuffer.log(
            FP_LOG_TAG,
@@ -301,15 +270,6 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        logBuffer.log(TAG, VERBOSE, { str1 = "$callback" }, { "*** register callback for $str1" })
    }

    fun logRetryingAfterFaceHwUnavailable(retryCount: Int) {
        logBuffer.log(
            TAG,
            WARNING,
            { int1 = retryCount },
            { "Retrying face after HW unavailable, attempt $int1" }
        )
    }

    fun logRetryAfterFpErrorWithDelay(msgId: Int, errString: String?, delay: Int) {
        logBuffer.log(
            TAG,
@@ -419,43 +379,6 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        logBuffer.log(TAG, VERBOSE, { int1 = subId }, { "reportSimUnlocked(subId=$int1)" })
    }

    fun logStartedListeningForFace(faceRunningState: Int, faceAuthUiEvent: FaceAuthUiEvent) {
        logBuffer.log(
            TAG,
            VERBOSE,
            {
                int1 = faceRunningState
                str1 = faceAuthUiEvent.reason
                str2 = faceAuthUiEvent.extraInfoToString()
            },
            { "startListeningForFace(): $int1, reason: $str1 $str2" }
        )
    }

    fun logStartedListeningForFaceFromWakeUp(faceRunningState: Int, @WakeReason pmWakeReason: Int) {
        logBuffer.log(
            TAG,
            VERBOSE,
            {
                int1 = faceRunningState
                str1 = PowerManager.wakeReasonToString(pmWakeReason)
            },
            { "startListeningForFace(): $int1, reason: wakeUp-$str1" }
        )
    }

    fun logStoppedListeningForFace(faceRunningState: Int, faceAuthReason: String) {
        logBuffer.log(
            TAG,
            VERBOSE,
            {
                int1 = faceRunningState
                str1 = faceAuthReason
            },
            { "stopListeningForFace(): currentFaceRunningState: $int1, reason: $str1" }
        )
    }

    fun logSubInfo(subInfo: SubscriptionInfo?) {
        logBuffer.log(TAG, DEBUG, { str1 = "$subInfo" }, { "SubInfo:$str1" })
    }
@@ -476,22 +399,6 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        logBuffer.log(TAG, DEBUG, { int1 = sensorId }, { "onUdfpsPointerUp, sensorId: $int1" })
    }

    fun logUnexpectedFaceCancellationSignalState(faceRunningState: Int, unlockPossible: Boolean) {
        logBuffer.log(
            TAG,
            ERROR,
            {
                int1 = faceRunningState
                bool1 = unlockPossible
            },
            {
                "Cancellation signal is not null, high chance of bug in " +
                    "face auth lifecycle management. " +
                    "Face state: $int1, unlockPossible: $bool1"
            }
        )
    }

    fun logUnexpectedFpCancellationSignalState(
        fingerprintRunningState: Int,
        unlockPossible: Boolean
@@ -588,15 +495,6 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        )
    }

    fun logSkipUpdateFaceListeningOnWakeup(@WakeReason pmWakeReason: Int) {
        logBuffer.log(
            TAG,
            VERBOSE,
            { str1 = PowerManager.wakeReasonToString(pmWakeReason) },
            { "Skip updating face listening state on wakeup from $str1" }
        )
    }

    fun logTaskStackChangedForAssistant(assistantVisible: Boolean) {
        logBuffer.log(
            TAG,
@@ -648,18 +546,6 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        )
    }

    fun logFaceEnrolledUpdated(oldValue: Boolean, newValue: Boolean) {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                bool1 = oldValue
                bool2 = newValue
            },
            { "Face enrolled state changed: old: $bool1, new: $bool2" }
        )
    }

    fun logTrustUsuallyManagedUpdated(
        userId: Int,
        oldValue: Boolean,
@@ -745,18 +631,6 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
        )
    }

    fun logFingerprintHelp(helpMsgId: Int, helpString: CharSequence) {
        logBuffer.log(
            FP_LOG_TAG,
            DEBUG,
            {
                int1 = helpMsgId
                str1 = "$helpString"
            },
            { "fingerprint help message: $int1, $str1" }
        )
    }

    fun logFingerprintAcquired(acquireInfo: Int) {
        logBuffer.log(
            FP_LOG_TAG,
Loading