InputReader: Use shared keyboard source for all key events

When multiple EventHub devices are merged into a single InputDevice,
it's possible that there are more than one KeyboardInputMappers created
for the device. In this case, each mapper could be configured with a
different source. This can lead to situations where a device generates
key events that have different sources, depending on the mapper from
which it originated.

To make sure all key events use a consistent source for each
InputDevice, use the shared keyboard source when generating events from
a KeyboardInputMapper.

Bug: 354270482
Test: atest inputflinger_tests
Flag: EXEMPT bugfix
Change-Id: I586424b5e8d31d17cbe635d9f91a889aee906d40
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.h b/services/inputflinger/reader/mapper/KeyboardInputMapper.h
index c7df558..2df0b85 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.h
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.h
@@ -60,7 +60,10 @@
         int32_t flags{};
     };
 
-    uint32_t mSource{};
+    // The keyboard source for this mapper. Events generated should use the source shared
+    // by all KeyboardInputMappers for this input device.
+    uint32_t mMapperSource{};
+
     std::optional<KeyboardLayoutInfo> mKeyboardLayoutInfo;
 
     std::vector<KeyDown> mKeyDowns{}; // keys that are down
@@ -106,6 +109,7 @@
     std::optional<DisplayViewport> findViewport(const InputReaderConfiguration& readerConfig);
     [[nodiscard]] std::list<NotifyArgs> cancelAllDownKeys(nsecs_t when);
     void onKeyDownProcessed(nsecs_t downTime);
+    uint32_t getEventSource() const;
 };
 
 } // namespace android