diff --git a/packages/SystemUI/src/com/android/systemui/log/LogBuffer.kt b/packages/SystemUI/src/com/android/systemui/log/LogBuffer.kt index 492fdc699935a..b15807c0475c1 100644 --- a/packages/SystemUI/src/com/android/systemui/log/LogBuffer.kt +++ b/packages/SystemUI/src/com/android/systemui/log/LogBuffer.kt @@ -66,11 +66,12 @@ import java.util.Locale * @param poolSize The maximum amount that the size of the buffer is allowed to flex in response to * sequential calls to [document] that aren't immediately followed by a matching call to [push]. */ -class LogBuffer( +class LogBuffer @JvmOverloads constructor( private val name: String, private val maxLogs: Int, private val poolSize: Int, - private val logcatEchoTracker: LogcatEchoTracker + private val logcatEchoTracker: LogcatEchoTracker, + private val systrace: Boolean = true ) { init { if (maxLogs < poolSize) { @@ -175,6 +176,10 @@ class LogBuffer( buffer.removeFirst() } buffer.add(message as LogMessageImpl) + if (systrace) { + val messageStr = message.printer(message) + Trace.instantForTrack(Trace.TRACE_TAG_APP, "UI Events", "$name - $messageStr") + } if (logcatEchoTracker.isBufferLoggable(name, message.level) || logcatEchoTracker.isTagLoggable(message.tag, message.level)) { echo(message) @@ -237,7 +242,6 @@ class LogBuffer( LogLevel.ERROR -> Log.e(message.tag, strMessage) LogLevel.WTF -> Log.wtf(message.tag, strMessage) } - Trace.instantForTrack(Trace.TRACE_TAG_APP, "UI Events", strMessage) } } diff --git a/packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt b/packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt index 5296ee603f402..cbfca25e0c603 100644 --- a/packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt +++ b/packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt @@ -36,8 +36,13 @@ class LogBufferFactory @Inject constructor( } @JvmOverloads - fun create(name: String, maxPoolSize: Int, flexSize: Int = 10): LogBuffer { - val buffer = LogBuffer(name, poolLimit(maxPoolSize), flexSize, logcatEchoTracker) + fun create( + name: String, + maxPoolSize: Int, + flexSize: Int = 10, + systrace: Boolean = true + ): LogBuffer { + val buffer = LogBuffer(name, poolLimit(maxPoolSize), flexSize, logcatEchoTracker, systrace) dumpManager.registerBuffer(name, buffer) return buffer } 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 d3bd0a5e31a00..1f953d7ee6c91 100644 --- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java @@ -49,7 +49,8 @@ public class LogModule { @SysUISingleton @NotificationLog public static LogBuffer provideNotificationsLogBuffer(LogBufferFactory factory) { - return factory.create("NotifLog", 1000); + return factory.create("NotifLog", 1000 /* maxPoolSize */, + 10 /* flexSize */, false /* systrace */); } /** Provides a logging buffer for all logs related to the data layer of notifications. */ @@ -65,7 +66,8 @@ public class LogModule { @SysUISingleton @NotificationSectionLog public static LogBuffer provideNotificationSectionLogBuffer(LogBufferFactory factory) { - return factory.create("NotifSectionLog", 1000); + return factory.create("NotifSectionLog", 1000 /* maxPoolSize */, + 10 /* flexSize */, false /* systrace */); } /** Provides a logging buffer for all logs related to the data layer of notifications. */ @@ -81,7 +83,8 @@ public class LogModule { @SysUISingleton @QSLog public static LogBuffer provideQuickSettingsLogBuffer(LogBufferFactory factory) { - return factory.create("QSLog", 500); + return factory.create("QSLog", 500 /* maxPoolSize */, + 10 /* flexSize */, false /* systrace */); } /** Provides a logging buffer for {@link com.android.systemui.broadcast.BroadcastDispatcher} */ @@ -89,7 +92,8 @@ public class LogModule { @SysUISingleton @BroadcastDispatcherLog public static LogBuffer provideBroadcastDispatcherLogBuffer(LogBufferFactory factory) { - return factory.create("BroadcastDispatcherLog", 500); + return factory.create("BroadcastDispatcherLog", 500 /* maxPoolSize */, + 10 /* flexSize */, false /* systrace */); } /** Provides a logging buffer for all logs related to Toasts shown by SystemUI. */ @@ -127,7 +131,8 @@ public class LogModule { @SysUISingleton @QSFragmentDisableLog public static LogBuffer provideQSFragmentDisableLogBuffer(LogBufferFactory factory) { - return factory.create("QSFragmentDisableFlagsLog", 10); + return factory.create("QSFragmentDisableFlagsLog", 10 /* maxPoolSize */, + 10 /* flexSize */, false /* systrace */); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java index 2dbe59e27ea68..bd948eceab9cd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java @@ -28,6 +28,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.os.SystemProperties; +import android.os.Trace; import android.text.format.DateFormat; import android.util.FloatProperty; import android.util.Log; @@ -193,6 +194,7 @@ public class StatusBarStateControllerImpl implements mState = state; mUpcomingState = state; mUiEventLogger.log(StatusBarStateEvent.fromState(mState)); + Trace.instantForTrack(Trace.TRACE_TAG_APP, "UI Events", "StatusBarState " + tag); for (RankedListener rl : new ArrayList<>(mListeners)) { rl.mListener.onStateChanged(mState); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java index 2dfcc98b5037c..c1f63b80dbf80 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerImpl.java @@ -171,6 +171,8 @@ public class KeyguardStateControllerImpl implements KeyguardStateController, Dum if (mShowing == showing && mOccluded == occluded) return; mShowing = showing; mOccluded = occluded; + Trace.instantForTrack(Trace.TRACE_TAG_APP, "UI Events", + "Keyguard showing: " + showing + " occluded: " + occluded); notifyKeyguardChanged(); // Update the dismiss amount to the full 0f/1f if we explicitly show or hide the keyguard.