From 977c98126599df5d7600836066e6bfe44596d2af Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 8 Nov 2023 17:55:25 -0800 Subject: [PATCH] Make sure native bridge is restored on daemon restart --- native/src/core/daemon.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/native/src/core/daemon.cpp b/native/src/core/daemon.cpp index e05ae964c7c3..3404e5deb37a 100644 --- a/native/src/core/daemon.cpp +++ b/native/src/core/daemon.cpp @@ -179,11 +179,24 @@ static void handle_request_sync(int client, int code) { case MainRequest::START_DAEMON: rust::get_magiskd().setup_logfile(); break; - case MainRequest::STOP_DAEMON: + case MainRequest::STOP_DAEMON: { + // Unmount all overlays denylist_handler(-1, nullptr); + + // Restore native bridge property + auto nb = get_prop(NBPROP); + auto len = sizeof(ZYGISKLDR) - 1; + if (nb == ZYGISKLDR) { + set_prop(NBPROP, "0"); + } else if (nb.size() > len) { + set_prop(NBPROP, nb.data() + len); + } + write_int(client, 0); + // Terminate the daemon! exit(0); + } default: __builtin_unreachable(); }