Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin uninstall functionality optimized for synchronizing multiple p… #199

Merged
merged 4 commits into from
Jul 13, 2017
Merged

Conversation

SkyEric
Copy link
Contributor

@SkyEric SkyEric commented Jul 13, 2017

…rocess plugin information

Thank you for contributing! Let's make RePlugin better and better!

Now please tell us the following info for better understanding:

Summary

Description

The issue id of this Pull Request fixes and your general idea of implementation.

@@ -74,6 +74,9 @@ public void remove(String pn) {
JSONHelper.remove(mJson, i);
}
}
if (mMap.containsKey(pn)) {
mMap.remove(pn);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是也应该清掉mList?

if (RePluginInternal.getAppContext().getApplicationContext() != null) {
IPC.sendLocalBroadcast2AllSync(RePluginInternal.getAppContext(), intent);
} else {
Tasks.init();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RePlugin.onCreate内部也调用了Tasks.init,不如挪到attachBaseContext中靠前位置,这样这里就不用调用了。

// 3. 给各进程发送广播,同步更新
final Intent intent = new Intent(PluginInfoUpdater.ACTION_UNINSTALL_PLUGIN);
intent.putExtra("obj", info);
// 注意:attachBaseContext内部获取getApplicationContext会为空,则此情况仅在UI线程进行更新
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块儿的注释还是不够清晰。建议改为:

“注意:若在attachBaseContext中调用此方法,则由于此时getApplicationContext为空,导致发送广播时会出现空指针异常。则应该Post一下,待getApplicationContext有值后再发送广播”

@@ -73,6 +73,12 @@
public static final String LOCAL_PLUGIN_APK_LIB_DIR = "p_n";

/**
* "纯APK"插件同版本升级时插件、Odex、Native(SO库)的用于覆盖的存放目录
* Added by Zhiwei Liu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议去掉Added by 字样,因为开源后的PR可以体现改动点。

@@ -201,7 +201,19 @@ private boolean verifySignature(PackageInfo pi, String path) {
}

private boolean checkVersion(PluginInfo instPli, PluginInfo curPli) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议改下返回值为int,-1为instPli小于curPli,1为instPli大于curPli,0为两者相等,这样就不必再checkVersion中做set操作了

LogDebug.d(TAG, "isSameVersion: same version. " +
"inst_ver=" + instPli.getVersion() + "; cur_ver=" + curPli.getVersion());
}
instPli.setIsPendingCover(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议改下返回值为int,-1为instPli小于curPli,1为instPli大于curPli,0为两者相等,这样就不必再checkVersion中做set操作了

if (instPli.getVersion() > curPli.getVersion()) {
// 高版本升级
instPli.setIsThisPendingUpdateInfo(true);
curPli.setPendingUpdate(instPli);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果已经要做升级了,应该需要做一次setPendingCover(null)和setPendingDelete(null),之后的操作覆盖之前的。并打个Log出来

curPli.setPendingUpdate(instPli);
} else if (instPli.getVersion() == curPli.getVersion()){
// 同版本覆盖
curPli.setPendingCover(instPli);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同理,应该setPendingDelete(null),但无需setPendingUpdate,因为在updatePendingUpdate时就已经return了(建议加个注释说明一下)

}
} finally {
try {
FileUtils.forceDelete(newPi.getApkFile().getParentFile());
Copy link
Contributor

@jiongxuan jiongxuan Jul 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议这么写,这样减少歧义:

File parentDir = newPi.getApkFile().getParentFile();
FileUtils.forceDelete(parentDir);

@jiongxuan jiongxuan merged commit fec6bab into Qihoo360:master Jul 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants