diff --git a/native/jni/core/bootstages.cpp b/native/jni/core/bootstages.cpp index 046b35324..453202fa8 100644 --- a/native/jni/core/bootstages.cpp +++ b/native/jni/core/bootstages.cpp @@ -482,6 +482,9 @@ static void collect_modules() { if (access("remove", F_OK) == 0) { chdir(".."); LOGI("%s: remove\n", entry->d_name); + sprintf(buf, "%s/uninstall.sh", entry->d_name); + if (access(buf, F_OK) == 0) + exec_script(buf); rm_rf(entry->d_name); continue; } diff --git a/native/jni/core/scripting.cpp b/native/jni/core/scripting.cpp index 2e4f9d1b8..2ae0f7547 100644 --- a/native/jni/core/scripting.cpp +++ b/native/jni/core/scripting.cpp @@ -16,6 +16,14 @@ static void set_path() { setenv("PATH", buf, 1); } +void exec_script(const char *script) { + exec_t exec { + .pre_exec = set_path, + .fork = fork_no_zombie + }; + exec_command_sync(exec, "/system/bin/sh", script); +} + void exec_common_script(const char *stage) { char path[4096]; DIR *dir; diff --git a/native/jni/include/daemon.h b/native/jni/include/daemon.h index f8edcd5b0..637a7a6c2 100644 --- a/native/jni/include/daemon.h +++ b/native/jni/include/daemon.h @@ -69,6 +69,7 @@ void boot_complete(int client); * Scripting * *************/ +void exec_script(const char *script); void exec_common_script(const char *stage); void exec_module_script(const char *stage, const std::vector &module_list); void migrate_img(const char *img);