This commit is contained in:
LoveSy 2023-02-06 23:39:12 +08:00 committed by John Wu
parent 584bad5314
commit 9656cf2f86

View File

@ -238,14 +238,13 @@ abstract class MagiskInstallImpl protected constructor(
} }
boot.delete() boot.delete()
} else { } else {
if (!initBoot.exists()) { srcBoot = when {
if (!boot.exists()) { initBoot.exists() -> initBoot
boot.exists() -> boot
else -> {
console.add("! No boot image found") console.add("! No boot image found")
throw IOException() throw IOException()
} }
srcBoot = boot
} else {
srcBoot = initBoot
} }
} }
return tarOut return tarOut
@ -306,14 +305,13 @@ abstract class MagiskInstallImpl protected constructor(
try { try {
val newBoot = installDir.getChildFile("new-boot.img") val newBoot = installDir.getChildFile("new-boot.img")
if (outStream is TarOutputStream) { if (outStream is TarOutputStream) {
val name = val name = with(srcBoot.path) {
if (srcBoot.path.contains("recovery")) { when {
"recovery.img" contains("recovery") -> "recovery.img"
} else if (srcBoot.path.contains("init_boot")) { contains("init_boot") -> "init_boot.img"
"init_boot.img" else -> "boot.img"
} else {
"boot.img"
} }
}
outStream.putNextEntry(newTarEntry(name, newBoot.length())) outStream.putNextEntry(newTarEntry(name, newBoot.length()))
} }
newBoot.newInputStream().cleanPump(outStream) newBoot.newInputStream().cleanPump(outStream)