the new and improved apk installer

This commit is contained in:
Aria Moradi
2021-04-03 19:47:31 +04:30
parent abc3a16ee3
commit 15bd5b4b7a
12 changed files with 302 additions and 390 deletions

View File

@@ -22,7 +22,7 @@ data class InstalledPackage(val root: File) {
val icon = File(root, "icon.png")
val info: PackageInfo
get() = ApkParsers.getMetaInfo(apk).toPackageInfo(root, apk).also {
get() = ApkParsers.getMetaInfo(apk).toPackageInfo(apk).also {
val parsed = ApkFile(apk)
val dbFactory = DocumentBuilderFactory.newInstance()
val dBuilder = dbFactory.newDocumentBuilder()
@@ -82,12 +82,14 @@ data class InstalledPackage(val root: File) {
}
}
private fun NodeList.toList(): List<Node> {
val out = mutableListOf<Node>()
companion object {
fun NodeList.toList(): List<Node> {
val out = mutableListOf<Node>()
for(i in 0 until length)
out += item(i)
for (i in 0 until length)
out += item(i)
return out
return out
}
}
}

View File

@@ -6,7 +6,7 @@ import android.content.pm.PackageInfo
import net.dongliu.apk.parser.bean.ApkMeta
import java.io.File
fun ApkMeta.toPackageInfo(root: File, apk: File): PackageInfo {
fun ApkMeta.toPackageInfo(apk: File): PackageInfo {
return PackageInfo().also {
it.packageName = packageName
it.versionCode = versionCode.toInt()