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
6f0fae5b
authored
Mar 17, 2020
by
pye52
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'new_master' into new_for_phone
parents
a0f9d013
3c5f689c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
18 deletions
+5
-18
app/src/main/java/com/bgycc/smartcanteen/listener/DownloadProgressListener.java
+0
-10
app/src/main/java/com/bgycc/smartcanteen/utils/InstallManager.java
+5
-8
No files found.
app/src/main/java/com/bgycc/smartcanteen/listener/DownloadProgressListener.java
deleted
100644 → 0
View file @
a0f9d013
package
com
.
bgycc
.
smartcanteen
.
listener
;
public
interface
DownloadProgressListener
{
/**
* @param progress 已经下载或上传字节数
* @param total 总字节数
* @param done 是否完成
*/
void
onProgress
(
long
progress
,
long
total
,
boolean
done
);
}
app/src/main/java/com/bgycc/smartcanteen/utils/InstallManager.java
View file @
6f0fae5b
...
...
@@ -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
);
...
...
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