• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "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     }
65 
66     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_WINDOW_RECT),
67         data, reply, option) != ERR_NONE) {
68         WLOGFE("SendRequest failed");
69         return WMError::WM_ERROR_IPC_FAILED;
70     }
71     return WMError::WM_OK;
72 }
73 
UpdateWindowMode(WindowMode mode)74 WMError WindowProxy::UpdateWindowMode(WindowMode mode)
75 {
76     MessageParcel data;
77     MessageParcel reply;
78     MessageOption option(MessageOption::TF_ASYNC);
79     if (!data.WriteInterfaceToken(GetDescriptor())) {
80         WLOGFE("WriteInterfaceToken failed");
81         return WMError::WM_ERROR_IPC_FAILED;
82     }
83     if (!data.WriteUint32(static_cast<uint32_t>(mode))) {
84         WLOGFE("Write WindowMode failed");
85         return WMError::WM_ERROR_IPC_FAILED;
86     }
87 
88     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_WINDOW_MODE),
89         data, reply, option) != ERR_NONE) {
90         WLOGFE("SendRequest failed");
91         return WMError::WM_ERROR_IPC_FAILED;
92     }
93     return WMError::WM_OK;
94 }
95 
UpdateWindowModeSupportInfo(uint32_t modeSupportInfo)96 WMError WindowProxy::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo)
97 {
98     MessageParcel data;
99     MessageParcel reply;
100     MessageOption option(MessageOption::TF_ASYNC);
101     if (!data.WriteInterfaceToken(GetDescriptor())) {
102         WLOGFE("WriteInterfaceToken failed");
103         return WMError::WM_ERROR_IPC_FAILED;
104     }
105     if (!data.WriteUint32(modeSupportInfo)) {
106         WLOGFE("Write WindowMode failed");
107         return WMError::WM_ERROR_IPC_FAILED;
108     }
109 
110     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO),
111         data, reply, option) != ERR_NONE) {
112         WLOGFE("SendRequest failed");
113         return WMError::WM_ERROR_IPC_FAILED;
114     }
115     return WMError::WM_OK;
116 }
117 
UpdateFocusStatus(bool focused)118 WMError WindowProxy::UpdateFocusStatus(bool focused)
119 {
120     MessageParcel data;
121     MessageParcel reply;
122     MessageOption option(MessageOption::TF_ASYNC);
123     if (!data.WriteInterfaceToken(GetDescriptor())) {
124         WLOGFE("WriteInterfaceToken failed");
125         return WMError::WM_ERROR_IPC_FAILED;
126     }
127     if (!data.WriteBool(focused)) {
128         WLOGFE("Write Focus failed");
129         return WMError::WM_ERROR_IPC_FAILED;
130     }
131 
132     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS),
133         data, reply, option) != ERR_NONE) {
134         WLOGFE("SendRequest failed");
135         return WMError::WM_ERROR_IPC_FAILED;
136     }
137     return WMError::WM_OK;
138 }
139 
UpdateAvoidArea(const sptr<AvoidArea> & avoidArea,AvoidAreaType type)140 WMError WindowProxy::UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)
141 {
142     MessageParcel data;
143     MessageParcel reply;
144     MessageOption option(MessageOption::TF_ASYNC);
145     if (!data.WriteInterfaceToken(GetDescriptor())) {
146         WLOGFE("WriteInterfaceToken failed");
147         return WMError::WM_ERROR_IPC_FAILED;
148     }
149     if (!data.WriteStrongParcelable(avoidArea)) {
150         WLOGFE("Write WindowRect failed");
151         return WMError::WM_ERROR_IPC_FAILED;
152     }
153     if (!data.WriteUint32(static_cast<uint32_t>(type))) {
154         WLOGFE("Write AvoidAreaType failed");
155         return WMError::WM_ERROR_IPC_FAILED;
156     }
157     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_AVOID_AREA),
158         data, reply, option) != ERR_NONE) {
159         WLOGFE("SendRequest failed");
160         return WMError::WM_ERROR_IPC_FAILED;
161     }
162     return WMError::WM_OK;
163 }
164 
UpdateWindowState(WindowState state)165 WMError WindowProxy::UpdateWindowState(WindowState state)
166 {
167     MessageParcel data;
168     MessageParcel reply;
169     MessageOption option(MessageOption::TF_ASYNC);
170     if (!data.WriteInterfaceToken(GetDescriptor())) {
171         WLOGFE("WriteInterfaceToken failed");
172         return WMError::WM_ERROR_IPC_FAILED;
173     }
174 
175     if (!data.WriteUint32(static_cast<uint32_t>(state))) {
176         WLOGFE("Write isStopped");
177         return WMError::WM_ERROR_IPC_FAILED;
178     }
179     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_WINDOW_STATE),
180         data, reply, option) != ERR_NONE) {
181         WLOGFE("SendRequest failed");
182         return WMError::WM_ERROR_IPC_FAILED;
183     }
184     return WMError::WM_OK;
185 }
186 
UpdateWindowDragInfo(const PointInfo & point,DragEvent event)187 WMError WindowProxy::UpdateWindowDragInfo(const PointInfo& point, DragEvent event)
188 {
189     MessageParcel data;
190     MessageParcel reply;
191     MessageOption option(MessageOption::TF_ASYNC);
192     if (!data.WriteInterfaceToken(GetDescriptor())) {
193         WLOGFE("WriteInterfaceToken failed");
194         return WMError::WM_ERROR_IPC_FAILED;
195     }
196     if (!(data.WriteInt32(point.x) and data.WriteInt32(point.y))) {
197         WLOGFE("Write pos failed");
198         return WMError::WM_ERROR_IPC_FAILED;
199     }
200     if (!data.WriteInt32(static_cast<uint32_t>(event))) {
201         WLOGFE("Write event failed");
202         return WMError::WM_ERROR_IPC_FAILED;
203     }
204 
205     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_DRAG_EVENT),
206         data, reply, option) != ERR_NONE) {
207         WLOGFE("SendRequest TRANS_ID_UPDATE_DRAG_EVENT failed");
208         return WMError::WM_ERROR_IPC_FAILED;
209     }
210     return WMError::WM_OK;
211 }
212 
UpdateDisplayId(DisplayId from,DisplayId to)213 WMError WindowProxy::UpdateDisplayId(DisplayId from, DisplayId to)
214 {
215     MessageParcel data;
216     MessageParcel reply;
217     MessageOption option(MessageOption::TF_ASYNC);
218     if (!data.WriteInterfaceToken(GetDescriptor())) {
219         WLOGFE("WriteInterfaceToken failed");
220         return WMError::WM_ERROR_IPC_FAILED;
221     }
222     if (!(data.WriteUint64(from) and data.WriteUint64(to))) {
223         WLOGFE("Write displayid failed");
224         return WMError::WM_ERROR_IPC_FAILED;
225     }
226     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_DISPLAY_ID),
227         data, reply, option) != ERR_NONE) {
228         WLOGFE("SendRequest TRANS_ID_UPDATE_DISPLAY_ID failed");
229         return WMError::WM_ERROR_IPC_FAILED;
230     }
231     return WMError::WM_OK;
232 }
233 
UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo> & info,const std::shared_ptr<RSTransaction> & rsTransaction)234 WMError WindowProxy::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info,
235     const std::shared_ptr<RSTransaction>& rsTransaction)
236 {
237     MessageParcel data;
238     MessageParcel reply;
239     MessageOption option(MessageOption::TF_ASYNC);
240     if (!data.WriteInterfaceToken(GetDescriptor())) {
241         WLOGFE("WriteInterfaceToken failed");
242         return WMError::WM_ERROR_IPC_FAILED;
243     }
244     if (!data.WriteParcelable(info)) {
245         WLOGFE("Write OccupiedAreaChangeInfo failed");
246         return WMError::WM_ERROR_IPC_FAILED;
247     }
248 
249     bool hasRSTransaction = rsTransaction != nullptr;
250     if (!data.WriteBool(hasRSTransaction)) {
251         WLOGFE("Write transaction sync Id failed");
252         return WMError::WM_ERROR_IPC_FAILED;
253     }
254     if (hasRSTransaction) {
255         if (!data.WriteParcelable(rsTransaction.get())) {
256             WLOGFE("Write transaction sync Id failed");
257             return WMError::WM_ERROR_IPC_FAILED;
258         }
259     }
260 
261     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA),
262         data, reply, option) != ERR_NONE) {
263         WLOGFE("SendRequest failed");
264         return WMError::WM_ERROR_IPC_FAILED;
265     }
266     return WMError::WM_OK;
267 }
268 
UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo> & info,const Rect & rect,const std::shared_ptr<RSTransaction> & rsTransaction)269 WMError WindowProxy::UpdateOccupiedAreaAndRect(const sptr<OccupiedAreaChangeInfo>& info, const Rect& rect,
270     const std::shared_ptr<RSTransaction>& rsTransaction)
271 {
272     MessageParcel data;
273     MessageParcel reply;
274     MessageOption option(MessageOption::TF_ASYNC);
275     if (!data.WriteInterfaceToken(GetDescriptor())) {
276         WLOGFE("WriteInterfaceToken failed");
277         return WMError::WM_ERROR_IPC_FAILED;
278     }
279     if (!data.WriteParcelable(info)) {
280         WLOGFE("Write OccupiedAreaChangeInfo failed");
281         return WMError::WM_ERROR_IPC_FAILED;
282     }
283 
284     if (!(data.WriteInt32(rect.posX_) && data.WriteInt32(rect.posY_) &&
285         data.WriteUint32(rect.width_) && data.WriteUint32(rect.height_))) {
286         WLOGFE("Write WindowRect failed");
287         return WMError::WM_ERROR_IPC_FAILED;
288     }
289 
290     bool hasRSTransaction = rsTransaction != nullptr;
291     if (!data.WriteBool(hasRSTransaction)) {
292         WLOGFE("Write transaction sync Id failed");
293         return WMError::WM_ERROR_IPC_FAILED;
294     }
295     if (hasRSTransaction) {
296         if (!data.WriteParcelable(rsTransaction.get())) {
297             WLOGFE("Write transaction sync Id failed");
298             return WMError::WM_ERROR_IPC_FAILED;
299         }
300     }
301 
302     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA_AND_RECT),
303         data, reply, option) != ERR_NONE) {
304         WLOGFE("SendRequest failed");
305         return WMError::WM_ERROR_IPC_FAILED;
306     }
307     return WMError::WM_OK;
308 }
309 
UpdateActiveStatus(bool isActive)310 WMError WindowProxy::UpdateActiveStatus(bool isActive)
311 {
312     MessageParcel data;
313     MessageParcel reply;
314     MessageOption option(MessageOption::TF_ASYNC);
315     if (!data.WriteInterfaceToken(GetDescriptor())) {
316         WLOGFE("WriteInterfaceToken failed");
317         return WMError::WM_ERROR_IPC_FAILED;
318     }
319     if (!data.WriteBool(isActive)) {
320         WLOGFE("Write Focus failed");
321         return WMError::WM_ERROR_IPC_FAILED;
322     }
323 
324     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_ACTIVE_STATUS),
325         data, reply, option) != ERR_NONE) {
326         WLOGFE("SendRequest failed");
327         return WMError::WM_ERROR_IPC_FAILED;
328     }
329     return WMError::WM_OK;
330 }
331 
GetWindowProperty()332 sptr<WindowProperty> WindowProxy::GetWindowProperty()
333 {
334     MessageParcel data;
335     MessageParcel reply;
336     MessageOption option;
337     if (!data.WriteInterfaceToken(GetDescriptor())) {
338         WLOGFE("WriteInterfaceToken failed");
339         return nullptr;
340     }
341     uint32_t requestCode = static_cast<uint32_t>(WindowMessage::TRANS_ID_GET_WINDOW_PROPERTY);
342     if (Remote()->SendRequest(requestCode, data, reply, option) != ERR_NONE) {
343         WLOGFE("SendRequest failed");
344         return nullptr;
345     }
346     sptr<WindowProperty> property = reply.ReadParcelable<WindowProperty>();
347     return property;
348 }
349 
NotifyTouchOutside()350 WMError WindowProxy::NotifyTouchOutside()
351 {
352     MessageParcel data;
353     MessageParcel reply;
354     MessageOption option(MessageOption::TF_ASYNC);
355     if (!data.WriteInterfaceToken(GetDescriptor())) {
356         WLOGFE("WriteInterfaceToken failed");
357         return WMError::WM_ERROR_IPC_FAILED;
358     }
359 
360     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_OUTSIDE_PRESSED),
361         data, reply, option) != ERR_NONE) {
362         WLOGFE("SendRequest failed");
363         return WMError::WM_ERROR_IPC_FAILED;
364     }
365     return WMError::WM_OK;
366 }
367 
NotifyScreenshot()368 WMError WindowProxy::NotifyScreenshot()
369 {
370     MessageParcel data;
371     MessageParcel reply;
372     MessageOption option(MessageOption::TF_ASYNC);
373     if (!data.WriteInterfaceToken(GetDescriptor())) {
374         WLOGFE("WriteInterfaceToken failed");
375         return WMError::WM_ERROR_IPC_FAILED;
376     }
377 
378     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_SCREEN_SHOT),
379         data, reply, option) != ERR_NONE) {
380         WLOGFE("SendRequest failed");
381         return WMError::WM_ERROR_IPC_FAILED;
382     }
383     return WMError::WM_OK;
384 }
385 
DumpInfo(const std::vector<std::string> & params)386 WMError WindowProxy::DumpInfo(const std::vector<std::string>& params)
387 {
388     MessageParcel data;
389     MessageParcel reply;
390     MessageOption option(MessageOption::TF_ASYNC);
391     if (!data.WriteInterfaceToken(GetDescriptor())) {
392         WLOGFE("WriteInterfaceToken failed");
393         return WMError::WM_ERROR_IPC_FAILED;
394     }
395     if (!data.WriteStringVector(params)) {
396         WLOGFE("Write params failed");
397         return WMError::WM_ERROR_IPC_FAILED;
398     }
399     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_DUMP_INFO),
400         data, reply, option) != ERR_NONE) {
401         WLOGFE("SendRequest failed");
402         return WMError::WM_ERROR_IPC_FAILED;
403     }
404     return WMError::WM_OK;
405 }
406 
UpdateZoomTransform(const Transform & trans,bool isDisplayZoomOn)407 WMError WindowProxy::UpdateZoomTransform(const Transform& trans, bool isDisplayZoomOn)
408 {
409     MessageParcel data;
410     MessageParcel reply;
411     MessageOption option;
412     if (!data.WriteInterfaceToken(GetDescriptor())) {
413         WLOGFE("WriteInterfaceToken failed");
414         return WMError::WM_ERROR_IPC_FAILED;
415     }
416     if (!trans.Marshalling(data)) {
417         WLOGFE("Write params failed");
418         return WMError::WM_ERROR_IPC_FAILED;
419     }
420     if (!data.WriteBool(isDisplayZoomOn)) {
421         WLOGFE("Write params failed");
422         return WMError::WM_ERROR_IPC_FAILED;
423     }
424     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_ZOOM_TRANSFORM),
425         data, reply, option) != ERR_NONE) {
426         WLOGFE("SendRequest failed");
427         return WMError::WM_ERROR_IPC_FAILED;
428     }
429     return WMError::WM_OK;
430 }
431 
NotifyDestroy(void)432 WMError WindowProxy::NotifyDestroy(void)
433 {
434     MessageParcel data;
435     MessageParcel replay;
436     MessageOption option(MessageOption::TF_ASYNC);
437     if (!data.WriteInterfaceToken(GetDescriptor())) {
438         WLOGFE("WriteInterfaceToken failed");
439         return WMError::WM_ERROR_IPC_FAILED;
440     }
441 
442     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_DESTROY),
443         data, replay, option) != ERR_NONE) {
444         WLOGFE("SendRequest failed");
445         return WMError::WM_ERROR_IPC_FAILED;
446     }
447     return WMError::WM_OK;
448 }
449 
NotifyForeground(void)450 WMError WindowProxy::NotifyForeground(void)
451 {
452     MessageParcel data;
453     MessageParcel replay;
454     MessageOption option(MessageOption::TF_ASYNC);
455     if (!data.WriteInterfaceToken(GetDescriptor())) {
456         WLOGFE("WriteInterfaceToken failed");
457         return WMError::WM_ERROR_IPC_FAILED;
458     }
459 
460     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_FOREGROUND),
461         data, replay, option) != ERR_NONE) {
462         WLOGFE("SendRequest failed");
463         return WMError::WM_ERROR_IPC_FAILED;
464     }
465     return WMError::WM_OK;
466 }
467 
NotifyBackground(void)468 WMError WindowProxy::NotifyBackground(void)
469 {
470     MessageParcel data;
471     MessageParcel replay;
472     MessageOption option(MessageOption::TF_ASYNC);
473     if (!data.WriteInterfaceToken(GetDescriptor())) {
474         WLOGFE("WriteInterfaceToken failed");
475         return WMError::WM_ERROR_IPC_FAILED;
476     }
477 
478     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_BACKGROUND),
479         data, replay, option) != ERR_NONE) {
480         WLOGFE("SendRequest failed");
481         return WMError::WM_ERROR_IPC_FAILED;
482     }
483     return WMError::WM_OK;
484 }
485 
NotifyWindowClientPointUp(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)486 WMError WindowProxy::NotifyWindowClientPointUp(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
487 {
488     if (!pointerEvent) {
489         WLOGFE("pointerEvent is nullptr");
490         return WMError::WM_ERROR_NULLPTR;
491     }
492     MessageParcel data;
493     MessageParcel reply;
494     MessageOption option(MessageOption::TF_ASYNC);
495     if (!data.WriteInterfaceToken(GetDescriptor())) {
496         WLOGFE("WriteInterfaceToken failed");
497         return WMError::WM_ERROR_IPC_FAILED;
498     }
499     if (!pointerEvent->WriteToParcel(data)) {
500         WLOGFE("Failed to write point event");
501         return WMError::WM_ERROR_IPC_FAILED;
502     }
503     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_CLIENT_POINT_UP),
504         data, reply, option) != ERR_NONE) {
505         WLOGFE("SendRequest failed");
506         return WMError::WM_ERROR_IPC_FAILED;
507     }
508     return WMError::WM_OK;
509 }
510 
RestoreSplitWindowMode(uint32_t mode)511 WMError WindowProxy::RestoreSplitWindowMode(uint32_t mode)
512 {
513     MessageParcel data;
514     MessageParcel reply;
515     MessageOption option(MessageOption::TF_ASYNC);
516     if (!data.WriteInterfaceToken(GetDescriptor())) {
517         WLOGFE("WriteInterfaceToken failed");
518         return WMError::WM_ERROR_IPC_FAILED;
519     }
520     if (!data.WriteUint32(mode)) {
521         WLOGFE("mode failed");
522         return WMError::WM_ERROR_IPC_FAILED;
523     }
524     uint32_t requestCode = static_cast<uint32_t>(WindowMessage::TRANS_ID_RESTORE_SPLIT_WINDOW_MODE);
525     if (Remote()->SendRequest(requestCode, data, reply, option) != ERR_NONE) {
526         WLOGFE("SendRequest failed");
527         return WMError::WM_ERROR_IPC_FAILED;
528     }
529     return WMError::WM_OK;
530 }
531 
ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent> event)532 void WindowProxy::ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent> event)
533 {
534     MessageParcel data;
535     MessageParcel reply;
536     MessageOption option(MessageOption::TF_ASYNC);
537     if (!data.WriteInterfaceToken(GetDescriptor())) {
538         WLOGFE("WriteInterfaceToken failed");
539         return;
540     }
541     if (!event->WriteToParcel(data)) {
542         WLOGFE("Write point event failed");
543         return;
544     }
545     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_CONSUME_KEY_EVENT),
546         data, reply, option) != ERR_NONE) {
547         WLOGFE("SendRequest failed");
548         return;
549     }
550 }
551 
NotifyForegroundInteractiveStatus(bool interactive)552 void WindowProxy::NotifyForegroundInteractiveStatus(bool interactive)
553 {
554     MessageParcel data;
555     MessageParcel reply;
556     MessageOption option(MessageOption::TF_ASYNC);
557     if (!data.WriteInterfaceToken(GetDescriptor())) {
558         WLOGFE("WriteInterfaceToken failed");
559         return;
560     }
561     if (!data.WriteBool(interactive)) {
562         WLOGFE("Write Focus failed");
563         return;
564     }
565 
566     if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS),
567         data, reply, option) != ERR_NONE) {
568         WLOGFE("SendRequest failed");
569     }
570 }
571 
572 } // namespace Rosen
573 } // namespace OHOS
574 
575