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
072f0164
authored
Mar 13, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整合new_master多机型安装方案
parent
4c0691ea
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
3 deletions
+60
-3
app/src/main/java/com/bgycc/smartcanteen/action/UpdateAction.kt
+2
-1
app/src/main/java/com/bgycc/smartcanteen/task/QRCodeTask.java
+2
-2
app/src/main/java/com/bgycc/smartcanteen/util/DangerousUtils.java
+0
-0
app/src/main/java/com/bgycc/smartcanteen/util/DeviceProxy.java
+23
-0
app/src/main/java/com/bgycc/smartcanteen/util/InstallManager.java
+33
-0
No files found.
app/src/main/java/com/bgycc/smartcanteen/action/UpdateAction.kt
View file @
072f0164
...
...
@@ -3,6 +3,7 @@ package com.bgycc.smartcanteen.action
import
com.bgycc.smartcanteen.BuildConfig
import
com.bgycc.smartcanteen.event.SettingStateEvent
import
com.bgycc.smartcanteen.helper.TimerHelper
import
com.bgycc.smartcanteen.util.InstallManager
import
com.blankj.utilcode.util.*
import
okhttp3.Call
import
okhttp3.OkHttpClient
...
...
@@ -88,7 +89,7 @@ class UpdateAction private constructor() : Action(ActionEnum.CONFIG_UPDATE.name)
EventBus
.
getDefault
().
post
(
SettingStateEvent
(
99
,
"不允许安装低版本"
))
}
else
{
EventBus
.
getDefault
().
post
(
SettingStateEvent
(
99
,
"安装更新包"
))
AppUtils
.
installApp
(
FILE_UPDATE_APK
)
InstallManager
.
install
(
FILE_UPDATE_APK
)
}
finish
()
return
...
...
app/src/main/java/com/bgycc/smartcanteen/task/QRCodeTask.java
View file @
072f0164
...
...
@@ -8,9 +8,9 @@ import com.bgycc.smartcanteen.event.LogEvent;
import
com.bgycc.smartcanteen.event.QRCodeInvalidEvent
;
import
com.bgycc.smartcanteen.helper.TimerHelper
;
import
com.bgycc.smartcanteen.qrcode.IQRCodeScan
;
import
com.bgycc.smartcanteen.qrcode.QRCodeScanFactory
;
import
com.bgycc.smartcanteen.server.websocket.MainWebSocket
;
import
com.bgycc.smartcanteen.util.ByteUtil
;
import
com.bgycc.smartcanteen.util.DeviceProxy
;
import
com.blankj.utilcode.util.LogUtils
;
import
org.greenrobot.eventbus.EventBus
;
...
...
@@ -53,7 +53,7 @@ public class QRCodeTask {
if
(
mScanAsyncTask
==
null
)
{
try
{
serial
=
QRCodeScanFactory
.
create
();
serial
=
DeviceProxy
.
createQRCodeScan
();
}
catch
(
Exception
e
)
{
LogUtils
.
file
(
"串口初始化失败"
);
}
...
...
app/src/main/java/com/bgycc/smartcanteen/util/DangerousUtils.java
0 → 100644
View file @
072f0164
This diff is collapsed.
Click to expand it.
app/src/main/java/com/bgycc/smartcanteen/util/DeviceProxy.java
0 → 100644
View file @
072f0164
package
com
.
bgycc
.
smartcanteen
.
util
;
import
com.bgycc.smartcanteen.qrcode.IQRCodeScan
;
import
com.bgycc.smartcanteen.qrcode.QRCodeScanFactory
;
import
java.io.File
;
/**
* 多设备相关方案的代理类 <br/>
* 设计该代理类目的是为了增加设备时,务必在下面所有方法的实际执行里进行适配
*/
public
class
DeviceProxy
{
public
static
final
String
DEVICE_MODEL_TPS
=
"TPS"
;
public
static
final
String
DEVICE_MODEL_QUAD
=
"QUAD"
;
public
static
IQRCodeScan
createQRCodeScan
()
throws
Exception
{
return
QRCodeScanFactory
.
create
();
}
public
static
boolean
updateApp
(
File
updateApk
)
{
return
InstallManager
.
install
(
updateApk
);
}
}
app/src/main/java/com/bgycc/smartcanteen/util/InstallManager.java
0 → 100644
View file @
072f0164
package
com
.
bgycc
.
smartcanteen
.
util
;
import
android.os.Build
;
import
com.blankj.utilcode.util.AppUtils
;
import
com.blankj.utilcode.util.LogUtils
;
import
java.io.File
;
public
class
InstallManager
{
public
static
boolean
install
(
File
updateApk
)
{
String
model
=
Build
.
MODEL
;
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
M
)
{
// 6.0以下安装包需要修改权限才能安装
try
{
Process
p
=
Runtime
.
getRuntime
().
exec
(
"chmod 755 "
+
updateApk
);
p
.
waitFor
();
LogUtils
.
d
(
"InstallManager"
,
"开始安装"
);
}
catch
(
Exception
e
)
{
LogUtils
.
e
(
"InstallManager"
,
"安装文件权限修改失败"
);
return
false
;
}
}
if
(
model
.
contains
(
DeviceProxy
.
DEVICE_MODEL_TPS
))
{
return
DangerousUtils
.
installAppSilent
(
updateApk
);
}
else
if
(
model
.
contains
(
DeviceProxy
.
DEVICE_MODEL_QUAD
))
{
AppUtils
.
installApp
(
updateApk
);
return
true
;
}
else
{
throw
new
RuntimeException
(
"不明设备型号: "
+
model
);
}
}
}
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