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

Commit ec178382 authored by Zachary Kuznia's avatar Zachary Kuznia
Browse files

Ensure MotionEvent.split() won't be given an invalid value.

b/27496784

Change-Id: I28bb4ac5bb8a705e7af9b22b2b56cd4061aa06a0
parent c4b6e2a1
Loading
Loading
Loading
Loading
+13 −1
Original line number Original line Diff line number Diff line
@@ -648,7 +648,16 @@ class TouchExplorer implements EventStreamTransformation, AccessibilityGestureDe
     * @param policyFlags The policy flags associated with the event.
     * @param policyFlags The policy flags associated with the event.
     */
     */
    private void handleMotionEventStateDragging(MotionEvent event, int policyFlags) {
    private void handleMotionEventStateDragging(MotionEvent event, int policyFlags) {
        final int pointerIdBits = (1 << mDraggingPointerId);
        int pointerIdBits = 0;
        // Clear the dragging pointer id if it's no longer valid.
        if (event.findPointerIndex(mDraggingPointerId) == -1) {
            Slog.e(LOG_TAG, "mDraggingPointerId doesn't match any pointers on current event. " +
                    "mDraggingPointerId: " + Integer.toString(mDraggingPointerId) +
                    ", Event: " + event);
            mDraggingPointerId = INVALID_POINTER_ID;
        } else {
            pointerIdBits = (1 << mDraggingPointerId);
        }
        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 "
                throw new IllegalStateException("Dragging state can be reached only if two "
@@ -664,6 +673,9 @@ class TouchExplorer implements EventStreamTransformation, AccessibilityGestureDe
                sendDownForAllNotInjectedPointers(event, policyFlags);
                sendDownForAllNotInjectedPointers(event, policyFlags);
            } break;
            } break;
            case MotionEvent.ACTION_MOVE: {
            case MotionEvent.ACTION_MOVE: {
                if (mDraggingPointerId == INVALID_POINTER_ID) {
                    break;
                }
                switch (event.getPointerCount()) {
                switch (event.getPointerCount()) {
                    case 1: {
                    case 1: {
                        // do nothing
                        // do nothing