Increase leniency of precondition check for MotionEvent::split
The severity of a specific precondition check was unintentionally
promoted from WARNING to FATAL in the following refactor:
I6230b6aa0696dcfc275a5a14ab4af3d4b7bd0b45
Here, we demote it back to a non-fatal check.
Bug: 328852741
Bug: 329107108
Test: atest inputflinger_tests
Change-Id: If2cb22d528d5e68c1e035a3e4291dae7fc32bb34
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 73bbed6..3c83aff 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4285,6 +4285,20 @@
MotionEvent::split(originalMotionEntry.action, originalMotionEntry.flags,
/*historySize=*/0, originalMotionEntry.pointerProperties,
originalMotionEntry.pointerCoords, pointerIds);
+ if (pointerIds.count() != pointerCoords.size()) {
+ // TODO(b/329107108): Determine why some IDs in pointerIds were not in originalMotionEntry.
+ // This is bad. We are missing some of the pointers that we expected to deliver.
+ // Most likely this indicates that we received an ACTION_MOVE events that has
+ // different pointer ids than we expected based on the previous ACTION_DOWN
+ // or ACTION_POINTER_DOWN events that caused us to decide to split the pointers
+ // in this way.
+ ALOGW("Dropping split motion event because the pointer count is %d but "
+ "we expected there to be %zu pointers. This probably means we received "
+ "a broken sequence of pointer ids from the input device: %s",
+ pointerCoords.size(), pointerIds.count(),
+ originalMotionEntry.getDescription().c_str());
+ return nullptr;
+ }
// TODO(b/327503168): Move this check inside MotionEvent::split once all callers handle it
// correctly.