From 492d4441b479946a8570dd62fba9623fad0ee207 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Tue, 17 Jan 2023 15:26:37 -0800 Subject: [PATCH] Add trace sections for LogcatEchoTrackerDebug IContentProvider calls are causing jank in NOTIFICATION_ADD. To debug the issue, we need more trace sections to find the root cause. Bug: 261706477 Test: Capture trace, search for new trace sections Change-Id: I39ad5b9a436e1dea429e2b8e26977413b5d047bd --- .../plugins/log/LogcatEchoTrackerDebug.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/log/LogcatEchoTrackerDebug.kt b/packages/SystemUI/plugin/src/com/android/systemui/plugins/log/LogcatEchoTrackerDebug.kt index d3fabaccb6d35..faf1b78c598db 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/log/LogcatEchoTrackerDebug.kt +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/log/LogcatEchoTrackerDebug.kt @@ -21,6 +21,7 @@ import android.database.ContentObserver import android.net.Uri import android.os.Handler import android.os.Looper +import android.os.Trace import android.provider.Settings /** @@ -51,14 +52,21 @@ class LogcatEchoTrackerDebug private constructor(private val contentResolver: Co } } + private fun clearCache() { + Trace.beginSection("LogcatEchoTrackerDebug#clearCache") + cachedBufferLevels.clear() + Trace.endSection() + } + private fun attach(mainLooper: Looper) { + Trace.beginSection("LogcatEchoTrackerDebug#attach") contentResolver.registerContentObserver( Settings.Global.getUriFor(BUFFER_PATH), true, object : ContentObserver(Handler(mainLooper)) { override fun onChange(selfChange: Boolean, uri: Uri?) { super.onChange(selfChange, uri) - cachedBufferLevels.clear() + clearCache() } } ) @@ -69,10 +77,11 @@ class LogcatEchoTrackerDebug private constructor(private val contentResolver: Co object : ContentObserver(Handler(mainLooper)) { override fun onChange(selfChange: Boolean, uri: Uri?) { super.onChange(selfChange, uri) - cachedTagLevels.clear() + clearCache() } } ) + Trace.endSection() } /** Whether [bufferName] should echo messages of [level] or higher to logcat. */ @@ -97,9 +106,12 @@ class LogcatEchoTrackerDebug private constructor(private val contentResolver: Co private fun readSetting(path: String): LogLevel { return try { + Trace.beginSection("LogcatEchoTrackerDebug#readSetting") parseProp(Settings.Global.getString(contentResolver, path)) } catch (_: Settings.SettingNotFoundException) { DEFAULT_LEVEL + } finally { + Trace.endSection() } }