Loading core/java/android/view/View.java +7 −9 Original line number Diff line number Diff line Loading @@ -16860,7 +16860,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // Window is obscured, drop this touch. return false; } if (android.view.accessibility.Flags.preventA11yNontoolFromInjectingIntoSensitiveViews()) { if (event.isInjectedFromAccessibilityService() // If the event came from an Accessibility Service that does *not* declare // itself as AccessibilityServiceInfo#isAccessibilityTool and this View is Loading @@ -16869,7 +16868,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, && !event.isInjectedFromAccessibilityTool() && isAccessibilityDataSensitive()) { return false; } } return true; } core/java/android/view/accessibility/flags/accessibility_flags.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -237,16 +237,6 @@ flag { bug: "410601652" } flag { name: "prevent_a11y_nontool_from_injecting_into_sensitive_views" namespace: "accessibility" description: "Prevents injected gestures from A11yServices without isAccessibilityTool=true from reaching AccessibilityDataSensitive UI elements" bug: "284180538" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "prevent_leaking_viewrootimpl" namespace: "accessibility" Loading services/accessibility/accessibility.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -216,16 +216,6 @@ flag { } } flag { name: "motion_event_injector_cancel_fix" namespace: "accessibility" description: "Fix the ACTION_CANCEL logic used in MotionEventInjector to avoid InputDispatcher inconsistency" bug: "384451671" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "only_reset_magnification_if_needed_when_destroy_handler" namespace: "accessibility" Loading services/accessibility/java/com/android/server/accessibility/MotionEventInjector.java +9 −29 Original line number Diff line number Diff line Loading @@ -137,19 +137,8 @@ public class MotionEventInjector extends BaseEventStreamTransformation implement && mOpenTouchGestureInProgress) { return; } if (Flags.motionEventInjectorCancelFix()) { // Pass this real event down the stream unmodified. super.onMotionEvent(event, rawEvent, policyFlags); } else { cancelAnyPendingInjectedEvents(); if (!android.view.accessibility.Flags .preventA11yNontoolFromInjectingIntoSensitiveViews()) { // Indicate that the input event is injected from accessibility, to let applications // distinguish it from events injected by other means. policyFlags |= WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY; } sendMotionEventToNext(event, rawEvent, policyFlags); } } @Override Loading Loading @@ -189,12 +178,10 @@ public class MotionEventInjector extends BaseEventStreamTransformation implement MotionEvent motionEvent = (MotionEvent) message.obj; int policyFlags = WindowManagerPolicyConstants.FLAG_PASS_TO_USER | WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY; if (android.view.accessibility.Flags.preventA11yNontoolFromInjectingIntoSensitiveViews()) { boolean fromAccessibilityTool = message.arg2 == 1; if (fromAccessibilityTool) { policyFlags |= WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY_TOOL; } } sendMotionEventToNext(motionEvent, motionEvent, policyFlags); boolean isEndOfSequence = message.arg1 != 0; if (isEndOfSequence) { Loading Loading @@ -234,10 +221,6 @@ public class MotionEventInjector extends BaseEventStreamTransformation implement } if (!continuingGesture) { cancelAnyPendingInjectedEvents(); if (!Flags.motionEventInjectorCancelFix()) { // Injected gestures have been canceled, but real gestures still need cancelling cancelInjectedGestureInProgress(); } } mServiceInterfaceForCurrentGesture = serviceInterface; Loading Loading @@ -354,13 +337,10 @@ public class MotionEventInjector extends BaseEventStreamTransformation implement obtainMotionEvent(now, now, MotionEvent.ACTION_CANCEL, getLastTouchPoints(), 1); int policyFlags = WindowManagerPolicyConstants.FLAG_PASS_TO_USER | WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY; if (android.view.accessibility.Flags .preventA11yNontoolFromInjectingIntoSensitiveViews()) { // ACTION_CANCEL events are internal system details for event stream state // management and not used for performing new actions, so always treat them as // originating from an accessibility tool. policyFlags |= WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY_TOOL; } sendMotionEventToNext(cancelEvent, cancelEvent, policyFlags); mOpenTouchGestureInProgress = false; } Loading services/tests/servicestests/src/com/android/server/accessibility/MotionEventInjectorTest.java +0 −129 Original line number Diff line number Diff line Loading @@ -20,14 +20,12 @@ import static android.view.KeyCharacterMap.VIRTUAL_KEYBOARD; import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_HOVER_MOVE; import static android.view.MotionEvent.ACTION_UP; import static android.view.accessibility.Flags.FLAG_PREVENT_A11Y_NONTOOL_FROM_INJECTING_INTO_SENSITIVE_VIEWS; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.everyItem; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; Loading @@ -46,8 +44,6 @@ import android.graphics.Point; import android.os.Handler; import android.os.Message; import android.os.RemoteException; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.view.Display; import android.view.InputDevice; Loading Loading @@ -234,7 +230,6 @@ public class MotionEventInjectorTest { } @Test @EnableFlags(FLAG_PREVENT_A11Y_NONTOOL_FROM_INJECTING_INTO_SENSITIVE_VIEWS) public void testInjectEvents_fromAccessibilityTool_providesToolPolicyFlag() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE, Loading Loading @@ -273,25 +268,6 @@ public class MotionEventInjectorTest { } @Test @DisableFlags({ FLAG_PREVENT_A11Y_NONTOOL_FROM_INJECTING_INTO_SENSITIVE_VIEWS, Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX }) public void testRegularEvent_afterGestureComplete_shouldPassToNext_withFlagInjectedFromA11y() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); mMessageCapturingHandler.sendAllMessages(); // Send all motion events reset(next); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); verify(next).onMotionEvent(argThat(mIsClickDown), argThat(mIsClickDown), eq(WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY)); } @Test @EnableFlags({ FLAG_PREVENT_A11Y_NONTOOL_FROM_INJECTING_INTO_SENSITIVE_VIEWS, Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX }) public void testRegularEvent_afterGestureComplete_shouldPassToNext_withNoPolicyFlagChanges() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); Loading @@ -304,26 +280,6 @@ public class MotionEventInjectorTest { } @Test @DisableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testInjectEvents_withRealGestureUnderway_shouldCancelRealAndPassInjected() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); verify(next, times(2)).onMotionEvent(mCaptor1.capture(), mCaptor2.capture(), anyInt()); assertThat(mCaptor1.getAllValues().get(0), mIsClickDown); assertThat(mCaptor1.getAllValues().get(1), IS_ACTION_CANCEL); reset(next); mMessageCapturingHandler.sendOneMessage(); // Send a motion event verify(next).onMotionEvent( argThat(mIsLineStart), argThat(mIsLineStart), eq(WindowManagerPolicyConstants.FLAG_PASS_TO_USER | WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY)); } @Test @EnableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testInjectEvents_withRealGestureUnderway_shouldNotCancelReal_ShouldPassInjected() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); Loading Loading @@ -378,23 +334,6 @@ public class MotionEventInjectorTest { } @Test @DisableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testOnMotionEvents_openInjectedGestureInProgress_shouldCancelAndNotifyAndPassReal() throws RemoteException { EventStreamTransformation next = attachMockNext(mMotionEventInjector); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); mMessageCapturingHandler.sendOneMessage(); // Send a motion event mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); verify(next, times(3)).onMotionEvent(mCaptor1.capture(), mCaptor2.capture(), anyInt()); assertThat(mCaptor1.getAllValues().get(0), mIsLineStart); assertThat(mCaptor1.getAllValues().get(1), IS_ACTION_CANCEL); assertThat(mCaptor1.getAllValues().get(2), mIsClickDown); verify(mServiceInterface).onPerformGestureResult(LINE_SEQUENCE, false); } @Test @EnableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testOnMotionEvents_openInjectedGestureInProgress_shouldNotCancel_shouldPassReal() throws RemoteException { EventStreamTransformation next = attachMockNext(mMotionEventInjector); Loading Loading @@ -428,36 +367,6 @@ public class MotionEventInjectorTest { verify(mServiceInterface).onPerformGestureResult(LINE_SEQUENCE, true); } @Test @DisableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testOnMotionEvents_closedInjectedGestureInProgress_shouldOnlyNotifyAndPassReal() throws RemoteException { EventStreamTransformation next = attachMockNext(mMotionEventInjector); // Tack a click down to the end of the line TouchPoint clickTouchPoint = new TouchPoint(); clickTouchPoint.mIsStartOfPath = true; clickTouchPoint.mX = CLICK_POINT.x; clickTouchPoint.mY = CLICK_POINT.y; mLineList.add(new GestureStep(0, 1, new TouchPoint[] {clickTouchPoint})); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); // Send 3 motion events, leaving the extra down in the queue mMessageCapturingHandler.sendOneMessage(); mMessageCapturingHandler.sendOneMessage(); mMessageCapturingHandler.sendOneMessage(); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); verify(next, times(4)).onMotionEvent(mCaptor1.capture(), mCaptor2.capture(), anyInt()); assertThat(mCaptor1.getAllValues().get(0), mIsLineStart); assertThat(mCaptor1.getAllValues().get(1), mIsLineMiddle); assertThat(mCaptor1.getAllValues().get(2), mIsLineEnd); assertThat(mCaptor1.getAllValues().get(3), mIsClickDown); verify(mServiceInterface).onPerformGestureResult(LINE_SEQUENCE, false); assertFalse(mMessageCapturingHandler.hasMessages()); } @Test public void testInjectEvents_openInjectedGestureInProgress_shouldCancelAndNotifyAndPassNew() throws RemoteException { Loading Loading @@ -719,28 +628,6 @@ public class MotionEventInjectorTest { assertThat(events.get(1), IS_ACTION_CANCEL); } @Test @DisableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testContinuedGesture_realGestureArrivesInBetween_getsCanceled() throws Exception { EventStreamTransformation next = attachMockNext(mMotionEventInjector); injectEventsSync(mContinuedLineList1, mServiceInterface, CONTINUED_LINE_SEQUENCE_1); mMessageCapturingHandler.sendAllMessages(); // Send all motion events verify(mServiceInterface).onPerformGestureResult(CONTINUED_LINE_SEQUENCE_1, true); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); injectEventsSync(mContinuedLineList2, mServiceInterface, CONTINUED_LINE_SEQUENCE_2); mMessageCapturingHandler.sendAllMessages(); // Send all motion events verify(mServiceInterface).onPerformGestureResult(CONTINUED_LINE_SEQUENCE_2, false); verify(next, times(4)).onMotionEvent(mCaptor1.capture(), mCaptor2.capture(), anyInt()); List<MotionEvent> events = mCaptor1.getAllValues(); assertThat(events.get(0), allOf(isAtPoint(CONTINUED_LINE_START), IS_ACTION_DOWN)); assertThat(events.get(1), allOf(isAtPoint(CONTINUED_LINE_MID1), IS_ACTION_MOVE)); assertThat(events.get(2), IS_ACTION_CANCEL); assertThat(events.get(3), allOf(isAtPoint(CLICK_POINT), IS_ACTION_DOWN)); } @Test public void testClearEvents_realGestureInProgress_shouldForgetAboutGesture() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); Loading @@ -755,22 +642,6 @@ public class MotionEventInjectorTest { } @Test @DisableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testClearEventsOnOtherSource_realGestureInProgress_shouldNotForgetAboutGesture() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); mMotionEventInjector.clearEvents(OTHER_EVENT_SOURCE); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); mMessageCapturingHandler.sendOneMessage(); // Send a motion event verify(next, times(3)).onMotionEvent(mCaptor1.capture(), mCaptor2.capture(), anyInt()); assertThat(mCaptor1.getAllValues().get(0), mIsClickDown); assertThat(mCaptor1.getAllValues().get(1), IS_ACTION_CANCEL); assertThat(mCaptor1.getAllValues().get(2), mIsLineStart); } @Test @EnableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testClearEventsOnOtherSource_shouldNotCancelRealOrInjectedGesture() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); Loading Loading
core/java/android/view/View.java +7 −9 Original line number Diff line number Diff line Loading @@ -16860,7 +16860,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // Window is obscured, drop this touch. return false; } if (android.view.accessibility.Flags.preventA11yNontoolFromInjectingIntoSensitiveViews()) { if (event.isInjectedFromAccessibilityService() // If the event came from an Accessibility Service that does *not* declare // itself as AccessibilityServiceInfo#isAccessibilityTool and this View is Loading @@ -16869,7 +16868,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, && !event.isInjectedFromAccessibilityTool() && isAccessibilityDataSensitive()) { return false; } } return true; }
core/java/android/view/accessibility/flags/accessibility_flags.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -237,16 +237,6 @@ flag { bug: "410601652" } flag { name: "prevent_a11y_nontool_from_injecting_into_sensitive_views" namespace: "accessibility" description: "Prevents injected gestures from A11yServices without isAccessibilityTool=true from reaching AccessibilityDataSensitive UI elements" bug: "284180538" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "prevent_leaking_viewrootimpl" namespace: "accessibility" Loading
services/accessibility/accessibility.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -216,16 +216,6 @@ flag { } } flag { name: "motion_event_injector_cancel_fix" namespace: "accessibility" description: "Fix the ACTION_CANCEL logic used in MotionEventInjector to avoid InputDispatcher inconsistency" bug: "384451671" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "only_reset_magnification_if_needed_when_destroy_handler" namespace: "accessibility" Loading
services/accessibility/java/com/android/server/accessibility/MotionEventInjector.java +9 −29 Original line number Diff line number Diff line Loading @@ -137,19 +137,8 @@ public class MotionEventInjector extends BaseEventStreamTransformation implement && mOpenTouchGestureInProgress) { return; } if (Flags.motionEventInjectorCancelFix()) { // Pass this real event down the stream unmodified. super.onMotionEvent(event, rawEvent, policyFlags); } else { cancelAnyPendingInjectedEvents(); if (!android.view.accessibility.Flags .preventA11yNontoolFromInjectingIntoSensitiveViews()) { // Indicate that the input event is injected from accessibility, to let applications // distinguish it from events injected by other means. policyFlags |= WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY; } sendMotionEventToNext(event, rawEvent, policyFlags); } } @Override Loading Loading @@ -189,12 +178,10 @@ public class MotionEventInjector extends BaseEventStreamTransformation implement MotionEvent motionEvent = (MotionEvent) message.obj; int policyFlags = WindowManagerPolicyConstants.FLAG_PASS_TO_USER | WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY; if (android.view.accessibility.Flags.preventA11yNontoolFromInjectingIntoSensitiveViews()) { boolean fromAccessibilityTool = message.arg2 == 1; if (fromAccessibilityTool) { policyFlags |= WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY_TOOL; } } sendMotionEventToNext(motionEvent, motionEvent, policyFlags); boolean isEndOfSequence = message.arg1 != 0; if (isEndOfSequence) { Loading Loading @@ -234,10 +221,6 @@ public class MotionEventInjector extends BaseEventStreamTransformation implement } if (!continuingGesture) { cancelAnyPendingInjectedEvents(); if (!Flags.motionEventInjectorCancelFix()) { // Injected gestures have been canceled, but real gestures still need cancelling cancelInjectedGestureInProgress(); } } mServiceInterfaceForCurrentGesture = serviceInterface; Loading Loading @@ -354,13 +337,10 @@ public class MotionEventInjector extends BaseEventStreamTransformation implement obtainMotionEvent(now, now, MotionEvent.ACTION_CANCEL, getLastTouchPoints(), 1); int policyFlags = WindowManagerPolicyConstants.FLAG_PASS_TO_USER | WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY; if (android.view.accessibility.Flags .preventA11yNontoolFromInjectingIntoSensitiveViews()) { // ACTION_CANCEL events are internal system details for event stream state // management and not used for performing new actions, so always treat them as // originating from an accessibility tool. policyFlags |= WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY_TOOL; } sendMotionEventToNext(cancelEvent, cancelEvent, policyFlags); mOpenTouchGestureInProgress = false; } Loading
services/tests/servicestests/src/com/android/server/accessibility/MotionEventInjectorTest.java +0 −129 Original line number Diff line number Diff line Loading @@ -20,14 +20,12 @@ import static android.view.KeyCharacterMap.VIRTUAL_KEYBOARD; import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_HOVER_MOVE; import static android.view.MotionEvent.ACTION_UP; import static android.view.accessibility.Flags.FLAG_PREVENT_A11Y_NONTOOL_FROM_INJECTING_INTO_SENSITIVE_VIEWS; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.everyItem; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; Loading @@ -46,8 +44,6 @@ import android.graphics.Point; import android.os.Handler; import android.os.Message; import android.os.RemoteException; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.view.Display; import android.view.InputDevice; Loading Loading @@ -234,7 +230,6 @@ public class MotionEventInjectorTest { } @Test @EnableFlags(FLAG_PREVENT_A11Y_NONTOOL_FROM_INJECTING_INTO_SENSITIVE_VIEWS) public void testInjectEvents_fromAccessibilityTool_providesToolPolicyFlag() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE, Loading Loading @@ -273,25 +268,6 @@ public class MotionEventInjectorTest { } @Test @DisableFlags({ FLAG_PREVENT_A11Y_NONTOOL_FROM_INJECTING_INTO_SENSITIVE_VIEWS, Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX }) public void testRegularEvent_afterGestureComplete_shouldPassToNext_withFlagInjectedFromA11y() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); mMessageCapturingHandler.sendAllMessages(); // Send all motion events reset(next); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); verify(next).onMotionEvent(argThat(mIsClickDown), argThat(mIsClickDown), eq(WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY)); } @Test @EnableFlags({ FLAG_PREVENT_A11Y_NONTOOL_FROM_INJECTING_INTO_SENSITIVE_VIEWS, Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX }) public void testRegularEvent_afterGestureComplete_shouldPassToNext_withNoPolicyFlagChanges() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); Loading @@ -304,26 +280,6 @@ public class MotionEventInjectorTest { } @Test @DisableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testInjectEvents_withRealGestureUnderway_shouldCancelRealAndPassInjected() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); verify(next, times(2)).onMotionEvent(mCaptor1.capture(), mCaptor2.capture(), anyInt()); assertThat(mCaptor1.getAllValues().get(0), mIsClickDown); assertThat(mCaptor1.getAllValues().get(1), IS_ACTION_CANCEL); reset(next); mMessageCapturingHandler.sendOneMessage(); // Send a motion event verify(next).onMotionEvent( argThat(mIsLineStart), argThat(mIsLineStart), eq(WindowManagerPolicyConstants.FLAG_PASS_TO_USER | WindowManagerPolicyConstants.FLAG_INJECTED_FROM_ACCESSIBILITY)); } @Test @EnableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testInjectEvents_withRealGestureUnderway_shouldNotCancelReal_ShouldPassInjected() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); Loading Loading @@ -378,23 +334,6 @@ public class MotionEventInjectorTest { } @Test @DisableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testOnMotionEvents_openInjectedGestureInProgress_shouldCancelAndNotifyAndPassReal() throws RemoteException { EventStreamTransformation next = attachMockNext(mMotionEventInjector); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); mMessageCapturingHandler.sendOneMessage(); // Send a motion event mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); verify(next, times(3)).onMotionEvent(mCaptor1.capture(), mCaptor2.capture(), anyInt()); assertThat(mCaptor1.getAllValues().get(0), mIsLineStart); assertThat(mCaptor1.getAllValues().get(1), IS_ACTION_CANCEL); assertThat(mCaptor1.getAllValues().get(2), mIsClickDown); verify(mServiceInterface).onPerformGestureResult(LINE_SEQUENCE, false); } @Test @EnableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testOnMotionEvents_openInjectedGestureInProgress_shouldNotCancel_shouldPassReal() throws RemoteException { EventStreamTransformation next = attachMockNext(mMotionEventInjector); Loading Loading @@ -428,36 +367,6 @@ public class MotionEventInjectorTest { verify(mServiceInterface).onPerformGestureResult(LINE_SEQUENCE, true); } @Test @DisableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testOnMotionEvents_closedInjectedGestureInProgress_shouldOnlyNotifyAndPassReal() throws RemoteException { EventStreamTransformation next = attachMockNext(mMotionEventInjector); // Tack a click down to the end of the line TouchPoint clickTouchPoint = new TouchPoint(); clickTouchPoint.mIsStartOfPath = true; clickTouchPoint.mX = CLICK_POINT.x; clickTouchPoint.mY = CLICK_POINT.y; mLineList.add(new GestureStep(0, 1, new TouchPoint[] {clickTouchPoint})); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); // Send 3 motion events, leaving the extra down in the queue mMessageCapturingHandler.sendOneMessage(); mMessageCapturingHandler.sendOneMessage(); mMessageCapturingHandler.sendOneMessage(); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); verify(next, times(4)).onMotionEvent(mCaptor1.capture(), mCaptor2.capture(), anyInt()); assertThat(mCaptor1.getAllValues().get(0), mIsLineStart); assertThat(mCaptor1.getAllValues().get(1), mIsLineMiddle); assertThat(mCaptor1.getAllValues().get(2), mIsLineEnd); assertThat(mCaptor1.getAllValues().get(3), mIsClickDown); verify(mServiceInterface).onPerformGestureResult(LINE_SEQUENCE, false); assertFalse(mMessageCapturingHandler.hasMessages()); } @Test public void testInjectEvents_openInjectedGestureInProgress_shouldCancelAndNotifyAndPassNew() throws RemoteException { Loading Loading @@ -719,28 +628,6 @@ public class MotionEventInjectorTest { assertThat(events.get(1), IS_ACTION_CANCEL); } @Test @DisableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testContinuedGesture_realGestureArrivesInBetween_getsCanceled() throws Exception { EventStreamTransformation next = attachMockNext(mMotionEventInjector); injectEventsSync(mContinuedLineList1, mServiceInterface, CONTINUED_LINE_SEQUENCE_1); mMessageCapturingHandler.sendAllMessages(); // Send all motion events verify(mServiceInterface).onPerformGestureResult(CONTINUED_LINE_SEQUENCE_1, true); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); injectEventsSync(mContinuedLineList2, mServiceInterface, CONTINUED_LINE_SEQUENCE_2); mMessageCapturingHandler.sendAllMessages(); // Send all motion events verify(mServiceInterface).onPerformGestureResult(CONTINUED_LINE_SEQUENCE_2, false); verify(next, times(4)).onMotionEvent(mCaptor1.capture(), mCaptor2.capture(), anyInt()); List<MotionEvent> events = mCaptor1.getAllValues(); assertThat(events.get(0), allOf(isAtPoint(CONTINUED_LINE_START), IS_ACTION_DOWN)); assertThat(events.get(1), allOf(isAtPoint(CONTINUED_LINE_MID1), IS_ACTION_MOVE)); assertThat(events.get(2), IS_ACTION_CANCEL); assertThat(events.get(3), allOf(isAtPoint(CLICK_POINT), IS_ACTION_DOWN)); } @Test public void testClearEvents_realGestureInProgress_shouldForgetAboutGesture() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); Loading @@ -755,22 +642,6 @@ public class MotionEventInjectorTest { } @Test @DisableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testClearEventsOnOtherSource_realGestureInProgress_shouldNotForgetAboutGesture() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); mMotionEventInjector.clearEvents(OTHER_EVENT_SOURCE); injectEventsSync(mLineList, mServiceInterface, LINE_SEQUENCE); mMessageCapturingHandler.sendOneMessage(); // Send a motion event verify(next, times(3)).onMotionEvent(mCaptor1.capture(), mCaptor2.capture(), anyInt()); assertThat(mCaptor1.getAllValues().get(0), mIsClickDown); assertThat(mCaptor1.getAllValues().get(1), IS_ACTION_CANCEL); assertThat(mCaptor1.getAllValues().get(2), mIsLineStart); } @Test @EnableFlags(Flags.FLAG_MOTION_EVENT_INJECTOR_CANCEL_FIX) public void testClearEventsOnOtherSource_shouldNotCancelRealOrInjectedGesture() { EventStreamTransformation next = attachMockNext(mMotionEventInjector); mMotionEventInjector.onMotionEvent(mClickDownEvent, mClickDownEvent, 0); Loading