parent
57f15c1fc1
commit
f51e71d858
|
|
@ -2,6 +2,7 @@ package com.elderdrivers.riru.edxp.proxy;
|
|||
|
||||
import com.elderdrivers.riru.edxp.config.ConfigManager;
|
||||
import com.elderdrivers.riru.edxp.deopt.PrebuiltMethodsDeopter;
|
||||
import com.elderdrivers.riru.edxp.util.Utils;
|
||||
|
||||
import de.robv.android.xposed.SELinuxHelper;
|
||||
import de.robv.android.xposed.XposedInit;
|
||||
|
|
@ -22,14 +23,6 @@ public class NormalProxy extends BaseProxy {
|
|||
}
|
||||
|
||||
public void forkAndSpecializePost(int pid, String appDataDir, String niceName) {
|
||||
SELinuxHelper.initOnce();
|
||||
mRouter.initResourcesHook();
|
||||
// call this to ensure the flag is set to false ASAP
|
||||
mRouter.prepare(false);
|
||||
PrebuiltMethodsDeopter.deoptBootMethods(); // do it once for secondary zygote
|
||||
// install bootstrap hooks for secondary zygote
|
||||
mRouter.installBootstrapHooks(false);
|
||||
// TODO consider processes without forkAndSpecializePost being called
|
||||
forkPostCommon(pid, false, appDataDir, niceName);
|
||||
}
|
||||
|
||||
|
|
@ -38,27 +31,22 @@ public class NormalProxy extends BaseProxy {
|
|||
}
|
||||
|
||||
public void forkSystemServerPost(int pid) {
|
||||
SELinuxHelper.initOnce();
|
||||
mRouter.initResourcesHook();
|
||||
// set startsSystemServer flag used when loadModules
|
||||
mRouter.prepare(true);
|
||||
PrebuiltMethodsDeopter.deoptBootMethods(); // do it once for main zygote
|
||||
// install bootstrap hooks for main zygote as early as possible
|
||||
// in case we miss some processes not forked via forkAndSpecialize
|
||||
// for instance com.android.phone
|
||||
mRouter.installBootstrapHooks(true);
|
||||
// in system_server process
|
||||
forkPostCommon(pid, true,
|
||||
getDataPathPrefix() + "android", "system_server");
|
||||
}
|
||||
|
||||
|
||||
private void forkPostCommon(int pid, boolean isSystem, String appDataDir, String niceName) {
|
||||
SELinuxHelper.initOnce();
|
||||
mRouter.initResourcesHook();
|
||||
mRouter.prepare(isSystem);
|
||||
PrebuiltMethodsDeopter.deoptBootMethods(); // do it once for secondary zygote
|
||||
mRouter.installBootstrapHooks(isSystem);
|
||||
ConfigManager.appDataDir = appDataDir;
|
||||
ConfigManager.niceName = niceName;
|
||||
XposedInit.prefsBasePath = ConfigManager.getPrefsPath("");
|
||||
mRouter.prepare(isSystem);
|
||||
mRouter.onEnterChildProcess();
|
||||
Utils.logI("Loading modules for " + niceName);
|
||||
mRouter.loadModulesSafely(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -312,14 +312,8 @@ namespace edxp {
|
|||
fs::permissions(conf_path, fs::perms::owner_all | fs::perms::group_all);
|
||||
fs::permissions(log_path, fs::perms::owner_all | fs::perms::group_all);
|
||||
if (pkg_name == "android") uid = -1;
|
||||
if (const auto &[r_uid, r_gid] = path_own(conf_path);
|
||||
(uid != -1 && r_uid != uid) || r_gid != 1000u) {
|
||||
path_chown(conf_path, uid, 1000u, true);
|
||||
}
|
||||
if (const auto &[r_uid, r_gid] = path_own(log_path);
|
||||
(uid != -1 && r_uid != uid) || r_gid != 1000u) {
|
||||
path_chown(log_path, uid, 1000u, true);
|
||||
}
|
||||
path_chown(conf_path, uid, 1000u, true);
|
||||
path_chown(log_path, uid, 1000u, true);
|
||||
|
||||
if (pkg_name == kPrimaryInstallerPkgName) {
|
||||
auto installer_pkg_name_path = GetConfigPath("installer");
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ grep_prop() {
|
|||
MODDIR=${0%/*}
|
||||
|
||||
RIRU_PATH="/data/adb/riru"
|
||||
RIRU_PROP="/data/adb/modules/riru-core/module.prop"
|
||||
RIRU_PROP="$(magisk --path)/.magisk/modules/riru-core/module.prop"
|
||||
TARGET="${RIRU_PATH}/modules"
|
||||
[[ "$(getenforce)" == "Enforcing" ]] && ENFORCE=true || ENFORCE=false
|
||||
|
||||
|
|
|
|||
|
|
@ -81,14 +81,13 @@ public class PackageReceiver {
|
|||
File enabledModules = new File(CONFIG_PATH, uid + "/" + ENABLED_MODULES_LIST_FILENAME);
|
||||
if (!enabledModules.exists()) return result;
|
||||
Scanner scanner = new Scanner(enabledModules);
|
||||
if (scanner.hasNextLine()) {
|
||||
while (scanner.hasNextLine()) {
|
||||
String packageName = scanner.nextLine();
|
||||
PackageInfo info = getPackageInfo(packageName);
|
||||
if (info != null && isXposedModule(info.applicationInfo)) {
|
||||
if (info != null && isXposedModule(info.applicationInfo))
|
||||
result.put(packageName, info.applicationInfo.sourceDir);
|
||||
} else {
|
||||
Utils.logW(String.format("remove obsolete package %s", packageName));
|
||||
}
|
||||
else if (info == null)
|
||||
result.put(packageName, null);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Utils.logE("Unable to read enabled modules", e);
|
||||
|
|
@ -96,25 +95,43 @@ public class PackageReceiver {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void updateModuleList(int uid, String packageName) {
|
||||
private boolean updateModuleList(int uid, String packageName) {
|
||||
Map<String, String> enabledModules = loadEnabledModules(uid);
|
||||
|
||||
if(packageName != null && !enabledModules.containsKey(packageName)) return;
|
||||
if (!enabledModules.containsKey(packageName)) return false;
|
||||
|
||||
try {
|
||||
File moduleListFile = new File(CONFIG_PATH, uid + "/" + MODULES_LIST_FILENAME);
|
||||
moduleListFile.createNewFile();
|
||||
File enabledModuleListFile = new File(CONFIG_PATH, uid + "/" + ENABLED_MODULES_LIST_FILENAME);
|
||||
if (moduleListFile.exists() && !moduleListFile.canWrite()) {
|
||||
moduleListFile.delete();
|
||||
moduleListFile.createNewFile();
|
||||
}
|
||||
if (enabledModuleListFile.exists() && !enabledModuleListFile.canWrite()) {
|
||||
enabledModuleListFile.delete();
|
||||
enabledModuleListFile.createNewFile();
|
||||
}
|
||||
PrintWriter modulesList = new PrintWriter(moduleListFile);
|
||||
PrintWriter enabledModulesList = new PrintWriter(new File(CONFIG_PATH, uid + "/" + ENABLED_MODULES_LIST_FILENAME));
|
||||
PrintWriter enabledModulesList = new PrintWriter(enabledModuleListFile);
|
||||
for (Map.Entry<String, String> module : enabledModules.entrySet()) {
|
||||
modulesList.println(module.getValue());
|
||||
enabledModulesList.println(module.getKey());
|
||||
String apkPath = module.getValue();
|
||||
if (apkPath != null) {
|
||||
modulesList.println(module.getValue());
|
||||
enabledModulesList.println(module.getKey());
|
||||
} else {
|
||||
Utils.logI(String.format("remove obsolete package %s", packageName));
|
||||
File prefsDir = new File(CONFIG_PATH, uid + "/prefs/" + packageName);
|
||||
for (File childFile : prefsDir.listFiles()) {
|
||||
childFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
modulesList.close();
|
||||
enabledModulesList.close();
|
||||
} catch (Throwable e) {
|
||||
Utils.logE("Fail to update module list", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -152,12 +169,14 @@ public class PackageReceiver {
|
|||
@SuppressLint("DiscouragedPrivateApi")
|
||||
Method m = UserManager.class.getDeclaredMethod("getUsers");
|
||||
m.setAccessible(true);
|
||||
boolean res = false;
|
||||
for (Object uh : (List<Object>) m.invoke(um)) {
|
||||
int uid = (int) uh.getClass().getDeclaredField("id").get(uh);
|
||||
Utils.logI("updating uid: " + uid);
|
||||
updateModuleList(uid, pkgInfo == null ? null : packageName);
|
||||
res = res || updateModuleList(uid, packageName);
|
||||
}
|
||||
Toast.makeText(context, "EdXposed: Updated " + packageName, Toast.LENGTH_SHORT).show();
|
||||
if (res)
|
||||
Toast.makeText(context, "EdXposed: Updated " + packageName, Toast.LENGTH_SHORT).show();
|
||||
} catch (Throwable e) {
|
||||
Utils.logW("update failed", e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue