[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
Signed-off-by: liushenxiang <liushenxiang@xiaomi.com>
Change-Id: Ic0e37d1e1e447d4965f3fbb479e0eca7c726a6ab
(cherry picked from commit 97b0d3b5fcbe4dcf0a8d359f52027bbf49a8f387)
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 7e069c8..1117ecd 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -1256,6 +1256,11 @@
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);