Loading services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +12 −2 Original line number Diff line number Diff line Loading @@ -1363,8 +1363,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub * </p> * * @param displayId The logical display id * @param region the new magnified region, may be empty if * magnification is not enabled (e.g. scale is 1) * @param region The magnification region. * If the config mode is * {@link MagnificationConfig#MAGNIFICATION_MODE_FULLSCREEN}, * it is the region of the screen currently active for magnification. * the returned region will be empty if the magnification is not active * (e.g. scale is 1. And the magnification is active if magnification * gestures are enabled or if a service is running that can control * magnification. * If the config mode is * {@link MagnificationConfig#MAGNIFICATION_MODE_WINDOW}, * it is the region of screen projected on the magnification window. * The region will be empty if magnification is not activated. * @param config The magnification config. That has magnification mode, the new scale and the * new screen-relative center position */ Loading services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationController.java +18 −18 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.function.pooled.PooledLambda; import com.android.server.LocalServices; import com.android.server.accessibility.AccessibilityManagerService; import com.android.server.accessibility.AccessibilityTraceManager; import com.android.server.wm.WindowManagerInternal; Loading Loading @@ -374,9 +373,8 @@ public class FullScreenMagnificationController implements .setScale(getScale()) .setCenterX(getCenterX()) .setCenterY(getCenterY()).build(); mControllerCtx.getAms().notifyMagnificationChanged(mDisplayId, mMagnificationRegion, config); mMagnificationInfoChangedCallback.onFullScreenMagnificationChanged(mDisplayId, mMagnificationRegion, config); if (mUnregisterPending && !isMagnifying()) { unregister(mDeleteAfterUnregister); } Loading Loading @@ -665,10 +663,10 @@ public class FullScreenMagnificationController implements * FullScreenMagnificationController Constructor */ public FullScreenMagnificationController(@NonNull Context context, @NonNull AccessibilityManagerService ams, @NonNull Object lock, @NonNull AccessibilityTraceManager traceManager, @NonNull Object lock, @NonNull MagnificationInfoChangedCallback magnificationInfoChangedCallback, @NonNull MagnificationScaleProvider scaleProvider) { this(new ControllerContext(context, ams, this(new ControllerContext(context, traceManager, LocalServices.getService(WindowManagerInternal.class), new Handler(context.getMainLooper()), context.getResources().getInteger(R.integer.config_longAnimTime)), lock, Loading Loading @@ -1521,7 +1519,6 @@ public class FullScreenMagnificationController implements @VisibleForTesting public static class ControllerContext { private final Context mContext; private final AccessibilityManagerService mAms; private final AccessibilityTraceManager mTrace; private final WindowManagerInternal mWindowManager; private final Handler mHandler; Loading @@ -1531,13 +1528,12 @@ public class FullScreenMagnificationController implements * Constructor for ControllerContext. */ public ControllerContext(@NonNull Context context, @NonNull AccessibilityManagerService ams, @NonNull AccessibilityTraceManager traceManager, @NonNull WindowManagerInternal windowManager, @NonNull Handler handler, long animationDuration) { mContext = context; mAms = ams; mTrace = ams.getTraceManager(); mTrace = traceManager; mWindowManager = windowManager; mHandler = handler; mAnimationDuration = animationDuration; Loading @@ -1551,14 +1547,6 @@ public class FullScreenMagnificationController implements return mContext; } /** * @return AccessibilityManagerService */ @NonNull public AccessibilityManagerService getAms() { return mAms; } /** * @return AccessibilityTraceManager */ Loading Loading @@ -1632,5 +1620,17 @@ public class FullScreenMagnificationController implements * hidden. */ void onImeWindowVisibilityChanged(boolean shown); /** * Called when the magnification spec changed. * * @param displayId The logical display id * @param region The region of the screen currently active for magnification. * The returned region will be empty if the magnification is not active. * @param config The magnification config. That has magnification mode, the new scale and * the new screen-relative center position */ void onFullScreenMagnificationChanged(int displayId, @NonNull Region region, @NonNull MagnificationConfig config); } } services/accessibility/java/com/android/server/accessibility/magnification/MagnificationController.java +7 −1 Original line number Diff line number Diff line Loading @@ -405,6 +405,12 @@ public class MagnificationController implements WindowMagnificationManager.Callb mAms.notifyMagnificationChanged(displayId, new Region(bounds), config); } @Override public void onFullScreenMagnificationChanged(int displayId, @NonNull Region region, @NonNull MagnificationConfig config) { mAms.notifyMagnificationChanged(displayId, region, config); } private void disableFullScreenMagnificationIfNeeded(int displayId) { final FullScreenMagnificationController fullScreenMagnificationController = getFullScreenMagnificationController(); Loading Loading @@ -590,7 +596,7 @@ public class MagnificationController implements WindowMagnificationManager.Callb synchronized (mLock) { if (mFullScreenMagnificationController == null) { mFullScreenMagnificationController = new FullScreenMagnificationController(mContext, mAms, mLock, this, mScaleProvider); mAms.getTraceManager(), mLock, this, mScaleProvider); } } return mFullScreenMagnificationController; Loading services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationControllerTest.java +10 −14 Original line number Diff line number Diff line Loading @@ -52,7 +52,6 @@ import android.view.accessibility.MagnificationAnimationCallback; import androidx.test.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; import com.android.server.accessibility.AccessibilityManagerService; import com.android.server.accessibility.AccessibilityTraceManager; import com.android.server.accessibility.test.MessageCapturingHandler; import com.android.server.wm.WindowManagerInternal; Loading Loading @@ -94,7 +93,6 @@ public class FullScreenMagnificationControllerTest { final FullScreenMagnificationController.ControllerContext mMockControllerCtx = mock(FullScreenMagnificationController.ControllerContext.class); final Context mMockContext = mock(Context.class); final AccessibilityManagerService mMockAms = mock(AccessibilityManagerService.class); final AccessibilityTraceManager mMockTraceManager = mock(AccessibilityTraceManager.class); final WindowManagerInternal mMockWindowManager = mock(WindowManagerInternal.class); private final MagnificationAnimationCallback mAnimationCallback = mock( Loading @@ -121,12 +119,10 @@ public class FullScreenMagnificationControllerTest { // Pretending ID of the Thread associated with looper as main thread ID in controller when(mMockContext.getMainLooper()).thenReturn(looper); when(mMockControllerCtx.getContext()).thenReturn(mMockContext); when(mMockControllerCtx.getAms()).thenReturn(mMockAms); when(mMockControllerCtx.getTraceManager()).thenReturn(mMockTraceManager); when(mMockControllerCtx.getWindowManager()).thenReturn(mMockWindowManager); when(mMockControllerCtx.getHandler()).thenReturn(mMessageCapturingHandler); when(mMockControllerCtx.getAnimationDuration()).thenReturn(1000L); when(mMockAms.getTraceManager()).thenReturn(mMockTraceManager); initMockWindowManager(); mFullScreenMagnificationController = new FullScreenMagnificationController( Loading Loading @@ -357,8 +353,8 @@ public class FullScreenMagnificationControllerTest { assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5); assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.5); assertThat(getCurrentMagnificationSpec(displayId), closeTo(endSpec)); verify(mMockAms).notifyMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture()); verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture()); assertConfigEquals(config, mConfigCaptor.getValue()); verify(mMockValueAnimator).start(); verify(mRequestObserver).onRequestMagnificationSpec(displayId, SERVICE_ID_1); Loading Loading @@ -501,7 +497,7 @@ public class FullScreenMagnificationControllerTest { mMessageCapturingHandler.sendAllMessages(); MagnificationConfig config = buildConfig(1.0f, OTHER_MAGNIFICATION_BOUNDS.centerX(), OTHER_MAGNIFICATION_BOUNDS.centerY()); verify(mMockAms).notifyMagnificationChanged(eq(displayId), eq(OTHER_REGION), verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId), eq(OTHER_REGION), mConfigCaptor.capture()); assertConfigEquals(config, mConfigCaptor.getValue()); } Loading Loading @@ -655,9 +651,9 @@ public class FullScreenMagnificationControllerTest { register(displayId); zoomIn2xToMiddle(displayId); mMessageCapturingHandler.sendAllMessages(); reset(mMockAms); reset(mRequestObserver); assertTrue(mFullScreenMagnificationController.resetIfNeeded(displayId, false)); verify(mMockAms).notifyMagnificationChanged(eq(displayId), verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), any(MagnificationConfig.class)); assertFalse(mFullScreenMagnificationController.isMagnifying(displayId)); assertFalse(mFullScreenMagnificationController.resetIfNeeded(displayId, false)); Loading @@ -676,8 +672,8 @@ public class FullScreenMagnificationControllerTest { assertFalse(mFullScreenMagnificationController.reset(displayId, mAnimationCallback)); mMessageCapturingHandler.sendAllMessages(); verify(mMockAms, never()).notifyMagnificationChanged(eq(displayId), any(Region.class), any(MagnificationConfig.class)); verify(mRequestObserver, never()).onFullScreenMagnificationChanged(eq(displayId), any(Region.class), any(MagnificationConfig.class)); verify(mAnimationCallback).onResult(true); } Loading Loading @@ -1072,8 +1068,8 @@ public class FullScreenMagnificationControllerTest { when(mMockValueAnimator.getAnimatedFraction()).thenReturn(0.0f); mTargetAnimationListener.onAnimationUpdate(mMockValueAnimator); verify(mMockWindowManager).setMagnificationSpec(eq(displayId), eq(startSpec)); verify(mMockAms).notifyMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture()); verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture()); assertConfigEquals(config, mConfigCaptor.getValue()); Mockito.reset(mMockWindowManager); Loading @@ -1097,7 +1093,7 @@ public class FullScreenMagnificationControllerTest { // Animation should have been restarted verify(mMockValueAnimator, times(2)).start(); verify(mMockAms, times(2)).notifyMagnificationChanged(eq(displayId), verify(mRequestObserver, times(2)).onFullScreenMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture()); assertConfigEquals(newConfig, mConfigCaptor.getValue()); Loading services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandlerTest.java +0 −2 Original line number Diff line number Diff line Loading @@ -151,8 +151,6 @@ public class FullScreenMagnificationGestureHandlerTest { mock(FullScreenMagnificationController.ControllerContext.class); final WindowManagerInternal mockWindowManager = mock(WindowManagerInternal.class); when(mockController.getContext()).thenReturn(mContext); when(mockController.getAms()).thenReturn(mMockAccessibilityManagerService); when(mMockAccessibilityManagerService.getTraceManager()).thenReturn(mMockTraceManager); when(mockController.getTraceManager()).thenReturn(mMockTraceManager); when(mockController.getWindowManager()).thenReturn(mockWindowManager); when(mockController.getHandler()).thenReturn(new Handler(mContext.getMainLooper())); Loading Loading
services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +12 −2 Original line number Diff line number Diff line Loading @@ -1363,8 +1363,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub * </p> * * @param displayId The logical display id * @param region the new magnified region, may be empty if * magnification is not enabled (e.g. scale is 1) * @param region The magnification region. * If the config mode is * {@link MagnificationConfig#MAGNIFICATION_MODE_FULLSCREEN}, * it is the region of the screen currently active for magnification. * the returned region will be empty if the magnification is not active * (e.g. scale is 1. And the magnification is active if magnification * gestures are enabled or if a service is running that can control * magnification. * If the config mode is * {@link MagnificationConfig#MAGNIFICATION_MODE_WINDOW}, * it is the region of screen projected on the magnification window. * The region will be empty if magnification is not activated. * @param config The magnification config. That has magnification mode, the new scale and the * new screen-relative center position */ Loading
services/accessibility/java/com/android/server/accessibility/magnification/FullScreenMagnificationController.java +18 −18 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.function.pooled.PooledLambda; import com.android.server.LocalServices; import com.android.server.accessibility.AccessibilityManagerService; import com.android.server.accessibility.AccessibilityTraceManager; import com.android.server.wm.WindowManagerInternal; Loading Loading @@ -374,9 +373,8 @@ public class FullScreenMagnificationController implements .setScale(getScale()) .setCenterX(getCenterX()) .setCenterY(getCenterY()).build(); mControllerCtx.getAms().notifyMagnificationChanged(mDisplayId, mMagnificationRegion, config); mMagnificationInfoChangedCallback.onFullScreenMagnificationChanged(mDisplayId, mMagnificationRegion, config); if (mUnregisterPending && !isMagnifying()) { unregister(mDeleteAfterUnregister); } Loading Loading @@ -665,10 +663,10 @@ public class FullScreenMagnificationController implements * FullScreenMagnificationController Constructor */ public FullScreenMagnificationController(@NonNull Context context, @NonNull AccessibilityManagerService ams, @NonNull Object lock, @NonNull AccessibilityTraceManager traceManager, @NonNull Object lock, @NonNull MagnificationInfoChangedCallback magnificationInfoChangedCallback, @NonNull MagnificationScaleProvider scaleProvider) { this(new ControllerContext(context, ams, this(new ControllerContext(context, traceManager, LocalServices.getService(WindowManagerInternal.class), new Handler(context.getMainLooper()), context.getResources().getInteger(R.integer.config_longAnimTime)), lock, Loading Loading @@ -1521,7 +1519,6 @@ public class FullScreenMagnificationController implements @VisibleForTesting public static class ControllerContext { private final Context mContext; private final AccessibilityManagerService mAms; private final AccessibilityTraceManager mTrace; private final WindowManagerInternal mWindowManager; private final Handler mHandler; Loading @@ -1531,13 +1528,12 @@ public class FullScreenMagnificationController implements * Constructor for ControllerContext. */ public ControllerContext(@NonNull Context context, @NonNull AccessibilityManagerService ams, @NonNull AccessibilityTraceManager traceManager, @NonNull WindowManagerInternal windowManager, @NonNull Handler handler, long animationDuration) { mContext = context; mAms = ams; mTrace = ams.getTraceManager(); mTrace = traceManager; mWindowManager = windowManager; mHandler = handler; mAnimationDuration = animationDuration; Loading @@ -1551,14 +1547,6 @@ public class FullScreenMagnificationController implements return mContext; } /** * @return AccessibilityManagerService */ @NonNull public AccessibilityManagerService getAms() { return mAms; } /** * @return AccessibilityTraceManager */ Loading Loading @@ -1632,5 +1620,17 @@ public class FullScreenMagnificationController implements * hidden. */ void onImeWindowVisibilityChanged(boolean shown); /** * Called when the magnification spec changed. * * @param displayId The logical display id * @param region The region of the screen currently active for magnification. * The returned region will be empty if the magnification is not active. * @param config The magnification config. That has magnification mode, the new scale and * the new screen-relative center position */ void onFullScreenMagnificationChanged(int displayId, @NonNull Region region, @NonNull MagnificationConfig config); } }
services/accessibility/java/com/android/server/accessibility/magnification/MagnificationController.java +7 −1 Original line number Diff line number Diff line Loading @@ -405,6 +405,12 @@ public class MagnificationController implements WindowMagnificationManager.Callb mAms.notifyMagnificationChanged(displayId, new Region(bounds), config); } @Override public void onFullScreenMagnificationChanged(int displayId, @NonNull Region region, @NonNull MagnificationConfig config) { mAms.notifyMagnificationChanged(displayId, region, config); } private void disableFullScreenMagnificationIfNeeded(int displayId) { final FullScreenMagnificationController fullScreenMagnificationController = getFullScreenMagnificationController(); Loading Loading @@ -590,7 +596,7 @@ public class MagnificationController implements WindowMagnificationManager.Callb synchronized (mLock) { if (mFullScreenMagnificationController == null) { mFullScreenMagnificationController = new FullScreenMagnificationController(mContext, mAms, mLock, this, mScaleProvider); mAms.getTraceManager(), mLock, this, mScaleProvider); } } return mFullScreenMagnificationController; Loading
services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationControllerTest.java +10 −14 Original line number Diff line number Diff line Loading @@ -52,7 +52,6 @@ import android.view.accessibility.MagnificationAnimationCallback; import androidx.test.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; import com.android.server.accessibility.AccessibilityManagerService; import com.android.server.accessibility.AccessibilityTraceManager; import com.android.server.accessibility.test.MessageCapturingHandler; import com.android.server.wm.WindowManagerInternal; Loading Loading @@ -94,7 +93,6 @@ public class FullScreenMagnificationControllerTest { final FullScreenMagnificationController.ControllerContext mMockControllerCtx = mock(FullScreenMagnificationController.ControllerContext.class); final Context mMockContext = mock(Context.class); final AccessibilityManagerService mMockAms = mock(AccessibilityManagerService.class); final AccessibilityTraceManager mMockTraceManager = mock(AccessibilityTraceManager.class); final WindowManagerInternal mMockWindowManager = mock(WindowManagerInternal.class); private final MagnificationAnimationCallback mAnimationCallback = mock( Loading @@ -121,12 +119,10 @@ public class FullScreenMagnificationControllerTest { // Pretending ID of the Thread associated with looper as main thread ID in controller when(mMockContext.getMainLooper()).thenReturn(looper); when(mMockControllerCtx.getContext()).thenReturn(mMockContext); when(mMockControllerCtx.getAms()).thenReturn(mMockAms); when(mMockControllerCtx.getTraceManager()).thenReturn(mMockTraceManager); when(mMockControllerCtx.getWindowManager()).thenReturn(mMockWindowManager); when(mMockControllerCtx.getHandler()).thenReturn(mMessageCapturingHandler); when(mMockControllerCtx.getAnimationDuration()).thenReturn(1000L); when(mMockAms.getTraceManager()).thenReturn(mMockTraceManager); initMockWindowManager(); mFullScreenMagnificationController = new FullScreenMagnificationController( Loading Loading @@ -357,8 +353,8 @@ public class FullScreenMagnificationControllerTest { assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5); assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.5); assertThat(getCurrentMagnificationSpec(displayId), closeTo(endSpec)); verify(mMockAms).notifyMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture()); verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture()); assertConfigEquals(config, mConfigCaptor.getValue()); verify(mMockValueAnimator).start(); verify(mRequestObserver).onRequestMagnificationSpec(displayId, SERVICE_ID_1); Loading Loading @@ -501,7 +497,7 @@ public class FullScreenMagnificationControllerTest { mMessageCapturingHandler.sendAllMessages(); MagnificationConfig config = buildConfig(1.0f, OTHER_MAGNIFICATION_BOUNDS.centerX(), OTHER_MAGNIFICATION_BOUNDS.centerY()); verify(mMockAms).notifyMagnificationChanged(eq(displayId), eq(OTHER_REGION), verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId), eq(OTHER_REGION), mConfigCaptor.capture()); assertConfigEquals(config, mConfigCaptor.getValue()); } Loading Loading @@ -655,9 +651,9 @@ public class FullScreenMagnificationControllerTest { register(displayId); zoomIn2xToMiddle(displayId); mMessageCapturingHandler.sendAllMessages(); reset(mMockAms); reset(mRequestObserver); assertTrue(mFullScreenMagnificationController.resetIfNeeded(displayId, false)); verify(mMockAms).notifyMagnificationChanged(eq(displayId), verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), any(MagnificationConfig.class)); assertFalse(mFullScreenMagnificationController.isMagnifying(displayId)); assertFalse(mFullScreenMagnificationController.resetIfNeeded(displayId, false)); Loading @@ -676,8 +672,8 @@ public class FullScreenMagnificationControllerTest { assertFalse(mFullScreenMagnificationController.reset(displayId, mAnimationCallback)); mMessageCapturingHandler.sendAllMessages(); verify(mMockAms, never()).notifyMagnificationChanged(eq(displayId), any(Region.class), any(MagnificationConfig.class)); verify(mRequestObserver, never()).onFullScreenMagnificationChanged(eq(displayId), any(Region.class), any(MagnificationConfig.class)); verify(mAnimationCallback).onResult(true); } Loading Loading @@ -1072,8 +1068,8 @@ public class FullScreenMagnificationControllerTest { when(mMockValueAnimator.getAnimatedFraction()).thenReturn(0.0f); mTargetAnimationListener.onAnimationUpdate(mMockValueAnimator); verify(mMockWindowManager).setMagnificationSpec(eq(displayId), eq(startSpec)); verify(mMockAms).notifyMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture()); verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture()); assertConfigEquals(config, mConfigCaptor.getValue()); Mockito.reset(mMockWindowManager); Loading @@ -1097,7 +1093,7 @@ public class FullScreenMagnificationControllerTest { // Animation should have been restarted verify(mMockValueAnimator, times(2)).start(); verify(mMockAms, times(2)).notifyMagnificationChanged(eq(displayId), verify(mRequestObserver, times(2)).onFullScreenMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture()); assertConfigEquals(newConfig, mConfigCaptor.getValue()); Loading
services/tests/servicestests/src/com/android/server/accessibility/magnification/FullScreenMagnificationGestureHandlerTest.java +0 −2 Original line number Diff line number Diff line Loading @@ -151,8 +151,6 @@ public class FullScreenMagnificationGestureHandlerTest { mock(FullScreenMagnificationController.ControllerContext.class); final WindowManagerInternal mockWindowManager = mock(WindowManagerInternal.class); when(mockController.getContext()).thenReturn(mContext); when(mockController.getAms()).thenReturn(mMockAccessibilityManagerService); when(mMockAccessibilityManagerService.getTraceManager()).thenReturn(mMockTraceManager); when(mockController.getTraceManager()).thenReturn(mMockTraceManager); when(mockController.getWindowManager()).thenReturn(mockWindowManager); when(mockController.getHandler()).thenReturn(new Handler(mContext.getMainLooper())); Loading