Matthew 1 month ago
commit fc7fc294eb

@ -715,9 +715,10 @@ public class AppMaster {
String otaurl = jsonObject.optString("otaurl", null);
String oldurl = jsonObject.optString("oldurl", null);
String appurl = jsonObject.optString("appurl", null);
String checkMd5 = jsonObject.optString("checkMd5", null);
String checkMd5 = jsonObject.optString("md5", null);
String key = jsonObject.optString("key", null);
if (!TextUtils.isEmpty(otaurl)) {
upgradeAppOta(cid, cmd, otaurl, oldurl, appurl, checkMd5);
upgradeAppOta(cid, cmd, otaurl, oldurl, appurl, checkMd5, key);
}
}
}
@ -1033,7 +1034,7 @@ public class AppMaster {
}
}
private void upgradeAppOta(long cid, String action, String otaurl, String oldurl, String newurl, String checkMd5) {
private void upgradeAppOta(long cid, String action, String otaurl, String oldurl, String newurl, String checkMd5, String key) {
mService.logger.warning("Recv upgradeAppOta Cmd: url=" + otaurl);
if (StringUtils.isEmpty(otaurl) || StringUtils.isEmpty(oldurl) || StringUtils.isEmpty(newurl)) {
mService.logger.warning("upgradeAppOta otaurl,oldurl或者newurl缺失");
@ -1046,7 +1047,7 @@ public class AppMaster {
path.mkdirs();
}
//Patch存储路径
File patchFile = new File(path, otaurlMd5 + ".patch");
File patchFile = new File(path, key + "_" + otaurlMd5 + ".patch");
if (patchFile.exists()) {
patchFile.delete();
}
@ -1055,11 +1056,14 @@ public class AppMaster {
//老的Apk路径
String oldurlMd5 = MD5Util.md5(oldurl);//获取URL的Md5
File oldApk = new File(path, oldurlMd5 + ".apk");
if (!oldApk.exists()) {
oldApk = new File(path, key + "_" + oldurlMd5 + ".apk");
}
String oldApkPath = oldApk.getAbsolutePath();
//新的Apk路径
String newurlMd5 = MD5Util.md5(newurl);//获取URL的Md5
File newApk = new File(path, newurlMd5 + ".apk");
File newApk = new File(path, key + "_" + newurlMd5 + ".apk");
String newApkPath = newApk.getAbsolutePath();
FileDownloader dl = new FileDownloader();
@ -1083,6 +1087,9 @@ public class AppMaster {
if (b) {
String fileMd5 = MD5Util.getFileMd5(newApk.getAbsolutePath());
if (checkMd5 != null && checkMd5.equals(fileMd5)) {
//删除增量更新包和老的apk包
patchFile.delete();
oldApk.delete();
SysApi.installApk(context, newApkPath, context.getPackageName(), true);
sendResult(cid, 1, action, action + ":" + mCmdid + " is installing");
}

Loading…
Cancel
Save