diff options
| author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-12-15 18:48:31 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-12-15 18:48:31 +0000 |
| commit | 8b81ff8dbc9a2644f27f7038f93d65c490c3d30a (patch) | |
| tree | efa7cc92a69b5a9034414a620de6a9a5db0c9645 /core/java/android | |
| parent | d9c2da8152c847a7dd3fd74a0d7b17ecd012b224 (diff) | |
| parent | 6e713ddc1eb6726d77a4564c966ccdfb97e8e636 (diff) | |
Merge "Log UI events to traces" am: a9666fccb9 am: 6e713ddc1e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1920746
Change-Id: Ica852f77a0771b6a44bbaffbe019a634f0dc4622
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/os/Trace.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/core/java/android/os/Trace.java b/core/java/android/os/Trace.java index ddb6533547bb..d974e0c0713a 100644 --- a/core/java/android/os/Trace.java +++ b/core/java/android/os/Trace.java @@ -131,6 +131,10 @@ public final class Trace { private static native void nativeAsyncTraceBegin(long tag, String name, int cookie); @FastNative private static native void nativeAsyncTraceEnd(long tag, String name, int cookie); + @FastNative + private static native void nativeInstant(long tag, String name); + @FastNative + private static native void nativeInstantForTrack(long tag, String trackName, String name); private Trace() { } @@ -258,6 +262,42 @@ public final class Trace { } /** + * Writes a trace message to indicate that a given section of code was invoked. + * + * @param traceTag The trace tag. + * @param methodName The method name to appear in the trace. + * @hide + */ + public static void instant(long traceTag, String methodName) { + if (methodName == null) { + throw new IllegalArgumentException("methodName cannot be null"); + } + if (isTagEnabled(traceTag)) { + nativeInstant(traceTag, methodName); + } + } + + /** + * Writes a trace message to indicate that a given section of code was invoked. + * + * @param traceTag The trace tag. + * @param trackName The track where the event should appear in the trace. + * @param methodName The method name to appear in the trace. + * @hide + */ + public static void instantForTrack(long traceTag, String trackName, String methodName) { + if (trackName == null) { + throw new IllegalArgumentException("trackName cannot be null"); + } + if (methodName == null) { + throw new IllegalArgumentException("methodName cannot be null"); + } + if (isTagEnabled(traceTag)) { + nativeInstantForTrack(traceTag, trackName, methodName); + } + } + + /** * Checks whether or not tracing is currently enabled. This is useful to avoid intermediate * string creation for trace sections that require formatting. It is not necessary * to guard all Trace method calls as they internally already check this. However it is |
