You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Remove JNI; use native Java zipadjust
This commit is contained in:
@@ -96,7 +96,7 @@ public class FlashActivity extends Activity {
|
||||
reboot.setVisibility(View.GONE);
|
||||
|
||||
logs = new ArrayList<>();
|
||||
CallbackList console = new CallbackList<String>(new ArrayList<>()) {
|
||||
CallbackList<String> console = new CallbackList<String>(new ArrayList<>()) {
|
||||
@Override
|
||||
public void onAddElement(String s) {
|
||||
logs.add(s);
|
||||
|
||||
@@ -123,7 +123,7 @@ public class HideManager extends ParallelTask<Void, Void, Boolean> {
|
||||
apk.getOutputStream(je).write(xml);
|
||||
|
||||
// Sign the APK
|
||||
ZipUtils.signZip(apk, repack, false);
|
||||
ZipUtils.signZip(apk, repack);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
|
||||
@@ -120,14 +120,8 @@ public class ProcessRepoZip extends ParallelTask<Void, Object, Boolean> {
|
||||
// First remove top folder in Github source zip, temp1 -> temp2
|
||||
removeTopFolder(temp1, temp2);
|
||||
|
||||
// Then sign the zip for the first time, temp2 -> temp1
|
||||
ZipUtils.signZip(temp2, temp1, false);
|
||||
|
||||
// Adjust the zip to prevent unzip issues, temp1 -> temp2
|
||||
ZipUtils.zipAdjust(temp1.getPath(), temp2.getPath());
|
||||
|
||||
// Finally, sign the whole zip file again, temp2 -> target
|
||||
ZipUtils.signZip(temp2, mFile, true);
|
||||
// Then sign the zip
|
||||
ZipUtils.signZip(temp2, mFile);
|
||||
|
||||
// Delete temp files
|
||||
temp1.delete();
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.topjohnwu.magisk.utils;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
import com.topjohnwu.crypto.JarMap;
|
||||
import com.topjohnwu.crypto.SignAPK;
|
||||
import com.topjohnwu.magisk.MagiskManager;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
@@ -18,12 +15,6 @@ import java.util.zip.ZipInputStream;
|
||||
|
||||
public class ZipUtils {
|
||||
|
||||
static {
|
||||
System.loadLibrary("zipadjust");
|
||||
}
|
||||
|
||||
public native static void zipAdjust(String filenameIn, String filenameOut);
|
||||
|
||||
public static void unzip(File zip, File folder, String path, boolean junkPath) throws Exception {
|
||||
InputStream in = new BufferedInputStream(new FileInputStream(zip));
|
||||
unzip(in, folder, path, junkPath);
|
||||
@@ -57,25 +48,25 @@ public class ZipUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void signZip(InputStream is, File output, boolean minSign) throws Exception {
|
||||
public static void signZip(InputStream is, File output) throws Exception {
|
||||
try (JarMap map = new JarMap(is, false)) {
|
||||
signZip(map, output, minSign);
|
||||
signZip(map, output);
|
||||
}
|
||||
}
|
||||
|
||||
public static void signZip(File input, File output, boolean minSign) throws Exception {
|
||||
public static void signZip(File input, File output) throws Exception {
|
||||
try (JarMap map = new JarMap(input, false)) {
|
||||
signZip(map, output, minSign);
|
||||
signZip(map, output);
|
||||
}
|
||||
}
|
||||
|
||||
public static void signZip(JarMap input, File output, boolean minSign) throws Exception {
|
||||
public static void signZip(JarMap input, File output) throws Exception {
|
||||
try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(output))) {
|
||||
signZip(input, out, minSign);
|
||||
signZip(input, out);
|
||||
}
|
||||
}
|
||||
|
||||
public static void signZip(JarMap input, OutputStream output, boolean minSign) throws Exception {
|
||||
SignAPK.signZip(null, null, input, output, minSign);
|
||||
public static void signZip(JarMap input, OutputStream output) throws Exception {
|
||||
SignAPK.signZip(null, null, input, output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user