Skip to content

Commit

Permalink
Make the layout of dynamic patch bundle similar to APK. (flutter#7925)
Browse files Browse the repository at this point in the history
This will help further changes when we pull other artifacts into the bundle.
  • Loading branch information
sbaranov authored Feb 22, 2019
1 parent e2a449a commit 5809ade
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
16 changes: 9 additions & 7 deletions shell/platform/android/io/flutter/view/ResourceExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ private boolean extractAPK(File dataDir) {

for (String asset : mResources) {
try {
final String resource = "assets/" + asset;
final File output = new File(dataDir, asset);
if (output.exists()) {
continue;
Expand All @@ -192,7 +193,7 @@ private boolean extractAPK(File dataDir) {
copy(is, os);
}

Log.i(TAG, "Extracted baseline resource " + asset);
Log.i(TAG, "Extracted baseline resource " + resource);

} catch (FileNotFoundException fnfe) {
continue;
Expand Down Expand Up @@ -239,11 +240,10 @@ private boolean extractUpdate(File dataDir) {
}

for (String asset : mResources) {
boolean useDiff = false;
ZipEntry entry = zipFile.getEntry(asset);
final String resource = "assets/" + asset;
ZipEntry entry = zipFile.getEntry(resource);
if (entry == null) {
useDiff = true;
entry = zipFile.getEntry(asset + ".bzdiff40");
entry = zipFile.getEntry(resource + ".bzdiff40");
if (entry == null) {
continue;
}
Expand All @@ -258,7 +258,7 @@ private boolean extractUpdate(File dataDir) {
}

try {
if (useDiff) {
if (entry.getName().endsWith(".bzdiff40")) {
ByteArrayOutputStream diff = new ByteArrayOutputStream();
try (InputStream is = zipFile.getInputStream(entry)) {
copy(is, diff);
Expand All @@ -267,6 +267,8 @@ private boolean extractUpdate(File dataDir) {
ByteArrayOutputStream orig = new ByteArrayOutputStream();
try (InputStream is = manager.open(asset)) {
copy(is, orig);
} catch (FileNotFoundException e) {
throw new IOException("Could not find APK resource " + resource);
}

try (OutputStream os = new FileOutputStream(output)) {
Expand All @@ -280,7 +282,7 @@ private boolean extractUpdate(File dataDir) {
}
}

Log.i(TAG, "Extracted override resource " + asset);
Log.i(TAG, "Extracted override resource " + entry.getName());

} catch (FileNotFoundException fnfe) {
continue;
Expand Down
5 changes: 3 additions & 2 deletions shell/platform/android/platform_view_android_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,9 @@ static void RunBundleAndSnapshotFromLibrary(JNIEnv* env,
// 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, "flutter_assets"));
asset_manager->PushBack(std::make_unique<blink::ZipAssetStore>(
bundlepath, "assets/flutter_assets"));

} else {
asset_manager->PushBack(
std::make_unique<blink::DirectoryAssetBundle>(fml::OpenDirectory(
Expand Down

0 comments on commit 5809ade

Please sign in to comment.