You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Some refinements
This commit is contained in:
@@ -3,6 +3,8 @@ package com.topjohnwu.magisk.utils;
|
||||
import android.content.Context;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Utils.ByteArrayInOutStream;
|
||||
|
||||
import org.spongycastle.asn1.ASN1InputStream;
|
||||
import org.spongycastle.asn1.ASN1ObjectIdentifier;
|
||||
import org.spongycastle.asn1.DEROutputStream;
|
||||
@@ -81,6 +83,11 @@ public class ZipUtils {
|
||||
|
||||
public native static byte[] zipAdjust(byte[] bytes, int size);
|
||||
|
||||
// Wrapper function for the JNI function
|
||||
public static void adjustZip(ByteArrayInOutStream buffer) {
|
||||
buffer.setBuffer(zipAdjust(buffer.toByteArray(), buffer.size()));
|
||||
}
|
||||
|
||||
public static void removeTopFolder(InputStream in, OutputStream out) {
|
||||
try {
|
||||
JarInputStream source = new JarInputStream(in);
|
||||
@@ -482,7 +489,7 @@ public class ZipUtils {
|
||||
private static void copyFiles(Manifest manifest,
|
||||
JarMap in, JarOutputStream out, long timestamp) throws IOException {
|
||||
Map<String, Attributes> entries = manifest.getEntries();
|
||||
ArrayList<String> names = new ArrayList<String>(entries.keySet());
|
||||
ArrayList<String> names = new ArrayList<>(entries.keySet());
|
||||
Collections.sort(names);
|
||||
for (String name : names) {
|
||||
JarEntry inEntry = in.getJarEntry(name);
|
||||
@@ -588,10 +595,7 @@ public class ZipUtils {
|
||||
copyFiles(manifest, inputJar, outputJar, timestamp);
|
||||
// Don't add Otacert, it's not an OTA
|
||||
// addOtacert(outputJar, publicKeyFile, timestamp, manifest, hash);
|
||||
signFile(manifest, inputJar,
|
||||
publicKey,
|
||||
privateKey,
|
||||
outputJar);
|
||||
signFile(manifest, inputJar, publicKey, privateKey, outputJar);
|
||||
signer.notifyClosing();
|
||||
outputJar.close();
|
||||
signer.finish();
|
||||
|
||||
Reference in New Issue
Block a user