Fix check for whether a trace tag is enabled

With the introduction of libperfetto_tracing, we need to check both
perfetto track_events and atrace categories to determine if a trace
tag is enabled. Perfetto SDK doesn't expose a list (or bitmask) of
all enabled categories, but we can check if a specific category is
enabled.

Rewrote the internal impl for Trace#isTagEnabled to pass the tag into
native and return a boolean instead of getting all the enabled tags
from native and checking in Java.

Test: atest libtracing_perfetto_tests
Bug: 303199244
Change-Id: I175deb4d03fef486e4a2d571c8a8f1fbde220f36
diff --git a/libs/tracing_perfetto/include/tracing_perfetto.h b/libs/tracing_perfetto/include/tracing_perfetto.h
index 4e3c83f..2c1c2a4 100644
--- a/libs/tracing_perfetto/include/tracing_perfetto.h
+++ b/libs/tracing_perfetto/include/tracing_perfetto.h
@@ -46,7 +46,7 @@
 
 Result traceCounter(uint64_t category, const char* name, int64_t value);
 
-uint64_t getEnabledCategories();
+bool isTagEnabled(uint64_t category);
 
 }  // namespace tracing_perfetto
 
diff --git a/libs/tracing_perfetto/tracing_perfetto.cpp b/libs/tracing_perfetto/tracing_perfetto.cpp
index 19d1eb6..6f716ee 100644
--- a/libs/tracing_perfetto/tracing_perfetto.cpp
+++ b/libs/tracing_perfetto/tracing_perfetto.cpp
@@ -130,12 +130,13 @@
   }
 }
 
-uint64_t getEnabledCategories() {
-  if (internal::isPerfettoRegistered()) {
-    // TODO(b/303199244): Return only enabled categories and not all registered ones
-    return internal::getDefaultCategories();
+bool isTagEnabled(uint64_t category) {
+  struct PerfettoTeCategory* perfettoTeCategory =
+      internal::toPerfettoCategory(category);
+  if (perfettoTeCategory != nullptr) {
+    return true;
   } else {
-    return atrace_get_enabled_tags();
+    return (atrace_get_enabled_tags() & category) != 0;
   }
 }