writeTo has closed InputStream

This commit is contained in:
vvb2060 2021-01-23 20:26:00 +08:00 committed by topjohnwu
parent 4ea5f34bf3
commit 96405c26d0
3 changed files with 5 additions and 9 deletions

View File

@ -37,7 +37,7 @@ suspend fun BaseDownloader.handleAPK(subject: Subject.Manager) {
if (Info.stubChk.version < subject.stub.versionCode) {
notifyHide(id)
// Also upgrade stub
service.fetchFile(subject.stub.link).byteStream().use { it.writeTo(apk) }
service.fetchFile(subject.stub.link).byteStream().writeTo(apk)
patch(apk)
} else {
// Simply relaunch the app

View File

@ -94,9 +94,7 @@ object HideAPK {
val src = if (!isRunningAsStub && SDK_INT >= 28) {
val stub = File(context.cacheDir, "stub.apk")
try {
svc.fetchFile(Info.remote.stub.link).byteStream().use {
it.writeTo(stub)
}
svc.fetchFile(Info.remote.stub.link).byteStream().writeTo(stub)
} catch (e: IOException) {
Timber.e(e)
return false
@ -150,9 +148,7 @@ object HideAPK {
} else {
File(context.cacheDir, "manager.apk").also { apk ->
try {
svc.fetchFile(Info.remote.app.link).byteStream().use {
it.writeTo(apk)
}
svc.fetchFile(Info.remote.app.link).byteStream().writeTo(apk)
} catch (e: IOException) {
Timber.e(e)
return false

View File

@ -140,14 +140,14 @@ abstract class MagiskInstallImpl protected constructor(
// Extract scripts
for (script in listOf("util_functions.sh", "boot_patch.sh", "addon.d.sh")) {
val dest = File(binDir, script)
context.assets.open(script).use { it.writeTo(dest) }
context.assets.open(script).writeTo(dest)
}
// Extract chromeos tools
File(binDir, "chromeos").mkdir()
for (file in listOf("futility", "kernel_data_key.vbprivk", "kernel.keyblock")) {
val name = "chromeos/$file"
val dest = File(binDir, name)
context.assets.open(name).use { it.writeTo(dest) }
context.assets.open(name).writeTo(dest)
}
} catch (e: Exception) {
console.add("! Unable to extract files")