AndroidInputEvent: Migrate from TracePacket to WinscopeExtenstions

Bug: 332714237
Test: tools/diff_test_trace_processor.py <trace_processor_shell> \
          --name-filter "AndroidInputEvent"
Change-Id: I9e241e2c3b374d202610df247231bd56c10f82f7
Merged-In: I9e241e2c3b374d202610df247231bd56c10f82f7
diff --git a/Android.bp b/Android.bp
index 6f7501b..d586d0e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -5474,7 +5474,6 @@
     name: "perfetto_protos_perfetto_trace_android_cpp",
     srcs: [
         "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",
@@ -5504,7 +5503,6 @@
     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_cpp)",
     out: [
         "external/perfetto/protos/perfetto/trace/android/android_game_intervention_list.gen.cc",
-        "external/perfetto/protos/perfetto/trace/android/android_input_event.gen.cc",
         "external/perfetto/protos/perfetto/trace/android/android_log.gen.cc",
         "external/perfetto/protos/perfetto/trace/android/android_system_property.gen.cc",
         "external/perfetto/protos/perfetto/trace/android/camera_event.gen.cc",
@@ -5534,7 +5532,6 @@
     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_cpp)",
     out: [
         "external/perfetto/protos/perfetto/trace/android/android_game_intervention_list.gen.h",
-        "external/perfetto/protos/perfetto/trace/android/android_input_event.gen.h",
         "external/perfetto/protos/perfetto/trace/android/android_log.gen.h",
         "external/perfetto/protos/perfetto/trace/android/android_system_property.gen.h",
         "external/perfetto/protos/perfetto/trace/android/camera_event.gen.h",
@@ -5557,7 +5554,6 @@
     name: "perfetto_protos_perfetto_trace_android_lite",
     srcs: [
         "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",
@@ -5586,7 +5582,6 @@
     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_lite)",
     out: [
         "external/perfetto/protos/perfetto/trace/android/android_game_intervention_list.pb.cc",
-        "external/perfetto/protos/perfetto/trace/android/android_input_event.pb.cc",
         "external/perfetto/protos/perfetto/trace/android/android_log.pb.cc",
         "external/perfetto/protos/perfetto/trace/android/android_system_property.pb.cc",
         "external/perfetto/protos/perfetto/trace/android/camera_event.pb.cc",
@@ -5615,7 +5610,6 @@
     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_lite)",
     out: [
         "external/perfetto/protos/perfetto/trace/android/android_game_intervention_list.pb.h",
-        "external/perfetto/protos/perfetto/trace/android/android_input_event.pb.h",
         "external/perfetto/protos/perfetto/trace/android/android_log.pb.h",
         "external/perfetto/protos/perfetto/trace/android/android_system_property.pb.h",
         "external/perfetto/protos/perfetto/trace/android/camera_event.pb.h",
@@ -5803,6 +5797,7 @@
         "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/android_input_event.proto",
         "protos/perfetto/trace/android/graphics/pixelformat.proto",
         "protos/perfetto/trace/android/graphics/point.proto",
         "protos/perfetto/trace/android/graphics/rect.proto",
@@ -5850,6 +5845,7 @@
 filegroup {
     name: "perfetto_protos_perfetto_trace_android_winscope_extensions_zero",
     srcs: [
+        "protos/perfetto/trace/android/android_input_event.proto",
         "protos/perfetto/trace/android/graphics/pixelformat.proto",
         "protos/perfetto/trace/android/inputmethodeditor.proto",
         "protos/perfetto/trace/android/inputmethodservice/inputmethodservice.proto",
@@ -5891,6 +5887,7 @@
     ],
     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/android_input_event.pbzero.cc",
         "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",
@@ -5932,6 +5929,7 @@
     ],
     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/android_input_event.pbzero.h",
         "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",
@@ -6146,7 +6144,6 @@
     name: "perfetto_protos_perfetto_trace_android_zero",
     srcs: [
         "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",
@@ -6176,7 +6173,6 @@
     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_zero)",
     out: [
         "external/perfetto/protos/perfetto/trace/android/android_game_intervention_list.pbzero.cc",
-        "external/perfetto/protos/perfetto/trace/android/android_input_event.pbzero.cc",
         "external/perfetto/protos/perfetto/trace/android/android_log.pbzero.cc",
         "external/perfetto/protos/perfetto/trace/android/android_system_property.pbzero.cc",
         "external/perfetto/protos/perfetto/trace/android/camera_event.pbzero.cc",
@@ -6206,7 +6202,6 @@
     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_zero)",
     out: [
         "external/perfetto/protos/perfetto/trace/android/android_game_intervention_list.pbzero.h",
-        "external/perfetto/protos/perfetto/trace/android/android_input_event.pbzero.h",
         "external/perfetto/protos/perfetto/trace/android/android_log.pbzero.h",
         "external/perfetto/protos/perfetto/trace/android/android_system_property.pbzero.h",
         "external/perfetto/protos/perfetto/trace/android/camera_event.pbzero.h",
@@ -6448,7 +6443,6 @@
         "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",
@@ -12352,7 +12346,6 @@
     srcs: [
         "src/trace_processor/importers/proto/additional_modules.cc",
         "src/trace_processor/importers/proto/android_camera_event_module.cc",
-        "src/trace_processor/importers/proto/android_input_event_module.cc",
         "src/trace_processor/importers/proto/android_probes_module.cc",
         "src/trace_processor/importers/proto/android_probes_parser.cc",
         "src/trace_processor/importers/proto/android_probes_tracker.cc",
@@ -12517,6 +12510,7 @@
 filegroup {
     name: "perfetto_src_trace_processor_importers_proto_winscope_full",
     srcs: [
+        "src/trace_processor/importers/proto/winscope/android_input_event_parser.cc",
         "src/trace_processor/importers/proto/winscope/protolog_messages_tracker.cc",
         "src/trace_processor/importers/proto/winscope/protolog_parser.cc",
         "src/trace_processor/importers/proto/winscope/shell_transitions_parser.cc",
@@ -14566,7 +14560,6 @@
         "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",
@@ -15762,6 +15755,35 @@
     ],
 }
 
+// GN: //protos/perfetto/trace/android:perfetto_winscope_extensions_zero
+cc_library_static {
+    name: "perfetto_winscope_extensions_zero",
+    srcs: [
+        ":perfetto_include_perfetto_base_base",
+        ":perfetto_include_perfetto_ext_base_base",
+        ":perfetto_include_perfetto_protozero_protozero",
+        ":perfetto_include_perfetto_public_abi_base",
+        ":perfetto_include_perfetto_public_base",
+        ":perfetto_include_perfetto_public_protozero",
+        ":perfetto_protos_perfetto_trace_android_winscope_common_zero_gen",
+        ":perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen",
+        ":perfetto_src_base_base",
+        ":perfetto_src_protozero_protozero",
+    ],
+    host_supported: true,
+    generated_headers: [
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen_headers",
+    ],
+    export_generated_headers: [
+        "perfetto_protos_perfetto_trace_android_winscope_common_zero_gen_headers",
+        "perfetto_protos_perfetto_trace_android_winscope_extensions_zero_gen_headers",
+    ],
+    defaults: [
+        "perfetto_defaults",
+    ],
+}
+
 // GN: [//protos/perfetto/trace:non_minimal_source_set, //protos/perfetto/trace/android:winscope_extensions_source_set]
 filegroup {
     name: "perfetto_winscope_filegroup_proto",
diff --git a/BUILD b/BUILD
index cc2854f..5054ec9 100644
--- a/BUILD
+++ b/BUILD
@@ -1765,6 +1765,8 @@
 perfetto_filegroup(
     name = "src_trace_processor_importers_proto_winscope_full",
     srcs = [
+        "src/trace_processor/importers/proto/winscope/android_input_event_parser.cc",
+        "src/trace_processor/importers/proto/winscope/android_input_event_parser.h",
         "src/trace_processor/importers/proto/winscope/protolog_messages_tracker.cc",
         "src/trace_processor/importers/proto/winscope/protolog_messages_tracker.h",
         "src/trace_processor/importers/proto/winscope/protolog_parser.cc",
@@ -1803,8 +1805,6 @@
         "src/trace_processor/importers/proto/additional_modules.h",
         "src/trace_processor/importers/proto/android_camera_event_module.cc",
         "src/trace_processor/importers/proto/android_camera_event_module.h",
-        "src/trace_processor/importers/proto/android_input_event_module.cc",
-        "src/trace_processor/importers/proto/android_input_event_module.h",
         "src/trace_processor/importers/proto/android_probes_module.cc",
         "src/trace_processor/importers/proto/android_probes_module.h",
         "src/trace_processor/importers/proto/android_probes_parser.cc",
@@ -4786,7 +4786,6 @@
     name = "protos_perfetto_trace_android_protos",
     srcs = [
         "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",
@@ -4845,6 +4844,7 @@
 perfetto_proto_library(
     name = "protos_perfetto_trace_android_winscope_extensions_protos",
     srcs = [
+        "protos/perfetto/trace/android/android_input_event.proto",
         "protos/perfetto/trace/android/graphics/pixelformat.proto",
         "protos/perfetto/trace/android/inputmethodeditor.proto",
         "protos/perfetto/trace/android/inputmethodservice/inputmethodservice.proto",
diff --git a/protos/perfetto/trace/android/BUILD.gn b/protos/perfetto/trace/android/BUILD.gn
index 0902ceb..50af2b2 100644
--- a/protos/perfetto/trace/android/BUILD.gn
+++ b/protos/perfetto/trace/android/BUILD.gn
@@ -22,7 +22,6 @@
 
   sources = [
     "android_game_intervention_list.proto",
-    "android_input_event.proto",
     "android_log.proto",
     "android_system_property.proto",
     "camera_event.proto",
@@ -67,6 +66,7 @@
   ]
   public_deps = [ ":winscope_common_@TYPE@" ]
   sources = [
+    "android_input_event.proto",
     "graphics/pixelformat.proto",
     "inputmethodeditor.proto",
     "inputmethodservice/inputmethodservice.proto",
@@ -95,6 +95,11 @@
   import_dirs = [ "${perfetto_protobuf_src_dir}" ]
 }
 
+static_library("perfetto_winscope_extensions_zero") {
+  complete_static_lib = true
+  deps = [ ":winscope_extensions_zero" ]
+}
+
 perfetto_proto_library("winscope_descriptor") {
   proto_generators = [ "descriptor" ]
   generate_descriptor = "winscope.descriptor"
diff --git a/protos/perfetto/trace/android/winscope.proto b/protos/perfetto/trace/android/winscope.proto
index 50723ee..c71daff 100644
--- a/protos/perfetto/trace/android/winscope.proto
+++ b/protos/perfetto/trace/android/winscope.proto
@@ -18,6 +18,7 @@
 
 package perfetto.protos;
 
+import "protos/perfetto/trace/android/android_input_event.proto";
 import "protos/perfetto/trace/android/protolog.proto";
 import "protos/perfetto/trace/android/shell_transition.proto";
 import "protos/perfetto/trace/android/surfaceflinger_layers.proto";
@@ -34,4 +35,5 @@
   optional ProtoLogMessage protolog_message = 4;
   optional WinscopeExtensionsImpl winscope_extensions = 5;
   optional ViewCapture viewcapture = 6;
+  optional AndroidInputEvent android_input_event = 7;
 }
diff --git a/protos/perfetto/trace/android/winscope_extensions.proto b/protos/perfetto/trace/android/winscope_extensions.proto
index a27a5c5..cb635f3 100644
--- a/protos/perfetto/trace/android/winscope_extensions.proto
+++ b/protos/perfetto/trace/android/winscope_extensions.proto
@@ -19,5 +19,5 @@
 package perfetto.protos;
 
 message WinscopeExtensions {
-  extensions 1 to 4;
+  extensions 1 to 5;
 }
diff --git a/protos/perfetto/trace/android/winscope_extensions_impl.proto b/protos/perfetto/trace/android/winscope_extensions_impl.proto
index 0d33163..8b7eb1f 100644
--- a/protos/perfetto/trace/android/winscope_extensions_impl.proto
+++ b/protos/perfetto/trace/android/winscope_extensions_impl.proto
@@ -19,6 +19,7 @@
 package perfetto.protos;
 
 import public "protos/perfetto/trace/android/winscope_extensions.proto";
+import "protos/perfetto/trace/android/android_input_event.proto";
 import "protos/perfetto/trace/android/inputmethodeditor.proto";
 import "protos/perfetto/trace/android/viewcapture.proto";
 
@@ -29,5 +30,6 @@
     optional InputMethodManagerServiceTraceProto inputmethod_manager_service =
         3;
     optional ViewCapture viewcapture = 4;
+    optional AndroidInputEvent android_input_event = 5;
   }
 }
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index 7466ff6..f6576c1 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -4358,125 +4358,6 @@
 
 // End of protos/perfetto/trace/android/android_game_intervention_list.proto
 
-// Begin of protos/perfetto/trace/android/android_input_event.proto
-
-// A representation of an Android MotionEvent.
-// See: https://developer.android.com/reference/android/view/MotionEvent
-message AndroidMotionEvent {
-  // A representation of one pointer inside a MotionEvent.
-  // Each Pointer contains the values present in its corresponding
-  // MotionEvent.PointerCoords and MotionEvent.PointerProperties.
-  message Pointer {
-     message AxisValue {
-      optional int32 axis = 1;
-      optional float value = 2;
-    }
-    repeated AxisValue axis_value = 1;
-    optional int32 pointer_id = 2;
-    optional int32 tool_type = 3;
-  }
-
-  // The randomly-generated ID used to track the event through the pipeline.
-  optional fixed32 event_id = 1;
-  // The event's timestamp - generated by the kernel.
-  optional int64 event_time_nanos = 2;
-  optional uint32 source = 3;
-  optional int32 action = 4;
-  optional int32 device_id = 5;
-  // Use a signed int for display_id, because -1 (DISPLAY_IS_NONE) is a common value.
-  optional sint32 display_id = 6;
-  optional int32 classification = 7;
-  optional uint32 flags = 8;
-  repeated Pointer pointer = 9;
-
-  // Field numbers 10-15 are reserved for commonly used fields.
-
-  // If this event was synthesized as a result of one or more different
-  // event, original_event_ids are the event_ids associated with the original events.
-  // For example, if this is an ACTION_HOVER_ENTER event that is synthesized
-  // due to an ACTION_HOVER_MOVE event entering the bounds of a window, the
-  // id of the original hover move event will be listed here.
-  repeated fixed32 original_event_id = 16 [packed = true];
-  // The timestamp of the ACTION_DOWN event associated with this gesture.
-  optional int64 down_time_nanos = 17;
-  optional float cursor_position_x = 18;
-  optional float cursor_position_y = 19;
-  optional int32 action_button = 20;
-  optional uint32 button_state = 21;
-  optional uint32 meta_state = 22;
-  optional uint32 policy_flags = 23;
-  optional float precision_x = 24;
-  optional float precision_y = 25;
-}
-
-// A representation of an Android KeyEvent.
-// See: https://developer.android.com/reference/android/view/KeyEvent
-message AndroidKeyEvent {
-  // The randomly-generated ID used to track the event through the pipeline.
-  optional fixed32 event_id = 1;
-  // The event's timestamp - generated by the kernel.
-  optional int64 event_time_nanos = 2;
-  // The timestamp of the ACTION_DOWN event associated with this gesture.
-  optional int64 down_time_nanos = 3;
-  optional uint32 source = 4;
-  optional int32 action = 5;
-  optional int32 device_id = 6;
-  // Use a signed int for display_id, because -1 (DISPLAY_IS_NONE) is a common value.
-  optional sint32 display_id = 7;
-  optional int32 key_code = 8;
-  optional uint32 scan_code = 9;
-  optional uint32 meta_state = 10;
-  optional int32 repeat_count = 11;
-  optional uint32 flags = 12;
-  optional uint32 policy_flags = 13;
-}
-
-// An event that traces an input event being dispatched by the system to one window.
-message AndroidWindowInputDispatchEvent {
-  // Stores x/y values for each pointer sent to the window for events
-  // that are dispatched to a certain location on the screen. This is not relevant
-  // for KeyEvents and MotionEvents that are dispatched to focused windows.
-  message DispatchedPointer {
-    optional int32 pointer_id = 1;
-    // The coordinates of the pointer in the logical display space, AKA "raw coordinates".
-    optional float x_in_display = 2;
-    optional float y_in_display = 3;
-    // The axis values for this pointer that were modified by the window transform.
-    repeated AndroidMotionEvent.Pointer.AxisValue axis_value_in_window = 4;
-  }
-
-  // The event_id of the event that was dispatched to the window.
-  optional fixed32 event_id = 1;
-  // The vsync_id of the frame in which the decision was made to dispatch the event to
-  // the window.
-  optional int64 vsync_id = 2;
-  // The id of the window to which the event was dispatched.
-  optional int32 window_id = 3;
-  // Only relevant for MotionEvents that are dispatched to a screen location.
-  // Each DispatchedPointer has a 1:1 correspondence with the Pointers in the AndroidMotionEvent.
-  repeated DispatchedPointer dispatched_pointer = 4;
-  // The event flags that were used when dispatching the event to this window.
-  // If the same event is dispatched to more than one window, it is possible that they
-  // were dispatched using different flag values for each window.
-  optional uint32 resolved_flags = 5;
-}
-
-message AndroidInputEvent {
-  oneof event {
-    // Traces input events received by or generated by InputDispatcher
-    AndroidMotionEvent dispatcher_motion_event = 1;
-    AndroidMotionEvent dispatcher_motion_event_redacted = 2;
-    AndroidKeyEvent dispatcher_key_event = 3;
-    AndroidKeyEvent dispatcher_key_event_redacted = 4;
-
-    // Traces an event being dispatched to a window.
-    AndroidWindowInputDispatchEvent dispatcher_window_dispatch_event = 5;
-    AndroidWindowInputDispatchEvent dispatcher_window_dispatch_event_redacted = 6;
-  }
-}
-
-// End of protos/perfetto/trace/android/android_input_event.proto
-
 // Begin of protos/perfetto/trace/android/android_log.proto
 
 message AndroidLogPacket {
@@ -5844,7 +5725,7 @@
 // Begin of protos/perfetto/trace/android/winscope_extensions.proto
 
 message WinscopeExtensions {
-  extensions 1 to 4;
+  extensions 1 to 5;
 }
 
 // End of protos/perfetto/trace/android/winscope_extensions.proto
@@ -15198,10 +15079,6 @@
     V8WasmCode v8_wasm_code = 101;
     V8RegExpCode v8_reg_exp_code = 102;
     V8CodeMove v8_code_move = 103;
-
-    // InputFlinger traces
-    AndroidInputEvent android_input_event = 106;
-
     // Clock synchronization with remote machines.
     RemoteClockSync remote_clock_sync = 107;
 
@@ -15217,6 +15094,9 @@
     TestEvent for_testing = 900;
   }
 
+  // AndroidInputEvent android_input_event (moved to winscope_extensions)
+  reserved 106;
+
   // 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 63bc59e..b6489e0 100644
--- a/protos/perfetto/trace/trace_packet.proto
+++ b/protos/perfetto/trace/trace_packet.proto
@@ -20,7 +20,6 @@
 import "protos/perfetto/config/trace_config.proto";
 import "protos/perfetto/trace/extension_descriptor.proto";
 import "protos/perfetto/trace/android/android_game_intervention_list.proto";
-import "protos/perfetto/trace/android/android_input_event.proto";
 import "protos/perfetto/trace/android/android_log.proto";
 import "protos/perfetto/trace/android/android_system_property.proto";
 import "protos/perfetto/trace/android/camera_event.proto";
@@ -239,10 +238,6 @@
     V8WasmCode v8_wasm_code = 101;
     V8RegExpCode v8_reg_exp_code = 102;
     V8CodeMove v8_code_move = 103;
-
-    // InputFlinger traces
-    AndroidInputEvent android_input_event = 106;
-
     // Clock synchronization with remote machines.
     RemoteClockSync remote_clock_sync = 107;
 
@@ -258,6 +253,9 @@
     TestEvent for_testing = 900;
   }
 
+  // AndroidInputEvent android_input_event (moved to winscope_extensions)
+  reserved 106;
+
   // Trusted user id of the producer which generated this packet. Keep in sync
   // with TrustedPacket.trusted_uid.
   //
diff --git a/src/trace_processor/importers/proto/BUILD.gn b/src/trace_processor/importers/proto/BUILD.gn
index effda82..b92bed6 100644
--- a/src/trace_processor/importers/proto/BUILD.gn
+++ b/src/trace_processor/importers/proto/BUILD.gn
@@ -115,8 +115,6 @@
     "additional_modules.h",
     "android_camera_event_module.cc",
     "android_camera_event_module.h",
-    "android_input_event_module.cc",
-    "android_input_event_module.h",
     "android_probes_module.cc",
     "android_probes_module.h",
     "android_probes_parser.cc",
diff --git a/src/trace_processor/importers/proto/additional_modules.cc b/src/trace_processor/importers/proto/additional_modules.cc
index cf2ee84..91645c3 100644
--- a/src/trace_processor/importers/proto/additional_modules.cc
+++ b/src/trace_processor/importers/proto/additional_modules.cc
@@ -18,7 +18,6 @@
 #include "src/trace_processor/importers/etw/etw_module_impl.h"
 #include "src/trace_processor/importers/ftrace/ftrace_module_impl.h"
 #include "src/trace_processor/importers/proto/android_camera_event_module.h"
-#include "src/trace_processor/importers/proto/android_input_event_module.h"
 #include "src/trace_processor/importers/proto/android_probes_module.h"
 #include "src/trace_processor/importers/proto/graphics_event_module.h"
 #include "src/trace_processor/importers/proto/heap_graph_module.h"
@@ -46,7 +45,6 @@
   context->modules.emplace_back(new MetadataModule(context));
   context->modules.emplace_back(new V8Module(context));
   context->modules.emplace_back(new WinscopeModule(context));
-  context->modules.emplace_back(new AndroidInputEventModule(context));
 
   // Ftrace/Etw modules are special, because it has one extra method for parsing
   // ftrace/etw packets. So we need to store a pointer to it separately.
diff --git a/src/trace_processor/importers/proto/winscope/BUILD.gn b/src/trace_processor/importers/proto/winscope/BUILD.gn
index f518f42..682fc4b 100644
--- a/src/trace_processor/importers/proto/winscope/BUILD.gn
+++ b/src/trace_processor/importers/proto/winscope/BUILD.gn
@@ -16,6 +16,8 @@
 
 source_set("full") {
   sources = [
+    "android_input_event_parser.cc",
+    "android_input_event_parser.h",
     "protolog_messages_tracker.cc",
     "protolog_messages_tracker.h",
     "protolog_parser.cc",
diff --git a/src/trace_processor/importers/proto/android_input_event_module.cc b/src/trace_processor/importers/proto/winscope/android_input_event_parser.cc
similarity index 84%
rename from src/trace_processor/importers/proto/android_input_event_module.cc
rename to src/trace_processor/importers/proto/winscope/android_input_event_parser.cc
index 26671a7..566ab8c 100644
--- a/src/trace_processor/importers/proto/android_input_event_module.cc
+++ b/src/trace_processor/importers/proto/winscope/android_input_event_parser.cc
@@ -14,12 +14,12 @@
  * limitations under the License.
  */
 
-#include "src/trace_processor/importers/proto/android_input_event_module.h"
+#include "src/trace_processor/importers/proto/winscope/android_input_event_parser.h"
 
 #include "protos/perfetto/trace/android/android_input_event.pbzero.h"
 #include "src/trace_processor/importers/common/args_tracker.h"
 #include "src/trace_processor/importers/proto/args_parser.h"
-#include "src/trace_processor/importers/proto/trace.descriptor.h"
+#include "src/trace_processor/importers/proto/winscope/winscope.descriptor.h"
 #include "src/trace_processor/storage/trace_storage.h"
 #include "src/trace_processor/tables/android_tables_py.h"
 #include "src/trace_processor/types/trace_processor_context.h"
@@ -32,22 +32,16 @@
 using perfetto::protos::pbzero::AndroidWindowInputDispatchEvent;
 using perfetto::protos::pbzero::TracePacket;
 
-AndroidInputEventModule::AndroidInputEventModule(TraceProcessorContext* context)
-    : context_(*context), args_parser_(pool_) {
-  pool_.AddFromFileDescriptorSet(kTraceDescriptor.data(),
-                                 kTraceDescriptor.size());
-  RegisterForField(TracePacket::kAndroidInputEventFieldNumber, context);
+AndroidInputEventParser::AndroidInputEventParser(TraceProcessorContext* context)
+    : context_(*context), args_parser_{pool_} {
+  pool_.AddFromFileDescriptorSet(kWinscopeDescriptor.data(),
+                                 kWinscopeDescriptor.size());
 }
 
-void AndroidInputEventModule::ParseTracePacketData(
-    const TracePacket::Decoder& decoder,
+void AndroidInputEventParser::ParseAndroidInputEvent(
     int64_t packet_ts,
-    const TracePacketData&,
-    uint32_t field_id) {
-  if (field_id != TracePacket::kAndroidInputEventFieldNumber)
-    return;
-
-  auto input_event = AndroidInputEvent::Decoder(decoder.android_input_event());
+    const protozero::ConstBytes& bytes) {
+  auto input_event = AndroidInputEvent::Decoder(bytes);
 
   constexpr static auto supported_fields = std::array{
       AndroidInputEvent::kDispatcherMotionEventFieldNumber,
@@ -79,7 +73,7 @@
   }
 }
 
-void AndroidInputEventModule::ParseMotionEvent(
+void AndroidInputEventParser::ParseMotionEvent(
     int64_t packet_ts,
     const protozero::ConstBytes& bytes) {
   AndroidMotionEvent::Decoder event_proto(bytes);
@@ -100,7 +94,7 @@
     context_.storage->IncrementStats(stats::android_input_event_parse_errors);
 }
 
-void AndroidInputEventModule::ParseKeyEvent(
+void AndroidInputEventParser::ParseKeyEvent(
     int64_t packet_ts,
     const protozero::ConstBytes& bytes) {
   AndroidKeyEvent::Decoder event_proto(bytes);
@@ -121,7 +115,7 @@
     context_.storage->IncrementStats(stats::android_input_event_parse_errors);
 }
 
-void AndroidInputEventModule::ParseWindowDispatchEvent(
+void AndroidInputEventParser::ParseWindowDispatchEvent(
     int64_t packet_ts,
     const protozero::ConstBytes& bytes) {
   AndroidWindowInputDispatchEvent::Decoder event_proto(bytes);
diff --git a/src/trace_processor/importers/proto/android_input_event_module.h b/src/trace_processor/importers/proto/winscope/android_input_event_parser.h
similarity index 70%
rename from src/trace_processor/importers/proto/android_input_event_module.h
rename to src/trace_processor/importers/proto/winscope/android_input_event_parser.h
index c310909..96f523b 100644
--- a/src/trace_processor/importers/proto/android_input_event_module.h
+++ b/src/trace_processor/importers/proto/winscope/android_input_event_parser.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_ANDROID_INPUT_EVENT_MODULE_H_
-#define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_ANDROID_INPUT_EVENT_MODULE_H_
+#ifndef SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_WINSCOPE_ANDROID_INPUT_EVENT_PARSER_H_
+#define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_WINSCOPE_ANDROID_INPUT_EVENT_PARSER_H_
 
 #include <cstdint>
 #include "perfetto/base/build_config.h"
@@ -27,14 +27,12 @@
 
 namespace perfetto::trace_processor {
 
-class AndroidInputEventModule : public ProtoImporterModule {
+class AndroidInputEventParser {
  public:
-  explicit AndroidInputEventModule(TraceProcessorContext* context);
+  explicit AndroidInputEventParser(TraceProcessorContext* context);
 
-  void ParseTracePacketData(const protos::pbzero::TracePacket::Decoder&,
-                            int64_t packet_ts,
-                            const TracePacketData&,
-                            uint32_t field_id) override;
+  void ParseAndroidInputEvent(int64_t packet_ts,
+                            const protozero::ConstBytes& bytes);
 
  private:
   TraceProcessorContext& context_;
@@ -48,4 +46,4 @@
 
 }  // namespace perfetto::trace_processor
 
-#endif  // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_ANDROID_INPUT_EVENT_MODULE_H_
+#endif  // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_WINSCOPE_ANDROID_INPUT_EVENT_PARSER_H_
diff --git a/src/trace_processor/importers/proto/winscope/winscope_module.cc b/src/trace_processor/importers/proto/winscope/winscope_module.cc
index 81c7a59..1d63140 100644
--- a/src/trace_processor/importers/proto/winscope/winscope_module.cc
+++ b/src/trace_processor/importers/proto/winscope/winscope_module.cc
@@ -33,7 +33,8 @@
       surfaceflinger_layers_parser_(context),
       surfaceflinger_transactions_parser_(context),
       shell_transitions_parser_(context),
-      protolog_parser_(context) {
+      protolog_parser_(context),
+      android_input_event_parser_(context) {
   RegisterForField(TracePacket::kSurfaceflingerLayersSnapshotFieldNumber,
                    context);
   RegisterForField(TracePacket::kSurfaceflingerTransactionsFieldNumber,
@@ -105,6 +106,11 @@
              field.valid()) {
     ParseViewCaptureData(timestamp, field.as_bytes(),
                          data.sequence_state.get());
+  } else if (field = decoder.Get(
+                 WinscopeExtensionsImpl::kAndroidInputEventFieldNumber);
+             field.valid()) {
+    android_input_event_parser_.ParseAndroidInputEvent(timestamp,
+                                                       field.as_bytes());
   }
 }
 
diff --git a/src/trace_processor/importers/proto/winscope/winscope_module.h b/src/trace_processor/importers/proto/winscope/winscope_module.h
index 7f6ae08..c66d005 100644
--- a/src/trace_processor/importers/proto/winscope/winscope_module.h
+++ b/src/trace_processor/importers/proto/winscope/winscope_module.h
@@ -21,6 +21,7 @@
 #include "perfetto/base/build_config.h"
 #include "src/trace_processor/importers/common/parser_types.h"
 #include "src/trace_processor/importers/proto/proto_importer_module.h"
+#include "src/trace_processor/importers/proto/winscope/android_input_event_parser.h"
 #include "src/trace_processor/importers/proto/winscope/protolog_parser.h"
 #include "src/trace_processor/importers/proto/winscope/shell_transitions_parser.h"
 #include "src/trace_processor/importers/proto/winscope/surfaceflinger_layers_parser.h"
@@ -70,6 +71,7 @@
   SurfaceFlingerTransactionsParser surfaceflinger_transactions_parser_;
   ShellTransitionsParser shell_transitions_parser_;
   ProtoLogParser protolog_parser_;
+  AndroidInputEventParser android_input_event_parser_;
 };
 
 }  // namespace trace_processor
diff --git a/test/trace_processor/diff_tests/parser/android/input_event_trace.textproto b/test/trace_processor/diff_tests/parser/android/input_event_trace.textproto
index 02ecce4..2cb52b8 100644
--- a/test/trace_processor/diff_tests/parser/android/input_event_trace.textproto
+++ b/test/trace_processor/diff_tests/parser/android/input_event_trace.textproto
@@ -150,59 +150,61 @@
 }
 packet {
   first_packet_on_sequence: true
-  android_input_event {
-    dispatcher_motion_event {
-      event_id: 104114844
-      event_time_nanos: 64179212500000
-      down_time_nanos: 64179212500000
-      source: 4098
-      action: 0
-      device_id: 4
-      display_id: 0
-      classification: 0
-      flags: 0
-      policy_flags: 1644167168
-      cursor_position_x: nan
-      cursor_position_y: nan
-      meta_state: 0
-      pointer {
-        pointer_id: 0
-        tool_type: 1
-        axis_value {
-          axis: 0
-          value: 580.000000
-        }
-        axis_value {
-          axis: 1
-          value: 798.000000
-        }
-        axis_value {
-          axis: 2
-          value: 1.003906
-        }
-        axis_value {
-          axis: 3
-          value: 0.033998
-        }
-        axis_value {
-          axis: 4
-          value: 92.000000
-        }
-        axis_value {
-          axis: 5
-          value: 82.000000
-        }
-        axis_value {
-          axis: 6
-          value: 92.000000
-        }
-        axis_value {
-          axis: 7
-          value: 82.000000
-        }
-        axis_value {
-          axis: 8
-          value: 0.983282
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_motion_event {
+        event_id: 104114844
+        event_time_nanos: 64179212500000
+        down_time_nanos: 64179212500000
+        source: 4098
+        action: 0
+        device_id: 4
+        display_id: 0
+        classification: 0
+        flags: 0
+        policy_flags: 1644167168
+        cursor_position_x: nan
+        cursor_position_y: nan
+        meta_state: 0
+        pointer {
+          pointer_id: 0
+          tool_type: 1
+          axis_value {
+            axis: 0
+            value: 580.000000
+          }
+          axis_value {
+            axis: 1
+            value: 798.000000
+          }
+          axis_value {
+            axis: 2
+            value: 1.003906
+          }
+          axis_value {
+            axis: 3
+            value: 0.033998
+          }
+          axis_value {
+            axis: 4
+            value: 92.000000
+          }
+          axis_value {
+            axis: 5
+            value: 82.000000
+          }
+          axis_value {
+            axis: 6
+            value: 92.000000
+          }
+          axis_value {
+            axis: 7
+            value: 82.000000
+          }
+          axis_value {
+            axis: 8
+            value: 0.983282
+          }
         }
       }
     }
@@ -213,59 +215,61 @@
   previous_packet_dropped: true
 }
 packet {
-  android_input_event {
-    dispatcher_motion_event {
-      event_id: 1141228253
-      event_time_nanos: 64179212500000
-      down_time_nanos: 64179212500000
-      source: 4098
-      action: 4
-      device_id: 4
-      display_id: 0
-      classification: 0
-      flags: 0
-      policy_flags: 1644167168
-      cursor_position_x: nan
-      cursor_position_y: nan
-      meta_state: 0
-      pointer {
-        pointer_id: 0
-        tool_type: 1
-        axis_value {
-          axis: 0
-          value: 580.000000
-        }
-        axis_value {
-          axis: 1
-          value: 798.000000
-        }
-        axis_value {
-          axis: 2
-          value: 1.003906
-        }
-        axis_value {
-          axis: 3
-          value: 0.033998
-        }
-        axis_value {
-          axis: 4
-          value: 92.000000
-        }
-        axis_value {
-          axis: 5
-          value: 82.000000
-        }
-        axis_value {
-          axis: 6
-          value: 92.000000
-        }
-        axis_value {
-          axis: 7
-          value: 82.000000
-        }
-        axis_value {
-          axis: 8
-          value: 0.983282
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_motion_event {
+        event_id: 1141228253
+        event_time_nanos: 64179212500000
+        down_time_nanos: 64179212500000
+        source: 4098
+        action: 4
+        device_id: 4
+        display_id: 0
+        classification: 0
+        flags: 0
+        policy_flags: 1644167168
+        cursor_position_x: nan
+        cursor_position_y: nan
+        meta_state: 0
+        pointer {
+          pointer_id: 0
+          tool_type: 1
+          axis_value {
+            axis: 0
+            value: 580.000000
+          }
+          axis_value {
+            axis: 1
+            value: 798.000000
+          }
+          axis_value {
+            axis: 2
+            value: 1.003906
+          }
+          axis_value {
+            axis: 3
+            value: 0.033998
+          }
+          axis_value {
+            axis: 4
+            value: 92.000000
+          }
+          axis_value {
+            axis: 5
+            value: 82.000000
+          }
+          axis_value {
+            axis: 6
+            value: 92.000000
+          }
+          axis_value {
+            axis: 7
+            value: 82.000000
+          }
+          axis_value {
+            axis: 8
+            value: 0.983282
+          }
         }
       }
     }
@@ -275,27 +279,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 1141228253
-      vsync_id: 182239
-      window_id: 105
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: -681.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.554132
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 1141228253
+        vsync_id: 182239
+        window_id: 105
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: -681.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.554132
+          }
         }
       }
     }
@@ -305,27 +311,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 104114844
-      vsync_id: 182239
-      window_id: 181
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.554157
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 104114844
+        vsync_id: 182239
+        window_id: 181
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.554157
+          }
         }
       }
     }
@@ -335,27 +343,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 104114844
-      vsync_id: 182239
-      window_id: 58
-      resolved_flags: 3
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1718.181641
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 600.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.554074
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 104114844
+        vsync_id: 182239
+        window_id: 58
+        resolved_flags: 3
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1718.181641
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 600.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.554074
+          }
         }
       }
     }
@@ -365,27 +375,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 104114844
-      vsync_id: 182239
-      window_id: 76
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.554157
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 104114844
+        vsync_id: 182239
+        window_id: 76
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.554157
+          }
         }
       }
     }
@@ -395,27 +407,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 104114844
-      vsync_id: 182239
-      window_id: 68
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.554157
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 104114844
+        vsync_id: 182239
+        window_id: 68
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.554157
+          }
         }
       }
     }
@@ -425,27 +439,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 104114844
-      vsync_id: 0
-      window_id: 0
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.554157
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 104114844
+        vsync_id: 0
+        window_id: 0
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.554157
+          }
         }
       }
     }
