35
35
import com .qihoo360 .replugin .packages .PluginManagerProxy ;
36
36
import com .qihoo360 .replugin .packages .PluginManagerServer ;
37
37
38
+ import org .json .JSONArray ;
39
+ import org .json .JSONException ;
40
+ import org .json .JSONObject ;
41
+
38
42
import java .io .FileDescriptor ;
39
43
import java .io .PrintWriter ;
40
44
import java .util .HashMap ;
@@ -229,6 +233,10 @@ public String toString() {
229
233
}
230
234
return super .toString ();
231
235
}
236
+
237
+ public IPluginClient getClient () {
238
+ return client ;
239
+ }
232
240
}
233
241
234
242
static final void reportStatus () {
@@ -242,6 +250,69 @@ static final void reportStatus() {
242
250
}
243
251
}
244
252
253
+ static final String dump () {
254
+
255
+ // 1.dump Activity映射表, service列表
256
+ JSONArray activityArr = new JSONArray ();
257
+ JSONArray serviceArr = new JSONArray ();
258
+
259
+ for (ProcessClientRecord clientRecord : ALL .values ()) {
260
+ try {
261
+ IPluginClient pluginClient = clientRecord .getClient ();
262
+ if (pluginClient == null ) {
263
+ continue ;
264
+ }
265
+
266
+ String activityDumpInfo = pluginClient .dumpActivities ();
267
+ JSONArray activityList = new JSONArray (activityDumpInfo );
268
+ int activityCount = activityList .length ();
269
+ if (activityCount > 0 ) {
270
+ for (int i = 0 ; i < activityCount ; i ++) {
271
+ activityArr .put (activityList .getJSONObject (i ));
272
+ }
273
+ }
274
+
275
+ String serviceDumpInfo = pluginClient .dumpServices ();
276
+ JSONArray serviceList = new JSONArray (serviceDumpInfo );
277
+ int serviceCount = serviceList .length ();
278
+ if (serviceCount > 0 ) {
279
+ for (int i = 0 ; i < serviceCount ; i ++) {
280
+ serviceArr .put (serviceList .getJSONObject (i ));
281
+ }
282
+ }
283
+ } catch (Throwable e ) {
284
+ e .printStackTrace ();
285
+ }
286
+ }
287
+
288
+ // 2.dump 插件信息表
289
+ JSONArray pluginArr = new JSONArray ();
290
+ List <PluginInfo > pluginList = MP .getPlugins (false );
291
+ if (pluginList != null ) {
292
+ JSONObject pluginObj ;
293
+ for (PluginInfo pluginInfo : pluginList ) {
294
+ try {
295
+ pluginObj = new JSONObject ();
296
+ pluginObj .put (pluginInfo .getName (), pluginInfo .toString ());
297
+ pluginArr .put (pluginObj );
298
+ } catch (JSONException e ) {
299
+ e .printStackTrace ();
300
+ }
301
+ }
302
+ }
303
+
304
+ JSONObject detailObj = new JSONObject ();
305
+ try {
306
+ detailObj .put ("activity" , activityArr );
307
+ detailObj .put ("service" , serviceArr );
308
+ detailObj .put ("plugin" , pluginArr );
309
+ } catch (JSONException e ) {
310
+ e .printStackTrace ();
311
+ }
312
+
313
+ return detailObj .toString ();
314
+ }
315
+
245
316
static final void dump (FileDescriptor fd , PrintWriter writer , String [] args ) {
246
317
if (LogDebug .DUMP_ENABLED ) {
247
318
writer .println ("--- ALL.length = " + ALL .size () + " ---" );
0 commit comments