Fix toggleCapsLock failed for multiple EventHub devices
If a physical device includes multiple EventHub devices for different
funcions, it would also create multiple InputMappers to process raw
events. And it may contain multiple KeyboardInputMapper.
When 'toggleCapsLock' called, we have to check if device has the meta
state key such as CAPS_LOCK or NUMS_LOCK, then we should just update the
the first InputMapper that own the meta state key to prevent other
InputMapper update the global state multiple times.
Bug: 195405545
Test: atest inputflinger_tests
Test: shortcut key META-ALT
Change-Id: I9d09e13d1de416370b8570b6621db5c4bf1ba8eb
diff --git a/services/inputflinger/reader/include/EventHub.h b/services/inputflinger/reader/include/EventHub.h
index 3c3f88e..7a00bac 100644
--- a/services/inputflinger/reader/include/EventHub.h
+++ b/services/inputflinger/reader/include/EventHub.h
@@ -312,6 +312,7 @@
uint8_t* outFlags) const = 0;
virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const = 0;
+ virtual bool hasKeyCode(int32_t deviceId, int32_t keyCode) const = 0;
/* LED related functions expect Android LED constants, not scan codes or HID usages */
virtual bool hasLed(int32_t deviceId, int32_t led) const = 0;
@@ -489,6 +490,7 @@
std::vector<TouchVideoFrame> getVideoFrames(int32_t deviceId) override final;
bool hasScanCode(int32_t deviceId, int32_t scanCode) const override final;
+ bool hasKeyCode(int32_t deviceId, int32_t keyCode) const override final;
bool hasLed(int32_t deviceId, int32_t led) const override final;
void setLedState(int32_t deviceId, int32_t led, bool on) override final;