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

Commit 36585c98 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "tracinglib: remove -Xmulti-platform" into main

parents 8cfb03b7 0be4b1e4
Loading
Loading
Loading
Loading
+2 −21
Original line number Diff line number Diff line
@@ -18,38 +18,19 @@ package {

java_library {
    name: "tracinglib-platform",
    defaults: ["tracinglib-defaults"],
    static_libs: [
        "kotlinx_coroutines_android",
        "com_android_systemui_flags_lib",
        "//frameworks/libs/systemui:compilelib",
    ],
    srcs: ["android/src/**/*.kt"],
}

java_test_host {
    name: "tracinglib-host-test",
    defaults: ["tracinglib-defaults"],
    srcs: [
        "host/src-fake/**/*.kt",
        "host/test/**/*.kt",
    ],
    static_libs: [
        "kotlinx_coroutines",
    ],
    libs: [
        "junit",
        "androidx.annotation_annotation",
    ],
}

java_defaults {
    name: "tracinglib-defaults",
    common_srcs: ["common/src/**/*.kt"],
    kotlincflags: [
        "-Xjvm-default=all",
        "-Xmulti-platform",
        "-opt-in=kotlin.ExperimentalStdlibApi",
        "-opt-in=kotlinx.coroutines.DelicateCoroutinesApi",
        "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
    ],
    srcs: ["src/**/*.kt"],
}
+0 −63
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.app.tracing

import android.os.Trace

@PublishedApi
internal actual fun isEnabled(): Boolean {
    return Trace.isEnabled()
}

internal actual fun traceCounter(counterName: String, counterValue: Int) {
    Trace.traceCounter(Trace.TRACE_TAG_APP, counterName, counterValue)
}

internal actual fun traceBegin(methodName: String) {
    Trace.traceBegin(Trace.TRACE_TAG_APP, methodName)
}

internal actual fun traceEnd() {
    Trace.traceEnd(Trace.TRACE_TAG_APP)
}

internal actual fun asyncTraceBegin(methodName: String, cookie: Int) {
    Trace.asyncTraceBegin(Trace.TRACE_TAG_APP, methodName, cookie)
}

internal actual fun asyncTraceEnd(methodName: String, cookie: Int) {
    Trace.asyncTraceEnd(Trace.TRACE_TAG_APP, methodName, cookie)
}

@PublishedApi
internal actual fun asyncTraceForTrackBegin(trackName: String, methodName: String, cookie: Int) {
    Trace.asyncTraceForTrackBegin(Trace.TRACE_TAG_APP, trackName, methodName, cookie)
}

@PublishedApi
internal actual fun asyncTraceForTrackEnd(trackName: String, methodName: String, cookie: Int) {
    Trace.asyncTraceForTrackEnd(Trace.TRACE_TAG_APP, trackName, cookie)
}

internal actual fun instant(eventName: String) {
    Trace.instant(Trace.TRACE_TAG_APP, eventName)
}

@PublishedApi
internal actual fun instantForTrack(trackName: String, eventName: String) {
    Trace.instantForTrack(Trace.TRACE_TAG_APP, trackName, eventName)
}
+0 −62
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.app.tracing

internal expect fun isEnabled(): Boolean

internal expect fun traceCounter(counterName: String, counterValue: Int)

internal expect fun traceBegin(methodName: String)

internal expect fun traceEnd()

internal expect fun asyncTraceBegin(methodName: String, cookie: Int)

internal expect fun asyncTraceEnd(methodName: String, cookie: Int)

internal expect fun asyncTraceForTrackBegin(trackName: String, methodName: String, cookie: Int)

internal expect fun asyncTraceForTrackEnd(trackName: String, methodName: String, cookie: Int)

/**
 * Writes a trace message indicating that an instant event occurred on the current thread. Unlike
 * slices, instant events have no duration and do not need to be matched with another call. Perfetto
 * will display instant events using an arrow pointing to the timestamp they occurred:
 * ```
 * Thread #1 | [==============]               [======]
 *           |     [====]                        ^
 *           |        ^
 * ```
 *
 * @param eventName The name of the event to appear in the trace.
 */
internal expect fun instant(eventName: String)

/**
 * Writes a trace message indicating that an instant event occurred on the given track. Unlike
 * slices, instant events have no duration and do not need to be matched with another call. Perfetto
 * will display instant events using an arrow pointing to the timestamp they occurred:
 * ```
 * Async  | [==============]               [======]
 *  Track |     [====]                        ^
 *   Name |        ^
 * ```
 *
 * @param trackName The track where the event should appear in the trace.
 * @param eventName The name of the event to appear in the trace.
 */
internal expect fun instantForTrack(trackName: String, eventName: String)
+0 −28
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.util

object Compile {
    private var _isDebug = true

    val IS_DEBUG: Boolean
        get() = _isDebug

    fun setIsDebug(isDebug: Boolean) {
        _isDebug = isDebug
    }
}
+0 −34
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.util

@Suppress("UNUSED_PARAMETER")
object Log {
    const val VERBOSE: Int = 2

    fun v(tag: String, msg: String) {}

    fun d(tag: String, msg: String) {}

    fun i(tag: String, msg: String) {}

    fun w(tag: String, msg: String) {}

    fun e(tag: String, msg: String) {}

    fun isLoggable(tag: String, level: Int) = true
}
Loading