|
41 | 41 | import android.content.pm.Signature;
|
42 | 42 | import android.net.Uri;
|
43 | 43 | import android.os.Binder;
|
44 |
| -import android.os.Build; |
45 | 44 | import android.os.Build.VERSION;
|
46 | 45 | import android.os.Build.VERSION_CODES;
|
47 | 46 | import android.os.RemoteException;
|
|
54 | 53 | import com.morgoo.droidplugin.pm.parser.IntentMatcher;
|
55 | 54 | import com.morgoo.droidplugin.pm.parser.PluginPackageParser;
|
56 | 55 | import com.morgoo.helper.Log;
|
57 |
| -import com.morgoo.helper.compat.PackageManagerCompat; |
58 | 56 | import com.morgoo.helper.Utils;
|
| 57 | +import com.morgoo.helper.compat.BuildCompat; |
| 58 | +import com.morgoo.helper.compat.PackageManagerCompat; |
| 59 | +import com.morgoo.helper.compat.VMRuntimeCompat; |
59 | 60 |
|
60 | 61 | import java.io.File;
|
61 | 62 | import java.io.FileOutputStream;
|
@@ -1009,9 +1010,9 @@ private void copyNativeLibs(Context context, String apkfile, ApplicationInfo app
|
1009 | 1010 | }
|
1010 | 1011 |
|
1011 | 1012 | for (String soName : soList.keySet()) {
|
1012 |
| - Log.e(TAG, "==========so name=" + soName); |
| 1013 | + Log.e(TAG, "try so =" + soName); |
1013 | 1014 | Set<String> soPaths = soList.get(soName);
|
1014 |
| - String soPath = findSoPath(soPaths); |
| 1015 | + String soPath = findSoPath(soPaths, soName); |
1015 | 1016 | if (soPath != null) {
|
1016 | 1017 | File file = new File(nativeLibraryDir, soName);
|
1017 | 1018 | if (file.exists()) {
|
@@ -1061,17 +1062,26 @@ private void copyNativeLibs(Context context, String apkfile, ApplicationInfo app
|
1061 | 1062 | }
|
1062 | 1063 | }
|
1063 | 1064 |
|
1064 |
| - private String findSoPath(Set<String> soPaths) { |
| 1065 | + |
| 1066 | + private String findSoPath(Set<String> soPaths, String soName) { |
1065 | 1067 | if (soPaths != null && soPaths.size() > 0) {
|
1066 |
| - for (String soPath : soPaths) { |
1067 |
| - if (!TextUtils.isEmpty(Build.CPU_ABI) && soPath.contains(Build.CPU_ABI)) { |
1068 |
| - return soPath; |
| 1068 | + if (VMRuntimeCompat.is64Bit()) { |
| 1069 | + //在宿主程序运行在64位进程中的时候,插件的so也只拷贝64位,否则会出现不支持的情况。 |
| 1070 | + for (String soPath : soPaths) { |
| 1071 | + String abi = soPath.replaceFirst("lib/", ""); |
| 1072 | + abi = abi.replace("/" + soName, ""); |
| 1073 | + if (!TextUtils.isEmpty(abi) && Arrays.binarySearch(BuildCompat.SUPPORTED_64_BIT_ABIS, abi) >= 0) { |
| 1074 | + return soPath; |
| 1075 | + } |
1069 | 1076 | }
|
1070 |
| - } |
1071 |
| - |
1072 |
| - for (String soPath : soPaths) { |
1073 |
| - if (!TextUtils.isEmpty(Build.CPU_ABI2) && soPath.contains(Build.CPU_ABI2)) { |
1074 |
| - return soPath; |
| 1077 | + } else { |
| 1078 | + //在宿主程序运行在32位进程中的时候,插件的so也只拷贝64位,否则会出现不支持的情况。 |
| 1079 | + for (String soPath : soPaths) { |
| 1080 | + String abi = soPath.replaceFirst("lib/", ""); |
| 1081 | + abi = abi.replace("/" + soName, ""); |
| 1082 | + if (!TextUtils.isEmpty(abi) && Arrays.binarySearch(BuildCompat.SUPPORTED_32_BIT_ABIS, abi) >= 0) { |
| 1083 | + return soPath; |
| 1084 | + } |
1075 | 1085 | }
|
1076 | 1086 | }
|
1077 | 1087 | }
|
@@ -1347,12 +1357,12 @@ public void onDestroy() {
|
1347 | 1357 | }
|
1348 | 1358 |
|
1349 | 1359 | @Override
|
1350 |
| - public void onActivtyOnNewIntent(ActivityInfo stubInfo, ActivityInfo targetInfo, Intent intent) throws RemoteException{ |
| 1360 | + public void onActivtyOnNewIntent(ActivityInfo stubInfo, ActivityInfo targetInfo, Intent intent) throws RemoteException { |
1351 | 1361 | mActivityManagerService.onActivtyOnNewIntent(Binder.getCallingPid(), Binder.getCallingUid(), stubInfo, targetInfo, intent);
|
1352 | 1362 | }
|
1353 | 1363 |
|
1354 | 1364 | @Override
|
1355 |
| - public int getMyPid(){ |
| 1365 | + public int getMyPid() { |
1356 | 1366 | return android.os.Process.myPid();
|
1357 | 1367 | }
|
1358 | 1368 |
|
|
0 commit comments