diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index cc5dfc91af8503bba4e6ba79ec302d3bea789bff..bc36210e4c9b780649618767d3d46c205f8cf53c 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -216,7 +216,6 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega throw new IllegalStateException( "Sending touch to an unknown view with id: " + touch.viewId); } - View view = vdControllers.get(touch.viewId).getView(); MotionEvent event = MotionEvent.obtain( @@ -235,7 +234,7 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega touch.source, touch.flags); - view.dispatchTouchEvent(event); + vdControllers.get(touch.viewId).dispatchTouchEvent(event); } @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) diff --git a/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java b/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java index 81c59b6135bea31354bd44bc2a79d1abf786efbe..7c4b6bec8acb0459356e08c9595f921e60d898f4 100644 --- a/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java +++ b/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java @@ -11,6 +11,7 @@ import android.content.Context; import android.hardware.display.DisplayManager; import android.hardware.display.VirtualDisplay; import android.os.Build; +import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewTreeObserver; @@ -201,6 +202,12 @@ class VirtualDisplayController { return platformView.getView(); } + /** Dispatches a motion event to the presentation for this controller. */ + public void dispatchTouchEvent(MotionEvent event) { + if (presentation == null) return; + presentation.dispatchTouchEvent(event); + } + @TargetApi(Build.VERSION_CODES.JELLY_BEAN) static class OneTimeOnDrawListener implements ViewTreeObserver.OnDrawListener { static void schedule(View view, Runnable runnable) {