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

Commit 1418a6b0 authored by Jackal Guo's avatar Jackal Guo
Browse files

Magnification isn't reset when service is disabled

If the disabled service is the last service to magnify, reset the
magnification.

Bug: 28623059
Test: manual
Test: atest CtsAccessibilityTestCases
Test: atest CtsAccessibilityServiceTestCases
Test: testResetIfNeeded_resetsOnlyIfLastMagnifyingServiceIsDisabled
Change-Id: I6b12a5251b5fede8d2c9eb06048bf9fa4bd70f8b
parent 6eac8af6
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect
        UserState userState = mUserStateWeakReference.get();
        if (userState == null) return;
        userState.removeServiceLocked(this);
        mSystemSupport.getMagnificationController().resetIfNeeded(mId);
        resetLocked();
    }

@@ -263,9 +264,7 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect
            if (userState != null) {
                userState.serviceDisconnectedLocked(this);
            }
            if (mId == mSystemSupport.getMagnificationController().getIdOfLastServiceToMagnify()) {
                mSystemSupport.getMagnificationController().resetIfNeeded(true);
            }
            mSystemSupport.getMagnificationController().resetIfNeeded(mId);
            mSystemSupport.onClientChange(false);
        }
    }
+13 −0
Original line number Diff line number Diff line
@@ -722,6 +722,19 @@ public class MagnificationController implements Handler.Callback {
        }
    }

    /**
     * Resets magnification if last magnifying service is disabled.
     *
     * @param connectionId the connection ID be disabled.
     * @return {@code true} on success, {@code false} on failure
     */
    boolean resetIfNeeded(int connectionId) {
        if (mIdOfLastServiceToMagnify == connectionId) {
            return resetIfNeeded(true /*animate*/);
        }
        return false;
    }

    void setForceShowMagnifiableBounds(boolean show) {
        if (mRegistered) {
            mWindowManager.setForceShowMagnifiableBounds(show);
+3 −0
Original line number Diff line number Diff line
@@ -247,6 +247,9 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation {
        if (mScreenStateReceiver != null) {
            mScreenStateReceiver.unregister();
        }
        // Check if need to reset when MagnificationGestureHandler is the last magnifying service.
        mMagnificationController.resetIfNeeded(
                AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID);
        clearAndTransitionToStateDetecting();
    }

+14 −0
Original line number Diff line number Diff line
@@ -452,6 +452,20 @@ public class MagnificationControllerTest {
        assertEquals(SERVICE_ID_2, mMagnificationController.getIdOfLastServiceToMagnify());
    }

    @Test
    public void testResetIfNeeded_resetsOnlyIfLastMagnifyingServiceIsDisabled() {
        mMagnificationController.register();
        PointF startCenter = INITIAL_MAGNIFICATION_BOUNDS_CENTER;
        mMagnificationController
                .setScale(2.0f, startCenter.x, startCenter.y, false, SERVICE_ID_1);
        mMagnificationController
                .setScale(1.5f, startCenter.x, startCenter.y, false, SERVICE_ID_2);
        assertFalse(mMagnificationController.resetIfNeeded(SERVICE_ID_1));
        assertTrue(mMagnificationController.isMagnifying());
        assertTrue(mMagnificationController.resetIfNeeded(SERVICE_ID_2));
        assertFalse(mMagnificationController.isMagnifying());
    }

    @Test
    public void testSetUserId_resetsOnlyIfIdChanges() {
        final int userId1 = 1;