@@ -455,59 +471,61 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_motion_event {
-      event_id: 843076721
-      event_time_nanos: 64179262122000
-      down_time_nanos: 64179212500000
-      source: 4098
-      action: 2
-      device_id: 4
-      display_id: 0
-      classification: 1
-      flags: 0
-      policy_flags: 1644167168
-      cursor_position_x: nan
-      cursor_position_y: nan
-      meta_state: 0
-      pointer {
-        pointer_id: 0
-        tool_type: 1
-        axis_value {
-          axis: 0
-          value: 580.000000
-        }
-        axis_value {
-          axis: 1
-          value: 798.000000
-        }
-        axis_value {
-          axis: 2
-          value: 0.113281
-        }
-        axis_value {
-          axis: 3
-          value: 0.011333
-        }
-        axis_value {
-          axis: 4
-          value: 29.000000
-        }
-        axis_value {
-          axis: 5
-          value: 29.000000
-        }
-        axis_value {
-          axis: 6
-          value: 29.000000
-        }
-        axis_value {
-          axis: 7
-          value: 29.000000
-        }
-        axis_value {
-          axis: 8
-          value: 0.912335
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_motion_event {
+        event_id: 843076721
+        event_time_nanos: 64179262122000
+        down_time_nanos: 64179212500000
+        source: 4098
+        action: 2
+        device_id: 4
+        display_id: 0
+        classification: 1
+        flags: 0
+        policy_flags: 1644167168
+        cursor_position_x: nan
+        cursor_position_y: nan
+        meta_state: 0
+        pointer {
+          pointer_id: 0
+          tool_type: 1
+          axis_value {
+            axis: 0
+            value: 580.000000
+          }
+          axis_value {
+            axis: 1
+            value: 798.000000
+          }
+          axis_value {
+            axis: 2
+            value: 0.113281
+          }
+          axis_value {
+            axis: 3
+            value: 0.011333
+          }
+          axis_value {
+            axis: 4
+            value: 29.000000
+          }
+          axis_value {
+            axis: 5
+            value: 29.000000
+          }
+          axis_value {
+            axis: 6
+            value: 29.000000
+          }
+          axis_value {
+            axis: 7
+            value: 29.000000
+          }
+          axis_value {
+            axis: 8
+            value: 0.912335
+          }
         }
       }
     }
@@ -517,27 +535,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 843076721
-      vsync_id: 182239
-      window_id: 181
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.483198
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 843076721
+        vsync_id: 182239
+        window_id: 181
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.483198
+          }
         }
       }
     }
