@@ -235,6 +235,11 @@ public static synchronized int installPlugin(String srcPluginFile) {
235
235
}
236
236
}
237
237
238
+ /**
239
+ * 通过插件Id唤起插件
240
+ * @param pluginId
241
+ * @return
242
+ */
238
243
public static PluginDescriptor initPluginByPluginId (String pluginId ) {
239
244
PluginDescriptor pluginDescriptor = getPluginDescriptorByPluginId (pluginId );
240
245
if (pluginDescriptor != null ) {
@@ -338,8 +343,12 @@ public static Context getDefaultPluginContext(@SuppressWarnings("rawtypes") Clas
338
343
339
344
/**
340
345
* 根据当前插件的默认Context, 为当前插件的组件创建一个单独的context
346
+ *
347
+ * @param pluginContext
348
+ * @param base 由系统创建的Context。 其实际类型应该是ContextImpl
349
+ * @return
341
350
*/
342
- public static Context getNewPluginComponentContext (Context pluginContext , Context base ) {
351
+ /*package*/ static Context getNewPluginComponentContext (Context pluginContext , Context base ) {
343
352
Context newContext = null ;
344
353
if (pluginContext != null ) {
345
354
newContext = PluginCreator .createPluginContext (((PluginContextTheme ) pluginContext ).getPluginDescriptor (),
@@ -426,50 +435,10 @@ private static void callPluginApplicationOnCreate(PluginDescriptor pluginDescrip
426
435
changeListener .onPluginStarted (pluginDescriptor .getPackageName ());
427
436
}
428
437
429
- /**
430
- * for eclipse & ant with public.xml
431
- *
432
- * unused
433
- * @param pluginDescriptor
434
- * @param res
435
- * @return
436
- */
437
- private static boolean checkPluginPublicXml (PluginDescriptor pluginDescriptor , Resources res ) {
438
-
439
- // "plugin_layout_1"资源id时由public.xml配置的
440
- // 如果没有检测到这个资源,说明编译时没有引入public.xml,
441
- // 这里直接抛个异常出去。
442
- // 不同的系统版本获取id的方式不同,
443
- // 三星4.x等系统适用
444
- int publicStub = res .getIdentifier ("plugin_layout_1" , "layout" , pluginDescriptor .getPackageName ());
445
- if (publicStub == 0 ) {
446
- // 小米5.x等系统适用
447
- publicStub = res .getIdentifier ("plugin_layout_1" , "layout" , sApplication .getPackageName ());
448
- }
449
- if (publicStub == 0 ) {
450
- try {
451
- // 如果以上两种方式都检测失败,最后尝试通过反射检测
452
- Class layoutClass = ((ClassLoader ) pluginDescriptor .getPluginClassLoader ()).loadClass (pluginDescriptor
453
- .getPackageName () + ".R$layout" );
454
- Integer layouId = (Integer ) RefInvoker .getFieldObject (null , layoutClass , "plugin_layout_1" );
455
- if (layouId != null ) {
456
- publicStub = layouId ;
457
- }
458
- } catch (ClassNotFoundException e ) {
459
- e .printStackTrace ();
460
- }
461
- }
462
-
463
- if (publicStub == 0 ) {
464
- throw new IllegalStateException ("\n 插件工程没有使用public.xml给资源id分组!!!\n " + "插件工程没有使用public.xml给资源id分组!!!\n "
465
- + "插件工程没有使用public.xml给资源id分组!!!\n " + "重要的事情讲三遍!!!" );
466
- }
467
- return true ;
468
- }
469
-
470
438
public static boolean isInstalled (String pluginId , String pluginVersion ) {
471
439
PluginDescriptor pluginDescriptor = getPluginDescriptorByPluginId (pluginId );
472
440
if (pluginDescriptor != null ) {
441
+ LogUtil .d (pluginId , pluginDescriptor .getVersion (), pluginVersion );
473
442
return pluginDescriptor .getVersion ().equals (pluginVersion );
474
443
}
475
444
return false ;
0 commit comments