traceconv: support winscope extensions

Change-Id: I061318d15a9bdbb15ea15530c3e4a26c9c9241e8
diff --git a/Android.bp b/Android.bp
index 381e654..2b9fcc5 100644
--- a/Android.bp
+++ b/Android.bp
@@ -13653,6 +13653,21 @@
     ],
 }
 
+// GN: //src/traceconv:gen_cc_winscope_descriptor
+genrule {
+    name: "perfetto_src_traceconv_gen_cc_winscope_descriptor",
+    srcs: [
+        ":perfetto_protos_perfetto_trace_android_winscope_descriptor",
+    ],
+    cmd: "$(location tools/gen_cc_proto_descriptor.py) --gen_dir=$(genDir) --cpp_out=$(out) $(in)",
+    out: [
+        "src/traceconv/winscope.descriptor.h",
+    ],
+    tool_files: [
+        "tools/gen_cc_proto_descriptor.py",
+    ],
+}
+
 // GN: //src/traceconv:lib
 filegroup {
     name: "perfetto_src_traceconv_lib",
@@ -15396,6 +15411,7 @@
         "perfetto_src_trace_processor_tables_py_tables_unittest",
         "perfetto_src_trace_processor_tables_tables_python",
         "perfetto_src_traceconv_gen_cc_trace_descriptor",
+        "perfetto_src_traceconv_gen_cc_winscope_descriptor",
         "perfetto_src_traced_probes_ftrace_test_messages_cpp_gen_headers",
         "perfetto_src_traced_probes_ftrace_test_messages_lite_gen_headers",
         "perfetto_src_traced_probes_ftrace_test_messages_zero_gen_headers",
@@ -16613,6 +16629,7 @@
         "perfetto_src_trace_processor_perfetto_sql_stdlib_stdlib",
         "perfetto_src_trace_processor_tables_tables_python",
         "perfetto_src_traceconv_gen_cc_trace_descriptor",
+        "perfetto_src_traceconv_gen_cc_winscope_descriptor",
     ],
     defaults: [
         "perfetto_defaults",
diff --git a/BUILD b/BUILD
index b51ba69..c55ec4f 100644
--- a/BUILD
+++ b/BUILD
@@ -3212,6 +3212,17 @@
     ],
 )
 
+# GN target: //src/traceconv:gen_cc_winscope_descriptor
+perfetto_cc_proto_descriptor(
+    name = "src_traceconv_gen_cc_winscope_descriptor",
+    deps = [
+        ":protos_perfetto_trace_android_winscope_descriptor",
+    ],
+    outs = [
+        "src/traceconv/winscope.descriptor.h",
+    ],
+)
+
 # GN target: //src/traceconv:lib
 perfetto_filegroup(
     name = "src_traceconv_lib",
@@ -6566,6 +6577,7 @@
                ":src_trace_processor_perfetto_sql_prelude_prelude",
                ":src_trace_processor_perfetto_sql_stdlib_stdlib",
                ":src_traceconv_gen_cc_trace_descriptor",
+               ":src_traceconv_gen_cc_winscope_descriptor",
            ] + PERFETTO_CONFIG.deps.jsoncpp +
            PERFETTO_CONFIG.deps.sqlite +
            PERFETTO_CONFIG.deps.sqlite_ext_percentile +
diff --git a/src/traceconv/BUILD.gn b/src/traceconv/BUILD.gn
index b578ff6..dc143f3 100644
--- a/src/traceconv/BUILD.gn
+++ b/src/traceconv/BUILD.gn
@@ -75,6 +75,7 @@
 source_set("lib") {
   deps = [
     ":gen_cc_trace_descriptor",
+    ":gen_cc_winscope_descriptor",
     ":pprofbuilder",
     ":utils",
     "../../gn:default_deps",
@@ -141,6 +142,11 @@
   descriptor_target = "../../protos/perfetto/trace:descriptor"
 }
 
+perfetto_cc_proto_descriptor("gen_cc_winscope_descriptor") {
+  descriptor_name = "winscope.descriptor"
+  descriptor_target = "../../protos/perfetto/trace/android:winscope_descriptor"
+}
+
 perfetto_unittest_source_set("unittests") {
   testonly = true
   deps = [
diff --git a/src/traceconv/trace_to_text.cc b/src/traceconv/trace_to_text.cc
index 3fc82fe..80c550d 100644
--- a/src/traceconv/trace_to_text.cc
+++ b/src/traceconv/trace_to_text.cc
@@ -21,6 +21,7 @@
 #include "perfetto/ext/base/scoped_file.h"
 #include "perfetto/ext/protozero/proto_ring_buffer.h"
 #include "src/traceconv/trace.descriptor.h"
+#include "src/traceconv/winscope.descriptor.h"
 #include "src/traceconv/utils.h"
 
 #include "protos/perfetto/trace/trace.pbzero.h"
@@ -53,6 +54,8 @@
   OnlineTraceToText(std::ostream* output) : output_(output) {
     pool_.AddFromFileDescriptorSet(kTraceDescriptor.data(),
                                    kTraceDescriptor.size());
+    pool_.AddFromFileDescriptorSet(kWinscopeDescriptor.data(),
+                                   kWinscopeDescriptor.size());
   }
   OnlineTraceToText(const OnlineTraceToText&) = delete;
   OnlineTraceToText& operator=(const OnlineTraceToText&) = delete;