diff --git a/utils/include/serialize_helper.h b/utils/include/serialize_helper.h new file mode 100644 index 00000000..7907b086 --- /dev/null +++ b/utils/include/serialize_helper.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ROSEN_SERIALIZE_HELPER +#define OHOS_ROSEN_SERIALIZE_HELPER + +namespace OHOS { +namespace Rosen { +enum PrimitiveType { + // commom type + PT_Uint32, + PT_Float, + PT_Bool, + PT_String, + PT_Rect, + // custom type + PT_SysBarPropMap, +}; + +struct MemberVariable { + PrimitiveType primitiveType_; + size_t offset_; +}; +} +} +#endif // OHOS_ROSEN_SERIALIZE_HELPER \ No newline at end of file diff --git a/utils/include/window_property.h b/utils/include/window_property.h index 0008606a..d60771bd 100644 --- a/utils/include/window_property.h +++ b/utils/include/window_property.h @@ -25,11 +25,47 @@ #include "dm_common.h" #include "wm_common.h" #include "wm_common_inner.h" +#include "serialize_helper.h" namespace OHOS { namespace Rosen { class WindowProperty : public Parcelable { public: + enum WindowPropertyReplicationState : uint64_t { + WPRS_WindowName = 1 << 0, + WPRS_WindowRect = 1 << 1, + WPRS_RequestRect = 1 << 2, + WPRS_DecoStatus = 1 << 3, + WPRS_Type = 1 << 4, + WPRS_Mode = 1 << 5, + WPRS_LastMode = 1 << 6, + WPRS_Level = 1 << 7, + WPRS_Flags = 1 << 8, + WPRS_IsFullScreen = 1 << 9, + WPRS_Focusable = 1 << 10, + WPRS_Touchable = 1 << 11, + WPRS_IsPrivacyMode = 1 << 12, + WPRS_IsTransparent = 1 << 13, + WPRS_Alpha = 1 << 14, + WPRS_Brightness = 1 << 15, + WPRS_DisplayId = 1 << 16, + WPRS_WindowId = 1 << 17, + WPRS_ParentId = 1 << 18, + WPRS_SysBarPropMap = 1 << 19, + WPRS_IsDecorEnable = 1 << 20, + WPRS_HitOffset = 1 << 21, + WPRS_AnimationFlag = 1 << 22, + WPRS_WindowSizeChangeReason = 1 << 23, + WPRS_TokenState = 1 << 24, + WPRS_CallingWindow = 1 << 25, + WPRS_RequestedOrientation = 1 << 26, + WPRS_TurnScreenOn = 1 << 27, + WPRS_KeepScreenOn = 1 << 28, + WPRS_ModeSupportInfo = 1 << 29, + WPRS_DragType = 1 << 30, + WPRS_OriginRect = static_cast(1) << 31, + WPRS_IsStretchable = static_cast(1) << 32, + }; WindowProperty() = default; WindowProperty(const sptr& property); ~WindowProperty() = default; @@ -108,10 +144,17 @@ public: virtual bool Marshalling(Parcel& parcel) const override; static WindowProperty* Unmarshalling(Parcel& parcel); + + bool Write(Parcel& parcel, uint64_t inDirtyState); + void Read(Parcel& parcel); private: bool MapMarshalling(Parcel& parcel) const; static void MapUnmarshalling(Parcel& parcel, WindowProperty* property); + bool WriteMemberVariable(Parcel& parcel, const MemberVariable& mv); + void ReadMemberVariable(Parcel& parcel, const MemberVariable& mv); + static const std::unordered_map dataTypeMap_; + std::string windowName_; Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size) Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index d8573dbf..6bf6ee91 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -19,7 +19,44 @@ namespace OHOS { namespace Rosen { -WindowProperty::WindowProperty(const sptr& property) +const std::unordered_map WindowProperty::dataTypeMap_ = { + {WPRS_RequestRect, {PrimitiveType::PT_Rect, + (size_t) & (static_cast(nullptr)->requestRect_)}}, + {WPRS_DecoStatus, {PrimitiveType::PT_Bool, + (size_t) & (static_cast(nullptr)->decoStatus_)}}, + {WPRS_Mode, {PrimitiveType::PT_Uint32, + (size_t) & (static_cast(nullptr)->mode_)}}, + {WPRS_Flags, {PrimitiveType::PT_Uint32, + (size_t) & (static_cast(nullptr)->flags_)}}, + {WPRS_Focusable, {PrimitiveType::PT_Bool, + (size_t) & (static_cast(nullptr)->focusable_)}}, + {WPRS_Touchable, {PrimitiveType::PT_Bool, + (size_t) & (static_cast(nullptr)->touchable_)}}, + {WPRS_Brightness, {PrimitiveType::PT_Float, + (size_t) & (static_cast(nullptr)->brightness_)}}, + {WPRS_WindowId, {PrimitiveType::PT_Uint32, + (size_t) & (static_cast(nullptr)->windowId_)}}, + {WPRS_SysBarPropMap, {PrimitiveType::PT_SysBarPropMap, + (size_t) & (static_cast(nullptr)->sysBarPropMap_)}}, + {WPRS_WindowSizeChangeReason, {PrimitiveType::PT_Uint32, + (size_t) & (static_cast(nullptr)->windowSizeChangeReason_)}}, + {WPRS_CallingWindow, {PrimitiveType::PT_Uint32, + (size_t) & (static_cast(nullptr)->callingWindow_)}}, + {WPRS_RequestedOrientation, {PrimitiveType::PT_Uint32, + (size_t) & (static_cast(nullptr)->requestedOrientation_)}}, + {WPRS_TurnScreenOn, {PrimitiveType::PT_Bool, + (size_t) & (static_cast(nullptr)->turnScreenOn_)}}, + {WPRS_KeepScreenOn, {PrimitiveType::PT_Bool, + (size_t) & (static_cast(nullptr)->keepScreenOn_)}}, + {WPRS_ModeSupportInfo, {PrimitiveType::PT_Uint32, + (size_t) & (static_cast(nullptr)->modeSupportInfo_)}}, + {WPRS_DragType, {PrimitiveType::PT_Uint32, + (size_t) & (static_cast(nullptr)->dragType_)}}, + {WPRS_OriginRect, {PrimitiveType::PT_Rect, + (size_t) & (static_cast(nullptr)->originRect_)}}, +}; + +WindowProperty::WindowProperty(const sptr &property) { CopyFrom(property); } @@ -467,6 +504,108 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) return property; } +bool WindowProperty::WriteMemberVariable(Parcel& parcel, const MemberVariable& mv) +{ + void* mvData = reinterpret_cast(this) + mv.offset_; + switch (mv.primitiveType_) { + case PrimitiveType::PT_Uint32: + if (!parcel.WriteUint32(*reinterpret_cast(mvData))) { + return false; + } + break; + case PrimitiveType::PT_Float: + if (!parcel.WriteFloat(*reinterpret_cast(mvData))) { + return false; + } + break; + case PrimitiveType::PT_Bool: + if (!parcel.WriteBool(*reinterpret_cast(mvData))) { + return false; + } + break; + case PrimitiveType::PT_String: + if (!parcel.WriteString(*reinterpret_cast(mvData))) { + return false; + } + break; + case PrimitiveType::PT_Rect: + if (!parcel.WriteInt32(reinterpret_cast(mvData)->posX_) || + !parcel.WriteInt32(reinterpret_cast(mvData)->posY_) || + !parcel.WriteUint32(reinterpret_cast(mvData)->width_) || + !parcel.WriteUint32(reinterpret_cast(mvData)->height_)) { + return false; + } + break; + case PrimitiveType::PT_SysBarPropMap: + if (!MapMarshalling(parcel)) { + return false; + } + break; + default: + break; + } + return true; +} +void WindowProperty::ReadMemberVariable(Parcel& parcel, const MemberVariable& mv) +{ + void* mvData = reinterpret_cast(this) + mv.offset_; + switch (mv.primitiveType_) { + case PrimitiveType::PT_Uint32: + *reinterpret_cast(mvData) = parcel.ReadUint32(); + break; + case PrimitiveType::PT_Float: + *reinterpret_cast(mvData) = parcel.ReadFloat(); + break; + case PrimitiveType::PT_Bool: + *reinterpret_cast(mvData) = parcel.ReadBool(); + break; + case PrimitiveType::PT_String: + *reinterpret_cast(mvData) = parcel.ReadString(); + break; + case PrimitiveType::PT_Rect: + *reinterpret_cast(mvData) = { + parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32() }; + break; + case PrimitiveType::PT_SysBarPropMap: + MapUnmarshalling(parcel, this); + break; + default: + break; + } +} + +bool WindowProperty::Write(Parcel& parcel, uint64_t inDirtyState) +{ + uint64_t dirtyState = inDirtyState; + uint64_t replicationState; + if (!parcel.WriteUint64(inDirtyState)) { + return false; + } + while (dirtyState) { + replicationState = dirtyState & (~dirtyState + 1); + if (dataTypeMap_.count(replicationState)) { + if (!WriteMemberVariable(parcel, dataTypeMap_.at(replicationState))) { + return false; + } + } + dirtyState -= replicationState; + } + return true; +} + +void WindowProperty::Read(Parcel& parcel) +{ + uint64_t dirtyState = parcel.ReadUint64(); + uint64_t replicationState; + while (dirtyState) { + replicationState = dirtyState & (~dirtyState + 1); + if (dataTypeMap_.count(replicationState)) { + ReadMemberVariable(parcel, dataTypeMap_.at(replicationState)); + } + dirtyState -= replicationState; + } +} + void WindowProperty::CopyFrom(const sptr& property) { windowName_ = property->windowName_; diff --git a/wm/include/window_adapter.h b/wm/include/window_adapter.h index e85fb3d2..db9cd225 100644 --- a/wm/include/window_adapter.h +++ b/wm/include/window_adapter.h @@ -51,7 +51,8 @@ public: virtual WMError ToggleShownStateForAllAppWindows(); virtual WMError MaxmizeWindow(uint32_t windowId); virtual WMError SetWindowLayoutMode(WindowLayoutMode mode); - virtual WMError UpdateProperty(sptr& windowProperty, PropertyChangeAction action); + virtual WMError UpdateProperty(sptr& windowProperty, + PropertyChangeAction action, uint64_t dirtyState); virtual WMError GetSystemConfig(SystemConfig& systemConfig); virtual WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones); diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index a6696711..91554ada 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -245,10 +245,11 @@ WMError WindowAdapter::SetWindowLayoutMode(WindowLayoutMode mode) return windowManagerServiceProxy_->SetWindowLayoutMode(mode); } -WMError WindowAdapter::UpdateProperty(sptr& windowProperty, PropertyChangeAction action) +WMError WindowAdapter::UpdateProperty(sptr& windowProperty, + PropertyChangeAction action, uint64_t dirtyState) { INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); - return windowManagerServiceProxy_->UpdateProperty(windowProperty, action); + return windowManagerServiceProxy_->UpdateProperty(windowProperty, action, dirtyState); } WMError WindowAdapter::NotifyWindowTransition(sptr from, sptr to) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 127f4c92..313fafb4 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -619,7 +619,51 @@ void WindowImpl::MapFloatingWindowToAppIfNeeded() WMError WindowImpl::UpdateProperty(PropertyChangeAction action) { - return SingletonContainer::Get().UpdateProperty(property_, action); + uint64_t dirtyState = 0; + dirtyState |= WindowProperty::WPRS_WindowId; + switch (action) { + case PropertyChangeAction::ACTION_UPDATE_RECT: + dirtyState |= WindowProperty::WPRS_DecoStatus | WindowProperty::WPRS_DragType | + WindowProperty::WPRS_OriginRect | WindowProperty::WPRS_RequestRect | + WindowProperty::WPRS_WindowSizeChangeReason; + break; + case PropertyChangeAction::ACTION_UPDATE_MODE: + dirtyState |= WindowProperty::WPRS_Mode; + break; + case PropertyChangeAction::ACTION_UPDATE_FLAGS: + dirtyState |= WindowProperty::WPRS_Flags; + break; + case PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS: + dirtyState |= WindowProperty::WPRS_SysBarPropMap; + break; + case PropertyChangeAction::ACTION_UPDATE_FOCUSABLE: + dirtyState |= WindowProperty::WPRS_Focusable; + break; + case PropertyChangeAction::ACTION_UPDATE_TOUCHABLE: + dirtyState |= WindowProperty::WPRS_Touchable; + break; + case PropertyChangeAction::ACTION_UPDATE_CALLING_WINDOW: + dirtyState |= WindowProperty::WPRS_CallingWindow; + break; + case PropertyChangeAction::ACTION_UPDATE_ORIENTATION: + dirtyState |= WindowProperty::WPRS_RequestedOrientation; + break; + case PropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON: + dirtyState |= WindowProperty::WPRS_TurnScreenOn; + break; + case PropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON: + dirtyState |= WindowProperty::WPRS_KeepScreenOn; + break; + case PropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS: + dirtyState |= WindowProperty::WPRS_Brightness; + break; + case PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: + dirtyState |= WindowProperty::WPRS_ModeSupportInfo; + break; + default: + break; + } + return SingletonContainer::Get().UpdateProperty(property_, action, dirtyState); } WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr& context) diff --git a/wm/test/unittest/mock_window_adapter.h b/wm/test/unittest/mock_window_adapter.h index eda3cefc..e4132de3 100644 --- a/wm/test/unittest/mock_window_adapter.h +++ b/wm/test/unittest/mock_window_adapter.h @@ -31,7 +31,8 @@ public: MOCK_METHOD1(DestroyWindow, WMError(uint32_t windowId)); MOCK_METHOD2(SetWindowBackgroundBlur, WMError(uint32_t windowId, WindowBlurLevel level)); MOCK_METHOD2(SetAlpha, WMError(uint32_t windowId, float alpha)); - MOCK_METHOD2(UpdateProperty, WMError(sptr& windowProperty, PropertyChangeAction action)); + MOCK_METHOD3(UpdateProperty, WMError(sptr& windowProperty, + PropertyChangeAction action, uint64_t dirtyState)); MOCK_METHOD1(MaxmizeWindow, WMError(uint32_t windowId)); }; } diff --git a/wm/test/unittest/window_impl_test.cpp b/wm/test/unittest/window_impl_test.cpp index df3ffbab..b38c9cff 100644 --- a/wm/test/unittest/window_impl_test.cpp +++ b/wm/test/unittest/window_impl_test.cpp @@ -549,7 +549,7 @@ HWTEST_F(WindowImplTest, SetSystemBarProperty02, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Show(); - EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR)); + EXPECT_CALL(m->Mock(), UpdateProperty(_, _, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR)); WindowType type = WindowType::WINDOW_TYPE_STATUS_BAR; const SystemBarProperty SYS_BAR_PROP(false, 0xE5222222, 0xE5333333); ASSERT_EQ(WMError::WM_ERROR_SAMGR, window->SetSystemBarProperty(type, SYS_BAR_PROP)); @@ -590,7 +590,7 @@ HWTEST_F(WindowImplTest, GetSystemBarPropertyByType01, Function | SmallTest | Le EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); - EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); + EXPECT_CALL(m->Mock(), UpdateProperty(_, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); WindowType type = WindowType::WINDOW_TYPE_STATUS_BAR; const SystemBarProperty SYS_BAR_PROP(false, 0xE5222222, 0xE5333344); ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperty(type, SYS_BAR_PROP)); @@ -617,7 +617,7 @@ HWTEST_F(WindowImplTest, GetSystemBarPropertyByType02, Function | SmallTest | Le EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Show(); - EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); + EXPECT_CALL(m->Mock(), UpdateProperty(_, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); const SystemBarProperty SYS_BAR_PROP(false, 0xE5222222, 0xE5333333); const SystemBarProperty DEFAULT_PROP; ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, SYS_BAR_PROP)); @@ -644,7 +644,7 @@ HWTEST_F(WindowImplTest, GetSystemBarPropertyByType03, Function | SmallTest | Le EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Show(); - EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); + EXPECT_CALL(m->Mock(), UpdateProperty(_, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); const SystemBarProperty SYS_BAR_PROP(false, 0xE5222222, 0xE5333366); const SystemBarProperty DEFAULT_PROP; ASSERT_EQ(WMError::WM_OK, window->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, SYS_BAR_PROP)); @@ -698,7 +698,7 @@ HWTEST_F(WindowImplTest, Recover01, Function | SmallTest | Level3) window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Show(); - EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); + EXPECT_CALL(m->Mock(), UpdateProperty(_, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); window->Recover(); ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode()); EXPECT_CALL(m->Mock(), RemoveWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); @@ -1042,7 +1042,7 @@ HWTEST_F(WindowImplTest, SetTurnScreenOn02, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_FALSE(window->IsTurnScreenOn()); - EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2).WillOnce(Return(WMError::WM_OK)) + EXPECT_CALL(m->Mock(), UpdateProperty(_, _, _)).Times(2).WillOnce(Return(WMError::WM_OK)) .WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->SetTurnScreenOn(true)); ASSERT_TRUE(window->IsTurnScreenOn()); @@ -1096,7 +1096,7 @@ HWTEST_F(WindowImplTest, SetKeepScreenOn02, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_FALSE(window->IsKeepScreenOn()); - EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2).WillOnce(Return(WMError::WM_OK)) + EXPECT_CALL(m->Mock(), UpdateProperty(_, _, _)).Times(2).WillOnce(Return(WMError::WM_OK)) .WillOnce(Return(WMError::WM_OK));; ASSERT_EQ(WMError::WM_OK, window->SetKeepScreenOn(true)); ASSERT_TRUE(window->IsKeepScreenOn()); @@ -1152,7 +1152,7 @@ HWTEST_F(WindowImplTest, SetBrightness02, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(UNDEFINED_BRIGHTNESS, window->GetBrightness()); - EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2).WillOnce(Return(WMError::WM_OK)) + EXPECT_CALL(m->Mock(), UpdateProperty(_, _, _)).Times(2).WillOnce(Return(WMError::WM_OK)) .WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->SetBrightness(MAXIMUM_BRIGHTNESS)); ASSERT_EQ(MAXIMUM_BRIGHTNESS, window->GetBrightness()); @@ -1234,7 +1234,7 @@ HWTEST_F(WindowImplTest, SetFocusable02, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_TRUE(window->GetFocusable()); - EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2).WillOnce(Return(WMError::WM_OK)) + EXPECT_CALL(m->Mock(), UpdateProperty(_, _, _)).Times(2).WillOnce(Return(WMError::WM_OK)) .WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->SetFocusable(false)); ASSERT_FALSE(window->GetFocusable()); @@ -1290,7 +1290,7 @@ HWTEST_F(WindowImplTest, SetTouchable02, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_TRUE(window->GetTouchable()); - EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2).WillOnce(Return(WMError::WM_OK)) + EXPECT_CALL(m->Mock(), UpdateProperty(_, _, _)).Times(2).WillOnce(Return(WMError::WM_OK)) .WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->SetTouchable(false)); ASSERT_FALSE(window->GetTouchable()); diff --git a/wmserver/include/window_manager_service.h b/wmserver/include/window_manager_service.h index f6adb418..d35e7870 100644 --- a/wmserver/include/window_manager_service.h +++ b/wmserver/include/window_manager_service.h @@ -82,7 +82,8 @@ public: WMError ToggleShownStateForAllAppWindows() override; WMError MaxmizeWindow(uint32_t windowId) override; WMError SetWindowLayoutMode(WindowLayoutMode mode) override; - WMError UpdateProperty(sptr& windowProperty, PropertyChangeAction action) override; + WMError UpdateProperty(sptr& windowProperty, + PropertyChangeAction action, uint64_t dirtyState) override; WMError GetAccessibilityWindowInfo(sptr& windowInfo) override; WMError HandleAddWindow(sptr& property); diff --git a/wmserver/include/zidl/window_manager_interface.h b/wmserver/include/zidl/window_manager_interface.h index a445b9da..47551202 100644 --- a/wmserver/include/zidl/window_manager_interface.h +++ b/wmserver/include/zidl/window_manager_interface.h @@ -78,7 +78,8 @@ public: virtual WMError ToggleShownStateForAllAppWindows() = 0; virtual WMError MaxmizeWindow(uint32_t windowId) = 0; virtual WMError SetWindowLayoutMode(WindowLayoutMode mode) = 0; - virtual WMError UpdateProperty(sptr& windowProperty, PropertyChangeAction action) = 0; + virtual WMError UpdateProperty(sptr& windowProperty, + PropertyChangeAction action, uint64_t dirtyState = 0) = 0; virtual void RegisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) = 0; virtual void UnregisterWindowManagerAgent(WindowManagerAgentType type, diff --git a/wmserver/include/zidl/window_manager_proxy.h b/wmserver/include/zidl/window_manager_proxy.h index ad8d7f8a..a34fce8e 100644 --- a/wmserver/include/zidl/window_manager_proxy.h +++ b/wmserver/include/zidl/window_manager_proxy.h @@ -45,7 +45,8 @@ public: WMError ToggleShownStateForAllAppWindows() override; WMError MaxmizeWindow(uint32_t windowId) override; WMError SetWindowLayoutMode(WindowLayoutMode mode) override; - WMError UpdateProperty(sptr& windowProperty, PropertyChangeAction action) override; + WMError UpdateProperty(sptr& windowProperty, + PropertyChangeAction action, uint64_t dirtyState) override; void RegisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 9326a2a3..8a974b78 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -544,7 +544,8 @@ WMError WindowManagerService::SetWindowLayoutMode(WindowLayoutMode mode) }).get(); } -WMError WindowManagerService::UpdateProperty(sptr& windowProperty, PropertyChangeAction action) +WMError WindowManagerService::UpdateProperty(sptr& windowProperty, + PropertyChangeAction action, uint64_t dirtyState) { if (windowProperty == nullptr) { WLOGFE("property is invalid"); diff --git a/wmserver/src/zidl/window_manager_proxy.cpp b/wmserver/src/zidl/window_manager_proxy.cpp index 8afcfc42..3ef54854 100644 --- a/wmserver/src/zidl/window_manager_proxy.cpp +++ b/wmserver/src/zidl/window_manager_proxy.cpp @@ -476,7 +476,8 @@ WMError WindowManagerProxy::SetWindowLayoutMode(WindowLayoutMode mode) return static_cast(ret); } -WMError WindowManagerProxy::UpdateProperty(sptr& windowProperty, PropertyChangeAction action) +WMError WindowManagerProxy::UpdateProperty(sptr& windowProperty, + PropertyChangeAction action, uint64_t dirtyState) { MessageParcel data; MessageParcel reply; @@ -486,7 +487,7 @@ WMError WindowManagerProxy::UpdateProperty(sptr& windowProperty, return WMError::WM_ERROR_IPC_FAILED; } - if (!data.WriteParcelable(windowProperty.GetRefPtr())) { + if (!windowProperty->Write(data, dirtyState)) { WLOGFE("Write windowProperty failed"); return WMError::WM_ERROR_IPC_FAILED; } diff --git a/wmserver/src/zidl/window_manager_stub.cpp b/wmserver/src/zidl/window_manager_stub.cpp index f6d59556..c9776c03 100644 --- a/wmserver/src/zidl/window_manager_stub.cpp +++ b/wmserver/src/zidl/window_manager_stub.cpp @@ -159,7 +159,8 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M break; } case WindowManagerMessage::TRANS_ID_UPDATE_PROPERTY: { - sptr windowProperty = data.ReadStrongParcelable(); + sptr windowProperty = new WindowProperty(); + windowProperty->Read(data); PropertyChangeAction action = static_cast(data.ReadUint32()); WMError errCode = UpdateProperty(windowProperty, action); reply.WriteInt32(static_cast(errCode));