Implement onSystemServerLoaded

This commit is contained in:
LoveSy 2023-01-11 09:40:36 +08:00 committed by LoveSy
parent 2d0797973e
commit 1ef284f287
2 changed files with 31 additions and 0 deletions

View File

@ -22,12 +22,19 @@ package org.lsposed.lspd.hooker;
import static org.lsposed.lspd.util.Utils.logD; import static org.lsposed.lspd.util.Utils.logD;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.lsposed.lspd.impl.LSPosedContext;
import org.lsposed.lspd.util.Hookers; import org.lsposed.lspd.util.Hookers;
import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedInit; import de.robv.android.xposed.XposedInit;
import de.robv.android.xposed.callbacks.XC_LoadPackage; import de.robv.android.xposed.callbacks.XC_LoadPackage;
import io.github.libxposed.XposedModuleInterface;
public class StartBootstrapServicesHooker extends XC_MethodHook { public class StartBootstrapServicesHooker extends XC_MethodHook {
@ -45,6 +52,20 @@ public class StartBootstrapServicesHooker extends XC_MethodHook {
lpparam.appInfo = null; lpparam.appInfo = null;
lpparam.isFirstApplication = true; lpparam.isFirstApplication = true;
XC_LoadPackage.callAll(lpparam); XC_LoadPackage.callAll(lpparam);
LSPosedContext.callOnSystemServerLoaded(new XposedModuleInterface.SystemServerLoadedParam() {
@Override
@NonNull
public ClassLoader getClassLoader() {
return HandleSystemServerProcessHooker.systemServerCL;
}
@Override
@Nullable
public Bundle getExtras() {
return null;
}
});
} catch (Throwable t) { } catch (Throwable t) {
Hookers.logE("error when hooking startBootstrapServices", t); Hookers.logE("error when hooking startBootstrapServices", t);
} }

View File

@ -104,6 +104,16 @@ public class LSPosedContext extends XposedContext {
} }
} }
public static void callOnSystemServerLoaded(XposedModuleInterface.SystemServerLoadedParam param) {
for (XposedModule module : modules) {
try {
module.onSystemServerLoaded(param);
} catch (Throwable t) {
Log.e(TAG, "Error when calling onSystemServerLoaded of " + ((LSPosedContext) module.getBaseContext()).mPackageName, t);
}
}
}
public static boolean loadModule(ActivityThread at, Module module) { public static boolean loadModule(ActivityThread at, Module module) {
try { try {
Log.d(TAG, "Loading module " + module.packageName); Log.d(TAG, "Loading module " + module.packageName);