From 97705704e2c39fc562e27fb1dce8f7888a847dd2 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Thu, 4 Jan 2024 15:57:36 +0800 Subject: [PATCH] install or uninstall apk asynchronously --- native/src/core/scripting.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/native/src/core/scripting.cpp b/native/src/core/scripting.cpp index f045efc11..5e482c188 100644 --- a/native/src/core/scripting.cpp +++ b/native/src/core/scripting.cpp @@ -161,12 +161,9 @@ rm -f $APK void install_apk(const char *apk) { setfilecon(apk, MAGISK_FILE_CON); - exec_t exec { - .fork = fork_no_orphan - }; char cmds[sizeof(install_script) + 4096]; ssprintf(cmds, sizeof(cmds), install_script, apk, JAVA_PACKAGE_NAME); - exec_command_sync(exec, "/system/bin/sh", "-c", cmds); + exec_command_async("/system/bin/sh", "-c", cmds); } constexpr char uninstall_script[] = R"EOF( @@ -176,12 +173,9 @@ log -t Magisk "pm_uninstall: $(pm uninstall $PKG 2>&1)" )EOF"; void uninstall_pkg(const char *pkg) { - exec_t exec { - .fork = fork_no_orphan - }; char cmds[sizeof(uninstall_script) + 256]; ssprintf(cmds, sizeof(cmds), uninstall_script, pkg); - exec_command_sync(exec, "/system/bin/sh", "-c", cmds); + exec_command_async("/system/bin/sh", "-c", cmds); } constexpr char clear_script[] = R"EOF( @@ -192,12 +186,9 @@ log -t Magisk "pm_clear: $(pm clear --user $USER $PKG 2>&1)" )EOF"; void clear_pkg(const char *pkg, int user_id) { - exec_t exec { - .fork = fork_no_orphan - }; char cmds[sizeof(clear_script) + 288]; ssprintf(cmds, sizeof(cmds), clear_script, pkg, user_id); - exec_command_sync(exec, "/system/bin/sh", "-c", cmds); + exec_command_async("/system/bin/sh", "-c", cmds); } [[noreturn]] __printflike(2, 3)