Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
633e3868
authored
May 14, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、修复更新时更新文件地址问题
2、增加执行更新指令时的日志输出
parent
78c022e6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletions
+5
-1
app/src/main/java/com/bgycc/smartcanteen/command/UpdateCommandWorker.java
+5
-1
No files found.
app/src/main/java/com/bgycc/smartcanteen/command/UpdateCommandWorker.java
View file @
633e3868
...
...
@@ -37,7 +37,7 @@ import static com.bgycc.smartcanteen.utils.SmartCanteenUtils.TAG;
*/
public
class
UpdateCommandWorker
extends
CommandWorker
{
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
long
INSTALL_DELAY
=
500
;
...
...
@@ -75,6 +75,7 @@ public class UpdateCommandWorker extends CommandWorker {
Response
response
=
client
.
newCall
(
request
).
execute
();
ResponseBody
body
=
response
.
body
();
if
(
body
==
null
)
{
LogUtils
.
w
(
TAG
,
"更新包数据为空"
);
return
failed
(
"更新包异常"
);
}
...
...
@@ -100,6 +101,7 @@ public class UpdateCommandWorker extends CommandWorker {
body
.
close
();
}
catch
(
IOException
e
)
{
f
.
deleteOnExit
();
LogUtils
.
w
(
TAG
,
"更新包下载失败: "
+
e
.
getMessage
(),
e
);
return
failed
(
"更新包下载失败"
);
}
finally
{
if
(
is
!=
null
)
{
...
...
@@ -122,6 +124,7 @@ public class UpdateCommandWorker extends CommandWorker {
LogUtils
.
d
(
TAG
,
"更新包下载成功,开始安装: "
+
(
info
==
null
?
"null"
:
info
.
getPackageName
()));
if
(
info
==
null
||
!
info
.
getPackageName
().
equals
(
BuildConfig
.
APPLICATION_ID
))
{
FileUtils
.
delete
(
updateApk
);
LogUtils
.
w
(
TAG
,
"安装包包名异常"
);
return
failed
(
"安装包包名异常"
);
}
if
(
info
.
getVersionCode
()
==
BuildConfig
.
VERSION_CODE
)
{
...
...
@@ -132,6 +135,7 @@ public class UpdateCommandWorker extends CommandWorker {
LogUtils
.
d
(
TAG
,
"不允许安装低版本"
);
inProgress
(
"不允许安装低版本"
);
}
else
{
LogUtils
.
d
(
TAG
,
"开始安装更新包: "
+
updateApk
.
getAbsolutePath
());
if
(
DeviceProxy
.
updateApp
(
updateApk
))
{
inProgress
(
"开始安装"
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment