mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-15 08:44:08 -05:00
Fix memory leak on APK extension install
This commit is contained in:
@@ -95,46 +95,47 @@ object PackageTools {
|
|||||||
/** A modified version of `xyz.nulldev.androidcompat.pm.InstalledPackage.info` */
|
/** A modified version of `xyz.nulldev.androidcompat.pm.InstalledPackage.info` */
|
||||||
fun getPackageInfo(apkFile: Path): PackageInfo =
|
fun getPackageInfo(apkFile: Path): PackageInfo =
|
||||||
ApkParsers.getMetaInfo(apkFile.toFile()).toPackageInfo(apkFile.toFile()).apply {
|
ApkParsers.getMetaInfo(apkFile.toFile()).toPackageInfo(apkFile.toFile()).apply {
|
||||||
val parsed = ApkFile(apkFile.toFile())
|
ApkFile(apkFile.toFile()).use { parsed ->
|
||||||
val dbFactory = DocumentBuilderFactory.newInstance()
|
val dbFactory = DocumentBuilderFactory.newInstance()
|
||||||
val dBuilder = dbFactory.newDocumentBuilder()
|
val dBuilder = dbFactory.newDocumentBuilder()
|
||||||
val doc =
|
val doc =
|
||||||
parsed.manifestXml.byteInputStream().use {
|
parsed.manifestXml.byteInputStream().use {
|
||||||
dBuilder.parse(it)
|
dBuilder.parse(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace { parsed.manifestXml }
|
logger.trace { parsed.manifestXml }
|
||||||
|
|
||||||
applicationInfo.metaData =
|
applicationInfo.metaData =
|
||||||
Bundle().apply {
|
Bundle().apply {
|
||||||
val appTag = doc.getElementsByTagName("application").item(0)
|
val appTag = doc.getElementsByTagName("application").item(0)
|
||||||
|
|
||||||
appTag
|
appTag
|
||||||
?.childNodes
|
?.childNodes
|
||||||
?.toList()
|
?.toList()
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter {
|
.filter {
|
||||||
it.nodeType == Node.ELEMENT_NODE
|
it.nodeType == Node.ELEMENT_NODE
|
||||||
}.map {
|
}.map {
|
||||||
it as Element
|
it as Element
|
||||||
}.filter {
|
}.filter {
|
||||||
it.tagName == "meta-data"
|
it.tagName == "meta-data"
|
||||||
}.forEach {
|
}.forEach {
|
||||||
putString(
|
putString(
|
||||||
it.attributes.getNamedItem("android:name").nodeValue,
|
it.attributes.getNamedItem("android:name").nodeValue,
|
||||||
it.attributes.getNamedItem("android:value").nodeValue,
|
it.attributes.getNamedItem("android:value").nodeValue,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signatures =
|
signatures =
|
||||||
(
|
(
|
||||||
parsed.apkSingers.flatMap { it.certificateMetas }
|
parsed.apkSingers.flatMap { it.certificateMetas }
|
||||||
// + parsed.apkV2Singers.flatMap { it.certificateMetas }
|
// + parsed.apkV2Singers.flatMap { it.certificateMetas }
|
||||||
) // Blocked by: https://github.com/hsiafan/apk-parser/issues/72
|
) // Blocked by: https://github.com/hsiafan/apk-parser/issues/72
|
||||||
.map { Signature(it.data) }
|
.map { Signature(it.data) }
|
||||||
.toTypedArray()
|
.toTypedArray()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSignatureHash(pkgInfo: PackageInfo): String? {
|
fun getSignatureHash(pkgInfo: PackageInfo): String? {
|
||||||
|
|||||||
Reference in New Issue
Block a user