refactor: change apk zip entry alignment to field

This commit is contained in:
oSumAtrIX 2023-09-19 20:24:26 +02:00
parent 52c5259451
commit 978032cce1
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 4 additions and 3 deletions

View File

@ -32,7 +32,7 @@ object ApkUtils {
patchedEntriesSource.resourceFile?.let {
file.copyEntriesFromFileAligned(
ZipFile(it), ZipAligner::getEntryAlignment
ZipFile(it), ZipAligner.apkZipEntryAlignment
)
}
@ -40,7 +40,7 @@ object ApkUtils {
// TODO: Fix copying resources that are not needed anymore.
file.copyEntriesFromFileAligned(
ZipFile(apkFile), ZipAligner::getEntryAlignment
ZipFile(apkFile), ZipAligner.apkZipEntryAlignment
)
}
}

View File

@ -6,8 +6,9 @@ object ZipAligner {
private const val DEFAULT_ALIGNMENT = 4
private const val LIBRARY_ALIGNMENT = 4096
fun getEntryAlignment(entry: ZipEntry): Int? =
val apkZipEntryAlignment = { entry: ZipEntry ->
if (entry.compression.toUInt() != 0u) null
else if (entry.fileName.endsWith(".so")) LIBRARY_ALIGNMENT
else DEFAULT_ALIGNMENT
}
}