Skip to content

Commit 468e93c

Browse files
committed
添加注释
1 parent ddce91d commit 468e93c

File tree

2 files changed

+14
-43
lines changed

2 files changed

+14
-43
lines changed

PluginCore/src/com/plugin/core/PluginLoader.java

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ public static synchronized int installPlugin(String srcPluginFile) {
235235
}
236236
}
237237

238+
/**
239+
* 通过插件Id唤起插件
240+
* @param pluginId
241+
* @return
242+
*/
238243
public static PluginDescriptor initPluginByPluginId(String pluginId) {
239244
PluginDescriptor pluginDescriptor = getPluginDescriptorByPluginId(pluginId);
240245
if (pluginDescriptor != null) {
@@ -338,8 +343,12 @@ public static Context getDefaultPluginContext(@SuppressWarnings("rawtypes") Clas
338343

339344
/**
340345
* 根据当前插件的默认Context, 为当前插件的组件创建一个单独的context
346+
*
347+
* @param pluginContext
348+
* @param base 由系统创建的Context。 其实际类型应该是ContextImpl
349+
* @return
341350
*/
342-
public static Context getNewPluginComponentContext(Context pluginContext, Context base) {
351+
/*package*/ static Context getNewPluginComponentContext(Context pluginContext, Context base) {
343352
Context newContext = null;
344353
if (pluginContext != null) {
345354
newContext = PluginCreator.createPluginContext(((PluginContextTheme) pluginContext).getPluginDescriptor(),
@@ -426,50 +435,10 @@ private static void callPluginApplicationOnCreate(PluginDescriptor pluginDescrip
426435
changeListener.onPluginStarted(pluginDescriptor.getPackageName());
427436
}
428437

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-
470438
public static boolean isInstalled(String pluginId, String pluginVersion) {
471439
PluginDescriptor pluginDescriptor = getPluginDescriptorByPluginId(pluginId);
472440
if (pluginDescriptor != null) {
441+
LogUtil.d(pluginId, pluginDescriptor.getVersion(), pluginVersion);
473442
return pluginDescriptor.getVersion().equals(pluginVersion);
474443
}
475444
return false;

PluginCore/src/com/plugin/util/FileUtil.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ public static boolean copySo(File sourceDir, String so, String dest) {
8989
String name = "lib" + File.separator + abi + File.separator + so;
9090
File sourceFile = new File(sourceDir, name);
9191
if (sourceFile.exists()) {
92-
isSuccess = copyFile(sourceFile.getAbsolutePath(), dest + File.separator + name);
92+
isSuccess = copyFile(sourceFile.getAbsolutePath(), dest + File.separator + "lib" + File.separator + so);
93+
//api21 64位系统的目录可能有些不同
94+
//copyFile(sourceFile.getAbsolutePath(), dest + File.separator + name);
9395
break;
9496
}
9597
}

0 commit comments

Comments
 (0)