Skip to content

Commit

Permalink
Support running bundles from zip file. (flutter#5473)
Browse files Browse the repository at this point in the history
Support running bundles from zip file.
  • Loading branch information
sbaranov authored Jun 7, 2018
1 parent 34c5bfd commit f51b6b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 0 additions & 2 deletions assets/directory_asset_bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class DirectoryAssetBundle : public AssetResolver {
const fml::UniqueFD descriptor_;
bool is_valid_ = false;

std::string GetPathForAsset(const std::string& asset_name) const;

// |blink::AssetResolver|
bool IsValid() const override;

Expand Down
14 changes: 11 additions & 3 deletions shell/platform/android/platform_view_android_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <utility>

#include "flutter/assets/directory_asset_bundle.h"
#include "flutter/assets/zip_asset_store.h"
#include "flutter/common/settings.h"
#include "flutter/fml/file.h"
#include "flutter/fml/platform/android/jni_util.h"
Expand Down Expand Up @@ -207,9 +208,16 @@ static void RunBundleAndSnapshot(

if (bundlepath.size() > 0) {
// If we got a bundle path, attempt to use that as a directory asset
// bundle.
asset_manager->PushBack(std::make_unique<blink::DirectoryAssetBundle>(
fml::OpenFile(bundlepath.c_str(), fml::OpenPermission::kRead, true)));
// bundle or a zip asset bundle.
const auto file_ext_index = bundlepath.rfind(".");
if (bundlepath.substr(file_ext_index) == ".zip") {
asset_manager->PushBack(std::make_unique<blink::ZipAssetStore>(
bundlepath));
} else {
asset_manager->PushBack(std::make_unique<blink::DirectoryAssetBundle>(
fml::OpenFile(bundlepath.c_str(), fml::OpenPermission::kRead, true),
bundlepath));
}

// Use the last path component of the bundle path to determine the
// directory in the APK assets.
Expand Down

0 comments on commit f51b6b3

Please sign in to comment.