Commit e68dd866 authored by topjohnwu's avatar topjohnwu

Only create app_id_map if necessary

parent 73d36fdf
...@@ -24,6 +24,8 @@ static pthread_mutex_t data_lock = PTHREAD_MUTEX_INITIALIZER; ...@@ -24,6 +24,8 @@ static pthread_mutex_t data_lock = PTHREAD_MUTEX_INITIALIZER;
atomic<bool> denylist_enabled = false; atomic<bool> denylist_enabled = false;
static void rebuild_map() { static void rebuild_map() {
if (!zygisk_enabled)
return;
app_id_proc_map->clear(); app_id_proc_map->clear();
string data_path(APP_DATA_DIR); string data_path(APP_DATA_DIR);
size_t len = data_path.length(); size_t len = data_path.length();
...@@ -146,6 +148,8 @@ static bool validate(const char *pkg, const char *proc) { ...@@ -146,6 +148,8 @@ static bool validate(const char *pkg, const char *proc) {
static void add_hide_set(const char *pkg, const char *proc) { static void add_hide_set(const char *pkg, const char *proc) {
LOGI("denylist add: [%s/%s]\n", pkg, proc); LOGI("denylist add: [%s/%s]\n", pkg, proc);
deny_set->emplace(pkg, proc); deny_set->emplace(pkg, proc);
if (!zygisk_enabled)
return;
if (strcmp(pkg, ISOLATED_MAGIC) == 0) { if (strcmp(pkg, ISOLATED_MAGIC) == 0) {
// Kill all matching isolated processes // Kill all matching isolated processes
kill_process<&str_starts>(proc, true); kill_process<&str_starts>(proc, true);
...@@ -237,7 +241,7 @@ static bool init_list() { ...@@ -237,7 +241,7 @@ static bool init_list() {
db_err_cmd(err, return false); db_err_cmd(err, return false);
// If Android Q+, also kill blastula pool and all app zygotes // If Android Q+, also kill blastula pool and all app zygotes
if (SDK_INT >= 29) { if (SDK_INT >= 29 && zygisk_enabled) {
kill_process("usap32", true); kill_process("usap32", true);
kill_process("usap64", true); kill_process("usap64", true);
kill_process<&str_ends_safe>("_zygote", true); kill_process<&str_ends_safe>("_zygote", true);
...@@ -309,6 +313,7 @@ int enable_deny() { ...@@ -309,6 +313,7 @@ int enable_deny() {
denylist_enabled = true; denylist_enabled = true;
if (zygisk_enabled) {
default_new(app_id_proc_map); default_new(app_id_proc_map);
rebuild_map(); rebuild_map();
...@@ -320,6 +325,7 @@ int enable_deny() { ...@@ -320,6 +325,7 @@ int enable_deny() {
register_poll(&inotify_pfd, inotify_handler); register_poll(&inotify_pfd, inotify_handler);
} }
} }
}
update_deny_config(); update_deny_config();
return DAEMON_SUCCESS; return DAEMON_SUCCESS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment