diff options
Diffstat (limited to 'services/inputflinger')
-rw-r--r-- | services/inputflinger/Android.mk | 7 | ||||
-rw-r--r-- | services/inputflinger/EventHub.cpp | 8 | ||||
-rw-r--r-- | services/inputflinger/InputDispatcher.cpp | 12 | ||||
-rw-r--r-- | services/inputflinger/InputDispatcher.h | 11 | ||||
-rw-r--r-- | services/inputflinger/InputReader.cpp | 18 | ||||
-rw-r--r-- | services/inputflinger/InputReader.h | 3 | ||||
-rw-r--r-- | services/inputflinger/tests/Android.mk | 12 | ||||
-rw-r--r-- | services/inputflinger/tests/InputDispatcher_test.cpp | 32 | ||||
-rw-r--r-- | services/inputflinger/tests/InputReader_test.cpp | 56 |
9 files changed, 76 insertions, 83 deletions
diff --git a/services/inputflinger/Android.mk b/services/inputflinger/Android.mk index 85edbe5..1af59a3 100644 --- a/services/inputflinger/Android.mk +++ b/services/inputflinger/Android.mk @@ -31,16 +31,13 @@ LOCAL_SHARED_LIBRARIES := \ libinput \ liblog \ libutils \ - libui \ - libhardware_legacy + libui \ + libhardware_legacy # TODO: Move inputflinger to its own process and mark it hidden #LOCAL_CFLAGS += -fvisibility=hidden -LOCAL_C_INCLUDES := \ - external/openssl/include \ - LOCAL_CFLAGS += -Wno-unused-parameter LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp index dfe5d3d..93ce010 100644 --- a/services/inputflinger/EventHub.cpp +++ b/services/inputflinger/EventHub.cpp @@ -858,7 +858,6 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz int(iev.time.tv_sec), int(iev.time.tv_usec)); } -#ifdef HAVE_POSIX_CLOCKS // Use the time specified in the event instead of the current time // so that downstream code can get more accurate estimates of // event dispatch latency from the time the event is enqueued onto @@ -909,9 +908,6 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz event->when, time, now); } } -#else - event->when = now; -#endif event->deviceId = deviceId; event->type = iev.type; event->code = iev.code; @@ -1443,7 +1439,7 @@ void EventHub::setLedForController(Device* device) { } bool EventHub::hasKeycodeLocked(Device* device, int keycode) const { - if (!device->keyMap.haveKeyLayout() || !device->keyBitmask) { + if (!device->keyMap.haveKeyLayout()) { return false; } @@ -1461,7 +1457,7 @@ bool EventHub::hasKeycodeLocked(Device* device, int keycode) const { } status_t EventHub::mapLed(Device* device, int32_t led, int32_t* outScanCode) const { - if (!device->keyMap.haveKeyLayout() || !device->ledBitmask) { + if (!device->keyMap.haveKeyLayout()) { return NAME_NOT_FOUND; } diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp index 603836a..9157bc1 100644 --- a/services/inputflinger/InputDispatcher.cpp +++ b/services/inputflinger/InputDispatcher.cpp @@ -3789,18 +3789,6 @@ void InputDispatcher::monitor() { } -// --- InputDispatcher::Queue --- - -template <typename T> -uint32_t InputDispatcher::Queue<T>::count() const { - uint32_t result = 0; - for (const T* entry = head; entry; entry = entry->next) { - result += 1; - } - return result; -} - - // --- InputDispatcher::InjectionState --- InputDispatcher::InjectionState::InjectionState(int32_t injectorPid, int32_t injectorUid) : diff --git a/services/inputflinger/InputDispatcher.h b/services/inputflinger/InputDispatcher.h index 70b0a34..8c78a44 100644 --- a/services/inputflinger/InputDispatcher.h +++ b/services/inputflinger/InputDispatcher.h @@ -606,8 +606,9 @@ private: struct Queue { T* head; T* tail; + uint32_t entryCount; - inline Queue() : head(NULL), tail(NULL) { + inline Queue() : head(NULL), tail(NULL), entryCount(0) { } inline bool isEmpty() const { @@ -615,6 +616,7 @@ private: } inline void enqueueAtTail(T* entry) { + entryCount++; entry->prev = tail; if (tail) { tail->next = entry; @@ -626,6 +628,7 @@ private: } inline void enqueueAtHead(T* entry) { + entryCount++; entry->next = head; if (head) { head->prev = entry; @@ -637,6 +640,7 @@ private: } inline void dequeue(T* entry) { + entryCount--; if (entry->prev) { entry->prev->next = entry->next; } else { @@ -650,6 +654,7 @@ private: } inline T* dequeueAtHead() { + entryCount--; T* entry = head; head = entry->next; if (head) { @@ -660,7 +665,9 @@ private: return entry; } - uint32_t count() const; + uint32_t count() const { + return entryCount; + } }; /* Specifies which events are to be canceled and why. */ diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index 8634e42..ccf8ced 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -1078,6 +1078,14 @@ void InputDevice::cancelVibrate(int32_t token) { } } +void InputDevice::cancelTouch(nsecs_t when) { + size_t numMappers = mMappers.size(); + for (size_t i = 0; i < numMappers; i++) { + InputMapper* mapper = mMappers[i]; + mapper->cancelTouch(when); + } +} + int32_t InputDevice::getMetaState() { int32_t result = 0; size_t numMappers = mMappers.size(); @@ -1786,6 +1794,9 @@ void InputMapper::vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t re void InputMapper::cancelVibrate(int32_t token) { } +void InputMapper::cancelTouch(nsecs_t when) { +} + int32_t InputMapper::getMetaState() { return 0; } @@ -2134,6 +2145,9 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode, getDevice(), keyCode, scanCode)) { return; } + if (policyFlags & POLICY_FLAG_GESTURE) { + mDevice->cancelTouch(when); + } mKeyDowns.push(); KeyDown& keyDown = mKeyDowns.editTop(); @@ -5717,6 +5731,10 @@ void TouchInputMapper::fadePointer() { } } +void TouchInputMapper::cancelTouch(nsecs_t when) { + abortPointerUsage(when, 0 /*policyFlags*/); +} + bool TouchInputMapper::isPointInsideSurface(int32_t x, int32_t y) { return x >= mRawPointerAxes.x.minValue && x <= mRawPointerAxes.x.maxValue && y >= mRawPointerAxes.y.minValue && y <= mRawPointerAxes.y.maxValue; diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h index c5896d4..34f20af 100644 --- a/services/inputflinger/InputReader.h +++ b/services/inputflinger/InputReader.h @@ -572,6 +572,7 @@ public: const int32_t* keyCodes, uint8_t* outFlags); void vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t repeat, int32_t token); void cancelVibrate(int32_t token); + void cancelTouch(nsecs_t when); int32_t getMetaState(); @@ -973,6 +974,7 @@ public: virtual void vibrate(const nsecs_t* pattern, size_t patternSize, ssize_t repeat, int32_t token); virtual void cancelVibrate(int32_t token); + virtual void cancelTouch(nsecs_t when); virtual int32_t getMetaState(); @@ -1191,6 +1193,7 @@ public: const int32_t* keyCodes, uint8_t* outFlags); virtual void fadePointer(); + virtual void cancelTouch(nsecs_t when); virtual void timeoutExpired(nsecs_t when); protected: diff --git a/services/inputflinger/tests/Android.mk b/services/inputflinger/tests/Android.mk index 6dae82f..0742a08 100644 --- a/services/inputflinger/tests/Android.mk +++ b/services/inputflinger/tests/Android.mk @@ -16,20 +16,11 @@ shared_libraries := \ libhardware_legacy \ libui \ libskia \ - libstlport \ libinput \ libinputflinger \ libinputservice -static_libraries := \ - libgtest \ - libgtest_main - c_includes := \ - bionic \ - bionic/libstdc++/include \ - external/gtest/include \ - external/stlport/stlport \ external/skia/include/core @@ -38,9 +29,8 @@ module_tags := eng tests $(foreach file,$(test_src_files), \ $(eval include $(CLEAR_VARS)) \ $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \ - $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \ $(eval LOCAL_C_INCLUDES := $(c_includes)) \ - $(eval LOCAL_CFLAGS += -Wno-unused-parameter) \ + $(eval LOCAL_CFLAGS += -Wno-unused-parameter) \ $(eval LOCAL_SRC_FILES := $(file)) \ $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \ $(eval LOCAL_MODULE_TAGS := $(module_tags)) \ diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp index 7aac6ed..9b68986 100644 --- a/services/inputflinger/tests/InputDispatcher_test.cpp +++ b/services/inputflinger/tests/InputDispatcher_test.cpp @@ -49,51 +49,49 @@ public: } private: - virtual void notifyConfigurationChanged(nsecs_t when) { + virtual void notifyConfigurationChanged(nsecs_t) { } - virtual nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle, - const sp<InputWindowHandle>& inputWindowHandle, - const String8& reason) { + virtual nsecs_t notifyANR(const sp<InputApplicationHandle>&, + const sp<InputWindowHandle>&, + const String8&) { return 0; } - virtual void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle) { + virtual void notifyInputChannelBroken(const sp<InputWindowHandle>&) { } virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) { *outConfig = mConfig; } - virtual bool filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags) { + virtual bool filterInputEvent(const InputEvent*, uint32_t) { return true; } - virtual void interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags) { + virtual void interceptKeyBeforeQueueing(const KeyEvent*, uint32_t&) { } - virtual void interceptMotionBeforeQueueing(nsecs_t when, uint32_t& policyFlags) { + virtual void interceptMotionBeforeQueueing(nsecs_t, uint32_t&) { } - virtual nsecs_t interceptKeyBeforeDispatching(const sp<InputWindowHandle>& inputWindowHandle, - const KeyEvent* keyEvent, uint32_t policyFlags) { + virtual nsecs_t interceptKeyBeforeDispatching(const sp<InputWindowHandle>&, + const KeyEvent*, uint32_t) { return 0; } - virtual bool dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle, - const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent) { + virtual bool dispatchUnhandledKey(const sp<InputWindowHandle>&, + const KeyEvent*, uint32_t, KeyEvent*) { return false; } - virtual void notifySwitch(nsecs_t when, - uint32_t switchValues, uint32_t switchMask, uint32_t policyFlags) { + virtual void notifySwitch(nsecs_t, uint32_t, uint32_t, uint32_t) { } - virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType) { + virtual void pokeUserActivity(nsecs_t, int32_t) { } - virtual bool checkInjectEventsPermissionNonReentrant( - int32_t injectorPid, int32_t injectorUid) { + virtual bool checkInjectEventsPermissionNonReentrant(int32_t, int32_t) { return false; } }; diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index c6eb1fd..40f51b6 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -104,17 +104,16 @@ private: if (mY > mMaxY) mY = mMaxY; } - virtual void fade(Transition transition) { + virtual void fade(Transition) { } - virtual void unfade(Transition transition) { + virtual void unfade(Transition) { } - virtual void setPresentation(Presentation presentation) { + virtual void setPresentation(Presentation) { } - virtual void setSpots(const PointerCoords* spotCoords, - const uint32_t* spotIdToIndex, BitSet32 spotIdBits) { + virtual void setSpots(const PointerCoords*, const uint32_t*, BitSet32) { } virtual void clearSpots() { @@ -196,11 +195,11 @@ private: mInputDevices = inputDevices; } - virtual sp<KeyCharacterMap> getKeyboardLayoutOverlay(const InputDeviceIdentifier& identifier) { + virtual sp<KeyCharacterMap> getKeyboardLayoutOverlay(const InputDeviceIdentifier&) { return NULL; } - virtual String8 getDeviceAlias(const InputDeviceIdentifier& identifier) { + virtual String8 getDeviceAlias(const InputDeviceIdentifier&) { return String8::empty(); } }; @@ -482,7 +481,7 @@ private: return device ? device->identifier : InputDeviceIdentifier(); } - virtual int32_t getDeviceControllerNumber(int32_t deviceId) const { + virtual int32_t getDeviceControllerNumber(int32_t) const { return 0; } @@ -515,7 +514,7 @@ private: return false; } - virtual bool hasInputProperty(int32_t deviceId, int property) const { + virtual bool hasInputProperty(int32_t, int) const { return false; } @@ -553,8 +552,7 @@ private: return NULL; } - virtual status_t mapAxis(int32_t deviceId, int32_t scanCode, - AxisInfo* outAxisInfo) const { + virtual status_t mapAxis(int32_t, int32_t, AxisInfo*) const { return NAME_NOT_FOUND; } @@ -562,7 +560,7 @@ private: mExcludedDevices = devices; } - virtual size_t getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) { + virtual size_t getEvents(int, RawEvent* buffer, size_t) { if (mEvents.empty()) { return 0; } @@ -680,25 +678,25 @@ private: } } - virtual sp<KeyCharacterMap> getKeyCharacterMap(int32_t deviceId) const { + virtual sp<KeyCharacterMap> getKeyCharacterMap(int32_t) const { return NULL; } - virtual bool setKeyboardLayoutOverlay(int32_t deviceId, const sp<KeyCharacterMap>& map) { + virtual bool setKeyboardLayoutOverlay(int32_t, const sp<KeyCharacterMap>&) { return false; } - virtual void vibrate(int32_t deviceId, nsecs_t duration) { + virtual void vibrate(int32_t, nsecs_t) { } - virtual void cancelVibrate(int32_t deviceId) { + virtual void cancelVibrate(int32_t) { } - virtual bool isExternal(int32_t deviceId) const { + virtual bool isExternal(int32_t) const { return false; } - virtual void dump(String8& dump) { + virtual void dump(String8&) { } virtual void monitor() { @@ -763,18 +761,17 @@ private: return mListener.get(); } - virtual void disableVirtualKeysUntil(nsecs_t time) { + virtual void disableVirtualKeysUntil(nsecs_t) { } - virtual bool shouldDropVirtualKey(nsecs_t now, - InputDevice* device, int32_t keyCode, int32_t scanCode) { + virtual bool shouldDropVirtualKey(nsecs_t, InputDevice*, int32_t, int32_t) { return false; } virtual void fadePointer() { } - virtual void requestTimeoutAtTime(nsecs_t when) { + virtual void requestTimeoutAtTime(nsecs_t) { } virtual int32_t bumpGeneration() { @@ -867,12 +864,11 @@ private: } } - virtual void configure(nsecs_t when, - const InputReaderConfiguration* config, uint32_t changes) { + virtual void configure(nsecs_t, const InputReaderConfiguration*, uint32_t) { mConfigureWasCalled = true; } - virtual void reset(nsecs_t when) { + virtual void reset(nsecs_t) { mResetWasCalled = true; } @@ -881,22 +877,22 @@ private: mProcessWasCalled = true; } - virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode) { + virtual int32_t getKeyCodeState(uint32_t, int32_t keyCode) { ssize_t index = mKeyCodeStates.indexOfKey(keyCode); return index >= 0 ? mKeyCodeStates.valueAt(index) : AKEY_STATE_UNKNOWN; } - virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode) { + virtual int32_t getScanCodeState(uint32_t, int32_t scanCode) { ssize_t index = mScanCodeStates.indexOfKey(scanCode); return index >= 0 ? mScanCodeStates.valueAt(index) : AKEY_STATE_UNKNOWN; } - virtual int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode) { + virtual int32_t getSwitchState(uint32_t, int32_t switchCode) { ssize_t index = mSwitchStates.indexOfKey(switchCode); return index >= 0 ? mSwitchStates.valueAt(index) : AKEY_STATE_UNKNOWN; } - virtual bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, + virtual bool markSupportedKeyCodes(uint32_t, size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) { bool result = false; for (size_t i = 0; i < numCodes; i++) { @@ -1536,7 +1532,7 @@ protected: }; void KeyboardInputMapperTest::testDPadKeyRotation(KeyboardInputMapper* mapper, - int32_t originalScanCode, int32_t originalKeyCode, int32_t rotatedKeyCode) { + int32_t originalScanCode, int32_t, int32_t rotatedKeyCode) { NotifyKeyArgs args; process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, originalScanCode, 1); |