Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
teble committed Sep 25, 2022
1 parent a11dbe9 commit 5eaa396
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 135 deletions.
44 changes: 1 addition & 43 deletions Android/dexkit/src/main/cpp/native-bridge.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <jni.h>
#include <android/log.h>
#include <dex_kit.h>
#include "dex_kit.h"
#include "dex_kit_jni_helper.h"

#define TAG "DexKit"
Expand Down Expand Up @@ -30,27 +30,18 @@ extern "C"
JNIEXPORT void JNICALL
Java_io_luckypray_dexkit_DexKitBridge_nativeSetThreadNum(JNIEnv *env, jclass clazz,
jlong native_ptr, jint thread_num) {
if (!native_ptr) {
return;
}
SetThreadNum(env, native_ptr, thread_num);
}

DEXKIT_JNI jint
Java_io_luckypray_dexkit_DexKitBridge_nativeGetDexNum(JNIEnv *env, jclass clazz,
jlong native_ptr) {
if (!native_ptr) {
return 0;
}
return GetDexNum(env, native_ptr);
}

DEXKIT_JNI void
Java_io_luckypray_dexkit_DexKitBridge_nativeRelease(JNIEnv *env, jclass clazz,
jlong native_ptr) {
if (!native_ptr) {
return;
}
ReleaseDexKitInstance(env, native_ptr);
}

Expand All @@ -61,9 +52,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeBatchFindClassesUsingStrings(JNIEnv
jobject map,
jboolean advanced_match,
jintArray dex_priority) {
if (!native_ptr) {
return CMap2JMap(env, std::map<std::string, std::vector<std::string>>());
}
return BatchFindClassesUsingStrings(env, native_ptr, map, advanced_match, dex_priority);
}

Expand All @@ -74,9 +62,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeBatchFindMethodsUsingStrings(JNIEnv
jobject map,
jboolean advanced_match,
jintArray dex_priority) {
if (!native_ptr) {
return CMap2JMap(env, std::map<std::string, std::vector<std::string>>());
}
return BatchFindMethodsUsingStrings(env, native_ptr, map, advanced_match, dex_priority);
}

Expand All @@ -93,9 +78,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeFindMethodCaller(JNIEnv *env, jclass
jstring caller_method_return_type,
jobjectArray caller_method_param_types,
jintArray dex_priority) {
if (!native_ptr) {
return StrVec2JStrArr(env, std::vector<std::string>());
}
return FindMethodCaller(env, native_ptr, method_descriptor, method_declare_class,
method_declare_name, method_return_type, method_param_types,
caller_method_declare_class, caller_method_declare_name,
Expand All @@ -115,9 +97,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeFindMethodInvoking(JNIEnv *env, jcla
jstring be_called_method_return_type,
jobjectArray be_called_method_param_types,
jintArray dex_priority) {
if (!native_ptr) {
return CMap2JMap(env, std::map<std::string, std::vector<std::string>>());
}
return FindMethodInvoking(env, native_ptr, method_descriptor, method_declare_class,
method_declare_name, method_return_type, method_param_types,
be_called_method_declare_class, be_called_method_declare_name,
Expand All @@ -138,9 +117,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeFindMethodUsingField(JNIEnv *env, jc
jstring caller_method_return_type,
jobjectArray caller_method_param_types,
jintArray dex_priority) {
if (!native_ptr) {
return StrVec2JStrArr(env, std::vector<std::string>());
}
return FindMethodUsingField(env, native_ptr, field_descriptor, field_declare_class, field_name,
field_type, used_flags, caller_method_declare_class,
caller_method_name, caller_method_return_type,
Expand All @@ -157,9 +133,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeFindMethodUsingString(JNIEnv *env, j
jstring method_return_type,
jobjectArray method_param_types,
jintArray dex_priority) {
if (!native_ptr) {
return StrVec2JStrArr(env, std::vector<std::string>());
}
return FindMethodUsingString(env, native_ptr, used_string, advanced_match, method_declare_class,
method_name, method_return_type, method_param_types, dex_priority);
}
Expand All @@ -172,9 +145,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeFindMethod(JNIEnv *env, jclass clazz
jstring method_return_type,
jobjectArray method_param_types,
jintArray dex_priority) {
if (!native_ptr) {
return StrVec2JStrArr(env, std::vector<std::string>());
}
return FindMethod(env, native_ptr, method_declare_class, method_name, method_return_type,
method_param_types, dex_priority);
}
Expand All @@ -184,9 +154,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeFindSubClasses(JNIEnv *env, jclass c
jlong native_ptr,
jstring parent_class,
jintArray dex_priority) {
if (!native_ptr) {
return StrVec2JStrArr(env, std::vector<std::string>());
}
return FindSubClasses(env, native_ptr, parent_class, dex_priority);
}

Expand All @@ -199,9 +166,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeFindMethodOpPrefixSeq(JNIEnv *env, j
jstring method_return_type,
jobjectArray method_param_types,
jintArray dex_priority) {
if (!native_ptr) {
return StrVec2JStrArr(env, std::vector<std::string>());
}
return FindMethodOpPrefixSeq(env, native_ptr, op_prefix_seq, method_declare_class, method_name,
method_return_type, method_param_types, dex_priority);
}
Expand All @@ -216,9 +180,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeFindMethodUsingOpCodeSeq(JNIEnv *env
jstring method_return_type,
jobjectArray method_param_types,
jintArray dex_priority) {
if (!native_ptr) {
return StrVec2JStrArr(env, std::vector<std::string>());
}
return FindMethodUsingOpCodeSeq(env, native_ptr, op_seq, method_declare_class, method_name,
method_return_type, method_param_types, dex_priority);
}
Expand All @@ -233,9 +194,6 @@ Java_io_luckypray_dexkit_DexKitBridge_nativeGetMethodOpCodeSeq(JNIEnv *env, jcla
jstring method_return_type,
jobjectArray method_param_types,
jintArray dex_priority) {
if (!native_ptr) {
return EmptyJMap(env);
}
return GetMethodOpCodeSeq(env, native_ptr, method_descriptor, method_declare_class, method_name,
method_return_type, method_param_types, dex_priority);
}
Loading

0 comments on commit 5eaa396

Please sign in to comment.