-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Changes from 1 commit
e06f331
f2d71d5
75e9d4e
d2f85fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import com.qihoo360.loader2.CertUtils; | ||
import com.qihoo360.loader2.MP; | ||
import com.qihoo360.loader2.PluginNativeLibsHelper; | ||
import com.qihoo360.mobilesafe.api.Tasks; | ||
import com.qihoo360.mobilesafe.utils.pkg.PackageFilesUtil; | ||
import com.qihoo360.replugin.RePlugin; | ||
import com.qihoo360.replugin.RePluginEventCallbacks; | ||
|
@@ -340,10 +341,8 @@ private boolean updateIfNeeded(PluginInfo curInfo) { | |
LogDebug.d(TAG, "updateIfNeeded: delete plugin. pn=" + curInfo.getName()); | ||
} | ||
|
||
// 移除插件及其已释放的Dex、Native库等文件 | ||
PackageFilesUtil.forceDelete(curInfo.getPendingDelete()); | ||
mList.remove(curInfo.getName()); | ||
return true; | ||
// 移除插件及其已释放的Dex、Native库等文件并向各进程发送广播,同步更新 | ||
return uninstallNow(curInfo.getPendingDelete()); | ||
|
||
} else if (curInfo.isNeedUpdate()) { | ||
// 需要更新插件?那就直接来 | ||
|
@@ -436,14 +435,25 @@ private boolean uninstallNow(PluginInfo info) { | |
// 1. 移除插件及其已释放的Dex、Native库等文件 | ||
PackageFilesUtil.forceDelete(info); | ||
|
||
// 2. 给各进程发送广播,同步更新 | ||
Intent intent = new Intent(PluginInfoUpdater.ACTION_UNINSTALL_PLUGIN); | ||
intent.putExtra("obj", info); | ||
IPC.sendLocalBroadcast2AllSync(RePluginInternal.getAppContext(), intent); | ||
|
||
// 3. 保存插件信息到文件中 | ||
// 2. 保存插件信息到文件中 | ||
mList.remove(info.getName()); | ||
mList.save(mContext); | ||
|
||
// 3. 给各进程发送广播,同步更新 | ||
final Intent intent = new Intent(PluginInfoUpdater.ACTION_UNINSTALL_PLUGIN); | ||
intent.putExtra("obj", info); | ||
// 注意:attachBaseContext内部获取getApplicationContext会为空,则此情况仅在UI线程进行更新 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这块儿的注释还是不够清晰。建议改为: “注意:若在attachBaseContext中调用此方法,则由于此时getApplicationContext为空,导致发送广播时会出现空指针异常。则应该Post一下,待getApplicationContext有值后再发送广播” |
||
if (RePluginInternal.getAppContext().getApplicationContext() != null) { | ||
IPC.sendLocalBroadcast2AllSync(RePluginInternal.getAppContext(), intent); | ||
} else { | ||
Tasks.init(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RePlugin.onCreate内部也调用了Tasks.init,不如挪到attachBaseContext中靠前位置,这样这里就不用调用了。 |
||
Tasks.post2UI(new Runnable() { | ||
@Override | ||
public void run() { | ||
IPC.sendLocalBroadcast2All(RePluginInternal.getAppContext(), intent); | ||
} | ||
}); | ||
} | ||
return true; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是也应该清掉mList?