Loading services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java +1 −1 Original line number Diff line number Diff line Loading @@ -402,7 +402,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo MagnificationGestureHandler magnificationGestureHandler = new MagnificationGestureHandler(mContext, mAms.getMagnificationController(), detectControlGestures, triggerable); detectControlGestures, triggerable, displayId); addFirstEventHandler(displayId, magnificationGestureHandler); mMagnificationGestureHandler.put(displayId, magnificationGestureHandler); } Loading services/accessibility/java/com/android/server/accessibility/MagnificationGestureHandler.java +22 −31 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ import android.util.Log; import android.util.MathUtils; import android.util.Slog; import android.util.TypedValue; import android.view.Display; import android.view.GestureDetector; import android.view.GestureDetector.SimpleOnGestureListener; import android.view.MotionEvent; Loading Loading @@ -149,6 +148,8 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { private PointerCoords[] mTempPointerCoords; private PointerProperties[] mTempPointerProperties; private final int mDisplayId; private final Queue<MotionEvent> mDebugInputEventHistory; private final Queue<MotionEvent> mDebugOutputEventHistory; Loading @@ -162,11 +163,13 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { * @param detectShortcutTrigger {@code true} if this detector should be "triggerable" by some * external shortcut invoking {@link #notifyShortcutTriggered}, * {@code false} if it should ignore such triggers. * @param displayId The logical display id. */ public MagnificationGestureHandler(Context context, MagnificationController magnificationController, boolean detectTripleTap, boolean detectShortcutTrigger) { boolean detectShortcutTrigger, int displayId) { if (DEBUG_ALL) { Log.i(LOG_TAG, "MagnificationGestureHandler(detectTripleTap = " + detectTripleTap Loading @@ -174,6 +177,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { } mMagnificationController = magnificationController; mDisplayId = displayId; mDelegatingState = new DelegatingState(); mDetectingState = new DetectingState(context); Loading Loading @@ -259,8 +263,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { void notifyShortcutTriggered() { if (mDetectShortcutTrigger) { // TODO: multi-display support for magnification gesture handler boolean wasMagnifying = mMagnificationController.resetIfNeeded(Display.DEFAULT_DISPLAY, boolean wasMagnifying = mMagnificationController.resetIfNeeded(mDisplayId, /* animate */ true); if (wasMagnifying) { clearAndTransitionToStateDetecting(); Loading Loading @@ -422,8 +425,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { Slog.i(LOG_TAG, "Panned content by scrollX: " + distanceX + " scrollY: " + distanceY); } // TODO: multi-display support for magnification gesture handler mMagnificationController.offsetMagnifiedRegion(Display.DEFAULT_DISPLAY, distanceX, mMagnificationController.offsetMagnifiedRegion(mDisplayId, distanceX, distanceY, AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID); return /* event consumed: */ true; } Loading @@ -440,8 +442,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { return mScaling; } // TODO: multi-display support for magnification gesture handler final float initialScale = mMagnificationController.getScale(Display.DEFAULT_DISPLAY); final float initialScale = mMagnificationController.getScale(mDisplayId); final float targetScale = initialScale * detector.getScaleFactor(); // Don't allow a gesture to move the user further outside the Loading @@ -463,8 +464,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { final float pivotX = detector.getFocusX(); final float pivotY = detector.getFocusY(); if (DEBUG_PANNING_SCALING) Slog.i(LOG_TAG, "Scaled content to: " + scale + "x"); // TODO: multi-display support for magnification gesture handler mMagnificationController.setScale(Display.DEFAULT_DISPLAY, scale, pivotX, pivotY, false, mMagnificationController.setScale(mDisplayId, scale, pivotX, pivotY, false, AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID); return /* handled: */ true; } Loading Loading @@ -524,10 +524,9 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { } final float eventX = event.getX(); final float eventY = event.getY(); // TODO: multi-display support for magnification gesture handler if (mMagnificationController.magnificationRegionContains( Display.DEFAULT_DISPLAY, eventX, eventY)) { mMagnificationController.setCenter(Display.DEFAULT_DISPLAY, eventX, eventY, mDisplayId, eventX, eventY)) { mMagnificationController.setCenter(mDisplayId, eventX, eventY, /* animate */ mLastMoveOutsideMagnifiedRegion, AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID); mLastMoveOutsideMagnifiedRegion = false; Loading Loading @@ -665,9 +664,8 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { mHandler.removeMessages(MESSAGE_TRANSITION_TO_DELEGATING_STATE); // TODO: multi-display support for magnification gesture handler if (!mMagnificationController.magnificationRegionContains( Display.DEFAULT_DISPLAY, event.getX(), event.getY())) { mDisplayId, event.getX(), event.getY())) { transitionToDelegatingStateAndClear(); Loading @@ -684,8 +682,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { // If magnified, delay an ACTION_DOWN for mMultiTapMaxDelay // to ensure reachability of // STATE_PANNING_SCALING(triggerable with ACTION_POINTER_DOWN) // TODO: multi-display support for magnification gesture handler || mMagnificationController.isMagnifying(Display.DEFAULT_DISPLAY)) { || mMagnificationController.isMagnifying(mDisplayId)) { afterMultiTapTimeoutTransitionToDelegatingState(); Loading @@ -697,8 +694,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { } break; case ACTION_POINTER_DOWN: { // TODO: multi-display support for magnification gesture handler if (mMagnificationController.isMagnifying(Display.DEFAULT_DISPLAY)) { if (mMagnificationController.isMagnifying(mDisplayId)) { transitionTo(mPanningScalingState); clear(); } else { Loading Loading @@ -727,9 +723,8 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { mHandler.removeMessages(MESSAGE_ON_TRIPLE_TAP_AND_HOLD); // TODO: multi-display support for magnification gesture handler if (!mMagnificationController.magnificationRegionContains( Display.DEFAULT_DISPLAY, event.getX(), event.getY())) { mDisplayId, event.getX(), event.getY())) { transitionToDelegatingStateAndClear(); Loading Loading @@ -880,8 +875,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { clear(); // Toggle zoom // TODO: multi-display support for magnification gesture handler if (mMagnificationController.isMagnifying(Display.DEFAULT_DISPLAY)) { if (mMagnificationController.isMagnifying(mDisplayId)) { zoomOff(); } else { zoomOn(up.getX(), up.getY()); Loading @@ -893,9 +887,8 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { if (DEBUG_DETECTING) Slog.i(LOG_TAG, "onTripleTapAndHold()"); clear(); // TODO: multi-display support for magnification gesture handler mViewportDraggingState.mZoomedInBeforeDrag = mMagnificationController.isMagnifying(Display.DEFAULT_DISPLAY); mMagnificationController.isMagnifying(mDisplayId); zoomOn(down.getX(), down.getY()); Loading @@ -922,8 +915,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { if (DEBUG_DETECTING) Slog.i(LOG_TAG, "setShortcutTriggered(" + state + ")"); mShortcutTriggered = state; // TODO: multi-display support for magnification gesture handler mMagnificationController.setForceShowMagnifiableBounds(Display.DEFAULT_DISPLAY, state); mMagnificationController.setForceShowMagnifiableBounds(mDisplayId, state); } /** Loading Loading @@ -958,8 +950,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { final float scale = MathUtils.constrain( mMagnificationController.getPersistedScale(), MIN_SCALE, MAX_SCALE); // TODO: multi-display support for magnification gesture handler mMagnificationController.setScaleAndCenter(Display.DEFAULT_DISPLAY, mMagnificationController.setScaleAndCenter(mDisplayId, scale, centerX, centerY, /* animate */ true, AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID); Loading @@ -967,8 +958,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { private void zoomOff() { if (DEBUG_DETECTING) Slog.i(LOG_TAG, "zoomOff()"); // TODO: multi-display support for magnification gesture handler mMagnificationController.reset(Display.DEFAULT_DISPLAY, /* animate */ true); mMagnificationController.reset(mDisplayId, /* animate */ true); } private static MotionEvent recycleAndNullify(@Nullable MotionEvent event) { Loading @@ -990,6 +980,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { ", mCurrentState=" + State.nameOf(mCurrentState) + ", mPreviousState=" + State.nameOf(mPreviousState) + ", mMagnificationController=" + mMagnificationController + ", mDisplayId=" + mDisplayId + '}'; } Loading services/accessibility/java/com/android/server/accessibility/TouchExplorer.java +2 −2 Original line number Diff line number Diff line Loading @@ -435,7 +435,7 @@ class TouchExplorer extends BaseEventStreamTransformation MotionEvent click_event = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), MotionEvent.ACTION_DOWN, 1, properties, coords, 0, 0, 1.0f, 1.0f, event.getDeviceId(), 0, event.getSource(), event.getFlags()); event.getSource(), event.getDisplayId(), event.getFlags()); final boolean targetAccessibilityFocus = (result == CLICK_LOCATION_ACCESSIBILITY_FOCUS); sendActionDownAndUp(click_event, policyFlags, targetAccessibilityFocus); click_event.recycle(); Loading Loading @@ -1029,7 +1029,7 @@ class TouchExplorer extends BaseEventStreamTransformation event.getEventTime(), event.getAction(), event.getPointerCount(), props, coords, event.getMetaState(), event.getButtonState(), 1.0f, 1.0f, event.getDeviceId(), event.getEdgeFlags(), event.getSource(), event.getFlags()); event.getSource(), event.getDisplayId(), event.getFlags()); } /** Loading services/tests/servicestests/src/com/android/server/accessibility/MagnificationGestureHandlerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ public class MagnificationGestureHandlerTest { boolean detectShortcutTrigger) { MagnificationGestureHandler h = new MagnificationGestureHandler( mContext, mMagnificationController, detectTripleTap, detectShortcutTrigger); detectTripleTap, detectShortcutTrigger, DISPLAY_0); mHandler = new TestHandler(h.mDetectingState, mClock) { @Override protected String messageToString(Message m) { Loading Loading
services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java +1 −1 Original line number Diff line number Diff line Loading @@ -402,7 +402,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo MagnificationGestureHandler magnificationGestureHandler = new MagnificationGestureHandler(mContext, mAms.getMagnificationController(), detectControlGestures, triggerable); detectControlGestures, triggerable, displayId); addFirstEventHandler(displayId, magnificationGestureHandler); mMagnificationGestureHandler.put(displayId, magnificationGestureHandler); } Loading
services/accessibility/java/com/android/server/accessibility/MagnificationGestureHandler.java +22 −31 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ import android.util.Log; import android.util.MathUtils; import android.util.Slog; import android.util.TypedValue; import android.view.Display; import android.view.GestureDetector; import android.view.GestureDetector.SimpleOnGestureListener; import android.view.MotionEvent; Loading Loading @@ -149,6 +148,8 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { private PointerCoords[] mTempPointerCoords; private PointerProperties[] mTempPointerProperties; private final int mDisplayId; private final Queue<MotionEvent> mDebugInputEventHistory; private final Queue<MotionEvent> mDebugOutputEventHistory; Loading @@ -162,11 +163,13 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { * @param detectShortcutTrigger {@code true} if this detector should be "triggerable" by some * external shortcut invoking {@link #notifyShortcutTriggered}, * {@code false} if it should ignore such triggers. * @param displayId The logical display id. */ public MagnificationGestureHandler(Context context, MagnificationController magnificationController, boolean detectTripleTap, boolean detectShortcutTrigger) { boolean detectShortcutTrigger, int displayId) { if (DEBUG_ALL) { Log.i(LOG_TAG, "MagnificationGestureHandler(detectTripleTap = " + detectTripleTap Loading @@ -174,6 +177,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { } mMagnificationController = magnificationController; mDisplayId = displayId; mDelegatingState = new DelegatingState(); mDetectingState = new DetectingState(context); Loading Loading @@ -259,8 +263,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { void notifyShortcutTriggered() { if (mDetectShortcutTrigger) { // TODO: multi-display support for magnification gesture handler boolean wasMagnifying = mMagnificationController.resetIfNeeded(Display.DEFAULT_DISPLAY, boolean wasMagnifying = mMagnificationController.resetIfNeeded(mDisplayId, /* animate */ true); if (wasMagnifying) { clearAndTransitionToStateDetecting(); Loading Loading @@ -422,8 +425,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { Slog.i(LOG_TAG, "Panned content by scrollX: " + distanceX + " scrollY: " + distanceY); } // TODO: multi-display support for magnification gesture handler mMagnificationController.offsetMagnifiedRegion(Display.DEFAULT_DISPLAY, distanceX, mMagnificationController.offsetMagnifiedRegion(mDisplayId, distanceX, distanceY, AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID); return /* event consumed: */ true; } Loading @@ -440,8 +442,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { return mScaling; } // TODO: multi-display support for magnification gesture handler final float initialScale = mMagnificationController.getScale(Display.DEFAULT_DISPLAY); final float initialScale = mMagnificationController.getScale(mDisplayId); final float targetScale = initialScale * detector.getScaleFactor(); // Don't allow a gesture to move the user further outside the Loading @@ -463,8 +464,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { final float pivotX = detector.getFocusX(); final float pivotY = detector.getFocusY(); if (DEBUG_PANNING_SCALING) Slog.i(LOG_TAG, "Scaled content to: " + scale + "x"); // TODO: multi-display support for magnification gesture handler mMagnificationController.setScale(Display.DEFAULT_DISPLAY, scale, pivotX, pivotY, false, mMagnificationController.setScale(mDisplayId, scale, pivotX, pivotY, false, AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID); return /* handled: */ true; } Loading Loading @@ -524,10 +524,9 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { } final float eventX = event.getX(); final float eventY = event.getY(); // TODO: multi-display support for magnification gesture handler if (mMagnificationController.magnificationRegionContains( Display.DEFAULT_DISPLAY, eventX, eventY)) { mMagnificationController.setCenter(Display.DEFAULT_DISPLAY, eventX, eventY, mDisplayId, eventX, eventY)) { mMagnificationController.setCenter(mDisplayId, eventX, eventY, /* animate */ mLastMoveOutsideMagnifiedRegion, AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID); mLastMoveOutsideMagnifiedRegion = false; Loading Loading @@ -665,9 +664,8 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { mHandler.removeMessages(MESSAGE_TRANSITION_TO_DELEGATING_STATE); // TODO: multi-display support for magnification gesture handler if (!mMagnificationController.magnificationRegionContains( Display.DEFAULT_DISPLAY, event.getX(), event.getY())) { mDisplayId, event.getX(), event.getY())) { transitionToDelegatingStateAndClear(); Loading @@ -684,8 +682,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { // If magnified, delay an ACTION_DOWN for mMultiTapMaxDelay // to ensure reachability of // STATE_PANNING_SCALING(triggerable with ACTION_POINTER_DOWN) // TODO: multi-display support for magnification gesture handler || mMagnificationController.isMagnifying(Display.DEFAULT_DISPLAY)) { || mMagnificationController.isMagnifying(mDisplayId)) { afterMultiTapTimeoutTransitionToDelegatingState(); Loading @@ -697,8 +694,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { } break; case ACTION_POINTER_DOWN: { // TODO: multi-display support for magnification gesture handler if (mMagnificationController.isMagnifying(Display.DEFAULT_DISPLAY)) { if (mMagnificationController.isMagnifying(mDisplayId)) { transitionTo(mPanningScalingState); clear(); } else { Loading Loading @@ -727,9 +723,8 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { mHandler.removeMessages(MESSAGE_ON_TRIPLE_TAP_AND_HOLD); // TODO: multi-display support for magnification gesture handler if (!mMagnificationController.magnificationRegionContains( Display.DEFAULT_DISPLAY, event.getX(), event.getY())) { mDisplayId, event.getX(), event.getY())) { transitionToDelegatingStateAndClear(); Loading Loading @@ -880,8 +875,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { clear(); // Toggle zoom // TODO: multi-display support for magnification gesture handler if (mMagnificationController.isMagnifying(Display.DEFAULT_DISPLAY)) { if (mMagnificationController.isMagnifying(mDisplayId)) { zoomOff(); } else { zoomOn(up.getX(), up.getY()); Loading @@ -893,9 +887,8 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { if (DEBUG_DETECTING) Slog.i(LOG_TAG, "onTripleTapAndHold()"); clear(); // TODO: multi-display support for magnification gesture handler mViewportDraggingState.mZoomedInBeforeDrag = mMagnificationController.isMagnifying(Display.DEFAULT_DISPLAY); mMagnificationController.isMagnifying(mDisplayId); zoomOn(down.getX(), down.getY()); Loading @@ -922,8 +915,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { if (DEBUG_DETECTING) Slog.i(LOG_TAG, "setShortcutTriggered(" + state + ")"); mShortcutTriggered = state; // TODO: multi-display support for magnification gesture handler mMagnificationController.setForceShowMagnifiableBounds(Display.DEFAULT_DISPLAY, state); mMagnificationController.setForceShowMagnifiableBounds(mDisplayId, state); } /** Loading Loading @@ -958,8 +950,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { final float scale = MathUtils.constrain( mMagnificationController.getPersistedScale(), MIN_SCALE, MAX_SCALE); // TODO: multi-display support for magnification gesture handler mMagnificationController.setScaleAndCenter(Display.DEFAULT_DISPLAY, mMagnificationController.setScaleAndCenter(mDisplayId, scale, centerX, centerY, /* animate */ true, AccessibilityManagerService.MAGNIFICATION_GESTURE_HANDLER_ID); Loading @@ -967,8 +958,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { private void zoomOff() { if (DEBUG_DETECTING) Slog.i(LOG_TAG, "zoomOff()"); // TODO: multi-display support for magnification gesture handler mMagnificationController.reset(Display.DEFAULT_DISPLAY, /* animate */ true); mMagnificationController.reset(mDisplayId, /* animate */ true); } private static MotionEvent recycleAndNullify(@Nullable MotionEvent event) { Loading @@ -990,6 +980,7 @@ class MagnificationGestureHandler extends BaseEventStreamTransformation { ", mCurrentState=" + State.nameOf(mCurrentState) + ", mPreviousState=" + State.nameOf(mPreviousState) + ", mMagnificationController=" + mMagnificationController + ", mDisplayId=" + mDisplayId + '}'; } Loading
services/accessibility/java/com/android/server/accessibility/TouchExplorer.java +2 −2 Original line number Diff line number Diff line Loading @@ -435,7 +435,7 @@ class TouchExplorer extends BaseEventStreamTransformation MotionEvent click_event = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), MotionEvent.ACTION_DOWN, 1, properties, coords, 0, 0, 1.0f, 1.0f, event.getDeviceId(), 0, event.getSource(), event.getFlags()); event.getSource(), event.getDisplayId(), event.getFlags()); final boolean targetAccessibilityFocus = (result == CLICK_LOCATION_ACCESSIBILITY_FOCUS); sendActionDownAndUp(click_event, policyFlags, targetAccessibilityFocus); click_event.recycle(); Loading Loading @@ -1029,7 +1029,7 @@ class TouchExplorer extends BaseEventStreamTransformation event.getEventTime(), event.getAction(), event.getPointerCount(), props, coords, event.getMetaState(), event.getButtonState(), 1.0f, 1.0f, event.getDeviceId(), event.getEdgeFlags(), event.getSource(), event.getFlags()); event.getSource(), event.getDisplayId(), event.getFlags()); } /** Loading
services/tests/servicestests/src/com/android/server/accessibility/MagnificationGestureHandlerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ public class MagnificationGestureHandlerTest { boolean detectShortcutTrigger) { MagnificationGestureHandler h = new MagnificationGestureHandler( mContext, mMagnificationController, detectTripleTap, detectShortcutTrigger); detectTripleTap, detectShortcutTrigger, DISPLAY_0); mHandler = new TestHandler(h.mDetectingState, mClock) { @Override protected String messageToString(Message m) { Loading