|
@@ -41,12 +41,15 @@ import com.xhly.corelib.utils.CustomOSUtils
|
41
|
41
|
import com.xhly.corelib.utils.FileUtils
|
42
|
42
|
import com.xhly.corelib.utils.GsonUtils
|
43
|
43
|
import com.xhly.corelib.utils.LogShow
|
|
44
|
+import com.xhly.corelib.utils.MD5Utils
|
44
|
45
|
import com.xhly.corelib.utils.SharedPreferencesUtils
|
45
|
46
|
import com.xhly.corelib.utils.SystemUtil
|
46
|
47
|
import com.xhly.manageapp.AppAdapter
|
47
|
48
|
import com.xhly.manageapp.ManageApplication
|
48
|
49
|
import com.xhly.manageapp.bean.EventLog
|
49
|
50
|
import com.xhly.manageapp.bean.SocketMsgBean
|
|
51
|
+import com.xhly.manageapp.bean.app.AppInstallBean
|
|
52
|
+import com.xhly.manageapp.bean.app.AppModel
|
50
|
53
|
import com.xhly.manageapp.bean.log.LogPushBean
|
51
|
54
|
import com.xhly.manageapp.bean.log.LogdOperateBean
|
52
|
55
|
import com.xhly.manageapp.bean.log.UpdateBean
|
|
@@ -389,6 +392,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
389
|
392
|
super.onResume()
|
390
|
393
|
useTimeStrategy()
|
391
|
394
|
updatePadInfo()
|
|
395
|
+ updateMcApp()
|
392
|
396
|
getLocation()
|
393
|
397
|
}
|
394
|
398
|
|
|
@@ -415,23 +419,58 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
415
|
419
|
updatePadInfo()
|
416
|
420
|
}
|
417
|
421
|
|
418
|
|
- private fun updateAppInstallInfo(packageInfo: PackageInfo) {
|
|
422
|
+ private fun updateAppInstallInfo() {
|
419
|
423
|
try {
|
|
424
|
+ //获得已安装应用列表
|
|
425
|
+ val appList = AppUtils.GetAppList(this)
|
|
426
|
+ try {
|
|
427
|
+ //获得预装应用的包名
|
|
428
|
+ val currentList =
|
|
429
|
+ currentSpUtils.getFromJson(
|
|
430
|
+ Const.FIRSTAPPLIST,
|
|
431
|
+ ArrayList<String>().javaClass
|
|
432
|
+ ) as ArrayList<String>
|
|
433
|
+ val removeList = arrayListOf<AppInfo>()
|
|
434
|
+ currentList.forEach { pkg ->
|
|
435
|
+ //除了管控之类的我们的app之外的预装都不在统计范围
|
|
436
|
+ if (Const.CURRENTAPPPKG!=pkg&&Const.STOREAPPPKG!=pkg) {
|
|
437
|
+ appList.filter { it.packageName == pkg }.forEach {
|
|
438
|
+ removeList.add(it)
|
|
439
|
+ }
|
|
440
|
+ }
|
|
441
|
+ }
|
|
442
|
+ //除了管控之类的我们的app之外的预装都不在统计范围,所以移除
|
|
443
|
+ appList.removeAll(removeList)
|
|
444
|
+ } catch (e: Exception) {
|
|
445
|
+
|
|
446
|
+ }
|
420
|
447
|
val userBean = spUtils.getFromJson(Const.USERINFO, UserBean().javaClass) as UserBean
|
421
|
|
- val updateBean = UpdateBean()
|
422
|
|
- ManageApplication.getDeviceInfo()?.let {
|
423
|
|
- updateBean.sn = it
|
|
448
|
+ val appInstallList= arrayListOf<AppInstallBean>()
|
|
449
|
+ appList.forEach {
|
|
450
|
+ val appInstallBean=AppInstallBean()
|
|
451
|
+ appInstallBean.userid=userBean.userid
|
|
452
|
+ appInstallBean.appName=it.name
|
|
453
|
+ appInstallBean.appVersion=it.versionName
|
|
454
|
+ appInstallBean.appNum=it.versionNum
|
|
455
|
+ appInstallBean.appPackage=it.packageName
|
|
456
|
+ ManageApplication.getDeviceInfo()?.let {sn->
|
|
457
|
+ appInstallBean.sn = sn
|
|
458
|
+ }
|
|
459
|
+ ManageApplication.getDeviceInfo(1)?.let {mac->
|
|
460
|
+ appInstallBean.mac = mac
|
|
461
|
+ }
|
|
462
|
+ appInstallBean.schoolid=userBean.schoolid
|
|
463
|
+ appInstallBean.regionid=userBean.regionid
|
|
464
|
+ appInstallList.add(appInstallBean)
|
424
|
465
|
}
|
425
|
|
- updateBean.cversion = packageInfo.versionName
|
426
|
|
- updateBean.schoolid = userBean.schoolid
|
427
|
|
- updateBean.userid = userBean.userid
|
428
|
|
- updateBean.regionid = userBean.regionid
|
429
|
|
- viewModel.updateAppInstallInfo(updateBean)
|
|
466
|
+
|
|
467
|
+ viewModel.updateAppInstallInfo(appInstallList)
|
430
|
468
|
}catch (e:Exception){
|
431
|
469
|
|
432
|
470
|
}
|
433
|
471
|
}
|
434
|
472
|
|
|
473
|
+
|
435
|
474
|
@SuppressLint("CheckResult")
|
436
|
475
|
private fun updatePadInfo() {
|
437
|
476
|
try {
|
|
@@ -464,6 +503,38 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
464
|
503
|
}
|
465
|
504
|
}
|
466
|
505
|
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+ private fun updateMcApp() {
|
|
509
|
+ //每天请求一次app更新接口,这个接口是用于提交管控自身的版本信息统计
|
|
510
|
+ try {
|
|
511
|
+ val userBean = spUtils.getFromJson(Const.USERINFO, UserBean().javaClass) as UserBean
|
|
512
|
+ //存储pad更新请求时间,如果为同一天则不在上传,不然继续上传
|
|
513
|
+ val padTime = spUtils.getParam(Const.PADUPDATETIMEKEY, 0L) as Long
|
|
514
|
+ val instance = Calendar.getInstance()
|
|
515
|
+ val currentYear = instance.get(Calendar.YEAR)
|
|
516
|
+ val currentDay = instance.get(Calendar.DAY_OF_YEAR)
|
|
517
|
+ instance.timeInMillis = padTime
|
|
518
|
+ val year = instance.get(Calendar.YEAR)
|
|
519
|
+ val day = instance.get(Calendar.DAY_OF_YEAR)
|
|
520
|
+ if (!(currentYear == year && currentDay == day)) {
|
|
521
|
+ val updateBean = UpdateBean()
|
|
522
|
+ ManageApplication.getDeviceInfo()?.let {
|
|
523
|
+ updateBean.sn = it
|
|
524
|
+ }
|
|
525
|
+ val packageInfo =
|
|
526
|
+ packageManager.getPackageInfo(packageName, PackageManager.GET_META_DATA)
|
|
527
|
+ updateBean.cversion = packageInfo.versionName
|
|
528
|
+ updateBean.schoolid = userBean.schoolid
|
|
529
|
+ updateBean.userid = userBean.userid
|
|
530
|
+ updateBean.regionid = userBean.regionid
|
|
531
|
+ viewModel.updateMcApp(updateBean)
|
|
532
|
+ }
|
|
533
|
+ } catch (e: Exception) {
|
|
534
|
+
|
|
535
|
+ }
|
|
536
|
+ }
|
|
537
|
+
|
467
|
538
|
@SuppressLint("CheckResult")
|
468
|
539
|
private fun getLocation() {
|
469
|
540
|
val rxPermissions = RxPermissions(this)
|
|
@@ -650,11 +721,13 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
650
|
721
|
}
|
651
|
722
|
val packageInfo =
|
652
|
723
|
packageManager.getPackageInfo(message, PackageManager.GET_META_DATA)
|
653
|
|
- data.comm = "App安装"
|
|
724
|
+ val label =
|
|
725
|
+ packageManager.getApplicationLabel(packageInfo.applicationInfo)
|
|
726
|
+ data.comm = "App安装,应用名:${label}"
|
654
|
727
|
data.appPackage = message
|
655
|
728
|
data.doEvent = EventLog.APPINSTALLEVENT
|
656
|
729
|
viewModel.eventLog(data)
|
657
|
|
- updateAppInstallInfo(packageInfo)
|
|
730
|
+ updateAppInstallInfo()
|
658
|
731
|
}catch (e:Exception){
|
659
|
732
|
|
660
|
733
|
}
|
|
@@ -781,6 +854,10 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
781
|
854
|
}
|
782
|
855
|
}
|
783
|
856
|
}
|
|
857
|
+ //如果包含应用商店也移除,因为会在自定义app中添加
|
|
858
|
+ appList.filter { it.packageName == Const.STOREAPPPKG}.forEach {
|
|
859
|
+ removeList.add(it)
|
|
860
|
+ }
|
784
|
861
|
//移除学校控制之外预装应用
|
785
|
862
|
appList.removeAll(removeList)
|
786
|
863
|
} catch (e: Exception) {
|