From e49d31bbecc5c2b169158a484632b94246536c1c Mon Sep 17 00:00:00 2001 From: Amir Hardon Date: Tue, 25 Jun 2019 09:45:20 -0700 Subject: [PATCH] fix NPE when a touch event is sent to an unknown Android platform view (flutter/engine#9476) --- .../flutter/plugin/platform/PlatformViewsController.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index 8ea704b39c..201cfcb631 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -192,11 +192,10 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega parsePointerCoordsList(touch.rawPointerCoords, density) .toArray(new PointerCoords[touch.pointerCount]); - View view = vdControllers.get(touch.viewId).getView(); - if (view == null) { - throw new IllegalStateException("Sending touch to an unknown view with id: " - + touch.viewId); + if (!vdControllers.containsKey(touch.viewId)) { + throw new IllegalStateException("Sending touch to an unknown view with id: " + touch.viewId); } + View view = vdControllers.get(touch.viewId).getView(); MotionEvent event = MotionEvent.obtain( touch.downTime.longValue(),