blob: 188d5f048d6beaf89cde8e189c117c7ed7e07b7d [file] [log] [blame]
Siarhei Vishniakoud0784762019-11-01 15:33:48 -07001/*
2 * Copyright (C) 2019 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#include <benchmark/benchmark.h>
18
Siarhei Vishniakouf2652122021-03-05 21:39:46 +000019#include <android/os/IInputConstants.h>
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070020#include <binder/Binder.h>
chaviw3277faf2021-05-19 16:45:23 -050021#include <gui/constants.h>
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070022#include "../dispatcher/InputDispatcher.h"
23
Siarhei Vishniakou18050092021-09-01 13:32:49 -070024using android::base::Result;
chaviw3277faf2021-05-19 16:45:23 -050025using android::gui::WindowInfo;
26using android::gui::WindowInfoHandle;
Siarhei Vishniakouf2652122021-03-05 21:39:46 +000027using android::os::IInputConstants;
Siarhei Vishniakouae6229e2019-12-30 16:23:19 -080028using android::os::InputEventInjectionResult;
29using android::os::InputEventInjectionSync;
30
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070031namespace android::inputdispatcher {
32
Siarhei Vishniakouadeb6fa2023-05-26 09:11:06 -070033namespace {
34
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070035// An arbitrary device id.
Prabir Pradhan5735a322022-04-11 17:23:34 +000036constexpr int32_t DEVICE_ID = 1;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070037
Prabir Pradhan5735a322022-04-11 17:23:34 +000038// The default pid and uid for windows created by the test.
Prabir Pradhanaeebeb42023-06-13 19:53:03 +000039constexpr gui::Pid WINDOW_PID{999};
Prabir Pradhan8a5c41d2023-06-08 19:13:46 +000040constexpr gui::Uid WINDOW_UID{1001};
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070041
Siarhei Vishniakou097c3db2020-05-06 14:18:38 -070042static constexpr std::chrono::duration INJECT_EVENT_TIMEOUT = 5s;
43static constexpr std::chrono::nanoseconds DISPATCHING_TIMEOUT = 100ms;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070044
45static nsecs_t now() {
46 return systemTime(SYSTEM_TIME_MONOTONIC);
47}
48
49// --- FakeInputDispatcherPolicy ---
50
51class FakeInputDispatcherPolicy : public InputDispatcherPolicyInterface {
52public:
Prabir Pradhana41d2442023-04-20 21:30:40 +000053 FakeInputDispatcherPolicy() = default;
54 virtual ~FakeInputDispatcherPolicy() = default;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070055
56private:
Siarhei Vishniakouc1ae5562020-06-30 14:22:57 -050057 void notifyConfigurationChanged(nsecs_t) override {}
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070058
Siarhei Vishniakou234129c2020-10-22 22:28:12 -050059 void notifyNoFocusedWindowAnr(
60 const std::shared_ptr<InputApplicationHandle>& applicationHandle) override {
61 ALOGE("There is no focused window for %s", applicationHandle->getName().c_str());
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070062 }
63
Prabir Pradhanaeebeb42023-06-13 19:53:03 +000064 void notifyWindowUnresponsive(const sp<IBinder>& connectionToken, std::optional<gui::Pid> pid,
Siarhei Vishniakou3c63fa42020-12-15 02:59:54 +000065 const std::string& reason) override {
66 ALOGE("Window is not responding: %s", reason.c_str());
Siarhei Vishniakou234129c2020-10-22 22:28:12 -050067 }
68
Prabir Pradhanedd96402022-02-15 01:46:16 -080069 void notifyWindowResponsive(const sp<IBinder>& connectionToken,
Prabir Pradhanaeebeb42023-06-13 19:53:03 +000070 std::optional<gui::Pid> pid) override {}
Siarhei Vishniakou234129c2020-10-22 22:28:12 -050071
Siarhei Vishniakouc1ae5562020-06-30 14:22:57 -050072 void notifyInputChannelBroken(const sp<IBinder>&) override {}
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070073
Siarhei Vishniakouc1ae5562020-06-30 14:22:57 -050074 void notifyFocusChanged(const sp<IBinder>&, const sp<IBinder>&) override {}
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070075
Chris Yef59a2f42020-10-16 12:55:26 -070076 void notifySensorEvent(int32_t deviceId, InputDeviceSensorType sensorType,
77 InputDeviceSensorAccuracy accuracy, nsecs_t timestamp,
78 const std::vector<float>& values) override {}
79
80 void notifySensorAccuracy(int32_t deviceId, InputDeviceSensorType sensorType,
81 InputDeviceSensorAccuracy accuracy) override {}
82
Chris Yefb552902021-02-03 17:18:37 -080083 void notifyVibratorState(int32_t deviceId, bool isOn) override {}
84
Prabir Pradhana41d2442023-04-20 21:30:40 +000085 bool filterInputEvent(const InputEvent& inputEvent, uint32_t policyFlags) override {
86 return true; // dispatch event normally
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070087 }
88
Prabir Pradhana41d2442023-04-20 21:30:40 +000089 void interceptKeyBeforeQueueing(const KeyEvent&, uint32_t&) override {}
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070090
Siarhei Vishniakouc1ae5562020-06-30 14:22:57 -050091 void interceptMotionBeforeQueueing(int32_t, nsecs_t, uint32_t&) override {}
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070092
Prabir Pradhana41d2442023-04-20 21:30:40 +000093 nsecs_t interceptKeyBeforeDispatching(const sp<IBinder>&, const KeyEvent&, uint32_t) override {
Siarhei Vishniakoud0784762019-11-01 15:33:48 -070094 return 0;
95 }
96
Prabir Pradhana41d2442023-04-20 21:30:40 +000097 std::optional<KeyEvent> dispatchUnhandledKey(const sp<IBinder>&, const KeyEvent&,
98 uint32_t) override {
99 return {};
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700100 }
101
Siarhei Vishniakouc1ae5562020-06-30 14:22:57 -0500102 void notifySwitch(nsecs_t, uint32_t, uint32_t, uint32_t) override {}
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700103
Sean Stoutb4e0a592021-02-23 07:34:53 -0800104 void pokeUserActivity(nsecs_t, int32_t, int32_t) override {}
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700105
Siarhei Vishniakouc1ae5562020-06-30 14:22:57 -0500106 void onPointerDownOutsideFocus(const sp<IBinder>& newToken) override {}
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700107
Prabir Pradhan5cc1a692021-08-06 14:01:18 +0000108 void setPointerCapture(const PointerCaptureRequest&) override {}
Prabir Pradhan99987712020-11-10 18:43:05 -0800109
arthurhungf452d0b2021-01-06 00:19:52 +0800110 void notifyDropWindow(const sp<IBinder>&, float x, float y) override {}
111
Prabir Pradhan8ede1d12023-05-08 19:37:44 +0000112 void notifyDeviceInteraction(int32_t deviceId, nsecs_t timestamp,
Prabir Pradhan8a5c41d2023-06-08 19:13:46 +0000113 const std::set<gui::Uid>& uids) override {}
Prabir Pradhan8ede1d12023-05-08 19:37:44 +0000114
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700115 InputDispatcherConfiguration mConfig;
116};
117
118class FakeApplicationHandle : public InputApplicationHandle {
119public:
120 FakeApplicationHandle() {}
121 virtual ~FakeApplicationHandle() {}
122
123 virtual bool updateInfo() {
Siarhei Vishniakou70622952020-07-30 11:17:23 -0500124 mInfo.dispatchingTimeoutMillis =
125 std::chrono::duration_cast<std::chrono::milliseconds>(DISPATCHING_TIMEOUT).count();
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700126 return true;
127 }
128};
129
130class FakeInputReceiver {
131public:
132 void consumeEvent() {
Siarhei Vishniakoud549b252020-08-11 11:25:26 -0500133 uint32_t consumeSeq = 0;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700134 InputEvent* event;
135
Siarhei Vishniakouadfd4fa2019-12-20 11:02:58 -0800136 std::chrono::time_point start = std::chrono::steady_clock::now();
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700137 status_t result = WOULD_BLOCK;
138 while (result == WOULD_BLOCK) {
Siarhei Vishniakouadfd4fa2019-12-20 11:02:58 -0800139 std::chrono::duration elapsed = std::chrono::steady_clock::now() - start;
140 if (elapsed > 10ms) {
141 ALOGE("Waited too long for consumer to produce an event, giving up");
142 break;
143 }
Harry Cutts33476232023-01-30 19:57:29 +0000144 result = mConsumer->consume(&mEventFactory, /*consumeBatches=*/true, -1, &consumeSeq,
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700145 &event);
146 }
147 if (result != OK) {
148 ALOGE("Received result = %d from consume()", result);
149 }
150 result = mConsumer->sendFinishedSignal(consumeSeq, true);
151 if (result != OK) {
152 ALOGE("Received result = %d from sendFinishedSignal", result);
153 }
154 }
155
156protected:
Siarhei Vishniakou18050092021-09-01 13:32:49 -0700157 explicit FakeInputReceiver(InputDispatcher& dispatcher, const std::string name) {
158 Result<std::unique_ptr<InputChannel>> channelResult = dispatcher.createInputChannel(name);
159 LOG_ALWAYS_FATAL_IF(!channelResult.ok());
160 mClientChannel = std::move(*channelResult);
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700161 mConsumer = std::make_unique<InputConsumer>(mClientChannel);
162 }
163
164 virtual ~FakeInputReceiver() {}
165
Garfield Tan15601662020-09-22 15:32:38 -0700166 std::shared_ptr<InputChannel> mClientChannel;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700167 std::unique_ptr<InputConsumer> mConsumer;
168 PreallocatedInputEventFactory mEventFactory;
169};
170
chaviw3277faf2021-05-19 16:45:23 -0500171class FakeWindowHandle : public WindowInfoHandle, public FakeInputReceiver {
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700172public:
173 static const int32_t WIDTH = 200;
174 static const int32_t HEIGHT = 200;
175
Chris Yea209fde2020-07-22 13:54:51 -0700176 FakeWindowHandle(const std::shared_ptr<InputApplicationHandle>& inputApplicationHandle,
Siarhei Vishniakou18050092021-09-01 13:32:49 -0700177 InputDispatcher& dispatcher, const std::string name)
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700178 : FakeInputReceiver(dispatcher, name), mFrame(Rect(0, 0, WIDTH, HEIGHT)) {
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700179 inputApplicationHandle->updateInfo();
chaviw15fab6f2021-06-07 14:15:52 -0500180 updateInfo();
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700181 mInfo.applicationInfo = *inputApplicationHandle->getInfo();
182 }
183
chaviw15fab6f2021-06-07 14:15:52 -0500184 void updateInfo() {
Garfield Tan15601662020-09-22 15:32:38 -0700185 mInfo.token = mClientChannel->getConnectionToken();
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700186 mInfo.name = "FakeWindowHandle";
Siarhei Vishniakouc1ae5562020-06-30 14:22:57 -0500187 mInfo.dispatchingTimeout = DISPATCHING_TIMEOUT;
Chavi Weingarten7f019192023-08-08 20:39:01 +0000188 mInfo.frame = mFrame;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700189 mInfo.globalScaleFactor = 1.0;
190 mInfo.touchableRegion.clear();
191 mInfo.addTouchableRegion(mFrame);
Prabir Pradhan5735a322022-04-11 17:23:34 +0000192 mInfo.ownerPid = WINDOW_PID;
193 mInfo.ownerUid = WINDOW_UID;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700194 mInfo.displayId = ADISPLAY_ID_DEFAULT;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700195 }
196
197protected:
198 Rect mFrame;
199};
200
201static MotionEvent generateMotionEvent() {
202 PointerProperties pointerProperties[1];
203 PointerCoords pointerCoords[1];
204
205 pointerProperties[0].clear();
206 pointerProperties[0].id = 0;
Siarhei Vishniakou6d73f832022-07-21 17:27:03 -0700207 pointerProperties[0].toolType = ToolType::FINGER;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700208
209 pointerCoords[0].clear();
210 pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 100);
211 pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 100);
212
213 const nsecs_t currentTime = now();
214
chaviw9eaa22c2020-07-01 16:21:27 -0700215 ui::Transform identityTransform;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700216 MotionEvent event;
Siarhei Vishniakouf2652122021-03-05 21:39:46 +0000217 event.initialize(IInputConstants::INVALID_INPUT_EVENT_ID, DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
Garfield Tanfbe732e2020-01-24 11:26:14 -0800218 ADISPLAY_ID_DEFAULT, INVALID_HMAC, AMOTION_EVENT_ACTION_DOWN,
219 /* actionButton */ 0, /* flags */ 0,
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700220 /* edgeFlags */ 0, AMETA_NONE, /* buttonState */ 0, MotionClassification::NONE,
chaviw9eaa22c2020-07-01 16:21:27 -0700221 identityTransform, /* xPrecision */ 0,
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700222 /* yPrecision */ 0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
Prabir Pradhanb9b18502021-08-26 12:30:32 -0700223 AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform, currentTime,
224 currentTime,
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700225 /*pointerCount*/ 1, pointerProperties, pointerCoords);
226 return event;
227}
228
229static NotifyMotionArgs generateMotionArgs() {
230 PointerProperties pointerProperties[1];
231 PointerCoords pointerCoords[1];
232
233 pointerProperties[0].clear();
234 pointerProperties[0].id = 0;
Siarhei Vishniakou6d73f832022-07-21 17:27:03 -0700235 pointerProperties[0].toolType = ToolType::FINGER;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700236
237 pointerCoords[0].clear();
238 pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 100);
239 pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 100);
240
241 const nsecs_t currentTime = now();
242 // Define a valid motion event.
Siarhei Vishniakouf2652122021-03-05 21:39:46 +0000243 NotifyMotionArgs args(IInputConstants::INVALID_INPUT_EVENT_ID, currentTime, currentTime,
244 DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
245 POLICY_FLAG_PASS_TO_USER, AMOTION_EVENT_ACTION_DOWN,
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700246 /* actionButton */ 0, /* flags */ 0, AMETA_NONE, /* buttonState */ 0,
247 MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, 1,
248 pointerProperties, pointerCoords,
249 /* xPrecision */ 0, /* yPrecision */ 0,
250 AMOTION_EVENT_INVALID_CURSOR_POSITION,
251 AMOTION_EVENT_INVALID_CURSOR_POSITION, currentTime, /* videoFrames */ {});
252
253 return args;
254}
255
256static void benchmarkNotifyMotion(benchmark::State& state) {
257 // Create dispatcher
Prabir Pradhana41d2442023-04-20 21:30:40 +0000258 FakeInputDispatcherPolicy fakePolicy;
Siarhei Vishniakou8c84b802022-03-23 15:48:41 -0700259 InputDispatcher dispatcher(fakePolicy);
260 dispatcher.setInputDispatchMode(/*enabled*/ true, /*frozen*/ false);
261 dispatcher.start();
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700262
263 // Create a window that will receive motion events
Chris Yea209fde2020-07-22 13:54:51 -0700264 std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
Siarhei Vishniakouaed7ad02022-08-03 15:04:33 -0700265 sp<FakeWindowHandle> window =
266 sp<FakeWindowHandle>::make(application, dispatcher, "Fake Window");
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700267
Siarhei Vishniakouc41de372023-07-20 13:14:26 -0700268 dispatcher.onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700269
270 NotifyMotionArgs motionArgs = generateMotionArgs();
271
272 for (auto _ : state) {
273 // Send ACTION_DOWN
274 motionArgs.action = AMOTION_EVENT_ACTION_DOWN;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700275 motionArgs.downTime = now();
276 motionArgs.eventTime = motionArgs.downTime;
Prabir Pradhan678438e2023-04-13 19:32:51 +0000277 dispatcher.notifyMotion(motionArgs);
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700278
279 // Send ACTION_UP
280 motionArgs.action = AMOTION_EVENT_ACTION_UP;
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700281 motionArgs.eventTime = now();
Prabir Pradhan678438e2023-04-13 19:32:51 +0000282 dispatcher.notifyMotion(motionArgs);
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700283
284 window->consumeEvent();
285 window->consumeEvent();
286 }
287
Siarhei Vishniakou8c84b802022-03-23 15:48:41 -0700288 dispatcher.stop();
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700289}
290
291static void benchmarkInjectMotion(benchmark::State& state) {
292 // Create dispatcher
Prabir Pradhana41d2442023-04-20 21:30:40 +0000293 FakeInputDispatcherPolicy fakePolicy;
Siarhei Vishniakou8c84b802022-03-23 15:48:41 -0700294 InputDispatcher dispatcher(fakePolicy);
295 dispatcher.setInputDispatchMode(/*enabled*/ true, /*frozen*/ false);
296 dispatcher.start();
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700297
298 // Create a window that will receive motion events
Chris Yea209fde2020-07-22 13:54:51 -0700299 std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
Siarhei Vishniakouaed7ad02022-08-03 15:04:33 -0700300 sp<FakeWindowHandle> window =
301 sp<FakeWindowHandle>::make(application, dispatcher, "Fake Window");
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700302
Siarhei Vishniakouc41de372023-07-20 13:14:26 -0700303 dispatcher.onWindowInfosChanged({{*window->getInfo()}, {}, 0, 0});
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700304
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700305 for (auto _ : state) {
Siarhei Vishniakouadfd4fa2019-12-20 11:02:58 -0800306 MotionEvent event = generateMotionEvent();
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700307 // Send ACTION_DOWN
Harry Cutts33476232023-01-30 19:57:29 +0000308 dispatcher.injectInputEvent(&event, /*targetUid=*/{}, InputEventInjectionSync::NONE,
Prabir Pradhan5735a322022-04-11 17:23:34 +0000309 INJECT_EVENT_TIMEOUT,
Siarhei Vishniakou8c84b802022-03-23 15:48:41 -0700310 POLICY_FLAG_FILTERED | POLICY_FLAG_PASS_TO_USER);
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700311
312 // Send ACTION_UP
313 event.setAction(AMOTION_EVENT_ACTION_UP);
Harry Cutts33476232023-01-30 19:57:29 +0000314 dispatcher.injectInputEvent(&event, /*targetUid=*/{}, InputEventInjectionSync::NONE,
Prabir Pradhan5735a322022-04-11 17:23:34 +0000315 INJECT_EVENT_TIMEOUT,
Siarhei Vishniakou8c84b802022-03-23 15:48:41 -0700316 POLICY_FLAG_FILTERED | POLICY_FLAG_PASS_TO_USER);
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700317
318 window->consumeEvent();
319 window->consumeEvent();
320 }
321
Siarhei Vishniakou8c84b802022-03-23 15:48:41 -0700322 dispatcher.stop();
323}
324
325static void benchmarkOnWindowInfosChanged(benchmark::State& state) {
326 // Create dispatcher
Prabir Pradhana41d2442023-04-20 21:30:40 +0000327 FakeInputDispatcherPolicy fakePolicy;
Siarhei Vishniakou8c84b802022-03-23 15:48:41 -0700328 InputDispatcher dispatcher(fakePolicy);
329 dispatcher.setInputDispatchMode(/*enabled*/ true, /*frozen*/ false);
330 dispatcher.start();
331
332 // Create a window
333 std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
Siarhei Vishniakouaed7ad02022-08-03 15:04:33 -0700334 sp<FakeWindowHandle> window =
335 sp<FakeWindowHandle>::make(application, dispatcher, "Fake Window");
Siarhei Vishniakou8c84b802022-03-23 15:48:41 -0700336
337 std::vector<gui::WindowInfo> windowInfos{*window->getInfo()};
338 gui::DisplayInfo info;
339 info.displayId = window->getInfo()->displayId;
340 std::vector<gui::DisplayInfo> displayInfos{info};
341
342 for (auto _ : state) {
Patrick Williamsd828f302023-04-28 17:52:08 -0500343 dispatcher.onWindowInfosChanged(
344 {windowInfos, displayInfos, /*vsyncId=*/0, /*timestamp=*/0});
345 dispatcher.onWindowInfosChanged(
346 {/*windowInfos=*/{}, /*displayInfos=*/{}, /*vsyncId=*/{}, /*timestamp=*/0});
Siarhei Vishniakou8c84b802022-03-23 15:48:41 -0700347 }
348 dispatcher.stop();
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700349}
350
Siarhei Vishniakouadeb6fa2023-05-26 09:11:06 -0700351} // namespace
352
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700353BENCHMARK(benchmarkNotifyMotion);
354BENCHMARK(benchmarkInjectMotion);
Siarhei Vishniakou8c84b802022-03-23 15:48:41 -0700355BENCHMARK(benchmarkOnWindowInfosChanged);
Siarhei Vishniakoud0784762019-11-01 15:33:48 -0700356
357} // namespace android::inputdispatcher
358
359BENCHMARK_MAIN();