summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-09-18 18:43:25 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-09-18 18:43:25 +0000
commite2502506d70a3b362a09ee2d48643537b01a692c (patch)
tree899e1cd846912074b977a2e94a2b486b37e2651d
parent6ced56d50907178d50ce3c768b15657e5fd910c7 (diff)
parent841b68bbf14452c46cf82a066a51bdd5545af2a0 (diff)
Merge "Disabled two-finger dragging on TouchpadDebugView" into main
-rw-r--r--services/core/java/com/android/server/input/debug/TouchpadDebugView.java4
-rw-r--r--tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java44
2 files changed, 46 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/input/debug/TouchpadDebugView.java b/services/core/java/com/android/server/input/debug/TouchpadDebugView.java
index 5ff8568f81b2..0e940d281b09 100644
--- a/services/core/java/com/android/server/input/debug/TouchpadDebugView.java
+++ b/services/core/java/com/android/server/input/debug/TouchpadDebugView.java
@@ -180,6 +180,10 @@ public class TouchpadDebugView extends LinearLayout {
@Override
public boolean onTouchEvent(MotionEvent event) {
+ if (event.getClassification() == MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE) {
+ return false;
+ }
+
float deltaX;
float deltaY;
switch (event.getAction()) {
diff --git a/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java b/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java
index eac2e9282714..b3a998ebca0d 100644
--- a/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java
+++ b/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java
@@ -16,6 +16,7 @@
package com.android.server.input.debug;
+import static android.view.InputDevice.SOURCE_MOUSE;
import static android.view.InputDevice.SOURCE_TOUCHSCREEN;
import static org.junit.Assert.assertEquals;
@@ -92,7 +93,7 @@ public class TouchpadDebugViewTest {
InputDevice inputDevice = new InputDevice.Builder()
.setId(TOUCHPAD_DEVICE_ID)
- .setSources(InputDevice.SOURCE_TOUCHPAD | InputDevice.SOURCE_MOUSE)
+ .setSources(InputDevice.SOURCE_TOUCHPAD | SOURCE_MOUSE)
.setName("Test Device " + TOUCHPAD_DEVICE_ID)
.build();
@@ -354,4 +355,43 @@ public class TouchpadDebugViewTest {
mTouchpadDebugView.updateGestureInfo(gestureType, TOUCHPAD_DEVICE_ID);
assertEquals(child.getText().toString(), TouchpadDebugView.getGestureText(gestureType));
}
-}
+
+ @Test
+ public void testTwoFingerDrag() {
+ float offsetX = ViewConfiguration.get(mTestableContext).getScaledTouchSlop() + 10;
+ float offsetY = ViewConfiguration.get(mTestableContext).getScaledTouchSlop() + 10;
+
+ // Simulate ACTION_DOWN event (gesture starts).
+ MotionEvent actionDown = new MotionEventBuilder(MotionEvent.ACTION_DOWN, SOURCE_MOUSE)
+ .pointer(new PointerBuilder(0, MotionEvent.TOOL_TYPE_FINGER)
+ .x(40f)
+ .y(40f)
+ )
+ .classification(MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE)
+ .build();
+ mTouchpadDebugView.dispatchTouchEvent(actionDown);
+
+ // Simulate ACTION_MOVE event (dragging with two fingers, processed as one pointer).
+ MotionEvent actionMove = new MotionEventBuilder(MotionEvent.ACTION_MOVE, SOURCE_MOUSE)
+ .pointer(new PointerBuilder(0, MotionEvent.TOOL_TYPE_FINGER)
+ .x(40f + offsetX)
+ .y(40f + offsetY)
+ )
+ .classification(MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE)
+ .build();
+ mTouchpadDebugView.dispatchTouchEvent(actionMove);
+
+ // Simulate ACTION_UP event (gesture ends).
+ MotionEvent actionUp = new MotionEventBuilder(MotionEvent.ACTION_UP, SOURCE_MOUSE)
+ .pointer(new PointerBuilder(0, MotionEvent.TOOL_TYPE_FINGER)
+ .x(40f + offsetX)
+ .y(40f + offsetY)
+ )
+ .classification(MotionEvent.CLASSIFICATION_TWO_FINGER_SWIPE)
+ .build();
+ mTouchpadDebugView.dispatchTouchEvent(actionUp);
+
+ // Verify that no updateViewLayout is called (as expected for a two-finger drag gesture).
+ verify(mWindowManager, times(0)).updateViewLayout(any(), any());
+ }
+} \ No newline at end of file