|
@@ -25,6 +25,7 @@ import androidx.work.WorkManager
|
25
|
25
|
import com.bumptech.glide.Glide
|
26
|
26
|
import com.bumptech.glide.request.target.CustomViewTarget
|
27
|
27
|
import com.bumptech.glide.request.transition.Transition
|
|
28
|
+import com.google.gson.reflect.TypeToken
|
28
|
29
|
import com.kongzue.dialogx.dialogs.CustomDialog
|
29
|
30
|
import com.kongzue.dialogx.interfaces.OnBindView
|
30
|
31
|
import com.tbruyelle.rxpermissions2.RxPermissions
|
|
@@ -46,6 +47,7 @@ import com.xhly.manageapp.bean.SocketMsgBean
|
46
|
47
|
import com.xhly.manageapp.bean.UpdateBean
|
47
|
48
|
import com.xhly.manageapp.bean.log.LogdOperateBean
|
48
|
49
|
import com.xhly.manageapp.bean.school.SchoolDeviceSetBean
|
|
50
|
+import com.xhly.manageapp.bean.strategy.AppTimeManageBean
|
49
|
51
|
import com.xhly.manageapp.bean.strategy.StrategyBean
|
50
|
52
|
import com.xhly.manageapp.bean.user.UserBean
|
51
|
53
|
import com.xhly.manageapp.broadcastreceiver.AppInstallReceiver
|
|
@@ -56,6 +58,7 @@ import com.xhly.manageapp.ui.ManageActivity
|
56
|
58
|
import com.xhly.manageapp.ui.login.activity.LoginActivity
|
57
|
59
|
import com.xhly.manageapp.ui.main.viewmodel.MainViewModel
|
58
|
60
|
import com.xhly.manageapp.utils.AppDownLoadUtils
|
|
61
|
+import com.xhly.manageapp.utils.CurrentAppSharedPreferencesUtils
|
59
|
62
|
import com.xhly.manageapp.utils.CustomAppUtils
|
60
|
63
|
import com.xhly.manageapp.utils.PadInfoUtils
|
61
|
64
|
import com.xhly.manageapp.utils.StrategyUtils
|
|
@@ -74,6 +77,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
74
|
77
|
private var dataList: ArrayList<AppInfo> = arrayListOf()
|
75
|
78
|
private var userBean: UserBean? = null
|
76
|
79
|
private var timer: Timer?=null
|
|
80
|
+ private val currentSpUtils by lazy { CurrentAppSharedPreferencesUtils.getInstance(this) }
|
77
|
81
|
override fun getBinding() = ActivityMainBinding.inflate(layoutInflater)
|
78
|
82
|
|
79
|
83
|
override fun initData() {
|
|
@@ -101,10 +105,23 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
101
|
105
|
viewModel.listAppData.observe(this) { modelList ->
|
102
|
106
|
//获得应用集合,必装应用和推荐应用,再加上预装应用,其余应用需要静默卸载,必装应用需要进行静默下载和安装。安装应用从forceapp接口获取
|
103
|
107
|
val appList = AppUtils.GetAppList(this)
|
|
108
|
+ val firstAppList= arrayListOf<String>()
|
|
109
|
+ try {
|
|
110
|
+ //获得预装应用的包名
|
|
111
|
+ val currentList =
|
|
112
|
+ currentSpUtils.getFromJson(Const.FIRSTAPPLIST, ArrayList<String>().javaClass) as ArrayList<String>
|
|
113
|
+ firstAppList.addAll(currentList)
|
|
114
|
+ }catch (e:Exception){
|
|
115
|
+ LogShow("冻结失败"+e.toString())
|
|
116
|
+ }
|
104
|
117
|
appList.forEach { app ->
|
105
|
118
|
val filter = modelList.filter { it.appPackage.equals(app.packageName) }
|
106
|
|
- //列表中不存在则将应用冻结或者卸载,目前是冻结
|
107
|
|
- ManageApplication.setPackageEnabled(app.packageName, (filter.isNotEmpty()))
|
|
119
|
+ val appInfos = firstAppList.filter { app.packageName.equals(it) }
|
|
120
|
+ //接口列表以及初始化列表中不存在则将应用冻结或者卸载,目前是冻结
|
|
121
|
+ LogShow("${app.name},被冻结"+(filter.isEmpty() && appInfos.isEmpty()))
|
|
122
|
+ if (filter.isEmpty() && appInfos.isEmpty()){
|
|
123
|
+ ManageApplication.setPackageEnabled(app.packageName, (filter.isNotEmpty()))
|
|
124
|
+ }
|
108
|
125
|
}
|
109
|
126
|
}
|
110
|
127
|
viewModel.forceListAppData.observe(this) { modelList ->
|
|
@@ -693,6 +710,13 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
693
|
710
|
}
|
694
|
711
|
|
695
|
712
|
private fun loginOut() {
|
|
713
|
+ val data = LogdOperateBean()
|
|
714
|
+ ManageApplication.getDeviceInfo()?.let {
|
|
715
|
+ data.sn = it
|
|
716
|
+ }
|
|
717
|
+ data.comm = "退出登录"
|
|
718
|
+ data.doEvent = EventLog.ACCOUNTQUITEVENT
|
|
719
|
+ viewModel.eventLog(data)
|
696
|
720
|
WorkManager.getInstance(this).cancelAllWork()
|
697
|
721
|
deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)
|
698
|
722
|
startIntentActivity(LoginActivity().javaClass)
|