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

Commit fcc5ac23 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Move BiometricUnlockController logs to LogBuffer

Additionally log whether unlocking was allowed when
BiometricUnlockController determines which unlock MODE
to use.

Also log additional fingerprint errors in
KeyguardUpdateMonitorLog.

Test: adb shell settings put global systemui/buffer/BiometricLog
Bug: 250392997
Change-Id: I3b87325f7fdeb3a0d53a2573cd6aae93907bb81c
parent 68888b39
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -29,5 +29,4 @@ public class KeyguardConstants {
     */
    public static final boolean DEBUG = Log.isLoggable("Keyguard", Log.DEBUG);
    public static final boolean DEBUG_SIM_STATES = true;
    public static final boolean DEBUG_BIOMETRIC_WAKELOCK = true;
}
+4 −0
Original line number Diff line number Diff line
@@ -845,6 +845,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    + " triggered while waiting for cancellation, removing watchdog");
            mHandler.removeCallbacks(mFpCancelNotReceived);
        }
        mLogger.d("handleFingerprintAuthFailed");
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
@@ -974,6 +975,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            stopListeningForFace(FACE_AUTH_STOPPED_FP_LOCKED_OUT);
        }

        mLogger.logFingerprintError(msgId, errString);
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
@@ -3900,6 +3902,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            pw.println("    listening: actual=" + mFaceRunningState
                    + " expected=(" + (shouldListenForFace() ? 1 : 0));
            pw.println("    strongAuthFlags=" + Integer.toHexString(strongAuthFlags));
            pw.println("    isNonStrongBiometricAllowedAfterIdleTimeout="
                    + mStrongAuthTracker.isNonStrongBiometricAllowedAfterIdleTimeout(userId));
            pw.println("    trustManaged=" + getUserTrustIsManaged(userId));
            pw.println("    mFaceLockedOutPermanent=" + mFaceLockedOutPermanent);
            pw.println("    enabledByUser=" + mBiometricEnabledForUser.get(userId));
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.keyguard.logging

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.log.dagger.BiometricMessagesLog
import com.android.systemui.log.dagger.BiometricLog
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel.DEBUG
import javax.inject.Inject
@@ -26,7 +26,7 @@ import javax.inject.Inject
@SysUISingleton
class FaceMessageDeferralLogger
@Inject
constructor(@BiometricMessagesLog private val logBuffer: LogBuffer) :
constructor(@BiometricLog private val logBuffer: LogBuffer) :
    BiometricMessageDeferralLogger(logBuffer, "FaceMessageDeferralLogger")

