Browse Source

1.添加网络白名单地址接口请求。

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

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

471
         fun setUrlWhiteListWrite(list:ArrayList<String>){
471
         fun setUrlWhiteListWrite(list:ArrayList<String>){
472
             if (ModelNameUtils.IS_LianxX505f()) {
472
             if (ModelNameUtils.IS_LianxX505f()) {
473
                 csdkManager?.SetEnable(true)
473
                 csdkManager?.SetEnable(true)
474
+                //默认添加自己应用为白名单
475
+                list.add("mcapitest.xhkjedu.com")
476
+                list.add("mcwstest.xhkjedu.com")
474
                 csdkManager?.urlWhiteListWrite(list)
477
                 csdkManager?.urlWhiteListWrite(list)
475
             }
478
             }
476
         }
479
         }

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

31
      */
31
      */
32
     const val APP_LISTPAD = "/stApp/list_pad"
32
     const val APP_LISTPAD = "/stApp/list_pad"
33
 
33
 
34
+    /**
35
+     * 网址白名单
36
+     */
37
+    const val APP_NET_WHITELIST="/white/list_pad"
38
+
34
     /**
39
     /**
35
      * 设备--地理位置添加
40
      * 设备--地理位置添加
36
      */
41
      */

+ 12
- 1
app/src/main/java/com/xhly/manageapp/network/strategy/StrategyService.kt View File

9
 import retrofit2.http.POST
9
 import retrofit2.http.POST
10
 
10
 
11
 interface StrategyService {
11
 interface StrategyService {
12
+    /**
13
+     * 获得平板策略
14
+     */
12
     @POST(UriAdress.DETAIL_PAD)
15
     @POST(UriAdress.DETAIL_PAD)
13
     suspend fun postDetailPad(): ResponseData<StrategyBean>
16
     suspend fun postDetailPad(): ResponseData<StrategyBean>
14
-
17
+    /**
18
+     * 获得应用策略
19
+     */
15
     @POST(UriAdress.APP_LISTPAD)
20
     @POST(UriAdress.APP_LISTPAD)
16
     suspend fun postAppListPad():ResponseData<ArrayList<AppTimeManageBean>>
21
     suspend fun postAppListPad():ResponseData<ArrayList<AppTimeManageBean>>
17
 
22
 
20
      */
25
      */
21
     @POST(UriAdress.DEVICESETDETAIL)
26
     @POST(UriAdress.DEVICESETDETAIL)
22
     suspend fun postDevicesetDetail(@Body map:HashMap<String,Any>):ResponseData<SchoolDeviceSetBean>
27
     suspend fun postDevicesetDetail(@Body map:HashMap<String,Any>):ResponseData<SchoolDeviceSetBean>
28
+
29
+    /**
30
+     * 获得网络白名单
31
+     */
32
+    @POST(UriAdress.APP_NET_WHITELIST)
33
+    suspend fun postAppNetWhiteList():ResponseData<ArrayList<String>>
23
 }
34
 }

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

191
                 })
191
                 })
192
             }
192
             }
193
         }
193
         }
194
+        viewModel.netWhiteListData.observe(this){
195
+           StrategyUtils.setNetWhiteList(it)
196
+        }
194
         startWorkManager()
197
         startWorkManager()
195
     }
198
     }
196
 
199
 
232
         viewModel.updateStrategy()
235
         viewModel.updateStrategy()
233
         viewModel.uploadAppStrategy()
236
         viewModel.uploadAppStrategy()
234
         viewModel.getAppList()
237
         viewModel.getAppList()
238
+        viewModel.postAppNetWhiteList()
235
         userBean?.let {
239
         userBean?.let {
236
             viewModel.postDevicesetDetail(it.schoolid)
240
             viewModel.postDevicesetDetail(it.schoolid)
237
         }
241
         }

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

40
     val loginOutData: LiveData<Boolean> = loginOut
40
     val loginOutData: LiveData<Boolean> = loginOut
41
     private val schoolSet=MutableLiveData<SchoolDeviceSetBean>()
41
     private val schoolSet=MutableLiveData<SchoolDeviceSetBean>()
42
     val schoolSetData:LiveData<SchoolDeviceSetBean> =schoolSet
42
     val schoolSetData:LiveData<SchoolDeviceSetBean> =schoolSet
43
-
44
     private val wallpaper=MutableLiveData<WallpaperBean>()
43
     private val wallpaper=MutableLiveData<WallpaperBean>()
45
     val wallpaperData:LiveData<WallpaperBean> =wallpaper
44
     val wallpaperData:LiveData<WallpaperBean> =wallpaper
45
+    private val netWhiteList=MutableLiveData<ArrayList<String>>()
46
+    val netWhiteListData:LiveData<ArrayList<String>> =netWhiteList
46
 
47
 
47
     fun getAppList() {
48
     fun getAppList() {
48
         launchUI {
49
         launchUI {
174
             }
175
             }
175
         }
176
         }
176
     }
177
     }
178
+
179
+    /**
180
+     * 获得网址白名单
181
+     */
182
+    fun postAppNetWhiteList(){
183
+        launchUI {
184
+            val postAppNetWhiteList = strategyService.postAppNetWhiteList()
185
+            if (postAppNetWhiteList.code==0){
186
+                 val urlList= arrayListOf<String>()
187
+                postAppNetWhiteList.obj.forEach {
188
+                    if (it.contains(";")){
189
+                        it.split(";").forEach {str->
190
+                            urlList.add(str)
191
+                        }
192
+                    }else{
193
+                        urlList.add(it)
194
+                    }
195
+                }
196
+                  netWhiteList.value=urlList
197
+            }
198
+        }
199
+    }
177
 }
200
 }

+ 7
- 0
app/src/main/java/com/xhly/manageapp/utils/StrategyUtils.kt View File

283
         }
283
         }
284
         return schoolDeviceSetBean
284
         return schoolDeviceSetBean
285
     }
285
     }
286
+
287
+    /**
288
+     * 设置网络白名单
289
+     */
290
+    public fun setNetWhiteList(data:ArrayList<String>){
291
+        ManageApplication.setUrlWhiteListWrite(data)
292
+    }
286
 }
293
 }

Loading…
Cancel
Save