diff --git a/client/android/pm3_main.c b/client/android/pm3_main.c index 6855856ab..b1e388cce 100644 --- a/client/android/pm3_main.c +++ b/client/android/pm3_main.c @@ -53,6 +53,14 @@ const char *get_my_executable_path(void) { } const char *get_my_executable_directory(void) { + if (my_executable_directory != NULL) free(my_executable_directory); + char buf[1024]; + // get current work directory + getcwd(buf, sizeof(buf)); + // add / to end. + sprintf(buf, "%s%s", buf, PATHSEP); + // create on global + my_executable_directory = strdup(buf); return my_executable_directory; } @@ -95,7 +103,7 @@ jint sendCMD(JNIEnv *env, jobject instance, jstring cmd_) { } // display on new line PrintAndLogEx(NORMAL, "\n"); - char *cmd = (char *)((*env)->GetStringUTFChars(env, cmd_, 0)); + char *cmd = (char *) ((*env)->GetStringUTFChars(env, cmd_, 0)); int ret = CommandReceived(cmd); if (ret == 99) { // exit / quit @@ -110,7 +118,7 @@ jint sendCMD(JNIEnv *env, jobject instance, jstring cmd_) { * Is client running! * */ jboolean isExecuting(JNIEnv *env, jobject instance) { - return (jboolean)((jboolean) conn.run); + return (jboolean) ((jboolean) conn.run); } /* @@ -123,7 +131,7 @@ jboolean testPm3(JNIEnv *env, jobject instance) { return false; } bool ret2 = TestProxmark() == PM3_SUCCESS; - return (jboolean)(ret1 && ret2); + return (jboolean) (ret1 && ret2); } /* @@ -148,21 +156,21 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) { } jclass clz_test = (*jniEnv)->FindClass(jniEnv, "cn/rrg/devices/Proxmark3RRGRdv4"); JNINativeMethod methods[] = { - {"startExecute", "(Ljava/lang/String;)I", (void *) sendCMD}, - {"stopExecute", "()V", (void *) stopPm3}, - {"isExecuting", "()Z", (void *) isExecuting} + {"startExecute", "(Ljava/lang/String;)I", (void *) sendCMD}, + {"stopExecute", "()V", (void *) stopPm3}, + {"isExecuting", "()Z", (void *) isExecuting} }; JNINativeMethod methods1[] = { - {"testPm3", "()Z", (void *) testPm3}, - {"closePm3", "()V", stopPm3} + {"testPm3", "()Z", (void *) testPm3}, + {"closePm3", "()V", stopPm3} }; if ((*jniEnv)->RegisterNatives(jniEnv, clazz, methods, sizeof(methods) / sizeof(methods[0])) != - JNI_OK) { + JNI_OK) { return -1; } if ((*jniEnv)->RegisterNatives(jniEnv, clz_test, methods1, sizeof(methods1) / sizeof(methods1[0])) != - JNI_OK) { + JNI_OK) { return -1; } (*jniEnv)->DeleteLocalRef(jniEnv, clazz);