diff --git a/interfaces/innerkits/wm/window_manager.h b/interfaces/innerkits/wm/window_manager.h index 845f1a2f..fcc8b41c 100644 --- a/interfaces/innerkits/wm/window_manager.h +++ b/interfaces/innerkits/wm/window_manager.h @@ -125,6 +125,11 @@ public: virtual void OnWindowUpdate(const sptr& windowInfo, WindowUpdateType type) = 0; }; +class ICameraFloatWindowChangedListener : virtual public RefBase { +public: + virtual void OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing) = 0; +}; + class WindowManager { WM_DECLARE_SINGLE_INSTANCE_BASE(WindowManager); friend class WindowManagerAgent; @@ -137,6 +142,8 @@ public: void UnregisterWindowUpdateListener(const sptr& listener); void RegisterVisibilityChangedListener(const sptr& listener); void UnregisterVisibilityChangedListener(const sptr& listener); + void RegisterCameraFloatWindowChangedListener(const sptr& listener); + void UnregisterCameraFloatWindowChangedListener(const sptr& listener); void MinimizeAllAppWindows(DisplayId displayId); WMError ToggleShownStateForAllAppWindows(); WMError SetWindowLayoutMode(WindowLayoutMode mode); @@ -155,6 +162,7 @@ private: void NotifyAccessibilityWindowInfo(const sptr& windowInfo, WindowUpdateType type) const; void UpdateWindowVisibilityInfo( const std::vector>& windowVisibilityInfos) const; + void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) const; }; } // namespace Rosen } // namespace OHOS diff --git a/utils/include/window_property.h b/utils/include/window_property.h index e21cf975..7aec8721 100644 --- a/utils/include/window_property.h +++ b/utils/include/window_property.h @@ -72,6 +72,7 @@ public: void SetStretchable(bool stretchable); void SetOriginRect(const Rect& rect); void SetTouchHotAreas(const std::vector& rects); + void SetAccessTokenId(uint32_t accessTokenId); WindowSizeChangeReason GetWindowSizeChangeReason() const; const std::string& GetWindowName() const; @@ -107,6 +108,7 @@ public: bool GetStretchable() const; const Rect& GetOriginRect() const; void GetTouchHotAreas(std::vector& rects) const; + uint32_t GetAccessTokenId() const; virtual bool Marshalling(Parcel& parcel) const override; static WindowProperty* Unmarshalling(Parcel& parcel); @@ -155,6 +157,7 @@ private: bool isStretchable_ {false}; DragType dragType_ = DragType::DRAG_UNDEFINED; std::vector touchHotAreas_; // coordinates relative to window. + uint32_t accessTokenId_ { 0 }; DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, RequestedOrientation, requestedOrientation, Orientation::UNSPECIFIED); }; } diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index b672c1c8..fa4f73d9 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -180,6 +180,11 @@ void WindowProperty::SetOriginRect(const Rect& rect) originRect_ = rect; } +void WindowProperty::SetAccessTokenId(uint32_t accessTokenId) +{ + accessTokenId_ = accessTokenId; +} + WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const { return windowSizeChangeReason_; @@ -375,6 +380,11 @@ void WindowProperty::GetTouchHotAreas(std::vector& rects) const rects = touchHotAreas_; } +uint32_t WindowProperty::GetAccessTokenId() const +{ + return accessTokenId_; +} + bool WindowProperty::MapMarshalling(Parcel& parcel) const { auto size = sysBarPropMap_.size(); @@ -450,7 +460,7 @@ bool WindowProperty::Marshalling(Parcel& parcel) const parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) && parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(static_cast(dragType_)) && parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) && - parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel); + parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_); } WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) @@ -498,6 +508,7 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) property->SetOriginRect(Rect { 0, 0, w, h }); property->SetStretchable(parcel.ReadBool()); UnmarshallingTouchHotAreas(parcel, property); + property->SetAccessTokenId(parcel.ReadUint32()); return property; } @@ -643,6 +654,7 @@ void WindowProperty::CopyFrom(const sptr& property) originRect_ = property->originRect_; isStretchable_ = property->isStretchable_; touchHotAreas_ = property->touchHotAreas_; + accessTokenId_ = property->accessTokenId_; } } } diff --git a/wm/include/window_manager_agent.h b/wm/include/window_manager_agent.h index 5adf8ee6..0e14a94c 100644 --- a/wm/include/window_manager_agent.h +++ b/wm/include/window_manager_agent.h @@ -30,6 +30,7 @@ public: void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& props) override; void NotifyAccessibilityWindowInfo(const sptr& windowInfo, WindowUpdateType type) override; void UpdateWindowVisibilityInfo(const std::vector>& visibilityInfos) override; + void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override; }; } // namespace Rosen } // namespace OHOS diff --git a/wm/include/zidl/window_manager_agent_interface.h b/wm/include/zidl/window_manager_agent_interface.h index 705f5e8c..76c03263 100644 --- a/wm/include/zidl/window_manager_agent_interface.h +++ b/wm/include/zidl/window_manager_agent_interface.h @@ -27,6 +27,7 @@ enum class WindowManagerAgentType : uint32_t { WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR, WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE, WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY, + WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT, }; class IWindowManagerAgent : public IRemoteBroker { @@ -38,6 +39,7 @@ public: TRANS_ID_UPDATE_SYSTEM_BAR_PROPS, TRANS_ID_UPDATE_WINDOW_STATUS, TRANS_ID_UPDATE_WINDOW_VISIBILITY, + TRANS_ID_UPDATE_CAMERA_FLOAT, }; virtual void UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) = 0; @@ -45,6 +47,7 @@ public: virtual void NotifyAccessibilityWindowInfo(const sptr& windowInfo, WindowUpdateType type) = 0; virtual void UpdateWindowVisibilityInfo(const std::vector>& visibilityInfos) = 0; + virtual void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) = 0; }; } // namespace Rosen } // namespace OHOS diff --git a/wm/include/zidl/window_manager_agent_proxy.h b/wm/include/zidl/window_manager_agent_proxy.h index f54ad701..657801d9 100644 --- a/wm/include/zidl/window_manager_agent_proxy.h +++ b/wm/include/zidl/window_manager_agent_proxy.h @@ -31,6 +31,7 @@ public: void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) override; void NotifyAccessibilityWindowInfo(const sptr& windowInfo, WindowUpdateType type) override; void UpdateWindowVisibilityInfo(const std::vector>& visibilityInfos) override; + void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override; private: static inline BrokerDelegator delegator_; diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 66cfeb33..cddff153 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -16,10 +16,11 @@ #include "window_impl.h" #include +#include #include #include -#include +#include "ipc_skeleton.h" #include "color_parser.h" #include "display_manager.h" @@ -2341,6 +2342,9 @@ bool WindowImpl::CheckCameraFloatingWindowMultiCreated(WindowType type) return true; } } + uint32_t accessTokenId = static_cast(IPCSkeleton::GetCallingTokenID()); + property_->SetAccessTokenId(accessTokenId); + WLOGFI("Create camera float window, accessTokenId = %{public}u", accessTokenId); return false; } } // namespace Rosen diff --git a/wm/src/window_manager.cpp b/wm/src/window_manager.cpp index 34aa8956..e16ff519 100644 --- a/wm/src/window_manager.cpp +++ b/wm/src/window_manager.cpp @@ -146,6 +146,7 @@ public: void NotifySystemBarChanged(DisplayId displayId, const SystemBarRegionTints& tints); void NotifyAccessibilityWindowInfo(const sptr& windowInfo, WindowUpdateType type); void NotifyWindowVisibilityInfoChanged(const std::vector>& windowVisibilityInfos); + void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); static inline SingletonDelegator delegator_; bool isHandlerRunning_ = false; @@ -159,6 +160,8 @@ public: sptr windowUpdateListenerAgent_; std::vector> windowVisibilityListeners_; sptr windowVisibilityListenerAgent_; + std::vector> cameraFloatWindowChangedListeners_; + sptr cameraFloatWindowChangedListenerAgent_; }; void WindowManager::Impl::PostTask(ListenerTaskCallback &&callback, EventPriority priority = EventPriority::LOW, @@ -270,6 +273,16 @@ void WindowManager::Impl::NotifyWindowVisibilityInfoChanged( }, EventPriority::LOW, "AccessibilityWindowInfo"); } +void WindowManager::Impl::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) +{ + WLOGFI("Camera float window, accessTokenId = %{public}u, isShowing = %{public}u", accessTokenId, isShowing); + PostTask([this, accessTokenId, isShowing]() mutable { + for (auto& listener : cameraFloatWindowChangedListeners_) { + listener->OnCameraFloatWindowChange(accessTokenId, isShowing); + } + }, EventPriority::LOW, "CameraFloatWindowStatus"); +} + WindowManager::WindowManager() : pImpl_(std::make_unique()) { } @@ -467,6 +480,53 @@ void WindowManager::UnregisterVisibilityChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + WLOGFE("listener could not be null"); + return; + } + + std::lock_guard lock(pImpl_->mutex_); + auto iter = std::find(pImpl_->cameraFloatWindowChangedListeners_.begin(), + pImpl_->cameraFloatWindowChangedListeners_.end(), listener); + if (iter != pImpl_->cameraFloatWindowChangedListeners_.end()) { + WLOGFI("Listener is already registered."); + return; + } + pImpl_->cameraFloatWindowChangedListeners_.push_back(listener); + if (pImpl_->cameraFloatWindowChangedListenerAgent_ == nullptr) { + pImpl_->cameraFloatWindowChangedListenerAgent_ = new WindowManagerAgent(); + SingletonContainer::Get().RegisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT, + pImpl_->cameraFloatWindowChangedListenerAgent_); + } +} + +void WindowManager::UnregisterCameraFloatWindowChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + WLOGFE("listener could not be null"); + return; + } + + std::lock_guard lock(pImpl_->mutex_); + auto iter = std::find(pImpl_->cameraFloatWindowChangedListeners_.begin(), + pImpl_->cameraFloatWindowChangedListeners_.end(), listener); + if (iter == pImpl_->cameraFloatWindowChangedListeners_.end()) { + WLOGFE("could not find this listener"); + return; + } + pImpl_->cameraFloatWindowChangedListeners_.erase(iter); + if (pImpl_->cameraFloatWindowChangedListeners_.empty() && + pImpl_->cameraFloatWindowChangedListenerAgent_ != nullptr) { + SingletonContainer::Get().UnregisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT, + pImpl_->cameraFloatWindowChangedListenerAgent_); + pImpl_->cameraFloatWindowChangedListenerAgent_ = nullptr; + } +} + void WindowManager::UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) const { if (focusChangeInfo == nullptr) { @@ -511,5 +571,11 @@ WMError WindowManager::GetAccessibilityWindowInfo(sptr& } return ret; } + +void WindowManager::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) const +{ + std::lock_guard lock(pImpl_->mutex_); + pImpl_->UpdateCameraFloatWindowStatus(accessTokenId, isShowing); +} } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_manager_agent.cpp b/wm/src/window_manager_agent.cpp index b8328fc4..aa00b692 100644 --- a/wm/src/window_manager_agent.cpp +++ b/wm/src/window_manager_agent.cpp @@ -40,5 +40,10 @@ void WindowManagerAgent::UpdateWindowVisibilityInfo(const std::vector().UpdateWindowVisibilityInfo(visibilityInfos); } + +void WindowManagerAgent::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) +{ + SingletonContainer::Get().UpdateCameraFloatWindowStatus(accessTokenId, isShowing); +} } // namespace Rosen } // namespace OHOS diff --git a/wm/src/zidl/window_manager_agent_proxy.cpp b/wm/src/zidl/window_manager_agent_proxy.cpp index a9112ae1..d2c492f7 100644 --- a/wm/src/zidl/window_manager_agent_proxy.cpp +++ b/wm/src/zidl/window_manager_agent_proxy.cpp @@ -144,6 +144,32 @@ void WindowManagerAgentProxy::UpdateWindowVisibilityInfo( WLOGFE("SendRequest failed"); } } + +void WindowManagerAgentProxy::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return; + } + + if (!data.WriteUint32(accessTokenId)) { + WLOGFE("Write accessTokenId failed"); + return; + } + + if (!data.WriteBool(isShowing)) { + WLOGFE("Write is showing status failed"); + return; + } + + if (Remote()->SendRequest(static_cast(WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + } +} } // namespace Rosen } // namespace OHOS diff --git a/wm/src/zidl/window_manager_agent_stub.cpp b/wm/src/zidl/window_manager_agent_stub.cpp index 558d2ebf..d15facfb 100644 --- a/wm/src/zidl/window_manager_agent_stub.cpp +++ b/wm/src/zidl/window_manager_agent_stub.cpp @@ -84,6 +84,12 @@ int WindowManagerAgentStub::OnRemoteRequest(uint32_t code, MessageParcel& data, UpdateWindowVisibilityInfo(infos); break; } + case WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT: { + uint32_t accessTokenId = data.ReadUint32(); + bool isShowing = data.ReadBool(); + UpdateCameraFloatWindowStatus(accessTokenId, isShowing); + break; + } default: break; } diff --git a/wm/test/systemtest/window_app_floating_window_test.cpp b/wm/test/systemtest/window_app_floating_window_test.cpp index df14fa72..6f42ece0 100644 --- a/wm/test/systemtest/window_app_floating_window_test.cpp +++ b/wm/test/systemtest/window_app_floating_window_test.cpp @@ -16,7 +16,9 @@ // gtest #include #include "ability_context_impl.h" +#include "ipc_skeleton.h" #include "window.h" +#include "window_manager.h" #include "window_option.h" #include "window_scene.h" #include "window_test_utils.h" @@ -27,6 +29,17 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { +namespace { + constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAppFloatingWindowTest"}; +} + +class TestCameraFloatWindowChangedListener : public ICameraFloatWindowChangedListener { +public: + uint32_t accessTokenId_ = 0; + bool isShowing_ = false; + void OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing) override; +}; + class WindowAppFloatingWindowTest : public testing::Test { public: static void SetUpTestCase(); @@ -36,8 +49,19 @@ public: static inline float virtualPixelRatio_ = 1.0; static inline std::shared_ptr abilityContext_ = nullptr; + static sptr testCameraFloatWindowChangedListener_; }; +sptr WindowAppFloatingWindowTest::testCameraFloatWindowChangedListener_ = + new TestCameraFloatWindowChangedListener(); + +void TestCameraFloatWindowChangedListener::OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing) +{ + WLOGFI("TestCameraFloatWindowChangedListener [%{public}u, %{public}u]", accessTokenId, isShowing); + accessTokenId_ = accessTokenId; + isShowing_ = isShowing; +} + void WindowAppFloatingWindowTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); @@ -308,5 +332,65 @@ HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow09, Function | MediumTest ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); } + +/** + * @tc.name: AppFloatingWindow10 + * @tc.desc: Camera AppFloatingWindow multi create + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow10, Function | MediumTest | Level3) +{ + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + sptr fltWin2 = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect); + ASSERT_EQ(nullptr, fltWin2); + + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); + sptr fltWin3 = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect); + ASSERT_NE(nullptr, fltWin3); + + ASSERT_EQ(WMError::WM_OK, fltWin3->Destroy()); + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); +} + +/** + * @tc.name: AppFloatingWindow11 + * @tc.desc: Camera AppFloatingWindow listener + * @tc.type: FUNC + */ +HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow11, Function | MediumTest | Level2) +{ + uint32_t tokenId = static_cast(IPCSkeleton::GetCallingTokenID()); + WindowManager::GetInstance().RegisterCameraFloatWindowChangedListener(testCameraFloatWindowChangedListener_); + sptr scene = CreateWindowScene(); + ASSERT_NE(nullptr, scene); + + Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600); + sptr fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect); + ASSERT_NE(nullptr, fltWin); + + ASSERT_EQ(WMError::WM_OK, scene->GoForeground()); + ASSERT_EQ(WMError::WM_OK, fltWin->Show()); + + usleep(500000); // 500000us = 0.5s + ASSERT_EQ(tokenId, testCameraFloatWindowChangedListener_->accessTokenId_); + ASSERT_EQ(true, testCameraFloatWindowChangedListener_->isShowing_); + + ASSERT_EQ(WMError::WM_OK, fltWin->Hide()); + + usleep(500000); // 500000us = 0.5s + ASSERT_EQ(tokenId, testCameraFloatWindowChangedListener_->accessTokenId_); + ASSERT_EQ(false, testCameraFloatWindowChangedListener_->isShowing_); + + ASSERT_EQ(WMError::WM_OK, fltWin->Destroy()); + ASSERT_EQ(WMError::WM_OK, scene->GoDestroy()); + + WindowManager::GetInstance().UnregisterCameraFloatWindowChangedListener(testCameraFloatWindowChangedListener_); +} } // namespace Rosen } // namespace OHOS diff --git a/wmserver/include/window_manager_agent_controller.h b/wmserver/include/window_manager_agent_controller.h index 02e35d42..30c05d99 100644 --- a/wmserver/include/window_manager_agent_controller.h +++ b/wmserver/include/window_manager_agent_controller.h @@ -35,6 +35,7 @@ public: void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints); void NotifyAccessibilityWindowInfo(const sptr& windowInfo, WindowUpdateType type); void UpdateWindowVisibilityInfo(const std::vector>& windowVisibilityInfos); + void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); private: WindowManagerAgentController() {} diff --git a/wmserver/include/window_node.h b/wmserver/include/window_node.h index 194cbd3c..1406214e 100644 --- a/wmserver/include/window_node.h +++ b/wmserver/include/window_node.h @@ -104,6 +104,7 @@ public: const Rect& GetOriginRect() const; void ResetWindowSizeChangeReason(); void GetTouchHotAreas(std::vector& rects) const; + uint32_t GetAccessTokenId() const; sptr parent_; std::vector> children_; diff --git a/wmserver/include/window_node_container.h b/wmserver/include/window_node_container.h index 1afda27d..e37923df 100644 --- a/wmserver/include/window_node_container.h +++ b/wmserver/include/window_node_container.h @@ -106,6 +106,7 @@ public: sptr GetMultiDisplayController() const; sptr GetRootNode(WindowRootNodeType type) const; void NotifyDockWindowStateChanged(sptr& node, bool isEnable); + void UpdateCameraFloatWindowStatus(const sptr& node, bool isShowing); private: void TraverseWindowNode(sptr& root, std::vector>& windowNodes) const; diff --git a/wmserver/src/window_manager_agent_controller.cpp b/wmserver/src/window_manager_agent_controller.cpp index 812be8bb..2686a809 100644 --- a/wmserver/src/window_manager_agent_controller.cpp +++ b/wmserver/src/window_manager_agent_controller.cpp @@ -74,5 +74,13 @@ void WindowManagerAgentController::UpdateWindowVisibilityInfo( agent->UpdateWindowVisibilityInfo(windowVisibilityInfos); } } + +void WindowManagerAgentController::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) +{ + for (auto& agent : wmAgentContainer_.GetAgentsByType( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT)) { + agent->UpdateCameraFloatWindowStatus(accessTokenId, isShowing); + } +} } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/wmserver/src/window_node.cpp b/wmserver/src/window_node.cpp index a187e915..fbbb02e2 100644 --- a/wmserver/src/window_node.cpp +++ b/wmserver/src/window_node.cpp @@ -348,5 +348,10 @@ void WindowNode::GetTouchHotAreas(std::vector& rects) const { rects = touchHotAreas_; } + +uint32_t WindowNode::GetAccessTokenId() const +{ + return property_->GetAccessTokenId(); +} } // namespace Rosen } // namespace OHOS diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index fdc02692..ae993458 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -183,7 +183,7 @@ WMError WindowNodeContainer::AddWindowNode(sptr& node, sptrGetWindowId()); + UpdateCameraFloatWindowStatus(node, true); if (WindowHelper::IsAppWindow(node->GetWindowType())) { backupWindowIds_.clear(); } @@ -191,6 +191,7 @@ WMError WindowNodeContainer::AddWindowNode(sptr& node, sptrGetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD) { isScreenLocked_ = true; } + WLOGFI("AddWindowNode windowId: %{public}u end", node->GetWindowId()); return WMError::WM_OK; } @@ -301,6 +302,7 @@ WMError WindowNodeContainer::RemoveWindowNode(sptr& node) DumpScreenWindowTree(); NotifyAccessibilityWindowInfo(node, WindowUpdateType::WINDOW_UPDATE_REMOVED); RecoverScreenDefaultOrientationIfNeed(node->GetDisplayId()); + UpdateCameraFloatWindowStatus(node, false); if (node->GetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD) { isScreenLocked_ = false; } @@ -1880,5 +1882,12 @@ Orientation WindowNodeContainer::GetFullScreenWindowRequestedOrientation() } return Orientation::UNSPECIFIED; } + +void WindowNodeContainer::UpdateCameraFloatWindowStatus(const sptr& node, bool isShowing) +{ + if (node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) { + WindowManagerAgentController::GetInstance().UpdateCameraFloatWindowStatus(node->GetAccessTokenId(), isShowing); + } +} } // namespace Rosen } // namespace OHOS