Skip to content

Commit

Permalink
Update LSPApplication.java (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
HSSkyBoy authored Mar 17, 2024
1 parent 2fca350 commit 0932a05
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public static void onLoad() throws RemoteException, IOException {
// WARN: Since it uses `XResource`, the following class should not be initialized
// before forkPostCommon is invoke. Otherwise, you will get failure of XResources
Log.i(TAG, "Load modules");
LSPLoader.initModules(appLoadedApk);
LSPLoader.initLegacyModules(appLoadedApk);
// LSPLoader.initModules(appLoadedApk);
Log.i(TAG, "Modules initialized");

switchAllClassLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

import android.app.ActivityThread;
import android.app.LoadedApk;
import android.content.pm.ApplicationInfo;
import android.content.res.XResources;

import org.lsposed.lspd.impl.LSPosedContext;

import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedInit;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import io.github.libxposed.api.XposedModuleInterface;

public class LSPLoader {
public static void initModules(LoadedApk loadedApk) {
public static void initLegacyModules(LoadedApk loadedApk) {
XposedInit.loadedPackagesInProcess.add(loadedApk.getPackageName());
XResources.setPackageNameForResDir(loadedApk.getPackageName(), loadedApk.getResDir());
XC_LoadPackage.LoadPackageParam lpparam = new XC_LoadPackage.LoadPackageParam(
Expand All @@ -21,4 +25,34 @@ public static void initModules(LoadedApk loadedApk) {
lpparam.isFirstApplication = true;
XC_LoadPackage.callAll(lpparam);
}
}

public static void initModules(LoadedApk loadedApk) {
XposedModuleInterface.PackageLoadedParam param = new XposedModuleInterface.PackageLoadedParam() {
@Override
public String getPackageName() {
return loadedApk.getPackageName();
}

@Override
public ApplicationInfo getApplicationInfo() {
return loadedApk.getApplicationInfo();
}

@Override
public ClassLoader getDefaultClassLoader() {
return loadedApk.getClassLoader();
}

@Override
public ClassLoader getClassLoader() {
return loadedApk.getClassLoader();
}

@Override
public boolean isFirstPackage() {
return true;
}
};
LSPosedContext.callOnPackageLoaded(param);
}
}

0 comments on commit 0932a05

Please sign in to comment.