diff options
| author | 2018-10-29 18:02:27 -0700 | |
|---|---|---|
| committer | 2018-11-01 15:13:29 -0700 | |
| commit | 622bd3244d82bb982f4f8bf2e5b7d1d9c98860d3 (patch) | |
| tree | 6ea4e775f717df38f8185f4537fe64993e186b14 /services/inputflinger/InputDispatcher.cpp | |
| parent | a5517d710e729ed4ebfc44016d3cc77c25505d87 (diff) | |
Allow injected events to specify repeatCount
Injected key events may contain repeatCount. Currently, all injected
events are hardcoded to have zero key repeat. This breaks any injected
key event that simulates long-press behaviour.
To fix this, ensure that we are using the specified repeatCount from the
injected event.
Test: atest KeyEventInjectionTest
Bug: 113341746
Change-Id: Ic663df984703b04f021e428463868293366b4250
Diffstat (limited to 'services/inputflinger/InputDispatcher.cpp')
| -rw-r--r-- | services/inputflinger/InputDispatcher.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/services/inputflinger/InputDispatcher.cpp b/services/inputflinger/InputDispatcher.cpp index 2cad9861ab..2e984d9ca9 100644 --- a/services/inputflinger/InputDispatcher.cpp +++ b/services/inputflinger/InputDispatcher.cpp @@ -2545,6 +2545,9 @@ void InputDispatcher::notifyKey(const NotifyKeyArgs* args) { uint32_t policyFlags = args->policyFlags; int32_t flags = args->flags; int32_t metaState = args->metaState; + // InputDispatcher tracks and generates key repeats on behalf of + // whatever notifies it, so repeatCount should always be set to 0 + constexpr int32_t repeatCount = 0; if ((policyFlags & POLICY_FLAG_VIRTUAL) || (flags & AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY)) { policyFlags |= POLICY_FLAG_VIRTUAL; flags |= AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY; @@ -2560,7 +2563,7 @@ void InputDispatcher::notifyKey(const NotifyKeyArgs* args) { KeyEvent event; event.initialize(args->deviceId, args->source, args->displayId, args->action, - flags, keyCode, args->scanCode, metaState, 0, + flags, keyCode, args->scanCode, metaState, repeatCount, args->downTime, args->eventTime); android::base::Timer t; @@ -2585,7 +2588,6 @@ void InputDispatcher::notifyKey(const NotifyKeyArgs* args) { mLock.lock(); } - int32_t repeatCount = 0; KeyEntry* newEntry = new KeyEntry(args->eventTime, args->deviceId, args->source, args->displayId, policyFlags, args->action, flags, keyCode, args->scanCode, @@ -2756,7 +2758,7 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event, accelerateMetaShortcuts(keyEvent.getDeviceId(), action, /*byref*/ keyCode, /*byref*/ metaState); keyEvent.initialize(keyEvent.getDeviceId(), keyEvent.getSource(), keyEvent.getDisplayId(), - action, flags, keyCode, keyEvent.getScanCode(), metaState, 0, + action, flags, keyCode, keyEvent.getScanCode(), metaState, keyEvent.getRepeatCount(), keyEvent.getDownTime(), keyEvent.getEventTime()); if (flags & AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY) { |