|
@@ -121,8 +121,6 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
121
|
121
|
private var autoAppFlag=true
|
122
|
122
|
|
123
|
123
|
private var accountDialog:CustomDialog?=null
|
124
|
|
- //创建应用卸载集合,方便获得应用信息
|
125
|
|
- private val unInstallAppList= arrayListOf<AppInfo>()
|
126
|
124
|
|
127
|
125
|
//标记是否可以点击啊
|
128
|
126
|
private var canClickFlag=false
|
|
@@ -134,6 +132,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
134
|
132
|
//判断是否从oncreat执行,防止时间策略多次执行
|
135
|
133
|
private var isCreatFlag=false
|
136
|
134
|
|
|
135
|
+ private var appStroeList:ArrayList<AppModel> = arrayListOf()
|
137
|
136
|
|
138
|
137
|
|
139
|
138
|
override fun getBinding() = ActivityMainBinding.inflate(layoutInflater)
|
|
@@ -246,6 +245,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
246
|
245
|
//在这里执行获得策略的操作,用来处理在后台时的数据处理。
|
247
|
246
|
viewModel.listAppData.collect{ modelList ->
|
248
|
247
|
modelList?.let {
|
|
248
|
+ appStroeList.clear()
|
|
249
|
+ appStroeList.addAll(it)
|
249
|
250
|
//存储商店应用包名到本地,并且存储商店应用列表数据到本地集合
|
250
|
251
|
val appNameList = arrayListOf<String>()
|
251
|
252
|
val whiteList = arrayListOf<String>()
|
|
@@ -275,14 +276,12 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
275
|
276
|
LogShow("冻结失败" + e.toString())
|
276
|
277
|
}
|
277
|
278
|
appList.forEach { app ->
|
278
|
|
- unInstallAppList.clear()
|
279
|
279
|
val filter = modelList.filter { it.appPackage.equals(app.packageName) }
|
280
|
280
|
val appInfos = firstAppList.filter { app.packageName.equals(it) }
|
281
|
281
|
//接口列表以及初始化列表中不存在则将应用冻结或者卸载,目前是卸载
|
282
|
282
|
LogShow("${app.name},被冻结" + (filter.isEmpty() && appInfos.isEmpty()))
|
283
|
283
|
if (filter.isEmpty() && appInfos.isEmpty()) {
|
284
|
284
|
//ManageApplication.setPackageEnabled(app.packageName, (filter.isNotEmpty()))
|
285
|
|
- unInstallAppList.add(app)
|
286
|
285
|
ManageApplication.uninstallPackage(app.packageName)
|
287
|
286
|
}
|
288
|
287
|
}
|
|
@@ -1156,11 +1155,27 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
1156
|
1155
|
ManageApplication.getDeviceInfo()?.let {
|
1157
|
1156
|
data.sn = it
|
1158
|
1157
|
}
|
1159
|
|
- val packageInfo =
|
1160
|
|
- packageManager.getPackageInfo(message, PackageManager.GET_META_DATA)
|
1161
|
|
- val label =
|
1162
|
|
- packageManager.getApplicationLabel(packageInfo.applicationInfo)
|
1163
|
|
- data.comm =label.toString()
|
|
1158
|
+ try {
|
|
1159
|
+ //优先从集合中取名字
|
|
1160
|
+ getAppStoreList()
|
|
1161
|
+ val filter = appStroeList.filter { it.appPackage == message }
|
|
1162
|
+ val label =if (filter.isNotEmpty()){
|
|
1163
|
+ filter[0].appName
|
|
1164
|
+ }else{
|
|
1165
|
+ ""
|
|
1166
|
+ }
|
|
1167
|
+ data.comm =label.toString()
|
|
1168
|
+ }catch (e:Exception){
|
|
1169
|
+
|
|
1170
|
+ }finally {
|
|
1171
|
+ if (data.comm.isNullOrBlank()){
|
|
1172
|
+ val packageInfo =
|
|
1173
|
+ packageManager.getPackageInfo(message, PackageManager.GET_META_DATA)
|
|
1174
|
+ val label =
|
|
1175
|
+ packageManager.getApplicationLabel(packageInfo.applicationInfo)
|
|
1176
|
+ data.comm =label.toString()
|
|
1177
|
+ }
|
|
1178
|
+ }
|
1164
|
1179
|
data.appPackage = message
|
1165
|
1180
|
data.doEvent = EventLog.APPINSTALLEVENT
|
1166
|
1181
|
viewModel.eventLog(data)
|
|
@@ -1178,13 +1193,19 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
1178
|
1193
|
ManageApplication.getDeviceInfo()?.let {
|
1179
|
1194
|
data.sn = it
|
1180
|
1195
|
}
|
1181
|
|
- val filter = unInstallAppList.filter { it.packageName == message }
|
1182
|
|
- val label =if (filter.isNotEmpty()){
|
1183
|
|
- filter[0].name
|
1184
|
|
- }else{
|
1185
|
|
- ""
|
|
1196
|
+ try {
|
|
1197
|
+ //从存储集合中获得名字
|
|
1198
|
+ getAppStoreList()
|
|
1199
|
+ val filter = appStroeList.filter { it.appPackage == message }
|
|
1200
|
+ val label =if (filter.isNotEmpty()){
|
|
1201
|
+ filter[0].appName
|
|
1202
|
+ }else{
|
|
1203
|
+ ""
|
|
1204
|
+ }
|
|
1205
|
+ data.comm =label.toString()
|
|
1206
|
+ }catch (e:Exception){
|
|
1207
|
+
|
1186
|
1208
|
}
|
1187
|
|
- data.comm =label.toString()
|
1188
|
1209
|
data.appPackage = message
|
1189
|
1210
|
data.doEvent = EventLog.APPUNINSTALLEVENT
|
1190
|
1211
|
viewModel.eventLog(data)
|
|
@@ -1299,6 +1320,22 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
1299
|
1320
|
}
|
1300
|
1321
|
}
|
1301
|
1322
|
|
|
1323
|
+ private fun getAppStoreList(){
|
|
1324
|
+ try {
|
|
1325
|
+ if (appStroeList.size==0){
|
|
1326
|
+ val type = object : TypeToken<List<AppModel>>() {}.type
|
|
1327
|
+ val appModelList = spUtils.getFromJsonType(
|
|
1328
|
+ Const.APPSTOREDATAKEY,
|
|
1329
|
+ ArrayList<AppModel>().javaClass,
|
|
1330
|
+ type
|
|
1331
|
+ ) as ArrayList<AppModel>
|
|
1332
|
+ appStroeList.addAll(appModelList)
|
|
1333
|
+ }
|
|
1334
|
+ }catch (e:Exception){
|
|
1335
|
+
|
|
1336
|
+ }
|
|
1337
|
+ }
|
|
1338
|
+
|
1302
|
1339
|
private fun postLogPush(pushType: Int) {
|
1303
|
1340
|
//执行这些操作优先跳回本页面,不然livedata会不刷新
|
1304
|
1341
|
val pushBean = LogPushBean()
|
|
@@ -1320,6 +1357,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
1320
|
1357
|
schoolDeviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this)
|
1321
|
1358
|
val storeList = arrayListOf<String>()
|
1322
|
1359
|
val storeRemoveList= arrayListOf<String>()
|
|
1360
|
+ //获得已安装app
|
|
1361
|
+ var appList = AppUtils.GetAppList(this)
|
1323
|
1362
|
try {
|
1324
|
1363
|
val type = object : TypeToken<List<AppModel>>() {}.type
|
1325
|
1364
|
val appModelList = spUtils.getFromJsonType(
|
|
@@ -1335,11 +1374,16 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
|
1335
|
1374
|
storeRemoveList.add(it.appPackage)
|
1336
|
1375
|
}
|
1337
|
1376
|
}
|
|
1377
|
+ appList.forEach {app->
|
|
1378
|
+ appModelList.filter { it.appPackage==app.packageName }.forEach {
|
|
1379
|
+ app.name=it.appName
|
|
1380
|
+ }
|
|
1381
|
+ }
|
1338
|
1382
|
} catch (e: Exception) {
|
1339
|
1383
|
LogShow("商店应用为空"+e.toString())
|
1340
|
1384
|
}
|
1341
|
1385
|
dataList.clear()
|
1342
|
|
- var appList = AppUtils.GetAppList(this)
|
|
1386
|
+
|
1343
|
1387
|
//获得预装应用直接隐藏
|
1344
|
1388
|
val removeList = arrayListOf<AppInfo>()
|
1345
|
1389
|
try {
|