Parcourir la source

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

20241218TB223FC(测试jar包)
wangwanlei il y a 8 mois
Parent
révision
b85d015da4

+ 0
- 27
app/src/main/java/com/xhly/manageapp/service/websocket/AppSocket.kt Voir le fichier

@@ -94,31 +94,4 @@ class AppSocket : SocketClient() {
94 94
         context.sendBroadcast(intent)
95 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 Voir le fichier

@@ -144,28 +144,4 @@ open class AppSocketService : LongConnService() {
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 Voir le fichier

@@ -25,7 +25,7 @@ class MainViewModel : CommonBaseViewModel() {
25 25
     private val listData = MutableLiveData<ArrayList<AppModel>>()
26 26
     val listAppData: LiveData<ArrayList<AppModel>> = listData
27 27
     private val forceData = MutableLiveData<ArrayList<AppModel>>()
28
-    val forceListAppData: LiveData<ArrayList<AppModel>> = listData
28
+    val forceListAppData: LiveData<ArrayList<AppModel>> = forceData
29 29
 
30 30
     private val strategy = MutableLiveData<StrategyBean>()
31 31
     val strategyData: LiveData<StrategyBean> = strategy
@@ -54,17 +54,22 @@ class MainViewModel : CommonBaseViewModel() {
54 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 66
         launchUI {
62 67
             val result= appService.postForceApp()
63 68
             if (result.code==0&&result.obj!=null&&result.obj.isNotEmpty()){
64 69
                 forceData.value=result.obj
65 70
             }
66 71
         }
67
-    }
72
+    }*/
68 73
 
69 74
     fun updateStrategy() {
70 75
         launchUI {

Chargement…
Annuler
Enregistrer