Explorar el Código

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

20241218TB223FC(测试jar包)
wangwanlei hace 10 meses
padre
commit
565f15c97b

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

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

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

@@ -0,0 +1,14 @@
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 Ver fichero

@@ -41,5 +41,5 @@ interface LogService {
41 41
      * 设备--推送事件接口
42 42
      */
43 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 Ver fichero

@@ -129,6 +129,30 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
129 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 156
         onBackPressedDispatcher.addCallback {
133 157
             //屏蔽返回
134 158
         }
@@ -256,31 +280,23 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
256 280
 
257 281
             Const.CODE2002.toString() -> {
258 282
                 postLogPush(3)
259
-                spUtils.setParam(Const.DISABLEPAD, true)
260
-                useTimeStrategy()
261 283
             }
262 284
 
263 285
             Const.CODE2003.toString() -> {
264 286
                 postLogPush(2)
265
-                spUtils.setParam(Const.DISABLEPAD, false)
266
-                useTimeStrategy()
267 287
             }
268 288
 
269 289
 
270 290
             Const.CODE2005.toString() -> {
271 291
                 postLogPush(5)
272
-                ManageApplication.rebootDevice()
273 292
             }
274 293
 
275 294
             Const.CODE2006.toString() -> {
276 295
                 postLogPush(6)
277
-                ManageApplication.launchFactoryReset()
278 296
             }
279 297
 
280 298
             Const.CODE2007.toString() -> {
281 299
                 postLogPush(7)
282
-                currentSpUtils.setParam(Const.EXIT_CONTROL,true)
283
-                StrategyUtils.releaseControl(this)
284 300
             }
285 301
 
286 302
             Const.SDINSTALL -> {

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

@@ -260,6 +260,39 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
260 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 296
         startWorkManager()
264 297
         updateAllStrategy()
265 298
     }
@@ -665,41 +698,26 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
665 698
             Const.CODE2002.toString() -> {
666 699
                 //杀掉其他app之保留自己
667 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 703
             Const.CODE2003.toString() -> {
676 704
                 postLogPush(2)
677
-                spUtils.setParam(Const.DISABLEPAD, false)
678
-                useTimeStrategy()
679 705
             }
680 706
 
681 707
             Const.CODE2004.toString() -> {
682 708
                 postLogPush(4)
683
-                //请求接口更新策略
684
-                /*viewModel.uploadAppStrategy()
685
-                viewModel.updateStrategy()*/
686
-                updateAllStrategy()
687 709
             }
688 710
 
689 711
             Const.CODE2005.toString() -> {
690 712
                 postLogPush(5)
691
-                ManageApplication.rebootDevice()
692 713
             }
693 714
 
694 715
             Const.CODE2006.toString() -> {
695 716
                 postLogPush(6)
696
-                ManageApplication.launchFactoryReset()
697 717
             }
698 718
 
699 719
             Const.CODE2007.toString() -> {
700 720
                 postLogPush(7)
701
-                currentSpUtils.setParam(Const.EXIT_CONTROL,true)
702
-                StrategyUtils.releaseControl(this)
703 721
             }
704 722
 
705 723
             Const.CODE2008.toString() -> {

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

@@ -6,6 +6,7 @@ import com.xhly.corelib.base.viewmodel.CommonBaseViewModel
6 6
 import com.xhly.corelib.network.RetrofitService
7 7
 import com.xhly.corelib.utils.MD5Utils
8 8
 import com.xhly.manageapp.bean.log.LogPushBean
9
+import com.xhly.manageapp.bean.log.LogPushResultBean
9 10
 import com.xhly.manageapp.bean.log.LogdOperateBean
10 11
 import com.xhly.manageapp.network.log.LogService
11 12
 import com.xhly.manageapp.ui.login.netservice.LoginService
@@ -23,6 +24,8 @@ open class BaseViewModel : CommonBaseViewModel() {
23 24
     val lockResultData: LiveData<Boolean> = lockResult
24 25
     private val resetResult = MutableLiveData<Boolean>()
25 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,11 +70,18 @@ open class BaseViewModel : CommonBaseViewModel() {
67 70
     }
68 71
 
69 72
     /**
70
-     * 发送事件推送日志
73
+     * 发送事件推送日志,再接口回调后再调用功能实现
71 74
      */
72 75
     fun postLogPushAdd(logPushBean: LogPushBean) {
73 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…
Cancelar
Guardar