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

Commit 9404bea4 authored by Phil Weaver's avatar Phil Weaver
Browse files

Stop throwing exceptions in TouchExplorer

These crash the system. Resetting and trying to muddle
through seems like a better solution than restarting
the device.

Bug: 68269250
Test: make, try TalkBack a bit. The crashes were so rare that
the code I'm changing *almost* never executes.

Change-Id: I7931417832cb2ce39de5c8b00312c12354d76803
parent 92ab9f1c
Loading
Loading
Loading
Loading
+9 −5
Original line number Original line Diff line number Diff line
@@ -21,7 +21,6 @@ import android.graphics.Point;
import android.os.Handler;
import android.os.Handler;
import android.util.Slog;
import android.util.Slog;
import android.view.InputDevice;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.MotionEvent.PointerCoords;
import android.view.MotionEvent.PointerCoords;
import android.view.MotionEvent.PointerProperties;
import android.view.MotionEvent.PointerProperties;
@@ -296,7 +295,8 @@ class TouchExplorer extends BaseEventStreamTransformation
                // Already handled.
                // Already handled.
            } break;
            } break;
            default:
            default:
                throw new IllegalStateException("Illegal state: " + mCurrentState);
                Slog.e(LOG_TAG, "Illegal state: " + mCurrentState);
                clear(event, policyFlags);
        }
        }
    }
    }


@@ -649,8 +649,10 @@ class TouchExplorer extends BaseEventStreamTransformation
        }
        }
        switch (event.getActionMasked()) {
        switch (event.getActionMasked()) {
            case MotionEvent.ACTION_DOWN: {
            case MotionEvent.ACTION_DOWN: {
                throw new IllegalStateException("Dragging state can be reached only if two "
                Slog.e(LOG_TAG, "Dragging state can be reached only if two "
                        + "pointers are already down");
                        + "pointers are already down");
                clear(event, policyFlags);
                return;
            }
            }
            case MotionEvent.ACTION_POINTER_DOWN: {
            case MotionEvent.ACTION_POINTER_DOWN: {
                // We are in dragging state so we have two pointers and another one
                // We are in dragging state so we have two pointers and another one
@@ -741,8 +743,10 @@ class TouchExplorer extends BaseEventStreamTransformation
    private void handleMotionEventStateDelegating(MotionEvent event, int policyFlags) {
    private void handleMotionEventStateDelegating(MotionEvent event, int policyFlags) {
        switch (event.getActionMasked()) {
        switch (event.getActionMasked()) {
            case MotionEvent.ACTION_DOWN: {
            case MotionEvent.ACTION_DOWN: {
                throw new IllegalStateException("Delegating state can only be reached if "
                Slog.e(LOG_TAG, "Delegating state can only be reached if "
                        + "there is at least one pointer down!");
                        + "there is at least one pointer down!");
                clear(event, policyFlags);
                return;
            }
            }
            case MotionEvent.ACTION_UP: {
            case MotionEvent.ACTION_UP: {
                // Offset the event if we are doing a long press as the
                // Offset the event if we are doing a long press as the
@@ -1093,7 +1097,7 @@ class TouchExplorer extends BaseEventStreamTransformation
            case STATE_GESTURE_DETECTING:
            case STATE_GESTURE_DETECTING:
                return "STATE_GESTURE_DETECTING";
                return "STATE_GESTURE_DETECTING";
            default:
            default:
                throw new IllegalArgumentException("Unknown state: " + state);
                return "Unknown state: " + state;
        }
        }
    }
    }