mirror of
https://gitee.com/replugin/RePlugin.git
synced 2024-12-04 04:38:25 +08:00
Fixed an issue that could cause a crash when opening an Activity in Intent-Filter mode
This commit is contained in:
parent
71dbe4159e
commit
610ddf5f0d
@ -229,7 +229,7 @@ class Loader {
|
|||||||
mComponents = Plugin.queryCachedComponentList(mPath);
|
mComponents = Plugin.queryCachedComponentList(mPath);
|
||||||
if (mComponents == null) {
|
if (mComponents == null) {
|
||||||
// ComponentList
|
// ComponentList
|
||||||
mComponents = new ComponentList(mPackageInfo, mPath, mPluginName);
|
mComponents = new ComponentList(mPackageInfo, mPath, mPluginObj.mInfo);
|
||||||
|
|
||||||
// 动态注册插件中声明的 receiver
|
// 动态注册插件中声明的 receiver
|
||||||
regReceivers();
|
regReceivers();
|
||||||
|
@ -21,6 +21,7 @@ import android.os.PatternMatcher;
|
|||||||
|
|
||||||
import com.qihoo360.mobilesafe.parser.manifest.bean.ComponentBean;
|
import com.qihoo360.mobilesafe.parser.manifest.bean.ComponentBean;
|
||||||
import com.qihoo360.replugin.helper.LogDebug;
|
import com.qihoo360.replugin.helper.LogDebug;
|
||||||
|
import com.qihoo360.replugin.model.PluginInfo;
|
||||||
|
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
@ -67,23 +68,23 @@ public enum ManifestParser {
|
|||||||
/**
|
/**
|
||||||
* 解析 AndroidManifest
|
* 解析 AndroidManifest
|
||||||
*
|
*
|
||||||
* @param plugin 插件名称
|
* @param pli 插件信息
|
||||||
* @param manifestStr AndroidManifest.xml 字符串
|
* @param manifestStr AndroidManifest.xml 字符串
|
||||||
*/
|
*/
|
||||||
public void parse(String plugin, String manifestStr) {
|
public void parse(PluginInfo pli, String manifestStr) {
|
||||||
XmlHandler handler = parseManifest(manifestStr);
|
XmlHandler handler = parseManifest(manifestStr);
|
||||||
|
|
||||||
Map<String, List<IntentFilter>> activityFilterMap = new HashMap<>();
|
Map<String, List<IntentFilter>> activityFilterMap = new HashMap<>();
|
||||||
mPluginActivityInfoMap.put(plugin, activityFilterMap);
|
putToMap(mPluginActivityInfoMap, activityFilterMap, pli);
|
||||||
parseComponent(plugin, activityFilterMap, handler.getActivities(), mActivityActionPluginsMap);
|
parseComponent(pli.getName(), activityFilterMap, handler.getActivities(), mActivityActionPluginsMap);
|
||||||
|
|
||||||
Map<String, List<IntentFilter>> serviceFilterMap = new HashMap<>();
|
Map<String, List<IntentFilter>> serviceFilterMap = new HashMap<>();
|
||||||
mPluginServiceInfoMap.put(plugin, serviceFilterMap);
|
putToMap(mPluginServiceInfoMap, serviceFilterMap, pli);
|
||||||
parseComponent(plugin, serviceFilterMap, handler.getServices(), mServiceActionPluginsMap);
|
parseComponent(pli.getName(), serviceFilterMap, handler.getServices(), mServiceActionPluginsMap);
|
||||||
|
|
||||||
Map<String, List<IntentFilter>> receiverFilterMap = new HashMap<>();
|
Map<String, List<IntentFilter>> receiverFilterMap = new HashMap<>();
|
||||||
mPluginReceiverInfoMap.put(plugin, receiverFilterMap);
|
putToMap(mPluginReceiverInfoMap, receiverFilterMap, pli);
|
||||||
parseComponent(plugin, receiverFilterMap, handler.getReceivers(), null);
|
parseComponent(pli.getName(), receiverFilterMap, handler.getReceivers(), null);
|
||||||
|
|
||||||
/* 打印日志 */
|
/* 打印日志 */
|
||||||
if (LOG) {
|
if (LOG) {
|
||||||
@ -91,6 +92,11 @@ public enum ManifestParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void putToMap(Map<String, Map<String, List<IntentFilter>>> infoMap, Map<String, List<IntentFilter>> filterMap, PluginInfo pi) {
|
||||||
|
infoMap.put(pi.getPackageName(), filterMap);
|
||||||
|
infoMap.put(pi.getAlias(), filterMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parseComponent
|
* parseComponent
|
||||||
*
|
*
|
||||||
|
@ -34,6 +34,7 @@ import com.qihoo360.replugin.component.utils.ApkCommentReader;
|
|||||||
import com.qihoo360.replugin.component.utils.IntentMatcherHelper;
|
import com.qihoo360.replugin.component.utils.IntentMatcherHelper;
|
||||||
import com.qihoo360.replugin.ext.parser.ApkParser;
|
import com.qihoo360.replugin.ext.parser.ApkParser;
|
||||||
import com.qihoo360.replugin.helper.LogDebug;
|
import com.qihoo360.replugin.helper.LogDebug;
|
||||||
|
import com.qihoo360.replugin.model.PluginInfo;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -92,7 +93,7 @@ public class ComponentList {
|
|||||||
* 初始化ComponentList对象 <p>
|
* 初始化ComponentList对象 <p>
|
||||||
* 注意:仅框架内部使用
|
* 注意:仅框架内部使用
|
||||||
*/
|
*/
|
||||||
public ComponentList(PackageInfo pi, String path, String plugin) {
|
public ComponentList(PackageInfo pi, String path, PluginInfo pli) {
|
||||||
if (pi.activities != null) {
|
if (pi.activities != null) {
|
||||||
for (ActivityInfo ai : pi.activities) {
|
for (ActivityInfo ai : pi.activities) {
|
||||||
if (LOG) {
|
if (LOG) {
|
||||||
@ -157,11 +158,11 @@ public class ComponentList {
|
|||||||
String manifest = getManifestFromApk(path);
|
String manifest = getManifestFromApk(path);
|
||||||
|
|
||||||
if (LOG) {
|
if (LOG) {
|
||||||
LogDebug.d(PLUGIN_TAG, "\n解析插件 " + plugin + " : " + path + "\nAndroidManifest: \n" + manifest);
|
LogDebug.d(PLUGIN_TAG, "\n解析插件 " + pli.getName() + " : " + path + "\nAndroidManifest: \n" + manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成组件与 IntentFilter 的对应关系
|
// 生成组件与 IntentFilter 的对应关系
|
||||||
ManifestParser.INS.parse(plugin, manifest);
|
ManifestParser.INS.parse(pli, manifest);
|
||||||
|
|
||||||
mApplication = pi.applicationInfo;
|
mApplication = pi.applicationInfo;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user