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

Commit 9e795d82 authored by Jackal Guo's avatar Jackal Guo Committed by Android (Google) Code Review
Browse files

Merge "Magnification isn't reset when service is disabled"

parents 7f766434 1418a6b0
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();
    }

@@ -257,9 +258,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;