Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add order field to bundle.json to set 'so' load sequence #536

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -91,15 +92,24 @@ public class ApkBundleLauncher extends SoBundleLauncher {
private static final String FILE_DEX = "bundle.dex";
private static final String STUB_QUEUE_RESTORE_KEY = "small.stubQueue";

private static class LoadedApk {
private static class LoadedApk implements Comparable {
public String packageName;
public File packagePath;
public String applicationName;
public int order;
public String path;
public DexFile dexFile;
public File optDexFile;
public File libraryPath;
public boolean nonResources; /** no resources.arsc */

@Override
public int compareTo(Object o) {
if (o instanceof LoadedApk) {
return order - ((LoadedApk) o).order;
}
return order;
}
}

private static ConcurrentHashMap<String, LoadedApk> sLoadedApks;
Expand Down Expand Up @@ -800,7 +810,10 @@ public void postSetUp() {
}

// Trigger all the bundle application `onCreate' event
for (final LoadedApk apk : apks) {
List<LoadedApk> apkList = new ArrayList<>(apks);
//noinspection unchecked
Collections.sort(apkList);
for (final LoadedApk apk : apkList) {
String bundleApplicationName = apk.applicationName;
if (bundleApplicationName == null) continue;

Expand Down Expand Up @@ -880,6 +893,7 @@ public void loadBundle(Bundle bundle) {
if (pluginInfo.applicationInfo != null) {
apk.applicationName = pluginInfo.applicationInfo.className;
}
apk.order = bundle.getOrder();
apk.packagePath = bundle.getExtractPath();
apk.optDexFile = new File(apk.packagePath, FILE_DEX);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ private static final class Manifest {
private Intent mIntent;
private String type;
private String path;
//Launch application order.
private int order;
private String query;
private HashMap<String, String> rules;
private int versionCode;
Expand Down Expand Up @@ -527,6 +529,12 @@ private void initWithMap(JSONObject map) throws JSONException {
this.type = map.getString("type");
}

if (map.has("order")) {
this.order = Integer.parseInt(map.getString("order"));
} else {
//Default means don't care the order, so put it at last.
this.order = Integer.MAX_VALUE;
}
this.rules = new HashMap<String, String>();
String entrancePath = DEFAULT_ENTRANCE_PATH;
if (map.has("rules")) {
Expand Down Expand Up @@ -591,6 +599,10 @@ protected Uri getUri() {
return uri;
}

protected int getOrder() {
return order;
}

protected void setURL(URL url) {
this.url = url;
}
Expand Down