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

Commit eb467b99 authored by mincheli's avatar mincheli
Browse files

Also regarded as magnification activated when it is forced to show magnification bounds

When fullscreen magnification is showing initially, it would force to
show magnification bounds but not not be magnifying first.
Then a user has to perform one tap to make the magnifier scaling.
For this case, we also think that it is magnification activated when the
magnification bounds are showing but not magnifying.

Bug: 181597348
Test: atest MagnificationControllerTest;atest FullScreenMagnificationControllerTest
Change-Id: I90b34cc25aca636d4ac84f6627d1a674faecbb1c
parent 93501a33
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@ public class FullScreenMagnificationController {
        private boolean mUnregisterPending;
        private boolean mDeleteAfterUnregister;

        private boolean mForceShowMagnifiableBounds;

        private final int mDisplayId;

        private static final int INVALID_ID = -1;
@@ -420,11 +422,17 @@ public class FullScreenMagnificationController {
        @GuardedBy("mLock")
        void setForceShowMagnifiableBounds(boolean show) {
            if (mRegistered) {
                mForceShowMagnifiableBounds = show;
                mControllerCtx.getWindowManager().setForceShowMagnifiableBounds(
                        mDisplayId, show);
            }
        }

        @GuardedBy("mLock")
        boolean isForceShowMagnifiableBounds() {
            return mRegistered && mForceShowMagnifiableBounds;
        }

        @GuardedBy("mLock")
        boolean reset(boolean animate) {
            return reset(transformToStubCallback(animate));
@@ -442,6 +450,7 @@ public class FullScreenMagnificationController {
                onMagnificationChangedLocked();
            }
            mIdOfLastServiceToMagnify = INVALID_ID;
            mForceShowMagnifiableBounds = false;
            sendSpecToAnimation(spec, animationCallback);
            return changed;
        }
@@ -1158,6 +1167,21 @@ public class FullScreenMagnificationController {
        }
    }

    /**
     * Returns {@code true} if the magnifiable regions of the display is forced to be shown.
     *
     * @param displayId The logical display id.
     */
    public boolean isForceShowMagnifiableBounds(int displayId) {
        synchronized (mLock) {
            final DisplayMagnification display = mDisplays.get(displayId);
            if (display == null) {
                return false;
            }
            return display.isForceShowMagnifiableBounds();
        }
    }

    private void onScreenTurnedOff() {
        final Message m = PooledLambda.obtainMessage(
                FullScreenMagnificationController::resetAllIfNeeded, this, false);
+2 −1
Original line number Diff line number Diff line
@@ -358,7 +358,8 @@ public class MagnificationController implements WindowMagnificationManager.Callb
        boolean isActivated = false;
        if (mode == ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN
                && mFullScreenMagnificationController != null) {
            isActivated = mFullScreenMagnificationController.isMagnifying(displayId);
            isActivated = mFullScreenMagnificationController.isMagnifying(displayId)
                    || mFullScreenMagnificationController.isForceShowMagnifiableBounds(displayId);
        } else if (mode == ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW
                && mWindowMagnificationMgr != null) {
            isActivated = mWindowMagnificationMgr.isWindowMagnifierEnabled(displayId);
+22 −9
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import java.util.Locale;
@@ -1114,6 +1113,23 @@ public class FullScreenMagnificationControllerTest {
                argThat(closeTo(newEndSpec)));
    }

    @Test
    public void testSetForceShowMagnifiableBounds() {
        register(DISPLAY_0);

        mFullScreenMagnificationController.setForceShowMagnifiableBounds(DISPLAY_0, true);

        verify(mMockWindowManager).setForceShowMagnifiableBounds(DISPLAY_0, true);
    }

    @Test
    public void testIsForceShowMagnifiableBounds() {
        register(DISPLAY_0);
        mFullScreenMagnificationController.setForceShowMagnifiableBounds(DISPLAY_0, true);

        assertTrue(mFullScreenMagnificationController.isForceShowMagnifiableBounds(DISPLAY_0));
    }

    @Test
    public void testSetScale_toMagnifying_shouldNotifyActivatedState() {
        setScaleToMagnifying();
@@ -1142,14 +1158,11 @@ public class FullScreenMagnificationControllerTest {
        for (int i = 0; i < DISPLAY_COUNT; i++) {
            when(mMockWindowManager.setMagnificationCallbacks(eq(i), any())).thenReturn(true);
        }
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
        doAnswer((Answer<Void>) invocationOnMock -> {
            Object[] args = invocationOnMock.getArguments();
            Region regionArg = (Region) args[1];
            regionArg.set(INITIAL_MAGNIFICATION_REGION);
            return null;
            }
        }).when(mMockWindowManager).getMagnificationRegion(anyInt(), (Region) anyObject());
    }

+15 −0
Original line number Diff line number Diff line
@@ -365,6 +365,19 @@ public class MagnificationControllerTest {
                eq(MODE_FULLSCREEN));
    }


    @Test
    public void onTouchInteractionChanged_fullscreenNotActivated_notShowMagnificationButton()
            throws RemoteException {
        setMagnificationModeSettings(MODE_FULLSCREEN);

        mMagnificationController.onTouchInteractionStart(TEST_DISPLAY, MODE_FULLSCREEN);
        mMagnificationController.onTouchInteractionEnd(TEST_DISPLAY, MODE_FULLSCREEN);

        verify(mWindowMagnificationManager, never()).showMagnificationButton(eq(TEST_DISPLAY),
                eq(MODE_FULLSCREEN));
    }

    @Test
    public void onShortcutTriggered_windowModeEnabledAndCapabilitiesAll_showMagnificationButton()
            throws RemoteException {
@@ -450,6 +463,8 @@ public class MagnificationControllerTest {
        }
        if (mode == MODE_FULLSCREEN) {
            when(mScreenMagnificationController.isMagnifying(TEST_DISPLAY)).thenReturn(true);
            when(mScreenMagnificationController.isForceShowMagnifiableBounds(
                    TEST_DISPLAY)).thenReturn(true);
            when(mScreenMagnificationController.getPersistedScale()).thenReturn(DEFAULT_SCALE);
            when(mScreenMagnificationController.getScale(TEST_DISPLAY)).thenReturn(DEFAULT_SCALE);
            when(mScreenMagnificationController.getCenterX(TEST_DISPLAY)).thenReturn(