summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/log/src/com/android/systemui/log/LogBuffer.kt10
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/dagger/NotificationsLogModule.kt48
4 files changed, 56 insertions, 11 deletions
diff --git a/packages/SystemUI/log/src/com/android/systemui/log/LogBuffer.kt b/packages/SystemUI/log/src/com/android/systemui/log/LogBuffer.kt
index 4b5e9de2cce7..72304a19c17d 100644
--- a/packages/SystemUI/log/src/com/android/systemui/log/LogBuffer.kt
+++ b/packages/SystemUI/log/src/com/android/systemui/log/LogBuffer.kt
@@ -75,6 +75,7 @@ constructor(
private val maxSize: Int,
private val logcatEchoTracker: LogcatEchoTracker,
private val systrace: Boolean = true,
+ private val systraceTrackName: String = DEFAULT_LOGBUFFER_TRACK_NAME,
) : MessageBuffer {
private val buffer = RingBuffer(maxSize) { LogMessageImpl.create() }
@@ -244,10 +245,11 @@ constructor(
}
private fun echoToSystrace(level: LogLevel, tag: String, strMessage: String) {
+ if (!Trace.isEnabled()) return
Trace.instantForTrack(
Trace.TRACE_TAG_APP,
- "UI Events",
- "$name - ${level.shortString} $tag: $strMessage"
+ systraceTrackName,
+ "$name - ${level.shortString} $tag: $strMessage",
)
}
@@ -261,6 +263,10 @@ constructor(
LogLevel.WTF -> Log.wtf(message.tag, strMessage, message.exception)
}
}
+
+ companion object {
+ const val DEFAULT_LOGBUFFER_TRACK_NAME = "UI Events"
+ }
}
private const val TAG = "LogBuffer"
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt
index a06353171c33..6a33b5f58820 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt
@@ -54,7 +54,7 @@ class QSTileLoggerTest : SysuiTestCase() {
@Before
fun setup() {
MockitoAnnotations.initMocks(this)
- whenever(logBufferFactory.create(any(), any(), any(), any())).thenReturn(logBuffer)
+ whenever(logBufferFactory.create(any(), any(), any(), any(), any())).thenReturn(logBuffer)
val tileSpec: TileSpec = TileSpec.create("chatty_tile")
underTest =
QSTileLogger(mapOf(tileSpec to chattyLogBuffer), logBufferFactory, statusBarController)
diff --git a/packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt b/packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt
index 6351d7d28d07..c9d6f81dc79c 100644
--- a/packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt
+++ b/packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt
@@ -18,6 +18,7 @@ package com.android.systemui.log
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
+import com.android.systemui.log.LogBuffer.Companion.DEFAULT_LOGBUFFER_TRACK_NAME
import com.android.systemui.log.LogBufferHelper.Companion.adjustMaxSize
import com.android.systemui.log.echo.LogcatEchoTrackerAlways
import javax.inject.Inject
@@ -27,7 +28,7 @@ class LogBufferFactory
@Inject
constructor(
private val dumpManager: DumpManager,
- private val logcatEchoTracker: LogcatEchoTracker
+ private val logcatEchoTracker: LogcatEchoTracker,
) {
@JvmOverloads
fun create(
@@ -35,9 +36,11 @@ constructor(
maxSize: Int,
systrace: Boolean = true,
alwaysLogToLogcat: Boolean = false,
+ systraceTrackName: String = DEFAULT_LOGBUFFER_TRACK_NAME,
): LogBuffer {
val echoTracker = if (alwaysLogToLogcat) LogcatEchoTrackerAlways else logcatEchoTracker
- val buffer = LogBuffer(name, adjustMaxSize(maxSize), echoTracker, systrace)
+ val buffer =
+ LogBuffer(name, adjustMaxSize(maxSize), echoTracker, systrace, systraceTrackName)
dumpManager.registerBuffer(name, buffer)
return buffer
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/dagger/NotificationsLogModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/dagger/NotificationsLogModule.kt
index d3359d39e959..6bcce3e21998 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/dagger/NotificationsLogModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/dagger/NotificationsLogModule.kt
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.notification.logging.dagger
+import com.android.app.tracing.TrackGroupUtils.trackGroup
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogBufferFactory
@@ -44,7 +45,11 @@ object NotificationsLogModule {
@SysUISingleton
@NotificationHeadsUpLog
fun provideNotificationHeadsUpLogBuffer(factory: LogBufferFactory): LogBuffer {
- return factory.create("NotifHeadsUpLog", 1000)
+ return factory.create(
+ "NotifHeadsUpLog",
+ 1000,
+ systraceTrackName = notifPipelineTrack("NotifHeadsUpLog"),
+ )
}
/** Provides a logging buffer for logs related to inflation of notifications. */
@@ -52,7 +57,11 @@ object NotificationsLogModule {
@SysUISingleton
@NotifInflationLog
fun provideNotifInflationLogBuffer(factory: LogBufferFactory): LogBuffer {
- return factory.create("NotifInflationLog", 250)
+ return factory.create(
+ "NotifInflationLog",
+ 250,
+ systraceTrackName = notifPipelineTrack("NotifInflationLog"),
+ )
}
/** Provides a logging buffer for all logs related to the data layer of notifications. */
@@ -60,7 +69,11 @@ object NotificationsLogModule {
@SysUISingleton
@NotifInteractionLog
fun provideNotifInteractionLogBuffer(factory: LogBufferFactory): LogBuffer {
- return factory.create("NotifInteractionLog", 50)
+ return factory.create(
+ "NotifInteractionLog",
+ 50,
+ systraceTrackName = notifPipelineTrack("NotifInteractionLog"),
+ )
}
/** Provides a logging buffer for notification interruption calculations. */
@@ -68,7 +81,11 @@ object NotificationsLogModule {
@SysUISingleton
@NotificationInterruptLog
fun provideNotificationInterruptLogBuffer(factory: LogBufferFactory): LogBuffer {
- return factory.create("NotifInterruptLog", 100)
+ return factory.create(
+ "NotifInterruptLog",
+ 100,
+ systraceTrackName = notifPipelineTrack("NotifInterruptLog"),
+ )
}
/** Provides a logging buffer for all logs related to notifications on the lockscreen. */
@@ -91,7 +108,12 @@ object NotificationsLogModule {
if (Compile.IS_DEBUG && notifPipelineFlags.isDevLoggingEnabled()) {
maxSize *= 10
}
- return factory.create("NotifLog", maxSize, Compile.IS_DEBUG /* systrace */)
+ return factory.create(
+ "NotifLog",
+ maxSize,
+ /* systrace= */ Compile.IS_DEBUG,
+ systraceTrackName = notifPipelineTrack("NotifLog"),
+ )
}
/** Provides a logging buffer for all logs related to remote input controller. */
@@ -107,7 +129,11 @@ object NotificationsLogModule {
@SysUISingleton
@NotificationRenderLog
fun provideNotificationRenderLogBuffer(factory: LogBufferFactory): LogBuffer {
- return factory.create("NotifRenderLog", 100)
+ return factory.create(
+ "NotifRenderLog",
+ 100,
+ systraceTrackName = notifPipelineTrack("NotifRenderLog"),
+ )
}
/** Provides a logging buffer for all logs related to managing notification sections. */
@@ -150,3 +176,13 @@ object NotificationsLogModule {
return factory.create("VisualStabilityLog", 50, /* maxSize */ false /* systrace */)
}
}
+
+private const val NOTIF_PIPELINE_TRACK_GROUP_NAME = "Notification pipeline"
+
+/**
+ * This generates a track name that is hierarcically collapsed inside
+ * [NOTIF_PIPELINE_TRACK_GROUP_NAME] in perfetto traces.
+ */
+private fun notifPipelineTrack(trackName: String): String {
+ return trackGroup(NOTIF_PIPELINE_TRACK_GROUP_NAME, trackName)
+}