mirror of
https://github.com/ReVanced/revanced-cli.git
synced 2026-01-18 17:03:58 +00:00
refactor: Move alignment code to ZipFile
This commit is contained in:
@@ -2,7 +2,6 @@ package app.revanced.lib
|
||||
|
||||
import app.revanced.lib.signing.ApkSigner
|
||||
import app.revanced.lib.signing.SigningOptions
|
||||
import app.revanced.lib.zip.ZipAligner
|
||||
import app.revanced.lib.zip.ZipFile
|
||||
import app.revanced.lib.zip.structures.ZipEntry
|
||||
import app.revanced.patcher.PatcherResult
|
||||
@@ -35,7 +34,7 @@ object ApkUtils {
|
||||
|
||||
patchedEntriesSource.resourceFile?.let {
|
||||
file.copyEntriesFromFileAligned(
|
||||
ZipFile(it), ZipAligner.apkZipEntryAlignment
|
||||
ZipFile(it), ZipFile.apkZipEntryAlignment
|
||||
)
|
||||
}
|
||||
|
||||
@@ -43,7 +42,7 @@ object ApkUtils {
|
||||
|
||||
// TODO: Fix copying resources that are not needed anymore.
|
||||
file.copyEntriesFromFileAligned(
|
||||
ZipFile(apkFile), ZipAligner.apkZipEntryAlignment
|
||||
ZipFile(apkFile), ZipFile.apkZipEntryAlignment
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package app.revanced.lib.zip
|
||||
|
||||
import app.revanced.lib.zip.structures.ZipEntry
|
||||
|
||||
object ZipAligner {
|
||||
private const val DEFAULT_ALIGNMENT = 4
|
||||
private const val LIBRARY_ALIGNMENT = 4096
|
||||
|
||||
val apkZipEntryAlignment = { entry: ZipEntry ->
|
||||
if (entry.compression.toUInt() != 0u) null
|
||||
else if (entry.fileName.endsWith(".so")) LIBRARY_ALIGNMENT
|
||||
else DEFAULT_ALIGNMENT
|
||||
}
|
||||
}
|
||||
@@ -178,4 +178,15 @@ class ZipFile(file: File) : Closeable {
|
||||
if (centralDirectoryNeedsRewrite) writeCD()
|
||||
filePointer.close()
|
||||
}
|
||||
|
||||
companion object ApkZipFile {
|
||||
private const val DEFAULT_ALIGNMENT = 4
|
||||
private const val LIBRARY_ALIGNMENT = 4096
|
||||
|
||||
val apkZipEntryAlignment = { entry: ZipEntry ->
|
||||
if (entry.compression.toUInt() != 0u) null
|
||||
else if (entry.fileName.endsWith(".so")) LIBRARY_ALIGNMENT
|
||||
else DEFAULT_ALIGNMENT
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user