Do not enter touch mode on non-touchscreen events

Currently ACTION_DOWN and ACTION_SCROLL cause
entering touch mode regardless of the event source.
This is especially awkward for mouse.

This should only happen when the event source is
SOURCE_TOUCHSCREEN.

Bug: 35314124
Test: android.cts.view.ViewTest#testTouchMode
Change-Id: I2205d4240be4afcbd9a3ac5558e701f7cac51926
This commit is contained in:
Vladislav Kaznacheev
2017-02-13 10:46:05 -08:00
parent d0e1022237
commit 75e5029e46

View File

@@ -4279,7 +4279,8 @@ public final class ViewRootImpl implements ViewParent,
// Enter touch mode on down or scroll.
final int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_SCROLL) {
if (event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN)
&& (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_SCROLL)) {
ensureTouchMode(true);
}