Merge "Update auto multiuser metric;" into main
diff --git a/Android.bp b/Android.bp
index 6f18ab9..4fe5a6a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -63,6 +63,8 @@
         ":perfetto_protos_perfetto_ipc_cpp_gen",
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -150,6 +152,8 @@
         "perfetto_protos_perfetto_ipc_cpp_gen_headers",
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -331,6 +335,8 @@
         ":perfetto_protos_perfetto_ipc_cpp_gen",
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -427,6 +433,8 @@
         "perfetto_protos_perfetto_ipc_cpp_gen_headers",
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -537,6 +545,8 @@
         ":perfetto_protos_perfetto_ipc_cpp_gen",
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -643,6 +653,8 @@
         "perfetto_protos_perfetto_ipc_cpp_gen_headers",
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -781,6 +793,8 @@
         ":perfetto_protos_perfetto_ipc_cpp_gen",
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -866,6 +880,8 @@
         "perfetto_protos_perfetto_ipc_cpp_gen_headers",
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -952,6 +968,8 @@
         ":perfetto_protos_perfetto_ipc_cpp_gen",
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -1041,6 +1059,8 @@
         "perfetto_protos_perfetto_ipc_cpp_gen_headers",
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -1094,6 +1114,8 @@
         "perfetto_protos_perfetto_ipc_cpp_gen_headers",
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -1175,6 +1197,8 @@
         ":perfetto_protos_perfetto_ipc_cpp_gen",
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -1252,6 +1276,8 @@
         "perfetto_protos_perfetto_ipc_cpp_gen_headers",
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -1408,6 +1434,10 @@
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_cpp_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
@@ -1540,6 +1570,10 @@
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
@@ -1611,6 +1645,10 @@
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
@@ -1707,6 +1745,10 @@
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_cpp_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
@@ -1832,6 +1874,10 @@
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
@@ -1903,6 +1949,10 @@
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
@@ -2238,6 +2288,13 @@
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_lite_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_cpp_gen",
         ":perfetto_protos_perfetto_trace_chrome_lite_gen",
@@ -2515,6 +2572,13 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
@@ -5417,11 +5481,6 @@
         "protos/perfetto/trace/android/network_trace.proto",
         "protos/perfetto/trace/android/packages_list.proto",
         "protos/perfetto/trace/android/pixel_modem_events.proto",
-        "protos/perfetto/trace/android/protolog.proto",
-        "protos/perfetto/trace/android/shell_transition.proto",
-        "protos/perfetto/trace/android/surfaceflinger_common.proto",
-        "protos/perfetto/trace/android/surfaceflinger_layers.proto",
-        "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
     ],
 }
 
@@ -5431,6 +5490,8 @@
     srcs: [
         ":perfetto_protos_perfetto_common_cpp",
         ":perfetto_protos_perfetto_trace_android_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp",
     ],
     tools: [
         "aprotoc",
@@ -5450,11 +5511,6 @@
         "external/perfetto/protos/perfetto/trace/android/network_trace.gen.cc",
         "external/perfetto/protos/perfetto/trace/android/packages_list.gen.cc",
         "external/perfetto/protos/perfetto/trace/android/pixel_modem_events.gen.cc",
-        "external/perfetto/protos/perfetto/trace/android/protolog.gen.cc",
-        "external/perfetto/protos/perfetto/trace/android/shell_transition.gen.cc",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.gen.cc",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.gen.cc",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.gen.cc",
     ],
 }
 
@@ -5464,6 +5520,8 @@
     srcs: [
         ":perfetto_protos_perfetto_common_cpp",
         ":perfetto_protos_perfetto_trace_android_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp",
     ],
     tools: [
         "aprotoc",
@@ -5483,11 +5541,6 @@
         "external/perfetto/protos/perfetto/trace/android/network_trace.gen.h",
         "external/perfetto/protos/perfetto/trace/android/packages_list.gen.h",
         "external/perfetto/protos/perfetto/trace/android/pixel_modem_events.gen.h",
-        "external/perfetto/protos/perfetto/trace/android/protolog.gen.h",
-        "external/perfetto/protos/perfetto/trace/android/shell_transition.gen.h",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.gen.h",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.gen.h",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.gen.h",
     ],
     export_include_dirs: [
         ".",
@@ -5511,11 +5564,6 @@
         "protos/perfetto/trace/android/network_trace.proto",
         "protos/perfetto/trace/android/packages_list.proto",
         "protos/perfetto/trace/android/pixel_modem_events.proto",
-        "protos/perfetto/trace/android/protolog.proto",
-        "protos/perfetto/trace/android/shell_transition.proto",
-        "protos/perfetto/trace/android/surfaceflinger_common.proto",
-        "protos/perfetto/trace/android/surfaceflinger_layers.proto",
-        "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
     ],
 }
 
@@ -5525,6 +5573,8 @@
     srcs: [
         ":perfetto_protos_perfetto_common_lite",
         ":perfetto_protos_perfetto_trace_android_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite",
     ],
     tools: [
         "aprotoc",
@@ -5543,11 +5593,6 @@
         "external/perfetto/protos/perfetto/trace/android/network_trace.pb.cc",
         "external/perfetto/protos/perfetto/trace/android/packages_list.pb.cc",
         "external/perfetto/protos/perfetto/trace/android/pixel_modem_events.pb.cc",
-        "external/perfetto/protos/perfetto/trace/android/protolog.pb.cc",
-        "external/perfetto/protos/perfetto/trace/android/shell_transition.pb.cc",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.pb.cc",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.pb.cc",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.pb.cc",
     ],
 }
 
