Skip to content

Commit

Permalink
Guard against using Android API not defined in API level 16 & 17 (flu…
Browse files Browse the repository at this point in the history
…tter#8006)

This adds a guard around the call to MotionEvent.isFromSource, which is not implemented in API 16 and 17.

Fixes flutter/flutter#28640
  • Loading branch information
gspencergoog authored Mar 1, 2019
1 parent d7e0bc1 commit 293cfca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion shell/platform/android/io/flutter/view/FlutterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,11 @@ public boolean onHoverEvent(MotionEvent event) {

@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);
Expand Down

0 comments on commit 293cfca

Please sign in to comment.