|
@@ -28,6 +28,7 @@ import androidx.work.WorkManager
|
28
|
28
|
import com.bumptech.glide.Glide
|
29
|
29
|
import com.bumptech.glide.request.target.CustomViewTarget
|
30
|
30
|
import com.bumptech.glide.request.transition.Transition
|
|
31
|
+import com.google.gson.reflect.TypeToken
|
31
|
32
|
import com.hjq.toast.Toaster
|
32
|
33
|
import com.kongzue.dialogx.dialogs.CustomDialog
|
33
|
34
|
import com.kongzue.dialogx.interfaces.OnBindView
|
|
@@ -51,6 +52,7 @@ import com.xhly.manageapp.ManageApplication
|
51
|
52
|
import com.xhly.manageapp.bean.EventLog
|
52
|
53
|
import com.xhly.manageapp.bean.SocketMsgBean
|
53
|
54
|
import com.xhly.manageapp.bean.app.AppInstallBean
|
|
55
|
+import com.xhly.manageapp.bean.app.AppModel
|
54
|
56
|
import com.xhly.manageapp.bean.log.LogPushBean
|
55
|
57
|
import com.xhly.manageapp.bean.log.LogdOperateBean
|
56
|
58
|
import com.xhly.manageapp.bean.log.UpdateBean
|
|
@@ -139,7 +141,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
139
|
141
|
// csdkManagerUtils.csdkManager.enableAccessibility("com.xhly.manageapp","com.xhly.manageapp.service.TestService",true)
|
140
|
142
|
|
141
|
143
|
viewModel.listAppData.observe(this) { modelList ->
|
142
|
|
- //存储商店应用包名到本地
|
|
144
|
+ //存储商店应用包名到本地,并且存储商店应用列表数据到本地集合
|
143
|
145
|
val appNameList = arrayListOf<String>()
|
144
|
146
|
val whiteList = arrayListOf<String>()
|
145
|
147
|
modelList.forEach {
|
|
@@ -149,7 +151,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
149
|
151
|
}
|
150
|
152
|
}
|
151
|
153
|
ManageApplication.addAppWhiteRule(whiteList)
|
152
|
|
- spUtils.saveJson(Const.APPSTOREKEY, appNameList)
|
|
154
|
+ spUtils.saveJson(Const.APPSTOREDATAKEY,modelList)
|
153
|
155
|
//获得应用集合,必装应用和推荐应用,再加上预装应用(预装应用直接隐藏),其余应用需要静默卸载,必装应用需要进行静默下载和安装。安装应用从forceapp接口获取
|
154
|
156
|
val appList = AppUtils.GetAppList(this)
|
155
|
157
|
val firstAppList = arrayListOf<String>()
|
|
@@ -936,14 +938,25 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
936
|
938
|
|
937
|
939
|
private fun updateAppRv() {
|
938
|
940
|
try {
|
939
|
|
- //获得预装应用和商店应用,商店应用和预装重叠直接显示,其余预装直接隐藏
|
|
941
|
+ //获得预装应用和商店应用,商店应用(隐藏图标的不显示)和预装重叠直接显示,其余预装直接隐藏
|
940
|
942
|
var schoolDeviceSetBean: SchoolDeviceSetBean? = null
|
941
|
943
|
schoolDeviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this)
|
942
|
944
|
val storeList = arrayListOf<String>()
|
|
945
|
+ val storeRemoveList= arrayListOf<String>()
|
943
|
946
|
try {
|
944
|
|
- val fromJson = spUtils.getFromJson(Const.APPSTOREKEY, ArrayList<String>().javaClass)
|
945
|
|
- if (fromJson != null) {
|
946
|
|
- storeList.addAll(fromJson as ArrayList<String>)
|
|
947
|
+ val type = object : TypeToken<List<AppModel>>() {}.type
|
|
948
|
+ val appModelList = spUtils.getFromJsonType(
|
|
949
|
+ Const.APPSTOREDATAKEY,
|
|
950
|
+ ArrayList<AppModel>().javaClass,
|
|
951
|
+ type
|
|
952
|
+ ) as ArrayList<AppModel>
|
|
953
|
+ if (appModelList != null) {
|
|
954
|
+ appModelList.filter { it.showico==1}.forEach {
|
|
955
|
+ storeList.add(it.appPackage)
|
|
956
|
+ }
|
|
957
|
+ appModelList.filter { it.showico==0}.forEach {
|
|
958
|
+ storeRemoveList.add(it.appPackage)
|
|
959
|
+ }
|
947
|
960
|
}
|
948
|
961
|
} catch (e: Exception) {
|
949
|
962
|
LogShow("商店应用为空")
|
|
@@ -960,7 +973,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
960
|
973
|
ArrayList<String>().javaClass
|
961
|
974
|
) as ArrayList<String>
|
962
|
975
|
currentList.forEach { pkg ->
|
963
|
|
- //学校控制之外的预装应用加入移除集合,应用商店列表包含的不需要加入移除集合
|
|
976
|
+ //获得预装,在学校控制和应用商店显示以外的app加入移除集合
|
964
|
977
|
if (!Const.schoolSetAppList.contains(pkg) && !storeList.contains(pkg)) {
|
965
|
978
|
appList.filter { it.packageName == pkg }.forEach {
|
966
|
979
|
removeList.add(it)
|
|
@@ -971,8 +984,13 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
971
|
984
|
|
972
|
985
|
}
|
973
|
986
|
//如果包含应用商店也移除,因为会在自定义app中添加
|
974
|
|
- appList.filter { it.packageName == Const.STOREAPPPKG }.forEach {
|
|
987
|
+ /* appList.filter { it.packageName == Const.STOREAPPPKG }.forEach {
|
975
|
988
|
removeList.add(it)
|
|
989
|
+ }*/
|
|
990
|
+
|
|
991
|
+ //移除应用列表隐藏的应用
|
|
992
|
+ storeRemoveList.forEach {pkg->
|
|
993
|
+ appList.removeIf { it.packageName==pkg }
|
976
|
994
|
}
|
977
|
995
|
//移除学校控制之外预装应用
|
978
|
996
|
appList.removeAll(removeList)
|