Loading packages/SystemUI/log/src/com/android/systemui/log/LogBuffer.kt +8 −2 Original line number Diff line number Diff line Loading @@ -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() } Loading Loading @@ -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", ) } Loading @@ -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" Loading packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -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) Loading packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt +5 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -27,7 +28,7 @@ class LogBufferFactory @Inject constructor( private val dumpManager: DumpManager, private val logcatEchoTracker: LogcatEchoTracker private val logcatEchoTracker: LogcatEchoTracker, ) { @JvmOverloads fun create( Loading @@ -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 } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/dagger/NotificationsLogModule.kt +42 −6 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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. */ Loading @@ -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. */ Loading @@ -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. */ Loading @@ -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. */ Loading @@ -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. */ Loading @@ -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. */ Loading Loading @@ -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) } Loading
packages/SystemUI/log/src/com/android/systemui/log/LogBuffer.kt +8 −2 Original line number Diff line number Diff line Loading @@ -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() } Loading Loading @@ -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", ) } Loading @@ -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" Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/base/logging/QSTileLoggerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -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) Loading
packages/SystemUI/src/com/android/systemui/log/LogBufferFactory.kt +5 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -27,7 +28,7 @@ class LogBufferFactory @Inject constructor( private val dumpManager: DumpManager, private val logcatEchoTracker: LogcatEchoTracker private val logcatEchoTracker: LogcatEchoTracker, ) { @JvmOverloads fun create( Loading @@ -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 } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/dagger/NotificationsLogModule.kt +42 −6 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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. */ Loading @@ -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. */ Loading @@ -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. */ Loading @@ -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. */ Loading @@ -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. */ Loading @@ -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. */ Loading Loading @@ -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) }