Skip processing repeat EV_KEY events for keyboards
Key repeat is handled by Android internally so we should not use the
kernel level key repeat.
Android attempts to disable key repeat by sending a EVIOCSREP ioctl
call, however this does not work on all keyboards (namely any that use
the atkbd driver) as [0, 0] are considered invalid configuration values
for the driver.
This functions in a similar way to the original intention in that it
will discard all kernel level repeat EV_KEY events to allow the system
level key-repeat to function correctly.
Bug: b/374209729
Test: Manually with offending device
Flag: EXEMPT bugfix
Change-Id: I5219edcddfc2fdb420e5c3ef7ecc9b5c557e5c6a
diff --git a/services/inputflinger/tests/TestEventMatchers.h b/services/inputflinger/tests/TestEventMatchers.h
index 6fa3365..f58d8fd 100644
--- a/services/inputflinger/tests/TestEventMatchers.h
+++ b/services/inputflinger/tests/TestEventMatchers.h
@@ -540,6 +540,34 @@
return WithKeyCodeMatcher(keyCode);
}
+/// Scan code
+class WithScanCodeMatcher {
+public:
+ using is_gtest_matcher = void;
+ explicit WithScanCodeMatcher(int32_t scanCode) : mScanCode(scanCode) {}
+
+ bool MatchAndExplain(const NotifyKeyArgs& args, std::ostream*) const {
+ return mScanCode == args.scanCode;
+ }
+
+ bool MatchAndExplain(const KeyEvent& event, std::ostream*) const {
+ return mScanCode == event.getKeyCode();
+ }
+
+ void DescribeTo(std::ostream* os) const {
+ *os << "with scan code " << KeyEvent::getLabel(mScanCode);
+ }
+
+ void DescribeNegationTo(std::ostream* os) const { *os << "wrong scan code"; }
+
+private:
+ const int32_t mScanCode;
+};
+
+inline WithScanCodeMatcher WithScanCode(int32_t scanCode) {
+ return WithScanCodeMatcher(scanCode);
+}
+
/// EventId
class WithEventIdMatcher {
public: