Loading aconfig/systemui.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,13 @@ flag { bug: "308482106" } flag { name: "return_animation_framework_library" namespace: "systemui" description: "Turn on Return functionality in the Animation library" bug: "273205603" } flag { name: "shade_allow_back_gesture" namespace: "systemui" Loading tracinglib/Android.bp +26 −5 Original line number Diff line number Diff line Loading @@ -17,14 +17,35 @@ package { } java_library { name: "tracinglib", name: "tracinglib-platform", defaults: ["tracinglib-defaults"], srcs: ["src/platform/kotlin/**/*.kt"], platform_apis: true, } java_library { name: "tracinglib-androidx", defaults: ["tracinglib-defaults"], srcs: ["src/androidx/kotlin/**/*.kt"], sdk_version: "31", min_sdk_version: "19", static_libs: [ "androidx.tracing_tracing", ], } java_defaults { name: "tracinglib-defaults", common_srcs: ["src/common/kotlin/**/*.kt"], static_libs: [ "kotlinx_coroutines_android", "com_android_systemui_flags_lib", ], srcs: [ "src/**/*.kt" kotlincflags: [ "-Xjvm-default=all", "-Xmulti-platform", "-opt-in=kotlin.ExperimentalStdlibApi", "-opt-in=kotlinx.coroutines.DelicateCoroutinesApi", "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", ], kotlincflags: ["-Xjvm-default=all"], platform_apis: true, } tracinglib/src/androidx/kotlin/com/android/app/tracing/TraceProxy.androidx.kt 0 → 100644 +72 −0 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 androidx.tracing.Trace import kotlin.random.Random internal actual fun traceCounter(counterName: String, counterValue: Int) { Trace.setCounter(counterName, counterValue) } internal actual fun traceBegin(methodName: String) { Trace.beginSection(methodName) } internal actual fun traceEnd() { Trace.endSection() } internal actual fun asyncTraceBegin(methodName: String, cookie: Int) { Trace.beginAsyncSection(methodName, cookie) } internal actual fun asyncTraceEnd(methodName: String, cookie: Int) { Trace.endAsyncSection(methodName, cookie) } private fun namedSlice(trackName: String, methodName: String) = "$trackName:$methodName" @PublishedApi internal actual fun asyncTraceForTrackBegin(trackName: String, methodName: String, cookie: Int) { if (isEnabled()) { asyncTraceBegin(namedSlice(trackName, methodName), cookie) } } @PublishedApi internal actual fun asyncTraceForTrackEnd(trackName: String, methodName: String, cookie: Int) { if (isEnabled()) { asyncTraceEnd(namedSlice(trackName, methodName), cookie) } } internal actual fun instant(eventName: String) { if (isEnabled()) { traceBegin("instant:$eventName") traceEnd() } } internal actual fun instantForTrack(trackName: String, eventName: String) { if (Trace.isEnabled()) { val cookie = Random.nextInt() val name = "instant:${namedSlice(trackName,eventName)}" asyncTraceBegin(name, cookie) asyncTraceEnd(name, cookie) } } tracinglib/src/com/android/app/tracing/FlowTracing.kt→tracinglib/src/common/kotlin/com/android/app/tracing/FlowTracing.kt +12 −1 Original line number Diff line number Diff line Loading @@ -25,9 +25,20 @@ object FlowTracing { inline fun <T> Flow<T>.traceEach( flowName: String, logcat: Boolean = false, traceEmissionCount: Boolean = false, crossinline valueToString: (T) -> String = { it.toString() } ): Flow<T> { val stateLogger = TraceStateLogger(flowName, logcat = logcat) return onEach { stateLogger.log(valueToString(it)) } val baseFlow = if (traceEmissionCount) traceEmissionCount(flowName) else this return baseFlow.onEach { stateLogger.log(valueToString(it)) } } fun <T> Flow<T>.traceEmissionCount(flowName: String): Flow<T> { val trackName = "$flowName#emissionCount" var count = 0 return onEach { count += 1 traceCounter(trackName, count) } } } tracinglib/src/com/android/app/tracing/ListenersTracing.kt→tracinglib/src/common/kotlin/com/android/app/tracing/ListenersTracing.kt +0 −0 File moved. View file Loading
aconfig/systemui.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,13 @@ flag { bug: "308482106" } flag { name: "return_animation_framework_library" namespace: "systemui" description: "Turn on Return functionality in the Animation library" bug: "273205603" } flag { name: "shade_allow_back_gesture" namespace: "systemui" Loading
tracinglib/Android.bp +26 −5 Original line number Diff line number Diff line Loading @@ -17,14 +17,35 @@ package { } java_library { name: "tracinglib", name: "tracinglib-platform", defaults: ["tracinglib-defaults"], srcs: ["src/platform/kotlin/**/*.kt"], platform_apis: true, } java_library { name: "tracinglib-androidx", defaults: ["tracinglib-defaults"], srcs: ["src/androidx/kotlin/**/*.kt"], sdk_version: "31", min_sdk_version: "19", static_libs: [ "androidx.tracing_tracing", ], } java_defaults { name: "tracinglib-defaults", common_srcs: ["src/common/kotlin/**/*.kt"], static_libs: [ "kotlinx_coroutines_android", "com_android_systemui_flags_lib", ], srcs: [ "src/**/*.kt" kotlincflags: [ "-Xjvm-default=all", "-Xmulti-platform", "-opt-in=kotlin.ExperimentalStdlibApi", "-opt-in=kotlinx.coroutines.DelicateCoroutinesApi", "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", ], kotlincflags: ["-Xjvm-default=all"], platform_apis: true, }
tracinglib/src/androidx/kotlin/com/android/app/tracing/TraceProxy.androidx.kt 0 → 100644 +72 −0 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 androidx.tracing.Trace import kotlin.random.Random internal actual fun traceCounter(counterName: String, counterValue: Int) { Trace.setCounter(counterName, counterValue) } internal actual fun traceBegin(methodName: String) { Trace.beginSection(methodName) } internal actual fun traceEnd() { Trace.endSection() } internal actual fun asyncTraceBegin(methodName: String, cookie: Int) { Trace.beginAsyncSection(methodName, cookie) } internal actual fun asyncTraceEnd(methodName: String, cookie: Int) { Trace.endAsyncSection(methodName, cookie) } private fun namedSlice(trackName: String, methodName: String) = "$trackName:$methodName" @PublishedApi internal actual fun asyncTraceForTrackBegin(trackName: String, methodName: String, cookie: Int) { if (isEnabled()) { asyncTraceBegin(namedSlice(trackName, methodName), cookie) } } @PublishedApi internal actual fun asyncTraceForTrackEnd(trackName: String, methodName: String, cookie: Int) { if (isEnabled()) { asyncTraceEnd(namedSlice(trackName, methodName), cookie) } } internal actual fun instant(eventName: String) { if (isEnabled()) { traceBegin("instant:$eventName") traceEnd() } } internal actual fun instantForTrack(trackName: String, eventName: String) { if (Trace.isEnabled()) { val cookie = Random.nextInt() val name = "instant:${namedSlice(trackName,eventName)}" asyncTraceBegin(name, cookie) asyncTraceEnd(name, cookie) } }
tracinglib/src/com/android/app/tracing/FlowTracing.kt→tracinglib/src/common/kotlin/com/android/app/tracing/FlowTracing.kt +12 −1 Original line number Diff line number Diff line Loading @@ -25,9 +25,20 @@ object FlowTracing { inline fun <T> Flow<T>.traceEach( flowName: String, logcat: Boolean = false, traceEmissionCount: Boolean = false, crossinline valueToString: (T) -> String = { it.toString() } ): Flow<T> { val stateLogger = TraceStateLogger(flowName, logcat = logcat) return onEach { stateLogger.log(valueToString(it)) } val baseFlow = if (traceEmissionCount) traceEmissionCount(flowName) else this return baseFlow.onEach { stateLogger.log(valueToString(it)) } } fun <T> Flow<T>.traceEmissionCount(flowName: String): Flow<T> { val trackName = "$flowName#emissionCount" var count = 0 return onEach { count += 1 traceCounter(trackName, count) } } }
tracinglib/src/com/android/app/tracing/ListenersTracing.kt→tracinglib/src/common/kotlin/com/android/app/tracing/ListenersTracing.kt +0 −0 File moved. View file