Преглед изворни кода

1.添加应用安装和卸载事件提交

20241218TB223FC(测试jar包)
wangwanlei пре 9 месеци
родитељ
комит
e5e66e0e52

+ 11
- 6
app/src/main/java/com/xhly/manageapp/ui/login/activity/LoginActivity.kt Прегледај датотеку

@@ -34,11 +34,14 @@ import com.xhly.manageapp.databinding.ActivityLoginBinding
34 34
 import com.xhly.manageapp.service.websocket.AppSocket
35 35
 import com.xhly.manageapp.ui.login.viewmodel.LoginViewModel
36 36
 import com.xhly.manageapp.ui.main.activity.MainActivity
37
+import com.xhly.manageapp.utils.CurrentAppSharedPreferencesUtils
37 38
 import com.xhly.manageapp.utils.StrategyUtils
38 39
 import com.xhly.manageapp.workmanager.TimingWorker
39 40
 import java.util.concurrent.TimeUnit
40 41
 
41 42
 class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
43
+    //单独创建sharedpreference用来存储初始化的应用
44
+    private val currentSpUtils by lazy { CurrentAppSharedPreferencesUtils.getInstance(this) }
42 45
     private var regioncode = ""
43 46
     override fun getBinding() = ActivityLoginBinding.inflate(layoutInflater)
44 47
 
@@ -58,6 +61,7 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
58 61
     @SuppressLint("CheckResult")
59 62
     override fun initView() {
60 63
         setSoftInput(mBinding.root)
64
+
61 65
         mBinding.loginBtn.setOnClickListener {
62 66
             val rxPermissions = RxPermissions(this)
63 67
             val request = rxPermissions.request(Manifest.permission.READ_PHONE_STATE)
@@ -100,6 +104,13 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
100 104
     }
101 105
 
102 106
     private fun loginSucess(userBean: UserBean){
107
+        //提交登录事件
108
+        val data = LogdOperateBean()
109
+        ManageApplication.getDeviceInfo()?.let {
110
+            data.sn = it
111
+        }
112
+        data.doEvent = EventLog.ACCOUNTLOGINEVENT
113
+        viewModel.eventLog(data)
103 114
         spUtils.saveJson(Const.USERINFO,userBean)
104 115
         val parseClassToJson = GsonUtils.parseClassToJson(userBean)
105 116
         ZSpProvider.save(this,Const.USERINFO,parseClassToJson)
@@ -174,12 +185,6 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
174 185
 
175 186
             }
176 187
 
177
-
178
-            Const.LOGAPPSTART -> {
179
-
180
-            }
181
-
182
-
183 188
             Const.SDINSTALL -> {
184 189
                 val data = LogdOperateBean()
185 190
                 ManageApplication.getDeviceInfo()?.let {

+ 18
- 4
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt Прегледај датотеку

@@ -486,11 +486,29 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
486 486
             }
487 487
 
488 488
             Const.APPINSTALL -> {
489
+                val message = uiEvent.message
489 490
                 updateAppRv()
491
+                val data = LogdOperateBean()
492
+                ManageApplication.getDeviceInfo()?.let {
493
+                    data.sn = it
494
+                }
495
+                data.comm = "App安装"
496
+                data.appPackage = message
497
+                data.doEvent = EventLog.APPINSTALLEVENT
498
+                viewModel.eventLog(data)
490 499
             }
491 500
 
492 501
             Const.APPUNINSTALL -> {
502
+                val message = uiEvent.message
493 503
                 updateAppRv()
504
+                val data = LogdOperateBean()
505
+                ManageApplication.getDeviceInfo()?.let {
506
+                    data.sn = it
507
+                }
508
+                data.comm = "App卸载"
509
+                data.appPackage = message
510
+                data.doEvent = EventLog.APPUNINSTALLEVENT
511
+                viewModel.eventLog(data)
494 512
             }
495 513
 
496 514
             Const.SDINSTALL -> {
@@ -552,10 +570,6 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
552 570
                 data.doEvent = EventLog.USBDISCONNECTEVENT
553 571
                 viewModel.eventLog(data)
554 572
             }
555
-
556
-            "策略更新" -> {
557
-
558
-            }
559 573
         }
560 574
     }
561 575
 

Loading…
Откажи
Сачувај