优化下载服务中检测apk完整性时顺便同步检查版本号是否和当前吧版本号一致,如果一致认为就是最新包不再重复安装
This commit is contained in:
parent
cfb9cca71a
commit
589e855aba
@ -188,8 +188,10 @@ public class DownloadService extends Service {
|
|||||||
if (downloadFile == null || !downloadFile.exists()) return false;
|
if (downloadFile == null || !downloadFile.exists()) return false;
|
||||||
try {
|
try {
|
||||||
PackageManager pm = mContext.getPackageManager();
|
PackageManager pm = mContext.getPackageManager();
|
||||||
|
PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), Context.MODE_PRIVATE);
|
||||||
PackageInfo info = pm.getPackageArchiveInfo(downloadFile.getAbsolutePath(), PackageManager.GET_ACTIVITIES);
|
PackageInfo info = pm.getPackageArchiveInfo(downloadFile.getAbsolutePath(), PackageManager.GET_ACTIVITIES);
|
||||||
if (info == null) return false;
|
if (info == null) return false;
|
||||||
|
if(info.versionCode == packageInfo.versionCode) return false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user