Browse Source

1.修改推送消息的处理逻辑,收到推送消息后再请求接口然后再执行。

20241218TB223FC(测试jar包)
wangwanlei 10 months ago
parent
commit
565f15c97b

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

1
 package com.xhly.manageapp.bean.log
1
 package com.xhly.manageapp.bean.log
2
 
2
 
3
 /**
3
 /**
4
- * 处理推送事件后的回调
4
+ * 接收到推送事件,后调用接口
5
  */
5
  */
6
 class LogPushBean {
6
 class LogPushBean {
7
     /** app不处理1
7
     /** app不处理1
8
-     * 1发送消息2解除锁定3锁定4更新策略5重启设备6恢复出厂7解除管控
8
+     * 1发送消息2解除锁定3锁定4更新策略5重启设备6恢复出厂7解除管控,8注销登录
9
      */
9
      */
10
     var pushType = 0
10
     var pushType = 0
11
 
11
 

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

1
+package com.xhly.manageapp.bean.log
2
+
3
+/**
4
+ * 处理推送事件的接口调用的结果
5
+ */
6
+class LogPushResultBean {
7
+    /** app不处理1
8
+     * 1发送消息2解除锁定3锁定4更新策略5重启设备6恢复出厂7解除管控,8注销登录
9
+     */
10
+    var pushType = 0
11
+
12
+    //是否调用
13
+    var enableFlag = false
14
+}

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

41
      * 设备--推送事件接口
41
      * 设备--推送事件接口
42
      */
42
      */
43
     @POST(UriAdress.LOGPUSH_RECEIVED)
43
     @POST(UriAdress.LOGPUSH_RECEIVED)
44
-    suspend fun postLogPushAdd(@Body logPushBean: LogPushBean)
44
+    suspend fun postLogPushAdd(@Body logPushBean: LogPushBean):ResponseData<Any>
45
 }
45
 }

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

129
                 showSettingDialog()
129
                 showSettingDialog()
130
             }
130
             }
131
         }
131
         }
132
+        viewModel.logResultData.observe(this){
133
+            if (it.enableFlag){
134
+                when(it.pushType){
135
+                    2->{
136
+                        spUtils.setParam(Const.DISABLEPAD, false)
137
+                        useTimeStrategy()
138
+                    }
139
+                    3->{
140
+                        spUtils.setParam(Const.DISABLEPAD, true)
141
+                        useTimeStrategy()
142
+                    }
143
+                    5->{
144
+                        ManageApplication.rebootDevice()
145
+                    }
146
+                    6->{
147
+                        ManageApplication.launchFactoryReset()
148
+                    }
149
+                    7->{
150
+                        currentSpUtils.setParam(Const.EXIT_CONTROL,true)
151
+                        StrategyUtils.releaseControl(this)
152
+                    }
153
+                }
154
+            }
155
+        }
132
         onBackPressedDispatcher.addCallback {
156
         onBackPressedDispatcher.addCallback {
133
             //屏蔽返回
157
             //屏蔽返回
134
         }
158
         }
256
 
280
 
257
             Const.CODE2002.toString() -> {
281
             Const.CODE2002.toString() -> {
258
                 postLogPush(3)
282
                 postLogPush(3)
259
-                spUtils.setParam(Const.DISABLEPAD, true)
260
-                useTimeStrategy()
261
             }
283
             }
262
 
284
 
263
             Const.CODE2003.toString() -> {
285
             Const.CODE2003.toString() -> {
264
                 postLogPush(2)
286
                 postLogPush(2)
265
-                spUtils.setParam(Const.DISABLEPAD, false)
266
-                useTimeStrategy()
267
             }
287
             }
268
 
288
 
269
 
289
 
270
             Const.CODE2005.toString() -> {
290
             Const.CODE2005.toString() -> {
271
                 postLogPush(5)
291
                 postLogPush(5)
272
-                ManageApplication.rebootDevice()
273
             }
292
             }
274
 
293
 
275
             Const.CODE2006.toString() -> {
294
             Const.CODE2006.toString() -> {
276
                 postLogPush(6)
295
                 postLogPush(6)
277
-                ManageApplication.launchFactoryReset()
278
             }
296
             }
279
 
297
 
280
             Const.CODE2007.toString() -> {
298
             Const.CODE2007.toString() -> {
281
                 postLogPush(7)
299
                 postLogPush(7)
282
-                currentSpUtils.setParam(Const.EXIT_CONTROL,true)
283
-                StrategyUtils.releaseControl(this)
284
             }
300
             }
285
 
301
 
286
             Const.SDINSTALL -> {
302
             Const.SDINSTALL -> {

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

260
                 ManageApplication.launchFactoryReset()
260
                 ManageApplication.launchFactoryReset()
261
             }
261
             }
262
         }
262
         }
263
+        viewModel.logResultData.observe(this){
264
+            if (it.enableFlag){
265
+                when(it.pushType){
266
+                    2->{
267
+                        spUtils.setParam(Const.DISABLEPAD, false)
268
+                        useTimeStrategy()
269
+                    }
270
+                    3->{
271
+                        val appList = AppUtils.GetAppList(this)
272
+                        StrategyUtils.clearMemory(this, appList)
273
+                        spUtils.setParam(Const.DISABLEPAD, true)
274
+                        startIntentActivity(MainActivity().javaClass)
275
+                    }
276
+                    4->{
277
+                        //请求接口更新策略
278
+                        updateAllStrategy()
279
+                    }
280
+                    5->{
281
+                        ManageApplication.rebootDevice()
282
+                    }
283
+                    6->{
284
+                        ManageApplication.launchFactoryReset()
285
+                    }
286
+                    7->{
287
+                        currentSpUtils.setParam(Const.EXIT_CONTROL,true)
288
+                        StrategyUtils.releaseControl(this)
289
+                    }
290
+                    8->{
291
+                        loginOut()
292
+                    }
293
+                }
294
+            }
295
+        }
263
         startWorkManager()
