|
13 | 13 |
|
14 | 14 | #include "flutter/assets/directory_asset_bundle.h" |
15 | 15 | #include "flutter/common/settings.h" |
| 16 | +#include "flutter/fml/command_line.h" |
16 | 17 | #include "flutter/fml/file.h" |
17 | 18 | #include "flutter/fml/platform/android/jni_util.h" |
18 | 19 | #include "flutter/fml/platform/android/jni_weak_ref.h" |
19 | 20 | #include "flutter/fml/platform/android/scoped_java_ref.h" |
20 | 21 | #include "flutter/fml/size.h" |
21 | 22 | #include "flutter/lib/ui/plugins/callback_cache.h" |
22 | 23 | #include "flutter/runtime/dart_service_isolate.h" |
| 24 | +#include "flutter/runtime/dart_snapshot.h" |
23 | 25 | #include "flutter/shell/common/run_configuration.h" |
| 26 | +#include "flutter/shell/common/switches.h" |
24 | 27 | #include "flutter/shell/platform/android/android_external_texture_gl.h" |
25 | 28 | #include "flutter/shell/platform/android/android_shell_holder.h" |
26 | 29 | #include "flutter/shell/platform/android/apk_asset_provider.h" |
@@ -514,48 +517,46 @@ static jboolean FlutterTextUtilsIsRegionalIndicator(JNIEnv* env, |
514 | 517 | static void LoadDartLibrary(JNIEnv* env, |
515 | 518 | jobject obj, |
516 | 519 | jlong shell_holder, |
517 | | - jstring jLibPath, |
| 520 | + jint jLoadingUnitId, |
| 521 | + jstring jAssetPath, |
| 522 | + jstring jLibName, |
518 | 523 | jobject jAssetManager) { |
| 524 | + FML_LOG(ERROR) << "LoadDartLibrary Native"; |
519 | 525 | // see RunBundleAndSnapshotFromLibrary above for dart loading code |
520 | 526 | auto asset_manager = std::make_shared<flutter::AssetManager>(); |
521 | 527 |
|
522 | 528 | asset_manager->PushBack(std::make_unique<flutter::APKAssetProvider>( |
523 | | - env, // jni environment |
524 | | - jAssetManager, // asset manager |
525 | | - fml::jni::JavaStringToString(env, jLibPath)) // apk asset dir |
| 529 | + env, // jni environment |
| 530 | + jAssetManager, // asset manager |
| 531 | + fml::jni::JavaStringToString(env, jAssetPath)) // apk asset dir |
526 | 532 | ); |
527 | 533 |
|
528 | | - std::unique_ptr<IsolateConfiguration> isolate_configuration; |
529 | | - if (flutter::DartVM::IsRunningPrecompiledCode()) { |
530 | | - isolate_configuration = IsolateConfiguration::CreateForAppSnapshot(); |
531 | | - } else { |
532 | | - std::unique_ptr<fml::Mapping> kernel_blob = |
533 | | - fml::FileMapping::CreateReadOnly( |
534 | | - ANDROID_SHELL_HOLDER->GetSettings().application_kernel_asset); |
535 | | - if (!kernel_blob) { |
536 | | - FML_DLOG(ERROR) << "Unable to load the kernel blob asset."; |
537 | | - return; |
538 | | - } |
539 | | - isolate_configuration = |
540 | | - IsolateConfiguration::CreateForKernel(std::move(kernel_blob)); |
541 | | - } |
542 | | - |
543 | | - RunConfiguration config(std::move(isolate_configuration), |
544 | | - std::move(asset_manager)); |
| 534 | + // std::unique_ptr<IsolateConfiguration> isolate_configuration; |
| 535 | + // if (flutter::DartVM::IsRunningPrecompiledCode()) { |
| 536 | + // isolate_configuration = IsolateConfiguration::CreateForAppSnapshot(); |
| 537 | + // } else { |
| 538 | + // std::unique_ptr<fml::Mapping> kernel_blob = |
| 539 | + // fml::FileMapping::CreateReadOnly( |
| 540 | + // ANDROID_SHELL_HOLDER->GetSettings().application_kernel_asset); |
| 541 | + // if (!kernel_blob) { |
| 542 | + // FML_DLOG(ERROR) << "Unable to load the kernel blob asset."; |
| 543 | + // return; |
| 544 | + // } |
| 545 | + // isolate_configuration = |
| 546 | + // IsolateConfiguration::CreateForKernel(std::move(kernel_blob)); |
| 547 | + // } |
545 | 548 |
|
546 | | - // { |
547 | | - // auto entrypoint = fml::jni::JavaStringToString(env, jEntrypoint); |
548 | | - // auto libraryUrl = fml::jni::JavaStringToString(env, jLibraryUrl); |
| 549 | + // RunConfiguration config(std::move(isolate_configuration), |
| 550 | + // std::move(asset_manager)); |
549 | 551 |
|
550 | | - // if ((entrypoint.size() > 0) && (libraryUrl.size() > 0)) { |
551 | | - // config.SetEntrypointAndLibrary(std::move(entrypoint), |
552 | | - // std::move(libraryUrl)); |
553 | | - // } else if (entrypoint.size() > 0) { |
554 | | - // config.SetEntrypoint(std::move(entrypoint)); |
555 | | - // } |
| 552 | + ANDROID_SHELL_HOLDER->GetPlatformView()->CompleteDartLoadLibrary( |
| 553 | + static_cast<intptr_t>(jLoadingUnitId), |
| 554 | + fml::jni::JavaStringToString(env, jLibName)); |
| 555 | + FML_LOG(ERROR) << "LoadDartLibrary Native Finished"; |
| 556 | + // if (Dart_IsError(result)) { |
| 557 | + // return; |
556 | 558 | // } |
557 | 559 |
|
558 | | - ANDROID_SHELL_HOLDER->Launch(std::move(config)); |
559 | 560 | // ANDROID_SHELL_HOLDER->DynamicFeatureInstallSuccess(); |
560 | 561 | } |
561 | 562 |
|
@@ -730,7 +731,8 @@ bool RegisterApi(JNIEnv* env) { |
730 | 731 | { |
731 | 732 | .name = "nativeLoadDartLibrary", |
732 | 733 | .signature = |
733 | | - "(JLjava/lang/String;Landroid/content/res/AssetManager;)V", |
| 734 | + "(JILjava/lang/String;Ljava/lang/String;Landroid/content/" |
| 735 | + "res/AssetManager;)V", |
734 | 736 | .fnPtr = reinterpret_cast<void*>(&LoadDartLibrary), |
735 | 737 | }, |
736 | 738 | { |
@@ -1420,20 +1422,20 @@ double PlatformViewAndroidJNIImpl::GetDisplayRefreshRate() { |
1420 | 1422 | return static_cast<double>(env->GetStaticFloatField(clazz, fid)); |
1421 | 1423 | } |
1422 | 1424 |
|
1423 | | -Dart_Handle PlatformViewAndroidJNIImpl::FlutterViewDownloadDynamicFeature( |
| 1425 | +bool PlatformViewAndroidJNIImpl::FlutterViewDownloadDynamicFeature( |
1424 | 1426 | int loading_unit_id) { |
1425 | 1427 | JNIEnv* env = fml::jni::AttachCurrentThread(); |
1426 | 1428 |
|
1427 | 1429 | auto java_object = java_object_.get(env); |
1428 | 1430 | if (java_object.is_null()) { |
1429 | | - return Dart_Null(); |
| 1431 | + return true; |
1430 | 1432 | } |
1431 | 1433 |
|
1432 | 1434 | env->CallObjectMethod(java_object.obj(), g_download_dynamic_feature_method, |
1433 | 1435 | loading_unit_id); |
1434 | 1436 |
|
1435 | 1437 | FML_CHECK(CheckException(env)); |
1436 | | - return Dart_Null(); |
| 1438 | + return true; |
1437 | 1439 | } |
1438 | 1440 |
|
1439 | 1441 | } // namespace flutter |
0 commit comments