@@ -547,27 +567,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 843076721
-      vsync_id: 182239
-      window_id: 58
-      resolved_flags: 3
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1718.181641
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 600.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.483237
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 843076721
+        vsync_id: 182239
+        window_id: 58
+        resolved_flags: 3
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1718.181641
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 600.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.483237
+          }
         }
       }
     }
@@ -577,27 +599,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 843076721
-      vsync_id: 182239
-      window_id: 76
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.483198
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 843076721
+        vsync_id: 182239
+        window_id: 76
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.483198
+          }
         }
       }
     }
@@ -607,27 +631,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 843076721
-      vsync_id: 182239
-      window_id: 68
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.483198
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 843076721
+        vsync_id: 182239
+        window_id: 68
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.483198
+          }
         }
       }
     }
@@ -637,27 +663,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 843076721
-      vsync_id: 0
-      window_id: 0
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.483198
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 843076721
+        vsync_id: 0
+        window_id: 0
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.483198
+          }
         }
       }
     }
@@ -667,59 +695,61 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_motion_event {
-      event_id: 744146837
-      event_time_nanos: 64179268985000
-      down_time_nanos: 64179212500000
-      source: 4098
-      action: 1
-      device_id: 4
-      display_id: 0
-      classification: 1
-      flags: 0
-      policy_flags: 1644167168
-      cursor_position_x: nan
-      cursor_position_y: nan
-      meta_state: 0
-      pointer {
-        pointer_id: 0
-        tool_type: 1
-        axis_value {
-          axis: 0
-          value: 580.000000
-        }
-        axis_value {
-          axis: 1
-          value: 798.000000
-        }
-        axis_value {
-          axis: 2
-          value: 0.113281
-        }
-        axis_value {
-          axis: 3
-          value: 0.011333
-        }
-        axis_value {
-          axis: 4
-          value: 29.000000
-        }
-        axis_value {
-          axis: 5
-          value: 29.000000
-        }
-        axis_value {
-          axis: 6
-          value: 29.000000
-        }
-        axis_value {
-          axis: 7
-          value: 29.000000
-        }
-        axis_value {
-          axis: 8
-          value: 0.912335
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_motion_event {
+        event_id: 744146837
+        event_time_nanos: 64179268985000
+        down_time_nanos: 64179212500000
+        source: 4098
+        action: 1
+        device_id: 4
+        display_id: 0
+        classification: 1
+        flags: 0
+        policy_flags: 1644167168
+        cursor_position_x: nan
+        cursor_position_y: nan
+        meta_state: 0
+        pointer {
+          pointer_id: 0
+          tool_type: 1
+          axis_value {
+            axis: 0
+            value: 580.000000
+          }
+          axis_value {
+            axis: 1
+            value: 798.000000
+          }
+          axis_value {
+            axis: 2
+            value: 0.113281
+          }
+          axis_value {
+            axis: 3
+            value: 0.011333
+          }
+          axis_value {
+            axis: 4
+            value: 29.000000
+          }
+          axis_value {
+            axis: 5
+            value: 29.000000
+          }
+          axis_value {
+            axis: 6
+            value: 29.000000
+          }
+          axis_value {
+            axis: 7
+            value: 29.000000
+          }
+          axis_value {
+            axis: 8
+            value: 0.912335
+          }
         }
       }
     }
@@ -729,27 +759,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 744146837
-      vsync_id: 182239
-      window_id: 181
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.483198
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 744146837
+        vsync_id: 182239
+        window_id: 181
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.483198
+          }
         }
       }
     }
