From 75d2df1d16b16c15711995e37b92a5b104afbe6b Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Fri, 30 Sep 2022 17:48:31 +0100 Subject: [PATCH] Adding general KeyguardLogger and more logs to keyguard status bar Extra logs to help with solving b/237743330. The logs will be removed after the bug is fixed, probably except dump section. Adding extra info in bugreports using newly added KeyguardLogger and dumping more info to dumpsys. Bug: 237743330 Test: generating bug report and checking more logs present Change-Id: I37f3c53477f003d8a350f7bd9905f32e8de53d6f Merged-In: I37f3c53477f003d8a350f7bd9905f32e8de53d6f --- .../keyguard/logging/KeyguardLogger.kt | 74 +++++++++++++++++++ .../logging/KeyguardUpdateMonitorLogger.kt | 2 +- .../systemui/log/dagger/KeyguardLog.kt | 10 +++ .../systemui/log/dagger/LogModule.java | 10 +++ .../NotificationPanelViewController.java | 2 + .../KeyguardStatusBarViewController.java | 21 +++++- .../KeyguardStatusBarViewControllerTest.java | 5 +- 7 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 packages/SystemUI/src/com/android/keyguard/logging/KeyguardLogger.kt create mode 100644 packages/SystemUI/src/com/android/systemui/log/dagger/KeyguardLog.kt diff --git a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardLogger.kt new file mode 100644 index 0000000000000..50012a589b5ad --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardLogger.kt @@ -0,0 +1,74 @@ +/* + * 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.log.LogBuffer +import com.android.systemui.log.LogLevel +import com.android.systemui.log.LogLevel.DEBUG +import com.android.systemui.log.LogLevel.ERROR +import com.android.systemui.log.LogLevel.VERBOSE +import com.android.systemui.log.LogLevel.WARNING +import com.android.systemui.log.MessageInitializer +import com.android.systemui.log.MessagePrinter +import com.android.systemui.log.dagger.KeyguardLog +import com.google.errorprone.annotations.CompileTimeConstant +import javax.inject.Inject + +private const val TAG = "KeyguardLog" + +/** + * Generic logger for keyguard that's wrapping [LogBuffer]. This class should be used for adding + * temporary logs or logs for smaller classes when creating whole new [LogBuffer] wrapper might be + * an overkill. + */ +class KeyguardLogger @Inject constructor(@KeyguardLog private val buffer: LogBuffer) { + fun d(@CompileTimeConstant msg: String) = log(msg, DEBUG) + + fun e(@CompileTimeConstant msg: String) = log(msg, ERROR) + + fun v(@CompileTimeConstant msg: String) = log(msg, VERBOSE) + + fun w(@CompileTimeConstant msg: String) = log(msg, WARNING) + + fun log(msg: String, level: LogLevel) = buffer.log(TAG, level, msg) + + private fun debugLog(messageInitializer: MessageInitializer, messagePrinter: MessagePrinter) { + buffer.log(TAG, DEBUG, messageInitializer, messagePrinter) + } + + // TODO: remove after b/237743330 is fixed + fun logStatusBarCalculatedAlpha(alpha: Float) { + debugLog({ 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" }) + } + + // TODO: remove after b/237743330 is fixed + fun logStatusBarAlphaVisibility(visibility: Int, alpha: Float, state: String) { + debugLog( + { + int1 = visibility + double1 = alpha.toDouble() + str1 = state + }, + { "changing visibility to $int1 with alpha $double1 in state: $str1" } + ) + } +} diff --git a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt index 7a00cd930f2a3..bf9f4c88bde34 100644 --- a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt +++ b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt @@ -45,7 +45,7 @@ class KeyguardUpdateMonitorLogger @Inject constructor( fun e(@CompileTimeConstant msg: String) = log(msg, ERROR) - fun v(@CompileTimeConstant msg: String) = log(msg, ERROR) + fun v(@CompileTimeConstant msg: String) = log(msg, VERBOSE) fun w(@CompileTimeConstant msg: String) = log(msg, WARNING) diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/KeyguardLog.kt b/packages/SystemUI/src/com/android/systemui/log/dagger/KeyguardLog.kt new file mode 100644 index 0000000000000..aef3471ea8adc --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/log/dagger/KeyguardLog.kt @@ -0,0 +1,10 @@ +package com.android.systemui.log.dagger + +import javax.inject.Qualifier + +/** + * A [com.android.systemui.log.LogBuffer] for keyguard-related stuff. Should be used mostly for + * adding temporary logs or logging from smaller classes when creating new separate log class might + * be an overkill. + */ +@Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class KeyguardLog diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java index 29e2c1cd89003..91475715ab7b2 100644 --- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java @@ -334,4 +334,14 @@ public class LogModule { public static LogBuffer providerBluetoothLogBuffer(LogBufferFactory factory) { return factory.create("BluetoothLog", 50); } + + /** + * Provides a {@link LogBuffer} for general keyguard-related logs. + */ + @Provides + @SysUISingleton + @KeyguardLog + public static LogBuffer provideKeyguardLogBuffer(LogBufferFactory factory) { + return factory.create("KeyguardLog", 250); + } } diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index d7e86b6e29195..08e39934f32c4 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -4684,6 +4684,8 @@ public final class NotificationPanelViewController extends PanelViewController { if (!animatingUnlockedShadeToKeyguard) { // Only make the status bar visible if we're not animating the screen off, since // we only want to be showing the clock/notifications during the animation. + mShadeLog.v("Updating keyguard status bar state to " + + (keyguardShowing ? "visible" : "invisible")); mKeyguardStatusBarViewController.updateViewState( /* alpha= */ 1f, keyguardShowing ? View.VISIBLE : View.INVISIBLE); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java index ce2c9c2446962..82ee8118f314a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java @@ -40,6 +40,7 @@ import androidx.annotation.VisibleForTesting; import com.android.keyguard.CarrierTextController; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; +import com.android.keyguard.logging.KeyguardLogger; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; import com.android.systemui.battery.BatteryMeterViewController; @@ -116,6 +117,7 @@ public class KeyguardStatusBarViewController extends ViewController