From d4cabccccc98ef86e2a3e28cccbca891172c10a6 Mon Sep 17 00:00:00 2001 From: cg021 Date: Sun, 14 Jun 2020 22:01:17 -0500 Subject: [PATCH 1/6] createOverlaySurface JNI --- .../flutter/embedding/engine/FlutterJNI.java | 11 +++ .../engine/FlutterOverlaySurface.java | 28 ++++++++ .../platform/PlatformViewsController.java | 6 ++ .../android/jni/platform_view_android_jni.h | 1 + .../android/platform_view_android_jni.h | 69 +++++++++++++++++++ .../android/platform_view_android_jni_impl.cc | 55 +++++++++++++++ .../android/platform_view_android_jni_impl.h | 2 + .../embedding/engine/FlutterJNITest.java | 16 +++++ 8 files changed, 188 insertions(+) create mode 100644 shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java create mode 100644 shell/platform/android/platform_view_android_jni.h diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java b/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java index 397c99e41dcd2..787cf9a90e6ff 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java @@ -821,6 +821,17 @@ public void onEndFrame() { } platformViewsController.onEndFrame(); } + + @SuppressWarnings("unused") + @UiThread + public FlutterOverlaySurface createOverlaySurface() { + 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/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java b/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java new file mode 100644 index 0000000000000..842cb1873c79d --- /dev/null +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java @@ -0,0 +1,28 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package io.flutter.embedding.engine; + +import android.view.Surface; + +public class FlutterOverlaySurface { + // @NonNull + private final Surface surface; + + private final long id; + + // @Keep + public FlutterOverlaySurface(long id, Surface surface) { + this.id = id; + this.surface = surface; + } + + public long getId() { + return id; + } + + public Surface getSurface() { + return surface; + } +} diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index 8a394fa43fdc3..706b31228a090 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -17,6 +17,7 @@ import androidx.annotation.NonNull; import androidx.annotation.UiThread; import androidx.annotation.VisibleForTesting; +import io.flutter.embedding.engine.FlutterOverlaySurface; import io.flutter.embedding.engine.dart.DartExecutor; import io.flutter.embedding.engine.systemchannels.PlatformViewsChannel; import io.flutter.plugin.editing.TextInputPlugin; @@ -549,4 +550,9 @@ public void onBeginFrame() { public void onEndFrame() { // TODO: Implement this method. https://github.com/flutter/flutter/issues/58288 } + + public FlutterOverlaySurface createOverlaySurface() { + // TODO: Implement this method. https://github.com/flutter/flutter/issues/58288 + return null; + } } diff --git a/shell/platform/android/jni/platform_view_android_jni.h b/shell/platform/android/jni/platform_view_android_jni.h index 5d00ef13b1fce..933b6f60f5002 100644 --- a/shell/platform/android/jni/platform_view_android_jni.h +++ b/shell/platform/android/jni/platform_view_android_jni.h @@ -130,6 +130,7 @@ class PlatformViewAndroidJNI { int y, int width, int height) = 0; + //---------------------------------------------------------------------------- /// @brief Initiates a frame if using hybrid composition. /// diff --git a/shell/platform/android/platform_view_android_jni.h b/shell/platform/android/platform_view_android_jni.h new file mode 100644 index 0000000000000..1ba25e0f05498 --- /dev/null +++ b/shell/platform/android/platform_view_android_jni.h @@ -0,0 +1,69 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_JNI_H_ +#define FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_JNI_H_ + +#include +#include "flutter/fml/macros.h" +#include "flutter/shell/platform/android/platform_view_android.h" + +namespace flutter { + +void FlutterViewHandlePlatformMessage(JNIEnv* env, + jobject obj, + jstring channel, + jobject message, + jint responseId); + +void FlutterViewHandlePlatformMessageResponse(JNIEnv* env, + jobject obj, + jint responseId, + jobject response); + +void FlutterViewUpdateSemantics(JNIEnv* env, + jobject obj, + jobject buffer, + jobjectArray strings); + +void FlutterViewUpdateCustomAccessibilityActions(JNIEnv* env, + jobject obj, + jobject buffer, + jobjectArray strings); + +void FlutterViewOnFirstFrame(JNIEnv* env, jobject obj); + +void FlutterViewOnPreEngineRestart(JNIEnv* env, jobject obj); + +class AndroidFlutterOverlaySurface { + public: + AndroidFlutterOverlaySurface(long id, fml::RefPtr window) + : id_(id), window_(std::move(window)){}; + + long GetId() { return id_; } + + fml::RefPtr GetWindow() { return window_; } + + private: + long id_; + fml::RefPtr window_; +}; + +std::unique_ptr FlutterViewCreateOverlaySurface( + JNIEnv* env, + jobject obj); + +void SurfaceTextureAttachToGLContext(JNIEnv* env, jobject obj, jint textureId); + +void SurfaceTextureUpdateTexImage(JNIEnv* env, jobject obj); + +void SurfaceTextureGetTransformMatrix(JNIEnv* env, + jobject obj, + jfloatArray result); + +void SurfaceTextureDetachFromGLContext(JNIEnv* env, jobject obj); + +} // namespace flutter + +#endif // FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_JNI_H_ diff --git a/shell/platform/android/platform_view_android_jni_impl.cc b/shell/platform/android/platform_view_android_jni_impl.cc index 4e2d0db99b637..0c0bd0dc16c04 100644 --- a/shell/platform/android/platform_view_android_jni_impl.cc +++ b/shell/platform/android/platform_view_android_jni_impl.cc @@ -80,10 +80,36 @@ static jmethodID g_on_first_frame_method = nullptr; static jmethodID g_on_engine_restart_method = nullptr; +static jmethodID g_create_overlay_surface_method = nullptr; +static jmethodID g_flutter_overlay_layer_get_id_method = nullptr; +static jmethodID g_flutter_overlay_layer_get_surface_method = nullptr; + +std::unique_ptr FlutterViewCreateOverlaySurface( + JNIEnv* env, + jobject obj) { + jobject joverlay_layer = + env->CallObjectMethod(obj, g_create_overlay_surface_method); + jlong layer_id = env->CallLongMethod(joverlay_layer, + g_flutter_overlay_layer_get_id_method); + jobject surface = env->CallObjectMethod( + joverlay_layer, g_flutter_overlay_layer_get_surface_method); + + FML_CHECK(CheckException(env)); + return std::make_unique( + layer_id, fml::MakeRefCounted( + ANativeWindow_fromSurface(env, surface))); +} + static jmethodID g_on_begin_frame_method = nullptr; static jmethodID g_on_end_frame_method = nullptr; +static jmethodID g_create_overlay_surface_method = nullptr; + +static jmethodID g_flutter_overlay_layer_get_id_method = nullptr; + +static jmethodID g_flutter_overlay_layer_get_surface_method = nullptr; + static jmethodID g_attach_to_gl_context_method = nullptr; static jmethodID g_update_tex_image_method = nullptr; @@ -683,6 +709,10 @@ bool RegisterApi(JNIEnv* env) { return false; } + g_create_overlay_surface_method = + env->GetMethodID(g_flutter_jni_class->obj(), "createOverlaySurface", + "()Lio/flutter/embedding/engine/FlutterOverlaySurface;"); + return true; } @@ -707,6 +737,10 @@ bool PlatformViewAndroid::Register(JNIEnv* env) { return false; } + g_create_overlay_surface_method = + env->GetMethodID(g_flutter_jni_class->obj(), "createOverlaySurface", + "()Lio/flutter/embedding/engine/FlutterOverlaySurface;"); + g_flutter_jni_class = new fml::jni::ScopedJavaGlobalRef( env, env->FindClass("io/flutter/embedding/engine/FlutterJNI")); if (g_flutter_jni_class->is_null()) { @@ -738,6 +772,14 @@ bool PlatformViewAndroid::Register(JNIEnv* env) { return false; } + g_create_overlay_surface_method = env->GetMethodID( + g_flutter_jni_class->obj(), "createOverlaySurface", "()V"); + + if (g_create_overlay_surface_method == nullptr) { + FML_LOG(ERROR) << "Could not locate createOverlaySurface method"; + return false; + } + g_on_display_overlay_surface_method = env->GetMethodID( g_flutter_jni_class->obj(), "onDisplayOverlaySurface", "(IIIII)V"); @@ -1080,4 +1122,17 @@ void PlatformViewAndroidJNIImpl::FlutterViewEndFrame() { FML_CHECK(CheckException(env)); } +void PlatformViewAndroidJNIImpl::FlutterViewCreateOverlaySurface() { + JNIEnv* env = fml::jni::AttachCurrentThread(); + + auto java_object = java_object_.get(env); + if (java_object.is_null()) { + return; + } + + env->CallVoidMethod(java_object.obj(), g_create_overlay_surface_method); + + FML_CHECK(CheckException(env)); +} + } // namespace flutter diff --git a/shell/platform/android/platform_view_android_jni_impl.h b/shell/platform/android/platform_view_android_jni_impl.h index 0ab94a28c685f..25b62987ebf18 100644 --- a/shell/platform/android/platform_view_android_jni_impl.h +++ b/shell/platform/android/platform_view_android_jni_impl.h @@ -66,6 +66,8 @@ class PlatformViewAndroidJNIImpl final : public PlatformViewAndroidJNI { void FlutterViewEndFrame() override; + void FlutterViewCreateOverlaySurface() override; + private: // Reference to FlutterJNI object. const fml::jni::JavaObjectWeakGlobalRef java_object_; diff --git a/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java b/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java index 8918e4102aace..ac88420509bb4 100644 --- a/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java +++ b/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java @@ -111,4 +111,20 @@ public void onEndFrame__callsPlatformViewsController() { // --- Verify Results --- verify(platformViewsController, times(1)).onEndFrame(); } + + @Test + public void createOverlaySurface__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); + } } From c19a30ba3c5a7c037de7876fe94467c4b7d296d2 Mon Sep 17 00:00:00 2001 From: cg021 Date: Sun, 14 Jun 2020 23:49:09 -0500 Subject: [PATCH 2/6] update imports --- shell/platform/android/BUILD.gn | 1 + .../flutter/embedding/engine/FlutterJNI.java | 2 +- .../engine/FlutterOverlaySurface.java | 8 +++--- .../android/jni/platform_view_android_jni.h | 8 ++++++ .../android/platform_view_android_jni.h | 1 + .../android/platform_view_android_jni_impl.cc | 26 ++----------------- 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index a14e3809d22d8..94ee1f77d8a33 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -150,6 +150,7 @@ android_java_sources = [ "io/flutter/embedding/engine/FlutterEngineCache.java", "io/flutter/embedding/engine/FlutterEnginePluginRegistry.java", "io/flutter/embedding/engine/FlutterJNI.java", + "io/flutter/embedding/engine/FlutterOverlaySurface.java", "io/flutter/embedding/engine/FlutterShellArgs.java", "io/flutter/embedding/engine/dart/DartExecutor.java", "io/flutter/embedding/engine/dart/DartMessenger.java", diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java b/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java index 787cf9a90e6ff..3f6155f93f0b1 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java @@ -830,7 +830,7 @@ public FlutterOverlaySurface createOverlaySurface() { throw new RuntimeException( "platformViewsController must be set before attempting to position an overlay surface"); } - platformViewsController.onDisplayOverlaySurface(id, x, y, width, height); + return platformViewsController.createOverlaySurface(); } // ----- End Engine Lifecycle Support ---- diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java b/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java index 842cb1873c79d..b0270b2108ab2 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java @@ -5,15 +5,17 @@ package io.flutter.embedding.engine; import android.view.Surface; +import androidx.annotation.Keep; +import androidx.annotation.NonNull; public class FlutterOverlaySurface { - // @NonNull + @NonNull private final Surface surface; private final long id; - // @Keep - public FlutterOverlaySurface(long id, Surface surface) { + @Keep + public FlutterOverlaySurface(long id, @NonNull Surface surface) { this.id = id; this.surface = surface; } diff --git a/shell/platform/android/jni/platform_view_android_jni.h b/shell/platform/android/jni/platform_view_android_jni.h index 933b6f60f5002..d5fe648094ba2 100644 --- a/shell/platform/android/jni/platform_view_android_jni.h +++ b/shell/platform/android/jni/platform_view_android_jni.h @@ -146,6 +146,14 @@ class PlatformViewAndroidJNI { /// @note Must be called from the platform thread. /// virtual void FlutterViewEndFrame() = 0; + + //---------------------------------------------------------------------------- + /// @brief Instantiates an overlay surface in hybrid composition. + /// + /// + /// @note Must be called from the platform thread. + /// + virtual void FlutterViewCreateOverlaySurface() = 0; }; } // namespace flutter diff --git a/shell/platform/android/platform_view_android_jni.h b/shell/platform/android/platform_view_android_jni.h index 1ba25e0f05498..fb56ec96f4ca2 100644 --- a/shell/platform/android/platform_view_android_jni.h +++ b/shell/platform/android/platform_view_android_jni.h @@ -1,3 +1,4 @@ + // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/shell/platform/android/platform_view_android_jni_impl.cc b/shell/platform/android/platform_view_android_jni_impl.cc index 0c0bd0dc16c04..5f6b12ace80d0 100644 --- a/shell/platform/android/platform_view_android_jni_impl.cc +++ b/shell/platform/android/platform_view_android_jni_impl.cc @@ -25,6 +25,8 @@ #include "flutter/shell/platform/android/apk_asset_provider.h" #include "flutter/shell/platform/android/flutter_main.h" #include "flutter/shell/platform/android/platform_view_android.h" +#include "flutter/shell/platform/android/jni/platform_view_android_jni.h" +#include "flutter/shell/platform/android/platform_view_android_jni.h" #define ANDROID_SHELL_HOLDER \ (reinterpret_cast(shell_holder)) @@ -81,35 +83,11 @@ static jmethodID g_on_first_frame_method = nullptr; static jmethodID g_on_engine_restart_method = nullptr; static jmethodID g_create_overlay_surface_method = nullptr; -static jmethodID g_flutter_overlay_layer_get_id_method = nullptr; -static jmethodID g_flutter_overlay_layer_get_surface_method = nullptr; - -std::unique_ptr FlutterViewCreateOverlaySurface( - JNIEnv* env, - jobject obj) { - jobject joverlay_layer = - env->CallObjectMethod(obj, g_create_overlay_surface_method); - jlong layer_id = env->CallLongMethod(joverlay_layer, - g_flutter_overlay_layer_get_id_method); - jobject surface = env->CallObjectMethod( - joverlay_layer, g_flutter_overlay_layer_get_surface_method); - - FML_CHECK(CheckException(env)); - return std::make_unique( - layer_id, fml::MakeRefCounted( - ANativeWindow_fromSurface(env, surface))); -} static jmethodID g_on_begin_frame_method = nullptr; static jmethodID g_on_end_frame_method = nullptr; -static jmethodID g_create_overlay_surface_method = nullptr; - -static jmethodID g_flutter_overlay_layer_get_id_method = nullptr; - -static jmethodID g_flutter_overlay_layer_get_surface_method = nullptr; - static jmethodID g_attach_to_gl_context_method = nullptr; static jmethodID g_update_tex_image_method = nullptr; From 69a633ee6edfc6046a83ef308809b361964eb0f0 Mon Sep 17 00:00:00 2001 From: cg021 Date: Sun, 14 Jun 2020 23:58:29 -0500 Subject: [PATCH 3/6] remove unused method --- .../io/flutter/embedding/engine/FlutterOverlaySurface.java | 3 +-- shell/platform/android/platform_view_android_jni.h | 2 +- shell/platform/android/platform_view_android_jni_impl.cc | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java b/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java index b0270b2108ab2..05a3bdafb0c8c 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java @@ -9,8 +9,7 @@ import androidx.annotation.NonNull; public class FlutterOverlaySurface { - @NonNull - private final Surface surface; + @NonNull private final Surface surface; private final long id; diff --git a/shell/platform/android/platform_view_android_jni.h b/shell/platform/android/platform_view_android_jni.h index fb56ec96f4ca2..14db70fdd80ca 100644 --- a/shell/platform/android/platform_view_android_jni.h +++ b/shell/platform/android/platform_view_android_jni.h @@ -1,4 +1,4 @@ - + // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/shell/platform/android/platform_view_android_jni_impl.cc b/shell/platform/android/platform_view_android_jni_impl.cc index 5f6b12ace80d0..dfcdf41113249 100644 --- a/shell/platform/android/platform_view_android_jni_impl.cc +++ b/shell/platform/android/platform_view_android_jni_impl.cc @@ -24,8 +24,8 @@ #include "flutter/shell/platform/android/android_shell_holder.h" #include "flutter/shell/platform/android/apk_asset_provider.h" #include "flutter/shell/platform/android/flutter_main.h" -#include "flutter/shell/platform/android/platform_view_android.h" #include "flutter/shell/platform/android/jni/platform_view_android_jni.h" +#include "flutter/shell/platform/android/platform_view_android.h" #include "flutter/shell/platform/android/platform_view_android_jni.h" #define ANDROID_SHELL_HOLDER \ @@ -717,7 +717,7 @@ bool PlatformViewAndroid::Register(JNIEnv* env) { g_create_overlay_surface_method = env->GetMethodID(g_flutter_jni_class->obj(), "createOverlaySurface", - "()Lio/flutter/embedding/engine/FlutterOverlaySurface;"); + "()Lio/flutter/embedding/engine/FlutterOverlaySurface;"); g_flutter_jni_class = new fml::jni::ScopedJavaGlobalRef( env, env->FindClass("io/flutter/embedding/engine/FlutterJNI")); From ba63b9af8da1205e4872d61d591c2a3d1f737caa Mon Sep 17 00:00:00 2001 From: cg021 Date: Mon, 15 Jun 2020 00:11:20 -0500 Subject: [PATCH 4/6] license --- ci/licenses_golden/licenses_flutter | 2 ++ shell/platform/android/jni/platform_view_android_jni.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 4497a763ed419..680642a5c8977 100755 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -702,6 +702,7 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/Flutte FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngineCache.java FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEnginePluginRegistry.java FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java +FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/dart/DartExecutor.java FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/dart/DartMessenger.java @@ -791,6 +792,7 @@ FILE: ../../../flutter/shell/platform/android/platform_message_response_android. FILE: ../../../flutter/shell/platform/android/platform_message_response_android.h FILE: ../../../flutter/shell/platform/android/platform_view_android.cc FILE: ../../../flutter/shell/platform/android/platform_view_android.h +FILE: ../../../flutter/shell/platform/android/platform_view_android_jni.h FILE: ../../../flutter/shell/platform/android/platform_view_android_jni_impl.cc FILE: ../../../flutter/shell/platform/android/platform_view_android_jni_impl.h FILE: ../../../flutter/shell/platform/android/robolectric.properties diff --git a/shell/platform/android/jni/platform_view_android_jni.h b/shell/platform/android/jni/platform_view_android_jni.h index d5fe648094ba2..efbca69e5112f 100644 --- a/shell/platform/android/jni/platform_view_android_jni.h +++ b/shell/platform/android/jni/platform_view_android_jni.h @@ -150,7 +150,6 @@ class PlatformViewAndroidJNI { //---------------------------------------------------------------------------- /// @brief Instantiates an overlay surface in hybrid composition. /// - /// /// @note Must be called from the platform thread. /// virtual void FlutterViewCreateOverlaySurface() = 0; From 9473188b9e53ea81219673e036043900bfe69069 Mon Sep 17 00:00:00 2001 From: cg021 Date: Mon, 15 Jun 2020 13:57:45 -0500 Subject: [PATCH 5/6] deleted unused file --- ci/licenses_golden/licenses_flutter | 1 - .../android/platform_view_android_jni.h | 70 ------------------- .../android/platform_view_android_jni_impl.cc | 1 - 3 files changed, 72 deletions(-) delete mode 100644 shell/platform/android/platform_view_android_jni.h diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 680642a5c8977..d23154cafeb3e 100755 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -792,7 +792,6 @@ FILE: ../../../flutter/shell/platform/android/platform_message_response_android. FILE: ../../../flutter/shell/platform/android/platform_message_response_android.h FILE: ../../../flutter/shell/platform/android/platform_view_android.cc FILE: ../../../flutter/shell/platform/android/platform_view_android.h -FILE: ../../../flutter/shell/platform/android/platform_view_android_jni.h FILE: ../../../flutter/shell/platform/android/platform_view_android_jni_impl.cc FILE: ../../../flutter/shell/platform/android/platform_view_android_jni_impl.h FILE: ../../../flutter/shell/platform/android/robolectric.properties diff --git a/shell/platform/android/platform_view_android_jni.h b/shell/platform/android/platform_view_android_jni.h deleted file mode 100644 index 14db70fdd80ca..0000000000000 --- a/shell/platform/android/platform_view_android_jni.h +++ /dev/null @@ -1,70 +0,0 @@ - -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_JNI_H_ -#define FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_JNI_H_ - -#include -#include "flutter/fml/macros.h" -#include "flutter/shell/platform/android/platform_view_android.h" - -namespace flutter { - -void FlutterViewHandlePlatformMessage(JNIEnv* env, - jobject obj, - jstring channel, - jobject message, - jint responseId); - -void FlutterViewHandlePlatformMessageResponse(JNIEnv* env, - jobject obj, - jint responseId, - jobject response); - -void FlutterViewUpdateSemantics(JNIEnv* env, - jobject obj, - jobject buffer, - jobjectArray strings); - -void FlutterViewUpdateCustomAccessibilityActions(JNIEnv* env, - jobject obj, - jobject buffer, - jobjectArray strings); - -void FlutterViewOnFirstFrame(JNIEnv* env, jobject obj); - -void FlutterViewOnPreEngineRestart(JNIEnv* env, jobject obj); - -class AndroidFlutterOverlaySurface { - public: - AndroidFlutterOverlaySurface(long id, fml::RefPtr window) - : id_(id), window_(std::move(window)){}; - - long GetId() { return id_; } - - fml::RefPtr GetWindow() { return window_; } - - private: - long id_; - fml::RefPtr window_; -}; - -std::unique_ptr FlutterViewCreateOverlaySurface( - JNIEnv* env, - jobject obj); - -void SurfaceTextureAttachToGLContext(JNIEnv* env, jobject obj, jint textureId); - -void SurfaceTextureUpdateTexImage(JNIEnv* env, jobject obj); - -void SurfaceTextureGetTransformMatrix(JNIEnv* env, - jobject obj, - jfloatArray result); - -void SurfaceTextureDetachFromGLContext(JNIEnv* env, jobject obj); - -} // namespace flutter - -#endif // FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_JNI_H_ diff --git a/shell/platform/android/platform_view_android_jni_impl.cc b/shell/platform/android/platform_view_android_jni_impl.cc index dfcdf41113249..c23f5b48ba742 100644 --- a/shell/platform/android/platform_view_android_jni_impl.cc +++ b/shell/platform/android/platform_view_android_jni_impl.cc @@ -26,7 +26,6 @@ #include "flutter/shell/platform/android/flutter_main.h" #include "flutter/shell/platform/android/jni/platform_view_android_jni.h" #include "flutter/shell/platform/android/platform_view_android.h" -#include "flutter/shell/platform/android/platform_view_android_jni.h" #define ANDROID_SHELL_HOLDER \ (reinterpret_cast(shell_holder)) From 4187c3a350f327a187517394a5871b45554ecb91 Mon Sep 17 00:00:00 2001 From: cg021 Date: Mon, 15 Jun 2020 14:41:09 -0500 Subject: [PATCH 6/6] remove wrong function call --- .../test/io/flutter/embedding/engine/FlutterJNITest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java b/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java index ac88420509bb4..f63530a555ac7 100644 --- a/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java +++ b/shell/platform/android/test/io/flutter/embedding/engine/FlutterJNITest.java @@ -120,11 +120,9 @@ public void createOverlaySurface__callsPlatformViewsController() { flutterJNI.setPlatformViewsController(platformViewsController); // --- Execute Test --- - flutterJNI.onDisplayOverlaySurface( - /*id=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200); + flutterJNI.createOverlaySurface(); // --- Verify Results --- - verify(platformViewsController, times(1)) - .onDisplayOverlaySurface(/*id=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200); + verify(platformViewsController, times(1)).createOverlaySurface(); } }