@@ -759,27 +791,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 744146837
-      vsync_id: 182239
-      window_id: 58
-      resolved_flags: 3
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1718.181641
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 600.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.483237
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 744146837
+        vsync_id: 182239
+        window_id: 58
+        resolved_flags: 3
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1718.181641
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 600.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.483237
+          }
         }
       }
     }
@@ -789,27 +823,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 744146837
-      vsync_id: 182239
-      window_id: 76
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.483198
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 744146837
+        vsync_id: 182239
+        window_id: 76
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.483198
+          }
         }
       }
     }
@@ -819,27 +855,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 744146837
-      vsync_id: 182239
-      window_id: 68
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.483198
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 744146837
+        vsync_id: 182239
+        window_id: 68
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.483198
+          }
         }
       }
     }
@@ -849,27 +887,29 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 744146837
-      vsync_id: 0
-      window_id: 0
-      resolved_flags: 0
-      dispatched_pointer {
-        pointer_id: 0
-        x_in_display: 1762.000000
-        y_in_display: 580.000000
-        axis_value_in_window {
-          axis: 0
-          value: 1762.000000
-        }
-        axis_value_in_window {
-          axis: 1
-          value: 580.000000
-        }
-        axis_value_in_window {
-          axis: 8
-          value: 2.483198
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 744146837
+        vsync_id: 0
+        window_id: 0
+        resolved_flags: 0
+        dispatched_pointer {
+          pointer_id: 0
+          x_in_display: 1762.000000
+          y_in_display: 580.000000
+          axis_value_in_window {
+            axis: 0
+            value: 1762.000000
+          }
+          axis_value_in_window {
+            axis: 1
+            value: 580.000000
+          }
+          axis_value_in_window {
+            axis: 8
+            value: 2.483198
+          }
         }
       }
     }
