mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
Minor cleanup
This commit is contained in:
parent
4e99997013
commit
1dcf325547
@ -132,12 +132,12 @@ const MagiskD &MagiskD::get() {
|
||||
return *reinterpret_cast<const MagiskD*>(&rust::get_magiskd());
|
||||
}
|
||||
|
||||
const rust::MagiskD &MagiskD::as_rust() const {
|
||||
return *reinterpret_cast<const rust::MagiskD*>(this);
|
||||
const rust::MagiskD *MagiskD::operator->() const {
|
||||
return reinterpret_cast<const rust::MagiskD*>(this);
|
||||
}
|
||||
|
||||
void MagiskD::boot_stage_handler(int client, int code) const {
|
||||
as_rust().boot_stage_handler(client, code);
|
||||
const rust::MagiskD &MagiskD::as_rust() const {
|
||||
return *operator->();
|
||||
}
|
||||
|
||||
void MagiskD::reboot() const {
|
||||
@ -196,7 +196,7 @@ static void handle_request_sync(int client, int code) {
|
||||
write_int(client, MAGISK_VER_CODE);
|
||||
break;
|
||||
case +RequestCode::START_DAEMON:
|
||||
rust::get_magiskd().setup_logfile();
|
||||
MagiskD::get()->setup_logfile();
|
||||
break;
|
||||
case +RequestCode::STOP_DAEMON: {
|
||||
// Unmount all overlays
|
||||
@ -298,7 +298,7 @@ static void handle_request(pollfd *pfd) {
|
||||
exec_task([=, fd = client.release()] { handle_request_async(fd, code, cred); });
|
||||
} else {
|
||||
exec_task([=, fd = client.release()] {
|
||||
MagiskD::get().boot_stage_handler(fd, code);
|
||||
MagiskD::get()->boot_stage_handler(fd, code);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -97,16 +97,8 @@ impl MagiskD {
|
||||
}
|
||||
}
|
||||
|
||||
mod cxx_extern {
|
||||
use base::libc::c_char;
|
||||
|
||||
extern "C" {
|
||||
pub fn get_magisk_tmp() -> *const c_char;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_magisk_tmp() -> &'static Utf8CStr {
|
||||
unsafe { Utf8CStr::from_ptr(cxx_extern::get_magisk_tmp()).unwrap_unchecked() }
|
||||
unsafe { Utf8CStr::from_ptr(super::ffi::get_magisk_tmp()).unwrap_unchecked() }
|
||||
}
|
||||
|
||||
pub fn daemon_entry() {
|
||||
|
@ -116,7 +116,7 @@ db_settings::db_settings() {
|
||||
data[SU_MULTIUSER_MODE] = MULTIUSER_MODE_OWNER_ONLY;
|
||||
data[SU_MNT_NS] = NAMESPACE_MODE_REQUESTER;
|
||||
data[DENYLIST_CONFIG] = false;
|
||||
data[ZYGISK_CONFIG] = rust::get_magiskd().is_emulator();
|
||||
data[ZYGISK_CONFIG] = MagiskD::get()->is_emulator();
|
||||
}
|
||||
|
||||
int db_settings::get_idx(string_view key) const {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <functional>
|
||||
|
||||
#include "socket.hpp"
|
||||
#include "../core-rs.hpp"
|
||||
|
||||
#define AID_ROOT 0
|
||||
#define AID_SHELL 2000
|
||||
@ -18,28 +19,6 @@
|
||||
#define to_app_id(uid) (uid % AID_USER_OFFSET)
|
||||
#define to_user_id(uid) (uid / AID_USER_OFFSET)
|
||||
|
||||
namespace rust {
|
||||
struct MagiskD;
|
||||
}
|
||||
|
||||
struct MagiskD {
|
||||
// Make sure only references can exist
|
||||
~MagiskD() = delete;
|
||||
|
||||
// Binding to Rust
|
||||
static const MagiskD &get();
|
||||
void boot_stage_handler(int client, int code) const;
|
||||
|
||||
// C++ implementation
|
||||
void reboot() const;
|
||||
bool post_fs_data() const;
|
||||
void late_start() const;
|
||||
void boot_complete() const;
|
||||
|
||||
private:
|
||||
const rust::MagiskD &as_rust() const;
|
||||
};
|
||||
|
||||
// Return codes for daemon
|
||||
enum class RespondCode : int {
|
||||
ERROR = -1,
|
||||
@ -61,11 +40,9 @@ extern bool zygisk_enabled;
|
||||
extern std::vector<module_info> *module_list;
|
||||
|
||||
void reset_zygisk(bool restore);
|
||||
extern "C" const char *get_magisk_tmp();
|
||||
int connect_daemon(int req, bool create = false);
|
||||
std::string find_preinit_device();
|
||||
void unlock_blocks();
|
||||
void reboot();
|
||||
|
||||
// Poll control
|
||||
using poll_callback = void(*)(pollfd*);
|
||||
@ -115,6 +92,3 @@ int denylist_cli(int argc, char **argv);
|
||||
void initialize_denylist();
|
||||
bool is_deny_target(int uid, std::string_view process);
|
||||
void revert_unmount();
|
||||
|
||||
// Include last to prevent recursive include issues
|
||||
#include "../core-rs.hpp"
|
||||
|
26
native/src/core/include/daemon.hpp
Normal file
26
native/src/core/include/daemon.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
namespace rust {
|
||||
struct MagiskD;
|
||||
}
|
||||
|
||||
struct MagiskD {
|
||||
// Make sure only references can exist
|
||||
~MagiskD() = delete;
|
||||
|
||||
// Binding to Rust
|
||||
static const MagiskD &get();
|
||||
|
||||
// C++ implementation
|
||||
void reboot() const;
|
||||
bool post_fs_data() const;
|
||||
void late_start() const;
|
||||
void boot_complete() const;
|
||||
|
||||
const rust::MagiskD *operator->() const;
|
||||
|
||||
private:
|
||||
const rust::MagiskD &as_rust() const;
|
||||
};
|
||||
|
||||
const char *get_magisk_tmp();
|
@ -53,7 +53,9 @@ pub mod ffi {
|
||||
}
|
||||
|
||||
unsafe extern "C++" {
|
||||
include!("include/core.hpp");
|
||||
include!("include/daemon.hpp");
|
||||
|
||||
fn get_magisk_tmp() -> *const c_char;
|
||||
|
||||
#[cxx_name = "MagiskD"]
|
||||
type CxxMagiskD;
|
||||
|
Loading…
x
Reference in New Issue
Block a user