• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
18
19package perfetto.protos;
20
21// Custom configuration for the "android.input.inputevent" data source.
22//
23// NOTE: Input traces can only be taken on debuggable (userdebug/eng) builds!
24//
25// Next ID: 5
26message AndroidInputEventConfig {
27  // Trace modes are tracing presets that are included in the system.
28  enum TraceMode {
29    // Preset mode for maximal tracing.
30    // WARNING: This will bypass all privacy measures on debuggable builds, and
31    // will record all
32    //          input events processed by the system, regardless of the context
33    //          in which they were processed. It should only be used for tracing
34    //          on a local device or for tests. It should NEVER be used for
35    //          field tracing.
36    TRACE_MODE_TRACE_ALL = 0;
37    // Use the tracing rules defined in this config to specify what events to
38    // trace.
39    TRACE_MODE_USE_RULES = 1;
40  }
41
42  // The tracing mode to use. If unspecified, it will default to
43  // TRACE_MODE_USE_RULES.
44  optional TraceMode mode = 1;
45
46  // The level of tracing that should be applied to an event.
47  enum TraceLevel {
48    // Do not trace the input event.
49    TRACE_LEVEL_NONE = 0;
50    // Trace the event as a redacted event, where certain sensitive fields are
51    // omitted from the trace, including the coordinates of pointer events and
52    // the key/scan codes of key events.
53    TRACE_LEVEL_REDACTED = 1;
54    // Trace the complete event.
55    TRACE_LEVEL_COMPLETE = 2;
56  }
57
58  // A rule that specifies the TraceLevel for an event based on matching
59  // conditions. All matchers in the rule are optional. To trigger this rule, an
60  // event must match all of its specified matchers (i.e. the matchers function
61  // like a series of conditions connected by a logical 'AND' operator). A rule
62  // with no specified matchers will match all events. Next ID: 6
63  message TraceRule {
64    // The trace level to be used for events that trigger this rule.
65    // If unspecified, TRACE_LEVEL_NONE will be used by default.
66    optional TraceLevel trace_level = 1;
67
68    // --- Optional Matchers ---
69
70    // Package matchers
71    //
72    // Respectively matches if all or any of the target apps for this event are
73    // contained in the specified list of package names.
74    //
75    // Intended usage:
76    //   - Use match_all_packages to selectively allow tracing for the listed
77    //   packages.
78    //   - Use match_any_packages to selectively deny tracing for certain
79    //   packages.
80    //
81    // WARNING: Great care must be taken when designing rules for field tracing!
82    //          This is because each event is almost always sent to more than
83    //          one app.
84    //              For example, when allowing tracing for a package that has a
85    //              spy window
86    //          over the display (e.g. SystemUI) using match_any_packages,
87    //          essentially all input will be recorded on that display. This is
88    //          because the events will be sent to the spy as well as the
89    //          foreground app, and regardless of what the foreground app is,
90    //          the event will end up being traced.
91    //              Alternatively, when attempting to block tracing for specific
92    //              packages using
93    //          match_all_packages, no events will likely be blocked. This is
94    //          because the event will also be sent to other apps (such as, but
95    //          not limited to, ones with spy windows), so the matcher will not
96    //          match unless all other targets are also listed under the
97    //          match_all_packages list.
98    repeated string match_all_packages = 2;
99    repeated string match_any_packages = 3;
100
101    // Matches if the event is secure, which means that at least one of the
102    // targets of this event is using the window flag FLAG_SECURE.
103    optional bool match_secure = 4;
104
105    // Matches if there was an active IME connection while this event was being
106    // processed.
107    optional bool match_ime_connection_active = 5;
108  }
109
110  // The list of rules to use to determine the trace level of events.
111  // Each event will be traced using the TraceLevel of the first rule that it
112  // triggers from this list. The rules are evaluated in the order in which they
113  // are specified. If an event does not match any of the rules,
114  // TRACE_LEVEL_NONE will be used by default.
115  repeated TraceRule rules = 2;
116
117  // --- Control flags ---
118
119  // Trace input events processed by the system as they are being dispatched
120  // to application windows. All trace rules will apply.
121  //   - If this flag is used without enabling trace_dispatcher_window_dispatch,
122  //   it will
123  //     trace InputDispatcher's inbound events (which does not include events
124  //     synthesized within InputDispatcher) that match the rules.
125  //   - If used with trace_dispatcher_window_dispatch, all inbound and outbound
126  //   events
127  //     matching the rules, including all events synthesized within
128  //     InputDispatcher, will be traced.
129  optional bool trace_dispatcher_input_events = 3;
130
131  // Trace details about which windows the system is sending each input event
132  // to. All trace rules will apply.
133  optional bool trace_dispatcher_window_dispatch = 4;
134}
135