Only clear modules' LoadedApks rather than all (#2647)

This commit is contained in:
LoveSy 2023-07-27 01:37:54 +08:00 committed by GitHub
parent e83ef1841b
commit afe74b536b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -237,12 +237,14 @@ public final class XposedInit {
}
public static void loadModules(ActivityThread at) {
var packages = (ArrayMap<?, ?>) XposedHelpers.getObjectField(at, "mPackages");
serviceClient.getModulesList().forEach(module -> {
loadedModules.put(module.packageName, Optional.empty());
if (!LSPosedContext.loadModule(at, module)) {
loadedModules.remove(module.packageName);
} else {
packages.remove(module.packageName);
}
((ArrayMap<?, ?>) XposedHelpers.getObjectField(ActivityThread.currentActivityThread(), "mPackages")).clear();
});
}

View File

@ -143,6 +143,7 @@ public class LSPosedContext extends XposedContext {
Log.e(TAG, " This may cause strange issues and must be fixed by the module developer.");
return false;
}
module.applicationInfo.packageName = module.packageName; // Just in case
var loadedApk = at.getPackageInfoNoCheck(module.applicationInfo, null);
XposedHelpers.setObjectField(loadedApk, "mClassLoader", mcl);
XposedHelpers.setObjectField(loadedApk, "mDataDir", appDir);
@ -217,13 +218,13 @@ public class LSPosedContext extends XposedContext {
Log.e(TAG, " Failed to load class " + moduleClass, e);
}
}
Log.d(TAG, "Loaded module " + module.packageName + ": " + ctx);
module.file.moduleLibraryNames.forEach(NativeAPI::recordNativeEntrypoint);
return true;
Log.d(TAG, "Loaded module " + module.packageName + ": " + ctx);
} catch (Throwable e) {
Log.d(TAG, "Loading module " + module.packageName, e);
return false;
}
return false;
return true;
}
@Override