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
d84e8318
authored
Mar 17, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化installDaemonFromAssets方法,不再向参数传入字符串
parent
7eb29a76
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
app/src/main/java/com/bgycc/smartcanteen/utils/InstallManager.java
+5
-8
No files found.
app/src/main/java/com/bgycc/smartcanteen/utils/InstallManager.java
View file @
d84e8318
...
...
@@ -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