open class BiometricMessageDeferralLogger(
+174 −0
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.logging

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.log.dagger.BiometricLog
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel
import com.android.systemui.plugins.log.LogLevel.DEBUG
import com.android.systemui.plugins.log.LogLevel.INFO
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_DISMISS_BOUNCER
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_NONE
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_ONLY_WAKE
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_SHOW_BOUNCER
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_UNLOCK_COLLAPSING
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK_FROM_DREAM
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject

private const val TAG = "BiometricUnlockLogger"

/** Helper class for logging for [com.android.systemui.statusbar.phone.BiometricUnlockController] */
@SysUISingleton
class BiometricUnlockLogger @Inject constructor(@BiometricLog private val logBuffer: LogBuffer) {
    fun i(@CompileTimeConstant msg: String) = log(msg, INFO)
    fun d(@CompileTimeConstant msg: String) = log(msg, DEBUG)
    fun log(@CompileTimeConstant msg: String, level: LogLevel) = logBuffer.log(TAG, level, msg)

    fun logStartWakeAndUnlock(mode: Int) {
        logBuffer.log(
            TAG,
            DEBUG,
            { int1 = mode },
            { "startWakeAndUnlock(${wakeAndUnlockModeToString(int1)})" }
        )
    }

    fun logUdfpsAttemptThresholdMet(consecutiveFailedAttempts: Int) {
        logBuffer.log(
            TAG,
            DEBUG,
            { int1 = consecutiveFailedAttempts },
            { "udfpsAttemptThresholdMet consecutiveFailedAttempts=$int1" }
        )
    }

    fun logCalculateModeForFingerprintUnlockingAllowed(
        deviceInteractive: Boolean,
        keyguardShowing: Boolean,
        deviceDreaming: Boolean
    ) {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                bool1 = deviceInteractive
                bool2 = keyguardShowing
                bool3 = deviceDreaming
            },
            {
                "calculateModeForFingerprint unlockingAllowed=true" +
                    " deviceInteractive=$bool1 isKeyguardShowing=$bool2" +
                    " deviceDreaming=$bool3"
            }
        )
    }

    fun logCalculateModeForFingerprintUnlockingNotAllowed(
        strongBiometric: Boolean,
        strongAuthFlags: Int,
        nonStrongBiometricAllowed: Boolean,
        deviceInteractive: Boolean,
        keyguardShowing: Boolean
    ) {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                int1 = strongAuthFlags
                bool1 = strongBiometric
                bool2 = nonStrongBiometricAllowed
                bool3 = deviceInteractive
                bool4 = keyguardShowing
            },
            {
                "calculateModeForFingerprint unlockingAllowed=false" +
                    " strongBiometric=$bool1 strongAuthFlags=$int1" +
                    " nonStrongBiometricAllowed=$bool2" +
                    " deviceInteractive=$bool3 isKeyguardShowing=$bool4"
            }
        )
    }

    fun logCalculateModeForPassiveAuthUnlockingAllowed(
        deviceInteractive: Boolean,
        keyguardShowing: Boolean,
        deviceDreaming: Boolean,
        bypass: Boolean
    ) {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                bool1 = deviceInteractive
                bool2 = keyguardShowing
                bool3 = deviceDreaming
                bool4 = bypass
            },
            {
                "calculateModeForPassiveAuth unlockingAllowed=true" +
                    " deviceInteractive=$bool1 isKeyguardShowing=$bool2" +
                    " deviceDreaming=$bool3 bypass=$bool4"
            }
        )
    }

    fun logCalculateModeForPassiveAuthUnlockingNotAllowed(
        strongBiometric: Boolean,
        strongAuthFlags: Int,
        nonStrongBiometricAllowed: Boolean,
        deviceInteractive: Boolean,
        keyguardShowing: Boolean,
        bypass: Boolean
    ) {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                int1 = if (strongBiometric) 1 else 0
                int2 = strongAuthFlags
                bool1 = nonStrongBiometricAllowed
                bool2 = deviceInteractive
                bool3 = keyguardShowing
                bool4 = bypass
            },
            {
                "calculateModeForPassiveAuth unlockingAllowed=false" +
                    " strongBiometric=${int1 == 1}" +
                    " strongAuthFlags=$int2 nonStrongBiometricAllowed=$bool1" +
                    " deviceInteractive=$bool2 isKeyguardShowing=$bool3 bypass=$bool4"
            }
        )
    }
}

private fun wakeAndUnlockModeToString(mode: Int): String {
    return when (mode) {
        MODE_NONE -> "MODE_NONE"
        MODE_WAKE_AND_UNLOCK -> "MODE_WAKE_AND_UNLOCK"
        MODE_WAKE_AND_UNLOCK_PULSING -> "MODE_WAKE_AND_UNLOCK_PULSING"
        MODE_SHOW_BOUNCER -> "MODE_SHOW_BOUNCER"
        MODE_ONLY_WAKE -> "MODE_ONLY_WAKE"
        MODE_UNLOCK_COLLAPSING -> "MODE_UNLOCK_COLLAPSING"
        MODE_WAKE_AND_UNLOCK_FROM_DREAM -> "MODE_WAKE_AND_UNLOCK_FROM_DREAM"
        MODE_DISMISS_BOUNCER -> "MODE_DISMISS_BOUNCER"
        else -> "UNKNOWN{$mode}"
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -161,6 +161,13 @@ class KeyguardUpdateMonitorLogger @Inject constructor(
        }, {"Fingerprint auth successful: userId: $int1, isStrongBiometric: $bool1"})
    }

    fun logFingerprintError(msgId: Int, originalErrMsg: String) {
        logBuffer.log(TAG, DEBUG, {
            str1 = originalErrMsg
            int1 = msgId
        }, { "Fingerprint error received: $str1 msgId= $int1" })
    }

    fun logInvalidSubId(subId: Int) {
        logBuffer.log(TAG, INFO,
                { int1 = subId },
Loading