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