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

Commit 83184c1e authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge "ViewGroup: Split ACTION_CANCEL events during dispatch" into main

parents 00dafb19 714ff200
Loading
Loading
Loading
Loading
+55 −55
Original line number Diff line number Diff line
@@ -3093,30 +3093,26 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
     */
    private boolean dispatchTransformedTouchEvent(MotionEvent event, boolean cancel,
            View child, int desiredPointerIdBits) {
        final boolean handled;

        // Canceling motions is a special case.  We don't need to perform any transformations
        // or filtering.  The important part is the action, not the contents.
        final int oldAction = event.getAction();
        if (cancel || oldAction == MotionEvent.ACTION_CANCEL) {
        try {
            final boolean handled;
            if (cancel) {
                event.setAction(MotionEvent.ACTION_CANCEL);
            if (child == null) {
                handled = super.dispatchTouchEvent(event);
            } else {
                handled = child.dispatchTouchEvent(event);
            }
            event.setAction(oldAction);
            return handled;
            }

            // Calculate the number of pointers to deliver.
            final int oldPointerIdBits = event.getPointerIdBits();
        final int newPointerIdBits = oldPointerIdBits & desiredPointerIdBits;
            int newPointerIdBits = oldPointerIdBits & desiredPointerIdBits;

            // If for some reason we ended up in an inconsistent state where it looks like we
        // might produce a motion event with no pointers in it, then drop the event.
            // might produce a non-cancel motion event with no pointers in it, then drop the event.
            // Make sure that we don't drop any cancel events.
            if (newPointerIdBits == 0) {
                if (event.getAction() != MotionEvent.ACTION_CANCEL) {
                    return false;
                } else {
                    newPointerIdBits = oldPointerIdBits;
                }
            }

            // If the number of pointers is the same and we don't need to perform any fancy
@@ -3161,6 +3157,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            // Done.
            transformedEvent.recycle();
            return handled;

        } finally {
            event.setAction(oldAction);
        }
    }

    /**