Skip to content

Commit 811dfda

Browse files
committed
The version was upgraded to v2.2.2
2 parents b9c3480 + a21eed6 commit 811dfda

File tree

147 files changed

+6917
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+6917
-83
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ If you **have any question, please [click here to read FAQ(Chinese Version)](htt
106106
<td><b><a href="http://www.jielem.com/">JieLeMa</a></b></td>
107107
</tr>
108108
<tr align="center">
109-
<td><img src="https://github.com/Qihoo360/RePlugin/wiki/img/apps/os.png" width="80" height="80"/></td>
110-
<td><img src="https://github.com/Qihoo360/RePlugin/wiki/img/apps/jietiao.png" width="80" height="80"/></td>
109+
<td><img src="https://raw.githubusercontent.com/wiki/Qihoo360/RePlugin/img/apps/qihoo_os.jpg" width="80" height="80"/></td>
110+
<td><img src="https://raw.githubusercontent.com/wiki/Qihoo360/RePlugin/img/apps/qihoo_jietiao.jpg" width="80" height="80"/></td>
111111
<td><img src="https://github.com/Qihoo360/RePlugin/wiki/img/apps/yourapps.png" width="80" height="80"/></td>
112112
<td><img src="https://github.com/Qihoo360/RePlugin/wiki/img/apps/yourapps.png" width="80" height="80"/></td>
113113
<td><img src="https://github.com/Qihoo360/RePlugin/wiki/img/apps/yourapps.png" width="80" height="80"/></td>

README_CN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ RePlugin的使用方法非常简单,大部分情况下和“单品”开发无
7575

7676
若您是**第一次接触RePlugin,则[请点击这里阅读《快速上手》](https://github.com/Qihoo360/RePlugin/wiki/%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B)**,跟随我们的指引,了解更多的内容。
7777

78-
若您想**了解更多有关RePlugin的玩法,则[请点击这里阅读《详细教程》](https://github.com/Qihoo360/RePlugin/wiki/%E8%AF%A6%E7%BB%86%E6%95%99%E7%A8%8B)**了解更多好玩的玩法。
78+
若您想**了解更多有关RePlugin的玩法,则[请点击这里阅读《详细教程》](https://github.com/Qihoo360/RePlugin/wiki/%E8%AF%A6%E7%BB%86%E6%95%99%E7%A8%8B)**了解更多好玩的玩法。
7979

8080
若您想**看下RePlugin的Sample工程,进而了解框架的具体用法,则[请点击这里查看Sample源代码](https://github.com/Qihoo360/RePlugin/blob/master/replugin-sample)**
8181

@@ -118,8 +118,8 @@ RePlugin的使用方法非常简单,大部分情况下和“单品”开发无
118118
       <td><b><a href="http://www.jielem.com/">借了吗</a></b></td>
119119
</tr>
120120
<tr align="center">
121-
<td><img src="https://github.com/Qihoo360/RePlugin/wiki/img/apps/os.png" width="80" height="80"/></td>
122-
<td><img src="https://github.com/Qihoo360/RePlugin/wiki/img/apps/jietiao.png" width="80" height="80"/></td>
121+
<td><img src="https://raw.githubusercontent.com/wiki/Qihoo360/RePlugin/img/apps/qihoo_os.jpg" width="80" height="80"/></td>
122+
<td><img src="https://raw.githubusercontent.com/wiki/Qihoo360/RePlugin/img/apps/qihoo_jietiao.jpg" width="80" height="80"/></td>
123123
<td><img src="https://github.com/Qihoo360/RePlugin/wiki/img/apps/yourapps.png" width="80" height="80"/></td>
124124
<td><img src="https://github.com/Qihoo360/RePlugin/wiki/img/apps/yourapps.png" width="80" height="80"/></td>
125125
<td><img src="https://github.com/Qihoo360/RePlugin/wiki/img/apps/yourapps.png" width="80" height="80"/></td>

replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/loader2/Loader.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,11 @@ private HashMap<String, String> getConfigProcessMap(ApplicationInfo appInfo) {
601601
private void adjustPluginProcess(ApplicationInfo appInfo) {
602602
HashMap<String, String> processMap = getConfigProcessMap(appInfo);
603603
if (processMap == null || processMap.isEmpty()) {
604-
processMap = genDynamicProcessMap();
604+
605+
PluginInfo pi = MP.getPlugin(mPluginName, false);
606+
if (pi != null && pi.getFrameworkVersion() >= 4) {
607+
processMap = genDynamicProcessMap();
608+
}
605609
}
606610

607611
if (LOG) {

replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/loader2/PmBase.java

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.content.pm.ProviderInfo;
2626
import android.content.pm.ServiceInfo;
2727
import android.os.IBinder;
28+
import android.os.Parcelable;
2829
import android.os.RemoteException;
2930
import android.support.v4.content.LocalBroadcastManager;
3031
import android.text.TextUtils;
@@ -229,6 +230,9 @@ static final void cleanIntentPluginParams(Intent intent) {
229230
}
230231

231232
void init() {
233+
234+
RePlugin.getConfig().getCallbacks().initPnPluginOverride();
235+
232236
if (HostConfigHelper.PERSISTENT_ENABLE) {
233237
// (默认)“常驻进程”作为插件管理进程,则常驻进程作为Server,其余进程作为Client
234238
if (IPC.isPersistentProcess()) {
@@ -381,12 +385,47 @@ private final void refreshPluginMap(List<PluginInfo> plugins) {
381385
}
382386
}
383387

388+
/**
389+
* 把插件Add到插件列表
390+
*
391+
* @param info 待add插件的PluginInfo对象
392+
* @param plugin 待add插件的Plugin对象
393+
*/
384394
private void putPluginObject(PluginInfo info, Plugin plugin) {
385-
// 同时加入PackageName和Alias(如有)
386-
mPlugins.put(info.getPackageName(), plugin);
387-
if (!TextUtils.isEmpty(info.getAlias())) {
388-
// 即便Alias和包名相同也可以再Put一次,反正只是覆盖了相同Value而已
389-
mPlugins.put(info.getAlias(), plugin);
395+
if (mPlugins.containsKey(info.getAlias()) || mPlugins.containsKey(info.getPackageName())) {
396+
if (LOG) {
397+
LogDebug.d(PLUGIN_TAG, "当前内置插件列表中已经有" + info.getName() + ",需要看看谁的版本号大。");
398+
}
399+
400+
// 找到已经存在的
401+
Plugin existedPlugin = mPlugins.get(info.getPackageName());
402+
if (existedPlugin == null) {
403+
existedPlugin = mPlugins.get(info.getAlias());
404+
}
405+
406+
if (existedPlugin.mInfo.getVersion() < info.getVersion()) {
407+
if (LOG) {
408+
LogDebug.d(PLUGIN_TAG, "新传入的纯APK插件, name=" + info.getName() + ", 版本号比较大,ver=" + info.getVersion() + ",以TA为准。");
409+
}
410+
411+
// 同时加入PackageName和Alias(如有)
412+
mPlugins.put(info.getPackageName(), plugin);
413+
if (!TextUtils.isEmpty(info.getAlias())) {
414+
// 即便Alias和包名相同也可以再Put一次,反正只是覆盖了相同Value而已
415+
mPlugins.put(info.getAlias(), plugin);
416+
}
417+
} else {
418+
if (LOG) {
419+
LogDebug.d(PLUGIN_TAG, "新传入的纯APK插件" + info.getName() + "版本号还没有内置的大,什么都不做。");
420+
}
421+
}
422+
} else {
423+
// 同时加入PackageName和Alias(如有)
424+
mPlugins.put(info.getPackageName(), plugin);
425+
if (!TextUtils.isEmpty(info.getAlias())) {
426+
// 即便Alias和包名相同也可以再Put一次,反正只是覆盖了相同Value而已
427+
mPlugins.put(info.getAlias(), plugin);
428+
}
390429
}
391430
}
392431

@@ -1133,7 +1172,7 @@ final void newPluginFound(PluginInfo info, boolean persistNeedRestart) {
11331172

11341173
// 通知本进程:通知给外部使用者
11351174
Intent intent = new Intent(RePluginConstants.ACTION_NEW_PLUGIN);
1136-
intent.putExtra(RePluginConstants.KEY_PLUGIN_INFO, info);
1175+
intent.putExtra(RePluginConstants.KEY_PLUGIN_INFO, (Parcelable) info);
11371176
intent.putExtra(RePluginConstants.KEY_PERSIST_NEED_RESTART, persistNeedRestart);
11381177
intent.putExtra(RePluginConstants.KEY_SELF_NEED_RESTART, mNeedRestart);
11391178
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);

replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/loader2/PmHostSvc.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import android.content.pm.ActivityInfo;
2424
import android.os.Binder;
2525
import android.os.IBinder;
26+
import android.os.Parcelable;
2627
import android.os.RemoteException;
2728
import android.support.v4.content.LocalBroadcastManager;
2829
import android.text.TextUtils;
@@ -256,6 +257,10 @@ public void regReceiver(String plugin, Map rcvFilMap) throws RemoteException {
256257
return;
257258
}
258259

260+
if (rcvFilMap == null) {
261+
return;
262+
}
263+
259264
HashMap<String, List<IntentFilter>> receiverFilterMap = (HashMap<String, List<IntentFilter>>) rcvFilMap;
260265

261266
// 遍历此插件中所有静态声明的 Receiver
@@ -378,7 +383,7 @@ private void syncInstalledPluginInfo2All(PluginInfo pi) {
378383
// 通知其它进程去更新
379384
Intent intent = new Intent(PmBase.ACTION_NEW_PLUGIN);
380385
intent.putExtra(RePluginConstants.KEY_PERSIST_NEED_RESTART, mNeedRestart);
381-
intent.putExtra("obj", needToSyncPi);
386+
intent.putExtra("obj", (Parcelable) needToSyncPi);
382387
IPC.sendLocalBroadcast2AllSync(mContext, intent);
383388

384389
if (LOG) {
@@ -394,7 +399,7 @@ private void syncUninstalledPluginInfo2All(PluginInfo pi) {
394399

395400
// 给各进程发送广播,同步更新
396401
final Intent intent = new Intent(PluginInfoUpdater.ACTION_UNINSTALL_PLUGIN);
397-
intent.putExtra("obj", pi);
402+
intent.putExtra("obj", (Parcelable) pi);
398403
// 注意:若在attachBaseContext中调用此方法,则由于此时getApplicationContext为空,导致发送广播时会出现空指针异常。
399404
// 则应该Post一下,待getApplicationContext有值后再发送广播。
400405
if (RePluginInternal.getAppContext().getApplicationContext() != null) {
@@ -459,7 +464,7 @@ public boolean pluginExtracted(String path) throws RemoteException {
459464
// 通知其它进程
460465
Intent intent = new Intent(PmBase.ACTION_NEW_PLUGIN);
461466
intent.putExtra(RePluginConstants.KEY_PERSIST_NEED_RESTART, mNeedRestart);
462-
intent.putExtra("obj", info);
467+
intent.putExtra("obj", (Parcelable) info);
463468
IPC.sendLocalBroadcast2AllSync(mContext, intent);
464469

465470
return true;

replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/replugin/RePluginCallbacks.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,14 @@ public boolean isPluginBlocked(PluginInfo pluginInfo) {
167167
// Nothing, allow all
168168
return false;
169169
}
170-
}
170+
171+
/**
172+
* 为了p-n插件初始化PluginOverride逻辑,只有老插件方案使用
173+
* 可以通过该回调,在进程初始化时,设置插件的override逻辑(每个进程都会调到)
174+
*
175+
* @since 2.2.2
176+
*/
177+
public void initPnPluginOverride() {
178+
// default, do Nothing
179+
}
180+
}

replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/replugin/RePluginConfig.java

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public final class RePluginConfig {
4848
private boolean printDetailLog = false;
4949
private int defaultFrameworkVersion = 4;
5050

51+
private String hostVersionName = "";
52+
private String hostBuildID = "";
53+
54+
private boolean optimizeArtLoadDex = false;
55+
5156
/**
5257
* 获取插件回调方法。通常无需调用此方法。
5358
*
@@ -199,6 +204,66 @@ public RePluginConfig setMoveFileWhenInstalling(boolean moveFileWhenInstalling)
199204
return this;
200205
}
201206

207+
/**
208+
* 获取宿主的 BuildID
209+
*
210+
* @return 宿主的BuildID
211+
* @since 2.2.2
212+
*/
213+
public String getHostBuildID() {
214+
return hostBuildID;
215+
}
216+
217+
/**
218+
* 设置宿主的 BuildID <p>
219+
* BuildID 是一个比 VersionName 和 VersionCode 更细的维度(例如:服务器每 build 一次,版本号加 1)
220+
*
221+
* @param buildID 宿主的BuildID
222+
* @return RePluginConfig自己。这样可以连环调用set方法
223+
* @since 2.2.2
224+
*/
225+
public RePluginConfig setHostBuild(String buildID) {
226+
if (!checkAllowModify()) {
227+
return this;
228+
}
229+
hostBuildID = buildID;
230+
return this;
231+
}
232+
233+
/**
234+
* 获取宿主的 VersionName
235+
*
236+
* @since 2.2.2
237+
*/
238+
public String getHostVersionName() {
239+
return hostVersionName;
240+
}
241+
242+
/**
243+
* 设置宿主的 VersionName
244+
*
245+
* @param versionName 宿主的VersionName
246+
* @return RePluginConfig自己。这样可以连环调用set方法
247+
* @since 2.2.2
248+
*/
249+
public RePluginConfig setHostVersionName(String versionName) {
250+
if (!checkAllowModify()) {
251+
return this;
252+
}
253+
hostVersionName = versionName;
254+
return this;
255+
}
256+
257+
/**
258+
* 获取宿主的VersionBuild号
259+
*
260+
* @return
261+
* @since 2.2.2
262+
*/
263+
public String getHostVersionBuild() {
264+
return RePlugin.getConfig().getHostVersionName() + "." + RePlugin.getConfig().getHostBuildID();
265+
}
266+
202267
/**
203268
* 是否打印更详细的日志?
204269
*
@@ -274,4 +339,28 @@ private boolean checkAllowModify() {
274339
}
275340
return true;
276341
}
277-
}
342+
343+
/**
344+
* 是否在Art上对首次加载插件速度做优化
345+
*
346+
* @return
347+
*/
348+
public boolean isOptimizeArtLoadDex() {
349+
return optimizeArtLoadDex;
350+
}
351+
352+
/**
353+
* 是否在Art上对首次加载插件速度做优化,默认为false
354+
*
355+
* @param optimizeArtLoadDex
356+
* @return
357+
* @since 2.2.2
358+
*/
359+
public RePluginConfig setOptimizeArtLoadDex(boolean optimizeArtLoadDex) {
360+
if (!checkAllowModify()) {
361+
return this;
362+
}
363+
this.optimizeArtLoadDex = optimizeArtLoadDex;
364+
return this;
365+
}
366+
}

replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/replugin/component/service/server/PluginServiceServer.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,13 @@ public void handleMessage(Message msg) {
105105
Bundle data = msg.getData();
106106
Intent intent = data.getParcelable("intent");
107107

108-
if (intent != null) {
109-
ServiceRecord sr = retrieveServiceLocked(intent);
110-
if (sr != null) {
111-
sr.service.onStartCommand(intent, 0, 0);
112-
} else {
113-
if (LOG) {
114-
LogDebug.e(PLUGIN_TAG, "pss.onStartCommand fail.");
115-
}
108+
ServiceRecord sr = (ServiceRecord)msg.obj;
109+
110+
if (intent != null && sr != null) {
111+
sr.service.onStartCommand(intent, 0, 0);
112+
}else{
113+
if (LOG) {
114+
LogDebug.e(PLUGIN_TAG, "pss.onStartCommand fail.");
116115
}
117116
}
118117
break;
@@ -152,7 +151,7 @@ ComponentName startServiceLocked(Intent intent, Messenger client) {
152151
Bundle data = new Bundle();
153152
data.putParcelable("intent", intent);
154153
message.setData(data);
155-
154+
message.obj = sr;
156155
mHandler.sendMessage(message);
157156

158157
return cn;

replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/replugin/component/service/server/ServiceRecord.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
/**
3131
* 用来表示一个Service对象的信息
3232
* 包含绑定此Service的连接信息、Intent绑定信息等
33-
*
33+
* <p>
3434
* NOTE 类似于Android的ServiceRecord
3535
*
3636
* @author RePlugin Team
@@ -110,7 +110,7 @@ public boolean hasAutoCreateConnections() {
110110

111111
@Override
112112
public String toString() {
113-
return "[srv=" + service.getClass().getName() + "; startRequested=" + startRequested + "; bindings=(" + bindings.size() + ") " + bindings + "]";
113+
return "[srv=" + service == null ? "null" : service.getClass().getName() + "; startRequested=" + startRequested + "; bindings=(" + bindings.size() + ") " + bindings + "]";
114114
}
115115

116116
public String getPlugin() {

0 commit comments

Comments
 (0)