Fix patching files

Fix #3765
This commit is contained in:
topjohnwu 2021-01-25 02:24:12 -08:00
parent b1dbbdef12
commit 07bd36c94b
2 changed files with 12 additions and 6 deletions

View File

@ -188,10 +188,15 @@ abstract class MagiskInstallImpl protected constructor(
val name = entry.name.replace(".lz4", "")
console.add("-- Extracting: $name")
val extract = File(installDir, name)
extract.outputStream().use { decompressedStream().copyTo(it) }
val extract = installDirFile(name)
SuFileOutputStream(extract).use { decompressedStream().copyTo(it) }
} else if (entry.name.contains("vbmeta.img")) {
val rawData = decompressedStream().readBytes()
// DO NOT USE readBytes() DUE TO BUG IN LZ4FrameInputStream
val rawData = decompressedStream().run {
val buffer = ByteArrayOutputStream()
copyTo(buffer)
buffer.toByteArray()
}
// Valid vbmeta.img should be at least 256 bytes
if (rawData.size < 256)
continue
@ -264,9 +269,10 @@ abstract class MagiskInstallImpl protected constructor(
handleTar(src, outFile!!.uri.outputStream())
} else {
// Raw image
srcBoot = File(installDir, "boot.img").path
val image = installDirFile("boot.img")
srcBoot = image.path
console.add("- Copying image to cache")
FileOutputStream(srcBoot).use { src.copyTo(it) }
SuFileOutputStream(image).use { src.copyTo(it) }
outFile = MediaStoreUtils.getFile("$filename.img", true)
outFile!!.uri.outputStream()
}

View File

@ -28,6 +28,6 @@ kapt.incremental.apt=true
# Magisk
magisk.stubVersion=16
magisk.versionCode=21403
magisk.versionCode=21404
magisk.ndkVersion=21d
magisk.fullNdkVersion=21.3.6528147