• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "common/include/window_session_property.h"
17 #include "window_manager_hilog.h"
18 #include "wm_common.h"
19 #include "window_helper.h"
20 
21 namespace OHOS {
22 namespace Rosen {
23 namespace {
24 constexpr uint32_t TOUCH_HOT_AREA_MAX_NUM = 50;
25 constexpr uint32_t MAX_SIZE_PIP_CONTROL_GROUP = 8;
26 constexpr uint32_t MAX_SIZE_PIP_CONTROL = 9;
27 }
28 
29 const std::map<uint32_t, HandlWritePropertyFunc> WindowSessionProperty::writeFuncMap_ {
30     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON),
31         &WindowSessionProperty::WriteActionUpdateTurnScreenOn),
32     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON),
33         &WindowSessionProperty::WriteActionUpdateKeepScreenOn),
34     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE),
35         &WindowSessionProperty::WriteActionUpdateFocusable),
36     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE),
37         &WindowSessionProperty::WriteActionUpdateTouchable),
38     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS),
39         &WindowSessionProperty::WriteActionUpdateSetBrightness),
40     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION),
41         &WindowSessionProperty::WriteActionUpdateOrientation),
42     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE),
43         &WindowSessionProperty::WriteActionUpdatePrivacyMode),
44     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE),
45         &WindowSessionProperty::WriteActionUpdatePrivacyMode),
46     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP),
47         &WindowSessionProperty::WriteActionUpdateSnapshotSkip),
48     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE),
49         &WindowSessionProperty::WriteActionUpdateMaximizeState),
50     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS),
51         &WindowSessionProperty::WriteActionUpdateSystemBar),
52     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS),
53         &WindowSessionProperty::WriteActionUpdateSystemBar),
54     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_PROPS),
55         &WindowSessionProperty::WriteActionUpdateSystemBar),
56     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS),
57         &WindowSessionProperty::WriteActionUpdateSystemBar),
58     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_FLAGS),
59         &WindowSessionProperty::WriteActionUpdateFlags),
60     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE),
61         &WindowSessionProperty::WriteActionUpdateMode),
62     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG),
63         &WindowSessionProperty::WriteActionUpdateAnimationFlag),
64     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA),
65         &WindowSessionProperty::WriteActionUpdateTouchHotArea),
66     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_KEYBOARD_TOUCH_HOT_AREA),
67         &WindowSessionProperty::WriteActionUpdateKeyboardTouchHotArea),
68     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE),
69         &WindowSessionProperty::WriteActionUpdateDecorEnable),
70     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS),
71         &WindowSessionProperty::WriteActionUpdateWindowLimits),
72     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED),
73         &WindowSessionProperty::WriteActionUpdateDragenabled),
74     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED),
75         &WindowSessionProperty::WriteActionUpdateRaiseenabled),
76     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS),
77         &WindowSessionProperty::WriteActionUpdateHideNonSystemFloatingWindows),
78     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO),
79         &WindowSessionProperty::WriteActionUpdateTextfieldAvoidInfo),
80     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK),
81         &WindowSessionProperty::WriteActionUpdateWindowMask),
82     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST),
83         &WindowSessionProperty::WriteActionUpdateTopmost),
84     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO),
85         &WindowSessionProperty::WriteActionUpdateWindowModeSupportType),
86     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST),
87         &WindowSessionProperty::WriteActionUpdateMainWindowTopmost),
88     std::make_pair(static_cast<uint64_t>(WSPropertyChangeAction::ACTION_UPDATE_EXCLUSIVE_HIGHLIGHTED),
89         &WindowSessionProperty::WriteActionUpdateExclusivelyHighlighted),
90 };
91 
92 const std::map<uint32_t, HandlReadPropertyFunc> WindowSessionProperty::readFuncMap_ {
93     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON),
94         &WindowSessionProperty::ReadActionUpdateTurnScreenOn),
95     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON),
96         &WindowSessionProperty::ReadActionUpdateKeepScreenOn),
97     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE),
98         &WindowSessionProperty::ReadActionUpdateFocusable),
99     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE),
100         &WindowSessionProperty::ReadActionUpdateTouchable),
101     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS),
102         &WindowSessionProperty::ReadActionUpdateSetBrightness),
103     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION),
104         &WindowSessionProperty::ReadActionUpdateOrientation),
105     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE),
106         &WindowSessionProperty::ReadActionUpdatePrivacyMode),
107     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE),
108         &WindowSessionProperty::ReadActionUpdatePrivacyMode),
109     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP),
110         &WindowSessionProperty::ReadActionUpdateSnapshotSkip),
111     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE),
112         &WindowSessionProperty::ReadActionUpdateMaximizeState),
113     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_OTHER_PROPS),
114         &WindowSessionProperty::ReadActionUpdateSystemBar),
115     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS),
116         &WindowSessionProperty::ReadActionUpdateSystemBar),
117     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_PROPS),
118         &WindowSessionProperty::ReadActionUpdateSystemBar),
119     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS),
120         &WindowSessionProperty::ReadActionUpdateSystemBar),
121     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_FLAGS),
122         &WindowSessionProperty::ReadActionUpdateFlags),
123     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE),
124         &WindowSessionProperty::ReadActionUpdateMode),
125     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG),
126         &WindowSessionProperty::ReadActionUpdateAnimationFlag),
127     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA),
128         &WindowSessionProperty::ReadActionUpdateTouchHotArea),
129     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_KEYBOARD_TOUCH_HOT_AREA),
130         &WindowSessionProperty::ReadActionUpdateKeyboardTouchHotArea),
131     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE),
132         &WindowSessionProperty::ReadActionUpdateDecorEnable),
133     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS),
134         &WindowSessionProperty::ReadActionUpdateWindowLimits),
135     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED),
136         &WindowSessionProperty::ReadActionUpdateDragenabled),
137     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED),
138         &WindowSessionProperty::ReadActionUpdateRaiseenabled),
139     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS),
140         &WindowSessionProperty::ReadActionUpdateHideNonSystemFloatingWindows),
141     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO),
142         &WindowSessionProperty::ReadActionUpdateTextfieldAvoidInfo),
143     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK),
144         &WindowSessionProperty::ReadActionUpdateWindowMask),
145     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST),
146         &WindowSessionProperty::ReadActionUpdateTopmost),
147     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO),
148         &WindowSessionProperty::ReadActionUpdateWindowModeSupportType),
149     std::make_pair(static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST),
150         &WindowSessionProperty::ReadActionUpdateMainWindowTopmost),
151     std::make_pair(static_cast<uint64_t>(WSPropertyChangeAction::ACTION_UPDATE_EXCLUSIVE_HIGHLIGHTED),
152         &WindowSessionProperty::ReadActionUpdateExclusivelyHighlighted),
153 };
154 
WindowSessionProperty(const sptr<WindowSessionProperty> & property)155 WindowSessionProperty::WindowSessionProperty(const sptr<WindowSessionProperty>& property)
156 {
157     CopyFrom(property);
158 }
159 
SetWindowName(const std::string & name)160 void WindowSessionProperty::SetWindowName(const std::string& name)
161 {
162     windowName_ = name;
163 }
164 
SetSessionInfo(const SessionInfo & info)165 void WindowSessionProperty::SetSessionInfo(const SessionInfo& info)
166 {
167     sessionInfo_ = info;
168 }
169 
SetWindowRect(const struct Rect & rect)170 void WindowSessionProperty::SetWindowRect(const struct Rect& rect)
171 {
172     std::lock_guard<std::mutex> lock(windowRectMutex_);
173     windowRect_ = rect;
174 }
175 
SetRequestRect(const Rect & requestRect)176 void WindowSessionProperty::SetRequestRect(const Rect& requestRect)
177 {
178     std::lock_guard<std::mutex> lock(requestRectMutex_);
179     requestRect_ = requestRect;
180 }
181 
SetWindowType(WindowType type)182 void WindowSessionProperty::SetWindowType(WindowType type)
183 {
184     type_ = type;
185 }
186 
SetFocusable(bool isFocusable)187 void WindowSessionProperty::SetFocusable(bool isFocusable)
188 {
189     focusable_ = isFocusable;
190 }
191 
SetFocusableOnShow(bool isFocusableOnShow)192 void WindowSessionProperty::SetFocusableOnShow(bool isFocusableOnShow)
193 {
194     focusableOnShow_ = isFocusableOnShow;
195 }
196 
SetTouchable(bool isTouchable)197 void WindowSessionProperty::SetTouchable(bool isTouchable)
198 {
199     touchable_ = isTouchable;
200 }
201 
SetDragEnabled(bool dragEnabled)202 void WindowSessionProperty::SetDragEnabled(bool dragEnabled)
203 {
204     dragEnabled_ = dragEnabled;
205 }
206 
SetHideNonSystemFloatingWindows(bool hide)207 void WindowSessionProperty::SetHideNonSystemFloatingWindows(bool hide)
208 {
209     hideNonSystemFloatingWindows_ = hide;
210 }
211 
SetForceHide(bool hide)212 void WindowSessionProperty::SetForceHide(bool hide)
213 {
214     forceHide_ = hide;
215 }
216 
SetRaiseEnabled(bool raiseEnabled)217 void WindowSessionProperty::SetRaiseEnabled(bool raiseEnabled)
218 {
219     raiseEnabled_ = raiseEnabled;
220 }
221 
SetRequestedOrientation(Orientation orientation)222 void WindowSessionProperty::SetRequestedOrientation(Orientation orientation)
223 {
224     requestedOrientation_ = orientation;
225 }
226 
SetDefaultRequestedOrientation(Orientation orientation)227 void WindowSessionProperty::SetDefaultRequestedOrientation(Orientation orientation)
228 {
229     defaultRequestedOrientation_ = orientation;
230 }
231 
SetPrivacyMode(bool isPrivate)232 void WindowSessionProperty::SetPrivacyMode(bool isPrivate)
233 {
234     isPrivacyMode_ = isPrivate;
235 }
236 
SetSystemPrivacyMode(bool isSystemPrivate)237 void WindowSessionProperty::SetSystemPrivacyMode(bool isSystemPrivate)
238 {
239     isSystemPrivacyMode_ = isSystemPrivate;
240 }
241 
SetSnapshotSkip(bool isSkip)242 void WindowSessionProperty::SetSnapshotSkip(bool isSkip)
243 {
244     isSnapshotSkip_ = isSkip;
245 }
246 
SetBrightness(float brightness)247 void WindowSessionProperty::SetBrightness(float brightness)
248 {
249     brightness_ = brightness;
250 }
251 
SetSystemCalling(bool isSystemCalling)252 void WindowSessionProperty::SetSystemCalling(bool isSystemCalling)
253 {
254     isSystemCalling_ = isSystemCalling;
255 }
256 
SetDisplayId(DisplayId displayId)257 void WindowSessionProperty::SetDisplayId(DisplayId displayId)
258 {
259     displayId_ = displayId;
260 }
261 
SetFloatingWindowAppType(bool isAppType)262 void WindowSessionProperty::SetFloatingWindowAppType(bool isAppType)
263 {
264     isFloatingWindowAppType_ = isAppType;
265 }
266 
GetWindowName() const267 const std::string& WindowSessionProperty::GetWindowName() const
268 {
269     return windowName_;
270 }
271 
GetSessionInfo() const272 const SessionInfo& WindowSessionProperty::GetSessionInfo() const
273 {
274     return sessionInfo_;
275 }
276 
EditSessionInfo()277 SessionInfo& WindowSessionProperty::EditSessionInfo()
278 {
279     return sessionInfo_;
280 }
281 
GetWindowRect() const282 Rect WindowSessionProperty::GetWindowRect() const
283 {
284     std::lock_guard<std::mutex> lock(windowRectMutex_);
285     return windowRect_;
286 }
287 
GetRequestRect() const288 Rect WindowSessionProperty::GetRequestRect() const
289 {
290     std::lock_guard<std::mutex> lock(requestRectMutex_);
291     return requestRect_;
292 }
293 
GetWindowType() const294 WindowType WindowSessionProperty::GetWindowType() const
295 {
296     return type_;
297 }
298 
GetFocusable() const299 bool WindowSessionProperty::GetFocusable() const
300 {
301     return focusable_;
302 }
303 
GetFocusableOnShow() const304 bool WindowSessionProperty::GetFocusableOnShow() const
305 {
306     return focusableOnShow_;
307 }
308 
GetTouchable() const309 bool WindowSessionProperty::GetTouchable() const
310 {
311     return touchable_;
312 }
313 
GetDragEnabled() const314 bool WindowSessionProperty::GetDragEnabled() const
315 {
316     return dragEnabled_;
317 }
318 
GetHideNonSystemFloatingWindows() const319 bool WindowSessionProperty::GetHideNonSystemFloatingWindows() const
320 {
321     return hideNonSystemFloatingWindows_;
322 }
323 
GetForceHide() const324 bool WindowSessionProperty::GetForceHide() const
325 {
326     return forceHide_;
327 }
328 
GetRaiseEnabled() const329 bool WindowSessionProperty::GetRaiseEnabled() const
330 {
331     return raiseEnabled_;
332 }
333 
GetRequestedOrientation() const334 Orientation WindowSessionProperty::GetRequestedOrientation() const
335 {
336     return requestedOrientation_;
337 }
338 
GetDefaultRequestedOrientation() const339 Orientation WindowSessionProperty::GetDefaultRequestedOrientation() const
340 {
341     return defaultRequestedOrientation_;
342 }
343 
GetPrivacyMode() const344 bool WindowSessionProperty::GetPrivacyMode() const
345 {
346     return isPrivacyMode_;
347 }
348 
GetSystemPrivacyMode() const349 bool WindowSessionProperty::GetSystemPrivacyMode() const
350 {
351     return isSystemPrivacyMode_;
352 }
353 
GetSnapshotSkip() const354 bool WindowSessionProperty::GetSnapshotSkip() const
355 {
356     return isSnapshotSkip_;
357 }
358 
GetBrightness() const359 float WindowSessionProperty::GetBrightness() const
360 {
361     return brightness_;
362 }
363 
GetSystemCalling() const364 bool WindowSessionProperty::GetSystemCalling() const
365 {
366     return isSystemCalling_;
367 }
368 
GetDisplayId() const369 DisplayId WindowSessionProperty::GetDisplayId() const
370 {
371     return displayId_;
372 }
373 
SetParentId(int32_t parentId)374 void WindowSessionProperty::SetParentId(int32_t parentId)
375 {
376     parentId_ = parentId;
377 }
378 
GetParentId() const379 int32_t WindowSessionProperty::GetParentId() const
380 {
381     return parentId_;
382 }
383 
SetWindowFlags(uint32_t flags)384 void WindowSessionProperty::SetWindowFlags(uint32_t flags)
385 {
386     flags_ = flags;
387 }
388 
389 /** @note @window.hierarchy */
SetTopmost(bool topmost)390 void WindowSessionProperty::SetTopmost(bool topmost)
391 {
392     topmost_ = topmost;
393 }
394 
IsTopmost() const395 bool WindowSessionProperty::IsTopmost() const
396 {
397     return topmost_;
398 }
399 
SetMainWindowTopmost(bool isTopmost)400 void WindowSessionProperty::SetMainWindowTopmost(bool isTopmost)
401 {
402     mainWindowTopmost_ = isTopmost;
403 }
404 
IsMainWindowTopmost() const405 bool WindowSessionProperty::IsMainWindowTopmost() const
406 {
407     return mainWindowTopmost_;
408 }
409 
AddWindowFlag(WindowFlag flag)410 void WindowSessionProperty::AddWindowFlag(WindowFlag flag)
411 {
412     flags_ |= static_cast<uint32_t>(flag);
413 }
414 
GetWindowFlags() const415 uint32_t WindowSessionProperty::GetWindowFlags() const
416 {
417     return flags_;
418 }
419 
SetPersistentId(int32_t persistentId)420 void WindowSessionProperty::SetPersistentId(int32_t persistentId)
421 {
422     persistentId_ = persistentId;
423 }
424 
GetPersistentId() const425 int32_t WindowSessionProperty::GetPersistentId() const
426 {
427     return persistentId_;
428 }
429 
SetParentPersistentId(int32_t persistentId)430 void WindowSessionProperty::SetParentPersistentId(int32_t persistentId)
431 {
432     parentPersistentId_ = persistentId;
433 }
434 
GetParentPersistentId() const435 int32_t WindowSessionProperty::GetParentPersistentId() const
436 {
437     return parentPersistentId_;
438 }
439 
SetTurnScreenOn(bool turnScreenOn)440 void WindowSessionProperty::SetTurnScreenOn(bool turnScreenOn)
441 {
442     turnScreenOn_ = turnScreenOn;
443 }
444 
IsTurnScreenOn() const445 bool WindowSessionProperty::IsTurnScreenOn() const
446 {
447     return turnScreenOn_;
448 }
449 
SetKeepScreenOn(bool keepScreenOn)450 void WindowSessionProperty::SetKeepScreenOn(bool keepScreenOn)
451 {
452     keepScreenOn_ = keepScreenOn;
453 }
454 
IsKeepScreenOn() const455 bool WindowSessionProperty::IsKeepScreenOn() const
456 {
457     return keepScreenOn_;
458 }
459 
SetAccessTokenId(uint32_t accessTokenId)460 void WindowSessionProperty::SetAccessTokenId(uint32_t accessTokenId)
461 {
462     accessTokenId_ = accessTokenId;
463 }
464 
GetAccessTokenId() const465 uint32_t WindowSessionProperty::GetAccessTokenId() const
466 {
467     return accessTokenId_;
468 }
469 
SetTokenState(bool hasToken)470 void WindowSessionProperty::SetTokenState(bool hasToken)
471 {
472     tokenState_ = hasToken;
473 }
474 
GetTokenState() const475 bool WindowSessionProperty::GetTokenState() const
476 {
477     return tokenState_;
478 }
479 
GetMaximizeMode() const480 MaximizeMode WindowSessionProperty::GetMaximizeMode() const
481 {
482     return maximizeMode_;
483 }
484 
SetMaximizeMode(MaximizeMode mode)485 void WindowSessionProperty::SetMaximizeMode(MaximizeMode mode)
486 {
487     maximizeMode_ = mode;
488 }
489 
SetSystemBarProperty(WindowType type,const SystemBarProperty & property)490 void WindowSessionProperty::SetSystemBarProperty(WindowType type, const SystemBarProperty& property)
491 {
492     if (type == WindowType::WINDOW_TYPE_STATUS_BAR
493         || type ==WindowType::WINDOW_TYPE_NAVIGATION_BAR
494         || type == WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR) {
495         sysBarPropMap_[type] = property;
496     }
497 }
498 
GetSystemBarProperty() const499 std::unordered_map<WindowType, SystemBarProperty> WindowSessionProperty::GetSystemBarProperty() const
500 {
501     return sysBarPropMap_;
502 }
503 
SetWindowLimits(const WindowLimits & windowLimits)504 void WindowSessionProperty::SetWindowLimits(const WindowLimits& windowLimits)
505 {
506     limits_ = windowLimits;
507 }
508 
GetWindowLimits() const509 WindowLimits WindowSessionProperty::GetWindowLimits() const
510 {
511     return limits_;
512 }
513 
SetWindowMode(WindowMode mode)514 void WindowSessionProperty::SetWindowMode(WindowMode mode)
515 {
516     windowMode_ = mode;
517 }
518 
GetWindowMode() const519 WindowMode WindowSessionProperty::GetWindowMode() const
520 {
521     return windowMode_;
522 }
523 
GetWindowState() const524 WindowState WindowSessionProperty::GetWindowState() const
525 {
526     return windowState_;
527 }
528 
SetWindowState(WindowState state)529 void WindowSessionProperty::SetWindowState(WindowState state)
530 {
531     windowState_ = state;
532 }
533 
SetKeyboardLayoutParams(const KeyboardLayoutParams & params)534 void WindowSessionProperty::SetKeyboardLayoutParams(const KeyboardLayoutParams& params)
535 {
536     keyboardLayoutParams_.gravity_ = params.gravity_;
537     keyboardLayoutParams_.landscapeAvoidHeight_ = params.landscapeAvoidHeight_;
538     keyboardLayoutParams_.portraitAvoidHeight_ = params.portraitAvoidHeight_;
539     keyboardLayoutParams_.LandscapeKeyboardRect_ = params.LandscapeKeyboardRect_;
540     keyboardLayoutParams_.PortraitKeyboardRect_ = params.PortraitKeyboardRect_;
541     keyboardLayoutParams_.LandscapePanelRect_ = params.LandscapePanelRect_;
542     keyboardLayoutParams_.PortraitPanelRect_ = params.PortraitPanelRect_;
543 }
544 
GetKeyboardLayoutParams() const545 KeyboardLayoutParams WindowSessionProperty::GetKeyboardLayoutParams() const
546 {
547     return keyboardLayoutParams_;
548 }
549 
SetDecorEnable(bool isDecorEnable)550 void WindowSessionProperty::SetDecorEnable(bool isDecorEnable)
551 {
552     isDecorEnable_ = isDecorEnable;
553 }
554 
IsDecorEnable()555 bool WindowSessionProperty::IsDecorEnable()
556 {
557     return isDecorEnable_;
558 }
559 
SetWindowModeSupportType(uint32_t windowModeSupportType)560 void WindowSessionProperty::SetWindowModeSupportType(uint32_t windowModeSupportType)
561 {
562     windowModeSupportType_ = windowModeSupportType;
563 }
564 
GetWindowModeSupportType() const565 uint32_t WindowSessionProperty::GetWindowModeSupportType() const
566 {
567     return windowModeSupportType_;
568 }
569 
SetSupportedWindowModes(const std::vector<AppExecFwk::SupportWindowMode> & supportedWindowModes)570 void WindowSessionProperty::SetSupportedWindowModes(
571     const std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes)
572 {
573     std::lock_guard<std::mutex> lock(supportWindowModesMutex_);
574     supportedWindowModes_ = supportedWindowModes;
575 }
576 
GetSupportedWindowModes(std::vector<AppExecFwk::SupportWindowMode> & supportedWindowModes) const577 void WindowSessionProperty::GetSupportedWindowModes(
578     std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes) const
579 {
580     std::lock_guard<std::mutex> lock(supportWindowModesMutex_);
581     supportedWindowModes = supportedWindowModes_;
582 }
583 
SetAnimationFlag(uint32_t animationFlag)584 void WindowSessionProperty::SetAnimationFlag(uint32_t animationFlag)
585 {
586     animationFlag_ = animationFlag;
587 }
588 
GetAnimationFlag() const589 uint32_t WindowSessionProperty::GetAnimationFlag() const
590 {
591     return animationFlag_;
592 }
593 
IsFloatingWindowAppType() const594 bool WindowSessionProperty::IsFloatingWindowAppType() const
595 {
596     return isFloatingWindowAppType_;
597 }
598 
SetTouchHotAreasInner(const std::vector<Rect> & rects,std::vector<Rect> & touchHotAreas)599 void WindowSessionProperty::SetTouchHotAreasInner(const std::vector<Rect>& rects, std::vector<Rect>& touchHotAreas)
600 {
601     if (GetPersistentId() != 0 && rects != touchHotAreas) {
602         std::ostringstream oss;
603         for (const auto& rect : rects) {
604             oss << "[ " << rect.posX_ << " , " << rect.posY_ << " , " << rect.width_ << " , " << rect.height_ << "]";
605         }
606         TLOGI(WmsLogTag::WMS_EVENT, "id:%{public}d rects:%{public}s", GetPersistentId(), oss.str().c_str());
607     }
608     touchHotAreas = rects;
609 }
610 
SetTouchHotAreas(const std::vector<Rect> & rects)611 void WindowSessionProperty::SetTouchHotAreas(const std::vector<Rect>& rects)
612 {
613     {
614         std::lock_guard lock(touchHotAreasMutex_);
615         SetTouchHotAreasInner(rects, touchHotAreas_);
616     }
617     if (touchHotAreasChangeCallback_) {
618         touchHotAreasChangeCallback_();
619     }
620 }
621 
SetKeyboardTouchHotAreas(const KeyboardTouchHotAreas & keyboardTouchHotAreas)622 void WindowSessionProperty::SetKeyboardTouchHotAreas(const KeyboardTouchHotAreas& keyboardTouchHotAreas)
623 {
624     {
625         std::lock_guard<std::mutex> lock(touchHotAreasMutex_);
626         SetTouchHotAreasInner(
627             keyboardTouchHotAreas.landscapeKeyboardHotAreas_, keyboardTouchHotAreas_.landscapeKeyboardHotAreas_);
628         SetTouchHotAreasInner(
629             keyboardTouchHotAreas.portraitKeyboardHotAreas_, keyboardTouchHotAreas_.portraitKeyboardHotAreas_);
630         SetTouchHotAreasInner(
631             keyboardTouchHotAreas.landscapePanelHotAreas_, keyboardTouchHotAreas_.landscapePanelHotAreas_);
632         SetTouchHotAreasInner(
633             keyboardTouchHotAreas.portraitPanelHotAreas_, keyboardTouchHotAreas_.portraitPanelHotAreas_);
634     }
635     if (touchHotAreasChangeCallback_) {
636         touchHotAreasChangeCallback_();
637     }
638 }
639 
GetTouchHotAreas(std::vector<Rect> & rects) const640 void WindowSessionProperty::GetTouchHotAreas(std::vector<Rect>& rects) const
641 {
642     std::lock_guard lock(touchHotAreasMutex_);
643     rects = touchHotAreas_;
644 }
645 
GetKeyboardTouchHotAreas() const646 KeyboardTouchHotAreas WindowSessionProperty::GetKeyboardTouchHotAreas() const
647 {
648     std::lock_guard lock(touchHotAreasMutex_);
649     return keyboardTouchHotAreas_;
650 }
651 
KeepKeyboardOnFocus(bool keepKeyboardFlag)652 void WindowSessionProperty::KeepKeyboardOnFocus(bool keepKeyboardFlag)
653 {
654     keepKeyboardFlag_ = keepKeyboardFlag;
655 }
656 
GetKeepKeyboardFlag() const657 bool WindowSessionProperty::GetKeepKeyboardFlag() const
658 {
659     return keepKeyboardFlag_;
660 }
661 
SetCallingSessionId(uint32_t sessionId)662 void WindowSessionProperty::SetCallingSessionId(uint32_t sessionId)
663 {
664     callingSessionId_ = sessionId;
665 }
666 
GetCallingSessionId() const667 uint32_t WindowSessionProperty::GetCallingSessionId() const
668 {
669     return callingSessionId_;
670 }
671 
SetSessionPropertyChangeCallback(std::function<void ()> && callback)672 void WindowSessionProperty::SetSessionPropertyChangeCallback(std::function<void()>&& callback)
673 {
674     touchHotAreasChangeCallback_ = std::move(callback);
675 }
676 
SetPiPTemplateInfo(const PiPTemplateInfo & pipTemplateInfo)677 void WindowSessionProperty::SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo)
678 {
679     pipTemplateInfo_ = pipTemplateInfo;
680 }
681 
GetPiPTemplateInfo() const682 PiPTemplateInfo WindowSessionProperty::GetPiPTemplateInfo() const
683 {
684     return pipTemplateInfo_;
685 }
686 
SetIsNeedUpdateWindowMode(bool isNeedUpdateWindowMode)687 void WindowSessionProperty::SetIsNeedUpdateWindowMode(bool isNeedUpdateWindowMode)
688 {
689     isNeedUpdateWindowMode_ = isNeedUpdateWindowMode;
690 }
691 
GetIsNeedUpdateWindowMode() const692 bool WindowSessionProperty::GetIsNeedUpdateWindowMode() const
693 {
694     return isNeedUpdateWindowMode_;
695 }
696 
MarshallingWindowLimits(Parcel & parcel) const697 bool WindowSessionProperty::MarshallingWindowLimits(Parcel& parcel) const
698 {
699     if (parcel.WriteUint32(limits_.maxWidth_) &&
700         parcel.WriteUint32(limits_.maxHeight_) && parcel.WriteUint32(limits_.minWidth_) &&
701         parcel.WriteUint32(limits_.minHeight_) && parcel.WriteFloat(limits_.maxRatio_) &&
702         parcel.WriteFloat(limits_.minRatio_) && parcel.WriteFloat(limits_.vpRatio_)) {
703         return true;
704     }
705     return false;
706 }
707 
UnmarshallingWindowLimits(Parcel & parcel,WindowSessionProperty * property)708 void WindowSessionProperty::UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property)
709 {
710     WindowLimits windowLimits = { parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32(),
711         parcel.ReadUint32(), parcel.ReadFloat(), parcel.ReadFloat(), parcel.ReadFloat() };
712     property->SetWindowLimits(windowLimits);
713 }
714 
MarshallingSystemBarMap(Parcel & parcel) const715 bool WindowSessionProperty::MarshallingSystemBarMap(Parcel& parcel) const
716 {
717     auto size = sysBarPropMap_.size();
718     uint32_t maxSystemBarNumber = 3;
719     if (size > maxSystemBarNumber) { // max systembar number
720         return false;
721     }
722 
723     if (!parcel.WriteUint32(static_cast<uint32_t>(size))) {
724         return false;
725     }
726     for (auto it : sysBarPropMap_) {
727         if (!parcel.WriteUint32(static_cast<uint32_t>(it.first))) {
728             return false;
729         }
730         if (!(parcel.WriteBool(it.second.enable_) && parcel.WriteUint32(it.second.backgroundColor_) &&
731               parcel.WriteUint32(it.second.contentColor_) && parcel.WriteBool(it.second.enableAnimation_) &&
732               parcel.WriteUint32(static_cast<uint32_t>(it.second.settingFlag_)))) {
733             return false;
734         }
735     }
736     return true;
737 }
738 
UnMarshallingSystemBarMap(Parcel & parcel,WindowSessionProperty * property)739 void WindowSessionProperty::UnMarshallingSystemBarMap(Parcel& parcel, WindowSessionProperty* property)
740 {
741     uint32_t size = parcel.ReadUint32();
742     uint32_t maxSystemBarNumber = 3;
743     if (size > maxSystemBarNumber) { // max systembar number
744         return;
745     }
746 
747     for (uint32_t i = 0; i < size; i++) {
748         WindowType type = static_cast<WindowType>(parcel.ReadUint32());
749         SystemBarProperty prop = { parcel.ReadBool(), parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadBool(),
750             static_cast<SystemBarSettingFlag>(parcel.ReadUint32()) };
751         property->SetSystemBarProperty(type, prop);
752     }
753 }
754 
MarshallingTouchHotAreasInner(const std::vector<Rect> & touchHotAreas,Parcel & parcel) const755 bool WindowSessionProperty::MarshallingTouchHotAreasInner(const std::vector<Rect>& touchHotAreas, Parcel& parcel) const
756 {
757     auto size = touchHotAreas.size();
758     if (size > TOUCH_HOT_AREA_MAX_NUM) {
759         return false;
760     }
761     if (!parcel.WriteUint32(static_cast<uint32_t>(size))) {
762         return false;
763     }
764     for (const auto& rect : touchHotAreas) {
765         if (!parcel.WriteInt32(rect.posX_) || !parcel.WriteInt32(rect.posY_) ||
766             !parcel.WriteUint32(rect.width_) || !parcel.WriteUint32(rect.height_)) {
767             return false;
768         }
769     }
770     return true;
771 }
772 
MarshallingTouchHotAreas(Parcel & parcel) const773 bool WindowSessionProperty::MarshallingTouchHotAreas(Parcel& parcel) const
774 {
775     return MarshallingTouchHotAreasInner(touchHotAreas_, parcel);
776 }
777 
MarshallingKeyboardTouchHotAreas(Parcel & parcel) const778 bool WindowSessionProperty::MarshallingKeyboardTouchHotAreas(Parcel& parcel) const
779 {
780     return MarshallingTouchHotAreasInner(keyboardTouchHotAreas_.landscapeKeyboardHotAreas_, parcel) &&
781            MarshallingTouchHotAreasInner(keyboardTouchHotAreas_.portraitKeyboardHotAreas_, parcel) &&
782            MarshallingTouchHotAreasInner(keyboardTouchHotAreas_.landscapePanelHotAreas_, parcel) &&
783            MarshallingTouchHotAreasInner(keyboardTouchHotAreas_.portraitPanelHotAreas_, parcel);
784 }
785 
UnmarshallingTouchHotAreasInner(Parcel & parcel,std::vector<Rect> & touchHotAreas)786 void WindowSessionProperty::UnmarshallingTouchHotAreasInner(Parcel& parcel, std::vector<Rect>& touchHotAreas)
787 {
788     uint32_t size = parcel.ReadUint32();
789     if (size > TOUCH_HOT_AREA_MAX_NUM) {
790         return;
791     }
792     for (uint32_t i = 0; i < size; i++) {
793         touchHotAreas.emplace_back(
794             Rect{ parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() });
795     }
796 }
797 
UnmarshallingTouchHotAreas(Parcel & parcel,WindowSessionProperty * property)798 void WindowSessionProperty::UnmarshallingTouchHotAreas(Parcel& parcel, WindowSessionProperty* property)
799 {
800     UnmarshallingTouchHotAreasInner(parcel, property->touchHotAreas_);
801 }
802 
UnmarshallingKeyboardTouchHotAreas(Parcel & parcel,WindowSessionProperty * property)803 void WindowSessionProperty::UnmarshallingKeyboardTouchHotAreas(Parcel& parcel, WindowSessionProperty* property)
804 {
805     UnmarshallingTouchHotAreasInner(parcel, property->keyboardTouchHotAreas_.landscapeKeyboardHotAreas_);
806     UnmarshallingTouchHotAreasInner(parcel, property->keyboardTouchHotAreas_.portraitKeyboardHotAreas_);
807     UnmarshallingTouchHotAreasInner(parcel, property->keyboardTouchHotAreas_.landscapePanelHotAreas_);
808     UnmarshallingTouchHotAreasInner(parcel, property->keyboardTouchHotAreas_.portraitPanelHotAreas_);
809 }
810 
MarshallingPiPTemplateInfo(Parcel & parcel) const811 bool WindowSessionProperty::MarshallingPiPTemplateInfo(Parcel& parcel) const
812 {
813     if (!WindowHelper::IsPipWindow(type_)) {
814         return true;
815     }
816     if (!parcel.WriteUint32(pipTemplateInfo_.pipTemplateType)) {
817         return false;
818     }
819     if (!parcel.WriteUint32(pipTemplateInfo_.priority)) {
820         return false;
821     }
822     auto size = pipTemplateInfo_.controlGroup.size();
823     if (size > MAX_SIZE_PIP_CONTROL_GROUP) {
824         return false;
825     }
826     if (!parcel.WriteUint32(static_cast<uint32_t>(size))) {
827         return false;
828     }
829     for (uint32_t i = 0; i < size; i++) {
830         if (!parcel.WriteUint32(pipTemplateInfo_.controlGroup[i])) {
831             return false;
832         }
833     }
834     auto controlStatusSize = pipTemplateInfo_.pipControlStatusInfoList.size();
835     if (controlStatusSize > MAX_SIZE_PIP_CONTROL) {
836         return false;
837     }
838     if (!parcel.WriteUint32(static_cast<uint32_t>(controlStatusSize))) {
839         return false;
840     }
841     for (uint32_t i = 0; i < controlStatusSize; i++) {
842         if (!parcel.WriteUint32(static_cast<uint32_t>(pipTemplateInfo_.pipControlStatusInfoList[i].controlType)) ||
843             !parcel.WriteInt32(static_cast<int32_t>(pipTemplateInfo_.pipControlStatusInfoList[i].status))) {
844             return false;
845         }
846     }
847     auto controlEnableSize = pipTemplateInfo_.pipControlEnableInfoList.size();
848     if (controlEnableSize > MAX_SIZE_PIP_CONTROL) {
849         return false;
850     }
851     if (!parcel.WriteUint32(static_cast<uint32_t>(controlEnableSize))) {
852         return false;
853     }
854     for (uint32_t i = 0; i < controlEnableSize; i++) {
855         if (!parcel.WriteUint32(static_cast<uint32_t>(pipTemplateInfo_.pipControlEnableInfoList[i].controlType)) ||
856             !parcel.WriteInt32(static_cast<int32_t>(pipTemplateInfo_.pipControlEnableInfoList[i].enabled))) {
857             return false;
858         }
859     }
860     return true;
861 }
862 
UnmarshallingPiPTemplateInfo(Parcel & parcel,WindowSessionProperty * property)863 void WindowSessionProperty::UnmarshallingPiPTemplateInfo(Parcel& parcel, WindowSessionProperty* property)
864 {
865     if (!WindowHelper::IsPipWindow(property->GetWindowType())) {
866         return;
867     }
868     PiPTemplateInfo pipTemplateInfo;
869     pipTemplateInfo.pipTemplateType = parcel.ReadUint32();
870     pipTemplateInfo.priority = parcel.ReadUint32();
871     auto size = parcel.ReadUint32();
872     if (size > MAX_SIZE_PIP_CONTROL_GROUP) {
873         return;
874     }
875     for (uint32_t i = 0; i < size; i++) {
876         uint32_t controlGroupId = 0;
877         if (!parcel.ReadUint32(controlGroupId)) {
878             return;
879         }
880         pipTemplateInfo.controlGroup.push_back(controlGroupId);
881     }
882     auto controlStatusSize = parcel.ReadUint32();
883     if (controlStatusSize > MAX_SIZE_PIP_CONTROL) {
884         return;
885     }
886     for (uint32_t i = 0; i < controlStatusSize; i++) {
887         PiPControlStatusInfo pipControlStatusInfo;
888         uint32_t controlType = 0;
889         int32_t status = 0;
890         if (!parcel.ReadUint32(controlType) || !parcel.ReadInt32(status)) {
891             return;
892         }
893         pipControlStatusInfo.controlType = static_cast<PiPControlType>(controlType);
894         pipControlStatusInfo.status = static_cast<PiPControlStatus>(status);
895         pipTemplateInfo.pipControlStatusInfoList.push_back(pipControlStatusInfo);
896     }
897     auto controlEnableSize = parcel.ReadUint32();
898     if (controlEnableSize > MAX_SIZE_PIP_CONTROL) {
899         return;
900     }
901     for (uint32_t i = 0; i < controlEnableSize; i++) {
902         PiPControlEnableInfo pipControlEnableInfo;
903         uint32_t controlType = 0;
904         int32_t enabled = 0;
905         if (!parcel.ReadUint32(controlType) || !parcel.ReadInt32(enabled)) {
906             return;
907         }
908         pipControlEnableInfo.controlType = static_cast<PiPControlType>(controlType);
909         pipControlEnableInfo.enabled = static_cast<PiPControlStatus>(enabled);
910         pipTemplateInfo.pipControlEnableInfoList.push_back(pipControlEnableInfo);
911     }
912     property->SetPiPTemplateInfo(pipTemplateInfo);
913 }
914 
MarshallingWindowMask(Parcel & parcel) const915 bool WindowSessionProperty::MarshallingWindowMask(Parcel& parcel) const
916 {
917     if (!parcel.WriteBool(isShaped_)) {
918         return false;
919     }
920     if (isShaped_) {
921         if (!windowMask_->Marshalling(parcel)) {
922             return false;
923         }
924     }
925     return true;
926 }
927 
UnmarshallingWindowMask(Parcel & parcel,WindowSessionProperty * property)928 void WindowSessionProperty::UnmarshallingWindowMask(Parcel& parcel, WindowSessionProperty* property)
929 {
930     bool isShaped = parcel.ReadBool();
931     property->SetIsShaped(isShaped);
932     if (isShaped) {
933         Media::PixelMap* windowMask = Media::PixelMap::Unmarshalling(parcel);
934         if (windowMask != nullptr) {
935             property->SetWindowMask(std::shared_ptr<Media::PixelMap>(windowMask));
936         }
937     }
938 }
939 
MarshallingMainWindowTopmost(Parcel & parcel) const940 bool WindowSessionProperty::MarshallingMainWindowTopmost(Parcel& parcel) const
941 {
942     if (!parcel.WriteBool(mainWindowTopmost_) || !parcel.WriteUint32(accessTokenId_)) {
943         return false;
944     }
945     return true;
946 }
947 
UnmarshallingMainWindowTopmost(Parcel & parcel,WindowSessionProperty * property)948 void WindowSessionProperty::UnmarshallingMainWindowTopmost(Parcel& parcel, WindowSessionProperty* property)
949 {
950     property->SetMainWindowTopmost(parcel.ReadBool());
951     property->SetAccessTokenId(parcel.ReadUint32());
952 }
953 
MarshallingSessionInfo(Parcel & parcel) const954 bool WindowSessionProperty::MarshallingSessionInfo(Parcel& parcel) const
955 {
956     if (!parcel.WriteString(sessionInfo_.bundleName_) || !parcel.WriteString(sessionInfo_.moduleName_) ||
957         !parcel.WriteString(sessionInfo_.abilityName_) ||
958         !parcel.WriteInt32(static_cast<int32_t>(sessionInfo_.continueState))) {
959         return false;
960     }
961     const auto& want = sessionInfo_.want;
962     bool hasWant = want != nullptr;
963     if (!parcel.WriteBool(hasWant)) {
964         return false;
965     }
966     if (hasWant && !parcel.WriteParcelable(want.get())) {
967         return false;
968     }
969     return true;
970 }
971 
UnmarshallingSessionInfo(Parcel & parcel,WindowSessionProperty * property)972 bool WindowSessionProperty::UnmarshallingSessionInfo(Parcel& parcel, WindowSessionProperty* property)
973 {
974     std::string bundleName;
975     std::string moduleName;
976     std::string abilityName;
977     if (!parcel.ReadString(bundleName) || !parcel.ReadString(moduleName) || !parcel.ReadString(abilityName)) {
978         TLOGE(WmsLogTag::DEFAULT, "Failed to read String!");
979         return false;
980     }
981     SessionInfo info = { bundleName, moduleName, abilityName };
982     int32_t continueState;
983     if (!parcel.ReadInt32(continueState)) {
984         TLOGE(WmsLogTag::DEFAULT, "Failed to read continueState!");
985         return false;
986     }
987     info.continueState = static_cast<ContinueState>(continueState);
988     bool hasWant;
989     if (!parcel.ReadBool(hasWant)) {
990         TLOGE(WmsLogTag::DEFAULT, "Failed to read hasWant!");
991         return false;
992     }
993     if (hasWant) {
994         std::shared_ptr<AAFwk::Want> want(parcel.ReadParcelable<AAFwk::Want>());
995         if (want == nullptr) {
996             TLOGE(WmsLogTag::DEFAULT, "Failed to read want!");
997             return false;
998         }
999         info.want = want;
1000     }
1001     property->SetSessionInfo(info);
1002     return true;
1003 }
1004 
SetCompatibleModeInPc(bool compatibleModeInPc)1005 void WindowSessionProperty::SetCompatibleModeInPc(bool compatibleModeInPc)
1006 {
1007     compatibleModeInPc_ = compatibleModeInPc;
1008 }
1009 
GetCompatibleModeInPc() const1010 bool WindowSessionProperty::GetCompatibleModeInPc() const
1011 {
1012     return compatibleModeInPc_;
1013 }
1014 
SetCompatibleWindowSizeInPc(int32_t portraitWidth,int32_t portraitHeight,int32_t landscapeWidth,int32_t landscapeHeight)1015 void WindowSessionProperty::SetCompatibleWindowSizeInPc(int32_t portraitWidth,
1016     int32_t portraitHeight, int32_t landscapeWidth, int32_t landscapeHeight)
1017 {
1018     compatibleInPcPortraitWidth_ = portraitWidth;
1019     compatibleInPcPortraitHeight_ = portraitHeight;
1020     compatibleInPcLandscapeWidth_ = landscapeWidth;
1021     compatibleInPcLandscapeHeight_ = landscapeHeight;
1022 }
1023 
GetCompatibleInPcPortraitWidth() const1024 int32_t WindowSessionProperty::GetCompatibleInPcPortraitWidth() const
1025 {
1026     return compatibleInPcPortraitWidth_;
1027 }
1028 
GetCompatibleInPcPortraitHeight() const1029 int32_t WindowSessionProperty::GetCompatibleInPcPortraitHeight() const
1030 {
1031     return compatibleInPcPortraitHeight_;
1032 }
1033 
GetCompatibleInPcLandscapeWidth() const1034 int32_t WindowSessionProperty::GetCompatibleInPcLandscapeWidth() const
1035 {
1036     return compatibleInPcLandscapeWidth_;
1037 }
1038 
GetCompatibleInPcLandscapeHeight() const1039 int32_t WindowSessionProperty::GetCompatibleInPcLandscapeHeight() const
1040 {
1041     return compatibleInPcLandscapeHeight_;
1042 }
1043 
SetIsAppSupportPhoneInPc(bool isSupportPhone)1044 void WindowSessionProperty::SetIsAppSupportPhoneInPc(bool isSupportPhone)
1045 {
1046     isAppSupportPhoneInPc_ = isSupportPhone;
1047 }
1048 
GetIsAppSupportPhoneInPc() const1049 bool WindowSessionProperty::GetIsAppSupportPhoneInPc() const
1050 {
1051     return isAppSupportPhoneInPc_;
1052 }
1053 
SetIsPcAppInPad(bool isPcAppInPad)1054 void WindowSessionProperty::SetIsPcAppInPad(bool isPcAppInPad)
1055 {
1056     isPcAppInPad_ = isPcAppInPad;
1057 }
1058 
GetIsPcAppInPad() const1059 bool WindowSessionProperty::GetIsPcAppInPad() const
1060 {
1061     return isPcAppInPad_;
1062 }
1063 
SetSubWindowLevel(uint32_t subWindowLevel)1064 void WindowSessionProperty::SetSubWindowLevel(uint32_t subWindowLevel)
1065 {
1066     subWindowLevel_ = subWindowLevel;
1067 }
1068 
GetSubWindowLevel() const1069 uint32_t WindowSessionProperty::GetSubWindowLevel() const
1070 {
1071     return subWindowLevel_;
1072 }
1073 
SetCompatibleModeEnableInPad(bool enable)1074 void WindowSessionProperty::SetCompatibleModeEnableInPad(bool enable)
1075 {
1076     std::lock_guard<std::mutex> lock(compatibleModeMutex_);
1077     compatibleModeEnableInPad_ = enable;
1078 }
1079 
GetCompatibleModeEnableInPad() const1080 bool WindowSessionProperty::GetCompatibleModeEnableInPad() const
1081 {
1082     std::lock_guard<std::mutex> lock(compatibleModeMutex_);
1083     return compatibleModeEnableInPad_;
1084 }
1085 
SetIsSupportDragInPcCompatibleMode(bool isSupportDragInPcCompatibleMode)1086 void WindowSessionProperty::SetIsSupportDragInPcCompatibleMode(bool isSupportDragInPcCompatibleMode)
1087 {
1088     isSupportDragInPcCompatibleMode_ = isSupportDragInPcCompatibleMode;
1089 }
1090 
GetIsSupportDragInPcCompatibleMode() const1091 bool WindowSessionProperty::GetIsSupportDragInPcCompatibleMode() const
1092 {
1093     return isSupportDragInPcCompatibleMode_;
1094 }
1095 
Marshalling(Parcel & parcel) const1096 bool WindowSessionProperty::Marshalling(Parcel& parcel) const
1097 {
1098     return parcel.WriteString(windowName_) && parcel.WriteInt32(windowRect_.posX_) &&
1099         parcel.WriteInt32(windowRect_.posY_) && parcel.WriteUint32(windowRect_.width_) &&
1100         parcel.WriteUint32(windowRect_.height_) && parcel.WriteInt32(requestRect_.posX_) &&
1101         parcel.WriteInt32(requestRect_.posY_) && parcel.WriteUint32(requestRect_.width_) &&
1102         parcel.WriteUint32(requestRect_.height_) &&
1103         parcel.WriteUint32(static_cast<uint32_t>(type_)) &&
1104         parcel.WriteBool(focusable_) && parcel.WriteBool(focusableOnShow_) &&
1105         parcel.WriteBool(touchable_) && parcel.WriteBool(tokenState_) &&
1106         parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) &&
1107         parcel.WriteBool(isPrivacyMode_) && parcel.WriteBool(isSystemPrivacyMode_) &&
1108         parcel.WriteBool(isSnapshotSkip_) &&
1109         parcel.WriteUint64(displayId_) && parcel.WriteInt32(persistentId_) &&
1110         MarshallingSessionInfo(parcel) &&
1111         parcel.WriteInt32(parentPersistentId_) &&
1112         parcel.WriteUint32(accessTokenId_) && parcel.WriteUint32(static_cast<uint32_t>(maximizeMode_)) &&
1113         parcel.WriteUint32(static_cast<uint32_t>(requestedOrientation_)) &&
1114         parcel.WriteUint32(static_cast<uint32_t>(windowMode_)) &&
1115         parcel.WriteUint32(flags_) && parcel.WriteBool(raiseEnabled_) &&
1116         parcel.WriteBool(topmost_) && parcel.WriteBool(mainWindowTopmost_) &&
1117         parcel.WriteBool(isDecorEnable_) && parcel.WriteBool(dragEnabled_) &&
1118         parcel.WriteBool(hideNonSystemFloatingWindows_) && parcel.WriteBool(forceHide_) &&
1119         MarshallingWindowLimits(parcel) && parcel.WriteFloat(brightness_) &&
1120         MarshallingSystemBarMap(parcel) && parcel.WriteUint32(animationFlag_) &&
1121         MarshallingPiPTemplateInfo(parcel) &&
1122         parcel.WriteBool(isFloatingWindowAppType_) && MarshallingTouchHotAreas(parcel) &&
1123         parcel.WriteBool(isSystemCalling_) &&
1124         parcel.WriteDouble(textFieldPositionY_) && parcel.WriteDouble(textFieldHeight_) &&
1125         parcel.WriteBool(isNeedUpdateWindowMode_) && parcel.WriteUint32(callingSessionId_) &&
1126         parcel.WriteUint32(static_cast<uint32_t>(windowState_)) &&
1127         parcel.WriteBool(isLayoutFullScreen_) &&
1128         parcel.WriteInt32(realParentId_) &&
1129         parcel.WriteBool(isExtensionFlag_) &&
1130         parcel.WriteBool(isUIExtensionAbilityProcess_) &&
1131         parcel.WriteUint32(static_cast<uint32_t>(uiExtensionUsage_)) &&
1132         parcel.WriteUint32(static_cast<uint32_t>(parentWindowType_)) &&
1133         MarshallingWindowMask(parcel) &&
1134         parcel.WriteParcelable(&keyboardLayoutParams_) &&
1135         parcel.WriteBool(compatibleModeInPc_) &&
1136         parcel.WriteInt32(compatibleInPcPortraitWidth_) && parcel.WriteInt32(compatibleInPcPortraitHeight_) &&
1137         parcel.WriteInt32(compatibleInPcLandscapeWidth_) && parcel.WriteInt32(compatibleInPcLandscapeHeight_) &&
1138         parcel.WriteBool(isAppSupportPhoneInPc_) &&
1139         parcel.WriteBool(isSupportDragInPcCompatibleMode_) &&
1140         parcel.WriteBool(isPcAppInPad_) && parcel.WriteBool(compatibleModeEnableInPad_)  &&
1141         parcel.WriteUint32(static_cast<uint32_t>(keyboardViewMode_)) && parcel.WriteBool(isExclusivelyHighlighted_);
1142 }
1143 
Unmarshalling(Parcel & parcel)1144 WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel)
1145 {
1146     WindowSessionProperty* property = new(std::nothrow) WindowSessionProperty();
1147     if (property == nullptr) {
1148         return nullptr;
1149     }
1150     property->SetWindowName(parcel.ReadString());
1151     Rect rect = { parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() };
1152     property->SetWindowRect(rect);
1153     Rect reqRect = { parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() };
1154     property->SetRequestRect(reqRect);
1155     property->SetWindowType(static_cast<WindowType>(parcel.ReadUint32()));
1156     property->SetFocusable(parcel.ReadBool());
1157     property->SetFocusableOnShow(parcel.ReadBool());
1158     property->SetTouchable(parcel.ReadBool());
1159     property->SetTokenState(parcel.ReadBool());
1160     property->SetTurnScreenOn(parcel.ReadBool());
1161     property->SetKeepScreenOn(parcel.ReadBool());
1162     property->SetPrivacyMode(parcel.ReadBool());
1163     property->SetSystemPrivacyMode(parcel.ReadBool());
1164     property->SetSnapshotSkip(parcel.ReadBool());
1165     property->SetDisplayId(parcel.ReadUint64());
1166     property->SetPersistentId(parcel.ReadInt32());
1167     if (!UnmarshallingSessionInfo(parcel, property)) {
1168         delete property;
1169         return nullptr;
1170     }
1171     property->SetParentPersistentId(parcel.ReadInt32());
1172     property->SetAccessTokenId(parcel.ReadUint32());
1173     property->SetMaximizeMode(static_cast<MaximizeMode>(parcel.ReadUint32()));
1174     property->SetRequestedOrientation(static_cast<Orientation>(parcel.ReadUint32()));
1175     property->SetWindowMode(static_cast<WindowMode>(parcel.ReadUint32()));
1176     property->SetWindowFlags(parcel.ReadUint32());
1177     property->SetRaiseEnabled(parcel.ReadBool());
1178     property->SetTopmost(parcel.ReadBool());
1179     property->SetMainWindowTopmost(parcel.ReadBool());
1180     property->SetDecorEnable(parcel.ReadBool());
1181     property->SetDragEnabled(parcel.ReadBool());
1182     property->SetHideNonSystemFloatingWindows(parcel.ReadBool());
1183     property->SetForceHide(parcel.ReadBool());
1184     UnmarshallingWindowLimits(parcel, property);
1185     property->SetBrightness(parcel.ReadFloat());
1186     UnMarshallingSystemBarMap(parcel, property);
1187     property->SetAnimationFlag(parcel.ReadUint32());
1188     UnmarshallingPiPTemplateInfo(parcel, property);
1189     property->SetFloatingWindowAppType(parcel.ReadBool());
1190     UnmarshallingTouchHotAreas(parcel, property);
1191     property->SetSystemCalling(parcel.ReadBool());
1192     property->SetTextFieldPositionY(parcel.ReadDouble());
1193     property->SetTextFieldHeight(parcel.ReadDouble());
1194     property->SetIsNeedUpdateWindowMode(parcel.ReadBool());
1195     property->SetCallingSessionId(parcel.ReadUint32());
1196     property->SetWindowState(static_cast<WindowState>(parcel.ReadUint32()));
1197     property->SetIsLayoutFullScreen(parcel.ReadBool());
1198     property->SetRealParentId(parcel.ReadInt32());
1199     property->SetExtensionFlag(parcel.ReadBool());
1200     property->SetIsUIExtensionAbilityProcess(parcel.ReadBool());
1201     property->SetUIExtensionUsage(static_cast<UIExtensionUsage>(parcel.ReadUint32()));
1202     property->SetParentWindowType(static_cast<WindowType>(parcel.ReadUint32()));
1203     UnmarshallingWindowMask(parcel, property);
1204     sptr<KeyboardLayoutParams> keyboardLayoutParams = parcel.ReadParcelable<KeyboardLayoutParams>();
1205     if (keyboardLayoutParams == nullptr) {
1206         delete property;
1207         return nullptr;
1208     }
1209     property->SetKeyboardLayoutParams(*keyboardLayoutParams);
1210     property->SetCompatibleModeInPc(parcel.ReadBool());
1211     property->SetCompatibleWindowSizeInPc(parcel.ReadInt32(), parcel.ReadInt32(),
1212                                           parcel.ReadInt32(), parcel.ReadInt32());
1213     property->SetIsAppSupportPhoneInPc(parcel.ReadBool());
1214     property->SetIsSupportDragInPcCompatibleMode(parcel.ReadBool());
1215     property->SetIsPcAppInPad(parcel.ReadBool());
1216     property->SetCompatibleModeEnableInPad(parcel.ReadBool());
1217     property->SetKeyboardViewMode(static_cast<KeyboardViewMode>(parcel.ReadUint32()));
1218     property->SetExclusivelyHighlighted(parcel.ReadBool());
1219     return property;
1220 }
1221 
CopyFrom(const sptr<WindowSessionProperty> & property)1222 void WindowSessionProperty::CopyFrom(const sptr<WindowSessionProperty>& property)
1223 {
1224     windowName_ = property->windowName_;
1225     sessionInfo_ = property->sessionInfo_;
1226     requestRect_ = property->requestRect_;
1227     windowRect_ = property->windowRect_;
1228     type_ = property->type_;
1229     focusable_ = property->focusable_;
1230     focusableOnShow_ = property->focusableOnShow_;
1231     touchable_ = property->touchable_;
1232     dragEnabled_ = property->dragEnabled_;
1233     hideNonSystemFloatingWindows_ = property->hideNonSystemFloatingWindows_;
1234     forceHide_ = property->forceHide_;
1235     raiseEnabled_ = property->raiseEnabled_;
1236     topmost_ = property->topmost_;
1237     mainWindowTopmost_ = property->mainWindowTopmost_;
1238     tokenState_ = property->tokenState_;
1239     turnScreenOn_ = property->turnScreenOn_;
1240     keepScreenOn_ = property->keepScreenOn_;
1241     requestedOrientation_ = property->requestedOrientation_;
1242     defaultRequestedOrientation_ = property->defaultRequestedOrientation_;
1243     isPrivacyMode_ = property->isPrivacyMode_;
1244     isSystemPrivacyMode_ = property->isSystemPrivacyMode_;
1245     isSnapshotSkip_ = property->isSnapshotSkip_;
1246     brightness_ = property->brightness_;
1247     displayId_ = property->displayId_;
1248     parentId_ = property->parentId_;
1249     flags_ = property->flags_;
1250     persistentId_ = property->persistentId_;
1251     parentPersistentId_ = property->parentPersistentId_;
1252     accessTokenId_ = property->accessTokenId_;
1253     maximizeMode_ = property->maximizeMode_;
1254     windowMode_ = property->windowMode_;
1255     limits_ = property->limits_;
1256     windowModeSupportType_ = property->windowModeSupportType_;
1257     sysBarPropMap_ = property->sysBarPropMap_;
1258     isDecorEnable_ = property->isDecorEnable_;
1259     animationFlag_ = property->animationFlag_;
1260     isFloatingWindowAppType_ = property->isFloatingWindowAppType_;
1261     touchHotAreas_ = property->touchHotAreas_;
1262     keyboardTouchHotAreas_ = property->keyboardTouchHotAreas_;
1263     isSystemCalling_ = property->isSystemCalling_;
1264     textFieldPositionY_ = property->textFieldPositionY_;
1265     textFieldHeight_ = property->textFieldHeight_;
1266     isNeedUpdateWindowMode_ = property->isNeedUpdateWindowMode_;
1267     callingSessionId_ = property->callingSessionId_;
1268     isLayoutFullScreen_ = property->isLayoutFullScreen_;
1269     windowMask_ = property->windowMask_;
1270     isShaped_ = property->isShaped_;
1271     keyboardViewMode_ = property->keyboardViewMode_;
1272     isExclusivelyHighlighted_ = property->isExclusivelyHighlighted_;
1273 }
1274 
Write(Parcel & parcel,WSPropertyChangeAction action)1275 bool WindowSessionProperty::Write(Parcel& parcel, WSPropertyChangeAction action)
1276 {
1277     const auto funcIter = writeFuncMap_.find(static_cast<uint32_t>(action));
1278     if (funcIter == writeFuncMap_.end()) {
1279         TLOGE(WmsLogTag::DEFAULT, "Failed to find func handler!");
1280         return false;
1281     }
1282     bool ret = parcel.WriteUint32(static_cast<uint32_t>(persistentId_));
1283     return ret && (this->*(funcIter->second))(parcel);
1284 }
1285 
WriteActionUpdateTurnScreenOn(Parcel & parcel)1286 bool WindowSessionProperty::WriteActionUpdateTurnScreenOn(Parcel& parcel)
1287 {
1288     return parcel.WriteBool(turnScreenOn_);
1289 }
1290 
WriteActionUpdateKeepScreenOn(Parcel & parcel)1291 bool WindowSessionProperty::WriteActionUpdateKeepScreenOn(Parcel& parcel)
1292 {
1293     return parcel.WriteBool(keepScreenOn_);
1294 }
1295 
WriteActionUpdateFocusable(Parcel & parcel)1296 bool WindowSessionProperty::WriteActionUpdateFocusable(Parcel& parcel)
1297 {
1298     return parcel.WriteBool(focusable_);
1299 }
1300 
WriteActionUpdateTouchable(Parcel & parcel)1301 bool WindowSessionProperty::WriteActionUpdateTouchable(Parcel& parcel)
1302 {
1303     return parcel.WriteBool(touchable_);
1304 }
1305 
WriteActionUpdateSetBrightness(Parcel & parcel)1306 bool WindowSessionProperty::WriteActionUpdateSetBrightness(Parcel& parcel)
1307 {
1308     return parcel.WriteFloat(brightness_);
1309 }
1310 
WriteActionUpdateOrientation(Parcel & parcel)1311 bool WindowSessionProperty::WriteActionUpdateOrientation(Parcel& parcel)
1312 {
1313     return parcel.WriteUint32(static_cast<uint32_t>(requestedOrientation_));
1314 }
1315 
WriteActionUpdatePrivacyMode(Parcel & parcel)1316 bool WindowSessionProperty::WriteActionUpdatePrivacyMode(Parcel& parcel)
1317 {
1318     return parcel.WriteBool(isPrivacyMode_) && parcel.WriteBool(isSystemPrivacyMode_);
1319 }
1320 
WriteActionUpdateSnapshotSkip(Parcel & parcel)1321 bool WindowSessionProperty::WriteActionUpdateSnapshotSkip(Parcel& parcel)
1322 {
1323     return parcel.WriteBool(isSnapshotSkip_);
1324 }
1325 
WriteActionUpdateMaximizeState(Parcel & parcel)1326 bool WindowSessionProperty::WriteActionUpdateMaximizeState(Parcel& parcel)
1327 {
1328     return parcel.WriteUint32(static_cast<uint32_t>(maximizeMode_)) &&
1329         parcel.WriteBool(isLayoutFullScreen_);
1330 }
1331 
WriteActionUpdateSystemBar(Parcel & parcel)1332 bool WindowSessionProperty::WriteActionUpdateSystemBar(Parcel& parcel)
1333 {
1334     return MarshallingSystemBarMap(parcel);
1335 }
1336 
WriteActionUpdateFlags(Parcel & parcel)1337 bool WindowSessionProperty::WriteActionUpdateFlags(Parcel& parcel)
1338 {
1339     return parcel.WriteUint32(flags_);
1340 }
1341 
WriteActionUpdateMode(Parcel & parcel)1342 bool WindowSessionProperty::WriteActionUpdateMode(Parcel& parcel)
1343 {
1344     return parcel.WriteUint32(static_cast<uint32_t>(windowMode_));
1345 }
1346 
WriteActionUpdateAnimationFlag(Parcel & parcel)1347 bool WindowSessionProperty::WriteActionUpdateAnimationFlag(Parcel& parcel)
1348 {
1349     return parcel.WriteUint32(animationFlag_);
1350 }
1351 
WriteActionUpdateTouchHotArea(Parcel & parcel)1352 bool WindowSessionProperty::WriteActionUpdateTouchHotArea(Parcel& parcel)
1353 {
1354     return MarshallingTouchHotAreas(parcel);
1355 }
1356 
WriteActionUpdateKeyboardTouchHotArea(Parcel & parcel)1357 bool WindowSessionProperty::WriteActionUpdateKeyboardTouchHotArea(Parcel& parcel)
1358 {
1359     return MarshallingKeyboardTouchHotAreas(parcel);
1360 }
1361 
WriteActionUpdateDecorEnable(Parcel & parcel)1362 bool WindowSessionProperty::WriteActionUpdateDecorEnable(Parcel& parcel)
1363 {
1364     return parcel.WriteBool(isDecorEnable_);
1365 }
1366 
WriteActionUpdateWindowLimits(Parcel & parcel)1367 bool WindowSessionProperty::WriteActionUpdateWindowLimits(Parcel& parcel)
1368 {
1369     return MarshallingWindowLimits(parcel);
1370 }
1371 
WriteActionUpdateDragenabled(Parcel & parcel)1372 bool WindowSessionProperty::WriteActionUpdateDragenabled(Parcel& parcel)
1373 {
1374     return parcel.WriteBool(dragEnabled_);
1375 }
1376 
WriteActionUpdateRaiseenabled(Parcel & parcel)1377 bool WindowSessionProperty::WriteActionUpdateRaiseenabled(Parcel& parcel)
1378 {
1379     return parcel.WriteBool(raiseEnabled_);
1380 }
1381 
WriteActionUpdateHideNonSystemFloatingWindows(Parcel & parcel)1382 bool WindowSessionProperty::WriteActionUpdateHideNonSystemFloatingWindows(Parcel& parcel)
1383 {
1384     return parcel.WriteBool(hideNonSystemFloatingWindows_) &&
1385         parcel.WriteBool(isFloatingWindowAppType_) && parcel.WriteBool(forceHide_);
1386 }
1387 
WriteActionUpdateTextfieldAvoidInfo(Parcel & parcel)1388 bool WindowSessionProperty::WriteActionUpdateTextfieldAvoidInfo(Parcel& parcel)
1389 {
1390     return parcel.WriteDouble(textFieldPositionY_) && parcel.WriteDouble(textFieldHeight_);
1391 }
1392 
WriteActionUpdateWindowMask(Parcel & parcel)1393 bool WindowSessionProperty::WriteActionUpdateWindowMask(Parcel& parcel)
1394 {
1395     return MarshallingWindowMask(parcel);
1396 }
1397 
WriteActionUpdateTopmost(Parcel & parcel)1398 bool WindowSessionProperty::WriteActionUpdateTopmost(Parcel& parcel)
1399 {
1400     return parcel.WriteBool(topmost_);
1401 }
1402 
WriteActionUpdateMainWindowTopmost(Parcel & parcel)1403 bool WindowSessionProperty::WriteActionUpdateMainWindowTopmost(Parcel& parcel)
1404 {
1405     return MarshallingMainWindowTopmost(parcel);
1406 }
1407 
WriteActionUpdateWindowModeSupportType(Parcel & parcel)1408 bool WindowSessionProperty::WriteActionUpdateWindowModeSupportType(Parcel& parcel)
1409 {
1410     return parcel.WriteUint32(windowModeSupportType_);
1411 }
1412 
WriteActionUpdateExclusivelyHighlighted(Parcel & parcel)1413 bool WindowSessionProperty::WriteActionUpdateExclusivelyHighlighted(Parcel& parcel)
1414 {
1415     return parcel.WriteBool(isExclusivelyHighlighted_);
1416 }
1417 
Read(Parcel & parcel,WSPropertyChangeAction action)1418 void WindowSessionProperty::Read(Parcel& parcel, WSPropertyChangeAction action)
1419 {
1420     const auto funcIter = readFuncMap_.find(static_cast<uint32_t>(action));
1421     if (funcIter == readFuncMap_.end()) {
1422         TLOGE(WmsLogTag::DEFAULT, "Failed to find func handler!");
1423         return;
1424     }
1425     SetPersistentId(parcel.ReadUint32());
1426     (this->*(funcIter->second))(parcel);
1427 }
1428 
ReadActionUpdateTurnScreenOn(Parcel & parcel)1429 void WindowSessionProperty::ReadActionUpdateTurnScreenOn(Parcel& parcel)
1430 {
1431     SetTurnScreenOn(parcel.ReadBool());
1432 }
1433 
ReadActionUpdateKeepScreenOn(Parcel & parcel)1434 void WindowSessionProperty::ReadActionUpdateKeepScreenOn(Parcel& parcel)
1435 {
1436     SetKeepScreenOn(parcel.ReadBool());
1437 }
1438 
ReadActionUpdateFocusable(Parcel & parcel)1439 void WindowSessionProperty::ReadActionUpdateFocusable(Parcel& parcel)
1440 {
1441     SetFocusable(parcel.ReadBool());
1442 }
1443 
ReadActionUpdateTouchable(Parcel & parcel)1444 void WindowSessionProperty::ReadActionUpdateTouchable(Parcel& parcel)
1445 {
1446     SetTouchable(parcel.ReadBool());
1447 }
1448 
ReadActionUpdateSetBrightness(Parcel & parcel)1449 void WindowSessionProperty::ReadActionUpdateSetBrightness(Parcel& parcel)
1450 {
1451     SetBrightness(parcel.ReadFloat());
1452 }
1453 
ReadActionUpdateOrientation(Parcel & parcel)1454 void WindowSessionProperty::ReadActionUpdateOrientation(Parcel& parcel)
1455 {
1456     SetRequestedOrientation(static_cast<Orientation>(parcel.ReadUint32()));
1457 }
1458 
ReadActionUpdatePrivacyMode(Parcel & parcel)1459 void WindowSessionProperty::ReadActionUpdatePrivacyMode(Parcel& parcel)
1460 {
1461     SetPrivacyMode(parcel.ReadBool());
1462     SetSystemPrivacyMode(parcel.ReadBool());
1463 }
1464 
ReadActionUpdateSnapshotSkip(Parcel & parcel)1465 void WindowSessionProperty::ReadActionUpdateSnapshotSkip(Parcel& parcel)
1466 {
1467     SetSnapshotSkip(parcel.ReadBool());
1468 }
1469 
ReadActionUpdateMaximizeState(Parcel & parcel)1470 void WindowSessionProperty::ReadActionUpdateMaximizeState(Parcel& parcel)
1471 {
1472     SetMaximizeMode(static_cast<MaximizeMode>(parcel.ReadUint32()));
1473     SetIsLayoutFullScreen(parcel.ReadBool());
1474 }
1475 
ReadActionUpdateSystemBar(Parcel & parcel)1476 void WindowSessionProperty::ReadActionUpdateSystemBar(Parcel& parcel)
1477 {
1478     UnMarshallingSystemBarMap(parcel, this);
1479 }
1480 
ReadActionUpdateFlags(Parcel & parcel)1481 void WindowSessionProperty::ReadActionUpdateFlags(Parcel& parcel)
1482 {
1483     SetWindowFlags(parcel.ReadUint32());
1484 }
1485 
ReadActionUpdateMode(Parcel & parcel)1486 void WindowSessionProperty::ReadActionUpdateMode(Parcel& parcel)
1487 {
1488     SetWindowMode(static_cast<WindowMode>(parcel.ReadUint32()));
1489 }
1490 
ReadActionUpdateAnimationFlag(Parcel & parcel)1491 void WindowSessionProperty::ReadActionUpdateAnimationFlag(Parcel& parcel)
1492 {
1493     SetAnimationFlag(parcel.ReadUint32());
1494 }
1495 
ReadActionUpdateTouchHotArea(Parcel & parcel)1496 void WindowSessionProperty::ReadActionUpdateTouchHotArea(Parcel& parcel)
1497 {
1498     UnmarshallingTouchHotAreas(parcel, this);
1499 }
1500 
ReadActionUpdateKeyboardTouchHotArea(Parcel & parcel)1501 void WindowSessionProperty::ReadActionUpdateKeyboardTouchHotArea(Parcel& parcel)
1502 {
1503     UnmarshallingKeyboardTouchHotAreas(parcel, this);
1504 }
1505 
ReadActionUpdateDecorEnable(Parcel & parcel)1506 void WindowSessionProperty::ReadActionUpdateDecorEnable(Parcel& parcel)
1507 {
1508     SetDecorEnable(parcel.ReadBool());
1509 }
1510 
ReadActionUpdateWindowLimits(Parcel & parcel)1511 void WindowSessionProperty::ReadActionUpdateWindowLimits(Parcel& parcel)
1512 {
1513     UnmarshallingWindowLimits(parcel, this);
1514 }
1515 
ReadActionUpdateDragenabled(Parcel & parcel)1516 void WindowSessionProperty::ReadActionUpdateDragenabled(Parcel& parcel)
1517 {
1518     SetDragEnabled(parcel.ReadBool());
1519 }
1520 
ReadActionUpdateRaiseenabled(Parcel & parcel)1521 void WindowSessionProperty::ReadActionUpdateRaiseenabled(Parcel& parcel)
1522 {
1523     SetRaiseEnabled(parcel.ReadBool());
1524 }
1525 
ReadActionUpdateHideNonSystemFloatingWindows(Parcel & parcel)1526 void WindowSessionProperty::ReadActionUpdateHideNonSystemFloatingWindows(Parcel& parcel)
1527 {
1528     SetHideNonSystemFloatingWindows(parcel.ReadBool());
1529     SetFloatingWindowAppType(parcel.ReadBool());
1530     SetForceHide(parcel.ReadBool());
1531 }
1532 
ReadActionUpdateTextfieldAvoidInfo(Parcel & parcel)1533 void WindowSessionProperty::ReadActionUpdateTextfieldAvoidInfo(Parcel& parcel)
1534 {
1535     SetTextFieldPositionY(parcel.ReadDouble());
1536     SetTextFieldHeight(parcel.ReadDouble());
1537 }
1538 
ReadActionUpdateWindowMask(Parcel & parcel)1539 void WindowSessionProperty::ReadActionUpdateWindowMask(Parcel& parcel)
1540 {
1541     UnmarshallingWindowMask(parcel, this);
1542 }
1543 
ReadActionUpdateTopmost(Parcel & parcel)1544 void WindowSessionProperty::ReadActionUpdateTopmost(Parcel& parcel)
1545 {
1546     SetTopmost(parcel.ReadBool());
1547 }
1548 
ReadActionUpdateMainWindowTopmost(Parcel & parcel)1549 void WindowSessionProperty::ReadActionUpdateMainWindowTopmost(Parcel& parcel)
1550 {
1551     UnmarshallingMainWindowTopmost(parcel, this);
1552 }
1553 
ReadActionUpdateWindowModeSupportType(Parcel & parcel)1554 void WindowSessionProperty::ReadActionUpdateWindowModeSupportType(Parcel& parcel)
1555 {
1556     SetWindowModeSupportType(parcel.ReadUint32());
1557 }
1558 
ReadActionUpdateExclusivelyHighlighted(Parcel & parcel)1559 void WindowSessionProperty::ReadActionUpdateExclusivelyHighlighted(Parcel& parcel)
1560 {
1561     SetExclusivelyHighlighted(parcel.ReadBool());
1562 }
1563 
SetTransform(const Transform & trans)1564 void WindowSessionProperty::SetTransform(const Transform& trans)
1565 {
1566     trans_ = trans;
1567 }
1568 
GetTransform() const1569 const Transform& WindowSessionProperty::GetTransform() const
1570 {
1571     return trans_;
1572 }
1573 
SetTextFieldPositionY(double textFieldPositionY)1574 void WindowSessionProperty::SetTextFieldPositionY(double textFieldPositionY)
1575 {
1576     textFieldPositionY_ = textFieldPositionY;
1577 }
1578 
SetTextFieldHeight(double textFieldHeight)1579 void WindowSessionProperty::SetTextFieldHeight(double textFieldHeight)
1580 {
1581     textFieldHeight_ = textFieldHeight;
1582 }
1583 
GetTextFieldPositionY() const1584 double WindowSessionProperty::GetTextFieldPositionY() const
1585 {
1586     return textFieldPositionY_;
1587 }
1588 
GetTextFieldHeight() const1589 double WindowSessionProperty::GetTextFieldHeight() const
1590 {
1591     return textFieldHeight_;
1592 }
1593 
IsLayoutFullScreen() const1594 bool WindowSessionProperty::IsLayoutFullScreen() const
1595 {
1596     return isLayoutFullScreen_;
1597 }
1598 
SetIsLayoutFullScreen(bool isLayoutFullScreen)1599 void WindowSessionProperty::SetIsLayoutFullScreen(bool isLayoutFullScreen)
1600 {
1601     isLayoutFullScreen_ = isLayoutFullScreen;
1602 }
1603 
SetRealParentId(int32_t realParentId)1604 void WindowSessionProperty::SetRealParentId(int32_t realParentId)
1605 {
1606     realParentId_ = realParentId;
1607 }
1608 
GetRealParentId() const1609 int32_t WindowSessionProperty::GetRealParentId() const
1610 {
1611     return realParentId_;
1612 }
1613 
SetExtensionFlag(bool isExtensionFlag)1614 void WindowSessionProperty::SetExtensionFlag(bool isExtensionFlag)
1615 {
1616     isExtensionFlag_ = isExtensionFlag;
1617 }
1618 
GetExtensionFlag() const1619 bool WindowSessionProperty::GetExtensionFlag() const
1620 {
1621     return isExtensionFlag_;
1622 }
1623 
SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag)1624 void WindowSessionProperty::SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag)
1625 {
1626     isUIExtensionSubWindowFlag_ = isUIExtensionSubWindowFlag;
1627 }
1628 
GetIsUIExtensionSubWindowFlag() const1629 bool WindowSessionProperty::GetIsUIExtensionSubWindowFlag() const
1630 {
1631     return isUIExtensionSubWindowFlag_;
1632 }
1633 
SetIsUIExtensionAbilityProcess(bool isUIExtensionAbilityProcess)1634 void WindowSessionProperty::SetIsUIExtensionAbilityProcess(bool isUIExtensionAbilityProcess)
1635 {
1636     isUIExtensionAbilityProcess_ = isUIExtensionAbilityProcess;
1637 }
1638 
GetIsUIExtensionAbilityProcess() const1639 bool WindowSessionProperty::GetIsUIExtensionAbilityProcess() const
1640 {
1641     return isUIExtensionAbilityProcess_;
1642 }
1643 
SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage)1644 void WindowSessionProperty::SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage)
1645 {
1646     uiExtensionUsage_ = uiExtensionUsage;
1647 }
1648 
GetUIExtensionUsage() const1649 UIExtensionUsage WindowSessionProperty::GetUIExtensionUsage() const
1650 {
1651     return uiExtensionUsage_;
1652 }
1653 
SetParentWindowType(WindowType parentWindowType)1654 void WindowSessionProperty::SetParentWindowType(WindowType parentWindowType)
1655 {
1656     parentWindowType_= parentWindowType;
1657 }
1658 
GetParentWindowType() const1659 WindowType WindowSessionProperty::GetParentWindowType() const
1660 {
1661     return parentWindowType_;
1662 }
1663 
SetWindowMask(const std::shared_ptr<Media::PixelMap> & windowMask)1664 void WindowSessionProperty::SetWindowMask(const std::shared_ptr<Media::PixelMap>& windowMask)
1665 {
1666     windowMask_ = windowMask;
1667 }
1668 
GetWindowMask() const1669 std::shared_ptr<Media::PixelMap> WindowSessionProperty::GetWindowMask() const
1670 {
1671     return windowMask_;
1672 }
1673 
SetIsShaped(bool isShaped)1674 void WindowSessionProperty::SetIsShaped(bool isShaped)
1675 {
1676     isShaped_ = isShaped;
1677 }
1678 
GetIsShaped() const1679 bool WindowSessionProperty::GetIsShaped() const
1680 {
1681     return isShaped_;
1682 }
1683 
GetCollaboratorType() const1684 int32_t WindowSessionProperty::GetCollaboratorType() const
1685 {
1686     return collaboratorType_;
1687 }
1688 
SetCollaboratorType(int32_t collaboratorType)1689 void WindowSessionProperty::SetCollaboratorType(int32_t collaboratorType)
1690 {
1691     collaboratorType_ = collaboratorType;
1692 }
1693 
SetUserWindowLimits(const WindowLimits & windowUserLimits)1694 void WindowSessionProperty::SetUserWindowLimits(const WindowLimits& windowUserLimits)
1695 {
1696     userLimits_ = windowUserLimits;
1697 }
1698 
GetUserWindowLimits() const1699 WindowLimits WindowSessionProperty::GetUserWindowLimits() const
1700 {
1701     return userLimits_;
1702 }
1703 
SetConfigWindowLimitsVP(const WindowLimits & windowConfigLimitsVP)1704 void WindowSessionProperty::SetConfigWindowLimitsVP(const WindowLimits& windowConfigLimitsVP)
1705 {
1706     configLimitsVP_ = windowConfigLimitsVP;
1707 }
1708 
GetConfigWindowLimitsVP() const1709 WindowLimits WindowSessionProperty::GetConfigWindowLimitsVP() const
1710 {
1711     return configLimitsVP_;
1712 }
1713 
SetLastLimitsVpr(float vpr)1714 void WindowSessionProperty::SetLastLimitsVpr(float vpr)
1715 {
1716     lastVpr_ = vpr;
1717 }
1718 
GetLastLimitsVpr() const1719 float WindowSessionProperty::GetLastLimitsVpr() const
1720 {
1721     return lastVpr_;
1722 }
1723 
GetFullScreenStart() const1724 bool WindowSessionProperty::GetFullScreenStart() const
1725 {
1726     return fullScreenStart_;
1727 }
1728 
SetFullScreenStart(bool fullScreenStart)1729 void WindowSessionProperty::SetFullScreenStart(bool fullScreenStart)
1730 {
1731     fullScreenStart_ = fullScreenStart;
1732 }
1733 
SetKeyboardViewMode(KeyboardViewMode mode)1734 void WindowSessionProperty::SetKeyboardViewMode(KeyboardViewMode mode)
1735 {
1736     keyboardViewMode_ = mode;
1737 }
1738 
GetKeyboardViewMode() const1739 KeyboardViewMode WindowSessionProperty::GetKeyboardViewMode() const
1740 {
1741     return keyboardViewMode_;
1742 }
1743 
SetConstrainedModal(bool isConstrained)1744 void WindowSessionProperty::SetConstrainedModal(bool isConstrained)
1745 {
1746     isConstrainedModal_ = isConstrained;
1747 }
1748 
IsConstrainedModal() const1749 bool WindowSessionProperty::IsConstrainedModal() const
1750 {
1751     return isConstrainedModal_;
1752 }
1753 
SetExclusivelyHighlighted(bool isExclusivelyHighlighted)1754 void WindowSessionProperty::SetExclusivelyHighlighted(bool isExclusivelyHighlighted)
1755 {
1756     isExclusivelyHighlighted_ = isExclusivelyHighlighted;
1757 }
1758 
GetExclusivelyHighlighted() const1759 bool WindowSessionProperty::GetExclusivelyHighlighted() const
1760 {
1761     return isExclusivelyHighlighted_;
1762 }
1763 } // namespace Rosen
1764 } // namespace OHOS
1765