1 /*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "server_msg_handler.h"
17 #include <cinttypes>
18 #include "event_dump.h"
19 #include "event_package.h"
20 #include "input_device_manager.h"
21 #include "input_event_data_transformation.h"
22 #include "input_event.h"
23 #include "input_event_monitor_manager.h"
24 #include "input_handler_manager_global.h"
25 #include "input_windows_manager.h"
26 #include "interceptor_manager_global.h"
27 #include "key_event_subscriber.h"
28 #include "mmi_func_callback.h"
29 #include "time_cost_chk.h"
30
31 namespace OHOS {
32 namespace MMI {
33 namespace {
34 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "ServerMsgHandler" };
35 }
36 } // namespace MMI
37 } // namespace OHOS
38
ServerMsgHandler()39 OHOS::MMI::ServerMsgHandler::ServerMsgHandler() {}
40
~ServerMsgHandler()41 OHOS::MMI::ServerMsgHandler::~ServerMsgHandler() {}
42
Init(UDSServer & udsServer)43 bool OHOS::MMI::ServerMsgHandler::Init(UDSServer& udsServer)
44 {
45 udsServer_ = &udsServer;
46 MsgCallback funs[] = {
47 {MmiMessageId::ON_VIRTUAL_KEY, MsgCallbackBind2(&ServerMsgHandler::OnVirtualKeyEvent, this)},
48 {MmiMessageId::NEW_CHECK_REPLY_MESSAGE,
49 MsgCallbackBind2(&ServerMsgHandler::NewCheckReplyMessageFormClient, this)},
50 {MmiMessageId::ON_DUMP, MsgCallbackBind2(&ServerMsgHandler::OnDump, this)},
51 {MmiMessageId::GET_MMI_INFO_REQ, MsgCallbackBind2(&ServerMsgHandler::GetMultimodeInputInfo, this)},
52 {MmiMessageId::INJECT_KEY_EVENT, MsgCallbackBind2(&ServerMsgHandler::OnInjectKeyEvent, this) },
53 {MmiMessageId::INJECT_POINTER_EVENT, MsgCallbackBind2(&ServerMsgHandler::OnInjectPointerEvent, this) },
54 {MmiMessageId::INPUT_DEVICE, MsgCallbackBind2(&ServerMsgHandler::OnInputDevice, this)},
55 {MmiMessageId::INPUT_DEVICE_IDS, MsgCallbackBind2(&ServerMsgHandler::OnInputDeviceIds, this)},
56 {MmiMessageId::DISPLAY_INFO, MsgCallbackBind2(&ServerMsgHandler::OnDisplayInfo, this)},
57 {MmiMessageId::ADD_INPUT_EVENT_MONITOR, MsgCallbackBind2(&ServerMsgHandler::OnAddInputEventMontior, this)},
58 {MmiMessageId::REMOVE_INPUT_EVENT_MONITOR, MsgCallbackBind2(&ServerMsgHandler::OnRemoveInputEventMontior, this)},
59 {MmiMessageId::ADD_INPUT_EVENT_TOUCHPAD_MONITOR,
60 MsgCallbackBind2(&ServerMsgHandler::OnAddInputEventTouchpadMontior, this)},
61 {MmiMessageId::REMOVE_INPUT_EVENT_TOUCHPAD_MONITOR,
62 MsgCallbackBind2(&ServerMsgHandler::OnRemoveInputEventTouchpadMontior, this)},
63 {MmiMessageId::ADD_INPUT_HANDLER, MsgCallbackBind2(&ServerMsgHandler::OnAddInputHandler, this)},
64 {MmiMessageId::REMOVE_INPUT_HANDLER, MsgCallbackBind2(&ServerMsgHandler::OnRemoveInputHandler, this)},
65 {MmiMessageId::MARK_CONSUMED, MsgCallbackBind2(&ServerMsgHandler::OnMarkConsumed, this)},
66 {MmiMessageId::SUBSCRIBE_KEY_EVENT, MsgCallbackBind2(&ServerMsgHandler::OnSubscribeKeyEvent, this)},
67 {MmiMessageId::UNSUBSCRIBE_KEY_EVENT, MsgCallbackBind2(&ServerMsgHandler::OnUnSubscribeKeyEvent, this)},
68 {MmiMessageId::ADD_EVENT_INTERCEPTOR,
69 MsgCallbackBind2(&ServerMsgHandler::OnAddTouchpadEventFilter, this)},
70 {MmiMessageId::REMOVE_EVENT_INTERCEPTOR,
71 MsgCallbackBind2(&ServerMsgHandler::OnRemoveTouchpadEventFilter, this)},
72 };
73 for (auto& it : funs) {
74 CHKC(RegistrationEvent(it), EVENT_REG_FAIL);
75 }
76 return true;
77 }
78
OnMsgHandler(SessionPtr sess,NetPacket & pkt)79 void OHOS::MMI::ServerMsgHandler::OnMsgHandler(SessionPtr sess, NetPacket& pkt)
80 {
81 CHKPV(sess);
82 auto id = pkt.GetMsgId();
83 OHOS::MMI::TimeCostChk chk("ServerMsgHandler::OnMsgHandler", "overtime 300(us)", MAX_OVER_TIME, id);
84 auto callback = GetMsgCallback(id);
85 if (callback == nullptr) {
86 MMI_LOGE("ServerMsgHandler::OnMsgHandler Unknown msg id:%{public}d,errCode:%{public}d", id, UNKNOWN_MSG_ID);
87 return;
88 }
89 auto ret = (*callback)(sess, pkt);
90 if (ret < 0) {
91 MMI_LOGE("ServerMsgHandler::OnMsgHandler Msg handling failed. id:%{public}d,errCode:%{public}d", id, ret);
92 }
93 }
94
OnVirtualKeyEvent(SessionPtr sess,NetPacket & pkt)95 int32_t OHOS::MMI::ServerMsgHandler::OnVirtualKeyEvent(SessionPtr sess, NetPacket& pkt)
96 {
97 VirtualKey virtualKeyEvent;
98 pkt >> virtualKeyEvent;
99 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
100 if (virtualKeyEvent.keyCode == HOS_KEY_HOME) {
101 MMI_LOGD(" home press");
102 } else if (virtualKeyEvent.keyCode == HOS_KEY_BACK) {
103 MMI_LOGD(" back press");
104 } else if (virtualKeyEvent.keyCode == HOS_KEY_VIRTUAL_MULTITASK) {
105 MMI_LOGD(" multitask press");
106 }
107 return RET_OK;
108 }
109
OnDump(SessionPtr sess,NetPacket & pkt)110 int32_t OHOS::MMI::ServerMsgHandler::OnDump(SessionPtr sess, NetPacket& pkt)
111 {
112 CHKPR(udsServer_, ERROR_NULL_POINTER);
113 int32_t fd = -1;
114 pkt >> fd;
115 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
116 MMIEventDump->Dump(fd);
117 return RET_OK;
118 }
119
NewCheckReplyMessageFormClient(SessionPtr sess,NetPacket & pkt)120 int32_t OHOS::MMI::ServerMsgHandler::NewCheckReplyMessageFormClient(SessionPtr sess, NetPacket& pkt)
121 {
122 MMI_LOGD("begin");
123 CHKPR(sess, ERROR_NULL_POINTER);
124 int32_t id = 0;
125 pkt >> id;
126 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
127 sess->DelEvents(id);
128 MMI_LOGD("end");
129 return RET_OK;
130 }
131
GetMultimodeInputInfo(SessionPtr sess,NetPacket & pkt)132 int32_t OHOS::MMI::ServerMsgHandler::GetMultimodeInputInfo(SessionPtr sess, NetPacket& pkt)
133 {
134 CHKPR(sess, ERROR_NULL_POINTER);
135 CHKPR(udsServer_, ERROR_NULL_POINTER);
136 TagPackHead tagPackHead;
137 pkt >> tagPackHead;
138 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
139 int32_t fd = sess->GetFd();
140 if (tagPackHead.idMsg != MmiMessageId::INVALID) {
141 TagPackHead tagPackHeadAck = { MmiMessageId::INVALID, {fd}};
142 NetPacket pkt(MmiMessageId::GET_MMI_INFO_ACK);
143 pkt << tagPackHeadAck;
144 if (!udsServer_->SendMsg(fd, pkt)) {
145 MMI_LOGE("Sending message failed");
146 return MSG_SEND_FAIL;
147 }
148 }
149 return RET_OK;
150 }
151
OnInjectKeyEvent(SessionPtr sess,NetPacket & pkt)152 int32_t OHOS::MMI::ServerMsgHandler::OnInjectKeyEvent(SessionPtr sess, NetPacket& pkt)
153 {
154 CHKPR(sess, ERROR_NULL_POINTER);
155 int64_t preHandlerTime = GetSysClockTime();
156 auto creKey = OHOS::MMI::KeyEvent::Create();
157 int32_t errCode = InputEventDataTransformation::NetPacketToKeyEvent(pkt, creKey);
158 if (errCode != RET_OK) {
159 MMI_LOGE("Deserialization is Failed, errCode:%{public}u", errCode);
160 return RET_ERR;
161 }
162
163 auto eventDispatchResult = eventDispatch_.DispatchKeyEventPid(*udsServer_, creKey, preHandlerTime);
164 if (eventDispatchResult != RET_OK) {
165 MMI_LOGE("Key event dispatch failed. ret:%{public}d,errCode:%{public}d",
166 eventDispatchResult, KEY_EVENT_DISP_FAIL);
167 }
168 MMI_LOGD("Inject keyCode:%{public}d, action:%{public}d", creKey->GetKeyCode(), creKey->GetKeyAction());
169 return RET_OK;
170 }
171
OnInjectPointerEvent(SessionPtr sess,NetPacket & pkt)172 int32_t OHOS::MMI::ServerMsgHandler::OnInjectPointerEvent(SessionPtr sess, NetPacket& pkt)
173 {
174 MMI_LOGD("enter");
175 auto pointerEvent = OHOS::MMI::PointerEvent::Create();
176 CHKR((RET_OK == InputEventDataTransformation::Unmarshalling(pkt, pointerEvent)),
177 STREAM_BUF_READ_FAIL, RET_ERR);
178 pointerEvent->UpdateId();
179 CHKR((RET_OK == eventDispatch_.HandlePointerEvent(pointerEvent)), POINT_EVENT_DISP_FAIL, RET_ERR);
180 MMI_LOGD("leave");
181 return RET_OK;
182 }
183
OnDisplayInfo(SessionPtr sess,NetPacket & pkt)184 int32_t OHOS::MMI::ServerMsgHandler::OnDisplayInfo(SessionPtr sess, NetPacket &pkt)
185 {
186 MMI_LOGD("enter");
187 CHKPR(sess, ERROR_NULL_POINTER);
188
189 std::vector<PhysicalDisplayInfo> physicalDisplays;
190 int32_t num = 0;
191 pkt.Read(num);
192 for (int32_t i = 0; i < num; i++) {
193 PhysicalDisplayInfo info;
194 pkt.Read(info.id);
195 pkt.Read(info.leftDisplayId);
196 pkt.Read(info.upDisplayId);
197 pkt.Read(info.topLeftX);
198 pkt.Read(info.topLeftY);
199 pkt.Read(info.width);
200 pkt.Read(info.height);
201 pkt.Read(info.name);
202 pkt.Read(info.seatId);
203 pkt.Read(info.seatName);
204 pkt.Read(info.logicWidth);
205 pkt.Read(info.logicHeight);
206 pkt.Read(info.direction);
207 physicalDisplays.push_back(info);
208 }
209
210 std::vector<LogicalDisplayInfo> logicalDisplays;
211 pkt.Read(num);
212 for (int32_t i = 0; i < num; i++) {
213 LogicalDisplayInfo info;
214 pkt.Read(info.id);
215 pkt.Read(info.topLeftX);
216 pkt.Read(info.topLeftY);
217 pkt.Read(info.width);
218 pkt.Read(info.height);
219 pkt.Read(info.name);
220 pkt.Read(info.seatId);
221 pkt.Read(info.seatName);
222 pkt.Read(info.focusWindowId);
223
224 std::vector<WindowInfo> windowInfos;
225 int32_t numWindow = 0;
226 pkt.Read(numWindow);
227 for (int32_t j = 0; j < numWindow; j++) {
228 WindowInfo info;
229 pkt.Read(info);
230 windowInfos.push_back(info);
231 }
232 info.windowsInfo_ = windowInfos;
233 logicalDisplays.push_back(info);
234 }
235
236 OHOS::MMI::InputWindowsManager::GetInstance()->UpdateDisplayInfo(physicalDisplays, logicalDisplays);
237 MMI_LOGD("leave");
238 return RET_OK;
239 }
240
OnAddInputHandler(SessionPtr sess,NetPacket & pkt)241 int32_t OHOS::MMI::ServerMsgHandler::OnAddInputHandler(SessionPtr sess, NetPacket& pkt)
242 {
243 int32_t handlerId;
244 InputHandlerType handlerType;
245 CHKR(pkt.Read(handlerId), STREAM_BUF_READ_FAIL, RET_ERR);
246 CHKR(pkt.Read(handlerType), STREAM_BUF_READ_FAIL, RET_ERR);
247 MMI_LOGD("OnAddInputHandler handler:%{public}d,handlerType:%{public}d", handlerId, handlerType);
248 return InputHandlerManagerGlobal::GetInstance().AddInputHandler(handlerId, handlerType, sess);
249 }
250
OnRemoveInputHandler(SessionPtr sess,NetPacket & pkt)251 int32_t OHOS::MMI::ServerMsgHandler::OnRemoveInputHandler(SessionPtr sess, NetPacket& pkt)
252 {
253 int32_t handlerId;
254 InputHandlerType handlerType;
255 CHKR(pkt.Read(handlerId), STREAM_BUF_READ_FAIL, RET_ERR);
256 CHKR(pkt.Read(handlerType), STREAM_BUF_READ_FAIL, RET_ERR);
257 MMI_LOGD("OnRemoveInputHandler handler:%{public}d,handlerType:%{public}d", handlerId, handlerType);
258 InputHandlerManagerGlobal::GetInstance().RemoveInputHandler(handlerId, handlerType, sess);
259 return RET_OK;
260 }
261
OnMarkConsumed(SessionPtr sess,NetPacket & pkt)262 int32_t OHOS::MMI::ServerMsgHandler::OnMarkConsumed(SessionPtr sess, NetPacket& pkt)
263 {
264 int32_t monitorId, eventId;
265 CHKR(pkt.Read(monitorId), STREAM_BUF_READ_FAIL, RET_ERR);
266 CHKR(pkt.Read(eventId), STREAM_BUF_READ_FAIL, RET_ERR);
267 InputHandlerManagerGlobal::GetInstance().MarkConsumed(monitorId, eventId, sess);
268 return RET_OK;
269 }
270
OnSubscribeKeyEvent(SessionPtr sess,NetPacket & pkt)271 int32_t OHOS::MMI::ServerMsgHandler::OnSubscribeKeyEvent(SessionPtr sess, NetPacket &pkt)
272 {
273 int32_t subscribeId = -1;
274 uint32_t preKeySize = 0;
275 int32_t finalKey = -1;
276 bool isFinalKeyDown = true;
277 int32_t finalKeyDownDuration = 0;
278 pkt >> subscribeId >> finalKey >> isFinalKeyDown >> finalKeyDownDuration >> preKeySize;
279 std::set<int32_t> preKeys;
280 for (uint32_t i = 0; i < preKeySize; ++i) {
281 int32_t tmpKey = -1;
282 pkt >> tmpKey;
283 if (!(preKeys.insert(tmpKey).second)) {
284 MMI_LOGE("Insert value failed, tmpKey:%{public}d", tmpKey);
285 }
286 }
287 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
288 auto keyOption = std::make_shared<OHOS::MMI::KeyOption>();
289 keyOption->SetPreKeys(preKeys);
290 keyOption->SetFinalKey(finalKey);
291 keyOption->SetFinalKeyDown(isFinalKeyDown);
292 keyOption->SetFinalKeyDownDuration(finalKeyDownDuration);
293 int32_t ret = KeyEventSubscriber_.SubscribeKeyEvent(sess, subscribeId, keyOption);
294 return ret;
295 }
296
OnUnSubscribeKeyEvent(SessionPtr sess,NetPacket & pkt)297 int32_t OHOS::MMI::ServerMsgHandler::OnUnSubscribeKeyEvent(SessionPtr sess, NetPacket &pkt)
298 {
299 int32_t subscribeId = -1;
300 pkt >> subscribeId;
301 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
302 int32_t ret = KeyEventSubscriber_.UnSubscribeKeyEvent(sess, subscribeId);
303 return ret;
304 }
305
OnInputDeviceIds(SessionPtr sess,NetPacket & pkt)306 int32_t OHOS::MMI::ServerMsgHandler::OnInputDeviceIds(SessionPtr sess, NetPacket& pkt)
307 {
308 MMI_LOGD("begin");
309 CHKPR(sess, ERROR_NULL_POINTER);
310 int32_t userData = 0;
311 CHKR(pkt.Read(userData), STREAM_BUF_READ_FAIL, RET_ERR);
312 std::vector<int32_t> ids = InputDevMgr->GetInputDeviceIds();
313 NetPacket pkt2(MmiMessageId::INPUT_DEVICE_IDS);
314 int32_t size = static_cast<int32_t>(ids.size());
315 CHKR(pkt2.Write(userData), STREAM_BUF_WRITE_FAIL, RET_ERR);
316 CHKR(pkt2.Write(size), STREAM_BUF_WRITE_FAIL, RET_ERR);
317 for (const auto& item : ids) {
318 CHKR(pkt2.Write(item), STREAM_BUF_WRITE_FAIL, RET_ERR);
319 }
320 if (!sess->SendMsg(pkt2)) {
321 MMI_LOGE("Sending failed");
322 return MSG_SEND_FAIL;
323 }
324 MMI_LOGD("end");
325 return RET_OK;
326 }
327
OnInputDevice(SessionPtr sess,NetPacket & pkt)328 int32_t OHOS::MMI::ServerMsgHandler::OnInputDevice(SessionPtr sess, NetPacket& pkt)
329 {
330 MMI_LOGD("begin");
331 CHKPR(sess, ERROR_NULL_POINTER);
332 int32_t userData = 0;
333 CHKR(pkt.Read(userData), STREAM_BUF_READ_FAIL, RET_ERR);
334 int32_t deviceId = 0;
335 CHKR(pkt.Read(deviceId), STREAM_BUF_READ_FAIL, RET_ERR);
336 std::shared_ptr<InputDevice> inputDevice = InputDevMgr->GetInputDevice(deviceId);
337 NetPacket pkt2(MmiMessageId::INPUT_DEVICE);
338 if (inputDevice == nullptr) {
339 MMI_LOGI("Input device not found");
340 int32_t id = -1;
341 std::string name = "null";
342 int32_t deviceType = -1;
343 CHKR(pkt2.Write(userData), STREAM_BUF_WRITE_FAIL, RET_ERR);
344 CHKR(pkt2.Write(id), STREAM_BUF_WRITE_FAIL, RET_ERR);
345 CHKR(pkt2.Write(name), STREAM_BUF_WRITE_FAIL, RET_ERR);
346 CHKR(pkt2.Write(deviceType), STREAM_BUF_WRITE_FAIL, RET_ERR);
347 if (!sess->SendMsg(pkt2)) {
348 MMI_LOGE("Sending failed");
349 return MSG_SEND_FAIL;
350 }
351 return RET_OK;
352 }
353 int32_t id = inputDevice->GetId();
354 std::string name = inputDevice->GetName();
355 int32_t deviceType = inputDevice->GetType();
356 CHKR(pkt2.Write(userData), STREAM_BUF_WRITE_FAIL, RET_ERR);
357 CHKR(pkt2.Write(id), STREAM_BUF_WRITE_FAIL, RET_ERR);
358 CHKR(pkt2.Write(name), STREAM_BUF_WRITE_FAIL, RET_ERR);
359 CHKR(pkt2.Write(deviceType), STREAM_BUF_WRITE_FAIL, RET_ERR);
360 if (!sess->SendMsg(pkt2)) {
361 MMI_LOGE("Sending failed");
362 return MSG_SEND_FAIL;
363 }
364 MMI_LOGD("end");
365 return RET_OK;
366 }
367
OnAddInputEventMontior(SessionPtr sess,NetPacket & pkt)368 int32_t OHOS::MMI::ServerMsgHandler::OnAddInputEventMontior(SessionPtr sess, NetPacket& pkt)
369 {
370 CHKPR(sess, ERROR_NULL_POINTER);
371 int32_t eventType = 0;
372 pkt >> eventType;
373 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
374 if (eventType != OHOS::MMI::InputEvent::EVENT_TYPE_KEY) {
375 MMI_LOGE("Wrong event type, eventType:%{public}d", eventType);
376 return RET_ERR;
377 }
378 InputMonitorServiceMgr.AddInputEventMontior(sess, eventType);
379 return RET_OK;
380 }
381
OnAddInputEventTouchpadMontior(SessionPtr sess,NetPacket & pkt)382 int32_t OHOS::MMI::ServerMsgHandler::OnAddInputEventTouchpadMontior(SessionPtr sess, NetPacket& pkt)
383 {
384 MMI_LOGD("begin");
385 CHKPR(sess, ERROR_NULL_POINTER);
386 int32_t eventType = 0;
387 pkt >> eventType;
388 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
389 if (eventType != OHOS::MMI::InputEvent::EVENT_TYPE_POINTER) {
390 MMI_LOGE("Wrong event type, eventType:%{public}d", eventType);
391 return RET_ERR;
392 }
393 InputMonitorServiceMgr.AddInputEventTouchpadMontior(eventType, sess);
394 return RET_OK;
395 }
396
OnRemoveInputEventMontior(SessionPtr sess,NetPacket & pkt)397 int32_t OHOS::MMI::ServerMsgHandler::OnRemoveInputEventMontior(SessionPtr sess, NetPacket& pkt)
398 {
399 CHKPR(sess, ERROR_NULL_POINTER);
400 int32_t eventType = 0;
401 pkt >> eventType;
402 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
403 if (eventType != OHOS::MMI::InputEvent::EVENT_TYPE_KEY) {
404 MMI_LOGE("Wrong event type, eventType:%{public}d", eventType);
405 return RET_ERR;
406 }
407 InputMonitorServiceMgr.RemoveInputEventMontior(sess, eventType);
408 return RET_OK;
409 }
410
OnRemoveInputEventTouchpadMontior(SessionPtr sess,NetPacket & pkt)411 int32_t OHOS::MMI::ServerMsgHandler::OnRemoveInputEventTouchpadMontior(SessionPtr sess, NetPacket& pkt)
412 {
413 CHKPR(sess, ERROR_NULL_POINTER);
414 int32_t eventType = 0;
415 pkt >> eventType;
416 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
417 if (eventType != OHOS::MMI::InputEvent::EVENT_TYPE_POINTER) {
418 MMI_LOGE("Wrong event type, eventType:%{public}d", eventType);
419 return RET_ERR;
420 }
421 InputMonitorServiceMgr.RemoveInputEventMontior(sess, eventType);
422 return RET_OK;
423 }
OnAddTouchpadEventFilter(SessionPtr sess,NetPacket & pkt)424 int32_t OHOS::MMI::ServerMsgHandler::OnAddTouchpadEventFilter(SessionPtr sess, NetPacket& pkt)
425 {
426 CHKPR(sess, ERROR_NULL_POINTER);
427 int32_t sourceType = 0;
428 int32_t id = 0;
429 pkt >> sourceType >> id;
430 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
431 InterceptorMgrGbl.OnAddInterceptor(sourceType, id, sess);
432 return RET_OK;
433 }
434
OnRemoveTouchpadEventFilter(SessionPtr sess,NetPacket & pkt)435 int32_t OHOS::MMI::ServerMsgHandler::OnRemoveTouchpadEventFilter(SessionPtr sess, NetPacket& pkt)
436 {
437 CHKPR(sess, ERROR_NULL_POINTER);
438 int32_t id = 0;
439 pkt >> id;
440 CHKR(!pkt.ChkRWError(), PACKET_READ_FAIL, PACKET_READ_FAIL);
441 InterceptorMgrGbl.OnRemoveInterceptor(id);
442 return RET_OK;
443 }
444 // LCOV_EXCL_STOP