From 75e5029e4659d4a286c89bc9bc1981cc196028e6 Mon Sep 17 00:00:00 2001 From: Vladislav Kaznacheev Date: Mon, 13 Feb 2017 10:46:05 -0800 Subject: [PATCH] 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 --- core/java/android/view/ViewRootImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 9e8dda8389bff..bdaac4bf1dabd 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -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); }