1 /*
2 * Copyright (c) 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 "input_manager_impl.h"
17
18 #include <cinttypes>
19
20 #include "define_multimodal.h"
21 #include "error_multimodal.h"
22
23 #include "bytrace_adapter.h"
24 #include "event_filter_service.h"
25 #include "mmi_client.h"
26 #include "multimodal_event_handler.h"
27 #include "multimodal_input_connect_manager.h"
28 #include "switch_event_input_subscribe_manager.h"
29
30 namespace OHOS {
31 namespace MMI {
32 namespace {
33 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "InputManagerImpl" };
34 constexpr size_t MAX_FILTER_NUM = 4;
35 constexpr int32_t MAX_DELAY = 4000;
36 constexpr int32_t MIN_DELAY = 0;
37 } // namespace
38
39 struct MonitorEventConsumer : public IInputEventConsumer {
MonitorEventConsumerOHOS::MMI::MonitorEventConsumer40 explicit MonitorEventConsumer(const std::function<void(std::shared_ptr<PointerEvent>)> &monitor)
41 : monitor_ (monitor) {}
42
MonitorEventConsumerOHOS::MMI::MonitorEventConsumer43 explicit MonitorEventConsumer(const std::function<void(std::shared_ptr<KeyEvent>)> &monitor)
44 : keyMonitor_ (monitor) {}
45
OnInputEventOHOS::MMI::MonitorEventConsumer46 void OnInputEvent(std::shared_ptr<KeyEvent> keyEvent) const
47 {
48 CHKPV(keyEvent);
49 CHKPV(keyMonitor_);
50 keyMonitor_(keyEvent);
51 }
52
OnInputEventOHOS::MMI::MonitorEventConsumer53 void OnInputEvent(std::shared_ptr<PointerEvent> pointerEvent) const
54 {
55 CHKPV(pointerEvent);
56 CHKPV(monitor_);
57 monitor_(pointerEvent);
58 }
59
OnInputEventOHOS::MMI::MonitorEventConsumer60 void OnInputEvent(std::shared_ptr<AxisEvent> axisEvent) const
61 {
62 CHKPV(axisEvent);
63 CHKPV(axisMonitor_);
64 axisMonitor_(axisEvent);
65 }
66
67 private:
68 std::function<void(std::shared_ptr<PointerEvent>)> monitor_;
69 std::function<void(std::shared_ptr<KeyEvent>)> keyMonitor_;
70 std::function<void(std::shared_ptr<AxisEvent>)> axisMonitor_;
71 };
72
InputManagerImpl()73 InputManagerImpl::InputManagerImpl() {}
~InputManagerImpl()74 InputManagerImpl::~InputManagerImpl() {}
75
GetDisplayBindInfo(DisplayBindInfos & infos)76 int32_t InputManagerImpl::GetDisplayBindInfo(DisplayBindInfos &infos)
77 {
78 CALL_DEBUG_ENTER;
79 std::lock_guard<std::mutex> guard(mtx_);
80 int32_t ret = MultimodalInputConnMgr->GetDisplayBindInfo(infos);
81 if (ret != RET_OK) {
82 MMI_HILOGE("GetDisplayBindInfo failed, ret:%{public}d", ret);
83 return RET_ERR;
84 }
85 return RET_OK;
86 }
87
SetDisplayBind(int32_t deviceId,int32_t displayId,std::string & msg)88 int32_t InputManagerImpl::SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg)
89 {
90 std::lock_guard<std::mutex> guard(mtx_);
91 int32_t ret = MultimodalInputConnMgr->SetDisplayBind(deviceId, displayId, msg);
92 if (ret != RET_OK) {
93 MMI_HILOGE("SetDisplayBind failed, ret:%{public}d", ret);
94 return RET_ERR;
95 }
96 return RET_OK;
97 }
98
GetWindowPid(int32_t windowId)99 int32_t InputManagerImpl::GetWindowPid(int32_t windowId)
100 {
101 std::lock_guard<std::mutex> guard(mtx_);
102 return MultimodalInputConnMgr->GetWindowPid(windowId);
103 }
104
UpdateDisplayInfo(const DisplayGroupInfo & displayGroupInfo)105 void InputManagerImpl::UpdateDisplayInfo(const DisplayGroupInfo &displayGroupInfo)
106 {
107 CALL_DEBUG_ENTER;
108 std::lock_guard<std::mutex> guard(mtx_);
109 if (!MMIEventHdl.InitClient()) {
110 MMI_HILOGE("Get mmi client is nullptr");
111 return;
112 }
113 if (displayGroupInfo.windowsInfo.empty() || displayGroupInfo.displaysInfo.empty()) {
114 MMI_HILOGE("The windows info or display info is empty!");
115 return;
116 }
117 for (const auto &item : displayGroupInfo.windowsInfo) {
118 if ((item.defaultHotAreas.size() > WindowInfo::MAX_HOTAREA_COUNT) ||
119 (item.pointerHotAreas.size() > WindowInfo::MAX_HOTAREA_COUNT) ||
120 item.defaultHotAreas.empty() || item.pointerHotAreas.empty()) {
121 MMI_HILOGE("Hot areas check failed! defaultHotAreas:size:%{public}zu,"
122 "pointerHotAreas:size:%{public}zu",
123 item.defaultHotAreas.size(), item.pointerHotAreas.size());
124 return;
125 }
126 }
127 displayGroupInfo_ = displayGroupInfo;
128 SendDisplayInfo();
129 PrintDisplayInfo();
130 }
131
132 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
SetEnhanceConfig(uint8_t * cfg,uint32_t cfgLen)133 void InputManagerImpl::SetEnhanceConfig(uint8_t *cfg, uint32_t cfgLen)
134 {
135 CALL_DEBUG_ENTER;
136 if (cfg == nullptr || cfgLen == 0) {
137 MMI_HILOGE("SecCompEnhance cfg info is empty!");
138 return;
139 }
140 enhanceCfg_ = new (std::nothrow) uint8_t[cfgLen];
141 if (memcpy_s(enhanceCfg_, cfgLen, cfg, cfgLen)) {
142 MMI_HILOGE("cfg memcpy failed!");
143 return;
144 }
145 enhanceCfgLen_ = cfgLen;
146 std::lock_guard<std::mutex> guard(mtx_);
147 if (!MMIEventHdl.InitClient()) {
148 MMI_HILOGE("Get mmi client is nullptr");
149 return;
150 }
151 SendEnhanceConfig();
152 PrintEnhanceConfig();
153 }
154 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
155
AddInputEventFilter(std::shared_ptr<IInputEventFilter> filter,int32_t priority,uint32_t deviceTags)156 int32_t InputManagerImpl::AddInputEventFilter(std::shared_ptr<IInputEventFilter> filter, int32_t priority,
157 uint32_t deviceTags)
158 {
159 CALL_INFO_TRACE;
160 std::lock_guard<std::mutex> guard(mtx_);
161 CHKPR(filter, RET_ERR);
162 if (eventFilterServices_.size() >= MAX_FILTER_NUM) {
163 MMI_HILOGE("Too many filters, size:%{public}zu", eventFilterServices_.size());
164 return RET_ERR;
165 }
166 sptr<IEventFilter> service = new (std::nothrow) EventFilterService(filter);
167 CHKPR(service, RET_ERR);
168 const int32_t filterId = EventFilterService::GetNextId();
169 int32_t ret = MultimodalInputConnMgr->AddInputEventFilter(service, filterId, priority, deviceTags);
170 if (ret != RET_OK) {
171 MMI_HILOGE("AddInputEventFilter has send to server failed, priority:%{public}d, ret:%{public}d", priority, ret);
172 service = nullptr;
173 return RET_ERR;
174 }
175 auto it = eventFilterServices_.emplace(filterId, std::make_tuple(service, priority, deviceTags));
176 if (!it.second) {
177 MMI_HILOGW("Filter id duplicate");
178 }
179 return filterId;
180 }
181
RemoveInputEventFilter(int32_t filterId)182 int32_t InputManagerImpl::RemoveInputEventFilter(int32_t filterId)
183 {
184 CALL_INFO_TRACE;
185 std::lock_guard<std::mutex> guard(mtx_);
186 if (eventFilterServices_.empty()) {
187 MMI_HILOGE("Filters is empty, size:%{public}zu", eventFilterServices_.size());
188 return RET_OK;
189 }
190 std::map<int32_t, std::tuple<sptr<IEventFilter>, int32_t, uint32_t>>::iterator it;
191 if (filterId != -1) {
192 it = eventFilterServices_.find(filterId);
193 if (it == eventFilterServices_.end()) {
194 MMI_HILOGE("Filter not found");
195 return RET_OK;
196 }
197 }
198 int32_t ret = MultimodalInputConnMgr->RemoveInputEventFilter(filterId);
199 if (ret != RET_OK) {
200 MMI_HILOGE("Remove filter failed, filter id:%{public}d, ret:%{public}d", filterId, ret);
201 return RET_ERR;
202 }
203 if (filterId != -1) {
204 eventFilterServices_.erase(it);
205 } else {
206 eventFilterServices_.clear();
207 }
208 MMI_HILOGI("Filter remove success");
209 return RET_OK;
210 }
211
GetEventHandler() const212 EventHandlerPtr InputManagerImpl::GetEventHandler() const
213 {
214 if (eventHandler_ == nullptr) {
215 MMI_HILOGD("eventHandler_ is nullptr");
216 auto MMIClient = MMIEventHdl.GetMMIClient();
217 if (MMIClient == nullptr) {
218 MMI_HILOGE("Get MMIClient is failed");
219 return nullptr;
220 }
221 return MMIClient->GetEventHandler();
222 }
223 return eventHandler_;
224 }
225
SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer,std::shared_ptr<AppExecFwk::EventHandler> eventHandler)226 void InputManagerImpl::SetWindowInputEventConsumer(std::shared_ptr<IInputEventConsumer> inputEventConsumer,
227 std::shared_ptr<AppExecFwk::EventHandler> eventHandler)
228 {
229 CALL_DEBUG_ENTER;
230 CHK_PID_AND_TID();
231 CHKPV(inputEventConsumer);
232 CHKPV(eventHandler);
233 std::lock_guard<std::mutex> guard(mtx_);
234 if (!MMIEventHdl.InitClient(eventHandler)) {
235 MMI_HILOGE("Client init failed");
236 return;
237 }
238 consumer_ = inputEventConsumer;
239 eventHandler_ = eventHandler;
240 }
241
SubscribeKeyEvent(std::shared_ptr<KeyOption> keyOption,std::function<void (std::shared_ptr<KeyEvent>)> callback)242 int32_t InputManagerImpl::SubscribeKeyEvent(std::shared_ptr<KeyOption> keyOption,
243 std::function<void(std::shared_ptr<KeyEvent>)> callback)
244 {
245 CALL_DEBUG_ENTER;
246 CHK_PID_AND_TID();
247 std::lock_guard<std::mutex> guard(mtx_);
248 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
249 CHKPR(keyOption, RET_ERR);
250 CHKPR(callback, RET_ERR);
251 return KeyEventInputSubscribeMgr.SubscribeKeyEvent(keyOption, callback);
252 #else
253 MMI_HILOGW("Keyboard device does not support");
254 return ERROR_UNSUPPORT;
255 #endif // OHOS_BUILD_ENABLE_KEYBOARD
256 }
257
UnsubscribeKeyEvent(int32_t subscriberId)258 void InputManagerImpl::UnsubscribeKeyEvent(int32_t subscriberId)
259 {
260 CALL_INFO_TRACE;
261 CHK_PID_AND_TID();
262 std::lock_guard<std::mutex> guard(mtx_);
263 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
264 KeyEventInputSubscribeMgr.UnsubscribeKeyEvent(subscriberId);
265 #else
266 MMI_HILOGW("Keyboard device does not support");
267 #endif // OHOS_BUILD_ENABLE_KEYBOARD
268 }
269
SubscribeSwitchEvent(std::function<void (std::shared_ptr<SwitchEvent>)> callback)270 int32_t InputManagerImpl::SubscribeSwitchEvent(std::function<void(std::shared_ptr<SwitchEvent>)> callback)
271 {
272 CALL_INFO_TRACE;
273 CHK_PID_AND_TID();
274 #ifdef OHOS_BUILD_ENABLE_SWITCH
275 CHKPR(callback, RET_ERR);
276 return SWITCH_EVENT_INPUT_SUBSCRIBE_MGR.SubscribeSwitchEvent(callback);
277 #else
278 MMI_HILOGW("switch device does not support");
279 return ERROR_UNSUPPORT;
280 #endif // OHOS_BUILD_ENABLE_SWITCH
281 }
282
UnsubscribeSwitchEvent(int32_t subscriberId)283 void InputManagerImpl::UnsubscribeSwitchEvent(int32_t subscriberId)
284 {
285 CALL_INFO_TRACE;
286 CHK_PID_AND_TID();
287 #ifdef OHOS_BUILD_ENABLE_SWITCH
288 SWITCH_EVENT_INPUT_SUBSCRIBE_MGR.UnsubscribeSwitchEvent(subscriberId);
289 #else
290 MMI_HILOGW("switch device does not support");
291 #endif // OHOS_BUILD_ENABLE_SWITCH
292 }
293
294 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
OnKeyEventTask(std::shared_ptr<IInputEventConsumer> consumer,std::shared_ptr<KeyEvent> keyEvent)295 void InputManagerImpl::OnKeyEventTask(std::shared_ptr<IInputEventConsumer> consumer,
296 std::shared_ptr<KeyEvent> keyEvent)
297 {
298 CHK_PID_AND_TID();
299 CHKPV(consumer);
300 consumer->OnInputEvent(keyEvent);
301 MMI_HILOGD("Key event callback keyCode:%{public}d", keyEvent->GetKeyCode());
302 }
303
OnKeyEvent(std::shared_ptr<KeyEvent> keyEvent)304 void InputManagerImpl::OnKeyEvent(std::shared_ptr<KeyEvent> keyEvent)
305 {
306 CHK_PID_AND_TID();
307 CHKPV(keyEvent);
308 CHKPV(eventHandler_);
309 CHKPV(consumer_);
310 std::shared_ptr<AppExecFwk::EventHandler> eventHandler = nullptr;
311 std::shared_ptr<IInputEventConsumer> inputConsumer = nullptr;
312 {
313 std::lock_guard<std::mutex> guard(mtx_);
314 eventHandler = eventHandler_;
315 inputConsumer = consumer_;
316 }
317 BytraceAdapter::StartBytrace(keyEvent, BytraceAdapter::TRACE_STOP, BytraceAdapter::KEY_DISPATCH_EVENT);
318 MMIClientPtr client = MMIEventHdl.GetMMIClient();
319 CHKPV(client);
320 if (client->IsEventHandlerChanged()) {
321 if (!eventHandler->PostHighPriorityTask(std::bind(&InputManagerImpl::OnKeyEventTask,
322 this, inputConsumer, keyEvent))) {
323 MMI_HILOGE("Post task failed");
324 return;
325 }
326 } else {
327 inputConsumer->OnInputEvent(keyEvent);
328 MMI_HILOGD("Key event report keyCode:%{public}d", keyEvent->GetKeyCode());
329 }
330 MMI_HILOGD("Key event keyCode:%{public}d", keyEvent->GetKeyCode());
331 }
332 #endif // OHOS_BUILD_ENABLE_KEYBOARD
333
334 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
OnPointerEventTask(std::shared_ptr<IInputEventConsumer> consumer,std::shared_ptr<PointerEvent> pointerEvent)335 void InputManagerImpl::OnPointerEventTask(std::shared_ptr<IInputEventConsumer> consumer,
336 std::shared_ptr<PointerEvent> pointerEvent)
337 {
338 CHK_PID_AND_TID();
339 CHKPV(consumer);
340 CHKPV(pointerEvent);
341 consumer->OnInputEvent(pointerEvent);
342 MMI_HILOGD("Pointer event callback pointerId:%{public}d", pointerEvent->GetPointerId());
343 }
344
OnPointerEvent(std::shared_ptr<PointerEvent> pointerEvent)345 void InputManagerImpl::OnPointerEvent(std::shared_ptr<PointerEvent> pointerEvent)
346 {
347 CALL_DEBUG_ENTER;
348 CHK_PID_AND_TID();
349 CHKPV(pointerEvent);
350 CHKPV(eventHandler_);
351 CHKPV(consumer_);
352 std::shared_ptr<AppExecFwk::EventHandler> eventHandler = nullptr;
353 std::shared_ptr<IInputEventConsumer> inputConsumer = nullptr;
354 {
355 std::lock_guard<std::mutex> guard(mtx_);
356 eventHandler = eventHandler_;
357 inputConsumer = consumer_;
358 }
359 BytraceAdapter::StartBytrace(pointerEvent, BytraceAdapter::TRACE_STOP, BytraceAdapter::POINT_DISPATCH_EVENT);
360 MMIClientPtr client = MMIEventHdl.GetMMIClient();
361 CHKPV(client);
362 if (client->IsEventHandlerChanged()) {
363 if (!eventHandler->PostHighPriorityTask(std::bind(&InputManagerImpl::OnPointerEventTask,
364 this, inputConsumer, pointerEvent))) {
365 MMI_HILOGE("Post task failed");
366 return;
367 }
368 } else {
369 inputConsumer->OnInputEvent(pointerEvent);
370 MMI_HILOGD("Pointer event report pointerId:%{public}d", pointerEvent->GetPointerId());
371 }
372 MMI_HILOGD("Pointer event pointerId:%{public}d", pointerEvent->GetPointerId());
373 }
374 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
375
PackDisplayData(NetPacket & pkt)376 int32_t InputManagerImpl::PackDisplayData(NetPacket &pkt)
377 {
378 pkt << displayGroupInfo_.width << displayGroupInfo_.height << displayGroupInfo_.focusWindowId;
379 if (pkt.ChkRWError()) {
380 MMI_HILOGE("Packet write logical data failed");
381 return RET_ERR;
382 }
383 if (PackWindowInfo(pkt) == RET_ERR) {
384 MMI_HILOGE("Packet write windows info failed");
385 return RET_ERR;
386 }
387 return PackDisplayInfo(pkt);
388 }
389
390 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
PackEnhanceConfig(NetPacket & pkt)391 int32_t InputManagerImpl::PackEnhanceConfig(NetPacket &pkt)
392 {
393 if (enhanceCfg_ == nullptr) {
394 MMI_HILOGE("security info config failed");
395 return RET_ERR;
396 }
397 pkt << enhanceCfgLen_;
398 for (uint32_t i = 0; i < enhanceCfgLen_; i++) {
399 pkt << enhanceCfg_[i];
400 }
401 if (pkt.ChkRWError()) {
402 MMI_HILOGE("Packet write security info config failed");
403 return RET_ERR;
404 }
405 return RET_OK;
406 }
407 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
408
PackWindowInfo(NetPacket & pkt)409 int32_t InputManagerImpl::PackWindowInfo(NetPacket &pkt)
410 {
411 uint32_t num = static_cast<uint32_t>(displayGroupInfo_.windowsInfo.size());
412 pkt << num;
413 for (const auto &item : displayGroupInfo_.windowsInfo) {
414 pkt << item.id << item.pid << item.uid << item.area
415 << item.defaultHotAreas << item.pointerHotAreas
416 << item.agentWindowId << item.flags;
417 }
418 if (pkt.ChkRWError()) {
419 MMI_HILOGE("Packet write windows data failed");
420 return RET_ERR;
421 }
422 return RET_OK;
423 }
424
PackDisplayInfo(NetPacket & pkt)425 int32_t InputManagerImpl::PackDisplayInfo(NetPacket &pkt)
426 {
427 uint32_t num = static_cast<uint32_t>(displayGroupInfo_.displaysInfo.size());
428 pkt << num;
429 for (const auto &item : displayGroupInfo_.displaysInfo) {
430 pkt << item.id << item.x << item.y << item.width
431 << item.height << item.dpi << item.name << item.uniq << item.direction;
432 }
433 if (pkt.ChkRWError()) {
434 MMI_HILOGE("Packet write display data failed");
435 return RET_ERR;
436 }
437 return RET_OK;
438 }
439
PrintDisplayInfo()440 void InputManagerImpl::PrintDisplayInfo()
441 {
442 MMI_HILOGD("logicalInfo,width:%{public}d,height:%{public}d,focusWindowId:%{public}d",
443 displayGroupInfo_.width, displayGroupInfo_.height, displayGroupInfo_.focusWindowId);
444 MMI_HILOGD("windowsInfos,num:%{public}zu", displayGroupInfo_.windowsInfo.size());
445 for (const auto &item : displayGroupInfo_.windowsInfo) {
446 MMI_HILOGD("windowsInfos,id:%{public}d,pid:%{public}d,uid:%{public}d,"
447 "area.x:%{public}d,area.y:%{public}d,area.width:%{public}d,area.height:%{public}d,"
448 "defaultHotAreas.size:%{public}zu,pointerHotAreas.size:%{public}zu,"
449 "agentWindowId:%{public}d,flags:%{public}d",
450 item.id, item.pid, item.uid, item.area.x, item.area.y, item.area.width,
451 item.area.height, item.defaultHotAreas.size(), item.pointerHotAreas.size(),
452 item.agentWindowId, item.flags);
453 for (const auto &win : item.defaultHotAreas) {
454 MMI_HILOGD("defaultHotAreas:x:%{public}d,y:%{public}d,width:%{public}d,height:%{public}d",
455 win.x, win.y, win.width, win.height);
456 }
457 for (const auto &pointer : item.pointerHotAreas) {
458 MMI_HILOGD("pointerHotAreas:x:%{public}d,y:%{public}d,width:%{public}d,height:%{public}d",
459 pointer.x, pointer.y, pointer.width, pointer.height);
460 }
461 }
462
463 MMI_HILOGD("displayInfos,num:%{public}zu", displayGroupInfo_.displaysInfo.size());
464 for (const auto &item : displayGroupInfo_.displaysInfo) {
465 MMI_HILOGD("displayInfos,id:%{public}d,x:%{public}d,y:%{public}d,"
466 "width:%{public}d,height:%{public}d,dpi:%{public}d,name:%{public}s,"
467 "uniq:%{public}s,direction:%{public}d",
468 item.id, item.x, item.y, item.width, item.height, item.dpi, item.name.c_str(),
469 item.uniq.c_str(), item.direction);
470 }
471 }
472
473 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
PrintEnhanceConfig()474 void InputManagerImpl::PrintEnhanceConfig()
475 {
476 if (enhanceCfg_ == nullptr) {
477 MMI_HILOGE("SecCompEnhanceCfg is null");
478 return;
479 }
480 MMI_HILOGD("securityConfigInfo, cfg len:%{public}d", enhanceCfgLen_);
481 }
482 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
483
AddMonitor(std::function<void (std::shared_ptr<KeyEvent>)> monitor)484 int32_t InputManagerImpl::AddMonitor(std::function<void(std::shared_ptr<KeyEvent>)> monitor)
485 {
486 CALL_INFO_TRACE;
487 #if defined(OHOS_BUILD_ENABLE_KEYBOARD) && defined(OHOS_BUILD_ENABLE_MONITOR)
488 CHKPR(monitor, INVALID_HANDLER_ID);
489 auto consumer = std::make_shared<MonitorEventConsumer>(monitor);
490 return AddMonitor(consumer);
491 #else
492 MMI_HILOGW("Keyboard device or monitor function does not support");
493 return ERROR_UNSUPPORT;
494 #endif // OHOS_BUILD_ENABLE_KEYBOARD || OHOS_BUILD_ENABLE_MONITOR
495 }
496
AddMonitor(std::function<void (std::shared_ptr<PointerEvent>)> monitor)497 int32_t InputManagerImpl::AddMonitor(std::function<void(std::shared_ptr<PointerEvent>)> monitor)
498 {
499 CALL_INFO_TRACE;
500 #if (defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)) && defined(OHOS_BUILD_ENABLE_MONITOR)
501 CHKPR(monitor, INVALID_HANDLER_ID);
502 auto consumer = std::make_shared<MonitorEventConsumer>(monitor);
503 return AddMonitor(consumer);
504 #else
505 MMI_HILOGW("Pointer/touchscreen device or monitor function does not support");
506 return ERROR_UNSUPPORT;
507 #endif // OHOS_BUILD_ENABLE_MONITOR || OHOS_BUILD_ENABLE_TOUCH && OHOS_BUILD_ENABLE_MONITOR
508 }
509
AddMonitor(std::shared_ptr<IInputEventConsumer> consumer)510 int32_t InputManagerImpl::AddMonitor(std::shared_ptr<IInputEventConsumer> consumer)
511 {
512 CALL_INFO_TRACE;
513 #ifdef OHOS_BUILD_ENABLE_MONITOR
514 CHKPR(consumer, INVALID_HANDLER_ID);
515 std::lock_guard<std::mutex> guard(mtx_);
516 if (!MMIEventHdl.InitClient()) {
517 MMI_HILOGE("Client init failed");
518 return RET_ERR;
519 }
520 return IMonitorMgr->AddMonitor(consumer);
521 #else
522 MMI_HILOGI("Monitor function does not support");
523 return ERROR_UNSUPPORT;
524 #endif // OHOS_BUILD_ENABLE_MONITOR
525 }
526
RemoveMonitor(int32_t monitorId)527 void InputManagerImpl::RemoveMonitor(int32_t monitorId)
528 {
529 CALL_INFO_TRACE;
530 #ifdef OHOS_BUILD_ENABLE_MONITOR
531 std::lock_guard<std::mutex> guard(mtx_);
532 if (!MMIEventHdl.InitClient()) {
533 MMI_HILOGE("Client init failed");
534 return;
535 }
536 IMonitorMgr->RemoveMonitor(monitorId);
537 #else
538 MMI_HILOGI("Monitor function does not support");
539 #endif // OHOS_BUILD_ENABLE_MONITOR
540 }
541
MarkConsumed(int32_t monitorId,int32_t eventId)542 void InputManagerImpl::MarkConsumed(int32_t monitorId, int32_t eventId)
543 {
544 CALL_DEBUG_ENTER;
545 #ifdef OHOS_BUILD_ENABLE_MONITOR
546 std::lock_guard<std::mutex> guard(mtx_);
547 if (!MMIEventHdl.InitClient()) {
548 MMI_HILOGE("Client init failed");
549 return;
550 }
551 IMonitorMgr->MarkConsumed(monitorId, eventId);
552 #else
553 MMI_HILOGI("Monitor function does not support");
554 #endif // OHOS_BUILD_ENABLE_MONITOR
555 }
556
MoveMouse(int32_t offsetX,int32_t offsetY)557 void InputManagerImpl::MoveMouse(int32_t offsetX, int32_t offsetY)
558 {
559 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING)
560 std::lock_guard<std::mutex> guard(mtx_);
561 if (MMIEventHdl.MoveMouseEvent(offsetX, offsetY) != RET_OK) {
562 MMI_HILOGE("Failed to inject move mouse offset event");
563 }
564 #else
565 MMI_HILOGW("Pointer device or pointer drawing module does not support");
566 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING
567 }
568
AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptor,int32_t priority,uint32_t deviceTags)569 int32_t InputManagerImpl::AddInterceptor(std::shared_ptr<IInputEventConsumer> interceptor,
570 int32_t priority, uint32_t deviceTags)
571 {
572 CALL_INFO_TRACE;
573 #ifdef OHOS_BUILD_ENABLE_INTERCEPTOR
574 CHKPR(interceptor, INVALID_HANDLER_ID);
575 std::lock_guard<std::mutex> guard(mtx_);
576 if (!MMIEventHdl.InitClient()) {
577 MMI_HILOGE("Client init failed");
578 return RET_ERR;
579 }
580 return InputInterMgr->AddInterceptor(interceptor, HANDLE_EVENT_TYPE_ALL, priority, deviceTags);
581 #else
582 MMI_HILOGW("Interceptor function does not support");
583 return ERROR_UNSUPPORT;
584 #endif // OHOS_BUILD_ENABLE_INTERCEPTOR
585 }
586
AddInterceptor(std::function<void (std::shared_ptr<KeyEvent>)> interceptor,int32_t priority,uint32_t deviceTags)587 int32_t InputManagerImpl::AddInterceptor(std::function<void(std::shared_ptr<KeyEvent>)> interceptor,
588 int32_t priority, uint32_t deviceTags)
589 {
590 CALL_INFO_TRACE;
591 #if defined(OHOS_BUILD_ENABLE_KEYBOARD) && defined(OHOS_BUILD_ENABLE_INTERCEPTOR)
592 CHKPR(interceptor, INVALID_HANDLER_ID);
593 std::lock_guard<std::mutex> guard(mtx_);
594 auto consumer = std::make_shared<MonitorEventConsumer>(interceptor);
595 if (!MMIEventHdl.InitClient()) {
596 MMI_HILOGE("Client init failed");
597 return RET_ERR;
598 }
599 return InputInterMgr->AddInterceptor(consumer, HANDLE_EVENT_TYPE_KEY, priority, deviceTags);
600 #else
601 MMI_HILOGW("Keyboard device or interceptor function does not support");
602 return ERROR_UNSUPPORT;
603 #endif // OHOS_BUILD_ENABLE_KEYBOARD && OHOS_BUILD_ENABLE_INTERCEPTOR
604 }
605
RemoveInterceptor(int32_t interceptorId)606 void InputManagerImpl::RemoveInterceptor(int32_t interceptorId)
607 {
608 CALL_INFO_TRACE;
609 #ifdef OHOS_BUILD_ENABLE_INTERCEPTOR
610 std::lock_guard<std::mutex> guard(mtx_);
611 if (!MMIEventHdl.InitClient()) {
612 MMI_HILOGE("Client init failed");
613 return;
614 }
615 InputInterMgr->RemoveInterceptor(interceptorId);
616 #else
617 MMI_HILOGW("Interceptor function does not support");
618 #endif // OHOS_BUILD_ENABLE_INTERCEPTOR
619 }
620
SimulateInputEvent(std::shared_ptr<KeyEvent> keyEvent)621 void InputManagerImpl::SimulateInputEvent(std::shared_ptr<KeyEvent> keyEvent)
622 {
623 CALL_DEBUG_ENTER;
624 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
625 CHKPV(keyEvent);
626 std::lock_guard<std::mutex> guard(mtx_);
627 if (MMIEventHdl.InjectEvent(keyEvent) != RET_OK) {
628 MMI_HILOGE("Failed to inject keyEvent");
629 }
630 #else
631 MMI_HILOGW("Keyboard device does not support");
632 #endif // OHOS_BUILD_ENABLE_KEYBOARD
633 }
634
SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent)635 void InputManagerImpl::SimulateInputEvent(std::shared_ptr<PointerEvent> pointerEvent)
636 {
637 CALL_DEBUG_ENTER;
638 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
639 CHKPV(pointerEvent);
640 if (pointerEvent->GetSourceType() == PointerEvent::SOURCE_TYPE_MOUSE ||
641 pointerEvent->GetSourceType() == PointerEvent::SOURCE_TYPE_TOUCHPAD) {
642 #ifndef OHOS_BUILD_ENABLE_POINTER
643 MMI_HILOGW("Pointer device does not support");
644 return;
645 #endif
646 }
647 if (pointerEvent->GetSourceType() == PointerEvent::SOURCE_TYPE_TOUCHSCREEN) {
648 #ifndef OHOS_BUILD_ENABLE_TOUCH
649 MMI_HILOGW("Touchscreen device does not support");
650 return;
651 #endif
652 }
653 #ifndef OHOS_BUILD_ENABLE_JOYSTICK
654 if (pointerEvent->GetSourceType() == PointerEvent::SOURCE_TYPE_JOYSTICK) {
655 MMI_HILOGW("Joystick device does not support");
656 return;
657 }
658 #endif
659 std::lock_guard<std::mutex> guard(mtx_);
660 if (MMIEventHdl.InjectPointerEvent(pointerEvent) != RET_OK) {
661 MMI_HILOGE("Failed to inject pointer event");
662 }
663 #else
664 MMI_HILOGW("Pointer and touchscreen device does not support");
665 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
666 }
667
SetMouseScrollRows(int32_t rows)668 int32_t InputManagerImpl::SetMouseScrollRows(int32_t rows)
669 {
670 CALL_DEBUG_ENTER;
671 #if defined OHOS_BUILD_ENABLE_POINTER
672 std::lock_guard<std::mutex> guard(mtx_);
673 int32_t ret = MultimodalInputConnMgr->SetMouseScrollRows(rows);
674 if (ret != RET_OK) {
675 MMI_HILOGE("Set the number of mouse scrolling rows failed, ret:%{public}d", ret);
676 }
677 return ret;
678 #else
679 MMI_HILOGW("Pointer device module does not support");
680 return ERROR_UNSUPPORT;
681 #endif // OHOS_BUILD_ENABLE_POINTER
682 }
683
SetMouseIcon(int32_t windowId,void * pixelMap)684 int32_t InputManagerImpl::SetMouseIcon(int32_t windowId, void* pixelMap)
685 {
686 CALL_DEBUG_ENTER;
687 #if defined OHOS_BUILD_ENABLE_POINTER
688 int32_t ret = MultimodalInputConnMgr->SetMouseIcon(windowId, pixelMap);
689 if (ret != RET_OK) {
690 MMI_HILOGE("Set the number of mouse scrolling rows failed, ret:%{public}d", ret);
691 }
692 return ret;
693 #else
694 MMI_HILOGW("Pointer device module does not support");
695 return ERROR_UNSUPPORT;
696 #endif // OHOS_BUILD_ENABLE_POINTER
697 }
698
SetMouseHotSpot(int32_t windowId,int32_t hotSpotX,int32_t hotSpotY)699 int32_t InputManagerImpl::SetMouseHotSpot(int32_t windowId, int32_t hotSpotX, int32_t hotSpotY)
700 {
701 CALL_DEBUG_ENTER;
702 #if defined OHOS_BUILD_ENABLE_POINTER
703 int32_t ret = MultimodalInputConnMgr->SetMouseHotSpot(windowId, hotSpotX, hotSpotY);
704 if (ret != RET_OK) {
705 MMI_HILOGE("Set mouse hot spot failed, ret:%{public}d", ret);
706 }
707 return ret;
708 #else
709 MMI_HILOGW("Pointer device module does not support");
710 return ERROR_UNSUPPORT;
711 #endif // OHOS_BUILD_ENABLE_POINTER
712 }
713
GetMouseScrollRows(int32_t & rows)714 int32_t InputManagerImpl::GetMouseScrollRows(int32_t &rows)
715 {
716 CALL_DEBUG_ENTER;
717 #ifdef OHOS_BUILD_ENABLE_POINTER
718 std::lock_guard<std::mutex> guard(mtx_);
719 int32_t ret = MultimodalInputConnMgr->GetMouseScrollRows(rows);
720 if (ret != RET_OK) {
721 MMI_HILOGE("Get the number of mouse scrolling rows failed");
722 }
723 return ret;
724 #else
725 MMI_HILOGW("Pointer device does not support");
726 return ERROR_UNSUPPORT;
727 #endif // OHOS_BUILD_ENABLE_POINTER
728 }
729
SetPointerSize(int32_t size)730 int32_t InputManagerImpl::SetPointerSize(int32_t size)
731 {
732 CALL_DEBUG_ENTER;
733 #if defined OHOS_BUILD_ENABLE_POINTER
734 std::lock_guard<std::mutex> guard(mtx_);
735 int32_t ret = MultimodalInputConnMgr->SetPointerSize(size);
736 if (ret != RET_OK) {
737 MMI_HILOGE("Set pointer size failed, ret:%{public}d", ret);
738 }
739 return ret;
740 #else
741 MMI_HILOGW("Pointer device module does not support");
742 return ERROR_UNSUPPORT;
743 #endif // OHOS_BUILD_ENABLE_POINTER
744 }
745
GetPointerSize(int32_t & size)746 int32_t InputManagerImpl::GetPointerSize(int32_t &size)
747 {
748 CALL_DEBUG_ENTER;
749 #ifdef OHOS_BUILD_ENABLE_POINTER
750 std::lock_guard<std::mutex> guard(mtx_);
751 int32_t ret = MultimodalInputConnMgr->GetPointerSize(size);
752 if (ret != RET_OK) {
753 MMI_HILOGE("Get pointer size failed");
754 }
755 return ret;
756 #else
757 MMI_HILOGW("Pointer device does not support");
758 return ERROR_UNSUPPORT;
759 #endif // OHOS_BUILD_ENABLE_POINTER
760 }
761
SetMousePrimaryButton(int32_t primaryButton)762 int32_t InputManagerImpl::SetMousePrimaryButton(int32_t primaryButton)
763 {
764 CALL_DEBUG_ENTER;
765 #if defined OHOS_BUILD_ENABLE_POINTER
766 std::lock_guard<std::mutex> guard(mtx_);
767 if (primaryButton != LEFT_BUTTON && primaryButton != RIGHT_BUTTON) {
768 MMI_HILOGE("primaryButton is invalid");
769 return RET_ERR;
770 }
771 int32_t ret = MultimodalInputConnMgr->SetMousePrimaryButton(primaryButton);
772 if (ret != RET_OK) {
773 MMI_HILOGE("Set mouse primary button failed, ret:%{public}d", ret);
774 }
775 return ret;
776 #else
777 MMI_HILOGW("Pointer device module does not support");
778 return ERROR_UNSUPPORT;
779 #endif // OHOS_BUILD_ENABLE_POINTER
780 }
781
GetMousePrimaryButton(int32_t & primaryButton)782 int32_t InputManagerImpl::GetMousePrimaryButton(int32_t &primaryButton)
783 {
784 CALL_DEBUG_ENTER;
785 #ifdef OHOS_BUILD_ENABLE_POINTER
786 std::lock_guard<std::mutex> guard(mtx_);
787 int32_t ret = MultimodalInputConnMgr->GetMousePrimaryButton(primaryButton);
788 if (ret != RET_OK) {
789 MMI_HILOGE("Get mouse primary button failed");
790 }
791 return ret;
792 #else
793 MMI_HILOGW("Pointer device does not support");
794 return ERROR_UNSUPPORT;
795 #endif // OHOS_BUILD_ENABLE_POINTER
796 }
797
SetHoverScrollState(bool state)798 int32_t InputManagerImpl::SetHoverScrollState(bool state)
799 {
800 CALL_DEBUG_ENTER;
801 #if defined OHOS_BUILD_ENABLE_POINTER
802 std::lock_guard<std::mutex> guard(mtx_);
803 int32_t ret = MultimodalInputConnMgr->SetHoverScrollState(state);
804 if (ret != RET_OK) {
805 MMI_HILOGE("Set mouse hover scroll state failed, ret:%{public}d", ret);
806 }
807 return ret;
808 #else
809 MMI_HILOGW("Pointer device module does not support");
810 return ERROR_UNSUPPORT;
811 #endif // OHOS_BUILD_ENABLE_POINTER
812 }
813
GetHoverScrollState(bool & state)814 int32_t InputManagerImpl::GetHoverScrollState(bool &state)
815 {
816 CALL_DEBUG_ENTER;
817 #ifdef OHOS_BUILD_ENABLE_POINTER
818 std::lock_guard<std::mutex> guard(mtx_);
819 int32_t ret = MultimodalInputConnMgr->GetHoverScrollState(state);
820 if (ret != RET_OK) {
821 MMI_HILOGE("Get mouse hover scroll state failed, ret:%{public}d", ret);
822 }
823 return ret;
824 #else
825 MMI_HILOGW("Pointer device does not support");
826 return ERROR_UNSUPPORT;
827 #endif // OHOS_BUILD_ENABLE_POINTER
828 }
829
SetPointerVisible(bool visible)830 int32_t InputManagerImpl::SetPointerVisible(bool visible)
831 {
832 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING)
833 CALL_DEBUG_ENTER;
834 std::lock_guard<std::mutex> guard(mtx_);
835 int32_t ret = MultimodalInputConnMgr->SetPointerVisible(visible);
836 if (ret != RET_OK) {
837 MMI_HILOGE("Set pointer visible failed, ret:%{public}d", ret);
838 }
839 return ret;
840 #else
841 MMI_HILOGW("Pointer device or pointer drawing module does not support");
842 return ERROR_UNSUPPORT;
843 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING
844 }
845
IsPointerVisible()846 bool InputManagerImpl::IsPointerVisible()
847 {
848 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING)
849 CALL_DEBUG_ENTER;
850 std::lock_guard<std::mutex> guard(mtx_);
851 bool visible;
852 int32_t ret = MultimodalInputConnMgr->IsPointerVisible(visible);
853 if (ret != 0) {
854 MMI_HILOGE("Get pointer visible failed, ret:%{public}d", ret);
855 }
856 return visible;
857 #else
858 MMI_HILOGW("Pointer device or pointer drawing module does not support");
859 return false;
860 #endif // OHOS_BUILD_ENABLE_POINTER_DRAWING
861 }
862
SetPointerColor(int32_t color)863 int32_t InputManagerImpl::SetPointerColor(int32_t color)
864 {
865 CALL_DEBUG_ENTER;
866 #if defined OHOS_BUILD_ENABLE_POINTER
867 std::lock_guard<std::mutex> guard(mtx_);
868 int32_t ret = MultimodalInputConnMgr->SetPointerColor(color);
869 if (ret != RET_OK) {
870 MMI_HILOGE("Set pointer color failed, ret:%{public}d", ret);
871 }
872 return ret;
873 #else
874 MMI_HILOGW("Pointer device module does not support");
875 return ERROR_UNSUPPORT;
876 #endif // OHOS_BUILD_ENABLE_POINTER
877 }
878
GetPointerColor(int32_t & color)879 int32_t InputManagerImpl::GetPointerColor(int32_t &color)
880 {
881 CALL_DEBUG_ENTER;
882 #ifdef OHOS_BUILD_ENABLE_POINTER
883 std::lock_guard<std::mutex> guard(mtx_);
884 int32_t ret = MultimodalInputConnMgr->GetPointerColor(color);
885 if (ret != RET_OK) {
886 MMI_HILOGE("Get pointer color failed");
887 }
888 return ret;
889 #else
890 MMI_HILOGW("Pointer device does not support");
891 return ERROR_UNSUPPORT;
892 #endif // OHOS_BUILD_ENABLE_POINTER
893 }
894
SetPointerSpeed(int32_t speed)895 int32_t InputManagerImpl::SetPointerSpeed(int32_t speed)
896 {
897 CALL_DEBUG_ENTER;
898 #ifdef OHOS_BUILD_ENABLE_POINTER
899 int32_t ret = MultimodalInputConnMgr->SetPointerSpeed(speed);
900 if (ret != RET_OK) {
901 MMI_HILOGE("Failed to set pointer speed");
902 return RET_ERR;
903 }
904 return RET_OK;
905 #else
906 MMI_HILOGW("Pointer device does not support");
907 return ERROR_UNSUPPORT;
908 #endif // OHOS_BUILD_ENABLE_POINTER
909 }
910
GetPointerSpeed(int32_t & speed)911 int32_t InputManagerImpl::GetPointerSpeed(int32_t &speed)
912 {
913 CALL_DEBUG_ENTER;
914 #ifdef OHOS_BUILD_ENABLE_POINTER
915 int32_t ret = MultimodalInputConnMgr->GetPointerSpeed(speed);
916 if (ret != RET_OK) {
917 MMI_HILOGE("Get pointer speed failed");
918 return RET_ERR;
919 }
920 return RET_OK;
921 #else
922 return ERROR_UNSUPPORT;
923 MMI_HILOGW("Pointer device does not support");
924 #endif // OHOS_BUILD_ENABLE_POINTER
925 }
926
SetPointerStyle(int32_t windowId,const PointerStyle & pointerStyle)927 int32_t InputManagerImpl::SetPointerStyle(int32_t windowId, const PointerStyle& pointerStyle)
928 {
929 CALL_DEBUG_ENTER;
930 if (pointerStyle.id < 0) {
931 MMI_HILOGE("The param is invalid");
932 return RET_ERR;
933 }
934 int32_t ret = MultimodalInputConnMgr->SetPointerStyle(windowId, pointerStyle);
935 if (ret != RET_OK) {
936 MMI_HILOGE("Set pointer style failed, ret:%{public}d", ret);
937 return ret;
938 }
939 return RET_OK;
940 }
941
GetPointerStyle(int32_t windowId,PointerStyle & pointerStyle)942 int32_t InputManagerImpl::GetPointerStyle(int32_t windowId, PointerStyle &pointerStyle)
943 {
944 CALL_DEBUG_ENTER;
945 int32_t ret = MultimodalInputConnMgr->GetPointerStyle(windowId, pointerStyle);
946 if (ret != RET_OK) {
947 MMI_HILOGE("Get pointer style failed, ret:%{public}d", ret);
948 return ret;
949 }
950 return RET_OK;
951 }
952
OnConnected()953 void InputManagerImpl::OnConnected()
954 {
955 CALL_DEBUG_ENTER;
956 ReAddInputEventFilter();
957 if (displayGroupInfo_.windowsInfo.empty() || displayGroupInfo_.displaysInfo.empty()) {
958 MMI_HILOGD("The windows info or display info is empty");
959 return;
960 }
961 SendDisplayInfo();
962 PrintDisplayInfo();
963 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
964 SendEnhanceConfig();
965 PrintEnhanceConfig();
966 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
967 if (anrObservers_.empty()) {
968 return;
969 }
970 int32_t ret = MultimodalInputConnMgr->SetAnrObserver();
971 if (ret != RET_OK) {
972 MMI_HILOGE("Set anr observer failed, ret:%{public}d", ret);
973 }
974 }
975
SendDisplayInfo()976 void InputManagerImpl::SendDisplayInfo()
977 {
978 MMIClientPtr client = MMIEventHdl.GetMMIClient();
979 CHKPV(client);
980 NetPacket pkt(MmiMessageId::DISPLAY_INFO);
981 if (PackDisplayData(pkt) == RET_ERR) {
982 MMI_HILOGE("Pack display info failed");
983 return;
984 }
985 if (!client->SendMessage(pkt)) {
986 MMI_HILOGE("Send message failed, errCode:%{public}d", MSG_SEND_FAIL);
987 }
988 }
989
990 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
SendEnhanceConfig()991 void InputManagerImpl::SendEnhanceConfig()
992 {
993 MMIClientPtr client = MMIEventHdl.GetMMIClient();
994 CHKPV(client);
995 NetPacket pkt(MmiMessageId::SCINFO_CONFIG);
996 if (PackEnhanceConfig(pkt) == RET_ERR) {
997 return;
998 }
999 if (!client->SendMessage(pkt)) {
1000 MMI_HILOGE("Send message failed, errCode:%{public}d", MSG_SEND_FAIL);
1001 }
1002 }
1003 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
1004
ReAddInputEventFilter()1005 void InputManagerImpl::ReAddInputEventFilter()
1006 {
1007 CALL_DEBUG_ENTER;
1008 if (eventFilterServices_.size() > MAX_FILTER_NUM) {
1009 MMI_HILOGE("Too many filters, size:%{public}zu", eventFilterServices_.size());
1010 return;
1011 }
1012 for (const auto &[filterId, t] : eventFilterServices_) {
1013 const auto &[service, priority, deviceTags] = t;
1014 int32_t ret = MultimodalInputConnMgr->AddInputEventFilter(service, filterId, priority, deviceTags);
1015 if (ret != RET_OK) {
1016 MMI_HILOGE("AddInputEventFilter has send to server failed, filterId:%{public}d, priority:%{public}d,"
1017 "deviceTags:%{public}u, ret:%{public}d", filterId, priority, deviceTags, ret);
1018 }
1019 }
1020 }
1021
RegisterDevListener(std::string type,std::shared_ptr<IInputDeviceListener> listener)1022 int32_t InputManagerImpl::RegisterDevListener(std::string type, std::shared_ptr<IInputDeviceListener> listener)
1023 {
1024 std::lock_guard<std::mutex> guard(mtx_);
1025 if (!MMIEventHdl.InitClient()) {
1026 MMI_HILOGE("Client init failed");
1027 return RET_ERR;
1028 }
1029 return InputDevImpl.RegisterDevListener(type, listener);
1030 }
1031
UnregisterDevListener(std::string type,std::shared_ptr<IInputDeviceListener> listener)1032 int32_t InputManagerImpl::UnregisterDevListener(std::string type,
1033 std::shared_ptr<IInputDeviceListener> listener)
1034 {
1035 std::lock_guard<std::mutex> guard(mtx_);
1036 if (!MMIEventHdl.InitClient()) {
1037 MMI_HILOGE("Client init failed");
1038 return RET_ERR;
1039 }
1040 return InputDevImpl.UnregisterDevListener(type, listener);
1041 }
1042
GetDeviceIds(std::function<void (std::vector<int32_t> &)> callback)1043 int32_t InputManagerImpl::GetDeviceIds(std::function<void(std::vector<int32_t>&)> callback)
1044 {
1045 std::lock_guard<std::mutex> guard(mtx_);
1046 if (!MMIEventHdl.InitClient()) {
1047 MMI_HILOGE("Client init failed");
1048 return RET_ERR;
1049 }
1050 return InputDevImpl.GetInputDeviceIds(callback);
1051 }
1052
GetDevice(int32_t deviceId,std::function<void (std::shared_ptr<InputDevice>)> callback)1053 int32_t InputManagerImpl::GetDevice(int32_t deviceId,
1054 std::function<void(std::shared_ptr<InputDevice>)> callback)
1055 {
1056 std::lock_guard<std::mutex> guard(mtx_);
1057 if (!MMIEventHdl.InitClient()) {
1058 MMI_HILOGE("Client init failed");
1059 return RET_ERR;
1060 }
1061 return InputDevImpl.GetInputDevice(deviceId, callback);
1062 }
1063
SupportKeys(int32_t deviceId,std::vector<int32_t> & keyCodes,std::function<void (std::vector<bool> &)> callback)1064 int32_t InputManagerImpl::SupportKeys(int32_t deviceId, std::vector<int32_t> &keyCodes,
1065 std::function<void(std::vector<bool>&)> callback)
1066 {
1067 CALL_DEBUG_ENTER;
1068 std::lock_guard<std::mutex> guard(mtx_);
1069 if (!MMIEventHdl.InitClient()) {
1070 MMI_HILOGE("Client init failed");
1071 return RET_ERR;
1072 }
1073 return InputDevImpl.SupportKeys(deviceId, keyCodes, callback);
1074 }
1075
GetKeyboardType(int32_t deviceId,std::function<void (int32_t)> callback)1076 int32_t InputManagerImpl::GetKeyboardType(int32_t deviceId, std::function<void(int32_t)> callback)
1077 {
1078 CALL_DEBUG_ENTER;
1079 std::lock_guard<std::mutex> guard(mtx_);
1080 if (!MMIEventHdl.InitClient()) {
1081 MMI_HILOGE("Client init failed");
1082 return RET_ERR;
1083 }
1084 return InputDevImpl.GetKeyboardType(deviceId, callback);
1085 }
1086
SetKeyboardRepeatDelay(int32_t delay)1087 int32_t InputManagerImpl::SetKeyboardRepeatDelay(int32_t delay)
1088 {
1089 CALL_DEBUG_ENTER;
1090 std::lock_guard<std::mutex> guard(mtx_);
1091 if (!MMIEventHdl.InitClient()) {
1092 MMI_HILOGE("Client init failed");
1093 return RET_ERR;
1094 }
1095 return InputDevImpl.SetKeyboardRepeatDelay(delay);
1096 }
1097
SetKeyboardRepeatRate(int32_t rate)1098 int32_t InputManagerImpl::SetKeyboardRepeatRate(int32_t rate)
1099 {
1100 CALL_DEBUG_ENTER;
1101 std::lock_guard<std::mutex> guard(mtx_);
1102 if (!MMIEventHdl.InitClient()) {
1103 MMI_HILOGE("Client init failed");
1104 return RET_ERR;
1105 }
1106 return InputDevImpl.SetKeyboardRepeatRate(rate);
1107 }
1108
GetKeyboardRepeatDelay(std::function<void (int32_t)> callback)1109 int32_t InputManagerImpl::GetKeyboardRepeatDelay(std::function<void(int32_t)> callback)
1110 {
1111 CALL_DEBUG_ENTER;
1112 std::lock_guard<std::mutex> guard(mtx_);
1113 if (!MMIEventHdl.InitClient()) {
1114 MMI_HILOGE("Client init failed");
1115 return RET_ERR;
1116 }
1117 return InputDevImpl.GetKeyboardRepeatDelay(callback);
1118 }
1119
GetKeyboardRepeatRate(std::function<void (int32_t)> callback)1120 int32_t InputManagerImpl::GetKeyboardRepeatRate(std::function<void(int32_t)> callback)
1121 {
1122 CALL_DEBUG_ENTER;
1123 std::lock_guard<std::mutex> guard(mtx_);
1124 if (!MMIEventHdl.InitClient()) {
1125 MMI_HILOGE("Client init failed");
1126 return RET_ERR;
1127 }
1128 return InputDevImpl.GetKeyboardRepeatRate(callback);
1129 }
1130
SetAnrObserver(std::shared_ptr<IAnrObserver> observer)1131 void InputManagerImpl::SetAnrObserver(std::shared_ptr<IAnrObserver> observer)
1132 {
1133 CALL_DEBUG_ENTER;
1134 std::lock_guard<std::mutex> guard(mtx_);
1135 if (!MMIEventHdl.InitClient()) {
1136 MMI_HILOGE("Client init failed");
1137 return;
1138 }
1139 for (auto iter = anrObservers_.begin(); iter != anrObservers_.end(); ++iter) {
1140 if (*iter == observer) {
1141 MMI_HILOGE("Observer already exist");
1142 return;
1143 }
1144 }
1145 anrObservers_.push_back(observer);
1146 int32_t ret = MultimodalInputConnMgr->SetAnrObserver();
1147 if (ret != RET_OK) {
1148 MMI_HILOGE("Set anr observer failed, ret:%{public}d", ret);
1149 }
1150 }
1151
OnAnr(int32_t pid)1152 void InputManagerImpl::OnAnr(int32_t pid)
1153 {
1154 CALL_DEBUG_ENTER;
1155 CHK_PID_AND_TID();
1156 {
1157 std::lock_guard<std::mutex> guard(mtx_);
1158 for (const auto &observer : anrObservers_) {
1159 CHKPC(observer);
1160 observer->OnAnr(pid);
1161 }
1162 }
1163 MMI_HILOGI("ANR noticed pid:%{public}d", pid);
1164 }
1165
GetFunctionKeyState(int32_t funcKey)1166 bool InputManagerImpl::GetFunctionKeyState(int32_t funcKey)
1167 {
1168 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
1169 CALL_DEBUG_ENTER;
1170 bool state { false };
1171 int32_t ret = MultimodalInputConnMgr->GetFunctionKeyState(funcKey, state);
1172 if (ret != RET_OK) {
1173 MMI_HILOGE("Send to server failed, ret:%{public}d", ret);
1174 }
1175 return state;
1176 #else
1177 MMI_HILOGW("Keyboard device does not support");
1178 return false;
1179 #endif // OHOS_BUILD_ENABLE_KEYBOARD
1180 }
1181
SetFunctionKeyState(int32_t funcKey,bool enable)1182 int32_t InputManagerImpl::SetFunctionKeyState(int32_t funcKey, bool enable)
1183 {
1184 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
1185 CALL_DEBUG_ENTER;
1186 int32_t ret = MultimodalInputConnMgr->SetFunctionKeyState(funcKey, enable);
1187 if (ret != RET_OK) {
1188 MMI_HILOGE("Send to server failed, ret:%{public}d", ret);
1189 return RET_ERR;
1190 }
1191 return RET_OK;
1192 #else
1193 MMI_HILOGW("Keyboard device does not support");
1194 return ERROR_UNSUPPORT;
1195 #endif // OHOS_BUILD_ENABLE_KEYBOARD
1196 }
1197
SetPointerLocation(int32_t x,int32_t y)1198 void InputManagerImpl::SetPointerLocation(int32_t x, int32_t y)
1199 {
1200 CALL_DEBUG_ENTER;
1201 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING)
1202 int32_t ret = MultimodalInputConnMgr->SetPointerLocation(x, y);
1203 if (ret != RET_OK) {
1204 MMI_HILOGE("Set Pointer Location failed, ret:%{public}d", ret);
1205 }
1206 #else
1207 MMI_HILOGW("Pointer device or pointer drawing module does not support");
1208 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING
1209 }
1210
EnterCaptureMode(int32_t windowId)1211 int32_t InputManagerImpl::EnterCaptureMode(int32_t windowId)
1212 {
1213 #if defined(OHOS_BUILD_ENABLE_POINTER)
1214 CALL_DEBUG_ENTER;
1215 std::lock_guard<std::mutex> guard(mtx_);
1216 int32_t ret = MultimodalInputConnMgr->SetMouseCaptureMode(windowId, true);
1217 if (ret != RET_OK) {
1218 MMI_HILOGE("Enter captrue mode failed");
1219 }
1220 return ret;
1221 #else
1222 MMI_HILOGW("Pointer device module does not support");
1223 return ERROR_UNSUPPORT;
1224 #endif // OHOS_BUILD_ENABLE_POINTER
1225 }
1226
LeaveCaptureMode(int32_t windowId)1227 int32_t InputManagerImpl::LeaveCaptureMode(int32_t windowId)
1228 {
1229 #if defined(OHOS_BUILD_ENABLE_POINTER)
1230 CALL_DEBUG_ENTER;
1231 std::lock_guard<std::mutex> guard(mtx_);
1232 int32_t ret = MultimodalInputConnMgr->SetMouseCaptureMode(windowId, false);
1233 if (ret != RET_OK) {
1234 MMI_HILOGE("Leave captrue mode failed");
1235 }
1236 return ret;
1237 #else
1238 MMI_HILOGW("Pointer device module does not support");
1239 return ERROR_UNSUPPORT;
1240 #endif // OHOS_BUILD_ENABLE_POINTER
1241 }
1242
AppendExtraData(const ExtraData & extraData)1243 void InputManagerImpl::AppendExtraData(const ExtraData& extraData)
1244 {
1245 CALL_DEBUG_ENTER;
1246 std::lock_guard<std::mutex> guard(mtx_);
1247 if (extraData.buffer.size() > ExtraData::MAX_BUFFER_SIZE) {
1248 MMI_HILOGE("Append extra data failed, buffer is oversize:%{public}zu", extraData.buffer.size());
1249 return;
1250 }
1251 int32_t ret = MultimodalInputConnMgr->AppendExtraData(extraData);
1252 if (ret != RET_OK) {
1253 MMI_HILOGE("Append extra data failed:%{public}d", ret);
1254 }
1255 }
1256
EnableInputDevice(bool enable)1257 int32_t InputManagerImpl::EnableInputDevice(bool enable)
1258 {
1259 CALL_DEBUG_ENTER;
1260 int32_t ret = MultimodalInputConnMgr->EnableInputDevice(enable);
1261 if (ret != RET_OK) {
1262 MMI_HILOGE("Enable input device failed, ret:%{public}d", ret);
1263 }
1264 return ret;
1265 }
1266
SetKeyDownDuration(const std::string & businessId,int32_t delay)1267 int32_t InputManagerImpl::SetKeyDownDuration(const std::string &businessId, int32_t delay)
1268 {
1269 CALL_DEBUG_ENTER;
1270 if (delay < MIN_DELAY || delay > MAX_DELAY) {
1271 MMI_HILOGE("The param is invalid");
1272 return RET_ERR;
1273 }
1274 int32_t ret = MultimodalInputConnMgr->SetKeyDownDuration(businessId, delay);
1275 if (ret != RET_OK) {
1276 MMI_HILOGE("Set Key down duration failed, ret:%{public}d", ret);
1277 return ret;
1278 }
1279 return RET_OK;
1280 }
1281
SetTouchpadScrollSwitch(bool switchFlag)1282 int32_t InputManagerImpl::SetTouchpadScrollSwitch(bool switchFlag)
1283 {
1284 CALL_DEBUG_ENTER;
1285 #if defined OHOS_BUILD_ENABLE_POINTER
1286 std::lock_guard<std::mutex> guard(mtx_);
1287 int32_t ret = MultimodalInputConnMgr->SetTouchpadScrollSwitch(switchFlag);
1288 if (ret != RET_OK) {
1289 MMI_HILOGE("Set the touchpad scroll switch failed, ret:%{public}d", ret);
1290 }
1291 return ret;
1292 #else
1293 MMI_HILOGW("Pointer device module does not support");
1294 return ERROR_UNSUPPORT;
1295 #endif // OHOS_BUILD_ENABLE_POINTER
1296 }
1297
GetTouchpadScrollSwitch(bool & switchFlag)1298 int32_t InputManagerImpl::GetTouchpadScrollSwitch(bool &switchFlag)
1299 {
1300 CALL_DEBUG_ENTER;
1301 #ifdef OHOS_BUILD_ENABLE_POINTER
1302 std::lock_guard<std::mutex> guard(mtx_);
1303 int32_t ret = MultimodalInputConnMgr->GetTouchpadScrollSwitch(switchFlag);
1304 if (ret != RET_OK) {
1305 MMI_HILOGE("Get the touchpad scroll switch failed");
1306 }
1307 return ret;
1308 #else
1309 MMI_HILOGW("Pointer device does not support");
1310 return ERROR_UNSUPPORT;
1311 #endif // OHOS_BUILD_ENABLE_POINTER
1312 }
1313
SetTouchpadScrollDirection(bool state)1314 int32_t InputManagerImpl::SetTouchpadScrollDirection(bool state)
1315 {
1316 CALL_DEBUG_ENTER;
1317 #if defined OHOS_BUILD_ENABLE_POINTER
1318 std::lock_guard<std::mutex> guard(mtx_);
1319 int32_t ret = MultimodalInputConnMgr->SetTouchpadScrollDirection(state);
1320 if (ret != RET_OK) {
1321 MMI_HILOGE("Set the touchpad scroll direction switch failed, ret:%{public}d", ret);
1322 }
1323 return ret;
1324 #else
1325 MMI_HILOGW("Pointer device module does not support");
1326 return ERROR_UNSUPPORT;
1327 #endif // OHOS_BUILD_ENABLE_POINTER
1328 }
1329
GetTouchpadScrollDirection(bool & state)1330 int32_t InputManagerImpl::GetTouchpadScrollDirection(bool &state)
1331 {
1332 CALL_DEBUG_ENTER;
1333 #ifdef OHOS_BUILD_ENABLE_POINTER
1334 std::lock_guard<std::mutex> guard(mtx_);
1335 int32_t ret = MultimodalInputConnMgr->GetTouchpadScrollDirection(state);
1336 if (ret != RET_OK) {
1337 MMI_HILOGE("Get the touchpad scroll direction switch failed");
1338 }
1339 return ret;
1340 #else
1341 MMI_HILOGW("Pointer device does not support");
1342 return ERROR_UNSUPPORT;
1343 #endif // OHOS_BUILD_ENABLE_POINTER
1344 }
1345
SetTouchpadTapSwitch(bool switchFlag)1346 int32_t InputManagerImpl::SetTouchpadTapSwitch(bool switchFlag)
1347 {
1348 CALL_DEBUG_ENTER;
1349 #if defined OHOS_BUILD_ENABLE_POINTER
1350 std::lock_guard<std::mutex> guard(mtx_);
1351 int32_t ret = MultimodalInputConnMgr->SetTouchpadTapSwitch(switchFlag);
1352 if (ret != RET_OK) {
1353 MMI_HILOGE("Set the touchpad tap switch failed, ret:%{public}d", ret);
1354 }
1355 return ret;
1356 #else
1357 MMI_HILOGW("Pointer device module does not support");
1358 return ERROR_UNSUPPORT;
1359 #endif // OHOS_BUILD_ENABLE_POINTER
1360 }
1361
GetTouchpadTapSwitch(bool & switchFlag)1362 int32_t InputManagerImpl::GetTouchpadTapSwitch(bool &switchFlag)
1363 {
1364 CALL_DEBUG_ENTER;
1365 #ifdef OHOS_BUILD_ENABLE_POINTER
1366 std::lock_guard<std::mutex> guard(mtx_);
1367 int32_t ret = MultimodalInputConnMgr->GetTouchpadTapSwitch(switchFlag);
1368 if (ret != RET_OK) {
1369 MMI_HILOGE("Get the touchpad tap switch failed");
1370 }
1371 return ret;
1372 #else
1373 MMI_HILOGW("Pointer device does not support");
1374 return ERROR_UNSUPPORT;
1375 #endif // OHOS_BUILD_ENABLE_POINTER
1376 }
1377
SetTouchpadPointerSpeed(int32_t speed)1378 int32_t InputManagerImpl::SetTouchpadPointerSpeed(int32_t speed)
1379 {
1380 CALL_DEBUG_ENTER;
1381 #if defined OHOS_BUILD_ENABLE_POINTER
1382 std::lock_guard<std::mutex> guard(mtx_);
1383 int32_t ret = MultimodalInputConnMgr->SetTouchpadPointerSpeed(speed);
1384 if (ret != RET_OK) {
1385 MMI_HILOGE("Set the touchpad pointer speed failed, ret:%{public}d", ret);
1386 }
1387 return ret;
1388 #else
1389 MMI_HILOGW("Pointer device module does not support");
1390 return ERROR_UNSUPPORT;
1391 #endif // OHOS_BUILD_ENABLE_POINTER
1392 }
1393
GetTouchpadPointerSpeed(int32_t & speed)1394 int32_t InputManagerImpl::GetTouchpadPointerSpeed(int32_t &speed)
1395 {
1396 CALL_DEBUG_ENTER;
1397 #ifdef OHOS_BUILD_ENABLE_POINTER
1398 std::lock_guard<std::mutex> guard(mtx_);
1399 int32_t ret = MultimodalInputConnMgr->GetTouchpadPointerSpeed(speed);
1400 if (ret != RET_OK) {
1401 MMI_HILOGE("Get the touchpad pointer speed failed");
1402 }
1403 return ret;
1404 #else
1405 MMI_HILOGW("Pointer device does not support");
1406 return ERROR_UNSUPPORT;
1407 #endif // OHOS_BUILD_ENABLE_POINTER
1408 }
1409
SetTouchpadPinchSwitch(bool switchFlag)1410 int32_t InputManagerImpl::SetTouchpadPinchSwitch(bool switchFlag)
1411 {
1412 CALL_DEBUG_ENTER;
1413 #if defined OHOS_BUILD_ENABLE_POINTER
1414 std::lock_guard<std::mutex> guard(mtx_);
1415 int32_t ret = MultimodalInputConnMgr->SetTouchpadPinchSwitch(switchFlag);
1416 if (ret != RET_OK) {
1417 MMI_HILOGE("Set the touchpad pinch switch failed, ret:%{public}d", ret);
1418 }
1419 return ret;
1420 #else
1421 MMI_HILOGW("Pointer device module does not support");
1422 return ERROR_UNSUPPORT;
1423 #endif // OHOS_BUILD_ENABLE_POINTER
1424 }
1425
GetTouchpadPinchSwitch(bool & switchFlag)1426 int32_t InputManagerImpl::GetTouchpadPinchSwitch(bool &switchFlag)
1427 {
1428 CALL_DEBUG_ENTER;
1429 #ifdef OHOS_BUILD_ENABLE_POINTER
1430 std::lock_guard<std::mutex> guard(mtx_);
1431 int32_t ret = MultimodalInputConnMgr->GetTouchpadPinchSwitch(switchFlag);
1432 if (ret != RET_OK) {
1433 MMI_HILOGE("Get the touchpad pinch switch failed");
1434 }
1435 return ret;
1436 #else
1437 MMI_HILOGW("Pointer device does not support");
1438 return ERROR_UNSUPPORT;
1439 #endif // OHOS_BUILD_ENABLE_POINTER
1440 }
1441
SetTouchpadSwipeSwitch(bool switchFlag)1442 int32_t InputManagerImpl::SetTouchpadSwipeSwitch(bool switchFlag)
1443 {
1444 CALL_DEBUG_ENTER;
1445 #if defined OHOS_BUILD_ENABLE_POINTER
1446 std::lock_guard<std::mutex> guard(mtx_);
1447 int32_t ret = MultimodalInputConnMgr->SetTouchpadSwipeSwitch(switchFlag);
1448 if (ret != RET_OK) {
1449 MMI_HILOGE("Set the touchpad swipe switch failed, ret:%{public}d", ret);
1450 }
1451 return ret;
1452 #else
1453 MMI_HILOGW("Pointer device module does not support");
1454 return ERROR_UNSUPPORT;
1455 #endif // OHOS_BUILD_ENABLE_POINTER
1456 }
1457
GetTouchpadSwipeSwitch(bool & switchFlag)1458 int32_t InputManagerImpl::GetTouchpadSwipeSwitch(bool &switchFlag)
1459 {
1460 CALL_DEBUG_ENTER;
1461 #ifdef OHOS_BUILD_ENABLE_POINTER
1462 std::lock_guard<std::mutex> guard(mtx_);
1463 int32_t ret = MultimodalInputConnMgr->GetTouchpadSwipeSwitch(switchFlag);
1464 if (ret != RET_OK) {
1465 MMI_HILOGE("Get the touchpad swipe switch failed");
1466 }
1467 return ret;
1468 #else
1469 MMI_HILOGW("Pointer device does not support");
1470 return ERROR_UNSUPPORT;
1471 #endif // OHOS_BUILD_ENABLE_POINTER
1472 }
1473
SetTouchpadRightClickType(int32_t type)1474 int32_t InputManagerImpl::SetTouchpadRightClickType(int32_t type)
1475 {
1476 CALL_DEBUG_ENTER;
1477 #if defined OHOS_BUILD_ENABLE_POINTER
1478 std::lock_guard<std::mutex> guard(mtx_);
1479 int32_t ret = MultimodalInputConnMgr->SetTouchpadRightClickType(type);
1480 if (ret != RET_OK) {
1481 MMI_HILOGE("Set the touchpad right click type failed, ret:%{public}d", ret);
1482 }
1483 return ret;
1484 #else
1485 MMI_HILOGW("Pointer device module does not support");
1486 return ERROR_UNSUPPORT;
1487 #endif // OHOS_BUILD_ENABLE_POINTER
1488 }
1489
GetTouchpadRightClickType(int32_t & type)1490 int32_t InputManagerImpl::GetTouchpadRightClickType(int32_t &type)
1491 {
1492 CALL_DEBUG_ENTER;
1493 #ifdef OHOS_BUILD_ENABLE_POINTER
1494 std::lock_guard<std::mutex> guard(mtx_);
1495 int32_t ret = MultimodalInputConnMgr->GetTouchpadRightClickType(type);
1496 if (ret != RET_OK) {
1497 MMI_HILOGE("Get the touchpad right click failed");
1498 }
1499 return ret;
1500 #else
1501 MMI_HILOGW("Pointer device does not support");
1502 return ERROR_UNSUPPORT;
1503 #endif // OHOS_BUILD_ENABLE_POINTER
1504 }
1505 } // namespace MMI
1506 } // namespace OHOS
1507