/** * 构造插件信息 * * @param */ static void ensurePluginInited(PluginDescriptor pluginDescriptor) { if (pluginDescriptor != null) { DexClassLoader pluginClassLoader = pluginDescriptor.getPluginClassLoader(); if (pluginClassLoader == null) { LogUtil.d("正在初始化插件Resources, DexClassLoader, Context, Application "); LogUtil.d("是否为独立插件", pluginDescriptor.isStandalone()); Resources pluginRes = PluginCreator.createPluginResource( sApplication, pluginDescriptor.getInstalledPath(), pluginDescriptor.isStandalone()); pluginClassLoader = PluginCreator.createPluginClassLoader( pluginDescriptor.getInstalledPath(), pluginDescriptor.isStandalone()); Context pluginContext = PluginCreator.createPluginApplicationContext( pluginDescriptor, sApplication, pluginRes, pluginClassLoader); pluginContext.setTheme(sApplication.getApplicationContext().getApplicationInfo().theme); pluginDescriptor.setPluginContext(pluginContext); pluginDescriptor.setPluginClassLoader(pluginClassLoader); // 使用了openAtlasExtention之后就不需要Public.xml文件了 // checkPluginPublicXml(pluginDescriptor, pluginRes); callPluginApplicationOnCreate(pluginDescriptor); LogUtil.d("初始化插件" + pluginDescriptor.getPackageName() + "完成"); } } }
/** * 构造插件信息 * * @param */ static void ensurePluginInited(PluginDescriptor pluginDescriptor) { if (pluginDescriptor != null) { DexClassLoader pluginClassLoader = pluginDescriptor.getPluginClassLoader(); if (pluginClassLoader == null) { LogUtil.e( "正在初始化插件" + pluginDescriptor.getPackageName() + "Resources, DexClassLoader, Context, Application"); LogUtil.d("是否为独立插件", pluginDescriptor.isStandalone()); Resources pluginRes = PluginCreator.createPluginResource(sApplication, pluginDescriptor); pluginClassLoader = PluginCreator.createPluginClassLoader( pluginDescriptor.getInstalledPath(), pluginDescriptor.isStandalone(), pluginDescriptor.getDependencies()); Context pluginContext = PluginCreator.createPluginContext( pluginDescriptor, sApplication, pluginRes, pluginClassLoader); // 插件Context默认主题设置为插件application主题 pluginContext.setTheme(pluginDescriptor.getApplicationTheme()); pluginDescriptor.setPluginContext(pluginContext); pluginDescriptor.setPluginClassLoader(pluginClassLoader); try { ActivityThread.installPackageInfo(getApplicatoin(), pluginDescriptor.getPackageName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } callPluginApplicationOnCreate(pluginDescriptor); LogUtil.e("初始化插件" + pluginDescriptor.getPackageName() + "完成"); } } }