Update proguard to minimize APK size

This commit is contained in:
topjohnwu 2018-01-23 05:04:59 +08:00
parent 821726e7c0
commit 00d655f346
2 changed files with 17 additions and 3 deletions

4
proguard-rules.pro vendored
View File

@ -20,7 +20,9 @@
-keepnames class ** { *; }
# BouncyCastle
-keep class org.bouncycastle.jcajce.provider.** { *; }
-keep class org.bouncycastle.jcajce.provider.asymmetric.rsa.**SHA1** { *; }
-keep class org.bouncycastle.jcajce.provider.asymmetric.RSA** { *; }
-keep class org.bouncycastle.jcajce.provider.digest.SHA1** { *; }
-dontwarn javax.naming.**
# Gson

View File

@ -7,10 +7,12 @@ import com.topjohnwu.crypto.SignAPK;
import com.topjohnwu.magisk.MagiskManager;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@ -56,14 +58,24 @@ public class ZipUtils {
}
public static void signZip(InputStream is, File output, boolean minSign) throws Exception {
signZip(new JarMap(is, false), output, minSign);
try (JarMap map = new JarMap(is, false)) {
signZip(map, output, minSign);
}
}
public static void signZip(File input, File output, boolean minSign) throws Exception {
signZip(new JarMap(input, false), output, minSign);
try (JarMap map = new JarMap(input, false)) {
signZip(map, output, minSign);
}
}
public static void signZip(JarMap input, File output, boolean minSign) throws Exception {
try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(output))) {
signZip(input, out, minSign);
}
}
public static void signZip(JarMap input, OutputStream output, boolean minSign) throws Exception {
AssetManager assets = MagiskManager.get().getAssets();
SignAPK.signZip(
assets.open(Const.PUBLIC_KEY_NAME), assets.open(Const.PRIVATE_KEY_NAME),