mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Guard against using Android API not defined in API level 16 & 17 (#8006)
This adds a guard around the call to MotionEvent.isFromSource, which is not implemented in API 16 and 17. Fixes flutter/flutter#28640
This commit is contained in:
parent
d7e0bc10c2
commit
293cfcaa54
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user