Minor changes

This commit is contained in:
topjohnwu
2019-10-30 04:15:53 -04:00
parent fdf04f77f2
commit dc9f69bab0
9 changed files with 30 additions and 34 deletions

View File

@@ -55,11 +55,11 @@ public class DelegateApplication extends Application {
ClassLoader cl = new DynamicClassLoader(MANAGER_APK, factory.loader);
try {
// Create the delegate AppComponentFactory
Object df = cl.loadClass("a.a").newInstance();
AppComponentFactory df = (AppComponentFactory) cl.loadClass("a.a").newInstance();
// Create the delegate Application
delegate = (Application) cl.loadClass("a.e").getConstructor(Object.class)
.newInstance(DynAPK.pack(Mapping.data));
.newInstance(DynAPK.pack(Mapping.data()));
// Call attachBaseContext without ContextImpl to show it is being wrapped
Method m = ContextWrapper.class.getDeclaredMethod("attachBaseContext", Context.class);
@@ -67,7 +67,7 @@ public class DelegateApplication extends Application {
m.invoke(delegate, this);
// If everything went well, set our loader and delegate
factory.delegate = (AppComponentFactory) df;
factory.delegate = df;
factory.loader = cl;
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "", e);

View File

@@ -8,22 +8,8 @@ import static com.topjohnwu.magisk.DynAPK.Data;
public class Mapping {
private static Map<String, String> map = new HashMap<>();
// This mapping will be sent into the guest app
public static Data data = new Data();
static {
map.put(a.z.class.getName(), "a.c");
map.put("a.x", "a.f");
map.put("a.o", "a.b");
map.put("a.g", "a.m");
map.put(a.w.class.getName(), "a.h");
map.put("a.v", "a.j");
map.put("a.j", "androidx.work.impl.background.systemjob.SystemJobService");
data.componentMap = new HashMap<>(map.size());
for (Map.Entry<String, String> e : map.entrySet()) {
data.componentMap.put(e.getValue(), e.getKey());
}
map.put("a.x", "androidx.work.impl.background.systemjob.SystemJobService");
}
public static String get(String name) {
@@ -31,4 +17,14 @@ public class Mapping {
return n != null ? n : name;
}
public static Data data() {
Map<String, String> componentMap = new HashMap<>(map.size());
for (Map.Entry<String, String> e : map.entrySet()) {
componentMap.put(e.getValue(), e.getKey());
}
Data data = new Data();
data.componentMap = componentMap;
return data;
}
}