|
@@ -180,6 +180,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
180
|
180
|
private var isDestroyFlag=false
|
181
|
181
|
//执行了自启请求
|
182
|
182
|
private var netAutoAppFlag=false
|
|
183
|
+ //表示请求了策略更新
|
|
184
|
+ private var netStrategyDataFlag=false
|
183
|
185
|
|
184
|
186
|
override fun getBinding() = ActivityMainBinding.inflate(layoutInflater)
|
185
|
187
|
|
|
@@ -287,6 +289,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
287
|
289
|
|
288
|
290
|
viewModel.lockResultData.observe(this) {
|
289
|
291
|
if (it) {
|
|
292
|
+ //获得违规状态后,锁定桌面
|
290
|
293
|
spUtils.setParam(Const.DISABLEPAD, true)
|
291
|
294
|
startIntentActivity(MainActivity().javaClass)
|
292
|
295
|
val appList = AppUtils.GetAppList(this)
|
|
@@ -438,15 +441,20 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
438
|
441
|
|
439
|
442
|
viewModel.viewModelScope.launch {
|
440
|
443
|
viewModel.strategyData.collect {
|
441
|
|
- it?.let {
|
442
|
|
- spUtils.saveJson(Const.STRATEGYBEANKEY, it)
|
443
|
|
- StrategyUtils.setStrategy(it)
|
444
|
|
- useTimeStrategy()
|
445
|
|
- /* updateStrategyFlag = true
|
446
|
|
- if (updateTimeFlag) {
|
447
|
|
- showSucessToast()
|
448
|
|
- }*/
|
449
|
|
- showSucessToast()
|
|
444
|
+ //netStrategyDataFlag表示接口请求了,才可以接收数据
|
|
445
|
+ if (netStrategyDataFlag){
|
|
446
|
+ netStrategyDataFlag=false
|
|
447
|
+ it?.let {
|
|
448
|
+ spUtils.saveJson(Const.STRATEGYBEANKEY, it)
|
|
449
|
+ StrategyUtils.setStrategy(it)
|
|
450
|
+ //更新策略时执行
|
|
451
|
+ useTimeStrategy(1)
|
|
452
|
+ /* updateStrategyFlag = true
|
|
453
|
+ if (updateTimeFlag) {
|
|
454
|
+ showSucessToast()
|
|
455
|
+ }*/
|
|
456
|
+ showSucessToast()
|
|
457
|
+ }
|
450
|
458
|
}
|
451
|
459
|
}
|
452
|
460
|
}
|
|
@@ -530,10 +538,12 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
530
|
538
|
when (it.pushType) {
|
531
|
539
|
2 -> {
|
532
|
540
|
spUtils.setParam(Const.DISABLEPAD, false)
|
533
|
|
- useTimeStrategy()
|
|
541
|
+ //远程socket解除锁定时执行
|
|
542
|
+ useTimeStrategy(2)
|
534
|
543
|
}
|
535
|
544
|
|
536
|
545
|
3 -> {
|
|
546
|
+ //远程socket消息后,回调执行锁定
|
537
|
547
|
val appList = AppUtils.GetAppList(this@MainActivity)
|
538
|
548
|
StrategyUtils.clearMemory(this@MainActivity, appList)
|
539
|
549
|
spUtils.setParam(Const.DISABLEPAD, true)
|
|
@@ -677,6 +687,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
677
|
687
|
try {
|
678
|
688
|
StrategyUtils.initMainResume()
|
679
|
689
|
try {
|
|
690
|
+ canClickFlag=true
|
680
|
691
|
val am = getSystemService(ACTIVITY_SERVICE) as ActivityManager
|
681
|
692
|
/*val runningTasks = am.getRunningTasks(1)
|
682
|
693
|
if (!runningTasks.isNullOrEmpty()){
|
|
@@ -794,7 +805,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
794
|
805
|
//解锁屏幕
|
795
|
806
|
private fun unBindBlock() {
|
796
|
807
|
spUtils.setParam(Const.DISABLEPAD, false)
|
797
|
|
- useTimeStrategy()
|
|
808
|
+ //输入密码解锁屏幕时执行,因为要判断锁定原因是因为不在使用时间还是违规。
|
|
809
|
+ useTimeStrategy(3)
|
798
|
810
|
if (mBinding.mainLlayout.visibility == View.GONE) {
|
799
|
811
|
Toast(getString(R.string.padtimestoptips))
|
800
|
812
|
}
|
|
@@ -971,7 +983,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
971
|
983
|
}
|
972
|
984
|
if (!screenFlag) {
|
973
|
985
|
if (!NetworkUtils.isAvailable(this)) {
|
974
|
|
- useTimeStrategy()
|
|
986
|
+ //在onresume中时使用,如果未联网执行
|
|
987
|
+ useTimeStrategy(4)
|
975
|
988
|
hasNetFlag = false
|
976
|
989
|
lifecycleScope.launch {
|
977
|
990
|
withContext(Dispatchers.IO){
|
|
@@ -996,7 +1009,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
996
|
1009
|
updateAllStrategy()
|
997
|
1010
|
} else {
|
998
|
1011
|
if (!isCreatFlag) {
|
999
|
|
- useTimeStrategy()
|
|
1012
|
+ //!isCreatFlag表示不是第一次启动时使用useTimeStrategy
|
|
1013
|
+ useTimeStrategy(5)
|
1000
|
1014
|
}
|
1001
|
1015
|
isCreatFlag = false
|
1002
|
1016
|
}
|
|
@@ -1017,6 +1031,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
1017
|
1031
|
}
|
1018
|
1032
|
mBinding.userschoolTv.text = name.toString()
|
1019
|
1033
|
}
|
|
1034
|
+ netStrategyDataFlag=true
|
1020
|
1035
|
viewModel.postWallpaperPad()
|
1021
|
1036
|
viewModel.updateStrategy()
|
1022
|
1037
|
viewModel.uploadAppStrategy()
|
|
@@ -1246,8 +1261,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
1246
|
1261
|
locationClient?.start()
|
1247
|
1262
|
}
|
1248
|
1263
|
|
1249
|
|
- private fun useTimeStrategy() {
|
1250
|
|
- LogShow("开始执行了吧哈哈")
|
|
1264
|
+ private fun useTimeStrategy(type:Int) {
|
|
1265
|
+ LogShow("开始获得时间策略$type")
|
1251
|
1266
|
//获得sputils中的平板锁定策略
|
1252
|
1267
|
try {
|
1253
|
1268
|
//如果存储的是锁定则锁定
|
|
@@ -1294,10 +1309,12 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
|
1294
|
1309
|
LogShow("锁定了吧" + mainLockFlag + "|||" + autoAppFlag)
|
1295
|
1310
|
//自动退出时优先退出而不是拉起app
|
1296
|
1311
|
if (autoAppFlag&&!loginoutFlag) {
|
1297
|
|
- //只有网络请求之后两秒延迟后才执行
|
1298
|
|
- userBean?.let {
|
1299
|
|
- netAutoAppFlag=true
|
1300
|
|
- viewModel.postAutoAppDetail(it.regionid)
|
|
1312
|
+ //因为对于学生端app退出登录的处理,所以类型为5(这时认为执行的时机是学生主动退出了登录,所以不拉起)时不执行拉起
|
|
1313
|
+ if (type!=5){
|
|
1314
|
+ userBean?.let {
|
|
1315
|
+ netAutoAppFlag=true
|
|
1316
|
+ viewModel.postAutoAppDetail(it.regionid)
|
|
1317
|
+ }
|
1301
|
1318
|
}
|
1302
|
1319
|
}
|
1303
|
1320
|
}
|