Make sure native bridge is restored on daemon restart

This commit is contained in:
topjohnwu 2023-11-08 17:55:25 -08:00
parent ef48abf19d
commit 977c981265

View File

@ -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();
}