diff options
3 files changed, 54 insertions, 33 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardLogger.kt index 32ce537ea25a..9e58500c7206 100644 --- a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardLogger.kt +++ b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardLogger.kt @@ -18,14 +18,11 @@ package com.android.keyguard.logging import com.android.systemui.log.dagger.KeyguardLog 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.ERROR import com.android.systemui.plugins.log.LogLevel.INFO import com.android.systemui.plugins.log.LogLevel.VERBOSE import com.android.systemui.plugins.log.LogLevel.WARNING -import com.android.systemui.plugins.log.MessageInitializer -import com.android.systemui.plugins.log.MessagePrinter import com.google.errorprone.annotations.CompileTimeConstant import javax.inject.Inject @@ -37,18 +34,16 @@ private const val TAG = "KeyguardLog" * an overkill. */ class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuffer) { - fun d(@CompileTimeConstant msg: String) = log(msg, DEBUG) + fun d(@CompileTimeConstant msg: String) = buffer.log(TAG, DEBUG, msg) - fun e(@CompileTimeConstant msg: String) = log(msg, ERROR) + fun e(@CompileTimeConstant msg: String) = buffer.log(TAG, ERROR, msg) - fun v(@CompileTimeConstant msg: String) = log(msg, VERBOSE) + fun v(@CompileTimeConstant msg: String) = buffer.log(TAG, VERBOSE, msg) - fun w(@CompileTimeConstant msg: String) = log(msg, WARNING) + fun w(@CompileTimeConstant msg: String) = buffer.log(TAG, WARNING, msg) - fun log(msg: String, level: LogLevel) = buffer.log(TAG, level, msg) - - private fun debugLog(messageInitializer: MessageInitializer, messagePrinter: MessagePrinter) { - buffer.log(TAG, DEBUG, messageInitializer, messagePrinter) + fun logException(ex: Exception, @CompileTimeConstant logMsg: String) { + buffer.log(TAG, ERROR, {}, { logMsg }, exception = ex) } fun v(msg: String, arg: Any) { @@ -61,17 +56,24 @@ class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuf // TODO: remove after b/237743330 is fixed fun logStatusBarCalculatedAlpha(alpha: Float) { - debugLog({ double1 = alpha.toDouble() }, { "Calculated new alpha: $double1" }) + buffer.log(TAG, DEBUG, { double1 = alpha.toDouble() }, { "Calculated new alpha: $double1" }) } // TODO: remove after b/237743330 is fixed fun logStatusBarExplicitAlpha(alpha: Float) { - debugLog({ double1 = alpha.toDouble() }, { "new mExplicitAlpha value: $double1" }) + buffer.log( + TAG, + DEBUG, + { double1 = alpha.toDouble() }, + { "new mExplicitAlpha value: $double1" } + ) } // TODO: remove after b/237743330 is fixed fun logStatusBarAlphaVisibility(visibility: Int, alpha: Float, state: String) { - debugLog( + buffer.log( + TAG, + DEBUG, { int1 = visibility double1 = alpha.toDouble() @@ -80,4 +82,22 @@ class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuf { "changing visibility to $int1 with alpha $double1 in state: $str1" } ) } + + @JvmOverloads + fun logBiometricMessage( + @CompileTimeConstant context: String, + msgId: Int? = null, + msg: String? = null + ) { + buffer.log( + TAG, + DEBUG, + { + str1 = context + str2 = "$msgId" + str3 = msg + }, + { "$str1 msgId: $str2 msg: $str3" } + ) + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 15f4b12ba10e..2101efb61443 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -55,7 +55,6 @@ import android.hardware.biometrics.BiometricSourceType; import android.hardware.face.FaceManager; import android.hardware.fingerprint.FingerprintManager; import android.os.BatteryManager; -import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -64,7 +63,6 @@ import android.os.UserHandle; import android.os.UserManager; import android.text.TextUtils; import android.text.format.Formatter; -import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityManager; @@ -76,6 +74,7 @@ import com.android.internal.app.IBatteryStats; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; +import com.android.keyguard.logging.KeyguardLogger; import com.android.settingslib.Utils; import com.android.settingslib.fuelgauge.BatteryStatus; import com.android.systemui.R; @@ -123,7 +122,6 @@ public class KeyguardIndicationController { private static final String TAG = "KeyguardIndication"; private static final boolean DEBUG_CHARGING_SPEED = false; - private static final boolean DEBUG = Build.IS_DEBUGGABLE; private static final int MSG_HIDE_TRANSIENT = 1; private static final int MSG_SHOW_ACTION_TO_UNLOCK = 2; @@ -139,6 +137,7 @@ public class KeyguardIndicationController { protected final StatusBarStateController mStatusBarStateController; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final AuthController mAuthController; + private final KeyguardLogger mKeyguardLogger; private ViewGroup mIndicationArea; private KeyguardIndicationTextView mTopIndicationView; private KeyguardIndicationTextView mLockScreenIndicationView; @@ -229,7 +228,8 @@ public class KeyguardIndicationController { ScreenLifecycle screenLifecycle, KeyguardBypassController keyguardBypassController, AccessibilityManager accessibilityManager, - FaceHelpMessageDeferral faceHelpMessageDeferral) { + FaceHelpMessageDeferral faceHelpMessageDeferral, + KeyguardLogger keyguardLogger) { mContext = context; mBroadcastDispatcher = broadcastDispatcher; mDevicePolicyManager = devicePolicyManager; @@ -249,6 +249,7 @@ public class KeyguardIndicationController { mKeyguardBypassController = keyguardBypassController; mAccessibilityManager = accessibilityManager; mScreenLifecycle = screenLifecycle; + mKeyguardLogger = keyguardLogger; mScreenLifecycle.addObserver(mScreenObserver); mFaceAcquiredMessageDeferral = faceHelpMessageDeferral; @@ -1024,7 +1025,7 @@ public class KeyguardIndicationController { mChargingTimeRemaining = mPowerPluggedIn ? mBatteryInfo.computeChargeTimeRemaining() : -1; } catch (RemoteException e) { - Log.e(TAG, "Error calling IBatteryStats: ", e); + mKeyguardLogger.logException(e, "Error calling IBatteryStats"); mChargingTimeRemaining = -1; } updateDeviceEntryIndication(!wasPluggedIn && mPowerPluggedInWired); @@ -1072,8 +1073,10 @@ public class KeyguardIndicationController { final boolean isCoExFaceAcquisitionMessage = faceAuthSoftError && isUnlockWithFingerprintPossible; if (isCoExFaceAcquisitionMessage && !mCoExFaceAcquisitionMsgIdsToShow.contains(msgId)) { - debugLog("skip showing msgId=" + msgId + " helpString=" + helpString - + ", due to co-ex logic"); + mKeyguardLogger.logBiometricMessage( + "skipped showing help message due to co-ex logic", + msgId, + helpString); } else if (mStatusBarKeyguardViewManager.isBouncerShowing()) { mStatusBarKeyguardViewManager.setKeyguardMessage(helpString, mInitialTextColorState); @@ -1131,7 +1134,7 @@ public class KeyguardIndicationController { CharSequence deferredFaceMessage = mFaceAcquiredMessageDeferral.getDeferredMessage(); mFaceAcquiredMessageDeferral.reset(); if (shouldSuppressFaceError(msgId, mKeyguardUpdateMonitor)) { - debugLog("suppressingFaceError msgId=" + msgId + " errString= " + errString); + mKeyguardLogger.logBiometricMessage("suppressingFaceError", msgId, errString); return; } if (msgId == FaceManager.FACE_ERROR_TIMEOUT) { @@ -1145,8 +1148,9 @@ public class KeyguardIndicationController { private void onFingerprintAuthError(int msgId, String errString) { if (shouldSuppressFingerprintError(msgId, mKeyguardUpdateMonitor)) { - debugLog("suppressingFingerprintError msgId=" + msgId - + " errString= " + errString); + mKeyguardLogger.logBiometricMessage("suppressingFingerprintError", + msgId, + errString); } else { showErrorMessageNowOrLater(errString, null); } @@ -1282,7 +1286,8 @@ public class KeyguardIndicationController { } private void handleFaceAuthTimeoutError(@Nullable CharSequence deferredFaceMessage) { - debugLog("showDeferredFaceMessage msgId=" + deferredFaceMessage); + mKeyguardLogger.logBiometricMessage("deferred message after face auth timeout", + null, String.valueOf(deferredFaceMessage)); if (canUnlockWithFingerprint()) { // Co-ex: show deferred message OR nothing // if we're on the lock screen (bouncer isn't showing), show the deferred msg @@ -1294,7 +1299,8 @@ public class KeyguardIndicationController { ); } else { // otherwise, don't show any message - debugLog("skip showing FACE_ERROR_TIMEOUT due to co-ex logic"); + mKeyguardLogger.logBiometricMessage( + "skip showing FACE_ERROR_TIMEOUT due to co-ex logic"); } } else if (deferredFaceMessage != null) { // Face-only: The face timeout message is not very actionable, let's ask the @@ -1315,12 +1321,6 @@ public class KeyguardIndicationController { KeyguardUpdateMonitor.getCurrentUser()); } - private void debugLog(String logMsg) { - if (DEBUG) { - Log.d(TAG, logMsg); - } - } - private void showErrorMessageNowOrLater(String errString, @Nullable String followUpMsg) { if (mStatusBarKeyguardViewManager.isBouncerShowing()) { mStatusBarKeyguardViewManager.setKeyguardMessage(errString, mInitialTextColorState); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java index 1598dbb7d29e..2487cafe0d90 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java @@ -87,6 +87,7 @@ import com.android.internal.app.IBatteryStats; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; +import com.android.keyguard.logging.KeyguardLogger; import com.android.settingslib.fuelgauge.BatteryStatus; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; @@ -271,7 +272,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { mUserManager, mExecutor, mExecutor, mFalsingManager, mAuthController, mLockPatternUtils, mScreenLifecycle, mKeyguardBypassController, mAccessibilityManager, - mFaceHelpMessageDeferral); + mFaceHelpMessageDeferral, mock(KeyguardLogger.class)); mController.init(); mController.setIndicationArea(mIndicationArea); verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture()); |