summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ben Murdoch <benm@google.com> 2024-08-08 16:24:14 +0000
committer Ben Murdoch <benm@google.com> 2024-08-08 16:30:23 +0000
commit6a2489cfe8ea330f3155bd576fb95b00b07d4e5f (patch)
tree50ea20429629d9f7c63dd3a76dd7ec80af2be8aa
parenta99107543b378b1d7a14555a7dd5ca1d9db4001e (diff)
Add a hidden API to set trace tag on atrace counters.
Currently the only counter API on trace uses the APP tag. Add a new (hidden) API that will allow the system to set counters with different tags. Bug: 358369221 Flag: EXEMPT - adding hidden API only with no usage yet Test: Try to add a counter with TRACE_TAG_WINDOW_MANAGER and check trace Change-Id: I874d60998a26b7a80ac93b0a5e70ffddcaa9197c
-rw-r--r--core/java/android/os/Trace.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/core/java/android/os/Trace.java b/core/java/android/os/Trace.java
index edb3a641f107..4a37e0a70443 100644
--- a/core/java/android/os/Trace.java
+++ b/core/java/android/os/Trace.java
@@ -520,8 +520,20 @@ public final class Trace {
* @param counterValue The counter value.
*/
public static void setCounter(@NonNull String counterName, long counterValue) {
- if (isTagEnabled(TRACE_TAG_APP)) {
- nativeTraceCounter(TRACE_TAG_APP, counterName, counterValue);
+ setCounter(TRACE_TAG_APP, counterName, counterValue);
+ }
+
+ /**
+ * Writes trace message to indicate the value of a given counter under a given trace tag.
+ *
+ * @param traceTag The trace tag.
+ * @param counterName The counter name to appear in the trace.
+ * @param counterValue The counter value.
+ * @hide
+ */
+ public static void setCounter(long traceTag, @NonNull String counterName, long counterValue) {
+ if (isTagEnabled(traceTag)) {
+ nativeTraceCounter(traceTag, counterName, counterValue);
}
}