From 55f7ab72d89370377e0c0523f34ff199041636dd Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Fri, 1 Mar 2019 14:53:22 -0800 Subject: [PATCH] Guard against using Android API not defined in API level 16 & 17 (flutter/engine#8006) This adds a guard around the call to MotionEvent.isFromSource, which is not implemented in API 16 and 17. Fixes flutter/flutter#28640 --- .../shell/platform/android/io/flutter/view/FlutterView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java index 58a44a37a7..c766305fd7 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java @@ -570,7 +570,11 @@ public class FlutterView extends SurfaceView @Override public boolean onGenericMotionEvent(MotionEvent event) { - if (!event.isFromSource(InputDevice.SOURCE_CLASS_POINTER) || + // Method isFromSource is only available in API 18+ (Jelly Bean MR2) + // Mouse hover support is not implemented for API < 18. + boolean isPointerEvent = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 + && event.isFromSource(InputDevice.SOURCE_CLASS_POINTER); + if (!isPointerEvent || event.getActionMasked() != MotionEvent.ACTION_HOVER_MOVE || !isAttached()) { return super.onGenericMotionEvent(event);