[BugFix] Reset key repeating in case a keyboard device was disabled or enabled.
The "resetKeyRepeatLocked" will never be called when we disable a keyboard device. In this case, if we long click a key on keyboard and it began to repeat. Then we disable the keyboard. We find that the key repeating will never stop until a next key event come.
Test: atest inputflinger_tests
Change-Id: Ic0e37d1e1e447d4965f3fbb479e0eca7c726a6ab
Merged-In: Ic0e37d1e1e447d4965f3fbb479e0eca7c726a6ab
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 668a7ab..8d80f2a 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -1799,6 +1799,16 @@
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) {