Loading packages/SystemUI/src/com/android/systemui/lifecycle/RepeatWhenAttached.kt +16 −10 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.lifecycle import android.os.Trace import android.view.View import android.view.ViewTreeObserver import androidx.annotation.MainThread Loading Loading @@ -73,7 +74,7 @@ fun View.repeatWhenAttached( Dispatchers.Main + createCoroutineTracingContext() + coroutineContext val traceName = if (Compile.IS_DEBUG && coroutineTracing()) { traceSectionName() inferTraceSectionName() } else { DEFAULT_TRACE_NAME } Loading Loading @@ -197,17 +198,22 @@ private fun isFrameInteresting(frame: StackWalker.StackFrame): Boolean = frame.className != CURRENT_CLASS_NAME && frame.className != JAVA_ADAPTER_CLASS_NAME /** Get a name for the trace section include the name of the call site. */ private fun traceSectionName(): String { private fun inferTraceSectionName(): String { try { Trace.traceBegin(Trace.TRACE_TAG_APP, "RepeatWhenAttachedKt#inferTraceSectionName") val interestingFrame = StackWalker.getInstance().walk { stream -> stream.filter(::isFrameInteresting).limit(5).findFirst() } if (interestingFrame.isPresent) { val frame = interestingFrame.get() return "${frame.className}#${frame.methodName}:${frame.lineNumber} [$DEFAULT_TRACE_NAME]" val f = interestingFrame.get() return "${f.className}#${f.methodName}:${f.lineNumber} [$DEFAULT_TRACE_NAME]" } else { return DEFAULT_TRACE_NAME } } finally { Trace.traceEnd(Trace.TRACE_TAG_APP) } } private const val DEFAULT_TRACE_NAME = "repeatWhenAttached" Loading Loading
packages/SystemUI/src/com/android/systemui/lifecycle/RepeatWhenAttached.kt +16 −10 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.lifecycle import android.os.Trace import android.view.View import android.view.ViewTreeObserver import androidx.annotation.MainThread Loading Loading @@ -73,7 +74,7 @@ fun View.repeatWhenAttached( Dispatchers.Main + createCoroutineTracingContext() + coroutineContext val traceName = if (Compile.IS_DEBUG && coroutineTracing()) { traceSectionName() inferTraceSectionName() } else { DEFAULT_TRACE_NAME } Loading Loading @@ -197,17 +198,22 @@ private fun isFrameInteresting(frame: StackWalker.StackFrame): Boolean = frame.className != CURRENT_CLASS_NAME && frame.className != JAVA_ADAPTER_CLASS_NAME /** Get a name for the trace section include the name of the call site. */ private fun traceSectionName(): String { private fun inferTraceSectionName(): String { try { Trace.traceBegin(Trace.TRACE_TAG_APP, "RepeatWhenAttachedKt#inferTraceSectionName") val interestingFrame = StackWalker.getInstance().walk { stream -> stream.filter(::isFrameInteresting).limit(5).findFirst() } if (interestingFrame.isPresent) { val frame = interestingFrame.get() return "${frame.className}#${frame.methodName}:${frame.lineNumber} [$DEFAULT_TRACE_NAME]" val f = interestingFrame.get() return "${f.className}#${f.methodName}:${f.lineNumber} [$DEFAULT_TRACE_NAME]" } else { return DEFAULT_TRACE_NAME } } finally { Trace.traceEnd(Trace.TRACE_TAG_APP) } } private const val DEFAULT_TRACE_NAME = "repeatWhenAttached" Loading