diff options
3 files changed, 18 insertions, 18 deletions
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityGestureDetector.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityGestureDetector.java index b95d2e689873..075c2fe47f32 100644 --- a/services/accessibility/java/com/android/server/accessibility/AccessibilityGestureDetector.java +++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityGestureDetector.java @@ -235,14 +235,15 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen * callback on mListener is called, and the return value of the callback is * passed to the caller. * - * @param event The raw motion event. It's important that this be the raw + * @param event The transformed motion event to be handled. + * @param rawEvent The raw motion event. It's important that this be the raw * event, before any transformations have been applied, so that measurements * can be made in physical units. * @param policyFlags Policy flags for the event. * * @return true if the event is consumed, else false */ - public boolean onMotionEvent(MotionEvent event, int policyFlags) { + public boolean onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) { // Construct GestureDetector double-tap detector on demand, so that testable sub-class // can use mock GestureDetector. @@ -255,12 +256,14 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen mGestureDetector.setOnDoubleTapListener(this); } - final float x = event.getX(); - final float y = event.getY(); - final long time = event.getEventTime(); + // The accessibility gesture detector is interested in the movements in physical space, + // so it uses the rawEvent to ignore magnification and other transformations. + final float x = rawEvent.getX(); + final float y = rawEvent.getY(); + final long time = rawEvent.getEventTime(); mPolicyFlags = policyFlags; - switch (event.getActionMasked()) { + switch (rawEvent.getActionMasked()) { case MotionEvent.ACTION_DOWN: mDoubleTapDetected = false; mSecondFingerDoubleTap = false; @@ -311,7 +314,7 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen // timeout, cancel gesture detection. if (timeDelta > threshold) { cancelGesture(); - return mListener.onGestureCancelled(event, policyFlags); + return mListener.onGestureCancelled(rawEvent, policyFlags); } } @@ -327,7 +330,7 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen case MotionEvent.ACTION_UP: if (mDoubleTapDetected) { - return finishDoubleTap(event, policyFlags); + return finishDoubleTap(rawEvent, policyFlags); } if (mGestureStarted) { final float dX = Math.abs(x - mPreviousGestureX); @@ -335,7 +338,7 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen if (dX >= mMinPixelsBetweenSamplesX || dY >= mMinPixelsBetweenSamplesY) { mStrokeBuffer.add(new GesturePoint(x, y, time)); } - return recognizeGesture(event, policyFlags); + return recognizeGesture(rawEvent, policyFlags); } break; @@ -344,7 +347,7 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen // recognizing a gesture. cancelGesture(); - if (event.getPointerCount() == 2) { + if (rawEvent.getPointerCount() == 2) { // If this was the second finger, attempt to recognize double // taps on it. mSecondFingerDoubleTap = true; @@ -360,7 +363,7 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen // If we're detecting taps on the second finger, see if we // should finish the double tap. if (mSecondFingerDoubleTap && mDoubleTapDetected) { - return finishDoubleTap(event, policyFlags); + return finishDoubleTap(rawEvent, policyFlags); } break; @@ -372,7 +375,7 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen // If we're detecting taps on the second finger, map events from the // finger to the first finger. if (mSecondFingerDoubleTap) { - MotionEvent newEvent = mapSecondPointerToFirstPointer(event); + MotionEvent newEvent = mapSecondPointerToFirstPointer(rawEvent); if (newEvent == null) { return false; } @@ -385,7 +388,7 @@ class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListen return false; } - // Pass the event on to the standard gesture detector. + // Pass the transformed event on to the standard gesture detector. return mGestureDetector.onTouchEvent(event); } diff --git a/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java b/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java index 84a8d45a99b9..2cae060eb071 100644 --- a/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java +++ b/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java @@ -268,10 +268,7 @@ class TouchExplorer extends BaseEventStreamTransformation mReceivedPointerTracker.onMotionEvent(rawEvent); - // The motion detector is interested in the movements in physical space, - // so it uses the rawEvent to ignore magnification and other - // transformations. - if (mGestureDetector.onMotionEvent(rawEvent, policyFlags)) { + if (mGestureDetector.onMotionEvent(event, rawEvent, policyFlags)) { // Event was handled by the gesture detector. return; } diff --git a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityGestureDetectorTest.java b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityGestureDetectorTest.java index 14abb8a1d7bf..41b834ac1a83 100644 --- a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityGestureDetectorTest.java +++ b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityGestureDetectorTest.java @@ -195,7 +195,7 @@ public class AccessibilityGestureDetectorTest { point.x, point.y, 0); // Send event. - mDetector.onMotionEvent(event, policyFlags); + mDetector.onMotionEvent(event, event, policyFlags); eventTimeMs += PATH_STEP_MILLISEC; } |