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 #ifndef OHOS_ROSEN_WINDOW_SESSION_PROPERTY_H 17 #define OHOS_ROSEN_WINDOW_SESSION_PROPERTY_H 18 19 #include <refbase.h> 20 #include <string> 21 #include <unordered_map> 22 #include <parcel.h> 23 #include "interfaces/include/ws_common.h" 24 #include "interfaces/include/ws_common_inner.h" 25 #include "wm_common.h" 26 #include "dm_common.h" 27 #include <cfloat> 28 #include "pixel_map.h" 29 30 namespace OHOS { 31 namespace Rosen { 32 class WindowSessionProperty; 33 using HandlWritePropertyFunc = bool (WindowSessionProperty::*)(Parcel& parcel); 34 using HandlReadPropertyFunc = void (WindowSessionProperty::*)(Parcel& parcel); 35 36 class WindowSessionProperty : public Parcelable { 37 public: 38 friend class HidumpController; 39 WindowSessionProperty() = default; 40 ~WindowSessionProperty() = default; 41 explicit WindowSessionProperty(const sptr<WindowSessionProperty>& property); 42 void CopyFrom(const sptr<WindowSessionProperty>& property); 43 void SetWindowName(const std::string& name); 44 void SetSessionInfo(const SessionInfo& info); 45 void SetRequestRect(const struct Rect& rect); 46 void SetWindowRect(const struct Rect& rect); 47 void SetFocusable(bool isFocusable); 48 void SetTouchable(bool isTouchable); 49 void SetDragEnabled(bool dragEnabled); 50 void SetHideNonSystemFloatingWindows(bool hide); 51 void SetForceHide(bool hide); 52 void SetRaiseEnabled(bool raiseEnabled); 53 void SetSystemCalling(bool isSystemCalling); 54 void SetTurnScreenOn(bool turnScreenOn); 55 void SetKeepScreenOn(bool keepScreenOn); 56 void SetRequestedOrientation(Orientation orientation); 57 void SetDefaultRequestedOrientation(Orientation orientation); 58 void SetPrivacyMode(bool isPrivate); 59 void SetSystemPrivacyMode(bool isSystemPrivate); 60 void SetSnapshotSkip(bool isSkip); 61 void SetBrightness(float brightness); 62 void SetDisplayId(uint64_t displayId); 63 void SetWindowType(WindowType type); 64 void SetParentId(int32_t parentId); 65 void SetPersistentId(int32_t persistentId); 66 void SetParentPersistentId(int32_t persistentId); 67 void SetAccessTokenId(uint32_t accessTokenId); 68 void SetTokenState(bool hasToken); 69 void SetMaximizeMode(MaximizeMode mode); 70 void SetWindowMode(WindowMode mode); 71 void SetWindowLimits(const WindowLimits& windowLimits); 72 void SetUserWindowLimits(const WindowLimits& windowLimits); 73 void SetConfigWindowLimitsVP(const WindowLimits& windowLimitsVP); 74 void SetLastLimitsVpr(float vpr); 75 void SetSystemBarProperty(WindowType type, const SystemBarProperty& property); 76 void SetKeyboardSessionGravity(SessionGravity gravity_, uint32_t percent); 77 void SetKeyboardLayoutParams(const KeyboardLayoutParams& params); 78 void SetDecorEnable(bool isDecorEnable); 79 void SetAnimationFlag(uint32_t animationFlag); 80 void SetTransform(const Transform& trans); 81 void SetWindowFlags(uint32_t flags); 82 void SetTopmost(bool topmost); 83 bool IsTopmost() const; 84 void SetMainWindowTopmost(bool isTopmost); 85 bool IsMainWindowTopmost() const; 86 void AddWindowFlag(WindowFlag flag); 87 void SetModeSupportInfo(uint32_t modeSupportInfo); 88 void SetFloatingWindowAppType(bool isAppType); 89 void SetTouchHotAreas(const std::vector<Rect>& rects); 90 void KeepKeyboardOnFocus(bool keepKeyboardFlag); 91 void SetIsNeedUpdateWindowMode(bool isNeedUpdateWindowMode); 92 void SetCallingSessionId(uint32_t sessionId); 93 void SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo); 94 void SetWindowMask(const std::shared_ptr<Media::PixelMap>& windowMask); 95 void SetIsShaped(bool isShaped); 96 void SetCompatibleModeInPc(bool compatibleModeInPc); 97 void SetCompatibleWindowSizeInPc(int32_t portraitWidth, int32_t portraitHeight, 98 int32_t landscapeWidth, int32_t landscapeHeight); 99 void SetIsAppSupportPhoneInPc(bool isSupportPhone); 100 void SetIsSupportDragInPcCompatibleMode(bool isSupportDragInPcCompatibleMode); 101 void SetIsPcAppInPad(bool isPcAppInPad); 102 void SetCompatibleModeEnableInPad(bool enable); 103 104 bool GetIsNeedUpdateWindowMode() const; 105 const std::string& GetWindowName() const; 106 const SessionInfo& GetSessionInfo() const; 107 SessionInfo& EditSessionInfo(); 108 Rect GetWindowRect() const; 109 Rect GetRequestRect() const; 110 WindowType GetWindowType() const; 111 bool GetFocusable() const; 112 bool GetTouchable() const; 113 bool GetDragEnabled() const; 114 bool GetHideNonSystemFloatingWindows() const; 115 bool GetForceHide() const; 116 bool GetRaiseEnabled() const; 117 bool GetSystemCalling() const; 118 bool IsTurnScreenOn() const; 119 bool IsKeepScreenOn() const; 120 Orientation GetRequestedOrientation() const; 121 Orientation GetDefaultRequestedOrientation() const; 122 bool GetPrivacyMode() const; 123 bool GetSystemPrivacyMode() const; 124 bool GetSnapshotSkip() const; 125 float GetBrightness() const; 126 int32_t GetParentId() const; 127 uint32_t GetWindowFlags() const; 128 uint64_t GetDisplayId() const; 129 int32_t GetPersistentId() const; 130 int32_t GetParentPersistentId() const; 131 uint32_t GetAccessTokenId() const; 132 bool GetTokenState() const; 133 MaximizeMode GetMaximizeMode() const; 134 WindowMode GetWindowMode() const; 135 WindowLimits GetWindowLimits() const; 136 WindowLimits GetUserWindowLimits() const; 137 WindowLimits GetConfigWindowLimitsVP() const; 138 float GetLastLimitsVpr() const; 139 uint32_t GetModeSupportInfo() const; 140 std::unordered_map<WindowType, SystemBarProperty> GetSystemBarProperty() const; 141 void GetSessionGravity(SessionGravity& gravity, uint32_t& percent); 142 bool IsDecorEnable(); 143 uint32_t GetAnimationFlag() const; 144 const Transform& GetTransform() const; 145 bool IsFloatingWindowAppType() const; 146 void GetTouchHotAreas(std::vector<Rect>& rects) const; 147 bool GetKeepKeyboardFlag() const; 148 uint32_t GetCallingSessionId() const; 149 PiPTemplateInfo GetPiPTemplateInfo() const; 150 std::shared_ptr<Media::PixelMap> GetWindowMask() const; 151 bool GetIsShaped() const; 152 KeyboardLayoutParams GetKeyboardLayoutParams() const; 153 bool GetCompatibleModeInPc() const; 154 int32_t GetCompatibleInPcPortraitWidth() const; 155 int32_t GetCompatibleInPcPortraitHeight() const; 156 int32_t GetCompatibleInPcLandscapeWidth() const; 157 int32_t GetCompatibleInPcLandscapeHeight() const; 158 bool GetIsAppSupportPhoneInPc() const; 159 bool GetIsPcAppInPad() const; 160 bool GetIsSupportDragInPcCompatibleMode() const; 161 bool GetCompatibleModeEnableInPad() const; 162 163 bool MarshallingWindowLimits(Parcel& parcel) const; 164 static void UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property); 165 bool MarshallingSystemBarMap(Parcel& parcel) const; 166 static void UnMarshallingSystemBarMap(Parcel& parcel, WindowSessionProperty* property); 167 bool MarshallingPiPTemplateInfo(Parcel& parcel) const; 168 static void UnmarshallingPiPTemplateInfo(Parcel& parcel, WindowSessionProperty* property); 169 bool Marshalling(Parcel& parcel) const override; 170 static WindowSessionProperty* Unmarshalling(Parcel& parcel); 171 bool MarshallingWindowMask(Parcel& parcel) const; 172 static void UnmarshallingWindowMask(Parcel& parcel, WindowSessionProperty* property); 173 bool MarshallingMainWindowTopmost(Parcel& parcel) const; 174 static void UnmarshallingMainWindowTopmost(Parcel& parcel, WindowSessionProperty* property); 175 bool MarshallingSessionInfo(Parcel& parcel) const; 176 static bool UnmarshallingSessionInfo(Parcel& parcel, WindowSessionProperty* property); 177 178 void SetTextFieldPositionY(double textFieldPositionY); 179 void SetTextFieldHeight(double textFieldHeight); 180 181 WindowState GetWindowState() const; 182 void SetWindowState(WindowState state); 183 184 double GetTextFieldPositionY() const; 185 double GetTextFieldHeight() const; 186 187 void SetSessionPropertyChangeCallback(std::function<void()>&& callback); 188 bool IsLayoutFullScreen() const; 189 void SetIsLayoutFullScreen(bool isLayoutFullScreen); 190 int32_t GetCollaboratorType() const; 191 void SetCollaboratorType(int32_t collaboratorType); 192 bool Write(Parcel& parcel, WSPropertyChangeAction action); 193 void Read(Parcel& parcel, WSPropertyChangeAction action); 194 void SetFullScreenStart(bool fullScreenStart); 195 bool GetFullScreenStart() const; 196 197 /** 198 * Sub Window 199 */ 200 void SetSubWindowLevel(uint32_t subWindowLevel); 201 uint32_t GetSubWindowLevel() const; 202 203 /* 204 * UIExtension 205 */ 206 void SetRealParentId(int32_t realParentId); 207 int32_t GetRealParentId() const; 208 void SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage); 209 UIExtensionUsage GetUIExtensionUsage() const; 210 void SetIsUIExtFirstSubWindow(bool isUIExtFirstSubWindow); 211 bool GetIsUIExtFirstSubWindow() const; 212 void SetIsUIExtensionAbilityProcess(bool isUIExtensionAbilityProcess); 213 bool GetIsUIExtensionAbilityProcess() const; 214 void SetParentWindowType(WindowType parentWindowType); 215 WindowType GetParentWindowType() const; 216 void SetIsUIExtAnySubWindow(bool isUIExtAnySubWindow); 217 bool GetIsUIExtAnySubWindow() const; 218 219 /* 220 * Multi instance 221 */ 222 void SetAppInstanceKey(const std::string& appInstanceKey); 223 std::string GetAppInstanceKey() const; 224 225 private: 226 bool MarshallingTouchHotAreas(Parcel& parcel) const; 227 static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowSessionProperty* property); 228 bool WriteActionUpdateTurnScreenOn(Parcel& parcel); 229 bool WriteActionUpdateKeepScreenOn(Parcel& parcel); 230 bool WriteActionUpdateFocusable(Parcel& parcel); 231 bool WriteActionUpdateTouchable(Parcel& parcel); 232 bool WriteActionUpdateSetBrightness(Parcel& parcel); 233 bool WriteActionUpdateOrientation(Parcel& parcel); 234 bool WriteActionUpdatePrivacyMode(Parcel& parcel); 235 bool WriteActionUpdateSnapshotSkip(Parcel& parcel); 236 bool WriteActionUpdateMaximizeState(Parcel& parcel); 237 bool WriteActionUpdateSystemBar(Parcel& parcel); 238 bool WriteActionUpdateFlags(Parcel& parcel); 239 bool WriteActionUpdateMode(Parcel& parcel); 240 bool WriteActionUpdateAnimationFlag(Parcel& parcel); 241 bool WriteActionUpdateTouchHotArea(Parcel& parcel); 242 bool WriteActionUpdateDecorEnable(Parcel& parcel); 243 bool WriteActionUpdateWindowLimits(Parcel& parcel); 244 bool WriteActionUpdateDragenabled(Parcel& parcel); 245 bool WriteActionUpdateRaiseenabled(Parcel& parcel); 246 bool WriteActionUpdateHideNonSystemFloatingWindows(Parcel& parcel); 247 bool WriteActionUpdateTextfieldAvoidInfo(Parcel& parcel); 248 bool WriteActionUpdateWindowMask(Parcel& parcel); 249 bool WriteActionUpdateTopmost(Parcel& parcel); 250 bool WriteActionUpdateMainWindowTopmost(Parcel& parcel); 251 bool WriteActionUpdateModeSupportInfo(Parcel& parcel); 252 void ReadActionUpdateTurnScreenOn(Parcel& parcel); 253 void ReadActionUpdateKeepScreenOn(Parcel& parcel); 254 void ReadActionUpdateFocusable(Parcel& parcel); 255 void ReadActionUpdateTouchable(Parcel& parcel); 256 void ReadActionUpdateSetBrightness(Parcel& parcel); 257 void ReadActionUpdateOrientation(Parcel& parcel); 258 void ReadActionUpdatePrivacyMode(Parcel& parcel); 259 void ReadActionUpdateSnapshotSkip(Parcel& parcel); 260 void ReadActionUpdateMaximizeState(Parcel& parcel); 261 void ReadActionUpdateSystemBar(Parcel& parcel); 262 void ReadActionUpdateFlags(Parcel& parcel); 263 void ReadActionUpdateMode(Parcel& parcel); 264 void ReadActionUpdateAnimationFlag(Parcel& parcel); 265 void ReadActionUpdateTouchHotArea(Parcel& parcel); 266 void ReadActionUpdateDecorEnable(Parcel& parcel); 267 void ReadActionUpdateWindowLimits(Parcel& parcel); 268 void ReadActionUpdateDragenabled(Parcel& parcel); 269 void ReadActionUpdateRaiseenabled(Parcel& parcel); 270 void ReadActionUpdateHideNonSystemFloatingWindows(Parcel& parcel); 271 void ReadActionUpdateTextfieldAvoidInfo(Parcel& parcel); 272 void ReadActionUpdateWindowMask(Parcel& parcel); 273 void ReadActionUpdateTopmost(Parcel& parcel); 274 void ReadActionUpdateMainWindowTopmost(Parcel& parcel); 275 void ReadActionUpdateModeSupportInfo(Parcel& parcel); 276 std::string windowName_; 277 SessionInfo sessionInfo_; 278 Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size) 279 Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect 280 WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW }; // type main window 281 bool focusable_ { true }; 282 bool touchable_ { true }; 283 bool dragEnabled_ = { true }; 284 bool raiseEnabled_ = { true }; 285 bool isSystemCalling_ = { false }; 286 bool tokenState_ { false }; 287 bool turnScreenOn_ = false; 288 bool keepScreenOn_ = false; 289 bool topmost_ = false; 290 bool mainWindowTopmost_ = false; 291 Orientation requestedOrientation_ = Orientation::UNSPECIFIED; 292 Orientation defaultRequestedOrientation_ = Orientation::UNSPECIFIED; 293 bool isPrivacyMode_ { false }; 294 bool isSystemPrivacyMode_ { false }; 295 bool isSnapshotSkip_ { false }; 296 float brightness_ = UNDEFINED_BRIGHTNESS; 297 uint64_t displayId_ = 0; 298 int32_t parentId_ = INVALID_SESSION_ID; // parentId of sceneSession, which is low 32 bite of parentPersistentId_ 299 uint32_t flags_ = 0; 300 int32_t persistentId_ = INVALID_SESSION_ID; 301 int32_t parentPersistentId_ = INVALID_SESSION_ID; 302 uint32_t accessTokenId_ = INVALID_SESSION_ID; 303 MaximizeMode maximizeMode_ = MaximizeMode::MODE_RECOVER; 304 WindowMode windowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; 305 WindowState windowState_ = WindowState::STATE_INITIAL; 306 WindowLimits limits_; 307 WindowLimits userLimits_; 308 WindowLimits configLimitsVP_; 309 float lastVpr_ = 0.0f; 310 PiPTemplateInfo pipTemplateInfo_ = {0, 0, {}}; 311 SessionGravity sessionGravity_ = SessionGravity::SESSION_GRAVITY_DEFAULT; 312 KeyboardLayoutParams keyboardLayoutParams_; 313 uint32_t sessionGravitySizePercent_ = 0; 314 uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; 315 std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ { 316 { WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, 317 { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, 318 { WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, 319 }; 320 bool isDecorEnable_ = false; 321 uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) }; 322 // Transform info 323 Transform trans_; 324 bool isFloatingWindowAppType_ = false; 325 mutable std::mutex touchHotAreasMutex_; 326 std::vector<Rect> touchHotAreas_; // coordinates relative to window. 327 bool hideNonSystemFloatingWindows_ = false; 328 bool forceHide_ = false; 329 bool keepKeyboardFlag_ = false; 330 uint32_t callingSessionId_ = INVALID_SESSION_ID; 331 332 double textFieldPositionY_ = 0.0; 333 double textFieldHeight_ = 0.0; 334 bool isNeedUpdateWindowMode_ = false; 335 std::function<void()> touchHotAreasChangeCallback_; 336 bool isLayoutFullScreen_ = false; 337 338 bool isShaped_ = false; 339 bool fullScreenStart_ = false; 340 std::shared_ptr<Media::PixelMap> windowMask_ = nullptr; 341 int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE; 342 static const std::map<uint32_t, HandlWritePropertyFunc> writeFuncMap_; 343 static const std::map<uint32_t, HandlReadPropertyFunc> readFuncMap_; 344 bool compatibleModeInPc_ = false; 345 int32_t compatibleInPcPortraitWidth_ = 0; 346 int32_t compatibleInPcPortraitHeight_ = 0; 347 int32_t compatibleInPcLandscapeWidth_ = 0; 348 int32_t compatibleInPcLandscapeHeight_ = 0; 349 bool isAppSupportPhoneInPc_ = false; 350 bool isSupportDragInPcCompatibleMode_ = false; 351 bool isPcAppInPad_ = false; 352 mutable std::mutex compatibleModeMutex_; 353 bool compatibleModeEnableInPad_ = false; 354 355 /** 356 * Sub Window 357 */ 358 uint32_t subWindowLevel_ = 1; 359 360 /* 361 * UIExtension 362 */ 363 int32_t realParentId_ = INVALID_SESSION_ID; 364 UIExtensionUsage uiExtensionUsage_ { UIExtensionUsage::EMBEDDED }; 365 bool isUIExtFirstSubWindow_ = false; 366 bool isUIExtensionAbilityProcess_ = false; 367 bool isUIExtAnySubWindow_ = false; 368 WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; 369 370 /* 371 * Multi instance 372 */ 373 std::string appInstanceKey_; 374 }; 375 376 struct FreeMultiWindowConfig : public Parcelable { 377 bool isSystemDecorEnable_ = true; 378 uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; 379 WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; 380 uint32_t maxMainFloatingWindowNumber_ = 0; 381 382 virtual bool Marshalling(Parcel& parcel) const override 383 { 384 if (!parcel.WriteBool(isSystemDecorEnable_) || 385 !parcel.WriteUint32(decorModeSupportInfo_)) { 386 return false; 387 } 388 389 if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) || 390 !parcel.WriteUint32(maxMainFloatingWindowNumber_)) { 391 return false; 392 } 393 return true; 394 } 395 UnmarshallingOHOS::Rosen::FreeMultiWindowConfig396 static FreeMultiWindowConfig* Unmarshalling(Parcel& parcel) 397 { 398 FreeMultiWindowConfig* config = new (std::nothrow) FreeMultiWindowConfig(); 399 if (config == nullptr) { 400 return nullptr; 401 } 402 config->isSystemDecorEnable_ = parcel.ReadBool(); 403 config->decorModeSupportInfo_ = parcel.ReadUint32(); 404 config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32()); 405 config->maxMainFloatingWindowNumber_ = parcel.ReadUint32(); 406 return config; 407 } 408 }; 409 410 struct AppForceLandscapeConfig : public Parcelable { 411 int32_t mode_ = 0; 412 std::string homePage_; 413 AppForceLandscapeConfigOHOS::Rosen::AppForceLandscapeConfig414 AppForceLandscapeConfig() {} AppForceLandscapeConfigOHOS::Rosen::AppForceLandscapeConfig415 AppForceLandscapeConfig(int32_t mode, const std::string& homePage) : mode_(mode), homePage_(homePage) {} 416 417 virtual bool Marshalling(Parcel& parcel) const override 418 { 419 if (!parcel.WriteInt32(mode_) || 420 !parcel.WriteString(homePage_)) { 421 return false; 422 } 423 return true; 424 } 425 UnmarshallingOHOS::Rosen::AppForceLandscapeConfig426 static AppForceLandscapeConfig* Unmarshalling(Parcel& parcel) 427 { 428 AppForceLandscapeConfig* config = new (std::nothrow) AppForceLandscapeConfig(); 429 if (config == nullptr) { 430 return nullptr; 431 } 432 config->mode_ = parcel.ReadInt32(); 433 config->homePage_ = parcel.ReadString(); 434 return config; 435 } 436 }; 437 438 struct SystemSessionConfig : public Parcelable { 439 bool isSystemDecorEnable_ = true; 440 uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; 441 bool isStretchable_ = false; 442 WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; 443 KeyboardAnimationCurve animationIn_; 444 KeyboardAnimationCurve animationOut_; 445 // 1920: default max window size 446 uint32_t maxFloatingWindowSize_ = 1920; 447 // 320: default minWidth main window size 448 uint32_t miniWidthOfMainWindow_ = 320; 449 // 240: default minHeight main window size 450 uint32_t miniHeightOfMainWindow_ = 240; 451 // 320: default minWidth sub window size 452 uint32_t miniWidthOfSubWindow_ = 320; 453 // 240: default minHeight sub window size 454 uint32_t miniHeightOfSubWindow_ = 240; 455 bool backgroundswitch = false; 456 bool freeMultiWindowEnable_ = false; 457 bool freeMultiWindowSupport_ = false; 458 FreeMultiWindowConfig freeMultiWindowConfig_; 459 WindowUIType windowUIType_ = WindowUIType::INVALID_WINDOW; 460 bool supportTypeFloatWindow_ = false; 461 462 virtual bool Marshalling(Parcel& parcel) const override 463 { 464 if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) || 465 !parcel.WriteUint32(decorModeSupportInfo_)) { 466 return false; 467 } 468 469 if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) || 470 !parcel.WriteParcelable(&animationIn_) || !parcel.WriteParcelable(&animationOut_) || 471 !parcel.WriteUint32(maxFloatingWindowSize_)) { 472 return false; 473 } 474 475 if (!parcel.WriteUint32(miniWidthOfMainWindow_) || !parcel.WriteUint32(miniHeightOfMainWindow_) || 476 !parcel.WriteUint32(miniWidthOfSubWindow_) || !parcel.WriteUint32(miniHeightOfSubWindow_)) { 477 return false; 478 } 479 480 if (!parcel.WriteBool(backgroundswitch)) { 481 return false; 482 } 483 484 if (!parcel.WriteBool(freeMultiWindowEnable_)) { 485 return false; 486 } 487 488 if (!parcel.WriteBool(freeMultiWindowSupport_)) { 489 return false; 490 } 491 if (!parcel.WriteParcelable(&freeMultiWindowConfig_)) { 492 return false; 493 } 494 if (!parcel.WriteUint8(static_cast<uint8_t>(windowUIType_))) { 495 return false; 496 } 497 if (!parcel.WriteBool(supportTypeFloatWindow_)) { 498 return false; 499 } 500 return true; 501 } 502 UnmarshallingOHOS::Rosen::SystemSessionConfig503 static SystemSessionConfig* Unmarshalling(Parcel& parcel) 504 { 505 SystemSessionConfig* config = new (std::nothrow) SystemSessionConfig(); 506 if (config == nullptr) { 507 return nullptr; 508 } 509 config->isSystemDecorEnable_ = parcel.ReadBool(); 510 config->isStretchable_ = parcel.ReadBool(); 511 config->decorModeSupportInfo_ = parcel.ReadUint32(); 512 config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32()); 513 sptr<KeyboardAnimationCurve> animationIn = parcel.ReadParcelable<KeyboardAnimationCurve>(); 514 if (animationIn == nullptr) { 515 delete config; 516 return nullptr; 517 } 518 config->animationIn_ = *animationIn; 519 sptr<KeyboardAnimationCurve> animationOut = parcel.ReadParcelable<KeyboardAnimationCurve>(); 520 if (animationOut == nullptr) { 521 delete config; 522 return nullptr; 523 } 524 config->animationOut_ = *animationOut; 525 config->maxFloatingWindowSize_ = parcel.ReadUint32(); 526 config->miniWidthOfMainWindow_ = parcel.ReadUint32(); 527 config->miniHeightOfMainWindow_ = parcel.ReadUint32(); 528 config->miniWidthOfSubWindow_ = parcel.ReadUint32(); 529 config->miniHeightOfSubWindow_ = parcel.ReadUint32(); 530 config->backgroundswitch = parcel.ReadBool(); 531 config->freeMultiWindowEnable_ = parcel.ReadBool(); 532 config->freeMultiWindowSupport_ = parcel.ReadBool(); 533 sptr<FreeMultiWindowConfig> freeMultiWindowConfig = parcel.ReadParcelable<FreeMultiWindowConfig>(); 534 if (freeMultiWindowConfig == nullptr) { 535 delete config; 536 return nullptr; 537 } 538 config->freeMultiWindowConfig_ = *freeMultiWindowConfig; 539 config->windowUIType_ = static_cast<WindowUIType>(parcel.ReadUint8()); 540 config->supportTypeFloatWindow_ = parcel.ReadBool(); 541 return config; 542 } 543 IsFreeMultiWindowModeOHOS::Rosen::SystemSessionConfig544 bool IsFreeMultiWindowMode() const 545 { 546 return freeMultiWindowEnable_ && freeMultiWindowSupport_; 547 } 548 IsPhoneWindowOHOS::Rosen::SystemSessionConfig549 bool IsPhoneWindow() const 550 { 551 return windowUIType_ == WindowUIType::PHONE_WINDOW; 552 } 553 IsPcWindowOHOS::Rosen::SystemSessionConfig554 bool IsPcWindow() const 555 { 556 return windowUIType_ == WindowUIType::PC_WINDOW; 557 } 558 IsPadWindowOHOS::Rosen::SystemSessionConfig559 bool IsPadWindow() const 560 { 561 return windowUIType_ == WindowUIType::PAD_WINDOW; 562 } 563 }; 564 } // namespace Rosen 565 } // namespace OHOS 566 #endif // OHOS_ROSEN_WINDOW_PROPERTY_H 567