Commit 772d3721 by pye52

更新包下载目录更改为cache目录后,下载的更新包需要修改权限才能进入安装状态

parent 9a36e6e2
package com.bgycc.smartcanteen.command;
import android.os.Build;
import com.bgycc.smartcanteen.BuildConfig;
import com.bgycc.smartcanteen.api.SCRetrofit;
import com.bgycc.smartcanteen.entity.Command;
......@@ -165,9 +167,23 @@ public class UpdateCommandHandler extends CommandHandler {
LogUtils.d(TAG, "不允许安装低版本");
failed("不允许安装低版本", 0);
} else {
DangerousUtils.installAppSilent(updateApk);
LogUtils.d(TAG, "开始安装");
success("开始安装", 100);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
// 6.0以下安装包需要修改权限才能安装
try {
Process p = Runtime.getRuntime().exec("chmod 755 " + updateApk);
p.waitFor();
DangerousUtils.installAppSilent(updateApk);
LogUtils.d(TAG, "开始安装");
success("开始安装", 100);
} catch (Exception e) {
LogUtils.e(TAG, "安装文件权限修改失败");
failed("安装文件权限修改失败", 0);
}
} else {
DangerousUtils.installAppSilent(updateApk);
LogUtils.d(TAG, "开始安装");
success("开始安装", 100);
}
}
try {
Thread.sleep(DEFAULT_DELAY);
......
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