1 /*
2 * Copyright (c) 2021 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_manager_agent_proxy.h"
17 #include <ipc_types.h>
18 #include "marshalling_helper.h"
19 #include "window_manager_hilog.h"
20 #include "wm_common.h"
21
22 namespace OHOS {
23 namespace Rosen {
24 namespace {
25 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowManagerAgentProxy"};
26 }
27
UpdateFocusChangeInfo(const sptr<FocusChangeInfo> & focusChangeInfo,bool focused)28 void WindowManagerAgentProxy::UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused)
29 {
30 MessageParcel data;
31 if (focusChangeInfo == nullptr) {
32 WLOGFE("Invalid focus change info");
33 return;
34 }
35
36 if (!data.WriteInterfaceToken(GetDescriptor())) {
37 WLOGFE("WriteInterfaceToken failed");
38 return;
39 }
40
41 if (!data.WriteParcelable(focusChangeInfo)) {
42 WLOGFE("Write displayId failed");
43 return;
44 }
45
46 if (!data.WriteBool(focused)) {
47 WLOGFE("Write Focus failed");
48 return;
49 }
50 MessageParcel reply;
51 MessageOption option(MessageOption::TF_ASYNC);
52 sptr<IRemoteObject> remote = Remote();
53 if (remote == nullptr) {
54 WLOGFE("remote is null");
55 return;
56 }
57 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_FOCUS),
58 data, reply, option) != ERR_NONE) {
59 WLOGFE("SendRequest failed");
60 }
61 }
62
UpdateWindowModeTypeInfo(WindowModeType type)63 void WindowManagerAgentProxy::UpdateWindowModeTypeInfo(WindowModeType type)
64 {
65 MessageParcel data;
66
67 if (!data.WriteInterfaceToken(GetDescriptor())) {
68 TLOGE(WmsLogTag::WMS_MAIN, "WriteInterfaceToken failed");
69 return;
70 }
71
72 if (!data.WriteUint8(static_cast<uint8_t>(type))) {
73 TLOGE(WmsLogTag::WMS_MAIN, "Write displayId failed");
74 return;
75 }
76
77 MessageParcel reply;
78 MessageOption option(MessageOption::TF_ASYNC);
79 sptr<IRemoteObject> remote = Remote();
80 if (remote == nullptr) {
81 WLOGFE("remote is null");
82 return;
83 }
84 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE),
85 data, reply, option) != ERR_NONE) {
86 TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed");
87 }
88 }
89
UpdateSystemBarRegionTints(DisplayId displayId,const SystemBarRegionTints & tints)90 void WindowManagerAgentProxy::UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints)
91 {
92 MessageParcel data;
93 if (!data.WriteInterfaceToken(GetDescriptor())) {
94 WLOGFE("WriteInterfaceToken failed");
95 return;
96 }
97
98 if (!data.WriteUint64(displayId)) {
99 WLOGFE("Write displayId failed");
100 return;
101 }
102 bool res = MarshallingHelper::MarshallingVectorObj<SystemBarRegionTint>(data, tints,
103 [](Parcel& parcel, const SystemBarRegionTint& tint) {
104 return parcel.WriteUint32(static_cast<uint32_t>(tint.type_)) && parcel.WriteBool(tint.prop_.enable_) &&
105 parcel.WriteUint32(tint.prop_.backgroundColor_) && parcel.WriteUint32(tint.prop_.contentColor_) &&
106 parcel.WriteInt32(tint.region_.posX_) && parcel.WriteInt32(tint.region_.posY_) &&
107 parcel.WriteInt32(tint.region_.width_) && parcel.WriteInt32(tint.region_.height_);
108 }
109 );
110 if (!res) {
111 WLOGFE("Write SystemBarRegionTint failed");
112 return;
113 }
114 MessageParcel reply;
115 MessageOption option(MessageOption::TF_ASYNC);
116 sptr<IRemoteObject> remote = Remote();
117 if (remote == nullptr) {
118 WLOGFE("remote is null");
119 return;
120 }
121 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_SYSTEM_BAR_PROPS),
122 data, reply, option) != ERR_NONE) {
123 WLOGFE("SendRequest failed");
124 }
125 }
126
NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>> & infos,WindowUpdateType type)127 void WindowManagerAgentProxy::NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>>& infos,
128 WindowUpdateType type)
129 {
130 MessageParcel data;
131 if (!data.WriteInterfaceToken(GetDescriptor())) {
132 WLOGFE("WriteInterfaceToken failed");
133 return;
134 }
135
136 if (!MarshallingHelper::MarshallingVectorParcelableObj<AccessibilityWindowInfo>(data, infos)) {
137 WLOGFE("Write accessibility window infos failed");
138 return;
139 }
140
141 if (!data.WriteInt32(static_cast<int32_t>(type))) {
142 WLOGFE("Write windowUpdateType failed");
143 return;
144 }
145 MessageParcel reply;
146 MessageOption option(MessageOption::TF_ASYNC);
147 sptr<IRemoteObject> remote = Remote();
148 if (remote == nullptr) {
149 WLOGFE("remote is null");
150 return;
151 }
152 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_STATUS),
153 data, reply, option) != ERR_NONE) {
154 WLOGFE("SendRequest failed");
155 }
156 }
157
NotifyWindowSystemBarPropertyChange(WindowType type,const SystemBarProperty & systemBarProperty)158 void WindowManagerAgentProxy::NotifyWindowSystemBarPropertyChange(
159 WindowType type, const SystemBarProperty& systemBarProperty)
160 {
161 MessageParcel data;
162 if (!data.WriteInterfaceToken(GetDescriptor())) {
163 TLOGE(WmsLogTag::WMS_IMMS, "WriteInterfaceToken failed");
164 return;
165 }
166 if (!data.WriteInt32(static_cast<int32_t>(type))) {
167 TLOGE(WmsLogTag::WMS_IMMS, "Write type failed");
168 return;
169 }
170 if (!data.WriteBool(systemBarProperty.enable_)) {
171 TLOGE(WmsLogTag::WMS_IMMS, "Write enable failed");
172 return;
173 }
174 if (!data.WriteUint32(systemBarProperty.backgroundColor_)) {
175 TLOGE(WmsLogTag::WMS_IMMS, "Write backgroundColor failed");
176 return;
177 }
178 if (!data.WriteUint32(systemBarProperty.contentColor_)) {
179 TLOGE(WmsLogTag::WMS_IMMS, "Write contentColor failed");
180 return;
181 }
182 if (!data.WriteBool(systemBarProperty.enableAnimation_)) {
183 TLOGE(WmsLogTag::WMS_IMMS, "Write enableAnimation failed");
184 return;
185 }
186 if (!data.WriteUint32(static_cast<uint32_t>(systemBarProperty.settingFlag_))) {
187 TLOGE(WmsLogTag::WMS_IMMS, "Write settingFlag failed");
188 return;
189 }
190 MessageParcel reply;
191 MessageOption option(MessageOption::TF_ASYNC);
192 sptr<IRemoteObject> remote = Remote();
193 if (remote == nullptr) {
194 TLOGE(WmsLogTag::WMS_IMMS, "remote is null");
195 return;
196 }
197 if (remote->SendRequest(static_cast<uint32_t>(
198 WindowManagerAgentMsg::TRANS_ID_NOTIFY_WINDOW_SYSTEM_BAR_PROPERTY_CHANGE), data, reply, option) != ERR_NONE) {
199 TLOGE(WmsLogTag::WMS_IMMS, "sendRequest failed");
200 }
201 }
202
UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>> & visibilityInfos)203 void WindowManagerAgentProxy::UpdateWindowVisibilityInfo(
204 const std::vector<sptr<WindowVisibilityInfo>>& visibilityInfos)
205 {
206 MessageParcel data;
207 if (!data.WriteInterfaceToken(GetDescriptor())) {
208 WLOGFE("WriteInterfaceToken failed");
209 return;
210 }
211 if (!data.WriteUint32(static_cast<uint32_t>(visibilityInfos.size()))) {
212 WLOGFE("write windowVisibilityInfos size failed");
213 return;
214 }
215 for (auto& info : visibilityInfos) {
216 if (!data.WriteParcelable(info)) {
217 WLOGFE("Write windowVisibilityInfo failed");
218 return;
219 }
220 }
221 MessageParcel reply;
222 MessageOption option(MessageOption::TF_ASYNC);
223 sptr<IRemoteObject> remote = Remote();
224 if (remote == nullptr) {
225 WLOGFE("remote is null");
226 return;
227 }
228 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_VISIBILITY),
229 data, reply, option) != ERR_NONE) {
230 WLOGFE("SendRequest failed");
231 }
232 }
233
UpdateWindowDrawingContentInfo(const std::vector<sptr<WindowDrawingContentInfo>> & windowDrawingContentInfos)234 void WindowManagerAgentProxy::UpdateWindowDrawingContentInfo(
235 const std::vector<sptr<WindowDrawingContentInfo>>& windowDrawingContentInfos)
236 {
237 MessageParcel data;
238 if (!data.WriteInterfaceToken(GetDescriptor())) {
239 WLOGFE("WriteInterfaceToken failed");
240 return;
241 }
242 if (!data.WriteUint32(static_cast<uint32_t>(windowDrawingContentInfos.size()))) {
243 WLOGFE("write windowDrawingContentInfos size failed");
244 return;
245 }
246 for (auto& info : windowDrawingContentInfos) {
247 if (!data.WriteParcelable(info)) {
248 WLOGFE("Write windowDrawingContentInfos failed");
249 return;
250 }
251 }
252 MessageParcel reply;
253 MessageOption option(MessageOption::TF_ASYNC);
254 sptr<IRemoteObject> remote = Remote();
255 if (remote == nullptr) {
256 WLOGFE("remote is null");
257 return;
258 }
259 if (remote->SendRequest(
260 static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_DRAWING_STATE), data, reply,
261 option) != ERR_NONE) {
262 WLOGFE("SendRequest failed");
263 }
264 }
265
UpdateCameraFloatWindowStatus(uint32_t accessTokenId,bool isShowing)266 void WindowManagerAgentProxy::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
267 {
268 MessageParcel data;
269 if (!data.WriteInterfaceToken(GetDescriptor())) {
270 WLOGFE("WriteInterfaceToken failed");
271 return;
272 }
273
274 if (!data.WriteUint32(accessTokenId)) {
275 WLOGFE("Write accessTokenId failed");
276 return;
277 }
278
279 if (!data.WriteBool(isShowing)) {
280 WLOGFE("Write is showing status failed");
281 return;
282 }
283 MessageParcel reply;
284 MessageOption option(MessageOption::TF_ASYNC);
285 sptr<IRemoteObject> remote = Remote();
286 if (remote == nullptr) {
287 WLOGFE("remote is null");
288 return;
289 }
290 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT),
291 data, reply, option) != ERR_NONE) {
292 WLOGFE("SendRequest failed");
293 }
294 }
295
NotifyWaterMarkFlagChangedResult(bool showWaterMark)296 void WindowManagerAgentProxy::NotifyWaterMarkFlagChangedResult(bool showWaterMark)
297 {
298 MessageParcel data;
299 if (!data.WriteInterfaceToken(GetDescriptor())) {
300 WLOGFE("WriteInterfaceToken failed");
301 return;
302 }
303
304 if (!data.WriteBool(showWaterMark)) {
305 WLOGFE("Write is showing status failed");
306 return;
307 }
308 MessageParcel reply;
309 MessageOption option(MessageOption::TF_ASYNC);
310 sptr<IRemoteObject> remote = Remote();
311 if (remote == nullptr) {
312 WLOGFE("remote is null");
313 return;
314 }
315 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_WATER_MARK_FLAG),
316 data, reply, option) != ERR_NONE) {
317 WLOGFE("SendRequest failed");
318 }
319 }
320
UpdateVisibleWindowNum(const std::vector<VisibleWindowNumInfo> & visibleWindowNumInfo)321 void WindowManagerAgentProxy::UpdateVisibleWindowNum(
322 const std::vector<VisibleWindowNumInfo>& visibleWindowNumInfo)
323 {
324 MessageParcel data;
325 if (!data.WriteInterfaceToken(GetDescriptor())) {
326 WLOGFE("WriteInterfaceToken failed");
327 return;
328 }
329
330 bool res = MarshallingHelper::MarshallingVectorObj<VisibleWindowNumInfo>(data, visibleWindowNumInfo,
331 [](Parcel& parcel, const VisibleWindowNumInfo& num) {
332 return parcel.WriteUint32(num.displayId) && parcel.WriteUint32(num.visibleWindowNum);
333 }
334 );
335 if (!res) {
336 WLOGFE("Write VisibleWindowNumInfo failed");
337 return;
338 }
339 MessageParcel reply;
340 MessageOption option(MessageOption::TF_ASYNC);
341 sptr<IRemoteObject> remote = Remote();
342 if (remote == nullptr) {
343 WLOGFE("remote is null");
344 return;
345 }
346 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_VISIBLE_WINDOW_NUM),
347 data, reply, option) != ERR_NONE) {
348 WLOGFE("SendRequest failed");
349 }
350 }
351
NotifyGestureNavigationEnabledResult(bool enable)352 void WindowManagerAgentProxy::NotifyGestureNavigationEnabledResult(bool enable)
353 {
354 MessageParcel data;
355 if (!data.WriteInterfaceToken(GetDescriptor())) {
356 WLOGFE("WriteInterfaceToken failed");
357 return;
358 }
359
360 if (!data.WriteBool(enable)) {
361 WLOGFE("Write is showing status failed");
362 return;
363 }
364 MessageParcel reply;
365 MessageOption option(MessageOption::TF_ASYNC);
366 sptr<IRemoteObject> remote = Remote();
367 if (remote == nullptr) {
368 WLOGFE("remote is null");
369 return;
370 }
371 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_GESTURE_NAVIGATION_ENABLED),
372 data, reply, option) != ERR_NONE) {
373 WLOGFE("SendRequest failed");
374 }
375 }
376
UpdateCameraWindowStatus(uint32_t accessTokenId,bool isShowing)377 void WindowManagerAgentProxy::UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing)
378 {
379 MessageParcel data;
380 if (!data.WriteInterfaceToken(GetDescriptor())) {
381 TLOGE(WmsLogTag::WMS_MAIN, "WriteInterfaceToken failed");
382 return;
383 }
384 if (!data.WriteUint32(accessTokenId)) {
385 TLOGE(WmsLogTag::WMS_MAIN, "Write accessTokenId failed");
386 return;
387 }
388 if (!data.WriteBool(isShowing)) {
389 TLOGE(WmsLogTag::WMS_MAIN, "Write isShowing status failed");
390 return;
391 }
392 MessageParcel reply;
393 MessageOption option(MessageOption::TF_ASYNC);
394 sptr<IRemoteObject> remote = Remote();
395 if (remote == nullptr) {
396 TLOGE(WmsLogTag::WMS_MAIN, "remote is null");
397 return;
398 }
399 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_WINDOW_STATUS),
400 data, reply, option) != ERR_NONE) {
401 TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed");
402 }
403 }
404
NotifyWindowStyleChange(WindowStyleType type)405 void WindowManagerAgentProxy::NotifyWindowStyleChange(WindowStyleType type)
406 {
407 MessageParcel data;
408 MessageParcel reply;
409 MessageOption option(MessageOption::TF_ASYNC);
410 if (!data.WriteInterfaceToken(GetDescriptor())) {
411 TLOGE(WmsLogTag::WMS_MAIN, "WriteInterfaceToken failed");
412 return;
413 }
414 if (!data.WriteUint8(static_cast<uint8_t>(type))) {
415 TLOGE(WmsLogTag::WMS_MAIN, "Write displayId failed");
416 return;
417 }
418 sptr<IRemoteObject> remote = Remote();
419 if (remote == nullptr) {
420 TLOGE(WmsLogTag::WMS_MAIN, "remote is null");
421 return;
422 }
423 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_STYLE_TYPE),
424 data, reply, option) != ERR_NONE) {
425 TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed");
426 }
427 }
428
NotifyCallingWindowDisplayChanged(const CallingWindowInfo & callingWindowInfo)429 void WindowManagerAgentProxy::NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo)
430 {
431 MessageParcel data;
432 MessageParcel reply;
433 MessageOption option(MessageOption::TF_ASYNC);
434 if (!data.WriteInterfaceToken(GetDescriptor())) {
435 TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
436 return;
437 }
438 if (!data.WriteParcelable(&callingWindowInfo)) {
439 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write callingWindowInfo failed");
440 return;
441 }
442
443 sptr<IRemoteObject> remote = Remote();
444 if (remote == nullptr) {
445 TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
446 return;
447 }
448 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_NOTIFY_CALLING_DISPLAY_CHANGE),
449 data, reply, option) != ERR_NONE) {
450 TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest calling display info change failed");
451 }
452 }
453
NotifyWindowPidVisibilityChanged(const sptr<WindowPidVisibilityInfo> & info)454 void WindowManagerAgentProxy::NotifyWindowPidVisibilityChanged(const sptr<WindowPidVisibilityInfo>& info)
455 {
456 MessageParcel data;
457 if (info == nullptr) {
458 TLOGE(WmsLogTag::WMS_LIFE, "Invalid window pid visibility info");
459 return;
460 }
461
462 if (!data.WriteInterfaceToken(GetDescriptor())) {
463 TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
464 return;
465 }
466
467 if (!data.WriteParcelable(info)) {
468 TLOGE(WmsLogTag::WMS_LIFE, "Write windowPidVisibilityInfo failed");
469 return;
470 }
471
472 MessageParcel reply;
473 MessageOption option(MessageOption::TF_ASYNC);
474 sptr<IRemoteObject> remote = Remote();
475 if (remote == nullptr) {
476 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
477 return;
478 }
479 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_NOTIFY_WINDOW_PID_VISIBILITY),
480 data, reply, option) != ERR_NONE) {
481 TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
482 }
483 }
484
UpdatePiPWindowStateChanged(const std::string & bundleName,bool isForeground)485 void WindowManagerAgentProxy::UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground)
486 {
487 MessageParcel data;
488 MessageParcel reply;
489 MessageOption option(MessageOption::TF_ASYNC);
490 if (!data.WriteInterfaceToken(GetDescriptor())) {
491 TLOGE(WmsLogTag::WMS_PIP, "WriteInterfaceToken failed");
492 return;
493 }
494 if (!data.WriteString(bundleName)) {
495 TLOGE(WmsLogTag::WMS_PIP, "Write bundleName failed");
496 return;
497 }
498 if (!data.WriteBool(isForeground)) {
499 TLOGE(WmsLogTag::WMS_PIP, "Write state failed");
500 return;
501 }
502 sptr<IRemoteObject> remote = Remote();
503 if (remote == nullptr) {
504 TLOGE(WmsLogTag::WMS_PIP, "remote is null");
505 return;
506 }
507 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_PIP_WINDOW_STATE_CHANGED),
508 data, reply, option) != ERR_NONE) {
509 TLOGE(WmsLogTag::WMS_PIP, "SendRequest failed");
510 }
511 }
512
NotifyWindowPropertyChange(uint32_t propertyDirtyFlags,const std::vector<std::unordered_map<WindowInfoKey,WindowChangeInfoType>> & windowInfoList)513 void WindowManagerAgentProxy::NotifyWindowPropertyChange(uint32_t propertyDirtyFlags,
514 const std::vector<std::unordered_map<WindowInfoKey, WindowChangeInfoType>>& windowInfoList)
515 {
516 MessageParcel data;
517 MessageParcel reply;
518 MessageOption option(MessageOption::TF_ASYNC);
519 if (!data.WriteInterfaceToken(GetDescriptor())) {
520 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
521 return;
522 }
523 if (!data.WriteUint32(propertyDirtyFlags)) {
524 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write propertyDirtyFlags failed");
525 return;
526 }
527 if (!data.WriteUint32(static_cast<uint32_t>(windowInfoList.size()))) {
528 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write windowInfoList failed");
529 return;
530 }
531
532 for (const auto& windowInfo : windowInfoList) {
533 if (!data.WriteUint32(static_cast<uint32_t>(windowInfo.size()))) {
534 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write windowInfo failed");
535 return;
536 }
537
538 for (const auto& pair : windowInfo) {
539 if (!WriteWindowChangeInfoValue(data, pair)) {
540 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write window change info value failed");
541 return;
542 }
543 }
544 }
545 sptr<IRemoteObject> remote = Remote();
546 if (remote == nullptr) {
547 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
548 return;
549 }
550 if (remote->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_NOTIFY_WINDOW_PROPERTY_CHANGE),
551 data, reply, option) != ERR_NONE) {
552 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
553 }
554 }
555
WriteWindowChangeInfoValue(MessageParcel & data,const std::pair<WindowInfoKey,WindowChangeInfoType> & windowInfoPair)556 bool WindowManagerAgentProxy::WriteWindowChangeInfoValue(MessageParcel& data,
557 const std::pair<WindowInfoKey, WindowChangeInfoType>& windowInfoPair)
558 {
559 if (!data.WriteInt32(static_cast<int32_t>(windowInfoPair.first))) {
560 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write windowInfoKey failed");
561 return false;
562 }
563 switch (windowInfoPair.first) {
564 case WindowInfoKey::WINDOW_ID: {
565 if (!data.WriteUint32(static_cast<uint32_t>(std::get<int32_t>(windowInfoPair.second)) )) {
566 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write uint32_t failed");
567 return false;
568 }
569 break;
570 }
571 case WindowInfoKey::BUNDLE_NAME :
572 case WindowInfoKey::ABILITY_NAME: {
573 if (!data.WriteString(std::get<std::string>(windowInfoPair.second))) {
574 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write string failed");
575 return false;
576 }
577 break;
578 }
579 case WindowInfoKey::APP_INDEX : {
580 if (!data.WriteInt32(std::get<int32_t>(windowInfoPair.second))) {
581 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write int32_t failed");
582 return false;
583 }
584 break;
585 }
586 case WindowInfoKey::VISIBILITY_STATE : {
587 if (!data.WriteUint32(static_cast<uint32_t>(std::get<WindowVisibilityState>(windowInfoPair.second)))) {
588 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write WindowVisibilityState failed");
589 return false;
590 }
591 break;
592 }
593 case WindowInfoKey::WINDOW_MODE : {
594 if (!data.WriteUint32(static_cast<uint32_t>(std::get<WindowMode>(windowInfoPair.second)))) {
595 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write WindowMode failed");
596 return false;
597 }
598 break;
599 }
600 case WindowInfoKey::DISPLAY_ID : {
601 if (!data.WriteUint64(std::get<uint64_t>(windowInfoPair.second))) {
602 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write uint64_t failed");
603 return false;
604 }
605 break;
606 }
607 case WindowInfoKey::WINDOW_RECT : {
608 Rect rect = std::get<Rect>(windowInfoPair.second);
609 if (!data.WriteInt32(rect.posX_)) {
610 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write posX failed");
611 return false;
612 }
613 if (!data.WriteInt32(rect.posY_)) {
614 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write posY failed");
615 return false;
616 }
617 if (!data.WriteUint32(rect.width_)) {
618 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write Width failed");
619 return false;
620 }
621 if (!data.WriteUint32(rect.height_)) {
622 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write Height failed");
623 return false;
624 }
625 break;
626 }
627 case WindowInfoKey::FLOATING_SCALE : {
628 if (!data.WriteFloat(std::get<float>(windowInfoPair.second))) {
629 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write float failed");
630 return false;
631 }
632 break;
633 }
634 default : {
635 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Unknown WindowInfoKey: %{public}d",
636 static_cast<int32_t>(windowInfoPair.first));
637 return false;
638 }
639 }
640 return true;
641 }
642 } // namespace Rosen
643 } // namespace OHOS
644
645