Skip to content

Commit 03682c9

Browse files
committed
perf: --rip-lib
1 parent de652d6 commit 03682c9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

api/revanced-library.api

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public final class app/revanced/library/ApkSigner$Signer {
3333

3434
public final class app/revanced/library/ApkUtils {
3535
public static final field INSTANCE Lapp/revanced/library/ApkUtils;
36-
public final fun applyTo (Lapp/revanced/patcher/PatcherResult;Ljava/io/File;)V
36+
public final fun applyTo (Lapp/revanced/patcher/PatcherResult;Ljava/io/File;[Ljava/lang/String;)V
3737
public final fun newPrivateKeyCertificatePair (Lapp/revanced/library/ApkUtils$PrivateKeyCertificatePairDetails;Lapp/revanced/library/ApkUtils$KeyStoreDetails;)Lapp/revanced/library/ApkSigner$PrivateKeyCertificatePair;
3838
public final fun readPrivateKeyCertificatePairFromKeyStore (Lapp/revanced/library/ApkUtils$KeyStoreDetails;)Lapp/revanced/library/ApkSigner$PrivateKeyCertificatePair;
3939
public final fun sign (Ljava/io/File;Lapp/revanced/library/ApkUtils$SigningOptions;)V

src/main/kotlin/app/revanced/library/ApkUtils.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ object ApkUtils {
5050
*
5151
* @param apkFile The file to apply the patched files to.
5252
*/
53-
fun PatcherResult.applyTo(apkFile: File) {
53+
fun PatcherResult.applyTo(apkFile: File, ripLibs: Array<String> ) {
5454
ZFile.openReadWrite(apkFile, zFileOptions).use { targetApkZFile ->
5555
dexFiles.forEach { dexFile ->
5656
targetApkZFile.add(dexFile.name, dexFile.stream)
@@ -86,6 +86,10 @@ object ApkUtils {
8686
}.forEach(StoredEntry::delete)
8787
}
8888
}
89+
if (ripLibs.isNotEmpty()) {
90+
logger.info("Ripping selected native libs")
91+
targetApkZFile.entries().filter { entry -> ripLibs.any { entry.centralDirectoryHeader.name.startsWith("lib/$it/") } }.forEach(StoredEntry::delete)
92+
}
8993

9094
logger.info("Aligning APK")
9195

0 commit comments

Comments
 (0)