Browse Source

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

20241218TB223FC(测试jar包)
wangwanlei 9 months ago
parent
commit
e5e66e0e52

+ 11
- 6
app/src/main/java/com/xhly/manageapp/ui/login/activity/LoginActivity.kt View File

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

+ 18
- 4
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

486
             }
486
             }
487
 
487
 
488
             Const.APPINSTALL -> {
488
             Const.APPINSTALL -> {
489
+                val message = uiEvent.message
489
                 updateAppRv()
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
             Const.APPUNINSTALL -> {
501
             Const.APPUNINSTALL -> {
502
+                val message = uiEvent.message
493
                 updateAppRv()
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
             Const.SDINSTALL -> {
514
             Const.SDINSTALL -> {
552
                 data.doEvent = EventLog.USBDISCONNECTEVENT
570
                 data.doEvent = EventLog.USBDISCONNECTEVENT
553
                 viewModel.eventLog(data)
571
                 viewModel.eventLog(data)
554
             }
572
             }
555
-
556
-            "策略更新" -> {
557
-
558
-            }
559
         }
573
         }
560
     }
574
     }
561
 
575
 

Loading…
Cancel
Save