浏览代码

1.增加卸载逻辑处理,记录既不是初始应用,也不在商店列表的应用删除时的记录。

20241218TB223FC(测试jar包)
wangwanlei 10 个月前
父节点
当前提交
d808d8dd54
共有 1 个文件被更改,包括 16 次插入2 次删除
  1. 16
    2
      app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt

+ 16
- 2
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt 查看文件

@@ -120,7 +120,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
120 120
 
121 121
     private var accountDialog:CustomDialog?=null
122 122
     private var tipsDialog:CustomDialog?=null
123
-
123
+    //创建应用卸载集合,方便获得应用信息
124
+    private val unInstallAppList= arrayListOf<AppInfo>()
124 125
     //标记是否可以点击啊
125 126
     private var canClickFlag=false
126 127
     //百度定位
@@ -274,12 +275,14 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
274 275
                     } catch (e: Exception) {
275 276
                         LogShow("冻结失败" + e.toString())
276 277
                     }
278
+                    unInstallAppList.clear()
277 279
                     appList.forEach { app ->
278 280
                         val filter = modelList.filter { it.appPackage.equals(app.packageName) }
279 281
                         val appInfos = firstAppList.filter { app.packageName.equals(it) }
280 282
                         //接口列表以及初始化列表中不存在则将应用冻结或者卸载,目前是卸载
281 283
                         LogShow("${app.name},被冻结" + (filter.isEmpty() && appInfos.isEmpty()))
282 284
                         if (filter.isEmpty() && appInfos.isEmpty()) {
285
+                            unInstallAppList.add(app)
283 286
                             //ManageApplication.setPackageEnabled(app.packageName, (filter.isNotEmpty()))
284 287
                             ManageApplication.uninstallPackage(app.packageName)
285 288
                         }
@@ -1204,6 +1207,17 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
1204 1207
                     data.comm =label.toString()
1205 1208
                 }catch (e:Exception){
1206 1209
 
1210
+                }finally {
1211
+                    //商店集合为空则从卸载列表读取
1212
+                    if (data.comm.isNullOrBlank()){
1213
+                        val filter = unInstallAppList.filter { it.packageName == message }
1214
+                        val label =if (filter.isNotEmpty()){
1215
+                            filter[0].name
1216
+                        }else{
1217
+                            ""
1218
+                        }
1219
+                        data.comm =label.toString()
1220
+                    }
1207 1221
                 }
1208 1222
                 data.appPackage = message
1209 1223
                 data.doEvent = EventLog.APPUNINSTALLEVENT
@@ -1609,7 +1623,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
1609 1623
     private fun loginOutSucess() {
1610 1624
         spUtils.setParam(Const.DISABLEPAD,false)
1611 1625
         WorkManager.getInstance(this).cancelAllWork()
1612
-        val deleteSharedPreferences =spUtils.clearData()
1626
+        spUtils.clearData()
1613 1627
         Const.USERID = null
1614 1628
         Const.USERNAME = ""
1615 1629
         AppSocket.onDestroy()

正在加载...
取消
保存