Move key remapping to InputReader thread(1/n)
Currently, the key remapping operation occurs on a non-Reader thread,
which leads to concurrent operations on the KCM object by this thread
and the Reader, causing unpredictable concurrency issues.
Here, we move this operation to the Reader thread, aligning it with
most configuration refresh methods, which can resolve the
aforementioned issues.
Additionally, we are removing the device traversal method on the Java
side because we actually intend for the key remapping operation to
apply to all full-keyboard devices. This can be fully achieved during
the InputReader refresh, so we are also removing the deviceId parameter
from the remapping interface.
There should be no behavioral changes.
Bug: 358042225
Test: atest CtsInputTestCases
Test: atest InputTests
Test: atest inputflinger_tests
Flag: EXEMPT refactor
Change-Id: I6ab802b70dc1242c796f672ac30672d10e34857f
Signed-off-by: Linnan Li <lilinnan@xiaomi.corp-partner.google.com>
diff --git a/services/inputflinger/reader/include/EventHub.h b/services/inputflinger/reader/include/EventHub.h
index 657126a..edc3037 100644
--- a/services/inputflinger/reader/include/EventHub.h
+++ b/services/inputflinger/reader/include/EventHub.h
@@ -281,8 +281,8 @@
virtual bool hasMscEvent(int32_t deviceId, int mscEvent) const = 0;
- virtual void addKeyRemapping(int32_t deviceId, int32_t fromKeyCode,
- int32_t toKeyCode) const = 0;
+ virtual void setKeyRemapping(int32_t deviceId,
+ const std::map<int32_t, int32_t>& keyRemapping) const = 0;
virtual status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode,
int32_t metaState, int32_t* outKeycode, int32_t* outMetaState,
@@ -513,8 +513,8 @@
bool hasMscEvent(int32_t deviceId, int mscEvent) const override final;
- void addKeyRemapping(int32_t deviceId, int32_t fromKeyCode,
- int32_t toKeyCode) const override final;
+ void setKeyRemapping(int32_t deviceId,
+ const std::map<int32_t, int32_t>& keyRemapping) const override final;
status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode, int32_t metaState,
int32_t* outKeycode, int32_t* outMetaState,