diff --git a/Bcore/src/main/java/top/niunaijun/blackbox/BlackBoxCore.java b/Bcore/src/main/java/top/niunaijun/blackbox/BlackBoxCore.java index b0a5a72..2c22ea1 100644 --- a/Bcore/src/main/java/top/niunaijun/blackbox/BlackBoxCore.java +++ b/Bcore/src/main/java/top/niunaijun/blackbox/BlackBoxCore.java @@ -243,6 +243,11 @@ public class BlackBoxCore extends ClientConfiguration { return mClientConfiguration.isFixCodeItem(); } + @Override + public boolean isEnableHookDump() { + return mClientConfiguration.isEnableHookDump(); + } + private void startLogcat() { File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), getContext().getPackageName() + "_logcat.txt"); FileUtils.deleteDir(file); diff --git a/Bcore/src/main/java/top/niunaijun/blackbox/app/configuration/ClientConfiguration.java b/Bcore/src/main/java/top/niunaijun/blackbox/app/configuration/ClientConfiguration.java index 8dfd5a1..367cfce 100644 --- a/Bcore/src/main/java/top/niunaijun/blackbox/app/configuration/ClientConfiguration.java +++ b/Bcore/src/main/java/top/niunaijun/blackbox/app/configuration/ClientConfiguration.java @@ -31,4 +31,8 @@ public abstract class ClientConfiguration { public boolean isFixCodeItem() { return false; } + + public boolean isEnableHookDump() { + return true; + } } diff --git a/Bcore/src/main/java/top/niunaijun/blackbox/fake/delegate/AppInstrumentation.java b/Bcore/src/main/java/top/niunaijun/blackbox/fake/delegate/AppInstrumentation.java index 548ecca..39fa03f 100644 --- a/Bcore/src/main/java/top/niunaijun/blackbox/fake/delegate/AppInstrumentation.java +++ b/Bcore/src/main/java/top/niunaijun/blackbox/fake/delegate/AppInstrumentation.java @@ -100,15 +100,17 @@ public final class AppInstrumentation extends BaseInstrumentationDelegate implem @Override public Application newApplication(ClassLoader cl, String className, Context context) throws InstantiationException, IllegalAccessException, ClassNotFoundException { ContextCompat.fix(context); - String absolutePath = new File(BlackBoxCore.get().getDexDumpDir(), context.getPackageName()).getAbsolutePath(); - FileUtils.mkdirs(absolutePath); - Class aClass = cl.loadClass(VMCore.class.getName()); - try { - Method initDumpDex = aClass.getDeclaredMethod("hookDumpDex", String.class); - initDumpDex.setAccessible(true); - initDumpDex.invoke(null, absolutePath); - } catch (Throwable e) { - e.printStackTrace(); + if (BlackBoxCore.get().isEnableHookDump()) { + String absolutePath = new File(BlackBoxCore.get().getDexDumpDir(), context.getPackageName()).getAbsolutePath(); + FileUtils.mkdirs(absolutePath); + Class aClass = cl.loadClass(VMCore.class.getName()); + try { + Method initDumpDex = aClass.getDeclaredMethod("hookDumpDex", String.class); + initDumpDex.setAccessible(true); + initDumpDex.invoke(null, absolutePath); + } catch (Throwable e) { + e.printStackTrace(); + } } return super.newApplication(cl, className, context); }