diff options
| author | 2021-06-01 23:25:58 +0000 | |
|---|---|---|
| committer | 2021-06-01 23:25:58 +0000 | |
| commit | e040fd14ef597a49da7ebbf299ca0d8a61c5ed1e (patch) | |
| tree | 60855f833b8dd094768ac89e7b47479493c7b3fd | |
| parent | c32a92fb0c594e415e808db0fbaab679f50700b1 (diff) | |
| parent | fea99012bc9b58d037659ac219ec3274c862824e (diff) | |
Merge "[BugFix] Reset key repeating in case a keyboard device was disabled or enabled."
| -rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 5 | ||||
| -rw-r--r-- | services/inputflinger/tests/InputDispatcher_test.cpp | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index 6ea64b440e..674d6deece 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -1098,6 +1098,11 @@ bool InputDispatcher::dispatchDeviceResetLocked(nsecs_t currentTime, DeviceReset entry->deviceId); #endif + // Reset key repeating in case a keyboard device was disabled or enabled. + if (mKeyRepeatState.lastKeyEntry && mKeyRepeatState.lastKeyEntry->deviceId == entry->deviceId) { + resetKeyRepeatLocked(); + } + CancelationOptions options(CancelationOptions::CANCEL_ALL_EVENTS, "device was reset"); options.deviceId = entry->deviceId; synthesizeCancelationEventsForAllConnectionsLocked(options); diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp index 668a7ab421..8d80f2aa48 100644 --- a/services/inputflinger/tests/InputDispatcher_test.cpp +++ b/services/inputflinger/tests/InputDispatcher_test.cpp @@ -1799,6 +1799,16 @@ TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_StopsKeyRepeatAfterUp) { mWindow->assertNoEvents(); } +TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_StopsKeyRepeatAfterDisableInputDevice) { + sendAndConsumeKeyDown(); + expectKeyRepeatOnce(1 /*repeatCount*/); + NotifyDeviceResetArgs args(10 /*id*/, 20 /*eventTime*/, DEVICE_ID); + mDispatcher->notifyDeviceReset(&args); + mWindow->consumeKeyUp(ADISPLAY_ID_DEFAULT, + AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_LONG_PRESS); + mWindow->assertNoEvents(); +} + TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_RepeatKeyEventsUseEventIdFromInputDispatcher) { sendAndConsumeKeyDown(); for (int32_t repeatCount = 1; repeatCount <= 10; ++repeatCount) { |