capacitor-dex-editor 0.0.60 → 0.0.62
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.
|
@@ -151,6 +151,13 @@ public class DexManager {
|
|
|
151
151
|
String apkPath;
|
|
152
152
|
Map<String, DexBackedDexFile> dexFiles;
|
|
153
153
|
Map<String, ClassDef> modifiedClasses;
|
|
154
|
+
// 使用 LRU 缓存限制内存,最多缓存 200 个类
|
|
155
|
+
Map<String, String> smaliCache = new java.util.LinkedHashMap<String, String>(200, 0.75f, true) {
|
|
156
|
+
@Override
|
|
157
|
+
protected boolean removeEldestEntry(Map.Entry<String, String> eldest) {
|
|
158
|
+
return size() > 200;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
154
161
|
boolean modified = false;
|
|
155
162
|
|
|
156
163
|
MultiDexSession(String sessionId, String apkPath) {
|
|
@@ -1830,8 +1837,8 @@ public class DexManager {
|
|
|
1830
1837
|
|
|
1831
1838
|
case "string":
|
|
1832
1839
|
case "code":
|
|
1833
|
-
//
|
|
1834
|
-
String smali =
|
|
1840
|
+
// 使用缓存的 smali 搜索
|
|
1841
|
+
String smali = getCachedSmali(session, className, dexFile, classDef);
|
|
1835
1842
|
String smaliMatch = caseSensitive ? smali : smali.toLowerCase();
|
|
1836
1843
|
if (smaliMatch.contains(queryMatch)) {
|
|
1837
1844
|
JSObject item = new JSObject();
|
|
@@ -1853,8 +1860,8 @@ public class DexManager {
|
|
|
1853
1860
|
break;
|
|
1854
1861
|
|
|
1855
1862
|
case "int":
|
|
1856
|
-
//
|
|
1857
|
-
String smaliForInt =
|
|
1863
|
+
// 搜索整数常量(使用缓存)
|
|
1864
|
+
String smaliForInt = getCachedSmali(session, className, dexFile, classDef);
|
|
1858
1865
|
if (smaliForInt.contains("0x" + query) || smaliForInt.contains(" " + query + "\n") ||
|
|
1859
1866
|
smaliForInt.contains(" " + query + " ")) {
|
|
1860
1867
|
JSObject item = new JSObject();
|
|
@@ -1893,6 +1900,21 @@ public class DexManager {
|
|
|
1893
1900
|
}
|
|
1894
1901
|
}
|
|
1895
1902
|
|
|
1903
|
+
/**
|
|
1904
|
+
* 获取缓存的 Smali 代码(用于搜索优化)
|
|
1905
|
+
*/
|
|
1906
|
+
private String getCachedSmali(MultiDexSession session, String className, DexBackedDexFile dexFile, ClassDef classDef) {
|
|
1907
|
+
// 先查缓存
|
|
1908
|
+
String cached = session.smaliCache.get(className);
|
|
1909
|
+
if (cached != null) {
|
|
1910
|
+
return cached;
|
|
1911
|
+
}
|
|
1912
|
+
// 缓存未命中,反编译并缓存
|
|
1913
|
+
String smali = getSmaliForClass(dexFile, classDef);
|
|
1914
|
+
session.smaliCache.put(className, smali);
|
|
1915
|
+
return smali;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1896
1918
|
/**
|
|
1897
1919
|
* 从多 DEX 会话获取类的 Smali 代码
|
|
1898
1920
|
*/
|