capacitor-dex-editor 0.0.62 → 0.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,13 +9,16 @@ buildscript {
9
9
  repositories {
10
10
  google()
11
11
  mavenCentral()
12
+ maven { url "https://plugins.gradle.org/m2/" }
12
13
  }
13
14
  dependencies {
14
15
  classpath 'com.android.tools.build:gradle:8.7.2'
16
+ classpath 'org.mozilla.rust-android-gradle:plugin:0.9.6'
15
17
  }
16
18
  }
17
19
 
18
20
  apply plugin: 'com.android.library'
21
+ apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
19
22
 
20
23
  android {
21
24
  namespace "com.aetherlink.dexeditor"
@@ -72,3 +75,18 @@ dependencies {
72
75
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
73
76
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
74
77
  }
78
+
79
+ // Rust 编译配置
80
+ cargo {
81
+ module = "../rust"
82
+ libname = "dex_rust"
83
+ targets = ["arm", "arm64", "x86", "x86_64"]
84
+ profile = "release"
85
+ }
86
+
87
+ // 将 Rust 编译任务添加到构建流程
88
+ tasks.configureEach { task ->
89
+ if ((task.name == 'javaPreCompileDebug' || task.name == 'javaPreCompileRelease')) {
90
+ task.dependsOn 'cargoBuild'
91
+ }
92
+ }
@@ -1759,6 +1759,7 @@ public class DexManager {
1759
1759
 
1760
1760
  /**
1761
1761
  * 在多 DEX 会话中搜索
1762
+ * 优先使用 Rust 实现,如果不可用则回退到 Java 实现
1762
1763
  */
1763
1764
  public JSObject searchInMultiSession(String sessionId, String query, String searchType,
1764
1765
  boolean caseSensitive, int maxResults) throws Exception {
@@ -1767,6 +1768,10 @@ public class DexManager {
1767
1768
  throw new IllegalArgumentException("Session not found: " + sessionId);
1768
1769
  }
1769
1770
 
1771
+ // 尝试使用 Rust 实现(仅对 string/code 搜索有显著提升)
1772
+ // 目前 Rust 实现需要 DEX 字节数据,暂时禁用
1773
+ // TODO: 实现 Rust 加速搜索
1774
+
1770
1775
  JSObject result = new JSObject();
1771
1776
  JSArray results = new JSArray();
1772
1777
  String queryMatch = caseSensitive ? query : query.toLowerCase();
@@ -0,0 +1,86 @@
1
+ package com.aetherlink.dexeditor;
2
+
3
+ import android.util.Log;
4
+
5
+ /**
6
+ * RustDex - Rust 实现的 DEX 解析器 JNI 接口
7
+ * 使用 azw413/smali crate 实现高性能 DEX 搜索
8
+ */
9
+ public class RustDex {
10
+ private static final String TAG = "RustDex";
11
+ private static boolean libraryLoaded = false;
12
+
13
+ static {
14
+ try {
15
+ System.loadLibrary("dex_rust");
16
+ libraryLoaded = true;
17
+ Log.d(TAG, "Rust library loaded successfully");
18
+ } catch (UnsatisfiedLinkError e) {
19
+ Log.w(TAG, "Failed to load Rust library: " + e.getMessage());
20
+ libraryLoaded = false;
21
+ }
22
+ }
23
+
24
+ /**
25
+ * 检查 Rust 库是否可用
26
+ */
27
+ public static boolean isAvailable() {
28
+ return libraryLoaded;
29
+ }
30
+
31
+ /**
32
+ * 在 DEX 中搜索
33
+ * @param dexBytes DEX 文件字节数组
34
+ * @param query 搜索查询
35
+ * @param searchType 搜索类型: class, method, field, string, code
36
+ * @param caseSensitive 是否区分大小写
37
+ * @param maxResults 最大结果数
38
+ * @return JSON 格式的搜索结果
39
+ */
40
+ public static native String searchInDex(
41
+ byte[] dexBytes,
42
+ String query,
43
+ String searchType,
44
+ boolean caseSensitive,
45
+ int maxResults
46
+ );
47
+
48
+ /**
49
+ * 列出 DEX 中的类
50
+ * @param dexBytes DEX 文件字节数组
51
+ * @param packageFilter 包名过滤器
52
+ * @param offset 偏移量
53
+ * @param limit 限制数量
54
+ * @return JSON 格式的类列表
55
+ */
56
+ public static native String listClasses(
57
+ byte[] dexBytes,
58
+ String packageFilter,
59
+ int offset,
60
+ int limit
61
+ );
62
+
63
+ /**
64
+ * 获取类的 Smali 代码
65
+ * @param dexBytes DEX 文件字节数组
66
+ * @param className 类名
67
+ * @return JSON 格式的 Smali 代码
68
+ */
69
+ public static native String getClassSmali(
70
+ byte[] dexBytes,
71
+ String className
72
+ );
73
+
74
+ /**
75
+ * Java 回退实现 - 当 Rust 库不可用时使用
76
+ */
77
+ public static String searchInDexFallback(
78
+ byte[] dexBytes,
79
+ String query,
80
+ String searchType,
81
+ boolean caseSensitive,
82
+ int maxResults
83
+ ) {
84
+ return "{\"error\": \"Rust library not available, using Java implementation\", \"fallback\": true}";
85
+ }
86
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-dex-editor",
3
- "version": "0.0.62",
3
+ "version": "0.0.63",
4
4
  "description": "Capacitor-plugin-for-editing-DEX-files-in-APK",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",