com.facebook.stetho.dumpapp.DumperPlugin Java Examples

The following examples show how to use com.facebook.stetho.dumpapp.DumperPlugin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginBuilderTest.java    From stetho with MIT License 6 votes vote down vote up
@Test
public void test_Remove_DefaultDumperPluginsBuilder() throws IOException {
  //HprofDumperPlugin.NAME is private
  final String hprofDumperPluginNAME = "hprof";
  final Iterable<DumperPlugin> dumperPlugins = new Stetho.DefaultDumperPluginsBuilder(mActivity)
          .remove(hprofDumperPluginNAME)
          .finish();

  boolean containsDebugggerDomain = false;
  for (DumperPlugin plugin : dumperPlugins) {
    if (plugin.getClass().equals(HprofDumperPlugin.class)) {
      containsDebugggerDomain = true;
      break;
    }
  }

  assertFalse(containsDebugggerDomain);
}
 
Example #2
Source File: ComparisonApp.java    From fresco with MIT License 6 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();
  final Context context = this;
  Stetho.initialize(
      Stetho.newInitializerBuilder(context)
          .enableDumpapp(
              new DumperPluginsProvider() {
                @Override
                public Iterable<DumperPlugin> get() {
                  return new Stetho.DefaultDumperPluginsBuilder(context)
                      .provide(new FrescoStethoPlugin())
                      .finish();
                }
              })
          .build());
}
 
Example #3
Source File: StethoInitializer.java    From droidconat-2016 with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<DumperPlugin> get() {
    List<DumperPlugin> plugins = new ArrayList<>();
    for (DumperPlugin plugin : Stetho.defaultDumperPluginsProvider(context).get()) {
        plugins.add(plugin);
    }
    plugins.add(appDumper);
    return plugins;
}
 
Example #4
Source File: Stetho.java    From stetho with MIT License 5 votes vote down vote up
/**
 * Start the listening server.  Most of the heavy lifting initialization is deferred until the
 * first socket connection is received, allowing this to be safely used for debug builds on
 * even low-end hardware without noticeably affecting performance.
 */
public static void initializeWithDefaults(final Context context) {
  initialize(new Initializer(context) {
    @Override
    protected Iterable<DumperPlugin> getDumperPlugins() {
      return new DefaultDumperPluginsBuilder(context).finish();
    }

    @Override
    protected Iterable<ChromeDevtoolsDomain> getInspectorModules() {
      return new DefaultInspectorModulesBuilder(context).finish();
    }
  });
}
 
Example #5
Source File: Stetho.java    From stetho with MIT License 5 votes vote down vote up
public static DumperPluginsProvider defaultDumperPluginsProvider(final Context context) {
  return new DumperPluginsProvider() {
    @Override
    public Iterable<DumperPlugin> get() {
      return new DefaultDumperPluginsBuilder(context).finish();
    }
  };
}
 
Example #6
Source File: Stetho.java    From stetho with MIT License 5 votes vote down vote up
public Iterable<DumperPlugin> finish() {
  provideIfDesired(new HprofDumperPlugin(mContext));
  provideIfDesired(new SharedPreferencesDumperPlugin(mContext));
  provideIfDesired(new CrashDumperPlugin());
  provideIfDesired(new FilesDumperPlugin(mContext));
  return mDelegate.finish();
}
 
Example #7
Source File: Stetho.java    From stetho with MIT License 5 votes vote down vote up
@Override
public SocketHandler create() {
  ProtocolDetectingSocketHandler socketHandler =
      new ProtocolDetectingSocketHandler(mContext);

  Iterable<DumperPlugin> dumperPlugins = getDumperPlugins();
  if (dumperPlugins != null) {
    Dumper dumper = new Dumper(dumperPlugins);

    socketHandler.addHandler(
        new ProtocolDetectingSocketHandler.ExactMagicMatcher(
            DumpappSocketLikeHandler.PROTOCOL_MAGIC),
        new DumpappSocketLikeHandler(dumper));

    // Support the old HTTP-based protocol since it's relatively straight forward to do.
    DumpappHttpSocketLikeHandler legacyHandler = new DumpappHttpSocketLikeHandler(dumper);
    socketHandler.addHandler(
        new ProtocolDetectingSocketHandler.ExactMagicMatcher(
            "GET /dumpapp".getBytes()),
        legacyHandler);
    socketHandler.addHandler(
        new ProtocolDetectingSocketHandler.ExactMagicMatcher(
            "POST /dumpapp".getBytes()),
        legacyHandler);
  }

  Iterable<ChromeDevtoolsDomain> inspectorModules = getInspectorModules();
  if (inspectorModules != null) {
    socketHandler.addHandler(
        new ProtocolDetectingSocketHandler.AlwaysMatchMatcher(),
        new DevtoolsSocketHandler(mContext, inspectorModules));
  }

  return socketHandler;
}
 
Example #8
Source File: SampleDebugApplication.java    From stetho with MIT License 5 votes vote down vote up
private void initializeStetho(final Context context) {
  // See also: Stetho.initializeWithDefaults(Context)
  Stetho.initialize(Stetho.newInitializerBuilder(context)
      .enableDumpapp(new DumperPluginsProvider() {
        @Override
        public Iterable<DumperPlugin> get() {
          return new Stetho.DefaultDumperPluginsBuilder(context)
              .provide(new HelloWorldDumperPlugin())
              .provide(new APODDumperPlugin(context.getContentResolver()))
              .finish();
        }
      })
      .enableWebKitInspector(new ExtInspectorModulesProvider(context))
      .build());
}
 
Example #9
Source File: Stetho.java    From stetho with MIT License 4 votes vote down vote up
public DefaultDumperPluginsBuilder provide(DumperPlugin plugin) {
  mDelegate.provide(plugin.getName(), plugin);
  return this;
}
 
Example #10
Source File: Stetho.java    From stetho with MIT License 4 votes vote down vote up
private DefaultDumperPluginsBuilder provideIfDesired(DumperPlugin plugin) {
  mDelegate.provideIfDesired(plugin.getName(), plugin);
  return this;
}
 
Example #11
Source File: Stetho.java    From stetho with MIT License 4 votes vote down vote up
@Nullable
protected abstract Iterable<DumperPlugin> getDumperPlugins();
 
Example #12
Source File: Stetho.java    From stetho with MIT License 4 votes vote down vote up
@Nullable
@Override
protected Iterable<DumperPlugin> getDumperPlugins() {
  return mDumperPlugins != null ? mDumperPlugins.get() : null;
}
 
Example #13
Source File: DumperPluginsProvider.java    From stetho with MIT License votes vote down vote up
Iterable<DumperPlugin> get();