@@ -5557,6 +5602,8 @@
     srcs: [
         ":perfetto_protos_perfetto_common_lite",
         ":perfetto_protos_perfetto_trace_android_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite",
     ],
     tools: [
         "aprotoc",
@@ -5575,11 +5622,154 @@
         "external/perfetto/protos/perfetto/trace/android/network_trace.pb.h",
         "external/perfetto/protos/perfetto/trace/android/packages_list.pb.h",
         "external/perfetto/protos/perfetto/trace/android/pixel_modem_events.pb.h",
-        "external/perfetto/protos/perfetto/trace/android/protolog.pb.h",
-        "external/perfetto/protos/perfetto/trace/android/shell_transition.pb.h",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.pb.h",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.pb.h",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.pb.h",
+    ],
+    export_include_dirs: [
+        ".",
+        "protos",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_common:cpp
+filegroup {
+    name: "perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+    srcs: [
+        "protos/perfetto/trace/android/graphics/point.proto",
+        "protos/perfetto/trace/android/graphics/rect.proto",
+        "protos/perfetto/trace/android/winscope_extensions.proto",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_common:cpp
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen",
+    srcs: [
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+    ],
+    tools: [
+        "aprotoc",
+        "perfetto_src_protozero_protoc_plugin_cppgen_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_cppgen_plugin) --plugin_out=wrapper_namespace=gen:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_common_cpp)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/graphics/point.gen.cc",
+        "external/perfetto/protos/perfetto/trace/android/graphics/rect.gen.cc",
+        "external/perfetto/protos/perfetto/trace/android/winscope_extensions.gen.cc",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_common:cpp
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen_headers",
+    srcs: [
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+    ],
+    tools: [
+        "aprotoc",
+        "perfetto_src_protozero_protoc_plugin_cppgen_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_cppgen_plugin) --plugin_out=wrapper_namespace=gen:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_common_cpp)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/graphics/point.gen.h",
+        "external/perfetto/protos/perfetto/trace/android/graphics/rect.gen.h",
+        "external/perfetto/protos/perfetto/trace/android/winscope_extensions.gen.h",
+    ],
+    export_include_dirs: [
+        ".",
+        "protos",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_common:lite
+filegroup {
+    name: "perfetto_protos_perfetto_trace_android_winscope_common_lite",
+    srcs: [
+        "protos/perfetto/trace/android/graphics/point.proto",
+        "protos/perfetto/trace/android/graphics/rect.proto",
+        "protos/perfetto/trace/android/winscope_extensions.proto",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_common:lite
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_common_lite_gen",
+    srcs: [
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite",
+    ],
+    tools: [
+        "aprotoc",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_common_lite)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/graphics/point.pb.cc",
+        "external/perfetto/protos/perfetto/trace/android/graphics/rect.pb.cc",
+        "external/perfetto/protos/perfetto/trace/android/winscope_extensions.pb.cc",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_common:lite
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_common_lite_gen_headers",
+    srcs: [
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite",
+    ],
+    tools: [
+        "aprotoc",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_common_lite)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/graphics/point.pb.h",
+        "external/perfetto/protos/perfetto/trace/android/graphics/rect.pb.h",
+        "external/perfetto/protos/perfetto/trace/android/winscope_extensions.pb.h",
+    ],
+    export_include_dirs: [
+        ".",
+        "protos",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_common:zero
+filegroup {
+    name: "perfetto_protos_perfetto_trace_android_winscope_common_zero",
+    srcs: [
+        "protos/perfetto/trace/android/graphics/point.proto",
+        "protos/perfetto/trace/android/graphics/rect.proto",
+        "protos/perfetto/trace/android/winscope_extensions.proto",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_common:zero
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+    srcs: [
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+    ],
+    tools: [
+        "aprotoc",
+        "protozero_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location protozero_plugin) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_common_zero)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/graphics/point.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/graphics/rect.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/winscope_extensions.pbzero.cc",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_common:zero
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+    srcs: [
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+    ],
+    tools: [
+        "aprotoc",
+        "protozero_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location protozero_plugin) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_common_zero)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/graphics/point.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/graphics/rect.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/winscope_extensions.pbzero.h",
     ],
     export_include_dirs: [
         ".",
@@ -5591,6 +5781,7 @@
 genrule {
     name: "perfetto_protos_perfetto_trace_android_winscope_descriptor",
     srcs: [
+        ":libprotobuf-internal-descriptor-proto",
         "protos/perfetto/common/android_energy_consumer_descriptor.proto",
         "protos/perfetto/common/android_log_constants.proto",
         "protos/perfetto/common/builtin_clock.proto",
@@ -5608,19 +5799,337 @@
         "protos/perfetto/common/tracing_service_capabilities.proto",
         "protos/perfetto/common/tracing_service_state.proto",
         "protos/perfetto/common/track_event_descriptor.proto",
+        "protos/perfetto/trace/android/graphics/pixelformat.proto",
+        "protos/perfetto/trace/android/graphics/point.proto",
+        "protos/perfetto/trace/android/graphics/rect.proto",
+        "protos/perfetto/trace/android/inputmethodeditor.proto",
+        "protos/perfetto/trace/android/inputmethodservice/inputmethodservice.proto",
+        "protos/perfetto/trace/android/inputmethodservice/softinputwindow.proto",
+        "protos/perfetto/trace/android/protolog.proto",
+        "protos/perfetto/trace/android/server/inputmethod/inputmethodmanagerservice.proto",
+        "protos/perfetto/trace/android/shell_transition.proto",
+        "protos/perfetto/trace/android/surfaceflinger_common.proto",
+        "protos/perfetto/trace/android/surfaceflinger_layers.proto",
+        "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
+        "protos/perfetto/trace/android/typedef.proto",
+        "protos/perfetto/trace/android/view/display.proto",
+        "protos/perfetto/trace/android/view/displaycutout.proto",
+        "protos/perfetto/trace/android/view/imefocuscontroller.proto",
+        "protos/perfetto/trace/android/view/imeinsetssourceconsumer.proto",
+        "protos/perfetto/trace/android/view/inputmethod/editorinfo.proto",
+        "protos/perfetto/trace/android/view/inputmethod/inputconnection.proto",
+        "protos/perfetto/trace/android/view/inputmethod/inputmethodmanager.proto",
+        "protos/perfetto/trace/android/view/insetsanimationcontrolimpl.proto",
+        "protos/perfetto/trace/android/view/insetscontroller.proto",
+        "protos/perfetto/trace/android/view/insetssource.proto",
+        "protos/perfetto/trace/android/view/insetssourceconsumer.proto",
+        "protos/perfetto/trace/android/view/insetssourcecontrol.proto",
+        "protos/perfetto/trace/android/view/insetsstate.proto",
+        "protos/perfetto/trace/android/view/surfacecontrol.proto",
+        "protos/perfetto/trace/android/view/viewrootimpl.proto",
+        "protos/perfetto/trace/android/view/windowlayoutparams.proto",
+        "protos/perfetto/trace/android/winscope.proto",
+        "protos/perfetto/trace/android/winscope_extensions.proto",
+        "protos/perfetto/trace/android/winscope_extensions_impl.proto",
+    ],
+    tools: [
+        "aprotoc",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --proto_path=external/protobuf/src --descriptor_set_out=$(out) $(in)",
+    out: [
+        "perfetto_protos_perfetto_trace_android_winscope_descriptor.bin",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_extensions:zero
+filegroup {
+    name: "perfetto_protos_perfetto_trace_android_winscope_extensions_zero",
+    srcs: [
+        "protos/perfetto/trace/android/graphics/pixelformat.proto",
+        "protos/perfetto/trace/android/inputmethodeditor.proto",
+        "protos/perfetto/trace/android/inputmethodservice/inputmethodservice.proto",
+        "protos/perfetto/trace/android/inputmethodservice/softinputwindow.proto",
+        "protos/perfetto/trace/android/server/inputmethod/inputmethodmanagerservice.proto",
+        "protos/perfetto/trace/android/typedef.proto",
+        "protos/perfetto/trace/android/view/display.proto",
+        "protos/perfetto/trace/android/view/displaycutout.proto",
+        "protos/perfetto/trace/android/view/imefocuscontroller.proto",
+        "protos/perfetto/trace/android/view/imeinsetssourceconsumer.proto",
+        "protos/perfetto/trace/android/view/inputmethod/editorinfo.proto",
+        "protos/perfetto/trace/android/view/inputmethod/inputconnection.proto",
+        "protos/perfetto/trace/android/view/inputmethod/inputmethodmanager.proto",
+        "protos/perfetto/trace/android/view/insetsanimationcontrolimpl.proto",
+        "protos/perfetto/trace/android/view/insetscontroller.proto",
+        "protos/perfetto/trace/android/view/insetssource.proto",
+        "protos/perfetto/trace/android/view/insetssourceconsumer.proto",
+        "protos/perfetto/trace/android/view/insetssourcecontrol.proto",
+        "protos/perfetto/trace/android/view/insetsstate.proto",
+        "protos/perfetto/trace/android/view/surfacecontrol.proto",
+        "protos/perfetto/trace/android/view/viewrootimpl.proto",
+        "protos/perfetto/trace/android/view/windowlayoutparams.proto",
+        "protos/perfetto/trace/android/winscope_extensions_impl.proto",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_extensions:zero
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen",
+    srcs: [
+        ":libprotobuf-internal-descriptor-proto",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_extensions_zero",
+    ],
+    tools: [
+        "aprotoc",
+        "protozero_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --proto_path=external/protobuf/src --plugin=protoc-gen-plugin=$(location protozero_plugin) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_extensions_zero)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/graphics/pixelformat.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/inputmethodeditor.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/inputmethodservice/inputmethodservice.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/inputmethodservice/softinputwindow.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/server/inputmethod/inputmethodmanagerservice.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/typedef.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/display.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/displaycutout.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/imefocuscontroller.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/imeinsetssourceconsumer.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/inputmethod/editorinfo.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/inputmethod/inputconnection.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/inputmethod/inputmethodmanager.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/insetsanimationcontrolimpl.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/insetscontroller.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/insetssource.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/insetssourceconsumer.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/insetssourcecontrol.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/insetsstate.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/surfacecontrol.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/viewrootimpl.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/view/windowlayoutparams.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/winscope_extensions_impl.pbzero.cc",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_extensions:zero
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen_headers",
+    srcs: [
+        ":libprotobuf-internal-descriptor-proto",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_extensions_zero",
+    ],
+    tools: [
+        "aprotoc",
+        "protozero_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --proto_path=external/protobuf/src --plugin=protoc-gen-plugin=$(location protozero_plugin) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_extensions_zero)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/graphics/pixelformat.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/inputmethodeditor.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/inputmethodservice/inputmethodservice.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/inputmethodservice/softinputwindow.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/server/inputmethod/inputmethodmanagerservice.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/typedef.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/display.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/displaycutout.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/imefocuscontroller.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/imeinsetssourceconsumer.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/inputmethod/editorinfo.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/inputmethod/inputconnection.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/inputmethod/inputmethodmanager.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/insetsanimationcontrolimpl.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/insetscontroller.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/insetssource.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/insetssourceconsumer.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/insetssourcecontrol.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/insetsstate.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/surfacecontrol.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/viewrootimpl.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/view/windowlayoutparams.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/winscope_extensions_impl.pbzero.h",
+    ],
+    export_include_dirs: [
+        ".",
+        "protos",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_regular:cpp
+filegroup {
+    name: "perfetto_protos_perfetto_trace_android_winscope_regular_cpp",
+    srcs: [
         "protos/perfetto/trace/android/protolog.proto",
         "protos/perfetto/trace/android/shell_transition.proto",
         "protos/perfetto/trace/android/surfaceflinger_common.proto",
         "protos/perfetto/trace/android/surfaceflinger_layers.proto",
         "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
-        "protos/perfetto/trace/android/winscope.proto",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_regular:cpp
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen",
+    srcs: [
+        ":perfetto_protos_perfetto_common_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp",
+    ],
+    tools: [
+        "aprotoc",
+        "perfetto_src_protozero_protoc_plugin_cppgen_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_cppgen_plugin) --plugin_out=wrapper_namespace=gen:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_regular_cpp)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/protolog.gen.cc",
+        "external/perfetto/protos/perfetto/trace/android/shell_transition.gen.cc",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.gen.cc",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.gen.cc",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.gen.cc",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_regular:cpp
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen_headers",
+    srcs: [
+        ":perfetto_protos_perfetto_common_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp",
+    ],
+    tools: [
+        "aprotoc",
+        "perfetto_src_protozero_protoc_plugin_cppgen_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_cppgen_plugin) --plugin_out=wrapper_namespace=gen:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_regular_cpp)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/protolog.gen.h",
+        "external/perfetto/protos/perfetto/trace/android/shell_transition.gen.h",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.gen.h",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.gen.h",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.gen.h",
+    ],
+    export_include_dirs: [
+        ".",
+        "protos",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_regular:lite
+filegroup {
+    name: "perfetto_protos_perfetto_trace_android_winscope_regular_lite",
+    srcs: [
+        "protos/perfetto/trace/android/protolog.proto",
+        "protos/perfetto/trace/android/shell_transition.proto",
+        "protos/perfetto/trace/android/surfaceflinger_common.proto",
+        "protos/perfetto/trace/android/surfaceflinger_layers.proto",
+        "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_regular:lite
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_regular_lite_gen",
+    srcs: [
+        ":perfetto_protos_perfetto_common_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite",
     ],
     tools: [
         "aprotoc",
     ],
-    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --descriptor_set_out=$(out) $(in)",
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_regular_lite)",
     out: [
-        "perfetto_protos_perfetto_trace_android_winscope_descriptor.bin",
+        "external/perfetto/protos/perfetto/trace/android/protolog.pb.cc",
+        "external/perfetto/protos/perfetto/trace/android/shell_transition.pb.cc",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.pb.cc",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.pb.cc",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.pb.cc",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_regular:lite
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_regular_lite_gen_headers",
+    srcs: [
+        ":perfetto_protos_perfetto_common_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite",
+    ],
+    tools: [
+        "aprotoc",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --cpp_out=lite=true:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_regular_lite)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/protolog.pb.h",
+        "external/perfetto/protos/perfetto/trace/android/shell_transition.pb.h",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.pb.h",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.pb.h",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.pb.h",
+    ],
+    export_include_dirs: [
+        ".",
+        "protos",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_regular:zero
+filegroup {
+    name: "perfetto_protos_perfetto_trace_android_winscope_regular_zero",
+    srcs: [
+        "protos/perfetto/trace/android/protolog.proto",
+        "protos/perfetto/trace/android/shell_transition.proto",
+        "protos/perfetto/trace/android/surfaceflinger_common.proto",
+        "protos/perfetto/trace/android/surfaceflinger_layers.proto",
+        "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_regular:zero
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
+    srcs: [
+        ":perfetto_protos_perfetto_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero",
+    ],
+    tools: [
+        "aprotoc",
+        "protozero_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location protozero_plugin) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_regular_zero)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/protolog.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/shell_transition.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.pbzero.cc",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.pbzero.cc",
+    ],
+}
+
+// GN: //protos/perfetto/trace/android:winscope_regular:zero
+genrule {
+    name: "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
+    srcs: [
+        ":perfetto_protos_perfetto_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero",
+    ],
+    tools: [
+        "aprotoc",
+        "protozero_plugin",
+    ],
+    cmd: "mkdir -p $(genDir)/external/perfetto/ && $(location aprotoc) --proto_path=external/perfetto --plugin=protoc-gen-plugin=$(location protozero_plugin) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/ $(locations :perfetto_protos_perfetto_trace_android_winscope_regular_zero)",
+    out: [
+        "external/perfetto/protos/perfetto/trace/android/protolog.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/shell_transition.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.pbzero.h",
+        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.pbzero.h",
+    ],
+    export_include_dirs: [
+        ".",
+        "protos",
     ],
 }
 
@@ -5640,11 +6149,6 @@
         "protos/perfetto/trace/android/network_trace.proto",
         "protos/perfetto/trace/android/packages_list.proto",
         "protos/perfetto/trace/android/pixel_modem_events.proto",
-        "protos/perfetto/trace/android/protolog.proto",
-        "protos/perfetto/trace/android/shell_transition.proto",
-        "protos/perfetto/trace/android/surfaceflinger_common.proto",
-        "protos/perfetto/trace/android/surfaceflinger_layers.proto",
-        "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
     ],
 }
 
@@ -5653,6 +6157,8 @@
     name: "perfetto_protos_perfetto_trace_android_zero_gen",
     srcs: [
         ":perfetto_protos_perfetto_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero",
         ":perfetto_protos_perfetto_trace_android_zero",
     ],
     tools: [
@@ -5673,11 +6179,6 @@
         "external/perfetto/protos/perfetto/trace/android/network_trace.pbzero.cc",
         "external/perfetto/protos/perfetto/trace/android/packages_list.pbzero.cc",
         "external/perfetto/protos/perfetto/trace/android/pixel_modem_events.pbzero.cc",
-        "external/perfetto/protos/perfetto/trace/android/protolog.pbzero.cc",
-        "external/perfetto/protos/perfetto/trace/android/shell_transition.pbzero.cc",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.pbzero.cc",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.pbzero.cc",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.pbzero.cc",
     ],
 }
 
@@ -5686,6 +6187,8 @@
     name: "perfetto_protos_perfetto_trace_android_zero_gen_headers",
     srcs: [
         ":perfetto_protos_perfetto_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero",
         ":perfetto_protos_perfetto_trace_android_zero",
     ],
     tools: [
@@ -5706,11 +6209,6 @@
         "external/perfetto/protos/perfetto/trace/android/network_trace.pbzero.h",
         "external/perfetto/protos/perfetto/trace/android/packages_list.pbzero.h",
         "external/perfetto/protos/perfetto/trace/android/pixel_modem_events.pbzero.h",
-        "external/perfetto/protos/perfetto/trace/android/protolog.pbzero.h",
-        "external/perfetto/protos/perfetto/trace/android/shell_transition.pbzero.h",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_common.pbzero.h",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_layers.pbzero.h",
-        "external/perfetto/protos/perfetto/trace/android/surfaceflinger_transactions.pbzero.h",
     ],
     export_include_dirs: [
         ".",
@@ -5948,6 +6446,8 @@
         "protos/perfetto/trace/android/camera_event.proto",
         "protos/perfetto/trace/android/frame_timeline_event.proto",
         "protos/perfetto/trace/android/gpu_mem_event.proto",
+        "protos/perfetto/trace/android/graphics/point.proto",
+        "protos/perfetto/trace/android/graphics/rect.proto",
         "protos/perfetto/trace/android/graphics_frame_event.proto",
         "protos/perfetto/trace/android/initial_display_state.proto",
         "protos/perfetto/trace/android/network_trace.proto",
@@ -5958,6 +6458,7 @@
         "protos/perfetto/trace/android/surfaceflinger_common.proto",
         "protos/perfetto/trace/android/surfaceflinger_layers.proto",
         "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
+        "protos/perfetto/trace/android/winscope_extensions.proto",
         "protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto",
         "protos/perfetto/trace/chrome/chrome_metadata.proto",
         "protos/perfetto/trace/chrome/chrome_trace_event.proto",
@@ -7326,6 +7827,8 @@
     srcs: [
         ":perfetto_protos_perfetto_common_cpp",
         ":perfetto_protos_perfetto_trace_android_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp",
         ":perfetto_protos_perfetto_trace_chrome_cpp",
         ":perfetto_protos_perfetto_trace_gpu_cpp",
         ":perfetto_protos_perfetto_trace_interned_data_cpp",
@@ -7348,6 +7851,8 @@
     srcs: [
         ":perfetto_protos_perfetto_common_cpp",
         ":perfetto_protos_perfetto_trace_android_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp",
         ":perfetto_protos_perfetto_trace_chrome_cpp",
         ":perfetto_protos_perfetto_trace_gpu_cpp",
         ":perfetto_protos_perfetto_trace_interned_data_cpp",
@@ -7382,6 +7887,8 @@
     srcs: [
         ":perfetto_protos_perfetto_common_lite",
         ":perfetto_protos_perfetto_trace_android_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite",
         ":perfetto_protos_perfetto_trace_chrome_lite",
         ":perfetto_protos_perfetto_trace_gpu_lite",
         ":perfetto_protos_perfetto_trace_interned_data_lite",
@@ -7403,6 +7910,8 @@
     srcs: [
         ":perfetto_protos_perfetto_common_lite",
         ":perfetto_protos_perfetto_trace_android_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite",
         ":perfetto_protos_perfetto_trace_chrome_lite",
         ":perfetto_protos_perfetto_trace_gpu_lite",
         ":perfetto_protos_perfetto_trace_interned_data_lite",
@@ -7435,6 +7944,8 @@
     name: "perfetto_protos_perfetto_trace_interned_data_zero_gen",
     srcs: [
         ":perfetto_protos_perfetto_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero",
         ":perfetto_protos_perfetto_trace_android_zero",
         ":perfetto_protos_perfetto_trace_chrome_zero",
         ":perfetto_protos_perfetto_trace_gpu_zero",
@@ -7457,6 +7968,8 @@
     name: "perfetto_protos_perfetto_trace_interned_data_zero_gen_headers",
     srcs: [
         ":perfetto_protos_perfetto_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero",
         ":perfetto_protos_perfetto_trace_android_zero",
         ":perfetto_protos_perfetto_trace_chrome_zero",
         ":perfetto_protos_perfetto_trace_gpu_zero",
@@ -7754,6 +8267,8 @@
         ":perfetto_protos_perfetto_config_system_info_cpp",
         ":perfetto_protos_perfetto_config_track_event_cpp",
         ":perfetto_protos_perfetto_trace_android_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp",
         ":perfetto_protos_perfetto_trace_chrome_cpp",
         ":perfetto_protos_perfetto_trace_etw_cpp",
         ":perfetto_protos_perfetto_trace_filesystem_cpp",
@@ -7809,6 +8324,8 @@
         ":perfetto_protos_perfetto_config_system_info_cpp",
         ":perfetto_protos_perfetto_config_track_event_cpp",
         ":perfetto_protos_perfetto_trace_android_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp",
         ":perfetto_protos_perfetto_trace_chrome_cpp",
         ":perfetto_protos_perfetto_trace_etw_cpp",
         ":perfetto_protos_perfetto_trace_filesystem_cpp",
@@ -7884,6 +8401,8 @@
         ":perfetto_protos_perfetto_config_system_info_lite",
         ":perfetto_protos_perfetto_config_track_event_lite",
         ":perfetto_protos_perfetto_trace_android_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite",
         ":perfetto_protos_perfetto_trace_chrome_lite",
         ":perfetto_protos_perfetto_trace_etw_lite",
         ":perfetto_protos_perfetto_trace_filesystem_lite",
@@ -7938,6 +8457,8 @@
         ":perfetto_protos_perfetto_config_system_info_lite",
         ":perfetto_protos_perfetto_config_track_event_lite",
         ":perfetto_protos_perfetto_trace_android_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite",
         ":perfetto_protos_perfetto_trace_chrome_lite",
         ":perfetto_protos_perfetto_trace_etw_lite",
         ":perfetto_protos_perfetto_trace_filesystem_lite",
@@ -8011,6 +8532,8 @@
         ":perfetto_protos_perfetto_config_system_info_zero",
         ":perfetto_protos_perfetto_config_track_event_zero",
         ":perfetto_protos_perfetto_config_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero",
         ":perfetto_protos_perfetto_trace_android_zero",
         ":perfetto_protos_perfetto_trace_chrome_zero",
         ":perfetto_protos_perfetto_trace_etw_zero",
@@ -8066,6 +8589,8 @@
         ":perfetto_protos_perfetto_config_system_info_zero",
         ":perfetto_protos_perfetto_config_track_event_zero",
         ":perfetto_protos_perfetto_config_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero",
         ":perfetto_protos_perfetto_trace_android_zero",
         ":perfetto_protos_perfetto_trace_chrome_zero",
         ":perfetto_protos_perfetto_trace_etw_zero",
@@ -12942,6 +13467,7 @@
         "src/trace_redaction/filter_sched_waking_events.cc",
         "src/trace_redaction/filter_task_rename.cc",
         "src/trace_redaction/find_package_uid.cc",
+        "src/trace_redaction/modify_process_trees.cc",
         "src/trace_redaction/optimize_timeline.cc",
         "src/trace_redaction/populate_allow_lists.cc",
         "src/trace_redaction/process_thread_timeline.cc",
@@ -13826,226 +14352,6 @@
 }
 
 // GN: [//protos/perfetto/trace:non_minimal_source_set, //protos/perfetto/trace:minimal_source_set]
-filegroup {
-    name: "perfetto_trace_filegroup_proto",
-    srcs: [
-        "protos/perfetto/common/android_energy_consumer_descriptor.proto",
-        "protos/perfetto/common/android_log_constants.proto",
-        "protos/perfetto/common/builtin_clock.proto",
-        "protos/perfetto/common/commit_data_request.proto",
-        "protos/perfetto/common/data_source_descriptor.proto",
-        "protos/perfetto/common/descriptor.proto",
-        "protos/perfetto/common/ftrace_descriptor.proto",
-        "protos/perfetto/common/gpu_counter_descriptor.proto",
-        "protos/perfetto/common/interceptor_descriptor.proto",
-        "protos/perfetto/common/observable_events.proto",
-        "protos/perfetto/common/perf_events.proto",
-        "protos/perfetto/common/protolog_common.proto",
-        "protos/perfetto/common/sys_stats_counters.proto",
-        "protos/perfetto/common/trace_stats.proto",
-        "protos/perfetto/common/tracing_service_capabilities.proto",
-        "protos/perfetto/common/tracing_service_state.proto",
-        "protos/perfetto/common/track_event_descriptor.proto",
-        "protos/perfetto/config/android/android_game_intervention_list_config.proto",
-        "protos/perfetto/config/android/android_input_event_config.proto",
-        "protos/perfetto/config/android/android_log_config.proto",
-        "protos/perfetto/config/android/android_polled_state_config.proto",
-        "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
-        "protos/perfetto/config/android/android_system_property_config.proto",
-        "protos/perfetto/config/android/network_trace_config.proto",
-        "protos/perfetto/config/android/packages_list_config.proto",
-        "protos/perfetto/config/android/pixel_modem_config.proto",
-        "protos/perfetto/config/android/protolog_config.proto",
-        "protos/perfetto/config/android/surfaceflinger_layers_config.proto",
-        "protos/perfetto/config/android/surfaceflinger_transactions_config.proto",
-        "protos/perfetto/config/chrome/chrome_config.proto",
-        "protos/perfetto/config/chrome/scenario_config.proto",
-        "protos/perfetto/config/chrome/v8_config.proto",
-        "protos/perfetto/config/data_source_config.proto",
-        "protos/perfetto/config/etw/etw_config.proto",
-        "protos/perfetto/config/ftrace/ftrace_config.proto",
-        "protos/perfetto/config/gpu/gpu_counter_config.proto",
-        "protos/perfetto/config/gpu/vulkan_memory_config.proto",
-        "protos/perfetto/config/inode_file/inode_file_config.proto",
-        "protos/perfetto/config/interceptor_config.proto",
-        "protos/perfetto/config/interceptors/console_config.proto",
-        "protos/perfetto/config/power/android_power_config.proto",
-        "protos/perfetto/config/process_stats/process_stats_config.proto",
-        "protos/perfetto/config/profiling/heapprofd_config.proto",
-        "protos/perfetto/config/profiling/java_hprof_config.proto",
-        "protos/perfetto/config/profiling/perf_event_config.proto",
-        "protos/perfetto/config/statsd/atom_ids.proto",
-        "protos/perfetto/config/statsd/statsd_tracing_config.proto",
-        "protos/perfetto/config/stress_test_config.proto",
-        "protos/perfetto/config/sys_stats/sys_stats_config.proto",
-        "protos/perfetto/config/system_info/system_info.proto",
-        "protos/perfetto/config/test_config.proto",
-        "protos/perfetto/config/trace_config.proto",
-        "protos/perfetto/config/track_event/track_event_config.proto",
-        "protos/perfetto/trace/android/android_game_intervention_list.proto",
-        "protos/perfetto/trace/android/android_input_event.proto",
-        "protos/perfetto/trace/android/android_log.proto",
-        "protos/perfetto/trace/android/android_system_property.proto",
-        "protos/perfetto/trace/android/camera_event.proto",
-        "protos/perfetto/trace/android/frame_timeline_event.proto",
-        "protos/perfetto/trace/android/gpu_mem_event.proto",
-        "protos/perfetto/trace/android/graphics_frame_event.proto",
-        "protos/perfetto/trace/android/initial_display_state.proto",
-        "protos/perfetto/trace/android/network_trace.proto",
-        "protos/perfetto/trace/android/packages_list.proto",
-        "protos/perfetto/trace/android/pixel_modem_events.proto",
-        "protos/perfetto/trace/android/protolog.proto",
-        "protos/perfetto/trace/android/shell_transition.proto",
-        "protos/perfetto/trace/android/surfaceflinger_common.proto",
-        "protos/perfetto/trace/android/surfaceflinger_layers.proto",
-        "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
-        "protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto",
-        "protos/perfetto/trace/chrome/chrome_metadata.proto",
-        "protos/perfetto/trace/chrome/chrome_trace_event.proto",
-        "protos/perfetto/trace/chrome/chrome_trigger.proto",
-        "protos/perfetto/trace/chrome/v8.proto",
-        "protos/perfetto/trace/clock_snapshot.proto",
-        "protos/perfetto/trace/etw/etw.proto",
-        "protos/perfetto/trace/etw/etw_event.proto",
-        "protos/perfetto/trace/etw/etw_event_bundle.proto",
-        "protos/perfetto/trace/extension_descriptor.proto",
-        "protos/perfetto/trace/filesystem/inode_file_map.proto",
-        "protos/perfetto/trace/ftrace/android_fs.proto",
-        "protos/perfetto/trace/ftrace/binder.proto",
-        "protos/perfetto/trace/ftrace/block.proto",
-        "protos/perfetto/trace/ftrace/cgroup.proto",
-        "protos/perfetto/trace/ftrace/clk.proto",
-        "protos/perfetto/trace/ftrace/cma.proto",
-        "protos/perfetto/trace/ftrace/compaction.proto",
-        "protos/perfetto/trace/ftrace/cpuhp.proto",
-        "protos/perfetto/trace/ftrace/cros_ec.proto",
-        "protos/perfetto/trace/ftrace/dma_fence.proto",
-        "protos/perfetto/trace/ftrace/dmabuf_heap.proto",
-        "protos/perfetto/trace/ftrace/dpu.proto",
-        "protos/perfetto/trace/ftrace/drm.proto",
-        "protos/perfetto/trace/ftrace/ext4.proto",
-        "protos/perfetto/trace/ftrace/f2fs.proto",
-        "protos/perfetto/trace/ftrace/fastrpc.proto",
-        "protos/perfetto/trace/ftrace/fence.proto",
-        "protos/perfetto/trace/ftrace/filemap.proto",
-        "protos/perfetto/trace/ftrace/ftrace.proto",
-        "protos/perfetto/trace/ftrace/ftrace_event.proto",
-        "protos/perfetto/trace/ftrace/ftrace_event_bundle.proto",
-        "protos/perfetto/trace/ftrace/ftrace_stats.proto",
-        "protos/perfetto/trace/ftrace/g2d.proto",
-        "protos/perfetto/trace/ftrace/generic.proto",
-        "protos/perfetto/trace/ftrace/google_icc_trace.proto",
-        "protos/perfetto/trace/ftrace/google_irm_trace.proto",
-        "protos/perfetto/trace/ftrace/gpu_mem.proto",
-        "protos/perfetto/trace/ftrace/gpu_scheduler.proto",
-        "protos/perfetto/trace/ftrace/hyp.proto",
-        "protos/perfetto/trace/ftrace/i2c.proto",
-        "protos/perfetto/trace/ftrace/ion.proto",
-        "protos/perfetto/trace/ftrace/ipi.proto",
-        "protos/perfetto/trace/ftrace/irq.proto",
-        "protos/perfetto/trace/ftrace/kmem.proto",
-        "protos/perfetto/trace/ftrace/kvm.proto",
-        "protos/perfetto/trace/ftrace/lowmemorykiller.proto",
-        "protos/perfetto/trace/ftrace/lwis.proto",
-        "protos/perfetto/trace/ftrace/mali.proto",
-        "protos/perfetto/trace/ftrace/mdss.proto",
-        "protos/perfetto/trace/ftrace/mm_event.proto",
-        "protos/perfetto/trace/ftrace/net.proto",
-        "protos/perfetto/trace/ftrace/oom.proto",
-        "protos/perfetto/trace/ftrace/panel.proto",
-        "protos/perfetto/trace/ftrace/perf_trace_counters.proto",
-        "protos/perfetto/trace/ftrace/power.proto",
-        "protos/perfetto/trace/ftrace/printk.proto",
-        "protos/perfetto/trace/ftrace/raw_syscalls.proto",
-        "protos/perfetto/trace/ftrace/regulator.proto",
-        "protos/perfetto/trace/ftrace/rpm.proto",
-        "protos/perfetto/trace/ftrace/samsung.proto",
-        "protos/perfetto/trace/ftrace/sched.proto",
-        "protos/perfetto/trace/ftrace/scm.proto",
-        "protos/perfetto/trace/ftrace/sde.proto",
-        "protos/perfetto/trace/ftrace/signal.proto",
-        "protos/perfetto/trace/ftrace/skb.proto",
-        "protos/perfetto/trace/ftrace/sock.proto",
-        "protos/perfetto/trace/ftrace/sync.proto",
-        "protos/perfetto/trace/ftrace/synthetic.proto",
-        "protos/perfetto/trace/ftrace/systrace.proto",
-        "protos/perfetto/trace/ftrace/task.proto",
-        "protos/perfetto/trace/ftrace/tcp.proto",
-        "protos/perfetto/trace/ftrace/test_bundle_wrapper.proto",
-        "protos/perfetto/trace/ftrace/thermal.proto",
-        "protos/perfetto/trace/ftrace/trusty.proto",
-        "protos/perfetto/trace/ftrace/ufs.proto",
-        "protos/perfetto/trace/ftrace/v4l2.proto",
-        "protos/perfetto/trace/ftrace/virtio_gpu.proto",
-        "protos/perfetto/trace/ftrace/virtio_video.proto",
-        "protos/perfetto/trace/ftrace/vmscan.proto",
-        "protos/perfetto/trace/ftrace/workqueue.proto",
-        "protos/perfetto/trace/gpu/gpu_counter_event.proto",
-        "protos/perfetto/trace/gpu/gpu_log.proto",
-        "protos/perfetto/trace/gpu/gpu_render_stage_event.proto",
-        "protos/perfetto/trace/gpu/vulkan_api_event.proto",
-        "protos/perfetto/trace/gpu/vulkan_memory_event.proto",
-        "protos/perfetto/trace/interned_data/interned_data.proto",
-        "protos/perfetto/trace/memory_graph.proto",
-        "protos/perfetto/trace/perfetto/perfetto_metatrace.proto",
-        "protos/perfetto/trace/perfetto/tracing_service_event.proto",
-        "protos/perfetto/trace/power/android_energy_estimation_breakdown.proto",
-        "protos/perfetto/trace/power/android_entity_state_residency.proto",
-        "protos/perfetto/trace/power/battery_counters.proto",
-        "protos/perfetto/trace/power/power_rails.proto",
-        "protos/perfetto/trace/profiling/deobfuscation.proto",
-        "protos/perfetto/trace/profiling/heap_graph.proto",
-        "protos/perfetto/trace/profiling/profile_common.proto",
-        "protos/perfetto/trace/profiling/profile_packet.proto",
-        "protos/perfetto/trace/profiling/smaps.proto",
-        "protos/perfetto/trace/ps/process_stats.proto",
-        "protos/perfetto/trace/ps/process_tree.proto",
-        "protos/perfetto/trace/remote_clock_sync.proto",
-        "protos/perfetto/trace/statsd/statsd_atom.proto",
-        "protos/perfetto/trace/sys_stats/sys_stats.proto",
-        "protos/perfetto/trace/system_info.proto",
-        "protos/perfetto/trace/system_info/cpu_info.proto",
-        "protos/perfetto/trace/test_event.proto",
-        "protos/perfetto/trace/test_extensions.proto",
-        "protos/perfetto/trace/trace.proto",
-        "protos/perfetto/trace/trace_packet.proto",
-        "protos/perfetto/trace/trace_packet_defaults.proto",
-        "protos/perfetto/trace/trace_uuid.proto",
-        "protos/perfetto/trace/track_event/chrome_active_processes.proto",
-        "protos/perfetto/trace/track_event/chrome_application_state_info.proto",
-        "protos/perfetto/trace/track_event/chrome_compositor_scheduler_state.proto",
-        "protos/perfetto/trace/track_event/chrome_content_settings_event_info.proto",
-        "protos/perfetto/trace/track_event/chrome_frame_reporter.proto",
-        "protos/perfetto/trace/track_event/chrome_histogram_sample.proto",
-        "protos/perfetto/trace/track_event/chrome_keyed_service.proto",
-        "protos/perfetto/trace/track_event/chrome_latency_info.proto",
-        "protos/perfetto/trace/track_event/chrome_legacy_ipc.proto",
-        "protos/perfetto/trace/track_event/chrome_message_pump.proto",
-        "protos/perfetto/trace/track_event/chrome_mojo_event_info.proto",
-        "protos/perfetto/trace/track_event/chrome_process_descriptor.proto",
-        "protos/perfetto/trace/track_event/chrome_renderer_scheduler_state.proto",
-        "protos/perfetto/trace/track_event/chrome_thread_descriptor.proto",
-        "protos/perfetto/trace/track_event/chrome_user_event.proto",
-        "protos/perfetto/trace/track_event/chrome_window_handle_event_info.proto",
-        "protos/perfetto/trace/track_event/counter_descriptor.proto",
-        "protos/perfetto/trace/track_event/debug_annotation.proto",
-        "protos/perfetto/trace/track_event/log_message.proto",
-        "protos/perfetto/trace/track_event/pixel_modem.proto",
-        "protos/perfetto/trace/track_event/process_descriptor.proto",
-        "protos/perfetto/trace/track_event/range_of_interest.proto",
-        "protos/perfetto/trace/track_event/screenshot.proto",
-        "protos/perfetto/trace/track_event/source_location.proto",
-        "protos/perfetto/trace/track_event/task_execution.proto",
-        "protos/perfetto/trace/track_event/thread_descriptor.proto",
-        "protos/perfetto/trace/track_event/track_descriptor.proto",
-        "protos/perfetto/trace/track_event/track_event.proto",
-        "protos/perfetto/trace/translation/translation_table.proto",
-        "protos/perfetto/trace/trigger.proto",
-        "protos/perfetto/trace/ui_state.proto",
-    ],
-}
-
-// GN: [//protos/perfetto/trace:non_minimal_source_set, //protos/perfetto/trace:minimal_source_set]
 java_library {
     name: "perfetto_trace_java_protos",
     srcs: [
@@ -14109,6 +14415,8 @@
         "protos/perfetto/trace/android/camera_event.proto",
         "protos/perfetto/trace/android/frame_timeline_event.proto",
         "protos/perfetto/trace/android/gpu_mem_event.proto",
+        "protos/perfetto/trace/android/graphics/point.proto",
+        "protos/perfetto/trace/android/graphics/rect.proto",
         "protos/perfetto/trace/android/graphics_frame_event.proto",
         "protos/perfetto/trace/android/initial_display_state.proto",
         "protos/perfetto/trace/android/network_trace.proto",
@@ -14119,6 +14427,7 @@
         "protos/perfetto/trace/android/surfaceflinger_common.proto",
         "protos/perfetto/trace/android/surfaceflinger_layers.proto",
         "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
+        "protos/perfetto/trace/android/winscope_extensions.proto",
         "protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto",
         "protos/perfetto/trace/chrome/chrome_metadata.proto",
         "protos/perfetto/trace/chrome/chrome_trace_event.proto",
@@ -14288,6 +14597,8 @@
         ":perfetto_protos_perfetto_config_system_info_lite_gen",
         ":perfetto_protos_perfetto_config_track_event_lite_gen",
         ":perfetto_protos_perfetto_trace_android_lite_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite_gen",
         ":perfetto_protos_perfetto_trace_chrome_lite_gen",
         ":perfetto_protos_perfetto_trace_etw_lite_gen",
         ":perfetto_protos_perfetto_trace_filesystem_lite_gen",
@@ -14326,6 +14637,8 @@
         "perfetto_protos_perfetto_config_system_info_lite_gen_headers",
         "perfetto_protos_perfetto_config_track_event_lite_gen_headers",
         "perfetto_protos_perfetto_trace_android_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_lite_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
         "perfetto_protos_perfetto_trace_etw_lite_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_lite_gen_headers",
@@ -14360,6 +14673,8 @@
         "perfetto_protos_perfetto_config_system_info_lite_gen_headers",
         "perfetto_protos_perfetto_config_track_event_lite_gen_headers",
         "perfetto_protos_perfetto_trace_android_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_lite_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
         "perfetto_protos_perfetto_trace_etw_lite_gen_headers",
         "perfetto_protos_perfetto_trace_filesystem_lite_gen_headers",
@@ -14475,6 +14790,13 @@
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_lite_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_lite_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_lite_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_cpp_gen",
         ":perfetto_protos_perfetto_trace_chrome_lite_gen",
@@ -14841,6 +15163,13 @@
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_lite_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
@@ -15014,6 +15343,10 @@
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
         ":perfetto_protos_perfetto_trace_android_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_cpp_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
@@ -15139,6 +15472,10 @@
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
@@ -15210,6 +15547,10 @@
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_android_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_cpp_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
@@ -15253,6 +15594,252 @@
     ],
 }
 
+// GN: [//protos/perfetto/trace:non_minimal_source_set, //protos/perfetto/trace/android:winscope_extensions:source_set]
+filegroup {
+    name: "perfetto_winscope_filegroup_proto",
+    srcs: [
+        "protos/perfetto/common/android_energy_consumer_descriptor.proto",
+        "protos/perfetto/common/android_log_constants.proto",
+        "protos/perfetto/common/builtin_clock.proto",
+        "protos/perfetto/common/commit_data_request.proto",
+        "protos/perfetto/common/data_source_descriptor.proto",
+        "protos/perfetto/common/descriptor.proto",
+        "protos/perfetto/common/ftrace_descriptor.proto",
+        "protos/perfetto/common/gpu_counter_descriptor.proto",
+        "protos/perfetto/common/interceptor_descriptor.proto",
+        "protos/perfetto/common/observable_events.proto",
+        "protos/perfetto/common/perf_events.proto",
+        "protos/perfetto/common/protolog_common.proto",
+        "protos/perfetto/common/sys_stats_counters.proto",
+        "protos/perfetto/common/trace_stats.proto",
+        "protos/perfetto/common/tracing_service_capabilities.proto",
+        "protos/perfetto/common/tracing_service_state.proto",
+        "protos/perfetto/common/track_event_descriptor.proto",
+        "protos/perfetto/config/android/android_game_intervention_list_config.proto",
+        "protos/perfetto/config/android/android_input_event_config.proto",
+        "protos/perfetto/config/android/android_log_config.proto",
+        "protos/perfetto/config/android/android_polled_state_config.proto",
+        "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
+        "protos/perfetto/config/android/android_system_property_config.proto",
+        "protos/perfetto/config/android/network_trace_config.proto",
+        "protos/perfetto/config/android/packages_list_config.proto",
+        "protos/perfetto/config/android/pixel_modem_config.proto",
+        "protos/perfetto/config/android/protolog_config.proto",
+        "protos/perfetto/config/android/surfaceflinger_layers_config.proto",
+        "protos/perfetto/config/android/surfaceflinger_transactions_config.proto",
+        "protos/perfetto/config/chrome/chrome_config.proto",
+        "protos/perfetto/config/chrome/scenario_config.proto",
+        "protos/perfetto/config/chrome/v8_config.proto",
+        "protos/perfetto/config/data_source_config.proto",
+        "protos/perfetto/config/etw/etw_config.proto",
+        "protos/perfetto/config/ftrace/ftrace_config.proto",
+        "protos/perfetto/config/gpu/gpu_counter_config.proto",
+        "protos/perfetto/config/gpu/vulkan_memory_config.proto",
+        "protos/perfetto/config/inode_file/inode_file_config.proto",
+        "protos/perfetto/config/interceptor_config.proto",
+        "protos/perfetto/config/interceptors/console_config.proto",
+        "protos/perfetto/config/power/android_power_config.proto",
+        "protos/perfetto/config/process_stats/process_stats_config.proto",
+        "protos/perfetto/config/profiling/heapprofd_config.proto",
+        "protos/perfetto/config/profiling/java_hprof_config.proto",
+        "protos/perfetto/config/profiling/perf_event_config.proto",
+        "protos/perfetto/config/statsd/atom_ids.proto",
+        "protos/perfetto/config/statsd/statsd_tracing_config.proto",
+        "protos/perfetto/config/stress_test_config.proto",
+        "protos/perfetto/config/sys_stats/sys_stats_config.proto",
+        "protos/perfetto/config/system_info/system_info.proto",
+        "protos/perfetto/config/test_config.proto",
+        "protos/perfetto/config/trace_config.proto",
+        "protos/perfetto/config/track_event/track_event_config.proto",
+        "protos/perfetto/trace/android/android_game_intervention_list.proto",
+        "protos/perfetto/trace/android/android_input_event.proto",
+        "protos/perfetto/trace/android/android_log.proto",
+        "protos/perfetto/trace/android/android_system_property.proto",
+        "protos/perfetto/trace/android/camera_event.proto",
+        "protos/perfetto/trace/android/frame_timeline_event.proto",
+        "protos/perfetto/trace/android/gpu_mem_event.proto",
+        "protos/perfetto/trace/android/graphics/pixelformat.proto",
+        "protos/perfetto/trace/android/graphics/point.proto",
+        "protos/perfetto/trace/android/graphics/rect.proto",
+        "protos/perfetto/trace/android/graphics_frame_event.proto",
+        "protos/perfetto/trace/android/initial_display_state.proto",
+        "protos/perfetto/trace/android/inputmethodeditor.proto",
+        "protos/perfetto/trace/android/inputmethodservice/inputmethodservice.proto",
+        "protos/perfetto/trace/android/inputmethodservice/softinputwindow.proto",
+        "protos/perfetto/trace/android/network_trace.proto",
+        "protos/perfetto/trace/android/packages_list.proto",
+        "protos/perfetto/trace/android/pixel_modem_events.proto",
+        "protos/perfetto/trace/android/protolog.proto",
+        "protos/perfetto/trace/android/server/inputmethod/inputmethodmanagerservice.proto",
+        "protos/perfetto/trace/android/shell_transition.proto",
+        "protos/perfetto/trace/android/surfaceflinger_common.proto",
+        "protos/perfetto/trace/android/surfaceflinger_layers.proto",
+        "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
+        "protos/perfetto/trace/android/typedef.proto",
+        "protos/perfetto/trace/android/view/display.proto",
+        "protos/perfetto/trace/android/view/displaycutout.proto",
+        "protos/perfetto/trace/android/view/imefocuscontroller.proto",
+        "protos/perfetto/trace/android/view/imeinsetssourceconsumer.proto",
+        "protos/perfetto/trace/android/view/inputmethod/editorinfo.proto",
+        "protos/perfetto/trace/android/view/inputmethod/inputconnection.proto",
+        "protos/perfetto/trace/android/view/inputmethod/inputmethodmanager.proto",
+        "protos/perfetto/trace/android/view/insetsanimationcontrolimpl.proto",
+        "protos/perfetto/trace/android/view/insetscontroller.proto",
+        "protos/perfetto/trace/android/view/insetssource.proto",
+        "protos/perfetto/trace/android/view/insetssourceconsumer.proto",
+        "protos/perfetto/trace/android/view/insetssourcecontrol.proto",
+        "protos/perfetto/trace/android/view/insetsstate.proto",
+        "protos/perfetto/trace/android/view/surfacecontrol.proto",
+        "protos/perfetto/trace/android/view/viewrootimpl.proto",
+        "protos/perfetto/trace/android/view/windowlayoutparams.proto",
+        "protos/perfetto/trace/android/winscope_extensions.proto",
+        "protos/perfetto/trace/android/winscope_extensions_impl.proto",
+        "protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto",
+        "protos/perfetto/trace/chrome/chrome_metadata.proto",
+        "protos/perfetto/trace/chrome/chrome_trace_event.proto",
+        "protos/perfetto/trace/chrome/chrome_trigger.proto",
+        "protos/perfetto/trace/chrome/v8.proto",
+        "protos/perfetto/trace/clock_snapshot.proto",
+        "protos/perfetto/trace/etw/etw.proto",
+        "protos/perfetto/trace/etw/etw_event.proto",
+        "protos/perfetto/trace/etw/etw_event_bundle.proto",
+        "protos/perfetto/trace/extension_descriptor.proto",
+        "protos/perfetto/trace/filesystem/inode_file_map.proto",
+        "protos/perfetto/trace/ftrace/android_fs.proto",
+        "protos/perfetto/trace/ftrace/binder.proto",
+        "protos/perfetto/trace/ftrace/block.proto",
+        "protos/perfetto/trace/ftrace/cgroup.proto",
+        "protos/perfetto/trace/ftrace/clk.proto",
+        "protos/perfetto/trace/ftrace/cma.proto",
+        "protos/perfetto/trace/ftrace/compaction.proto",
+        "protos/perfetto/trace/ftrace/cpuhp.proto",
+        "protos/perfetto/trace/ftrace/cros_ec.proto",
+        "protos/perfetto/trace/ftrace/dma_fence.proto",
+        "protos/perfetto/trace/ftrace/dmabuf_heap.proto",
+        "protos/perfetto/trace/ftrace/dpu.proto",
+        "protos/perfetto/trace/ftrace/drm.proto",
+        "protos/perfetto/trace/ftrace/ext4.proto",
+        "protos/perfetto/trace/ftrace/f2fs.proto",
+        "protos/perfetto/trace/ftrace/fastrpc.proto",
+        "protos/perfetto/trace/ftrace/fence.proto",
+        "protos/perfetto/trace/ftrace/filemap.proto",
+        "protos/perfetto/trace/ftrace/ftrace.proto",
+        "protos/perfetto/trace/ftrace/ftrace_event.proto",
+        "protos/perfetto/trace/ftrace/ftrace_event_bundle.proto",
+        "protos/perfetto/trace/ftrace/ftrace_stats.proto",
+        "protos/perfetto/trace/ftrace/g2d.proto",
+        "protos/perfetto/trace/ftrace/generic.proto",
+        "protos/perfetto/trace/ftrace/google_icc_trace.proto",
+        "protos/perfetto/trace/ftrace/google_irm_trace.proto",
+        "protos/perfetto/trace/ftrace/gpu_mem.proto",
+        "protos/perfetto/trace/ftrace/gpu_scheduler.proto",
+        "protos/perfetto/trace/ftrace/hyp.proto",
+        "protos/perfetto/trace/ftrace/i2c.proto",
+        "protos/perfetto/trace/ftrace/ion.proto",
+        "protos/perfetto/trace/ftrace/ipi.proto",
+        "protos/perfetto/trace/ftrace/irq.proto",
+        "protos/perfetto/trace/ftrace/kmem.proto",
+        "protos/perfetto/trace/ftrace/kvm.proto",
+        "protos/perfetto/trace/ftrace/lowmemorykiller.proto",
+        "protos/perfetto/trace/ftrace/lwis.proto",
+        "protos/perfetto/trace/ftrace/mali.proto",
+        "protos/perfetto/trace/ftrace/mdss.proto",
+        "protos/perfetto/trace/ftrace/mm_event.proto",
+        "protos/perfetto/trace/ftrace/net.proto",
+        "protos/perfetto/trace/ftrace/oom.proto",
+        "protos/perfetto/trace/ftrace/panel.proto",
+        "protos/perfetto/trace/ftrace/perf_trace_counters.proto",
+        "protos/perfetto/trace/ftrace/power.proto",
+        "protos/perfetto/trace/ftrace/printk.proto",
+        "protos/perfetto/trace/ftrace/raw_syscalls.proto",
+        "protos/perfetto/trace/ftrace/regulator.proto",
+        "protos/perfetto/trace/ftrace/rpm.proto",
+        "protos/perfetto/trace/ftrace/samsung.proto",
+        "protos/perfetto/trace/ftrace/sched.proto",
+        "protos/perfetto/trace/ftrace/scm.proto",
+        "protos/perfetto/trace/ftrace/sde.proto",
+        "protos/perfetto/trace/ftrace/signal.proto",
+        "protos/perfetto/trace/ftrace/skb.proto",
+        "protos/perfetto/trace/ftrace/sock.proto",
+        "protos/perfetto/trace/ftrace/sync.proto",
+        "protos/perfetto/trace/ftrace/synthetic.proto",
+        "protos/perfetto/trace/ftrace/systrace.proto",
+        "protos/perfetto/trace/ftrace/task.proto",
+        "protos/perfetto/trace/ftrace/tcp.proto",
+        "protos/perfetto/trace/ftrace/test_bundle_wrapper.proto",
+        "protos/perfetto/trace/ftrace/thermal.proto",
+        "protos/perfetto/trace/ftrace/trusty.proto",
+        "protos/perfetto/trace/ftrace/ufs.proto",
+        "protos/perfetto/trace/ftrace/v4l2.proto",
+        "protos/perfetto/trace/ftrace/virtio_gpu.proto",
+        "protos/perfetto/trace/ftrace/virtio_video.proto",
+        "protos/perfetto/trace/ftrace/vmscan.proto",
+        "protos/perfetto/trace/ftrace/workqueue.proto",
+        "protos/perfetto/trace/gpu/gpu_counter_event.proto",
+        "protos/perfetto/trace/gpu/gpu_log.proto",
+        "protos/perfetto/trace/gpu/gpu_render_stage_event.proto",
+        "protos/perfetto/trace/gpu/vulkan_api_event.proto",
+        "protos/perfetto/trace/gpu/vulkan_memory_event.proto",
+        "protos/perfetto/trace/interned_data/interned_data.proto",
+        "protos/perfetto/trace/memory_graph.proto",
+        "protos/perfetto/trace/perfetto/perfetto_metatrace.proto",
+        "protos/perfetto/trace/perfetto/tracing_service_event.proto",
+        "protos/perfetto/trace/power/android_energy_estimation_breakdown.proto",
+        "protos/perfetto/trace/power/android_entity_state_residency.proto",
+        "protos/perfetto/trace/power/battery_counters.proto",
+        "protos/perfetto/trace/power/power_rails.proto",
+        "protos/perfetto/trace/profiling/deobfuscation.proto",
+        "protos/perfetto/trace/profiling/heap_graph.proto",
+        "protos/perfetto/trace/profiling/profile_common.proto",
+        "protos/perfetto/trace/profiling/profile_packet.proto",
+        "protos/perfetto/trace/profiling/smaps.proto",
+        "protos/perfetto/trace/ps/process_stats.proto",
+        "protos/perfetto/trace/ps/process_tree.proto",
+        "protos/perfetto/trace/remote_clock_sync.proto",
+        "protos/perfetto/trace/statsd/statsd_atom.proto",
+        "protos/perfetto/trace/sys_stats/sys_stats.proto",
+        "protos/perfetto/trace/system_info.proto",
+        "protos/perfetto/trace/system_info/cpu_info.proto",
+        "protos/perfetto/trace/test_event.proto",
+        "protos/perfetto/trace/test_extensions.proto",
+        "protos/perfetto/trace/trace.proto",
+        "protos/perfetto/trace/trace_packet.proto",
+        "protos/perfetto/trace/trace_packet_defaults.proto",
+        "protos/perfetto/trace/trace_uuid.proto",
+        "protos/perfetto/trace/track_event/chrome_active_processes.proto",
+        "protos/perfetto/trace/track_event/chrome_application_state_info.proto",
+        "protos/perfetto/trace/track_event/chrome_compositor_scheduler_state.proto",
+        "protos/perfetto/trace/track_event/chrome_content_settings_event_info.proto",
+        "protos/perfetto/trace/track_event/chrome_frame_reporter.proto",
+        "protos/perfetto/trace/track_event/chrome_histogram_sample.proto",
+        "protos/perfetto/trace/track_event/chrome_keyed_service.proto",
+        "protos/perfetto/trace/track_event/chrome_latency_info.proto",
+        "protos/perfetto/trace/track_event/chrome_legacy_ipc.proto",
+        "protos/perfetto/trace/track_event/chrome_message_pump.proto",
+        "protos/perfetto/trace/track_event/chrome_mojo_event_info.proto",
+        "protos/perfetto/trace/track_event/chrome_process_descriptor.proto",
+        "protos/perfetto/trace/track_event/chrome_renderer_scheduler_state.proto",
+        "protos/perfetto/trace/track_event/chrome_thread_descriptor.proto",
+        "protos/perfetto/trace/track_event/chrome_user_event.proto",
+        "protos/perfetto/trace/track_event/chrome_window_handle_event_info.proto",
+        "protos/perfetto/trace/track_event/counter_descriptor.proto",
+        "protos/perfetto/trace/track_event/debug_annotation.proto",
+        "protos/perfetto/trace/track_event/log_message.proto",
+        "protos/perfetto/trace/track_event/pixel_modem.proto",
+        "protos/perfetto/trace/track_event/process_descriptor.proto",
+        "protos/perfetto/trace/track_event/range_of_interest.proto",
+        "protos/perfetto/trace/track_event/screenshot.proto",
+        "protos/perfetto/trace/track_event/source_location.proto",
+        "protos/perfetto/trace/track_event/task_execution.proto",
+        "protos/perfetto/trace/track_event/thread_descriptor.proto",
+        "protos/perfetto/trace/track_event/track_descriptor.proto",
+        "protos/perfetto/trace/track_event/track_event.proto",
+        "protos/perfetto/trace/translation/translation_table.proto",
+        "protos/perfetto/trace/trigger.proto",
+        "protos/perfetto/trace/ui_state.proto",
+    ],
+}
+
 // GN: //src/protozero/protoc_plugin:protozero_plugin
 cc_binary_host {
     name: "protozero_plugin",
@@ -15313,6 +15900,9 @@
         ":perfetto_protos_perfetto_config_system_info_zero_gen",
         ":perfetto_protos_perfetto_config_track_event_zero_gen",
         ":perfetto_protos_perfetto_config_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -15434,6 +16024,9 @@
         "perfetto_protos_perfetto_config_system_info_zero_gen_headers",
         "perfetto_protos_perfetto_config_track_event_zero_gen_headers",
         "perfetto_protos_perfetto_config_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -15548,6 +16141,8 @@
         ":perfetto_protos_perfetto_config_system_info_zero_gen",
         ":perfetto_protos_perfetto_config_track_event_zero_gen",
         ":perfetto_protos_perfetto_config_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -15623,6 +16218,8 @@
         "perfetto_protos_perfetto_config_system_info_zero_gen_headers",
         "perfetto_protos_perfetto_config_track_event_zero_gen_headers",
         "perfetto_protos_perfetto_config_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -15689,6 +16286,9 @@
         ":perfetto_protos_perfetto_config_system_info_zero_gen",
         ":perfetto_protos_perfetto_config_track_event_zero_gen",
         ":perfetto_protos_perfetto_config_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -15810,6 +16410,9 @@
         "perfetto_protos_perfetto_config_system_info_zero_gen_headers",
         "perfetto_protos_perfetto_config_track_event_zero_gen_headers",
         "perfetto_protos_perfetto_config_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -15939,6 +16542,8 @@
         ":perfetto_protos_perfetto_ipc_cpp_gen",
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -16038,6 +16643,8 @@
         "perfetto_protos_perfetto_ipc_cpp_gen_headers",
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -16140,6 +16747,8 @@
         ":perfetto_protos_perfetto_ipc_cpp_gen",
         ":perfetto_protos_perfetto_ipc_ipc_gen",
         ":perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen",
         ":perfetto_protos_perfetto_trace_android_zero_gen",
         ":perfetto_protos_perfetto_trace_chrome_zero_gen",
         ":perfetto_protos_perfetto_trace_etw_zero_gen",
@@ -16214,6 +16823,8 @@
         "perfetto_protos_perfetto_ipc_cpp_gen_headers",
         "perfetto_protos_perfetto_ipc_ipc_gen_headers",
         "perfetto_protos_perfetto_ipc_wire_protocol_cpp_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_regular_zero_gen_headers",
         "perfetto_protos_perfetto_trace_android_zero_gen_headers",
         "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
         "perfetto_protos_perfetto_trace_etw_zero_gen_headers",
@@ -16418,7 +17029,7 @@
 gensrcs {
     name: "perfetto_trace_javastream_protos",
     srcs: [
-        ":perfetto_trace_filegroup_proto",
+        ":perfetto_winscope_filegroup_proto",
     ],
     tools: [
         "aprotoc",
@@ -16428,7 +17039,7 @@
     cmd: "mkdir -p $(genDir)/$(in) " +
         "&& $(location aprotoc) " +
         "--plugin=$(location protoc-gen-javastream) " +
-        "--javastream_opt=include_filter:perfetto.protos.TracePacket,perfetto.protos.ShellTransition,perfetto.protos.ShellHandlerMappings,perfetto.protos.ProtoLogMessage,perfetto.protos.ProtoLogViewerConfig,perfetto.protos.ShellHandlerMapping,perfetto.protos.ShellHandlerMappings,perfetto.protos.ProtoLogGroup,perfetto.protos.ProtoLogConfig,perfetto.protos.DataSourceConfig,perfetto.protos.InternedString,perfetto.protos.InternedData,perfetto.protos.ProtoLogLevel,perfetto.protos.TestEvent,perfetto.protos.TestEvent.TestPayload,perfetto.protos.TestConfig,perfetto.protos.TestConfig.DummyFields " +
+        "--javastream_opt=include_filter:perfetto.protos.TracePacket,perfetto.protos.ShellTransition,perfetto.protos.ShellHandlerMappings,perfetto.protos.ProtoLogMessage,perfetto.protos.ProtoLogViewerConfig,perfetto.protos.ShellHandlerMapping,perfetto.protos.ShellHandlerMappings,perfetto.protos.ProtoLogGroup,perfetto.protos.ProtoLogConfig,perfetto.protos.DataSourceConfig,perfetto.protos.InternedString,perfetto.protos.InternedData,perfetto.protos.ProtoLogLevel,perfetto.protos.TestEvent,perfetto.protos.TestEvent.TestPayload,perfetto.protos.TestConfig,perfetto.protos.TestConfig.DummyFields,perfetto.protos.WinscopeExtensionsImpl,perfetto.protos.InputMethodClientsTraceProto,perfetto.protos.InputMethodManagerServiceTraceProto,perfetto.protos.InputMethodServiceTraceProto " +
         "--javastream_out=$(genDir)/$(in) " +
         "-Iexternal/protobuf/src " +
         "-Iexternal/perfetto " +
diff --git a/Android.bp.extras b/Android.bp.extras
index 3ebf51e..75d3a81 100644
--- a/Android.bp.extras
+++ b/Android.bp.extras
@@ -175,7 +175,7 @@
 gensrcs {
     name: "perfetto_trace_javastream_protos",
     srcs: [
-        ":perfetto_trace_filegroup_proto",
+        ":perfetto_winscope_filegroup_proto",
     ],
     tools: [
         "aprotoc",
@@ -185,7 +185,7 @@
     cmd: "mkdir -p $(genDir)/$(in) " +
         "&& $(location aprotoc) " +
         "--plugin=$(location protoc-gen-javastream) " +
-        "--javastream_opt=include_filter:perfetto.protos.TracePacket,perfetto.protos.ShellTransition,perfetto.protos.ShellHandlerMappings,perfetto.protos.ProtoLogMessage,perfetto.protos.ProtoLogViewerConfig,perfetto.protos.ShellHandlerMapping,perfetto.protos.ShellHandlerMappings,perfetto.protos.ProtoLogGroup,perfetto.protos.ProtoLogConfig,perfetto.protos.DataSourceConfig,perfetto.protos.InternedString,perfetto.protos.InternedData,perfetto.protos.ProtoLogLevel,perfetto.protos.TestEvent,perfetto.protos.TestEvent.TestPayload,perfetto.protos.TestConfig,perfetto.protos.TestConfig.DummyFields " +
+        "--javastream_opt=include_filter:perfetto.protos.TracePacket,perfetto.protos.ShellTransition,perfetto.protos.ShellHandlerMappings,perfetto.protos.ProtoLogMessage,perfetto.protos.ProtoLogViewerConfig,perfetto.protos.ShellHandlerMapping,perfetto.protos.ShellHandlerMappings,perfetto.protos.ProtoLogGroup,perfetto.protos.ProtoLogConfig,perfetto.protos.DataSourceConfig,perfetto.protos.InternedString,perfetto.protos.InternedData,perfetto.protos.ProtoLogLevel,perfetto.protos.TestEvent,perfetto.protos.TestEvent.TestPayload,perfetto.protos.TestConfig,perfetto.protos.TestConfig.DummyFields,perfetto.protos.WinscopeExtensionsImpl,perfetto.protos.InputMethodClientsTraceProto,perfetto.protos.InputMethodManagerServiceTraceProto,perfetto.protos.InputMethodServiceTraceProto " +
         "--javastream_out=$(genDir)/$(in) " +
         "-Iexternal/protobuf/src " +
         "-Iexternal/perfetto " +
diff --git a/BUILD b/BUILD
index 8ffa4e0..5d1e5be 100644
--- a/BUILD
+++ b/BUILD
@@ -318,6 +318,9 @@
                ":protos_perfetto_config_system_info_zero",
                ":protos_perfetto_config_track_event_zero",
                ":protos_perfetto_config_zero",
+               ":protos_perfetto_trace_android_winscope_common_zero",
+               ":protos_perfetto_trace_android_winscope_extensions_zero",
+               ":protos_perfetto_trace_android_winscope_regular_zero",
                ":protos_perfetto_trace_android_zero",
                ":protos_perfetto_trace_chrome_zero",
                ":protos_perfetto_trace_etw_zero",
@@ -406,6 +409,8 @@
         ":protos_perfetto_config_track_event_cpp",
         ":protos_perfetto_config_track_event_zero",
         ":protos_perfetto_config_zero",
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_regular_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
         ":protos_perfetto_trace_etw_zero",
@@ -522,6 +527,8 @@
         ":protos_perfetto_config_zero",
         ":protos_perfetto_ipc_cpp",
         ":protos_perfetto_ipc_ipc",
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_regular_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
         ":protos_perfetto_trace_etw_zero",
@@ -3611,6 +3618,8 @@
         ":protos_perfetto_config_system_info_protos",
         ":protos_perfetto_config_track_event_protos",
         ":protos_perfetto_trace_android_protos",
+        ":protos_perfetto_trace_android_winscope_common_protos",
+        ":protos_perfetto_trace_android_winscope_regular_protos",
         ":protos_perfetto_trace_chrome_protos",
         ":protos_perfetto_trace_etw_protos",
         ":protos_perfetto_trace_filesystem_protos",
@@ -4638,23 +4647,101 @@
         "protos/perfetto/trace/android/network_trace.proto",
         "protos/perfetto/trace/android/packages_list.proto",
         "protos/perfetto/trace/android/pixel_modem_events.proto",
-        "protos/perfetto/trace/android/protolog.proto",
-        "protos/perfetto/trace/android/shell_transition.proto",
-        "protos/perfetto/trace/android/surfaceflinger_common.proto",
-        "protos/perfetto/trace/android/surfaceflinger_layers.proto",
-        "protos/perfetto/trace/android/surfaceflinger_transactions.proto",
     ],
     visibility = [
         PERFETTO_CONFIG.proto_library_visibility,
     ],
     deps = [
         ":protos_perfetto_common_protos",
+        ":protos_perfetto_trace_android_winscope_common_protos",
+        ":protos_perfetto_trace_android_winscope_regular_protos",
     ],
 )
 
-# GN target: //protos/perfetto/trace/android:winscope_deps
+# GN target: //protos/perfetto/trace/android:winscope_common:source_set
 perfetto_proto_library(
-    name = "protos_perfetto_trace_android_winscope_deps_protos",
+    name = "protos_perfetto_trace_android_winscope_common_protos",
+    srcs = [
+        "protos/perfetto/trace/android/graphics/point.proto",
+        "protos/perfetto/trace/android/graphics/rect.proto",
+        "protos/perfetto/trace/android/winscope_extensions.proto",
+    ],
+    visibility = [
+        PERFETTO_CONFIG.proto_library_visibility,
+    ],
+)
+
+# GN target: //protos/perfetto/trace/android:winscope_common:zero
+perfetto_cc_protozero_library(
+    name = "protos_perfetto_trace_android_winscope_common_zero",
+    deps = [
+        ":protos_perfetto_trace_android_winscope_common_protos",
+    ],
+)
+
+# GN target: //protos/perfetto/trace/android:winscope_descriptor
+perfetto_proto_descriptor(
+    name = "protos_perfetto_trace_android_winscope_descriptor",
+    deps = [
+        ":protos_perfetto_trace_android_winscope_extensions_protos",
+        ":protos_perfetto_trace_android_winscope_regular_protos",
+    ],
+    outs = [
+        "protos_perfetto_trace_android_winscope_descriptor.bin",
+    ],
+)
+
+# GN target: //protos/perfetto/trace/android:winscope_extensions:source_set
+perfetto_proto_library(
+    name = "protos_perfetto_trace_android_winscope_extensions_protos",
+    srcs = [
+        "protos/perfetto/trace/android/graphics/pixelformat.proto",
+        "protos/perfetto/trace/android/inputmethodeditor.proto",
+        "protos/perfetto/trace/android/inputmethodservice/inputmethodservice.proto",
+        "protos/perfetto/trace/android/inputmethodservice/softinputwindow.proto",
+        "protos/perfetto/trace/android/server/inputmethod/inputmethodmanagerservice.proto",
+        "protos/perfetto/trace/android/typedef.proto",
+        "protos/perfetto/trace/android/view/display.proto",
+        "protos/perfetto/trace/android/view/displaycutout.proto",
+        "protos/perfetto/trace/android/view/imefocuscontroller.proto",
+        "protos/perfetto/trace/android/view/imeinsetssourceconsumer.proto",
+        "protos/perfetto/trace/android/view/inputmethod/editorinfo.proto",
+        "protos/perfetto/trace/android/view/inputmethod/inputconnection.proto",
+        "protos/perfetto/trace/android/view/inputmethod/inputmethodmanager.proto",
+        "protos/perfetto/trace/android/view/insetsanimationcontrolimpl.proto",
+        "protos/perfetto/trace/android/view/insetscontroller.proto",
+        "protos/perfetto/trace/android/view/insetssource.proto",
+        "protos/perfetto/trace/android/view/insetssourceconsumer.proto",
+        "protos/perfetto/trace/android/view/insetssourcecontrol.proto",
+        "protos/perfetto/trace/android/view/insetsstate.proto",
+        "protos/perfetto/trace/android/view/surfacecontrol.proto",
+        "protos/perfetto/trace/android/view/viewrootimpl.proto",
+        "protos/perfetto/trace/android/view/windowlayoutparams.proto",
+        "protos/perfetto/trace/android/winscope_extensions_impl.proto",
+    ],
+    visibility = [
+        PERFETTO_CONFIG.proto_library_visibility,
+    ],
+    deps = [
+        ":protos_perfetto_trace_android_winscope_common_protos",
+    ] + PERFETTO_CONFIG.deps.protobuf_descriptor_proto,
+    exports = [
+        ":protos_perfetto_trace_android_winscope_common_protos",
+    ],
+)
+
+# GN target: //protos/perfetto/trace/android:winscope_extensions:zero
+perfetto_cc_protozero_library(
+    name = "protos_perfetto_trace_android_winscope_extensions_zero",
+    deps = [
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_extensions_protos",
+    ],
+)
+
+# GN target: //protos/perfetto/trace/android:winscope_regular:source_set
+perfetto_proto_library(
+    name = "protos_perfetto_trace_android_winscope_regular_protos",
     srcs = [
         "protos/perfetto/trace/android/protolog.proto",
         "protos/perfetto/trace/android/shell_transition.proto",
@@ -4667,17 +4754,17 @@
     ],
     deps = [
         ":protos_perfetto_common_protos",
+        ":protos_perfetto_trace_android_winscope_common_protos",
     ],
 )
 
-# GN target: //protos/perfetto/trace/android:winscope_descriptor
-perfetto_proto_descriptor(
-    name = "protos_perfetto_trace_android_winscope_descriptor",
+# GN target: //protos/perfetto/trace/android:winscope_regular:zero
+perfetto_cc_protozero_library(
+    name = "protos_perfetto_trace_android_winscope_regular_zero",
     deps = [
-        ":protos_perfetto_trace_android_winscope_deps_protos",
-    ],
-    outs = [
-        "protos_perfetto_trace_android_winscope_descriptor.bin",
+        ":protos_perfetto_common_zero",
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_regular_protos",
     ],
 )
 
@@ -4687,6 +4774,8 @@
     deps = [
         ":protos_perfetto_common_zero",
         ":protos_perfetto_trace_android_protos",
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_regular_zero",
     ],
 )
 
@@ -4891,6 +4980,8 @@
     deps = [
         ":protos_perfetto_common_protos",
         ":protos_perfetto_trace_android_protos",
+        ":protos_perfetto_trace_android_winscope_common_protos",
+        ":protos_perfetto_trace_android_winscope_regular_protos",
         ":protos_perfetto_trace_chrome_protos",
         ":protos_perfetto_trace_gpu_protos",
         ":protos_perfetto_trace_profiling_protos",
@@ -4903,6 +4994,8 @@
     name = "protos_perfetto_trace_interned_data_zero",
     deps = [
         ":protos_perfetto_common_zero",
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_regular_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
         ":protos_perfetto_trace_gpu_zero",
@@ -4997,6 +5090,8 @@
         ":protos_perfetto_config_system_info_protos",
         ":protos_perfetto_config_track_event_protos",
         ":protos_perfetto_trace_android_protos",
+        ":protos_perfetto_trace_android_winscope_common_protos",
+        ":protos_perfetto_trace_android_winscope_regular_protos",
         ":protos_perfetto_trace_chrome_protos",
         ":protos_perfetto_trace_etw_protos",
         ":protos_perfetto_trace_filesystem_protos",
@@ -5037,6 +5132,8 @@
         ":protos_perfetto_config_system_info_zero",
         ":protos_perfetto_config_track_event_zero",
         ":protos_perfetto_config_zero",
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_regular_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
         ":protos_perfetto_trace_etw_zero",
@@ -5517,6 +5614,8 @@
         ":protos_perfetto_config_zero",
         ":protos_perfetto_ipc_cpp",
         ":protos_perfetto_ipc_ipc",
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_regular_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
         ":protos_perfetto_trace_etw_zero",
@@ -5609,6 +5708,8 @@
         ":protos_perfetto_config_zero",
         ":protos_perfetto_ipc_cpp",
         ":protos_perfetto_ipc_ipc",
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_regular_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
         ":protos_perfetto_trace_etw_zero",
@@ -5716,6 +5817,8 @@
         ":protos_perfetto_config_zero",
         ":protos_perfetto_ipc_cpp",
         ":protos_perfetto_ipc_ipc",
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_regular_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
         ":protos_perfetto_trace_etw_zero",
@@ -5849,6 +5952,9 @@
                ":protos_perfetto_config_system_info_zero",
                ":protos_perfetto_config_track_event_zero",
                ":protos_perfetto_config_zero",
+               ":protos_perfetto_trace_android_winscope_common_zero",
+               ":protos_perfetto_trace_android_winscope_extensions_zero",
+               ":protos_perfetto_trace_android_winscope_regular_zero",
                ":protos_perfetto_trace_android_zero",
                ":protos_perfetto_trace_chrome_zero",
                ":protos_perfetto_trace_etw_zero",
@@ -6008,6 +6114,9 @@
                ":protos_perfetto_config_system_info_zero",
                ":protos_perfetto_config_track_event_zero",
                ":protos_perfetto_config_zero",
+               ":protos_perfetto_trace_android_winscope_common_zero",
+               ":protos_perfetto_trace_android_winscope_extensions_zero",
+               ":protos_perfetto_trace_android_winscope_regular_zero",
                ":protos_perfetto_trace_android_zero",
                ":protos_perfetto_trace_chrome_zero",
                ":protos_perfetto_trace_etw_zero",
@@ -6096,6 +6205,8 @@
         ":protos_perfetto_config_system_info_zero",
         ":protos_perfetto_config_track_event_zero",
         ":protos_perfetto_config_zero",
+        ":protos_perfetto_trace_android_winscope_common_zero",
+        ":protos_perfetto_trace_android_winscope_regular_zero",
         ":protos_perfetto_trace_android_zero",
         ":protos_perfetto_trace_chrome_zero",
         ":protos_perfetto_trace_etw_zero",
@@ -6236,6 +6347,9 @@
                ":protos_perfetto_config_system_info_zero",
                ":protos_perfetto_config_track_event_zero",
                ":protos_perfetto_config_zero",
+               ":protos_perfetto_trace_android_winscope_common_zero",
+               ":protos_perfetto_trace_android_winscope_extensions_zero",
+               ":protos_perfetto_trace_android_winscope_regular_zero",
                ":protos_perfetto_trace_android_zero",
                ":protos_perfetto_trace_chrome_zero",
                ":protos_perfetto_trace_etw_zero",
diff --git a/include/perfetto/ext/base/flat_hash_map.h b/include/perfetto/ext/base/flat_hash_map.h
index 0be192d..f4046ea 100644
--- a/include/perfetto/ext/base/flat_hash_map.h
+++ b/include/perfetto/ext/base/flat_hash_map.h
@@ -23,7 +23,6 @@
 #include "perfetto/ext/base/utils.h"
 
 #include <algorithm>
-#include <functional>
 #include <limits>
 
 namespace perfetto {
@@ -45,6 +44,11 @@
 // tsl::robin_map:            931,403,397 ns    243.622M insertions/s
 // absl::flat_hash_map:       998,013,459 ns    227.379M insertions/s
 // FollyF14FastMap:         1,181,480,602 ns    192.074M insertions/s
+//
+// TODO(primiano): the table regresses for heavy insert+erase workloads since we
+// don't clean up tombstones outside of resizes. In the limit, the entire
+// table's capacity is made up of values/tombstones, so each search has to
+// exhaustively scan the full capacity.
 
 // The structs below define the probing algorithm used to probe slots upon a
 // collision. They are guaranteed to visit all slots as our table size is always
diff --git a/include/perfetto/ext/base/hash.h b/include/perfetto/ext/base/hash.h
index 548003e..7809ed7 100644
--- a/include/perfetto/ext/base/hash.h
+++ b/include/perfetto/ext/base/hash.h
@@ -62,7 +62,7 @@
 
   // Allow hashing anything that has a |data| field, a |size| field,
   // and has the kHashable trait (e.g., base::StringView).
-  template <typename T, typename = std::enable_if<T::kHashable>>
+  template <typename T, typename = std::enable_if_t<T::kHashable>>
   void Update(const T& t) {
     Update(t.data(), t.size());
   }
diff --git a/protos/perfetto/trace/android/BUILD.gn b/protos/perfetto/trace/android/BUILD.gn
index 1910078..0c31db6 100644
--- a/protos/perfetto/trace/android/BUILD.gn
+++ b/protos/perfetto/trace/android/BUILD.gn
@@ -15,7 +15,7 @@
 import("../../../../gn/proto_library.gni")
 
 perfetto_proto_library("@TYPE@") {
-  deps = [ "../../common:@TYPE@" ]
+  deps = [ "../../common:@TYPE@", ":winscope_regular:@TYPE@" ]
 
   sources = [
     "android_game_intervention_list.proto",
@@ -30,17 +30,23 @@
     "network_trace.proto",
     "packages_list.proto",
     "pixel_modem_events.proto",
-    "protolog.proto",
-    "shell_transition.proto",
-    "surfaceflinger_common.proto",
-    "surfaceflinger_layers.proto",
-    "surfaceflinger_transactions.proto",
   ]
 }
 
-perfetto_proto_library("winscope_deps") {
-  proto_generators = [ "source_set" ]
-  deps = [ "../../common:@TYPE@" ]
+perfetto_proto_library("winscope_common:@TYPE@") {
+  sources = [
+    "graphics/point.proto",
+    "graphics/rect.proto",
+    "winscope_extensions.proto",
+  ]
+}
+
+# Winscope messages added to TracePacket directly
+perfetto_proto_library("winscope_regular:@TYPE@") {
+  deps = [
+    "../../common:@TYPE@",
+    ":winscope_common:@TYPE@",
+  ]
   sources = [
     "protolog.proto",
     "shell_transition.proto",
@@ -50,9 +56,44 @@
   ]
 }
 
+# Winscope messages added to TracePacket as extensions
+perfetto_proto_library("winscope_extensions:@TYPE@") {
+  public_deps = [ ":winscope_common:@TYPE@" ]
+  sources = [
+    "inputmethodeditor.proto",
+    "graphics/pixelformat.proto",
+    "inputmethodservice/inputmethodservice.proto",
+    "inputmethodservice/softinputwindow.proto",
+    "server/inputmethod/inputmethodmanagerservice.proto",
+    "typedef.proto",
+    "view/inputmethod/editorinfo.proto",
+    "view/inputmethod/inputconnection.proto",
+    "view/inputmethod/inputmethodmanager.proto",
+    "view/display.proto",
+    "view/displaycutout.proto",
+    "view/imefocuscontroller.proto",
+    "view/imeinsetssourceconsumer.proto",
+    "view/insetsanimationcontrolimpl.proto",
+    "view/insetscontroller.proto",
+    "view/insetssource.proto",
+    "view/insetssourceconsumer.proto",
+    "view/insetssourcecontrol.proto",
+    "view/insetsstate.proto",
+    "view/surfacecontrol.proto",
+    "view/viewrootimpl.proto",
+    "view/windowlayoutparams.proto",
+    "winscope_extensions_impl.proto",
+  ]
+  import_dirs = [ "${perfetto_protobuf_src_dir}" ]
+}
+
 perfetto_proto_library("winscope_descriptor") {
   proto_generators = [ "descriptor" ]
   generate_descriptor = "winscope.descriptor"
-  deps = [ ":winscope_deps" ]
+  deps = [
+    ":winscope_regular:source_set",
+    ":winscope_extensions:source_set",
+  ]
   sources = [ "winscope.proto" ]
+  import_dirs = [ "${perfetto_protobuf_src_dir}" ]
 }
diff --git a/protos/perfetto/trace/android/graphics/pixelformat.proto b/protos/perfetto/trace/android/graphics/pixelformat.proto
new file mode 100644
index 0000000..71dd948
--- /dev/null
+++ b/protos/perfetto/trace/android/graphics/pixelformat.proto
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+message PixelFormatProto {
+  enum Format {
+    UNKNOWN = 0;
+    TRANSLUCENT = -3;
+    TRANSPARENT = -2;
+    OPAQUE = -1;
+    RGBA_8888 = 1;
+    RGBX_8888 = 2;
+    RGB_888 = 3;
+    RGB_565 = 4;
+    RGBA_F16 = 0x16;
+    RGBA_1010102 = 0x2B;
+  }
+}
diff --git a/protos/perfetto/trace/android/graphics/point.proto b/protos/perfetto/trace/android/graphics/point.proto
new file mode 100644
index 0000000..cd25fa3
--- /dev/null
+++ b/protos/perfetto/trace/android/graphics/point.proto
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+message PointProto {
+  optional int32 x = 1;
+  optional int32 y = 2;
+}
diff --git a/protos/perfetto/trace/android/graphics/rect.proto b/protos/perfetto/trace/android/graphics/rect.proto
new file mode 100644
index 0000000..337a4f1
--- /dev/null
+++ b/protos/perfetto/trace/android/graphics/rect.proto
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+message RectProto {
+  optional int32 left = 1;
+  optional int32 top = 2;
+  optional int32 right = 3;
+  optional int32 bottom = 4;
+}
diff --git a/protos/perfetto/trace/android/inputmethodeditor.proto b/protos/perfetto/trace/android/inputmethodeditor.proto
new file mode 100644
index 0000000..29aeef1
--- /dev/null
+++ b/protos/perfetto/trace/android/inputmethodeditor.proto
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+import "protos/perfetto/trace/android/inputmethodservice/inputmethodservice.proto";
+import "protos/perfetto/trace/android/server/inputmethod/inputmethodmanagerservice.proto";
+import "protos/perfetto/trace/android/view/inputmethod/inputmethodmanager.proto";
+import "protos/perfetto/trace/android/view/viewrootimpl.proto";
+import "protos/perfetto/trace/android/view/insetscontroller.proto";
+import "protos/perfetto/trace/android/view/imeinsetssourceconsumer.proto";
+import "protos/perfetto/trace/android/view/inputmethod/editorinfo.proto";
+import "protos/perfetto/trace/android/view/inputmethod/inputconnection.proto";
+import "protos/perfetto/trace/android/view/imefocuscontroller.proto";
+
+// One dump entry for clients that use InputMethod
+message InputMethodClientsTraceProto {
+  // elapsed realtime in nanos since boot of when this entry was logged
+  optional fixed64 elapsed_realtime_nanos = 1;
+
+  // where the trace originated
+  optional string where = 2;
+
+  optional ClientSideProto client = 3;
+
+  // groups together the dump from ime related client side classes
+  message ClientSideProto {
+    optional int32 display_id = 1;
+    optional InputMethodManagerProto input_method_manager = 2;
+    optional ViewRootImplProto view_root_impl = 3;
+    optional InsetsControllerProto insets_controller = 4;
+    optional ImeInsetsSourceConsumerProto ime_insets_source_consumer = 5;
+    optional EditorInfoProto editor_info = 6;
+    optional ImeFocusControllerProto ime_focus_controller = 7;
+    optional InputConnectionProto input_connection = 8;
+    optional InputConnectionCallProto input_connection_call = 9;
+  }
+}
+
+// One dump entry for InputMethodService
+message InputMethodServiceTraceProto {
+  // elapsed realtime in nanos since boot of when this entry was logged
+  optional fixed64 elapsed_realtime_nanos = 1;
+
+  // where the trace originated
+  optional string where = 2;
+
+  optional InputMethodServiceProto input_method_service = 3;
+}
+
+// One dump entry for InputMethodManagerService
+message InputMethodManagerServiceTraceProto {
+  // elapsed realtime in nanos since boot of when this entry was logged
+  optional fixed64 elapsed_realtime_nanos = 1;
+
+  // where the trace originated
+  optional string where = 2;
+
+  optional InputMethodManagerServiceProto input_method_manager_service = 3;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/inputmethodservice/inputmethodservice.proto b/protos/perfetto/trace/android/inputmethodservice/inputmethodservice.proto
new file mode 100644
index 0000000..982dedb
--- /dev/null
+++ b/protos/perfetto/trace/android/inputmethodservice/inputmethodservice.proto
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/inputmethodservice/softinputwindow.proto";
+import "protos/perfetto/trace/android/view/inputmethod/editorinfo.proto";
+import "protos/perfetto/trace/android/view/inputmethod/inputconnection.proto";
+
+package perfetto.protos;
+
+message InputMethodServiceProto {
+  optional SoftInputWindowProto soft_input_window = 1;
+  optional bool views_created = 2;
+  optional bool decor_view_visible = 3;
+  optional bool decor_view_was_visible = 4;
+  optional bool window_visible = 5;
+  optional bool in_show_window = 6;
+  optional string configuration = 7;
+  optional string token = 8;
+  optional string input_binding = 9;
+  optional bool input_started = 10;
+  optional bool input_view_started = 11;
+  optional bool candidates_view_started = 12;
+  optional EditorInfoProto input_editor_info = 13;
+  optional bool show_input_requested = 14;
+  optional bool last_show_input_requested = 15;
+  // can_pre_render
+  reserved 16;
+  // is_pre_rendered
+  reserved 17;
+  optional int32 show_input_flags = 18;
+  optional int32 candidates_visibility = 19;
+  optional bool fullscreen_applied = 20;
+  optional bool is_fullscreen = 21;
+  optional bool extract_view_hidden = 22;
+  optional int32 extracted_token = 23;
+  optional bool is_input_view_shown = 24;
+  optional int32 status_icon = 25;
+  optional InsetsProto last_computed_insets = 26;
+  optional string settings_observer = 27;
+  optional InputConnectionCallProto input_connection_call = 28;
+
+  message InsetsProto {
+    optional int32 content_top_insets = 1;
+    optional int32 visible_top_insets = 2;
+    optional int32 touchable_insets = 3;
+    optional string touchable_region = 4;
+  }
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/inputmethodservice/softinputwindow.proto b/protos/perfetto/trace/android/inputmethodservice/softinputwindow.proto
new file mode 100644
index 0000000..1066ea3
--- /dev/null
+++ b/protos/perfetto/trace/android/inputmethodservice/softinputwindow.proto
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+message SoftInputWindowProto {
+  // name
+  reserved 1;
+  // window_type
+  reserved 2;
+  // gravity
+  reserved 3;
+  // takes_focus
+  reserved 4;
+  // bounds
+  reserved 5;
+  optional int32 window_state = 6;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/server/inputmethod/inputmethodmanagerservice.proto b/protos/perfetto/trace/android/server/inputmethod/inputmethodmanagerservice.proto
new file mode 100644
index 0000000..a9a0d9a
--- /dev/null
+++ b/protos/perfetto/trace/android/server/inputmethod/inputmethodmanagerservice.proto
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/view/inputmethod/editorinfo.proto";
+
+package perfetto.protos;
+
+message InputMethodManagerServiceProto {
+  optional string cur_method_id = 1;
+  optional int32 cur_seq = 2;
+  optional string cur_client = 3;
+  optional string cur_focused_window_name = 4;
+  optional string last_ime_target_window_name = 5;
+  optional string cur_focused_window_soft_input_mode = 6;
+  optional EditorInfoProto cur_attribute = 7;
+  optional string cur_id = 8;
+  // deprecated show_requested
+  reserved 9;
+  optional bool show_explicitly_requested = 10;
+  optional bool show_forced = 11;
+  optional bool input_shown = 12;
+  optional bool in_fullscreen_mode = 13;
+  optional string cur_token = 14;
+  optional int32 cur_token_display_id = 15;
+  optional bool system_ready = 16;
+  optional int32 last_switch_user_id = 17;
+  optional bool have_connection = 18;
+  optional bool bound_to_method = 19;
+  optional bool is_interactive = 20;
+  optional int32 back_disposition = 21;
+  optional int32 ime_window_visibility = 22;
+  optional bool show_ime_with_hard_keyboard = 23;
+  optional bool accessibility_requesting_no_soft_keyboard = 24;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/surfaceflinger_common.proto b/protos/perfetto/trace/android/surfaceflinger_common.proto
index ef27e11..72f8159 100644
--- a/protos/perfetto/trace/android/surfaceflinger_common.proto
+++ b/protos/perfetto/trace/android/surfaceflinger_common.proto
@@ -16,6 +16,8 @@
 
 syntax = "proto2";
 
+import "protos/perfetto/trace/android/graphics/rect.proto";
+
 package perfetto.protos;
 
 message RegionProto {
@@ -24,13 +26,6 @@
   repeated RectProto rect = 2;
 }
 
-message RectProto {
-  optional int32 left = 1;
-  optional int32 top = 2;
-  optional int32 right = 3;
-  optional int32 bottom = 4;
-}
-
 message SizeProto {
   optional int32 w = 1;
   optional int32 h = 2;
diff --git a/protos/perfetto/trace/android/surfaceflinger_layers.proto b/protos/perfetto/trace/android/surfaceflinger_layers.proto
index 6640fa7..bdc40d8 100644
--- a/protos/perfetto/trace/android/surfaceflinger_layers.proto
+++ b/protos/perfetto/trace/android/surfaceflinger_layers.proto
@@ -19,6 +19,7 @@
 package perfetto.protos;
 
 import "protos/perfetto/trace/android/surfaceflinger_common.proto";
+import "protos/perfetto/trace/android/graphics/rect.proto";
 
 // Message used by Winscope to process legacy trace files.
 // Represents a file full of surface flinger trace entries.
diff --git a/protos/perfetto/trace/android/surfaceflinger_transactions.proto b/protos/perfetto/trace/android/surfaceflinger_transactions.proto
index efc709c..bd128d8 100644
--- a/protos/perfetto/trace/android/surfaceflinger_transactions.proto
+++ b/protos/perfetto/trace/android/surfaceflinger_transactions.proto
@@ -19,6 +19,7 @@
 package perfetto.protos;
 
 import "protos/perfetto/trace/android/surfaceflinger_common.proto";
+import "protos/perfetto/trace/android/graphics/rect.proto";
 
 // Message used by Winscope to process legacy trace files.
 // Represents a file full of surface flinger transactions.
diff --git a/protos/perfetto/trace/android/typedef.proto b/protos/perfetto/trace/android/typedef.proto
new file mode 100644
index 0000000..495c648
--- /dev/null
+++ b/protos/perfetto/trace/android/typedef.proto
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+import "google/protobuf/descriptor.proto";
+
+extend google.protobuf.FieldOptions {
+  // Used to specify the IntDef annotation type so that ints
+  // can be associated with their string representation
+
+  // 60001 is a random field numbers assigned to the custom options
+  // numbers between 50000 and 99999 are reserved for internal use within
+  // individual organizations
+  optional string typedef = 60001;
+}
diff --git a/protos/perfetto/trace/android/view/display.proto b/protos/perfetto/trace/android/view/display.proto
new file mode 100644
index 0000000..43844c8
--- /dev/null
+++ b/protos/perfetto/trace/android/view/display.proto
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+package perfetto.protos;
+
+message ViewDisplayProto {
+  enum ColorMode {
+    COLOR_MODE_INVALID = -1;
+    // The default or native gamut of the display.
+    COLOR_MODE_DEFAULT = 0;
+    COLOR_MODE_BT601_625 = 1;
+    COLOR_MODE_BT601_625_UNADJUSTED = 2;
+    COLOR_MODE_BT601_525 = 3;
+    COLOR_MODE_BT601_525_UNADJUSTED = 4;
+    COLOR_MODE_BT709 = 5;
+    COLOR_MODE_DCI_P3 = 6;
+    COLOR_MODE_SRGB = 7;
+    COLOR_MODE_ADOBE_RGB = 8;
+    COLOR_MODE_DISPLAY_P3 = 9;
+  }
+}
diff --git a/protos/perfetto/trace/android/view/displaycutout.proto b/protos/perfetto/trace/android/view/displaycutout.proto
new file mode 100644
index 0000000..a7e5c94
--- /dev/null
+++ b/protos/perfetto/trace/android/view/displaycutout.proto
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/graphics/rect.proto";
+
+package perfetto.protos;
+
+message DisplayCutoutProto {
+  optional RectProto insets = 1;
+  // RectProto bounds
+  reserved 2;
+  optional RectProto bound_left = 3;
+  optional RectProto bound_top = 4;
+  optional RectProto bound_right = 5;
+  optional RectProto bound_bottom = 6;
+  optional RectProto waterfall_insets = 7;
+  repeated int32 side_overrides = 8;
+}
diff --git a/protos/perfetto/trace/android/view/imefocuscontroller.proto b/protos/perfetto/trace/android/view/imefocuscontroller.proto
new file mode 100644
index 0000000..3e86304
--- /dev/null
+++ b/protos/perfetto/trace/android/view/imefocuscontroller.proto
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.ImeFocusController} object
+message ImeFocusControllerProto {
+  optional bool has_ime_focus = 1;
+  optional string served_view = 2 [deprecated = true];
+  optional string next_served_view = 3 [deprecated = true];
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/imeinsetssourceconsumer.proto b/protos/perfetto/trace/android/view/imeinsetssourceconsumer.proto
new file mode 100644
index 0000000..280c2fd
--- /dev/null
+++ b/protos/perfetto/trace/android/view/imeinsetssourceconsumer.proto
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/view/insetssourceconsumer.proto";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.ImeInsetsSourceConsumer} object
+message ImeInsetsSourceConsumerProto {
+  optional InsetsSourceConsumerProto insets_source_consumer = 1;
+  // focused_editor = 2
+  reserved 2;
+  optional bool is_requested_visible_awaiting_control = 3;
+  optional bool is_hide_animation_running = 4 [deprecated = true];
+  optional bool is_show_requested_during_hide_animation = 5 [deprecated = true];
+  optional bool has_pending_request = 6;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/inputmethod/editorinfo.proto b/protos/perfetto/trace/android/view/inputmethod/editorinfo.proto
new file mode 100644
index 0000000..bc2847f
--- /dev/null
+++ b/protos/perfetto/trace/android/view/inputmethod/editorinfo.proto
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.inputmethod.EditorInfo} object
+message EditorInfoProto {
+  optional int32 input_type = 1;
+  optional int32 ime_options = 2;
+  optional string private_ime_options = 3;
+  optional string package_name = 4;
+  optional int32 field_id = 5;
+  optional int32 target_input_method_user_id = 6;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/inputmethod/inputconnection.proto b/protos/perfetto/trace/android/view/inputmethod/inputconnection.proto
new file mode 100644
index 0000000..5a5f177
--- /dev/null
+++ b/protos/perfetto/trace/android/view/inputmethod/inputconnection.proto
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.inputmethod.InputConnection} object
+message InputConnectionProto {
+  // string editable_text
+  reserved 1;
+  // string selected_text
+  reserved 2;
+  optional int32 selected_text_start = 3;
+  optional int32 selected_text_end = 4;
+  optional int32 cursor_caps_mode = 5;
+}
+
+// Shows information about parameters and result for method calls to
+// {@link android.view.inputmethod.InputConnection}
+message InputConnectionCallProto {
+  oneof method_call {
+    GetTextBeforeCursor get_text_before_cursor = 1;
+    GetTextAfterCursor get_text_after_cursor = 2;
+    GetSelectedText get_selected_text = 3;
+    GetSurroundingText get_surrounding_text = 4;
+    GetCursorCapsMode get_cursor_caps_mode = 5;
+    GetExtractedText get_extracted_text = 6;
+  }
+
+  message GetTextBeforeCursor {
+    optional int32 length = 1;
+    optional int32 flags = 2;
+    // string result
+    reserved 3;
+  }
+
+  message GetTextAfterCursor {
+    optional int32 length = 1;
+    optional int32 flags = 2;
+    // string result
+    reserved 3;
+  }
+
+  message GetSelectedText {
+    optional int32 flags = 1;
+    // string result
+    reserved 2;
+  }
+
+  message GetSurroundingText {
+    optional int32 before_length = 1;
+    optional int32 after_length = 2;
+    optional int32 flags = 3;
+    optional SurroundingText result = 4;
+
+    message SurroundingText {
+      // string text
+      reserved 1;
+      optional int32 selection_start = 2;
+      optional int32 selection_end = 3;
+      optional int32 offset = 4;
+    }
+  }
+
+  message GetCursorCapsMode {
+    optional int32 req_modes = 1;
+    optional int32 result = 2;
+  }
+
+  message GetExtractedText {
+    optional ExtractedTextRequest request = 1;
+    optional int32 flags = 2;
+    // string result
+    reserved 3;
+
+    message ExtractedTextRequest {
+      optional int32 token = 1;
+      optional int32 flags = 2;
+      optional int32 hint_max_lines = 3;
+      optional int32 hint_max_chars = 4;
+    }
+  }
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/inputmethod/inputmethodmanager.proto b/protos/perfetto/trace/android/view/inputmethod/inputmethodmanager.proto
new file mode 100644
index 0000000..e93be02
--- /dev/null
+++ b/protos/perfetto/trace/android/view/inputmethod/inputmethodmanager.proto
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.inputmethod.InputMethodManager} object
+message InputMethodManagerProto {
+  optional string cur_id = 1;
+  optional bool fullscreen_mode = 2;
+  optional int32 display_id = 3;
+  optional bool active = 4;
+  optional bool served_connecting = 5;
+  optional string served_view = 6;
+  optional string next_served_view = 7;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/insetsanimationcontrolimpl.proto b/protos/perfetto/trace/android/view/insetsanimationcontrolimpl.proto
new file mode 100644
index 0000000..9cd871d
--- /dev/null
+++ b/protos/perfetto/trace/android/view/insetsanimationcontrolimpl.proto
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.InsetsAnimationControlImpl} object
+message InsetsAnimationControlImplProto {
+  optional bool is_cancelled = 1;
+  optional bool is_finished = 2;
+  optional string tmp_matrix = 3;
+  optional string pending_insets = 4;
+  optional float pending_fraction = 5;
+  optional bool shown_on_finish = 6;
+  optional float current_alpha = 7;
+  optional float pending_alpha = 8;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/insetscontroller.proto b/protos/perfetto/trace/android/view/insetscontroller.proto
new file mode 100644
index 0000000..e5728ee
--- /dev/null
+++ b/protos/perfetto/trace/android/view/insetscontroller.proto
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/view/insetsstate.proto";
+import "protos/perfetto/trace/android/view/insetsanimationcontrolimpl.proto";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.InsetsController} object
+message InsetsControllerProto {
+  optional InsetsStateProto state = 1;
+  repeated InsetsAnimationControlImplProto control = 2;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/insetssource.proto b/protos/perfetto/trace/android/view/insetssource.proto
new file mode 100644
index 0000000..b09d81d
--- /dev/null
+++ b/protos/perfetto/trace/android/view/insetssource.proto
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/graphics/rect.proto";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.InsetsSource} object
+message InsetsSourceProto {
+  optional string type = 1 [deprecated = true];
+  optional RectProto frame = 2;
+  optional RectProto visible_frame = 3;
+  optional bool visible = 4;
+  optional int32 type_number = 5;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/insetssourceconsumer.proto b/protos/perfetto/trace/android/view/insetssourceconsumer.proto
new file mode 100644
index 0000000..1d0a860
--- /dev/null
+++ b/protos/perfetto/trace/android/view/insetssourceconsumer.proto
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/view/insetssourcecontrol.proto";
+import "protos/perfetto/trace/android/graphics/rect.proto";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.InsetsSourceConsumer} object
+message InsetsSourceConsumerProto {
+  optional string internal_insets_type = 1 [deprecated = true];
+  optional bool has_window_focus = 2;
+  optional bool is_requested_visible = 3;
+  optional InsetsSourceControlProto source_control = 4;
+  optional RectProto pending_frame = 5;
+  optional RectProto pending_visible_frame = 6;
+  optional int32 animation_state = 7;
+  optional int32 type_number = 8;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/insetssourcecontrol.proto b/protos/perfetto/trace/android/view/insetssourcecontrol.proto
new file mode 100644
index 0000000..5507f8b
--- /dev/null
+++ b/protos/perfetto/trace/android/view/insetssourcecontrol.proto
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/graphics/point.proto";
+import "protos/perfetto/trace/android/view/surfacecontrol.proto";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.InsetsSourceControl} object
+message InsetsSourceControlProto {
+  optional string type = 1 [deprecated = true];
+  optional PointProto position = 2;
+  optional SurfaceControlProto leash = 3;
+  optional int32 type_number = 4;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/insetsstate.proto b/protos/perfetto/trace/android/view/insetsstate.proto
new file mode 100644
index 0000000..89ac016
--- /dev/null
+++ b/protos/perfetto/trace/android/view/insetsstate.proto
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/graphics/rect.proto";
+import "protos/perfetto/trace/android/view/displaycutout.proto";
+import "protos/perfetto/trace/android/view/insetssource.proto";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.InsetsState} object
+message InsetsStateProto {
+  repeated InsetsSourceProto sources = 1;
+  optional RectProto display_frame = 2;
+  optional DisplayCutoutProto display_cutout = 3;
+}
diff --git a/protos/perfetto/trace/android/view/surfacecontrol.proto b/protos/perfetto/trace/android/view/surfacecontrol.proto
new file mode 100644
index 0000000..5b6a0c8
--- /dev/null
+++ b/protos/perfetto/trace/android/view/surfacecontrol.proto
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.SurfaceControl} object
+message SurfaceControlProto {
+  optional int32 hash_code = 1;
+  optional string name = 2;
+  optional int32 layerId = 3;
+}
diff --git a/protos/perfetto/trace/android/view/viewrootimpl.proto b/protos/perfetto/trace/android/view/viewrootimpl.proto
new file mode 100644
index 0000000..aab3ea1
--- /dev/null
+++ b/protos/perfetto/trace/android/view/viewrootimpl.proto
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/graphics/rect.proto";
+import "protos/perfetto/trace/android/view/displaycutout.proto";
+import "protos/perfetto/trace/android/view/windowlayoutparams.proto";
+
+package perfetto.protos;
+
+// Represents a {@link android.view.ViewRootImpl} object
+message ViewRootImplProto {
+  optional string view = 1;
+  optional int32 display_id = 2;
+  optional bool app_visible = 3;
+  optional int32 width = 4;
+  optional int32 height = 5;
+  optional bool is_animating = 6;
+  optional RectProto visible_rect = 7;
+  optional bool is_drawing = 8;
+  optional bool added = 9;
+  optional RectProto win_frame = 10;
+  optional DisplayCutoutProto pending_display_cutout = 11 [deprecated = true];
+  optional string last_window_insets = 12;
+  optional string soft_input_mode = 13;
+  optional int32 scroll_y = 14;
+  optional int32 cur_scroll_y = 15;
+  optional bool removed = 16;
+  optional WindowLayoutParamsProto window_attributes = 17;
+}
\ No newline at end of file
diff --git a/protos/perfetto/trace/android/view/windowlayoutparams.proto b/protos/perfetto/trace/android/view/windowlayoutparams.proto
new file mode 100644
index 0000000..ec60e94
--- /dev/null
+++ b/protos/perfetto/trace/android/view/windowlayoutparams.proto
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+import "protos/perfetto/trace/android/graphics/pixelformat.proto";
+import "protos/perfetto/trace/android/view/display.proto";
+import "protos/perfetto/trace/android/typedef.proto";
+
+package perfetto.protos;
+
+// represents WindowManager.LayoutParams
+message WindowLayoutParamsProto {
+  optional int32 type = 1
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowManager.LayoutParams.WindowType"];
+  optional int32 x = 2;
+  optional int32 y = 3;
+  optional int32 width = 4;
+  optional int32 height = 5;
+  optional float horizontal_margin = 6;
+  optional float vertical_margin = 7;
+  optional int32 gravity = 8
+      [(.perfetto.protos.typedef) = "android.view.Gravity.GravityFlags"];
+  optional int32 soft_input_mode = 9
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowManager.LayoutParams.SoftInputModeFlags"];
+  optional PixelFormatProto.Format format = 10;
+  optional int32 window_animations = 11;
+  optional float alpha = 12;
+  optional float screen_brightness = 13;
+  optional float button_brightness = 14;
+
+  enum RotationAnimation {
+    ROTATION_ANIMATION_UNSPECIFIED = -1;
+    ROTATION_ANIMATION_CROSSFADE = 1;
+    ROTATION_ANIMATION_JUMPCUT = 2;
+    ROTATION_ANIMATION_SEAMLESS = 3;
+  }
+  optional RotationAnimation rotation_animation = 15;
+
+  optional float preferred_refresh_rate = 16;
+  optional int32 preferred_display_mode_id = 17;
+  optional bool has_system_ui_listeners = 18;
+  optional uint32 input_feature_flags = 19
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowManager.LayoutParams.InputFeatureFlags"];
+  optional int64 user_activity_timeout = 20;
+
+  optional ViewDisplayProto.ColorMode color_mode = 23;
+  optional uint32 flags = 24
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowManager.LayoutParams.Flags"];
+  optional uint32 private_flags = 26
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowManager.LayoutParams.PrivateFlags"];
+  optional uint32 system_ui_visibility_flags = 27
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowManager.LayoutParams.SystemUiVisibilityFlags"];
+  optional uint32 subtree_system_ui_visibility_flags = 28
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowManager.LayoutParams.SystemUiVisibilityFlags"];
+  optional uint32 appearance = 29
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowInsetsController.Appearance"];
+  optional uint32 behavior = 30
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowInsetsController.Behavior"];
+  optional uint32 fit_insets_types = 31
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowInsets.Type.InsetsType"];
+  optional uint32 fit_insets_sides = 32
+      [(.perfetto.protos.typedef) =
+           "android.view.WindowInsets.Side.InsetsSide"];
+  optional bool fit_ignore_visibility = 33;
+}
diff --git a/protos/perfetto/trace/android/winscope.proto b/protos/perfetto/trace/android/winscope.proto
index a0c61f7..d7927d8 100644
--- a/protos/perfetto/trace/android/winscope.proto
+++ b/protos/perfetto/trace/android/winscope.proto
@@ -22,6 +22,7 @@
 import "protos/perfetto/trace/android/shell_transition.proto";
 import "protos/perfetto/trace/android/surfaceflinger_layers.proto";
 import "protos/perfetto/trace/android/surfaceflinger_transactions.proto";
+import "protos/perfetto/trace/android/winscope_extensions_impl.proto";
 
 // This file is used to generated descriptors for all the winscope protos.
 // List all the winscope top-level trace messages here:
@@ -30,4 +31,5 @@
   optional TransactionTraceEntry transactions = 2;
   optional ShellTransition shell_transition = 3;
   optional ProtoLogMessage protolog_message = 4;
+  optional WinscopeExtensionsImpl winscope_extensions = 5;
 }
diff --git a/protos/perfetto/trace/android/winscope_extensions.proto b/protos/perfetto/trace/android/winscope_extensions.proto
new file mode 100644
index 0000000..76e6c9e
--- /dev/null
+++ b/protos/perfetto/trace/android/winscope_extensions.proto
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+message WinscopeExtensions {
+  extensions 1 to 3;
+}
diff --git a/protos/perfetto/trace/android/winscope_extensions_impl.proto b/protos/perfetto/trace/android/winscope_extensions_impl.proto
new file mode 100644
index 0000000..bfc18e9
--- /dev/null
+++ b/protos/perfetto/trace/android/winscope_extensions_impl.proto
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+import public "protos/perfetto/trace/android/winscope_extensions.proto";
+import "protos/perfetto/trace/android/inputmethodeditor.proto";
+
+message WinscopeExtensionsImpl {
+  extend WinscopeExtensions {
+    optional InputMethodClientsTraceProto inputmethod_clients = 1;
+    optional InputMethodServiceTraceProto inputmethod_service = 2;
+    optional InputMethodManagerServiceTraceProto inputmethod_manager_service =
+        3;
+  }
+}
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index c829795..6d7c098 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -5189,13 +5189,7 @@
 
 // End of protos/perfetto/trace/android/shell_transition.proto
 
-// Begin of protos/perfetto/trace/android/surfaceflinger_common.proto
-
-message RegionProto {
-  // Previously: uint64 id
-  reserved 1;
-  repeated RectProto rect = 2;
-}
+// Begin of protos/perfetto/trace/android/graphics/rect.proto
 
 message RectProto {
   optional int32 left = 1;
@@ -5204,6 +5198,16 @@
   optional int32 bottom = 4;
 }
 
+// End of protos/perfetto/trace/android/graphics/rect.proto
+
+// Begin of protos/perfetto/trace/android/surfaceflinger_common.proto
+
+message RegionProto {
+  // Previously: uint64 id
+  reserved 1;
+  repeated RectProto rect = 2;
+}
+
 message SizeProto {
   optional int32 w = 1;
   optional int32 h = 2;
@@ -5812,6 +5816,14 @@
 
 // End of protos/perfetto/trace/android/surfaceflinger_transactions.proto
 
+// Begin of protos/perfetto/trace/android/winscope_extensions.proto
+
+message WinscopeExtensions {
+  extensions 1 to 3;
+}
+
+// End of protos/perfetto/trace/android/winscope_extensions.proto
+
 // Begin of protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto
 
 // This message is not intended to be written by the chrome on the device.
@@ -14805,7 +14817,7 @@
 // See the [Buffers and Dataflow](/docs/concepts/buffers.md) doc for details.
 //
 // Next reserved id: 14 (up to 15).
-// Next id: 112.
+// Next id: 113.
 message TracePacket {
   // The timestamp of the TracePacket.
   // By default this timestamps refers to the trace clock (CLOCK_BOOTTIME on
@@ -14957,6 +14969,8 @@
     TestEvent for_testing = 900;
   }
 
+  optional WinscopeExtensions winscope_extensions = 112;
+
   // Trusted user id of the producer which generated this packet. Keep in sync
   // with TrustedPacket.trusted_uid.
   //
diff --git a/protos/perfetto/trace/trace_packet.proto b/protos/perfetto/trace/trace_packet.proto
index 62d7e6f..974f6d3 100644
--- a/protos/perfetto/trace/trace_packet.proto
+++ b/protos/perfetto/trace/trace_packet.proto
@@ -35,6 +35,7 @@
 import "protos/perfetto/trace/android/shell_transition.proto";
 import "protos/perfetto/trace/android/surfaceflinger_layers.proto";
 import "protos/perfetto/trace/android/surfaceflinger_transactions.proto";
+import "protos/perfetto/trace/android/winscope_extensions.proto";
 import "protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto";
 import "protos/perfetto/trace/chrome/chrome_metadata.proto";
 import "protos/perfetto/trace/chrome/chrome_trace_event.proto";
@@ -104,7 +105,7 @@
 // See the [Buffers and Dataflow](/docs/concepts/buffers.md) doc for details.
 //
 // Next reserved id: 14 (up to 15).
-// Next id: 112.
+// Next id: 113.
 message TracePacket {
   // The timestamp of the TracePacket.
   // By default this timestamps refers to the trace clock (CLOCK_BOOTTIME on
@@ -256,6 +257,8 @@
     TestEvent for_testing = 900;
   }
 
+  optional WinscopeExtensions winscope_extensions = 112;
+
   // Trusted user id of the producer which generated this packet. Keep in sync
   // with TrustedPacket.trusted_uid.
   //
diff --git a/src/trace_processor/importers/ftrace/binder_tracker.cc b/src/trace_processor/importers/ftrace/binder_tracker.cc
index 29d0c2c..48cdf58 100644
--- a/src/trace_processor/importers/ftrace/binder_tracker.cc
+++ b/src/trace_processor/importers/ftrace/binder_tracker.cc
@@ -296,7 +296,7 @@
   transaction.args_inserter = args_inserter;
   transaction.send_track_id = track_id;
   transaction.send_slice_id = insert_slice();
-  outstanding_transactions_.Insert(transaction_id, std::move(transaction));
+  outstanding_transactions_[transaction_id] = std::move(transaction);
   auto* frame = GetTidTopFrame(tid);
   if (frame) {
     if (frame->state == TxnFrame::kSndAfterBC_TRANSACTION) {
@@ -315,18 +315,16 @@
 void BinderTracker::TransactionReceived(int64_t ts,
                                         uint32_t pid,
                                         int32_t transaction_id) {
-  const OutstandingTransaction* opt_transaction =
-      outstanding_transactions_.Find(transaction_id);
-  if (!opt_transaction) {
+  auto it = outstanding_transactions_.find(transaction_id);
+  if (it == outstanding_transactions_.end()) {
     // If we don't know what type of transaction it is, we don't know how to
     // insert the slice.
     // TODO(lalitm): maybe we should insert a dummy slice anyway - seems like
     // a questionable idea to just ignore these completely.
     return;
   }
-
-  OutstandingTransaction transaction(std::move(*opt_transaction));
-  outstanding_transactions_.Erase(transaction_id);
+  OutstandingTransaction transaction(std::move(it->second));
+  outstanding_transactions_.erase(it);
 
   UniqueTid utid = context_->process_tracker->GetOrCreateThread(pid);
   TrackId track_id = context_->track_tracker->InternThreadTrack(utid);
diff --git a/src/trace_processor/importers/ftrace/binder_tracker.h b/src/trace_processor/importers/ftrace/binder_tracker.h
index f1d682c..5912904 100644
--- a/src/trace_processor/importers/ftrace/binder_tracker.h
+++ b/src/trace_processor/importers/ftrace/binder_tracker.h
@@ -95,6 +95,8 @@
   bool utid_stacks_empty() const { return utid_stacks_.size() == 0; }
 
  private:
+  TraceProcessorContext* const context_;
+
   struct OutstandingTransaction {
     bool is_reply = false;
     bool is_oneway = false;
@@ -102,10 +104,10 @@
     std::optional<TrackId> send_track_id;
     std::optional<SliceId> send_slice_id;
   };
+  // TODO(rsavitski): switch back to FlatHashMap once the latter's perf is fixed
+  // for insert+erase heavy workfloads.
+  std::unordered_map<int32_t, OutstandingTransaction> outstanding_transactions_;
 
-  TraceProcessorContext* const context_;
-
-  base::FlatHashMap<int32_t, OutstandingTransaction> outstanding_transactions_;
   struct TxnFrame {
     // The state of this thread at this stack level.
     enum State : uint32_t;
diff --git a/src/trace_processor/importers/proto/winscope/BUILD.gn b/src/trace_processor/importers/proto/winscope/BUILD.gn
index 93f9d1b..c5a6316 100644
--- a/src/trace_processor/importers/proto/winscope/BUILD.gn
+++ b/src/trace_processor/importers/proto/winscope/BUILD.gn
@@ -39,6 +39,8 @@
     "../../../../../gn:default_deps",
     "../../../../../protos/perfetto/trace:zero",
     "../../../../../protos/perfetto/trace/android:zero",
+    "../../../../../protos/perfetto/trace/android:winscope_regular:zero",
+    "../../../../../protos/perfetto/trace/android:winscope_extensions:zero",
     "../../../../../protos/perfetto/trace/interned_data:zero",
     "../../../../../protos/perfetto/trace/profiling:zero",
     "../../../../protozero",
diff --git a/src/trace_redaction/BUILD.gn b/src/trace_redaction/BUILD.gn
index 037545d..8ff31a3 100644
--- a/src/trace_redaction/BUILD.gn
+++ b/src/trace_redaction/BUILD.gn
@@ -47,6 +47,8 @@
     "find_package_uid.cc",
     "find_package_uid.h",
     "frame_cookie.h",
+    "modify_process_trees.cc",
+    "modify_process_trees.h",
     "optimize_timeline.cc",
     "optimize_timeline.h",
     "populate_allow_lists.cc",
diff --git a/src/trace_redaction/modify_process_trees.cc b/src/trace_redaction/modify_process_trees.cc
new file mode 100644
index 0000000..099890b
--- /dev/null
+++ b/src/trace_redaction/modify_process_trees.cc
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "src/trace_redaction/modify_process_trees.h"
+
+#include <string>
+
+#include "perfetto/base/status.h"
+#include "perfetto/protozero/field.h"
+#include "perfetto/protozero/scattered_heap_buffer.h"
+#include "src/trace_redaction/proto_util.h"
+#include "src/trace_redaction/trace_redaction_framework.h"
+
+#include "protos/perfetto/trace/ps/process_tree.pbzero.h"
+#include "protos/perfetto/trace/trace_packet.pbzero.h"
+
+namespace perfetto::trace_redaction {
+
+base::Status ModifyProcessTree::VerifyContext(const Context&) const {
+  return base::OkStatus();
+}
+
+base::Status ModifyProcessTree::Transform(const Context& context,
+                                          std::string* packet) const {
+  protozero::ProtoDecoder decoder(*packet);
+
+  auto process_tree =
+      decoder.FindField(protos::pbzero::TracePacket::kProcessTreeFieldNumber);
+
+  if (!process_tree.valid()) {
+    return base::OkStatus();
+  }
+
+  auto timestamp =
+      decoder.FindField(protos::pbzero::TracePacket::kTimestampFieldNumber);
+
+  protozero::HeapBuffered<protos::pbzero::TracePacket> packet_message;
+
+  for (auto field = decoder.ReadField(); field.valid();
+       field = decoder.ReadField()) {
+    if (field.id() == protos::pbzero::TracePacket::kProcessTreeFieldNumber) {
+      TransformProcessTree(context, timestamp, field,
+                           packet_message->set_process_tree());
+    } else {
+      proto_util::AppendField(field, packet_message.get());
+    }
+  }
+
+  packet->assign(packet_message.SerializeAsString());
+
+  return base::OkStatus();
+}
+
+void ModifyProcessTree::TransformProcess(
+    const Context&,
+    const protozero::Field&,
+    const protozero::Field& process,
+    protos::pbzero::ProcessTree* process_tree) const {
+  PERFETTO_DCHECK(process.id() ==
+                  protos::pbzero::ProcessTree::kProcessesFieldNumber);
+  proto_util::AppendField(process, process_tree);
+}
+
+void ModifyProcessTree::TransformThread(
+    const Context&,
+    const protozero::Field&,
+    const protozero::Field& thread,
+    protos::pbzero::ProcessTree* process_tree) const {
+  PERFETTO_DCHECK(thread.id() ==
+                  protos::pbzero::ProcessTree::kThreadsFieldNumber);
+  proto_util::AppendField(thread, process_tree);
+}
+
+void ModifyProcessTree::TransformProcessTree(
+    const Context& context,
+    const protozero::Field& timestamp,
+    const protozero::Field& process_tree,
+    protos::pbzero::ProcessTree* message) const {
+  protozero::ProtoDecoder decoder(process_tree.as_bytes());
+
+  for (auto field = decoder.ReadField(); field.valid();
+       field = decoder.ReadField()) {
+    switch (field.id()) {
+      case protos::pbzero::ProcessTree::kProcessesFieldNumber:
+        TransformProcess(context, timestamp, field, message);
+        break;
+
+      case protos::pbzero::ProcessTree::kThreadsFieldNumber:
+        TransformThread(context, timestamp, field, message);
+        break;
+
+      default:
+        proto_util::AppendField(field, message);
+        break;
+    }
+  }
+
+  // TODO(vaage): Call the handler to add extra fields to the process tree.
+}
+
+}  // namespace perfetto::trace_redaction
diff --git a/src/trace_redaction/modify_process_trees.h b/src/trace_redaction/modify_process_trees.h
new file mode 100644
index 0000000..e36223e
--- /dev/null
+++ b/src/trace_redaction/modify_process_trees.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SRC_TRACE_REDACTION_MODIFY_PROCESS_TREES_H_
+#define SRC_TRACE_REDACTION_MODIFY_PROCESS_TREES_H_
+
+#include <string>
+
+#include "perfetto/base/status.h"
+#include "src/trace_redaction/trace_redaction_framework.h"
+
+#include "protos/perfetto/trace/ps/process_tree.pbzero.h"
+
+namespace perfetto::trace_redaction {
+
+// Walk through process trees, calling process and thread handlers to add new
+// process and threads messages to the process tree. If the default handler is
+// not replaced, the thread/process will be added to the parent.
+class ModifyProcessTree : public TransformPrimitive {
+ public:
+  base::Status Transform(const Context& context,
+                         std::string* packet) const override;
+
+ protected:
+  // Verifies that the context contains required values. No-op by default.
+  virtual base::Status VerifyContext(const Context& context) const;
+
+  // Modifies a process before adding it back to the process tree. Appends the
+  // field to the process tree without modification by default.
+  virtual void TransformProcess(
+      const Context& context,
+      const protozero::Field& timestamp,
+      const protozero::Field& process,
+      protos::pbzero::ProcessTree* process_tree) const;
+
+  // Modifies a thread before adding it back to the process tree. Appends the
+  // field to the process tree without modification by default.
+  virtual void TransformThread(
+      const Context& context,
+      const protozero::Field& timestamp,
+      const protozero::Field& thread,
+      protos::pbzero::ProcessTree* process_trees) const;
+
+  // TODO(vaage): Add a handler that is called the process tree is populated so
+  // that fields can be added to process tree (e.g. creating new threads -
+  // needed for thread merging).
+
+ private:
+  void TransformProcessTree(const Context& context,
+                            const protozero::Field& timestamp,
+                            const protozero::Field& process_tree,
+                            protos::pbzero::ProcessTree* message) const;
+};
+
+}  // namespace perfetto::trace_redaction
+
+#endif  // SRC_TRACE_REDACTION_MODIFY_PROCESS_TREES_H_
diff --git a/src/trace_redaction/populate_allow_lists.cc b/src/trace_redaction/populate_allow_lists.cc
index b2c9431..11d895b 100644
--- a/src/trace_redaction/populate_allow_lists.cc
+++ b/src/trace_redaction/populate_allow_lists.cc
@@ -84,24 +84,38 @@
     context->trace_packet_allow_list.insert(item);
   }
 
+  // FTRACE EVENT NOTES
+  //
+  //    Dma events (kDmaHeapStatFieldNumber) are global events and are not
+  //    emitted within a process context (they are centrally allocated by the
+  //    HAL process). We drop them for now as we don't have the required
+  //    attribution info in the trace.
+  //
+  //    ION events (e.g. kIonBufferCreateFieldNumber, kIonHeapGrowFieldNumber,
+  //    etc.) are global events are not emitted within a process context (they
+  //    are centrally allocated by the HAL process). We drop them for now as we
+  //    don't have the required attribution info in the trace.
+  //
+  //    TODO(vaage): The allowed rss stat events (i.e. kRssStatFieldNumber,
+  //    kRssStatThrottledFieldNumber) are process-scoped. It is non-trivial to
+  //    merge events, so all events outside of the target package should be
+  //    dropped.
+  //
+  //    TODO(vaage): kSchedBlockedReasonFieldNumber contains two pids, an outer
+  //    and inner pid. A primitive is needed to further redact these events.
+
   std::initializer_list<uint32_t> ftrace_events = {
-      protos::pbzero::FtraceEvent::kSchedSwitchFieldNumber,
       protos::pbzero::FtraceEvent::kCpuFrequencyFieldNumber,
       protos::pbzero::FtraceEvent::kCpuIdleFieldNumber,
+      protos::pbzero::FtraceEvent::kPrintFieldNumber,
+      protos::pbzero::FtraceEvent::kRssStatFieldNumber,
+      protos::pbzero::FtraceEvent::kRssStatThrottledFieldNumber,
       protos::pbzero::FtraceEvent::kSchedBlockedReasonFieldNumber,
+      protos::pbzero::FtraceEvent::kSchedProcessFreeFieldNumber,
+      protos::pbzero::FtraceEvent::kSchedSwitchFieldNumber,
       protos::pbzero::FtraceEvent::kSchedWakingFieldNumber,
       protos::pbzero::FtraceEvent::kTaskNewtaskFieldNumber,
       protos::pbzero::FtraceEvent::kTaskRenameFieldNumber,
-      protos::pbzero::FtraceEvent::kSchedProcessFreeFieldNumber,
-      protos::pbzero::FtraceEvent::kRssStatFieldNumber,
-      protos::pbzero::FtraceEvent::kIonHeapShrinkFieldNumber,
-      protos::pbzero::FtraceEvent::kIonHeapGrowFieldNumber,
-      protos::pbzero::FtraceEvent::kIonStatFieldNumber,
-      protos::pbzero::FtraceEvent::kIonBufferCreateFieldNumber,
-      protos::pbzero::FtraceEvent::kIonBufferDestroyFieldNumber,
-      protos::pbzero::FtraceEvent::kDmaHeapStatFieldNumber,
-      protos::pbzero::FtraceEvent::kRssStatThrottledFieldNumber,
-      protos::pbzero::FtraceEvent::kPrintFieldNumber,
   };
 
   for (auto item : ftrace_events) {
diff --git a/src/trace_redaction/redact_ftrace_event.cc b/src/trace_redaction/redact_ftrace_event.cc
index 6c09236..a16a90d 100644
--- a/src/trace_redaction/redact_ftrace_event.cc
+++ b/src/trace_redaction/redact_ftrace_event.cc
@@ -30,68 +30,76 @@
 
 base::Status RedactFtraceEvent::Transform(const Context& context,
                                           std::string* packet) const {
-  protozero::ConstBytes packet_bytes = {
-      reinterpret_cast<const uint8_t*>(packet->data()), packet->size()};
-
   protozero::HeapBuffered<protos::pbzero::TracePacket> message;
 
-  RedactPacket(context, packet_bytes, message.get());
+  protozero::ProtoDecoder decoder(*packet);
+
+  // Treat FtraceEvents (bundle) as a special case.
+  for (auto f = decoder.ReadField(); f.valid(); f = decoder.ReadField()) {
+    if (f.id() == protos::pbzero::TracePacket::kFtraceEventsFieldNumber) {
+      RedactEvents(context, f, message->set_ftrace_events());
+    } else {
+      proto_util::AppendField(f, message.get());
+    }
+  }
+
   packet->assign(message.SerializeAsString());
 
   return base::OkStatus();
 }
 
-// Iterate over every field in a packet, treating FtraceEvents (bundle) as a
-// special case.
-void RedactFtraceEvent::RedactPacket(
-    const Context& context,
-    protozero::ConstBytes bytes,
-    protos::pbzero::TracePacket* message) const {
-  protozero::ProtoDecoder decoder(bytes);
-
-  for (auto field = decoder.ReadField(); field.valid();
-       field = decoder.ReadField()) {
-    if (field.id() == protos::pbzero::TracePacket::kFtraceEventsFieldNumber) {
-      RedactEvents(context, field.as_bytes(), message->set_ftrace_events());
-    } else {
-      proto_util::AppendField(field, message);
-    }
-  }
-}
-
 // Iterate over every field in FtraceEvents (bundle), treating FtraceEvent as a
 // special case (calls the correct redaction).
 void RedactFtraceEvent::RedactEvents(
     const Context& context,
-    protozero::ConstBytes bytes,
+    protozero::Field bundle,
     protos::pbzero::FtraceEventBundle* message) const {
-  protozero::ProtoDecoder decoder(bytes);
+  PERFETTO_DCHECK(bundle.id() ==
+                  protos::pbzero::TracePacket::kFtraceEventsFieldNumber);
 
-  for (auto field = decoder.ReadField(); field.valid();
-       field = decoder.ReadField()) {
-    if (field.id() == protos::pbzero::FtraceEventBundle::kEventFieldNumber) {
-      RedactEvent(context, field.as_bytes(), message->add_event());
+  // There is only one bundle per packet, so creating the bundle decoder is an
+  // "okay" expense.
+  protos::pbzero::FtraceEventBundle::Decoder bundle_decoder(bundle.as_bytes());
+
+  // Even through we have `bundle_decoder` create a simpler decoder to iterate
+  // over every field.
+  protozero::ProtoDecoder decoder(bundle.as_bytes());
+
+  // Treat FtraceEvent as a special case.
+  for (auto f = decoder.ReadField(); f.valid(); f = decoder.ReadField()) {
+    if (f.id() == protos::pbzero::FtraceEventBundle::kEventFieldNumber) {
+      RedactEvent(context, bundle_decoder, f, message->add_event());
     } else {
-      proto_util::AppendField(field, message);
+      proto_util::AppendField(f, message);
     }
   }
 }
 
 void RedactFtraceEvent::RedactEvent(
     const Context& context,
-    protozero::ConstBytes bytes,
+    const protos::pbzero::FtraceEventBundle::Decoder& bundle,
+    protozero::Field event,
     protos::pbzero::FtraceEvent* message) const {
-  protozero::ProtoDecoder event(bytes);
+  PERFETTO_DCHECK(event.id() ==
+                  protos::pbzero::FtraceEventBundle::kEventFieldNumber);
 
-  for (auto field = event.ReadField(); field.valid();
-       field = event.ReadField()) {
-    auto* mod = redactions_.Find(field.id());
+  // A modifier can/will change the decoder by calling ReadField(). To avoid a
+  // modifier from interfering with the this function's loop, a reusable decoder
+  // is used for each modifier call.
+  protozero::ProtoDecoder outer_decoder(event.as_bytes());
+  protozero::ProtoDecoder inner_decoder(event.as_bytes());
 
+  // If there is a handler for a field, treat it as a special case.
+  for (auto f = outer_decoder.ReadField(); f.valid();
+       f = outer_decoder.ReadField()) {
+    auto* mod = redactions_.Find(f.id());
     if (mod && mod->get()) {
-      protos::pbzero::FtraceEvent::Decoder event_decoder(bytes);
-      mod->get()->Redact(context, event_decoder, field.as_bytes(), message);
+      // Reset the decoder so that it appears like a "new" decoder to the
+      // modifier.
+      inner_decoder.Reset();
+      mod->get()->Redact(context, bundle, inner_decoder, message);
     } else {
-      proto_util::AppendField(field, message);
+      proto_util::AppendField(f, message);
     }
   }
 }
diff --git a/src/trace_redaction/redact_ftrace_event.h b/src/trace_redaction/redact_ftrace_event.h
index fe282cf..9de6cc6 100644
--- a/src/trace_redaction/redact_ftrace_event.h
+++ b/src/trace_redaction/redact_ftrace_event.h
@@ -18,11 +18,16 @@
 #define SRC_TRACE_REDACTION_REDACT_FTRACE_EVENT_H_
 
 #include <cstdint>
+#include <memory>
+#include <string>
 
+#include "perfetto/base/status.h"
 #include "perfetto/ext/base/flat_hash_map.h"
+#include "perfetto/protozero/field.h"
 #include "src/trace_redaction/trace_redaction_framework.h"
 
 #include "protos/perfetto/trace/ftrace/ftrace_event.pbzero.h"
+#include "protos/perfetto/trace/ftrace/ftrace_event_bundle.pbzero.h"
 
 namespace perfetto::trace_redaction {
 
@@ -33,11 +38,14 @@
  public:
   virtual ~FtraceEventRedaction();
 
-  // Write a new version of the event to the message.
+  // Write at most one field from `event` to `event_message`. This relies on the
+  // honor system; other redactions may be registered on other values.
+  //
+  //  - event: effectively "protos::pbzero::FtraceEvent::Decoder"
   virtual base::Status Redact(
       const Context& context,
-      const protos::pbzero::FtraceEvent::Decoder& event,
-      protozero::ConstBytes bytes,
+      const protos::pbzero::FtraceEventBundle::Decoder& bundle,
+      protozero::ProtoDecoder& event,
       protos::pbzero::FtraceEvent* event_message) const = 0;
 };
 
@@ -46,23 +54,21 @@
   base::Status Transform(const Context& context,
                          std::string* packet) const override;
 
-  // Add a new redaction. T must extend FtraceEventRedaction.
-  template <uint32_t field_id, typename T>
+  // Add a new redaction. T must extend FtraceEventRedaction. This relies on the
+  // honor system; no more than one redaction can be mapped to a field.
+  template <uint32_t field_id, class T>
   void emplace_back() {
     redactions_.Insert(field_id, std::make_unique<T>());
   }
 
  private:
-  void RedactPacket(const Context& context,
-                    protozero::ConstBytes bytes,
-                    protos::pbzero::TracePacket* message) const;
-
   void RedactEvents(const Context& context,
-                    protozero::ConstBytes bytes,
+                    protozero::Field bundle,
                     protos::pbzero::FtraceEventBundle* message) const;
 
   void RedactEvent(const Context& context,
-                   protozero::ConstBytes bytes,
+                   const protos::pbzero::FtraceEventBundle::Decoder& bundle,
+                   protozero::Field event,
                    protos::pbzero::FtraceEvent* message) const;
 
   base::FlatHashMap<uint32_t, std::unique_ptr<FtraceEventRedaction>>
diff --git a/src/trace_redaction/redact_process_free.cc b/src/trace_redaction/redact_process_free.cc
index 7294d68..8f5a83e 100644
--- a/src/trace_redaction/redact_process_free.cc
+++ b/src/trace_redaction/redact_process_free.cc
@@ -44,20 +44,19 @@
 // of this, the timeline is not needed.
 base::Status RedactProcessFree::Redact(
     const Context&,
-    const protos::pbzero::FtraceEvent::Decoder&,
-    protozero::ConstBytes bytes,
+    const protos::pbzero::FtraceEventBundle::Decoder&,
+    protozero::ProtoDecoder& event,
     protos::pbzero::FtraceEvent* event_message) const {
-  // SchedProcessFreeFtraceEvent
-  protozero::ProtoDecoder process_free_decoder(bytes);
-
-  // There must be pid. If there's no pid, the safest option is to drop it.
-  auto pid = process_free_decoder.FindField(
-      protos::pbzero::SchedProcessFreeFtraceEvent::kPidFieldNumber);
-
-  if (!pid.valid()) {
-    return base::OkStatus();
+  auto sched_process_free = event.FindField(
+      protos::pbzero::FtraceEvent::kSchedProcessFreeFieldNumber);
+  if (!sched_process_free.valid()) {
+    return base::ErrStatus(
+        "RedactProcessFree: was used for unsupported field type");
   }
 
+  // SchedProcessFreeFtraceEvent
+  protozero::ProtoDecoder process_free_decoder(sched_process_free.as_bytes());
+
   auto* process_free_message = event_message->set_sched_process_free();
 
   // Replace the comm with an empty string instead of dropping the comm field.
diff --git a/src/trace_redaction/redact_process_free.h b/src/trace_redaction/redact_process_free.h
index 8d24153..19e954c 100644
--- a/src/trace_redaction/redact_process_free.h
+++ b/src/trace_redaction/redact_process_free.h
@@ -31,8 +31,8 @@
 
   base::Status Redact(
       const Context& context,
-      const protos::pbzero::FtraceEvent::Decoder& event,
-      protozero::ConstBytes bytes,
+      const protos::pbzero::FtraceEventBundle::Decoder& bundle,
+      protozero::ProtoDecoder& event,
       protos::pbzero::FtraceEvent* event_message) const override;
 };
 
diff --git a/src/trace_redaction/redact_process_free_unittest.cc b/src/trace_redaction/redact_process_free_unittest.cc
index ee119ca..04064ae 100644
--- a/src/trace_redaction/redact_process_free_unittest.cc
+++ b/src/trace_redaction/redact_process_free_unittest.cc
@@ -29,66 +29,72 @@
 
 namespace perfetto::trace_redaction {
 
-class RedactProcessFreeTest : public testing::Test {};
+class RedactProcessFreeTest : public testing::Test {
+ protected:
+  void SetUp() override {
+    auto* source_event = bundle.add_event();
+    source_event->set_timestamp(123456789);
+    source_event->set_pid(10);
+  }
 
-TEST_F(RedactProcessFreeTest, ClearsComm) {
-  protos::gen::FtraceEvent source_event;
-  source_event.set_timestamp(123456789);
-  source_event.set_pid(10);
+  base::Status Redact(protos::pbzero::FtraceEvent* event_message) {
+    RedactProcessFree redact;
+    Context context;
 
-  auto* process_free = source_event.mutable_sched_process_free();
+    auto bundle_str = bundle.SerializeAsString();
+    protos::pbzero::FtraceEventBundle::Decoder bundle_decoder(bundle_str);
+
+    auto event_str = bundle.event().back().SerializeAsString();
+    protos::pbzero::FtraceEvent::Decoder event_decoder(event_str);
+
+    return redact.Redact(context, bundle_decoder, event_decoder, event_message);
+  }
+
+  protos::gen::FtraceEventBundle bundle;
+};
+
+// A free event will always test as "not active". So the comm value should
+// always be replaced with an empty string.
+TEST_F(RedactProcessFreeTest, ClearsCommValue) {
+  auto* process_free =
+      bundle.mutable_event()->back().mutable_sched_process_free();
   process_free->set_comm("comm-a");
   process_free->set_pid(11);
 
-  RedactProcessFree redact;
-  Context context;
-
-  protos::pbzero::FtraceEvent::Decoder event_decoder(
-      source_event.SerializeAsString());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
 
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.sched_switch(),
-                    event_message.get());
+  auto result = Redact(event_message.get());
   ASSERT_OK(result) << result.c_message();
 
   protos::gen::FtraceEvent redacted_event;
   redacted_event.ParseFromString(event_message.SerializeAsString());
 
   // No process free event should have been added to the ftrace event.
-  ASSERT_FALSE(redacted_event.has_sched_process_free());
+  ASSERT_TRUE(redacted_event.has_sched_process_free());
+  ASSERT_TRUE(redacted_event.sched_process_free().has_comm());
+  ASSERT_TRUE(redacted_event.sched_process_free().comm().empty());
 }
 
-// Even if there is no pid in the process free event, the process free event
-// should still exist but no comm value should be present.
+// Even if there is no pid in the process free event, the comm value should be
+// replaced with an empty string.
 TEST_F(RedactProcessFreeTest, NoPidClearsEvent) {
-  protos::gen::FtraceEvent source_event;
-  source_event.set_timestamp(123456789);
-  source_event.set_pid(10);
-
-  // Don't add a pid. This should stop the process free event from being added
-  // to the event message.
-  auto* process_free = source_event.mutable_sched_process_free();
+  // Don't add a pid. This should have no change in behaviour.
+  auto* process_free =
+      bundle.mutable_event()->back().mutable_sched_process_free();
   process_free->set_comm("comm-a");
 
-  RedactProcessFree redact;
-  Context context;
-
-  protos::pbzero::FtraceEvent::Decoder event_decoder(
-      source_event.SerializeAsString());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
 
-  // Even if the process free event has been dropped, there should be no
-  // resulting error.
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.sched_switch(),
-                    event_message.get());
+  auto result = Redact(event_message.get());
   ASSERT_OK(result) << result.c_message();
 
   protos::gen::FtraceEvent redacted_event;
   redacted_event.ParseFromString(event_message.SerializeAsString());
 
-  ASSERT_FALSE(redacted_event.has_sched_process_free());
+  // No process free event should have been added to the ftrace event.
+  ASSERT_TRUE(redacted_event.has_sched_process_free());
+  ASSERT_TRUE(redacted_event.sched_process_free().has_comm());
+  ASSERT_TRUE(redacted_event.sched_process_free().comm().empty());
 }
 
 }  // namespace perfetto::trace_redaction
diff --git a/src/trace_redaction/redact_sched_switch.cc b/src/trace_redaction/redact_sched_switch.cc
index 361993d..8dca030 100644
--- a/src/trace_redaction/redact_sched_switch.cc
+++ b/src/trace_redaction/redact_sched_switch.cc
@@ -24,6 +24,20 @@
 
 namespace perfetto::trace_redaction {
 
+namespace {
+
+protozero::ConstChars SanitizeCommValue(const Context& context,
+                                        ProcessThreadTimeline::Slice slice,
+                                        protozero::Field field) {
+  if (NormalizeUid(slice.uid) == NormalizeUid(context.package_uid.value())) {
+    return field.as_string();
+  }
+
+  return {};
+}
+
+}  // namespace
+
 // Redact sched switch trace events in an ftrace event bundle:
 //
 //  event {
@@ -49,8 +63,8 @@
 
 base::Status RedactSchedSwitch::Redact(
     const Context& context,
-    const protos::pbzero::FtraceEvent::Decoder& event,
-    protozero::ConstBytes bytes,
+    const protos::pbzero::FtraceEventBundle::Decoder&,
+    protozero::ProtoDecoder& event,
     protos::pbzero::FtraceEvent* event_message) const {
   if (!context.package_uid.has_value()) {
     return base::ErrStatus("RedactSchedSwitch: missing package uid");
@@ -60,11 +74,31 @@
     return base::ErrStatus("RedactSchedSwitch: missing timeline");
   }
 
-  protos::pbzero::SchedSwitchFtraceEvent::Decoder sched_switch(bytes);
+  // The timestamp is needed to do the timeline look-up. If the packet has no
+  // timestamp, don't add the sched switch event. This is the safest option.
+  auto timestamp =
+      event.FindField(protos::pbzero::FtraceEvent::kTimestampFieldNumber);
+  if (!timestamp.valid()) {
+    return base::OkStatus();
+  }
+
+  auto sched_switch =
+      event.FindField(protos::pbzero::FtraceEvent::kSchedSwitchFieldNumber);
+  if (!sched_switch.valid()) {
+    return base::ErrStatus(
+        "RedactSchedSwitch: was used for unsupported field type");
+  }
+
+  protozero::ProtoDecoder sched_switch_decoder(sched_switch.as_bytes());
+
+  auto prev_pid = sched_switch_decoder.FindField(
+      protos::pbzero::SchedSwitchFtraceEvent::kPrevPidFieldNumber);
+  auto next_pid = sched_switch_decoder.FindField(
+      protos::pbzero::SchedSwitchFtraceEvent::kNextPidFieldNumber);
 
   // There must be a prev pid and a next pid. Otherwise, the event is invalid.
   // Dropping the event is the safest option.
-  if (!sched_switch.has_prev_pid() || !sched_switch.has_next_pid()) {
+  if (!prev_pid.valid() || !next_pid.valid()) {
     return base::OkStatus();
   }
 
@@ -72,30 +106,21 @@
   auto sched_switch_message = event_message->set_sched_switch();
 
   auto prev_slice =
-      context.timeline->Search(event.timestamp(), sched_switch.prev_pid());
+      context.timeline->Search(timestamp.as_uint64(), prev_pid.as_int32());
   auto next_slice =
-      context.timeline->Search(event.timestamp(), sched_switch.next_pid());
+      context.timeline->Search(timestamp.as_uint64(), next_pid.as_int32());
 
-  // To read the fields, move the read head back to the start.
-  sched_switch.Reset();
-
-  for (auto field = sched_switch.ReadField(); field.valid();
-       field = sched_switch.ReadField()) {
+  for (auto field = sched_switch_decoder.ReadField(); field.valid();
+       field = sched_switch_decoder.ReadField()) {
     switch (field.id()) {
       case protos::pbzero::SchedSwitchFtraceEvent::kNextCommFieldNumber:
-        if (next_slice.uid == context.package_uid) {
-          sched_switch_message->set_next_comm(field.as_string());
-        } else {
-          sched_switch_message->set_next_comm("");
-        }
+        sched_switch_message->set_next_comm(
+            SanitizeCommValue(context, next_slice, field));
         break;
 
       case protos::pbzero::SchedSwitchFtraceEvent::kPrevCommFieldNumber:
-        if (prev_slice.uid == context.package_uid) {
-          sched_switch_message->set_prev_comm(field.as_string());
-        } else {
-          sched_switch_message->set_prev_comm("");
-        }
+        sched_switch_message->set_prev_comm(
+            SanitizeCommValue(context, prev_slice, field));
         break;
 
       default:
diff --git a/src/trace_redaction/redact_sched_switch.h b/src/trace_redaction/redact_sched_switch.h
index e9d70cb..bcfa30d 100644
--- a/src/trace_redaction/redact_sched_switch.h
+++ b/src/trace_redaction/redact_sched_switch.h
@@ -31,8 +31,8 @@
 
   base::Status Redact(
       const Context& context,
-      const protos::pbzero::FtraceEvent::Decoder& event,
-      protozero::ConstBytes bytes,
+      const protos::pbzero::FtraceEventBundle::Decoder& bundle,
+      protozero::ProtoDecoder& event,
       protos::pbzero::FtraceEvent* event_message) const override;
 };
 
diff --git a/src/trace_redaction/redact_sched_switch_unittest.cc b/src/trace_redaction/redact_sched_switch_unittest.cc
index f6a4c13..72b65f4 100644
--- a/src/trace_redaction/redact_sched_switch_unittest.cc
+++ b/src/trace_redaction/redact_sched_switch_unittest.cc
@@ -22,7 +22,6 @@
 #include "protos/perfetto/trace/ftrace/ftrace_event.gen.h"
 #include "protos/perfetto/trace/ftrace/ftrace_event_bundle.gen.h"
 #include "protos/perfetto/trace/ftrace/sched.gen.h"
-#include "protos/perfetto/trace/ftrace/sched.pbzero.h"
 #include "protos/perfetto/trace/trace.gen.h"
 #include "protos/perfetto/trace/trace_packet.gen.h"
 
@@ -46,36 +45,54 @@
 class RedactSchedSwitchTest : public testing::Test {
  protected:
   void SetUp() override {
-    timeline_ = std::make_unique<ProcessThreadTimeline>();
-    timeline_->Append(
-        ProcessThreadTimeline::Event::Open(0, kPidA, kNoParent, kUidA));
-    timeline_->Append(
-        ProcessThreadTimeline::Event::Open(0, kPidB, kNoParent, kUidB));
-    timeline_->Sort();
+    auto* event = bundle_.add_event();
 
-    protozero::HeapBuffered<protos::pbzero::FtraceEvent> event;
     event->set_timestamp(123456789);
     event->set_pid(kPidA);
 
-    auto* sched_switch = event->set_sched_switch();
-    sched_switch->set_prev_comm(kCommA.data(), kCommA.size());
+    auto* sched_switch = event->mutable_sched_switch();
+    sched_switch->set_prev_comm(std::string(kCommA));
     sched_switch->set_prev_pid(kPidA);
-    sched_switch->set_next_comm(kCommB.data(), kCommB.size());
+    sched_switch->set_next_comm(std::string(kCommB));
     sched_switch->set_next_pid(kPidB);
+  }
 
-    event_string_ = event.SerializeAsString();
+  base::Status Redact(const Context& context,
+                      protos::pbzero::FtraceEvent* event_message) {
+    RedactSchedSwitch redact;
+
+    auto bundle_str = bundle_.SerializeAsString();
+    protos::pbzero::FtraceEventBundle::Decoder bundle_decoder(bundle_str);
+
+    auto event_str = bundle_.event().back().SerializeAsString();
+    protos::pbzero::FtraceEvent::Decoder event_decoder(event_str);
+
+    return redact.Redact(context, bundle_decoder, event_decoder, event_message);
   }
 
   const std::string& event_string() const { return event_string_; }
 
-  std::unique_ptr<ProcessThreadTimeline> timeline() {
-    return std::move(timeline_);
+  // This test breaks the rules for task_newtask and the timeline. The
+  // timeline will report the task existing before the new task event. This
+  // should not happen in the field, but it makes the test more robust.
+  std::unique_ptr<ProcessThreadTimeline> CreatePopulatedTimeline() {
+    auto timeline = std::make_unique<ProcessThreadTimeline>();
+
+    timeline->Append(
+        ProcessThreadTimeline::Event::Open(0, kPidA, kNoParent, kUidA));
+    timeline->Append(
+        ProcessThreadTimeline::Event::Open(0, kPidB, kNoParent, kUidB));
+    timeline->Sort();
+
+    return timeline;
   }
 
  private:
   std::string event_string_;
 
   std::unique_ptr<ProcessThreadTimeline> timeline_;
+
+  protos::gen::FtraceEventBundle bundle_;
 };
 
 TEST_F(RedactSchedSwitchTest, RejectMissingPackageUid) {
@@ -84,12 +101,8 @@
   Context context;
   context.timeline = std::make_unique<ProcessThreadTimeline>();
 
-  protos::pbzero::FtraceEvent::Decoder event_decoder(event_string());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
-
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.sched_switch(),
-                    event_message.get());
+  auto result = Redact(context, event_message.get());
   ASSERT_FALSE(result.ok());
 }
 
@@ -99,12 +112,8 @@
   Context context;
   context.package_uid = kUidA;
 
-  protos::pbzero::FtraceEvent::Decoder event_decoder(event_string());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
-
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.sched_switch(),
-                    event_message.get());
+  auto result = Redact(context, event_message.get());
   ASSERT_FALSE(result.ok());
 }
 
@@ -112,18 +121,14 @@
   RedactSchedSwitch redact;
 
   Context context;
-  context.timeline = timeline();
+  context.timeline = CreatePopulatedTimeline();
 
   // Neither pid is connected to the target package (see timeline
   // initialization).
   context.package_uid = kUidC;
 
-  protos::pbzero::FtraceEvent::Decoder event_decoder(event_string());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
-
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.sched_switch(),
-                    event_message.get());
+  auto result = Redact(context, event_message.get());
   ASSERT_OK(result) << result.c_message();
 
   protos::gen::FtraceEvent event;
@@ -143,18 +148,15 @@
   RedactSchedSwitch redact;
 
   Context context;
-  context.timeline = timeline();
+  context.timeline = CreatePopulatedTimeline();
 
   // Only next pid is connected to the target package (see timeline
   // initialization).
   context.package_uid = kUidB;
 
-  protos::pbzero::FtraceEvent::Decoder event_decoder(event_string());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
+  auto result = Redact(context, event_message.get());
 
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.sched_switch(),
-                    event_message.get());
   ASSERT_OK(result) << result.c_message();
 
   protos::gen::FtraceEvent event;
@@ -174,18 +176,14 @@
   RedactSchedSwitch redact;
 
   Context context;
-  context.timeline = timeline();
+  context.timeline = CreatePopulatedTimeline();
 
   // Only prev pid is connected to the target package (see timeline
   // initialization).
   context.package_uid = kUidA;
 
-  protos::pbzero::FtraceEvent::Decoder event_decoder(event_string());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
-
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.sched_switch(),
-                    event_message.get());
+  auto result = Redact(context, event_message.get());
   ASSERT_OK(result) << result.c_message();
 
   protos::gen::FtraceEvent event;
diff --git a/src/trace_redaction/redact_task_newtask.cc b/src/trace_redaction/redact_task_newtask.cc
index cb6a41c..c942612 100644
--- a/src/trace_redaction/redact_task_newtask.cc
+++ b/src/trace_redaction/redact_task_newtask.cc
@@ -16,8 +16,6 @@
 
 #include "src/trace_redaction/redact_task_newtask.h"
 
-#include <string>
-
 #include "src/trace_redaction/proto_util.h"
 
 #include "protos/perfetto/trace/ftrace/ftrace_event.pbzero.h"
@@ -26,6 +24,20 @@
 
 namespace perfetto::trace_redaction {
 
+namespace {
+
+protozero::ConstChars SanitizeCommValue(const Context& context,
+                                        ProcessThreadTimeline::Slice slice,
+                                        protozero::Field field) {
+  if (NormalizeUid(slice.uid) == NormalizeUid(context.package_uid.value())) {
+    return field.as_string();
+  }
+
+  return {};
+}
+
+}  // namespace
+
 // Redact sched switch trace events in an ftrace event bundle:
 //
 // event {
@@ -43,8 +55,8 @@
 // equal to "event.task_newtask.pid" (a thread cannot start itself).
 base::Status RedactTaskNewTask::Redact(
     const Context& context,
-    const protos::pbzero::FtraceEvent::Decoder& event,
-    protozero::ConstBytes bytes,
+    const protos::pbzero::FtraceEventBundle::Decoder&,
+    protozero::ProtoDecoder& event,
     protos::pbzero::FtraceEvent* event_message) const {
   if (!context.package_uid.has_value()) {
     return base::ErrStatus("RedactTaskNewTask: missing package uid");
@@ -54,14 +66,24 @@
     return base::ErrStatus("RedactTaskNewTask: missing timeline");
   }
 
-  // There must be a pid. If not, the message is meaningless and can be dropped.
-  if (!event.has_timestamp()) {
+  // The timestamp is needed to do the timeline look-up. If the packet has no
+  // timestamp, don't add the sched switch event. This is the safest option.
+  auto timestamp =
+      event.FindField(protos::pbzero::FtraceEvent::kTimestampFieldNumber);
+  if (!timestamp.valid()) {
     return base::OkStatus();
   }
 
-  protozero::ProtoDecoder new_task(bytes);
+  auto new_task =
+      event.FindField(protos::pbzero::FtraceEvent::kTaskNewtaskFieldNumber);
+  if (!new_task.valid()) {
+    return base::ErrStatus(
+        "RedactTaskNewTask: was used for unsupported field type");
+  }
 
-  auto pid = new_task.FindField(
+  protozero::ProtoDecoder new_task_decoder(new_task.as_bytes());
+
+  auto pid = new_task_decoder.FindField(
       protos::pbzero::TaskNewtaskFtraceEvent::kPidFieldNumber);
 
   if (!pid.valid()) {
@@ -71,20 +93,16 @@
   // Avoid making the message until we know that we have prev and next pids.
   auto* new_task_message = event_message->set_task_newtask();
 
-  auto slice = context.timeline->Search(event.timestamp(), pid.as_int32());
+  auto slice = context.timeline->Search(timestamp.as_uint64(), pid.as_int32());
 
-  for (auto field = new_task.ReadField(); field.valid();
-       field = new_task.ReadField()) {
+  for (auto field = new_task_decoder.ReadField(); field.valid();
+       field = new_task_decoder.ReadField()) {
+    // Perfetto view (ui.perfetto.dev) crashes if the comm value is missing.
+    // To work around this, the comm value is replaced with an empty string.
+    // This appears to work.
     if (field.id() ==
         protos::pbzero::TaskNewtaskFtraceEvent::kCommFieldNumber) {
-      if (slice.uid == context.package_uid) {
-        proto_util::AppendField(field, new_task_message);
-      } else {
-        // Perfetto view (ui.perfetto.dev) crashes if the comm value is missing.
-        // To work around this, the comm value is replaced with an empty string.
-        // This appears to work.
-        new_task_message->set_comm("");
-      }
+      new_task_message->set_comm(SanitizeCommValue(context, slice, field));
     } else {
       proto_util::AppendField(field, new_task_message);
     }
diff --git a/src/trace_redaction/redact_task_newtask.h b/src/trace_redaction/redact_task_newtask.h
index 51d384c..51c1124 100644
--- a/src/trace_redaction/redact_task_newtask.h
+++ b/src/trace_redaction/redact_task_newtask.h
@@ -31,8 +31,8 @@
 
   base::Status Redact(
       const Context& context,
-      const protos::pbzero::FtraceEvent::Decoder& event,
-      protozero::ConstBytes bytes,
+      const protos::pbzero::FtraceEventBundle::Decoder& bundle,
+      protozero::ProtoDecoder& event,
       protos::pbzero::FtraceEvent* event_message) const override;
 };
 
diff --git a/src/trace_redaction/redact_task_newtask_unittest.cc b/src/trace_redaction/redact_task_newtask_unittest.cc
index d09f044..33886f6 100644
--- a/src/trace_redaction/redact_task_newtask_unittest.cc
+++ b/src/trace_redaction/redact_task_newtask_unittest.cc
@@ -16,11 +16,15 @@
 
 #include "src/trace_redaction/redact_task_newtask.h"
 #include "perfetto/protozero/scattered_heap_buffer.h"
+#include "protos/perfetto/trace/ftrace/task.gen.h"
 #include "test/gtest_and_gmock.h"
 
 #include "protos/perfetto/trace/ftrace/ftrace_event.gen.h"
-#include "protos/perfetto/trace/ftrace/task.gen.h"
-#include "protos/perfetto/trace/ftrace/task.pbzero.h"
+#include "protos/perfetto/trace/ftrace/ftrace_event.pbzero.h"
+#include "protos/perfetto/trace/ftrace/ftrace_event_bundle.gen.h"
+#include "protos/perfetto/trace/ftrace/sched.gen.h"
+#include "protos/perfetto/trace/trace.gen.h"
+#include "protos/perfetto/trace/trace_packet.gen.h"
 
 namespace perfetto::trace_redaction {
 
@@ -40,37 +44,52 @@
 class RedactTaskNewTaskTest : public testing::Test {
  protected:
   void SetUp() override {
-    timeline_ = std::make_unique<ProcessThreadTimeline>();
-    timeline_->Append(
-        ProcessThreadTimeline::Event::Open(0, kPidA, kNoParent, kUidA));
-    timeline_->Append(
-        ProcessThreadTimeline::Event::Open(0, kPidB, kNoParent, kUidB));
-    timeline_->Sort();
+    auto* event = bundle_.add_event();
 
-    // This test breaks the rules for task_newtask and the timeline. The
-    // timeline will report the task existing before the new task event. This
-    // should not happen in the field, but it makes the test more robust.
-    protozero::HeapBuffered<protos::pbzero::FtraceEvent> event;
     event->set_timestamp(123456789);
     event->set_pid(kPidA);
 
-    auto* new_task = event->set_task_newtask();
-    new_task->set_comm(kCommA.data(), kCommA.size());
+    auto* new_task = event->mutable_task_newtask();
+    new_task->set_comm(std::string(kCommA));
     new_task->set_pid(kPidA);
+  }
 
-    event_string_ = event.SerializeAsString();
+  base::Status Redact(const Context& context,
+                      protos::pbzero::FtraceEvent* event_message) {
+    RedactTaskNewTask redact;
+
+    auto bundle_str = bundle_.SerializeAsString();
+    protos::pbzero::FtraceEventBundle::Decoder bundle_decoder(bundle_str);
+
+    auto event_str = bundle_.event().back().SerializeAsString();
+    protos::pbzero::FtraceEvent::Decoder event_decoder(event_str);
+
+    return redact.Redact(context, bundle_decoder, event_decoder, event_message);
   }
 
   const std::string& event_string() const { return event_string_; }
 
-  std::unique_ptr<ProcessThreadTimeline> timeline() {
-    return std::move(timeline_);
+  // This test breaks the rules for task_newtask and the timeline. The
+  // timeline will report the task existing before the new task event. This
+  // should not happen in the field, but it makes the test more robust.
+  std::unique_ptr<ProcessThreadTimeline> CreatePopulatedTimeline() {
+    auto timeline = std::make_unique<ProcessThreadTimeline>();
+
+    timeline->Append(
+        ProcessThreadTimeline::Event::Open(0, kPidA, kNoParent, kUidA));
+    timeline->Append(
+        ProcessThreadTimeline::Event::Open(0, kPidB, kNoParent, kUidB));
+    timeline->Sort();
+
+    return timeline;
   }
 
  private:
   std::string event_string_;
 
   std::unique_ptr<ProcessThreadTimeline> timeline_;
+
+  protos::gen::FtraceEventBundle bundle_;
 };
 
 TEST_F(RedactTaskNewTaskTest, RejectMissingPackageUid) {
@@ -82,9 +101,7 @@
   protos::pbzero::FtraceEvent::Decoder event_decoder(event_string());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
 
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.task_newtask(),
-                    event_message.get());
+  auto result = Redact(context, event_message.get());
   ASSERT_FALSE(result.ok());
 }
 
@@ -97,9 +114,7 @@
   protos::pbzero::FtraceEvent::Decoder event_decoder(event_string());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
 
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.task_newtask(),
-                    event_message.get());
+  auto result = Redact(context, event_message.get());
   ASSERT_FALSE(result.ok());
 }
 
@@ -110,14 +125,12 @@
   // keep its comm value.
   Context context;
   context.package_uid = kUidA;
-  context.timeline = timeline();
+  context.timeline = CreatePopulatedTimeline();
 
   protos::pbzero::FtraceEvent::Decoder event_decoder(event_string());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
 
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.task_newtask(),
-                    event_message.get());
+  auto result = Redact(context, event_message.get());
   ASSERT_TRUE(result.ok());
 
   protos::gen::FtraceEvent redacted_event;
@@ -135,14 +148,12 @@
   // lose its comm value.
   Context context;
   context.package_uid = kUidB;
-  context.timeline = timeline();
+  context.timeline = CreatePopulatedTimeline();
 
   protos::pbzero::FtraceEvent::Decoder event_decoder(event_string());
   protozero::HeapBuffered<protos::pbzero::FtraceEvent> event_message;
 
-  auto result =
-      redact.Redact(context, event_decoder, event_decoder.task_newtask(),
-                    event_message.get());
+  auto result = Redact(context, event_message.get());
   ASSERT_TRUE(result.ok());
 
   protos::gen::FtraceEvent redacted_event;
diff --git a/src/trace_redaction/scrub_process_trees.cc b/src/trace_redaction/scrub_process_trees.cc
index d8baf99..989d094 100644
--- a/src/trace_redaction/scrub_process_trees.cc
+++ b/src/trace_redaction/scrub_process_trees.cc
@@ -16,9 +16,6 @@
 
 #include "src/trace_redaction/scrub_process_trees.h"
 
-#include <cstdint>
-#include <string>
-
 #include "perfetto/base/status.h"
 #include "perfetto/protozero/field.h"
 #include "perfetto/protozero/scattered_heap_buffer.h"
@@ -29,149 +26,90 @@
 #include "protos/perfetto/trace/trace_packet.pbzero.h"
 
 namespace perfetto::trace_redaction {
+
 namespace {
 
-constexpr auto kThreadsFieldNumber =
-    protos::pbzero::ProcessTree::kThreadsFieldNumber;
-constexpr auto kTimestampFieldNumber =
-    protos::pbzero::TracePacket::kTimestampFieldNumber;
-constexpr auto kProcessTreeFieldNumber =
-    protos::pbzero::TracePacket::kProcessTreeFieldNumber;
-constexpr auto kProcessesFieldNumber =
-    protos::pbzero::ProcessTree::kProcessesFieldNumber;
-
-// Skips the cmdline fields.
-void ClearProcessName(protozero::ConstBytes bytes,
-                      protos::pbzero::ProcessTree::Process* message) {
-  protozero::ProtoDecoder decoder(bytes);
-
-  for (auto field = decoder.ReadField(); field; field = decoder.ReadField()) {
-    if (field.id() !=
-        protos::pbzero::ProcessTree::Process::kCmdlineFieldNumber) {
-      proto_util::AppendField(field, message);
-    }
-  }
-}
-
-void ScrubProcess(protozero::Field field,
-                  const ProcessThreadTimeline& timeline,
-                  uint64_t now,
-                  uint64_t uid,
-                  protos::pbzero::ProcessTree* message) {
-  if (field.id() != kProcessesFieldNumber) {
-    PERFETTO_FATAL(
-        "ScrubProcess() should only be called with a ProcessTree::Processes");
+// Appends a value to the message if (and only if) the pid belongs to the target
+// package.
+void TryAppendPid(const Context& context,
+                  const protozero::Field& timestamp,
+                  const protozero::Field& pid,
+                  const protozero::Field& value,
+                  protozero::Message* message) {
+  // All valid processes with have a time and pid/tid values. However, if
+  // they're missing values, the trace is corrupt. To avoid making this work by
+  // dropping too much data, drop the cmdline for all processes.
+  if (!timestamp.valid() || !pid.valid()) {
+    return;
   }
 
-  protos::pbzero::ProcessTree::Process::Decoder decoder(field.as_bytes());
-  auto slice = timeline.Search(now, decoder.pid());
+  auto slice = context.timeline->Search(timestamp.as_uint64(), pid.as_int32());
 
-  if (NormalizeUid(slice.uid) == NormalizeUid(uid)) {
-    proto_util::AppendField(field, message);
-  } else {
-    ClearProcessName(field.as_bytes(), message->add_processes());
-  }
-}
-
-// The thread name is unused, but it's safer to remove it.
-void ClearThreadName(protozero::ConstBytes bytes,
-                     protos::pbzero::ProcessTree::Thread* message) {
-  protozero::ProtoDecoder decoder(bytes);
-
-  for (auto field = decoder.ReadField(); field; field = decoder.ReadField()) {
-    if (field.id() != protos::pbzero::ProcessTree::Thread::kNameFieldNumber) {
-      proto_util::AppendField(field, message);
-    }
-  }
-}
-
-void ScrubThread(protozero::Field field,
-                 const ProcessThreadTimeline& timeline,
-                 uint64_t now,
-                 uint64_t uid,
-                 protos::pbzero::ProcessTree* message) {
-  if (field.id() != kThreadsFieldNumber) {
-    PERFETTO_FATAL(
-        "ScrubThread() should only be called with a ProcessTree::Threads");
+  // Only keep the target process cmdline.
+  if (NormalizeUid(slice.uid) != NormalizeUid(context.package_uid.value())) {
+    return;
   }
 
-  protos::pbzero::ProcessTree::Thread::Decoder thread_decoder(field.as_bytes());
-  auto slice = timeline.Search(now, thread_decoder.tid());
-
-  if (NormalizeUid(slice.uid) == NormalizeUid(uid)) {
-    proto_util::AppendField(field, message);
-  } else {
-    ClearThreadName(field.as_bytes(), message->add_threads());
-  }
+  proto_util::AppendField(value, message);
 }
 
 }  // namespace
 
-base::Status ScrubProcessTrees::Transform(const Context& context,
-                                          std::string* packet) const {
+base::Status ScrubProcessTrees::VerifyContext(const Context& context) const {
   if (!context.package_uid.has_value()) {
     return base::ErrStatus("ScrubProcessTrees: missing package uid.");
   }
 
-  if (context.timeline == nullptr) {
+  if (!context.timeline) {
     return base::ErrStatus("ScrubProcessTrees: missing timeline.");
   }
 
-  protozero::ProtoDecoder decoder(*packet);
-
-  if (!decoder.FindField(kProcessTreeFieldNumber).valid()) {
-    return base::OkStatus();
-  }
-
-  auto timestamp_field = decoder.FindField(kTimestampFieldNumber);
-
-  if (!timestamp_field.valid()) {
-    return base::ErrStatus("ScrubProcessTrees: trace packet missing timestamp");
-  }
-
-  auto timestamp = timestamp_field.as_uint64();
-
-  auto uid = context.package_uid.value();
-
-  const auto& timeline = *context.timeline.get();
-
-  protozero::HeapBuffered<protos::pbzero::TracePacket> message;
-
-  for (auto packet_field = decoder.ReadField(); packet_field.valid();
-       packet_field = decoder.ReadField()) {
-    if (packet_field.id() != kProcessTreeFieldNumber) {
-      proto_util::AppendField(packet_field, message.get());
-      continue;
-    }
-
-    auto* process_tree_message = message->set_process_tree();
-
-    protozero::ProtoDecoder process_tree_decoder(packet_field.as_bytes());
-
-    for (auto process_tree_field = process_tree_decoder.ReadField();
-         process_tree_field.valid();
-         process_tree_field = process_tree_decoder.ReadField()) {
-      switch (process_tree_field.id()) {
-        case kProcessesFieldNumber:
-          ScrubProcess(process_tree_field, timeline, timestamp, uid,
-                       process_tree_message);
-          break;
-
-        case kThreadsFieldNumber:
-          ScrubThread(process_tree_field, timeline, timestamp, uid,
-                      process_tree_message);
-          break;
-
-        default:
-          proto_util::AppendField(process_tree_field, process_tree_message);
-          break;
-      }
-    }
-  }
-
-  packet->assign(message.SerializeAsString());
-
   return base::OkStatus();
 }
 
+void ScrubProcessTrees::TransformProcess(
+    const Context& context,
+    const protozero::Field& timestamp,
+    const protozero::Field& process,
+    protos::pbzero::ProcessTree* process_tree) const {
+  protozero::ProtoDecoder decoder(process.as_bytes());
+
+  auto pid =
+      decoder.FindField(protos::pbzero::ProcessTree::Process::kPidFieldNumber);
+
+  auto* process_message = process_tree->add_processes();
+
+  for (auto field = decoder.ReadField(); field.valid();
+       field = decoder.ReadField()) {
+    if (field.id() ==
+        protos::pbzero::ProcessTree::Process::kCmdlineFieldNumber) {
+      TryAppendPid(context, timestamp, pid, field, process_message);
+    } else {
+      proto_util::AppendField(field, process_message);
+    }
+  }
+}
+
+void ScrubProcessTrees::TransformThread(
+    const Context& context,
+    const protozero::Field& timestamp,
+    const protozero::Field& thread,
+    protos::pbzero::ProcessTree* process_tree) const {
+  protozero::ProtoDecoder decoder(thread.as_bytes());
+
+  auto tid =
+      decoder.FindField(protos::pbzero::ProcessTree::Thread::kTidFieldNumber);
+
+  auto* thread_message = process_tree->add_threads();
+
+  for (auto field = decoder.ReadField(); field.valid();
+       field = decoder.ReadField()) {
+    if (field.id() == protos::pbzero::ProcessTree::Thread::kNameFieldNumber) {
+      TryAppendPid(context, timestamp, tid, field, thread_message);
+    } else {
+      proto_util::AppendField(field, thread_message);
+    }
+  }
+}
+
 }  // namespace perfetto::trace_redaction
diff --git a/src/trace_redaction/scrub_process_trees.h b/src/trace_redaction/scrub_process_trees.h
index 61cb85a..7c2b07a 100644
--- a/src/trace_redaction/scrub_process_trees.h
+++ b/src/trace_redaction/scrub_process_trees.h
@@ -17,19 +17,32 @@
 #ifndef SRC_TRACE_REDACTION_SCRUB_PROCESS_TREES_H_
 #define SRC_TRACE_REDACTION_SCRUB_PROCESS_TREES_H_
 
-#include <string>
-
 #include "perfetto/base/status.h"
+#include "perfetto/protozero/field.h"
+#include "src/trace_redaction/modify_process_trees.h"
 #include "src/trace_redaction/trace_redaction_framework.h"
 
+#include "protos/perfetto/trace/ps/process_tree.pbzero.h"
+
 namespace perfetto::trace_redaction {
 
 // Removes process names and thread names from process_trees if their pids/tids
 // are not connected to the target package.
-class ScrubProcessTrees final : public TransformPrimitive {
- public:
-  base::Status Transform(const Context& context,
-                         std::string* packet) const override;
+class ScrubProcessTrees : public ModifyProcessTree {
+ protected:
+  base::Status VerifyContext(const Context& context) const override;
+
+  void TransformProcess(
+      const Context& context,
+      const protozero::Field& timestamp,
+      const protozero::Field& process,
+      protos::pbzero::ProcessTree* process_trees) const override;
+
+  void TransformThread(
+      const Context& context,
+      const protozero::Field& timestamp,
+      const protozero::Field& thread,
+      protos::pbzero::ProcessTree* process_tree) const override;
 };
 
 }  // namespace perfetto::trace_redaction
diff --git a/tools/gen_android_bp b/tools/gen_android_bp
index c8a2b1a..82c2d76 100755
--- a/tools/gen_android_bp
+++ b/tools/gen_android_bp
@@ -122,12 +122,19 @@
 # Proto target groups which will be made public.
 proto_groups = {
     'trace': {
-        'types': ['filegroup', 'lite'],
+        'types': ['lite'],
         'targets': [
             '//protos/perfetto/trace:non_minimal_source_set',
             '//protos/perfetto/trace:minimal_source_set',
         ]
     },
+    'winscope': {
+        'types': ['filegroup'],
+        'targets': [
+            '//protos/perfetto/trace:non_minimal_source_set',
+            '//protos/perfetto/trace/android:winscope_extensions:source_set',
+        ]
+    },
     'config': {
         'types': ['lite'],
         'targets': [
diff --git a/tools/gn_utils.py b/tools/gn_utils.py
index 904760e..4fb0083 100644
--- a/tools/gn_utils.py
+++ b/tools/gn_utils.py
@@ -176,6 +176,7 @@
   e.g., //src/perfetto:tests -> src_perfetto_tests
   """
   name = re.sub(r'^//:?', '', label)
+  name = re.sub(r'/:', '/', name)
   name = re.sub(r'[^a-zA-Z0-9_]', '_', name)
   return name
 
diff --git a/ui/src/assets/details.scss b/ui/src/assets/details.scss
index ff66708..55a2cd9 100644
--- a/ui/src/assets/details.scss
+++ b/ui/src/assets/details.scss
@@ -453,11 +453,16 @@
   font-size: 11px;
   font-family: var(--monospace-font);
 
-  .colour {
-    display: inline-block;
-    height: 10px;
-    width: 10px;
-    margin-right: 4px;
+  .pf-ftrace-namebox {
+    display: flex;
+    align-items: center;
+
+    .pf-ftrace-colorbox {
+      display: inline-block;
+      height: 10px;
+      width: 10px;
+      margin-right: 4px;
+    }
   }
 }
 
diff --git a/ui/src/assets/widgets/virtual_table.scss b/ui/src/assets/widgets/virtual_table.scss
index acd22d5..9057db8 100644
--- a/ui/src/assets/widgets/virtual_table.scss
+++ b/ui/src/assets/widgets/virtual_table.scss
@@ -67,6 +67,8 @@
 
         .pf-vtable-puck {
           .pf-vtable-row {
+            display: flex;
+            align-items: center;
             white-space: nowrap;
             padding-inline: 4px;
 
diff --git a/ui/src/base/hotkeys.ts b/ui/src/base/hotkeys.ts
index ea278d1..bb43cec 100644
--- a/ui/src/base/hotkeys.ts
+++ b/ui/src/base/hotkeys.ts
@@ -104,6 +104,27 @@
 type AllowInEditable = '!' | '';
 export type Hotkey = `${AllowInEditable}${Modifier}${Key}`;
 
+// The following list of keys cannot be pressed wither with or without the
+// presence of the Shift modifier on most keyboard layouts. Thus we should
+// ignore shift in these cases.
+const shiftExceptions = [
+  '0',
+  '1',
+  '2',
+  '3',
+  '4',
+  '5',
+  '6',
+  '7',
+  '8',
+  '9',
+  '/',
+  '?',
+  '!',
+  '[',
+  ']',
+];
+
 // Represents a deconstructed hotkey.
 export interface HotkeyParts {
   // The name of the primary key of this hotkey.
@@ -191,7 +212,8 @@
 
   // For certain keys we relax the shift requirement, as they usually cannot be
   // pressed without the shift key on English keyboards.
-  const shiftOk = key.match(/[\?\!]/) || shiftKey === wantShift;
+  const shiftOk =
+    shiftExceptions.includes(key as string) || shiftKey === wantShift;
 
   return (
     metaKey === wantMeta &&
diff --git a/ui/src/frontend/app.ts b/ui/src/frontend/app.ts
index dc65d19..3dea6fd 100644
--- a/ui/src/frontend/app.ts
+++ b/ui/src/frontend/app.ts
@@ -466,7 +466,7 @@
       id: 'perfetto.Search',
       name: 'Search',
       callback: () => this.enterSearchMode(true),
-      defaultHotkey: '!Mod+S',
+      defaultHotkey: '/',
     },
     {
       id: 'perfetto.ShowHelp',
diff --git a/ui/src/frontend/base_slice_track.ts b/ui/src/frontend/base_slice_track.ts
index 329e441..39c38e5 100644
--- a/ui/src/frontend/base_slice_track.ts
+++ b/ui/src/frontend/base_slice_track.ts
@@ -356,8 +356,8 @@
           id
           ${extraCols ? ',' + extraCols : ''}
         from (${this.getSqlSource()})
-        where dur = -1
         group by 1
+        having dur = -1
       `);
     }
     const incomplete = new Array<CastInternal<T['slice']>>(queryRes.numRows());
diff --git a/ui/src/frontend/help_modal.ts b/ui/src/frontend/help_modal.ts
index 23f1c32..d08f6e7 100644
--- a/ui/src/frontend/help_modal.ts
+++ b/ui/src/frontend/help_modal.ts
@@ -247,11 +247,7 @@
           m('td', keycap(ctrlOrCmd), ' + ', keycap('o')),
           m('td', 'Run query'),
         ),
-        m(
-          'tr',
-          m('td', keycap(ctrlOrCmd), ' + ', keycap('s')),
-          m('td', 'Search'),
-        ),
+        m('tr', m('td', keycap('/')), m('td', 'Search')),
         m('tr', m('td', keycap('q')), m('td', 'Toggle tab drawer')),
         ...sidebarInstructions,
         m('tr', m('td', keycap('?')), m('td', 'Show help')),
diff --git a/ui/src/tracks/ftrace/ftrace_explorer.ts b/ui/src/tracks/ftrace/ftrace_explorer.ts
index 5e7eb32..d8cad78 100644
--- a/ui/src/tracks/ftrace/ftrace_explorer.ts
+++ b/ui/src/tracks/ftrace/ftrace_explorer.ts
@@ -188,7 +188,11 @@
         cells: [
           id,
           timestamp,
-          m('', m('span.colour', {style: {background: color}}), name),
+          m(
+            '.pf-ftrace-namebox',
+            m('.pf-ftrace-colorbox', {style: {background: color}}),
+            name,
+          ),
           cpu,
           process,
           args,