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

Commit 5a9585f0 authored by Peter Kalauskas's avatar Peter Kalauskas Committed by Android (Google) Code Review
Browse files

Merge "tracinglib: fix build warnings" into main

parents 1fe65fb9 d86adf77
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ internal class TraceData(
     */
    internal fun endAllOnThread() {
        strictModeCheck()
        repeat(openSliceCount.get()) { endSlice() }
        repeat(openSliceCount.get() ?: 0) { endSlice() }
        openSliceCount.set(0)
    }

+6 −4
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ const val DEBUG = false

/** Log a message with a tag indicating the current thread ID */
private fun debug(message: String) {
    if (DEBUG) println("Thread #${Thread.currentThread().id}: $message")
    if (DEBUG) println("Thread #${currentThreadId()}: $message")
}

private var isTracingEnabled = true
@@ -47,7 +47,7 @@ object FakeTraceState {
    private val allThreadStates = hashMapOf<Long, MutableList<String>>()

    fun begin(sectionName: String) {
        val threadId = Thread.currentThread().id
        val threadId = currentThreadId()
        synchronized(allThreadStates) {
            if (allThreadStates.containsKey(threadId)) {
                allThreadStates[threadId]!!.add(sectionName)
@@ -58,7 +58,7 @@ object FakeTraceState {
    }

    fun end() {
        val threadId = Thread.currentThread().id
        val threadId = currentThreadId()
        synchronized(allThreadStates) {
            assertFalse(
                "Attempting to close trace section on thread=$threadId, " +
@@ -71,7 +71,7 @@ object FakeTraceState {
    }

    fun getOpenTraceSectionsOnCurrentThread(): Array<String> {
        val threadId = Thread.currentThread().id
        val threadId = currentThreadId()
        synchronized(allThreadStates) {
            return allThreadStates[threadId]?.toTypedArray() ?: emptyArray()
        }
@@ -129,3 +129,5 @@ internal actual fun instant(eventName: String) {
internal actual fun instantForTrack(trackName: String, eventName: String) {
    debug("instantForTrack: track=$trackName name=$eventName")
}

private fun currentThreadId(): Long = Thread.currentThread().threadId()
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ class ExampleClass(
    private val incrementCounter: suspend () -> Unit,
) {
    suspend fun classMethod(value: Int) {
        value.inc() // <-- suppress warning that parameter 'value' is unused
        testBase.expect(
            "launch-for-collect",
            "com.android.app.tracing.coroutines.FlowTracingTest\$stateFlowCollection$1\$collectJob$1$3:collect",