diff --git a/black-shadow/src/main/java/top/niunaijun/shadow/BlackShadow.java b/black-shadow/src/main/java/top/niunaijun/shadow/BlackShadow.java index 9c06189..4772189 100644 --- a/black-shadow/src/main/java/top/niunaijun/shadow/BlackShadow.java +++ b/black-shadow/src/main/java/top/niunaijun/shadow/BlackShadow.java @@ -54,6 +54,10 @@ public static Context getContext() { return get().mContext; } + public static String getHostPackageName() { + return get().mContext.getPackageName(); + } + public static boolean isHostProcess() { return get().mProcessType == ProcessType.Host; } diff --git a/black-shadow/src/main/java/top/niunaijun/shadow/service/BSManagerService.java b/black-shadow/src/main/java/top/niunaijun/shadow/service/BSManagerService.java index a751e92..28708d3 100644 --- a/black-shadow/src/main/java/top/niunaijun/shadow/service/BSManagerService.java +++ b/black-shadow/src/main/java/top/niunaijun/shadow/service/BSManagerService.java @@ -16,6 +16,7 @@ import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -91,8 +92,16 @@ public InstallResult installPlugin(String pluginKey, String pluginPath, String[] // 复制so文件 NativeUtils.copyNativeLib(new File(pluginPath), BSFileManager.get().getPluginLibsDir(pluginKey, version)); + List allHostWhiteList = new ArrayList<>(); + if (hostWhiteList != null) { + allHostWhiteList.addAll(Arrays.asList(hostWhiteList)); + } + allHostWhiteList.add("top.niunaijun.shadow"); + allHostWhiteList.add("top.niunaijun.shadow.*"); + allHostWhiteList.add("top.niunaijun.shadow.**"); + LoadParameters loadParameters = new LoadParameters(null, pluginKey, null, - hostWhiteList); + allHostWhiteList.toArray(new String[0])); Parcel parcel = Parcel.obtain(); loadParameters.writeToParcel(parcel, 0); InstalledApk installedApk = installPlugin(pluginKey, pluginApk, version);