diff --git a/native/src/core/daemon.cpp b/native/src/core/daemon.cpp index 873cff72e..9023c6f53 100644 --- a/native/src/core/daemon.cpp +++ b/native/src/core/daemon.cpp @@ -128,13 +128,6 @@ static void poll_ctrl_handler(pollfd *pfd) { } } -void MagiskD::reboot() const noexcept { - if (is_recovery()) - exec_command_sync("/system/bin/reboot", "recovery"); - else - exec_command_sync("/system/bin/reboot"); -} - bool get_client_cred(int fd, sock_cred *cred) { socklen_t len = sizeof(ucred); if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, cred, &len) != 0) diff --git a/native/src/core/daemon.rs b/native/src/core/daemon.rs index 02707e823..6451d5f05 100644 --- a/native/src/core/daemon.rs +++ b/native/src/core/daemon.rs @@ -17,6 +17,7 @@ use base::{ use std::fmt::Write as FmtWrite; use std::io::{BufReader, Write}; use std::os::unix::net::UnixStream; +use std::process::Command; use std::sync::atomic::{AtomicBool, AtomicU32, Ordering}; use std::sync::{Mutex, OnceLock}; @@ -79,10 +80,6 @@ impl MagiskD { unsafe { MAGISKD.get().unwrap_unchecked() } } - pub fn is_recovery(&self) -> bool { - self.is_recovery - } - pub fn zygisk_enabled(&self) -> bool { self.zygisk_enabled.load(Ordering::Acquire) } @@ -217,6 +214,15 @@ impl MagiskD { } } } + + pub fn reboot(&self) { + if self.is_recovery { + Command::new("/system/bin/reboot").arg("recovery").status() + } else { + Command::new("/system/bin/reboot").status() + } + .ok(); + } } pub fn daemon_entry() { diff --git a/native/src/core/lib.rs b/native/src/core/lib.rs index ee962869f..7bbb394af 100644 --- a/native/src/core/lib.rs +++ b/native/src/core/lib.rs @@ -231,7 +231,7 @@ pub mod ffi { // FFI for MagiskD extern "Rust" { type MagiskD; - fn is_recovery(&self) -> bool; + fn reboot(&self); fn sdk_int(&self) -> i32; fn zygisk_enabled(&self) -> bool; fn boot_stage_handler(&self, client: i32, code: i32); @@ -253,8 +253,6 @@ pub mod ffi { fn get() -> &'static MagiskD; } unsafe extern "C++" { - #[allow(dead_code)] - fn reboot(self: &MagiskD); fn handle_modules(self: &MagiskD) -> Vec; } }