Commit 633e3868 by pye52

1、修复更新时更新文件地址问题

2、增加执行更新指令时的日志输出
parent 78c022e6
...@@ -37,7 +37,7 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG; ...@@ -37,7 +37,7 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
*/ */
public class UpdateCommandWorker extends CommandWorker { public class UpdateCommandWorker extends CommandWorker {
private static final String UPDATE_APK = "SmartCanteen-update.apk"; private static final String UPDATE_APK = "SmartCanteen-update.apk";
private static final String UPDATE_APK_PATH = PathUtils.getExternalStoragePath() + File.separator + UPDATE_APK; private static final String UPDATE_APK_PATH = PathUtils.getExternalStoragePath();
private static final int BUFFER_SIZE = 8 * 1024; private static final int BUFFER_SIZE = 8 * 1024;
// 下载完毕到唤起安装的延迟 // 下载完毕到唤起安装的延迟
private static final long INSTALL_DELAY = 500; private static final long INSTALL_DELAY = 500;
...@@ -75,6 +75,7 @@ public class UpdateCommandWorker extends CommandWorker { ...@@ -75,6 +75,7 @@ public class UpdateCommandWorker extends CommandWorker {
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
ResponseBody body = response.body(); ResponseBody body = response.body();
if (body == null) { if (body == null) {
LogUtils.w(TAG, "更新包数据为空");
return failed("更新包异常"); return failed("更新包异常");
} }
...@@ -100,6 +101,7 @@ public class UpdateCommandWorker extends CommandWorker { ...@@ -100,6 +101,7 @@ public class UpdateCommandWorker extends CommandWorker {
body.close(); body.close();
} catch (IOException e) { } catch (IOException e) {
f.deleteOnExit(); f.deleteOnExit();
LogUtils.w(TAG, "更新包下载失败: " + e.getMessage(), e);
return failed("更新包下载失败"); return failed("更新包下载失败");
} finally { } finally {
if (is != null) { if (is != null) {
...@@ -122,6 +124,7 @@ public class UpdateCommandWorker extends CommandWorker { ...@@ -122,6 +124,7 @@ public class UpdateCommandWorker extends CommandWorker {
LogUtils.d(TAG, "更新包下载成功,开始安装: " + (info == null ? "null" : info.getPackageName())); LogUtils.d(TAG, "更新包下载成功,开始安装: " + (info == null ? "null" : info.getPackageName()));
if (info == null || !info.getPackageName().equals(BuildConfig.APPLICATION_ID)) { if (info == null || !info.getPackageName().equals(BuildConfig.APPLICATION_ID)) {
FileUtils.delete(updateApk); FileUtils.delete(updateApk);
LogUtils.w(TAG, "安装包包名异常");
return failed("安装包包名异常"); return failed("安装包包名异常");
} }
if (info.getVersionCode() == BuildConfig.VERSION_CODE) { if (info.getVersionCode() == BuildConfig.VERSION_CODE) {
...@@ -132,6 +135,7 @@ public class UpdateCommandWorker extends CommandWorker { ...@@ -132,6 +135,7 @@ public class UpdateCommandWorker extends CommandWorker {
LogUtils.d(TAG, "不允许安装低版本"); LogUtils.d(TAG, "不允许安装低版本");
inProgress("不允许安装低版本"); inProgress("不允许安装低版本");
} else { } else {
LogUtils.d(TAG, "开始安装更新包: " + updateApk.getAbsolutePath());
if (DeviceProxy.updateApp(updateApk)) { if (DeviceProxy.updateApp(updateApk)) {
inProgress("开始安装"); inProgress("开始安装");
} else { } else {
......
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