Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LSPApplication.java #21

Merged
merged 2 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading