mirror of
https://gitee.com/replugin/RePlugin.git
synced 2024-12-02 11:48:02 +08:00
Change PmLocalImpl to PluginCommImpl and weakening IPluginManager
This commit is contained in:
parent
54bcf3e783
commit
ecfad42f87
@ -29,6 +29,7 @@ import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.qihoo360.loader2.PluginCommImpl;
|
||||
import com.qihoo360.mobilesafe.core.BuildConfig;
|
||||
import com.qihoo360.replugin.RePlugin;
|
||||
import com.qihoo360.replugin.component.ComponentList;
|
||||
@ -118,7 +119,7 @@ public final class Factory {
|
||||
/**
|
||||
* 参数1:插件上下文,可通过它获取应用上下文
|
||||
* 参数2:HOST的类加载器
|
||||
* 参数3:插件管理器 IPluginManager.aidl
|
||||
* 参数3:已废弃
|
||||
* 返回:插件 IPlugin.aidl
|
||||
* @hide 内部框架使用
|
||||
*/
|
||||
@ -129,7 +130,7 @@ public final class Factory {
|
||||
/**
|
||||
* @hide 内部框架使用
|
||||
*/
|
||||
public static IPluginManager sPluginManager;
|
||||
public static PluginCommImpl sPluginManager;
|
||||
|
||||
/**
|
||||
* @deprecated 新插件框架不再用i接口依赖,此接口已废弃
|
||||
|
@ -16,24 +16,8 @@
|
||||
|
||||
package com.qihoo360.i;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.qihoo360.replugin.component.ComponentList;
|
||||
import com.qihoo360.replugin.model.PluginInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 负责插件和插件之间的interface互通,可通过插件Entry得到,也可通过wrapper类Factory直接调用
|
||||
* 注意:这里目前仅放置一些常量,大部分方法已移动至 PluginCommImpl 中
|
||||
*
|
||||
* @author RePlugin Team
|
||||
*/
|
||||
@ -81,165 +65,4 @@ public interface IPluginManager {
|
||||
* 常驻进程
|
||||
*/
|
||||
int PROCESS_PERSIST = -2;
|
||||
|
||||
/**
|
||||
* 此方法调用主程序或特定插件的IPlugin.query,当插件未加载时会尝试加载
|
||||
* @param name 插件名
|
||||
* @param c 需要查询的interface的类
|
||||
* @return
|
||||
*/
|
||||
IModule query(String name, Class<? extends IModule> c);
|
||||
|
||||
/**
|
||||
* @param name 插件名
|
||||
* @return
|
||||
*/
|
||||
boolean isPluginLoaded(String name);
|
||||
|
||||
/**
|
||||
* @param name 插件名
|
||||
* @param binder 需要查询的binder的类
|
||||
* @return
|
||||
*/
|
||||
IBinder query(String name, String binder);
|
||||
|
||||
/**
|
||||
* @param name 插件名
|
||||
* @param binder 需要查询的binder的类
|
||||
* @param process 是否在指定进程中启动
|
||||
* @return
|
||||
*/
|
||||
IBinder query(String name, String binder, int process);
|
||||
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 当插件升级之后,通过adapter.jar标准接口,甚至invoke接口都无法完成任务时,可通过此接口反射来完成任务
|
||||
* @param name 插件名
|
||||
* @return 插件的context,可通过此context得到插件的ClassLoader
|
||||
*/
|
||||
Context queryPluginContext(String name);
|
||||
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不加载代码,只加载资源)
|
||||
* @param name 插件名
|
||||
* @return 插件的Resources
|
||||
*/
|
||||
Resources queryPluginResouces(String name);
|
||||
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不加载代码,只加载资源)
|
||||
* @param name 插件名
|
||||
* @return 插件的PackageInfo
|
||||
*/
|
||||
PackageInfo queryPluginPackageInfo(String name);
|
||||
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不加载代码和资源,只获取PackageInfo)
|
||||
*
|
||||
* @param pkgName 插件包名
|
||||
* @param flags Flags
|
||||
* @return 插件的PackageInfo
|
||||
*/
|
||||
PackageInfo queryPluginPackageInfo(String pkgName, int flags);
|
||||
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不加载代码和资源,只获取ComponentList)
|
||||
* @param name 插件名
|
||||
* @return 插件的ComponentList
|
||||
*/
|
||||
ComponentList queryPluginComponentList(String name);
|
||||
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不启动App)
|
||||
* @param name 插件名
|
||||
* @return 插件的Resources
|
||||
*/
|
||||
ClassLoader queryPluginClassLoader(String name);
|
||||
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会“依据PluginInfo中指定的插件信息”,在当前进程加载插件(不启动App)。通常用于“指定路径来直接安装”的情况
|
||||
* 注意:调用此接口将不会“通知插件更新”
|
||||
* Added by Jiongxuan Zhang
|
||||
* @param pi 插件信息
|
||||
* @return 插件的Resources
|
||||
*/
|
||||
ClassLoader loadPluginClassLoader(PluginInfo pi);
|
||||
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不加载代码和资源,只获取Collection<ReceiverInfo>)
|
||||
* @return 符合 action 的所有 ReceiverInfo
|
||||
*/
|
||||
List<ActivityInfo> queryPluginsReceiverList(Intent intent);
|
||||
|
||||
/**
|
||||
* 启动一个插件中的activity,如果插件不存在会触发下载界面
|
||||
* @param context 应用上下文或者Activity上下文
|
||||
* @param intent
|
||||
* @param plugin 插件名
|
||||
* @param activity 待启动的activity类名
|
||||
* @param process 是否在指定进程中启动
|
||||
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
||||
*/
|
||||
boolean startActivity(Context context, Intent intent, String plugin, String activity, int process);
|
||||
|
||||
/**
|
||||
* 启动一个插件中的 activity 'forResult'
|
||||
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
||||
*/
|
||||
boolean startActivityForResult(Activity activity, Intent intent, int requestCode, Bundle options);
|
||||
|
||||
/**
|
||||
* 加载插件Activity,在startActivity之前调用
|
||||
* @param intent
|
||||
* @param plugin 插件名
|
||||
* @param target 目标Service名,如果传null,则取获取到的第一个
|
||||
* @param process 是否在指定进程中启动
|
||||
* @return
|
||||
*/
|
||||
ComponentName loadPluginActivity(Intent intent, String plugin, String target, int process);
|
||||
|
||||
/**
|
||||
* 启动插件Service,在startService、bindService之前调用
|
||||
* @param plugin 插件名
|
||||
* @param target 目标Service名,如果传null,则取获取到的第一个
|
||||
* @param process 是否在指定进程中启动
|
||||
* @return
|
||||
*/
|
||||
ComponentName loadPluginService(String plugin, String target, int process);
|
||||
|
||||
/**
|
||||
* 启动插件的Provider
|
||||
* @param plugin 插件名
|
||||
* @param target 目标Provider名,如果传null,则取获取到的第一个
|
||||
* @param process 是否在指定进程中启动
|
||||
* @return
|
||||
* @deprecated 已废弃该方法,请使用PluginProviderClient里面的方法
|
||||
*/
|
||||
Uri loadPluginProvider(String plugin, String target, int process);
|
||||
|
||||
/**
|
||||
* 通过ClassLoader来获取插件名
|
||||
*
|
||||
* @param cl ClassLoader对象
|
||||
* @return 插件名,若和主程序一致,则返回IModule.PLUGIN_NAME_MAIN(“main”)
|
||||
* Added by Jiongxuan Zhang
|
||||
*/
|
||||
String fetchPluginName(ClassLoader cl);
|
||||
|
||||
/**
|
||||
* 根据条件,查找 ActivityInfo 对象
|
||||
*
|
||||
* @param plugin 插件名称
|
||||
* @param activity Activity 名称
|
||||
* @param intent 调用者传递过来的 Intent
|
||||
* @return 插件中 Activity 的 ActivityInfo
|
||||
*/
|
||||
ActivityInfo getActivityInfo(String plugin, String activity, Intent intent);
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import android.util.Log;
|
||||
import com.qihoo360.i.Factory;
|
||||
import com.qihoo360.i.IModule;
|
||||
import com.qihoo360.i.IPlugin;
|
||||
import com.qihoo360.i.IPluginManager;
|
||||
import com.qihoo360.mobilesafe.core.BuildConfig;
|
||||
import com.qihoo360.mobilesafe.parser.manifest.ManifestParser;
|
||||
import com.qihoo360.replugin.RePlugin;
|
||||
@ -397,7 +396,7 @@ class Loader {
|
||||
return mCreateMethod != null;
|
||||
}
|
||||
|
||||
final boolean invoke(IPluginManager manager) {
|
||||
final boolean invoke(PluginCommImpl manager) {
|
||||
try {
|
||||
mPlugin = (IPlugin) mCreateMethod.invoke(null, mPkgContext, manager);
|
||||
if (LOG) {
|
||||
@ -447,7 +446,7 @@ class Loader {
|
||||
return mCreateMethod2 != null;
|
||||
}
|
||||
|
||||
final boolean invoke2(IPluginManager x) {
|
||||
final boolean invoke2(PluginCommImpl x) {
|
||||
try {
|
||||
IBinder manager = null; // TODO
|
||||
IBinder b = (IBinder) mCreateMethod2.invoke(null, mPkgContext, getClass().getClassLoader(), manager);
|
||||
|
@ -26,7 +26,6 @@ import android.text.TextUtils;
|
||||
import com.qihoo360.i.Factory;
|
||||
import com.qihoo360.i.Factory2;
|
||||
import com.qihoo360.i.IModule;
|
||||
import com.qihoo360.i.IPluginManager;
|
||||
import com.qihoo360.loader.utils.PatchClassLoaderUtils;
|
||||
import com.qihoo360.replugin.helper.LogRelease;
|
||||
|
||||
@ -104,7 +103,7 @@ public class PMF {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static final IPluginManager getLocal() {
|
||||
public static final PluginCommImpl getLocal() {
|
||||
return sPluginMgr.mLocal;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ import android.text.TextUtils;
|
||||
|
||||
import com.qihoo360.i.IModule;
|
||||
import com.qihoo360.i.IPlugin;
|
||||
import com.qihoo360.i.IPluginManager;
|
||||
import com.qihoo360.loader.utils.AssetsUtils;
|
||||
import com.qihoo360.loader.utils.ProcessLocker;
|
||||
import com.qihoo360.mobilesafe.api.Tasks;
|
||||
@ -133,7 +132,7 @@ class Plugin {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
IPluginManager mPluginManager;
|
||||
PluginCommImpl mPluginManager;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -179,7 +178,7 @@ class Plugin {
|
||||
return new Plugin(info);
|
||||
}
|
||||
|
||||
static final Plugin cloneAndReattach(Context c, Plugin p, ClassLoader parent, IPluginManager pm) {
|
||||
static final Plugin cloneAndReattach(Context c, Plugin p, ClassLoader parent, PluginCommImpl pm) {
|
||||
if (p == null) {
|
||||
return null;
|
||||
}
|
||||
@ -381,7 +380,7 @@ class Plugin {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
final void attach(Context context, ClassLoader parent, IPluginManager manager) {
|
||||
final void attach(Context context, ClassLoader parent, PluginCommImpl manager) {
|
||||
mContext = context;
|
||||
mParent = parent;
|
||||
mPluginManager = manager;
|
||||
@ -601,7 +600,7 @@ class Plugin {
|
||||
|
||||
Context context = mContext;
|
||||
ClassLoader parent = mParent;
|
||||
IPluginManager manager = mPluginManager;
|
||||
PluginCommImpl manager = mPluginManager;
|
||||
|
||||
//
|
||||
String logTag = "try1";
|
||||
@ -722,7 +721,7 @@ class Plugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
private final boolean doLoad(String tag, Context context, ClassLoader parent, IPluginManager manager, int load) {
|
||||
private final boolean doLoad(String tag, Context context, ClassLoader parent, PluginCommImpl manager, int load) {
|
||||
if (mLoader == null) {
|
||||
// 试图释放文件
|
||||
PluginInfo info = null;
|
||||
@ -839,7 +838,7 @@ class Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean loadEntryLocked(IPluginManager manager) {
|
||||
private boolean loadEntryLocked(PluginCommImpl manager) {
|
||||
if (mDummyPlugin) {
|
||||
if (LOGR) {
|
||||
LogRelease.w(PLUGIN_TAG, "p.lel dm " + mInfo.getName());
|
||||
|
@ -50,9 +50,12 @@ import static com.qihoo360.replugin.helper.LogDebug.PLUGIN_TAG;
|
||||
import static com.qihoo360.replugin.helper.LogRelease.LOGR;
|
||||
|
||||
/**
|
||||
* 负责宿主与插件、插件间的互通,可通过插件的Factory直接调用,也可通过RePlugin来跳转 <p>
|
||||
* TODO 原名为PmLocalImpl。新名字也不太好,待重构后会去掉
|
||||
*
|
||||
* @author RePlugin Team
|
||||
*/
|
||||
class PmLocalImpl implements IPluginManager {
|
||||
public class PluginCommImpl {
|
||||
|
||||
private static final String CONTAINER_PROVIDER_AUTHORITY_PART = ".loader.p.pr";
|
||||
static final String INTENT_KEY_THEME_ID = "__themeId";
|
||||
@ -67,12 +70,15 @@ class PmLocalImpl implements IPluginManager {
|
||||
*/
|
||||
PmBase mPluginMgr;
|
||||
|
||||
PmLocalImpl(Context context, PmBase pm) {
|
||||
PluginCommImpl(Context context, PmBase pm) {
|
||||
mContext = context;
|
||||
mPluginMgr = pm;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* @param name 插件名
|
||||
* @return
|
||||
*/
|
||||
public boolean isPluginLoaded(String name) {
|
||||
if (LOG) {
|
||||
LogDebug.d(PLUGIN_TAG, "isPluginLoaded: name=" + name);
|
||||
@ -84,7 +90,12 @@ class PmLocalImpl implements IPluginManager {
|
||||
return plugin.isLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 此方法调用主程序或特定插件的IPlugin.query,当插件未加载时会尝试加载
|
||||
* @param name 插件名
|
||||
* @param c 需要查询的interface的类
|
||||
* @return
|
||||
*/
|
||||
public IModule query(String name, Class<? extends IModule> c) {
|
||||
if (LOG) {
|
||||
LogDebug.d(PLUGIN_TAG, "query: name=" + name + " class=" + c.getName());
|
||||
@ -106,7 +117,11 @@ class PmLocalImpl implements IPluginManager {
|
||||
return p.query(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* @param name 插件名
|
||||
* @param binder 需要查询的binder的类
|
||||
* @return
|
||||
*/
|
||||
public IBinder query(String name, String binder) {
|
||||
if (LOG) {
|
||||
LogDebug.d(PLUGIN_TAG, "query: name=" + name + " binder=" + binder);
|
||||
@ -134,7 +149,12 @@ class PmLocalImpl implements IPluginManager {
|
||||
return p.query(binder);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* @param name 插件名
|
||||
* @param binder 需要查询的binder的类
|
||||
* @param process 是否在指定进程中启动
|
||||
* @return
|
||||
*/
|
||||
public IBinder query(String name, String binder, int process) {
|
||||
// 自己进程
|
||||
if (IPC.isPersistentProcess() && process == IPluginManager.PROCESS_PERSIST) {
|
||||
@ -166,7 +186,12 @@ class PmLocalImpl implements IPluginManager {
|
||||
return QihooServiceManager.getPluginService(mContext, name, binder);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 当插件升级之后,通过adapter.jar标准接口,甚至invoke接口都无法完成任务时,可通过此接口反射来完成任务
|
||||
* @param name 插件名
|
||||
* @return 插件的context,可通过此context得到插件的ClassLoader
|
||||
*/
|
||||
public Context queryPluginContext(String name) {
|
||||
Plugin p = mPluginMgr.loadAppPlugin(name);
|
||||
if (p != null) {
|
||||
@ -180,7 +205,12 @@ class PmLocalImpl implements IPluginManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不加载代码,只加载资源)
|
||||
* @param name 插件名
|
||||
* @return 插件的Resources
|
||||
*/
|
||||
public Resources queryPluginResouces(String name) {
|
||||
// 先从缓存获取
|
||||
Resources resources = Plugin.queryCachedResources(Plugin.queryCachedFilename(name));
|
||||
@ -200,7 +230,12 @@ class PmLocalImpl implements IPluginManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不加载代码,只加载资源)
|
||||
* @param name 插件名
|
||||
* @return 插件的PackageInfo
|
||||
*/
|
||||
public PackageInfo queryPluginPackageInfo(String name) {
|
||||
// 先从缓存获取
|
||||
PackageInfo packageInfo = Plugin.queryCachedPackageInfo(Plugin.queryCachedFilename(name));
|
||||
@ -220,7 +255,14 @@ class PmLocalImpl implements IPluginManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不加载代码和资源,只获取PackageInfo)
|
||||
*
|
||||
* @param pkgName 插件包名
|
||||
* @param flags Flags
|
||||
* @return 插件的PackageInfo
|
||||
*/
|
||||
public PackageInfo queryPluginPackageInfo(String pkgName, int flags) {
|
||||
// 根据 pkgName 取得 pluginName
|
||||
String pluginName = Plugin.queryPluginNameByPkgName(pkgName);
|
||||
@ -230,7 +272,12 @@ class PmLocalImpl implements IPluginManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不加载代码和资源,只获取ComponentList)
|
||||
* @param name 插件名
|
||||
* @return 插件的ComponentList
|
||||
*/
|
||||
public ComponentList queryPluginComponentList(String name) {
|
||||
// 先从缓存获取
|
||||
ComponentList cl = Plugin.queryCachedComponentList(Plugin.queryCachedFilename(name));
|
||||
@ -250,7 +297,12 @@ class PmLocalImpl implements IPluginManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不启动App)
|
||||
* @param name 插件名
|
||||
* @return 插件的Resources
|
||||
*/
|
||||
public ClassLoader queryPluginClassLoader(String name) {
|
||||
// 先从缓存获取
|
||||
ClassLoader cl = Plugin.queryCachedClassLoader(Plugin.queryCachedFilename(name));
|
||||
@ -270,7 +322,14 @@ class PmLocalImpl implements IPluginManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会“依据PluginInfo中指定的插件信息”,在当前进程加载插件(不启动App)。通常用于“指定路径来直接安装”的情况
|
||||
* 注意:调用此接口将不会“通知插件更新”
|
||||
* Added by Jiongxuan Zhang
|
||||
* @param pi 插件信息
|
||||
* @return 插件的Resources
|
||||
*/
|
||||
public ClassLoader loadPluginClassLoader(PluginInfo pi) {
|
||||
// 不从缓存中获取,而是直接初始化ClassLoader
|
||||
Plugin p = mPluginMgr.loadPlugin(pi, this, Plugin.LOAD_DEX, false);
|
||||
@ -285,7 +344,11 @@ class PmLocalImpl implements IPluginManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 警告:低层接口
|
||||
* 调用此接口会在当前进程加载插件(不加载代码和资源,只获取Collection<ReceiverInfo>)
|
||||
* @return 符合 action 的所有 ReceiverInfo
|
||||
*/
|
||||
public List<ActivityInfo> queryPluginsReceiverList(Intent intent) {
|
||||
IPluginHost pluginHost = PluginProcessMain.getPluginHost();
|
||||
if (pluginHost != null) {
|
||||
@ -300,7 +363,15 @@ class PmLocalImpl implements IPluginManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 启动一个插件中的activity,如果插件不存在会触发下载界面
|
||||
* @param context 应用上下文或者Activity上下文
|
||||
* @param intent
|
||||
* @param plugin 插件名
|
||||
* @param activity 待启动的activity类名
|
||||
* @param process 是否在指定进程中启动
|
||||
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
||||
*/
|
||||
public boolean startActivity(Context context, Intent intent, String plugin, String activity, int process) {
|
||||
if (LOG) {
|
||||
LogDebug.d(PLUGIN_TAG, "start activity: intent=" + intent + " plugin=" + plugin + " activity=" + activity + " process=" + process);
|
||||
@ -309,7 +380,10 @@ class PmLocalImpl implements IPluginManager {
|
||||
return mPluginMgr.mInternal.startActivity(context, intent, plugin, activity, process, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 启动一个插件中的 activity 'forResult'
|
||||
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
||||
*/
|
||||
public boolean startActivityForResult(Activity activity, Intent intent, int requestCode, Bundle options) {
|
||||
if (LOG) {
|
||||
LogDebug.d(PLUGIN_TAG, "startActivityForResult: intent=" + intent + " requestCode=" + requestCode+ " options=" + options);
|
||||
@ -318,7 +392,14 @@ class PmLocalImpl implements IPluginManager {
|
||||
return mPluginMgr.mInternal.startActivityForResult(activity, intent, requestCode, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 加载插件Activity,在startActivity之前调用
|
||||
* @param intent
|
||||
* @param plugin 插件名
|
||||
* @param target 目标Service名,如果传null,则取获取到的第一个
|
||||
* @param process 是否在指定进程中启动
|
||||
* @return
|
||||
*/
|
||||
public ComponentName loadPluginActivity(Intent intent, String plugin, String activity, int process) {
|
||||
|
||||
ActivityInfo ai = null;
|
||||
@ -386,7 +467,13 @@ class PmLocalImpl implements IPluginManager {
|
||||
return new ComponentName(IPC.getPackageName(), container);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 启动插件Service,在startService、bindService之前调用
|
||||
* @param plugin 插件名
|
||||
* @param target 目标Service名,如果传null,则取获取到的第一个
|
||||
* @param process 是否在指定进程中启动
|
||||
* @return
|
||||
*/
|
||||
public ComponentName loadPluginService(String plugin, String target, int process) {
|
||||
String container = null;
|
||||
|
||||
@ -411,7 +498,14 @@ class PmLocalImpl implements IPluginManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 启动插件的Provider
|
||||
* @param plugin 插件名
|
||||
* @param target 目标Provider名,如果传null,则取获取到的第一个
|
||||
* @param process 是否在指定进程中启动
|
||||
* @return
|
||||
* @deprecated 已废弃该方法,请使用PluginProviderClient里面的方法
|
||||
*/
|
||||
public Uri loadPluginProvider(String plugin, String target, int process) {
|
||||
PluginBinderInfo info = new PluginBinderInfo(PluginBinderInfo.PROVIDER_REQUEST);
|
||||
try {
|
||||
@ -434,7 +528,13 @@ class PmLocalImpl implements IPluginManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 通过ClassLoader来获取插件名
|
||||
*
|
||||
* @param cl ClassLoader对象
|
||||
* @return 插件名,若和主程序一致,则返回IModule.PLUGIN_NAME_MAIN(“main”)
|
||||
* Added by Jiongxuan Zhang
|
||||
*/
|
||||
public String fetchPluginName(ClassLoader cl) {
|
||||
if (cl == mContext.getClassLoader()) {
|
||||
// Main工程的ClassLoader
|
||||
@ -448,7 +548,14 @@ class PmLocalImpl implements IPluginManager {
|
||||
return p.mInfo.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 根据条件,查找 ActivityInfo 对象
|
||||
*
|
||||
* @param plugin 插件名称
|
||||
* @param activity Activity 名称
|
||||
* @param intent 调用者传递过来的 Intent
|
||||
* @return 插件中 Activity 的 ActivityInfo
|
||||
*/
|
||||
public ActivityInfo getActivityInfo(String plugin, String activity, Intent intent) {
|
||||
// 获取插件对象
|
||||
Plugin p = mPluginMgr.loadAppPlugin(plugin);
|
@ -689,7 +689,7 @@ public class PluginLibraryInternalProxy {
|
||||
int dynamicThemeId = getDynamicThemeId(activity);
|
||||
|
||||
// 插件 manifest 中设置的 ThemeId
|
||||
int manifestThemeId = intent.getIntExtra(PmLocalImpl.INTENT_KEY_THEME_ID, 0);
|
||||
int manifestThemeId = intent.getIntExtra(PluginCommImpl.INTENT_KEY_THEME_ID, 0);
|
||||
//如果插件上没有主题则使用Application节点的Theme
|
||||
if (manifestThemeId == 0) {
|
||||
manifestThemeId = activity.getApplicationInfo().theme;
|
||||
|
@ -159,7 +159,7 @@ class PmBase {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
IPluginManager mLocal;
|
||||
PluginCommImpl mLocal;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -221,7 +221,7 @@ class PmBase {
|
||||
mClient = new PluginProcessPer(context, this, PluginManager.sPluginProcessIndex, mContainerActivities);
|
||||
|
||||
//
|
||||
mLocal = new PmLocalImpl(context, this);
|
||||
mLocal = new PluginCommImpl(context, this);
|
||||
|
||||
//
|
||||
mInternal = new PluginLibraryInternalProxy(this);
|
||||
@ -997,17 +997,17 @@ class PmBase {
|
||||
(info.getPendingUpdate() != null && !RePlugin.isPluginRunning(info.getName()));
|
||||
}
|
||||
|
||||
final Plugin loadPackageInfoPlugin(String plugin, IPluginManager pm) {
|
||||
final Plugin loadPackageInfoPlugin(String plugin, PluginCommImpl pm) {
|
||||
Plugin p = Plugin.cloneAndReattach(mContext, mPlugins.get(plugin), mClassLoader, pm);
|
||||
return loadPlugin(p, Plugin.LOAD_INFO, true);
|
||||
}
|
||||
|
||||
final Plugin loadResourcePlugin(String plugin, IPluginManager pm) {
|
||||
final Plugin loadResourcePlugin(String plugin, PluginCommImpl pm) {
|
||||
Plugin p = Plugin.cloneAndReattach(mContext, mPlugins.get(plugin), mClassLoader, pm);
|
||||
return loadPlugin(p, Plugin.LOAD_RESOURCES, true);
|
||||
}
|
||||
|
||||
final Plugin loadDexPlugin(String plugin, IPluginManager pm) {
|
||||
final Plugin loadDexPlugin(String plugin, PluginCommImpl pm) {
|
||||
Plugin p = Plugin.cloneAndReattach(mContext, mPlugins.get(plugin), mClassLoader, pm);
|
||||
return loadPlugin(p, Plugin.LOAD_DEX, true);
|
||||
}
|
||||
@ -1017,7 +1017,7 @@ class PmBase {
|
||||
}
|
||||
|
||||
// 底层接口
|
||||
final Plugin loadPlugin(PluginInfo pi, IPluginManager pm, int loadType, boolean useCache) {
|
||||
final Plugin loadPlugin(PluginInfo pi, PluginCommImpl pm, int loadType, boolean useCache) {
|
||||
Plugin p = Plugin.build(pi);
|
||||
p.attach(mContext, mClassLoader, pm);
|
||||
return loadPlugin(p, loadType, useCache);
|
||||
|
Loading…
Reference in New Issue
Block a user