Skip to content

Commit baf1d6b

Browse files
LoveSysolohsu
authored andcommitted
Move config path to /data/adb and /data/misc
1 parent 8bde89c commit baf1d6b

File tree

15 files changed

+304
-83
lines changed

15 files changed

+304
-83
lines changed

edxp-common/src/main/java/com/elderdrivers/riru/edxp/config/BaseEdxpConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
public class BaseEdxpConfig implements EdxpConfig {
66

77
@Override
8-
public String getInstallerConfigPath(String suffix) {
9-
return ConfigManager.getInstallerConfigPath(suffix != null ? suffix : "");
8+
public String getConfigPath(String suffix) {
9+
return ConfigManager.getConfigPath(suffix != null ? suffix : "");
1010
}
1111

1212
@Override

edxp-common/src/main/java/com/elderdrivers/riru/edxp/config/ConfigManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static boolean shouldUseCompatMode(String packageName) {
1818
&& (result = compatModeCache.get(packageName)) != null) {
1919
return result;
2020
}
21-
result = isFileExists(getInstallerConfigPath("compatlist/" + packageName));
21+
result = isFileExists(getConfigPath("compatlist/" + packageName));
2222
compatModeCache.put(packageName, result);
2323
return result;
2424
}
@@ -41,7 +41,9 @@ private static boolean isFileExists(String path) {
4141

4242
public static native String getLibSandHookName();
4343

44-
public static native String getInstallerConfigPath(String suffix);
44+
public static native String getConfigPath(String suffix);
45+
46+
public static native String getBaseConfigPath();
4547

4648
public static native String getDataPathPrefix();
4749

edxp-common/src/main/java/com/elderdrivers/riru/edxp/hooker/XposedInstallerHooker.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.elderdrivers.riru.edxp.hooker;
22

3+
import android.app.AndroidAppHelper;
4+
import android.view.View;
5+
36
import com.elderdrivers.riru.edxp.config.ConfigManager;
47
import com.elderdrivers.riru.edxp.util.Utils;
58

@@ -16,7 +19,7 @@ public class XposedInstallerHooker {
1619

1720
private static final String LEGACY_INSTALLER_PACKAGE_NAME = "de.robv.android.xposed.installer";
1821

19-
public static void hookXposedInstaller(ClassLoader classLoader) {
22+
public static void hookXposedInstaller(final ClassLoader classLoader) {
2023
try {
2124
final String xposedAppClass = LEGACY_INSTALLER_PACKAGE_NAME + ".XposedApp";
2225
final Class InstallZipUtil = XposedHelpers.findClass(LEGACY_INSTALLER_PACKAGE_NAME
@@ -66,6 +69,31 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
6669
}
6770
}
6871
});
72+
XposedHelpers.findAndHookMethod("org.meowcat.edxposed.manager.XposedApp", classLoader, "onCreate", new XC_MethodHook() {
73+
@Override
74+
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
75+
XposedHelpers.setStaticObjectField(param.thisObject.getClass(), "BASE_DIR", ConfigManager.getBaseConfigPath() + "/");
76+
XposedHelpers.setStaticObjectField(param.thisObject.getClass(), "ENABLED_MODULES_LIST_FILE", ConfigManager.getConfigPath("enabled_modules.list"));
77+
}
78+
});
79+
XposedHelpers.findAndHookMethod("org.meowcat.edxposed.manager.util.ModuleUtil", classLoader, "updateModulesList", boolean.class, View.class, new XC_MethodHook() {
80+
@Override
81+
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
82+
final Object thisObject = param.thisObject;
83+
synchronized (thisObject) {
84+
XposedHelpers.setStaticObjectField(param.thisObject.getClass(), "MODULES_LIST_FILE", ConfigManager.getConfigPath("modules.list"));
85+
}
86+
}
87+
});
88+
XposedHelpers.findAndHookMethod("org.meowcat.edxposed.manager.StatusInstallerFragment", classLoader, "getCanonicalFile", File.class, new XC_MethodHook() {
89+
@Override
90+
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
91+
File arg = (File)param.args[0];
92+
if(arg.equals(new File(AndroidAppHelper.currentApplicationInfo().deviceProtectedDataDir))) {
93+
param.args[0] = new File(ConfigManager.getBaseConfigPath());
94+
}
95+
}
96+
});
6997
} catch (Throwable t) {
7098
Utils.logE("Could not hook Xposed Installer", t);
7199
}

edxp-core/src/main/cpp/main/include/utils.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#include <string>
77
#include <filesystem>
88
#include <sys/system_properties.h>
9+
#include <unistd.h>
10+
#include <sys/stat.h>
911
#include "logging.h"
10-
#include <sys/system_properties.h>
1112

1213
namespace edxp {
1314

@@ -31,9 +32,24 @@ namespace edxp {
3132
}
3233
}
3334

34-
static inline int32_t GetAndroidApiLevel() {
35-
char prop_value[PROP_VALUE_MAX];
36-
__system_property_get("ro.build.version.sdk", prop_value);
37-
return std::atoi(prop_value);
35+
inline void path_chown(const std::filesystem::path &path, uid_t uid, gid_t gid, bool recursively=false) {
36+
if (chown(path.c_str(), uid, gid) != 0) {
37+
throw std::filesystem::filesystem_error(strerror(errno), path,
38+
{errno, std::system_category()});
39+
}
40+
if(recursively) {
41+
for(const auto &item : std::filesystem::recursive_directory_iterator(path)) {
42+
if (chown(item.path().c_str(), uid, gid) != 0) {
43+
throw std::filesystem::filesystem_error(strerror(errno), item.path(),
44+
{errno, std::system_category()});
45+
}
46+
}
47+
}
48+
}
49+
50+
inline std::tuple<uid_t, gid_t> path_own(const std::filesystem::path& path) {
51+
struct stat sb;
52+
stat(path.c_str(), &sb);
53+
return {sb.st_uid, sb.st_gid};
3854
}
3955
}

0 commit comments

Comments
 (0)