Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 180f25bf authored by Peter Kalauskas's avatar Peter Kalauskas Committed by Automerger Merge Worker
Browse files

Merge "Add androidx.tracing to sysui" into udc-dev am: f7d25db9 am: 6cd9a0aa

parents 6ea20c98 6cd9a0aa
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -173,6 +173,7 @@ android_library {
        "androidx.palette_palette",
        "androidx.palette_palette",
        "androidx.legacy_legacy-preference-v14",
        "androidx.legacy_legacy-preference-v14",
        "androidx.leanback_leanback",
        "androidx.leanback_leanback",
        "androidx.tracing_tracing",
        "androidx.slice_slice-core",
        "androidx.slice_slice-core",
        "androidx.slice_slice-view",
        "androidx.slice_slice-view",
        "androidx.slice_slice-builders",
        "androidx.slice_slice-builders",
+12 −8
Original line number Original line Diff line number Diff line
@@ -16,20 +16,22 @@


package com.android.systemui.util
package com.android.systemui.util


import android.os.Trace
import android.os.Handler
import android.os.TraceNameSupplier
import android.os.TraceNameSupplier
import androidx.tracing.Trace


/**
/**
 * Run a block within a [Trace] section.
 * Run a block within a [Trace] section. Calls [Trace.beginSection] before and [Trace.endSection]
 * Calls [Trace.beginSection] before and [Trace.endSection] after the passed block.
 * after the passed block. If tracing is disabled, it will run the block directly to avoid using an
 * unnecessary try-finally block.
 */
 */
inline fun <T> traceSection(tag: String, block: () -> T): T =
inline fun <T> traceSection(tag: String, block: () -> T): T =
        if (Trace.isTagEnabled(Trace.TRACE_TAG_APP)) {
        if (Trace.isEnabled()) {
            Trace.traceBegin(Trace.TRACE_TAG_APP, tag)
            Trace.beginSection(tag)
            try {
            try {
                block()
                block()
            } finally {
            } finally {
                Trace.traceEnd(Trace.TRACE_TAG_APP)
                Trace.endSection()
            }
            }
        } else {
        } else {
            block()
            block()
@@ -42,8 +44,10 @@ class TraceUtils {
        }
        }


        /**
        /**
         * Helper function for creating a Runnable object that implements TraceNameSupplier.
         * Helper function for creating a [Runnable] that implements [TraceNameSupplier]. This is
         * This is useful for posting Runnables to Handlers with meaningful names.
         * useful when posting to a [Handler] so that the [Runnable] has a meaningful name in the
         * trace. Otherwise, the class name of the [Runnable] is used, which is often something like
         * `pkg.MyClass$$ExternalSyntheticLambda0`.
         */
         */
        inline fun namedRunnable(tag: String, crossinline block: () -> Unit): Runnable {
        inline fun namedRunnable(tag: String, crossinline block: () -> Unit): Runnable {
            return object : Runnable, TraceNameSupplier {
            return object : Runnable, TraceNameSupplier {