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

Commit 00221e36 authored by mattsziklay's avatar mattsziklay Committed by Matt Sziklay
Browse files

Only take one pointer in caption MotionEvents.

Resolves a crash where any pointer beyond the first on caption results
in an invalid pointer index.

Bug: 280830379
Test: Manual
Test: atest WMShellUnitTests

Change-Id: I886345e19d653643ea83e7918cd723983ef2150d
parent 05ca0c87
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -268,7 +268,10 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
                    return false;
                }
                case MotionEvent.ACTION_MOVE: {
                    int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    if (e.findPointerIndex(mDragPointerId) == -1) {
                        mDragPointerId = e.getPointerId(0);
                    }
                    final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    mDragPositioningCallback.onDragPositioningMove(
                            e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
                    mIsDragging = true;
@@ -276,7 +279,10 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
                }
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL: {
                    int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    if (e.findPointerIndex(mDragPointerId) == -1) {
                        mDragPointerId = e.getPointerId(0);
                    }
                    final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    mDragPositioningCallback.onDragPositioningEnd(
                            e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
                    final boolean wasDragging = mIsDragging;
+6 −0
Original line number Diff line number Diff line
@@ -385,6 +385,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                case MotionEvent.ACTION_MOVE: {
                    final DesktopModeWindowDecoration decoration =
                            mWindowDecorByTaskId.get(mTaskId);
                    if (e.findPointerIndex(mDragPointerId) == -1) {
                        mDragPointerId = e.getPointerId(0);
                    }
                    final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    mDesktopTasksController.ifPresent(c -> c.onDragPositioningMove(taskInfo,
                            decoration.mTaskSurface, e.getRawY(dragPointerIdx)));
@@ -395,6 +398,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                }
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL: {
                    if (e.findPointerIndex(mDragPointerId) == -1) {
                        mDragPointerId = e.getPointerId(0);
                    }
                    final int dragPointerIdx = e.findPointerIndex(mDragPointerId);
                    // Position of the task is calculated by subtracting the raw location of the
                    // motion event (the location of the motion relative to the display) by the
+4 −1
Original line number Diff line number Diff line
@@ -73,8 +73,11 @@ class DragDetector {
                return mResultOfDownAction;
            }
            case ACTION_MOVE: {
                if (ev.findPointerIndex(mDragPointerId) == -1) {
                    mDragPointerId = ev.getPointerId(0);
                }
                final int dragPointerIndex = ev.findPointerIndex(mDragPointerId);
                if (!mIsDragEvent) {
                    int dragPointerIndex = ev.findPointerIndex(mDragPointerId);
                    float dx = ev.getRawX(dragPointerIndex) - mInputDownPoint.x;
                    float dy = ev.getRawY(dragPointerIndex) - mInputDownPoint.y;
                    // Touches generate noisy moves, so only once the move is past the touch