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

Commit 12214fb3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix TouchExplorerTest flakiness." into main

parents 96138388 fb76caf3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -20,3 +20,10 @@ flag {
    description: "Whether to enable joystick controls for magnification"
    bug: "297211257"
}

flag {
    name: "send_a11y_events_based_on_state"
    namespace: "accessibility"
    description: "Sends accessibility events in TouchExplorer#onAccessibilityEvent based on internal state to keep it consistent. This reduces test flakiness."
bug: "295575684"
}
 No newline at end of file
+28 −9
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.server.accessibility.AccessibilityManagerService;
import com.android.server.accessibility.BaseEventStreamTransformation;
import com.android.server.accessibility.EventStreamTransformation;
import com.android.server.accessibility.Flags;
import com.android.server.policy.WindowManagerPolicy;

import java.util.ArrayList;
@@ -352,6 +353,23 @@ public class TouchExplorer extends BaseEventStreamTransformation
        }
        // The event for gesture end should be strictly after the
        // last hover exit event.
        if (Flags.sendA11yEventsBasedOnState()) {
            if (mSendTouchExplorationEndDelayed.isPending()) {
                mSendTouchExplorationEndDelayed.cancel();
            }
            if (mState.isTouchExploring()) {
                mDispatcher.sendAccessibilityEvent(TYPE_TOUCH_EXPLORATION_GESTURE_END);
            }

            // The event for touch interaction end should be strictly after the
            // last hover exit and the touch exploration gesture end events.
            if (mSendTouchInteractionEndDelayed.isPending()) {
                mSendTouchInteractionEndDelayed.cancel();
            }
            if (mState.isTouchInteracting()) {
                mDispatcher.sendAccessibilityEvent(TYPE_TOUCH_INTERACTION_END);
            }
        } else {
            if (mSendTouchExplorationEndDelayed.isPending()) {
                mSendTouchExplorationEndDelayed.cancel();
                mDispatcher.sendAccessibilityEvent(TYPE_TOUCH_EXPLORATION_GESTURE_END);
@@ -364,6 +382,7 @@ public class TouchExplorer extends BaseEventStreamTransformation
                mDispatcher.sendAccessibilityEvent(TYPE_TOUCH_INTERACTION_END);
            }
        }
    }

    @Override
    public void onDoubleTapAndHold(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+2 −1
Original line number Diff line number Diff line
@@ -253,7 +253,8 @@ public class TouchExplorerTest {
        goFromStateClearTo(STATE_TOUCH_EXPLORING_1FINGER);
        moveEachPointers(mLastEvent, p(10, 10));
        send(mLastEvent);

        // Wait 10 ms to make sure that hover enter and exit are not scheduled for the same moment.
        mHandler.fastForward(10);
        send(upEvent());
        // Wait for sending hover exit event to transit to clear state.
        mHandler.fastForward(USER_INTENT_TIMEOUT);