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

Commit 86815fa0 authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Prevent crash on 2 finger drag.

This undoes the exception throw change made in this CL ag/28337643

Fixes: 396369165
Test: manual test, atest DragDetectorTest
Flag: EXEMPT minor refactoring
Change-Id: I579e266a2ace7fc9c48f42db2b7e1da060b44fed
parent f2aefe77
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import static android.view.MotionEvent.ACTION_UP;

import android.annotation.NonNull;
import android.graphics.PointF;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

@@ -43,6 +44,8 @@ import androidx.annotation.Nullable;
 * All touch events must be passed through this class to track a drag event.
 */
public class DragDetector {
    private static final String TAG = "DragDetector";

    private final MotionEventHandler mEventHandler;

    private final PointF mInputDownPoint = new PointF();
@@ -109,8 +112,12 @@ public class DragDetector {
                    return mResultOfDownAction;
                }
                final int dragPointerIndex = ev.findPointerIndex(mDragPointerId);
                // TODO(b/400635953): Separate the app header and its buttons'
                // touch listeners so they're not handled by the same DragDetector.
                if (dragPointerIndex == -1) {
                    throw new IllegalStateException("Failed to find primary pointer!");
                    Log.w(TAG, "Invalid pointer index on ACTION_MOVE. Drag"
                        + " pointer id: " + mDragPointerId);
                    return mResultOfDownAction;
                }
                if (!mIsDragEvent) {
                    float dx = ev.getRawX(dragPointerIndex) - mInputDownPoint.x;