Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | #ifndef _LIBINPUT_INPUT_TRANSPORT_H |
| 18 | #define _LIBINPUT_INPUT_TRANSPORT_H |
| 19 | |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 20 | #pragma GCC system_header |
| 21 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Native input transport. |
| 24 | * |
| 25 | * The InputChannel provides a mechanism for exchanging InputMessage structures across processes. |
| 26 | * |
| 27 | * The InputPublisher and InputConsumer each handle one end-point of an input channel. |
| 28 | * The InputPublisher is used by the input dispatcher to send events to the application. |
| 29 | * The InputConsumer is used by the application to receive events from the input dispatcher. |
| 30 | */ |
| 31 | |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 32 | #include <string> |
Siarhei Vishniakou | 3531ae7 | 2021-02-02 12:12:27 -1000 | [diff] [blame^] | 33 | #include <unordered_map> |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 34 | |
Atif Niyaz | 3d3fa52 | 2019-07-25 11:12:39 -0700 | [diff] [blame] | 35 | #include <android-base/chrono_utils.h> |
| 36 | |
Robert Carr | 803535b | 2018-08-02 16:38:15 -0700 | [diff] [blame] | 37 | #include <binder/IBinder.h> |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 38 | #include <binder/Parcelable.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 39 | #include <input/Input.h> |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 40 | #include <sys/stat.h> |
chaviw | 9eaa22c | 2020-07-01 16:21:27 -0700 | [diff] [blame] | 41 | #include <ui/Transform.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 42 | #include <utils/BitSet.h> |
Atif Niyaz | 3d3fa52 | 2019-07-25 11:12:39 -0700 | [diff] [blame] | 43 | #include <utils/Errors.h> |
| 44 | #include <utils/RefBase.h> |
| 45 | #include <utils/Timers.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 46 | |
Josh Gao | 2ccbe3a | 2019-08-09 14:35:36 -0700 | [diff] [blame] | 47 | #include <android-base/unique_fd.h> |
| 48 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 49 | namespace android { |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 50 | class Parcel; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * Intermediate representation used to send input events and related signals. |
Fengwei Yin | 83e0e42 | 2014-05-24 05:32:09 +0800 | [diff] [blame] | 54 | * |
| 55 | * Note that this structure is used for IPCs so its layout must be identical |
| 56 | * on 64 and 32 bit processes. This is tested in StructLayout_test.cpp. |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 57 | * |
| 58 | * Since the struct must be aligned to an 8-byte boundary, there could be uninitialized bytes |
| 59 | * in-between the defined fields. This padding data should be explicitly accounted for by adding |
| 60 | * "empty" fields into the struct. This data is memset to zero before sending the struct across |
| 61 | * the socket. Adding the explicit fields ensures that the memset is not optimized away by the |
| 62 | * compiler. When a new field is added to the struct, the corresponding change |
| 63 | * in StructLayout_test should be made. |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 64 | */ |
| 65 | struct InputMessage { |
Siarhei Vishniakou | 5240277 | 2019-10-22 09:32:30 -0700 | [diff] [blame] | 66 | enum class Type : uint32_t { |
| 67 | KEY, |
| 68 | MOTION, |
| 69 | FINISHED, |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 70 | FOCUS, |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 71 | CAPTURE, |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | struct Header { |
Siarhei Vishniakou | 5240277 | 2019-10-22 09:32:30 -0700 | [diff] [blame] | 75 | Type type; // 4 bytes |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 76 | uint32_t seq; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 77 | } header; |
| 78 | |
Fengwei Yin | 83e0e42 | 2014-05-24 05:32:09 +0800 | [diff] [blame] | 79 | // Body *must* be 8 byte aligned. |
Siarhei Vishniakou | 9c858ac | 2020-01-23 14:20:11 -0600 | [diff] [blame] | 80 | // For keys and motions, rely on the fact that std::array takes up exactly as much space |
| 81 | // as the underlying data. This is not guaranteed by C++, but it simplifies the conversions. |
| 82 | static_assert(sizeof(std::array<uint8_t, 32>) == 32); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 83 | union Body { |
| 84 | struct Key { |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 85 | int32_t eventId; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 86 | uint32_t empty1; |
Fengwei Yin | 83e0e42 | 2014-05-24 05:32:09 +0800 | [diff] [blame] | 87 | nsecs_t eventTime __attribute__((aligned(8))); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 88 | int32_t deviceId; |
| 89 | int32_t source; |
Siarhei Vishniakou | a62a8dd | 2018-06-08 21:17:33 +0100 | [diff] [blame] | 90 | int32_t displayId; |
Siarhei Vishniakou | 9c858ac | 2020-01-23 14:20:11 -0600 | [diff] [blame] | 91 | std::array<uint8_t, 32> hmac; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 92 | int32_t action; |
| 93 | int32_t flags; |
| 94 | int32_t keyCode; |
| 95 | int32_t scanCode; |
| 96 | int32_t metaState; |
| 97 | int32_t repeatCount; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 98 | uint32_t empty2; |
Fengwei Yin | 83e0e42 | 2014-05-24 05:32:09 +0800 | [diff] [blame] | 99 | nsecs_t downTime __attribute__((aligned(8))); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 100 | |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 101 | inline size_t size() const { return sizeof(Key); } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 102 | } key; |
| 103 | |
| 104 | struct Motion { |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 105 | int32_t eventId; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 106 | uint32_t empty1; |
Fengwei Yin | 83e0e42 | 2014-05-24 05:32:09 +0800 | [diff] [blame] | 107 | nsecs_t eventTime __attribute__((aligned(8))); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 108 | int32_t deviceId; |
| 109 | int32_t source; |
Tarandeep Singh | 5864150 | 2017-07-31 10:51:54 -0700 | [diff] [blame] | 110 | int32_t displayId; |
Siarhei Vishniakou | 9c858ac | 2020-01-23 14:20:11 -0600 | [diff] [blame] | 111 | std::array<uint8_t, 32> hmac; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 112 | int32_t action; |
Michael Wright | 7b159c9 | 2015-05-14 14:48:03 +0100 | [diff] [blame] | 113 | int32_t actionButton; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 114 | int32_t flags; |
| 115 | int32_t metaState; |
| 116 | int32_t buttonState; |
Siarhei Vishniakou | 16a2e30 | 2019-01-14 19:21:45 -0800 | [diff] [blame] | 117 | MotionClassification classification; // base type: uint8_t |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 118 | uint8_t empty2[3]; // 3 bytes to fill gap created by classification |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 119 | int32_t edgeFlags; |
Fengwei Yin | 83e0e42 | 2014-05-24 05:32:09 +0800 | [diff] [blame] | 120 | nsecs_t downTime __attribute__((aligned(8))); |
chaviw | 9eaa22c | 2020-07-01 16:21:27 -0700 | [diff] [blame] | 121 | float dsdx; |
| 122 | float dtdx; |
| 123 | float dtdy; |
| 124 | float dsdy; |
| 125 | float tx; |
| 126 | float ty; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 127 | float xPrecision; |
| 128 | float yPrecision; |
Garfield Tan | 00f511d | 2019-06-12 16:55:40 -0700 | [diff] [blame] | 129 | float xCursorPosition; |
| 130 | float yCursorPosition; |
Narayan Kamath | ed5fd38 | 2014-05-02 17:53:33 +0100 | [diff] [blame] | 131 | uint32_t pointerCount; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 132 | uint32_t empty3; |
Siarhei Vishniakou | 10fe676 | 2019-11-25 11:44:11 -0800 | [diff] [blame] | 133 | /** |
| 134 | * The "pointers" field must be the last field of the struct InputMessage. |
| 135 | * When we send the struct InputMessage across the socket, we are not |
| 136 | * writing the entire "pointers" array, but only the pointerCount portion |
| 137 | * of it as an optimization. Adding a field after "pointers" would break this. |
| 138 | */ |
Michael Wright | b03f103 | 2015-05-14 16:29:13 +0100 | [diff] [blame] | 139 | struct Pointer { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 140 | PointerProperties properties; |
| 141 | PointerCoords coords; |
Siarhei Vishniakou | 10fe676 | 2019-11-25 11:44:11 -0800 | [diff] [blame] | 142 | } pointers[MAX_POINTERS] __attribute__((aligned(8))); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 143 | |
| 144 | int32_t getActionId() const { |
| 145 | uint32_t index = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) |
| 146 | >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; |
| 147 | return pointers[index].properties.id; |
| 148 | } |
| 149 | |
| 150 | inline size_t size() const { |
| 151 | return sizeof(Motion) - sizeof(Pointer) * MAX_POINTERS |
| 152 | + sizeof(Pointer) * pointerCount; |
| 153 | } |
| 154 | } motion; |
| 155 | |
| 156 | struct Finished { |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 157 | uint32_t empty1; |
Siarhei Vishniakou | 10fe676 | 2019-11-25 11:44:11 -0800 | [diff] [blame] | 158 | uint32_t handled; // actually a bool, but we must maintain 8-byte alignment |
Siarhei Vishniakou | 3531ae7 | 2021-02-02 12:12:27 -1000 | [diff] [blame^] | 159 | nsecs_t consumeTime; // The time when the event was consumed by the receiving end |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 160 | |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 161 | inline size_t size() const { return sizeof(Finished); } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 162 | } finished; |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 163 | |
| 164 | struct Focus { |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 165 | int32_t eventId; |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 166 | // The following two fields take up 4 bytes total |
| 167 | uint16_t hasFocus; // actually a bool |
| 168 | uint16_t inTouchMode; // actually a bool, but we must maintain 8-byte alignment |
| 169 | |
| 170 | inline size_t size() const { return sizeof(Focus); } |
| 171 | } focus; |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 172 | |
| 173 | struct Capture { |
| 174 | int32_t eventId; |
| 175 | uint32_t pointerCaptureEnabled; // actually a bool, but we maintain 8-byte alignment |
| 176 | |
| 177 | inline size_t size() const { return sizeof(Capture); } |
| 178 | } capture; |
Fengwei Yin | 83e0e42 | 2014-05-24 05:32:09 +0800 | [diff] [blame] | 179 | } __attribute__((aligned(8))) body; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 180 | |
| 181 | bool isValid(size_t actualSize) const; |
| 182 | size_t size() const; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 183 | void getSanitizedCopy(InputMessage* msg) const; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 184 | |
| 185 | static const char* typeToString(Type type) { |
| 186 | switch (type) { |
| 187 | case Type::KEY: |
| 188 | return "KEY"; |
| 189 | case Type::MOTION: |
| 190 | return "MOTION"; |
| 191 | case Type::FINISHED: |
| 192 | return "FINISHED"; |
| 193 | case Type::FOCUS: |
| 194 | return "FOCUS"; |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 195 | case Type::CAPTURE: |
| 196 | return "CAPTURE"; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 197 | } |
| 198 | } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 199 | }; |
| 200 | |
| 201 | /* |
| 202 | * An input channel consists of a local unix domain socket used to send and receive |
| 203 | * input messages across processes. Each channel has a descriptive name for debugging purposes. |
| 204 | * |
| 205 | * Each endpoint has its own InputChannel object that specifies its file descriptor. |
| 206 | * |
| 207 | * The input channel is closed when all references to it are released. |
| 208 | */ |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 209 | class InputChannel : public Parcelable { |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 210 | public: |
Siarhei Vishniakou | d258827 | 2020-07-10 11:15:40 -0500 | [diff] [blame] | 211 | static std::unique_ptr<InputChannel> create(const std::string& name, |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 212 | android::base::unique_fd fd, sp<IBinder> token); |
| 213 | InputChannel() = default; |
| 214 | InputChannel(const InputChannel& other) |
| 215 | : mName(other.mName), mFd(::dup(other.mFd)), mToken(other.mToken){}; |
| 216 | InputChannel(const std::string name, android::base::unique_fd fd, sp<IBinder> token); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 217 | virtual ~InputChannel(); |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 218 | /** |
| 219 | * Create a pair of input channels. |
| 220 | * The two returned input channels are equivalent, and are labeled as "server" and "client" |
| 221 | * for convenience. The two input channels share the same token. |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 222 | * |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 223 | * Return OK on success. |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 224 | */ |
Siarhei Vishniakou | f93fcf4 | 2017-11-22 16:00:14 -0800 | [diff] [blame] | 225 | static status_t openInputChannelPair(const std::string& name, |
Siarhei Vishniakou | d258827 | 2020-07-10 11:15:40 -0500 | [diff] [blame] | 226 | std::unique_ptr<InputChannel>& outServerChannel, |
| 227 | std::unique_ptr<InputChannel>& outClientChannel); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 228 | |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 229 | inline std::string getName() const { return mName; } |
| 230 | inline const android::base::unique_fd& getFd() const { return mFd; } |
| 231 | inline sp<IBinder> getToken() const { return mToken; } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 232 | |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 233 | /* Send a message to the other endpoint. |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 234 | * |
| 235 | * If the channel is full then the message is guaranteed not to have been sent at all. |
| 236 | * Try again after the consumer has sent a finished signal indicating that it has |
| 237 | * consumed some of the pending messages from the channel. |
| 238 | * |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 239 | * Return OK on success. |
| 240 | * Return WOULD_BLOCK if the channel is full. |
| 241 | * Return DEAD_OBJECT if the channel's peer has been closed. |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 242 | * Other errors probably indicate that the channel is broken. |
| 243 | */ |
| 244 | status_t sendMessage(const InputMessage* msg); |
| 245 | |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 246 | /* Receive a message sent by the other endpoint. |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 247 | * |
| 248 | * If there is no message present, try again after poll() indicates that the fd |
| 249 | * is readable. |
| 250 | * |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 251 | * Return OK on success. |
| 252 | * Return WOULD_BLOCK if there is no message present. |
| 253 | * Return DEAD_OBJECT if the channel's peer has been closed. |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 254 | * Other errors probably indicate that the channel is broken. |
| 255 | */ |
| 256 | status_t receiveMessage(InputMessage* msg); |
| 257 | |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 258 | /* Return a new object that has a duplicate of this channel's fd. */ |
Siarhei Vishniakou | d258827 | 2020-07-10 11:15:40 -0500 | [diff] [blame] | 259 | std::unique_ptr<InputChannel> dup() const; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 260 | |
Garfield Tan | 1560166 | 2020-09-22 15:32:38 -0700 | [diff] [blame] | 261 | void copyTo(InputChannel& outChannel) const; |
| 262 | |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 263 | status_t readFromParcel(const android::Parcel* parcel) override; |
| 264 | status_t writeToParcel(android::Parcel* parcel) const override; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 265 | |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 266 | /** |
| 267 | * The connection token is used to identify the input connection, i.e. |
| 268 | * the pair of input channels that were created simultaneously. Input channels |
| 269 | * are always created in pairs, and the token can be used to find the server-side |
| 270 | * input channel from the client-side input channel, and vice versa. |
| 271 | * |
| 272 | * Do not use connection token to check equality of a specific input channel object |
| 273 | * to another, because two different (client and server) input channels will share the |
| 274 | * same connection token. |
| 275 | * |
| 276 | * Return the token that identifies this connection. |
| 277 | */ |
| 278 | sp<IBinder> getConnectionToken() const; |
Robert Carr | 803535b | 2018-08-02 16:38:15 -0700 | [diff] [blame] | 279 | |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 280 | bool operator==(const InputChannel& inputChannel) const { |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 281 | struct stat lhs, rhs; |
| 282 | if (fstat(mFd.get(), &lhs) != 0) { |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 283 | return false; |
| 284 | } |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 285 | if (fstat(inputChannel.getFd(), &rhs) != 0) { |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 286 | return false; |
| 287 | } |
| 288 | // If file descriptors are pointing to same inode they are duplicated fds. |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 289 | return inputChannel.getName() == getName() && inputChannel.getConnectionToken() == mToken && |
| 290 | lhs.st_ino == rhs.st_ino; |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 291 | } |
| 292 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 293 | private: |
Garfield Tan | 1560166 | 2020-09-22 15:32:38 -0700 | [diff] [blame] | 294 | base::unique_fd dupFd() const; |
| 295 | |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 296 | std::string mName; |
| 297 | android::base::unique_fd mFd; |
| 298 | |
| 299 | sp<IBinder> mToken; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | /* |
| 303 | * Publishes input events to an input channel. |
| 304 | */ |
| 305 | class InputPublisher { |
| 306 | public: |
| 307 | /* Creates a publisher associated with an input channel. */ |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 308 | explicit InputPublisher(const std::shared_ptr<InputChannel>& channel); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 309 | |
| 310 | /* Destroys the publisher and releases its input channel. */ |
| 311 | ~InputPublisher(); |
| 312 | |
| 313 | /* Gets the underlying input channel. */ |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 314 | inline std::shared_ptr<InputChannel> getChannel() { return mChannel; } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 315 | |
| 316 | /* Publishes a key event to the input channel. |
| 317 | * |
| 318 | * Returns OK on success. |
| 319 | * Returns WOULD_BLOCK if the channel is full. |
| 320 | * Returns DEAD_OBJECT if the channel's peer has been closed. |
| 321 | * Returns BAD_VALUE if seq is 0. |
| 322 | * Other errors probably indicate that the channel is broken. |
| 323 | */ |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 324 | status_t publishKeyEvent(uint32_t seq, int32_t eventId, int32_t deviceId, int32_t source, |
| 325 | int32_t displayId, std::array<uint8_t, 32> hmac, int32_t action, |
| 326 | int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState, |
Siarhei Vishniakou | 9c858ac | 2020-01-23 14:20:11 -0600 | [diff] [blame] | 327 | int32_t repeatCount, nsecs_t downTime, nsecs_t eventTime); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 328 | |
| 329 | /* Publishes a motion event to the input channel. |
| 330 | * |
| 331 | * Returns OK on success. |
| 332 | * Returns WOULD_BLOCK if the channel is full. |
| 333 | * Returns DEAD_OBJECT if the channel's peer has been closed. |
| 334 | * Returns BAD_VALUE if seq is 0 or if pointerCount is less than 1 or greater than MAX_POINTERS. |
| 335 | * Other errors probably indicate that the channel is broken. |
| 336 | */ |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 337 | status_t publishMotionEvent(uint32_t seq, int32_t eventId, int32_t deviceId, int32_t source, |
| 338 | int32_t displayId, std::array<uint8_t, 32> hmac, int32_t action, |
| 339 | int32_t actionButton, int32_t flags, int32_t edgeFlags, |
| 340 | int32_t metaState, int32_t buttonState, |
chaviw | 9eaa22c | 2020-07-01 16:21:27 -0700 | [diff] [blame] | 341 | MotionClassification classification, const ui::Transform& transform, |
| 342 | float xPrecision, float yPrecision, float xCursorPosition, |
| 343 | float yCursorPosition, nsecs_t downTime, nsecs_t eventTime, |
| 344 | uint32_t pointerCount, const PointerProperties* pointerProperties, |
Garfield Tan | 00f511d | 2019-06-12 16:55:40 -0700 | [diff] [blame] | 345 | const PointerCoords* pointerCoords); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 346 | |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 347 | /* Publishes a focus event to the input channel. |
| 348 | * |
| 349 | * Returns OK on success. |
| 350 | * Returns WOULD_BLOCK if the channel is full. |
| 351 | * Returns DEAD_OBJECT if the channel's peer has been closed. |
| 352 | * Other errors probably indicate that the channel is broken. |
| 353 | */ |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 354 | status_t publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus, bool inTouchMode); |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 355 | |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 356 | /* Publishes a capture event to the input channel. |
| 357 | * |
| 358 | * Returns OK on success. |
| 359 | * Returns WOULD_BLOCK if the channel is full. |
| 360 | * Returns DEAD_OBJECT if the channel's peer has been closed. |
| 361 | * Other errors probably indicate that the channel is broken. |
| 362 | */ |
| 363 | status_t publishCaptureEvent(uint32_t seq, int32_t eventId, bool pointerCaptureEnabled); |
| 364 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 365 | /* Receives the finished signal from the consumer in reply to the original dispatch signal. |
| 366 | * If a signal was received, returns the message sequence number, |
Siarhei Vishniakou | 3531ae7 | 2021-02-02 12:12:27 -1000 | [diff] [blame^] | 367 | * whether the consumer handled the message, and the time the event was first read by the |
| 368 | * consumer. |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 369 | * |
| 370 | * The returned sequence number is never 0 unless the operation failed. |
| 371 | * |
| 372 | * Returns OK on success. |
| 373 | * Returns WOULD_BLOCK if there is no signal present. |
| 374 | * Returns DEAD_OBJECT if the channel's peer has been closed. |
| 375 | * Other errors probably indicate that the channel is broken. |
| 376 | */ |
Siarhei Vishniakou | 3531ae7 | 2021-02-02 12:12:27 -1000 | [diff] [blame^] | 377 | status_t receiveFinishedSignal( |
| 378 | const std::function<void(uint32_t seq, bool handled, nsecs_t consumeTime)>& callback); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 379 | |
| 380 | private: |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 381 | std::shared_ptr<InputChannel> mChannel; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 382 | }; |
| 383 | |
| 384 | /* |
| 385 | * Consumes input events from an input channel. |
| 386 | */ |
| 387 | class InputConsumer { |
| 388 | public: |
| 389 | /* Creates a consumer associated with an input channel. */ |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 390 | explicit InputConsumer(const std::shared_ptr<InputChannel>& channel); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 391 | |
| 392 | /* Destroys the consumer and releases its input channel. */ |
| 393 | ~InputConsumer(); |
| 394 | |
| 395 | /* Gets the underlying input channel. */ |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 396 | inline std::shared_ptr<InputChannel> getChannel() { return mChannel; } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 397 | |
| 398 | /* Consumes an input event from the input channel and copies its contents into |
| 399 | * an InputEvent object created using the specified factory. |
| 400 | * |
| 401 | * Tries to combine a series of move events into larger batches whenever possible. |
| 402 | * |
| 403 | * If consumeBatches is false, then defers consuming pending batched events if it |
| 404 | * is possible for additional samples to be added to them later. Call hasPendingBatch() |
| 405 | * to determine whether a pending batch is available to be consumed. |
| 406 | * |
| 407 | * If consumeBatches is true, then events are still batched but they are consumed |
| 408 | * immediately as soon as the input channel is exhausted. |
| 409 | * |
| 410 | * The frameTime parameter specifies the time when the current display frame started |
| 411 | * rendering in the CLOCK_MONOTONIC time base, or -1 if unknown. |
| 412 | * |
| 413 | * The returned sequence number is never 0 unless the operation failed. |
| 414 | * |
| 415 | * Returns OK on success. |
| 416 | * Returns WOULD_BLOCK if there is no event present. |
| 417 | * Returns DEAD_OBJECT if the channel's peer has been closed. |
| 418 | * Returns NO_MEMORY if the event could not be created. |
| 419 | * Other errors probably indicate that the channel is broken. |
| 420 | */ |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 421 | status_t consume(InputEventFactoryInterface* factory, bool consumeBatches, nsecs_t frameTime, |
| 422 | uint32_t* outSeq, InputEvent** outEvent); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 423 | |
| 424 | /* Sends a finished signal to the publisher to inform it that the message |
| 425 | * with the specified sequence number has finished being process and whether |
| 426 | * the message was handled by the consumer. |
| 427 | * |
| 428 | * Returns OK on success. |
| 429 | * Returns BAD_VALUE if seq is 0. |
| 430 | * Other errors probably indicate that the channel is broken. |
| 431 | */ |
| 432 | status_t sendFinishedSignal(uint32_t seq, bool handled); |
| 433 | |
| 434 | /* Returns true if there is a deferred event waiting. |
| 435 | * |
| 436 | * Should be called after calling consume() to determine whether the consumer |
| 437 | * has a deferred event to be processed. Deferred events are somewhat special in |
| 438 | * that they have already been removed from the input channel. If the input channel |
| 439 | * becomes empty, the client may need to do extra work to ensure that it processes |
| 440 | * the deferred event despite the fact that the input channel's file descriptor |
| 441 | * is not readable. |
| 442 | * |
| 443 | * One option is simply to call consume() in a loop until it returns WOULD_BLOCK. |
| 444 | * This guarantees that all deferred events will be processed. |
| 445 | * |
| 446 | * Alternately, the caller can call hasDeferredEvent() to determine whether there is |
| 447 | * a deferred event waiting and then ensure that its event loop wakes up at least |
| 448 | * one more time to consume the deferred event. |
| 449 | */ |
| 450 | bool hasDeferredEvent() const; |
| 451 | |
| 452 | /* Returns true if there is a pending batch. |
| 453 | * |
| 454 | * Should be called after calling consume() with consumeBatches == false to determine |
| 455 | * whether consume() should be called again later on with consumeBatches == true. |
| 456 | */ |
| 457 | bool hasPendingBatch() const; |
| 458 | |
Arthur Hung | c7812be | 2020-02-27 22:40:27 +0800 | [diff] [blame] | 459 | /* Returns the source of first pending batch if exist. |
| 460 | * |
| 461 | * Should be called after calling consume() with consumeBatches == false to determine |
| 462 | * whether consume() should be called again later on with consumeBatches == true. |
| 463 | */ |
| 464 | int32_t getPendingBatchSource() const; |
| 465 | |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 466 | std::string dump() const; |
| 467 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 468 | private: |
| 469 | // True if touch resampling is enabled. |
| 470 | const bool mResampleTouch; |
| 471 | |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 472 | std::shared_ptr<InputChannel> mChannel; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 473 | |
| 474 | // The current input message. |
| 475 | InputMessage mMsg; |
| 476 | |
| 477 | // True if mMsg contains a valid input message that was deferred from the previous |
| 478 | // call to consume and that still needs to be handled. |
| 479 | bool mMsgDeferred; |
| 480 | |
| 481 | // Batched motion events per device and source. |
| 482 | struct Batch { |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 483 | std::vector<InputMessage> samples; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 484 | }; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 485 | std::vector<Batch> mBatches; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 486 | |
| 487 | // Touch state per device and source, only for sources of class pointer. |
| 488 | struct History { |
| 489 | nsecs_t eventTime; |
| 490 | BitSet32 idBits; |
| 491 | int32_t idToIndex[MAX_POINTER_ID + 1]; |
| 492 | PointerCoords pointers[MAX_POINTERS]; |
| 493 | |
Siarhei Vishniakou | 086a02a | 2017-06-12 15:01:41 +0100 | [diff] [blame] | 494 | void initializeFrom(const InputMessage& msg) { |
| 495 | eventTime = msg.body.motion.eventTime; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 496 | idBits.clear(); |
Siarhei Vishniakou | 086a02a | 2017-06-12 15:01:41 +0100 | [diff] [blame] | 497 | for (uint32_t i = 0; i < msg.body.motion.pointerCount; i++) { |
| 498 | uint32_t id = msg.body.motion.pointers[i].properties.id; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 499 | idBits.markBit(id); |
| 500 | idToIndex[id] = i; |
Siarhei Vishniakou | 086a02a | 2017-06-12 15:01:41 +0100 | [diff] [blame] | 501 | pointers[i].copyFrom(msg.body.motion.pointers[i].coords); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 502 | } |
| 503 | } |
| 504 | |
Siarhei Vishniakou | 56c9ae1 | 2017-11-06 21:16:47 -0800 | [diff] [blame] | 505 | void initializeFrom(const History& other) { |
| 506 | eventTime = other.eventTime; |
| 507 | idBits = other.idBits; // temporary copy |
| 508 | for (size_t i = 0; i < other.idBits.count(); i++) { |
| 509 | uint32_t id = idBits.clearFirstMarkedBit(); |
| 510 | int32_t index = other.idToIndex[id]; |
| 511 | idToIndex[id] = index; |
| 512 | pointers[index].copyFrom(other.pointers[index]); |
| 513 | } |
| 514 | idBits = other.idBits; // final copy |
| 515 | } |
| 516 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 517 | const PointerCoords& getPointerById(uint32_t id) const { |
| 518 | return pointers[idToIndex[id]]; |
| 519 | } |
Siarhei Vishniakou | c7dc378 | 2017-08-24 20:36:28 -0700 | [diff] [blame] | 520 | |
| 521 | bool hasPointerId(uint32_t id) const { |
| 522 | return idBits.hasBit(id); |
| 523 | } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 524 | }; |
| 525 | struct TouchState { |
| 526 | int32_t deviceId; |
| 527 | int32_t source; |
| 528 | size_t historyCurrent; |
| 529 | size_t historySize; |
| 530 | History history[2]; |
| 531 | History lastResample; |
| 532 | |
| 533 | void initialize(int32_t deviceId, int32_t source) { |
| 534 | this->deviceId = deviceId; |
| 535 | this->source = source; |
| 536 | historyCurrent = 0; |
| 537 | historySize = 0; |
| 538 | lastResample.eventTime = 0; |
| 539 | lastResample.idBits.clear(); |
| 540 | } |
| 541 | |
Siarhei Vishniakou | 086a02a | 2017-06-12 15:01:41 +0100 | [diff] [blame] | 542 | void addHistory(const InputMessage& msg) { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 543 | historyCurrent ^= 1; |
| 544 | if (historySize < 2) { |
| 545 | historySize += 1; |
| 546 | } |
| 547 | history[historyCurrent].initializeFrom(msg); |
| 548 | } |
| 549 | |
| 550 | const History* getHistory(size_t index) const { |
| 551 | return &history[(historyCurrent + index) & 1]; |
| 552 | } |
Siarhei Vishniakou | 086a02a | 2017-06-12 15:01:41 +0100 | [diff] [blame] | 553 | |
| 554 | bool recentCoordinatesAreIdentical(uint32_t id) const { |
| 555 | // Return true if the two most recently received "raw" coordinates are identical |
| 556 | if (historySize < 2) { |
| 557 | return false; |
| 558 | } |
Siarhei Vishniakou | c7dc378 | 2017-08-24 20:36:28 -0700 | [diff] [blame] | 559 | if (!getHistory(0)->hasPointerId(id) || !getHistory(1)->hasPointerId(id)) { |
| 560 | return false; |
| 561 | } |
Siarhei Vishniakou | 086a02a | 2017-06-12 15:01:41 +0100 | [diff] [blame] | 562 | float currentX = getHistory(0)->getPointerById(id).getX(); |
| 563 | float currentY = getHistory(0)->getPointerById(id).getY(); |
| 564 | float previousX = getHistory(1)->getPointerById(id).getX(); |
| 565 | float previousY = getHistory(1)->getPointerById(id).getY(); |
| 566 | if (currentX == previousX && currentY == previousY) { |
| 567 | return true; |
| 568 | } |
| 569 | return false; |
| 570 | } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 571 | }; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 572 | std::vector<TouchState> mTouchStates; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 573 | |
| 574 | // Chain of batched sequence numbers. When multiple input messages are combined into |
| 575 | // a batch, we append a record here that associates the last sequence number in the |
| 576 | // batch with the previous one. When the finished signal is sent, we traverse the |
| 577 | // chain to individually finish all input messages that were part of the batch. |
| 578 | struct SeqChain { |
| 579 | uint32_t seq; // sequence number of batched input message |
| 580 | uint32_t chain; // sequence number of previous batched input message |
| 581 | }; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 582 | std::vector<SeqChain> mSeqChains; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 583 | |
Siarhei Vishniakou | 3531ae7 | 2021-02-02 12:12:27 -1000 | [diff] [blame^] | 584 | // The time at which each event with the sequence number 'seq' was consumed. |
| 585 | // This data is provided in 'finishInputEvent' so that the receiving end can measure the latency |
| 586 | // This collection is populated when the event is received, and the entries are erased when the |
| 587 | // events are finished. It should not grow infinitely because if an event is not ack'd, ANR |
| 588 | // will be raised for that connection, and no further events will be posted to that channel. |
| 589 | std::unordered_map<uint32_t /*seq*/, nsecs_t /*consumeTime*/> mConsumeTimes; |
| 590 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 591 | status_t consumeBatch(InputEventFactoryInterface* factory, |
Siarhei Vishniakou | 777a10b | 2018-01-31 16:45:06 -0800 | [diff] [blame] | 592 | nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 593 | status_t consumeSamples(InputEventFactoryInterface* factory, |
Siarhei Vishniakou | 777a10b | 2018-01-31 16:45:06 -0800 | [diff] [blame] | 594 | Batch& batch, size_t count, uint32_t* outSeq, InputEvent** outEvent); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 595 | |
Siarhei Vishniakou | 086a02a | 2017-06-12 15:01:41 +0100 | [diff] [blame] | 596 | void updateTouchState(InputMessage& msg); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 597 | void resampleTouchState(nsecs_t frameTime, MotionEvent* event, |
| 598 | const InputMessage *next); |
| 599 | |
| 600 | ssize_t findBatch(int32_t deviceId, int32_t source) const; |
| 601 | ssize_t findTouchState(int32_t deviceId, int32_t source) const; |
| 602 | |
Siarhei Vishniakou | 3531ae7 | 2021-02-02 12:12:27 -1000 | [diff] [blame^] | 603 | nsecs_t getConsumeTime(uint32_t seq) const; |
| 604 | void popConsumeTime(uint32_t seq); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 605 | status_t sendUnchainedFinishedSignal(uint32_t seq, bool handled); |
| 606 | |
Siarhei Vishniakou | 56c9ae1 | 2017-11-06 21:16:47 -0800 | [diff] [blame] | 607 | static void rewriteMessage(TouchState& state, InputMessage& msg); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 608 | static void initializeKeyEvent(KeyEvent* event, const InputMessage* msg); |
| 609 | static void initializeMotionEvent(MotionEvent* event, const InputMessage* msg); |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 610 | static void initializeFocusEvent(FocusEvent* event, const InputMessage* msg); |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 611 | static void initializeCaptureEvent(CaptureEvent* event, const InputMessage* msg); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 612 | static void addSample(MotionEvent* event, const InputMessage* msg); |
| 613 | static bool canAddSample(const Batch& batch, const InputMessage* msg); |
| 614 | static ssize_t findSampleNoLaterThan(const Batch& batch, nsecs_t time); |
| 615 | static bool shouldResampleTool(int32_t toolType); |
| 616 | |
| 617 | static bool isTouchResamplingEnabled(); |
| 618 | }; |
| 619 | |
| 620 | } // namespace android |
| 621 | |
| 622 | #endif // _LIBINPUT_INPUT_TRANSPORT_H |