in ruler-common/src/main/java/com/spotify/ruler/common/apk/ApkParser.kt [32:74]
fun parse(apkFile: File) : List<ApkEntry> {
println(unstrippedNativeLibraryPaths.map { it.path }.joinToString { ", " })
val sizeCalculator = ApkSizeCalculator.getDefault()
val downloadSizePerFile = sizeCalculator.getDownloadSizePerFile(apkFile.toPath())
val installSizePerFile = sizeCalculator.getRawSizePerFile(apkFile.toPath())
val bloaty = Bloaty(bloatyPath)
val apkEntries = mutableListOf<ApkEntry>()
ZipFile(apkFile).use { zipFile ->
zipFile.entries().iterator().forEach { zipEntry ->
val name = "/${zipEntry.name}"
val downloadSize = downloadSizePerFile.getValue(name)
val installSize = installSizePerFile.getValue(name)
apkEntries += when {
isDexEntry(name) -> {
val bytes = zipFile.getInputStream(zipEntry).readBytes()
ApkEntry.Dex(name, downloadSize, installSize, parseDexEntry(bytes))
}
isNativeLibraryEntry(name) -> {
val bytes = zipFile.getInputStream(zipEntry).readBytes()
val native = ApkEntry.NativeLibrary(
name,
downloadSize,
installSize,
bloaty.parseNativeLibraryEntry(
bytes,
debugFileForNativeLibrary(entryName = name)
)
)
native
}
// When build from bazel resources coming from
// kt_android_library rule starts with /lib/res and are not attributed properly.
else -> ApkEntry.Default(
name.replace("/lib/res/", "/res/"),
downloadSize,
installSize
)
}
}
}
return apkEntries
}