mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 12:17:38 +00:00
Move things around
This commit is contained in:
parent
c8492b0c58
commit
dfa36fb25d
@ -130,15 +130,12 @@ class StubClassLoader extends ClassLoader {
|
||||
|
||||
class DelegateClassLoader extends ClassLoader {
|
||||
|
||||
// The active classloader
|
||||
static ClassLoader cl = DelegateClassLoader.class.getClassLoader();
|
||||
|
||||
DelegateClassLoader() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
return cl.loadClass(name);
|
||||
return DynLoad.activeClassLoader.loadClass(name);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class DelegateComponentFactory extends AppComponentFactory {
|
||||
public Activity instantiateActivity(ClassLoader cl, String className, Intent intent)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
if (receiver != null)
|
||||
return receiver.instantiateActivity(DelegateClassLoader.cl, className, intent);
|
||||
return receiver.instantiateActivity(DynLoad.activeClassLoader, className, intent);
|
||||
return create(className, DownloadActivity.class);
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class DelegateComponentFactory extends AppComponentFactory {
|
||||
public BroadcastReceiver instantiateReceiver(ClassLoader cl, String className, Intent intent)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
if (receiver != null)
|
||||
return receiver.instantiateReceiver(DelegateClassLoader.cl, className, intent);
|
||||
return receiver.instantiateReceiver(DynLoad.activeClassLoader, className, intent);
|
||||
return create(className, DummyReceiver.class);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public class DelegateComponentFactory extends AppComponentFactory {
|
||||
public Service instantiateService(ClassLoader cl, String className, Intent intent)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
if (receiver != null)
|
||||
return receiver.instantiateService(DelegateClassLoader.cl, className, intent);
|
||||
return receiver.instantiateService(DynLoad.activeClassLoader, className, intent);
|
||||
return create(className, DummyService.class);
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class DelegateComponentFactory extends AppComponentFactory {
|
||||
public ContentProvider instantiateProvider(ClassLoader cl, String className)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
if (receiver != null)
|
||||
return receiver.instantiateProvider(DelegateClassLoader.cl, className);
|
||||
return receiver.instantiateProvider(DynLoad.activeClassLoader, className);
|
||||
return create(className, DummyProvider.class);
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ public class DelegateComponentFactory extends AppComponentFactory {
|
||||
throws IllegalAccessException, InstantiationException {
|
||||
try {
|
||||
// noinspection unchecked
|
||||
return (T) DelegateClassLoader.cl.loadClass(name).newInstance();
|
||||
return (T) DynLoad.activeClassLoader.loadClass(name).newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
return fallback.newInstance();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class DownloadActivity extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (DelegateClassLoader.cl instanceof AppClassLoader) {
|
||||
if (DynLoad.activeClassLoader instanceof AppClassLoader) {
|
||||
// For some reason activity is created before Application.attach(),
|
||||
// relaunch the activity using the same intent
|
||||
finishAffinity();
|
||||
|
@ -28,6 +28,7 @@ import io.michaelrocks.paranoid.Obfuscate;
|
||||
public class DynLoad {
|
||||
|
||||
static Object componentFactory;
|
||||
static ClassLoader activeClassLoader = DynLoad.class.getClassLoader();
|
||||
|
||||
static StubApk.Data createApkData() {
|
||||
var data = new StubApk.Data();
|
||||
@ -150,7 +151,7 @@ public class DynLoad {
|
||||
delegate.receiver = (AppComponentFactory) factory;
|
||||
}
|
||||
|
||||
DelegateClassLoader.cl = cl;
|
||||
activeClassLoader = cl;
|
||||
|
||||
// Send real application to attachBaseContext
|
||||
attachContext(app, context);
|
||||
@ -161,7 +162,7 @@ public class DynLoad {
|
||||
apk.delete();
|
||||
}
|
||||
|
||||
DelegateClassLoader.cl = new StubClassLoader(info);
|
||||
activeClassLoader = new StubClassLoader(info);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user