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

Commit 8b9c3004 authored by Riley Jones's avatar Riley Jones Committed by Android (Google) Code Review
Browse files

Merge changes I223d50bf,If6068b9a into main

* changes:
  fix(touchexplorer): Avoid conflicts with real and TouchExplorer events by using a virtual device id
  Revert "Sends ACTION_CANCEL before the very first touch exploration HOVER event."
parents 646c4f66 a9faca97
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -303,16 +303,6 @@ flag {
    }
}

flag {
    name: "reset_input_dispatcher_before_first_touch_exploration"
    namespace: "accessibility"
    description: "Resets InputDispatcher state by sending ACTION_CANCEL before the first TouchExploration hover events"
    bug: "364408887"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "scan_packages_without_lock"
    namespace: "accessibility"
@@ -326,7 +316,6 @@ flag {
    description: "Sends accessibility events in TouchExplorer#onAccessibilityEvent based on internal state to keep it consistent. This reduces test flakiness."
    bug: "295575684"
}

flag {
    name: "send_hover_events_based_on_event_stream"
    namespace: "accessibility"
@@ -353,3 +342,13 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "touch_explorer_use_virtual_device_id"
    namespace: "accessibility"
    description: "Use a VIRTUAL device id for injected TouchExplorer events to avoid temporary conflicts with real pointer touches still on the screen when TouchExplorer starts up."
    bug: "364408887"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.accessibility;

import static com.android.server.accessibility.gestures.EventDispatcher.VIRTUAL_TOUCHSCREEN_DEVICE_ID;

import android.accessibilityservice.AccessibilityTrace;
import android.accessibilityservice.GestureDescription;
import android.accessibilityservice.GestureDescription.GestureStep;
@@ -30,7 +32,6 @@ import android.util.IntArray;
import android.util.Slog;
import android.util.SparseIntArray;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.MotionEvent;
import android.view.WindowManagerPolicyConstants;

@@ -526,7 +527,7 @@ public class MotionEventInjector extends BaseEventStreamTransformation implement
        }
        return MotionEvent.obtain(downTime, eventTime, action, touchPointsSize,
                sPointerProps, sPointerCoords, EVENT_META_STATE, EVENT_BUTTON_STATE,
                EVENT_X_PRECISION, EVENT_Y_PRECISION, KeyCharacterMap.VIRTUAL_KEYBOARD,
                EVENT_X_PRECISION, EVENT_Y_PRECISION, VIRTUAL_TOUCHSCREEN_DEVICE_ID,
                EVENT_EDGE_FLAGS, EVENT_SOURCE, EVENT_FLAGS);
    }

+14 −2
Original line number Diff line number Diff line
@@ -39,7 +39,16 @@ import com.android.server.policy.WindowManagerPolicy;
 * gesture dispatch. TouchExplorer is responsible for insuring that the receiver of motion events is
 * set correctly so that events go to the right place.
 */
class EventDispatcher {
public class EventDispatcher {

    /**
     * Device ID used for touchscreen events injected by touch exploration and gesture dispatch.
     *
     * <p>Using a virtual device ID that differs from a real touchscreen ID helps to prevent
     * conflicts in inputflinger/InputDispatcher between injected and real touch events.
     */
    public static final int VIRTUAL_TOUCHSCREEN_DEVICE_ID = -1;

    private static final String LOG_TAG = "EventDispatcher";
    private static final int CLICK_LOCATION_NONE = 0;
    private static final int CLICK_LOCATION_ACCESSIBILITY_FOCUS = 1;
@@ -125,10 +134,13 @@ class EventDispatcher {
            event.getPointerProperties(i, p);
            properties[i] = p;
        }
        final int deviceId = Flags.touchExplorerUseVirtualDeviceId()
                ? VIRTUAL_TOUCHSCREEN_DEVICE_ID
                : rawEvent.getDeviceId();
        event = MotionEvent.obtain(downTime, event.getEventTime(), event.getAction(),
                event.getPointerCount(), properties, coords,
                event.getMetaState(), event.getButtonState(),
                event.getXPrecision(), event.getYPrecision(), rawEvent.getDeviceId(),
                event.getXPrecision(), event.getYPrecision(), deviceId,
                event.getEdgeFlags(), rawEvent.getSource(), event.getDisplayId(), event.getFlags(),
                event.getClassification());
        // If the user is long pressing but the long pressing pointer
+0 −18
Original line number Diff line number Diff line
@@ -1618,19 +1618,6 @@ public class TouchExplorer extends BaseEventStreamTransformation
                dispatchGesture(gestureEvent);
            }
            if (!mEvents.isEmpty() && !mRawEvents.isEmpty()) {
                if (Flags.resetInputDispatcherBeforeFirstTouchExploration()
                        && !mState.hasResetInputDispatcherState()) {
                    // Cancel any possible ongoing touch gesture from before touch exploration
                    // started. This clears out the InputDispatcher event stream state so that it
                    // is ready to accept new injected HOVER events.
                    mDispatcher.sendMotionEvent(
                            mEvents.get(0),
                            ACTION_CANCEL,
                            mRawEvents.get(0),
                            mPointerIdBits,
                            mPolicyFlags);
                    setHasResetInputDispatcherState(true);
                }
                // Deliver a down event.
                mDispatcher.sendMotionEvent(
                        mEvents.get(0),
@@ -1791,9 +1778,4 @@ public class TouchExplorer extends BaseEventStreamTransformation
                + ", mDraggingPointerId: " + mDraggingPointerId
                + " }";
    }

    @VisibleForTesting
    void setHasResetInputDispatcherState(boolean value) {
        mState.setHasResetInputDispatcherState(value);
    }
}
+0 −9
Original line number Diff line number Diff line
@@ -89,7 +89,6 @@ public class TouchState {
    private MotionEvent mLastInjectedHoverEvent;
    // The last injected hover event used for performing clicks.
    private MotionEvent mLastInjectedHoverEventForClick;
    private boolean mHasResetInputDispatcherState;
    // The time of the last injected down.
    private long mLastInjectedDownEventTime;
    // Keep track of which pointers sent to the system are down.
@@ -376,14 +375,6 @@ public class TouchState {
        return mLastInjectedDownEventTime;
    }

    boolean hasResetInputDispatcherState() {
        return mHasResetInputDispatcherState;
    }

    void setHasResetInputDispatcherState(boolean value) {
        mHasResetInputDispatcherState = value;
    }

    public int getLastTouchedWindowId() {
        return mLastTouchedWindowId;
    }
Loading