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

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

Merge changes Ic4a32853,Iba9ec12c,I40ddbde7 into main

* changes:
  Fix parameters in FullScreenMagnificationGestureHandlerTest
  Simplify MouseEventHandler construction
  Cealnup released enable_magnification_follows_mouse_bugfix
parents 03496f1e d833bce1
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -144,16 +144,6 @@ flag {
    bug: "282039824"
}

flag {
    name: "enable_magnification_follows_mouse_bugfix"
    namespace: "accessibility"
    description: "Whether to enable mouse following for fullscreen magnification"
    bug: "354696546"
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "enable_magnification_follows_mouse_with_pointer_motion_filter"
    namespace: "accessibility"
+1 −3
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ import com.android.server.accessibility.magnification.FullScreenMagnificationGes
import com.android.server.accessibility.magnification.FullScreenMagnificationVibrationHelper;
import com.android.server.accessibility.magnification.MagnificationGestureHandler;
import com.android.server.accessibility.magnification.MagnificationKeyHandler;
import com.android.server.accessibility.magnification.MouseEventHandler;
import com.android.server.accessibility.magnification.WindowMagnificationGestureHandler;
import com.android.server.accessibility.magnification.WindowMagnificationPromptController;
import com.android.server.policy.WindowManagerPolicy;
@@ -899,8 +898,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
                            triggerable,
                            new WindowMagnificationPromptController(displayContext, mUserId),
                            displayId,
                            fullScreenMagnificationVibrationHelper,
                            new MouseEventHandler(controller));
                            fullScreenMagnificationVibrationHelper);
        }
        return magnificationGestureHandler;
    }
+13 −18
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
    private final int mMinimumVelocity;
    private final int mMaximumVelocity;

    private MouseEventHandler mMouseEventHandler;
    private final MouseEventHandler mMouseEventHandler;

    public FullScreenMagnificationGestureHandler(
            @UiContext Context context,
@@ -194,8 +194,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
            boolean detectShortcutTrigger,
            @NonNull WindowMagnificationPromptController promptController,
            int displayId,
            FullScreenMagnificationVibrationHelper fullScreenMagnificationVibrationHelper,
            MouseEventHandler mouseEventHandler) {
            FullScreenMagnificationVibrationHelper fullScreenMagnificationVibrationHelper) {
        this(
                context,
                fullScreenMagnificationController,
@@ -210,8 +209,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
                /* magnificationLogger= */ null,
                ViewConfiguration.get(context),
                new OneFingerPanningSettingsProvider(
                        context, Flags.enableMagnificationOneFingerPanningGesture()),
                mouseEventHandler);
                        context, Flags.enableMagnificationOneFingerPanningGesture()));
    }

    /** Constructor for tests. */
