@@ -236,15 +236,17 @@ std::unique_ptr<IsolateConfiguration> CreateIsolateConfiguration(
236236static void RunBundleAndSnapshotFromLibrary (JNIEnv* env,
237237 jobject jcaller,
238238 jlong shell_holder,
239- jstring jbundlepath,
240- jstring jdefaultPath,
239+ jobjectArray jbundlepaths,
241240 jstring jEntrypoint,
242241 jstring jLibraryUrl,
243242 jobject jAssetManager) {
244243 auto asset_manager = std::make_shared<blink::AssetManager>();
244+ for (const auto & bundlepath :
245+ fml::jni::StringArrayToVector (env, jbundlepaths)) {
246+ if (bundlepath.empty ()) {
247+ continue ;
248+ }
245249
246- const auto bundlepath = fml::jni::JavaStringToString (env, jbundlepath);
247- if (bundlepath.size () > 0 ) {
248250 // If we got a bundle path, attempt to use that as a directory asset
249251 // bundle or a zip asset bundle.
250252 const auto file_ext_index = bundlepath.rfind (" ." );
@@ -255,30 +257,23 @@ static void RunBundleAndSnapshotFromLibrary(JNIEnv* env,
255257 asset_manager->PushBack (
256258 std::make_unique<blink::DirectoryAssetBundle>(fml::OpenDirectory (
257259 bundlepath.c_str (), false , fml::FilePermission::kRead )));
258- }
259260
260- // Use the last path component of the bundle path to determine the
261- // directory in the APK assets.
262- const auto last_slash_index = bundlepath.rfind (" /" , bundlepath.size ());
263- if (last_slash_index != std::string::npos) {
264- auto apk_asset_dir = bundlepath.substr (
265- last_slash_index + 1 , bundlepath.size () - last_slash_index);
266-
267- asset_manager->PushBack (std::make_unique<blink::APKAssetProvider>(
268- env, // jni environment
269- jAssetManager, // asset manager
270- std::move (apk_asset_dir)) // apk asset dir
271- );
261+ // Use the last path component of the bundle path to determine the
262+ // directory in the APK assets.
263+ const auto last_slash_index = bundlepath.rfind (" /" , bundlepath.size ());
264+ if (last_slash_index != std::string::npos) {
265+ auto apk_asset_dir = bundlepath.substr (
266+ last_slash_index + 1 , bundlepath.size () - last_slash_index);
267+
268+ asset_manager->PushBack (std::make_unique<blink::APKAssetProvider>(
269+ env, // jni environment
270+ jAssetManager, // asset manager
271+ std::move (apk_asset_dir)) // apk asset dir
272+ );
273+ }
272274 }
273275 }
274276
275- const auto defaultpath = fml::jni::JavaStringToString (env, jdefaultPath);
276- if (defaultpath.size () > 0 ) {
277- asset_manager->PushBack (
278- std::make_unique<blink::DirectoryAssetBundle>(fml::OpenDirectory (
279- defaultpath.c_str (), false , fml::FilePermission::kRead )));
280- }
281-
282277 auto isolate_configuration = CreateIsolateConfiguration (*asset_manager);
283278 if (!isolate_configuration) {
284279 FML_DLOG (ERROR)
@@ -591,9 +586,8 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
591586 },
592587 {
593588 .name = " nativeRunBundleAndSnapshotFromLibrary" ,
594- .signature =
595- " (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;"
596- " Ljava/lang/String;Landroid/content/res/AssetManager;)V" ,
589+ .signature = " (J[Ljava/lang/String;Ljava/lang/String;"
590+ " Ljava/lang/String;Landroid/content/res/AssetManager;)V" ,
597591 .fnPtr =
598592 reinterpret_cast <void *>(&shell::RunBundleAndSnapshotFromLibrary),
599593 },
0 commit comments