Verify all injected events
Prior to this CL, we only verified the streams from events injected from
accessibility.
With this CL, we will now verify all injected events, even if they did
not originate from a11y. That means, these events were injected from
tests. For now, we will only log the fact that the stream is
inconsistent, but still let it through. Eventually, we can fail the
injection instead, which will prevent crashes in the dispatcher.
Bug: 329439551
Test: atest inputflinger_tests
Change-Id: Ie7313fd79f614d3347ef7198812be3c810eb86ea
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 9b97629..527edb6 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4885,10 +4885,11 @@
mLock.lock();
- if (policyFlags & POLICY_FLAG_FILTERED) {
- // The events from InputFilter impersonate real hardware devices. Check these
- // events for consistency and print an error. An inconsistent event sent from
- // InputFilter could cause a crash in the later stages of dispatching pipeline.
+ {
+ // Verify all injected streams, whether the injection is coming from apps or from
+ // input filter. Print an error if the stream becomes inconsistent with this event.
+ // An inconsistent injected event sent could cause a crash in the later stages of
+ // dispatching pipeline.
auto [it, _] =
mInputFilterVerifiersByDisplay.try_emplace(displayId,
std::string("Injection on ") +