xref: /aosp_15_r20/frameworks/native/services/inputflinger/dispatcher/LatencyTracker.cpp (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1*38e8c45fSAndroid Build Coastguard Worker /*
2*38e8c45fSAndroid Build Coastguard Worker  * Copyright (C) 2021 The Android Open Source Project
3*38e8c45fSAndroid Build Coastguard Worker  *
4*38e8c45fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*38e8c45fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*38e8c45fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*38e8c45fSAndroid Build Coastguard Worker  *
8*38e8c45fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*38e8c45fSAndroid Build Coastguard Worker  *
10*38e8c45fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*38e8c45fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*38e8c45fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*38e8c45fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*38e8c45fSAndroid Build Coastguard Worker  * limitations under the License.
15*38e8c45fSAndroid Build Coastguard Worker  */
16*38e8c45fSAndroid Build Coastguard Worker 
17*38e8c45fSAndroid Build Coastguard Worker #define LOG_TAG "LatencyTracker"
18*38e8c45fSAndroid Build Coastguard Worker #include "LatencyTracker.h"
19*38e8c45fSAndroid Build Coastguard Worker #include "../InputDeviceMetricsSource.h"
20*38e8c45fSAndroid Build Coastguard Worker 
21*38e8c45fSAndroid Build Coastguard Worker #include <inttypes.h>
22*38e8c45fSAndroid Build Coastguard Worker 
23*38e8c45fSAndroid Build Coastguard Worker #include <android-base/logging.h>
24*38e8c45fSAndroid Build Coastguard Worker #include <android-base/properties.h>
25*38e8c45fSAndroid Build Coastguard Worker #include <android-base/stringprintf.h>
26*38e8c45fSAndroid Build Coastguard Worker #include <android/os/IInputConstants.h>
27*38e8c45fSAndroid Build Coastguard Worker #include <input/Input.h>
28*38e8c45fSAndroid Build Coastguard Worker #include <input/InputDevice.h>
29*38e8c45fSAndroid Build Coastguard Worker #include <log/log.h>
30*38e8c45fSAndroid Build Coastguard Worker 
31*38e8c45fSAndroid Build Coastguard Worker using android::base::HwTimeoutMultiplier;
32*38e8c45fSAndroid Build Coastguard Worker using android::base::StringPrintf;
33*38e8c45fSAndroid Build Coastguard Worker 
34*38e8c45fSAndroid Build Coastguard Worker namespace android::inputdispatcher {
35*38e8c45fSAndroid Build Coastguard Worker 
36*38e8c45fSAndroid Build Coastguard Worker namespace {
37*38e8c45fSAndroid Build Coastguard Worker 
38*38e8c45fSAndroid Build Coastguard Worker /**
39*38e8c45fSAndroid Build Coastguard Worker  * Events that are older than this time will be considered mature, at which point we will stop
40*38e8c45fSAndroid Build Coastguard Worker  * waiting for the apps to provide further information about them.
41*38e8c45fSAndroid Build Coastguard Worker  * It's likely that the apps will ANR if the events are not received by this deadline, and we
42*38e8c45fSAndroid Build Coastguard Worker  * already track ANR metrics separately.
43*38e8c45fSAndroid Build Coastguard Worker  */
44*38e8c45fSAndroid Build Coastguard Worker const std::chrono::duration ANR_TIMEOUT = std::chrono::milliseconds(
45*38e8c45fSAndroid Build Coastguard Worker         android::os::IInputConstants::UNMULTIPLIED_DEFAULT_DISPATCHING_TIMEOUT_MILLIS *
46*38e8c45fSAndroid Build Coastguard Worker         HwTimeoutMultiplier());
47*38e8c45fSAndroid Build Coastguard Worker 
isMatureEvent(nsecs_t eventTime,nsecs_t now)48*38e8c45fSAndroid Build Coastguard Worker static bool isMatureEvent(nsecs_t eventTime, nsecs_t now) {
49*38e8c45fSAndroid Build Coastguard Worker     std::chrono::duration age = std::chrono::nanoseconds(now) - std::chrono::nanoseconds(eventTime);
50*38e8c45fSAndroid Build Coastguard Worker     return age > ANR_TIMEOUT;
51*38e8c45fSAndroid Build Coastguard Worker }
52*38e8c45fSAndroid Build Coastguard Worker 
53*38e8c45fSAndroid Build Coastguard Worker /**
54*38e8c45fSAndroid Build Coastguard Worker  * A multimap allows to have several entries with the same key. This function just erases a specific
55*38e8c45fSAndroid Build Coastguard Worker  * key-value pair. Equivalent to the imaginary std api std::multimap::erase(key, value).
56*38e8c45fSAndroid Build Coastguard Worker  */
57*38e8c45fSAndroid Build Coastguard Worker template <typename K, typename V>
eraseByValue(std::multimap<K,V> & map,const V & value)58*38e8c45fSAndroid Build Coastguard Worker static void eraseByValue(std::multimap<K, V>& map, const V& value) {
59*38e8c45fSAndroid Build Coastguard Worker     for (auto it = map.begin(); it != map.end();) {
60*38e8c45fSAndroid Build Coastguard Worker         if (it->second == value) {
61*38e8c45fSAndroid Build Coastguard Worker             it = map.erase(it);
62*38e8c45fSAndroid Build Coastguard Worker         } else {
63*38e8c45fSAndroid Build Coastguard Worker             it++;
64*38e8c45fSAndroid Build Coastguard Worker         }
65*38e8c45fSAndroid Build Coastguard Worker     }
66*38e8c45fSAndroid Build Coastguard Worker }
67*38e8c45fSAndroid Build Coastguard Worker 
68*38e8c45fSAndroid Build Coastguard Worker } // namespace
69*38e8c45fSAndroid Build Coastguard Worker 
LatencyTracker(InputEventTimelineProcessor & processor)70*38e8c45fSAndroid Build Coastguard Worker LatencyTracker::LatencyTracker(InputEventTimelineProcessor& processor)
71*38e8c45fSAndroid Build Coastguard Worker       : mTimelineProcessor(&processor) {}
72*38e8c45fSAndroid Build Coastguard Worker 
trackListener(const NotifyArgs & args)73*38e8c45fSAndroid Build Coastguard Worker void LatencyTracker::trackListener(const NotifyArgs& args) {
74*38e8c45fSAndroid Build Coastguard Worker     if (const NotifyKeyArgs* keyArgs = std::get_if<NotifyKeyArgs>(&args)) {
75*38e8c45fSAndroid Build Coastguard Worker         std::set<InputDeviceUsageSource> sources =
76*38e8c45fSAndroid Build Coastguard Worker                 getUsageSourcesForKeyArgs(*keyArgs, mInputDevices);
77*38e8c45fSAndroid Build Coastguard Worker         trackListener(keyArgs->id, keyArgs->eventTime, keyArgs->readTime, keyArgs->deviceId,
78*38e8c45fSAndroid Build Coastguard Worker                       sources, keyArgs->action, InputEventType::KEY);
79*38e8c45fSAndroid Build Coastguard Worker 
80*38e8c45fSAndroid Build Coastguard Worker     } else if (const NotifyMotionArgs* motionArgs = std::get_if<NotifyMotionArgs>(&args)) {
81*38e8c45fSAndroid Build Coastguard Worker         std::set<InputDeviceUsageSource> sources = getUsageSourcesForMotionArgs(*motionArgs);
82*38e8c45fSAndroid Build Coastguard Worker         trackListener(motionArgs->id, motionArgs->eventTime, motionArgs->readTime,
83*38e8c45fSAndroid Build Coastguard Worker                       motionArgs->deviceId, sources, motionArgs->action, InputEventType::MOTION);
84*38e8c45fSAndroid Build Coastguard Worker     } else {
85*38e8c45fSAndroid Build Coastguard Worker         LOG(FATAL) << "Unexpected NotifyArgs type: " << args.index();
86*38e8c45fSAndroid Build Coastguard Worker     }
87*38e8c45fSAndroid Build Coastguard Worker }
88*38e8c45fSAndroid Build Coastguard Worker 
trackListener(int32_t inputEventId,nsecs_t eventTime,nsecs_t readTime,DeviceId deviceId,const std::set<InputDeviceUsageSource> & sources,int32_t inputEventAction,InputEventType inputEventType)89*38e8c45fSAndroid Build Coastguard Worker void LatencyTracker::trackListener(int32_t inputEventId, nsecs_t eventTime, nsecs_t readTime,
90*38e8c45fSAndroid Build Coastguard Worker                                    DeviceId deviceId,
91*38e8c45fSAndroid Build Coastguard Worker                                    const std::set<InputDeviceUsageSource>& sources,
92*38e8c45fSAndroid Build Coastguard Worker                                    int32_t inputEventAction, InputEventType inputEventType) {
93*38e8c45fSAndroid Build Coastguard Worker     reportAndPruneMatureRecords(eventTime);
94*38e8c45fSAndroid Build Coastguard Worker     const auto it = mTimelines.find(inputEventId);
95*38e8c45fSAndroid Build Coastguard Worker     if (it != mTimelines.end()) {
96*38e8c45fSAndroid Build Coastguard Worker         // Input event ids are randomly generated, so it's possible that two events have the same
97*38e8c45fSAndroid Build Coastguard Worker         // event id. Drop this event, and also drop the existing event because the apps would
98*38e8c45fSAndroid Build Coastguard Worker         // confuse us by reporting the rest of the timeline for one of them. This should happen
99*38e8c45fSAndroid Build Coastguard Worker         // rarely, so we won't lose much data
100*38e8c45fSAndroid Build Coastguard Worker         mTimelines.erase(it);
101*38e8c45fSAndroid Build Coastguard Worker         eraseByValue(mEventTimes, inputEventId);
102*38e8c45fSAndroid Build Coastguard Worker         return;
103*38e8c45fSAndroid Build Coastguard Worker     }
104*38e8c45fSAndroid Build Coastguard Worker 
105*38e8c45fSAndroid Build Coastguard Worker     // Create an InputEventTimeline for the device ID. The vendorId and productId
106*38e8c45fSAndroid Build Coastguard Worker     // can be obtained from the InputDeviceIdentifier of the particular device.
107*38e8c45fSAndroid Build Coastguard Worker     const InputDeviceIdentifier* identifier = nullptr;
108*38e8c45fSAndroid Build Coastguard Worker     for (auto& inputDevice : mInputDevices) {
109*38e8c45fSAndroid Build Coastguard Worker         if (deviceId == inputDevice.getId()) {
110*38e8c45fSAndroid Build Coastguard Worker             identifier = &inputDevice.getIdentifier();
111*38e8c45fSAndroid Build Coastguard Worker             break;
112*38e8c45fSAndroid Build Coastguard Worker         }
113*38e8c45fSAndroid Build Coastguard Worker     }
114*38e8c45fSAndroid Build Coastguard Worker 
115*38e8c45fSAndroid Build Coastguard Worker     // If no matching ids can be found for the device from among the input devices connected,
116*38e8c45fSAndroid Build Coastguard Worker     // the call to trackListener will be dropped.
117*38e8c45fSAndroid Build Coastguard Worker     // Note: there generally isn't expected to be a situation where we can't find an InputDeviceInfo
118*38e8c45fSAndroid Build Coastguard Worker     // but a possibility of it is handled in case of race conditions
119*38e8c45fSAndroid Build Coastguard Worker     if (identifier == nullptr) {
120*38e8c45fSAndroid Build Coastguard Worker         ALOGE("Could not find input device identifier. Dropping call to LatencyTracker.");
121*38e8c45fSAndroid Build Coastguard Worker         return;
122*38e8c45fSAndroid Build Coastguard Worker     }
123*38e8c45fSAndroid Build Coastguard Worker 
124*38e8c45fSAndroid Build Coastguard Worker     const InputEventActionType inputEventActionType = [&]() {
125*38e8c45fSAndroid Build Coastguard Worker         switch (inputEventType) {
126*38e8c45fSAndroid Build Coastguard Worker             case InputEventType::MOTION: {
127*38e8c45fSAndroid Build Coastguard Worker                 switch (MotionEvent::getActionMasked(inputEventAction)) {
128*38e8c45fSAndroid Build Coastguard Worker                     case AMOTION_EVENT_ACTION_DOWN:
129*38e8c45fSAndroid Build Coastguard Worker                         return InputEventActionType::MOTION_ACTION_DOWN;
130*38e8c45fSAndroid Build Coastguard Worker                     case AMOTION_EVENT_ACTION_MOVE:
131*38e8c45fSAndroid Build Coastguard Worker                         return InputEventActionType::MOTION_ACTION_MOVE;
132*38e8c45fSAndroid Build Coastguard Worker                     case AMOTION_EVENT_ACTION_UP:
133*38e8c45fSAndroid Build Coastguard Worker                         return InputEventActionType::MOTION_ACTION_UP;
134*38e8c45fSAndroid Build Coastguard Worker                     case AMOTION_EVENT_ACTION_HOVER_MOVE:
135*38e8c45fSAndroid Build Coastguard Worker                         return InputEventActionType::MOTION_ACTION_HOVER_MOVE;
136*38e8c45fSAndroid Build Coastguard Worker                     case AMOTION_EVENT_ACTION_SCROLL:
137*38e8c45fSAndroid Build Coastguard Worker                         return InputEventActionType::MOTION_ACTION_SCROLL;
138*38e8c45fSAndroid Build Coastguard Worker                     default:
139*38e8c45fSAndroid Build Coastguard Worker                         return InputEventActionType::UNKNOWN_INPUT_EVENT;
140*38e8c45fSAndroid Build Coastguard Worker                 }
141*38e8c45fSAndroid Build Coastguard Worker             }
142*38e8c45fSAndroid Build Coastguard Worker             case InputEventType::KEY: {
143*38e8c45fSAndroid Build Coastguard Worker                 switch (inputEventAction) {
144*38e8c45fSAndroid Build Coastguard Worker                     case AKEY_EVENT_ACTION_DOWN:
145*38e8c45fSAndroid Build Coastguard Worker                     case AKEY_EVENT_ACTION_UP:
146*38e8c45fSAndroid Build Coastguard Worker                         return InputEventActionType::KEY;
147*38e8c45fSAndroid Build Coastguard Worker                     default:
148*38e8c45fSAndroid Build Coastguard Worker                         return InputEventActionType::UNKNOWN_INPUT_EVENT;
149*38e8c45fSAndroid Build Coastguard Worker                 }
150*38e8c45fSAndroid Build Coastguard Worker             }
151*38e8c45fSAndroid Build Coastguard Worker             default:
152*38e8c45fSAndroid Build Coastguard Worker                 return InputEventActionType::UNKNOWN_INPUT_EVENT;
153*38e8c45fSAndroid Build Coastguard Worker         }
154*38e8c45fSAndroid Build Coastguard Worker     }();
155*38e8c45fSAndroid Build Coastguard Worker 
156*38e8c45fSAndroid Build Coastguard Worker     mTimelines.emplace(inputEventId,
157*38e8c45fSAndroid Build Coastguard Worker                        InputEventTimeline(eventTime, readTime, identifier->vendor,
158*38e8c45fSAndroid Build Coastguard Worker                                           identifier->product, sources, inputEventActionType));
159*38e8c45fSAndroid Build Coastguard Worker     mEventTimes.emplace(eventTime, inputEventId);
160*38e8c45fSAndroid Build Coastguard Worker }
161*38e8c45fSAndroid Build Coastguard Worker 
trackFinishedEvent(int32_t inputEventId,const sp<IBinder> & connectionToken,nsecs_t deliveryTime,nsecs_t consumeTime,nsecs_t finishTime)162*38e8c45fSAndroid Build Coastguard Worker void LatencyTracker::trackFinishedEvent(int32_t inputEventId, const sp<IBinder>& connectionToken,
163*38e8c45fSAndroid Build Coastguard Worker                                         nsecs_t deliveryTime, nsecs_t consumeTime,
164*38e8c45fSAndroid Build Coastguard Worker                                         nsecs_t finishTime) {
165*38e8c45fSAndroid Build Coastguard Worker     const auto it = mTimelines.find(inputEventId);
166*38e8c45fSAndroid Build Coastguard Worker     if (it == mTimelines.end()) {
167*38e8c45fSAndroid Build Coastguard Worker         // This could happen if we erased this event when duplicate events were detected. It's
168*38e8c45fSAndroid Build Coastguard Worker         // also possible that an app sent a bad (or late) 'Finish' signal, since it's free to do
169*38e8c45fSAndroid Build Coastguard Worker         // anything in its process. Just drop the report and move on.
170*38e8c45fSAndroid Build Coastguard Worker         return;
171*38e8c45fSAndroid Build Coastguard Worker     }
172*38e8c45fSAndroid Build Coastguard Worker 
173*38e8c45fSAndroid Build Coastguard Worker     InputEventTimeline& timeline = it->second;
174*38e8c45fSAndroid Build Coastguard Worker     const auto connectionIt = timeline.connectionTimelines.find(connectionToken);
175*38e8c45fSAndroid Build Coastguard Worker     if (connectionIt == timeline.connectionTimelines.end()) {
176*38e8c45fSAndroid Build Coastguard Worker         // Most likely case: app calls 'finishInputEvent' before it reports the graphics timeline
177*38e8c45fSAndroid Build Coastguard Worker         timeline.connectionTimelines.emplace(connectionToken,
178*38e8c45fSAndroid Build Coastguard Worker                                              ConnectionTimeline{deliveryTime, consumeTime,
179*38e8c45fSAndroid Build Coastguard Worker                                                                 finishTime});
180*38e8c45fSAndroid Build Coastguard Worker     } else {
181*38e8c45fSAndroid Build Coastguard Worker         // Already have a record for this connectionToken
182*38e8c45fSAndroid Build Coastguard Worker         ConnectionTimeline& connectionTimeline = connectionIt->second;
183*38e8c45fSAndroid Build Coastguard Worker         const bool success =
184*38e8c45fSAndroid Build Coastguard Worker                 connectionTimeline.setDispatchTimeline(deliveryTime, consumeTime, finishTime);
185*38e8c45fSAndroid Build Coastguard Worker         if (!success) {
186*38e8c45fSAndroid Build Coastguard Worker             // We are receiving unreliable data from the app. Just delete the entire connection
187*38e8c45fSAndroid Build Coastguard Worker             // timeline for this event
188*38e8c45fSAndroid Build Coastguard Worker             timeline.connectionTimelines.erase(connectionIt);
189*38e8c45fSAndroid Build Coastguard Worker         }
190*38e8c45fSAndroid Build Coastguard Worker     }
191*38e8c45fSAndroid Build Coastguard Worker }
192*38e8c45fSAndroid Build Coastguard Worker 
trackGraphicsLatency(int32_t inputEventId,const sp<IBinder> & connectionToken,std::array<nsecs_t,GraphicsTimeline::SIZE> graphicsTimeline)193*38e8c45fSAndroid Build Coastguard Worker void LatencyTracker::trackGraphicsLatency(
194*38e8c45fSAndroid Build Coastguard Worker         int32_t inputEventId, const sp<IBinder>& connectionToken,
195*38e8c45fSAndroid Build Coastguard Worker         std::array<nsecs_t, GraphicsTimeline::SIZE> graphicsTimeline) {
196*38e8c45fSAndroid Build Coastguard Worker     const auto it = mTimelines.find(inputEventId);
197*38e8c45fSAndroid Build Coastguard Worker     if (it == mTimelines.end()) {
198*38e8c45fSAndroid Build Coastguard Worker         // This could happen if we erased this event when duplicate events were detected. It's
199*38e8c45fSAndroid Build Coastguard Worker         // also possible that an app sent a bad (or late) 'Timeline' signal, since it's free to do
200*38e8c45fSAndroid Build Coastguard Worker         // anything in its process. Just drop the report and move on.
201*38e8c45fSAndroid Build Coastguard Worker         return;
202*38e8c45fSAndroid Build Coastguard Worker     }
203*38e8c45fSAndroid Build Coastguard Worker 
204*38e8c45fSAndroid Build Coastguard Worker     InputEventTimeline& timeline = it->second;
205*38e8c45fSAndroid Build Coastguard Worker     const auto connectionIt = timeline.connectionTimelines.find(connectionToken);
206*38e8c45fSAndroid Build Coastguard Worker     if (connectionIt == timeline.connectionTimelines.end()) {
207*38e8c45fSAndroid Build Coastguard Worker         timeline.connectionTimelines.emplace(connectionToken, std::move(graphicsTimeline));
208*38e8c45fSAndroid Build Coastguard Worker     } else {
209*38e8c45fSAndroid Build Coastguard Worker         // Most likely case
210*38e8c45fSAndroid Build Coastguard Worker         ConnectionTimeline& connectionTimeline = connectionIt->second;
211*38e8c45fSAndroid Build Coastguard Worker         const bool success = connectionTimeline.setGraphicsTimeline(std::move(graphicsTimeline));
212*38e8c45fSAndroid Build Coastguard Worker         if (!success) {
213*38e8c45fSAndroid Build Coastguard Worker             // We are receiving unreliable data from the app. Just delete the entire connection
214*38e8c45fSAndroid Build Coastguard Worker             // timeline for this event
215*38e8c45fSAndroid Build Coastguard Worker             timeline.connectionTimelines.erase(connectionIt);
216*38e8c45fSAndroid Build Coastguard Worker         }
217*38e8c45fSAndroid Build Coastguard Worker     }
218*38e8c45fSAndroid Build Coastguard Worker }
219*38e8c45fSAndroid Build Coastguard Worker 
220*38e8c45fSAndroid Build Coastguard Worker /**
221*38e8c45fSAndroid Build Coastguard Worker  * We should use the current time 'now()' here to determine the age of the event, but instead we
222*38e8c45fSAndroid Build Coastguard Worker  * are using the latest 'eventTime' for efficiency since this time is already acquired, and
223*38e8c45fSAndroid Build Coastguard Worker  * 'trackListener' should happen soon after the event occurs.
224*38e8c45fSAndroid Build Coastguard Worker  */
reportAndPruneMatureRecords(nsecs_t newEventTime)225*38e8c45fSAndroid Build Coastguard Worker void LatencyTracker::reportAndPruneMatureRecords(nsecs_t newEventTime) {
226*38e8c45fSAndroid Build Coastguard Worker     while (!mEventTimes.empty()) {
227*38e8c45fSAndroid Build Coastguard Worker         const auto& [oldestEventTime, oldestInputEventId] = *mEventTimes.begin();
228*38e8c45fSAndroid Build Coastguard Worker         if (isMatureEvent(oldestEventTime, /*now=*/newEventTime)) {
229*38e8c45fSAndroid Build Coastguard Worker             // Report and drop this event
230*38e8c45fSAndroid Build Coastguard Worker             const auto it = mTimelines.find(oldestInputEventId);
231*38e8c45fSAndroid Build Coastguard Worker             LOG_ALWAYS_FATAL_IF(it == mTimelines.end(),
232*38e8c45fSAndroid Build Coastguard Worker                                 "Event %" PRId32 " is in mEventTimes, but not in mTimelines",
233*38e8c45fSAndroid Build Coastguard Worker                                 oldestInputEventId);
234*38e8c45fSAndroid Build Coastguard Worker             const InputEventTimeline& timeline = it->second;
235*38e8c45fSAndroid Build Coastguard Worker             mTimelineProcessor->processTimeline(timeline);
236*38e8c45fSAndroid Build Coastguard Worker             mTimelines.erase(it);
237*38e8c45fSAndroid Build Coastguard Worker             mEventTimes.erase(mEventTimes.begin());
238*38e8c45fSAndroid Build Coastguard Worker         } else {
239*38e8c45fSAndroid Build Coastguard Worker             // If the oldest event does not need to be pruned, no events should be pruned.
240*38e8c45fSAndroid Build Coastguard Worker             return;
241*38e8c45fSAndroid Build Coastguard Worker         }
242*38e8c45fSAndroid Build Coastguard Worker     }
243*38e8c45fSAndroid Build Coastguard Worker }
244*38e8c45fSAndroid Build Coastguard Worker 
dump(const char * prefix) const245*38e8c45fSAndroid Build Coastguard Worker std::string LatencyTracker::dump(const char* prefix) const {
246*38e8c45fSAndroid Build Coastguard Worker     return StringPrintf("%sLatencyTracker:\n", prefix) +
247*38e8c45fSAndroid Build Coastguard Worker             StringPrintf("%s  mTimelines.size() = %zu\n", prefix, mTimelines.size()) +
248*38e8c45fSAndroid Build Coastguard Worker             StringPrintf("%s  mEventTimes.size() = %zu\n", prefix, mEventTimes.size());
249*38e8c45fSAndroid Build Coastguard Worker }
250*38e8c45fSAndroid Build Coastguard Worker 
setInputDevices(const std::vector<InputDeviceInfo> & inputDevices)251*38e8c45fSAndroid Build Coastguard Worker void LatencyTracker::setInputDevices(const std::vector<InputDeviceInfo>& inputDevices) {
252*38e8c45fSAndroid Build Coastguard Worker     mInputDevices = inputDevices;
253*38e8c45fSAndroid Build Coastguard Worker }
254*38e8c45fSAndroid Build Coastguard Worker 
255*38e8c45fSAndroid Build Coastguard Worker } // namespace android::inputdispatcher
256