Commit 19af5f9e authored by topjohnwu's avatar topjohnwu

Remove JNI; use native Java zipadjust

parent f37f3306
......@@ -10,10 +10,6 @@ android {
targetSdkVersion 27
versionCode 91
versionName "5.5.5"
ndk {
moduleName 'zipadjust'
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
}
javaCompileOptions {
annotationProcessorOptions {
argument('butterknife.debuggable', 'false')
......@@ -36,11 +32,6 @@ android {
preDexLibraries true
javaMaxHeapSize "2g"
}
externalNativeBuild {
cmake {
path 'src/main/jni/CMakeLists.txt'
}
}
lintOptions {
disable 'MissingTranslation'
}
......
......@@ -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();
......
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);
}
}
cmake_minimum_required(VERSION 3.6)
add_library(zipadjust SHARED
jni_glue.c
zipadjust.c)
find_library(libz z)
find_library(liblog log)
target_link_libraries(zipadjust ${libz} ${liblog})
//
// Java entry point
//
#include <jni.h>
#include "zipadjust.h"
JNIEXPORT void JNICALL
Java_com_topjohnwu_magisk_utils_ZipUtils_zipAdjust(JNIEnv *env, jclass type, jstring filenameIn_,
jstring filenameOut_) {
const char *filenameIn = (*env)->GetStringUTFChars(env, filenameIn_, 0);
const char *filenameOut = (*env)->GetStringUTFChars(env, filenameOut_, 0);
// TODO
zipadjust(filenameIn, filenameOut, 0);
(*env)->ReleaseStringUTFChars(env, filenameIn_, filenameIn);
(*env)->ReleaseStringUTFChars(env, filenameOut_, filenameOut);
}
\ No newline at end of file
This diff is collapsed.
#ifndef MAGISKMANAGER_ZIPADJUST_H_H
#define MAGISKMANAGER_ZIPADJUST_H_H
#include <android/log.h>
int zipadjust(const char* filenameIn, const char* filenameOut, int decompress);
#define LOG_TAG "zipadjust"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#endif //MAGISKMANAGER_ZIPADJUST_H_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment