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 "zidl/window_proxy.h"
17 #include <ipc_types.h>
18 #include <key_event.h>
19 #include "pointer_event.h"
20 #include "message_option.h"
21 #include "window_manager_hilog.h"
22 #include "wm_common.h"
23
24 namespace OHOS {
25 namespace Rosen {
26 namespace {
27 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowProxy"};
28 }
29
UpdateWindowRect(const struct Rect & rect,bool decoStatus,WindowSizeChangeReason reason,const std::shared_ptr<RSTransaction> & rsTransaction)30 WMError WindowProxy::UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason,
31 const std::shared_ptr<RSTransaction>& rsTransaction)
32 {
33 MessageParcel data;
34 MessageParcel reply;
35 MessageOption option(MessageOption::TF_ASYNC);
36 if (!data.WriteInterfaceToken(GetDescriptor())) {
37 WLOGFE("WriteInterfaceToken failed");
38 return WMError::WM_ERROR_IPC_FAILED;
39 }
40 if (!(data.WriteInt32(rect.posX_) && data.WriteInt32(rect.posY_) &&
41 data.WriteUint32(rect.width_) && data.WriteUint32(rect.height_))) {
42 WLOGFE("Write WindowRect failed");
43 return WMError::WM_ERROR_IPC_FAILED;
44 }
45 if (!data.WriteBool(decoStatus)) {
46 WLOGFE("Write deco status failed");
47 return WMError::WM_ERROR_IPC_FAILED;
48 }
49 if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
50 WLOGFE("Write WindowSizeChangeReason failed");
51 return WMError::WM_ERROR_IPC_FAILED;
52 }
53
54 bool hasRSTransaction = rsTransaction != nullptr;
55 if (!data.WriteBool(hasRSTransaction)) {
56 WLOGFE("Write transaction sync Id failed");
57 return WMError::WM_ERROR_IPC_FAILED;
58 }
59 if (hasRSTransaction) {
60 if (!data.WriteParcelable(rsTransaction.get())) {
61 WLOGFE("Write transaction sync Id failed");
62 return WMError::WM_ERROR_IPC_FAILED;
63 }
64 rsTransaction->MarshallTransactionSyncController(data);
65 }
66
67 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_WINDOW_RECT),
68 data, reply, option) != ERR_NONE) {
69 WLOGFE("SendRequest failed");
70 return WMError::WM_ERROR_IPC_FAILED;
71 }
72 return WMError::WM_OK;
73 }
74
UpdateWindowMode(WindowMode mode)75 WMError WindowProxy::UpdateWindowMode(WindowMode mode)
76 {
77 MessageParcel data;
78 MessageParcel reply;
79 MessageOption option(MessageOption::TF_ASYNC);
80 if (!data.WriteInterfaceToken(GetDescriptor())) {
81 WLOGFE("WriteInterfaceToken failed");
82 return WMError::WM_ERROR_IPC_FAILED;
83 }
84 if (!data.WriteUint32(static_cast<uint32_t>(mode))) {
85 WLOGFE("Write WindowMode failed");
86 return WMError::WM_ERROR_IPC_FAILED;
87 }
88
89 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_WINDOW_MODE),
90 data, reply, option) != ERR_NONE) {
91 WLOGFE("SendRequest failed");
92 return WMError::WM_ERROR_IPC_FAILED;
93 }
94 return WMError::WM_OK;
95 }
96
UpdateWindowModeSupportInfo(uint32_t modeSupportInfo)97 WMError WindowProxy::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo)
98 {
99 MessageParcel data;
100 MessageParcel reply;
101 MessageOption option(MessageOption::TF_ASYNC);
102 if (!data.WriteInterfaceToken(GetDescriptor())) {
103 WLOGFE("WriteInterfaceToken failed");
104 return WMError::WM_ERROR_IPC_FAILED;
105 }
106 if (!data.WriteUint32(modeSupportInfo)) {
107 WLOGFE("Write WindowMode failed");
108 return WMError::WM_ERROR_IPC_FAILED;
109 }
110
111 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO),
112 data, reply, option) != ERR_NONE) {
113 WLOGFE("SendRequest failed");
114 return WMError::WM_ERROR_IPC_FAILED;
115 }
116 return WMError::WM_OK;
117 }
118
UpdateFocusStatus(bool focused)119 WMError WindowProxy::UpdateFocusStatus(bool focused)
120 {
121 MessageParcel data;
122 MessageParcel reply;
123 MessageOption option(MessageOption::TF_ASYNC);
124 if (!data.WriteInterfaceToken(GetDescriptor())) {
125 WLOGFE("WriteInterfaceToken failed");
126 return WMError::WM_ERROR_IPC_FAILED;
127 }
128 if (!data.WriteBool(focused)) {
129 WLOGFE("Write Focus failed");
130 return WMError::WM_ERROR_IPC_FAILED;
131 }
132
133 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS),
134 data, reply, option) != ERR_NONE) {
135 WLOGFE("SendRequest failed");
136 return WMError::WM_ERROR_IPC_FAILED;
137 }
138 return WMError::WM_OK;
139 }
140
UpdateAvoidArea(const sptr<AvoidArea> & avoidArea,AvoidAreaType type)141 WMError WindowProxy::UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)
142 {
143 MessageParcel data;
144 MessageParcel reply;
145 MessageOption option(MessageOption::TF_ASYNC);
146 if (!data.WriteInterfaceToken(GetDescriptor())) {
147 WLOGFE("WriteInterfaceToken failed");
148 return WMError::WM_ERROR_IPC_FAILED;
149 }
150 if (!data.WriteStrongParcelable(avoidArea)) {
151 WLOGFE("Write WindowRect failed");
152 return WMError::WM_ERROR_IPC_FAILED;
153 }
154 if (!data.WriteUint32(static_cast<uint32_t>(type))) {
155 WLOGFE("Write AvoidAreaType failed");
156 return WMError::WM_ERROR_IPC_FAILED;
157 }
158 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_AVOID_AREA),
159 data, reply, option) != ERR_NONE) {
160 WLOGFE("SendRequest failed");
161 return WMError::WM_ERROR_IPC_FAILED;
162 }
163 return WMError::WM_OK;
164 }
165
UpdateWindowState(WindowState state)166 WMError WindowProxy::UpdateWindowState(WindowState state)
167 {
168 MessageParcel data;
169 MessageParcel reply;
170 MessageOption option(MessageOption::TF_ASYNC);
171 if (!data.WriteInterfaceToken(GetDescriptor())) {
172 WLOGFE("WriteInterfaceToken failed");
173 return WMError::WM_ERROR_IPC_FAILED;
174 }
175
176 if (!data.WriteUint32(static_cast<uint32_t>(state))) {
177 WLOGFE("Write isStopped");
178 return WMError::WM_ERROR_IPC_FAILED;
179 }
180 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_WINDOW_STATE),
181 data, reply, option) != ERR_NONE) {
182 WLOGFE("SendRequest failed");
183 return WMError::WM_ERROR_IPC_FAILED;
184 }
185 return WMError::WM_OK;
186 }
187
UpdateWindowDragInfo(const PointInfo & point,DragEvent event)188 WMError WindowProxy::UpdateWindowDragInfo(const PointInfo& point, DragEvent event)
189 {
190 MessageParcel data;
191 MessageParcel reply;
192 MessageOption option(MessageOption::TF_ASYNC);
193 if (!data.WriteInterfaceToken(GetDescriptor())) {
194 WLOGFE("WriteInterfaceToken failed");
195 return WMError::WM_ERROR_IPC_FAILED;
196 }
197 if (!(data.WriteInt32(point.x) and data.WriteInt32(point.y))) {
198 WLOGFE("Write pos failed");
199 return WMError::WM_ERROR_IPC_FAILED;
200 }
201 if (!data.WriteInt32(static_cast<uint32_t>(event))) {
202 WLOGFE("Write event failed");
203 return WMError::WM_ERROR_IPC_FAILED;
204 }
205
206 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_DRAG_EVENT),
207 data, reply, option) != ERR_NONE) {
208 WLOGFE("SendRequest TRANS_ID_UPDATE_DRAG_EVENT failed");
209 return WMError::WM_ERROR_IPC_FAILED;
210 }
211 return WMError::WM_OK;
212 }
213
UpdateDisplayId(DisplayId from,DisplayId to)214 WMError WindowProxy::UpdateDisplayId(DisplayId from, DisplayId to)
215 {
216 MessageParcel data;
217 MessageParcel reply;
218 MessageOption option(MessageOption::TF_ASYNC);
219 if (!data.WriteInterfaceToken(GetDescriptor())) {
220 WLOGFE("WriteInterfaceToken failed");
221 return WMError::WM_ERROR_IPC_FAILED;
222 }
223 if (!(data.WriteUint64(from) and data.WriteUint64(to))) {
224 WLOGFE("Write displayid failed");
225 return WMError::WM_ERROR_IPC_FAILED;
226 }
227 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_DISPLAY_ID),
228 data, reply, option) != ERR_NONE) {
229 WLOGFE("SendRequest TRANS_ID_UPDATE_DISPLAY_ID failed");
230 return WMError::WM_ERROR_IPC_FAILED;
231 }
232 return WMError::WM_OK;
233 }
234
UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo> & info,const std::shared_ptr<RSTransaction> & rsTransaction)235 WMError WindowProxy::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
236 const std::shared_ptr<RSTransaction>& rsTransaction)
237 {
238 MessageParcel data;
239 MessageParcel reply;
240 MessageOption option(MessageOption::TF_ASYNC);
241 if (!data.WriteInterfaceToken(GetDescriptor())) {
242 WLOGFE("WriteInterfaceToken failed");
243 return WMError::WM_ERROR_IPC_FAILED;
244 }
245 if (!data.WriteParcelable(info)) {
246 WLOGFE("Write OccupiedAreaChangeInfo failed");
247 return WMError::WM_ERROR_IPC_FAILED;
248 }
249
250 bool hasRSTransaction = rsTransaction != nullptr;
251 if (!data.WriteBool(hasRSTransaction)) {
252 WLOGFE("Write transaction sync Id failed");
253 return WMError::WM_ERROR_IPC_FAILED;
254 }
255 if (hasRSTransaction) {
256 if (!data.WriteParcelable(rsTransaction.get())) {
257 WLOGFE("Write transaction sync Id failed");
258 return WMError::WM_ERROR_IPC_FAILED;
259 }
260 rsTransaction->MarshallTransactionSyncController(data);
261 }
262
263 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA),
264 data, reply, option) != ERR_NONE) {
265 WLOGFE("SendRequest failed");
266 return WMError::WM_ERROR_IPC_FAILED;
267 }
268 return WMError::WM_OK;
269 }
270
UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo> & info,const Rect & rect,const std::shared_ptr<RSTransaction> & rsTransaction)271 WMError WindowProxy::UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo>& info, const Rect& rect,
272 const std::shared_ptr<RSTransaction>& rsTransaction)
273 {
274 MessageParcel data;
275 MessageParcel reply;
276 MessageOption option(MessageOption::TF_ASYNC);
277 if (!data.WriteInterfaceToken(GetDescriptor())) {
278 WLOGFE("WriteInterfaceToken failed");
279 return WMError::WM_ERROR_IPC_FAILED;
280 }
281 if (!data.WriteParcelable(info)) {
282 WLOGFE("Write OccupiedAreaChangeInfo failed");
283 return WMError::WM_ERROR_IPC_FAILED;
284 }
285
286 if (!(data.WriteInt32(rect.posX_) && data.WriteInt32(rect.posY_) &&
287 data.WriteUint32(rect.width_) && data.WriteUint32(rect.height_))) {
288 WLOGFE("Write WindowRect failed");
289 return WMError::WM_ERROR_IPC_FAILED;
290 }
291
292 bool hasRSTransaction = rsTransaction != nullptr;
293 if (!data.WriteBool(hasRSTransaction)) {
294 WLOGFE("Write transaction sync Id failed");
295 return WMError::WM_ERROR_IPC_FAILED;
296 }
297 if (hasRSTransaction) {
298 if (!data.WriteParcelable(rsTransaction.get())) {
299 WLOGFE("Write transaction sync Id failed");
300 return WMError::WM_ERROR_IPC_FAILED;
301 }
302 rsTransaction->MarshallTransactionSyncController(data);
303 }
304
305 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA_AND_RECT),
306 data, reply, option) != ERR_NONE) {
307 WLOGFE("SendRequest failed");
308 return WMError::WM_ERROR_IPC_FAILED;
309 }
310 return WMError::WM_OK;
311 }
312
UpdateActiveStatus(bool isActive)313 WMError WindowProxy::UpdateActiveStatus(bool isActive)
314 {
315 MessageParcel data;
316 MessageParcel reply;
317 MessageOption option(MessageOption::TF_ASYNC);
318 if (!data.WriteInterfaceToken(GetDescriptor())) {
319 WLOGFE("WriteInterfaceToken failed");
320 return WMError::WM_ERROR_IPC_FAILED;
321 }
322 if (!data.WriteBool(isActive)) {
323 WLOGFE("Write Focus failed");
324 return WMError::WM_ERROR_IPC_FAILED;
325 }
326
327 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_ACTIVE_STATUS),
328 data, reply, option) != ERR_NONE) {
329 WLOGFE("SendRequest failed");
330 return WMError::WM_ERROR_IPC_FAILED;
331 }
332 return WMError::WM_OK;
333 }
334
GetWindowProperty()335 sptr<WindowProperty> WindowProxy::GetWindowProperty()
336 {
337 MessageParcel data;
338 MessageParcel reply;
339 MessageOption option;
340 if (!data.WriteInterfaceToken(GetDescriptor())) {
341 WLOGFE("WriteInterfaceToken failed");
342 return nullptr;
343 }
344 uint32_t requestCode = static_cast<uint32_t>(WindowMessage::TRANS_ID_GET_WINDOW_PROPERTY);
345 if (Remote()->SendRequest(requestCode, data, reply, option) != ERR_NONE) {
346 WLOGFE("SendRequest failed");
347 return nullptr;
348 }
349 sptr<WindowProperty> property = reply.ReadParcelable<WindowProperty>();
350 return property;
351 }
352
NotifyTouchOutside()353 WMError WindowProxy::NotifyTouchOutside()
354 {
355 MessageParcel data;
356 MessageParcel reply;
357 MessageOption option(MessageOption::TF_ASYNC);
358 if (!data.WriteInterfaceToken(GetDescriptor())) {
359 WLOGFE("WriteInterfaceToken failed");
360 return WMError::WM_ERROR_IPC_FAILED;
361 }
362
363 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_OUTSIDE_PRESSED),
364 data, reply, option) != ERR_NONE) {
365 WLOGFE("SendRequest failed");
366 return WMError::WM_ERROR_IPC_FAILED;
367 }
368 return WMError::WM_OK;
369 }
370
NotifyScreenshot()371 WMError WindowProxy::NotifyScreenshot()
372 {
373 MessageParcel data;
374 MessageParcel reply;
375 MessageOption option(MessageOption::TF_ASYNC);
376 if (!data.WriteInterfaceToken(GetDescriptor())) {
377 WLOGFE("WriteInterfaceToken failed");
378 return WMError::WM_ERROR_IPC_FAILED;
379 }
380
381 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_SCREEN_SHOT),
382 data, reply, option) != ERR_NONE) {
383 WLOGFE("SendRequest failed");
384 return WMError::WM_ERROR_IPC_FAILED;
385 }
386 return WMError::WM_OK;
387 }
388
DumpInfo(const std::vector<std::string> & params)389 WMError WindowProxy::DumpInfo(const std::vector<std::string>& params)
390 {
391 MessageParcel data;
392 MessageParcel reply;
393 MessageOption option(MessageOption::TF_ASYNC);
394 if (!data.WriteInterfaceToken(GetDescriptor())) {
395 WLOGFE("WriteInterfaceToken failed");
396 return WMError::WM_ERROR_IPC_FAILED;
397 }
398 if (!data.WriteStringVector(params)) {
399 WLOGFE("Write params failed");
400 return WMError::WM_ERROR_IPC_FAILED;
401 }
402 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_DUMP_INFO),
403 data, reply, option) != ERR_NONE) {
404 WLOGFE("SendRequest failed");
405 return WMError::WM_ERROR_IPC_FAILED;
406 }
407 return WMError::WM_OK;
408 }
409
UpdateZoomTransform(const Transform & trans,bool isDisplayZoomOn)410 WMError WindowProxy::UpdateZoomTransform(const Transform& trans, bool isDisplayZoomOn)
411 {
412 MessageParcel data;
413 MessageParcel reply;
414 MessageOption option;
415 if (!data.WriteInterfaceToken(GetDescriptor())) {
416 WLOGFE("WriteInterfaceToken failed");
417 return WMError::WM_ERROR_IPC_FAILED;
418 }
419 if (!trans.Marshalling(data)) {
420 WLOGFE("Write params failed");
421 return WMError::WM_ERROR_IPC_FAILED;
422 }
423 if (!data.WriteBool(isDisplayZoomOn)) {
424 WLOGFE("Write params failed");
425 return WMError::WM_ERROR_IPC_FAILED;
426 }
427 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_ZOOM_TRANSFORM),
428 data, reply, option) != ERR_NONE) {
429 WLOGFE("SendRequest failed");
430 return WMError::WM_ERROR_IPC_FAILED;
431 }
432 return WMError::WM_OK;
433 }
434
NotifyDestroy(void)435 WMError WindowProxy::NotifyDestroy(void)
436 {
437 MessageParcel data;
438 MessageParcel replay;
439 MessageOption option(MessageOption::TF_ASYNC);
440 if (!data.WriteInterfaceToken(GetDescriptor())) {
441 WLOGFE("WriteInterfaceToken failed");
442 return WMError::WM_ERROR_IPC_FAILED;
443 }
444
445 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_DESTROY),
446 data, replay, option) != ERR_NONE) {
447 WLOGFE("SendRequest failed");
448 return WMError::WM_ERROR_IPC_FAILED;
449 }
450 return WMError::WM_OK;
451 }
452
NotifyForeground(void)453 WMError WindowProxy::NotifyForeground(void)
454 {
455 MessageParcel data;
456 MessageParcel replay;
457 MessageOption option(MessageOption::TF_ASYNC);
458 if (!data.WriteInterfaceToken(GetDescriptor())) {
459 WLOGFE("WriteInterfaceToken failed");
460 return WMError::WM_ERROR_IPC_FAILED;
461 }
462
463 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_FOREGROUND),
464 data, replay, option) != ERR_NONE) {
465 WLOGFE("SendRequest failed");
466 return WMError::WM_ERROR_IPC_FAILED;
467 }
468 return WMError::WM_OK;
469 }
470
NotifyBackground(void)471 WMError WindowProxy::NotifyBackground(void)
472 {
473 MessageParcel data;
474 MessageParcel replay;
475 MessageOption option(MessageOption::TF_ASYNC);
476 if (!data.WriteInterfaceToken(GetDescriptor())) {
477 WLOGFE("WriteInterfaceToken failed");
478 return WMError::WM_ERROR_IPC_FAILED;
479 }
480
481 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_BACKGROUND),
482 data, replay, option) != ERR_NONE) {
483 WLOGFE("SendRequest failed");
484 return WMError::WM_ERROR_IPC_FAILED;
485 }
486 return WMError::WM_OK;
487 }
488
NotifyWindowClientPointUp(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)489 WMError WindowProxy::NotifyWindowClientPointUp(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
490 {
491 if (!pointerEvent) {
492 WLOGFE("pointerEvent is nullptr");
493 return WMError::WM_ERROR_NULLPTR;
494 }
495 MessageParcel data;
496 MessageParcel reply;
497 MessageOption option(MessageOption::TF_ASYNC);
498 if (!data.WriteInterfaceToken(GetDescriptor())) {
499 WLOGFE("WriteInterfaceToken failed");
500 return WMError::WM_ERROR_IPC_FAILED;
501 }
502 if (!pointerEvent->WriteToParcel(data)) {
503 WLOGFE("Failed to write point event");
504 return WMError::WM_ERROR_IPC_FAILED;
505 }
506 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_CLIENT_POINT_UP),
507 data, reply, option) != ERR_NONE) {
508 WLOGFE("SendRequest failed");
509 return WMError::WM_ERROR_IPC_FAILED;
510 }
511 return WMError::WM_OK;
512 }
513
RestoreSplitWindowMode(uint32_t mode)514 WMError WindowProxy::RestoreSplitWindowMode(uint32_t mode)
515 {
516 MessageParcel data;
517 MessageParcel reply;
518 MessageOption option(MessageOption::TF_ASYNC);
519 if (!data.WriteInterfaceToken(GetDescriptor())) {
520 WLOGFE("WriteInterfaceToken failed");
521 return WMError::WM_ERROR_IPC_FAILED;
522 }
523 if (!data.WriteUint32(mode)) {
524 WLOGFE("mode failed");
525 return WMError::WM_ERROR_IPC_FAILED;
526 }
527 uint32_t requestCode = static_cast<uint32_t>(WindowMessage::TRANS_ID_RESTORE_SPLIT_WINDOW_MODE);
528 if (Remote()->SendRequest(requestCode, data, reply, option) != ERR_NONE) {
529 WLOGFE("SendRequest failed");
530 return WMError::WM_ERROR_IPC_FAILED;
531 }
532 return WMError::WM_OK;
533 }
534
ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent> event)535 void WindowProxy::ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent> event)
536 {
537 MessageParcel data;
538 MessageParcel reply;
539 MessageOption option(MessageOption::TF_ASYNC);
540 if (!data.WriteInterfaceToken(GetDescriptor())) {
541 WLOGFE("WriteInterfaceToken failed");
542 return;
543 }
544 if (!event->WriteToParcel(data)) {
545 WLOGFE("Write point event failed");
546 return;
547 }
548 if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_CONSUME_KEY_EVENT),
549 data, reply, option) != ERR_NONE) {
550 WLOGFE("SendRequest failed");
551 return;
552 }
553 }
554 } // namespace Rosen
555 } // namespace OHOS
556
557