Browse Source

1.当应用列表接口为空时,认为未开启应用策略不限制应用的安装。

20241218TB223FC(测试jar包)
wangwanlei 1 month ago
parent
commit
088f7aa5d9
1 changed files with 12 additions and 10 deletions
  1. 12
    10
      app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt

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

@@ -307,18 +307,20 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
307 307
                         LogShow("冻结失败" + e.toString())
308 308
                     }
309 309
                     unInstallAppList.clear()
310
-                    appList.forEach { app ->
311
-                        val filter = modelList.filter { it.appPackage.equals(app.packageName) }
312
-                        val appInfos = firstAppList.filter { app.packageName.equals(it) }
313
-                        //接口列表以及初始化列表中不存在则将应用冻结或者卸载,目前是卸载
314
-                        LogShow("${app.name},被冻结" + (filter.isEmpty() && appInfos.isEmpty()))
315
-                        if (filter.isEmpty() && appInfos.isEmpty()) {
316
-                            unInstallAppList.add(app)
317
-                            //ManageApplication.setPackageEnabled(app.packageName, (filter.isNotEmpty()))
318
-                            ManageApplication.uninstallPackage(app.packageName)
310
+                    if (modelList.size>0){
311
+                        //modelList为0表示未打开应用策略,不删除应用
312
+                        appList.forEach { app ->
313
+                            val filter = modelList.filter { it.appPackage.equals(app.packageName) }
314
+                            val appInfos = firstAppList.filter { app.packageName.equals(it) }
315
+                            //接口列表以及初始化列表中不存在则将应用冻结或者卸载,目前是卸载
316
+                            LogShow("${app.name},被冻结" + (filter.isEmpty() && appInfos.isEmpty()))
317
+                            if (filter.isEmpty() && appInfos.isEmpty()) {
318
+                                unInstallAppList.add(app)
319
+                                //ManageApplication.setPackageEnabled(app.packageName, (filter.isNotEmpty()))
320
+                                ManageApplication.uninstallPackage(app.packageName)
321
+                            }
319 322
                         }
320 323
                     }
321
-
322 324
                 }
323 325
             }
324 326
         }

Loading…
Cancel
Save