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

Commit 45b8dff2 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Do not access specific pointers when non existent

Make sure we do not access coordinates of specific
pointers before mOngoingPinchResize is true.

Removed the unnecessary log messages as well, since
the InputEvent object is logged already and ACTION_MOVE
MotionEvent will be logged once mOngoingPinchResize is true
in onPinchResize.

This should fix the IllegalArgumentException that was emerging earlier

Bug: 271894660
Test: Reproduce the steps in the bug

Change-Id: I6e570c5381ebf98a7b7b271acdabaa99aadf9e5d
parent 3e6df193
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -244,6 +244,7 @@ public class PipResizeGestureHandler {

    @VisibleForTesting
    void onInputEvent(InputEvent ev) {
        // TODO: remove logging once b/269505548 is resolved
        Log.d(TAG, "onInputEvent: " + ev);
        if (!mEnableDragCornerResize && !mEnablePinchResize) {
            // No need to handle anything if neither form of resizing is enabled.
@@ -258,17 +259,6 @@ public class PipResizeGestureHandler {
        if (ev instanceof MotionEvent) {
            MotionEvent mv = (MotionEvent) ev;
            int action = mv.getActionMasked();

            // TODO: remove logging once b/269505548 is resolved
            if (action == MotionEvent.ACTION_MOVE && mFirstIndex != -1 && mSecondIndex != -1) {
                float x0 = mv.getRawX(mFirstIndex);
                float y0 = mv.getRawY(mFirstIndex);
                float x1 = mv.getRawX(mSecondIndex);
                float y1 = mv.getRawY(mSecondIndex);
                Log.d(TAG, "at onInputEvent (" + x0 + ", " + y0 + ")");
                Log.d(TAG, "at onInputEvent (" + x1 + ", " + y1 + ")");
            }

            final Rect pipBounds = mPipBoundsState.getBounds();
            if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
                if (!pipBounds.contains((int) mv.getRawX(), (int) mv.getRawY())