11
11
#include < vector>
12
12
#include < string>
13
13
#include < include/logging.h>
14
+ #include < sys/system_properties.h>
14
15
#include " config_manager.h"
15
16
16
- #define BLACK_LIST_PATH " /data/misc/riru/modules/edxposed/blacklist/"
17
- #define WHITE_LIST_PATH " /data/misc/riru/modules/edxposed/whitelist/"
18
- #define USE_WHITE_LIST " /data/misc/riru/modules/edxposed/usewhitelist"
19
- #define GLOBAL_MODE " /data/misc/riru/modules/edxposed/forceglobal"
20
- #define DYNAMIC_MODULES " /data/misc/riru/modules/edxposed/dynamicmodules"
17
+ #define INSTALLER_PACKAGE_NAME " org.meowcat.edxposed.manager"
21
18
22
19
static char package_name[256 ];
23
20
static bool global_mode = false ;
24
21
static bool dynamic_modules = false ;
25
22
static bool inited = false ;
23
+ static char sdk[PROP_VALUE_MAX + 1 ];
24
+ static bool use_protected_storage =
25
+ __system_property_get (" ro.build.version.sdk" , sdk) > 0 && atoi(sdk) >= 24;
26
+ static const char *data_dir = use_protected_storage ?
27
+ " /data/user_de/0/" INSTALLER_PACKAGE_NAME " /" :
28
+ " /data/user/0/" INSTALLER_PACKAGE_NAME " /" ;
26
29
27
- void initOnce () {
30
+ const char *get_black_list_path () {
31
+ char *result = new char [256 ];
32
+ return strcat (strcpy (result, data_dir), " conf/blacklist/" );
33
+ }
34
+
35
+ const char *get_white_list_path () {
36
+ char *result = new char [256 ];
37
+ return strcat (strcpy (result, data_dir), " conf/whitelist/" );
38
+ }
39
+
40
+ const char *get_use_white_list_file () {
41
+ char *result = new char [256 ];
42
+ return strcat (strcpy (result, data_dir), " conf/usewhitelist" );
43
+ }
44
+
45
+ const char *get_force_global_file () {
46
+ char *result = new char [256 ];
47
+ return strcat (strcpy (result, data_dir), " conf/forceglobal" );
48
+ }
49
+
50
+ const char *get_dynamic_modules_file () {
51
+ char *result = new char [256 ];
52
+ return strcat (strcpy (result, data_dir), " conf/dynamicmodules" );
53
+ }
54
+
55
+ void init_once () {
28
56
if (!inited) {
29
- global_mode = access (GLOBAL_MODE , F_OK) == 0 ;
30
- dynamic_modules = access (DYNAMIC_MODULES , F_OK) == 0 ;
57
+ global_mode = access (get_force_global_file () , F_OK) == 0 ;
58
+ dynamic_modules = access (get_dynamic_modules_file () , F_OK) == 0 ;
31
59
inited = true ;
32
60
}
33
61
}
@@ -51,18 +79,21 @@ int is_app_need_hook(JNIEnv *env, jstring appDataDir) {
51
79
}
52
80
}
53
81
env->ReleaseStringUTFChars (appDataDir, app_data_dir);
54
- bool use_white_list = access (USE_WHITE_LIST, F_OK) == 0 ;
55
- bool white_list_exists = access (WHITE_LIST_PATH, F_OK) == 0 ;
56
- bool black_list_exists = access (BLACK_LIST_PATH, F_OK) == 0 ;
82
+ const char *white_list_path = get_white_list_path ();
83
+ const char *black_list_path = get_black_list_path ();
84
+ bool use_white_list = access (get_use_white_list_file (), F_OK) == 0 ;
85
+ bool white_list_exists = access (white_list_path, F_OK) == 0 ;
86
+ bool black_list_exists = access (black_list_path, F_OK) == 0 ;
57
87
if (use_white_list && white_list_exists) {
58
88
char path[PATH_MAX];
59
- snprintf (path, PATH_MAX, WHITE_LIST_PATH " %s" , package_name);
89
+ LOGE (" package_name: %s" , package_name);
90
+ snprintf (path, PATH_MAX, " %s%s" , white_list_path, package_name);
60
91
int res = access (path, F_OK) == 0 ;
61
92
LOGD (" use whitelist, res=%d" , res);
62
93
return res;
63
94
} else if (!use_white_list && black_list_exists) {
64
95
char path[PATH_MAX];
65
- snprintf (path, PATH_MAX, BLACK_LIST_PATH " %s" , package_name);
96
+ snprintf (path, PATH_MAX, " %s%s " , black_list_path , package_name);
66
97
int res = access (path, F_OK) != 0 ;
67
98
LOGD (" use blacklist, res=%d" , res);
68
99
return res;
@@ -73,11 +104,11 @@ int is_app_need_hook(JNIEnv *env, jstring appDataDir) {
73
104
}
74
105
75
106
bool is_global_mode () {
76
- initOnce ();
107
+ init_once ();
77
108
return global_mode;
78
109
}
79
110
80
111
bool is_dynamic_modules () {
81
- initOnce ();
112
+ init_once ();
82
113
return dynamic_modules;
83
114
}
0 commit comments