blob: 536e32b857b8ac0639f502b079560debf8e57a0b [file] [log] [blame]
Prabir Pradhan58f19f62024-03-07 21:54:34 +00001/*
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
17#pragma once
18
19#include <ftl/enum.h>
20#include <ftl/flags.h>
21#include <perfetto/config/android/android_input_event_config.pbzero.h>
22#include <vector>
23
24namespace android::inputdispatcher::trace::impl {
25
26/** Flags representing the configurations that are enabled in the trace. */
27enum class TraceFlag : uint32_t {
28 // Trace details about input events processed by InputDispatcher.
29 TRACE_DISPATCHER_INPUT_EVENTS = 0x1,
30 // Trace details about an event being sent to a window by InputDispatcher.
31 TRACE_DISPATCHER_WINDOW_DISPATCH = 0x2,
32
33 ftl_last = TRACE_DISPATCHER_WINDOW_DISPATCH,
34};
35
36/** Representation of AndroidInputEventConfig::TraceLevel. */
37using TraceLevel = perfetto::protos::pbzero::AndroidInputEventConfig::TraceLevel;
38
39/** Representation of AndroidInputEventConfig::TraceRule. */
40struct TraceRule {
41 TraceLevel level;
42
43 std::vector<std::string> matchAllPackages;
44 std::vector<std::string> matchAnyPackages;
45 std::optional<bool> matchSecure;
46 std::optional<bool> matchImeConnectionActive;
47};
48
49/**
50 * A complete configuration for a tracing session.
51 *
52 * The trace rules are applied as documented in the perfetto config:
53 * /external/perfetto/protos/perfetto/config/android/android_input_event_config.proto
54 */
55struct TraceConfig {
56 ftl::Flags<TraceFlag> flags;
57 std::vector<TraceRule> rules;
58};
59
60} // namespace android::inputdispatcher::trace::impl