Skip to content

Commit

Permalink
Simplify loading of app bundles on Android (flutter#9360)
Browse files Browse the repository at this point in the history
* Remove deprecated runBundle APIs
* Remove code related to dynamic patching (including support for multiple
  bundle paths)
* Change FlutterRunArugments.bundlePath to be the Android AssetManager path
  where the app's assets are located
  • Loading branch information
jason-simmons authored Jun 25, 2019
1 parent 107fe82 commit 3f4f606
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 420 deletions.
6 changes: 0 additions & 6 deletions assets/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ source_set("assets") {
"asset_resolver.h",
"directory_asset_bundle.cc",
"directory_asset_bundle.h",
"zip_asset_store.cc",
"zip_asset_store.h",
]

deps = [
"$flutter_root/common",
"$flutter_root/fml",
]

public_deps = [
"//third_party/zlib:minizip",
]

public_configs = [ "$flutter_root:config" ]
}
129 changes: 0 additions & 129 deletions assets/zip_asset_store.cc

This file was deleted.

59 changes: 0 additions & 59 deletions assets/zip_asset_store.h

This file was deleted.

2 changes: 0 additions & 2 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ FILE: ../../../flutter/assets/asset_manager.h
FILE: ../../../flutter/assets/asset_resolver.h
FILE: ../../../flutter/assets/directory_asset_bundle.cc
FILE: ../../../flutter/assets/directory_asset_bundle.h
FILE: ../../../flutter/assets/zip_asset_store.cc
FILE: ../../../flutter/assets/zip_asset_store.h
FILE: ../../../flutter/benchmarking/benchmarking.cc
FILE: ../../../flutter/benchmarking/benchmarking.h
FILE: ../../../flutter/common/exported_symbols.sym
Expand Down
8 changes: 3 additions & 5 deletions shell/platform/android/flutter_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void FlutterMain::Init(JNIEnv* env,
jclass clazz,
jobject context,
jobjectArray jargs,
jstring bundlePath,
jstring kernelPath,
jstring appStoragePath,
jstring engineCachesPath) {
std::vector<std::string> args;
Expand All @@ -72,8 +72,6 @@ void FlutterMain::Init(JNIEnv* env,

auto settings = SettingsFromCommandLine(command_line);

settings.assets_path = fml::jni::JavaStringToString(env, bundlePath);

// Restore the callback cache.
// TODO(chinmaygarde): Route all cache file access through FML and remove this
// setter.
Expand All @@ -85,11 +83,11 @@ void FlutterMain::Init(JNIEnv* env,

flutter::DartCallbackCache::LoadCacheFromDisk();

if (!flutter::DartVM::IsRunningPrecompiledCode()) {
if (!flutter::DartVM::IsRunningPrecompiledCode() && kernelPath) {
// Check to see if the appropriate kernel files are present and configure
// settings accordingly.
auto application_kernel_path =
fml::paths::JoinPaths({settings.assets_path, "kernel_blob.bin"});
fml::jni::JavaStringToString(env, kernelPath);

if (fml::IsFile(application_kernel_path)) {
settings.application_kernel_asset = application_kernel_path;
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/android/flutter_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class FlutterMain {
jclass clazz,
jobject context,
jobjectArray jargs,
jstring bundlePath,
jstring appRootPath,
jstring kernelPath,
jstring appStoragePath,
jstring engineCachesPath);

void SetupObservatoryUriCallback(JNIEnv* env);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,7 @@ private boolean loadIntent(Intent intent) {
private void runBundle(String appBundlePath) {
if (!flutterView.getFlutterNativeView().isApplicationRunning()) {
FlutterRunArguments args = new FlutterRunArguments();
ArrayList<String> bundlePaths = new ArrayList<>();
bundlePaths.add(appBundlePath);
args.bundlePaths = bundlePaths.toArray(new String[0]);
args.bundlePath = appBundlePath;
args.entrypoint = "main";
flutterView.runFromBundle(args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public void unregisterTexture(long textureId) {
*/
@UiThread
public void runBundleAndSnapshotFromLibrary(
@NonNull String[] prioritizedBundlePaths,
@NonNull String bundlePath,
@Nullable String entrypointFunctionName,
@Nullable String pathToEntrypointFunction,
@NonNull AssetManager assetManager
Expand All @@ -589,7 +589,7 @@ public void runBundleAndSnapshotFromLibrary(
ensureAttachedToNative();
nativeRunBundleAndSnapshotFromLibrary(
nativePlatformViewId,
prioritizedBundlePaths,
bundlePath,
entrypointFunctionName,
pathToEntrypointFunction,
assetManager
Expand All @@ -598,7 +598,7 @@ public void runBundleAndSnapshotFromLibrary(

private native void nativeRunBundleAndSnapshotFromLibrary(
long nativePlatformViewId,
@NonNull String[] prioritizedBundlePaths,
@NonNull String bundlePath,
@Nullable String entrypointFunctionName,
@Nullable String pathToEntrypointFunction,
@NonNull AssetManager manager
Expand Down
Loading

0 comments on commit 3f4f606

Please sign in to comment.