support switch hookDump

pull/27/head
Milk 3 years ago
parent 5f12474fa4
commit 05ccd24c72
  1. 5
      Bcore/src/main/java/top/niunaijun/blackbox/BlackBoxCore.java
  2. 4
      Bcore/src/main/java/top/niunaijun/blackbox/app/configuration/ClientConfiguration.java
  3. 2
      Bcore/src/main/java/top/niunaijun/blackbox/fake/delegate/AppInstrumentation.java

@ -243,6 +243,11 @@ public class BlackBoxCore extends ClientConfiguration {
return mClientConfiguration.isFixCodeItem(); return mClientConfiguration.isFixCodeItem();
} }
@Override
public boolean isEnableHookDump() {
return mClientConfiguration.isEnableHookDump();
}
private void startLogcat() { private void startLogcat() {
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), getContext().getPackageName() + "_logcat.txt"); File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), getContext().getPackageName() + "_logcat.txt");
FileUtils.deleteDir(file); FileUtils.deleteDir(file);

@ -31,4 +31,8 @@ public abstract class ClientConfiguration {
public boolean isFixCodeItem() { public boolean isFixCodeItem() {
return false; return false;
} }
public boolean isEnableHookDump() {
return true;
}
} }

@ -100,6 +100,7 @@ public final class AppInstrumentation extends BaseInstrumentationDelegate implem
@Override @Override
public Application newApplication(ClassLoader cl, String className, Context context) throws InstantiationException, IllegalAccessException, ClassNotFoundException { public Application newApplication(ClassLoader cl, String className, Context context) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
ContextCompat.fix(context); ContextCompat.fix(context);
if (BlackBoxCore.get().isEnableHookDump()) {
String absolutePath = new File(BlackBoxCore.get().getDexDumpDir(), context.getPackageName()).getAbsolutePath(); String absolutePath = new File(BlackBoxCore.get().getDexDumpDir(), context.getPackageName()).getAbsolutePath();
FileUtils.mkdirs(absolutePath); FileUtils.mkdirs(absolutePath);
Class<?> aClass = cl.loadClass(VMCore.class.getName()); Class<?> aClass = cl.loadClass(VMCore.class.getName());
@ -110,6 +111,7 @@ public final class AppInstrumentation extends BaseInstrumentationDelegate implem
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
}
return super.newApplication(cl, className, context); return super.newApplication(cl, className, context);
} }

Loading…
Cancel
Save