|
@@ -40,7 +40,6 @@ import java.util.UUID
|
40
|
40
|
class AppSocket : SocketClient() {
|
41
|
41
|
var logService = RetrofitService.create<LogService>()
|
42
|
42
|
private val serviceScope = CoroutineScope(MainScope().coroutineContext)
|
43
|
|
- private var appList = arrayListOf<AppInfo>()
|
44
|
43
|
|
45
|
44
|
|
46
|
45
|
val spUtils by lazy { SharedPreferencesUtils.getInstance(context) }
|
|
@@ -51,11 +50,9 @@ class AppSocket : SocketClient() {
|
51
|
50
|
}
|
52
|
51
|
|
53
|
52
|
override fun startSocket(context: Context?) {
|
54
|
|
- EventBus.getDefault().register(this)
|
55
|
53
|
connectUrl = Const.WSURL
|
56
|
54
|
/* startNotification()*/
|
57
|
55
|
LogShow("已经创建")
|
58
|
|
- appList = AppUtils.GetAppList(context) as ArrayList<AppInfo>
|
59
|
56
|
//downLoadFile("")
|
60
|
57
|
super.startSocket(context)
|
61
|
58
|
}
|
|
@@ -85,67 +82,10 @@ class AppSocket : SocketClient() {
|
85
|
82
|
WebSocketHelper.getInstance().sendSocketString(GsonUtils.parseClassToJson(webData))
|
86
|
83
|
}
|
87
|
84
|
|
88
|
|
- @Subscribe(threadMode = ThreadMode.MAIN)
|
89
|
|
- fun onUiEvent(uiEvent: UIEvent) {
|
90
|
|
- when (uiEvent.event) {
|
91
|
|
- Const.CODE2001.toString() -> {
|
92
|
|
- Toast.makeText(context, "这就是新消息", Toast.LENGTH_LONG).show()
|
93
|
|
- }
|
94
|
|
-
|
95
|
|
- Const.CODE2002.toString() -> {
|
96
|
|
- Toast.makeText(context, "限制使用", Toast.LENGTH_LONG).show()
|
97
|
|
- spUtils.setParam(Const.DISABLEPAD, true)
|
98
|
|
- goMainActivity()
|
99
|
|
- }
|
100
|
|
-
|
101
|
|
- Const.CODE2003.toString() -> {
|
102
|
|
- Toast.makeText(context, "解除限制", Toast.LENGTH_LONG).show()
|
103
|
|
- spUtils.setParam(Const.DISABLEPAD, false)
|
104
|
|
- goMainActivity()
|
105
|
|
- }
|
106
|
|
-
|
107
|
|
- Const.CODE2004.toString() -> {
|
108
|
|
- //请求接口更新策略
|
109
|
|
- }
|
110
|
|
-
|
111
|
|
- Const.CODE2005.toString() -> {
|
112
|
|
- ManageApplication.rebootDevice()
|
113
|
|
- }
|
114
|
|
-
|
115
|
|
- Const.CODE2006.toString() -> {
|
116
|
|
- ManageApplication.launchFactoryReset()
|
117
|
|
- }
|
118
|
|
-
|
119
|
|
- }
|
120
|
|
- }
|
121
|
|
-
|
122
|
|
- private fun goMainActivity() {
|
123
|
|
- try {
|
124
|
|
- // 为应用程序的启动Activity 准备Intent
|
125
|
|
- val launchIntent = Intent()
|
126
|
|
- launchIntent.setComponent(
|
127
|
|
- ComponentName(
|
128
|
|
- "com.xhly.manageapp",
|
129
|
|
- "com.xhly.manageapp.ui.MainActivity"
|
130
|
|
- )
|
131
|
|
- )
|
132
|
|
- launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
133
|
|
- context.startActivity(launchIntent)
|
134
|
|
- } catch (e: Exception) {
|
135
|
|
- LogShow("跳转失败$e")
|
136
|
|
- }
|
137
|
|
- }
|
138
|
85
|
|
139
|
|
- //用来发送事件日志
|
140
|
|
- private fun eventLog(operateBean: LogdOperateBean) {
|
141
|
|
- serviceScope.launch {
|
142
|
|
- logService.postLogdoperateAdd(operateBean)
|
143
|
|
- }
|
144
|
|
- }
|
145
|
86
|
|
146
|
87
|
override fun onDestroy() {
|
147
|
88
|
super.onDestroy()
|
148
|
|
- EventBus.getDefault().unregister(this)
|
149
|
89
|
serviceScope.cancel()
|
150
|
90
|
/* stopForeground(Service.STOP_FOREGROUND_REMOVE)*/
|
151
|
91
|
val intent = Intent()
|