Rename and move classses
Rename MagnificationController and move the classess about magnification to magnification package. Test: FullScreenMagnificationGestureHandlerTest MagnificationControllerTest.java AbstractAccessibilityServiceConnectionTest Bug: 160557771 Change-Id: I8d1e4fced6874e7dcac13dd5e9fafc6279b4ac34
This commit is contained in:
@@ -79,6 +79,7 @@ import com.android.internal.util.DumpUtils;
|
||||
import com.android.internal.util.function.pooled.PooledLambda;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.accessibility.AccessibilityWindowManager.RemoteAccessibilityConnection;
|
||||
import com.android.server.accessibility.magnification.FullScreenMagnificationController;
|
||||
import com.android.server.wm.ActivityTaskManagerInternal;
|
||||
import com.android.server.wm.WindowManagerInternal;
|
||||
|
||||
@@ -205,7 +206,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
/**
|
||||
* @return The magnification controller
|
||||
*/
|
||||
@NonNull MagnificationController getMagnificationController();
|
||||
@NonNull
|
||||
FullScreenMagnificationController getFullScreenMagnificationController();
|
||||
|
||||
/**
|
||||
* Called back to notify system that the client has changed
|
||||
@@ -830,7 +832,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
}
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return mSystemSupport.getMagnificationController().getScale(displayId);
|
||||
return mSystemSupport.getFullScreenMagnificationController().getScale(displayId);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
@@ -843,8 +845,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
if (!hasRightsToCurrentUserLocked()) {
|
||||
return region;
|
||||
}
|
||||
MagnificationController magnificationController =
|
||||
mSystemSupport.getMagnificationController();
|
||||
FullScreenMagnificationController magnificationController =
|
||||
mSystemSupport.getFullScreenMagnificationController();
|
||||
boolean registeredJustForThisCall =
|
||||
registerMagnificationIfNeeded(displayId, magnificationController);
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
@@ -866,8 +868,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
if (!hasRightsToCurrentUserLocked()) {
|
||||
return 0.0f;
|
||||
}
|
||||
MagnificationController magnificationController =
|
||||
mSystemSupport.getMagnificationController();
|
||||
FullScreenMagnificationController magnificationController =
|
||||
mSystemSupport.getFullScreenMagnificationController();
|
||||
boolean registeredJustForThisCall =
|
||||
registerMagnificationIfNeeded(displayId, magnificationController);
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
@@ -888,8 +890,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
if (!hasRightsToCurrentUserLocked()) {
|
||||
return 0.0f;
|
||||
}
|
||||
MagnificationController magnificationController =
|
||||
mSystemSupport.getMagnificationController();
|
||||
FullScreenMagnificationController magnificationController =
|
||||
mSystemSupport.getFullScreenMagnificationController();
|
||||
boolean registeredJustForThisCall =
|
||||
registerMagnificationIfNeeded(displayId, magnificationController);
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
@@ -905,7 +907,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
}
|
||||
|
||||
private boolean registerMagnificationIfNeeded(int displayId,
|
||||
MagnificationController magnificationController) {
|
||||
FullScreenMagnificationController magnificationController) {
|
||||
if (!magnificationController.isRegistered(displayId)
|
||||
&& mSecurityPolicy.canControlMagnification(this)) {
|
||||
magnificationController.register(displayId);
|
||||
@@ -926,8 +928,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
}
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
MagnificationController magnificationController =
|
||||
mSystemSupport.getMagnificationController();
|
||||
FullScreenMagnificationController magnificationController =
|
||||
mSystemSupport.getFullScreenMagnificationController();
|
||||
return (magnificationController.reset(displayId, animate)
|
||||
|| !magnificationController.isMagnifying(displayId));
|
||||
} finally {
|
||||
@@ -947,8 +949,8 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
}
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
MagnificationController magnificationController =
|
||||
mSystemSupport.getMagnificationController();
|
||||
FullScreenMagnificationController magnificationController =
|
||||
mSystemSupport.getFullScreenMagnificationController();
|
||||
if (!magnificationController.isRegistered(displayId)) {
|
||||
magnificationController.register(displayId);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.accessibility.gestures.TouchExplorer;
|
||||
import com.android.server.accessibility.magnification.FullScreenMagnificationGestureHandler;
|
||||
import com.android.server.accessibility.magnification.MagnificationGestureHandler;
|
||||
import com.android.server.accessibility.magnification.WindowMagnificationGestureHandler;
|
||||
import com.android.server.policy.WindowManagerPolicy;
|
||||
@@ -539,7 +540,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
||||
detectControlGestures, triggerable, displayId);
|
||||
} else {
|
||||
magnificationGestureHandler = new FullScreenMagnificationGestureHandler(displayContext,
|
||||
mAms.getMagnificationController(), mAms::onMagnificationScaleChanged,
|
||||
mAms.getFullScreenMagnificationController(), mAms::onMagnificationScaleChanged,
|
||||
detectControlGestures, triggerable, displayId);
|
||||
}
|
||||
return magnificationGestureHandler;
|
||||
|
||||
@@ -116,6 +116,7 @@ import com.android.internal.util.DumpUtils;
|
||||
import com.android.internal.util.IntPair;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.accessibility.magnification.FullScreenMagnificationController;
|
||||
import com.android.server.accessibility.magnification.MagnificationGestureHandler;
|
||||
import com.android.server.accessibility.magnification.WindowMagnificationManager;
|
||||
import com.android.server.wm.ActivityTaskManagerInternal;
|
||||
@@ -212,7 +213,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
// Lazily initialized - access through getSystemActionPerfomer()
|
||||
private SystemActionPerformer mSystemActionPerformer;
|
||||
|
||||
private MagnificationController mMagnificationController;
|
||||
private FullScreenMagnificationController mFullScreenMagnificationController;
|
||||
|
||||
private InteractionBridge mInteractionBridge;
|
||||
|
||||
@@ -2191,13 +2192,13 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
return;
|
||||
}
|
||||
|
||||
if (mMagnificationController != null) {
|
||||
mMagnificationController.setUserId(userState.mUserId);
|
||||
if (mFullScreenMagnificationController != null) {
|
||||
mFullScreenMagnificationController.setUserId(userState.mUserId);
|
||||
}
|
||||
|
||||
if (mUiAutomationManager.suppressingAccessibilityServicesLocked()
|
||||
&& mMagnificationController != null) {
|
||||
mMagnificationController.unregisterAll();
|
||||
&& mFullScreenMagnificationController != null) {
|
||||
mFullScreenMagnificationController.unregisterAll();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2209,7 +2210,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
|| userState.isShortcutMagnificationEnabledLocked()) {
|
||||
for (int i = 0; i < displays.size(); i++) {
|
||||
final Display display = displays.get(i);
|
||||
getMagnificationController().register(display.getDisplayId());
|
||||
getFullScreenMagnificationController().register(display.getDisplayId());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -2219,9 +2220,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
final Display display = displays.get(i);
|
||||
final int displayId = display.getDisplayId();
|
||||
if (userHasListeningMagnificationServicesLocked(userState, displayId)) {
|
||||
getMagnificationController().register(displayId);
|
||||
} else if (mMagnificationController != null) {
|
||||
mMagnificationController.unregister(displayId);
|
||||
getFullScreenMagnificationController().register(displayId);
|
||||
} else if (mFullScreenMagnificationController != null) {
|
||||
mFullScreenMagnificationController.unregister(displayId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2568,7 +2569,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
}
|
||||
// In case user assigned magnification to the given shortcut.
|
||||
if (targetName.equals(MAGNIFICATION_CONTROLLER_NAME)) {
|
||||
final boolean enabled = !getMagnificationController().isMagnifying(displayId);
|
||||
final boolean enabled = !getFullScreenMagnificationController().isMagnifying(displayId);
|
||||
logAccessibilityShortcutActivated(MAGNIFICATION_COMPONENT_NAME, shortcutType, enabled);
|
||||
sendAccessibilityButtonToInputFilter(displayId);
|
||||
return;
|
||||
@@ -2928,13 +2929,14 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagnificationController getMagnificationController() {
|
||||
public FullScreenMagnificationController getFullScreenMagnificationController() {
|
||||
synchronized (mLock) {
|
||||
if (mMagnificationController == null) {
|
||||
mMagnificationController = new MagnificationController(mContext, this, mLock);
|
||||
mMagnificationController.setUserId(mCurrentUserId);
|
||||
if (mFullScreenMagnificationController == null) {
|
||||
mFullScreenMagnificationController = new FullScreenMagnificationController(mContext,
|
||||
this, mLock);
|
||||
mFullScreenMagnificationController.setUserId(mCurrentUserId);
|
||||
}
|
||||
return mMagnificationController;
|
||||
return mFullScreenMagnificationController;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3126,8 +3128,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mMagnificationController != null) {
|
||||
mMagnificationController.onDisplayRemoved(displayId);
|
||||
if (mFullScreenMagnificationController != null) {
|
||||
mFullScreenMagnificationController.onDisplayRemoved(displayId);
|
||||
}
|
||||
mA11yWindowManager.stopTrackingWindows(displayId);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect
|
||||
AccessibilityUserState userState = mUserStateWeakReference.get();
|
||||
if (userState == null) return;
|
||||
userState.removeServiceLocked(this);
|
||||
mSystemSupport.getMagnificationController().resetAllIfNeeded(mId);
|
||||
mSystemSupport.getFullScreenMagnificationController().resetAllIfNeeded(mId);
|
||||
mActivityTaskManagerService.setAllowAppSwitches(mComponentName.flattenToString(), -1,
|
||||
userState.mUserId);
|
||||
resetLocked();
|
||||
@@ -312,7 +312,7 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect
|
||||
userState.serviceDisconnectedLocked(this);
|
||||
}
|
||||
resetLocked();
|
||||
mSystemSupport.getMagnificationController().resetAllIfNeeded(mId);
|
||||
mSystemSupport.getFullScreenMagnificationController().resetAllIfNeeded(mId);
|
||||
mSystemSupport.onClientChangeLocked(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.accessibility;
|
||||
package com.android.server.accessibility.magnification;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.NonNull;
|
||||
@@ -42,6 +42,7 @@ 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.wm.WindowManagerInternal;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -56,9 +57,9 @@ import java.util.Locale;
|
||||
* magnification region. If a value is out of bounds, it will be adjusted to guarantee these
|
||||
* constraints.
|
||||
*/
|
||||
public class MagnificationController {
|
||||
public class FullScreenMagnificationController {
|
||||
private static final boolean DEBUG = false;
|
||||
private static final String LOG_TAG = "MagnificationController";
|
||||
private static final String LOG_TAG = "FullScreenMagnificationController";
|
||||
|
||||
public static final float MIN_SCALE = 1.0f;
|
||||
public static final float MAX_SCALE = 8.0f;
|
||||
@@ -140,11 +141,12 @@ public class MagnificationController {
|
||||
|
||||
/**
|
||||
* Unregisters magnification callback from window manager. Callbacks to
|
||||
* {@link MagnificationController#unregisterCallbackLocked(int, boolean)} after
|
||||
* {@link FullScreenMagnificationController#unregisterCallbackLocked(int, boolean)} after
|
||||
* unregistered.
|
||||
*
|
||||
* @param delete true if this instance should be removed from the SparseArray in
|
||||
* MagnificationController after unregistered, for example, display removed.
|
||||
* FullScreenMagnificationController after unregistered, for example,
|
||||
* display removed.
|
||||
*/
|
||||
@GuardedBy("mLock")
|
||||
void unregister(boolean delete) {
|
||||
@@ -164,7 +166,8 @@ public class MagnificationController {
|
||||
* called after animation finished.
|
||||
*
|
||||
* @param delete true if this instance should be removed from the SparseArray in
|
||||
* MagnificationController after unregistered, for example, display removed.
|
||||
* FullScreenMagnificationController after unregistered, for example,
|
||||
* display removed.
|
||||
*/
|
||||
@GuardedBy("mLock")
|
||||
void unregisterPending(boolean delete) {
|
||||
@@ -257,15 +260,17 @@ public class MagnificationController {
|
||||
@Override
|
||||
public void onRotationChanged(int rotation) {
|
||||
// Treat as context change and reset
|
||||
final Message m = PooledLambda.obtainMessage(MagnificationController::resetIfNeeded,
|
||||
MagnificationController.this, mDisplayId, true);
|
||||
final Message m = PooledLambda.obtainMessage(
|
||||
FullScreenMagnificationController::resetIfNeeded,
|
||||
FullScreenMagnificationController.this, mDisplayId, true);
|
||||
mControllerCtx.getHandler().sendMessage(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserContextChanged() {
|
||||
final Message m = PooledLambda.obtainMessage(MagnificationController::resetIfNeeded,
|
||||
MagnificationController.this, mDisplayId, true);
|
||||
final Message m = PooledLambda.obtainMessage(
|
||||
FullScreenMagnificationController::resetIfNeeded,
|
||||
FullScreenMagnificationController.this, mDisplayId, true);
|
||||
mControllerCtx.getHandler().sendMessage(m);
|
||||
}
|
||||
|
||||
@@ -554,25 +559,25 @@ public class MagnificationController {
|
||||
float getMinOffsetXLocked() {
|
||||
final float viewportWidth = mMagnificationBounds.width();
|
||||
final float viewportLeft = mMagnificationBounds.left;
|
||||
return (viewportLeft + viewportWidth) -
|
||||
(viewportLeft + viewportWidth) * mCurrentMagnificationSpec.scale;
|
||||
return (viewportLeft + viewportWidth)
|
||||
- (viewportLeft + viewportWidth) * mCurrentMagnificationSpec.scale;
|
||||
}
|
||||
|
||||
float getMaxOffsetXLocked() {
|
||||
return mMagnificationBounds.left -
|
||||
mMagnificationBounds.left * mCurrentMagnificationSpec.scale;
|
||||
return mMagnificationBounds.left
|
||||
- mMagnificationBounds.left * mCurrentMagnificationSpec.scale;
|
||||
}
|
||||
|
||||
float getMinOffsetYLocked() {
|
||||
final float viewportHeight = mMagnificationBounds.height();
|
||||
final float viewportTop = mMagnificationBounds.top;
|
||||
return (viewportTop + viewportHeight) -
|
||||
(viewportTop + viewportHeight) * mCurrentMagnificationSpec.scale;
|
||||
return (viewportTop + viewportHeight)
|
||||
- (viewportTop + viewportHeight) * mCurrentMagnificationSpec.scale;
|
||||
}
|
||||
|
||||
float getMaxOffsetYLocked() {
|
||||
return mMagnificationBounds.top -
|
||||
mMagnificationBounds.top * mCurrentMagnificationSpec.scale;
|
||||
return mMagnificationBounds.top
|
||||
- mMagnificationBounds.top * mCurrentMagnificationSpec.scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -590,9 +595,9 @@ public class MagnificationController {
|
||||
}
|
||||
|
||||
/**
|
||||
* MagnificationController Constructor
|
||||
* FullScreenMagnificationController Constructor
|
||||
*/
|
||||
public MagnificationController(@NonNull Context context,
|
||||
public FullScreenMagnificationController(@NonNull Context context,
|
||||
@NonNull AccessibilityManagerService ams, @NonNull Object lock) {
|
||||
this(new ControllerContext(context, ams,
|
||||
LocalServices.getService(WindowManagerInternal.class),
|
||||
@@ -604,7 +609,7 @@ public class MagnificationController {
|
||||
* Constructor for tests
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public MagnificationController(@NonNull ControllerContext ctx, @NonNull Object lock) {
|
||||
public FullScreenMagnificationController(@NonNull ControllerContext ctx, @NonNull Object lock) {
|
||||
mControllerCtx = ctx;
|
||||
mLock = lock;
|
||||
mMainThreadId = mControllerCtx.getContext().getMainLooper().getThread().getId();
|
||||
@@ -1088,7 +1093,7 @@ public class MagnificationController {
|
||||
|
||||
private void onScreenTurnedOff() {
|
||||
final Message m = PooledLambda.obtainMessage(
|
||||
MagnificationController::resetAllIfNeeded, this, false);
|
||||
FullScreenMagnificationController::resetAllIfNeeded, this, false);
|
||||
mControllerCtx.getHandler().sendMessage(m);
|
||||
}
|
||||
|
||||
@@ -1253,14 +1258,14 @@ public class MagnificationController {
|
||||
synchronized (mLock) {
|
||||
if (mEnabled) {
|
||||
float fract = animation.getAnimatedFraction();
|
||||
mTmpMagnificationSpec.scale = mStartMagnificationSpec.scale +
|
||||
(mEndMagnificationSpec.scale - mStartMagnificationSpec.scale) * fract;
|
||||
mTmpMagnificationSpec.offsetX = mStartMagnificationSpec.offsetX +
|
||||
(mEndMagnificationSpec.offsetX - mStartMagnificationSpec.offsetX)
|
||||
* fract;
|
||||
mTmpMagnificationSpec.offsetY = mStartMagnificationSpec.offsetY +
|
||||
(mEndMagnificationSpec.offsetY - mStartMagnificationSpec.offsetY)
|
||||
* fract;
|
||||
mTmpMagnificationSpec.scale = mStartMagnificationSpec.scale
|
||||
+ (mEndMagnificationSpec.scale - mStartMagnificationSpec.scale) * fract;
|
||||
mTmpMagnificationSpec.offsetX = mStartMagnificationSpec.offsetX
|
||||
+ (mEndMagnificationSpec.offsetX - mStartMagnificationSpec.offsetX)
|
||||
* fract;
|
||||
mTmpMagnificationSpec.offsetY = mStartMagnificationSpec.offsetY
|
||||
+ (mEndMagnificationSpec.offsetY - mStartMagnificationSpec.offsetY)
|
||||
* fract;
|
||||
setMagnificationSpecLocked(mTmpMagnificationSpec);
|
||||
}
|
||||
}
|
||||
@@ -1269,10 +1274,10 @@ public class MagnificationController {
|
||||
|
||||
private static class ScreenStateObserver extends BroadcastReceiver {
|
||||
private final Context mContext;
|
||||
private final MagnificationController mController;
|
||||
private final FullScreenMagnificationController mController;
|
||||
private boolean mRegistered = false;
|
||||
|
||||
public ScreenStateObserver(Context context, MagnificationController controller) {
|
||||
ScreenStateObserver(Context context, FullScreenMagnificationController controller) {
|
||||
mContext = context;
|
||||
mController = controller;
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.accessibility;
|
||||
package com.android.server.accessibility.magnification;
|
||||
|
||||
import static android.view.InputDevice.SOURCE_TOUCHSCREEN;
|
||||
import static android.view.MotionEvent.ACTION_CANCEL;
|
||||
@@ -59,8 +59,8 @@ import android.view.ViewConfiguration;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.server.accessibility.AccessibilityManagerService;
|
||||
import com.android.server.accessibility.gestures.GestureUtils;
|
||||
import com.android.server.accessibility.magnification.MagnificationGestureHandler;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Queue;
|
||||
@@ -114,7 +114,7 @@ import java.util.Queue;
|
||||
* 7. The magnification scale will be persisted in settings and in the cloud.
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler {
|
||||
public class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler {
|
||||
private static final String LOG_TAG = "FullScreenMagnificationGestureHandler";
|
||||
|
||||
private static final boolean DEBUG_ALL = false;
|
||||
@@ -127,9 +127,9 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
// to AccessibilityService.MagnificationController#setScale() has
|
||||
// different scale range
|
||||
private static final float MIN_SCALE = 2.0f;
|
||||
private static final float MAX_SCALE = MagnificationController.MAX_SCALE;
|
||||
private static final float MAX_SCALE = FullScreenMagnificationController.MAX_SCALE;
|
||||
|
||||
@VisibleForTesting final MagnificationController mMagnificationController;
|
||||
@VisibleForTesting final FullScreenMagnificationController mFullScreenMagnificationController;
|
||||
|
||||
@VisibleForTesting final DelegatingState mDelegatingState;
|
||||
@VisibleForTesting final DetectingState mDetectingState;
|
||||
@@ -163,7 +163,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
|
||||
/**
|
||||
* @param context Context for resolving various magnification-related resources
|
||||
* @param magnificationController the {@link MagnificationController}
|
||||
* @param fullScreenMagnificationController the {@link FullScreenMagnificationController}
|
||||
*
|
||||
* @param detectTripleTap {@code true} if this detector should detect and respond to triple-tap
|
||||
* gestures for engaging and disengaging magnification,
|
||||
@@ -173,8 +173,8 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
* {@code false} if it should ignore such triggers.
|
||||
* @param displayId The logical display id.
|
||||
*/
|
||||
FullScreenMagnificationGestureHandler(Context context,
|
||||
MagnificationController magnificationController,
|
||||
public FullScreenMagnificationGestureHandler(Context context,
|
||||
FullScreenMagnificationController fullScreenMagnificationController,
|
||||
MagnificationGestureHandler.ScaleChangedListener listener,
|
||||
boolean detectTripleTap,
|
||||
boolean detectShortcutTrigger,
|
||||
@@ -185,7 +185,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
"FullScreenMagnificationGestureHandler(detectTripleTap = " + detectTripleTap
|
||||
+ ", detectShortcutTrigger = " + detectShortcutTrigger + ")");
|
||||
}
|
||||
mMagnificationController = magnificationController;
|
||||
mFullScreenMagnificationController = fullScreenMagnificationController;
|
||||
mDisplayId = displayId;
|
||||
|
||||
mDelegatingState = new DelegatingState();
|
||||
@@ -265,7 +265,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
mScreenStateReceiver.unregister();
|
||||
}
|
||||
// Check if need to reset when MagnificationGestureHandler is the last magnifying service.
|
||||
mMagnificationController.resetAllIfNeeded(
|
||||
mFullScreenMagnificationController.resetAllIfNeeded(
|
||||
AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID);
|
||||
clearAndTransitionToStateDetecting();
|
||||
}
|
||||
@@ -273,7 +273,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
@Override
|
||||
public void notifyShortcutTriggered() {
|
||||
if (mDetectShortcutTrigger) {
|
||||
boolean wasMagnifying = mMagnificationController.resetIfNeeded(mDisplayId,
|
||||
boolean wasMagnifying = mFullScreenMagnificationController.resetIfNeeded(mDisplayId,
|
||||
/* animate */ true);
|
||||
if (wasMagnifying) {
|
||||
clearAndTransitionToStateDetecting();
|
||||
@@ -424,7 +424,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
}
|
||||
|
||||
public void persistScaleAndTransitionTo(State state) {
|
||||
mMagnificationController.persistScale();
|
||||
mFullScreenMagnificationController.persistScale();
|
||||
clear();
|
||||
transitionTo(state);
|
||||
}
|
||||
@@ -439,7 +439,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
Slog.i(LOG_TAG, "Panned content by scrollX: " + distanceX
|
||||
+ " scrollY: " + distanceY);
|
||||
}
|
||||
mMagnificationController.offsetMagnifiedRegion(mDisplayId, distanceX,
|
||||
mFullScreenMagnificationController.offsetMagnifiedRegion(mDisplayId, distanceX,
|
||||
distanceY, AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID);
|
||||
return /* event consumed: */ true;
|
||||
}
|
||||
@@ -455,7 +455,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
mScaling = abs(deltaScale) > mScalingThreshold;
|
||||
return mScaling;
|
||||
}
|
||||
final float initialScale = mMagnificationController.getScale(mDisplayId);
|
||||
final float initialScale = mFullScreenMagnificationController.getScale(mDisplayId);
|
||||
final float targetScale = initialScale * detector.getScaleFactor();
|
||||
|
||||
// Don't allow a gesture to move the user further outside the
|
||||
@@ -477,7 +477,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
final float pivotX = detector.getFocusX();
|
||||
final float pivotY = detector.getFocusY();
|
||||
if (DEBUG_PANNING_SCALING) Slog.i(LOG_TAG, "Scaled content to: " + scale + "x");
|
||||
mMagnificationController.setScale(mDisplayId, scale, pivotX, pivotY, false,
|
||||
mFullScreenMagnificationController.setScale(mDisplayId, scale, pivotX, pivotY, false,
|
||||
AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID);
|
||||
mListener.onMagnificationScaleChanged(mDisplayId, getMode());
|
||||
return /* handled: */ true;
|
||||
@@ -537,9 +537,9 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
}
|
||||
final float eventX = event.getX();
|
||||
final float eventY = event.getY();
|
||||
if (mMagnificationController.magnificationRegionContains(
|
||||
if (mFullScreenMagnificationController.magnificationRegionContains(
|
||||
mDisplayId, eventX, eventY)) {
|
||||
mMagnificationController.setCenter(mDisplayId, eventX, eventY,
|
||||
mFullScreenMagnificationController.setCenter(mDisplayId, eventX, eventY,
|
||||
/* animate */ mLastMoveOutsideMagnifiedRegion,
|
||||
AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID);
|
||||
mLastMoveOutsideMagnifiedRegion = false;
|
||||
@@ -687,7 +687,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
mLastDetectingDownEventTime = event.getDownTime();
|
||||
mHandler.removeMessages(MESSAGE_TRANSITION_TO_DELEGATING_STATE);
|
||||
|
||||
if (!mMagnificationController.magnificationRegionContains(
|
||||
if (!mFullScreenMagnificationController.magnificationRegionContains(
|
||||
mDisplayId, event.getX(), event.getY())) {
|
||||
|
||||
transitionToDelegatingStateAndClear();
|
||||
@@ -705,7 +705,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
// If magnified, delay an ACTION_DOWN for mMultiTapMaxDelay
|
||||
// to ensure reachability of
|
||||
// STATE_PANNING_SCALING(triggerable with ACTION_POINTER_DOWN)
|
||||
|| mMagnificationController.isMagnifying(mDisplayId)) {
|
||||
|| mFullScreenMagnificationController.isMagnifying(mDisplayId)) {
|
||||
|
||||
afterMultiTapTimeoutTransitionToDelegatingState();
|
||||
|
||||
@@ -717,7 +717,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
}
|
||||
break;
|
||||
case ACTION_POINTER_DOWN: {
|
||||
if (mMagnificationController.isMagnifying(mDisplayId)
|
||||
if (mFullScreenMagnificationController.isMagnifying(mDisplayId)
|
||||
&& event.getPointerCount() == 2) {
|
||||
storeSecondPointerDownLocation(event);
|
||||
mHandler.sendEmptyMessageDelayed(MESSAGE_TRANSITION_TO_PANNINGSCALING_STATE,
|
||||
@@ -760,7 +760,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
|
||||
mHandler.removeMessages(MESSAGE_ON_TRIPLE_TAP_AND_HOLD);
|
||||
|
||||
if (!mMagnificationController.magnificationRegionContains(
|
||||
if (!mFullScreenMagnificationController.magnificationRegionContains(
|
||||
mDisplayId, event.getX(), event.getY())) {
|
||||
|
||||
transitionToDelegatingStateAndClear();
|
||||
@@ -811,7 +811,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
|
||||
// Only log the triple tap event, use numTaps to filter.
|
||||
if (multitapTriggered && numTaps > 2) {
|
||||
final boolean enabled = mMagnificationController.isMagnifying(mDisplayId);
|
||||
final boolean enabled = mFullScreenMagnificationController.isMagnifying(mDisplayId);
|
||||
logMagnificationTripleTap(enabled);
|
||||
}
|
||||
return multitapTriggered;
|
||||
@@ -947,7 +947,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
clear();
|
||||
|
||||
// Toggle zoom
|
||||
if (mMagnificationController.isMagnifying(mDisplayId)) {
|
||||
if (mFullScreenMagnificationController.isMagnifying(mDisplayId)) {
|
||||
zoomOff();
|
||||
} else {
|
||||
zoomOn(up.getX(), up.getY());
|
||||
@@ -955,7 +955,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
}
|
||||
|
||||
private boolean isMagnifying() {
|
||||
return mMagnificationController.isMagnifying(mDisplayId);
|
||||
return mFullScreenMagnificationController.isMagnifying(mDisplayId);
|
||||
}
|
||||
|
||||
void transitionToViewportDraggingStateAndClear(MotionEvent down) {
|
||||
@@ -964,7 +964,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
clear();
|
||||
|
||||
mViewportDraggingState.mZoomedInBeforeDrag =
|
||||
mMagnificationController.isMagnifying(mDisplayId);
|
||||
mFullScreenMagnificationController.isMagnifying(mDisplayId);
|
||||
|
||||
// Triple tap and hold also belongs to triple tap event.
|
||||
final boolean enabled = !mViewportDraggingState.mZoomedInBeforeDrag;
|
||||
@@ -995,7 +995,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
if (DEBUG_DETECTING) Slog.i(LOG_TAG, "setShortcutTriggered(" + state + ")");
|
||||
|
||||
mShortcutTriggered = state;
|
||||
mMagnificationController.setForceShowMagnifiableBounds(mDisplayId, state);
|
||||
mFullScreenMagnificationController.setForceShowMagnifiableBounds(mDisplayId, state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1028,9 +1028,9 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
if (DEBUG_DETECTING) Slog.i(LOG_TAG, "zoomOn(" + centerX + ", " + centerY + ")");
|
||||
|
||||
final float scale = MathUtils.constrain(
|
||||
mMagnificationController.getPersistedScale(),
|
||||
mFullScreenMagnificationController.getPersistedScale(),
|
||||
MIN_SCALE, MAX_SCALE);
|
||||
mMagnificationController.setScaleAndCenter(mDisplayId,
|
||||
mFullScreenMagnificationController.setScaleAndCenter(mDisplayId,
|
||||
scale, centerX, centerY,
|
||||
/* animate */ true,
|
||||
AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID);
|
||||
@@ -1038,7 +1038,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
|
||||
private void zoomOff() {
|
||||
if (DEBUG_DETECTING) Slog.i(LOG_TAG, "zoomOff()");
|
||||
mMagnificationController.reset(mDisplayId, /* animate */ true);
|
||||
mFullScreenMagnificationController.reset(mDisplayId, /* animate */ true);
|
||||
}
|
||||
|
||||
private static MotionEvent recycleAndNullify(@Nullable MotionEvent event) {
|
||||
@@ -1059,7 +1059,7 @@ class FullScreenMagnificationGestureHandler extends MagnificationGestureHandler
|
||||
+ ", mDetectShortcutTrigger=" + mDetectShortcutTrigger
|
||||
+ ", mCurrentState=" + State.nameOf(mCurrentState)
|
||||
+ ", mPreviousState=" + State.nameOf(mPreviousState)
|
||||
+ ", mMagnificationController=" + mMagnificationController
|
||||
+ ", mMagnificationController=" + mFullScreenMagnificationController
|
||||
+ ", mDisplayId=" + mDisplayId
|
||||
+ '}';
|
||||
}
|
||||
@@ -34,7 +34,6 @@ import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.os.BackgroundThread;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.accessibility.MagnificationController;
|
||||
import com.android.server.statusbar.StatusBarManagerInternal;
|
||||
|
||||
/**
|
||||
@@ -50,8 +49,8 @@ public class WindowMagnificationManager implements
|
||||
private static final String TAG = "WindowMagnificationMgr";
|
||||
|
||||
//Ensure the range has consistency with full screen.
|
||||
static final float MAX_SCALE = MagnificationController.MAX_SCALE;
|
||||
static final float MIN_SCALE = MagnificationController.MIN_SCALE;
|
||||
static final float MAX_SCALE = FullScreenMagnificationController.MAX_SCALE;
|
||||
static final float MIN_SCALE = FullScreenMagnificationController.MIN_SCALE;
|
||||
|
||||
private final Object mLock = new Object();;
|
||||
private final Context mContext;
|
||||
|
||||
@@ -90,6 +90,7 @@ import android.view.accessibility.IAccessibilityInteractionConnection;
|
||||
import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
|
||||
|
||||
import com.android.server.accessibility.AccessibilityWindowManager.RemoteAccessibilityConnection;
|
||||
import com.android.server.accessibility.magnification.FullScreenMagnificationController;
|
||||
import com.android.server.accessibility.test.MessageCapturingHandler;
|
||||
import com.android.server.wm.WindowManagerInternal;
|
||||
|
||||
@@ -166,7 +167,7 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
@Mock private IAccessibilityInteractionConnection mMockIA11yInteractionConnection;
|
||||
@Mock private IAccessibilityInteractionConnectionCallback mMockCallback;
|
||||
@Mock private FingerprintGestureDispatcher mMockFingerprintGestureDispatcher;
|
||||
@Mock private MagnificationController mMockMagnificationController;
|
||||
@Mock private FullScreenMagnificationController mMockFullScreenMagnificationController;
|
||||
@Mock private RemoteCallback.OnResultListener mMockListener;
|
||||
|
||||
@Before
|
||||
@@ -177,8 +178,8 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
when(mMockSystemSupport.getKeyEventDispatcher()).thenReturn(mMockKeyEventDispatcher);
|
||||
when(mMockSystemSupport.getFingerprintGestureDispatcher())
|
||||
.thenReturn(mMockFingerprintGestureDispatcher);
|
||||
when(mMockSystemSupport.getMagnificationController())
|
||||
.thenReturn(mMockMagnificationController);
|
||||
when(mMockSystemSupport.getFullScreenMagnificationController())
|
||||
.thenReturn(mMockFullScreenMagnificationController);
|
||||
|
||||
PowerManager powerManager =
|
||||
new PowerManager(mMockContext, mMockIPowerManager, mMockIThermalService, mHandler);
|
||||
@@ -533,7 +534,7 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
public void getMagnificationScale() {
|
||||
final int displayId = 1;
|
||||
final float scale = 2.0f;
|
||||
when(mMockMagnificationController.getScale(displayId)).thenReturn(scale);
|
||||
when(mMockFullScreenMagnificationController.getScale(displayId)).thenReturn(scale);
|
||||
|
||||
final float result = mServiceConnection.getMagnificationScale(displayId);
|
||||
assertThat(result, is(scale));
|
||||
@@ -543,7 +544,7 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
public void getMagnificationScale_serviceNotBelongCurrentUser_returnNoScale() {
|
||||
final int displayId = 1;
|
||||
final float scale = 2.0f;
|
||||
when(mMockMagnificationController.getScale(displayId)).thenReturn(scale);
|
||||
when(mMockFullScreenMagnificationController.getScale(displayId)).thenReturn(scale);
|
||||
when(mMockSystemSupport.getCurrentUserIdLocked()).thenReturn(USER_ID2);
|
||||
|
||||
final float result = mServiceConnection.getMagnificationScale(displayId);
|
||||
@@ -557,13 +558,14 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
doAnswer((invocation) -> {
|
||||
((Region) invocation.getArguments()[1]).set(region);
|
||||
return null;
|
||||
}).when(mMockMagnificationController).getMagnificationRegion(eq(displayId), any());
|
||||
when(mMockMagnificationController.isRegistered(displayId)).thenReturn(false);
|
||||
}).when(mMockFullScreenMagnificationController).getMagnificationRegion(eq(displayId),
|
||||
any());
|
||||
when(mMockFullScreenMagnificationController.isRegistered(displayId)).thenReturn(false);
|
||||
|
||||
final Region result = mServiceConnection.getMagnificationRegion(displayId);
|
||||
assertThat(result, is(region));
|
||||
verify(mMockMagnificationController).register(displayId);
|
||||
verify(mMockMagnificationController).unregister(displayId);
|
||||
verify(mMockFullScreenMagnificationController).register(displayId);
|
||||
verify(mMockFullScreenMagnificationController).unregister(displayId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -573,7 +575,8 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
doAnswer((invocation) -> {
|
||||
((Region) invocation.getArguments()[1]).set(region);
|
||||
return null;
|
||||
}).when(mMockMagnificationController).getMagnificationRegion(eq(displayId), any());
|
||||
}).when(mMockFullScreenMagnificationController).getMagnificationRegion(eq(displayId),
|
||||
any());
|
||||
when(mMockSystemSupport.getCurrentUserIdLocked()).thenReturn(USER_ID2);
|
||||
|
||||
final Region result = mServiceConnection.getMagnificationRegion(displayId);
|
||||
@@ -584,20 +587,20 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
public void getMagnificationCenterX_notRegistered_shouldRegisterThenUnregister() {
|
||||
final int displayId = 1;
|
||||
final float centerX = 480.0f;
|
||||
when(mMockMagnificationController.getCenterX(displayId)).thenReturn(centerX);
|
||||
when(mMockMagnificationController.isRegistered(displayId)).thenReturn(false);
|
||||
when(mMockFullScreenMagnificationController.getCenterX(displayId)).thenReturn(centerX);
|
||||
when(mMockFullScreenMagnificationController.isRegistered(displayId)).thenReturn(false);
|
||||
|
||||
final float result = mServiceConnection.getMagnificationCenterX(displayId);
|
||||
assertThat(result, is(centerX));
|
||||
verify(mMockMagnificationController).register(displayId);
|
||||
verify(mMockMagnificationController).unregister(displayId);
|
||||
verify(mMockFullScreenMagnificationController).register(displayId);
|
||||
verify(mMockFullScreenMagnificationController).unregister(displayId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMagnificationCenterX_serviceNotBelongCurrentUser_returnZero() {
|
||||
final int displayId = 1;
|
||||
final float centerX = 480.0f;
|
||||
when(mMockMagnificationController.getCenterX(displayId)).thenReturn(centerX);
|
||||
when(mMockFullScreenMagnificationController.getCenterX(displayId)).thenReturn(centerX);
|
||||
when(mMockSystemSupport.getCurrentUserIdLocked()).thenReturn(USER_ID2);
|
||||
|
||||
final float result = mServiceConnection.getMagnificationCenterX(displayId);
|
||||
@@ -608,20 +611,20 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
public void getMagnificationCenterY_notRegistered_shouldRegisterThenUnregister() {
|
||||
final int displayId = 1;
|
||||
final float centerY = 640.0f;
|
||||
when(mMockMagnificationController.getCenterY(displayId)).thenReturn(centerY);
|
||||
when(mMockMagnificationController.isRegistered(displayId)).thenReturn(false);
|
||||
when(mMockFullScreenMagnificationController.getCenterY(displayId)).thenReturn(centerY);
|
||||
when(mMockFullScreenMagnificationController.isRegistered(displayId)).thenReturn(false);
|
||||
|
||||
final float result = mServiceConnection.getMagnificationCenterY(displayId);
|
||||
assertThat(result, is(centerY));
|
||||
verify(mMockMagnificationController).register(displayId);
|
||||
verify(mMockMagnificationController).unregister(displayId);
|
||||
verify(mMockFullScreenMagnificationController).register(displayId);
|
||||
verify(mMockFullScreenMagnificationController).unregister(displayId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMagnificationCenterY_serviceNotBelongCurrentUser_returnZero() {
|
||||
final int displayId = 1;
|
||||
final float centerY = 640.0f;
|
||||
when(mMockMagnificationController.getCenterY(displayId)).thenReturn(centerY);
|
||||
when(mMockFullScreenMagnificationController.getCenterY(displayId)).thenReturn(centerY);
|
||||
when(mMockSystemSupport.getCurrentUserIdLocked()).thenReturn(USER_ID2);
|
||||
|
||||
final float result = mServiceConnection.getMagnificationCenterY(displayId);
|
||||
@@ -631,7 +634,7 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
@Test
|
||||
public void resetMagnification() {
|
||||
final int displayId = 1;
|
||||
when(mMockMagnificationController.reset(displayId, true)).thenReturn(true);
|
||||
when(mMockFullScreenMagnificationController.reset(displayId, true)).thenReturn(true);
|
||||
|
||||
final boolean result = mServiceConnection.resetMagnification(displayId, true);
|
||||
assertThat(result, is(true));
|
||||
@@ -640,7 +643,7 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
@Test
|
||||
public void resetMagnification_cantControlMagnification_returnFalse() {
|
||||
final int displayId = 1;
|
||||
when(mMockMagnificationController.reset(displayId, true)).thenReturn(true);
|
||||
when(mMockFullScreenMagnificationController.reset(displayId, true)).thenReturn(true);
|
||||
when(mMockSecurityPolicy.canControlMagnification(mServiceConnection)).thenReturn(false);
|
||||
|
||||
final boolean result = mServiceConnection.resetMagnification(displayId, true);
|
||||
@@ -650,7 +653,7 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
@Test
|
||||
public void resetMagnification_serviceNotBelongCurrentUser_returnFalse() {
|
||||
final int displayId = 1;
|
||||
when(mMockMagnificationController.reset(displayId, true)).thenReturn(true);
|
||||
when(mMockFullScreenMagnificationController.reset(displayId, true)).thenReturn(true);
|
||||
when(mMockSystemSupport.getCurrentUserIdLocked()).thenReturn(USER_ID2);
|
||||
|
||||
final boolean result = mServiceConnection.resetMagnification(displayId, true);
|
||||
@@ -663,14 +666,14 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
final float scale = 1.8f;
|
||||
final float centerX = 50.5f;
|
||||
final float centerY = 100.5f;
|
||||
when(mMockMagnificationController.setScaleAndCenter(displayId,
|
||||
when(mMockFullScreenMagnificationController.setScaleAndCenter(displayId,
|
||||
scale, centerX, centerY, true, SERVICE_ID)).thenReturn(true);
|
||||
when(mMockMagnificationController.isRegistered(displayId)).thenReturn(false);
|
||||
when(mMockFullScreenMagnificationController.isRegistered(displayId)).thenReturn(false);
|
||||
|
||||
final boolean result = mServiceConnection.setMagnificationScaleAndCenter(
|
||||
displayId, scale, centerX, centerY, true);
|
||||
assertThat(result, is(true));
|
||||
verify(mMockMagnificationController).register(displayId);
|
||||
verify(mMockFullScreenMagnificationController).register(displayId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -679,7 +682,7 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
final float scale = 1.8f;
|
||||
final float centerX = 50.5f;
|
||||
final float centerY = 100.5f;
|
||||
when(mMockMagnificationController.setScaleAndCenter(displayId,
|
||||
when(mMockFullScreenMagnificationController.setScaleAndCenter(displayId,
|
||||
scale, centerX, centerY, true, SERVICE_ID)).thenReturn(true);
|
||||
when(mMockSecurityPolicy.canControlMagnification(mServiceConnection)).thenReturn(false);
|
||||
|
||||
@@ -694,7 +697,7 @@ public class AbstractAccessibilityServiceConnectionTest {
|
||||
final float scale = 1.8f;
|
||||
final float centerX = 50.5f;
|
||||
final float centerY = 100.5f;
|
||||
when(mMockMagnificationController.setScaleAndCenter(displayId,
|
||||
when(mMockFullScreenMagnificationController.setScaleAndCenter(displayId,
|
||||
scale, centerX, centerY, true, SERVICE_ID)).thenReturn(true);
|
||||
when(mMockSystemSupport.getCurrentUserIdLocked()).thenReturn(USER_ID2);
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.server.accessibility.gestures.TouchExplorer;
|
||||
import com.android.server.accessibility.magnification.FullScreenMagnificationController;
|
||||
import com.android.server.accessibility.magnification.FullScreenMagnificationGestureHandler;
|
||||
import com.android.server.accessibility.magnification.MagnificationGestureHandler;
|
||||
import com.android.server.accessibility.magnification.WindowMagnificationGestureHandler;
|
||||
|
||||
@@ -89,7 +91,7 @@ public class AccessibilityInputFilterTest {
|
||||
FullScreenMagnificationGestureHandler.class, TouchExplorer.class,
|
||||
AutoclickController.class, AccessibilityInputFilter.class};
|
||||
|
||||
private MagnificationController mMockMagnificationController;
|
||||
private FullScreenMagnificationController mMockFullScreenMagnificationController;
|
||||
private AccessibilityManagerService mAms;
|
||||
private AccessibilityInputFilter mA11yInputFilter;
|
||||
private EventCaptor mCaptor1;
|
||||
@@ -135,12 +137,13 @@ public class AccessibilityInputFilterTest {
|
||||
|
||||
setDisplayCount(1);
|
||||
mAms = spy(new AccessibilityManagerService(context));
|
||||
mMockMagnificationController = mock(MagnificationController.class);
|
||||
mMockFullScreenMagnificationController = mock(FullScreenMagnificationController.class);
|
||||
mA11yInputFilter = new AccessibilityInputFilter(context, mAms, mEventHandler);
|
||||
mA11yInputFilter.onInstalled();
|
||||
|
||||
when(mAms.getValidDisplayList()).thenReturn(mDisplayList);
|
||||
when(mAms.getMagnificationController()).thenReturn(mMockMagnificationController);
|
||||
when(mAms.getFullScreenMagnificationController()).thenReturn(
|
||||
mMockFullScreenMagnificationController);
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -44,6 +44,7 @@ import android.os.UserHandle;
|
||||
import android.testing.DexmakerShareClassLoaderRule;
|
||||
import android.view.Display;
|
||||
|
||||
import com.android.server.accessibility.magnification.FullScreenMagnificationController;
|
||||
import com.android.server.accessibility.test.MessageCapturingHandler;
|
||||
import com.android.server.wm.ActivityTaskManagerInternal;
|
||||
import com.android.server.wm.WindowManagerInternal;
|
||||
@@ -87,7 +88,8 @@ public class AccessibilityServiceConnectionTest {
|
||||
@Mock WindowManagerInternal mMockWindowManagerInternal;
|
||||
@Mock SystemActionPerformer mMockSystemActionPerformer;
|
||||
@Mock KeyEventDispatcher mMockKeyEventDispatcher;
|
||||
@Mock MagnificationController mMockMagnificationController;
|
||||
@Mock
|
||||
FullScreenMagnificationController mMockFullScreenMagnificationController;
|
||||
@Mock IBinder mMockIBinder;
|
||||
@Mock IAccessibilityServiceClient mMockServiceClient;
|
||||
@Mock MotionEventInjector mMockMotionEventInjector;
|
||||
@@ -98,8 +100,8 @@ public class AccessibilityServiceConnectionTest {
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mMockSystemSupport.getKeyEventDispatcher()).thenReturn(mMockKeyEventDispatcher);
|
||||
when(mMockSystemSupport.getMagnificationController())
|
||||
.thenReturn(mMockMagnificationController);
|
||||
when(mMockSystemSupport.getFullScreenMagnificationController())
|
||||
.thenReturn(mMockFullScreenMagnificationController);
|
||||
when(mMockSystemSupport.getMotionEventInjectorForDisplayLocked(
|
||||
Display.DEFAULT_DISPLAY)).thenReturn(mMockMotionEventInjector);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.accessibility;
|
||||
package com.android.server.accessibility.magnification;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -47,6 +47,7 @@ import android.view.MagnificationSpec;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.server.accessibility.AccessibilityManagerService;
|
||||
import com.android.server.accessibility.test.MessageCapturingHandler;
|
||||
import com.android.server.wm.WindowManagerInternal;
|
||||
import com.android.server.wm.WindowManagerInternal.MagnificationCallbacks;
|
||||
@@ -66,7 +67,7 @@ import org.mockito.stubbing.Answer;
|
||||
import java.util.Locale;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class MagnificationControllerTest {
|
||||
public class FullScreenMagnificationControllerTest {
|
||||
static final Rect INITIAL_MAGNIFICATION_BOUNDS = new Rect(0, 0, 100, 200);
|
||||
static final PointF INITIAL_MAGNIFICATION_BOUNDS_CENTER = new PointF(
|
||||
INITIAL_MAGNIFICATION_BOUNDS.centerX(), INITIAL_MAGNIFICATION_BOUNDS.centerY());
|
||||
@@ -85,8 +86,8 @@ public class MagnificationControllerTest {
|
||||
static final int DISPLAY_COUNT = 2;
|
||||
static final int INVALID_DISPLAY = 2;
|
||||
|
||||
final MagnificationController.ControllerContext mMockControllerCtx =
|
||||
mock(MagnificationController.ControllerContext.class);
|
||||
final FullScreenMagnificationController.ControllerContext mMockControllerCtx =
|
||||
mock(FullScreenMagnificationController.ControllerContext.class);
|
||||
final Context mMockContext = mock(Context.class);
|
||||
final AccessibilityManagerService mMockAms = mock(AccessibilityManagerService.class);
|
||||
final WindowManagerInternal mMockWindowManager = mock(WindowManagerInternal.class);
|
||||
@@ -95,7 +96,7 @@ public class MagnificationControllerTest {
|
||||
ValueAnimator mMockValueAnimator;
|
||||
ValueAnimator.AnimatorUpdateListener mTargetAnimationListener;
|
||||
|
||||
MagnificationController mMagnificationController;
|
||||
FullScreenMagnificationController mFullScreenMagnificationController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -109,7 +110,8 @@ public class MagnificationControllerTest {
|
||||
when(mMockControllerCtx.getAnimationDuration()).thenReturn(1000L);
|
||||
initMockWindowManager();
|
||||
|
||||
mMagnificationController = new MagnificationController(mMockControllerCtx, new Object());
|
||||
mFullScreenMagnificationController = new FullScreenMagnificationController(
|
||||
mMockControllerCtx, new Object());
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -131,23 +133,23 @@ public class MagnificationControllerTest {
|
||||
eq(DISPLAY_1), (MagnificationCallbacks) anyObject());
|
||||
verify(mMockWindowManager).setMagnificationCallbacks(
|
||||
eq(INVALID_DISPLAY), (MagnificationCallbacks) anyObject());
|
||||
assertTrue(mMagnificationController.isRegistered(DISPLAY_0));
|
||||
assertTrue(mMagnificationController.isRegistered(DISPLAY_1));
|
||||
assertFalse(mMagnificationController.isRegistered(INVALID_DISPLAY));
|
||||
assertTrue(mFullScreenMagnificationController.isRegistered(DISPLAY_0));
|
||||
assertTrue(mFullScreenMagnificationController.isRegistered(DISPLAY_1));
|
||||
assertFalse(mFullScreenMagnificationController.isRegistered(INVALID_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegister_WindowManagerAndContextUnregisterListeners() {
|
||||
register(DISPLAY_0);
|
||||
register(DISPLAY_1);
|
||||
mMagnificationController.unregister(DISPLAY_0);
|
||||
mFullScreenMagnificationController.unregister(DISPLAY_0);
|
||||
verify(mMockContext, times(0)).unregisterReceiver((BroadcastReceiver) anyObject());
|
||||
mMagnificationController.unregister(DISPLAY_1);
|
||||
mFullScreenMagnificationController.unregister(DISPLAY_1);
|
||||
verify(mMockContext).unregisterReceiver((BroadcastReceiver) anyObject());
|
||||
verify(mMockWindowManager).setMagnificationCallbacks(eq(DISPLAY_0), eq(null));
|
||||
verify(mMockWindowManager).setMagnificationCallbacks(eq(DISPLAY_1), eq(null));
|
||||
assertFalse(mMagnificationController.isRegistered(DISPLAY_0));
|
||||
assertFalse(mMagnificationController.isRegistered(DISPLAY_1));
|
||||
assertFalse(mFullScreenMagnificationController.isRegistered(DISPLAY_0));
|
||||
assertFalse(mFullScreenMagnificationController.isRegistered(DISPLAY_1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,14 +168,14 @@ public class MagnificationControllerTest {
|
||||
Rect initialBounds = new Rect();
|
||||
|
||||
assertEquals(expectedInitialSpec, getCurrentMagnificationSpec(displayId));
|
||||
mMagnificationController.getMagnificationRegion(displayId, initialMagRegion);
|
||||
mMagnificationController.getMagnificationBounds(displayId, initialBounds);
|
||||
mFullScreenMagnificationController.getMagnificationRegion(displayId, initialMagRegion);
|
||||
mFullScreenMagnificationController.getMagnificationBounds(displayId, initialBounds);
|
||||
assertEquals(INITIAL_MAGNIFICATION_REGION, initialMagRegion);
|
||||
assertEquals(INITIAL_MAGNIFICATION_BOUNDS, initialBounds);
|
||||
assertEquals(INITIAL_MAGNIFICATION_BOUNDS.centerX(),
|
||||
mMagnificationController.getCenterX(displayId), 0.0f);
|
||||
mFullScreenMagnificationController.getCenterX(displayId), 0.0f);
|
||||
assertEquals(INITIAL_MAGNIFICATION_BOUNDS.centerY(),
|
||||
mMagnificationController.getCenterY(displayId), 0.0f);
|
||||
mFullScreenMagnificationController.getCenterY(displayId), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -185,24 +187,26 @@ public class MagnificationControllerTest {
|
||||
}
|
||||
|
||||
private void notRegistered_publicMethodsShouldBeBenign(int displayId) {
|
||||
assertFalse(mMagnificationController.isMagnifying(displayId));
|
||||
assertFalse(mMagnificationController.magnificationRegionContains(displayId, 100, 100));
|
||||
assertFalse(mMagnificationController.reset(displayId, true));
|
||||
assertFalse(mMagnificationController.setScale(displayId, 2, 100, 100, true, 0));
|
||||
assertFalse(mMagnificationController.setCenter(displayId, 100, 100, false, 1));
|
||||
assertFalse(mMagnificationController.setScaleAndCenter(displayId,
|
||||
assertFalse(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||
assertFalse(
|
||||
mFullScreenMagnificationController.magnificationRegionContains(displayId, 100,
|
||||
100));
|
||||
assertFalse(mFullScreenMagnificationController.reset(displayId, true));
|
||||
assertFalse(mFullScreenMagnificationController.setScale(displayId, 2, 100, 100, true, 0));
|
||||
assertFalse(mFullScreenMagnificationController.setCenter(displayId, 100, 100, false, 1));
|
||||
assertFalse(mFullScreenMagnificationController.setScaleAndCenter(displayId,
|
||||
1.5f, 100, 100, false, 2));
|
||||
assertTrue(mMagnificationController.getIdOfLastServiceToMagnify(displayId) < 0);
|
||||
assertTrue(mFullScreenMagnificationController.getIdOfLastServiceToMagnify(displayId) < 0);
|
||||
|
||||
mMagnificationController.getMagnificationRegion(displayId, new Region());
|
||||
mMagnificationController.getMagnificationBounds(displayId, new Rect());
|
||||
mMagnificationController.getScale(displayId);
|
||||
mMagnificationController.getOffsetX(displayId);
|
||||
mMagnificationController.getOffsetY(displayId);
|
||||
mMagnificationController.getCenterX(displayId);
|
||||
mMagnificationController.getCenterY(displayId);
|
||||
mMagnificationController.offsetMagnifiedRegion(displayId, 50, 50, 1);
|
||||
mMagnificationController.unregister(displayId);
|
||||
mFullScreenMagnificationController.getMagnificationRegion(displayId, new Region());
|
||||
mFullScreenMagnificationController.getMagnificationBounds(displayId, new Rect());
|
||||
mFullScreenMagnificationController.getScale(displayId);
|
||||
mFullScreenMagnificationController.getOffsetX(displayId);
|
||||
mFullScreenMagnificationController.getOffsetY(displayId);
|
||||
mFullScreenMagnificationController.getCenterX(displayId);
|
||||
mFullScreenMagnificationController.getCenterY(displayId);
|
||||
mFullScreenMagnificationController.offsetMagnifiedRegion(displayId, 50, 50, 1);
|
||||
mFullScreenMagnificationController.unregister(displayId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -218,7 +222,7 @@ public class MagnificationControllerTest {
|
||||
final float scale = 2.0f;
|
||||
final PointF center = INITIAL_MAGNIFICATION_BOUNDS_CENTER;
|
||||
final PointF offsets = computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, center, scale);
|
||||
assertTrue(mMagnificationController
|
||||
assertTrue(mFullScreenMagnificationController
|
||||
.setScale(displayId, scale, center.x, center.y, false, SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
|
||||
@@ -226,8 +230,8 @@ public class MagnificationControllerTest {
|
||||
verify(mMockWindowManager).setMagnificationSpec(
|
||||
eq(displayId), argThat(closeTo(expectedSpec)));
|
||||
assertThat(getCurrentMagnificationSpec(displayId), closeTo(expectedSpec));
|
||||
assertEquals(center.x, mMagnificationController.getCenterX(displayId), 0.0);
|
||||
assertEquals(center.y, mMagnificationController.getCenterY(displayId), 0.0);
|
||||
assertEquals(center.x, mFullScreenMagnificationController.getCenterX(displayId), 0.0);
|
||||
assertEquals(center.y, mFullScreenMagnificationController.getCenterY(displayId), 0.0);
|
||||
verify(mMockValueAnimator, times(0)).start();
|
||||
}
|
||||
|
||||
@@ -244,7 +248,7 @@ public class MagnificationControllerTest {
|
||||
MagnificationSpec startSpec = getCurrentMagnificationSpec(displayId);
|
||||
float scale = 2.0f;
|
||||
PointF pivotPoint = INITIAL_BOUNDS_LOWER_RIGHT_2X_CENTER;
|
||||
assertTrue(mMagnificationController
|
||||
assertTrue(mFullScreenMagnificationController
|
||||
.setScale(displayId, scale, pivotPoint.x, pivotPoint.y, true, SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
|
||||
@@ -254,8 +258,8 @@ public class MagnificationControllerTest {
|
||||
PointF offsets = computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, newCenter, scale);
|
||||
MagnificationSpec endSpec = getMagnificationSpec(scale, offsets);
|
||||
|
||||
assertEquals(newCenter.x, mMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(newCenter.y, mMagnificationController.getCenterY(displayId), 0.5);
|
||||
assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.5);
|
||||
assertThat(getCurrentMagnificationSpec(displayId), closeTo(endSpec));
|
||||
verify(mMockValueAnimator).start();
|
||||
|
||||
@@ -291,13 +295,13 @@ public class MagnificationControllerTest {
|
||||
register(displayId);
|
||||
// First zoom in
|
||||
float scale = 2.0f;
|
||||
assertTrue(mMagnificationController.setScale(displayId, scale,
|
||||
assertTrue(mFullScreenMagnificationController.setScale(displayId, scale,
|
||||
INITIAL_MAGNIFICATION_BOUNDS.centerX(), INITIAL_MAGNIFICATION_BOUNDS.centerY(),
|
||||
false, SERVICE_ID_1));
|
||||
Mockito.reset(mMockWindowManager);
|
||||
|
||||
PointF newCenter = INITIAL_BOUNDS_LOWER_RIGHT_2X_CENTER;
|
||||
assertTrue(mMagnificationController
|
||||
assertTrue(mFullScreenMagnificationController
|
||||
.setCenter(displayId, newCenter.x, newCenter.y, false, SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
PointF expectedOffsets = computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, newCenter, scale);
|
||||
@@ -305,8 +309,8 @@ public class MagnificationControllerTest {
|
||||
|
||||
verify(mMockWindowManager).setMagnificationSpec(
|
||||
eq(displayId), argThat(closeTo(expectedSpec)));
|
||||
assertEquals(newCenter.x, mMagnificationController.getCenterX(displayId), 0.0);
|
||||
assertEquals(newCenter.y, mMagnificationController.getCenterY(displayId), 0.0);
|
||||
assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.0);
|
||||
assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.0);
|
||||
verify(mMockValueAnimator, times(0)).start();
|
||||
}
|
||||
|
||||
@@ -326,12 +330,12 @@ public class MagnificationControllerTest {
|
||||
PointF offsets = computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, newCenter, scale);
|
||||
MagnificationSpec endSpec = getMagnificationSpec(scale, offsets);
|
||||
|
||||
assertTrue(mMagnificationController.setScaleAndCenter(displayId, scale, newCenter.x,
|
||||
newCenter.y, true, SERVICE_ID_1));
|
||||
assertTrue(mFullScreenMagnificationController.setScaleAndCenter(displayId, scale,
|
||||
newCenter.x, newCenter.y, true, SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
|
||||
assertEquals(newCenter.x, mMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(newCenter.y, mMagnificationController.getCenterY(displayId), 0.5);
|
||||
assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.5);
|
||||
assertThat(getCurrentMagnificationSpec(displayId), closeTo(endSpec));
|
||||
verify(mMockAms).notifyMagnificationChanged(displayId,
|
||||
INITIAL_MAGNIFICATION_REGION, scale, newCenter.x, newCenter.y);
|
||||
@@ -370,30 +374,30 @@ public class MagnificationControllerTest {
|
||||
MagnificationSpec startSpec = getCurrentMagnificationSpec(displayId);
|
||||
PointF newCenter = INITIAL_BOUNDS_LOWER_RIGHT_2X_CENTER;
|
||||
PointF offsets = computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, newCenter,
|
||||
MagnificationController.MAX_SCALE);
|
||||
FullScreenMagnificationController.MAX_SCALE);
|
||||
MagnificationSpec endSpec = getMagnificationSpec(
|
||||
MagnificationController.MAX_SCALE, offsets);
|
||||
FullScreenMagnificationController.MAX_SCALE, offsets);
|
||||
|
||||
assertTrue(mMagnificationController.setScaleAndCenter(displayId,
|
||||
MagnificationController.MAX_SCALE + 1.0f,
|
||||
assertTrue(mFullScreenMagnificationController.setScaleAndCenter(displayId,
|
||||
FullScreenMagnificationController.MAX_SCALE + 1.0f,
|
||||
newCenter.x, newCenter.y, false, SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
|
||||
assertEquals(newCenter.x, mMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(newCenter.y, mMagnificationController.getCenterY(displayId), 0.5);
|
||||
assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.5);
|
||||
verify(mMockWindowManager).setMagnificationSpec(eq(displayId), argThat(closeTo(endSpec)));
|
||||
Mockito.reset(mMockWindowManager);
|
||||
|
||||
// Verify that we can't zoom below 1x
|
||||
assertTrue(mMagnificationController.setScaleAndCenter(displayId, 0.5f,
|
||||
assertTrue(mFullScreenMagnificationController.setScaleAndCenter(displayId, 0.5f,
|
||||
INITIAL_MAGNIFICATION_BOUNDS_CENTER.x, INITIAL_MAGNIFICATION_BOUNDS_CENTER.y,
|
||||
false, SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
|
||||
assertEquals(INITIAL_MAGNIFICATION_BOUNDS_CENTER.x,
|
||||
mMagnificationController.getCenterX(displayId), 0.5);
|
||||
mFullScreenMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(INITIAL_MAGNIFICATION_BOUNDS_CENTER.y,
|
||||
mMagnificationController.getCenterY(displayId), 0.5);
|
||||
mFullScreenMagnificationController.getCenterY(displayId), 0.5);
|
||||
verify(mMockWindowManager).setMagnificationSpec(eq(displayId), argThat(closeTo(startSpec)));
|
||||
}
|
||||
|
||||
@@ -410,27 +414,27 @@ public class MagnificationControllerTest {
|
||||
float scale = 2.0f;
|
||||
|
||||
// Off the edge to the top and left
|
||||
assertTrue(mMagnificationController.setScaleAndCenter(displayId,
|
||||
assertTrue(mFullScreenMagnificationController.setScaleAndCenter(displayId,
|
||||
scale, -100f, -200f, false, SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
|
||||
PointF newCenter = INITIAL_BOUNDS_UPPER_LEFT_2X_CENTER;
|
||||
PointF newOffsets = computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, newCenter, scale);
|
||||
assertEquals(newCenter.x, mMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(newCenter.y, mMagnificationController.getCenterY(displayId), 0.5);
|
||||
assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.5);
|
||||
verify(mMockWindowManager).setMagnificationSpec(eq(displayId),
|
||||
argThat(closeTo(getMagnificationSpec(scale, newOffsets))));
|
||||
Mockito.reset(mMockWindowManager);
|
||||
|
||||
// Off the edge to the bottom and right
|
||||
assertTrue(mMagnificationController.setScaleAndCenter(displayId, scale,
|
||||
assertTrue(mFullScreenMagnificationController.setScaleAndCenter(displayId, scale,
|
||||
INITIAL_MAGNIFICATION_BOUNDS.right + 1, INITIAL_MAGNIFICATION_BOUNDS.bottom + 1,
|
||||
false, SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
newCenter = INITIAL_BOUNDS_LOWER_RIGHT_2X_CENTER;
|
||||
newOffsets = computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, newCenter, scale);
|
||||
assertEquals(newCenter.x, mMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(newCenter.y, mMagnificationController.getCenterY(displayId), 0.5);
|
||||
assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.5);
|
||||
verify(mMockWindowManager).setMagnificationSpec(eq(displayId),
|
||||
argThat(closeTo(getMagnificationSpec(scale, newOffsets))));
|
||||
}
|
||||
@@ -466,7 +470,7 @@ public class MagnificationControllerTest {
|
||||
float scale = 2.0f;
|
||||
PointF startOffsets = computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, startCenter, scale);
|
||||
// First zoom in
|
||||
assertTrue(mMagnificationController
|
||||
assertTrue(mFullScreenMagnificationController
|
||||
.setScaleAndCenter(displayId, scale, startCenter.x, startCenter.y, false,
|
||||
SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
@@ -474,7 +478,7 @@ public class MagnificationControllerTest {
|
||||
|
||||
PointF newCenter = INITIAL_BOUNDS_LOWER_RIGHT_2X_CENTER;
|
||||
PointF newOffsets = computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, newCenter, scale);
|
||||
mMagnificationController.offsetMagnifiedRegion(displayId,
|
||||
mFullScreenMagnificationController.offsetMagnifiedRegion(displayId,
|
||||
startOffsets.x - newOffsets.x, startOffsets.y - newOffsets.y,
|
||||
SERVICE_ID_1);
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
@@ -482,8 +486,8 @@ public class MagnificationControllerTest {
|
||||
MagnificationSpec expectedSpec = getMagnificationSpec(scale, newOffsets);
|
||||
verify(mMockWindowManager).setMagnificationSpec(eq(displayId),
|
||||
argThat(closeTo(expectedSpec)));
|
||||
assertEquals(newCenter.x, mMagnificationController.getCenterX(displayId), 0.0);
|
||||
assertEquals(newCenter.y, mMagnificationController.getCenterY(displayId), 0.0);
|
||||
assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.0);
|
||||
assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.0);
|
||||
verify(mMockValueAnimator, times(0)).start();
|
||||
}
|
||||
|
||||
@@ -499,9 +503,9 @@ public class MagnificationControllerTest {
|
||||
register(displayId);
|
||||
Mockito.reset(mMockWindowManager);
|
||||
MagnificationSpec startSpec = getCurrentMagnificationSpec(displayId);
|
||||
mMagnificationController.offsetMagnifiedRegion(displayId, 10, 10, SERVICE_ID_1);
|
||||
mFullScreenMagnificationController.offsetMagnifiedRegion(displayId, 10, 10, SERVICE_ID_1);
|
||||
assertThat(getCurrentMagnificationSpec(displayId), closeTo(startSpec));
|
||||
mMagnificationController.offsetMagnifiedRegion(displayId, -10, -10, SERVICE_ID_1);
|
||||
mFullScreenMagnificationController.offsetMagnifiedRegion(displayId, -10, -10, SERVICE_ID_1);
|
||||
assertThat(getCurrentMagnificationSpec(displayId), closeTo(startSpec));
|
||||
verifyNoMoreInteractions(mMockWindowManager);
|
||||
}
|
||||
@@ -520,24 +524,24 @@ public class MagnificationControllerTest {
|
||||
|
||||
// Upper left edges
|
||||
PointF ulCenter = INITIAL_BOUNDS_UPPER_LEFT_2X_CENTER;
|
||||
assertTrue(mMagnificationController
|
||||
assertTrue(mFullScreenMagnificationController
|
||||
.setScaleAndCenter(displayId, scale, ulCenter.x, ulCenter.y, false,
|
||||
SERVICE_ID_1));
|
||||
Mockito.reset(mMockWindowManager);
|
||||
MagnificationSpec ulSpec = getCurrentMagnificationSpec(displayId);
|
||||
mMagnificationController.offsetMagnifiedRegion(displayId, -10, -10,
|
||||
mFullScreenMagnificationController.offsetMagnifiedRegion(displayId, -10, -10,
|
||||
SERVICE_ID_1);
|
||||
assertThat(getCurrentMagnificationSpec(displayId), closeTo(ulSpec));
|
||||
verifyNoMoreInteractions(mMockWindowManager);
|
||||
|
||||
// Lower right edges
|
||||
PointF lrCenter = INITIAL_BOUNDS_LOWER_RIGHT_2X_CENTER;
|
||||
assertTrue(mMagnificationController
|
||||
assertTrue(mFullScreenMagnificationController
|
||||
.setScaleAndCenter(displayId, scale, lrCenter.x, lrCenter.y, false,
|
||||
SERVICE_ID_1));
|
||||
Mockito.reset(mMockWindowManager);
|
||||
MagnificationSpec lrSpec = getCurrentMagnificationSpec(displayId);
|
||||
mMagnificationController.offsetMagnifiedRegion(displayId, 10, 10,
|
||||
mFullScreenMagnificationController.offsetMagnifiedRegion(displayId, 10, 10,
|
||||
SERVICE_ID_1);
|
||||
assertThat(getCurrentMagnificationSpec(displayId), closeTo(lrSpec));
|
||||
verifyNoMoreInteractions(mMockWindowManager);
|
||||
@@ -554,14 +558,16 @@ public class MagnificationControllerTest {
|
||||
private void getIdOfLastServiceToChange_returnsCorrectValue(int displayId) {
|
||||
register(displayId);
|
||||
PointF startCenter = INITIAL_MAGNIFICATION_BOUNDS_CENTER;
|
||||
assertTrue(mMagnificationController
|
||||
assertTrue(mFullScreenMagnificationController
|
||||
.setScale(displayId, 2.0f, startCenter.x, startCenter.y, false,
|
||||
SERVICE_ID_1));
|
||||
assertEquals(SERVICE_ID_1, mMagnificationController.getIdOfLastServiceToMagnify(displayId));
|
||||
assertTrue(mMagnificationController
|
||||
assertEquals(SERVICE_ID_1,
|
||||
mFullScreenMagnificationController.getIdOfLastServiceToMagnify(displayId));
|
||||
assertTrue(mFullScreenMagnificationController
|
||||
.setScale(displayId, 1.5f, startCenter.x, startCenter.y, false,
|
||||
SERVICE_ID_2));
|
||||
assertEquals(SERVICE_ID_2, mMagnificationController.getIdOfLastServiceToMagnify(displayId));
|
||||
assertEquals(SERVICE_ID_2,
|
||||
mFullScreenMagnificationController.getIdOfLastServiceToMagnify(displayId));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -575,16 +581,16 @@ public class MagnificationControllerTest {
|
||||
private void resetIfNeeded_resetsOnlyIfLastMagnifyingServiceIsDisabled(int displayId) {
|
||||
register(displayId);
|
||||
PointF startCenter = INITIAL_MAGNIFICATION_BOUNDS_CENTER;
|
||||
mMagnificationController
|
||||
mFullScreenMagnificationController
|
||||
.setScale(displayId, 2.0f, startCenter.x, startCenter.y, false,
|
||||
SERVICE_ID_1);
|
||||
mMagnificationController
|
||||
mFullScreenMagnificationController
|
||||
.setScale(displayId, 1.5f, startCenter.x, startCenter.y, false,
|
||||
SERVICE_ID_2);
|
||||
assertFalse(mMagnificationController.resetIfNeeded(displayId, SERVICE_ID_1));
|
||||
assertTrue(mMagnificationController.isMagnifying(displayId));
|
||||
assertTrue(mMagnificationController.resetIfNeeded(displayId, SERVICE_ID_2));
|
||||
assertFalse(mMagnificationController.isMagnifying(displayId));
|
||||
assertFalse(mFullScreenMagnificationController.resetIfNeeded(displayId, SERVICE_ID_1));
|
||||
assertTrue(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||
assertTrue(mFullScreenMagnificationController.resetIfNeeded(displayId, SERVICE_ID_2));
|
||||
assertFalse(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -600,16 +606,16 @@ public class MagnificationControllerTest {
|
||||
final int userId2 = 2;
|
||||
|
||||
register(displayId);
|
||||
mMagnificationController.setUserId(userId1);
|
||||
mFullScreenMagnificationController.setUserId(userId1);
|
||||
PointF startCenter = INITIAL_MAGNIFICATION_BOUNDS_CENTER;
|
||||
float scale = 2.0f;
|
||||
mMagnificationController.setScale(displayId, scale, startCenter.x, startCenter.y, false,
|
||||
SERVICE_ID_1);
|
||||
mFullScreenMagnificationController.setScale(displayId, scale, startCenter.x, startCenter.y,
|
||||
false, SERVICE_ID_1);
|
||||
|
||||
mMagnificationController.setUserId(userId1);
|
||||
assertTrue(mMagnificationController.isMagnifying(displayId));
|
||||
mMagnificationController.setUserId(userId2);
|
||||
assertFalse(mMagnificationController.isMagnifying(displayId));
|
||||
mFullScreenMagnificationController.setUserId(userId1);
|
||||
assertTrue(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||
mFullScreenMagnificationController.setUserId(userId2);
|
||||
assertFalse(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -625,11 +631,11 @@ public class MagnificationControllerTest {
|
||||
zoomIn2xToMiddle(displayId);
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
reset(mMockAms);
|
||||
assertTrue(mMagnificationController.resetIfNeeded(displayId, false));
|
||||
assertTrue(mFullScreenMagnificationController.resetIfNeeded(displayId, false));
|
||||
verify(mMockAms).notifyMagnificationChanged(eq(displayId),
|
||||
eq(INITIAL_MAGNIFICATION_REGION), eq(1.0f), anyFloat(), anyFloat());
|
||||
assertFalse(mMagnificationController.isMagnifying(displayId));
|
||||
assertFalse(mMagnificationController.resetIfNeeded(displayId, false));
|
||||
assertFalse(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||
assertFalse(mFullScreenMagnificationController.resetIfNeeded(displayId, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -646,8 +652,8 @@ public class MagnificationControllerTest {
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
br.onReceive(mMockContext, null);
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
assertFalse(mMagnificationController.isMagnifying(DISPLAY_0));
|
||||
assertFalse(mMagnificationController.isMagnifying(DISPLAY_1));
|
||||
assertFalse(mFullScreenMagnificationController.isMagnifying(DISPLAY_0));
|
||||
assertFalse(mFullScreenMagnificationController.isMagnifying(DISPLAY_1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -665,7 +671,7 @@ public class MagnificationControllerTest {
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
callbacks.onUserContextChanged();
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
assertFalse(mMagnificationController.isMagnifying(displayId));
|
||||
assertFalse(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -681,10 +687,10 @@ public class MagnificationControllerTest {
|
||||
MagnificationCallbacks callbacks = getMagnificationCallbacks(displayId);
|
||||
zoomIn2xToMiddle(displayId);
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
assertTrue(mMagnificationController.isMagnifying(displayId));
|
||||
assertTrue(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||
callbacks.onRotationChanged(0);
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
assertFalse(mMagnificationController.isMagnifying(displayId));
|
||||
assertFalse(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -722,8 +728,8 @@ public class MagnificationControllerTest {
|
||||
PointF startCenter = INITIAL_MAGNIFICATION_BOUNDS_CENTER;
|
||||
float scale = 2.0f;
|
||||
// setting animate parameter to true is differ from zoomIn2xToMiddle()
|
||||
mMagnificationController.setScale(displayId, scale, startCenter.x, startCenter.y, true,
|
||||
SERVICE_ID_1);
|
||||
mFullScreenMagnificationController.setScale(displayId, scale, startCenter.x, startCenter.y,
|
||||
true, SERVICE_ID_1);
|
||||
MagnificationSpec startSpec = getCurrentMagnificationSpec(displayId);
|
||||
MagnificationCallbacks callbacks = getMagnificationCallbacks(displayId);
|
||||
Mockito.reset(mMockWindowManager);
|
||||
@@ -750,8 +756,8 @@ public class MagnificationControllerTest {
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
PointF startCenter = OTHER_BOUNDS_LOWER_RIGHT_2X_CENTER;
|
||||
float scale = 2.0f;
|
||||
mMagnificationController.setScale(displayId, scale, startCenter.x, startCenter.y, false,
|
||||
SERVICE_ID_1);
|
||||
mFullScreenMagnificationController.setScale(displayId, scale, startCenter.x, startCenter.y,
|
||||
false, SERVICE_ID_1);
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
MagnificationSpec startSpec = getCurrentMagnificationSpec(displayId);
|
||||
verify(mMockWindowManager).setMagnificationSpec(eq(displayId), argThat(closeTo(startSpec)));
|
||||
@@ -784,8 +790,8 @@ public class MagnificationControllerTest {
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
PointF startCenter = OTHER_BOUNDS_LOWER_RIGHT_2X_CENTER;
|
||||
float scale = 2.0f;
|
||||
mMagnificationController.setScale(displayId, scale, startCenter.x, startCenter.y, true,
|
||||
SERVICE_ID_1);
|
||||
mFullScreenMagnificationController.setScale(displayId, scale, startCenter.x, startCenter.y,
|
||||
true, SERVICE_ID_1);
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
MagnificationSpec startSpec = getCurrentMagnificationSpec(displayId);
|
||||
when(mMockValueAnimator.isRunning()).thenReturn(true);
|
||||
@@ -947,12 +953,12 @@ public class MagnificationControllerTest {
|
||||
MagnificationSpec firstEndSpec = getMagnificationSpec(
|
||||
scale, computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, firstCenter, scale));
|
||||
|
||||
assertTrue(mMagnificationController.setScaleAndCenter(displayId,
|
||||
assertTrue(mFullScreenMagnificationController.setScaleAndCenter(displayId,
|
||||
scale, firstCenter.x, firstCenter.y, true, SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
|
||||
assertEquals(firstCenter.x, mMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(firstCenter.y, mMagnificationController.getCenterY(displayId), 0.5);
|
||||
assertEquals(firstCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5);
|
||||
assertEquals(firstCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.5);
|
||||
assertThat(getCurrentMagnificationSpec(displayId), closeTo(firstEndSpec));
|
||||
verify(mMockValueAnimator, times(1)).start();
|
||||
|
||||
@@ -977,7 +983,7 @@ public class MagnificationControllerTest {
|
||||
PointF newCenter = INITIAL_BOUNDS_UPPER_LEFT_2X_CENTER;
|
||||
MagnificationSpec newEndSpec = getMagnificationSpec(
|
||||
scale, computeOffsets(INITIAL_MAGNIFICATION_BOUNDS, newCenter, scale));
|
||||
assertTrue(mMagnificationController.setCenter(displayId,
|
||||
assertTrue(mFullScreenMagnificationController.setCenter(displayId,
|
||||
newCenter.x, newCenter.y, true, SERVICE_ID_1));
|
||||
mMessageCapturingHandler.sendAllMessages();
|
||||
|
||||
@@ -1032,7 +1038,7 @@ public class MagnificationControllerTest {
|
||||
private void register(int displayId) {
|
||||
mMockValueAnimator = mock(ValueAnimator.class);
|
||||
when(mMockControllerCtx.newValueAnimator()).thenReturn(mMockValueAnimator);
|
||||
mMagnificationController.register(displayId);
|
||||
mFullScreenMagnificationController.register(displayId);
|
||||
ArgumentCaptor<ValueAnimator.AnimatorUpdateListener> listenerArgumentCaptor =
|
||||
ArgumentCaptor.forClass(ValueAnimator.AnimatorUpdateListener.class);
|
||||
verify(mMockValueAnimator).addUpdateListener(listenerArgumentCaptor.capture());
|
||||
@@ -1043,9 +1049,9 @@ public class MagnificationControllerTest {
|
||||
private void zoomIn2xToMiddle(int displayId) {
|
||||
PointF startCenter = INITIAL_MAGNIFICATION_BOUNDS_CENTER;
|
||||
float scale = 2.0f;
|
||||
mMagnificationController.setScale(displayId, scale, startCenter.x, startCenter.y, false,
|
||||
SERVICE_ID_1);
|
||||
assertTrue(mMagnificationController.isMagnifying(displayId));
|
||||
mFullScreenMagnificationController.setScale(displayId, scale, startCenter.x, startCenter.y,
|
||||
false, SERVICE_ID_1);
|
||||
assertTrue(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||
}
|
||||
|
||||
private MagnificationCallbacks getMagnificationCallbacks(int displayId) {
|
||||
@@ -1084,9 +1090,9 @@ public class MagnificationControllerTest {
|
||||
}
|
||||
|
||||
private MagnificationSpec getCurrentMagnificationSpec(int displayId) {
|
||||
return getMagnificationSpec(mMagnificationController.getScale(displayId),
|
||||
mMagnificationController.getOffsetX(displayId),
|
||||
mMagnificationController.getOffsetY(displayId));
|
||||
return getMagnificationSpec(mFullScreenMagnificationController.getScale(displayId),
|
||||
mFullScreenMagnificationController.getOffsetX(displayId),
|
||||
mFullScreenMagnificationController.getOffsetY(displayId));
|
||||
}
|
||||
|
||||
private MagSpecMatcher closeTo(MagnificationSpec spec) {
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.accessibility;
|
||||
package com.android.server.accessibility.magnification;
|
||||
|
||||
import static android.view.MotionEvent.ACTION_DOWN;
|
||||
import static android.view.MotionEvent.ACTION_MOVE;
|
||||
@@ -51,6 +51,8 @@ import android.view.ViewConfiguration;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.server.accessibility.AccessibilityManagerService;
|
||||
import com.android.server.accessibility.EventStreamTransformation;
|
||||
import com.android.server.accessibility.magnification.MagnificationGestureHandler.ScaleChangedListener;
|
||||
import com.android.server.testutils.OffsettableClock;
|
||||
import com.android.server.testutils.TestHandler;
|
||||
@@ -121,7 +123,7 @@ public class FullScreenMagnificationGestureHandlerTest {
|
||||
private static final int DISPLAY_0 = 0;
|
||||
|
||||
private Context mContext;
|
||||
MagnificationController mMagnificationController;
|
||||
FullScreenMagnificationController mFullScreenMagnificationController;
|
||||
@Mock
|
||||
ScaleChangedListener mMockScaleChangedListener;
|
||||
|
||||
@@ -135,8 +137,8 @@ public class FullScreenMagnificationGestureHandlerTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = InstrumentationRegistry.getContext();
|
||||
final MagnificationController.ControllerContext mockController =
|
||||
mock(MagnificationController.ControllerContext.class);
|
||||
final FullScreenMagnificationController.ControllerContext mockController =
|
||||
mock(FullScreenMagnificationController.ControllerContext.class);
|
||||
final WindowManagerInternal mockWindowManager = mock(WindowManagerInternal.class);
|
||||
when(mockController.getContext()).thenReturn(mContext);
|
||||
when(mockController.getAms()).thenReturn(mock(AccessibilityManagerService.class));
|
||||
@@ -145,7 +147,8 @@ public class FullScreenMagnificationGestureHandlerTest {
|
||||
when(mockController.newValueAnimator()).thenReturn(new ValueAnimator());
|
||||
when(mockController.getAnimationDuration()).thenReturn(1000L);
|
||||
when(mockWindowManager.setMagnificationCallbacks(eq(DISPLAY_0), any())).thenReturn(true);
|
||||
mMagnificationController = new MagnificationController(mockController, new Object()) {
|
||||
mFullScreenMagnificationController = new FullScreenMagnificationController(mockController,
|
||||
new Object()) {
|
||||
@Override
|
||||
public boolean magnificationRegionContains(int displayId, float x, float y) {
|
||||
return true;
|
||||
@@ -154,7 +157,7 @@ public class FullScreenMagnificationGestureHandlerTest {
|
||||
@Override
|
||||
void setForceShowMagnifiableBounds(int displayId, boolean show) {}
|
||||
};
|
||||
mMagnificationController.register(DISPLAY_0);
|
||||
mFullScreenMagnificationController.register(DISPLAY_0);
|
||||
mClock = new OffsettableClock.Stopped();
|
||||
|
||||
boolean detectTripleTap = true;
|
||||
@@ -164,14 +167,14 @@ public class FullScreenMagnificationGestureHandlerTest {
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mMagnificationController.unregister(DISPLAY_0);
|
||||
mFullScreenMagnificationController.unregister(DISPLAY_0);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private FullScreenMagnificationGestureHandler newInstance(boolean detectTripleTap,
|
||||
boolean detectShortcutTrigger) {
|
||||
FullScreenMagnificationGestureHandler h = new FullScreenMagnificationGestureHandler(
|
||||
mContext, mMagnificationController, mMockScaleChangedListener,
|
||||
mContext, mFullScreenMagnificationController, mMockScaleChangedListener,
|
||||
detectTripleTap, detectShortcutTrigger, DISPLAY_0);
|
||||
mHandler = new TestHandler(h.mDetectingState, mClock) {
|
||||
@Override
|
||||
@@ -653,7 +656,7 @@ public class FullScreenMagnificationGestureHandlerTest {
|
||||
}
|
||||
|
||||
private boolean isZoomed() {
|
||||
return mMgh.mMagnificationController.isMagnifying(DISPLAY_0);
|
||||
return mMgh.mFullScreenMagnificationController.isMagnifying(DISPLAY_0);
|
||||
}
|
||||
|
||||
private int tapCount() {
|
||||
Reference in New Issue
Block a user