添加简单的更新控制

This commit is contained in:
juntao
2022-05-26 16:56:28 +08:00
parent 8e0dcd74e5
commit 26b0f33f1c
7 changed files with 131 additions and 50 deletions

View File

@ -22,13 +22,18 @@ import com.android.apksig.ApkVerifier;
import com.android.apksig.internal.apk.ApkSigningBlockUtilsLite;
import com.g00fy2.versioncompare.Version;
import com.gh.common.xapk.XapkInstaller;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.core.utils.SentryHelper;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.GameUpdateEntity;
import com.gh.gamecenter.manager.PackagesManager;
import com.gh.vspace.VHelper;
import com.halo.assistant.HaloApp;
import com.lightgame.download.DownloadEntity;
import com.lightgame.utils.Utils;
import net.dongliu.apk.parser.ApkFile;
@ -113,6 +118,19 @@ public class PackageUtils {
// 根据版本判断是否需要更新
shouldShowUpdate = new Version(versionFromRequest).isHigherThan(versionFromInstalledApp);
// 畅玩游戏根据 md5 是否一致确定是否需要更新
if (gameEntity.isVGame()) {
DownloadEntity entity = VHelper.getVGameSnapshot(apkEntity.getPackageName());
if (entity != null) {
String md5FromInstalledVGame = ExtensionsKt.getMetaExtra(entity, Constants.APK_MD5);
String md5FromRequest = apkEntity.getMd5();
if (md5FromRequest!= null && md5FromRequest.equals(md5FromInstalledVGame)) {
shouldShowUpdate = true;
}
}
}
// versionName 没法判定的时候尝试使用 versionCode 去判断
if (!shouldShowUpdate && versionCodeFromRequest != 0) {
shouldShowUpdate = versionCodeFromRequest > versionCodeFromInstalledApp;
@ -130,6 +148,8 @@ public class PackageUtils {
updateEntity.setUrl(apkEntity.getUrl());
updateEntity.setPlatform(apkEntity.getPlatform());
updateEntity.setEtag(apkEntity.getEtag());
updateEntity.setMd5(apkEntity.getMd5());
updateEntity.setDownloadStatus(gameEntity.getDownloadStatus());
updateEntity.setBrief(gameEntity.getBrief());
updateEntity.setTagStyle(gameEntity.getTagStyle());
updateEntity.setIndexPlugin(gameEntity.getIndexPlugin());