Flutter Engine
The Flutter Engine
platform_view_android_jni_impl.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/shell/platform/android/platform_view_android_jni_impl.h"
6
7#include <android/hardware_buffer_jni.h>
8#include <android/native_window_jni.h>
9#include <dlfcn.h>
10#include <jni.h>
11#include <memory>
12#include <sstream>
13#include <utility>
14
16#include "unicode/uchar.h"
17
18#include "flutter/assets/directory_asset_bundle.h"
19#include "flutter/common/constants.h"
20#include "flutter/fml/file.h"
21#include "flutter/fml/mapping.h"
22#include "flutter/fml/native_library.h"
23#include "flutter/fml/platform/android/jni_util.h"
24#include "flutter/fml/platform/android/jni_weak_ref.h"
25#include "flutter/fml/platform/android/scoped_java_ref.h"
26#include "flutter/fml/size.h"
27#include "flutter/lib/ui/plugins/callback_cache.h"
28#include "flutter/runtime/dart_service_isolate.h"
29#include "flutter/shell/common/run_configuration.h"
30#include "flutter/shell/platform/android/android_shell_holder.h"
31#include "flutter/shell/platform/android/apk_asset_provider.h"
32#include "flutter/shell/platform/android/flutter_main.h"
33#include "flutter/shell/platform/android/image_external_texture_gl.h"
34#include "flutter/shell/platform/android/jni/platform_view_android_jni.h"
35#include "flutter/shell/platform/android/platform_view_android.h"
36#include "flutter/shell/platform/android/surface_texture_external_texture_gl.h"
37
38#define ANDROID_SHELL_HOLDER \
39 (reinterpret_cast<AndroidShellHolder*>(shell_holder))
40
41namespace flutter {
42
44 nullptr;
45
47
49 nullptr;
50
52
55
57
59
61
63
65
66// Called By Native
67
68static jmethodID g_flutter_callback_info_constructor = nullptr;
70 JNIEnv* env,
71 const std::string& callbackName,
72 const std::string& callbackClassName,
73 const std::string& callbackLibraryPath) {
74 return env->NewObject(g_flutter_callback_info_class->obj(),
76 env->NewStringUTF(callbackName.c_str()),
77 env->NewStringUTF(callbackClassName.c_str()),
78 env->NewStringUTF(callbackLibraryPath.c_str()));
79}
80
81static jfieldID g_jni_shell_holder_field = nullptr;
82
83static jmethodID g_jni_constructor = nullptr;
84
85static jmethodID g_long_constructor = nullptr;
86
87static jmethodID g_handle_platform_message_method = nullptr;
88
90
91static jmethodID g_update_semantics_method = nullptr;
92
94
95static jmethodID g_get_scaled_font_size_method = nullptr;
96
97static jmethodID g_on_first_frame_method = nullptr;
98
99static jmethodID g_on_engine_restart_method = nullptr;
100
101static jmethodID g_create_overlay_surface_method = nullptr;
102
103static jmethodID g_destroy_overlay_surfaces_method = nullptr;
104
105static jmethodID g_on_begin_frame_method = nullptr;
106
107static jmethodID g_on_end_frame_method = nullptr;
108
109static jmethodID g_java_weak_reference_get_method = nullptr;
110
111static jmethodID g_attach_to_gl_context_method = nullptr;
112
114
115static jmethodID g_update_tex_image_method = nullptr;
116
117static jmethodID g_get_transform_matrix_method = nullptr;
118
119static jmethodID g_detach_from_gl_context_method = nullptr;
120
121static jmethodID g_acquire_latest_image_method = nullptr;
122
123static jmethodID g_image_get_hardware_buffer_method = nullptr;
124
125static jmethodID g_image_close_method = nullptr;
126
127static jmethodID g_hardware_buffer_close_method = nullptr;
128
130
131static jmethodID g_request_dart_deferred_library_method = nullptr;
132
133// Called By Java
134static jmethodID g_on_display_platform_view_method = nullptr;
135
136// static jmethodID g_on_composite_platform_view_method = nullptr;
137
138static jmethodID g_on_display_overlay_surface_method = nullptr;
139
140static jmethodID g_overlay_surface_id_method = nullptr;
141
142static jmethodID g_overlay_surface_surface_method = nullptr;
143
144static jmethodID g_bitmap_create_bitmap_method = nullptr;
145
147
148static jmethodID g_bitmap_config_value_of = nullptr;
149
150// Mutators
152static jmethodID g_mutators_stack_init_method = nullptr;
153static jmethodID g_mutators_stack_push_transform_method = nullptr;
154static jmethodID g_mutators_stack_push_cliprect_method = nullptr;
155static jmethodID g_mutators_stack_push_cliprrect_method = nullptr;
156
157// Called By Java
158static jlong AttachJNI(JNIEnv* env, jclass clazz, jobject flutterJNI) {
159 fml::jni::JavaObjectWeakGlobalRef java_object(env, flutterJNI);
160 std::shared_ptr<PlatformViewAndroidJNI> jni_facade =
161 std::make_shared<PlatformViewAndroidJNIImpl>(java_object);
162 auto shell_holder = std::make_unique<AndroidShellHolder>(
163 FlutterMain::Get().GetSettings(), jni_facade);
164 if (shell_holder->IsValid()) {
165 return reinterpret_cast<jlong>(shell_holder.release());
166 } else {
167 return 0;
168 }
169}
170
171static void DestroyJNI(JNIEnv* env, jobject jcaller, jlong shell_holder) {
173}
174
175// Signature is similar to RunBundleAndSnapshotFromLibrary but it can't change
176// the bundle path or asset manager since we can only spawn with the same
177// AOT.
178//
179// The shell_holder instance must be a pointer address to the current
180// AndroidShellHolder whose Shell will be used to spawn a new Shell.
181//
182// This creates a Java Long that points to the newly created
183// AndroidShellHolder's raw pointer, connects that Long to a newly created
184// FlutterJNI instance, then returns the FlutterJNI instance.
185static jobject SpawnJNI(JNIEnv* env,
186 jobject jcaller,
187 jlong shell_holder,
188 jstring jEntrypoint,
189 jstring jLibraryUrl,
190 jstring jInitialRoute,
191 jobject jEntrypointArgs) {
192 jobject jni = env->NewObject(g_flutter_jni_class->obj(), g_jni_constructor);
193 if (jni == nullptr) {
194 FML_LOG(ERROR) << "Could not create a FlutterJNI instance";
195 return nullptr;
196 }
197
199 std::shared_ptr<PlatformViewAndroidJNI> jni_facade =
200 std::make_shared<PlatformViewAndroidJNIImpl>(java_jni);
201
202 auto entrypoint = fml::jni::JavaStringToString(env, jEntrypoint);
203 auto libraryUrl = fml::jni::JavaStringToString(env, jLibraryUrl);
204 auto initial_route = fml::jni::JavaStringToString(env, jInitialRoute);
205 auto entrypoint_args = fml::jni::StringListToVector(env, jEntrypointArgs);
206
207 auto spawned_shell_holder = ANDROID_SHELL_HOLDER->Spawn(
208 jni_facade, entrypoint, libraryUrl, initial_route, entrypoint_args);
209
210 if (spawned_shell_holder == nullptr || !spawned_shell_holder->IsValid()) {
211 FML_LOG(ERROR) << "Could not spawn Shell";
212 return nullptr;
213 }
214
215 jobject javaLong = env->CallStaticObjectMethod(
217 reinterpret_cast<jlong>(spawned_shell_holder.release()));
218 if (javaLong == nullptr) {
219 FML_LOG(ERROR) << "Could not create a Long instance";
220 return nullptr;
221 }
222
223 env->SetObjectField(jni, g_jni_shell_holder_field, javaLong);
224
225 return jni;
226}
227
228static void SurfaceCreated(JNIEnv* env,
229 jobject jcaller,
230 jlong shell_holder,
231 jobject jsurface) {
232 // Note: This frame ensures that any local references used by
233 // ANativeWindow_fromSurface are released immediately. This is needed as a
234 // workaround for https://code.google.com/p/android/issues/detail?id=68174
235 fml::jni::ScopedJavaLocalFrame scoped_local_reference_frame(env);
236 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
237 ANativeWindow_fromSurface(env, jsurface));
238 ANDROID_SHELL_HOLDER->GetPlatformView()->NotifyCreated(std::move(window));
239}
240
241static void SurfaceWindowChanged(JNIEnv* env,
242 jobject jcaller,
243 jlong shell_holder,
244 jobject jsurface) {
245 // Note: This frame ensures that any local references used by
246 // ANativeWindow_fromSurface are released immediately. This is needed as a
247 // workaround for https://code.google.com/p/android/issues/detail?id=68174
248 fml::jni::ScopedJavaLocalFrame scoped_local_reference_frame(env);
249 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
250 ANativeWindow_fromSurface(env, jsurface));
251 ANDROID_SHELL_HOLDER->GetPlatformView()->NotifySurfaceWindowChanged(
252 std::move(window));
253}
254
255static void SurfaceChanged(JNIEnv* env,
256 jobject jcaller,
257 jlong shell_holder,
258 jint width,
259 jint height) {
260 ANDROID_SHELL_HOLDER->GetPlatformView()->NotifyChanged(
262}
263
264static void SurfaceDestroyed(JNIEnv* env, jobject jcaller, jlong shell_holder) {
265 ANDROID_SHELL_HOLDER->GetPlatformView()->NotifyDestroyed();
266}
267
269 jobject jcaller,
270 jlong shell_holder,
271 jstring jBundlePath,
272 jstring jEntrypoint,
273 jstring jLibraryUrl,
274 jobject jAssetManager,
275 jobject jEntrypointArgs) {
276 auto apk_asset_provider = std::make_unique<flutter::APKAssetProvider>(
277 env, // jni environment
278 jAssetManager, // asset manager
279 fml::jni::JavaStringToString(env, jBundlePath) // apk asset dir
280 );
281 auto entrypoint = fml::jni::JavaStringToString(env, jEntrypoint);
282 auto libraryUrl = fml::jni::JavaStringToString(env, jLibraryUrl);
283 auto entrypoint_args = fml::jni::StringListToVector(env, jEntrypointArgs);
284
285 ANDROID_SHELL_HOLDER->Launch(std::move(apk_asset_provider), entrypoint,
286 libraryUrl, entrypoint_args);
287}
288
289static jobject LookupCallbackInformation(JNIEnv* env,
290 /* unused */ jobject,
291 jlong handle) {
293 if (cbInfo == nullptr) {
294 return nullptr;
295 }
296 return CreateFlutterCallbackInformation(env, cbInfo->name, cbInfo->class_name,
297 cbInfo->library_path);
298}
299
300static void SetViewportMetrics(JNIEnv* env,
301 jobject jcaller,
302 jlong shell_holder,
303 jfloat devicePixelRatio,
304 jint physicalWidth,
305 jint physicalHeight,
306 jint physicalPaddingTop,
307 jint physicalPaddingRight,
308 jint physicalPaddingBottom,
309 jint physicalPaddingLeft,
310 jint physicalViewInsetTop,
311 jint physicalViewInsetRight,
312 jint physicalViewInsetBottom,
313 jint physicalViewInsetLeft,
314 jint systemGestureInsetTop,
315 jint systemGestureInsetRight,
316 jint systemGestureInsetBottom,
317 jint systemGestureInsetLeft,
318 jint physicalTouchSlop,
319 jintArray javaDisplayFeaturesBounds,
320 jintArray javaDisplayFeaturesType,
321 jintArray javaDisplayFeaturesState) {
322 // Convert java->c++. javaDisplayFeaturesBounds, javaDisplayFeaturesType and
323 // javaDisplayFeaturesState cannot be null
324 jsize rectSize = env->GetArrayLength(javaDisplayFeaturesBounds);
325 std::vector<int> boundsIntVector(rectSize);
326 env->GetIntArrayRegion(javaDisplayFeaturesBounds, 0, rectSize,
327 &boundsIntVector[0]);
328 std::vector<double> displayFeaturesBounds(boundsIntVector.begin(),
329 boundsIntVector.end());
330 jsize typeSize = env->GetArrayLength(javaDisplayFeaturesType);
331 std::vector<int> displayFeaturesType(typeSize);
332 env->GetIntArrayRegion(javaDisplayFeaturesType, 0, typeSize,
333 &displayFeaturesType[0]);
334
335 jsize stateSize = env->GetArrayLength(javaDisplayFeaturesState);
336 std::vector<int> displayFeaturesState(stateSize);
337 env->GetIntArrayRegion(javaDisplayFeaturesState, 0, stateSize,
338 &displayFeaturesState[0]);
339
340 const flutter::ViewportMetrics metrics{
341 static_cast<double>(devicePixelRatio),
342 static_cast<double>(physicalWidth),
343 static_cast<double>(physicalHeight),
344 static_cast<double>(physicalPaddingTop),
345 static_cast<double>(physicalPaddingRight),
346 static_cast<double>(physicalPaddingBottom),
347 static_cast<double>(physicalPaddingLeft),
348 static_cast<double>(physicalViewInsetTop),
349 static_cast<double>(physicalViewInsetRight),
350 static_cast<double>(physicalViewInsetBottom),
351 static_cast<double>(physicalViewInsetLeft),
352 static_cast<double>(systemGestureInsetTop),
353 static_cast<double>(systemGestureInsetRight),
354 static_cast<double>(systemGestureInsetBottom),
355 static_cast<double>(systemGestureInsetLeft),
356 static_cast<double>(physicalTouchSlop),
357 displayFeaturesBounds,
358 displayFeaturesType,
359 displayFeaturesState,
360 0, // Display ID
361 };
362
363 ANDROID_SHELL_HOLDER->GetPlatformView()->SetViewportMetrics(
364 kFlutterImplicitViewId, metrics);
365}
366
367static void UpdateDisplayMetrics(JNIEnv* env,
368 jobject jcaller,
369 jlong shell_holder) {
370 ANDROID_SHELL_HOLDER->UpdateDisplayMetrics();
371}
372
373static jobject GetBitmap(JNIEnv* env, jobject jcaller, jlong shell_holder) {
374 auto screenshot = ANDROID_SHELL_HOLDER->Screenshot(
376 if (screenshot.data == nullptr) {
377 return nullptr;
378 }
379
380 jstring argb = env->NewStringUTF("ARGB_8888");
381 if (argb == nullptr) {
382 return nullptr;
383 }
384
385 jobject bitmap_config = env->CallStaticObjectMethod(
387 if (bitmap_config == nullptr) {
388 return nullptr;
389 }
390
391 auto bitmap = env->CallStaticObjectMethod(
393 screenshot.frame_size.width(), screenshot.frame_size.height(),
394 bitmap_config);
395
397 env,
398 env->NewDirectByteBuffer(const_cast<uint8_t*>(screenshot.data->bytes()),
399 screenshot.data->size()));
400
402 buffer.obj());
403
404 return bitmap;
405}
406
407static void DispatchPlatformMessage(JNIEnv* env,
408 jobject jcaller,
409 jlong shell_holder,
410 jstring channel,
411 jobject message,
412 jint position,
413 jint responseId) {
414 ANDROID_SHELL_HOLDER->GetPlatformView()->DispatchPlatformMessage(
415 env, //
417 message, //
418 position, //
419 responseId //
420 );
421}
422
424 jobject jcaller,
425 jlong shell_holder,
426 jstring channel,
427 jint responseId) {
428 ANDROID_SHELL_HOLDER->GetPlatformView()->DispatchEmptyPlatformMessage(
429 env, //
431 responseId //
432 );
433}
434
435static void CleanupMessageData(JNIEnv* env,
436 jobject jcaller,
437 jlong message_data) {
438 // Called from any thread.
439 free(reinterpret_cast<void*>(message_data));
440}
441
442static void DispatchPointerDataPacket(JNIEnv* env,
443 jobject jcaller,
444 jlong shell_holder,
445 jobject buffer,
446 jint position) {
447 uint8_t* data = static_cast<uint8_t*>(env->GetDirectBufferAddress(buffer));
448 auto packet = std::make_unique<flutter::PointerDataPacket>(data, position);
449 ANDROID_SHELL_HOLDER->GetPlatformView()->DispatchPointerDataPacket(
450 std::move(packet));
451}
452
453static void DispatchSemanticsAction(JNIEnv* env,
454 jobject jcaller,
455 jlong shell_holder,
456 jint id,
457 jint action,
458 jobject args,
459 jint args_position) {
460 ANDROID_SHELL_HOLDER->GetPlatformView()->DispatchSemanticsAction(
461 env, //
462 id, //
463 action, //
464 args, //
465 args_position //
466 );
467}
468
469static void SetSemanticsEnabled(JNIEnv* env,
470 jobject jcaller,
471 jlong shell_holder,
472 jboolean enabled) {
473 ANDROID_SHELL_HOLDER->GetPlatformView()->SetSemanticsEnabled(enabled);
474}
475
476static void SetAccessibilityFeatures(JNIEnv* env,
477 jobject jcaller,
478 jlong shell_holder,
479 jint flags) {
480 ANDROID_SHELL_HOLDER->GetPlatformView()->SetAccessibilityFeatures(flags);
481}
482
483static jboolean GetIsSoftwareRendering(JNIEnv* env, jobject jcaller) {
485}
486
487static void RegisterTexture(JNIEnv* env,
488 jobject jcaller,
489 jlong shell_holder,
490 jlong texture_id,
491 jobject surface_texture) {
492 ANDROID_SHELL_HOLDER->GetPlatformView()->RegisterExternalTexture(
493 static_cast<int64_t>(texture_id), //
495 );
496}
497
498static void RegisterImageTexture(JNIEnv* env,
499 jobject jcaller,
500 jlong shell_holder,
501 jlong texture_id,
502 jobject image_texture_entry) {
503 ANDROID_SHELL_HOLDER->GetPlatformView()->RegisterImageTexture(
504 static_cast<int64_t>(texture_id), //
505 fml::jni::ScopedJavaGlobalRef<jobject>(env, image_texture_entry) //
506 );
507}
508
509static void UnregisterTexture(JNIEnv* env,
510 jobject jcaller,
511 jlong shell_holder,
512 jlong texture_id) {
513 ANDROID_SHELL_HOLDER->GetPlatformView()->UnregisterTexture(
514 static_cast<int64_t>(texture_id));
515}
516
517static void MarkTextureFrameAvailable(JNIEnv* env,
518 jobject jcaller,
519 jlong shell_holder,
520 jlong texture_id) {
521 ANDROID_SHELL_HOLDER->GetPlatformView()->MarkTextureFrameAvailable(
522 static_cast<int64_t>(texture_id));
523}
524
525static void ScheduleFrame(JNIEnv* env, jobject jcaller, jlong shell_holder) {
526 ANDROID_SHELL_HOLDER->GetPlatformView()->ScheduleFrame();
527}
528
530 jobject jcaller,
531 jlong shell_holder,
532 jint responseId,
533 jobject message,
534 jint position) {
535 uint8_t* response_data =
536 static_cast<uint8_t*>(env->GetDirectBufferAddress(message));
537 FML_DCHECK(response_data != nullptr);
538 auto mapping = std::make_unique<fml::MallocMapping>(
539 fml::MallocMapping::Copy(response_data, response_data + position));
540 ANDROID_SHELL_HOLDER->GetPlatformMessageHandler()
541 ->InvokePlatformMessageResponseCallback(responseId, std::move(mapping));
542}
543
545 jobject jcaller,
546 jlong shell_holder,
547 jint responseId) {
548 ANDROID_SHELL_HOLDER->GetPlatformMessageHandler()
549 ->InvokePlatformMessageEmptyResponseCallback(responseId);
550}
551
552static void NotifyLowMemoryWarning(JNIEnv* env,
553 jobject obj,
554 jlong shell_holder) {
555 ANDROID_SHELL_HOLDER->NotifyLowMemoryWarning();
556}
557
558static jboolean FlutterTextUtilsIsEmoji(JNIEnv* env,
559 jobject obj,
560 jint codePoint) {
561 return u_hasBinaryProperty(codePoint, UProperty::UCHAR_EMOJI);
562}
563
564static jboolean FlutterTextUtilsIsEmojiModifier(JNIEnv* env,
565 jobject obj,
566 jint codePoint) {
567 return u_hasBinaryProperty(codePoint, UProperty::UCHAR_EMOJI_MODIFIER);
568}
569
571 jobject obj,
572 jint codePoint) {
573 return u_hasBinaryProperty(codePoint, UProperty::UCHAR_EMOJI_MODIFIER_BASE);
574}
575
577 jobject obj,
578 jint codePoint) {
579 return u_hasBinaryProperty(codePoint, UProperty::UCHAR_VARIATION_SELECTOR);
580}
581
583 jobject obj,
584 jint codePoint) {
585 return u_hasBinaryProperty(codePoint, UProperty::UCHAR_REGIONAL_INDICATOR);
586}
587
588static void LoadLoadingUnitFailure(intptr_t loading_unit_id,
589 const std::string& message,
590 bool transient) {
591 // TODO(garyq): Implement
592}
593
595 jobject obj,
596 jint jLoadingUnitId,
597 jstring jError,
598 jboolean jTransient) {
599 LoadLoadingUnitFailure(static_cast<intptr_t>(jLoadingUnitId),
601 static_cast<bool>(jTransient));
602}
603
604static void LoadDartDeferredLibrary(JNIEnv* env,
605 jobject obj,
606 jlong shell_holder,
607 jint jLoadingUnitId,
608 jobjectArray jSearchPaths) {
609 // Convert java->c++
610 intptr_t loading_unit_id = static_cast<intptr_t>(jLoadingUnitId);
611 std::vector<std::string> search_paths =
612 fml::jni::StringArrayToVector(env, jSearchPaths);
613
614 // Use dlopen here to directly check if handle is nullptr before creating a
615 // NativeLibrary.
616 void* handle = nullptr;
617 while (handle == nullptr && !search_paths.empty()) {
618 std::string path = search_paths.back();
619 handle = ::dlopen(path.c_str(), RTLD_NOW);
620 search_paths.pop_back();
621 }
622 if (handle == nullptr) {
623 LoadLoadingUnitFailure(loading_unit_id,
624 "No lib .so found for provided search paths.", true);
625 return;
626 }
629
630 // Resolve symbols.
631 std::unique_ptr<const fml::SymbolMapping> data_mapping =
632 std::make_unique<const fml::SymbolMapping>(
634 std::unique_ptr<const fml::SymbolMapping> instructions_mapping =
635 std::make_unique<const fml::SymbolMapping>(
637
638 ANDROID_SHELL_HOLDER->GetPlatformView()->LoadDartDeferredLibrary(
639 loading_unit_id, std::move(data_mapping),
640 std::move(instructions_mapping));
641}
642
643static void UpdateJavaAssetManager(JNIEnv* env,
644 jobject obj,
645 jlong shell_holder,
646 jobject jAssetManager,
647 jstring jAssetBundlePath) {
648 auto asset_resolver = std::make_unique<flutter::APKAssetProvider>(
649 env, // jni environment
650 jAssetManager, // asset manager
651 fml::jni::JavaStringToString(env, jAssetBundlePath)); // apk asset dir
652
653 ANDROID_SHELL_HOLDER->GetPlatformView()->UpdateAssetResolverByType(
654 std::move(asset_resolver),
655 AssetResolver::AssetResolverType::kApkAssetProvider);
656}
657
658bool RegisterApi(JNIEnv* env) {
659 static const JNINativeMethod flutter_jni_methods[] = {
660 // Start of methods from FlutterJNI
661 {
662 .name = "nativeAttach",
663 .signature = "(Lio/flutter/embedding/engine/FlutterJNI;)J",
664 .fnPtr = reinterpret_cast<void*>(&AttachJNI),
665 },
666 {
667 .name = "nativeDestroy",
668 .signature = "(J)V",
669 .fnPtr = reinterpret_cast<void*>(&DestroyJNI),
670 },
671 {
672 .name = "nativeSpawn",
673 .signature = "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/"
674 "String;Ljava/util/List;)Lio/flutter/"
675 "embedding/engine/FlutterJNI;",
676 .fnPtr = reinterpret_cast<void*>(&SpawnJNI),
677 },
678 {
679 .name = "nativeRunBundleAndSnapshotFromLibrary",
680 .signature = "(JLjava/lang/String;Ljava/lang/String;"
681 "Ljava/lang/String;Landroid/content/res/"
682 "AssetManager;Ljava/util/List;)V",
683 .fnPtr = reinterpret_cast<void*>(&RunBundleAndSnapshotFromLibrary),
684 },
685 {
686 .name = "nativeDispatchEmptyPlatformMessage",
687 .signature = "(JLjava/lang/String;I)V",
688 .fnPtr = reinterpret_cast<void*>(&DispatchEmptyPlatformMessage),
689 },
690 {
691 .name = "nativeCleanupMessageData",
692 .signature = "(J)V",
693 .fnPtr = reinterpret_cast<void*>(&CleanupMessageData),
694 },
695 {
696 .name = "nativeDispatchPlatformMessage",
697 .signature = "(JLjava/lang/String;Ljava/nio/ByteBuffer;II)V",
698 .fnPtr = reinterpret_cast<void*>(&DispatchPlatformMessage),
699 },
700 {
701 .name = "nativeInvokePlatformMessageResponseCallback",
702 .signature = "(JILjava/nio/ByteBuffer;I)V",
703 .fnPtr =
704 reinterpret_cast<void*>(&InvokePlatformMessageResponseCallback),
705 },
706 {
707 .name = "nativeInvokePlatformMessageEmptyResponseCallback",
708 .signature = "(JI)V",
709 .fnPtr = reinterpret_cast<void*>(
711 },
712 {
713 .name = "nativeNotifyLowMemoryWarning",
714 .signature = "(J)V",
715 .fnPtr = reinterpret_cast<void*>(&NotifyLowMemoryWarning),
716 },
717
718 // Start of methods from FlutterView
719 {
720 .name = "nativeGetBitmap",
721 .signature = "(J)Landroid/graphics/Bitmap;",
722 .fnPtr = reinterpret_cast<void*>(&GetBitmap),
723 },
724 {
725 .name = "nativeSurfaceCreated",
726 .signature = "(JLandroid/view/Surface;)V",
727 .fnPtr = reinterpret_cast<void*>(&SurfaceCreated),
728 },
729 {
730 .name = "nativeSurfaceWindowChanged",
731 .signature = "(JLandroid/view/Surface;)V",
732 .fnPtr = reinterpret_cast<void*>(&SurfaceWindowChanged),
733 },
734 {
735 .name = "nativeSurfaceChanged",
736 .signature = "(JII)V",
737 .fnPtr = reinterpret_cast<void*>(&SurfaceChanged),
738 },
739 {
740 .name = "nativeSurfaceDestroyed",
741 .signature = "(J)V",
742 .fnPtr = reinterpret_cast<void*>(&SurfaceDestroyed),
743 },
744 {
745 .name = "nativeSetViewportMetrics",
746 .signature = "(JFIIIIIIIIIIIIIII[I[I[I)V",
747 .fnPtr = reinterpret_cast<void*>(&SetViewportMetrics),
748 },
749 {
750 .name = "nativeDispatchPointerDataPacket",
751 .signature = "(JLjava/nio/ByteBuffer;I)V",
752 .fnPtr = reinterpret_cast<void*>(&DispatchPointerDataPacket),
753 },
754 {
755 .name = "nativeDispatchSemanticsAction",
756 .signature = "(JIILjava/nio/ByteBuffer;I)V",
757 .fnPtr = reinterpret_cast<void*>(&DispatchSemanticsAction),
758 },
759 {
760 .name = "nativeSetSemanticsEnabled",
761 .signature = "(JZ)V",
762 .fnPtr = reinterpret_cast<void*>(&SetSemanticsEnabled),
763 },
764 {
765 .name = "nativeSetAccessibilityFeatures",
766 .signature = "(JI)V",
767 .fnPtr = reinterpret_cast<void*>(&SetAccessibilityFeatures),
768 },
769 {
770 .name = "nativeGetIsSoftwareRenderingEnabled",
771 .signature = "()Z",
772 .fnPtr = reinterpret_cast<void*>(&GetIsSoftwareRendering),
773 },
774 {
775 .name = "nativeRegisterTexture",
776 .signature = "(JJLjava/lang/ref/"
777 "WeakReference;)V",
778 .fnPtr = reinterpret_cast<void*>(&RegisterTexture),
779 },
780 {
781 .name = "nativeRegisterImageTexture",
782 .signature = "(JJLjava/lang/ref/"
783 "WeakReference;)V",
784 .fnPtr = reinterpret_cast<void*>(&RegisterImageTexture),
785 },
786 {
787 .name = "nativeMarkTextureFrameAvailable",
788 .signature = "(JJ)V",
789 .fnPtr = reinterpret_cast<void*>(&MarkTextureFrameAvailable),
790 },
791 {
792 .name = "nativeScheduleFrame",
793 .signature = "(J)V",
794 .fnPtr = reinterpret_cast<void*>(&ScheduleFrame),
795 },
796 {
797 .name = "nativeUnregisterTexture",
798 .signature = "(JJ)V",
799 .fnPtr = reinterpret_cast<void*>(&UnregisterTexture),
800 },
801 // Methods for Dart callback functionality.
802 {
803 .name = "nativeLookupCallbackInformation",
804 .signature = "(J)Lio/flutter/view/FlutterCallbackInformation;",
805 .fnPtr = reinterpret_cast<void*>(&LookupCallbackInformation),
806 },
807
808 // Start of methods for FlutterTextUtils
809 {
810 .name = "nativeFlutterTextUtilsIsEmoji",
811 .signature = "(I)Z",
812 .fnPtr = reinterpret_cast<void*>(&FlutterTextUtilsIsEmoji),
813 },
814 {
815 .name = "nativeFlutterTextUtilsIsEmojiModifier",
816 .signature = "(I)Z",
817 .fnPtr = reinterpret_cast<void*>(&FlutterTextUtilsIsEmojiModifier),
818 },
819 {
820 .name = "nativeFlutterTextUtilsIsEmojiModifierBase",
821 .signature = "(I)Z",
822 .fnPtr =
823 reinterpret_cast<void*>(&FlutterTextUtilsIsEmojiModifierBase),
824 },
825 {
826 .name = "nativeFlutterTextUtilsIsVariationSelector",
827 .signature = "(I)Z",
828 .fnPtr =
829 reinterpret_cast<void*>(&FlutterTextUtilsIsVariationSelector),
830 },
831 {
832 .name = "nativeFlutterTextUtilsIsRegionalIndicator",
833 .signature = "(I)Z",
834 .fnPtr =
835 reinterpret_cast<void*>(&FlutterTextUtilsIsRegionalIndicator),
836 },
837 {
838 .name = "nativeLoadDartDeferredLibrary",
839 .signature = "(JI[Ljava/lang/String;)V",
840 .fnPtr = reinterpret_cast<void*>(&LoadDartDeferredLibrary),
841 },
842 {
843 .name = "nativeUpdateJavaAssetManager",
844 .signature =
845 "(JLandroid/content/res/AssetManager;Ljava/lang/String;)V",
846 .fnPtr = reinterpret_cast<void*>(&UpdateJavaAssetManager),
847 },
848 {
849 .name = "nativeDeferredComponentInstallFailure",
850 .signature = "(ILjava/lang/String;Z)V",
851 .fnPtr = reinterpret_cast<void*>(&DeferredComponentInstallFailure),
852 },
853 {
854 .name = "nativeUpdateDisplayMetrics",
855 .signature = "(J)V",
856 .fnPtr = reinterpret_cast<void*>(&UpdateDisplayMetrics),
857 },
858 };
859
860 if (env->RegisterNatives(g_flutter_jni_class->obj(), flutter_jni_methods,
861 fml::size(flutter_jni_methods)) != 0) {
862 FML_LOG(ERROR) << "Failed to RegisterNatives with FlutterJNI";
863 return false;
864 }
865
866 g_jni_shell_holder_field = env->GetFieldID(
867 g_flutter_jni_class->obj(), "nativeShellHolderId", "Ljava/lang/Long;");
868
869 if (g_jni_shell_holder_field == nullptr) {
870 FML_LOG(ERROR) << "Could not locate FlutterJNI's nativeShellHolderId field";
871 return false;
872 }
873
875 env->GetMethodID(g_flutter_jni_class->obj(), "<init>", "()V");
876
877 if (g_jni_constructor == nullptr) {
878 FML_LOG(ERROR) << "Could not locate FlutterJNI's constructor";
879 return false;
880 }
881
882 g_long_constructor = env->GetStaticMethodID(g_java_long_class->obj(),
883 "valueOf", "(J)Ljava/lang/Long;");
884 if (g_long_constructor == nullptr) {
885 FML_LOG(ERROR) << "Could not locate Long's constructor";
886 return false;
887 }
888
890 env->GetMethodID(g_flutter_jni_class->obj(), "handlePlatformMessage",
891 "(Ljava/lang/String;Ljava/nio/ByteBuffer;IJ)V");
892
893 if (g_handle_platform_message_method == nullptr) {
894 FML_LOG(ERROR) << "Could not locate handlePlatformMessage method";
895 return false;
896 }
897
899 g_flutter_jni_class->obj(), "handlePlatformMessageResponse",
900 "(ILjava/nio/ByteBuffer;)V");
901
903 FML_LOG(ERROR) << "Could not locate handlePlatformMessageResponse method";
904 return false;
905 }
906
907 g_get_scaled_font_size_method = env->GetMethodID(
908 g_flutter_jni_class->obj(), "getScaledFontSize", "(FI)F");
909
910 if (g_get_scaled_font_size_method == nullptr) {
911 FML_LOG(ERROR) << "Could not locate FlutterJNI#getScaledFontSize method";
912 return false;
913 }
914
915 g_update_semantics_method = env->GetMethodID(
916 g_flutter_jni_class->obj(), "updateSemantics",
917 "(Ljava/nio/ByteBuffer;[Ljava/lang/String;[Ljava/nio/ByteBuffer;)V");
918
919 if (g_update_semantics_method == nullptr) {
920 FML_LOG(ERROR) << "Could not locate updateSemantics method";
921 return false;
922 }
923
925 g_flutter_jni_class->obj(), "updateCustomAccessibilityActions",
926 "(Ljava/nio/ByteBuffer;[Ljava/lang/String;)V");
927
930 << "Could not locate updateCustomAccessibilityActions method";
931 return false;
932 }
933
935 env->GetMethodID(g_flutter_jni_class->obj(), "onFirstFrame", "()V");
936
937 if (g_on_first_frame_method == nullptr) {
938 FML_LOG(ERROR) << "Could not locate onFirstFrame method";
939 return false;
940 }
941
943 env->GetMethodID(g_flutter_jni_class->obj(), "onPreEngineRestart", "()V");
944
945 if (g_on_engine_restart_method == nullptr) {
946 FML_LOG(ERROR) << "Could not locate onEngineRestart method";
947 return false;
948 }
949
951 env->GetMethodID(g_flutter_jni_class->obj(), "createOverlaySurface",
952 "()Lio/flutter/embedding/engine/FlutterOverlaySurface;");
953
954 if (g_create_overlay_surface_method == nullptr) {
955 FML_LOG(ERROR) << "Could not locate createOverlaySurface method";
956 return false;
957 }
958
960 g_flutter_jni_class->obj(), "destroyOverlaySurfaces", "()V");
961
962 if (g_destroy_overlay_surfaces_method == nullptr) {
963 FML_LOG(ERROR) << "Could not locate destroyOverlaySurfaces method";
964 return false;
965 }
966
967 fml::jni::ScopedJavaLocalRef<jclass> overlay_surface_class(
968 env, env->FindClass("io/flutter/embedding/engine/FlutterOverlaySurface"));
969 if (overlay_surface_class.is_null()) {
970 FML_LOG(ERROR) << "Could not locate FlutterOverlaySurface class";
971 return false;
972 }
974 env->GetMethodID(overlay_surface_class.obj(), "getId", "()I");
975 if (g_overlay_surface_id_method == nullptr) {
976 FML_LOG(ERROR) << "Could not locate FlutterOverlaySurface#getId() method";
977 return false;
978 }
980 overlay_surface_class.obj(), "getSurface", "()Landroid/view/Surface;");
981 if (g_overlay_surface_surface_method == nullptr) {
983 << "Could not locate FlutterOverlaySurface#getSurface() method";
984 return false;
985 }
986
988 env, env->FindClass("android/graphics/Bitmap"));
989 if (g_bitmap_class->is_null()) {
990 FML_LOG(ERROR) << "Could not locate Bitmap Class";
991 return false;
992 }
993
994 g_bitmap_create_bitmap_method = env->GetStaticMethodID(
995 g_bitmap_class->obj(), "createBitmap",
996 "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;");
997 if (g_bitmap_create_bitmap_method == nullptr) {
998 FML_LOG(ERROR) << "Could not locate Bitmap.createBitmap method";
999 return false;
1000 }
1001
1003 g_bitmap_class->obj(), "copyPixelsFromBuffer", "(Ljava/nio/Buffer;)V");
1005 FML_LOG(ERROR) << "Could not locate Bitmap.copyPixelsFromBuffer method";
1006 return false;
1007 }
1008
1010 env, env->FindClass("android/graphics/Bitmap$Config"));
1011 if (g_bitmap_config_class->is_null()) {
1012 FML_LOG(ERROR) << "Could not locate Bitmap.Config Class";
1013 return false;
1014 }
1015
1016 g_bitmap_config_value_of = env->GetStaticMethodID(
1017 g_bitmap_config_class->obj(), "valueOf",
1018 "(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;");
1019 if (g_bitmap_config_value_of == nullptr) {
1020 FML_LOG(ERROR) << "Could not locate Bitmap.Config.valueOf method";
1021 return false;
1022 }
1023
1024 return true;
1025}
1026
1028 if (env == nullptr) {
1029 FML_LOG(ERROR) << "No JNIEnv provided";
1030 return false;
1031 }
1032
1034 env, env->FindClass("io/flutter/view/FlutterCallbackInformation"));
1035 if (g_flutter_callback_info_class->is_null()) {
1036 FML_LOG(ERROR) << "Could not locate FlutterCallbackInformation class";
1037 return false;
1038 }
1039
1041 g_flutter_callback_info_class->obj(), "<init>",
1042 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
1043 if (g_flutter_callback_info_constructor == nullptr) {
1044 FML_LOG(ERROR) << "Could not locate FlutterCallbackInformation constructor";
1045 return false;
1046 }
1047
1049 env, env->FindClass("io/flutter/embedding/engine/FlutterJNI"));
1050 if (g_flutter_jni_class->is_null()) {
1051 FML_LOG(ERROR) << "Failed to find FlutterJNI Class.";
1052 return false;
1053 }
1054
1056 env,
1057 env->FindClass(
1058 "io/flutter/embedding/engine/mutatorsstack/FlutterMutatorsStack"));
1059 if (g_mutators_stack_class == nullptr) {
1060 FML_LOG(ERROR) << "Could not locate FlutterMutatorsStack";
1061 return false;
1062 }
1063
1065 env->GetMethodID(g_mutators_stack_class->obj(), "<init>", "()V");
1066 if (g_mutators_stack_init_method == nullptr) {
1067 FML_LOG(ERROR) << "Could not locate FlutterMutatorsStack.init method";
1068 return false;
1069 }
1070
1072 env->GetMethodID(g_mutators_stack_class->obj(), "pushTransform", "([F)V");
1074 FML_LOG(ERROR)
1075 << "Could not locate FlutterMutatorsStack.pushTransform method";
1076 return false;
1077 }
1078
1080 g_mutators_stack_class->obj(), "pushClipRect", "(IIII)V");
1082 FML_LOG(ERROR)
1083 << "Could not locate FlutterMutatorsStack.pushClipRect method";
1084 return false;
1085 }
1086
1088 g_mutators_stack_class->obj(), "pushClipRRect", "(IIII[F)V");
1090 FML_LOG(ERROR)
1091 << "Could not locate FlutterMutatorsStack.pushClipRRect method";
1092 return false;
1093 }
1094
1096 env->GetMethodID(g_flutter_jni_class->obj(), "onDisplayPlatformView",
1097 "(IIIIIIILio/flutter/embedding/engine/mutatorsstack/"
1098 "FlutterMutatorsStack;)V");
1099
1100 if (g_on_display_platform_view_method == nullptr) {
1101 FML_LOG(ERROR) << "Could not locate onDisplayPlatformView method";
1102 return false;
1103 }
1104
1106 env->GetMethodID(g_flutter_jni_class->obj(), "onBeginFrame", "()V");
1107
1108 if (g_on_begin_frame_method == nullptr) {
1109 FML_LOG(ERROR) << "Could not locate onBeginFrame method";
1110 return false;
1111 }
1112
1114 env->GetMethodID(g_flutter_jni_class->obj(), "onEndFrame", "()V");
1115
1116 if (g_on_end_frame_method == nullptr) {
1117 FML_LOG(ERROR) << "Could not locate onEndFrame method";
1118 return false;
1119 }
1120
1122 g_flutter_jni_class->obj(), "onDisplayOverlaySurface", "(IIIII)V");
1123
1124 if (g_on_display_overlay_surface_method == nullptr) {
1125 FML_LOG(ERROR) << "Could not locate onDisplayOverlaySurface method";
1126 return false;
1127 }
1128
1130 env, env->FindClass("java/lang/ref/WeakReference"));
1131 if (g_java_weak_reference_class->is_null()) {
1132 FML_LOG(ERROR) << "Could not locate WeakReference class";
1133 return false;
1134 }
1135
1137 g_java_weak_reference_class->obj(), "get", "()Ljava/lang/Object;");
1138 if (g_java_weak_reference_get_method == nullptr) {
1139 FML_LOG(ERROR) << "Could not locate WeakReference.get method";
1140 return false;
1141 }
1142
1144 env, env->FindClass(
1145 "io/flutter/embedding/engine/renderer/SurfaceTextureWrapper"));
1146 if (g_texture_wrapper_class->is_null()) {
1147 FML_LOG(ERROR) << "Could not locate SurfaceTextureWrapper class";
1148 return false;
1149 }
1150
1151 g_attach_to_gl_context_method = env->GetMethodID(
1152 g_texture_wrapper_class->obj(), "attachToGLContext", "(I)V");
1153
1154 if (g_attach_to_gl_context_method == nullptr) {
1155 FML_LOG(ERROR) << "Could not locate attachToGlContext method";
1156 return false;
1157 }
1158
1160 env->GetMethodID(g_texture_wrapper_class->obj(), "shouldUpdate", "()Z");
1161
1163 FML_LOG(ERROR)
1164 << "Could not locate SurfaceTextureWrapper.shouldUpdate method";
1165 return false;
1166 }
1167
1169 env->GetMethodID(g_texture_wrapper_class->obj(), "updateTexImage", "()V");
1170
1171 if (g_update_tex_image_method == nullptr) {
1172 FML_LOG(ERROR) << "Could not locate updateTexImage method";
1173 return false;
1174 }
1175
1176 g_get_transform_matrix_method = env->GetMethodID(
1177 g_texture_wrapper_class->obj(), "getTransformMatrix", "([F)V");
1178
1179 if (g_get_transform_matrix_method == nullptr) {
1180 FML_LOG(ERROR) << "Could not locate getTransformMatrix method";
1181 return false;
1182 }
1183
1184 g_detach_from_gl_context_method = env->GetMethodID(
1185 g_texture_wrapper_class->obj(), "detachFromGLContext", "()V");
1186
1187 if (g_detach_from_gl_context_method == nullptr) {
1188 FML_LOG(ERROR) << "Could not locate detachFromGlContext method";
1189 return false;
1190 }
1193 env, env->FindClass("io/flutter/view/TextureRegistry$ImageConsumer"));
1195 FML_LOG(ERROR) << "Could not locate TextureRegistry.ImageConsumer class";
1196 return false;
1197 }
1198
1201 "acquireLatestImage", "()Landroid/media/Image;");
1202 if (g_acquire_latest_image_method == nullptr) {
1203 FML_LOG(ERROR) << "Could not locate acquireLatestImage on "
1204 "TextureRegistry.ImageConsumer class";
1205 return false;
1206 }
1207
1209 env, env->FindClass("android/media/Image"));
1210 if (g_image_class->is_null()) {
1211 FML_LOG(ERROR) << "Could not locate Image class";
1212 return false;
1213 }
1214
1215 // Ensure we don't have any pending exceptions.
1217
1219 env->GetMethodID(g_image_class->obj(), "getHardwareBuffer",
1220 "()Landroid/hardware/HardwareBuffer;");
1221
1222 if (g_image_get_hardware_buffer_method == nullptr) {
1223 // Continue on as this method may not exist at API <= 29.
1225 }
1226
1227 g_image_close_method = env->GetMethodID(g_image_class->obj(), "close", "()V");
1228
1229 if (g_image_close_method == nullptr) {
1230 FML_LOG(ERROR) << "Could not locate close on Image class";
1231 return false;
1232 }
1233
1234 // Ensure we don't have any pending exceptions.
1237 env, env->FindClass("android/hardware/HardwareBuffer"));
1238
1239 if (!g_hardware_buffer_class->is_null()) {
1241 env->GetMethodID(g_hardware_buffer_class->obj(), "close", "()V");
1242 if (g_hardware_buffer_close_method == nullptr) {
1243 // Continue on as this class may not exist at API <= 26.
1245 }
1246 } else {
1247 // Continue on as this class may not exist at API <= 26.
1249 }
1250
1252 g_flutter_jni_class->obj(), "computePlatformResolvedLocale",
1253 "([Ljava/lang/String;)[Ljava/lang/String;");
1254
1256 FML_LOG(ERROR) << "Could not locate computePlatformResolvedLocale method";
1257 return false;
1258 }
1259
1261 g_flutter_jni_class->obj(), "requestDartDeferredLibrary", "(I)V");
1262
1264 FML_LOG(ERROR) << "Could not locate requestDartDeferredLibrary method";
1265 return false;
1266 }
1267
1269 env, env->FindClass("java/lang/Long"));
1270 if (g_java_long_class->is_null()) {
1271 FML_LOG(ERROR) << "Could not locate java.lang.Long class";
1272 return false;
1273 }
1274
1275 return RegisterApi(env);
1276}
1277
1279 const fml::jni::JavaObjectWeakGlobalRef& java_object)
1280 : java_object_(java_object) {}
1281
1283
1285 std::unique_ptr<flutter::PlatformMessage> message,
1286 int responseId) {
1287 // Called from any thread.
1289
1290 auto java_object = java_object_.get(env);
1291 if (java_object.is_null()) {
1292 return;
1293 }
1294
1297
1298 if (message->hasData()) {
1300 env, env->NewDirectByteBuffer(
1301 const_cast<uint8_t*>(message->data().GetMapping()),
1302 message->data().GetSize()));
1303 // Message data is deleted in CleanupMessageData.
1304 fml::MallocMapping mapping = message->releaseData();
1305 env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
1306 java_channel.obj(), message_array.obj(), responseId,
1307 reinterpret_cast<jlong>(mapping.Release()));
1308 } else {
1309 env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
1310 java_channel.obj(), nullptr, responseId, nullptr);
1311 }
1312
1314}
1315
1317 int responseId,
1318 std::unique_ptr<fml::Mapping> data) {
1319 // We are on the platform thread. Attempt to get the strong reference to
1320 // the Java object.
1322
1323 auto java_object = java_object_.get(env);
1324 if (java_object.is_null()) {
1325 // The Java object was collected before this message response got to
1326 // it. Drop the response on the floor.
1327 return;
1328 }
1329 if (data == nullptr) { // Empty response.
1330 env->CallVoidMethod(java_object.obj(),
1332 nullptr);
1333 } else {
1334 // Convert the vector to a Java byte array.
1336 env, env->NewDirectByteBuffer(const_cast<uint8_t*>(data->GetMapping()),
1337 data->GetSize()));
1338
1339 env->CallVoidMethod(java_object.obj(),
1341 data_array.obj());
1342 }
1343
1345}
1346
1348 double font_size,
1349 int configuration_id) const {
1351
1352 auto java_object = java_object_.get(env);
1353 if (java_object.is_null()) {
1354 return -3;
1355 }
1356
1357 const jfloat scaledSize =
1358 env->CallFloatMethod(java_object.obj(), g_get_scaled_font_size_method,
1359 (jfloat)font_size, (jint)configuration_id);
1361 return (double)scaledSize;
1362}
1363
1365 std::vector<uint8_t> buffer,
1366 std::vector<std::string> strings,
1367 std::vector<std::vector<uint8_t>> string_attribute_args) {
1369
1370 auto java_object = java_object_.get(env);
1371 if (java_object.is_null()) {
1372 return;
1373 }
1374
1376 env, env->NewDirectByteBuffer(buffer.data(), buffer.size()));
1379 fml::jni::ScopedJavaLocalRef<jobjectArray> jstring_attribute_args =
1380 fml::jni::VectorToBufferArray(env, string_attribute_args);
1381
1382 env->CallVoidMethod(java_object.obj(), g_update_semantics_method,
1383 direct_buffer.obj(), jstrings.obj(),
1384 jstring_attribute_args.obj());
1385
1387}
1388
1390 std::vector<uint8_t> actions_buffer,
1391 std::vector<std::string> strings) {
1393
1394 auto java_object = java_object_.get(env);
1395 if (java_object.is_null()) {
1396 return;
1397 }
1398
1399 fml::jni::ScopedJavaLocalRef<jobject> direct_actions_buffer(
1400 env,
1401 env->NewDirectByteBuffer(actions_buffer.data(), actions_buffer.size()));
1402
1405
1406 env->CallVoidMethod(java_object.obj(),
1408 direct_actions_buffer.obj(), jstrings.obj());
1409
1411}
1412
1415
1416 auto java_object = java_object_.get(env);
1417 if (java_object.is_null()) {
1418 return;
1419 }
1420
1421 env->CallVoidMethod(java_object.obj(), g_on_first_frame_method);
1422
1424}
1425
1428
1429 auto java_object = java_object_.get(env);
1430 if (java_object.is_null()) {
1431 return;
1432 }
1433
1434 env->CallVoidMethod(java_object.obj(), g_on_engine_restart_method);
1435
1437}
1438
1440 JavaLocalRef surface_texture,
1441 int textureId) {
1443
1444 if (surface_texture.is_null()) {
1445 return;
1446 }
1447
1448 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1449 env, env->CallObjectMethod(surface_texture.obj(),
1451
1452 if (surface_texture_local_ref.is_null()) {
1453 return;
1454 }
1455
1456 env->CallVoidMethod(surface_texture_local_ref.obj(),
1458
1460}
1461
1463 JavaLocalRef surface_texture) {
1465
1466 if (surface_texture.is_null()) {
1467 return false;
1468 }
1469
1470 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1471 env, env->CallObjectMethod(surface_texture.obj(),
1473 if (surface_texture_local_ref.is_null()) {
1474 return false;
1475 }
1476
1477 jboolean shouldUpdate = env->CallBooleanMethod(
1478 surface_texture_local_ref.obj(), g_surface_texture_wrapper_should_update);
1479
1481
1482 return shouldUpdate;
1483}
1484
1486 JavaLocalRef surface_texture) {
1488
1489 if (surface_texture.is_null()) {
1490 return;
1491 }
1492
1493 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1494 env, env->CallObjectMethod(surface_texture.obj(),
1496 if (surface_texture_local_ref.is_null()) {
1497 return;
1498 }
1499
1500 env->CallVoidMethod(surface_texture_local_ref.obj(),
1502
1504}
1505
1507 JavaLocalRef surface_texture,
1510
1511 if (surface_texture.is_null()) {
1512 return;
1513 }
1514
1515 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1516 env, env->CallObjectMethod(surface_texture.obj(),
1518 if (surface_texture_local_ref.is_null()) {
1519 return;
1520 }
1521
1523 env, env->NewFloatArray(16));
1524
1525 env->CallVoidMethod(surface_texture_local_ref.obj(),
1526 g_get_transform_matrix_method, transformMatrix.obj());
1528
1529 float* m = env->GetFloatArrayElements(transformMatrix.obj(), nullptr);
1530
1531 // SurfaceTexture 4x4 Column Major -> Skia 3x3 Row Major
1532
1533 // SurfaceTexture 4x4 (Column Major):
1534 // | m[0] m[4] m[ 8] m[12] |
1535 // | m[1] m[5] m[ 9] m[13] |
1536 // | m[2] m[6] m[10] m[14] |
1537 // | m[3] m[7] m[11] m[15] |
1538
1539 // According to Android documentation, the 4x4 matrix returned should be used
1540 // with texture coordinates in the form (s, t, 0, 1). Since the z component is
1541 // always 0.0, we are free to ignore any element that multiplies with the z
1542 // component. Converting this to a 3x3 matrix is easy:
1543
1544 // SurfaceTexture 3x3 (Column Major):
1545 // | m[0] m[4] m[12] |
1546 // | m[1] m[5] m[13] |
1547 // | m[3] m[7] m[15] |
1548
1549 // Skia (Row Major):
1550 // | m[0] m[1] m[2] |
1551 // | m[3] m[4] m[5] |
1552 // | m[6] m[7] m[8] |
1553
1554 SkScalar matrix3[] = {
1555 m[0], m[4], m[12], //
1556 m[1], m[5], m[13], //
1557 m[3], m[7], m[15], //
1558 };
1559 env->ReleaseFloatArrayElements(transformMatrix.obj(), m, JNI_ABORT);
1560 transform.set9(matrix3);
1561}
1562
1564 JavaLocalRef surface_texture) {
1566
1567 if (surface_texture.is_null()) {
1568 return;
1569 }
1570
1571 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1572 env, env->CallObjectMethod(surface_texture.obj(),
1574 if (surface_texture_local_ref.is_null()) {
1575 return;
1576 }
1577
1578 env->CallVoidMethod(surface_texture_local_ref.obj(),
1580
1582}
1583
1586 JavaLocalRef image_producer_texture_entry) {
1588
1589 if (image_producer_texture_entry.is_null()) {
1590 // Return null.
1591 return JavaLocalRef();
1592 }
1593
1594 // Convert the weak reference to ImageTextureEntry into a strong local
1595 // reference.
1596 fml::jni::ScopedJavaLocalRef<jobject> image_producer_texture_entry_local_ref(
1597 env, env->CallObjectMethod(image_producer_texture_entry.obj(),
1599
1600 if (image_producer_texture_entry_local_ref.is_null()) {
1601 // Return null.
1602 return JavaLocalRef();
1603 }
1604
1606 env, env->CallObjectMethod(image_producer_texture_entry_local_ref.obj(),
1609 return r;
1610}
1611
1616 if (image.is_null()) {
1617 // Return null.
1618 return JavaLocalRef();
1619 }
1621 env,
1622 env->CallObjectMethod(image.obj(), g_image_get_hardware_buffer_method));
1624 return r;
1625}
1626
1629 if (image.is_null()) {
1630 return;
1631 }
1632 env->CallVoidMethod(image.obj(), g_image_close_method);
1634}
1635
1637 JavaLocalRef hardware_buffer) {
1640 if (hardware_buffer.is_null()) {
1641 return;
1642 }
1643 env->CallVoidMethod(hardware_buffer.obj(), g_hardware_buffer_close_method);
1645}
1646
1648 int view_id,
1649 int x,
1650 int y,
1651 int width,
1652 int height,
1653 int viewWidth,
1654 int viewHeight,
1655 MutatorsStack mutators_stack) {
1657 auto java_object = java_object_.get(env);
1658 if (java_object.is_null()) {
1659 return;
1660 }
1661
1662 jobject mutatorsStack = env->NewObject(g_mutators_stack_class->obj(),
1664
1665 std::vector<std::shared_ptr<Mutator>>::const_iterator iter =
1666 mutators_stack.Begin();
1667 while (iter != mutators_stack.End()) {
1668 switch ((*iter)->GetType()) {
1669 case kTransform: {
1670 const SkMatrix& matrix = (*iter)->GetMatrix();
1671 SkScalar matrix_array[9];
1672 matrix.get9(matrix_array);
1674 env, env->NewFloatArray(9));
1675
1676 env->SetFloatArrayRegion(transformMatrix.obj(), 0, 9, matrix_array);
1677 env->CallVoidMethod(mutatorsStack,
1679 transformMatrix.obj());
1680 break;
1681 }
1682 case kClipRect: {
1683 const SkRect& rect = (*iter)->GetRect();
1684 env->CallVoidMethod(
1686 static_cast<int>(rect.left()), static_cast<int>(rect.top()),
1687 static_cast<int>(rect.right()), static_cast<int>(rect.bottom()));
1688 break;
1689 }
1690 case kClipRRect: {
1691 const SkRRect& rrect = (*iter)->GetRRect();
1692 const SkRect& rect = rrect.rect();
1693 const SkVector& upper_left = rrect.radii(SkRRect::kUpperLeft_Corner);
1694 const SkVector& upper_right = rrect.radii(SkRRect::kUpperRight_Corner);
1695 const SkVector& lower_right = rrect.radii(SkRRect::kLowerRight_Corner);
1696 const SkVector& lower_left = rrect.radii(SkRRect::kLowerLeft_Corner);
1697 SkScalar radiis[8] = {
1698 upper_left.x(), upper_left.y(), upper_right.x(), upper_right.y(),
1699 lower_right.x(), lower_right.y(), lower_left.x(), lower_left.y(),
1700 };
1702 env, env->NewFloatArray(8));
1703 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
1704 env->CallVoidMethod(
1706 static_cast<int>(rect.left()), static_cast<int>(rect.top()),
1707 static_cast<int>(rect.right()), static_cast<int>(rect.bottom()),
1708 radiisArray.obj());
1709 break;
1710 }
1711 // TODO(cyanglaz): Implement other mutators.
1712 // https://github.com/flutter/flutter/issues/58426
1713 case kClipPath:
1714 case kOpacity:
1715 case kBackdropFilter:
1716 break;
1717 }
1718 ++iter;
1719 }
1720
1721 env->CallVoidMethod(java_object.obj(), g_on_display_platform_view_method,
1722 view_id, x, y, width, height, viewWidth, viewHeight,
1723 mutatorsStack);
1724
1726}
1727
1729 int surface_id,
1730 int x,
1731 int y,
1732 int width,
1733 int height) {
1735
1736 auto java_object = java_object_.get(env);
1737 if (java_object.is_null()) {
1738 return;
1739 }
1740
1741 env->CallVoidMethod(java_object.obj(), g_on_display_overlay_surface_method,
1742 surface_id, x, y, width, height);
1743
1745}
1746
1749
1750 auto java_object = java_object_.get(env);
1751 if (java_object.is_null()) {
1752 return;
1753 }
1754
1755 env->CallVoidMethod(java_object.obj(), g_on_begin_frame_method);
1756
1758}
1759
1762
1763 auto java_object = java_object_.get(env);
1764 if (java_object.is_null()) {
1765 return;
1766 }
1767
1768 env->CallVoidMethod(java_object.obj(), g_on_end_frame_method);
1769
1771}
1772
1773std::unique_ptr<PlatformViewAndroidJNI::OverlayMetadata>
1776
1777 auto java_object = java_object_.get(env);
1778 if (java_object.is_null()) {
1779 return nullptr;
1780 }
1781
1783 env, env->CallObjectMethod(java_object.obj(),
1786
1787 if (overlay.is_null()) {
1788 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(0,
1789 nullptr);
1790 }
1791
1792 jint overlay_id =
1793 env->CallIntMethod(overlay.obj(), g_overlay_surface_id_method);
1794
1795 jobject overlay_surface =
1796 env->CallObjectMethod(overlay.obj(), g_overlay_surface_surface_method);
1797
1798 auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
1799 ANativeWindow_fromSurface(env, overlay_surface));
1800
1801 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
1802 overlay_id, std::move(overlay_window));
1803}
1804
1807
1808 auto java_object = java_object_.get(env);
1809 if (java_object.is_null()) {
1810 return;
1811 }
1812
1813 env->CallVoidMethod(java_object.obj(), g_destroy_overlay_surfaces_method);
1814
1816}
1817
1818std::unique_ptr<std::vector<std::string>>
1820 std::vector<std::string> supported_locales_data) {
1822
1823 std::unique_ptr<std::vector<std::string>> out =
1824 std::make_unique<std::vector<std::string>>();
1825
1826 auto java_object = java_object_.get(env);
1827 if (java_object.is_null()) {
1828 return out;
1829 }
1831 fml::jni::VectorToStringArray(env, supported_locales_data);
1832 jobjectArray result = static_cast<jobjectArray>(env->CallObjectMethod(
1834 j_locales_data.obj()));
1835
1837
1838 int length = env->GetArrayLength(result);
1839 for (int i = 0; i < length; i++) {
1840 out->emplace_back(fml::jni::JavaStringToString(
1841 env, static_cast<jstring>(env->GetObjectArrayElement(result, i))));
1842 }
1843 return out;
1844}
1845
1848
1849 auto java_object = java_object_.get(env);
1850 if (java_object.is_null()) {
1852 }
1853
1855 env, env->GetObjectClass(java_object.obj()));
1856 if (clazz.is_null()) {
1858 }
1859
1860 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "refreshRateFPS", "F");
1861 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1862}
1863
1866
1867 auto java_object = java_object_.get(env);
1868 if (java_object.is_null()) {
1869 return -1;
1870 }
1871
1873 env, env->GetObjectClass(java_object.obj()));
1874 if (clazz.is_null()) {
1875 return -1;
1876 }
1877
1878 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayWidth", "F");
1879 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1880}
1881
1884
1885 auto java_object = java_object_.get(env);
1886 if (java_object.is_null()) {
1887 return -1;
1888 }
1889
1891 env, env->GetObjectClass(java_object.obj()));
1892 if (clazz.is_null()) {
1893 return -1;
1894 }
1895
1896 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayHeight", "F");
1897 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1898}
1899
1902
1903 auto java_object = java_object_.get(env);
1904 if (java_object.is_null()) {
1905 return -1;
1906 }
1907
1909 env, env->GetObjectClass(java_object.obj()));
1910 if (clazz.is_null()) {
1911 return -1;
1912 }
1913
1914 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayDensity", "F");
1915 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1916}
1917
1919 int loading_unit_id) {
1921
1922 auto java_object = java_object_.get(env);
1923 if (java_object.is_null()) {
1924 return true;
1925 }
1926
1927 env->CallVoidMethod(java_object.obj(), g_request_dart_deferred_library_method,
1928 loading_unit_id);
1929
1931 return true;
1932}
1933
1934} // namespace flutter
const SkRect & rect() const
Definition: SkRRect.h:264
SkVector radii(Corner corner) const
Definition: SkRRect.h:271
@ kUpperLeft_Corner
index of top-left corner radii
Definition: SkRRect.h:252
@ kLowerRight_Corner
index of bottom-right corner radii
Definition: SkRRect.h:254
@ kUpperRight_Corner
index of top-right corner radii
Definition: SkRRect.h:253
@ kLowerLeft_Corner
index of bottom-left corner radii
Definition: SkRRect.h:255
static std::unique_ptr< DartCallbackRepresentation > GetCallbackInformation(int64_t handle)
static const char * kIsolateDataSymbol
Definition: dart_snapshot.h:58
static const char * kIsolateInstructionsSymbol
Definition: dart_snapshot.h:63
const flutter::Settings & GetSettings() const
Definition: flutter_main.cc:64
static FlutterMain & Get()
Definition: flutter_main.cc:58
const std::vector< std::shared_ptr< Mutator > >::const_iterator End() const
const std::vector< std::shared_ptr< Mutator > >::const_iterator Begin() const
void HardwareBufferClose(JavaLocalRef hardware_buffer) override
Call close on hardware_buffer.
bool RequestDartDeferredLibrary(int loading_unit_id) override
void FlutterViewDisplayOverlaySurface(int surface_id, int x, int y, int width, int height) override
Positions and sizes an overlay surface in hybrid composition.
void SurfaceTextureUpdateTexImage(JavaLocalRef surface_texture) override
Updates the texture image to the most recent frame from the image stream.
void FlutterViewEndFrame() override
Indicates that the current frame ended. It's used to clean up state.
void SurfaceTextureAttachToGLContext(JavaLocalRef surface_texture, int textureId) override
Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread.
void FlutterViewOnFirstFrame() override
Indicates that FlutterView should start painting pixels.
PlatformViewAndroidJNIImpl(const fml::jni::JavaObjectWeakGlobalRef &java_object)
void FlutterViewUpdateCustomAccessibilityActions(std::vector< uint8_t > actions_buffer, std::vector< std::string > strings) override
Sends new custom accessibility events.
void FlutterViewBeginFrame() override
Initiates a frame if using hybrid composition.
void SurfaceTextureDetachFromGLContext(JavaLocalRef surface_texture) override
Detaches a SurfaceTexture from the OpenGL ES context.
bool SurfaceTextureShouldUpdate(JavaLocalRef surface_texture) override
Returns true if surface_texture should be updated.
void FlutterViewDestroyOverlaySurfaces() override
Destroys the overlay surfaces.
void FlutterViewOnDisplayPlatformView(int view_id, int x, int y, int width, int height, int viewWidth, int viewHeight, MutatorsStack mutators_stack) override
Positions and sizes a platform view if using hybrid composition.
void FlutterViewHandlePlatformMessageResponse(int responseId, std::unique_ptr< fml::Mapping > data) override
Responds to a platform message. The data may be a nullptr.
double FlutterViewGetScaledFontSize(double unscaled_font_size, int configuration_id) const override
JavaLocalRef ImageGetHardwareBuffer(JavaLocalRef image) override
Grab the HardwareBuffer from image.
void SurfaceTextureGetTransformMatrix(JavaLocalRef surface_texture, SkMatrix &transform) override
Gets the transform matrix from the SurfaceTexture. Then, it updates the transform matrix,...
std::unique_ptr< PlatformViewAndroidJNI::OverlayMetadata > FlutterViewCreateOverlaySurface() override
Instantiates an overlay surface in hybrid composition and provides the necessary metadata to operate ...
void FlutterViewUpdateSemantics(std::vector< uint8_t > buffer, std::vector< std::string > strings, std::vector< std::vector< uint8_t > > string_attribute_args) override
Sends semantics tree updates.
JavaLocalRef ImageProducerTextureEntryAcquireLatestImage(JavaLocalRef image_texture_entry) override
Acquire the latest image available.
void FlutterViewHandlePlatformMessage(std::unique_ptr< flutter::PlatformMessage > message, int responseId) override
Sends a platform message. The message may be empty.
void ImageClose(JavaLocalRef image) override
Call close on image.
void FlutterViewOnPreEngineRestart() override
Indicates that a hot restart is about to happen.
std::unique_ptr< std::vector< std::string > > FlutterViewComputePlatformResolvedLocale(std::vector< std::string > supported_locales_data) override
Computes the locale Android would select.
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition: mapping.h:144
static MallocMapping Copy(const T *begin, const T *end)
Definition: mapping.h:162
uint8_t * Release()
Definition: mapping.cc:155
static fml::RefPtr< NativeLibrary > CreateWithHandle(Handle handle, bool close_handle_when_done)
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
SkScalar font_size
GLFWwindow * window
Definition: main.cc:45
float SkScalar
Definition: extension.cpp:12
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
GAsyncResult * result
#define FML_LOG(severity)
Definition: logging.h:82
#define FML_CHECK(condition)
Definition: logging.h:85
#define FML_DCHECK(condition)
Definition: logging.h:103
size_t length
Win32Message message
double y
double x
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkRRect rrect
Definition: SkRecords.h:232
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
Definition: bitmap.py:1
Definition: __init__.py:1
static jmethodID g_hardware_buffer_close_method
static jmethodID g_mutators_stack_init_method
static void RunBundleAndSnapshotFromLibrary(JNIEnv *env, jobject jcaller, jlong shell_holder, jstring jBundlePath, jstring jEntrypoint, jstring jLibraryUrl, jobject jAssetManager, jobject jEntrypointArgs)
constexpr int64_t kFlutterImplicitViewId
Definition: constants.h:35
static jmethodID g_handle_platform_message_method
static jfieldID g_jni_shell_holder_field
static void InvokePlatformMessageResponseCallback(JNIEnv *env, jobject jcaller, jlong shell_holder, jint responseId, jobject message, jint position)
static jmethodID g_request_dart_deferred_library_method
static jboolean GetIsSoftwareRendering(JNIEnv *env, jobject jcaller)
static void DispatchPointerDataPacket(JNIEnv *env, jobject jcaller, jlong shell_holder, jobject buffer, jint position)
bool RegisterApi(JNIEnv *env)
static jboolean FlutterTextUtilsIsEmojiModifier(JNIEnv *env, jobject obj, jint codePoint)
static fml::jni::ScopedJavaGlobalRef< jclass > * g_java_long_class
static void LoadLoadingUnitFailure(intptr_t loading_unit_id, const std::string &message, bool transient)
static jmethodID g_on_engine_restart_method
static jmethodID g_on_display_overlay_surface_method
static void InvokePlatformMessageEmptyResponseCallback(JNIEnv *env, jobject jcaller, jlong shell_holder, jint responseId)
static jmethodID g_handle_platform_message_response_method
static jmethodID g_acquire_latest_image_method
static jmethodID g_mutators_stack_push_transform_method
static jmethodID g_on_begin_frame_method
static fml::jni::ScopedJavaGlobalRef< jclass > * g_bitmap_class
std::nullptr_t JavaLocalRef
static void SurfaceDestroyed(JNIEnv *env, jobject jcaller, jlong shell_holder)
static jmethodID g_create_overlay_surface_method
static jmethodID g_destroy_overlay_surfaces_method
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
static jmethodID g_long_constructor
static void DestroyJNI(JNIEnv *env, jobject jcaller, jlong shell_holder)
static jmethodID g_get_scaled_font_size_method
static void DispatchSemanticsAction(JNIEnv *env, jobject jcaller, jlong shell_holder, jint id, jint action, jobject args, jint args_position)
static jmethodID g_jni_constructor
static void MarkTextureFrameAvailable(JNIEnv *env, jobject jcaller, jlong shell_holder, jlong texture_id)
static jmethodID g_attach_to_gl_context_method
static void RegisterImageTexture(JNIEnv *env, jobject jcaller, jlong shell_holder, jlong texture_id, jobject image_texture_entry)
static void SetSemanticsEnabled(JNIEnv *env, jobject jcaller, jlong shell_holder, jboolean enabled)
static void DeferredComponentInstallFailure(JNIEnv *env, jobject obj, jint jLoadingUnitId, jstring jError, jboolean jTransient)
@ kBackdropFilter
static fml::jni::ScopedJavaGlobalRef< jclass > * g_texture_wrapper_class
static void LoadDartDeferredLibrary(JNIEnv *env, jobject obj, jlong shell_holder, jint jLoadingUnitId, jobjectArray jSearchPaths)
static jmethodID g_java_weak_reference_get_method
static void NotifyLowMemoryWarning(JNIEnv *env, jobject obj, jlong shell_holder)
static jboolean FlutterTextUtilsIsVariationSelector(JNIEnv *env, jobject obj, jint codePoint)
static jmethodID g_image_get_hardware_buffer_method
static jmethodID g_update_custom_accessibility_actions_method
static void CleanupMessageData(JNIEnv *env, jobject jcaller, jlong message_data)
static jmethodID g_mutators_stack_push_cliprect_method
static jmethodID g_overlay_surface_surface_method
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition: switches.h:41
static void DispatchPlatformMessage(JNIEnv *env, jobject jcaller, jlong shell_holder, jstring channel, jobject message, jint position, jint responseId)
static jmethodID g_overlay_surface_id_method
static jmethodID g_mutators_stack_push_cliprrect_method
static jmethodID g_get_transform_matrix_method
static jmethodID g_compute_platform_resolved_locale_method
static void SurfaceWindowChanged(JNIEnv *env, jobject jcaller, jlong shell_holder, jobject jsurface)
static jmethodID g_bitmap_copy_pixels_from_buffer_method
static void SetViewportMetrics(JNIEnv *env, jobject jcaller, jlong shell_holder, jfloat devicePixelRatio, jint physicalWidth, jint physicalHeight, jint physicalPaddingTop, jint physicalPaddingRight, jint physicalPaddingBottom, jint physicalPaddingLeft, jint physicalViewInsetTop, jint physicalViewInsetRight, jint physicalViewInsetBottom, jint physicalViewInsetLeft, jint systemGestureInsetTop, jint systemGestureInsetRight, jint systemGestureInsetBottom, jint systemGestureInsetLeft, jint physicalTouchSlop, jintArray javaDisplayFeaturesBounds, jintArray javaDisplayFeaturesType, jintArray javaDisplayFeaturesState)
static fml::jni::ScopedJavaGlobalRef< jclass > * g_flutter_jni_class
static fml::jni::ScopedJavaGlobalRef< jclass > * g_bitmap_config_class
static jmethodID g_surface_texture_wrapper_should_update
static fml::jni::ScopedJavaGlobalRef< jclass > * g_image_class
static void SurfaceCreated(JNIEnv *env, jobject jcaller, jlong shell_holder, jobject jsurface)
static jmethodID g_flutter_callback_info_constructor
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
static void DispatchEmptyPlatformMessage(JNIEnv *env, jobject jcaller, jlong shell_holder, jstring channel, jint responseId)
static void ScheduleFrame(JNIEnv *env, jobject jcaller, jlong shell_holder)
static jlong AttachJNI(JNIEnv *env, jclass clazz, jobject flutterJNI)
static void SetAccessibilityFeatures(JNIEnv *env, jobject jcaller, jlong shell_holder, jint flags)
static jmethodID g_update_tex_image_method
static fml::jni::ScopedJavaGlobalRef< jclass > * g_java_weak_reference_class
static jmethodID g_on_display_platform_view_method
static jmethodID g_on_end_frame_method
static jmethodID g_image_close_method
static void UpdateDisplayMetrics(JNIEnv *env, jobject jcaller, jlong shell_holder)
static void SurfaceChanged(JNIEnv *env, jobject jcaller, jlong shell_holder, jint width, jint height)
static jmethodID g_bitmap_config_value_of
static fml::jni::ScopedJavaGlobalRef< jclass > * g_image_consumer_texture_registry_interface
static jmethodID g_on_first_frame_method
static void UpdateJavaAssetManager(JNIEnv *env, jobject obj, jlong shell_holder, jobject jAssetManager, jstring jAssetBundlePath)
static jobject GetBitmap(JNIEnv *env, jobject jcaller, jlong shell_holder)
jobject CreateFlutterCallbackInformation(JNIEnv *env, const std::string &callbackName, const std::string &callbackClassName, const std::string &callbackLibraryPath)
static jmethodID g_bitmap_create_bitmap_method
static jmethodID g_update_semantics_method
static void UnregisterTexture(JNIEnv *env, jobject jcaller, jlong shell_holder, jlong texture_id)
static fml::jni::ScopedJavaGlobalRef< jclass > * g_flutter_callback_info_class
static fml::jni::ScopedJavaGlobalRef< jclass > * g_mutators_stack_class
static jboolean FlutterTextUtilsIsEmojiModifierBase(JNIEnv *env, jobject obj, jint codePoint)
static jobject LookupCallbackInformation(JNIEnv *env, jobject, jlong handle)
static jboolean FlutterTextUtilsIsRegionalIndicator(JNIEnv *env, jobject obj, jint codePoint)
static jmethodID g_detach_from_gl_context_method
static jobject SpawnJNI(JNIEnv *env, jobject jcaller, jlong shell_holder, jstring jEntrypoint, jstring jLibraryUrl, jstring jInitialRoute, jobject jEntrypointArgs)
static fml::jni::ScopedJavaGlobalRef< jclass > * g_hardware_buffer_class
static jboolean FlutterTextUtilsIsEmoji(JNIEnv *env, jobject obj, jint codePoint)
static void RegisterTexture(JNIEnv *env, jobject jcaller, jlong shell_holder, jlong texture_id, jobject surface_texture)
static constexpr double kUnknownDisplayRefreshRate
To be used when the display refresh rate is unknown.
Definition: display.h:20
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:34
ScopedJavaLocalRef< jobjectArray > VectorToBufferArray(JNIEnv *env, const std::vector< std::vector< uint8_t > > &vector)
Definition: jni_util.cc:164
std::string JavaStringToString(JNIEnv *env, jstring str)
Definition: jni_util.cc:70
bool ClearException(JNIEnv *env, bool silent)
Definition: jni_util.cc:188
bool CheckException(JNIEnv *env)
Definition: jni_util.cc:199
ScopedJavaLocalRef< jobjectArray > VectorToStringArray(JNIEnv *env, const std::vector< std::string > &vector)
Definition: jni_util.cc:147
std::vector< std::string > StringListToVector(JNIEnv *env, jobject list)
Definition: jni_util.cc:118
std::vector< std::string > StringArrayToVector(JNIEnv *env, jobjectArray array)
Definition: jni_util.cc:96
ScopedJavaLocalRef< jstring > StringToJavaString(JNIEnv *env, const std::string &u8_string)
Definition: jni_util.cc:86
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47
#define ANDROID_SHELL_HOLDER
int32_t height
int32_t width
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181
bool enable_software_rendering
Definition: settings.h:309
int64_t texture_id
#define ERROR(message)
Definition: elf_loader.cc:260