提交 5ccb7f9a 编写于 作者: J Jason Simmons 提交者: GitHub

Allow multiple Android resource names for the app bundle (#2790)

Also provide an API for obtaining the path where the app bundle was extracted
上级 a2186883
......@@ -61,7 +61,10 @@ import org.domokit.vsync.VSyncProviderImpl;
public class FlutterMain {
private static final String TAG = "FlutterMain";
public static final String APP_BUNDLE = "app.flx";
// Resource names that can be used for the the FLX application bundle.
public static final String[] APP_BUNDLE_RESOURCES = {
"app.flx", "app_release.flx"
};
// Resource names used for components of the precompiled snapshot.
private static final String AOT_INSTR = "snapshot_aot_instr";
......@@ -78,7 +81,8 @@ public class FlutterMain {
private static final List<String> SKY_RESOURCES = new ArrayList<String>();
static {
Collections.addAll(SKY_RESOURCES, "icudtl.dat", APP_BUNDLE, MANIFEST);
Collections.addAll(SKY_RESOURCES, "icudtl.dat", MANIFEST);
Collections.addAll(SKY_RESOURCES, APP_BUNDLE_RESOURCES);
Collections.addAll(SKY_RESOURCES, AOT_RESOURCES);
}
......@@ -308,4 +312,14 @@ public class FlutterMain {
public static boolean isRunningPrecompiledCode() {
return sIsPrecompiled;
}
public static String findAppBundlePath(Context applicationContext) {
String dataDirectory = PathUtils.getDataDirectory(applicationContext);
for (String appBundleResource : APP_BUNDLE_RESOURCES) {
File appBundle = new File(dataDirectory, appBundleResource);
if (appBundle.exists())
return appBundle.getPath();
}
return null;
}
}
......@@ -122,10 +122,9 @@ public class SkyActivity extends Activity {
if (loadIntent(getIntent())) {
return;
}
File dataDir = new File(PathUtils.getDataDirectory(this));
File appBundle = new File(dataDir, FlutterMain.APP_BUNDLE);
if (appBundle.exists()) {
mView.runFromBundle(appBundle.getPath(), null);
String appBundlePath = FlutterMain.findAppBundlePath(getApplicationContext());
if (appBundlePath != null) {
mView.runFromBundle(appBundlePath, null);
return;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册