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
4a2f1ade
authored
Oct 10, 2019
by
patpat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加扫码更新和远程更新功能
parent
9b6dfd52
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
215 additions
and
23 deletions
+215
-23
app/build.gradle
+18
-2
app/canteen.jks
+0
-0
app/src/main/AndroidManifest.xml
+15
-2
app/src/main/java/com/bgycc/smartcanteen/App.kt
+6
-0
app/src/main/java/com/bgycc/smartcanteen/action/ActionEnum.java
+1
-0
app/src/main/java/com/bgycc/smartcanteen/action/UpdateAction.kt
+88
-0
app/src/main/java/com/bgycc/smartcanteen/action/WifiAction.kt
+15
-15
app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.kt
+4
-1
app/src/main/java/com/bgycc/smartcanteen/event/SettingStateEvent.java
+3
-3
app/src/main/java/com/bgycc/smartcanteen/manager/CacheManager.kt
+32
-0
app/src/main/java/com/bgycc/smartcanteen/receiver/UpdateReceiver.kt
+24
-0
app/src/main/java/com/bgycc/smartcanteen/server/websocket/MainWebSocket.java
+7
-0
app/src/main/java/com/bgycc/smartcanteen/task/QRCodeTask.java
+2
-0
No files found.
app/build.gradle
View file @
4a2f1ade
...
@@ -10,8 +10,8 @@ android {
...
@@ -10,8 +10,8 @@ android {
applicationId
"com.bgycc.smartcanteen"
applicationId
"com.bgycc.smartcanteen"
minSdkVersion
21
minSdkVersion
21
targetSdkVersion
22
targetSdkVersion
22
versionCode
2
versionCode
5
versionName
"1.0.
2
"
versionName
"1.0.
5
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
}
buildTypes
{
buildTypes
{
...
@@ -20,6 +20,22 @@ android {
...
@@ -20,6 +20,22 @@ android {
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
}
}
}
signingConfigs
{
canteen
{
keyAlias
'town'
keyPassword
'maxrocky'
storeFile
file
(
'./canteen.jks'
)
storePassword
'maxrocky'
}
buildTypes
{
debug
{
signingConfig
signingConfigs
.
canteen
}
release
{
signingConfig
signingConfigs
.
canteen
}
}
}
sourceSets
{
sourceSets
{
main
{
main
{
jniLibs
.
srcDirs
=
[
'libs'
]
jniLibs
.
srcDirs
=
[
'libs'
]
...
...
app/canteen.jks
0 → 100644
View file @
4a2f1ade
File added
app/src/main/AndroidManifest.xml
View file @
4a2f1ade
...
@@ -7,16 +7,18 @@
...
@@ -7,16 +7,18 @@
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.CHANGE_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.CHANGE_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<application
<application
android:name=
".App"
android:name=
".App"
android:allowBackup=
"
tru
e"
android:allowBackup=
"
fals
e"
android:icon=
"@mipmap/ic_launcher"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".activity.MainActivity"
>
<activity
android:name=
".activity.MainActivity"
android:launchMode=
"singleTask"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
...
@@ -41,6 +43,16 @@
...
@@ -41,6 +43,16 @@
<!--<category android:name="android.intent.category.DEFAULT" />-->
<!--<category android:name="android.intent.category.DEFAULT" />-->
<!--</intent-filter>-->
<!--</intent-filter>-->
<!--</receiver>-->
<!--</receiver>-->
<!--<receiver android:name=".receiver.UpdateReceiver"-->
<!--android:label="@string/app_name">-->
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.PACKAGE_ADDED" />-->
<!--<action android:name="android.intent.action.PACKAGE_REPLACED" />-->
<!--<data android:scheme="package" />-->
<!--</intent-filter>-->
<!--</receiver>-->
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
app/src/main/java/com/bgycc/smartcanteen/App.kt
View file @
4a2f1ade
package
com.bgycc.smartcanteen
package
com.bgycc.smartcanteen
import
android.Manifest
import
android.app.ActivityManager
import
android.app.ActivityManager
import
android.app.Application
import
android.app.Application
import
android.content.Context
import
android.content.Context
import
com.bgycc.smartcanteen.Storage.PayStorage
import
com.bgycc.smartcanteen.Storage.PayStorage
import
com.bgycc.smartcanteen.action.UpdateAction
import
com.bgycc.smartcanteen.helper.TimerHelper
import
com.bgycc.smartcanteen.helper.TimerHelper
import
com.bgycc.smartcanteen.helper.WifiHelpler
import
com.bgycc.smartcanteen.helper.WifiHelpler
import
com.bgycc.smartcanteen.util.LogUtil
import
com.bgycc.smartcanteen.util.LogUtil
import
com.bgycc.smartcanteen.module.Device
import
com.bgycc.smartcanteen.module.Device
import
com.blankj.utilcode.constant.PermissionConstants
import
com.blankj.utilcode.util.LogUtils
import
com.blankj.utilcode.util.LogUtils
import
com.blankj.utilcode.util.PermissionUtils
import
java.lang.Exception
import
java.lang.Exception
import
kotlin.system.exitProcess
import
kotlin.system.exitProcess
...
@@ -52,6 +56,8 @@ class App : Application() {
...
@@ -52,6 +56,8 @@ class App : Application() {
WifiHelpler
.
initialize
(
this
)
WifiHelpler
.
initialize
(
this
)
PayStorage
.
initialize
(
this
)
PayStorage
.
initialize
(
this
)
Device
.
initialize
(
this
)
Device
.
initialize
(
this
)
PermissionUtils
.
permission
(
PermissionConstants
.
STORAGE
).
request
()
UpdateAction
.
getDefault
().
initialize
()
}
}
fun
isMainProcess
():
Boolean
{
fun
isMainProcess
():
Boolean
{
...
...
app/src/main/java/com/bgycc/smartcanteen/action/ActionEnum.java
View file @
4a2f1ade
...
@@ -16,6 +16,7 @@ public enum ActionEnum {
...
@@ -16,6 +16,7 @@ public enum ActionEnum {
CONFIG_LOG
,
CONFIG_LOG
,
CONFIG_POWER
,
CONFIG_POWER
,
CONFIG_WIFI
,
CONFIG_WIFI
,
CONFIG_UPDATE
,
CONFIG_SERVER
,
CONFIG_SERVER
,
CONFIG_PAYCODE_RULE
CONFIG_PAYCODE_RULE
}
}
app/src/main/java/com/bgycc/smartcanteen/action/UpdateAction.kt
0 → 100644
View file @
4a2f1ade
package
com.bgycc.smartcanteen.action
import
com.bgycc.smartcanteen.event.SettingStateEvent
import
com.bgycc.smartcanteen.helper.TimerHelper
import
com.blankj.utilcode.util.*
import
okhttp3.Call
import
okhttp3.OkHttpClient
import
okhttp3.Request
import
okhttp3.Response
import
org.greenrobot.eventbus.EventBus
import
org.json.JSONObject
import
java.io.BufferedInputStream
import
java.io.File
import
java.io.IOException
import
java.util.concurrent.TimeUnit
class
UpdateAction
private
constructor
()
:
Action
(
ActionEnum
.
CONFIG_UPDATE
.
name
)
{
companion
object
{
private
val
TAG
=
UpdateAction
::
class
.
java
.
simpleName
private
val
FILE_UPDATE_APK
=
File
(
PathUtils
.
getExternalStoragePath
(),
"SmartCanteen-update.apk"
)
private
var
sDefault
:
UpdateAction
?
=
null
@Synchronized
fun
getDefault
():
UpdateAction
{
if
(
sDefault
==
null
)
{
sDefault
=
UpdateAction
()
}
return
sDefault
!!
}
}
private
val
mHttp
=
OkHttpClient
.
Builder
()
.
connectTimeout
(
6
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
6
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
6
,
TimeUnit
.
SECONDS
)
.
build
()
private
fun
finish
()
{
TimerHelper
.
timeout
({
state
=
State
.
INITED
EventBus
.
getDefault
().
post
(
SettingStateEvent
(-
1
))
},
3000
)
}
fun
initialize
()
{
FileUtils
.
delete
(
FILE_UPDATE_APK
)
}
fun
exec
(
data
:
JSONObject
)
{
if
(
state
!=
State
.
INITED
)
return
val
url
:
String
try
{
url
=
data
.
getString
(
"url"
)
if
(
url
.
isEmpty
())
return
FILE_UPDATE_APK
.
delete
()
FILE_UPDATE_APK
.
parentFile
.
mkdirs
()
}
catch
(
e
:
IOException
)
{
return
}
EventBus
.
getDefault
().
post
(
SettingStateEvent
(
1
,
"正在下载更新包"
))
state
=
State
.
STARTED
val
request
=
Request
.
Builder
().
url
(
url
).
build
()
mHttp
.
newCall
(
request
).
enqueue
(
object
:
okhttp3
.
Callback
{
override
fun
onFailure
(
call
:
Call
,
e
:
IOException
)
{
EventBus
.
getDefault
().
post
(
SettingStateEvent
(
1
,
"更新包下载失败"
))
finish
()
}
override
fun
onResponse
(
call
:
Call
,
response
:
Response
)
{
try
{
val
body
=
response
.
body
()
!!
val
success
=
FileIOUtils
.
writeFileFromIS
(
FILE_UPDATE_APK
,
BufferedInputStream
(
body
.
byteStream
()))
if
(
success
)
{
EventBus
.
getDefault
().
post
(
SettingStateEvent
(
99
,
"安装更新包"
))
AppUtils
.
installApp
(
FILE_UPDATE_APK
)
finish
()
}
}
catch
(
e
:
Exception
)
{}
EventBus
.
getDefault
().
post
(
SettingStateEvent
(
99
,
"更新包安装失败"
))
finish
()
}
})
}
}
\ No newline at end of file
app/src/main/java/com/bgycc/smartcanteen/action/WifiAction.kt
View file @
4a2f1ade
package
com.bgycc.smartcanteen.action
package
com.bgycc.smartcanteen.action
import
android.util.Log
import
android.util.Log
import
com.bgycc.smartcanteen.event.
Wifi
StateEvent
import
com.bgycc.smartcanteen.event.
Setting
StateEvent
import
com.bgycc.smartcanteen.helper.TimerHelper
import
com.bgycc.smartcanteen.helper.TimerHelper
import
com.bgycc.smartcanteen.helper.WifiHelpler
import
com.bgycc.smartcanteen.helper.WifiHelpler
import
org.greenrobot.eventbus.EventBus
import
org.greenrobot.eventbus.EventBus
...
@@ -26,7 +26,7 @@ class WifiAction private constructor() : Action(ActionEnum.CONFIG_WIFI.name) {
...
@@ -26,7 +26,7 @@ class WifiAction private constructor() : Action(ActionEnum.CONFIG_WIFI.name) {
fail
(
""
)
fail
(
""
)
TimerHelper
.
timeout
({
TimerHelper
.
timeout
({
state
=
State
.
INITED
state
=
State
.
INITED
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(-
1
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(-
1
))
},
3000
)
},
3000
)
}
}
...
@@ -41,23 +41,23 @@ class WifiAction private constructor() : Action(ActionEnum.CONFIG_WIFI.name) {
...
@@ -41,23 +41,23 @@ class WifiAction private constructor() : Action(ActionEnum.CONFIG_WIFI.name) {
val
identity
=
data
.
optString
(
"identity"
)
val
identity
=
data
.
optString
(
"identity"
)
WifiHelpler
.
connect
(
ssid
,
identity
,
pwd
,
type
)
WifiHelpler
.
connect
(
ssid
,
identity
,
pwd
,
type
)
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(
1
,
"正在启动Wifi"
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(
1
,
"正在启动Wifi"
))
if
(!
WifiHelpler
.
setEnable
(
true
))
{
if
(!
WifiHelpler
.
setEnable
(
true
))
{
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(
1
,
"无法启动Wifi"
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(
1
,
"无法启动Wifi"
))
TimerHelper
.
timeout
({
TimerHelper
.
timeout
({
state
=
State
.
INITED
state
=
State
.
INITED
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(-
1
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(-
1
))
},
3000
)
},
3000
)
return
return
}
}
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(
10
,
"正在配置Wifi"
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(
10
,
"正在配置Wifi"
))
val
config
=
WifiHelpler
.
createWifiConfiguration
(
ssid
,
identity
,
pwd
,
type
)
val
config
=
WifiHelpler
.
createWifiConfiguration
(
ssid
,
identity
,
pwd
,
type
)
if
(
config
==
null
)
{
if
(
config
==
null
)
{
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(
10
,
"Wifi参数有误"
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(
10
,
"Wifi参数有误"
))
TimerHelper
.
timeout
({
TimerHelper
.
timeout
({
state
=
State
.
INITED
state
=
State
.
INITED
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(-
1
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(-
1
))
},
3000
)
},
3000
)
return
return
}
}
...
@@ -67,23 +67,23 @@ class WifiAction private constructor() : Action(ActionEnum.CONFIG_WIFI.name) {
...
@@ -67,23 +67,23 @@ class WifiAction private constructor() : Action(ActionEnum.CONFIG_WIFI.name) {
val
netId
=
WifiHelpler
.
addNetwork
(
config
)
val
netId
=
WifiHelpler
.
addNetwork
(
config
)
if
(!
WifiHelpler
.
enableNetwork
(
netId
))
throw
Exception
(
"无法应用Wifi配置"
)
if
(!
WifiHelpler
.
enableNetwork
(
netId
))
throw
Exception
(
"无法应用Wifi配置"
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(
20
,
e
.
message
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(
20
,
e
.
message
))
TimerHelper
.
timeout
({
TimerHelper
.
timeout
({
state
=
State
.
INITED
state
=
State
.
INITED
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(-
1
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(-
1
))
},
3000
)
},
3000
)
return
return
}
}
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(
30
,
"正在连接Wifi"
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(
30
,
"正在连接Wifi"
))
TimerHelper
.
loop
({
id
,
isLastTime
->
TimerHelper
.
loop
({
id
,
isLastTime
->
if
(
isLastTime
)
{
if
(
isLastTime
)
{
if
(
state
==
State
.
STARTED
)
{
if
(
state
==
State
.
STARTED
)
{
state
=
State
.
FAIL
state
=
State
.
FAIL
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(
30
,
"无法连接Wifi"
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(
30
,
"无法连接Wifi"
))
TimerHelper
.
timeout
({
TimerHelper
.
timeout
({
state
=
State
.
INITED
state
=
State
.
INITED
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(-
1
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(-
1
))
},
3000
)
},
3000
)
}
}
}
else
{
}
else
{
...
@@ -92,10 +92,10 @@ class WifiAction private constructor() : Action(ActionEnum.CONFIG_WIFI.name) {
...
@@ -92,10 +92,10 @@ class WifiAction private constructor() : Action(ActionEnum.CONFIG_WIFI.name) {
Log
.
i
(
TAG
,
"ip: "
+
info
.
ipAddress
)
Log
.
i
(
TAG
,
"ip: "
+
info
.
ipAddress
)
if
(
info
.
ipAddress
!=
0
)
{
if
(
info
.
ipAddress
!=
0
)
{
state
=
State
.
SUCCESS
state
=
State
.
SUCCESS
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(
30
,
"已连接Wifi"
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(
30
,
"已连接Wifi"
))
TimerHelper
.
timeout
({
TimerHelper
.
timeout
({
state
=
State
.
INITED
state
=
State
.
INITED
EventBus
.
getDefault
().
post
(
Wifi
StateEvent
(-
1
))
EventBus
.
getDefault
().
post
(
Setting
StateEvent
(-
1
))
},
3000
)
},
3000
)
TimerHelper
.
cancel
(
id
)
TimerHelper
.
cancel
(
id
)
}
}
...
...
app/src/main/java/com/bgycc/smartcanteen/activity/MainActivity.kt
View file @
4a2f1ade
...
@@ -13,6 +13,8 @@ import android.view.animation.RotateAnimation
...
@@ -13,6 +13,8 @@ import android.view.animation.RotateAnimation
import
com.bgycc.smartcanteen.App
import
com.bgycc.smartcanteen.App
import
com.bgycc.smartcanteen.AppConfig
import
com.bgycc.smartcanteen.AppConfig
import
com.bgycc.smartcanteen.R
import
com.bgycc.smartcanteen.R
import
com.bgycc.smartcanteen.action.ActionEnum
import
com.bgycc.smartcanteen.action.UpdateAction
import
com.bgycc.smartcanteen.event.*
import
com.bgycc.smartcanteen.event.*
import
com.bgycc.smartcanteen.helper.EthernetHelper
import
com.bgycc.smartcanteen.helper.EthernetHelper
import
com.bgycc.smartcanteen.helper.TimerHelper
import
com.bgycc.smartcanteen.helper.TimerHelper
...
@@ -31,6 +33,7 @@ import org.greenrobot.eventbus.ThreadMode
...
@@ -31,6 +33,7 @@ import org.greenrobot.eventbus.ThreadMode
import
java.text.SimpleDateFormat
import
java.text.SimpleDateFormat
import
java.util.*
import
java.util.*
import
kotlinx.android.synthetic.main.activity_main.*
import
kotlinx.android.synthetic.main.activity_main.*
import
org.json.JSONObject
class
MainActivity
:
BaseActivity
()
{
class
MainActivity
:
BaseActivity
()
{
...
@@ -202,7 +205,7 @@ class MainActivity : BaseActivity() {
...
@@ -202,7 +205,7 @@ class MainActivity : BaseActivity() {
}
}
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
fun
onMessageEvent
(
event
:
Wifi
StateEvent
)
{
fun
onMessageEvent
(
event
:
Setting
StateEvent
)
{
if
(
event
.
progress
<
0
)
{
if
(
event
.
progress
<
0
)
{
_setting
.
animate
().
setDuration
(
300
).
alpha
(
0f
)
_setting
.
animate
().
setDuration
(
300
).
alpha
(
0f
)
}
else
{
}
else
{
...
...
app/src/main/java/com/bgycc/smartcanteen/event/
Wifi
StateEvent.java
→
app/src/main/java/com/bgycc/smartcanteen/event/
Setting
StateEvent.java
View file @
4a2f1ade
package
com
.
bgycc
.
smartcanteen
.
event
;
package
com
.
bgycc
.
smartcanteen
.
event
;
public
class
Wifi
StateEvent
{
public
class
Setting
StateEvent
{
public
int
progress
;
public
int
progress
;
public
String
message
;
public
String
message
;
public
Wifi
StateEvent
(
int
progress
)
{
public
Setting
StateEvent
(
int
progress
)
{
this
.
progress
=
progress
;
this
.
progress
=
progress
;
this
.
message
=
""
;
this
.
message
=
""
;
}
}
public
Wifi
StateEvent
(
int
progress
,
String
message
)
{
public
Setting
StateEvent
(
int
progress
,
String
message
)
{
this
.
progress
=
progress
;
this
.
progress
=
progress
;
this
.
message
=
message
;
this
.
message
=
message
;
}
}
...
...
app/src/main/java/com/bgycc/smartcanteen/manager/CacheManager.kt
0 → 100644
View file @
4a2f1ade
package
com.bgycc.smartcanteen.manager
import
java.io.File
object
CacheManager
{
private
var
mCount
=
0
get
()
{
return
field
++
}
fun
getDir
(
dirName
:
String
=
""
):
String
{
var
path
=
String
.
format
(
"%s/CacheManager/"
,
System
.
getProperty
(
"java.io.tmpdir"
)
!!
)
if
(
dirName
.
isNotEmpty
())
{
path
+=
File
.
separator
+
dirName
.
trimStart
(
'/'
,
'\\'
)
}
val
file
=
File
(
path
)
file
.
mkdirs
()
return
file
.
absolutePath
}
fun
buildNewFilePath
(
extension
:
String
):
String
{
var
path
=
getDir
()
path
+=
String
.
format
(
"/%d-%d"
,
System
.
currentTimeMillis
(),
mCount
)
if
(
extension
.
isNotEmpty
())
{
if
(!
extension
.
startsWith
(
"."
))
{
path
+=
"."
}
path
+=
extension
}
return
path
}
}
\ No newline at end of file
app/src/main/java/com/bgycc/smartcanteen/receiver/UpdateReceiver.kt
0 → 100644
View file @
4a2f1ade
package
com.bgycc.smartcanteen.receiver
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Intent
import
android.net.Uri
import
com.blankj.utilcode.util.AppUtils
import
java.util.*
class
UpdateReceiver
:
BroadcastReceiver
()
{
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
when
(
intent
.
action
)
{
"android.intent.action.PACKAGE_ADDED"
,
"android.intent.action.PACKAGE_REPLACED"
->
{
val
packageName
=
Objects
.
requireNonNull
<
Uri
>(
intent
.
data
).
encodedSchemeSpecificPart
if
(
packageName
==
AppUtils
.
getAppPackageName
())
{
val
intentToStart
=
context
.
packageManager
.
getLaunchIntentForPackage
(
packageName
)
context
.
startActivity
(
intentToStart
)
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/bgycc/smartcanteen/server/websocket/MainWebSocket.java
View file @
4a2f1ade
...
@@ -6,6 +6,7 @@ import com.bgycc.smartcanteen.App;
...
@@ -6,6 +6,7 @@ import com.bgycc.smartcanteen.App;
import
com.bgycc.smartcanteen.AppConfig
;
import
com.bgycc.smartcanteen.AppConfig
;
import
com.bgycc.smartcanteen.action.ActionEnum
;
import
com.bgycc.smartcanteen.action.ActionEnum
;
import
com.bgycc.smartcanteen.action.PayOfflineAction
;
import
com.bgycc.smartcanteen.action.PayOfflineAction
;
import
com.bgycc.smartcanteen.action.UpdateAction
;
import
com.bgycc.smartcanteen.helper.TimerHelper
;
import
com.bgycc.smartcanteen.helper.TimerHelper
;
import
com.bgycc.smartcanteen.server.websocket.event.ConnectStateEvent
;
import
com.bgycc.smartcanteen.server.websocket.event.ConnectStateEvent
;
import
com.bgycc.smartcanteen.server.websocket.event.RecvMessageEvent
;
import
com.bgycc.smartcanteen.server.websocket.event.RecvMessageEvent
;
...
@@ -191,6 +192,12 @@ public class MainWebSocket extends WebSocketClient {
...
@@ -191,6 +192,12 @@ public class MainWebSocket extends WebSocketClient {
super
.
send
(
j
.
toString
());
super
.
send
(
j
.
toString
());
return
;
return
;
}
}
// 设备更新
else
if
(
ActionEnum
.
CONFIG_UPDATE
.
name
().
equals
(
action
))
{
JSONObject
data
=
json
.
optJSONObject
(
FieldEnum
.
data
.
name
());
UpdateAction
.
Companion
.
getDefault
().
exec
(
data
);
return
;
}
ArrayList
<
Response
>
list
=
mSubscribeList
.
get
(
action
);
ArrayList
<
Response
>
list
=
mSubscribeList
.
get
(
action
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
...
...
app/src/main/java/com/bgycc/smartcanteen/task/QRCodeTask.java
View file @
4a2f1ade
...
@@ -190,6 +190,8 @@ public class QRCodeTask {
...
@@ -190,6 +190,8 @@ public class QRCodeTask {
if
(
action
.
startsWith
(
ActionEnum
.
CONFIG_
.
name
()))
{
if
(
action
.
startsWith
(
ActionEnum
.
CONFIG_
.
name
()))
{
if
(
action
.
equals
(
ActionEnum
.
CONFIG_WIFI
.
name
()))
{
if
(
action
.
equals
(
ActionEnum
.
CONFIG_WIFI
.
name
()))
{
WifiAction
.
Companion
.
getDefault
().
exec
(
data
);
WifiAction
.
Companion
.
getDefault
().
exec
(
data
);
}
else
if
(
action
.
equals
(
ActionEnum
.
CONFIG_UPDATE
.
name
()))
{
UpdateAction
.
Companion
.
getDefault
().
exec
(
data
);
}
else
if
(
action
.
equals
(
ActionEnum
.
CONFIG_LOG
.
name
()))
{
}
else
if
(
action
.
equals
(
ActionEnum
.
CONFIG_LOG
.
name
()))
{
EventBus
.
getDefault
().
post
(
new
LogEvent
());
EventBus
.
getDefault
().
post
(
new
LogEvent
());
}
}
...
...
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