@@ -229,8 +227,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
            FullScreenMagnificationVibrationHelper fullScreenMagnificationVibrationHelper,
            MagnificationLogger magnificationLogger,
            ViewConfiguration viewConfiguration,
            OneFingerPanningSettingsProvider oneFingerPanningSettingsProvider,
            MouseEventHandler mouseEventHandler) {
            OneFingerPanningSettingsProvider oneFingerPanningSettingsProvider) {
        super(displayId, detectSingleFingerTripleTap, detectTwoFingerTripleTap,
                detectShortcutTrigger, trace, callback);
        if (DEBUG_ALL) {
@@ -316,7 +313,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
        mOverscrollEdgeSlop = context.getResources().getDimensionPixelSize(
                R.dimen.accessibility_fullscreen_magnification_gesture_edge_slop);
        mIsWatch = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
        mMouseEventHandler = mouseEventHandler;
        mMouseEventHandler = new MouseEventHandler(mFullScreenMagnificationController);

        if (mDetectShortcutTrigger) {
            mScreenStateReceiver = new ScreenStateReceiver(context, this);
@@ -340,16 +337,15 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH

    @Override
    void handleMouseOrStylusEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
        if (Flags.enableMagnificationFollowsMouseBugfix()) {
            if (mFullScreenMagnificationController.isActivated(mDisplayId)) {
        if (!mFullScreenMagnificationController.isActivated(mDisplayId)) {
            return;
        }
        // TODO(b/354696546): Allow mouse/stylus to activate whichever display they are
        // over, rather than only interacting with the current display.

        // Send through the mouse/stylus event handler.
        mMouseEventHandler.onEvent(event, mDisplayId);
    }
        }
    }

    private void handleTouchEventWith(
            State stateHandler, MotionEvent event, MotionEvent rawEvent, int policyFlags) {
@@ -1170,8 +1166,7 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH

        protected void cacheDelayedMotionEvent(MotionEvent event, MotionEvent rawEvent,
                int policyFlags) {
            if (Flags.enableMagnificationFollowsMouseBugfix()
                    && !event.isFromSource(SOURCE_TOUCHSCREEN)) {
            if (!event.isFromSource(SOURCE_TOUCHSCREEN)) {
                // Only touch events need to be cached and sent later.
                return;
            }
+1 −2
Original line number Diff line number Diff line
@@ -146,8 +146,7 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
            } break;
            case SOURCE_MOUSE:
            case SOURCE_STYLUS: {
                if (magnificationShortcutExists()
                        && Flags.enableMagnificationFollowsMouseBugfix()) {
                if (magnificationShortcutExists()) {
                    handleMouseOrStylusEvent(event, rawEvent, policyFlags);
                }
            }
+12 −38
Original line number Diff line number Diff line
@@ -311,8 +311,7 @@ public class FullScreenMagnificationGestureHandlerTest {
                        mMockFullScreenMagnificationVibrationHelper,
                        mMockMagnificationLogger,
                        ViewConfiguration.get(mContext),
                        mMockOneFingerPanningSettingsProvider,
                        new MouseEventHandler(mFullScreenMagnificationController));
                        mMockOneFingerPanningSettingsProvider);
        // OverscrollHandler is only supported on watches.
        // @See config_enable_a11y_fullscreen_magnification_overscroll_handler
        if (isWatch()) {
@@ -482,8 +481,8 @@ public class FullScreenMagnificationGestureHandlerTest {
    @Test
    @RequiresFlagsDisabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
    public void testDisablingTripleTap_removesInputLag() {
        mMgh = newInstance(/* detectSingleFingerTripleTap */ false,
                /* detectTwoFingerTripleTap */ true, /* detectShortcut */ true);
        mMgh = newInstance(/* detectSingleFingerTripleTap= */ false,
                /* detectTwoFingerTripleTap= */ true, /* detectShortcutTrigger= */ true);
        goFromStateIdleTo(STATE_IDLE);
        allowEventDelegation();
        tap();
@@ -494,8 +493,8 @@ public class FullScreenMagnificationGestureHandlerTest {
    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
    public void testDisablingSingleFingerTripleTapAndTwoFingerTripleTap_removesInputLag() {
        mMgh = newInstance(/* detectSingleFingerTripleTap */ false,
                /* detectTwoFingerTripleTap */ false, /* detectShortcut */ true);
        mMgh = newInstance(/* detectSingleFingerTripleTap= */ false,
                /* detectTwoFingerTripleTap= */ false, /* detectShortcutTrigger= */ true);
        goFromStateIdleTo(STATE_IDLE);
        allowEventDelegation();
        tap();
@@ -1419,12 +1418,6 @@ public class FullScreenMagnificationGestureHandlerTest {
        mFullScreenMagnificationController.reset(DISPLAY_0, /* animate= */ false);
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void testMouseMoveEventsDoNotMoveMagnifierViewport() {
        runMoveEventsDoNotMoveMagnifierViewport(InputDevice.SOURCE_MOUSE);
    }

    @Test
    public void testStylusMoveEventsDoNotMoveMagnifierViewport() {
        runMoveEventsDoNotMoveMagnifierViewport(InputDevice.SOURCE_STYLUS);
@@ -1441,7 +1434,7 @@ public class FullScreenMagnificationGestureHandlerTest {
                (INITIAL_MAGNIFICATION_BOUNDS.top + INITIAL_MAGNIFICATION_BOUNDS.height()) / 2.0f;
        float scale = 5.6f; // value is unimportant but unique among tests to increase coverage.
        mFullScreenMagnificationController.setScaleAndCenter(
                DISPLAY_0, centerX, centerY, scale, true, /* animate= */ false, 1);
                DISPLAY_0, scale, centerX, centerY, true, /* animate= */ false, 1);
        centerX = mFullScreenMagnificationController.getCenterX(DISPLAY_0);
        centerY = mFullScreenMagnificationController.getCenterY(DISPLAY_0);

@@ -1474,55 +1467,36 @@ public class FullScreenMagnificationGestureHandlerTest {
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void testMouseHoverMoveEventsDoNotMoveMagnifierViewport() {
        runHoverMoveEventsDoNotMoveMagnifierViewport(InputDevice.SOURCE_MOUSE);
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void testStylusHoverMoveEventsDoNotMoveMagnifierViewport() {
        runHoverMoveEventsDoNotMoveMagnifierViewport(InputDevice.SOURCE_STYLUS);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void testMouseHoverMoveEventsMoveMagnifierViewport() {
        runHoverMovesViewportTest(InputDevice.SOURCE_MOUSE);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void testStylusHoverMoveEventsMoveMagnifierViewport() {
        runHoverMovesViewportTest(InputDevice.SOURCE_STYLUS);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void testMouseDownEventsDoNotMoveMagnifierViewport() {
        runDownDoesNotMoveViewportTest(InputDevice.SOURCE_MOUSE);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void testStylusDownEventsDoNotMoveMagnifierViewport() {
        runDownDoesNotMoveViewportTest(InputDevice.SOURCE_STYLUS);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void testMouseUpEventsDoNotMoveMagnifierViewport() {
        runUpDoesNotMoveViewportTest(InputDevice.SOURCE_MOUSE);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void testStylusUpEventsDoNotMoveMagnifierViewport() {
        runUpDoesNotMoveViewportTest(InputDevice.SOURCE_STYLUS);
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void testMouseMoveEventsMoveMagnifierViewport() {
        final EventCaptor eventCaptor = new EventCaptor();
        mMgh.setNext(eventCaptor);
@@ -1533,7 +1507,7 @@ public class FullScreenMagnificationGestureHandlerTest {
                (INITIAL_MAGNIFICATION_BOUNDS.top + INITIAL_MAGNIFICATION_BOUNDS.height()) / 2.0f;
        float scale = 6.2f; // value is unimportant but unique among tests to increase coverage.
        mFullScreenMagnificationController.setScaleAndCenter(
                DISPLAY_0, centerX, centerY, scale, true, /* animate= */ false, 1);
                DISPLAY_0, scale, centerX, centerY, true, /* animate= */ false, 1);
        MotionEvent event = mouseEvent(centerX, centerY, ACTION_HOVER_MOVE);
        send(event, InputDevice.SOURCE_MOUSE);
        fastForward(20);
@@ -1574,7 +1548,7 @@ public class FullScreenMagnificationGestureHandlerTest {
                (INITIAL_MAGNIFICATION_BOUNDS.top + INITIAL_MAGNIFICATION_BOUNDS.height()) / 2.0f;
        float scale = 4.0f; // value is unimportant but unique among tests to increase coverage.
        mFullScreenMagnificationController.setScaleAndCenter(
                DISPLAY_0, centerX, centerY, scale, true, /* animate= */ false, 1);
                DISPLAY_0, scale, centerX, centerY, true, /* animate= */ false, 1);

        // HOVER_MOVE should change magnifier viewport.
        MotionEvent event = motionEvent(centerX + 20, centerY, ACTION_HOVER_MOVE);
@@ -1618,7 +1592,7 @@ public class FullScreenMagnificationGestureHandlerTest {
                (INITIAL_MAGNIFICATION_BOUNDS.top + INITIAL_MAGNIFICATION_BOUNDS.height()) / 2.0f;
        float scale = 5.3f; // value is unimportant but unique among tests to increase coverage.
        mFullScreenMagnificationController.setScaleAndCenter(
                DISPLAY_0, centerX, centerY, scale, true, /* animate= */ false, 1);
                DISPLAY_0, scale, centerX, centerY, true, /* animate= */ false, 1);
        MotionEvent event = motionEvent(centerX, centerY, ACTION_HOVER_MOVE);
        send(event, source);
        fastForward(20);
@@ -1652,7 +1626,7 @@ public class FullScreenMagnificationGestureHandlerTest {
                (INITIAL_MAGNIFICATION_BOUNDS.top + INITIAL_MAGNIFICATION_BOUNDS.height()) / 2.0f;
        float scale = 2.7f; // value is unimportant but unique among tests to increase coverage.
        mFullScreenMagnificationController.setScaleAndCenter(
                DISPLAY_0, centerX, centerY, scale, true, /* animate= */ false, 1);
                DISPLAY_0, scale, centerX, centerY, true, /* animate= */ false, 1);
        MotionEvent event = motionEvent(centerX, centerY, ACTION_HOVER_MOVE);
        send(event, source);
        fastForward(20);
@@ -1688,7 +1662,7 @@ public class FullScreenMagnificationGestureHandlerTest {
                (INITIAL_MAGNIFICATION_BOUNDS.top + INITIAL_MAGNIFICATION_BOUNDS.height()) / 2.0f;
        float scale = 3.8f; // value is unimportant but unique among tests to increase coverage.
        mFullScreenMagnificationController.setScaleAndCenter(
                DISPLAY_0, centerX, centerY, scale, true, /* animate= */ false, 1);
                DISPLAY_0, scale, centerX, centerY, true, /* animate= */ false, 1);
        centerX = mFullScreenMagnificationController.getCenterX(DISPLAY_0);
        centerY = mFullScreenMagnificationController.getCenterY(DISPLAY_0);

@@ -1725,7 +1699,7 @@ public class FullScreenMagnificationGestureHandlerTest {
                (INITIAL_MAGNIFICATION_BOUNDS.top + INITIAL_MAGNIFICATION_BOUNDS.height()) / 2.0f;
        float scale = 4.0f; // value is unimportant but unique among tests to increase coverage.
        mFullScreenMagnificationController.setScaleAndCenter(
                DISPLAY_0, centerX, centerY, scale, true, /* animate= */ false, 1);
                DISPLAY_0, scale, centerX, centerY, true, /* animate= */ false, 1);
        centerX = mFullScreenMagnificationController.getCenterX(DISPLAY_0);
        centerY = mFullScreenMagnificationController.getCenterY(DISPLAY_0);

Loading