Loading core/java/android/accessibilityservice/AccessibilityService.java +29 −0 Original line number Diff line number Diff line Loading @@ -1394,6 +1394,12 @@ public abstract class AccessibilityService extends Service { * {@link AccessibilityService#onServiceConnected()} has not yet been * called) or the service has been disconnected, this method will * return a default value of {@code 1.0f}. * </p> * <p> * <strong>Note:</strong> This legacy API gets the scale of full-screen * magnification. To get the scale of the current controlling magnifier, * use {@link #getMagnificationConfig} instead. * </p> * * @return the current magnification scale */ Loading Loading @@ -1422,6 +1428,12 @@ public abstract class AccessibilityService extends Service { * {@link AccessibilityService#onServiceConnected()} has not yet been * called) or the service has been disconnected, this method will * return a default value of {@code 0.0f}. * </p> * <p> * <strong>Note:</strong> This legacy API gets the center position of full-screen * magnification. To get the magnification center of the current controlling magnifier, * use {@link #getMagnificationConfig} instead. * </p> * * @return the unscaled screen-relative X coordinate of the center of * the magnified region Loading Loading @@ -1451,6 +1463,12 @@ public abstract class AccessibilityService extends Service { * {@link AccessibilityService#onServiceConnected()} has not yet been * called) or the service has been disconnected, this method will * return a default value of {@code 0.0f}. * </p> * <p> * <strong>Note:</strong> This legacy API gets the center position of full-screen * magnification. To get the magnification center of the current controlling magnifier, * use {@link #getMagnificationConfig} instead. * </p> * * @return the unscaled screen-relative Y coordinate of the center of * the magnified region Loading Loading @@ -1571,6 +1589,11 @@ public abstract class AccessibilityService extends Service { * {@link AccessibilityService#onServiceConnected()} has not yet been * called) or the service has been disconnected, this method will have * no effect and return {@code false}. * <p> * <strong>Note:</strong> This legacy API sets the scale of full-screen * magnification. To set the scale of the specified magnifier, * use {@link #setMagnificationConfig} instead. * </p> * * @param scale the magnification scale to set, must be >= 1 and <= 8 * @param animate {@code true} to animate from the current scale or Loading Loading @@ -1602,6 +1625,12 @@ public abstract class AccessibilityService extends Service { * {@link AccessibilityService#onServiceConnected()} has not yet been * called) or the service has been disconnected, this method will have * no effect and return {@code false}. * </p> * <p> * <strong>Note:</strong> This legacy API sets the center of full-screen * magnification. To set the center of the specified magnifier, * use {@link #setMagnificationConfig} instead. * </p> * * @param centerX the unscaled screen-relative X coordinate on which to * center the viewport Loading services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java +3 −3 Original line number Diff line number Diff line Loading @@ -1027,8 +1027,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ mSystemSupport.getMagnificationProcessor(); final long identity = Binder.clearCallingIdentity(); try { magnificationProcessor.getMagnificationRegion(displayId, region, mSecurityPolicy.canControlMagnification(this)); magnificationProcessor.getFullscreenMagnificationRegion(displayId, region, mSecurityPolicy.canControlMagnification(this)); return region; } finally { Binder.restoreCallingIdentity(identity); Loading Loading @@ -1095,7 +1095,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ try { MagnificationProcessor magnificationProcessor = mSystemSupport.getMagnificationProcessor(); return (magnificationProcessor.reset(displayId, animate) return (magnificationProcessor.resetFullscreenMagnification(displayId, animate) || !magnificationProcessor.isMagnifying(displayId)); } finally { Binder.restoreCallingIdentity(identity); Loading services/accessibility/java/com/android/server/accessibility/magnification/MagnificationProcessor.java +49 −72 Original line number Diff line number Diff line Loading @@ -119,6 +119,18 @@ public class MagnificationProcessor { return false; } private boolean setScaleAndCenterForFullScreenMagnification(int displayId, float scale, float centerX, float centerY, boolean animate, int id) { if (!isRegistered(displayId)) { register(displayId); } return mController.getFullScreenMagnificationController().setScaleAndCenter( displayId, scale, centerX, centerY, animate, id); } /** * Returns {@code true} if transition magnification mode needed. And it is no need to transition * mode when the controlling mode is unchanged or the controlling magnifier is not activated. Loading @@ -135,24 +147,18 @@ public class MagnificationProcessor { } /** * Returns the magnification scale. If an animation is in progress, * this reflects the end state of the animation. * Returns the magnification scale of full-screen magnification on the display. * If an animation is in progress, this reflects the end state of the animation. * * @param displayId The logical display id. * @return the scale */ public float getScale(int displayId) { int mode = getControllingMode(displayId); if (mode == MAGNIFICATION_MODE_FULLSCREEN) { return mController.getFullScreenMagnificationController().getScale(displayId); } else if (mode == MAGNIFICATION_MODE_WINDOW) { return mController.getWindowMagnificationMgr().getScale(displayId); } return 0; } /** * Returns the magnification center in X coordinate of the controlling magnification mode. * Returns the magnification center in X coordinate of full-screen magnification. * If the service can control magnification but fullscreen magnifier is not registered, it will * register the magnifier for this call then unregister the magnifier finally to make the * magnification center correct. Loading @@ -162,8 +168,6 @@ public class MagnificationProcessor { * @return the X coordinate */ public float getCenterX(int displayId, boolean canControlMagnification) { int mode = getControllingMode(displayId); if (mode == MAGNIFICATION_MODE_FULLSCREEN) { boolean registeredJustForThisCall = registerDisplayMagnificationIfNeeded(displayId, canControlMagnification); try { Loading @@ -173,14 +177,10 @@ public class MagnificationProcessor { unregister(displayId); } } } else if (mode == MAGNIFICATION_MODE_WINDOW) { return mController.getWindowMagnificationMgr().getCenterX(displayId); } return 0; } /** * Returns the magnification center in Y coordinate of the controlling magnification mode. * Returns the magnification center in Y coordinate of full-screen magnification. * If the service can control magnification but fullscreen magnifier is not registered, it will * register the magnifier for this call then unregister the magnifier finally to make the * magnification center correct. Loading @@ -190,8 +190,6 @@ public class MagnificationProcessor { * @return the Y coordinate */ public float getCenterY(int displayId, boolean canControlMagnification) { int mode = getControllingMode(displayId); if (mode == MAGNIFICATION_MODE_FULLSCREEN) { boolean registeredJustForThisCall = registerDisplayMagnificationIfNeeded(displayId, canControlMagnification); try { Loading @@ -201,38 +199,16 @@ public class MagnificationProcessor { unregister(displayId); } } } else if (mode == MAGNIFICATION_MODE_WINDOW) { return mController.getWindowMagnificationMgr().getCenterY(displayId); } return 0; } /** * Return the magnification bounds of the current controlling magnification on the given * display. If the magnifier is not enabled, it returns an empty region. * If the service can control magnification but fullscreen magnifier is not registered, it will * register the magnifier for this call then unregister the magnifier finally to make * the magnification region correct. * Returns the magnification bounds of full-screen magnification on the given display. * * @param displayId The logical display id * @param outRegion the region to populate * @param canControlMagnification Whether the service can control magnification * @return outRegion the magnification bounds of full-screen magnifier or the magnification * source bounds of window magnifier */ public Region getMagnificationRegion(int displayId, @NonNull Region outRegion, boolean canControlMagnification) { int mode = getControllingMode(displayId); if (mode == MAGNIFICATION_MODE_FULLSCREEN) { getFullscreenMagnificationRegion(displayId, outRegion, canControlMagnification); } else if (mode == MAGNIFICATION_MODE_WINDOW) { mController.getWindowMagnificationMgr().getMagnificationSourceBounds(displayId, outRegion); } return outRegion; } private void getFullscreenMagnificationRegion(int displayId, @NonNull Region outRegion, public void getFullscreenMagnificationRegion(int displayId, @NonNull Region outRegion, boolean canControlMagnification) { boolean registeredJustForThisCall = registerDisplayMagnificationIfNeeded(displayId, canControlMagnification); Loading @@ -246,21 +222,9 @@ public class MagnificationProcessor { } } private boolean setScaleAndCenterForFullScreenMagnification(int displayId, float scale, float centerX, float centerY, boolean animate, int id) { if (!isRegistered(displayId)) { register(displayId); } return mController.getFullScreenMagnificationController().setScaleAndCenter( displayId, scale, centerX, centerY, animate, id); } /** * Resets the magnification on the given display. The reset mode could be full-screen or * window if it is activated. * Resets the current magnification on the given display. The reset mode could be * full-screen or window if it is activated. * * @param displayId The logical display id. * @param animate {@code true} to animate the transition, {@code false} Loading @@ -268,7 +232,7 @@ public class MagnificationProcessor { * @return {@code true} if the magnification spec changed, {@code false} if * the spec did not change */ public boolean reset(int displayId, boolean animate) { public boolean resetCurrentMagnification(int displayId, boolean animate) { int mode = getControllingMode(displayId); if (mode == MAGNIFICATION_MODE_FULLSCREEN) { return mController.getFullScreenMagnificationController().reset(displayId, animate); Loading @@ -278,6 +242,19 @@ public class MagnificationProcessor { return false; } /** * Resets the full-screen magnification on the given display. * * @param displayId The logical display id. * @param animate {@code true} to animate the transition, {@code false} * to transition immediately * @return {@code true} if the magnification spec changed, {@code false} if * the spec did not change */ public boolean resetFullscreenMagnification(int displayId, boolean animate) { return mController.getFullScreenMagnificationController().reset(displayId, animate); } /** * {@link FullScreenMagnificationController#resetIfNeeded(int, boolean)} */ Loading services/tests/servicestests/src/com/android/server/accessibility/AbstractAccessibilityServiceConnectionTest.java +8 −5 Original line number Diff line number Diff line Loading @@ -585,8 +585,8 @@ public class AbstractAccessibilityServiceConnectionTest { doAnswer((invocation) -> { ((Region) invocation.getArguments()[1]).set(region); return null; }).when(mMockMagnificationProcessor).getMagnificationRegion(eq(displayId), any(), anyBoolean()); }).when(mMockMagnificationProcessor).getFullscreenMagnificationRegion(eq(displayId), any(), anyBoolean()); when(mMockSystemSupport.getCurrentUserIdLocked()).thenReturn(USER_ID2); final Region result = mServiceConnection.getMagnificationRegion(displayId); Loading Loading @@ -620,7 +620,8 @@ public class AbstractAccessibilityServiceConnectionTest { @Test public void resetMagnification() { final int displayId = 1; when(mMockMagnificationProcessor.reset(displayId, true)).thenReturn(true); when(mMockMagnificationProcessor.resetFullscreenMagnification(displayId, true)).thenReturn( true); final boolean result = mServiceConnection.resetMagnification(displayId, true); assertThat(result, is(true)); Loading @@ -629,7 +630,8 @@ public class AbstractAccessibilityServiceConnectionTest { @Test public void resetMagnification_cantControlMagnification_returnFalse() { final int displayId = 1; when(mMockMagnificationProcessor.reset(displayId, true)).thenReturn(true); when(mMockMagnificationProcessor.resetFullscreenMagnification(displayId, true)).thenReturn( true); when(mMockSecurityPolicy.canControlMagnification(mServiceConnection)).thenReturn(false); final boolean result = mServiceConnection.resetMagnification(displayId, true); Loading @@ -639,7 +641,8 @@ public class AbstractAccessibilityServiceConnectionTest { @Test public void resetMagnification_serviceNotBelongCurrentUser_returnFalse() { final int displayId = 1; when(mMockMagnificationProcessor.reset(displayId, true)).thenReturn(true); when(mMockMagnificationProcessor.resetFullscreenMagnification(displayId, true)).thenReturn( true); when(mMockSystemSupport.getCurrentUserIdLocked()).thenReturn(USER_ID2); final boolean result = mServiceConnection.resetMagnification(displayId, true); Loading services/tests/servicestests/src/com/android/server/accessibility/MagnificationProcessorTest.java +10 −23 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public class MagnificationProcessorTest { .setScale(TEST_SCALE).build(); setMagnificationActivated(TEST_DISPLAY, config); float scale = mMagnificationProcessor.getScale(TEST_DISPLAY); float scale = mMagnificationProcessor.getMagnificationConfig(TEST_DISPLAY).getScale(); assertEquals(scale, TEST_SCALE, 0); } Loading @@ -117,14 +117,13 @@ public class MagnificationProcessorTest { } @Test public void getCenterX_canControlWindowMagnification_returnCenterX() { public void getCenterX_controlWindowMagnification_returnCenterX() { final MagnificationConfig config = new MagnificationConfig.Builder() .setMode(MAGNIFICATION_MODE_WINDOW) .setCenterX(TEST_CENTER_X).build(); setMagnificationActivated(TEST_DISPLAY, config); float centerX = mMagnificationProcessor.getCenterX( TEST_DISPLAY, /* canControlMagnification= */true); float centerX = mMagnificationProcessor.getMagnificationConfig(TEST_DISPLAY).getCenterX(); assertEquals(centerX, TEST_CENTER_X, 0); } Loading @@ -143,14 +142,13 @@ public class MagnificationProcessorTest { } @Test public void getCenterY_canControlWindowMagnification_returnCenterY() { public void getCenterY_controlWindowMagnification_returnCenterY() { final MagnificationConfig config = new MagnificationConfig.Builder() .setMode(MAGNIFICATION_MODE_WINDOW) .setCenterY(TEST_CENTER_Y).build(); setMagnificationActivated(TEST_DISPLAY, config); float centerY = mMagnificationProcessor.getCenterY( TEST_DISPLAY, /* canControlMagnification= */false); float centerY = mMagnificationProcessor.getMagnificationConfig(TEST_DISPLAY).getCenterY(); assertEquals(centerY, TEST_CENTER_Y, 0); } Loading @@ -159,24 +157,13 @@ public class MagnificationProcessorTest { public void getMagnificationRegion_canControlFullscreenMagnification_returnRegion() { final Region region = new Region(10, 20, 100, 200); setMagnificationActivated(TEST_DISPLAY, MAGNIFICATION_MODE_FULLSCREEN); mMagnificationProcessor.getMagnificationRegion(TEST_DISPLAY, mMagnificationProcessor.getFullscreenMagnificationRegion(TEST_DISPLAY, region, /* canControlMagnification= */true); verify(mMockFullScreenMagnificationController).getMagnificationRegion(eq(TEST_DISPLAY), eq(region)); } @Test public void getMagnificationRegion_canControlWindowMagnification_returnRegion() { final Region region = new Region(10, 20, 100, 200); setMagnificationActivated(TEST_DISPLAY, MAGNIFICATION_MODE_WINDOW); mMagnificationProcessor.getMagnificationRegion(TEST_DISPLAY, region, /* canControlMagnification= */true); verify(mMockWindowMagnificationManager).getMagnificationSourceBounds(eq(TEST_DISPLAY), eq(region)); } @Test public void getMagnificationRegion_fullscreenModeNotRegistered_shouldRegisterThenUnregister() { final Region region = new Region(10, 20, 100, 200); Loading @@ -188,7 +175,7 @@ public class MagnificationProcessorTest { any()); final Region result = new Region(); mMagnificationProcessor.getMagnificationRegion(TEST_DISPLAY, mMagnificationProcessor.getFullscreenMagnificationRegion(TEST_DISPLAY, result, /* canControlMagnification= */true); assertEquals(region, result); verify(mMockFullScreenMagnificationController).register(TEST_DISPLAY); Loading Loading @@ -237,7 +224,7 @@ public class MagnificationProcessorTest { public void reset_fullscreenMagnificationActivated() { setMagnificationActivated(TEST_DISPLAY, MAGNIFICATION_MODE_FULLSCREEN); mMagnificationProcessor.reset(TEST_DISPLAY, /* animate= */false); mMagnificationProcessor.resetFullscreenMagnification(TEST_DISPLAY, /* animate= */false); verify(mMockFullScreenMagnificationController).reset(TEST_DISPLAY, false); } Loading @@ -246,7 +233,7 @@ public class MagnificationProcessorTest { public void reset_windowMagnificationActivated() { setMagnificationActivated(TEST_DISPLAY, MAGNIFICATION_MODE_WINDOW); mMagnificationProcessor.reset(TEST_DISPLAY, /* animate= */false); mMagnificationProcessor.resetCurrentMagnification(TEST_DISPLAY, /* animate= */false); verify(mMockWindowMagnificationManager).reset(TEST_DISPLAY); } Loading Loading
core/java/android/accessibilityservice/AccessibilityService.java +29 −0 Original line number Diff line number Diff line Loading @@ -1394,6 +1394,12 @@ public abstract class AccessibilityService extends Service { * {@link AccessibilityService#onServiceConnected()} has not yet been * called) or the service has been disconnected, this method will * return a default value of {@code 1.0f}. * </p> * <p> * <strong>Note:</strong> This legacy API gets the scale of full-screen * magnification. To get the scale of the current controlling magnifier, * use {@link #getMagnificationConfig} instead. * </p> * * @return the current magnification scale */ Loading Loading @@ -1422,6 +1428,12 @@ public abstract class AccessibilityService extends Service { * {@link AccessibilityService#onServiceConnected()} has not yet been * called) or the service has been disconnected, this method will * return a default value of {@code 0.0f}. * </p> * <p> * <strong>Note:</strong> This legacy API gets the center position of full-screen * magnification. To get the magnification center of the current controlling magnifier, * use {@link #getMagnificationConfig} instead. * </p> * * @return the unscaled screen-relative X coordinate of the center of * the magnified region Loading Loading @@ -1451,6 +1463,12 @@ public abstract class AccessibilityService extends Service { * {@link AccessibilityService#onServiceConnected()} has not yet been * called) or the service has been disconnected, this method will * return a default value of {@code 0.0f}. * </p> * <p> * <strong>Note:</strong> This legacy API gets the center position of full-screen * magnification. To get the magnification center of the current controlling magnifier, * use {@link #getMagnificationConfig} instead. * </p> * * @return the unscaled screen-relative Y coordinate of the center of * the magnified region Loading Loading @@ -1571,6 +1589,11 @@ public abstract class AccessibilityService extends Service { * {@link AccessibilityService#onServiceConnected()} has not yet been * called) or the service has been disconnected, this method will have * no effect and return {@code false}. * <p> * <strong>Note:</strong> This legacy API sets the scale of full-screen * magnification. To set the scale of the specified magnifier, * use {@link #setMagnificationConfig} instead. * </p> * * @param scale the magnification scale to set, must be >= 1 and <= 8 * @param animate {@code true} to animate from the current scale or Loading Loading @@ -1602,6 +1625,12 @@ public abstract class AccessibilityService extends Service { * {@link AccessibilityService#onServiceConnected()} has not yet been * called) or the service has been disconnected, this method will have * no effect and return {@code false}. * </p> * <p> * <strong>Note:</strong> This legacy API sets the center of full-screen * magnification. To set the center of the specified magnifier, * use {@link #setMagnificationConfig} instead. * </p> * * @param centerX the unscaled screen-relative X coordinate on which to * center the viewport Loading
services/accessibility/java/com/android/server/accessibility/AbstractAccessibilityServiceConnection.java +3 −3 Original line number Diff line number Diff line Loading @@ -1027,8 +1027,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ mSystemSupport.getMagnificationProcessor(); final long identity = Binder.clearCallingIdentity(); try { magnificationProcessor.getMagnificationRegion(displayId, region, mSecurityPolicy.canControlMagnification(this)); magnificationProcessor.getFullscreenMagnificationRegion(displayId, region, mSecurityPolicy.canControlMagnification(this)); return region; } finally { Binder.restoreCallingIdentity(identity); Loading Loading @@ -1095,7 +1095,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ try { MagnificationProcessor magnificationProcessor = mSystemSupport.getMagnificationProcessor(); return (magnificationProcessor.reset(displayId, animate) return (magnificationProcessor.resetFullscreenMagnification(displayId, animate) || !magnificationProcessor.isMagnifying(displayId)); } finally { Binder.restoreCallingIdentity(identity); Loading
services/accessibility/java/com/android/server/accessibility/magnification/MagnificationProcessor.java +49 −72 Original line number Diff line number Diff line Loading @@ -119,6 +119,18 @@ public class MagnificationProcessor { return false; } private boolean setScaleAndCenterForFullScreenMagnification(int displayId, float scale, float centerX, float centerY, boolean animate, int id) { if (!isRegistered(displayId)) { register(displayId); } return mController.getFullScreenMagnificationController().setScaleAndCenter( displayId, scale, centerX, centerY, animate, id); } /** * Returns {@code true} if transition magnification mode needed. And it is no need to transition * mode when the controlling mode is unchanged or the controlling magnifier is not activated. Loading @@ -135,24 +147,18 @@ public class MagnificationProcessor { } /** * Returns the magnification scale. If an animation is in progress, * this reflects the end state of the animation. * Returns the magnification scale of full-screen magnification on the display. * If an animation is in progress, this reflects the end state of the animation. * * @param displayId The logical display id. * @return the scale */ public float getScale(int displayId) { int mode = getControllingMode(displayId); if (mode == MAGNIFICATION_MODE_FULLSCREEN) { return mController.getFullScreenMagnificationController().getScale(displayId); } else if (mode == MAGNIFICATION_MODE_WINDOW) { return mController.getWindowMagnificationMgr().getScale(displayId); } return 0; } /** * Returns the magnification center in X coordinate of the controlling magnification mode. * Returns the magnification center in X coordinate of full-screen magnification. * If the service can control magnification but fullscreen magnifier is not registered, it will * register the magnifier for this call then unregister the magnifier finally to make the * magnification center correct. Loading @@ -162,8 +168,6 @@ public class MagnificationProcessor { * @return the X coordinate */ public float getCenterX(int displayId, boolean canControlMagnification) { int mode = getControllingMode(displayId); if (mode == MAGNIFICATION_MODE_FULLSCREEN) { boolean registeredJustForThisCall = registerDisplayMagnificationIfNeeded(displayId, canControlMagnification); try { Loading @@ -173,14 +177,10 @@ public class MagnificationProcessor { unregister(displayId); } } } else if (mode == MAGNIFICATION_MODE_WINDOW) { return mController.getWindowMagnificationMgr().getCenterX(displayId); } return 0; } /** * Returns the magnification center in Y coordinate of the controlling magnification mode. * Returns the magnification center in Y coordinate of full-screen magnification. * If the service can control magnification but fullscreen magnifier is not registered, it will * register the magnifier for this call then unregister the magnifier finally to make the * magnification center correct. Loading @@ -190,8 +190,6 @@ public class MagnificationProcessor { * @return the Y coordinate */ public float getCenterY(int displayId, boolean canControlMagnification) { int mode = getControllingMode(displayId); if (mode == MAGNIFICATION_MODE_FULLSCREEN) { boolean registeredJustForThisCall = registerDisplayMagnificationIfNeeded(displayId, canControlMagnification); try { Loading @@ -201,38 +199,16 @@ public class MagnificationProcessor { unregister(displayId); } } } else if (mode == MAGNIFICATION_MODE_WINDOW) { return mController.getWindowMagnificationMgr().getCenterY(displayId); } return 0; } /** * Return the magnification bounds of the current controlling magnification on the given * display. If the magnifier is not enabled, it returns an empty region. * If the service can control magnification but fullscreen magnifier is not registered, it will * register the magnifier for this call then unregister the magnifier finally to make * the magnification region correct. * Returns the magnification bounds of full-screen magnification on the given display. * * @param displayId The logical display id * @param outRegion the region to populate * @param canControlMagnification Whether the service can control magnification * @return outRegion the magnification bounds of full-screen magnifier or the magnification * source bounds of window magnifier */ public Region getMagnificationRegion(int displayId, @NonNull Region outRegion, boolean canControlMagnification) { int mode = getControllingMode(displayId); if (mode == MAGNIFICATION_MODE_FULLSCREEN) { getFullscreenMagnificationRegion(displayId, outRegion, canControlMagnification); } else if (mode == MAGNIFICATION_MODE_WINDOW) { mController.getWindowMagnificationMgr().getMagnificationSourceBounds(displayId, outRegion); } return outRegion; } private void getFullscreenMagnificationRegion(int displayId, @NonNull Region outRegion, public void getFullscreenMagnificationRegion(int displayId, @NonNull Region outRegion, boolean canControlMagnification) { boolean registeredJustForThisCall = registerDisplayMagnificationIfNeeded(displayId, canControlMagnification); Loading @@ -246,21 +222,9 @@ public class MagnificationProcessor { } } private boolean setScaleAndCenterForFullScreenMagnification(int displayId, float scale, float centerX, float centerY, boolean animate, int id) { if (!isRegistered(displayId)) { register(displayId); } return mController.getFullScreenMagnificationController().setScaleAndCenter( displayId, scale, centerX, centerY, animate, id); } /** * Resets the magnification on the given display. The reset mode could be full-screen or * window if it is activated. * Resets the current magnification on the given display. The reset mode could be * full-screen or window if it is activated. * * @param displayId The logical display id. * @param animate {@code true} to animate the transition, {@code false} Loading @@ -268,7 +232,7 @@ public class MagnificationProcessor { * @return {@code true} if the magnification spec changed, {@code false} if * the spec did not change */ public boolean reset(int displayId, boolean animate) { public boolean resetCurrentMagnification(int displayId, boolean animate) { int mode = getControllingMode(displayId); if (mode == MAGNIFICATION_MODE_FULLSCREEN) { return mController.getFullScreenMagnificationController().reset(displayId, animate); Loading @@ -278,6 +242,19 @@ public class MagnificationProcessor { return false; } /** * Resets the full-screen magnification on the given display. * * @param displayId The logical display id. * @param animate {@code true} to animate the transition, {@code false} * to transition immediately * @return {@code true} if the magnification spec changed, {@code false} if * the spec did not change */ public boolean resetFullscreenMagnification(int displayId, boolean animate) { return mController.getFullScreenMagnificationController().reset(displayId, animate); } /** * {@link FullScreenMagnificationController#resetIfNeeded(int, boolean)} */ Loading
services/tests/servicestests/src/com/android/server/accessibility/AbstractAccessibilityServiceConnectionTest.java +8 −5 Original line number Diff line number Diff line Loading @@ -585,8 +585,8 @@ public class AbstractAccessibilityServiceConnectionTest { doAnswer((invocation) -> { ((Region) invocation.getArguments()[1]).set(region); return null; }).when(mMockMagnificationProcessor).getMagnificationRegion(eq(displayId), any(), anyBoolean()); }).when(mMockMagnificationProcessor).getFullscreenMagnificationRegion(eq(displayId), any(), anyBoolean()); when(mMockSystemSupport.getCurrentUserIdLocked()).thenReturn(USER_ID2); final Region result = mServiceConnection.getMagnificationRegion(displayId); Loading Loading @@ -620,7 +620,8 @@ public class AbstractAccessibilityServiceConnectionTest { @Test public void resetMagnification() { final int displayId = 1; when(mMockMagnificationProcessor.reset(displayId, true)).thenReturn(true); when(mMockMagnificationProcessor.resetFullscreenMagnification(displayId, true)).thenReturn( true); final boolean result = mServiceConnection.resetMagnification(displayId, true); assertThat(result, is(true)); Loading @@ -629,7 +630,8 @@ public class AbstractAccessibilityServiceConnectionTest { @Test public void resetMagnification_cantControlMagnification_returnFalse() { final int displayId = 1; when(mMockMagnificationProcessor.reset(displayId, true)).thenReturn(true); when(mMockMagnificationProcessor.resetFullscreenMagnification(displayId, true)).thenReturn( true); when(mMockSecurityPolicy.canControlMagnification(mServiceConnection)).thenReturn(false); final boolean result = mServiceConnection.resetMagnification(displayId, true); Loading @@ -639,7 +641,8 @@ public class AbstractAccessibilityServiceConnectionTest { @Test public void resetMagnification_serviceNotBelongCurrentUser_returnFalse() { final int displayId = 1; when(mMockMagnificationProcessor.reset(displayId, true)).thenReturn(true); when(mMockMagnificationProcessor.resetFullscreenMagnification(displayId, true)).thenReturn( true); when(mMockSystemSupport.getCurrentUserIdLocked()).thenReturn(USER_ID2); final boolean result = mServiceConnection.resetMagnification(displayId, true); Loading
services/tests/servicestests/src/com/android/server/accessibility/MagnificationProcessorTest.java +10 −23 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public class MagnificationProcessorTest { .setScale(TEST_SCALE).build(); setMagnificationActivated(TEST_DISPLAY, config); float scale = mMagnificationProcessor.getScale(TEST_DISPLAY); float scale = mMagnificationProcessor.getMagnificationConfig(TEST_DISPLAY).getScale(); assertEquals(scale, TEST_SCALE, 0); } Loading @@ -117,14 +117,13 @@ public class MagnificationProcessorTest { } @Test public void getCenterX_canControlWindowMagnification_returnCenterX() { public void getCenterX_controlWindowMagnification_returnCenterX() { final MagnificationConfig config = new MagnificationConfig.Builder() .setMode(MAGNIFICATION_MODE_WINDOW) .setCenterX(TEST_CENTER_X).build(); setMagnificationActivated(TEST_DISPLAY, config); float centerX = mMagnificationProcessor.getCenterX( TEST_DISPLAY, /* canControlMagnification= */true); float centerX = mMagnificationProcessor.getMagnificationConfig(TEST_DISPLAY).getCenterX(); assertEquals(centerX, TEST_CENTER_X, 0); } Loading @@ -143,14 +142,13 @@ public class MagnificationProcessorTest { } @Test public void getCenterY_canControlWindowMagnification_returnCenterY() { public void getCenterY_controlWindowMagnification_returnCenterY() { final MagnificationConfig config = new MagnificationConfig.Builder() .setMode(MAGNIFICATION_MODE_WINDOW) .setCenterY(TEST_CENTER_Y).build(); setMagnificationActivated(TEST_DISPLAY, config); float centerY = mMagnificationProcessor.getCenterY( TEST_DISPLAY, /* canControlMagnification= */false); float centerY = mMagnificationProcessor.getMagnificationConfig(TEST_DISPLAY).getCenterY(); assertEquals(centerY, TEST_CENTER_Y, 0); } Loading @@ -159,24 +157,13 @@ public class MagnificationProcessorTest { public void getMagnificationRegion_canControlFullscreenMagnification_returnRegion() { final Region region = new Region(10, 20, 100, 200); setMagnificationActivated(TEST_DISPLAY, MAGNIFICATION_MODE_FULLSCREEN); mMagnificationProcessor.getMagnificationRegion(TEST_DISPLAY, mMagnificationProcessor.getFullscreenMagnificationRegion(TEST_DISPLAY, region, /* canControlMagnification= */true); verify(mMockFullScreenMagnificationController).getMagnificationRegion(eq(TEST_DISPLAY), eq(region)); } @Test public void getMagnificationRegion_canControlWindowMagnification_returnRegion() { final Region region = new Region(10, 20, 100, 200); setMagnificationActivated(TEST_DISPLAY, MAGNIFICATION_MODE_WINDOW); mMagnificationProcessor.getMagnificationRegion(TEST_DISPLAY, region, /* canControlMagnification= */true); verify(mMockWindowMagnificationManager).getMagnificationSourceBounds(eq(TEST_DISPLAY), eq(region)); } @Test public void getMagnificationRegion_fullscreenModeNotRegistered_shouldRegisterThenUnregister() { final Region region = new Region(10, 20, 100, 200); Loading @@ -188,7 +175,7 @@ public class MagnificationProcessorTest { any()); final Region result = new Region(); mMagnificationProcessor.getMagnificationRegion(TEST_DISPLAY, mMagnificationProcessor.getFullscreenMagnificationRegion(TEST_DISPLAY, result, /* canControlMagnification= */true); assertEquals(region, result); verify(mMockFullScreenMagnificationController).register(TEST_DISPLAY); Loading Loading @@ -237,7 +224,7 @@ public class MagnificationProcessorTest { public void reset_fullscreenMagnificationActivated() { setMagnificationActivated(TEST_DISPLAY, MAGNIFICATION_MODE_FULLSCREEN); mMagnificationProcessor.reset(TEST_DISPLAY, /* animate= */false); mMagnificationProcessor.resetFullscreenMagnification(TEST_DISPLAY, /* animate= */false); verify(mMockFullScreenMagnificationController).reset(TEST_DISPLAY, false); } Loading @@ -246,7 +233,7 @@ public class MagnificationProcessorTest { public void reset_windowMagnificationActivated() { setMagnificationActivated(TEST_DISPLAY, MAGNIFICATION_MODE_WINDOW); mMagnificationProcessor.reset(TEST_DISPLAY, /* animate= */false); mMagnificationProcessor.resetCurrentMagnification(TEST_DISPLAY, /* animate= */false); verify(mMockWindowMagnificationManager).reset(TEST_DISPLAY); } Loading