• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 #include <cinttypes>
19 
20 #include "anr_manager.h"
21 #include "event_dump.h"
22 #include "event_interceptor_handler.h"
23 #include "event_monitor_handler.h"
24 #include "hos_key_event.h"
25 #include "input_device_manager.h"
26 #include "input_event.h"
27 #include "input_event_data_transformation.h"
28 #include "input_event_handler.h"
29 #include "input_windows_manager.h"
30 #include "i_pointer_drawing_manager.h"
31 #include "key_event_normalize.h"
32 #include "key_subscriber_handler.h"
33 #include "libinput_adapter.h"
34 #include "mmi_func_callback.h"
35 #include "mouse_event_normalize.h"
36 #include "switch_subscriber_handler.h"
37 #include "time_cost_chk.h"
38 
39 namespace OHOS {
40 namespace MMI {
41 namespace {
42 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "ServerMsgHandler" };
43 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
44 constexpr int32_t SECURITY_COMPONENT_SERVICE_ID = 3050;
45 #endif
46 } // namespace
47 
Init(UDSServer & udsServer)48 void ServerMsgHandler::Init(UDSServer& udsServer)
49 {
50     udsServer_ = &udsServer;
51     MsgCallback funs[] = {
52         {MmiMessageId::DISPLAY_INFO, MsgCallbackBind2(&ServerMsgHandler::OnDisplayInfo, this)},
53         {MmiMessageId::WINDOW_AREA_INFO, MsgCallbackBind2(&ServerMsgHandler::OnWindowAreaInfo, this)},
54         {MmiMessageId::WINDOW_INFO, MsgCallbackBind2(&ServerMsgHandler::OnWindowGroupInfo, this)},
55 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
56         {MmiMessageId::SCINFO_CONFIG, MsgCallbackBind2(&ServerMsgHandler::OnEnhanceConfig, this)},
57 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
58 
59     };
60     for (auto &it : funs) {
61         if (!RegistrationEvent(it)) {
62             MMI_HILOGW("Failed to register event errCode:%{public}d", EVENT_REG_FAIL);
63             continue;
64         }
65     }
66 }
67 
OnMsgHandler(SessionPtr sess,NetPacket & pkt)68 void ServerMsgHandler::OnMsgHandler(SessionPtr sess, NetPacket& pkt)
69 {
70     CHKPV(sess);
71     auto id = pkt.GetMsgId();
72     TimeCostChk chk("ServerMsgHandler::OnMsgHandler", "overtime 300(us)", MAX_OVER_TIME, id);
73     auto callback = GetMsgCallback(id);
74     if (callback == nullptr) {
75         MMI_HILOGE("Unknown msg id:%{public}d,errCode:%{public}d", id, UNKNOWN_MSG_ID);
76         return;
77     }
78     auto ret = (*callback)(sess, pkt);
79     if (ret < 0) {
80         MMI_HILOGE("Msg handling failed. id:%{public}d,errCode:%{public}d", id, ret);
81     }
82 }
83 
84 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
OnInjectKeyEvent(const std::shared_ptr<KeyEvent> keyEvent)85 int32_t ServerMsgHandler::OnInjectKeyEvent(const std::shared_ptr<KeyEvent> keyEvent)
86 {
87     CALL_DEBUG_ENTER;
88     CHKPR(keyEvent, ERROR_NULL_POINTER);
89     auto inputEventNormalizeHandler = InputHandler->GetEventNormalizeHandler();
90     CHKPR(inputEventNormalizeHandler, ERROR_NULL_POINTER);
91     inputEventNormalizeHandler->HandleKeyEvent(keyEvent);
92     MMI_HILOGD("Inject keyCode:%{public}d, action:%{public}d", keyEvent->GetKeyCode(), keyEvent->GetKeyAction());
93     return RET_OK;
94 }
95 
OnGetFunctionKeyState(int32_t funcKey,bool & state)96 int32_t ServerMsgHandler::OnGetFunctionKeyState(int32_t funcKey, bool &state)
97 {
98     CALL_INFO_TRACE;
99     const auto &keyEvent = KeyEventHdr->GetKeyEvent();
100     CHKPR(keyEvent, ERROR_NULL_POINTER);
101     state = keyEvent->GetFunctionKey(funcKey);
102     MMI_HILOGD("Get the function key:%{public}d status as %{public}s", funcKey, state ? "open" : "close");
103     return RET_OK;
104 }
105 
OnSetFunctionKeyState(int32_t funcKey,bool enable)106 int32_t ServerMsgHandler::OnSetFunctionKeyState(int32_t funcKey, bool enable)
107 {
108     CALL_INFO_TRACE;
109     auto device = InputDevMgr->GetKeyboardDevice();
110     CHKPR(device, ERROR_NULL_POINTER);
111     if (LibinputAdapter::DeviceLedUpdate(device, funcKey, enable) != RET_OK) {
112         MMI_HILOGE("Failed to set the keyboard led");
113         return RET_ERR;
114     }
115     int32_t state = libinput_get_funckey_state(device, funcKey);
116 
117     auto keyEvent = KeyEventHdr->GetKeyEvent();
118     CHKPR(keyEvent, ERROR_NULL_POINTER);
119     int32_t ret = keyEvent->SetFunctionKey(funcKey, state);
120     if (ret != funcKey) {
121         MMI_HILOGE("Failed to enable the function key");
122         return RET_ERR;
123     }
124     MMI_HILOGD("Update function key:%{public}d succeed", funcKey);
125     return RET_OK;
126 }
127 #endif // OHOS_BUILD_ENABLE_KEYBOARD
128 
129 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
OnInjectPointerEvent(const std::shared_ptr<PointerEvent> pointerEvent)130 int32_t ServerMsgHandler::OnInjectPointerEvent(const std::shared_ptr<PointerEvent> pointerEvent)
131 {
132     CALL_DEBUG_ENTER;
133     CHKPR(pointerEvent, ERROR_NULL_POINTER);
134     pointerEvent->UpdateId();
135     int32_t action = pointerEvent->GetPointerAction();
136     auto source = pointerEvent->GetSourceType();
137     switch (source) {
138         case PointerEvent::SOURCE_TYPE_TOUCHSCREEN: {
139 #ifdef OHOS_BUILD_ENABLE_TOUCH
140             auto inputEventNormalizeHandler = InputHandler->GetEventNormalizeHandler();
141             CHKPR(inputEventNormalizeHandler, ERROR_NULL_POINTER);
142             if (!FixTargetWindowId(pointerEvent, action)) {
143                 return RET_ERR;
144             }
145             inputEventNormalizeHandler->HandleTouchEvent(pointerEvent);
146 #endif // OHOS_BUILD_ENABLE_TOUCH
147             break;
148         }
149         case PointerEvent::SOURCE_TYPE_MOUSE:
150 #ifdef OHOS_BUILD_ENABLE_JOYSTICK
151         case PointerEvent::SOURCE_TYPE_JOYSTICK:
152 #endif // OHOS_BUILD_ENABLE_JOYSTICK
153         case PointerEvent::SOURCE_TYPE_TOUCHPAD: {
154 #ifdef OHOS_BUILD_ENABLE_POINTER
155             auto inputEventNormalizeHandler = InputHandler->GetEventNormalizeHandler();
156             CHKPR(inputEventNormalizeHandler, ERROR_NULL_POINTER);
157             if ((action < PointerEvent::POINTER_ACTION_PULL_DOWN ||
158                 action > PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW) &&
159                 !IPointerDrawingManager::GetInstance()->IsPointerVisible()) {
160                 IPointerDrawingManager::GetInstance()->SetPointerVisible(getpid(), true);
161             }
162             inputEventNormalizeHandler->HandlePointerEvent(pointerEvent);
163 #endif // OHOS_BUILD_ENABLE_POINTER
164             break;
165         }
166         default: {
167             MMI_HILOGW("Source type is unknown, source:%{public}d", source);
168             break;
169         }
170     }
171     if (source == PointerEvent::SOURCE_TYPE_TOUCHSCREEN && action == PointerEvent::POINTER_ACTION_DOWN) {
172         int32_t pointerId = pointerEvent->GetPointerId();
173         PointerEvent::PointerItem pointerItem;
174         if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
175             MMI_HILOGE("Can't find pointer item, pointer:%{public}d", pointerId);
176             return RET_ERR;
177         }
178         int32_t targetWindowId = pointerEvent->GetTargetWindowId();
179         targetWindowIds_[pointerId] = targetWindowId;
180     }
181     return RET_OK;
182 }
183 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
184 
185 #ifdef OHOS_BUILD_ENABLE_TOUCH
FixTargetWindowId(std::shared_ptr<PointerEvent> pointerEvent,int32_t action)186 bool ServerMsgHandler::FixTargetWindowId(std::shared_ptr<PointerEvent> pointerEvent, int32_t action)
187 {
188     int32_t targetWindowId = -1;
189     auto iter = targetWindowIds_.find(pointerEvent->GetPointerId());
190     if (iter != targetWindowIds_.end()) {
191         targetWindowId = iter->second;
192     }
193     if (action == PointerEvent::POINTER_ACTION_DOWN || targetWindowId < 0) {
194         MMI_HILOGD("Down event or targetWindowId less 0 is not need fix window id");
195         return true;
196     }
197     auto pointerIds = pointerEvent->GetPointerIds();
198     if (pointerIds.empty()) {
199         MMI_HILOGE("GetPointerIds is empty");
200         return false;
201     }
202     int32_t pointerId = pointerEvent->GetPointerId();
203     PointerEvent::PointerItem pointerItem;
204     if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
205         MMI_HILOGE("Can't find pointer item, pointer:%{public}d", pointerId);
206         return false;
207     }
208     pointerEvent->SetTargetWindowId(targetWindowId);
209     pointerItem.SetTargetWindowId(targetWindowId);
210     pointerEvent->UpdatePointerItem(pointerId, pointerItem);
211     return true;
212 }
213 #endif // OHOS_BUILD_ENABLE_TOUCH
214 
OnDisplayInfo(SessionPtr sess,NetPacket & pkt)215 int32_t ServerMsgHandler::OnDisplayInfo(SessionPtr sess, NetPacket &pkt)
216 {
217     CALL_DEBUG_ENTER;
218     CHKPR(sess, ERROR_NULL_POINTER);
219     DisplayGroupInfo displayGroupInfo;
220     pkt >> displayGroupInfo.width >> displayGroupInfo.height >> displayGroupInfo.focusWindowId;
221     uint32_t num = 0;
222     pkt >> num;
223     if (pkt.ChkRWError()) {
224         MMI_HILOGE("Packet read display info failed");
225         return RET_ERR;
226     }
227     for (uint32_t i = 0; i < num; i++) {
228         WindowInfo info;
229         pkt >> info.id >> info.pid >> info.uid >> info.area >> info.defaultHotAreas
230             >> info.pointerHotAreas >> info.agentWindowId >> info.flags >> info.action
231             >> info.displayId >> info.zOrder >> info.pointerChangeAreas >> info.transform;
232         displayGroupInfo.windowsInfo.push_back(info);
233         if (pkt.ChkRWError()) {
234             MMI_HILOGE("Packet read display info failed");
235             return RET_ERR;
236         }
237     }
238     pkt >> num;
239     for (uint32_t i = 0; i < num; i++) {
240         DisplayInfo info;
241         pkt >> info.id >> info.x >> info.y >> info.width >> info.height >> info.dpi >> info.name
242             >> info.uniq >> info.direction >> info.displayDirection >> info.displayMode;
243         displayGroupInfo.displaysInfo.push_back(info);
244         if (pkt.ChkRWError()) {
245         MMI_HILOGE("Packet read display info failed");
246         return RET_ERR;
247     }
248     }
249     if (pkt.ChkRWError()) {
250         MMI_HILOGE("Packet read display info failed");
251         return RET_ERR;
252     }
253     WinMgr->UpdateDisplayInfoExtIfNeed(displayGroupInfo, true);
254     return RET_OK;
255 }
256 
OnWindowAreaInfo(SessionPtr sess,NetPacket & pkt)257 int32_t ServerMsgHandler::OnWindowAreaInfo(SessionPtr sess, NetPacket &pkt)
258 {
259     CALL_DEBUG_ENTER;
260     CHKPR(sess, ERROR_NULL_POINTER);
261     int32_t temp;
262     int32_t pid;
263     int32_t windowId;
264     pkt >> temp >> pid >> windowId;
265     WindowArea area = static_cast<WindowArea>(temp);
266     if (pkt.ChkRWError()) {
267         MMI_HILOGE("Packet read display info failed");
268         return RET_ERR;
269     }
270     WinMgr->SetWindowPointerStyle(area, pid, windowId);
271     return RET_OK;
272 }
273 
OnWindowGroupInfo(SessionPtr sess,NetPacket & pkt)274 int32_t ServerMsgHandler::OnWindowGroupInfo(SessionPtr sess, NetPacket &pkt)
275 {
276     CALL_DEBUG_ENTER;
277     CHKPR(sess, ERROR_NULL_POINTER);
278     WindowGroupInfo windowGroupInfo;
279     pkt >> windowGroupInfo.focusWindowId >> windowGroupInfo.displayId;
280     uint32_t num = 0;
281     pkt >> num;
282     if (pkt.ChkRWError()) {
283         MMI_HILOGE("Packet read window group info failed");
284         return RET_ERR;
285     }
286     for (uint32_t i = 0; i < num; i++) {
287         WindowInfo info;
288         pkt >> info.id >> info.pid >> info.uid >> info.area >> info.defaultHotAreas
289             >> info.pointerHotAreas >> info.agentWindowId >> info.flags >> info.action
290             >> info.displayId >> info.zOrder >> info.pointerChangeAreas >> info.transform;
291         windowGroupInfo.windowsInfo.push_back(info);
292         if (pkt.ChkRWError()) {
293             MMI_HILOGE("Packet read display info failed");
294             return RET_ERR;
295         }
296     }
297 
298     WinMgr->UpdateWindowInfo(windowGroupInfo);
299     return RET_OK;
300 }
301 
302 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
OnEnhanceConfig(SessionPtr sess,NetPacket & pkt)303 int32_t ServerMsgHandler::OnEnhanceConfig(SessionPtr sess, NetPacket &pkt)
304 {
305     CHKPR(sess, ERROR_NULL_POINTER);
306     int32_t userId = sess->GetUid();
307     if (userId != SECURITY_COMPONENT_SERVICE_ID) {
308         MMI_HILOGE("Session is not security component service");
309         return RET_ERR;
310     }
311     uint32_t num = 0;
312     pkt >> num;
313     uint8_t cfg[num];
314     for (uint32_t i = 0; i < num; i++) {
315         pkt >> cfg[i];
316     }
317 
318     if (pkt.ChkRWError()) {
319         MMI_HILOGE("Packet read scinfo config failed");
320         return RET_ERR;
321     }
322     int32_t result = Security::SecurityComponent::SecCompEnhanceKit::SetEnhanceCfg(cfg, num);
323     if (result != 0) {
324         return RET_ERR;
325     }
326     return RET_OK;
327 }
328 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
329 
330 #if defined(OHOS_BUILD_ENABLE_INTERCEPTOR) || defined(OHOS_BUILD_ENABLE_MONITOR)
OnAddInputHandler(SessionPtr sess,InputHandlerType handlerType,HandleEventType eventType,int32_t priority,uint32_t deviceTags)331 int32_t ServerMsgHandler::OnAddInputHandler(SessionPtr sess, InputHandlerType handlerType,
332     HandleEventType eventType, int32_t priority, uint32_t deviceTags)
333 {
334     CHKPR(sess, ERROR_NULL_POINTER);
335     MMI_HILOGD("handlerType:%{public}d", handlerType);
336 #ifdef OHOS_BUILD_ENABLE_INTERCEPTOR
337     if (handlerType == InputHandlerType::INTERCEPTOR) {
338         auto interceptorHandler = InputHandler->GetInterceptorHandler();
339         CHKPR(interceptorHandler, ERROR_NULL_POINTER);
340         return interceptorHandler->AddInputHandler(handlerType, eventType, priority, deviceTags, sess);
341     }
342 #endif // OHOS_BUILD_ENABLE_INTERCEPTOR
343 #ifdef OHOS_BUILD_ENABLE_MONITOR
344     if (handlerType == InputHandlerType::MONITOR) {
345         auto monitorHandler = InputHandler->GetMonitorHandler();
346         CHKPR(monitorHandler, ERROR_NULL_POINTER);
347         return monitorHandler->AddInputHandler(handlerType, eventType, sess);
348     }
349 #endif // OHOS_BUILD_ENABLE_MONITOR
350     return RET_OK;
351 }
352 
OnRemoveInputHandler(SessionPtr sess,InputHandlerType handlerType,HandleEventType eventType,int32_t priority,uint32_t deviceTags)353 int32_t ServerMsgHandler::OnRemoveInputHandler(SessionPtr sess, InputHandlerType handlerType,
354     HandleEventType eventType, int32_t priority, uint32_t deviceTags)
355 {
356     CHKPR(sess, ERROR_NULL_POINTER);
357     MMI_HILOGD("OnRemoveInputHandler handlerType:%{public}d eventType:%{public}u", handlerType, eventType);
358 #ifdef OHOS_BUILD_ENABLE_INTERCEPTOR
359     if (handlerType == InputHandlerType::INTERCEPTOR) {
360         auto interceptorHandler = InputHandler->GetInterceptorHandler();
361         CHKPR(interceptorHandler, ERROR_NULL_POINTER);
362         interceptorHandler->RemoveInputHandler(handlerType, eventType, priority, deviceTags, sess);
363     }
364 #endif // OHOS_BUILD_ENABLE_INTERCEPTOR
365 #ifdef OHOS_BUILD_ENABLE_MONITOR
366     if (handlerType == InputHandlerType::MONITOR) {
367         auto monitorHandler = InputHandler->GetMonitorHandler();
368         CHKPR(monitorHandler, ERROR_NULL_POINTER);
369         monitorHandler->RemoveInputHandler(handlerType, eventType, sess);
370     }
371 #endif // OHOS_BUILD_ENABLE_MONITOR
372     return RET_OK;
373 }
374 #endif // OHOS_BUILD_ENABLE_INTERCEPTOR || OHOS_BUILD_ENABLE_MONITOR
375 
376 #ifdef OHOS_BUILD_ENABLE_MONITOR
OnMarkConsumed(SessionPtr sess,int32_t eventId)377 int32_t ServerMsgHandler::OnMarkConsumed(SessionPtr sess, int32_t eventId)
378 {
379     CHKPR(sess, ERROR_NULL_POINTER);
380     auto monitorHandler = InputHandler->GetMonitorHandler();
381     CHKPR(monitorHandler, ERROR_NULL_POINTER);
382     monitorHandler->MarkConsumed(eventId, sess);
383     return RET_OK;
384 }
385 #endif // OHOS_BUILD_ENABLE_MONITOR
386 
387 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING)
OnMoveMouse(int32_t offsetX,int32_t offsetY)388 int32_t ServerMsgHandler::OnMoveMouse(int32_t offsetX, int32_t offsetY)
389 {
390     CALL_DEBUG_ENTER;
391     if (MouseEventHdr->NormalizeMoveMouse(offsetX, offsetY)) {
392         auto pointerEvent = MouseEventHdr->GetPointerEvent();
393         CHKPR(pointerEvent, ERROR_NULL_POINTER);
394         auto inputEventNormalizeHandler = InputHandler->GetEventNormalizeHandler();
395         CHKPR(inputEventNormalizeHandler, ERROR_NULL_POINTER);
396         inputEventNormalizeHandler->HandlePointerEvent(pointerEvent);
397         MMI_HILOGD("Mouse movement message processed successfully");
398     }
399     return RET_OK;
400 }
401 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING
402 
403 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
OnSubscribeKeyEvent(IUdsServer * server,int32_t pid,int32_t subscribeId,const std::shared_ptr<KeyOption> option)404 int32_t ServerMsgHandler::OnSubscribeKeyEvent(IUdsServer *server, int32_t pid,
405     int32_t subscribeId, const std::shared_ptr<KeyOption> option)
406 {
407     CALL_DEBUG_ENTER;
408     CHKPR(server, ERROR_NULL_POINTER);
409     auto sess = server->GetSessionByPid(pid);
410     CHKPR(sess, ERROR_NULL_POINTER);
411     auto subscriberHandler = InputHandler->GetSubscriberHandler();
412     CHKPR(subscriberHandler, ERROR_NULL_POINTER);
413     return subscriberHandler->SubscribeKeyEvent(sess, subscribeId, option);
414 }
415 
OnUnsubscribeKeyEvent(IUdsServer * server,int32_t pid,int32_t subscribeId)416 int32_t ServerMsgHandler::OnUnsubscribeKeyEvent(IUdsServer *server, int32_t pid, int32_t subscribeId)
417 {
418     CALL_DEBUG_ENTER;
419     CHKPR(server, ERROR_NULL_POINTER);
420     auto sess = server->GetSessionByPid(pid);
421     CHKPR(sess, ERROR_NULL_POINTER);
422     auto subscriberHandler = InputHandler->GetSubscriberHandler();
423     CHKPR(subscriberHandler, ERROR_NULL_POINTER);
424     return subscriberHandler->UnsubscribeKeyEvent(sess, subscribeId);
425 }
426 #endif // OHOS_BUILD_ENABLE_KEYBOARD
427 
428 #ifdef OHOS_BUILD_ENABLE_SWITCH
OnSubscribeSwitchEvent(IUdsServer * server,int32_t pid,int32_t subscribeId)429 int32_t ServerMsgHandler::OnSubscribeSwitchEvent(IUdsServer *server, int32_t pid, int32_t subscribeId)
430 {
431     CALL_DEBUG_ENTER;
432     CHKPR(server, ERROR_NULL_POINTER);
433     auto sess = server->GetSessionByPid(pid);
434     CHKPR(sess, ERROR_NULL_POINTER);
435     auto subscriberHandler = InputHandler->GetSwitchSubscriberHandler();
436     CHKPR(subscriberHandler, ERROR_NULL_POINTER);
437     return subscriberHandler->SubscribeSwitchEvent(sess, subscribeId);
438 }
439 
OnUnsubscribeSwitchEvent(IUdsServer * server,int32_t pid,int32_t subscribeId)440 int32_t ServerMsgHandler::OnUnsubscribeSwitchEvent(IUdsServer *server, int32_t pid, int32_t subscribeId)
441 {
442     CALL_DEBUG_ENTER;
443     CHKPR(server, ERROR_NULL_POINTER);
444     auto sess = server->GetSessionByPid(pid);
445     CHKPR(sess, ERROR_NULL_POINTER);
446     auto subscriberHandler = InputHandler->GetSwitchSubscriberHandler();
447     CHKPR(subscriberHandler, ERROR_NULL_POINTER);
448     return subscriberHandler->UnsubscribeSwitchEvent(sess, subscribeId);
449 }
450 #endif // OHOS_BUILD_ENABLE_SWITCH
451 
452 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
AddInputEventFilter(sptr<IEventFilter> filter,int32_t filterId,int32_t priority,uint32_t deviceTags,int32_t clientPid)453 int32_t ServerMsgHandler::AddInputEventFilter(sptr<IEventFilter> filter,
454     int32_t filterId, int32_t priority, uint32_t deviceTags, int32_t clientPid)
455 {
456     auto filterHandler = InputHandler->GetFilterHandler();
457     CHKPR(filterHandler, ERROR_NULL_POINTER);
458     return filterHandler->AddInputEventFilter(filter, filterId, priority, deviceTags, clientPid);
459 }
460 
RemoveInputEventFilter(int32_t clientPid,int32_t filterId)461 int32_t ServerMsgHandler::RemoveInputEventFilter(int32_t clientPid, int32_t filterId)
462 {
463     auto filterHandler = InputHandler->GetFilterHandler();
464     CHKPR(filterHandler, ERROR_NULL_POINTER);
465     return filterHandler->RemoveInputEventFilter(clientPid, filterId);
466 }
467 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
468 
SetShieldStatus(int32_t shieldMode,bool isShield)469 int32_t ServerMsgHandler::SetShieldStatus(int32_t shieldMode, bool isShield)
470 {
471     return KeyEventHdr->SetShieldStatus(shieldMode, isShield);
472 }
473 
GetShieldStatus(int32_t shieldMode,bool & isShield)474 int32_t ServerMsgHandler::GetShieldStatus(int32_t shieldMode, bool &isShield)
475 {
476     return KeyEventHdr->GetShieldStatus(shieldMode, isShield);
477 }
478 } // namespace MMI
479 } // namespace OHOS
480