@@ -102,9 +102,9 @@ static jmethodID g_on_display_platform_view_method = nullptr;
102102
103103static jmethodID g_on_display_overlay_surface_method = nullptr ;
104104
105- static jfieldID g_overlay_surface_id_field = nullptr ;
105+ static jmethodID g_overlay_surface_id_method = nullptr ;
106106
107- static jfieldID g_overlay_surface_surface_field = nullptr ;
107+ static jmethodID g_overlay_surface_surface_method = nullptr ;
108108
109109// Called By Java
110110static jlong AttachJNI (JNIEnv* env,
@@ -708,16 +708,17 @@ bool RegisterApi(JNIEnv* env) {
708708 FML_LOG (ERROR) << " Could not locate FlutterOverlaySurface class" ;
709709 return false ;
710710 }
711- g_overlay_surface_id_field =
712- env->GetFieldID (overlay_surface_class.obj (), " id " , " J" );
713- if (g_overlay_surface_id_field == nullptr ) {
714- FML_LOG (ERROR) << " Could not locate FlutterOverlaySurface.id field " ;
711+ g_overlay_surface_id_method =
712+ env->GetMethodID (overlay_surface_class.obj (), " getId " , " () J" );
713+ if (g_overlay_surface_id_method == nullptr ) {
714+ FML_LOG (ERROR) << " Could not locate FlutterOverlaySurface#getId() method " ;
715715 return false ;
716716 }
717- g_overlay_surface_surface_field = env->GetFieldID (
718- overlay_surface_class.obj (), " surface" , " Landroid/view/Surface;" );
719- if (g_overlay_surface_surface_field == nullptr ) {
720- FML_LOG (ERROR) << " Could not locate FlutterOverlaySurface.surface field" ;
717+ g_overlay_surface_surface_method = env->GetMethodID (
718+ overlay_surface_class.obj (), " getSurface" , " ()Landroid/view/Surface;" );
719+ if (g_overlay_surface_surface_method == nullptr ) {
720+ FML_LOG (ERROR)
721+ << " Could not locate FlutterOverlaySurface#getSurface() method" ;
721722 return false ;
722723 }
723724
@@ -1147,13 +1148,13 @@ PlatformViewAndroidJNIImpl::FlutterViewCreateOverlaySurface() {
11471148 }
11481149
11491150 jlong overlay_id =
1150- env->GetLongField (overlay.obj (), g_overlay_surface_id_field );
1151+ env->CallLongMethod (overlay.obj (), g_overlay_surface_id_method );
11511152
1152- fml::jni::ScopedJavaLocalRef< jobject> overlay_surface (
1153- env, env-> GetObjectField (overlay.obj (), g_overlay_surface_surface_field) );
1153+ jobject overlay_surface =
1154+ env-> CallObjectMethod (overlay.obj (), g_overlay_surface_surface_method );
11541155
11551156 auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
1156- ANativeWindow_fromSurface (env, overlay_surface. obj () ));
1157+ ANativeWindow_fromSurface (env, overlay_surface));
11571158
11581159 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
11591160 overlay_id, std::move (overlay_window));
0 commit comments