@@ -879,21 +919,23 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_key_event {
-      event_id: 324105269
-      event_time_nanos: 64182660299000
-      down_time_nanos: 64182660299000
-      source: 257
-      action: 0
-      device_id: 2
-      display_id: -1
-      repeat_count: 0
-      flags: 8
-      policy_flags: 1644167168
-      key_code: 25
-      scan_code: 114
-      meta_state: 0
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_key_event {
+        event_id: 324105269
+        event_time_nanos: 64182660299000
+        down_time_nanos: 64182660299000
+        source: 257
+        action: 0
+        device_id: 2
+        display_id: -1
+        repeat_count: 0
+        flags: 8
+        policy_flags: 1644167168
+        key_code: 25
+        scan_code: 114
+        meta_state: 0
+      }
     }
   }
   trusted_uid: 1000
@@ -901,12 +943,14 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 324105269
-      vsync_id: 182239
-      window_id: 181
-      resolved_flags: 8
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 324105269
+        vsync_id: 182239
+        window_id: 181
+        resolved_flags: 8
+      }
     }
   }
   trusted_uid: 1000
@@ -914,12 +958,14 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 324105269
-      vsync_id: 0
-      window_id: 0
-      resolved_flags: 8
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 324105269
+        vsync_id: 0
+        window_id: 0
+        resolved_flags: 8
+      }
     }
   }
   trusted_uid: 1000
