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

Commit 425e2a21 authored by Hiroki Sato's avatar Hiroki Sato
Browse files

Cealnup released enable_magnification_follows_mouse_bugfix

This is already released.
We also plan to have a new implementation, so before starting a new
work, let's clean this up.

Bug: 354696546
Test: FullScreenMagnificationGestureHandlerTest
Test: MagnificationGestureHandlerTest
Flag: EXEMPT removing com.android.server.accessibility.enable_magnification_follows_mouse_bugfix
Change-Id: I40ddbde78c1a8c1b15a8a29ee3d15784c116dbd8
parent 17c5df85
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"
+8 −10
Original line number Diff line number Diff line
@@ -340,16 +340,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 +1169,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);
                }
            }
+0 −25
Original line number Diff line number Diff line
@@ -1419,12 +1419,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);
@@ -1474,55 +1468,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);
+0 −37
Original line number Diff line number Diff line
@@ -21,15 +21,11 @@ import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_HOVER_MOVE;
import static android.view.MotionEvent.ACTION_UP;

import static junit.framework.Assert.assertFalse;

import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.testng.AssertJUnit.assertTrue;

import android.annotation.NonNull;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.Settings;
@@ -39,7 +35,6 @@ import android.view.MotionEvent;
import androidx.test.runner.AndroidJUnit4;

import com.android.server.accessibility.AccessibilityTraceManager;
import com.android.server.accessibility.Flags;

import org.junit.Before;
import org.junit.Rule;
@@ -93,7 +88,6 @@ public class MagnificationGestureHandlerTest {
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void onMotionEvent_isFromMouse_handleMouseOrStylusEvent() {
        final MotionEvent mouseEvent = MotionEvent.obtain(0, 0, ACTION_HOVER_MOVE, 0, 0, 0);
        mouseEvent.setSource(InputDevice.SOURCE_MOUSE);
@@ -108,7 +102,6 @@ public class MagnificationGestureHandlerTest {
    }

    @Test
    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void onMotionEvent_isFromStylus_handleMouseOrStylusEvent() {
        final MotionEvent stylusEvent = MotionEvent.obtain(0, 0, ACTION_HOVER_MOVE, 0, 0, 0);
        stylusEvent.setSource(InputDevice.SOURCE_STYLUS);
@@ -122,36 +115,6 @@ public class MagnificationGestureHandlerTest {
        }
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void onMotionEvent_isFromMouse_handleMouseOrStylusEventNotCalled() {
        final MotionEvent mouseEvent = MotionEvent.obtain(0, 0, ACTION_HOVER_MOVE, 0, 0, 0);
        mouseEvent.setSource(InputDevice.SOURCE_MOUSE);

        mMgh.onMotionEvent(mouseEvent, mouseEvent, /* policyFlags= */ 0);

        try {
            assertFalse(mMgh.mIsHandleMouseOrStylusEventCalled);
        } finally {
            mouseEvent.recycle();
        }
    }

    @Test
    @RequiresFlagsDisabled(Flags.FLAG_ENABLE_MAGNIFICATION_FOLLOWS_MOUSE_BUGFIX)
    public void onMotionEvent_isFromStylus_handleMouseOrStylusEventNotCalled() {
        final MotionEvent stylusEvent = MotionEvent.obtain(0, 0, ACTION_HOVER_MOVE, 0, 0, 0);
        stylusEvent.setSource(InputDevice.SOURCE_STYLUS);

        mMgh.onMotionEvent(stylusEvent, stylusEvent, /* policyFlags= */ 0);

        try {
            assertFalse(mMgh.mIsHandleMouseOrStylusEventCalled);
        } finally {
            stylusEvent.recycle();
        }
    }

    @Test
    public void onMotionEvent_downEvent_handleInteractionStart() {
        final MotionEvent downEvent = MotionEvent.obtain(0, 0, ACTION_DOWN, 0, 0, 0);