296
         startWorkManager()
264
         updateAllStrategy()
297
         updateAllStrategy()
265
     }
298
     }
665
             Const.CODE2002.toString() -> {
698
             Const.CODE2002.toString() -> {
666
                 //杀掉其他app之保留自己
699
                 //杀掉其他app之保留自己
667
                 postLogPush(3)
700
                 postLogPush(3)
668
-                val appList = AppUtils.GetAppList(this)
669
-                StrategyUtils.clearMemory(this, appList)
670
-                spUtils.setParam(Const.DISABLEPAD, true)
671
-                //useTimeStrategy()
672
-                startIntentActivity(MainActivity().javaClass)
673
             }
701
             }
674
 
702
 
675
             Const.CODE2003.toString() -> {
703
             Const.CODE2003.toString() -> {
676
                 postLogPush(2)
704
                 postLogPush(2)
677
-                spUtils.setParam(Const.DISABLEPAD, false)
678
-                useTimeStrategy()
679
             }
705
             }
680
 
706
 
681
             Const.CODE2004.toString() -> {
707
             Const.CODE2004.toString() -> {
682
                 postLogPush(4)
708
                 postLogPush(4)
683
-                //请求接口更新策略
684
-                /*viewModel.uploadAppStrategy()
685
-                viewModel.updateStrategy()*/
686
-                updateAllStrategy()
687
             }
709
             }
688
 
710
 
689
             Const.CODE2005.toString() -> {
711
             Const.CODE2005.toString() -> {
690
                 postLogPush(5)
712
                 postLogPush(5)
691
-                ManageApplication.rebootDevice()
692
             }
713
             }
693
 
714
 
694
             Const.CODE2006.toString() -> {
715
             Const.CODE2006.toString() -> {
695
                 postLogPush(6)
716
                 postLogPush(6)
696
-                ManageApplication.launchFactoryReset()
697
             }
717
             }
698
 
718
 
699
             Const.CODE2007.toString() -> {
719
             Const.CODE2007.toString() -> {
700
                 postLogPush(7)
720
                 postLogPush(7)
701
-                currentSpUtils.setParam(Const.EXIT_CONTROL,true)
702
-                StrategyUtils.releaseControl(this)
703
             }
721
             }
704
 
722
 
705
             Const.CODE2008.toString() -> {
723
             Const.CODE2008.toString() -> {

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

6
 import com.xhly.corelib.network.RetrofitService
6
 import com.xhly.corelib.network.RetrofitService
7
 import com.xhly.corelib.utils.MD5Utils
7
 import com.xhly.corelib.utils.MD5Utils
8
 import com.xhly.manageapp.bean.log.LogPushBean
8
 import com.xhly.manageapp.bean.log.LogPushBean
9
+import com.xhly.manageapp.bean.log.LogPushResultBean
9
 import com.xhly.manageapp.bean.log.LogdOperateBean
10
 import com.xhly.manageapp.bean.log.LogdOperateBean
10
 import com.xhly.manageapp.network.log.LogService
11
 import com.xhly.manageapp.network.log.LogService
11
 import com.xhly.manageapp.ui.login.netservice.LoginService
12
 import com.xhly.manageapp.ui.login.netservice.LoginService
23
     val lockResultData: LiveData<Boolean> = lockResult
24
     val lockResultData: LiveData<Boolean> = lockResult
24
     private val resetResult = MutableLiveData<Boolean>()
25
     private val resetResult = MutableLiveData<Boolean>()
25
     val resetlResultData: LiveData<Boolean> = resetResult
26
     val resetlResultData: LiveData<Boolean> = resetResult
27
+    private val logResult=MutableLiveData<LogPushResultBean>()
28
+    val logResultData:LiveData<LogPushResultBean> =logResult
26
 
29
 
27
     /**
30
     /**
28
      * 解除当前锁屏
31
      * 解除当前锁屏
67
     }
70
     }
68
 
71
 
69
     /**
72
     /**
70
-     * 发送事件推送日志
73
+     * 发送事件推送日志,再接口回调后再调用功能实现
71
      */
74
      */
72
     fun postLogPushAdd(logPushBean: LogPushBean) {
75
     fun postLogPushAdd(logPushBean: LogPushBean) {
73
         launchUI {
76
         launchUI {
74
-            logService.postLogPushAdd(logPushBean)
77
+            val postLogPushAdd = logService.postLogPushAdd(logPushBean)
78
+            if (postLogPushAdd.code==0){
79
+                //为true则后续执行
80
+                val logPushResultBean=LogPushResultBean()
81
+                logPushResultBean.pushType=logPushBean.pushType
82
+                logPushResultBean.enableFlag=true
83
+                logResult.value=logPushResultBean
84
+            }
75
         }
85
         }
76
     }
86
     }
77
     /**
87
     /**

Loading…
Cancel
Save