Loading services/core/java/com/android/server/input/debug/TouchpadDebugView.java +4 −0 Original line number Diff line number Diff line Loading @@ -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()) { Loading tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java +42 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -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 Loading
services/core/java/com/android/server/input/debug/TouchpadDebugView.java +4 −0 Original line number Diff line number Diff line Loading @@ -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()) { Loading
tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java +42 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -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