5#include "flutter/shell/platform/android/platform_view_android_jni_impl.h"
7#include <android/hardware_buffer_jni.h>
8#include <android/native_window_jni.h>
16#include "unicode/uchar.h"
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"
38#define ANDROID_SHELL_HOLDER \
39 (reinterpret_cast<AndroidShellHolder*>(shell_holder))
71 const std::string& callbackName,
72 const std::string& callbackClassName,
73 const std::string& callbackLibraryPath) {
76 env->NewStringUTF(callbackName.c_str()),
77 env->NewStringUTF(callbackClassName.c_str()),
78 env->NewStringUTF(callbackLibraryPath.c_str()));
160 std::shared_ptr<PlatformViewAndroidJNI> jni_facade =
161 std::make_shared<PlatformViewAndroidJNIImpl>(java_object);
162 auto shell_holder = std::make_unique<AndroidShellHolder>(
164 if (shell_holder->IsValid()) {
165 return reinterpret_cast<jlong
>(shell_holder.release());
190 jstring jInitialRoute,
191 jobject jEntrypointArgs) {
193 if (jni ==
nullptr) {
194 FML_LOG(
ERROR) <<
"Could not create a FlutterJNI instance";
199 std::shared_ptr<PlatformViewAndroidJNI> jni_facade =
200 std::make_shared<PlatformViewAndroidJNIImpl>(java_jni);
208 jni_facade, entrypoint, libraryUrl, initial_route, entrypoint_args);
210 if (spawned_shell_holder ==
nullptr || !spawned_shell_holder->IsValid()) {
215 jobject javaLong =
env->CallStaticObjectMethod(
217 reinterpret_cast<jlong
>(spawned_shell_holder.release()));
218 if (javaLong ==
nullptr) {
236 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
237 ANativeWindow_fromSurface(
env, jsurface));
249 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
250 ANativeWindow_fromSurface(
env, jsurface));
274 jobject jAssetManager,
275 jobject jEntrypointArgs) {
276 auto apk_asset_provider = std::make_unique<flutter::APKAssetProvider>(
286 libraryUrl, entrypoint_args);
293 if (cbInfo ==
nullptr) {
297 cbInfo->library_path);
303 jfloat devicePixelRatio,
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) {
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]);
335 jsize stateSize =
env->GetArrayLength(javaDisplayFeaturesState);
336 std::vector<int> displayFeaturesState(stateSize);
337 env->GetIntArrayRegion(javaDisplayFeaturesState, 0, stateSize,
338 &displayFeaturesState[0]);
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,
359 displayFeaturesState,
369 jlong shell_holder) {
373static jobject
GetBitmap(JNIEnv*
env, jobject jcaller, jlong shell_holder) {
376 if (screenshot.data ==
nullptr) {
380 jstring argb =
env->NewStringUTF(
"ARGB_8888");
381 if (argb ==
nullptr) {
385 jobject bitmap_config =
env->CallStaticObjectMethod(
387 if (bitmap_config ==
nullptr) {
391 auto bitmap =
env->CallStaticObjectMethod(
393 screenshot.frame_size.width(), screenshot.frame_size.height(),
398 env->NewDirectByteBuffer(
const_cast<uint8_t*
>(screenshot.data->bytes()),
399 screenshot.data->size()));
437 jlong message_data) {
439 free(
reinterpret_cast<void*
>(message_data));
447 uint8_t*
data =
static_cast<uint8_t*
>(
env->GetDirectBufferAddress(
buffer));
448 auto packet = std::make_unique<flutter::PointerDataPacket>(
data, position);
459 jint args_position) {
491 jobject surface_texture) {
502 jobject image_texture_entry) {
535 uint8_t* response_data =
536 static_cast<uint8_t*
>(
env->GetDirectBufferAddress(
message));
538 auto mapping = std::make_unique<fml::MallocMapping>(
541 ->InvokePlatformMessageResponseCallback(responseId, std::move(mapping));
549 ->InvokePlatformMessageEmptyResponseCallback(responseId);
554 jlong shell_holder) {
561 return u_hasBinaryProperty(codePoint, UProperty::UCHAR_EMOJI);
567 return u_hasBinaryProperty(codePoint, UProperty::UCHAR_EMOJI_MODIFIER);
573 return u_hasBinaryProperty(codePoint, UProperty::UCHAR_EMOJI_MODIFIER_BASE);
579 return u_hasBinaryProperty(codePoint, UProperty::UCHAR_VARIATION_SELECTOR);
585 return u_hasBinaryProperty(codePoint, UProperty::UCHAR_REGIONAL_INDICATOR);
598 jboolean jTransient) {
601 static_cast<bool>(jTransient));
608 jobjectArray jSearchPaths) {
610 intptr_t loading_unit_id =
static_cast<intptr_t
>(jLoadingUnitId);
611 std::vector<std::string> search_paths =
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();
622 if (handle ==
nullptr) {
624 "No lib .so found for provided search paths.",
true);
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>(
639 loading_unit_id, std::move(data_mapping),
640 std::move(instructions_mapping));
646 jobject jAssetManager,
647 jstring jAssetBundlePath) {
648 auto asset_resolver = std::make_unique<flutter::APKAssetProvider>(
654 std::move(asset_resolver),
655 AssetResolver::AssetResolverType::kApkAssetProvider);
659 static const JNINativeMethod flutter_jni_methods[] = {
662 .name =
"nativeAttach",
663 .signature =
"(Lio/flutter/embedding/engine/FlutterJNI;)J",
664 .fnPtr =
reinterpret_cast<void*
>(&
AttachJNI),
667 .name =
"nativeDestroy",
669 .fnPtr =
reinterpret_cast<void*
>(&
DestroyJNI),
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),
679 .name =
"nativeRunBundleAndSnapshotFromLibrary",
680 .signature =
"(JLjava/lang/String;Ljava/lang/String;"
681 "Ljava/lang/String;Landroid/content/res/"
682 "AssetManager;Ljava/util/List;)V",
686 .name =
"nativeDispatchEmptyPlatformMessage",
687 .signature =
"(JLjava/lang/String;I)V",
691 .name =
"nativeCleanupMessageData",
696 .name =
"nativeDispatchPlatformMessage",
697 .signature =
"(JLjava/lang/String;Ljava/nio/ByteBuffer;II)V",
701 .name =
"nativeInvokePlatformMessageResponseCallback",
702 .signature =
"(JILjava/nio/ByteBuffer;I)V",
707 .name =
"nativeInvokePlatformMessageEmptyResponseCallback",
708 .signature =
"(JI)V",
709 .fnPtr =
reinterpret_cast<void*
>(
713 .name =
"nativeNotifyLowMemoryWarning",
720 .name =
"nativeGetBitmap",
721 .signature =
"(J)Landroid/graphics/Bitmap;",
722 .fnPtr =
reinterpret_cast<void*
>(&
GetBitmap),
725 .name =
"nativeSurfaceCreated",
726 .signature =
"(JLandroid/view/Surface;)V",
730 .name =
"nativeSurfaceWindowChanged",
731 .signature =
"(JLandroid/view/Surface;)V",
735 .name =
"nativeSurfaceChanged",
736 .signature =
"(JII)V",
740 .name =
"nativeSurfaceDestroyed",
745 .name =
"nativeSetViewportMetrics",
746 .signature =
"(JFIIIIIIIIIIIIIII[I[I[I)V",
750 .name =
"nativeDispatchPointerDataPacket",
751 .signature =
"(JLjava/nio/ByteBuffer;I)V",
755 .name =
"nativeDispatchSemanticsAction",
756 .signature =
"(JIILjava/nio/ByteBuffer;I)V",
760 .name =
"nativeSetSemanticsEnabled",
761 .signature =
"(JZ)V",
765 .name =
"nativeSetAccessibilityFeatures",
766 .signature =
"(JI)V",
770 .name =
"nativeGetIsSoftwareRenderingEnabled",
775 .name =
"nativeRegisterTexture",
776 .signature =
"(JJLjava/lang/ref/"
781 .name =
"nativeRegisterImageTexture",
782 .signature =
"(JJLjava/lang/ref/"
787 .name =
"nativeMarkTextureFrameAvailable",
788 .signature =
"(JJ)V",
792 .name =
"nativeScheduleFrame",
797 .name =
"nativeUnregisterTexture",
798 .signature =
"(JJ)V",
803 .name =
"nativeLookupCallbackInformation",
804 .signature =
"(J)Lio/flutter/view/FlutterCallbackInformation;",
810 .name =
"nativeFlutterTextUtilsIsEmoji",
815 .name =
"nativeFlutterTextUtilsIsEmojiModifier",
820 .name =
"nativeFlutterTextUtilsIsEmojiModifierBase",
826 .name =
"nativeFlutterTextUtilsIsVariationSelector",
832 .name =
"nativeFlutterTextUtilsIsRegionalIndicator",
838 .name =
"nativeLoadDartDeferredLibrary",
839 .signature =
"(JI[Ljava/lang/String;)V",
843 .name =
"nativeUpdateJavaAssetManager",
845 "(JLandroid/content/res/AssetManager;Ljava/lang/String;)V",
849 .name =
"nativeDeferredComponentInstallFailure",
850 .signature =
"(ILjava/lang/String;Z)V",
854 .name =
"nativeUpdateDisplayMetrics",
862 FML_LOG(
ERROR) <<
"Failed to RegisterNatives with FlutterJNI";
870 FML_LOG(
ERROR) <<
"Could not locate FlutterJNI's nativeShellHolderId field";
878 FML_LOG(
ERROR) <<
"Could not locate FlutterJNI's constructor";
883 "valueOf",
"(J)Ljava/lang/Long;");
885 FML_LOG(
ERROR) <<
"Could not locate Long's constructor";
891 "(Ljava/lang/String;Ljava/nio/ByteBuffer;IJ)V");
894 FML_LOG(
ERROR) <<
"Could not locate handlePlatformMessage method";
900 "(ILjava/nio/ByteBuffer;)V");
903 FML_LOG(
ERROR) <<
"Could not locate handlePlatformMessageResponse method";
911 FML_LOG(
ERROR) <<
"Could not locate FlutterJNI#getScaledFontSize method";
917 "(Ljava/nio/ByteBuffer;[Ljava/lang/String;[Ljava/nio/ByteBuffer;)V");
920 FML_LOG(
ERROR) <<
"Could not locate updateSemantics method";
926 "(Ljava/nio/ByteBuffer;[Ljava/lang/String;)V");
930 <<
"Could not locate updateCustomAccessibilityActions method";
938 FML_LOG(
ERROR) <<
"Could not locate onFirstFrame method";
946 FML_LOG(
ERROR) <<
"Could not locate onEngineRestart method";
952 "()Lio/flutter/embedding/engine/FlutterOverlaySurface;");
955 FML_LOG(
ERROR) <<
"Could not locate createOverlaySurface method";
963 FML_LOG(
ERROR) <<
"Could not locate destroyOverlaySurfaces method";
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";
974 env->GetMethodID(overlay_surface_class.
obj(),
"getId",
"()I");
976 FML_LOG(
ERROR) <<
"Could not locate FlutterOverlaySurface#getId() method";
980 overlay_surface_class.
obj(),
"getSurface",
"()Landroid/view/Surface;");
983 <<
"Could not locate FlutterOverlaySurface#getSurface() method";
988 env,
env->FindClass(
"android/graphics/Bitmap"));
996 "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;");
998 FML_LOG(
ERROR) <<
"Could not locate Bitmap.createBitmap method";
1003 g_bitmap_class->obj(),
"copyPixelsFromBuffer",
"(Ljava/nio/Buffer;)V");
1005 FML_LOG(
ERROR) <<
"Could not locate Bitmap.copyPixelsFromBuffer method";
1010 env,
env->FindClass(
"android/graphics/Bitmap$Config"));
1012 FML_LOG(
ERROR) <<
"Could not locate Bitmap.Config Class";
1018 "(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;");
1020 FML_LOG(
ERROR) <<
"Could not locate Bitmap.Config.valueOf method";
1028 if (
env ==
nullptr) {
1034 env,
env->FindClass(
"io/flutter/view/FlutterCallbackInformation"));
1036 FML_LOG(
ERROR) <<
"Could not locate FlutterCallbackInformation class";
1042 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
1044 FML_LOG(
ERROR) <<
"Could not locate FlutterCallbackInformation constructor";
1049 env,
env->FindClass(
"io/flutter/embedding/engine/FlutterJNI"));
1058 "io/flutter/embedding/engine/mutatorsstack/FlutterMutatorsStack"));
1060 FML_LOG(
ERROR) <<
"Could not locate FlutterMutatorsStack";
1067 FML_LOG(
ERROR) <<
"Could not locate FlutterMutatorsStack.init method";
1075 <<
"Could not locate FlutterMutatorsStack.pushTransform method";
1083 <<
"Could not locate FlutterMutatorsStack.pushClipRect method";
1091 <<
"Could not locate FlutterMutatorsStack.pushClipRRect method";
1097 "(IIIIIIILio/flutter/embedding/engine/mutatorsstack/"
1098 "FlutterMutatorsStack;)V");
1101 FML_LOG(
ERROR) <<
"Could not locate onDisplayPlatformView method";
1109 FML_LOG(
ERROR) <<
"Could not locate onBeginFrame method";
1117 FML_LOG(
ERROR) <<
"Could not locate onEndFrame method";
1125 FML_LOG(
ERROR) <<
"Could not locate onDisplayOverlaySurface method";
1130 env,
env->FindClass(
"java/lang/ref/WeakReference"));
1132 FML_LOG(
ERROR) <<
"Could not locate WeakReference class";
1139 FML_LOG(
ERROR) <<
"Could not locate WeakReference.get method";
1145 "io/flutter/embedding/engine/renderer/SurfaceTextureWrapper"));
1147 FML_LOG(
ERROR) <<
"Could not locate SurfaceTextureWrapper class";
1155 FML_LOG(
ERROR) <<
"Could not locate attachToGlContext method";
1164 <<
"Could not locate SurfaceTextureWrapper.shouldUpdate method";
1172 FML_LOG(
ERROR) <<
"Could not locate updateTexImage method";
1180 FML_LOG(
ERROR) <<
"Could not locate getTransformMatrix method";
1188 FML_LOG(
ERROR) <<
"Could not locate detachFromGlContext method";
1193 env,
env->FindClass(
"io/flutter/view/TextureRegistry$ImageConsumer"));
1195 FML_LOG(
ERROR) <<
"Could not locate TextureRegistry.ImageConsumer class";
1201 "acquireLatestImage",
"()Landroid/media/Image;");
1203 FML_LOG(
ERROR) <<
"Could not locate acquireLatestImage on "
1204 "TextureRegistry.ImageConsumer class";
1209 env,
env->FindClass(
"android/media/Image"));
1220 "()Landroid/hardware/HardwareBuffer;");
1230 FML_LOG(
ERROR) <<
"Could not locate close on Image class";
1237 env,
env->FindClass(
"android/hardware/HardwareBuffer"));
1253 "([Ljava/lang/String;)[Ljava/lang/String;");
1256 FML_LOG(
ERROR) <<
"Could not locate computePlatformResolvedLocale method";
1264 FML_LOG(
ERROR) <<
"Could not locate requestDartDeferredLibrary method";
1269 env,
env->FindClass(
"java/lang/Long"));
1271 FML_LOG(
ERROR) <<
"Could not locate java.lang.Long class";
1280 : java_object_(java_object) {}
1285 std::unique_ptr<flutter::PlatformMessage>
message,
1290 auto java_object = java_object_.
get(
env);
1291 if (java_object.is_null()) {
1300 env,
env->NewDirectByteBuffer(
1301 const_cast<uint8_t*
>(
message->data().GetMapping()),
1306 java_channel.
obj(), message_array.
obj(), responseId,
1307 reinterpret_cast<jlong
>(mapping.
Release()));
1310 java_channel.
obj(),
nullptr, responseId,
nullptr);
1318 std::unique_ptr<fml::Mapping>
data) {
1323 auto java_object = java_object_.
get(
env);
1324 if (java_object.is_null()) {
1329 if (
data ==
nullptr) {
1330 env->CallVoidMethod(java_object.obj(),
1336 env,
env->NewDirectByteBuffer(
const_cast<uint8_t*
>(
data->GetMapping()),
1339 env->CallVoidMethod(java_object.obj(),
1349 int configuration_id)
const {
1352 auto java_object = java_object_.
get(
env);
1353 if (java_object.is_null()) {
1357 const jfloat scaledSize =
1359 (jfloat)
font_size, (jint)configuration_id);
1361 return (
double)scaledSize;
1365 std::vector<uint8_t>
buffer,
1366 std::vector<std::string> strings,
1367 std::vector<std::vector<uint8_t>> string_attribute_args) {
1370 auto java_object = java_object_.
get(
env);
1371 if (java_object.is_null()) {
1383 direct_buffer.
obj(), jstrings.
obj(),
1384 jstring_attribute_args.
obj());
1390 std::vector<uint8_t> actions_buffer,
1391 std::vector<std::string> strings) {
1394 auto java_object = java_object_.
get(
env);
1395 if (java_object.is_null()) {
1401 env->NewDirectByteBuffer(actions_buffer.data(), actions_buffer.size()));
1406 env->CallVoidMethod(java_object.obj(),
1408 direct_actions_buffer.
obj(), jstrings.
obj());
1416 auto java_object = java_object_.
get(
env);
1417 if (java_object.is_null()) {
1429 auto java_object = java_object_.
get(
env);
1430 if (java_object.is_null()) {
1444 if (surface_texture.is_null()) {
1449 env,
env->CallObjectMethod(surface_texture.obj(),
1452 if (surface_texture_local_ref.is_null()) {
1456 env->CallVoidMethod(surface_texture_local_ref.
obj(),
1466 if (surface_texture.is_null()) {
1471 env,
env->CallObjectMethod(surface_texture.obj(),
1473 if (surface_texture_local_ref.is_null()) {
1477 jboolean shouldUpdate =
env->CallBooleanMethod(
1482 return shouldUpdate;
1489 if (surface_texture.is_null()) {
1494 env,
env->CallObjectMethod(surface_texture.obj(),
1496 if (surface_texture_local_ref.is_null()) {
1500 env->CallVoidMethod(surface_texture_local_ref.
obj(),
1511 if (surface_texture.is_null()) {
1516 env,
env->CallObjectMethod(surface_texture.obj(),
1518 if (surface_texture_local_ref.is_null()) {
1523 env,
env->NewFloatArray(16));
1525 env->CallVoidMethod(surface_texture_local_ref.
obj(),
1529 float*
m =
env->GetFloatArrayElements(transformMatrix.
obj(),
nullptr);
1559 env->ReleaseFloatArrayElements(transformMatrix.
obj(),
m, JNI_ABORT);
1567 if (surface_texture.is_null()) {
1572 env,
env->CallObjectMethod(surface_texture.obj(),
1574 if (surface_texture_local_ref.is_null()) {
1578 env->CallVoidMethod(surface_texture_local_ref.
obj(),
1589 if (image_producer_texture_entry.is_null()) {
1597 env,
env->CallObjectMethod(image_producer_texture_entry.obj(),
1600 if (image_producer_texture_entry_local_ref.is_null()) {
1606 env,
env->CallObjectMethod(image_producer_texture_entry_local_ref.
obj(),
1616 if (
image.is_null()) {
1629 if (
image.is_null()) {
1640 if (hardware_buffer.is_null()) {
1657 auto java_object = java_object_.
get(
env);
1658 if (java_object.is_null()) {
1665 std::vector<std::shared_ptr<Mutator>>::const_iterator iter =
1666 mutators_stack.
Begin();
1667 while (iter != mutators_stack.
End()) {
1668 switch ((*iter)->GetType()) {
1672 matrix.get9(matrix_array);
1674 env,
env->NewFloatArray(9));
1676 env->SetFloatArrayRegion(transformMatrix.
obj(), 0, 9, matrix_array);
1677 env->CallVoidMethod(mutatorsStack,
1679 transformMatrix.
obj());
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()));
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(),
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()),
1736 auto java_object = java_object_.
get(
env);
1737 if (java_object.is_null()) {
1750 auto java_object = java_object_.
get(
env);
1751 if (java_object.is_null()) {
1763 auto java_object = java_object_.
get(
env);
1764 if (java_object.is_null()) {
1773std::unique_ptr<PlatformViewAndroidJNI::OverlayMetadata>
1777 auto java_object = java_object_.
get(
env);
1778 if (java_object.is_null()) {
1783 env,
env->CallObjectMethod(java_object.obj(),
1787 if (overlay.is_null()) {
1788 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(0,
1795 jobject overlay_surface =
1798 auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
1799 ANativeWindow_fromSurface(
env, overlay_surface));
1801 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
1802 overlay_id, std::move(overlay_window));
1808 auto java_object = java_object_.
get(
env);
1809 if (java_object.is_null()) {
1818std::unique_ptr<std::vector<std::string>>
1820 std::vector<std::string> supported_locales_data) {
1823 std::unique_ptr<std::vector<std::string>>
out =
1824 std::make_unique<std::vector<std::string>>();
1826 auto java_object = java_object_.
get(
env);
1827 if (java_object.is_null()) {
1832 jobjectArray
result =
static_cast<jobjectArray
>(
env->CallObjectMethod(
1834 j_locales_data.
obj()));
1841 env,
static_cast<jstring
>(
env->GetObjectArrayElement(
result,
i))));
1849 auto java_object = java_object_.
get(
env);
1850 if (java_object.is_null()) {
1855 env,
env->GetObjectClass(java_object.obj()));
1856 if (clazz.is_null()) {
1860 jfieldID fid =
env->GetStaticFieldID(clazz.
obj(),
"refreshRateFPS",
"F");
1861 return static_cast<double>(
env->GetStaticFloatField(clazz.
obj(), fid));
1867 auto java_object = java_object_.
get(
env);
1868 if (java_object.is_null()) {
1873 env,
env->GetObjectClass(java_object.obj()));
1874 if (clazz.is_null()) {
1878 jfieldID fid =
env->GetStaticFieldID(clazz.
obj(),
"displayWidth",
"F");
1879 return static_cast<double>(
env->GetStaticFloatField(clazz.
obj(), fid));
1885 auto java_object = java_object_.
get(
env);
1886 if (java_object.is_null()) {
1891 env,
env->GetObjectClass(java_object.obj()));
1892 if (clazz.is_null()) {
1896 jfieldID fid =
env->GetStaticFieldID(clazz.
obj(),
"displayHeight",
"F");
1897 return static_cast<double>(
env->GetStaticFloatField(clazz.
obj(), fid));
1903 auto java_object = java_object_.
get(
env);
1904 if (java_object.is_null()) {
1909 env,
env->GetObjectClass(java_object.obj()));
1910 if (clazz.is_null()) {
1914 jfieldID fid =
env->GetStaticFieldID(clazz.
obj(),
"displayDensity",
"F");
1915 return static_cast<double>(
env->GetStaticFloatField(clazz.
obj(), fid));
1919 int loading_unit_id) {
1922 auto java_object = java_object_.
get(
env);
1923 if (java_object.is_null()) {
const SkRect & rect() const
SkVector radii(Corner corner) const
@ kUpperLeft_Corner
index of top-left corner radii
@ kLowerRight_Corner
index of bottom-right corner radii
@ kUpperRight_Corner
index of top-right corner radii
@ kLowerLeft_Corner
index of bottom-left corner radii
static std::unique_ptr< DartCallbackRepresentation > GetCallbackInformation(int64_t handle)
static const char * kIsolateDataSymbol
static const char * kIsolateInstructionsSymbol
const flutter::Settings & GetSettings() const
static FlutterMain & Get()
A Mapping like NonOwnedMapping, but uses Free as its release proc.
static MallocMapping Copy(const T *begin, const T *end)
static fml::RefPtr< NativeLibrary > CreateWithHandle(Handle handle, bool close_handle_when_done)
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
#define FML_LOG(severity)
#define FML_CHECK(condition)
#define FML_DCHECK(condition)
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< const SkImage > image
sk_sp< SkBlender > blender SkRect rect
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
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
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)
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
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
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.
JNIEnv * AttachCurrentThread()
ScopedJavaLocalRef< jobjectArray > VectorToBufferArray(JNIEnv *env, const std::vector< std::vector< uint8_t > > &vector)
std::string JavaStringToString(JNIEnv *env, jstring str)
bool ClearException(JNIEnv *env, bool silent)
bool CheckException(JNIEnv *env)
ScopedJavaLocalRef< jobjectArray > VectorToStringArray(JNIEnv *env, const std::vector< std::string > &vector)
std::vector< std::string > StringListToVector(JNIEnv *env, jobject list)
std::vector< std::string > StringArrayToVector(JNIEnv *env, jobjectArray array)
ScopedJavaLocalRef< jstring > StringToJavaString(JNIEnv *env, const std::string &u8_string)
constexpr std::size_t size(T(&array)[N])
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
static constexpr SkISize Make(int32_t w, int32_t h)
constexpr float y() const
constexpr float x() const
bool enable_software_rendering