mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 05:49:16 +01:00
using copyto method and also closing stream for extension installs
This commit is contained in:
parent
da76d4854f
commit
5f7069437e
@ -40,13 +40,7 @@ class ExtensionInstallActivity : Activity() {
|
|||||||
val sessionId = packageInstaller.createSession(params)
|
val sessionId = packageInstaller.createSession(params)
|
||||||
val session = packageInstaller.openSession(sessionId)
|
val session = packageInstaller.openSession(sessionId)
|
||||||
session.openWrite("package", 0, -1).use { packageInSession ->
|
session.openWrite("package", 0, -1).use { packageInSession ->
|
||||||
data.use { `is` ->
|
data.copyTo(packageInSession)
|
||||||
val buffer = ByteArray(16384)
|
|
||||||
var n: Int
|
|
||||||
while (`is`.read(buffer).also { n = it } >= 0) {
|
|
||||||
packageInSession.write(buffer, 0, n)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val newIntent = Intent(this, ExtensionInstallActivity::class.java)
|
val newIntent = Intent(this, ExtensionInstallActivity::class.java)
|
||||||
@ -59,6 +53,7 @@ class ExtensionInstallActivity : Activity() {
|
|||||||
session.commit(statusReceiver)
|
session.commit(statusReceiver)
|
||||||
val extensionManager: ExtensionManager by injectLazy()
|
val extensionManager: ExtensionManager by injectLazy()
|
||||||
extensionManager.setInstalling(downloadId, sessionId)
|
extensionManager.setInstalling(downloadId, sessionId)
|
||||||
|
data.close()
|
||||||
} catch (error: Exception) {
|
} catch (error: Exception) {
|
||||||
// Either install package can't be found (probably bots) or there's a security exception
|
// Either install package can't be found (probably bots) or there's a security exception
|
||||||
// with the download manager. Nothing we can workaround.
|
// with the download manager. Nothing we can workaround.
|
||||||
|
Loading…
Reference in New Issue
Block a user