You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Move some global state into Rust
This commit is contained in:
+11
-11
@@ -14,8 +14,6 @@ using namespace std;
|
||||
|
||||
int SDK_INT = -1;
|
||||
|
||||
bool RECOVERY_MODE = false;
|
||||
|
||||
static struct stat self_st;
|
||||
|
||||
static map<int, poll_callback> *poll_map;
|
||||
@@ -130,6 +128,13 @@ static void poll_ctrl_handler(pollfd *pfd) {
|
||||
}
|
||||
}
|
||||
|
||||
void MagiskD::reboot() const {
|
||||
if (is_recovery())
|
||||
exec_command_sync("/system/bin/reboot", "recovery");
|
||||
else
|
||||
exec_command_sync("/system/bin/reboot");
|
||||
}
|
||||
|
||||
static void handle_request_async(int client, int code, const sock_cred &cred) {
|
||||
switch (code) {
|
||||
case MainRequest::DENYLIST:
|
||||
@@ -153,7 +158,10 @@ static void handle_request_async(int client, int code, const sock_cred &cred) {
|
||||
remove_modules();
|
||||
write_int(client, 0);
|
||||
close(client);
|
||||
if (do_reboot) reboot();
|
||||
if (do_reboot) {
|
||||
MagiskD daemon;
|
||||
daemon.reboot();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MainRequest::ZYGISK:
|
||||
@@ -371,14 +379,6 @@ static void daemon_entry() {
|
||||
ssprintf(path, sizeof(path), "%s/" ROOTOVL, tmp);
|
||||
rm_rf(path);
|
||||
|
||||
// Load config status
|
||||
ssprintf(path, sizeof(path), "%s/" MAIN_CONFIG, tmp);
|
||||
parse_prop_file(path, [](auto key, auto val) -> bool {
|
||||
if (key == "RECOVERYMODE" && val == "true")
|
||||
RECOVERY_MODE = true;
|
||||
return true;
|
||||
});
|
||||
|
||||
// Use isolated devpts if kernel support
|
||||
if (access("/dev/pts/ptmx", F_OK) == 0) {
|
||||
ssprintf(path, sizeof(path), "%s/" SHELLPTS, tmp);
|
||||
|
||||
Reference in New Issue
Block a user