Make main app fully independent from the stub

- Skip 0x7f01XXXX - 0x7f05XXXX resource IDs in the main app; they are
reserved for stub resources
- Support sending additional data from host to guest
- Use resource mapping passed from host when they are being sent
to the system framework (notifications and shortcuts)
This commit is contained in:
topjohnwu
2019-10-17 02:04:22 -04:00
parent 9f9de8c43b
commit 40eda05a30
16 changed files with 161 additions and 133 deletions

View File

@@ -3,9 +3,21 @@ package com.topjohnwu.magisk.utils;
import android.content.Context;
import java.io.File;
import java.util.Map;
public class DynAPK {
// Indices of the object array
private static final int COMPONENT_MAP = 0;
private static final int RESOURCE_MAP = 1;
// Indices of the resource map
public static final int NOTIFICATION = 0;
public static final int DOWNLOAD = 1;
public static final int SUPERUSER = 2;
public static final int MODULES = 3;
public static final int MAGISKHIDE = 4;
private static File dynDir;
private static File getDynDir(Context c) {
@@ -23,4 +35,24 @@ public class DynAPK {
public static File update(Context c) {
return new File(getDynDir(c), "update.apk");
}
public static Data load(Object o) {
Object[] arr = (Object[]) o;
Data data = new Data();
data.componentMap = (Map<String, String>) arr[COMPONENT_MAP];
data.resourceMap = (int[]) arr[RESOURCE_MAP];
return data;
}
public static Object pack(Data data) {
Object[] arr = new Object[2];
arr[COMPONENT_MAP] = data.componentMap;
arr[RESOURCE_MAP] = data.resourceMap;
return arr;
}
public static class Data {
public Map<String, String> componentMap;
public int[] resourceMap;
}
}