mirror of
https://github.com/revanced/revanced-cli.git
synced 2025-01-06 01:05:50 +01:00
refactor: Move alignment code to ZipFile
This commit is contained in:
parent
a022febd0c
commit
ac5742dd6c
@ -96,18 +96,18 @@ public final class app/revanced/lib/signing/SigningOptions {
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class app/revanced/lib/zip/ZipAligner {
|
||||
public static final field INSTANCE Lapp/revanced/lib/zip/ZipAligner;
|
||||
public final fun getApkZipEntryAlignment ()Lkotlin/jvm/functions/Function1;
|
||||
}
|
||||
|
||||
public final class app/revanced/lib/zip/ZipFile : java/io/Closeable {
|
||||
public static final field ApkZipFile Lapp/revanced/lib/zip/ZipFile$ApkZipFile;
|
||||
public fun <init> (Ljava/io/File;)V
|
||||
public final fun addEntryCompressData (Lapp/revanced/lib/zip/structures/ZipEntry;[B)V
|
||||
public fun close ()V
|
||||
public final fun copyEntriesFromFileAligned (Lapp/revanced/lib/zip/ZipFile;Lkotlin/jvm/functions/Function1;)V
|
||||
}
|
||||
|
||||
public final class app/revanced/lib/zip/ZipFile$ApkZipFile {
|
||||
public final fun getApkZipEntryAlignment ()Lkotlin/jvm/functions/Function1;
|
||||
}
|
||||
|
||||
public final class app/revanced/lib/zip/structures/ZipEntry {
|
||||
public static final field Companion Lapp/revanced/lib/zip/structures/ZipEntry$Companion;
|
||||
public fun <init> (Ljava/lang/String;)V
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user