InputDispatcher: check consistency of filtered injected events -- try 3
This reverts commit d604df195f5d5f59d61b5ef68e1434d99037e2c2.
Reason for revert: fixed flags in b/309829647
Change-Id: I191eb04c95d1316cb505ba0861669ad004d02d67
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index c4bfa62..8e0da14 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4732,6 +4732,7 @@
}
void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs& args) {
+ // TODO(b/308677868) Remove device reset from the InputListener interface
if (debugInboundEventDetails()) {
ALOGD("notifyDeviceReset - eventTime=%" PRId64 ", deviceId=%d", args.eventTime,
args.deviceId);
@@ -4883,6 +4884,30 @@
}
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.
+ auto [it, _] =
+ mInputFilterVerifiersByDisplay
+ .try_emplace(displayId,
+ StringPrintf("Injection on %" PRId32, displayId));
+ InputVerifier& verifier = it->second;
+
+ Result<void> result =
+ verifier.processMovement(resolvedDeviceId, motionEvent.getSource(),
+ motionEvent.getAction(),
+ motionEvent.getPointerCount(),
+ motionEvent.getPointerProperties(),
+ motionEvent.getSamplePointerCoords(), flags);
+ if (!result.ok()) {
+ logDispatchStateLocked();
+ LOG(ERROR) << "Inconsistent event: " << motionEvent
+ << ", reason: " << result.error();
+ }
+ }
+
const nsecs_t* sampleEventTimes = motionEvent.getSampleEventTimes();
const size_t pointerCount = motionEvent.getPointerCount();
const std::vector<PointerProperties>
@@ -6962,6 +6987,7 @@
// Remove the associated touch mode state.
mTouchModePerDisplay.erase(displayId);
mVerifiersByDisplay.erase(displayId);
+ mInputFilterVerifiersByDisplay.erase(displayId);
} // release lock
// Wake up poll loop since it may need to make new input dispatching choices.