Support recovery based Magisk

Some devices (mainly new Samsung phones we're talking here...) using
A only system-as-root refuse to load ramdisk when booted with boot
no matter what we do. With many A only system-as-root devices, even
though their boot image is kernel only, we can still be able to add
a ramdisk section into the image and force the kernel to use it as
rootfs. However the bootloader on devices like the S10 simply does
not load anything within boot image into memory other than the kernel.
This gives as the only option is to install Magisk on the recovery
partition. This commits adds proper support for these kind of scenarios.
This commit is contained in:
topjohnwu
2019-03-30 00:49:48 -04:00
parent 5b30c77403
commit 1cd45b53b1
4 changed files with 28 additions and 14 deletions

View File

@@ -79,12 +79,12 @@ public abstract class MagiskInstaller {
}
protected boolean findImage() {
console.add("- Detecting target image");
srcBoot = ShellUtils.fastCmd("find_boot_image", "echo \"$BOOTIMAGE\"");
if (srcBoot.isEmpty()) {
console.add("! Unable to detect target image");
return false;
}
console.add("- Target image: " + srcBoot);
return true;
}
@@ -92,7 +92,6 @@ public abstract class MagiskInstaller {
String slot = ShellUtils.fastCmd("echo $SLOT");
String target = (TextUtils.equals(slot, "_a") ? "_b" : "_a");
console.add("- Target slot: " + target);
console.add("- Detecting target image");
srcBoot = ShellUtils.fastCmd(
"SLOT=" + target,
"find_boot_image",
@@ -103,6 +102,7 @@ public abstract class MagiskInstaller {
console.add("! Unable to detect target image");
return false;
}
console.add("- Target image: " + srcBoot);
return true;
}
@@ -216,8 +216,9 @@ public abstract class MagiskInstaller {
}
if (!Shell.sh("cd " + installDir, Utils.fmt(
"KEEPFORCEENCRYPT=%b KEEPVERITY=%b sh update-binary sh boot_patch.sh %s",
Config.keepEnc, Config.keepVerity, srcBoot))
"KEEPFORCEENCRYPT=%b KEEPVERITY=%b RECOVERYMODE=%b " +
"sh update-binary sh boot_patch.sh %s",
Config.keepEnc, Config.keepVerity, Config.recovery, srcBoot))
.to(console, logs).exec().isSuccess())
return false;