From 03418ddcbff9c64361489dee152cb49227da75e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?sh=C3=ACw=C4=93i=20nguyen?= <84650617+HuskyDG@users.noreply.github.com> Date: Fri, 10 Feb 2023 04:36:58 +0000 Subject: [PATCH] run module uninstall.sh on Magisk uninstallation --- native/src/core/daemon.cpp | 6 ++++-- native/src/core/magisk.cpp | 12 +++++++++++- scripts/uninstaller.sh | 5 +++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/native/src/core/daemon.cpp b/native/src/core/daemon.cpp index f5626a9b7..ee99069a4 100644 --- a/native/src/core/daemon.cpp +++ b/native/src/core/daemon.cpp @@ -151,12 +151,14 @@ static void handle_request_async(int client, int code, const sock_cred &cred) { case MainRequest::SQLITE_CMD: exec_sql(client); break; - case MainRequest::REMOVE_MODULES: + case MainRequest::REMOVE_MODULES: { + int do_reboot = read_int(client); remove_modules(); write_int(client, 0); close(client); - reboot(); + if (do_reboot) reboot(); break; + } case MainRequest::ZYGISK: case MainRequest::ZYGISK_PASSTHROUGH: zygisk_handler(client, &cred); diff --git a/native/src/core/magisk.cpp b/native/src/core/magisk.cpp index c7d2c4ff8..9405cbd47 100644 --- a/native/src/core/magisk.cpp +++ b/native/src/core/magisk.cpp @@ -23,7 +23,7 @@ Options: -v print running daemon version -V print running daemon version code --list list all available applets - --remove-modules remove all modules and reboot + --remove-modules [-n] remove all modules, reboot if -n is not provided --install-module ZIP install a module zip file Advanced Options (Internal APIs): @@ -114,7 +114,17 @@ int magisk_main(int argc, char *argv[]) { printf("%s\n", res.data()); } } else if (argv[1] == "--remove-modules"sv) { + int do_reboot; + if (argc == 3 && argv[2] == "-n"sv) { + do_reboot = 0; + } else if (argc == 2) { + do_reboot = 1; + } else { + usage(); + exit(1); + } int fd = connect_daemon(MainRequest::REMOVE_MODULES); + write_int(fd, do_reboot); return read_int(fd); } else if (argv[1] == "--path"sv) { int fd = connect_daemon(MainRequest::GET_PATH); diff --git a/scripts/uninstaller.sh b/scripts/uninstaller.sh index 619fe1e9f..3fa6c1fb9 100644 --- a/scripts/uninstaller.sh +++ b/scripts/uninstaller.sh @@ -137,6 +137,11 @@ case $((STATUS & 3)) in ;; esac +if $BOOTMODE; then + ui_print "- Removing modules" + magisk --remove-modules -n +fi + ui_print "- Removing Magisk files" rm -rf \ /cache/*magisk* /cache/unblock /data/*magisk* /data/cache/*magisk* /data/property/*magisk* \