Browse Source

1.修改Soekct消息类型

master
wangwanlei 10 months ago
parent
commit
42c896dca5

+ 13
- 0
app/src/main/java/com/xhly/manageapp/bean/strategy/PadViolateBean.kt View File

@@ -0,0 +1,13 @@
1
+package com.xhly.manageapp.bean.strategy
2
+
3
+class PadViolateBean {
4
+    /**
5
+     * 违规类型:1已ROOT 2安装非商店应用 3更换SIM卡 4USB连接电脑
6
+     */
7
+    var violateType: String? = "0"
8
+
9
+    /**
10
+     * 处理方式(中文分号隔开)
11
+     */
12
+    var handle_method: String? = ""
13
+}

+ 18
- 2
app/src/main/java/com/xhly/manageapp/service/websocket/AppSocket.kt View File

@@ -21,6 +21,7 @@ import com.xhly.manageapp.bean.log.LogAppStartBean
21 21
 import com.xhly.manageapp.bean.log.LogdOperateBean
22 22
 import com.xhly.manageapp.network.log.LogService
23 23
 import com.xhly.websocket.bean.WebSocketData
24
+import com.xhly.websocket.bean.WebSocketUserBean
24 25
 import com.xhly.websocket.service.SocketClient
25 26
 import com.xhly.websocket.service.WebSocketHelper
26 27
 import com.xhly.websocket.utils.SocketPushUtils
@@ -68,14 +69,19 @@ class AppSocket : SocketClient() {
68 69
         super.onConnectedSuccess()
69 70
         UIEvent(Const.UPDATE_CONNECTED_SUCCESS).post()
70 71
         val webData = WebSocketData()
71
-        webData.code = 1002
72
+        webData.code = 1001
72 73
         webData.mid = UUID.randomUUID().toString()
73 74
         val currentTimeSeconds = System.currentTimeMillis() / 1000
74 75
         webData.timeunix = currentTimeSeconds
75
-        webData.fid = 1
76
+        webData.fid = "1"
76 77
         val jsMD5 =
77 78
             MD5Utils.getJsMD5(webData.code.toString() + "_" + webData.mid + "_" + webData.timeunix.toString())
78 79
         webData.sign = MD5Utils.getJsMD5(jsMD5)
80
+        val socketUserBean = WebSocketUserBean()
81
+        socketUserBean.usertype = 1
82
+        socketUserBean.username = "测试"
83
+        socketUserBean.userid = ManageApplication.getDeviceInfo()
84
+        webData.body = socketUserBean
79 85
         WebSocketHelper.getInstance().sendSocketString(GsonUtils.parseClassToJson(webData))
80 86
     }
81 87
 
@@ -92,6 +98,16 @@ class AppSocket : SocketClient() {
92 98
                 goMainActivity()
93 99
             }
94 100
 
101
+            Const.CODE2003.toString() -> {
102
+                Toast.makeText(context, "解除限制", Toast.LENGTH_LONG).show()
103
+                spUtils.setParam(Const.DISABLEAPP, false)
104
+                goMainActivity()
105
+            }
106
+
107
+            Const.CODE2004.toString() -> {
108
+               //请求接口更新策略
109
+            }
110
+
95 111
             Const.CODE2005.toString() -> {
96 112
                 ManageApplication.rebootDevice()
97 113
             }

+ 2
- 4
app/src/main/java/com/xhly/manageapp/service/websocket/AppSocketService.kt View File

@@ -3,12 +3,10 @@ package com.xhly.manageapp.service.websocket
3 3
 import android.app.Notification
4 4
 import android.app.NotificationChannel
5 5
 import android.app.NotificationManager
6
-import android.app.Service
7 6
 import android.content.ComponentName
8 7
 import android.content.Context
9 8
 import android.content.Intent
10 9
 import android.os.Build
11
-import android.os.Environment
12 10
 import android.widget.Toast
13 11
 import com.billbook.lib.downloader.Download
14 12
 import com.billbook.lib.downloader.Downloader
@@ -88,7 +86,7 @@ open class AppSocketService : LongConnService() {
88 86
         webData.mid = UUID.randomUUID().toString()
89 87
         val currentTimeSeconds = System.currentTimeMillis() / 1000
90 88
         webData.timeunix = currentTimeSeconds
91
-        webData.fid = 1
89
+        webData.fid = "1"
92 90
         val jsMD5 =
93 91
             MD5Utils.getJsMD5(webData.code.toString() + "_" + webData.mid + "_" + webData.timeunix.toString())
94 92
         webData.sign = MD5Utils.getJsMD5(jsMD5)
@@ -247,7 +245,7 @@ open class AppSocketService : LongConnService() {
247 245
                 val successful = execute.isSuccessful()
248 246
                 LogShow("下载结果" + successful)
249 247
                 if (successful) {
250
-                    withContext(Dispatchers.Main){
248
+                    withContext(Dispatchers.Main) {
251 249
                         ManageApplication.installPackage(File(name, "test.apk").toString())
252 250
                     }
253 251
                 }

+ 6
- 0
corelib/src/main/java/com/xhly/corelib/Const.kt View File

@@ -14,6 +14,9 @@ object Const {
14 14
     //作为存储白名单应用的key
15 15
     const val WHITELISTAPP = "WHITELISTAPP"
16 16
 
17
+    //存储是否是第一次打开的key
18
+    const val FIRSTFLAG = "FIRSTFLAG"
19
+
17 20
     //401退出登录
18 21
     const val LOGIN_OUT_401 = "LOGIN_OUT_401"
19 22
 
@@ -52,4 +55,7 @@ object Const {
52 55
 
53 56
     //标记应用卸载
54 57
     const val APPUNINSTALL = "APPUNINSTALL"
58
+
59
+    //标记更新策略
60
+    const val UPDATESTRATEGY = "UPDATESTRATEGY"
55 61
 }

+ 2
- 2
websocket/src/main/java/com/xhly/websocket/bean/WebSocketData.kt View File

@@ -8,7 +8,7 @@ class WebSocketData() {
8 8
 
9 9
     //两次md5加密timeunix
10 10
     var sign: String? = null
11
-    var fid: Int = 0
12
-    var tids: IntArray = intArrayOf()
11
+    var fid: String? = "0"
12
+    var tids: Array<String?> = arrayOf()
13 13
     var body: Any? = null
14 14
 }

+ 9
- 0
websocket/src/main/java/com/xhly/websocket/bean/WebSocketUserBean.kt View File

@@ -0,0 +1,9 @@
1
+package com.xhly.websocket.bean
2
+
3
+class WebSocketUserBean {
4
+    var userid: String? = ""
5
+    var username: String? = ""
6
+
7
+    //1是管理员,2是学生
8
+    var usertype = 1
9
+}

Loading…
Cancel
Save