|
@@ -217,14 +217,21 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
217
|
217
|
mBinding.rv.adapter = adapter
|
218
|
218
|
updateAppRv()
|
219
|
219
|
// checkAccessibility(this)
|
220
|
|
- registerAppInstallReceiver()
|
221
|
|
- registerNetConnectReceiver()
|
222
|
|
- registerScreenReceiver()
|
223
|
|
- registerBleStateReceiver()
|
224
|
|
- registerUSBReceiver()
|
225
|
|
- registerSDReceiver()
|
226
|
|
- registerLoginOutReceiver()
|
227
|
|
- registerXhlyUpdeteStrategyReceiver()
|
|
220
|
+ try {
|
|
221
|
+ StrategyUtils.initMainControlStrategy()
|
|
222
|
+ userBean?.let {
|
|
223
|
+ registerAppInstallReceiver()
|
|
224
|
+ registerNetConnectReceiver()
|
|
225
|
+ registerScreenReceiver()
|
|
226
|
+ registerBleStateReceiver()
|
|
227
|
+ registerUSBReceiver()
|
|
228
|
+ registerSDReceiver()
|
|
229
|
+ registerLoginOutReceiver()
|
|
230
|
+ registerXhlyUpdeteStrategyReceiver()
|
|
231
|
+ }
|
|
232
|
+ }catch (e:Exception){
|
|
233
|
+ LogShow("错误是"+e.toString())
|
|
234
|
+ }
|
228
|
235
|
/*
|
229
|
236
|
使用情况权限
|
230
|
237
|
val permissionIntent = Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS)
|
|
@@ -324,7 +331,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
324
|
331
|
}
|
325
|
332
|
unInstallAppList.clear()
|
326
|
333
|
if (modelList.size>0){
|
327
|
|
- //modelList为0表示未打开应用策略,不删除应用
|
|
334
|
+ ManageApplication.disableInstallation(true)
|
|
335
|
+ //modelList为0表示未打开应用策略,不删除应用,并且打开应用安装权限,其余情况关闭
|
328
|
336
|
appList.forEach { app ->
|
329
|
337
|
val filter = modelList.filter { it.appPackage.equals(app.packageName) }
|
330
|
338
|
val appInfos = firstAppList.filter { app.packageName.equals(it) }
|
|
@@ -332,10 +340,12 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
332
|
340
|
LogShow("${app.name},被冻结" + (filter.isEmpty() && appInfos.isEmpty()))
|
333
|
341
|
if (filter.isEmpty() && appInfos.isEmpty()) {
|
334
|
342
|
unInstallAppList.add(app)
|
335
|
|
- //ManageApplication.setPackageEnabled(app.packageName, (filter.isNotEmpty()))
|
336
|
343
|
ManageApplication.uninstallPackage(app.packageName)
|
337
|
344
|
}
|
338
|
345
|
}
|
|
346
|
+ }else{
|
|
347
|
+ //modelList为0表示未打开应用策略,所以打开打开应用安装权限
|
|
348
|
+ ManageApplication.disableInstallation(false)
|
339
|
349
|
}
|
340
|
350
|
}
|
341
|
351
|
}
|
|
@@ -2078,7 +2088,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
2078
|
2088
|
mXhlyUpdeteStrategyReceiver?.let {
|
2079
|
2089
|
unregisterReceiver(it)
|
2080
|
2090
|
}
|
2081
|
|
- mLoginOutReceiver.let {
|
|
2091
|
+ mLoginOutReceiver?.let {
|
2082
|
2092
|
unregisterReceiver(it)
|
2083
|
2093
|
}
|
2084
|
2094
|
LogShow("MainActivity被销毁")
|