Commit 6f0fae5b by pye52

Merge branch 'new_master' into new_for_phone

parents a0f9d013 3c5f689c
package com.bgycc.smartcanteen.listener;
public interface DownloadProgressListener {
/**
* @param progress 已经下载或上传字节数
* @param total 总字节数
* @param done 是否完成
*/
void onProgress(long progress, long total, boolean done);
}
......@@ -46,9 +46,7 @@ public class InstallManager {
// 检查守护进程的安装情况,及其安装版本
if (!AppUtils.isAppInstalled(DAEMON_PACKAGE_NAME)) {
LogUtils.d(TAG, "守护app未安装,从assets复制并进行安装");
// 安装守护进程
if (installDaemonFromAssets("守护app安装失败,启动静默安装",
"assets文件夹中未找到守护apk,或守护app复制失败,启动静默安装")) {
if (installDaemonFromAssets(false)) {
return DangerousUtils.installAppSilent(updateApk);
}
} else {
......@@ -56,8 +54,7 @@ public class InstallManager {
AppUtils.AppInfo daemonAppInfo = AppUtils.getAppInfo(DAEMON_PACKAGE_NAME);
if (daemonAppInfo.getVersionCode() < BuildConfig.DaemonVersion) {
LogUtils.d(TAG, "当前守护app版本: " + daemonAppInfo.getVersionCode() + ", 最新版本: " + BuildConfig.DaemonVersion);
if (installDaemonFromAssets("守护app更新失败,启动静默安装",
"新版app复制失败,启动静默安装")) {
if (installDaemonFromAssets(true)) {
return DangerousUtils.installAppSilent(updateApk);
}
}
......@@ -85,18 +82,18 @@ public class InstallManager {
fos.close();
}
private static boolean installDaemonFromAssets(String installFailedLog, String copyErrorLog) {
private static boolean installDaemonFromAssets(boolean update) {
File daemonApk = new File(PathUtils.getExternalStoragePath(), DAEMON_APK_NAME);
try {
copyDaemonApkToTarget(daemonApk);
boolean result = DangerousUtils.installAppSilent(daemonApk);
LogUtils.d(TAG, "守护app安装结果: " + result);
if (!result) {
LogUtils.d(TAG, installFailedLog);
LogUtils.d(TAG, "守护app" + (update ? "更新" : "安装") + "失败,启动静默安装");
return true;
}
} catch (IOException e) {
LogUtils.d(TAG, "复制安装过程出错: " + copyErrorLog, e);
LogUtils.d(TAG, update ? "assets文件夹中未找到守护apk,或守护app复制失败,启动静默安装" : "新版app复制失败,启动静默安装", e);
return true;
} finally {
FileUtils.delete(daemonApk);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment