Browse Source

1.修改必装应用调用位置

20241218TB223FC(测试jar包)
wangwanlei 8 months ago
parent
commit
b85d015da4

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

94
         context.sendBroadcast(intent)
94
         context.sendBroadcast(intent)
95
         LogShow("Service被销毁")
95
         LogShow("Service被销毁")
96
     }
96
     }
97
-
98
-
99
-    private fun downLoadFile(url: String) {
100
-        serviceScope.launch {
101
-            withContext(Dispatchers.IO) {
102
-                //val file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
103
-                val file = context.getExternalFilesDir(null)
104
-                val name = file.toString()
105
-                val downloader = Downloader.Builder().build()
106
-                val request = Download.Request.Builder()
107
-                    .url("https://dl.hdslb.com/mobile/latest/android64/iBiliPlayer-bili.apk?t=20230728&spm_id_from=333.47.b_646f776e6c6f61642d6c696e6b.1")
108
-                    .into(File(name, "test.apk"))
109
-                    .build()
110
-                LogShow("开始下载")
111
-                val execute = downloader.newCall(request).execute()
112
-                val successful = execute.isSuccessful()
113
-                LogShow("下载结果" + successful)
114
-                if (successful) {
115
-                    withContext(Dispatchers.Main) {
116
-                        ManageApplication.installPackage(File(name, "test.apk").toString())
117
-                    }
118
-                }
119
-                LogShow("下载后,开始安装")
120
-            }
121
-        }
122
-    }
123
-
124
 }
97
 }

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

144
         }
144
         }
145
     }
145
     }
146
 
146
 
147
-    private fun downLoadFile(url: String) {
148
-        serviceScope.launch {
149
-            withContext(Dispatchers.IO) {
150
-                //val file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
151
-                val file = getExternalFilesDir(null)
152
-                val name = file.toString()
153
-                val downloader = Downloader.Builder().build()
154
-                val request = Download.Request.Builder()
155
-                    .url("https://dl.hdslb.com/mobile/latest/android64/iBiliPlayer-bili.apk?t=20230728&spm_id_from=333.47.b_646f776e6c6f61642d6c696e6b.1")
156
-                    .into(File(name, "test.apk"))
157
-                    .build()
158
-                LogShow("开始下载")
159
-                val execute = downloader.newCall(request).execute()
160
-                val successful = execute.isSuccessful()
161
-                LogShow("下载结果" + successful)
162
-                if (successful) {
163
-                    withContext(Dispatchers.Main) {
164
-                        ManageApplication.installPackage(File(name, "test.apk").toString())
165
-                    }
166
-                }
167
-                LogShow("下载后,开始安装")
168
-            }
169
-        }
170
-    }
171
 }
147
 }

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

25
     private val listData = MutableLiveData<ArrayList<AppModel>>()
25
     private val listData = MutableLiveData<ArrayList<AppModel>>()
26
     val listAppData: LiveData<ArrayList<AppModel>> = listData
26
     val listAppData: LiveData<ArrayList<AppModel>> = listData
27
     private val forceData = MutableLiveData<ArrayList<AppModel>>()
27
     private val forceData = MutableLiveData<ArrayList<AppModel>>()
28
-    val forceListAppData: LiveData<ArrayList<AppModel>> = listData
28
+    val forceListAppData: LiveData<ArrayList<AppModel>> = forceData
29
 
29
 
30
     private val strategy = MutableLiveData<StrategyBean>()
30
     private val strategy = MutableLiveData<StrategyBean>()
31
     val strategyData: LiveData<StrategyBean> = strategy
31
     val strategyData: LiveData<StrategyBean> = strategy
54
                     netMessage.value = postListApp.msg
54
                     netMessage.value = postListApp.msg
55
                 }
55
                 }
56
             }
56
             }
57
+            //获得必装应用
58
+            val result= appService.postForceApp()
59
+            if (result.code==0&&result.obj!=null&&result.obj.isNotEmpty()){
60
+                forceData.value=result.obj
61
+            }
57
         }
62
         }
58
     }
63
     }
59
 
64
 
60
-    fun getForceAppList(){
65
+/*    fun getForceAppList(){
61
         launchUI {
66
         launchUI {
62
             val result= appService.postForceApp()
67
             val result= appService.postForceApp()
63
             if (result.code==0&&result.obj!=null&&result.obj.isNotEmpty()){
68
             if (result.code==0&&result.obj!=null&&result.obj.isNotEmpty()){
64
                 forceData.value=result.obj
69
                 forceData.value=result.obj
65
             }
70
             }
66
         }
71
         }
67
-    }
72
+    }*/
68
 
73
 
69
     fun updateStrategy() {
74
     fun updateStrategy() {
70
         launchUI {
75
         launchUI {

Loading…
Cancel
Save