mirror of
https://gitee.com/replugin/RePlugin.git
synced 2024-11-30 02:38:34 +08:00
Change PmInternalImpl to PluginLibraryProxy and remove IPluginActivityManager
This commit is contained in:
parent
e8c9724e0a
commit
54bcf3e783
@ -22,10 +22,13 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.qihoo360.loader2.PluginLibraryInternalProxy;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide 内部框架使用
|
* plugin-library中,通过“反射”调用的内部逻辑(如PluginActivity类的调用等)均在此处 <p>
|
||||||
|
* 注意:务必要Keep住此类,否则插件调用将失败
|
||||||
*
|
*
|
||||||
* @author RePlugin Team
|
* @author RePlugin Team
|
||||||
*/
|
*/
|
||||||
@ -34,7 +37,7 @@ public final class Factory2 {
|
|||||||
/**
|
/**
|
||||||
* @hide 内部框架使用
|
* @hide 内部框架使用
|
||||||
*/
|
*/
|
||||||
public static IPluginActivityManager sPluginManager;
|
public static PluginLibraryInternalProxy sPLProxy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide 内部方法,插件框架使用
|
* @hide 内部方法,插件框架使用
|
||||||
@ -44,7 +47,7 @@ public final class Factory2 {
|
|||||||
* @return 为Activity构造一个base Context
|
* @return 为Activity构造一个base Context
|
||||||
*/
|
*/
|
||||||
public static final Context createActivityContext(Activity activity, Context newBase) {
|
public static final Context createActivityContext(Activity activity, Context newBase) {
|
||||||
return sPluginManager.createActivityContext(activity, newBase);
|
return sPLProxy.createActivityContext(activity, newBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +57,7 @@ public final class Factory2 {
|
|||||||
* @param savedInstanceState
|
* @param savedInstanceState
|
||||||
*/
|
*/
|
||||||
public static final void handleActivityCreateBefore(Activity activity, Bundle savedInstanceState) {
|
public static final void handleActivityCreateBefore(Activity activity, Bundle savedInstanceState) {
|
||||||
sPluginManager.handleActivityCreateBefore(activity, savedInstanceState);
|
sPLProxy.handleActivityCreateBefore(activity, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +67,7 @@ public final class Factory2 {
|
|||||||
* @param savedInstanceState
|
* @param savedInstanceState
|
||||||
*/
|
*/
|
||||||
public static final void handleActivityCreate(Activity activity, Bundle savedInstanceState) {
|
public static final void handleActivityCreate(Activity activity, Bundle savedInstanceState) {
|
||||||
sPluginManager.handleActivityCreate(activity, savedInstanceState);
|
sPLProxy.handleActivityCreate(activity, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,7 +76,7 @@ public final class Factory2 {
|
|||||||
* @param activity
|
* @param activity
|
||||||
*/
|
*/
|
||||||
public static final void handleActivityDestroy(Activity activity) {
|
public static final void handleActivityDestroy(Activity activity) {
|
||||||
sPluginManager.handleActivityDestroy(activity);
|
sPLProxy.handleActivityDestroy(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,7 +86,7 @@ public final class Factory2 {
|
|||||||
* @param savedInstanceState
|
* @param savedInstanceState
|
||||||
*/
|
*/
|
||||||
public static final void handleRestoreInstanceState(Activity activity, Bundle savedInstanceState) {
|
public static final void handleRestoreInstanceState(Activity activity, Bundle savedInstanceState) {
|
||||||
sPluginManager.handleRestoreInstanceState(activity, savedInstanceState);
|
sPLProxy.handleRestoreInstanceState(activity, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,7 +95,7 @@ public final class Factory2 {
|
|||||||
* @param service
|
* @param service
|
||||||
*/
|
*/
|
||||||
public static final void handleServiceCreate(Service service) {
|
public static final void handleServiceCreate(Service service) {
|
||||||
sPluginManager.handleServiceCreate(service);
|
sPLProxy.handleServiceCreate(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,7 +104,7 @@ public final class Factory2 {
|
|||||||
* @param service
|
* @param service
|
||||||
*/
|
*/
|
||||||
public static final void handleServiceDestroy(Service service) {
|
public static final void handleServiceDestroy(Service service) {
|
||||||
sPluginManager.handleServiceDestroy(service);
|
sPLProxy.handleServiceDestroy(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +116,7 @@ public final class Factory2 {
|
|||||||
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
||||||
*/
|
*/
|
||||||
public static final boolean startActivity(Activity activity, Intent intent) {
|
public static final boolean startActivity(Activity activity, Intent intent) {
|
||||||
return sPluginManager.startActivity(activity, intent);
|
return sPLProxy.startActivity(activity, intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,7 +131,7 @@ public final class Factory2 {
|
|||||||
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
||||||
*/
|
*/
|
||||||
public static final boolean startActivity(Context context, Intent intent, String plugin, String activity, int process, boolean download) {
|
public static final boolean startActivity(Context context, Intent intent, String plugin, String activity, int process, boolean download) {
|
||||||
return sPluginManager.startActivity(context, intent, plugin, activity, process, download);
|
return sPLProxy.startActivity(context, intent, plugin, activity, process, download);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,7 +144,7 @@ public final class Factory2 {
|
|||||||
* @see #startActivityForResult(Activity, Intent, int, Bundle)
|
* @see #startActivityForResult(Activity, Intent, int, Bundle)
|
||||||
*/
|
*/
|
||||||
public static final boolean startActivityForResult(Activity activity, Intent intent, int requestCode, Bundle options) {
|
public static final boolean startActivityForResult(Activity activity, Intent intent, int requestCode, Bundle options) {
|
||||||
return sPluginManager.startActivityForResult(activity, intent, requestCode, options);
|
return sPLProxy.startActivityForResult(activity, intent, requestCode, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,7 +154,7 @@ public final class Factory2 {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static final JSONArray fetchPlugins(String name) {
|
public static final JSONArray fetchPlugins(String name) {
|
||||||
return sPluginManager.fetchPlugins(name);
|
return sPLProxy.fetchPlugins(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,7 +167,7 @@ public final class Factory2 {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static final boolean registerDynamicClass(String className, String plugin, String type, String target) {
|
public static final boolean registerDynamicClass(String className, String plugin, String type, String target) {
|
||||||
return sPluginManager.registerDynamicClass(className, plugin, type, target);
|
return sPLProxy.registerDynamicClass(className, plugin, type, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,7 +179,7 @@ public final class Factory2 {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static final boolean registerDynamicClass(String className, String plugin, String target, Class defClass) {
|
public static final boolean registerDynamicClass(String className, String plugin, String target, Class defClass) {
|
||||||
return sPluginManager.registerDynamicClass(className, plugin, target, defClass);
|
return sPLProxy.registerDynamicClass(className, plugin, target, defClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,7 +190,7 @@ public final class Factory2 {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static final boolean isDynamicClass(String plugin, String className) {
|
public static final boolean isDynamicClass(String plugin, String className) {
|
||||||
return sPluginManager.isDynamicClass(plugin, className);
|
return sPLProxy.isDynamicClass(plugin, className);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,6 +201,6 @@ public final class Factory2 {
|
|||||||
* @return 插件名称
|
* @return 插件名称
|
||||||
*/
|
*/
|
||||||
public static final String getPluginByDynamicClass(String className) {
|
public static final String getPluginByDynamicClass(String className) {
|
||||||
return sPluginManager.getPluginByDynamicClass(className);
|
return sPLProxy.getPluginByDynamicClass(className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,152 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2017 Qihoo 360 Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
* use this file except in compliance with the License. You may obtain a copy of
|
|
||||||
* the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed To in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations under
|
|
||||||
* the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.qihoo360.i;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部框架使用
|
|
||||||
*
|
|
||||||
* @author RePlugin Team
|
|
||||||
*/
|
|
||||||
public interface IPluginActivityManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 插件的Activity创建成功后通过此方法获取其base context
|
|
||||||
* @param activity
|
|
||||||
* @param newBase
|
|
||||||
* @return 为Activity构造一个base Context
|
|
||||||
*/
|
|
||||||
Context createActivityContext(Activity activity, Context newBase);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 插件的Activity的onCreate调用前调用此方法
|
|
||||||
* @param activity
|
|
||||||
* @param savedInstanceState
|
|
||||||
*/
|
|
||||||
void handleActivityCreateBefore(Activity activity, Bundle savedInstanceState);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 插件的Activity的onCreate调用后调用此方法
|
|
||||||
* @param activity
|
|
||||||
* @param savedInstanceState
|
|
||||||
*/
|
|
||||||
void handleActivityCreate(Activity activity, Bundle savedInstanceState);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 插件的Activity的onDestroy调用后调用此方法
|
|
||||||
* @param activity
|
|
||||||
*/
|
|
||||||
void handleActivityDestroy(Activity activity);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 插件的Activity的onRestoreInstanceState调用后调用此方法
|
|
||||||
* @param activity
|
|
||||||
* @param savedInstanceState
|
|
||||||
*/
|
|
||||||
void handleRestoreInstanceState(Activity activity, Bundle savedInstanceState);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 插件的Service的onCreate调用后调用此方法
|
|
||||||
* @param service
|
|
||||||
*/
|
|
||||||
void handleServiceCreate(Service service);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 插件的Service的onDestroy调用后调用此方法
|
|
||||||
* @param service
|
|
||||||
*/
|
|
||||||
void handleServiceDestroy(Service service);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 启动一个插件中的activity
|
|
||||||
* 通过Extra参数IPluginManager.KEY_COMPATIBLE,IPluginManager.KEY_PLUGIN,IPluginManager.KEY_ACTIVITY,IPluginManager.KEY_PROCESS控制
|
|
||||||
* @param activity Activity上下文
|
|
||||||
* @param intent
|
|
||||||
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
|
||||||
*/
|
|
||||||
boolean startActivity(Activity activity, Intent intent);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 启动一个插件中的activity,如果插件不存在会触发下载界面
|
|
||||||
* @param context 应用上下文或者Activity上下文
|
|
||||||
* @param intent
|
|
||||||
* @param plugin 插件名
|
|
||||||
* @param activity 待启动的activity类名
|
|
||||||
* @param process 是否在指定进程中启动
|
|
||||||
* @param download 下载
|
|
||||||
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
|
||||||
*/
|
|
||||||
boolean startActivity(Context context, Intent intent, String plugin, String activity, int process, boolean download);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 返回所有插件的json串,格式见plugins-builtin.json文件
|
|
||||||
* @param name 插件名,传null或者空串表示获取全部
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JSONArray fetchPlugins(String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 登记动态映射的类(6.5.0 later)
|
|
||||||
* @param className 壳类名
|
|
||||||
* @param plugin 目标插件名
|
|
||||||
* @param type 目标类的类型: activity, service, provider
|
|
||||||
* @param target 目标类名
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean registerDynamicClass(String className, String plugin, String type, String target);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 登记动态映射的类(7.7.0 later)
|
|
||||||
*/
|
|
||||||
boolean registerDynamicClass(String className, String plugin, String target, Class defClass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 查询某个类是否是动态映射的类(7.7.0 later)
|
|
||||||
*/
|
|
||||||
boolean isDynamicClass(String plugin, String className);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
* 查询某个动态映射的类对应的插件(7.7.0 later)
|
|
||||||
*/
|
|
||||||
String getPluginByDynamicClass(String className);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide 内部方法,插件框架使用
|
|
||||||
*/
|
|
||||||
boolean startActivityForResult(Activity activity, Intent intent, int requestCode, Bundle options);
|
|
||||||
}
|
|
@ -26,7 +26,6 @@ import android.text.TextUtils;
|
|||||||
import com.qihoo360.i.Factory;
|
import com.qihoo360.i.Factory;
|
||||||
import com.qihoo360.i.Factory2;
|
import com.qihoo360.i.Factory2;
|
||||||
import com.qihoo360.i.IModule;
|
import com.qihoo360.i.IModule;
|
||||||
import com.qihoo360.i.IPluginActivityManager;
|
|
||||||
import com.qihoo360.i.IPluginManager;
|
import com.qihoo360.i.IPluginManager;
|
||||||
import com.qihoo360.loader.utils.PatchClassLoaderUtils;
|
import com.qihoo360.loader.utils.PatchClassLoaderUtils;
|
||||||
import com.qihoo360.replugin.helper.LogRelease;
|
import com.qihoo360.replugin.helper.LogRelease;
|
||||||
@ -74,7 +73,7 @@ public class PMF {
|
|||||||
sPluginMgr.init();
|
sPluginMgr.init();
|
||||||
|
|
||||||
Factory.sPluginManager = PMF.getLocal();
|
Factory.sPluginManager = PMF.getLocal();
|
||||||
Factory2.sPluginManager = PMF.getInternal();
|
Factory2.sPLProxy = PMF.getInternal();
|
||||||
|
|
||||||
PatchClassLoaderUtils.patch(application);
|
PatchClassLoaderUtils.patch(application);
|
||||||
}
|
}
|
||||||
@ -112,7 +111,7 @@ public class PMF {
|
|||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static final IPluginActivityManager getInternal() {
|
public static final PluginLibraryInternalProxy getInternal() {
|
||||||
return sPluginMgr.mInternal;
|
return sPluginMgr.mInternal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ import android.text.TextUtils;
|
|||||||
|
|
||||||
import com.qihoo360.i.Factory;
|
import com.qihoo360.i.Factory;
|
||||||
import com.qihoo360.i.Factory2;
|
import com.qihoo360.i.Factory2;
|
||||||
import com.qihoo360.i.IPluginActivityManager;
|
|
||||||
import com.qihoo360.i.IPluginManager;
|
import com.qihoo360.i.IPluginManager;
|
||||||
import com.qihoo360.replugin.utils.ReflectUtils;
|
import com.qihoo360.replugin.utils.ReflectUtils;
|
||||||
import com.qihoo360.replugin.RePlugin;
|
import com.qihoo360.replugin.RePlugin;
|
||||||
@ -50,20 +49,29 @@ import static com.qihoo360.replugin.helper.LogDebug.PLUGIN_TAG;
|
|||||||
import static com.qihoo360.replugin.helper.LogRelease.LOGR;
|
import static com.qihoo360.replugin.helper.LogRelease.LOGR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* plugin-library中,通过“反射”调用的内部逻辑(如PluginActivity类的调用、Factory2等)均在此处
|
||||||
|
*
|
||||||
* @author RePlugin Team
|
* @author RePlugin Team
|
||||||
*/
|
*/
|
||||||
class PmInternalImpl implements IPluginActivityManager {
|
public class PluginLibraryInternalProxy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
PmBase mPluginMgr;
|
PmBase mPluginMgr;
|
||||||
|
|
||||||
PmInternalImpl(PmBase pm) {
|
PluginLibraryInternalProxy(PmBase pm) {
|
||||||
mPluginMgr = pm;
|
mPluginMgr = pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 启动一个插件中的activity
|
||||||
|
* 通过Extra参数IPluginManager.KEY_COMPATIBLE,IPluginManager.KEY_PLUGIN,IPluginManager.KEY_ACTIVITY,IPluginManager.KEY_PROCESS控制
|
||||||
|
* @param activity Activity上下文
|
||||||
|
* @param intent
|
||||||
|
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
||||||
|
*/
|
||||||
public boolean startActivity(Activity activity, Intent intent) {
|
public boolean startActivity(Activity activity, Intent intent) {
|
||||||
if (LOG) {
|
if (LOG) {
|
||||||
LogDebug.d(PLUGIN_TAG, "start activity: intent=" + intent);
|
LogDebug.d(PLUGIN_TAG, "start activity: intent=" + intent);
|
||||||
@ -157,7 +165,17 @@ class PmInternalImpl implements IPluginActivityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME 建议去掉plugin和activity参数,直接用intent代替
|
// FIXME 建议去掉plugin和activity参数,直接用intent代替
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 启动一个插件中的activity,如果插件不存在会触发下载界面
|
||||||
|
* @param context 应用上下文或者Activity上下文
|
||||||
|
* @param intent
|
||||||
|
* @param plugin 插件名
|
||||||
|
* @param activity 待启动的activity类名
|
||||||
|
* @param process 是否在指定进程中启动
|
||||||
|
* @param download 下载
|
||||||
|
* @return 插件机制层是否成功,例如没有插件存在、没有合适的Activity坑
|
||||||
|
*/
|
||||||
public boolean startActivity(Context context, Intent intent, String plugin, String activity, int process, boolean download) {
|
public boolean startActivity(Context context, Intent intent, String plugin, String activity, int process, boolean download) {
|
||||||
if (LOG) {
|
if (LOG) {
|
||||||
LogDebug.d(PLUGIN_TAG, "start activity: intent=" + intent + " plugin=" + plugin + " activity=" + activity + " process=" + process + " download=" + download);
|
LogDebug.d(PLUGIN_TAG, "start activity: intent=" + intent + " plugin=" + plugin + " activity=" + activity + " process=" + process + " download=" + download);
|
||||||
@ -198,7 +216,7 @@ class PmInternalImpl implements IPluginActivityManager {
|
|||||||
// Added by Jiongxuan Zhang
|
// Added by Jiongxuan Zhang
|
||||||
if (PluginStatusController.getStatus(plugin) < PluginStatusController.STATUS_OK) {
|
if (PluginStatusController.getStatus(plugin) < PluginStatusController.STATUS_OK) {
|
||||||
if (LOG) {
|
if (LOG) {
|
||||||
LogDebug.d(PLUGIN_TAG, "PmInternalImpl.startActivity(): Plugin Disabled. pn=" + plugin);
|
LogDebug.d(PLUGIN_TAG, "PluginLibraryInternalProxy.startActivity(): Plugin Disabled. pn=" + plugin);
|
||||||
}
|
}
|
||||||
return RePlugin.getConfig().getCallbacks().onPluginNotExistsForActivity(context, plugin, intent, process);
|
return RePlugin.getConfig().getCallbacks().onPluginNotExistsForActivity(context, plugin, intent, process);
|
||||||
}
|
}
|
||||||
@ -273,7 +291,6 @@ class PmInternalImpl implements IPluginActivityManager {
|
|||||||
* @param requestCode 请求码
|
* @param requestCode 请求码
|
||||||
* @param options 附加的数据
|
* @param options 附加的数据
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public boolean startActivityForResult(Activity activity, Intent intent, int requestCode, Bundle options) {
|
public boolean startActivityForResult(Activity activity, Intent intent, int requestCode, Bundle options) {
|
||||||
String plugin = getPluginName(activity, intent);
|
String plugin = getPluginName(activity, intent);
|
||||||
|
|
||||||
@ -353,7 +370,13 @@ class PmInternalImpl implements IPluginActivityManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 插件的Activity创建成功后通过此方法获取其base context
|
||||||
|
* @param activity
|
||||||
|
* @param newBase
|
||||||
|
* @return 为Activity构造一个base Context
|
||||||
|
*/
|
||||||
public Context createActivityContext(Activity activity, Context newBase) {
|
public Context createActivityContext(Activity activity, Context newBase) {
|
||||||
// PluginContainers.ActivityState state = mPluginMgr.mClient.mACM.lookupLastLoading(activity.getClass().getName());
|
// PluginContainers.ActivityState state = mPluginMgr.mClient.mACM.lookupLastLoading(activity.getClass().getName());
|
||||||
// if (state == null) {
|
// if (state == null) {
|
||||||
@ -376,7 +399,12 @@ class PmInternalImpl implements IPluginActivityManager {
|
|||||||
return plugin.mLoader.createBaseContext(newBase);
|
return plugin.mLoader.createBaseContext(newBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 插件的Activity的onCreate调用前调用此方法
|
||||||
|
* @param activity
|
||||||
|
* @param savedInstanceState
|
||||||
|
*/
|
||||||
public void handleActivityCreateBefore(Activity activity, Bundle savedInstanceState) {
|
public void handleActivityCreateBefore(Activity activity, Bundle savedInstanceState) {
|
||||||
if (LOG) {
|
if (LOG) {
|
||||||
LogDebug.d(PLUGIN_TAG, "activity create before: " + activity.getClass().getName() + " this=" + activity.hashCode() + " taskid=" + activity.getTaskId());
|
LogDebug.d(PLUGIN_TAG, "activity create before: " + activity.getClass().getName() + " this=" + activity.hashCode() + " taskid=" + activity.getTaskId());
|
||||||
@ -404,7 +432,12 @@ class PmInternalImpl implements IPluginActivityManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 插件的Activity的onCreate调用后调用此方法
|
||||||
|
* @param activity
|
||||||
|
* @param savedInstanceState
|
||||||
|
*/
|
||||||
public void handleActivityCreate(Activity activity, Bundle savedInstanceState) {
|
public void handleActivityCreate(Activity activity, Bundle savedInstanceState) {
|
||||||
if (LOG) {
|
if (LOG) {
|
||||||
LogDebug.d(PLUGIN_TAG, "activity create: " + activity.getClass().getName() + " this=" + activity.hashCode() + " taskid=" + activity.getTaskId());
|
LogDebug.d(PLUGIN_TAG, "activity create: " + activity.getClass().getName() + " this=" + activity.hashCode() + " taskid=" + activity.getTaskId());
|
||||||
@ -490,7 +523,12 @@ class PmInternalImpl implements IPluginActivityManager {
|
|||||||
ActivityInjector.inject(activity, state.plugin, state.activity);
|
ActivityInjector.inject(activity, state.plugin, state.activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 插件的Activity的onRestoreInstanceState调用后调用此方法
|
||||||
|
* @param activity
|
||||||
|
* @param savedInstanceState
|
||||||
|
*/
|
||||||
public void handleRestoreInstanceState(Activity activity, Bundle savedInstanceState) {
|
public void handleRestoreInstanceState(Activity activity, Bundle savedInstanceState) {
|
||||||
if (LOG) {
|
if (LOG) {
|
||||||
LogDebug.d(PLUGIN_TAG, "activity restore instance state: " + activity.getClass().getName());
|
LogDebug.d(PLUGIN_TAG, "activity restore instance state: " + activity.getClass().getName());
|
||||||
@ -512,7 +550,11 @@ class PmInternalImpl implements IPluginActivityManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 插件的Activity的onDestroy调用后调用此方法
|
||||||
|
* @param activity
|
||||||
|
*/
|
||||||
public void handleActivityDestroy(Activity activity) {
|
public void handleActivityDestroy(Activity activity) {
|
||||||
if (LOG) {
|
if (LOG) {
|
||||||
LogDebug.d(PLUGIN_TAG, "activity destroy: " + activity.getClass().getName() + " this=" + activity.hashCode() + " taskid=" + activity.getTaskId());
|
LogDebug.d(PLUGIN_TAG, "activity destroy: " + activity.getClass().getName() + " this=" + activity.hashCode() + " taskid=" + activity.getTaskId());
|
||||||
@ -550,17 +592,30 @@ class PmInternalImpl implements IPluginActivityManager {
|
|||||||
RePlugin.getConfig().getEventCallbacks().onActivityDestroyed(activity);
|
RePlugin.getConfig().getEventCallbacks().onActivityDestroyed(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 插件的Service的onCreate调用后调用此方法
|
||||||
|
* @param service
|
||||||
|
*/
|
||||||
public void handleServiceCreate(Service service) {
|
public void handleServiceCreate(Service service) {
|
||||||
mPluginMgr.handleServiceCreated(service);
|
mPluginMgr.handleServiceCreated(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 插件的Service的onDestroy调用后调用此方法
|
||||||
|
* @param service
|
||||||
|
*/
|
||||||
public void handleServiceDestroy(Service service) {
|
public void handleServiceDestroy(Service service) {
|
||||||
mPluginMgr.handleServiceDestroyed(service);
|
mPluginMgr.handleServiceDestroyed(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 返回所有插件的json串,格式见plugins-builtin.json文件
|
||||||
|
* @param name 插件名,传null或者空串表示获取全部
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public JSONArray fetchPlugins(String name) {
|
public JSONArray fetchPlugins(String name) {
|
||||||
JSONArray ja = new JSONArray();
|
JSONArray ja = new JSONArray();
|
||||||
synchronized (PluginTable.PLUGINS) {
|
synchronized (PluginTable.PLUGINS) {
|
||||||
@ -574,22 +629,39 @@ class PmInternalImpl implements IPluginActivityManager {
|
|||||||
return ja;
|
return ja;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 登记动态映射的类(6.5.0 later)
|
||||||
|
* @param className 壳类名
|
||||||
|
* @param plugin 目标插件名
|
||||||
|
* @param type 目标类的类型: activity, service, provider
|
||||||
|
* @param target 目标类名
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean registerDynamicClass(String className, String plugin, String type, String target) {
|
public boolean registerDynamicClass(String className, String plugin, String type, String target) {
|
||||||
return mPluginMgr.addDynamicClass(className, plugin, type, target, null);
|
return mPluginMgr.addDynamicClass(className, plugin, type, target, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 登记动态映射的类(7.7.0 later)
|
||||||
|
*/
|
||||||
public boolean registerDynamicClass(String className, String plugin, String target, Class defClass) {
|
public boolean registerDynamicClass(String className, String plugin, String target, Class defClass) {
|
||||||
return mPluginMgr.addDynamicClass(className, plugin, "", target, defClass);
|
return mPluginMgr.addDynamicClass(className, plugin, "", target, defClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 查询某个类是否是动态映射的类(7.7.0 later)
|
||||||
|
*/
|
||||||
public boolean isDynamicClass(String plugin, String className) {
|
public boolean isDynamicClass(String plugin, String className) {
|
||||||
return mPluginMgr.isDynamicClass(plugin, className);
|
return mPluginMgr.isDynamicClass(plugin, className);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* @hide 内部方法,插件框架使用
|
||||||
|
* 查询某个动态映射的类对应的插件(7.7.0 later)
|
||||||
|
*/
|
||||||
public String getPluginByDynamicClass(String className) {
|
public String getPluginByDynamicClass(String className) {
|
||||||
return mPluginMgr.getPluginByDynamicClass(className);
|
return mPluginMgr.getPluginByDynamicClass(className);
|
||||||
}
|
}
|
@ -31,7 +31,6 @@ import android.text.TextUtils;
|
|||||||
|
|
||||||
import com.qihoo360.i.Factory;
|
import com.qihoo360.i.Factory;
|
||||||
import com.qihoo360.i.IModule;
|
import com.qihoo360.i.IModule;
|
||||||
import com.qihoo360.i.IPluginActivityManager;
|
|
||||||
import com.qihoo360.i.IPluginManager;
|
import com.qihoo360.i.IPluginManager;
|
||||||
import com.qihoo360.replugin.utils.ReflectUtils;
|
import com.qihoo360.replugin.utils.ReflectUtils;
|
||||||
import com.qihoo360.mobilesafe.api.Tasks;
|
import com.qihoo360.mobilesafe.api.Tasks;
|
||||||
@ -165,7 +164,7 @@ class PmBase {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
IPluginActivityManager mInternal;
|
PluginLibraryInternalProxy mInternal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* insertNewPlugin 时使用的线程锁
|
* insertNewPlugin 时使用的线程锁
|
||||||
@ -225,7 +224,7 @@ class PmBase {
|
|||||||
mLocal = new PmLocalImpl(context, this);
|
mLocal = new PmLocalImpl(context, this);
|
||||||
|
|
||||||
//
|
//
|
||||||
mInternal = new PmInternalImpl(this);
|
mInternal = new PluginLibraryInternalProxy(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
|
Loading…
Reference in New Issue
Block a user