Do not synthesize events for relative mouse movement.

If apps opt into relative mouse movement they must be prepared to
handle the events.

Bug: 268243026
Test: no synthetic key events are generated by an app with mouse
      capture that does not mark its events as handled.
Change-Id: I591c0036801473032d5e34a4c9ca3c1fd6215761
This commit is contained in:
Tom Cherry
2023-03-02 21:11:29 -08:00
parent 9f16957b06
commit b5ea1693b5

View File

@@ -7072,7 +7072,11 @@ public final class ViewRootImpl implements ViewParent,
final MotionEvent event = (MotionEvent)q.mEvent;
final int source = event.getSource();
if ((source & InputDevice.SOURCE_CLASS_TRACKBALL) != 0) {
mTrackball.process(event);
// Do not synthesize events for relative mouse movement. If apps opt into
// relative mouse movement they must be prepared to handle the events.
if (!event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE)) {
mTrackball.process(event);
}
return FINISH_HANDLED;
} else if ((source & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
mJoystick.process(event);