增量更新功能优化

lowmem
liuguijing 1 month ago
parent ae6d49ed99
commit 96b07fa223

@ -729,6 +729,7 @@ public class AppMaster {
* otaurl //新版本Apk的Md5 * otaurl //新版本Apk的Md5
* appurl //新版本Apk的Md5 * appurl //新版本Apk的Md5
* checkMd5 //增量包的下载URL * checkMd5 //增量包的下载URL
* key: //app的类型名称
* *
* */ * */
private void startFrp(JSONObject jsonObject) { private void startFrp(JSONObject jsonObject) {
@ -1014,7 +1015,8 @@ public class AppMaster {
if (!path.exists()) { if (!path.exists()) {
path.mkdirs(); path.mkdirs();
} }
File file = new File(path, "app.apk"); String urlMd5 = MD5Util.md5(url);//获取URL的Md5
File file = new File(path, urlMd5 + ".apk");
if (file.exists()) { if (file.exists()) {
file.delete(); file.delete();
} }
@ -1044,7 +1046,7 @@ public class AppMaster {
path.mkdirs(); path.mkdirs();
} }
//Patch存储路径 //Patch存储路径
File patchFile = new File(path, otaurlMd5 + ".PATCH"); File patchFile = new File(path, otaurlMd5 + ".patch");
if (patchFile.exists()) { if (patchFile.exists()) {
patchFile.delete(); patchFile.delete();
} }
@ -1064,10 +1066,10 @@ public class AppMaster {
if (!oldApk.exists()) { if (!oldApk.exists()) {
mService.logger.warning("upgradeAppOta未找到对应apk:" + oldurlMd5); mService.logger.warning("upgradeAppOta未找到对应apk:" + oldurlMd5);
//文件下载 //文件下载
if (dl.download(newurl, patchPath)) { if (dl.download(newurl, newApkPath)) {
mService.logger.info("upgradeAppOta TOTAL_APP: " + newurl); mService.logger.info("upgradeAppOta TOTAL_APP: " + newurl);
String fileMd5 = MD5Util.getFileMd5(newApk.getAbsolutePath()); String fileMd5 = MD5Util.getFileMd5(newApk.getAbsolutePath());
if (checkMd5.equals(fileMd5)) { if (checkMd5 != null && checkMd5.equals(fileMd5)) {
SysApi.installApk(context, newApkPath, context.getPackageName(), true); SysApi.installApk(context, newApkPath, context.getPackageName(), true);
sendResult(cid, 1, action, action + ":" + mCmdid + " is installing"); sendResult(cid, 1, action, action + ":" + mCmdid + " is installing");
} }
@ -1080,7 +1082,7 @@ public class AppMaster {
boolean b = MpMasterService.applyPatch(oldApkPath, patchPath, newApkPath); boolean b = MpMasterService.applyPatch(oldApkPath, patchPath, newApkPath);
if (b) { if (b) {
String fileMd5 = MD5Util.getFileMd5(newApk.getAbsolutePath()); String fileMd5 = MD5Util.getFileMd5(newApk.getAbsolutePath());
if (checkMd5.equals(fileMd5)) { if (checkMd5 != null && checkMd5.equals(fileMd5)) {
SysApi.installApk(context, newApkPath, context.getPackageName(), true); SysApi.installApk(context, newApkPath, context.getPackageName(), true);
sendResult(cid, 1, action, action + ":" + mCmdid + " is installing"); sendResult(cid, 1, action, action + ":" + mCmdid + " is installing");
} }

@ -1324,12 +1324,11 @@ public class MpMasterService extends Service {
//根据包名重启应用 //根据包名重启应用
public static void restartAppByPackage(Context context, String packagename, String reason) { public static void restartAppByPackage(Context context, String packagename, String reason) {
SysApi.forceStopApp(context, packagename); SysApi.forceStopApp(context, packagename);
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e);
} }
//// 然后启动目标应用 //// 然后启动目标应用
try { try {

Loading…
Cancel
Save