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

Commit baaac5fa authored by Hongyu Long's avatar Hongyu Long
Browse files

a11y: add zoomInFullScreenMagnification method in MagnificationController

* This CL addresses the scenario where the key gesture first time
  confirmation dialog is shown for Magnification. When the dialog pops
up, we should perform the zoom in action with persisted scale.
* This CL adds a method in MagnificationController to activate the
  fullscreen magnification and zoom in with persisted scale.

Bug: b/425722546
Flag:com.android.hardware.input.enable_magnify_magnification_key_gesture_dialog
Test: manual & atest MagnificationControllerTest,
MagnificationConnectionManagerTest

Change-Id: I8e19da5622591a8b8bc3fe35d4acb38ae04b422f
parent 0e63fbbb
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -478,6 +478,24 @@ public class MagnificationController implements MagnificationConnectionManager.C
                || getMagnificationConnectionManager().isWindowMagnifierEnabled(displayId);
    }

    /**
     * Perform the action to activate the fullscreen magnification and zoom in with persisted scale.
     *
     * @param displayId The logical display id
     */
    public void zoomInFullScreenMagnification(int displayId) {
        final float scale = mFullScreenMagnificationController.getPersistedScale(displayId);
        mFullScreenMagnificationController.setScaleAndCenter(
                displayId,
                scale,
                Float.NaN,
                Float.NaN,
                /* animate= */ true,
                AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID);

        // TODO: b/440359677 - Rename the method and add zoom in for window magnification.
    }

    private void maybeContinuePan() {
        if (mActivePanDisplay == Display.INVALID_DISPLAY) {
            return;
+19 −1
Original line number Diff line number Diff line
@@ -36,8 +36,8 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.floatThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.floatThat;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doAnswer;
@@ -2472,6 +2472,24 @@ public class MagnificationControllerTest {
                .onFullscreenMagnificationActivationChanged(TEST_DISPLAY, /* activated= */ true);
    }

    @Test
    public void zoomInFullScreenMagnification_setsPersistedScale() throws RemoteException {
        final float persistedScale = mScreenMagnificationController.getPersistedScale(TEST_DISPLAY);

        // Perform the zoom-in action
        mMagnificationController.zoomInFullScreenMagnification(TEST_DISPLAY);

        // Verify that the scale is set to the persisted value
        verify(mScreenMagnificationController)
                .setScaleAndCenter(
                        eq(TEST_DISPLAY),
                        eq(persistedScale),
                        eq(Float.NaN),
                        eq(Float.NaN),
                        /* animate= */ eq(true),
                        eq(AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID));
    }

    private void setMagnificationEnabled(int mode) throws RemoteException {
        setMagnificationEnabled(mode, MAGNIFIED_CENTER_X, MAGNIFIED_CENTER_Y);
    }