Add rule to generate javastream proto for perfetto

So that we can use and import the Perfetto protos in framework.

Bug: 309630341
Test: tools/gen_android_bp
Change-Id: I9ff326d07047c329a9e21ebfe0a053aa3165db3d
diff --git a/Android.bp b/Android.bp
index 3b4f823..528172c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -15481,3 +15481,29 @@
         "LICENSE",
     ],
 }
+
+// TODO(b/315118713): use list of proto file sources instead of merged proto
+gensrcs {
+    name: "perfetto_trace_javastream_protos",
+    srcs: [
+        "protos/perfetto/trace/perfetto_trace.proto",
+    ],
+    tools: [
+        "aprotoc",
+        "protoc-gen-javastream",
+        "soong_zip",
+    ],
+    cmd: "mkdir -p $(genDir)/$(in) " +
+      "&& $(location aprotoc) " +
+        "--plugin=$(location protoc-gen-javastream) " +
+        "--javastream_out=$(genDir)/$(in) " +
+        "-Iexternal/protobuf/src " +
+        "-Iexternal/perfetto " +
+        "-I . $(in) " +
+      "&& $(location soong_zip) " +
+        "-jar -o $(out) -C $(genDir)/$(in) -D $(genDir)/$(in)",
+    data: [
+        ":libprotobuf-internal-protos",
+    ],
+    output_extension: "srcjar",
+}