Skip to content

Commit aebd794

Browse files
authored
Merge pull request WindySha#10 from luoyesiqiu/master
Modify the so library copy logic.
2 parents 4806b02 + 62769e1 commit aebd794

File tree

1 file changed

+10
-31
lines changed

1 file changed

+10
-31
lines changed

xpatch/src/main/java/com/storm/wind/xpatch/task/SoAndDexCopyTask.java

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ public void run() {
4949
}
5050

5151
private void copySoFile() {
52-
String apkSoLibPath = findTargetLibPath();
53-
String apkSoFullPath = fullLibPath(apkSoLibPath);
54-
55-
copyLibFile(apkSoFullPath, SO_FILE_PATH_MAP.get(apkSoLibPath));
56-
52+
for (String libPath : APK_LIB_PATH_ARRAY) {
53+
String apkSoFullPath = fullLibPath(libPath);
54+
copyLibFile(apkSoFullPath, SO_FILE_PATH_MAP.get(libPath));
55+
}
5756
// copy xposed modules into the lib path
5857
if (xposedModuleArray != null && xposedModuleArray.length > 0) {
5958
int index = 0;
@@ -66,8 +65,12 @@ private void copySoFile() {
6665
if (!moduleFile.exists()) {
6766
continue;
6867
}
69-
String outputModuleFile = XPOSED_MODULE_FILE_NAME_PREFIX + index + SO_FILE_SUFFIX;
70-
FileUtils.copyFile(moduleFile, new File(apkSoFullPath, outputModuleFile));
68+
for (String libPath : APK_LIB_PATH_ARRAY) {
69+
String apkSoFullPath = fullLibPath(libPath);
70+
String outputModuleFile = XPOSED_MODULE_FILE_NAME_PREFIX + index + SO_FILE_SUFFIX;
71+
72+
FileUtils.copyFile(moduleFile, new File(apkSoFullPath, outputModuleFile));
73+
}
7174
index++;
7275
}
7376
}
@@ -99,31 +102,7 @@ private void copyLibFile(String libFilePath, String srcSoPath) {
99102
FileUtils.copyFileFromJar(srcSoPath, new File(apkSoParentFile, soFileName).getAbsolutePath());
100103
}
101104

102-
// Try to find the lib path where the so file should put.
103-
// If there is many lib path, try to find the path which has the most so files
104-
private String findTargetLibPath() {
105-
int maxChildFileCount = 0;
106-
int maxChildFileIndex = 0;
107-
int index = 0;
108-
for (String libPath : APK_LIB_PATH_ARRAY) {
109-
String fullPath = fullLibPath(libPath);
110-
File file = new File(fullPath);
111-
if (file.exists()) {
112-
String[] childList = file.list();
113-
int childCount = 0;
114-
if (childList != null) {
115-
childCount = childList.length;
116-
}
117-
if (childCount > maxChildFileCount) {
118-
maxChildFileCount = childCount;
119-
maxChildFileIndex = index;
120-
}
121-
}
122-
index++;
123-
}
124105

125-
return APK_LIB_PATH_ARRAY[maxChildFileIndex];
126-
}
127106

128107
private void deleteMetaInfo() {
129108
String metaInfoFilePath = "META-INF";

0 commit comments

Comments
 (0)