Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37cf33ce authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Increase leniency of precondition check for MotionEvent::split" into main

parents d23f53f9 1a41fe07
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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.";
    }
+14 −0
Original line number Diff line number Diff line
@@ -4357,6 +4357,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.