mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-03-12 21:23:02 -07:00
Skip loading magisk in charger mode
This commit is contained in:
@@ -143,6 +143,8 @@ void BootConfig::set(const kv_pairs &kv) noexcept {
|
||||
strscpy(hardware_plat.data(), value.data(), hardware_plat.size());
|
||||
} else if (key == "androidboot.fstab_suffix") {
|
||||
strscpy(fstab_suffix.data(), value.data(), fstab_suffix.size());
|
||||
} else if (key == "androidboot.mode") {
|
||||
strscpy(boot_mode.data(), value.data(), boot_mode.size());
|
||||
} else if (key == "qemu") {
|
||||
emulator = true;
|
||||
} else if (key == "androidboot.partition_map") {
|
||||
|
||||
@@ -9,6 +9,10 @@ impl BootConfig {
|
||||
debug!("force_normal_boot=[{}]", self.force_normal_boot);
|
||||
debug!("rootwait=[{}]", self.rootwait);
|
||||
unsafe {
|
||||
debug!(
|
||||
"boot_mode=[{}]",
|
||||
Utf8CStr::from_ptr_unchecked(self.boot_mode.as_ptr())
|
||||
);
|
||||
debug!(
|
||||
"slot=[{}]",
|
||||
Utf8CStr::from_ptr_unchecked(self.slot.as_ptr())
|
||||
|
||||
@@ -24,6 +24,7 @@ impl MagiskInit {
|
||||
fstab_suffix: [0; 32],
|
||||
hardware: [0; 32],
|
||||
hardware_plat: [0; 32],
|
||||
boot_mode: [0; 16],
|
||||
partition_map: Vec::new(),
|
||||
},
|
||||
}
|
||||
@@ -87,8 +88,8 @@ impl MagiskInit {
|
||||
self.patch_rw_root();
|
||||
}
|
||||
|
||||
fn recovery(&self) {
|
||||
info!("Ramdisk is recovery, abort");
|
||||
fn recovery_or_charger(&self) {
|
||||
info!("Charger mode or ramdisk is recovery, abort");
|
||||
self.restore_ramdisk_init();
|
||||
cstr!("/.backup").remove_all().ok();
|
||||
}
|
||||
@@ -151,8 +152,11 @@ impl MagiskInit {
|
||||
self.legacy_system_as_root();
|
||||
} else if self.config.force_normal_boot {
|
||||
self.first_stage();
|
||||
} else if cstr!("/sbin/recovery").exists() || cstr!("/system/bin/recovery").exists() {
|
||||
self.recovery();
|
||||
} else if cstr!("/sbin/recovery").exists()
|
||||
|| cstr!("/system/bin/recovery").exists()
|
||||
|| unsafe { CStr::from_ptr(self.config.boot_mode.as_ptr()) } == c"charger"
|
||||
{
|
||||
self.recovery_or_charger();
|
||||
} else if self.check_two_stage() {
|
||||
self.first_stage();
|
||||
} else {
|
||||
|
||||
@@ -35,6 +35,7 @@ pub mod ffi {
|
||||
fstab_suffix: [c_char; 32],
|
||||
hardware: [c_char; 32],
|
||||
hardware_plat: [c_char; 32],
|
||||
boot_mode: [c_char; 16],
|
||||
partition_map: Vec<KeyValue>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user