Loading include/input/InputTransport.h +23 −14 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/Timers.h> #include <utils/Vector.h> #include <android-base/unique_fd.h> Loading Loading @@ -71,10 +70,7 @@ struct InputMessage { struct Header { Type type; // 4 bytes // We don't need this field in order to align the body below but we // leave it here because InputMessage::size() and other functions // compute the size of this structure as sizeof(Header) + sizeof(Body). uint32_t padding; uint32_t seq; } header; // Body *must* be 8 byte aligned. Loading @@ -83,8 +79,8 @@ struct InputMessage { static_assert(sizeof(std::array<uint8_t, 32>) == 32); union Body { struct Key { uint32_t seq; int32_t eventId; uint32_t empty1; nsecs_t eventTime __attribute__((aligned(8))); int32_t deviceId; int32_t source; Loading @@ -103,8 +99,8 @@ struct InputMessage { } key; struct Motion { uint32_t seq; int32_t eventId; uint32_t empty1; nsecs_t eventTime __attribute__((aligned(8))); int32_t deviceId; int32_t source; Loading Loading @@ -153,16 +149,14 @@ struct InputMessage { } motion; struct Finished { uint32_t seq; uint32_t empty1; uint32_t handled; // actually a bool, but we must maintain 8-byte alignment inline size_t size() const { return sizeof(Finished); } } finished; struct Focus { uint32_t seq; int32_t eventId; uint32_t empty1; // The following two fields take up 4 bytes total uint16_t hasFocus; // actually a bool uint16_t inTouchMode; // actually a bool, but we must maintain 8-byte alignment Loading @@ -174,6 +168,19 @@ struct InputMessage { bool isValid(size_t actualSize) const; size_t size() const; void getSanitizedCopy(InputMessage* msg) const; static const char* typeToString(Type type) { switch (type) { case Type::KEY: return "KEY"; case Type::MOTION: return "MOTION"; case Type::FINISHED: return "FINISHED"; case Type::FOCUS: return "FOCUS"; } } }; struct InputChannelInfo : public Parcelable { Loading Loading @@ -438,6 +445,8 @@ public: */ int32_t getPendingBatchSource() const; std::string dump() const; private: // True if touch resampling is enabled. const bool mResampleTouch; Loading @@ -454,9 +463,9 @@ private: // Batched motion events per device and source. struct Batch { Vector<InputMessage> samples; std::vector<InputMessage> samples; }; Vector<Batch> mBatches; std::vector<Batch> mBatches; // Touch state per device and source, only for sources of class pointer. struct History { Loading Loading @@ -543,7 +552,7 @@ private: return false; } }; Vector<TouchState> mTouchStates; std::vector<TouchState> mTouchStates; // Chain of batched sequence numbers. When multiple input messages are combined into // a batch, we append a record here that associates the last sequence number in the Loading @@ -553,7 +562,7 @@ private: uint32_t seq; // sequence number of batched input message uint32_t chain; // sequence number of previous batched input message }; Vector<SeqChain> mSeqChains; std::vector<SeqChain> mSeqChains; status_t consumeBatch(InputEventFactoryInterface* factory, nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent); Loading libs/input/InputTransport.cpp +112 −56 Original line number Diff line number Diff line Loading @@ -133,12 +133,11 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const { // Write the header msg->header.type = header.type; msg->header.seq = header.seq; // Write the body switch(header.type) { case InputMessage::Type::KEY: { // uint32_t seq msg->body.key.seq = body.key.seq; // int32_t eventId msg->body.key.eventId = body.key.eventId; // nsecs_t eventTime Loading Loading @@ -168,8 +167,6 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const { break; } case InputMessage::Type::MOTION: { // uint32_t seq msg->body.motion.seq = body.motion.seq; // int32_t eventId msg->body.motion.eventId = body.motion.eventId; // nsecs_t eventTime Loading Loading @@ -232,12 +229,10 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const { break; } case InputMessage::Type::FINISHED: { msg->body.finished.seq = body.finished.seq; msg->body.finished.handled = body.finished.handled; break; } case InputMessage::Type::FOCUS: { msg->body.focus.seq = body.focus.seq; msg->body.focus.eventId = body.focus.eventId; msg->body.focus.hasFocus = body.focus.hasFocus; msg->body.focus.inTouchMode = body.focus.inTouchMode; Loading Loading @@ -468,7 +463,7 @@ status_t InputPublisher::publishKeyEvent(uint32_t seq, int32_t eventId, int32_t InputMessage msg; msg.header.type = InputMessage::Type::KEY; msg.body.key.seq = seq; msg.header.seq = seq; msg.body.key.eventId = eventId; msg.body.key.deviceId = deviceId; msg.body.key.source = source; Loading Loading @@ -526,7 +521,7 @@ status_t InputPublisher::publishMotionEvent( InputMessage msg; msg.header.type = InputMessage::Type::MOTION; msg.body.motion.seq = seq; msg.header.seq = seq; msg.body.motion.eventId = eventId; msg.body.motion.deviceId = deviceId; msg.body.motion.source = source; Loading Loading @@ -570,7 +565,7 @@ status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool h InputMessage msg; msg.header.type = InputMessage::Type::FOCUS; msg.body.focus.seq = seq; msg.header.seq = seq; msg.body.focus.eventId = eventId; msg.body.focus.hasFocus = hasFocus ? 1 : 0; msg.body.focus.inTouchMode = inTouchMode ? 1 : 0; Loading @@ -594,7 +589,7 @@ status_t InputPublisher::receiveFinishedSignal(uint32_t* outSeq, bool* outHandle mChannel->getName().c_str(), msg.header.type); return UNKNOWN_ERROR; } *outSeq = msg.body.finished.seq; *outSeq = msg.header.seq; *outHandled = msg.body.finished.handled == 1; return OK; } Loading Loading @@ -655,7 +650,7 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum if (!keyEvent) return NO_MEMORY; initializeKeyEvent(keyEvent, &mMsg); *outSeq = mMsg.body.key.seq; *outSeq = mMsg.header.seq; *outEvent = keyEvent; if (DEBUG_TRANSPORT_ACTIONS) { ALOGD("channel '%s' consumer ~ consumed key event, seq=%u", Loading @@ -667,9 +662,9 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum case InputMessage::Type::MOTION: { ssize_t batchIndex = findBatch(mMsg.body.motion.deviceId, mMsg.body.motion.source); if (batchIndex >= 0) { Batch& batch = mBatches.editItemAt(batchIndex); Batch& batch = mBatches[batchIndex]; if (canAddSample(batch, &mMsg)) { batch.samples.push(mMsg); batch.samples.push_back(mMsg); if (DEBUG_TRANSPORT_ACTIONS) { ALOGD("channel '%s' consumer ~ appended to batch event", mChannel->getName().c_str()); Loading @@ -680,18 +675,18 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum // No need to process events that we are going to cancel anyways const size_t count = batch.samples.size(); for (size_t i = 0; i < count; i++) { const InputMessage& msg = batch.samples.itemAt(i); sendFinishedSignal(msg.body.motion.seq, false); const InputMessage& msg = batch.samples[i]; sendFinishedSignal(msg.header.seq, false); } batch.samples.removeItemsAt(0, count); mBatches.removeAt(batchIndex); batch.samples.erase(batch.samples.begin(), batch.samples.begin() + count); mBatches.erase(mBatches.begin() + batchIndex); } else { // We cannot append to the batch in progress, so we need to consume // the previous batch right now and defer the new message until later. mMsgDeferred = true; status_t result = consumeSamples(factory, batch, batch.samples.size(), outSeq, outEvent); mBatches.removeAt(batchIndex); mBatches.erase(mBatches.begin() + batchIndex); if (result) { return result; } Loading @@ -707,9 +702,9 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum // Start a new batch if needed. if (mMsg.body.motion.action == AMOTION_EVENT_ACTION_MOVE || mMsg.body.motion.action == AMOTION_EVENT_ACTION_HOVER_MOVE) { mBatches.push(); Batch& batch = mBatches.editTop(); batch.samples.push(mMsg); Batch batch; batch.samples.push_back(mMsg); mBatches.push_back(batch); if (DEBUG_TRANSPORT_ACTIONS) { ALOGD("channel '%s' consumer ~ started batch event", mChannel->getName().c_str()); Loading @@ -722,7 +717,7 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum updateTouchState(mMsg); initializeMotionEvent(motionEvent, &mMsg); *outSeq = mMsg.body.motion.seq; *outSeq = mMsg.header.seq; *outEvent = motionEvent; if (DEBUG_TRANSPORT_ACTIONS) { Loading @@ -743,7 +738,7 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum if (!focusEvent) return NO_MEMORY; initializeFocusEvent(focusEvent, &mMsg); *outSeq = mMsg.body.focus.seq; *outSeq = mMsg.header.seq; *outEvent = focusEvent; break; } Loading @@ -757,10 +752,10 @@ status_t InputConsumer::consumeBatch(InputEventFactoryInterface* factory, status_t result; for (size_t i = mBatches.size(); i > 0; ) { i--; Batch& batch = mBatches.editItemAt(i); Batch& batch = mBatches[i]; if (frameTime < 0) { result = consumeSamples(factory, batch, batch.samples.size(), outSeq, outEvent); mBatches.removeAt(i); mBatches.erase(mBatches.begin() + i); return result; } Loading @@ -775,11 +770,11 @@ status_t InputConsumer::consumeBatch(InputEventFactoryInterface* factory, result = consumeSamples(factory, batch, split + 1, outSeq, outEvent); const InputMessage* next; if (batch.samples.isEmpty()) { mBatches.removeAt(i); if (batch.samples.empty()) { mBatches.erase(mBatches.begin() + i); next = nullptr; } else { next = &batch.samples.itemAt(0); next = &batch.samples[0]; } if (!result && mResampleTouch) { resampleTouchState(sampleTime, static_cast<MotionEvent*>(*outEvent), next); Loading @@ -797,20 +792,20 @@ status_t InputConsumer::consumeSamples(InputEventFactoryInterface* factory, uint32_t chain = 0; for (size_t i = 0; i < count; i++) { InputMessage& msg = batch.samples.editItemAt(i); InputMessage& msg = batch.samples[i]; updateTouchState(msg); if (i) { SeqChain seqChain; seqChain.seq = msg.body.motion.seq; seqChain.seq = msg.header.seq; seqChain.chain = chain; mSeqChains.push(seqChain); mSeqChains.push_back(seqChain); addSample(motionEvent, &msg); } else { initializeMotionEvent(motionEvent, &msg); } chain = msg.body.motion.seq; chain = msg.header.seq; } batch.samples.removeItemsAt(0, count); batch.samples.erase(batch.samples.begin(), batch.samples.begin() + count); *outSeq = chain; *outEvent = motionEvent; Loading @@ -832,10 +827,10 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_DOWN: { ssize_t index = findTouchState(deviceId, source); if (index < 0) { mTouchStates.push(); mTouchStates.push_back({}); index = mTouchStates.size() - 1; } TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; touchState.initialize(deviceId, source); touchState.addHistory(msg); break; Loading @@ -844,7 +839,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_MOVE: { ssize_t index = findTouchState(deviceId, source); if (index >= 0) { TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; touchState.addHistory(msg); rewriteMessage(touchState, msg); } Loading @@ -854,7 +849,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_POINTER_DOWN: { ssize_t index = findTouchState(deviceId, source); if (index >= 0) { TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; touchState.lastResample.idBits.clearBit(msg.body.motion.getActionId()); rewriteMessage(touchState, msg); } Loading @@ -864,7 +859,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_POINTER_UP: { ssize_t index = findTouchState(deviceId, source); if (index >= 0) { TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; rewriteMessage(touchState, msg); touchState.lastResample.idBits.clearBit(msg.body.motion.getActionId()); } Loading @@ -874,7 +869,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_SCROLL: { ssize_t index = findTouchState(deviceId, source); if (index >= 0) { TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; rewriteMessage(touchState, msg); } break; Loading @@ -884,9 +879,9 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_CANCEL: { ssize_t index = findTouchState(deviceId, source); if (index >= 0) { TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; rewriteMessage(touchState, msg); mTouchStates.removeAt(index); mTouchStates.erase(mTouchStates.begin() + index); } break; } Loading Loading @@ -943,7 +938,7 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event, return; } TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; if (touchState.historySize < 1) { #if DEBUG_RESAMPLING ALOGD("Not resampled, no history for device."); Loading Loading @@ -1089,11 +1084,11 @@ status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) { size_t chainIndex = 0; for (size_t i = seqChainCount; i > 0; ) { i--; const SeqChain& seqChain = mSeqChains.itemAt(i); const SeqChain& seqChain = mSeqChains[i]; if (seqChain.seq == currentSeq) { currentSeq = seqChain.chain; chainSeqs[chainIndex++] = currentSeq; mSeqChains.removeAt(i); mSeqChains.erase(mSeqChains.begin() + i); } } status_t status = OK; Loading @@ -1107,7 +1102,7 @@ status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) { SeqChain seqChain; seqChain.seq = chainIndex != 0 ? chainSeqs[chainIndex - 1] : seq; seqChain.chain = chainSeqs[chainIndex]; mSeqChains.push(seqChain); mSeqChains.push_back(seqChain); if (!chainIndex) break; chainIndex--; } Loading @@ -1122,7 +1117,7 @@ status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) { status_t InputConsumer::sendUnchainedFinishedSignal(uint32_t seq, bool handled) { InputMessage msg; msg.header.type = InputMessage::Type::FINISHED; msg.body.finished.seq = seq; msg.header.seq = seq; msg.body.finished.handled = handled ? 1 : 0; return mChannel->sendMessage(&msg); } Loading @@ -1132,23 +1127,23 @@ bool InputConsumer::hasDeferredEvent() const { } bool InputConsumer::hasPendingBatch() const { return !mBatches.isEmpty(); return !mBatches.empty(); } int32_t InputConsumer::getPendingBatchSource() const { if (mBatches.isEmpty()) { if (mBatches.empty()) { return AINPUT_SOURCE_CLASS_NONE; } const Batch& batch = mBatches.itemAt(0); const InputMessage& head = batch.samples.itemAt(0); const Batch& batch = mBatches[0]; const InputMessage& head = batch.samples[0]; return head.body.motion.source; } ssize_t InputConsumer::findBatch(int32_t deviceId, int32_t source) const { for (size_t i = 0; i < mBatches.size(); i++) { const Batch& batch = mBatches.itemAt(i); const InputMessage& head = batch.samples.itemAt(0); const Batch& batch = mBatches[i]; const InputMessage& head = batch.samples[0]; if (head.body.motion.deviceId == deviceId && head.body.motion.source == source) { return i; } Loading @@ -1158,7 +1153,7 @@ ssize_t InputConsumer::findBatch(int32_t deviceId, int32_t source) const { ssize_t InputConsumer::findTouchState(int32_t deviceId, int32_t source) const { for (size_t i = 0; i < mTouchStates.size(); i++) { const TouchState& touchState = mTouchStates.itemAt(i); const TouchState& touchState = mTouchStates[i]; if (touchState.deviceId == deviceId && touchState.source == source) { return i; } Loading Loading @@ -1212,7 +1207,7 @@ void InputConsumer::addSample(MotionEvent* event, const InputMessage* msg) { } bool InputConsumer::canAddSample(const Batch& batch, const InputMessage *msg) { const InputMessage& head = batch.samples.itemAt(0); const InputMessage& head = batch.samples[0]; uint32_t pointerCount = msg->body.motion.pointerCount; if (head.body.motion.pointerCount != pointerCount || head.body.motion.action != msg->body.motion.action) { Loading @@ -1230,11 +1225,72 @@ bool InputConsumer::canAddSample(const Batch& batch, const InputMessage *msg) { ssize_t InputConsumer::findSampleNoLaterThan(const Batch& batch, nsecs_t time) { size_t numSamples = batch.samples.size(); size_t index = 0; while (index < numSamples && batch.samples.itemAt(index).body.motion.eventTime <= time) { while (index < numSamples && batch.samples[index].body.motion.eventTime <= time) { index += 1; } return ssize_t(index) - 1; } std::string InputConsumer::dump() const { std::string out; out = out + "mResampleTouch = " + toString(mResampleTouch) + "\n"; out = out + "mChannel = " + mChannel->getName() + "\n"; out = out + "mMsgDeferred: " + toString(mMsgDeferred) + "\n"; if (mMsgDeferred) { out = out + "mMsg : " + InputMessage::typeToString(mMsg.header.type) + "\n"; } out += "Batches:\n"; for (const Batch& batch : mBatches) { out += " Batch:\n"; for (const InputMessage& msg : batch.samples) { out += android::base::StringPrintf(" Message %" PRIu32 ": %s ", msg.header.seq, InputMessage::typeToString(msg.header.type)); switch (msg.header.type) { case InputMessage::Type::KEY: { out += android::base::StringPrintf("action=%s keycode=%" PRId32, KeyEvent::actionToString( msg.body.key.action), msg.body.key.keyCode); break; } case InputMessage::Type::MOTION: { out = out + "action=" + MotionEvent::actionToString(msg.body.motion.action); for (uint32_t i = 0; i < msg.body.motion.pointerCount; i++) { const float x = msg.body.motion.pointers[i].coords.getX(); const float y = msg.body.motion.pointers[i].coords.getY(); out += android::base::StringPrintf("\n Pointer %" PRIu32 " : x=%.1f y=%.1f", i, x, y); } break; } case InputMessage::Type::FINISHED: { out += android::base::StringPrintf("handled=%s", toString(msg.body.finished.handled)); break; } case InputMessage::Type::FOCUS: { out += android::base::StringPrintf("hasFocus=%s inTouchMode=%s", toString(msg.body.focus.hasFocus), toString(msg.body.focus.inTouchMode)); break; } } out += "\n"; } } if (mBatches.empty()) { out += " <empty>\n"; } out += "mSeqChains:\n"; for (const SeqChain& chain : mSeqChains) { out += android::base::StringPrintf(" chain: seq = %" PRIu32 " chain=%" PRIu32, chain.seq, chain.chain); } if (mSeqChains.empty()) { out += " <empty>\n"; } return out; } } // namespace android libs/input/tests/InputChannel_test.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ TEST_F(InputChannelTest, OpenInputChannelPair_ReturnsAPairOfConnectedChannels) { InputMessage clientReply; memset(&clientReply, 0, sizeof(InputMessage)); clientReply.header.type = InputMessage::Type::FINISHED; clientReply.body.finished.seq = 0x11223344; clientReply.header.seq = 0x11223344; clientReply.body.finished.handled = true; EXPECT_EQ(OK, clientChannel->sendMessage(&clientReply)) << "client channel should be able to send message to server channel"; Loading @@ -113,7 +113,7 @@ TEST_F(InputChannelTest, OpenInputChannelPair_ReturnsAPairOfConnectedChannels) { << "server channel should be able to receive message from client channel"; EXPECT_EQ(clientReply.header.type, serverReply.header.type) << "server channel should receive the correct message from client channel"; EXPECT_EQ(clientReply.body.finished.seq, serverReply.body.finished.seq) EXPECT_EQ(clientReply.header.seq, serverReply.header.seq) << "server channel should receive the correct message from client channel"; EXPECT_EQ(clientReply.body.finished.handled, serverReply.body.finished.handled) << "server channel should receive the correct message from client channel"; Loading Loading @@ -181,7 +181,7 @@ TEST_F(InputChannelTest, SendAndReceive_MotionClassification) { InputMessage serverMsg = {}, clientMsg; serverMsg.header.type = InputMessage::Type::MOTION; serverMsg.body.motion.seq = 1; serverMsg.header.seq = 1; serverMsg.body.motion.pointerCount = 1; for (MotionClassification classification : classifications) { Loading libs/input/tests/StructLayout_test.cpp +8 −10 Original line number Diff line number Diff line Loading @@ -34,8 +34,7 @@ void TestPointerCoordsAlignment() { void TestInputMessageAlignment() { CHECK_OFFSET(InputMessage, body, 8); CHECK_OFFSET(InputMessage::Body::Key, seq, 0); CHECK_OFFSET(InputMessage::Body::Key, eventId, 4); CHECK_OFFSET(InputMessage::Body::Key, eventId, 0); CHECK_OFFSET(InputMessage::Body::Key, eventTime, 8); CHECK_OFFSET(InputMessage::Body::Key, deviceId, 16); CHECK_OFFSET(InputMessage::Body::Key, source, 20); Loading @@ -49,8 +48,7 @@ void TestInputMessageAlignment() { CHECK_OFFSET(InputMessage::Body::Key, repeatCount, 80); CHECK_OFFSET(InputMessage::Body::Key, downTime, 88); CHECK_OFFSET(InputMessage::Body::Motion, seq, 0); CHECK_OFFSET(InputMessage::Body::Motion, eventId, 4); CHECK_OFFSET(InputMessage::Body::Motion, eventId, 0); CHECK_OFFSET(InputMessage::Body::Motion, eventTime, 8); CHECK_OFFSET(InputMessage::Body::Motion, deviceId, 16); CHECK_OFFSET(InputMessage::Body::Motion, source, 20); Loading @@ -75,16 +73,16 @@ void TestInputMessageAlignment() { CHECK_OFFSET(InputMessage::Body::Motion, pointerCount, 128); CHECK_OFFSET(InputMessage::Body::Motion, pointers, 136); CHECK_OFFSET(InputMessage::Body::Focus, seq, 0); CHECK_OFFSET(InputMessage::Body::Focus, eventId, 4); CHECK_OFFSET(InputMessage::Body::Focus, hasFocus, 12); CHECK_OFFSET(InputMessage::Body::Focus, inTouchMode, 14); CHECK_OFFSET(InputMessage::Body::Focus, eventId, 0); CHECK_OFFSET(InputMessage::Body::Focus, hasFocus, 4); CHECK_OFFSET(InputMessage::Body::Focus, inTouchMode, 6); CHECK_OFFSET(InputMessage::Body::Finished, seq, 0); CHECK_OFFSET(InputMessage::Body::Finished, handled, 4); } void TestHeaderSize() { CHECK_OFFSET(InputMessage::Header, type, 0); CHECK_OFFSET(InputMessage::Header, seq, 4); static_assert(sizeof(InputMessage::Header) == 8); } Loading @@ -98,7 +96,7 @@ void TestBodySize() { offsetof(InputMessage::Body::Motion, pointers) + sizeof(InputMessage::Body::Motion::Pointer) * MAX_POINTERS); static_assert(sizeof(InputMessage::Body::Finished) == 8); static_assert(sizeof(InputMessage::Body::Focus) == 16); static_assert(sizeof(InputMessage::Body::Focus) == 8); } // --- VerifiedInputEvent --- Loading services/inputflinger/dispatcher/InputDispatcher.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -4269,10 +4269,10 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) { dump += INDENT4; entry->eventEntry->appendDescription(dump); dump += StringPrintf(", targetFlags=0x%08x, resolvedAction=%d, " "age=%" PRId64 "ms, wait=%" PRId64 "ms\n", "age=%" PRId64 "ms, wait=%" PRId64 "ms seq=%" PRIu32 "\n", entry->targetFlags, entry->resolvedAction, ns2ms(currentTime - entry->eventEntry->eventTime), ns2ms(currentTime - entry->deliveryTime)); ns2ms(currentTime - entry->deliveryTime), entry->seq); } } else { dump += INDENT3 "WaitQueue: <empty>\n"; Loading Loading
include/input/InputTransport.h +23 −14 Original line number Diff line number Diff line Loading @@ -41,7 +41,6 @@ #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/Timers.h> #include <utils/Vector.h> #include <android-base/unique_fd.h> Loading Loading @@ -71,10 +70,7 @@ struct InputMessage { struct Header { Type type; // 4 bytes // We don't need this field in order to align the body below but we // leave it here because InputMessage::size() and other functions // compute the size of this structure as sizeof(Header) + sizeof(Body). uint32_t padding; uint32_t seq; } header; // Body *must* be 8 byte aligned. Loading @@ -83,8 +79,8 @@ struct InputMessage { static_assert(sizeof(std::array<uint8_t, 32>) == 32); union Body { struct Key { uint32_t seq; int32_t eventId; uint32_t empty1; nsecs_t eventTime __attribute__((aligned(8))); int32_t deviceId; int32_t source; Loading @@ -103,8 +99,8 @@ struct InputMessage { } key; struct Motion { uint32_t seq; int32_t eventId; uint32_t empty1; nsecs_t eventTime __attribute__((aligned(8))); int32_t deviceId; int32_t source; Loading Loading @@ -153,16 +149,14 @@ struct InputMessage { } motion; struct Finished { uint32_t seq; uint32_t empty1; uint32_t handled; // actually a bool, but we must maintain 8-byte alignment inline size_t size() const { return sizeof(Finished); } } finished; struct Focus { uint32_t seq; int32_t eventId; uint32_t empty1; // The following two fields take up 4 bytes total uint16_t hasFocus; // actually a bool uint16_t inTouchMode; // actually a bool, but we must maintain 8-byte alignment Loading @@ -174,6 +168,19 @@ struct InputMessage { bool isValid(size_t actualSize) const; size_t size() const; void getSanitizedCopy(InputMessage* msg) const; static const char* typeToString(Type type) { switch (type) { case Type::KEY: return "KEY"; case Type::MOTION: return "MOTION"; case Type::FINISHED: return "FINISHED"; case Type::FOCUS: return "FOCUS"; } } }; struct InputChannelInfo : public Parcelable { Loading Loading @@ -438,6 +445,8 @@ public: */ int32_t getPendingBatchSource() const; std::string dump() const; private: // True if touch resampling is enabled. const bool mResampleTouch; Loading @@ -454,9 +463,9 @@ private: // Batched motion events per device and source. struct Batch { Vector<InputMessage> samples; std::vector<InputMessage> samples; }; Vector<Batch> mBatches; std::vector<Batch> mBatches; // Touch state per device and source, only for sources of class pointer. struct History { Loading Loading @@ -543,7 +552,7 @@ private: return false; } }; Vector<TouchState> mTouchStates; std::vector<TouchState> mTouchStates; // Chain of batched sequence numbers. When multiple input messages are combined into // a batch, we append a record here that associates the last sequence number in the Loading @@ -553,7 +562,7 @@ private: uint32_t seq; // sequence number of batched input message uint32_t chain; // sequence number of previous batched input message }; Vector<SeqChain> mSeqChains; std::vector<SeqChain> mSeqChains; status_t consumeBatch(InputEventFactoryInterface* factory, nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent); Loading
libs/input/InputTransport.cpp +112 −56 Original line number Diff line number Diff line Loading @@ -133,12 +133,11 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const { // Write the header msg->header.type = header.type; msg->header.seq = header.seq; // Write the body switch(header.type) { case InputMessage::Type::KEY: { // uint32_t seq msg->body.key.seq = body.key.seq; // int32_t eventId msg->body.key.eventId = body.key.eventId; // nsecs_t eventTime Loading Loading @@ -168,8 +167,6 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const { break; } case InputMessage::Type::MOTION: { // uint32_t seq msg->body.motion.seq = body.motion.seq; // int32_t eventId msg->body.motion.eventId = body.motion.eventId; // nsecs_t eventTime Loading Loading @@ -232,12 +229,10 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const { break; } case InputMessage::Type::FINISHED: { msg->body.finished.seq = body.finished.seq; msg->body.finished.handled = body.finished.handled; break; } case InputMessage::Type::FOCUS: { msg->body.focus.seq = body.focus.seq; msg->body.focus.eventId = body.focus.eventId; msg->body.focus.hasFocus = body.focus.hasFocus; msg->body.focus.inTouchMode = body.focus.inTouchMode; Loading Loading @@ -468,7 +463,7 @@ status_t InputPublisher::publishKeyEvent(uint32_t seq, int32_t eventId, int32_t InputMessage msg; msg.header.type = InputMessage::Type::KEY; msg.body.key.seq = seq; msg.header.seq = seq; msg.body.key.eventId = eventId; msg.body.key.deviceId = deviceId; msg.body.key.source = source; Loading Loading @@ -526,7 +521,7 @@ status_t InputPublisher::publishMotionEvent( InputMessage msg; msg.header.type = InputMessage::Type::MOTION; msg.body.motion.seq = seq; msg.header.seq = seq; msg.body.motion.eventId = eventId; msg.body.motion.deviceId = deviceId; msg.body.motion.source = source; Loading Loading @@ -570,7 +565,7 @@ status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool h InputMessage msg; msg.header.type = InputMessage::Type::FOCUS; msg.body.focus.seq = seq; msg.header.seq = seq; msg.body.focus.eventId = eventId; msg.body.focus.hasFocus = hasFocus ? 1 : 0; msg.body.focus.inTouchMode = inTouchMode ? 1 : 0; Loading @@ -594,7 +589,7 @@ status_t InputPublisher::receiveFinishedSignal(uint32_t* outSeq, bool* outHandle mChannel->getName().c_str(), msg.header.type); return UNKNOWN_ERROR; } *outSeq = msg.body.finished.seq; *outSeq = msg.header.seq; *outHandled = msg.body.finished.handled == 1; return OK; } Loading Loading @@ -655,7 +650,7 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum if (!keyEvent) return NO_MEMORY; initializeKeyEvent(keyEvent, &mMsg); *outSeq = mMsg.body.key.seq; *outSeq = mMsg.header.seq; *outEvent = keyEvent; if (DEBUG_TRANSPORT_ACTIONS) { ALOGD("channel '%s' consumer ~ consumed key event, seq=%u", Loading @@ -667,9 +662,9 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum case InputMessage::Type::MOTION: { ssize_t batchIndex = findBatch(mMsg.body.motion.deviceId, mMsg.body.motion.source); if (batchIndex >= 0) { Batch& batch = mBatches.editItemAt(batchIndex); Batch& batch = mBatches[batchIndex]; if (canAddSample(batch, &mMsg)) { batch.samples.push(mMsg); batch.samples.push_back(mMsg); if (DEBUG_TRANSPORT_ACTIONS) { ALOGD("channel '%s' consumer ~ appended to batch event", mChannel->getName().c_str()); Loading @@ -680,18 +675,18 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum // No need to process events that we are going to cancel anyways const size_t count = batch.samples.size(); for (size_t i = 0; i < count; i++) { const InputMessage& msg = batch.samples.itemAt(i); sendFinishedSignal(msg.body.motion.seq, false); const InputMessage& msg = batch.samples[i]; sendFinishedSignal(msg.header.seq, false); } batch.samples.removeItemsAt(0, count); mBatches.removeAt(batchIndex); batch.samples.erase(batch.samples.begin(), batch.samples.begin() + count); mBatches.erase(mBatches.begin() + batchIndex); } else { // We cannot append to the batch in progress, so we need to consume // the previous batch right now and defer the new message until later. mMsgDeferred = true; status_t result = consumeSamples(factory, batch, batch.samples.size(), outSeq, outEvent); mBatches.removeAt(batchIndex); mBatches.erase(mBatches.begin() + batchIndex); if (result) { return result; } Loading @@ -707,9 +702,9 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum // Start a new batch if needed. if (mMsg.body.motion.action == AMOTION_EVENT_ACTION_MOVE || mMsg.body.motion.action == AMOTION_EVENT_ACTION_HOVER_MOVE) { mBatches.push(); Batch& batch = mBatches.editTop(); batch.samples.push(mMsg); Batch batch; batch.samples.push_back(mMsg); mBatches.push_back(batch); if (DEBUG_TRANSPORT_ACTIONS) { ALOGD("channel '%s' consumer ~ started batch event", mChannel->getName().c_str()); Loading @@ -722,7 +717,7 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum updateTouchState(mMsg); initializeMotionEvent(motionEvent, &mMsg); *outSeq = mMsg.body.motion.seq; *outSeq = mMsg.header.seq; *outEvent = motionEvent; if (DEBUG_TRANSPORT_ACTIONS) { Loading @@ -743,7 +738,7 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, bool consum if (!focusEvent) return NO_MEMORY; initializeFocusEvent(focusEvent, &mMsg); *outSeq = mMsg.body.focus.seq; *outSeq = mMsg.header.seq; *outEvent = focusEvent; break; } Loading @@ -757,10 +752,10 @@ status_t InputConsumer::consumeBatch(InputEventFactoryInterface* factory, status_t result; for (size_t i = mBatches.size(); i > 0; ) { i--; Batch& batch = mBatches.editItemAt(i); Batch& batch = mBatches[i]; if (frameTime < 0) { result = consumeSamples(factory, batch, batch.samples.size(), outSeq, outEvent); mBatches.removeAt(i); mBatches.erase(mBatches.begin() + i); return result; } Loading @@ -775,11 +770,11 @@ status_t InputConsumer::consumeBatch(InputEventFactoryInterface* factory, result = consumeSamples(factory, batch, split + 1, outSeq, outEvent); const InputMessage* next; if (batch.samples.isEmpty()) { mBatches.removeAt(i); if (batch.samples.empty()) { mBatches.erase(mBatches.begin() + i); next = nullptr; } else { next = &batch.samples.itemAt(0); next = &batch.samples[0]; } if (!result && mResampleTouch) { resampleTouchState(sampleTime, static_cast<MotionEvent*>(*outEvent), next); Loading @@ -797,20 +792,20 @@ status_t InputConsumer::consumeSamples(InputEventFactoryInterface* factory, uint32_t chain = 0; for (size_t i = 0; i < count; i++) { InputMessage& msg = batch.samples.editItemAt(i); InputMessage& msg = batch.samples[i]; updateTouchState(msg); if (i) { SeqChain seqChain; seqChain.seq = msg.body.motion.seq; seqChain.seq = msg.header.seq; seqChain.chain = chain; mSeqChains.push(seqChain); mSeqChains.push_back(seqChain); addSample(motionEvent, &msg); } else { initializeMotionEvent(motionEvent, &msg); } chain = msg.body.motion.seq; chain = msg.header.seq; } batch.samples.removeItemsAt(0, count); batch.samples.erase(batch.samples.begin(), batch.samples.begin() + count); *outSeq = chain; *outEvent = motionEvent; Loading @@ -832,10 +827,10 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_DOWN: { ssize_t index = findTouchState(deviceId, source); if (index < 0) { mTouchStates.push(); mTouchStates.push_back({}); index = mTouchStates.size() - 1; } TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; touchState.initialize(deviceId, source); touchState.addHistory(msg); break; Loading @@ -844,7 +839,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_MOVE: { ssize_t index = findTouchState(deviceId, source); if (index >= 0) { TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; touchState.addHistory(msg); rewriteMessage(touchState, msg); } Loading @@ -854,7 +849,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_POINTER_DOWN: { ssize_t index = findTouchState(deviceId, source); if (index >= 0) { TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; touchState.lastResample.idBits.clearBit(msg.body.motion.getActionId()); rewriteMessage(touchState, msg); } Loading @@ -864,7 +859,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_POINTER_UP: { ssize_t index = findTouchState(deviceId, source); if (index >= 0) { TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; rewriteMessage(touchState, msg); touchState.lastResample.idBits.clearBit(msg.body.motion.getActionId()); } Loading @@ -874,7 +869,7 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_SCROLL: { ssize_t index = findTouchState(deviceId, source); if (index >= 0) { TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; rewriteMessage(touchState, msg); } break; Loading @@ -884,9 +879,9 @@ void InputConsumer::updateTouchState(InputMessage& msg) { case AMOTION_EVENT_ACTION_CANCEL: { ssize_t index = findTouchState(deviceId, source); if (index >= 0) { TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; rewriteMessage(touchState, msg); mTouchStates.removeAt(index); mTouchStates.erase(mTouchStates.begin() + index); } break; } Loading Loading @@ -943,7 +938,7 @@ void InputConsumer::resampleTouchState(nsecs_t sampleTime, MotionEvent* event, return; } TouchState& touchState = mTouchStates.editItemAt(index); TouchState& touchState = mTouchStates[index]; if (touchState.historySize < 1) { #if DEBUG_RESAMPLING ALOGD("Not resampled, no history for device."); Loading Loading @@ -1089,11 +1084,11 @@ status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) { size_t chainIndex = 0; for (size_t i = seqChainCount; i > 0; ) { i--; const SeqChain& seqChain = mSeqChains.itemAt(i); const SeqChain& seqChain = mSeqChains[i]; if (seqChain.seq == currentSeq) { currentSeq = seqChain.chain; chainSeqs[chainIndex++] = currentSeq; mSeqChains.removeAt(i); mSeqChains.erase(mSeqChains.begin() + i); } } status_t status = OK; Loading @@ -1107,7 +1102,7 @@ status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) { SeqChain seqChain; seqChain.seq = chainIndex != 0 ? chainSeqs[chainIndex - 1] : seq; seqChain.chain = chainSeqs[chainIndex]; mSeqChains.push(seqChain); mSeqChains.push_back(seqChain); if (!chainIndex) break; chainIndex--; } Loading @@ -1122,7 +1117,7 @@ status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) { status_t InputConsumer::sendUnchainedFinishedSignal(uint32_t seq, bool handled) { InputMessage msg; msg.header.type = InputMessage::Type::FINISHED; msg.body.finished.seq = seq; msg.header.seq = seq; msg.body.finished.handled = handled ? 1 : 0; return mChannel->sendMessage(&msg); } Loading @@ -1132,23 +1127,23 @@ bool InputConsumer::hasDeferredEvent() const { } bool InputConsumer::hasPendingBatch() const { return !mBatches.isEmpty(); return !mBatches.empty(); } int32_t InputConsumer::getPendingBatchSource() const { if (mBatches.isEmpty()) { if (mBatches.empty()) { return AINPUT_SOURCE_CLASS_NONE; } const Batch& batch = mBatches.itemAt(0); const InputMessage& head = batch.samples.itemAt(0); const Batch& batch = mBatches[0]; const InputMessage& head = batch.samples[0]; return head.body.motion.source; } ssize_t InputConsumer::findBatch(int32_t deviceId, int32_t source) const { for (size_t i = 0; i < mBatches.size(); i++) { const Batch& batch = mBatches.itemAt(i); const InputMessage& head = batch.samples.itemAt(0); const Batch& batch = mBatches[i]; const InputMessage& head = batch.samples[0]; if (head.body.motion.deviceId == deviceId && head.body.motion.source == source) { return i; } Loading @@ -1158,7 +1153,7 @@ ssize_t InputConsumer::findBatch(int32_t deviceId, int32_t source) const { ssize_t InputConsumer::findTouchState(int32_t deviceId, int32_t source) const { for (size_t i = 0; i < mTouchStates.size(); i++) { const TouchState& touchState = mTouchStates.itemAt(i); const TouchState& touchState = mTouchStates[i]; if (touchState.deviceId == deviceId && touchState.source == source) { return i; } Loading Loading @@ -1212,7 +1207,7 @@ void InputConsumer::addSample(MotionEvent* event, const InputMessage* msg) { } bool InputConsumer::canAddSample(const Batch& batch, const InputMessage *msg) { const InputMessage& head = batch.samples.itemAt(0); const InputMessage& head = batch.samples[0]; uint32_t pointerCount = msg->body.motion.pointerCount; if (head.body.motion.pointerCount != pointerCount || head.body.motion.action != msg->body.motion.action) { Loading @@ -1230,11 +1225,72 @@ bool InputConsumer::canAddSample(const Batch& batch, const InputMessage *msg) { ssize_t InputConsumer::findSampleNoLaterThan(const Batch& batch, nsecs_t time) { size_t numSamples = batch.samples.size(); size_t index = 0; while (index < numSamples && batch.samples.itemAt(index).body.motion.eventTime <= time) { while (index < numSamples && batch.samples[index].body.motion.eventTime <= time) { index += 1; } return ssize_t(index) - 1; } std::string InputConsumer::dump() const { std::string out; out = out + "mResampleTouch = " + toString(mResampleTouch) + "\n"; out = out + "mChannel = " + mChannel->getName() + "\n"; out = out + "mMsgDeferred: " + toString(mMsgDeferred) + "\n"; if (mMsgDeferred) { out = out + "mMsg : " + InputMessage::typeToString(mMsg.header.type) + "\n"; } out += "Batches:\n"; for (const Batch& batch : mBatches) { out += " Batch:\n"; for (const InputMessage& msg : batch.samples) { out += android::base::StringPrintf(" Message %" PRIu32 ": %s ", msg.header.seq, InputMessage::typeToString(msg.header.type)); switch (msg.header.type) { case InputMessage::Type::KEY: { out += android::base::StringPrintf("action=%s keycode=%" PRId32, KeyEvent::actionToString( msg.body.key.action), msg.body.key.keyCode); break; } case InputMessage::Type::MOTION: { out = out + "action=" + MotionEvent::actionToString(msg.body.motion.action); for (uint32_t i = 0; i < msg.body.motion.pointerCount; i++) { const float x = msg.body.motion.pointers[i].coords.getX(); const float y = msg.body.motion.pointers[i].coords.getY(); out += android::base::StringPrintf("\n Pointer %" PRIu32 " : x=%.1f y=%.1f", i, x, y); } break; } case InputMessage::Type::FINISHED: { out += android::base::StringPrintf("handled=%s", toString(msg.body.finished.handled)); break; } case InputMessage::Type::FOCUS: { out += android::base::StringPrintf("hasFocus=%s inTouchMode=%s", toString(msg.body.focus.hasFocus), toString(msg.body.focus.inTouchMode)); break; } } out += "\n"; } } if (mBatches.empty()) { out += " <empty>\n"; } out += "mSeqChains:\n"; for (const SeqChain& chain : mSeqChains) { out += android::base::StringPrintf(" chain: seq = %" PRIu32 " chain=%" PRIu32, chain.seq, chain.chain); } if (mSeqChains.empty()) { out += " <empty>\n"; } return out; } } // namespace android
libs/input/tests/InputChannel_test.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ TEST_F(InputChannelTest, OpenInputChannelPair_ReturnsAPairOfConnectedChannels) { InputMessage clientReply; memset(&clientReply, 0, sizeof(InputMessage)); clientReply.header.type = InputMessage::Type::FINISHED; clientReply.body.finished.seq = 0x11223344; clientReply.header.seq = 0x11223344; clientReply.body.finished.handled = true; EXPECT_EQ(OK, clientChannel->sendMessage(&clientReply)) << "client channel should be able to send message to server channel"; Loading @@ -113,7 +113,7 @@ TEST_F(InputChannelTest, OpenInputChannelPair_ReturnsAPairOfConnectedChannels) { << "server channel should be able to receive message from client channel"; EXPECT_EQ(clientReply.header.type, serverReply.header.type) << "server channel should receive the correct message from client channel"; EXPECT_EQ(clientReply.body.finished.seq, serverReply.body.finished.seq) EXPECT_EQ(clientReply.header.seq, serverReply.header.seq) << "server channel should receive the correct message from client channel"; EXPECT_EQ(clientReply.body.finished.handled, serverReply.body.finished.handled) << "server channel should receive the correct message from client channel"; Loading Loading @@ -181,7 +181,7 @@ TEST_F(InputChannelTest, SendAndReceive_MotionClassification) { InputMessage serverMsg = {}, clientMsg; serverMsg.header.type = InputMessage::Type::MOTION; serverMsg.body.motion.seq = 1; serverMsg.header.seq = 1; serverMsg.body.motion.pointerCount = 1; for (MotionClassification classification : classifications) { Loading
libs/input/tests/StructLayout_test.cpp +8 −10 Original line number Diff line number Diff line Loading @@ -34,8 +34,7 @@ void TestPointerCoordsAlignment() { void TestInputMessageAlignment() { CHECK_OFFSET(InputMessage, body, 8); CHECK_OFFSET(InputMessage::Body::Key, seq, 0); CHECK_OFFSET(InputMessage::Body::Key, eventId, 4); CHECK_OFFSET(InputMessage::Body::Key, eventId, 0); CHECK_OFFSET(InputMessage::Body::Key, eventTime, 8); CHECK_OFFSET(InputMessage::Body::Key, deviceId, 16); CHECK_OFFSET(InputMessage::Body::Key, source, 20); Loading @@ -49,8 +48,7 @@ void TestInputMessageAlignment() { CHECK_OFFSET(InputMessage::Body::Key, repeatCount, 80); CHECK_OFFSET(InputMessage::Body::Key, downTime, 88); CHECK_OFFSET(InputMessage::Body::Motion, seq, 0); CHECK_OFFSET(InputMessage::Body::Motion, eventId, 4); CHECK_OFFSET(InputMessage::Body::Motion, eventId, 0); CHECK_OFFSET(InputMessage::Body::Motion, eventTime, 8); CHECK_OFFSET(InputMessage::Body::Motion, deviceId, 16); CHECK_OFFSET(InputMessage::Body::Motion, source, 20); Loading @@ -75,16 +73,16 @@ void TestInputMessageAlignment() { CHECK_OFFSET(InputMessage::Body::Motion, pointerCount, 128); CHECK_OFFSET(InputMessage::Body::Motion, pointers, 136); CHECK_OFFSET(InputMessage::Body::Focus, seq, 0); CHECK_OFFSET(InputMessage::Body::Focus, eventId, 4); CHECK_OFFSET(InputMessage::Body::Focus, hasFocus, 12); CHECK_OFFSET(InputMessage::Body::Focus, inTouchMode, 14); CHECK_OFFSET(InputMessage::Body::Focus, eventId, 0); CHECK_OFFSET(InputMessage::Body::Focus, hasFocus, 4); CHECK_OFFSET(InputMessage::Body::Focus, inTouchMode, 6); CHECK_OFFSET(InputMessage::Body::Finished, seq, 0); CHECK_OFFSET(InputMessage::Body::Finished, handled, 4); } void TestHeaderSize() { CHECK_OFFSET(InputMessage::Header, type, 0); CHECK_OFFSET(InputMessage::Header, seq, 4); static_assert(sizeof(InputMessage::Header) == 8); } Loading @@ -98,7 +96,7 @@ void TestBodySize() { offsetof(InputMessage::Body::Motion, pointers) + sizeof(InputMessage::Body::Motion::Pointer) * MAX_POINTERS); static_assert(sizeof(InputMessage::Body::Finished) == 8); static_assert(sizeof(InputMessage::Body::Focus) == 16); static_assert(sizeof(InputMessage::Body::Focus) == 8); } // --- VerifiedInputEvent --- Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -4269,10 +4269,10 @@ void InputDispatcher::dumpDispatchStateLocked(std::string& dump) { dump += INDENT4; entry->eventEntry->appendDescription(dump); dump += StringPrintf(", targetFlags=0x%08x, resolvedAction=%d, " "age=%" PRId64 "ms, wait=%" PRId64 "ms\n", "age=%" PRId64 "ms, wait=%" PRId64 "ms seq=%" PRIu32 "\n", entry->targetFlags, entry->resolvedAction, ns2ms(currentTime - entry->eventEntry->eventTime), ns2ms(currentTime - entry->deliveryTime)); ns2ms(currentTime - entry->deliveryTime), entry->seq); } } else { dump += INDENT3 "WaitQueue: <empty>\n"; Loading