1 /*
2 * Copyright (c) 2021-2023 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 "event_dispatch_handler.h"
17
18 #include <cinttypes>
19
20 #include <linux/input-event-codes.h>
21
22 #include "hitrace_meter.h"
23 #include "transaction/rs_interfaces.h"
24
25 #include "anr_manager.h"
26 #include "app_debug_listener.h"
27 #include "bytrace_adapter.h"
28 #include "dfx_hisysevent.h"
29 #include "error_multimodal.h"
30 #include "event_log_helper.h"
31 #include "input_event_data_transformation.h"
32 #include "input_event_handler.h"
33 #include "mouse_device_state.h"
34 #include "napi_constants.h"
35 #include "proto.h"
36 #include "util.h"
37
38 #undef MMI_LOG_DOMAIN
39 #define MMI_LOG_DOMAIN MMI_LOG_DISPATCH
40 #undef MMI_LOG_TAG
41 #define MMI_LOG_TAG "EventDispatchHandler"
42
43 namespace OHOS {
44 namespace MMI {
45 namespace {
46 constexpr int64_t ERROR_TIME {3000000};
47 constexpr int32_t INTERVAL_TIME { 3000 }; // log time interval is 3 seconds.
48 constexpr int32_t INTERVAL_DURATION { 10 };
49 constexpr int32_t THREE_FINGERS { 3 };
50 } // namespace
51
52 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
HandleKeyEvent(const std::shared_ptr<KeyEvent> keyEvent)53 void EventDispatchHandler::HandleKeyEvent(const std::shared_ptr<KeyEvent> keyEvent)
54 {
55 CHKPV(keyEvent);
56 auto udsServer = InputHandler->GetUDSServer();
57 CHKPV(udsServer);
58 DispatchKeyEventPid(*udsServer, keyEvent);
59 }
60 #endif // OHOS_BUILD_ENABLE_KEYBOARD
61
62 #ifdef OHOS_BUILD_ENABLE_POINTER
HandlePointerEvent(const std::shared_ptr<PointerEvent> pointerEvent)63 void EventDispatchHandler::HandlePointerEvent(const std::shared_ptr<PointerEvent> pointerEvent)
64 {
65 CHKPV(pointerEvent);
66 HandlePointerEventInner(pointerEvent);
67 }
68 #endif // OHOS_BUILD_ENABLE_POINTER
69
70 #ifdef OHOS_BUILD_ENABLE_TOUCH
HandleTouchEvent(const std::shared_ptr<PointerEvent> pointerEvent)71 void EventDispatchHandler::HandleTouchEvent(const std::shared_ptr<PointerEvent> pointerEvent)
72 {
73 CHKPV(pointerEvent);
74 HandlePointerEventInner(pointerEvent);
75 }
76 #endif // OHOS_BUILD_ENABLE_TOUCH
77
78 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
FilterInvalidPointerItem(const std::shared_ptr<PointerEvent> pointerEvent,int32_t fd)79 void EventDispatchHandler::FilterInvalidPointerItem(const std::shared_ptr<PointerEvent> pointerEvent, int32_t fd)
80 {
81 CHKPV(pointerEvent);
82 auto udsServer = InputHandler->GetUDSServer();
83 CHKPV(udsServer);
84 auto pointerIdList = pointerEvent->GetPointerIds();
85 if (pointerIdList.size() > 1) {
86 for (const auto& id : pointerIdList) {
87 PointerEvent::PointerItem pointeritem;
88 if (!pointerEvent->GetPointerItem(id, pointeritem)) {
89 MMI_HILOGW("Can't find this pointerItem");
90 continue;
91 }
92 auto itemPid = WIN_MGR->GetWindowPid(pointeritem.GetTargetWindowId());
93 if ((itemPid >= 0) && (itemPid != udsServer->GetClientPid(fd))) {
94 pointerEvent->RemovePointerItem(id);
95 MMI_HILOGD("pointerIdList size:%{public}zu", pointerEvent->GetPointerIds().size());
96 }
97 }
98 }
99 }
100
SearchCancelList(int32_t pointerId,int32_t windowId)101 std::shared_ptr<WindowInfo> EventDispatchHandler::SearchCancelList (int32_t pointerId, int32_t windowId)
102 {
103 if (cancelEventList_.find(pointerId) == cancelEventList_.end()) {
104 return nullptr;
105 }
106 auto windowList = cancelEventList_[pointerId];
107 for (auto &info : windowList) {
108 if (info->id == windowId) {
109 return info;
110 }
111 }
112 return nullptr;
113 }
114
ReissueEvent(std::shared_ptr<PointerEvent> & point,int32_t windowId,std::optional<WindowInfo> & windowInfo)115 bool EventDispatchHandler::ReissueEvent(std::shared_ptr<PointerEvent> &point, int32_t windowId,
116 std::optional<WindowInfo> &windowInfo)
117 {
118 int32_t pointerId = point->GetPointerId();
119 if (windowInfo == std::nullopt) {
120 std::shared_ptr<WindowInfo> curInfo = SearchCancelList(pointerId, windowId);
121 if (curInfo != nullptr && point->GetPointerAction() == PointerEvent::POINTER_ACTION_UP) {
122 point->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
123 windowInfo = std::make_optional(*curInfo);
124 MMI_HILOG_DISPATCHI("Touch event send cancel to window:%{public}d", windowId);
125 } else {
126 if (point->GetPointerAction() != PointerEvent::POINTER_ACTION_MOVE) {
127 MMI_HILOGE("Window:%{public}d is nullptr", windowId);
128 }
129 return false;
130 }
131 }
132 std::shared_ptr<WindowInfo> curWindowInfo = std::make_shared<WindowInfo>(*windowInfo);
133 if (point->GetPointerAction() == PointerEvent::POINTER_ACTION_DOWN) {
134 if (cancelEventList_.find(pointerId) == cancelEventList_.end()) {
135 cancelEventList_[pointerId] = std::vector<std::shared_ptr<WindowInfo>>(0);
136 }
137 cancelEventList_[pointerId].push_back(curWindowInfo);
138 } else if (point->GetPointerAction() == PointerEvent::POINTER_ACTION_UP ||
139 point->GetPointerAction() == PointerEvent::POINTER_ACTION_CANCEL) {
140 if (cancelEventList_.find(pointerId) == cancelEventList_.end() ||
141 !SearchWindow(cancelEventList_[pointerId], curWindowInfo)) {
142 return false;
143 }
144 }
145 return true;
146 }
147
SearchWindow(std::vector<std::shared_ptr<WindowInfo>> & windowList,std::shared_ptr<WindowInfo> targetWindow)148 bool EventDispatchHandler::SearchWindow(std::vector<std::shared_ptr<WindowInfo>> &windowList,
149 std::shared_ptr<WindowInfo> targetWindow)
150 {
151 for (auto &window : windowList) {
152 if (window->id == targetWindow->id) {
153 return true;
154 }
155 }
156 return false;
157 }
158
HandleMultiWindowPointerEvent(std::shared_ptr<PointerEvent> point,PointerEvent::PointerItem pointerItem)159 void EventDispatchHandler::HandleMultiWindowPointerEvent(std::shared_ptr<PointerEvent> point,
160 PointerEvent::PointerItem pointerItem)
161 {
162 CALL_DEBUG_ENTER;
163 CHKPV(point);
164 std::vector<int32_t> windowIds;
165 WIN_MGR->GetTargetWindowIds(pointerItem.GetPointerId(), point->GetSourceType(), windowIds);
166 int32_t count = 0;
167 int32_t pointerId = point->GetPointerId();
168 if (point->GetPointerAction() == PointerEvent::POINTER_ACTION_DOWN) {
169 if (cancelEventList_.find(pointerId) != cancelEventList_.end()) {
170 cancelEventList_.erase(pointerId);
171 }
172 }
173 for (auto windowId : windowIds) {
174 auto pointerEvent = std::make_shared<PointerEvent>(*point);
175 auto windowInfo = WIN_MGR->GetWindowAndDisplayInfo(windowId, point->GetTargetDisplayId());
176 if (!ReissueEvent(pointerEvent, windowId, windowInfo)) {
177 continue;
178 }
179 if (!windowInfo) {
180 continue;
181 }
182 if (pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_PULL_UP &&
183 windowInfo->windowInputType == WindowInputType::TRANSMIT_ALL && windowIds.size() > 1) {
184 MMI_HILOGD("When the drag is finished, the multi-window distribution is canceled. window:%{public}d,"
185 "windowInputType:%{public}d", windowId, static_cast<int32_t>(windowInfo->windowInputType));
186 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
187 }
188 auto fd = WIN_MGR->GetClientFd(pointerEvent, windowInfo->id);
189 if (fd < 0) {
190 auto udsServer = InputHandler->GetUDSServer();
191 CHKPV(udsServer);
192 fd = udsServer->GetClientFd(windowInfo->pid);
193 MMI_HILOGI("Window:%{public}d exit front desk, windowfd:%{public}d", windowId, fd);
194 }
195 pointerEvent->SetTargetWindowId(windowId);
196 pointerEvent->SetAgentWindowId(windowInfo->agentWindowId);
197 int32_t windowX = pointerItem.GetDisplayX() - windowInfo->area.x;
198 int32_t windowY = pointerItem.GetDisplayY() - windowInfo->area.y;
199 if (!windowInfo->transform.empty()) {
200 auto windowXY = WIN_MGR->TransformWindowXY(*windowInfo, pointerItem.GetDisplayX(),
201 pointerItem.GetDisplayY());
202 windowX = windowXY.first;
203 windowY = windowXY.second;
204 }
205 pointerItem.SetWindowX(windowX);
206 pointerItem.SetWindowY(windowY);
207 pointerItem.SetTargetWindowId(windowId);
208 pointerEvent->UpdatePointerItem(pointerId, pointerItem);
209 pointerEvent->SetDispatchTimes(count++);
210 DispatchPointerEventInner(pointerEvent, fd);
211 }
212 if (point->GetPointerAction() == PointerEvent::POINTER_ACTION_UP ||
213 point->GetPointerAction() == PointerEvent::POINTER_ACTION_PULL_UP ||
214 point->GetPointerAction() == PointerEvent::POINTER_ACTION_CANCEL) {
215 if (cancelEventList_.find(pointerId) != cancelEventList_.end()) {
216 cancelEventList_.erase(pointerId);
217 }
218 WIN_MGR->ClearTargetWindowId(pointerId);
219 }
220 }
221
NotifyPointerEventToRS(int32_t pointAction,const std::string & programName,uint32_t pid,int32_t pointCnt)222 void EventDispatchHandler::NotifyPointerEventToRS(int32_t pointAction, const std::string& programName,
223 uint32_t pid, int32_t pointCnt)
224 {
225 OHOS::Rosen::RSInterfaces::GetInstance().NotifyTouchEvent(pointAction, pointCnt);
226 }
227
AcquireEnableMark(std::shared_ptr<PointerEvent> event)228 bool EventDispatchHandler::AcquireEnableMark(std::shared_ptr<PointerEvent> event)
229 {
230 auto currentEventTime = std::chrono::high_resolution_clock::now();
231 int64_t tm64Cost = std::chrono::duration_cast<std::chrono::milliseconds>(
232 std::chrono::high_resolution_clock::now() - LasteventBeginTime_).count();
233
234 if (event->GetPointerAction() == PointerEvent::POINTER_ACTION_PULL_MOVE
235 || event->GetPointerAction() == PointerEvent::POINTER_ACTION_MOVE) {
236 enableMark_ = (tm64Cost > INTERVAL_DURATION) ? true : false;
237 if (enableMark_) {
238 LasteventBeginTime_ = currentEventTime;
239 }
240 MMI_HILOGD("Id:%{public}d, markEnabled:%{public}d", event->GetId(), enableMark_);
241 return enableMark_;
242 }
243 return true;
244 }
245
SendWindowStateError(int32_t pid,int32_t windowId)246 void EventDispatchHandler::SendWindowStateError(int32_t pid, int32_t windowId)
247 {
248 CALL_DEBUG_ENTER;
249 auto udsServer = InputHandler->GetUDSServer();
250 auto sess = udsServer->GetSessionByPid(WIN_MGR->GetWindowStateNotifyPid());
251 if (sess != nullptr) {
252 NetPacket pkt(MmiMessageId::WINDOW_STATE_ERROR_NOTIFY);
253 pkt << pid << windowId;
254 if (!sess->SendMsg(pkt)) {
255 MMI_HILOGE("SendMsg failed");
256 return;
257 }
258 windowStateErrorInfo_.windowId = -1;
259 windowStateErrorInfo_.startTime = -1;
260 windowStateErrorInfo_.pid = -1;
261 }
262 }
263
HandlePointerEventInner(const std::shared_ptr<PointerEvent> point)264 void EventDispatchHandler::HandlePointerEventInner(const std::shared_ptr<PointerEvent> point)
265 {
266 CALL_DEBUG_ENTER;
267 CHKPV(point);
268 #ifdef OHOS_BUILD_ENABLE_ANCO
269 if (point->GetAncoDeal()) {
270 MMI_HILOGD("event dealed by anco, ignore it");
271 return;
272 }
273 #endif // OHOS_BUILD_ENABLE_ANCO
274 int32_t pointerId = point->GetPointerId();
275 PointerEvent::PointerItem pointerItem;
276 if (!point->GetPointerItem(pointerId, pointerItem)) {
277 MMI_HILOGE("Can't find pointer item, pointer:%{public}d", pointerId);
278 return;
279 }
280 std::vector<int32_t> windowIds;
281 WIN_MGR->GetTargetWindowIds(pointerItem.GetPointerId(), point->GetSourceType(), windowIds);
282 if (!windowIds.empty()) {
283 HandleMultiWindowPointerEvent(point, pointerItem);
284 return;
285 }
286 auto pid = WIN_MGR->GetPidByWindowId(point->GetTargetWindowId());
287 int32_t fd = GetClientFd(pid, point);
288 auto udsServer = InputHandler->GetUDSServer();
289 CHKPV(udsServer);
290 if (WIN_MGR->GetCancelEventFlag(point) && udsServer->GetSession(fd) == nullptr &&
291 pid != -1 && point->GetTargetWindowId() != -1) {
292 if (point->GetTargetWindowId() == windowStateErrorInfo_.windowId && pid == windowStateErrorInfo_.pid) {
293 if (GetSysClockTime() - windowStateErrorInfo_.startTime >= ERROR_TIME) {
294 SendWindowStateError(pid, point->GetTargetWindowId());
295 }
296 } else {
297 windowStateErrorInfo_.windowId = point->GetTargetWindowId();
298 windowStateErrorInfo_.startTime = GetSysClockTime();
299 windowStateErrorInfo_.pid = pid;
300 }
301 }
302 DispatchPointerEventInner(point, fd);
303 }
304
GetClientFd(int32_t pid,std::shared_ptr<PointerEvent> point)305 int32_t EventDispatchHandler::GetClientFd(int32_t pid, std::shared_ptr<PointerEvent> point)
306 {
307 CHKPR(point, INVALID_FD);
308 if (WIN_MGR->AdjustFingerFlag(point)) {
309 return INVALID_FD;
310 }
311 if (point->GetPointerAction() != PointerEvent::POINTER_ACTION_CANCEL &&
312 point->GetPointerAction() != PointerEvent::POINTER_ACTION_HOVER_CANCEL &&
313 (point->GetSourceType() == PointerEvent::SOURCE_TYPE_TOUCHSCREEN ||
314 point->GetSourceType() == PointerEvent::SOURCE_TYPE_MOUSE) && (pid > 0)) {
315 WIN_MGR->FoldScreenRotation(point);
316 auto udsServer = InputHandler->GetUDSServer();
317 CHKPR(udsServer, INVALID_FD);
318 return udsServer->GetClientFd(pid);
319 }
320 return WIN_MGR->GetClientFd(point);
321 }
322
DispatchPointerEventInner(std::shared_ptr<PointerEvent> point,int32_t fd)323 void EventDispatchHandler::DispatchPointerEventInner(std::shared_ptr<PointerEvent> point, int32_t fd)
324 {
325 currentTime_ = point->GetActionTime();
326 if (fd < 0 && currentTime_ - eventTime_ > INTERVAL_TIME) {
327 eventTime_ = currentTime_;
328 if (point->GetPointerCount() < THREE_FINGERS &&
329 point->GetPointerAction() != PointerEvent::POINTER_ACTION_AXIS_UPDATE &&
330 point->GetPointerAction() != PointerEvent::POINTER_ACTION_SWIPE_UPDATE &&
331 point->GetPointerAction() != PointerEvent::POINTER_ACTION_MOVE) {
332 MMI_HILOGE("InputTracking id:%{public}d The fd less than 0, fd:%{public}d", point->GetId(), fd);
333 }
334 return;
335 }
336 auto udsServer = InputHandler->GetUDSServer();
337 CHKPV(udsServer);
338 auto sess = udsServer->GetSession(fd);
339 if (sess == nullptr) {
340 return;
341 }
342 auto currentTime = GetSysClockTime();
343 if (ANRMgr->TriggerANR(ANR_DISPATCH, currentTime, sess)) {
344 MMI_HILOGD("The pointer event does not report normally,app not respon. PointerEvent(deviceid:%{public}d,"
345 "action:%{public}s)", point->GetDeviceId(), point->DumpPointerAction());
346 return;
347 }
348 auto pointerEvent = std::make_shared<PointerEvent>(*point);
349 pointerEvent->SetMarkEnabled(AcquireEnableMark(pointerEvent));
350 pointerEvent->SetSensorInputTime(point->GetSensorInputTime());
351 FilterInvalidPointerItem(pointerEvent, fd);
352 NetPacket pkt(MmiMessageId::ON_POINTER_EVENT);
353 InputEventDataTransformation::Marshalling(pointerEvent, pkt);
354 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
355 InputEventDataTransformation::MarshallingEnhanceData(pointerEvent, pkt);
356 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
357 BytraceAdapter::StartBytrace(point, BytraceAdapter::TRACE_STOP);
358 int32_t pointerAc = pointerEvent->GetPointerAction();
359 if (pointerAc == PointerEvent::POINTER_ACTION_PULL_DOWN || pointerAc == PointerEvent::POINTER_ACTION_UP ||
360 pointerAc == PointerEvent::POINTER_ACTION_DOWN || pointerAc == PointerEvent::POINTER_ACTION_PULL_UP) {
361 NotifyPointerEventToRS(pointerAc, sess->GetProgramName(),
362 static_cast<uint32_t>(sess->GetPid()), pointerEvent->GetPointerCount());
363 }
364 if (pointerAc != PointerEvent::POINTER_ACTION_MOVE && pointerAc != PointerEvent::POINTER_ACTION_AXIS_UPDATE &&
365 pointerAc != PointerEvent::POINTER_ACTION_ROTATE_UPDATE &&
366 pointerAc != PointerEvent::POINTER_ACTION_PULL_MOVE) {
367 MMI_HILOG_FREEZEI("SendMsg to %{public}s:pid:%{public}d", sess->GetProgramName().c_str(), sess->GetPid());
368 }
369 if (!udsServer->SendMsg(fd, pkt)) {
370 MMI_HILOGE("Sending structure of EventTouch failed! errCode:%{public}d", MSG_SEND_FAIL);
371 return;
372 }
373 if (sess->GetPid() != AppDebugListener::GetInstance()->GetAppDebugPid() && pointerEvent->IsMarkEnabled()) {
374 MMI_HILOGD("Session pid:%{public}d", sess->GetPid());
375 ANRMgr->AddTimer(ANR_DISPATCH, point->GetId(), currentTime, sess);
376 }
377 }
378 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_POINTER
379
380 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
DispatchKeyEventPid(UDSServer & udsServer,std::shared_ptr<KeyEvent> key)381 int32_t EventDispatchHandler::DispatchKeyEventPid(UDSServer& udsServer, std::shared_ptr<KeyEvent> key)
382 {
383 CALL_DEBUG_ENTER;
384 CHKPR(key, PARAM_INPUT_INVALID);
385 int32_t ret = RET_OK;
386 // 1.Determine whether the key event is a focus type event or an operation type event,
387 // 2.Determine whether the current focus window has a safety sub window.
388 auto secSubWindowTargets = WIN_MGR->UpdateTarget(key);
389 for (const auto &item : secSubWindowTargets) {
390 key->ClearFlag(InputEvent::EVENT_FLAG_PRIVACY_MODE);
391 if (item.second.privacyMode == SecureFlag::PRIVACY_MODE) {
392 key->AddFlag(InputEvent::EVENT_FLAG_PRIVACY_MODE);
393 }
394 key->SetTargetWindowId(item.second.id);
395 key->SetAgentWindowId(item.second.agentWindowId);
396 ret = DispatchKeyEvent(item.first, udsServer, key);
397 }
398 return ret;
399 }
400
DispatchKeyEvent(int32_t fd,UDSServer & udsServer,std::shared_ptr<KeyEvent> key)401 int32_t EventDispatchHandler::DispatchKeyEvent(int32_t fd, UDSServer& udsServer, std::shared_ptr<KeyEvent> key)
402 {
403 CALL_DEBUG_ENTER;
404 CHKPR(key, PARAM_INPUT_INVALID);
405 currentTime_ = key->GetActionTime();
406 if (fd < 0 && currentTime_ - eventTime_ > INTERVAL_TIME) {
407 eventTime_ = currentTime_;
408 MMI_HILOGE("Invalid fd, fd:%{public}d", fd);
409 DfxHisysevent::OnUpdateTargetKey(key, fd, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT);
410 return RET_ERR;
411 }
412 MMI_HILOGD("Event dispatcher of server, KeyEvent:KeyCode:%{private}d, Action:%{public}d, EventType:%{public}d,"
413 "Fd:%{public}d", key->GetKeyCode(), key->GetAction(), key->GetEventType(), fd);
414 auto session = udsServer.GetSession(fd);
415 CHKPR(session, RET_ERR);
416 auto currentTime = GetSysClockTime();
417 if (ANRMgr->TriggerANR(ANR_DISPATCH, currentTime, session)) {
418 if (!EventLogHelper::IsBetaVersion()) {
419 MMI_HILOGW("The key event does not report normally, application not response.KeyEvent(deviceid:%{public}d,"
420 "key action:%{public}d)", key->GetDeviceId(), key->GetKeyAction());
421 } else {
422 MMI_HILOGW("The key event does not report normally, application not response.KeyEvent(deviceid:%{public}d,"
423 "key action:%{public}d)", key->GetDeviceId(), key->GetKeyAction());
424 }
425 return RET_OK;
426 }
427 auto keyHandler = InputHandler->GetEventNormalizeHandler();
428 CHKPR(keyHandler, RET_ERR);
429 if (key->GetKeyCode() != keyHandler->GetCurrentHandleKeyCode()) {
430 MMI_HILOGW("Keycode has been changed");
431 }
432 NetPacket pkt(MmiMessageId::ON_KEY_EVENT);
433 InputEventDataTransformation::KeyEventToNetPacket(key, pkt);
434 BytraceAdapter::StartBytrace(key, BytraceAdapter::KEY_DISPATCH_EVENT);
435 pkt << fd;
436
437 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
438 InputEventDataTransformation::MarshallingEnhanceData(key, pkt);
439 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
440 if (pkt.ChkRWError()) {
441 MMI_HILOGE("Packet write structure of EventKeyboard failed");
442 return RET_ERR;
443 }
444 MMI_HILOGI("InputTracking id:%{public}d, SendMsg to %{public}s:pid:%{public}d",
445 key->GetId(), session->GetProgramName().c_str(), session->GetPid());
446 if (!udsServer.SendMsg(fd, pkt)) {
447 MMI_HILOGE("Sending structure of EventKeyboard failed! errCode:%{public}d", MSG_SEND_FAIL);
448 return MSG_SEND_FAIL;
449 }
450 if (session->GetPid() != AppDebugListener::GetInstance()->GetAppDebugPid()) {
451 MMI_HILOGD("Session pid:%{public}d", session->GetPid());
452 ANRMgr->AddTimer(ANR_DISPATCH, key->GetId(), currentTime, session);
453 }
454 return RET_OK;
455 }
456 #endif // OHOS_BUILD_ENABLE_KEYBOARD
457 } // namespace MMI
458 } // namespace OHOS
459