Magisk/stub/src/main/java/com/topjohnwu/magisk/DelegateRootService.java

34 lines
920 B
Java
Raw Normal View History

2021-12-13 03:57:27 -08:00
package com.topjohnwu.magisk;
import android.content.Context;
import android.content.ContextWrapper;
import android.util.Log;
import java.lang.reflect.Constructor;
import io.michaelrocks.paranoid.Obfuscate;
@Obfuscate
public class DelegateRootService extends ContextWrapper {
public DelegateRootService() {
super(null);
}
@Override
protected void attachBaseContext(Context base) {
if (DynLoad.createApp(base) == null)
2021-12-13 03:57:27 -08:00
return;
// Create the actual RootService and call its attachBaseContext
try {
Constructor<?> ctor = DynLoad.apkData.getRootService().getConstructor(Object.class);
ctor.setAccessible(true);
Object service = ctor.newInstance(this);
DynLoad.attachContext(service, base);
2021-12-13 03:57:27 -08:00
} catch (Exception e) {
Log.e(DelegateRootService.class.getSimpleName(), "", e);
}
}
}