From d36910ac190d412b5e06ac5eb256054aa609b239 Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Sun, 5 Sep 2021 14:36:03 +0200 Subject: [PATCH] Fix proguard rules --- app/proguard-rules.pro | 8 ++++---- .../sushi/hardcore/droidfs/explorers/ExplorerElement.kt | 6 ++++++ app/src/main/native/gocryptfs_jni.c | 7 ++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index af15bf1..3407e44 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -20,8 +20,8 @@ # hide the original source file name. #-renamesourcefileattribute SourceFile --keepattributes InnerClasses --keep class sushi.hardcore.droidfs.SettingsActivity$** { - *; +-keep class sushi.hardcore.droidfs.SettingsActivity$** +-keep class sushi.hardcore.droidfs.explorers.ExplorerElement +-keepclassmembers class sushi.hardcore.droidfs.explorers.ExplorerElement { + static sushi.hardcore.droidfs.explorers.ExplorerElement new(...); } --keep class sushi.hardcore.droidfs.explorers.ExplorerElement \ No newline at end of file diff --git a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerElement.kt b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerElement.kt index 27e3d7c..0a81d9d 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerElement.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/explorers/ExplorerElement.kt @@ -17,6 +17,12 @@ class ExplorerElement(val name: String, val elementType: Short, var size: Long = get() = elementType.toInt() == 1 companion object { + @JvmStatic + //this function is needed because I had some problems calling the constructor from JNI, probably due to arguments with default values + fun new(name: String, elementType: Short, size: Long, mTime: Long, parentPath: String): ExplorerElement { + return ExplorerElement(name, elementType, size, mTime, parentPath) + } + private fun foldersFirst(a: ExplorerElement, b: ExplorerElement, default: () -> Int): Int { return if (a.isDirectory && b.isRegularFile) { -1 diff --git a/app/src/main/native/gocryptfs_jni.c b/app/src/main/native/gocryptfs_jni.c index 8b1463e..13d8e52 100644 --- a/app/src/main/native/gocryptfs_jni.c +++ b/app/src/main/native/gocryptfs_jni.c @@ -3,7 +3,6 @@ #include #include #include -#include #include "libgocryptfs.h" void wipe(char* data, const unsigned int len){ @@ -234,8 +233,7 @@ Java_sushi_hardcore_droidfs_GocryptfsVolume_native_1list_1dir(JNIEnv *env, jobje jmethodID java_ArrayList_add = (*env)->GetMethodID(env, java_ArrayList, "add", "(Ljava/lang/Object;)Z"); jclass classExplorerElement = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "sushi/hardcore/droidfs/explorers/ExplorerElement")); - jmethodID classExplorerElement_init = (*env)->GetMethodID(env, classExplorerElement, "", "(Ljava/lang/String;SJJLjava/lang/String;)V"); - + jmethodID explorerElement_new = (*env)->GetStaticMethodID(env, classExplorerElement, "new", "(Ljava/lang/String;SJJLjava/lang/String;)Lsushi/hardcore/droidfs/explorers/ExplorerElement;"); jobject element_list = (*env)->NewObject(env, java_ArrayList, java_ArrayList_init, elements.r2); unsigned int c = 0; for (unsigned int i=0; iNewStringUTF(env, name); - jobject explorerElement = (*env)->NewObject(env, classExplorerElement, classExplorerElement_init, jname, type, (long long)attrs.r0, attrs.r1, jplain_dir); - (*env)->CallBooleanMethod(env, element_list, java_ArrayList_add, explorerElement); + jobject explorerElement = (*env)->CallStaticObjectMethod(env, classExplorerElement, explorerElement_new, jname, type, (long long)attrs.r0, attrs.r1, jplain_dir);(*env)->CallBooleanMethod(env, element_list, java_ArrayList_add, explorerElement); c += name_len+1; }