diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java index 71a93c0a04..3b007172b8 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java @@ -103,10 +103,6 @@ public class FlutterEngine { platformViewsController.onPreEngineRestart(); } - - public void onDisplayPlatformView(int viewId, int x, int y, int width, int height) { - platformViewsController.onDisplayPlatformView(viewId, x, y, width, height); - } }; /** diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java index 478db5b909..cf1992857d 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java @@ -788,6 +788,17 @@ public class FlutterJNI { listener.onPreEngineRestart(); } } + + @SuppressWarnings("unused") + @UiThread + public void onDisplayOverlaySurface(int id, int x, int y, int width, int height) { + ensureRunningOnMainThread(); + if (platformViewsController == null) { + throw new RuntimeException( + "platformViewsController must be set before attempting to position an overlay surface"); + } + platformViewsController.onDisplayOverlaySurface(id, x, y, width, height); + } // ----- End Engine Lifecycle Support ---- // @SuppressWarnings("unused") 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 fad763e339..43568fe9de 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 @@ -537,4 +537,8 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega public void onDisplayPlatformView(int viewId, int x, int y, int width, int height) { // TODO: Implement this method. https://github.com/flutter/flutter/issues/58288 } + + public void onDisplayOverlaySurface(int id, int x, int y, int width, int height) { + // TODO: Implement this method. https://github.com/flutter/flutter/issues/58288 + } } diff --git a/engine/src/flutter/shell/platform/android/platform_view_android_jni.h b/engine/src/flutter/shell/platform/android/platform_view_android_jni.h index 199af74bd6..ca0736410c 100644 --- a/engine/src/flutter/shell/platform/android/platform_view_android_jni.h +++ b/engine/src/flutter/shell/platform/android/platform_view_android_jni.h @@ -44,6 +44,14 @@ void FlutterViewOnDisplayPlatformView(JNIEnv* env, jint width, jint height); +void FlutterViewDisplayOverlaySurface(JNIEnv* env, + jobject obj, + jint id, + jint x, + jint y, + jint width, + jint height); + void SurfaceTextureAttachToGLContext(JNIEnv* env, jobject obj, jint textureId); void SurfaceTextureUpdateTexImage(JNIEnv* env, jobject obj); diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java index 03f5dc38db..3bb26ce757 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java @@ -65,4 +65,20 @@ public class FlutterJNITest { .onDisplayPlatformView( /*viewId=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200); } + + @Test + public void onDisplayOverlaySurface__callsPlatformViewsController() { + PlatformViewsController platformViewsController = mock(PlatformViewsController.class); + + FlutterJNI flutterJNI = new FlutterJNI(); + flutterJNI.setPlatformViewsController(platformViewsController); + + // --- Execute Test --- + flutterJNI.onDisplayOverlaySurface( + /*id=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200); + + // --- Verify Results --- + verify(platformViewsController, times(1)) + .onDisplayOverlaySurface(/*id=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200); + } }