@@ -927,21 +973,23 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_key_event {
-      event_id: 60594531
-      event_time_nanos: 64182816340000
-      down_time_nanos: 64182660299000
-      source: 257
-      action: 1
-      device_id: 2
-      display_id: -1
-      repeat_count: 0
-      flags: 8
-      policy_flags: 1644167168
-      key_code: 25
-      scan_code: 114
-      meta_state: 0
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_key_event {
+        event_id: 60594531
+        event_time_nanos: 64182816340000
+        down_time_nanos: 64182660299000
+        source: 257
+        action: 1
+        device_id: 2
+        display_id: -1
+        repeat_count: 0
+        flags: 8
+        policy_flags: 1644167168
+        key_code: 25
+        scan_code: 114
+        meta_state: 0
+      }
     }
   }
   trusted_uid: 1000
@@ -949,12 +997,14 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 60594531
-      vsync_id: 182239
-      window_id: 181
-      resolved_flags: 8
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 60594531
+        vsync_id: 182239
+        window_id: 181
+        resolved_flags: 8
+      }
     }
   }
   trusted_uid: 1000
@@ -962,12 +1012,14 @@
   trusted_pid: 1722
 }
 packet {
-  android_input_event {
-    dispatcher_window_dispatch_event {
-      event_id: 60594531
-      vsync_id: 0
-      window_id: 0
-      resolved_flags: 8
+  winscope_extensions {
+    [perfetto.protos.WinscopeExtensionsImpl.android_input_event] {
+      dispatcher_window_dispatch_event {
+        event_id: 60594531
+        vsync_id: 0
+        window_id: 0
+        resolved_flags: 8
+      }
     }
   }
   trusted_uid: 1000
diff --git a/tools/gen_android_bp b/tools/gen_android_bp
index 2aa0b7f..386a296 100755
--- a/tools/gen_android_bp
+++ b/tools/gen_android_bp
@@ -57,6 +57,7 @@
     '//:perfetto_integrationtests',
     '//:perfetto_unittests',
     '//protos/perfetto/trace:perfetto_trace_protos',
+    '//protos/perfetto/trace/android:perfetto_winscope_extensions_zero',
     '//src/android_internal:libperfetto_android_internal',
     '//src/base:perfetto_base_default_platform',
     '//src/shared_lib:libperfetto_c',
@@ -105,6 +106,7 @@
     '//:libperfetto',
     '//:libperfetto_client_experimental',
     '//protos/perfetto/trace:perfetto_trace_protos',
+    '//protos/perfetto/trace/android:perfetto_winscope_extensions_zero',
     '//src/shared_lib:libperfetto_c',
     '//src/trace_processor:demangle',
     '//src/trace_processor:trace_processor_shell',