Loading services/inputflinger/InputDispatcher.cpp +31 −21 Original line number Diff line number Diff line Loading @@ -97,6 +97,9 @@ constexpr std::chrono::milliseconds SLOW_INTERCEPTION_THRESHOLD = 50ms; // Number of recent events to keep for debugging purposes. constexpr size_t RECENT_QUEUE_MAX_SIZE = 10; // Sequence number for synthesized or injected events. constexpr uint32_t SYNTHESIZED_EVENT_SEQUENCE_NUM = 0; static inline nsecs_t now() { return systemTime(SYSTEM_TIME_MONOTONIC); Loading Loading @@ -710,7 +713,7 @@ InputDispatcher::KeyEntry* InputDispatcher::synthesizeKeyRepeatLocked(nsecs_t cu entry->policyFlags = policyFlags; entry->repeatCount += 1; } else { KeyEntry* newEntry = new KeyEntry(currentTime, KeyEntry* newEntry = new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime, entry->deviceId, entry->source, entry->displayId, policyFlags, entry->action, entry->flags, entry->keyCode, entry->scanCode, entry->metaState, entry->repeatCount + 1, entry->downTime); Loading Loading @@ -2474,6 +2477,7 @@ InputDispatcher::splitMotionEvent(const MotionEntry* originalMotionEntry, BitSet } MotionEntry* splitMotionEntry = new MotionEntry( originalMotionEntry->sequenceNum, originalMotionEntry->eventTime, originalMotionEntry->deviceId, originalMotionEntry->source, Loading Loading @@ -2507,7 +2511,8 @@ void InputDispatcher::notifyConfigurationChanged(const NotifyConfigurationChange { // acquire lock AutoMutex _l(mLock); ConfigurationChangedEntry* newEntry = new ConfigurationChangedEntry(args->eventTime); ConfigurationChangedEntry* newEntry = new ConfigurationChangedEntry(args->sequenceNum, args->eventTime); needWake = enqueueInboundEventLocked(newEntry); } // release lock Loading Loading @@ -2612,7 +2617,7 @@ void InputDispatcher::notifyKey(const NotifyKeyArgs* args) { mLock.lock(); } KeyEntry* newEntry = new KeyEntry(args->eventTime, KeyEntry* newEntry = new KeyEntry(args->sequenceNum, args->eventTime, args->deviceId, args->source, args->displayId, policyFlags, args->action, flags, keyCode, args->scanCode, metaState, repeatCount, args->downTime); Loading Loading @@ -2696,7 +2701,7 @@ void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) { } // Just enqueue a new motion event. MotionEntry* newEntry = new MotionEntry(args->eventTime, MotionEntry* newEntry = new MotionEntry(args->sequenceNum, args->eventTime, args->deviceId, args->source, args->displayId, policyFlags, args->action, args->actionButton, args->flags, args->metaState, args->buttonState, Loading Loading @@ -2740,7 +2745,8 @@ void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs* args) { { // acquire lock AutoMutex _l(mLock); DeviceResetEntry* newEntry = new DeviceResetEntry(args->eventTime, args->deviceId); DeviceResetEntry* newEntry = new DeviceResetEntry(args->sequenceNum, args->eventTime, args->deviceId); needWake = enqueueInboundEventLocked(newEntry); } // release lock Loading Loading @@ -2799,7 +2805,7 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event, } mLock.lock(); firstInjectedEntry = new KeyEntry(keyEvent.getEventTime(), firstInjectedEntry = new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, keyEvent.getEventTime(), keyEvent.getDeviceId(), keyEvent.getSource(), keyEvent.getDisplayId(), policyFlags, action, flags, keyEvent.getKeyCode(), keyEvent.getScanCode(), keyEvent.getMetaState(), Loading Loading @@ -2831,7 +2837,7 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event, mLock.lock(); const nsecs_t* sampleEventTimes = motionEvent->getSampleEventTimes(); const PointerCoords* samplePointerCoords = motionEvent->getSamplePointerCoords(); firstInjectedEntry = new MotionEntry(*sampleEventTimes, firstInjectedEntry = new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, *sampleEventTimes, motionEvent->getDeviceId(), motionEvent->getSource(), motionEvent->getDisplayId(), policyFlags, action, actionButton, motionEvent->getFlags(), Loading @@ -2845,7 +2851,8 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event, for (size_t i = motionEvent->getHistorySize(); i > 0; i--) { sampleEventTimes += 1; samplePointerCoords += pointerCount; MotionEntry* nextInjectedEntry = new MotionEntry(*sampleEventTimes, MotionEntry* nextInjectedEntry = new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, *sampleEventTimes, motionEvent->getDeviceId(), motionEvent->getSource(), motionEvent->getDisplayId(), policyFlags, action, actionButton, motionEvent->getFlags(), Loading Loading @@ -4279,9 +4286,10 @@ void InputDispatcher::InjectionState::release() { // --- InputDispatcher::EventEntry --- InputDispatcher::EventEntry::EventEntry(int32_t type, nsecs_t eventTime, uint32_t policyFlags) : refCount(1), type(type), eventTime(eventTime), policyFlags(policyFlags), injectionState(nullptr), dispatchInProgress(false) { InputDispatcher::EventEntry::EventEntry(uint32_t sequenceNum, int32_t type, nsecs_t eventTime, uint32_t policyFlags) : sequenceNum(sequenceNum), refCount(1), type(type), eventTime(eventTime), policyFlags(policyFlags), injectionState(nullptr), dispatchInProgress(false) { } InputDispatcher::EventEntry::~EventEntry() { Loading @@ -4307,8 +4315,9 @@ void InputDispatcher::EventEntry::releaseInjectionState() { // --- InputDispatcher::ConfigurationChangedEntry --- InputDispatcher::ConfigurationChangedEntry::ConfigurationChangedEntry(nsecs_t eventTime) : EventEntry(TYPE_CONFIGURATION_CHANGED, eventTime, 0) { InputDispatcher::ConfigurationChangedEntry::ConfigurationChangedEntry( uint32_t sequenceNum, nsecs_t eventTime) : EventEntry(sequenceNum, TYPE_CONFIGURATION_CHANGED, eventTime, 0) { } InputDispatcher::ConfigurationChangedEntry::~ConfigurationChangedEntry() { Loading @@ -4321,8 +4330,9 @@ void InputDispatcher::ConfigurationChangedEntry::appendDescription(std::string& // --- InputDispatcher::DeviceResetEntry --- InputDispatcher::DeviceResetEntry::DeviceResetEntry(nsecs_t eventTime, int32_t deviceId) : EventEntry(TYPE_DEVICE_RESET, eventTime, 0), InputDispatcher::DeviceResetEntry::DeviceResetEntry( uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId) : EventEntry(sequenceNum, TYPE_DEVICE_RESET, eventTime, 0), deviceId(deviceId) { } Loading @@ -4337,11 +4347,11 @@ void InputDispatcher::DeviceResetEntry::appendDescription(std::string& msg) cons // --- InputDispatcher::KeyEntry --- InputDispatcher::KeyEntry::KeyEntry(nsecs_t eventTime, InputDispatcher::KeyEntry::KeyEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState, int32_t repeatCount, nsecs_t downTime) : EventEntry(TYPE_KEY, eventTime, policyFlags), EventEntry(sequenceNum, TYPE_KEY, eventTime, policyFlags), deviceId(deviceId), source(source), displayId(displayId), action(action), flags(flags), keyCode(keyCode), scanCode(scanCode), metaState(metaState), repeatCount(repeatCount), downTime(downTime), Loading Loading @@ -4372,7 +4382,7 @@ void InputDispatcher::KeyEntry::recycle() { // --- InputDispatcher::MotionEntry --- InputDispatcher::MotionEntry::MotionEntry(nsecs_t eventTime, int32_t deviceId, InputDispatcher::MotionEntry::MotionEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags, Loading @@ -4380,7 +4390,7 @@ InputDispatcher::MotionEntry::MotionEntry(nsecs_t eventTime, int32_t deviceId, uint32_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, float xOffset, float yOffset) : EventEntry(TYPE_MOTION, eventTime, policyFlags), EventEntry(sequenceNum, TYPE_MOTION, eventTime, policyFlags), eventTime(eventTime), deviceId(deviceId), source(source), displayId(displayId), action(action), actionButton(actionButton), flags(flags), metaState(metaState), buttonState(buttonState), Loading Loading @@ -4694,7 +4704,7 @@ void InputDispatcher::InputState::synthesizeCancelationEvents(nsecs_t currentTim for (size_t i = 0; i < mKeyMementos.size(); i++) { const KeyMemento& memento = mKeyMementos.itemAt(i); if (shouldCancelKey(memento, options)) { outEvents.push(new KeyEntry(currentTime, outEvents.push(new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime, memento.deviceId, memento.source, memento.displayId, memento.policyFlags, AKEY_EVENT_ACTION_UP, memento.flags | AKEY_EVENT_FLAG_CANCELED, memento.keyCode, memento.scanCode, memento.metaState, 0, memento.downTime)); Loading @@ -4704,7 +4714,7 @@ void InputDispatcher::InputState::synthesizeCancelationEvents(nsecs_t currentTim for (size_t i = 0; i < mMotionMementos.size(); i++) { const MotionMemento& memento = mMotionMementos.itemAt(i); if (shouldCancelMotion(memento, options)) { outEvents.push(new MotionEntry(currentTime, outEvents.push(new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime, memento.deviceId, memento.source, memento.displayId, memento.policyFlags, memento.hovering ? AMOTION_EVENT_ACTION_HOVER_EXIT Loading services/inputflinger/InputDispatcher.h +6 −5 Original line number Diff line number Diff line Loading @@ -454,6 +454,7 @@ private: TYPE_MOTION }; uint32_t sequenceNum; mutable int32_t refCount; int32_t type; nsecs_t eventTime; Loading @@ -469,13 +470,13 @@ private: virtual void appendDescription(std::string& msg) const = 0; protected: EventEntry(int32_t type, nsecs_t eventTime, uint32_t policyFlags); EventEntry(uint32_t sequenceNum, int32_t type, nsecs_t eventTime, uint32_t policyFlags); virtual ~EventEntry(); void releaseInjectionState(); }; struct ConfigurationChangedEntry : EventEntry { explicit ConfigurationChangedEntry(nsecs_t eventTime); explicit ConfigurationChangedEntry(uint32_t sequenceNum, nsecs_t eventTime); virtual void appendDescription(std::string& msg) const; protected: Loading @@ -485,7 +486,7 @@ private: struct DeviceResetEntry : EventEntry { int32_t deviceId; DeviceResetEntry(nsecs_t eventTime, int32_t deviceId); DeviceResetEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId); virtual void appendDescription(std::string& msg) const; protected: Loading Loading @@ -515,7 +516,7 @@ private: InterceptKeyResult interceptKeyResult; // set based on the interception result nsecs_t interceptKeyWakeupTime; // used with INTERCEPT_KEY_RESULT_TRY_AGAIN_LATER KeyEntry(nsecs_t eventTime, KeyEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState, int32_t repeatCount, nsecs_t downTime); Loading Loading @@ -544,7 +545,7 @@ private: PointerProperties pointerProperties[MAX_POINTERS]; PointerCoords pointerCoords[MAX_POINTERS]; MotionEntry(nsecs_t eventTime, MotionEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags, Loading services/inputflinger/InputListener.cpp +23 −21 Original line number Diff line number Diff line Loading @@ -26,13 +26,14 @@ namespace android { // --- NotifyConfigurationChangedArgs --- NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(nsecs_t eventTime) : eventTime(eventTime) { NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs( uint32_t sequenceNum, nsecs_t eventTime) : NotifyArgs(sequenceNum), eventTime(eventTime) { } NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs( const NotifyConfigurationChangedArgs& other) : eventTime(other.eventTime) { NotifyArgs(other.sequenceNum), eventTime(other.eventTime) { } void NotifyConfigurationChangedArgs::notify(const sp<InputListenerInterface>& listener) const { Loading @@ -42,19 +43,19 @@ void NotifyConfigurationChangedArgs::notify(const sp<InputListenerInterface>& li // --- NotifyKeyArgs --- NotifyKeyArgs::NotifyKeyArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, NotifyKeyArgs::NotifyKeyArgs(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime) : eventTime(eventTime), deviceId(deviceId), source(source), displayId(displayId), policyFlags(policyFlags), NotifyArgs(sequenceNum), eventTime(eventTime), deviceId(deviceId), source(source), displayId(displayId), policyFlags(policyFlags), action(action), flags(flags), keyCode(keyCode), scanCode(scanCode), metaState(metaState), downTime(downTime) { } NotifyKeyArgs::NotifyKeyArgs(const NotifyKeyArgs& other) : eventTime(other.eventTime), deviceId(other.deviceId), source(other.source), displayId(other.displayId), policyFlags(other.policyFlags), NotifyArgs(other.sequenceNum), eventTime(other.eventTime), deviceId(other.deviceId), source(other.source), displayId(other.displayId), policyFlags(other.policyFlags), action(other.action), flags(other.flags), keyCode(other.keyCode), scanCode(other.scanCode), metaState(other.metaState), downTime(other.downTime) { Loading @@ -67,15 +68,15 @@ void NotifyKeyArgs::notify(const sp<InputListenerInterface>& listener) const { // --- NotifyMotionArgs --- NotifyMotionArgs::NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, NotifyMotionArgs::NotifyMotionArgs(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags, uint32_t deviceTimestamp, uint32_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, float xPrecision, float yPrecision, nsecs_t downTime) : eventTime(eventTime), deviceId(deviceId), source(source), displayId(displayId), policyFlags(policyFlags), NotifyArgs(sequenceNum), eventTime(eventTime), deviceId(deviceId), source(source), displayId(displayId), policyFlags(policyFlags), action(action), actionButton(actionButton), flags(flags), metaState(metaState), buttonState(buttonState), edgeFlags(edgeFlags), deviceTimestamp(deviceTimestamp), Loading @@ -88,8 +89,8 @@ NotifyMotionArgs::NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t } NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other) : eventTime(other.eventTime), deviceId(other.deviceId), source(other.source), displayId(other.displayId), policyFlags(other.policyFlags), NotifyArgs(other.sequenceNum), eventTime(other.eventTime), deviceId(other.deviceId), source(other.source), displayId(other.displayId), policyFlags(other.policyFlags), action(other.action), actionButton(other.actionButton), flags(other.flags), metaState(other.metaState), buttonState(other.buttonState), edgeFlags(other.edgeFlags), Loading @@ -108,14 +109,14 @@ void NotifyMotionArgs::notify(const sp<InputListenerInterface>& listener) const // --- NotifySwitchArgs --- NotifySwitchArgs::NotifySwitchArgs(nsecs_t eventTime, uint32_t policyFlags, NotifySwitchArgs::NotifySwitchArgs(uint32_t sequenceNum, nsecs_t eventTime, uint32_t policyFlags, uint32_t switchValues, uint32_t switchMask) : eventTime(eventTime), policyFlags(policyFlags), NotifyArgs(sequenceNum), eventTime(eventTime), policyFlags(policyFlags), switchValues(switchValues), switchMask(switchMask) { } NotifySwitchArgs::NotifySwitchArgs(const NotifySwitchArgs& other) : eventTime(other.eventTime), policyFlags(other.policyFlags), NotifyArgs(other.sequenceNum), eventTime(other.eventTime), policyFlags(other.policyFlags), switchValues(other.switchValues), switchMask(other.switchMask) { } Loading @@ -126,12 +127,13 @@ void NotifySwitchArgs::notify(const sp<InputListenerInterface>& listener) const // --- NotifyDeviceResetArgs --- NotifyDeviceResetArgs::NotifyDeviceResetArgs(nsecs_t eventTime, int32_t deviceId) : eventTime(eventTime), deviceId(deviceId) { NotifyDeviceResetArgs::NotifyDeviceResetArgs( uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId) : NotifyArgs(sequenceNum), eventTime(eventTime), deviceId(deviceId) { } NotifyDeviceResetArgs::NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other) : eventTime(other.eventTime), deviceId(other.deviceId) { NotifyArgs(other.sequenceNum), eventTime(other.eventTime), deviceId(other.deviceId) { } void NotifyDeviceResetArgs::notify(const sp<InputListenerInterface>& listener) const { Loading services/inputflinger/InputReader.cpp +47 −31 File changed.Preview size limit exceeded, changes collapsed. Show changes services/inputflinger/InputReader.h +6 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,8 @@ public: virtual InputReaderPolicyInterface* getPolicy() = 0; virtual InputListenerInterface* getListener() = 0; virtual EventHubInterface* getEventHub() = 0; virtual uint32_t getNextSequenceNum() = 0; }; Loading Loading @@ -168,6 +170,7 @@ protected: virtual InputReaderPolicyInterface* getPolicy(); virtual InputListenerInterface* getListener(); virtual EventHubInterface* getEventHub(); virtual uint32_t getNextSequenceNum(); } mContext; friend class ContextImpl; Loading @@ -183,6 +186,9 @@ private: InputReaderConfiguration mConfig; // used by InputReaderContext::getNextSequenceNum() as a counter for event sequence numbers uint32_t mNextSequenceNum; // The event queue. static const int EVENT_BUFFER_SIZE = 256; RawEvent mEventBuffer[EVENT_BUFFER_SIZE]; Loading Loading
services/inputflinger/InputDispatcher.cpp +31 −21 Original line number Diff line number Diff line Loading @@ -97,6 +97,9 @@ constexpr std::chrono::milliseconds SLOW_INTERCEPTION_THRESHOLD = 50ms; // Number of recent events to keep for debugging purposes. constexpr size_t RECENT_QUEUE_MAX_SIZE = 10; // Sequence number for synthesized or injected events. constexpr uint32_t SYNTHESIZED_EVENT_SEQUENCE_NUM = 0; static inline nsecs_t now() { return systemTime(SYSTEM_TIME_MONOTONIC); Loading Loading @@ -710,7 +713,7 @@ InputDispatcher::KeyEntry* InputDispatcher::synthesizeKeyRepeatLocked(nsecs_t cu entry->policyFlags = policyFlags; entry->repeatCount += 1; } else { KeyEntry* newEntry = new KeyEntry(currentTime, KeyEntry* newEntry = new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime, entry->deviceId, entry->source, entry->displayId, policyFlags, entry->action, entry->flags, entry->keyCode, entry->scanCode, entry->metaState, entry->repeatCount + 1, entry->downTime); Loading Loading @@ -2474,6 +2477,7 @@ InputDispatcher::splitMotionEvent(const MotionEntry* originalMotionEntry, BitSet } MotionEntry* splitMotionEntry = new MotionEntry( originalMotionEntry->sequenceNum, originalMotionEntry->eventTime, originalMotionEntry->deviceId, originalMotionEntry->source, Loading Loading @@ -2507,7 +2511,8 @@ void InputDispatcher::notifyConfigurationChanged(const NotifyConfigurationChange { // acquire lock AutoMutex _l(mLock); ConfigurationChangedEntry* newEntry = new ConfigurationChangedEntry(args->eventTime); ConfigurationChangedEntry* newEntry = new ConfigurationChangedEntry(args->sequenceNum, args->eventTime); needWake = enqueueInboundEventLocked(newEntry); } // release lock Loading Loading @@ -2612,7 +2617,7 @@ void InputDispatcher::notifyKey(const NotifyKeyArgs* args) { mLock.lock(); } KeyEntry* newEntry = new KeyEntry(args->eventTime, KeyEntry* newEntry = new KeyEntry(args->sequenceNum, args->eventTime, args->deviceId, args->source, args->displayId, policyFlags, args->action, flags, keyCode, args->scanCode, metaState, repeatCount, args->downTime); Loading Loading @@ -2696,7 +2701,7 @@ void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) { } // Just enqueue a new motion event. MotionEntry* newEntry = new MotionEntry(args->eventTime, MotionEntry* newEntry = new MotionEntry(args->sequenceNum, args->eventTime, args->deviceId, args->source, args->displayId, policyFlags, args->action, args->actionButton, args->flags, args->metaState, args->buttonState, Loading Loading @@ -2740,7 +2745,8 @@ void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs* args) { { // acquire lock AutoMutex _l(mLock); DeviceResetEntry* newEntry = new DeviceResetEntry(args->eventTime, args->deviceId); DeviceResetEntry* newEntry = new DeviceResetEntry(args->sequenceNum, args->eventTime, args->deviceId); needWake = enqueueInboundEventLocked(newEntry); } // release lock Loading Loading @@ -2799,7 +2805,7 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event, } mLock.lock(); firstInjectedEntry = new KeyEntry(keyEvent.getEventTime(), firstInjectedEntry = new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, keyEvent.getEventTime(), keyEvent.getDeviceId(), keyEvent.getSource(), keyEvent.getDisplayId(), policyFlags, action, flags, keyEvent.getKeyCode(), keyEvent.getScanCode(), keyEvent.getMetaState(), Loading Loading @@ -2831,7 +2837,7 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event, mLock.lock(); const nsecs_t* sampleEventTimes = motionEvent->getSampleEventTimes(); const PointerCoords* samplePointerCoords = motionEvent->getSamplePointerCoords(); firstInjectedEntry = new MotionEntry(*sampleEventTimes, firstInjectedEntry = new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, *sampleEventTimes, motionEvent->getDeviceId(), motionEvent->getSource(), motionEvent->getDisplayId(), policyFlags, action, actionButton, motionEvent->getFlags(), Loading @@ -2845,7 +2851,8 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event, for (size_t i = motionEvent->getHistorySize(); i > 0; i--) { sampleEventTimes += 1; samplePointerCoords += pointerCount; MotionEntry* nextInjectedEntry = new MotionEntry(*sampleEventTimes, MotionEntry* nextInjectedEntry = new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, *sampleEventTimes, motionEvent->getDeviceId(), motionEvent->getSource(), motionEvent->getDisplayId(), policyFlags, action, actionButton, motionEvent->getFlags(), Loading Loading @@ -4279,9 +4286,10 @@ void InputDispatcher::InjectionState::release() { // --- InputDispatcher::EventEntry --- InputDispatcher::EventEntry::EventEntry(int32_t type, nsecs_t eventTime, uint32_t policyFlags) : refCount(1), type(type), eventTime(eventTime), policyFlags(policyFlags), injectionState(nullptr), dispatchInProgress(false) { InputDispatcher::EventEntry::EventEntry(uint32_t sequenceNum, int32_t type, nsecs_t eventTime, uint32_t policyFlags) : sequenceNum(sequenceNum), refCount(1), type(type), eventTime(eventTime), policyFlags(policyFlags), injectionState(nullptr), dispatchInProgress(false) { } InputDispatcher::EventEntry::~EventEntry() { Loading @@ -4307,8 +4315,9 @@ void InputDispatcher::EventEntry::releaseInjectionState() { // --- InputDispatcher::ConfigurationChangedEntry --- InputDispatcher::ConfigurationChangedEntry::ConfigurationChangedEntry(nsecs_t eventTime) : EventEntry(TYPE_CONFIGURATION_CHANGED, eventTime, 0) { InputDispatcher::ConfigurationChangedEntry::ConfigurationChangedEntry( uint32_t sequenceNum, nsecs_t eventTime) : EventEntry(sequenceNum, TYPE_CONFIGURATION_CHANGED, eventTime, 0) { } InputDispatcher::ConfigurationChangedEntry::~ConfigurationChangedEntry() { Loading @@ -4321,8 +4330,9 @@ void InputDispatcher::ConfigurationChangedEntry::appendDescription(std::string& // --- InputDispatcher::DeviceResetEntry --- InputDispatcher::DeviceResetEntry::DeviceResetEntry(nsecs_t eventTime, int32_t deviceId) : EventEntry(TYPE_DEVICE_RESET, eventTime, 0), InputDispatcher::DeviceResetEntry::DeviceResetEntry( uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId) : EventEntry(sequenceNum, TYPE_DEVICE_RESET, eventTime, 0), deviceId(deviceId) { } Loading @@ -4337,11 +4347,11 @@ void InputDispatcher::DeviceResetEntry::appendDescription(std::string& msg) cons // --- InputDispatcher::KeyEntry --- InputDispatcher::KeyEntry::KeyEntry(nsecs_t eventTime, InputDispatcher::KeyEntry::KeyEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState, int32_t repeatCount, nsecs_t downTime) : EventEntry(TYPE_KEY, eventTime, policyFlags), EventEntry(sequenceNum, TYPE_KEY, eventTime, policyFlags), deviceId(deviceId), source(source), displayId(displayId), action(action), flags(flags), keyCode(keyCode), scanCode(scanCode), metaState(metaState), repeatCount(repeatCount), downTime(downTime), Loading Loading @@ -4372,7 +4382,7 @@ void InputDispatcher::KeyEntry::recycle() { // --- InputDispatcher::MotionEntry --- InputDispatcher::MotionEntry::MotionEntry(nsecs_t eventTime, int32_t deviceId, InputDispatcher::MotionEntry::MotionEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags, Loading @@ -4380,7 +4390,7 @@ InputDispatcher::MotionEntry::MotionEntry(nsecs_t eventTime, int32_t deviceId, uint32_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, float xOffset, float yOffset) : EventEntry(TYPE_MOTION, eventTime, policyFlags), EventEntry(sequenceNum, TYPE_MOTION, eventTime, policyFlags), eventTime(eventTime), deviceId(deviceId), source(source), displayId(displayId), action(action), actionButton(actionButton), flags(flags), metaState(metaState), buttonState(buttonState), Loading Loading @@ -4694,7 +4704,7 @@ void InputDispatcher::InputState::synthesizeCancelationEvents(nsecs_t currentTim for (size_t i = 0; i < mKeyMementos.size(); i++) { const KeyMemento& memento = mKeyMementos.itemAt(i); if (shouldCancelKey(memento, options)) { outEvents.push(new KeyEntry(currentTime, outEvents.push(new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime, memento.deviceId, memento.source, memento.displayId, memento.policyFlags, AKEY_EVENT_ACTION_UP, memento.flags | AKEY_EVENT_FLAG_CANCELED, memento.keyCode, memento.scanCode, memento.metaState, 0, memento.downTime)); Loading @@ -4704,7 +4714,7 @@ void InputDispatcher::InputState::synthesizeCancelationEvents(nsecs_t currentTim for (size_t i = 0; i < mMotionMementos.size(); i++) { const MotionMemento& memento = mMotionMementos.itemAt(i); if (shouldCancelMotion(memento, options)) { outEvents.push(new MotionEntry(currentTime, outEvents.push(new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime, memento.deviceId, memento.source, memento.displayId, memento.policyFlags, memento.hovering ? AMOTION_EVENT_ACTION_HOVER_EXIT Loading
services/inputflinger/InputDispatcher.h +6 −5 Original line number Diff line number Diff line Loading @@ -454,6 +454,7 @@ private: TYPE_MOTION }; uint32_t sequenceNum; mutable int32_t refCount; int32_t type; nsecs_t eventTime; Loading @@ -469,13 +470,13 @@ private: virtual void appendDescription(std::string& msg) const = 0; protected: EventEntry(int32_t type, nsecs_t eventTime, uint32_t policyFlags); EventEntry(uint32_t sequenceNum, int32_t type, nsecs_t eventTime, uint32_t policyFlags); virtual ~EventEntry(); void releaseInjectionState(); }; struct ConfigurationChangedEntry : EventEntry { explicit ConfigurationChangedEntry(nsecs_t eventTime); explicit ConfigurationChangedEntry(uint32_t sequenceNum, nsecs_t eventTime); virtual void appendDescription(std::string& msg) const; protected: Loading @@ -485,7 +486,7 @@ private: struct DeviceResetEntry : EventEntry { int32_t deviceId; DeviceResetEntry(nsecs_t eventTime, int32_t deviceId); DeviceResetEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId); virtual void appendDescription(std::string& msg) const; protected: Loading Loading @@ -515,7 +516,7 @@ private: InterceptKeyResult interceptKeyResult; // set based on the interception result nsecs_t interceptKeyWakeupTime; // used with INTERCEPT_KEY_RESULT_TRY_AGAIN_LATER KeyEntry(nsecs_t eventTime, KeyEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState, int32_t repeatCount, nsecs_t downTime); Loading Loading @@ -544,7 +545,7 @@ private: PointerProperties pointerProperties[MAX_POINTERS]; PointerCoords pointerCoords[MAX_POINTERS]; MotionEntry(nsecs_t eventTime, MotionEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags, Loading
services/inputflinger/InputListener.cpp +23 −21 Original line number Diff line number Diff line Loading @@ -26,13 +26,14 @@ namespace android { // --- NotifyConfigurationChangedArgs --- NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(nsecs_t eventTime) : eventTime(eventTime) { NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs( uint32_t sequenceNum, nsecs_t eventTime) : NotifyArgs(sequenceNum), eventTime(eventTime) { } NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs( const NotifyConfigurationChangedArgs& other) : eventTime(other.eventTime) { NotifyArgs(other.sequenceNum), eventTime(other.eventTime) { } void NotifyConfigurationChangedArgs::notify(const sp<InputListenerInterface>& listener) const { Loading @@ -42,19 +43,19 @@ void NotifyConfigurationChangedArgs::notify(const sp<InputListenerInterface>& li // --- NotifyKeyArgs --- NotifyKeyArgs::NotifyKeyArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, NotifyKeyArgs::NotifyKeyArgs(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime) : eventTime(eventTime), deviceId(deviceId), source(source), displayId(displayId), policyFlags(policyFlags), NotifyArgs(sequenceNum), eventTime(eventTime), deviceId(deviceId), source(source), displayId(displayId), policyFlags(policyFlags), action(action), flags(flags), keyCode(keyCode), scanCode(scanCode), metaState(metaState), downTime(downTime) { } NotifyKeyArgs::NotifyKeyArgs(const NotifyKeyArgs& other) : eventTime(other.eventTime), deviceId(other.deviceId), source(other.source), displayId(other.displayId), policyFlags(other.policyFlags), NotifyArgs(other.sequenceNum), eventTime(other.eventTime), deviceId(other.deviceId), source(other.source), displayId(other.displayId), policyFlags(other.policyFlags), action(other.action), flags(other.flags), keyCode(other.keyCode), scanCode(other.scanCode), metaState(other.metaState), downTime(other.downTime) { Loading @@ -67,15 +68,15 @@ void NotifyKeyArgs::notify(const sp<InputListenerInterface>& listener) const { // --- NotifyMotionArgs --- NotifyMotionArgs::NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, NotifyMotionArgs::NotifyMotionArgs(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action, int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags, uint32_t deviceTimestamp, uint32_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, float xPrecision, float yPrecision, nsecs_t downTime) : eventTime(eventTime), deviceId(deviceId), source(source), displayId(displayId), policyFlags(policyFlags), NotifyArgs(sequenceNum), eventTime(eventTime), deviceId(deviceId), source(source), displayId(displayId), policyFlags(policyFlags), action(action), actionButton(actionButton), flags(flags), metaState(metaState), buttonState(buttonState), edgeFlags(edgeFlags), deviceTimestamp(deviceTimestamp), Loading @@ -88,8 +89,8 @@ NotifyMotionArgs::NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t } NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other) : eventTime(other.eventTime), deviceId(other.deviceId), source(other.source), displayId(other.displayId), policyFlags(other.policyFlags), NotifyArgs(other.sequenceNum), eventTime(other.eventTime), deviceId(other.deviceId), source(other.source), displayId(other.displayId), policyFlags(other.policyFlags), action(other.action), actionButton(other.actionButton), flags(other.flags), metaState(other.metaState), buttonState(other.buttonState), edgeFlags(other.edgeFlags), Loading @@ -108,14 +109,14 @@ void NotifyMotionArgs::notify(const sp<InputListenerInterface>& listener) const // --- NotifySwitchArgs --- NotifySwitchArgs::NotifySwitchArgs(nsecs_t eventTime, uint32_t policyFlags, NotifySwitchArgs::NotifySwitchArgs(uint32_t sequenceNum, nsecs_t eventTime, uint32_t policyFlags, uint32_t switchValues, uint32_t switchMask) : eventTime(eventTime), policyFlags(policyFlags), NotifyArgs(sequenceNum), eventTime(eventTime), policyFlags(policyFlags), switchValues(switchValues), switchMask(switchMask) { } NotifySwitchArgs::NotifySwitchArgs(const NotifySwitchArgs& other) : eventTime(other.eventTime), policyFlags(other.policyFlags), NotifyArgs(other.sequenceNum), eventTime(other.eventTime), policyFlags(other.policyFlags), switchValues(other.switchValues), switchMask(other.switchMask) { } Loading @@ -126,12 +127,13 @@ void NotifySwitchArgs::notify(const sp<InputListenerInterface>& listener) const // --- NotifyDeviceResetArgs --- NotifyDeviceResetArgs::NotifyDeviceResetArgs(nsecs_t eventTime, int32_t deviceId) : eventTime(eventTime), deviceId(deviceId) { NotifyDeviceResetArgs::NotifyDeviceResetArgs( uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId) : NotifyArgs(sequenceNum), eventTime(eventTime), deviceId(deviceId) { } NotifyDeviceResetArgs::NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other) : eventTime(other.eventTime), deviceId(other.deviceId) { NotifyArgs(other.sequenceNum), eventTime(other.eventTime), deviceId(other.deviceId) { } void NotifyDeviceResetArgs::notify(const sp<InputListenerInterface>& listener) const { Loading
services/inputflinger/InputReader.cpp +47 −31 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/inputflinger/InputReader.h +6 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,8 @@ public: virtual InputReaderPolicyInterface* getPolicy() = 0; virtual InputListenerInterface* getListener() = 0; virtual EventHubInterface* getEventHub() = 0; virtual uint32_t getNextSequenceNum() = 0; }; Loading Loading @@ -168,6 +170,7 @@ protected: virtual InputReaderPolicyInterface* getPolicy(); virtual InputListenerInterface* getListener(); virtual EventHubInterface* getEventHub(); virtual uint32_t getNextSequenceNum(); } mContext; friend class ContextImpl; Loading @@ -183,6 +186,9 @@ private: InputReaderConfiguration mConfig; // used by InputReaderContext::getNextSequenceNum() as a counter for event sequence numbers uint32_t mNextSequenceNum; // The event queue. static const int EVENT_BUFFER_SIZE = 256; RawEvent mEventBuffer[EVENT_BUFFER_SIZE]; Loading