Browse Source

1.添加推送事件提交接口。

20241218TB223FC(测试jar包)
wangwanlei 9 months ago
parent
commit
20ee3365de

+ 1
- 0
app/src/main/java/com/xhly/manageapp/ManageApplication.kt View File

@@ -524,6 +524,7 @@ class ManageApplication : MultiDexApplication() {
524 524
             if (Const.isDebug){
525 525
                 csdkManager?.setPackageEnabled("com.xhly.easystud", true)
526 526
                 setUrlWhiteListEnable(false)
527
+                disableStatusBarPanel(false)
527 528
             }
528 529
             csdkManager?.urlWhiteListRead()?.forEach {
529 530
                 LogShow("白名单有"+it.toString())

+ 36
- 0
app/src/main/java/com/xhly/manageapp/bean/log/LogPushBean.kt View File

@@ -0,0 +1,36 @@
1
+package com.xhly.manageapp.bean.log
2
+
3
+/**
4
+ * 处理推送事件后的回调
5
+ */
6
+class LogPushBean {
7
+    /** app只处理6,2,3,7
8
+     * 推送类型:1发送消息2解除限制3限制使用4更新策略5重启设备6恢复出厂7解除管控
9
+     */
10
+    var pushType = 0
11
+
12
+    /**
13
+     * 推送对象:1学生2班级
14
+     */
15
+    var pushObj = 1
16
+
17
+    /**
18
+     * 推送目标:班级ID(pushObj=2)
19
+     */
20
+    var pushObjid = 0L
21
+
22
+    /**
23
+     * :学生ids(pushObj=1)
24
+     */
25
+    var userids = longArrayOf()
26
+
27
+    /**
28
+     * 推送目标:学生名称/班级名称
29
+     */
30
+    var pushObjname = ""
31
+
32
+    /**
33
+     * 日志内容
34
+     */
35
+    var content = ""
36
+}

+ 4
- 0
app/src/main/java/com/xhly/manageapp/network/UriAdress.kt View File

@@ -6,6 +6,10 @@ object UriAdress {
6 6
      */
7 7
     const val LOGDOPERATEADD = "/logdoperate/add"
8 8
 
9
+    /**
10
+     * 设备推送事件接口
11
+     */
12
+   const val LOGPUSH_ADD="/logPush/add"
9 13
     /**
10 14
      *应用启动日志-添加
11 15
      */

+ 7
- 0
app/src/main/java/com/xhly/manageapp/network/log/LogService.kt View File

@@ -2,6 +2,7 @@ package com.xhly.manageapp.network.log
2 2
 
3 3
 import com.xhly.corelib.network.bean.ResponseData
4 4
 import com.xhly.manageapp.bean.log.LogAppStartBean
5
+import com.xhly.manageapp.bean.log.LogPushBean
5 6
 import com.xhly.manageapp.bean.log.LogdOperateBean
6 7
 import com.xhly.manageapp.bean.log.PadInfoBean
7 8
 import com.xhly.manageapp.bean.log.PadLocationBean
@@ -35,4 +36,10 @@ interface LogService {
35 36
      */
36 37
     @POST(UriAdress.PADDETAILADD)
37 38
     suspend fun postPadDetailAdd(@Body padInfoBean: PadInfoBean):ResponseData<Any?>
39
+
40
+    /**
41
+     * 设备--推送事件接口
42
+     */
43
+    @POST(UriAdress.LOGPUSH_ADD)
44
+    suspend fun postLogPushAdd(@Body logPushBean: LogPushBean)
38 45
 }

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

@@ -70,7 +70,7 @@ class AppSocket : SocketClient() {
70 70
         webData.mid = UUID.randomUUID().toString()
71 71
         val currentTimeSeconds = System.currentTimeMillis() / 1000
72 72
         webData.timeunix = currentTimeSeconds
73
-        webData.fid = "1"
73
+        webData.fid = ManageApplication.getDeviceInfo()
74 74
         val jsMD5 =
75 75
             MD5Utils.getJsMD5(webData.code.toString() + "_" + webData.mid + "_" + webData.timeunix.toString())
76 76
         webData.sign = MD5Utils.getJsMD5(jsMD5)

+ 15
- 2
app/src/main/java/com/xhly/manageapp/ui/login/activity/LoginActivity.kt View File

@@ -28,6 +28,7 @@ import com.xhly.manageapp.R
28 28
 import com.xhly.manageapp.bean.EventLog
29 29
 import com.xhly.manageapp.bean.LoginBean
30 30
 import com.xhly.manageapp.bean.SocketMsgBean
31
+import com.xhly.manageapp.bean.log.LogPushBean
31 32
 import com.xhly.manageapp.bean.log.LogdOperateBean
32 33
 import com.xhly.manageapp.bean.strategy.StrategyBean
33 34
 import com.xhly.manageapp.bean.user.UserBean
@@ -152,7 +153,7 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
152 153
         }
153 154
         data.doEvent = EventLog.ACCOUNTLOGINEVENT
154 155
         viewModel.eventLog(data)
155
-        Const.USERID=userBean.userid.toString()
156
+        Const.USERID=userBean.userid
156 157
         Const.USERNAME=userBean.username.toString()
157 158
         spUtils.saveJson(Const.USERINFO,userBean)
158 159
         val parseClassToJson = GsonUtils.parseClassToJson(userBean)
@@ -213,11 +214,13 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
213 214
             Const.CODE2002.toString() -> {
214 215
                 spUtils.setParam(Const.DISABLEPAD, true)
215 216
                 useTimeStrategy()
217
+                postLogPush(3)
216 218
             }
217 219
 
218 220
             Const.CODE2003.toString() -> {
219 221
                 spUtils.setParam(Const.DISABLEPAD, false)
220 222
                 useTimeStrategy()
223
+                postLogPush(2)
221 224
             }
222 225
 
223 226
             Const.CODE2004.toString() -> {
@@ -229,11 +232,12 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
229 232
             }
230 233
 
231 234
             Const.CODE2006.toString() -> {
235
+                postLogPush(6)
232 236
                 ManageApplication.launchFactoryReset()
233 237
             }
234 238
 
235 239
             Const.CODE2007.toString() -> {
236
-
240
+                postLogPush(7)
237 241
             }
238 242
 
239 243
             Const.SDINSTALL -> {
@@ -299,6 +303,15 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
299 303
 
300 304
     }
301 305
 
306
+    private fun postLogPush(pushType:Int){
307
+        val pushBean=LogPushBean()
308
+        pushBean.pushType=pushType
309
+        pushBean.pushObjid=Const.SCHOOLID
310
+        pushBean.userids= longArrayOf(Const.USERID)
311
+        pushBean.pushObjname=Const.USERNAME
312
+        viewModel.postLogPushAdd(pushBean)
313
+    }
314
+
302 315
     private fun showNoticeDialog(msg: String) {
303 316
         CustomDialog.build()
304 317
             .setCustomView(object : OnBindView<CustomDialog>(R.layout.layout_notice_dialog) {

+ 4
- 33
app/src/main/java/com/xhly/manageapp/ui/login/viewmodel/LoginViewModel.kt View File

@@ -10,24 +10,16 @@ import com.xhly.manageapp.bean.log.LogdOperateBean
10 10
 import com.xhly.manageapp.bean.user.UserBean
11 11
 import com.xhly.manageapp.network.log.LogService
12 12
 import com.xhly.manageapp.ui.login.netservice.LoginService
13
+import com.xhly.manageapp.viewmodel.BaseViewModel
14
+
15
+class LoginViewModel: BaseViewModel() {
13 16
 
14
-class LoginViewModel: CommonBaseViewModel() {
15
-    private var logService = RetrofitService.create<LogService>()
16
-    private var service=RetrofitService.create<LoginService>()
17 17
     private val loginResult=MutableLiveData<UserBean>()
18 18
     val loginData:LiveData<UserBean> =loginResult
19
-    private val pwdResult = MutableLiveData<Boolean>()
20
-    val pwdResultData: LiveData<Boolean> = pwdResult
21
-    fun getTest(){
22
-        launchUI {
23
-            val test = service.getTest()
24
-            LogShow(test.toString()+"|||"+test.msg)
25
-        }
26
-    }
27 19
 
28 20
     fun login(loginBean: LoginBean){
29 21
         launchUI {
30
-            val postLogin = service.postLogin(loginBean)
22
+            val postLogin = loginService.postLogin(loginBean)
31 23
             if (postLogin.code==0){
32 24
                 if (postLogin.obj!=null){
33 25
                     loginResult.value=postLogin.obj
@@ -43,25 +35,4 @@ class LoginViewModel: CommonBaseViewModel() {
43 35
         }
44 36
     }
45 37
 
46
-    fun eventLog(operateBean: LogdOperateBean) {
47
-        launchUI {
48
-            logService.postLogdoperateAdd(operateBean)
49
-        }
50
-    }
51
-
52
-    /**
53
-     * 解除当前锁屏
54
-     */
55
-    fun postPwdDetail(code: String, sn: String) {
56
-        launchUI {
57
-            val map = HashMap<String, Any>()
58
-            map["sn"] = sn
59
-            val result = service.postPwdDetail(map)
60
-            if (result.code == 0) {
61
-                pwdResult.value = result.obj.toString().contains(code)
62
-            } else {
63
-                pwdResult.value = false
64
-            }
65
-        }
66
-    }
67 38
 }

+ 16
- 2
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

@@ -46,6 +46,7 @@ import com.xhly.manageapp.R
46 46
 import com.xhly.manageapp.bean.EventLog
47 47
 import com.xhly.manageapp.bean.SocketMsgBean
48 48
 import com.xhly.manageapp.bean.UpdateBean
49
+import com.xhly.manageapp.bean.log.LogPushBean
49 50
 import com.xhly.manageapp.bean.log.LogdOperateBean
50 51
 import com.xhly.manageapp.bean.school.SchoolDeviceSetBean
51 52
 import com.xhly.manageapp.bean.strategy.AppTimeManageBean
@@ -350,7 +351,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
350 351
     override fun onResume() {
351 352
         super.onResume()
352 353
         userBean?.let {
353
-            Const.USERID=it.userid.toString()
354
+            Const.USERID=it.userid
354 355
             Const.USERNAME=it.username.toString()
355 356
             viewModel.postDevicesetDetail(it.schoolid)
356 357
         }
@@ -541,6 +542,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
541 542
 
542 543
             Const.CODE2002.toString() -> {
543 544
                 //杀掉其他app之保留自己
545
+                postLogPush(3)
544 546
                 val appList = AppUtils.GetAppList(this)
545 547
                 StrategyUtils.clearMemory(this, appList)
546 548
                 spUtils.setParam(Const.DISABLEPAD, true)
@@ -549,6 +551,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
549 551
             }
550 552
 
551 553
             Const.CODE2003.toString() -> {
554
+                postLogPush(2)
552 555
                 spUtils.setParam(Const.DISABLEPAD, false)
553 556
                 useTimeStrategy()
554 557
             }
@@ -564,10 +567,12 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
564 567
             }
565 568
 
566 569
             Const.CODE2006.toString() -> {
570
+                postLogPush(6)
567 571
                 ManageApplication.launchFactoryReset()
568 572
             }
569 573
 
570 574
             Const.CODE2007.toString() -> {
575
+                postLogPush(7)
571 576
 
572 577
             }
573 578
 
@@ -677,6 +682,15 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
677 682
         }
678 683
     }
679 684
 
685
+    private fun postLogPush(pushType:Int){
686
+        val pushBean= LogPushBean()
687
+        pushBean.pushType=pushType
688
+        pushBean.pushObjid=Const.SCHOOLID
689
+        pushBean.userids= longArrayOf(Const.USERID)
690
+        pushBean.pushObjname=Const.USERNAME
691
+        viewModel.postLogPushAdd(pushBean)
692
+    }
693
+
680 694
     private fun updateAppRv() {
681 695
         try {
682 696
             var schoolDeviceSetBean: SchoolDeviceSetBean? = null
@@ -805,7 +819,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
805 819
         data.comm = "退出登录"
806 820
         data.doEvent = EventLog.ACCOUNTQUITEVENT
807 821
         viewModel.eventLog(data)
808
-        Const.USERID="1"
822
+        Const.USERID=1L
809 823
         Const.USERNAME=""
810 824
         WorkManager.getInstance(this).cancelAllWork()
811 825
         deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)

+ 2
- 25
app/src/main/java/com/xhly/manageapp/ui/main/viewmodel/MainViewModel.kt View File

@@ -17,10 +17,10 @@ import com.xhly.manageapp.network.app.AppService
17 17
 import com.xhly.manageapp.network.log.LogService
18 18
 import com.xhly.manageapp.network.strategy.StrategyService
19 19
 import com.xhly.manageapp.ui.login.netservice.LoginService
20
+import com.xhly.manageapp.viewmodel.BaseViewModel
20 21
 
21
-class MainViewModel : CommonBaseViewModel() {
22
+class MainViewModel : BaseViewModel() {
22 23
     private val appService by lazy { RetrofitService.create<AppService>() }
23
-    private val loginService by lazy { RetrofitService.create<LoginService>() }
24 24
     private val strategyService by lazy { RetrofitService.create<StrategyService>() }
25 25
     private var logService = RetrofitService.create<LogService>()
26 26
     private val listData = MutableLiveData<ArrayList<AppModel>>()
@@ -44,8 +44,6 @@ class MainViewModel : CommonBaseViewModel() {
44 44
     val wallpaperData: LiveData<WallpaperBean> = wallpaper
45 45
     private val netWhiteList = MutableLiveData<ArrayList<String>>()
46 46
     val netWhiteListData: LiveData<ArrayList<String>> = netWhiteList
47
-    private val pwdResult = MutableLiveData<Boolean>()
48
-    val pwdResultData: LiveData<Boolean> = pwdResult
49 47
 
50 48
     fun getAppList() {
51 49
         launchUI {
@@ -93,11 +91,6 @@ class MainViewModel : CommonBaseViewModel() {
93 91
         }
94 92
     }
95 93
 
96
-    fun eventLog(operateBean: LogdOperateBean) {
97
-        launchUI {
98
-            logService.postLogdoperateAdd(operateBean)
99
-        }
100
-    }
101 94
 
102 95
     /**
103 96
      * 获得app时间使用策略
@@ -202,20 +195,4 @@ class MainViewModel : CommonBaseViewModel() {
202 195
             }
203 196
         }
204 197
     }
205
-
206
-    /**
207
-     * 解除当前锁屏
208
-     */
209
-    fun postPwdDetail(code: String, sn: String) {
210
-        launchUI {
211
-            val map = HashMap<String, Any>()
212
-            map["sn"] = sn
213
-            val result = loginService.postPwdDetail(map)
214
-            if (result.code == 0) {
215
-                pwdResult.value = result.obj.toString().contains(code)
216
-            } else {
217
-                pwdResult.value = false
218
-            }
219
-        }
220
-    }
221 198
 }

+ 51
- 0
app/src/main/java/com/xhly/manageapp/viewmodel/BaseViewModel.kt View File

@@ -0,0 +1,51 @@
1
+package com.xhly.manageapp.viewmodel
2
+
3
+import androidx.lifecycle.LiveData
4
+import androidx.lifecycle.MutableLiveData
5
+import com.xhly.corelib.base.viewmodel.CommonBaseViewModel
6
+import com.xhly.corelib.network.RetrofitService
7
+import com.xhly.manageapp.bean.log.LogPushBean
8
+import com.xhly.manageapp.bean.log.LogdOperateBean
9
+import com.xhly.manageapp.network.log.LogService
10
+import com.xhly.manageapp.ui.login.netservice.LoginService
11
+
12
+open class BaseViewModel : CommonBaseViewModel() {
13
+    protected val loginService: LoginService by lazy { RetrofitService.create<LoginService>() }
14
+    private val logService: LogService = RetrofitService.create<LogService>()
15
+    private val pwdResult = MutableLiveData<Boolean>()
16
+    val pwdResultData: LiveData<Boolean> = pwdResult
17
+
18
+    /**
19
+     * 解除当前锁屏
20
+     */
21
+    fun postPwdDetail(code: String, sn: String) {
22
+        launchUI {
23
+            val map = HashMap<String, Any>()
24
+            map["sn"] = sn
25
+            val result = loginService.postPwdDetail(map)
26
+            if (result.code == 0) {
27
+                pwdResult.value = result.obj.toString().contains(code)
28
+            } else {
29
+                pwdResult.value = false
30
+            }
31
+        }
32
+    }
33
+
34
+    /**
35
+     * 发送事件日志
36
+     */
37
+    fun eventLog(operateBean: LogdOperateBean) {
38
+        launchUI {
39
+            logService.postLogdoperateAdd(operateBean)
40
+        }
41
+    }
42
+
43
+    /**
44
+     * 发送事件推送日志
45
+     */
46
+    fun postLogPushAdd(logPushBean: LogPushBean) {
47
+        launchUI {
48
+            logService.postLogPushAdd(logPushBean)
49
+        }
50
+    }
51
+}

+ 29
- 14
corelib/src/main/java/com/xhly/corelib/Const.kt View File

@@ -3,11 +3,19 @@ package com.xhly.corelib
3 3
 
4 4
 object Const {
5 5
     const val isDebug = true
6
+
6 7
     //用户id
7
-     var USERID = "1"
8
+    var USERID = 1L
9
+
8 10
     //用户姓名
9 11
     var USERNAME = ""
10 12
 
13
+    //学校id
14
+    var SCHOOLID = 0L
15
+
16
+    //班级id
17
+    var CLASSID = 0L
18
+
11 19
     //接口地址
12 20
     const val URL1: String = "https://mcapitest.xhkjedu.com/"
13 21
 
@@ -32,7 +40,7 @@ object Const {
32 40
     /**
33 41
      * 存储应用商店应用包名集合
34 42
      */
35
-    const val APPSTOREKEY="APPSTOREKEY"
43
+    const val APPSTOREKEY = "APPSTOREKEY"
36 44
 
37 45
     //401退出登录
38 46
     const val LOGIN_OUT_401 = "LOGIN_OUT_401"
@@ -117,7 +125,7 @@ object Const {
117 125
     const val USERINFO = "USERINFO"
118 126
 
119 127
     //存储学校设置的设备设置
120
-    const val SCHOOLSETDEVICE="SCHOOLSETDEVICE"
128
+    const val SCHOOLSETDEVICE = "SCHOOLSETDEVICE"
121 129
 
122 130
     //记录设备策略名称
123 131
     const val DEVICETYPE1 = "摄像头"
@@ -135,48 +143,55 @@ object Const {
135 143
     /**
136 144
      * 电话包名
137 145
      */
138
-    const val ANDROIDPHONE="com.android.contacts"
146
+    const val ANDROIDPHONE = "com.android.contacts"
147
+
139 148
     /**
140 149
      * 短信包名
141 150
      */
142
-    const val ANDROIDMMS="com.android.mms"
151
+    const val ANDROIDMMS = "com.android.mms"
152
+
143 153
     /**
144 154
      * 日历
145 155
      */
146
-    const val ANDROIDCALENDAR="com.android.calendar"
156
+    const val ANDROIDCALENDAR = "com.android.calendar"
157
+
147 158
     /**
148 159
      * 录音机
149 160
      */
150
-    const val ANDROIDRECORDER="com.android.soundrecorder"
161
+    const val ANDROIDRECORDER = "com.android.soundrecorder"
162
+
151 163
     /**
152 164
      *时钟
153 165
      */
154
-    const val ANDROIDDESKCLOCK="com.android.deskclock"
166
+    const val ANDROIDDESKCLOCK = "com.android.deskclock"
167
+
155 168
     /**
156 169
      * 联想相机相机
157 170
      */
158
-    const val ANDROIDCAMERA="com.dtab.camera"
171
+    const val ANDROIDCAMERA = "com.dtab.camera"
172
+
159 173
     /**
160 174
      * 联想相册
161 175
      */
162
-    const val ANDROIDGALLERY="com.android.gallery3d"
176
+    const val ANDROIDGALLERY = "com.android.gallery3d"
163 177
 
164 178
     /**
165 179
      *标记自定义的一键清理名称
166 180
      */
167
-    const val CUSTOMSPEEDAPP="CUSTOMSPEEDAPP"
181
+    const val CUSTOMSPEEDAPP = "CUSTOMSPEEDAPP"
168 182
 
169 183
     /**
170 184
      *标记自定义的清除缓存名称
171 185
      */
172
-    const val CUSTOMCLEARAPP="CUSTOMCLEARAPP"
186
+    const val CUSTOMCLEARAPP = "CUSTOMCLEARAPP"
173 187
 
174 188
     /**
175 189
      *标记自定义的自动旋转名称
176 190
      */
177
-    const val CUSTOMROTATIONAPP="CUSTOMROTATIONAPP"
191
+    const val CUSTOMROTATIONAPP = "CUSTOMROTATIONAPP"
192
+
178 193
     /**
179 194
      *标记自定义的修改密码
180 195
      */
181
-    const val CUSTOMCHANGEPSD="CUSTOMCHANGEPSD"
196
+    const val CUSTOMCHANGEPSD = "CUSTOMCHANGEPSD"
182 197
 }

+ 1
- 1
corelib/src/main/java/com/xhly/corelib/network/ResponseInterceptor.kt View File

@@ -23,7 +23,7 @@ class ResponseInterceptor : Interceptor {
23 23
         return try {
24 24
             val requestBuilder: Request.Builder = request.newBuilder()
25 25
             //TODO 需要替换userid和机型
26
-            requestBuilder.header("XH-UserId",Const.USERID)
26
+            requestBuilder.header("XH-UserId",Const.USERID.toString())
27 27
             requestBuilder.header("XH-DeviceModel", Build.MODEL)
28 28
             request = requestBuilder.build()
29 29
             val originalResponse = chain.proceed(request)

Loading…
Cancel
Save