Loading services/accessibility/java/com/android/server/accessibility/gestures/EventDispatcher.java +3 −3 Original line number Diff line number Diff line Loading @@ -301,7 +301,7 @@ class EventDispatcher { * @param policyFlags The policy flags associated with the event. */ void sendUpForInjectedDownPointers(MotionEvent prototype, int policyFlags) { int pointerIdBits = 0; int pointerIdBits = prototype.getPointerIdBits(); final int pointerCount = prototype.getPointerCount(); for (int i = 0; i < pointerCount; i++) { final int pointerId = prototype.getPointerId(i); Loading @@ -309,10 +309,10 @@ class EventDispatcher { if (!isInjectedPointerDown(pointerId)) { continue; } pointerIdBits |= (1 << pointerId); final int action = computeInjectionAction(MotionEvent.ACTION_UP, i); final int action = computeInjectionAction(MotionEvent.ACTION_POINTER_UP, i); sendMotionEvent( prototype, action, mState.getLastReceivedEvent(), pointerIdBits, policyFlags); pointerIdBits &= ~(1 << pointerId); } } } services/tests/servicestests/src/com/android/server/accessibility/gestures/TouchExplorerTest.java +36 −2 Original line number Diff line number Diff line Loading @@ -89,10 +89,13 @@ public class TouchExplorerTest { @Override public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) { MotionEventMatcher lastEventMatcher = new MotionEventMatcher(mLastEvent); mEvents.add(0, event.copy()); // LastEvent may not match if we're clearing the state if (mLastEvent != null) { MotionEventMatcher lastEventMatcher = new MotionEventMatcher(mLastEvent); assertThat(rawEvent, lastEventMatcher); } } @Override public void setNext(EventStreamTransformation next) { Loading Loading @@ -125,6 +128,31 @@ public class TouchExplorerTest { assertCapturedEventsNoHistory(); } @Test public void upEventWhenInTwoFingerMove_clearsState() { goFromStateClearTo(STATE_MOVING_2FINGERS); send(upEvent()); assertState(STATE_CLEAR); } @Test public void clearEventsWhenInTwoFingerMove_clearsStateAndSendsUp() { goFromStateClearTo(STATE_MOVING_2FINGERS); // Clear last event so we don't try to match against anything when cleanup events are sent // for the clear mLastEvent = null; mTouchExplorer.clearEvents(InputDevice.SOURCE_TOUCHSCREEN); assertState(STATE_CLEAR); List<MotionEvent> events = getCapturedEvents(); assertCapturedEvents( MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN, MotionEvent.ACTION_POINTER_UP, MotionEvent.ACTION_UP); } @Test public void testTwoFingersDrag_shouldDraggingAndActionDown() { goFromStateClearTo(STATE_DRAGGING_2FINGERS); Loading Loading @@ -268,6 +296,12 @@ public class TouchExplorerTest { DEFAULT_Y, 0)); } private MotionEvent upEvent() { MotionEvent event = downEvent(); event.setAction(MotionEvent.ACTION_UP); return event; } private MotionEvent pointerDownEvent() { final int secondPointerId = 0x0100; final int action = MotionEvent.ACTION_POINTER_DOWN | secondPointerId; Loading Loading
services/accessibility/java/com/android/server/accessibility/gestures/EventDispatcher.java +3 −3 Original line number Diff line number Diff line Loading @@ -301,7 +301,7 @@ class EventDispatcher { * @param policyFlags The policy flags associated with the event. */ void sendUpForInjectedDownPointers(MotionEvent prototype, int policyFlags) { int pointerIdBits = 0; int pointerIdBits = prototype.getPointerIdBits(); final int pointerCount = prototype.getPointerCount(); for (int i = 0; i < pointerCount; i++) { final int pointerId = prototype.getPointerId(i); Loading @@ -309,10 +309,10 @@ class EventDispatcher { if (!isInjectedPointerDown(pointerId)) { continue; } pointerIdBits |= (1 << pointerId); final int action = computeInjectionAction(MotionEvent.ACTION_UP, i); final int action = computeInjectionAction(MotionEvent.ACTION_POINTER_UP, i); sendMotionEvent( prototype, action, mState.getLastReceivedEvent(), pointerIdBits, policyFlags); pointerIdBits &= ~(1 << pointerId); } } }
services/tests/servicestests/src/com/android/server/accessibility/gestures/TouchExplorerTest.java +36 −2 Original line number Diff line number Diff line Loading @@ -89,10 +89,13 @@ public class TouchExplorerTest { @Override public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) { MotionEventMatcher lastEventMatcher = new MotionEventMatcher(mLastEvent); mEvents.add(0, event.copy()); // LastEvent may not match if we're clearing the state if (mLastEvent != null) { MotionEventMatcher lastEventMatcher = new MotionEventMatcher(mLastEvent); assertThat(rawEvent, lastEventMatcher); } } @Override public void setNext(EventStreamTransformation next) { Loading Loading @@ -125,6 +128,31 @@ public class TouchExplorerTest { assertCapturedEventsNoHistory(); } @Test public void upEventWhenInTwoFingerMove_clearsState() { goFromStateClearTo(STATE_MOVING_2FINGERS); send(upEvent()); assertState(STATE_CLEAR); } @Test public void clearEventsWhenInTwoFingerMove_clearsStateAndSendsUp() { goFromStateClearTo(STATE_MOVING_2FINGERS); // Clear last event so we don't try to match against anything when cleanup events are sent // for the clear mLastEvent = null; mTouchExplorer.clearEvents(InputDevice.SOURCE_TOUCHSCREEN); assertState(STATE_CLEAR); List<MotionEvent> events = getCapturedEvents(); assertCapturedEvents( MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN, MotionEvent.ACTION_POINTER_UP, MotionEvent.ACTION_UP); } @Test public void testTwoFingersDrag_shouldDraggingAndActionDown() { goFromStateClearTo(STATE_DRAGGING_2FINGERS); Loading Loading @@ -268,6 +296,12 @@ public class TouchExplorerTest { DEFAULT_Y, 0)); } private MotionEvent upEvent() { MotionEvent event = downEvent(); event.setAction(MotionEvent.ACTION_UP); return event; } private MotionEvent pointerDownEvent() { final int secondPointerId = 0x0100; final int action = MotionEvent.ACTION_POINTER_DOWN | secondPointerId; Loading