diff --git a/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java b/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java index 6febe9e3c4936..b3db5df1eb99b 100644 --- a/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java +++ b/shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java @@ -389,7 +389,7 @@ private int getPointerChangeForAction(int maskedAction) { if (maskedAction == MotionEvent.ACTION_SCROLL) { return PointerChange.HOVER; } - throw new AssertionError("Unexpected masked action"); + return -1; } @PointerChange diff --git a/shell/platform/android/test/io/flutter/embedding/android/AndroidTouchProcessorTest.java b/shell/platform/android/test/io/flutter/embedding/android/AndroidTouchProcessorTest.java index ae2e31366e986..dd3b896c37512 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/AndroidTouchProcessorTest.java +++ b/shell/platform/android/test/io/flutter/embedding/android/AndroidTouchProcessorTest.java @@ -3,6 +3,8 @@ import static junit.framework.TestCase.assertEquals; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.annotation.TargetApi; @@ -206,4 +208,14 @@ public void mouse() { assertEquals(5.0, readPointerPhysicalY(packet)); inOrder.verifyNoMoreInteractions(); } + + @Test + public void unexpectedMaskedAction() { + // Regression test for https://github.com/flutter/flutter/issues/111068 + MotionEventMocker mocker = + new MotionEventMocker(1, InputDevice.SOURCE_STYLUS, MotionEvent.TOOL_TYPE_STYLUS); + // ACTION_BUTTON_PRESS is not handled by AndroidTouchProcessor, nothing should be dispatched. + touchProcessor.onTouchEvent(mocker.mockEvent(MotionEvent.ACTION_BUTTON_PRESS, 0.0f, 0.0f, 0)); + verify(mockRenderer, never()).dispatchPointerDataPacket(ByteBuffer.allocate(0), 0); + } }