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

Commit fb6dd3bb authored by Phil Weaver's avatar Phil Weaver Committed by Android (Google) Code Review
Browse files

Merge "Treat accessibility gestures like physical ones." into nyc-dev

parents cff10250 155dda1e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -600,11 +600,16 @@ public abstract class AccessibilityService extends Service {
     * Dispatch a gesture to the touch screen. Any gestures currently in progress, whether from
     * the user, this service, or another service, will be cancelled.
     * <p>
     * The gesture will be dispatched as if it were performed directly on the screen by a user, so
     * the events may be affected by features such as magnification and explore by touch.
     * </p>
     * <p>
     * <strong>Note:</strong> In order to dispatch gestures, your service
     * must declare the capability by setting the
     * {@link android.R.styleable#AccessibilityService_canPerformGestures}
     * property in its meta-data. For more information, see
     * {@link #SERVICE_META_DATA}.
     * </p>
     *
     * @param gesture The gesture to dispatch
     * @param callback The object to call back when the status of the gesture is known. If
+6 −6
Original line number Diff line number Diff line
@@ -363,12 +363,6 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
    private void enableFeatures() {
        resetStreamState();

        if ((mEnabledFeatures & FLAG_FEATURE_INJECT_MOTION_EVENTS) != 0) {
            mMotionEventInjector = new MotionEventInjector(mContext.getMainLooper());
            addFirstEventHandler(mMotionEventInjector);
            mAms.setMotionEventInjector(mMotionEventInjector);
        }

        if ((mEnabledFeatures & FLAG_FEATURE_AUTOCLICK) != 0) {
            mAutoclickController = new AutoclickController(mContext, mUserId);
            addFirstEventHandler(mAutoclickController);
@@ -384,6 +378,12 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
            addFirstEventHandler(mMagnificationGestureHandler);
        }

        if ((mEnabledFeatures & FLAG_FEATURE_INJECT_MOTION_EVENTS) != 0) {
            mMotionEventInjector = new MotionEventInjector(mContext.getMainLooper());
            addFirstEventHandler(mMotionEventInjector);
            mAms.setMotionEventInjector(mMotionEventInjector);
        }

        if ((mEnabledFeatures & FLAG_FEATURE_FILTER_KEY_EVENTS) != 0) {
            mKeyboardInterceptor = new KeyboardInterceptor(mAms);
            addFirstEventHandler(mKeyboardInterceptor);
+6 −6
Original line number Diff line number Diff line
@@ -156,10 +156,10 @@ class MagnificationController {
            final float offsetY = sentSpec.offsetY;

            // Compute the new center and update spec as needed.
            final float centerX = (mMagnifiedBounds.width() / 2.0f
                    + mMagnifiedBounds.left - offsetX) / scale;
            final float centerY = (mMagnifiedBounds.height() / 2.0f
                    + mMagnifiedBounds.top - offsetY) / scale;
            final float centerX = (mMagnifiedBounds.width() / 2.0f - offsetX) / scale
                    + mMagnifiedBounds.left;
            final float centerY = (mMagnifiedBounds.height() / 2.0f - offsetY) / scale
                    + mMagnifiedBounds.top;
            if (updateSpec) {
                setScaleAndCenter(scale, centerX, centerY, false);
            } else {
@@ -256,7 +256,7 @@ class MagnificationController {
    public float getCenterX() {
        synchronized (mLock) {
            return  (mMagnifiedBounds.width() / 2.0f
                    + mMagnifiedBounds.left - getOffsetX()) / getScale();
                   - getOffsetX()) / getScale() + mMagnifiedBounds.left;
        }
    }

@@ -279,7 +279,7 @@ class MagnificationController {
    public float getCenterY() {
        synchronized (mLock) {
            return (mMagnifiedBounds.height() / 2.0f
                    + mMagnifiedBounds.top - getOffsetY()) / getScale();
                    - getOffsetY()) / getScale() + mMagnifiedBounds.top;
        }
    }