Attempt to rescan zygote multiple times

Close #1654
This commit is contained in:
topjohnwu 2019-11-01 02:12:28 -04:00
parent f4299fbea8
commit 493068c073
4 changed files with 18 additions and 5 deletions

View File

@ -757,6 +757,8 @@ void boot_complete(int client) {
if (!pfs_done) if (!pfs_done)
return; return;
auto_start_magiskhide();
if (access(MANAGERAPK, F_OK) == 0) { if (access(MANAGERAPK, F_OK) == 0) {
// Install Magisk Manager if exists // Install Magisk Manager if exists
rename(MANAGERAPK, "/data/magisk.apk"); rename(MANAGERAPK, "/data/magisk.apk");

View File

@ -217,7 +217,7 @@ static void set_hide_config() {
db_err(err); db_err(err);
} }
static inline void launch_err(int client, int code = DAEMON_ERROR) { [[noreturn]] static void launch_err(int client, int code = DAEMON_ERROR) {
if (code != HIDE_IS_ENABLED) if (code != HIDE_IS_ENABLED)
hide_enabled = false; hide_enabled = false;
if (client >= 0) { if (client >= 0) {
@ -280,10 +280,14 @@ int stop_magiskhide() {
} }
void auto_start_magiskhide() { void auto_start_magiskhide() {
db_settings dbs; if (hide_enabled) {
get_db_settings(dbs, HIDE_CONFIG); pthread_kill(proc_monitor_thread, SIGZYGOTE);
if (dbs[HIDE_CONFIG]) { } else if (SDK_INT >= 19) {
new_daemon_thread([]{ launch_magiskhide(-1); }); db_settings dbs;
get_db_settings(dbs, HIDE_CONFIG);
if (dbs[HIDE_CONFIG]) {
new_daemon_thread([]{ launch_magiskhide(-1); });
}
} }
} }

View File

@ -13,6 +13,7 @@
#include <daemon.h> #include <daemon.h>
#define SIGTERMTHRD SIGUSR1 #define SIGTERMTHRD SIGUSR1
#define SIGZYGOTE SIGUSR2
#define SAFETYNET_COMPONENT "com.google.android.gms/.droidguard.DroidGuardService" #define SAFETYNET_COMPONENT "com.google.android.gms/.droidguard.DroidGuardService"
#define SAFETYNET_PROCESS "com.google.android.gms.unstable" #define SAFETYNET_PROCESS "com.google.android.gms.unstable"

View File

@ -155,6 +155,10 @@ static void inotify_event(int) {
check_zygote(); check_zygote();
} }
static void check_zygote(int) {
check_zygote();
}
// Workaround for the lack of pthread_cancel // Workaround for the lack of pthread_cancel
static void term_thread(int) { static void term_thread(int) {
LOGD("proc_monitor: cleaning up\n"); LOGD("proc_monitor: cleaning up\n");
@ -312,6 +316,8 @@ void proc_monitor() {
sigaction(SIGTERMTHRD, &act, nullptr); sigaction(SIGTERMTHRD, &act, nullptr);
act.sa_handler = inotify_event; act.sa_handler = inotify_event;
sigaction(SIGIO, &act, nullptr); sigaction(SIGIO, &act, nullptr);
act.sa_handler = check_zygote;
sigaction(SIGZYGOTE, &act, nullptr);
setup_inotify(); setup_inotify();