diff options
author | 2024-03-11 18:38:40 +0000 | |
---|---|---|
committer | 2024-03-11 18:52:00 +0000 | |
commit | 1a41fe079e3347a017134fc74d0fd145420e1847 (patch) | |
tree | e9e8f5dc7e688bc5869edb8f3b7865db93e96bf2 | |
parent | 25cf7faf4a428573bec0a900ec628d0919657b2b (diff) |
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
-rw-r--r-- | libs/input/Input.cpp | 3 | ||||
-rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp index ff9d9a94c9..61a964ece9 100644 --- a/libs/input/Input.cpp +++ b/libs/input/Input.cpp @@ -1034,7 +1034,8 @@ std::tuple<int32_t, std::vector<PointerProperties>, std::vector<PointerCoords>> (splitPointerProperties.size() * (historySize + 1))); if (CC_UNLIKELY(splitPointerProperties.size() != splitCount)) { - LOG(FATAL) << "Cannot split MotionEvent: Requested splitting " << splitCount + // TODO(b/329107108): Promote this to a fatal check once bugs in the caller are resolved. + LOG(ERROR) << "Cannot split MotionEvent: Requested splitting " << splitCount << " pointers from the original event, but the original event only contained " << splitPointerProperties.size() << " of those pointers."; } diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index 73bbed6c68..3c83affcbe 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -4285,6 +4285,20 @@ std::unique_ptr<MotionEntry> InputDispatcher::splitMotionEvent( 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. |