diff --git a/wmserver/include/window_manager_service.h b/wmserver/include/window_manager_service.h index 0eff4459..5b214eb6 100644 --- a/wmserver/include/window_manager_service.h +++ b/wmserver/include/window_manager_service.h @@ -108,9 +108,9 @@ public: void MinimizeWindowsByLauncher(std::vector windowIds, bool isAnimated, sptr& finishCallback) override; void GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation); - void OnAccountSwitched() const; WMError UpdateRsTree(uint32_t windowId, bool isAdd) override; void OnScreenshot(DisplayId displayId); + void OnAccountSwitched(int accountId) const; protected: WindowManagerService(); virtual ~WindowManagerService() = default; diff --git a/wmserver/include/window_node_container.h b/wmserver/include/window_node_container.h index 8cd68ad1..621441e0 100644 --- a/wmserver/include/window_node_container.h +++ b/wmserver/include/window_node_container.h @@ -110,7 +110,7 @@ public: void BeforeProcessWindowAvoidAreaChangeWhenDisplayChange() const; void ProcessWindowAvoidAreaChangeWhenDisplayChange() const; WindowLayoutMode GetCurrentLayoutMode() const; - void RemoveSingleUserWindowNodes(); + void RemoveSingleUserWindowNodes(int accountId); WMError IsTileRectSatisfiedWithSizeLimits(sptr& node); private: diff --git a/wmserver/include/window_root.h b/wmserver/include/window_root.h index b3374e97..05874d07 100644 --- a/wmserver/include/window_root.h +++ b/wmserver/include/window_root.h @@ -96,8 +96,8 @@ public: void SetSplitRatios(const std::vector& splitRatioNumbers); void SetExitSplitRatios(const std::vector& exitSplitRatios); void MinimizeTargetWindows(std::vector& windowIds); - void RemoveSingleUserWindowNodes(); WMError UpdateRsTree(uint32_t windowId, bool isAdd); + void RemoveSingleUserWindowNodes(int accountId); private: void OnRemoteDied(const sptr& remoteObject); WMError DestroyWindowInner(sptr& node); diff --git a/wmserver/src/window_common_event.cpp b/wmserver/src/window_common_event.cpp index 3d15bcfa..dcc50596 100644 --- a/wmserver/src/window_common_event.cpp +++ b/wmserver/src/window_common_event.cpp @@ -90,7 +90,8 @@ void WindowCommonEvent::OnReceiveEvent(const EventFwk::CommonEventData& data) void WindowCommonEvent::HandleAccountSwitched(const EventFwk::CommonEventData& data) const { - WindowManagerService::GetInstance().OnAccountSwitched(); + int accountId = data.GetCode(); + WindowManagerService::GetInstance().OnAccountSwitched(accountId); } } // Rosen } // OHOS \ No newline at end of file diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 45d1ddba..c6d1abef 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -93,10 +93,10 @@ void WindowManagerService::OnAddSystemAbility(int32_t systemAbilityId, const std } } -void WindowManagerService::OnAccountSwitched() const +void WindowManagerService::OnAccountSwitched(int accountId) const { - wmsTaskLooper_->PostTask([this]() { - windowRoot_->RemoveSingleUserWindowNodes(); + wmsTaskLooper_->PostTask([this, accountId]() { + windowRoot_->RemoveSingleUserWindowNodes(accountId); }); WLOGFI("called"); } diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index d32f8feb..2cfcd930 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -43,6 +43,8 @@ namespace { constexpr uint32_t MAX_BRIGHTNESS = 255; constexpr uint32_t SPLIT_WINDOWS_CNT = 2; constexpr uint32_t EXIT_SPLIT_POINTS_NUMBER = 2; + constexpr int UID_TRANSFROM_DIVISOR = 20000; + constexpr int UID_MIN = 100; } WindowNodeContainer::WindowNodeContainer(const sptr& displayInfo, ScreenId displayGroupId) @@ -1898,21 +1900,20 @@ WindowLayoutMode WindowNodeContainer::GetCurrentLayoutMode() const return layoutMode_; } -void WindowNodeContainer::RemoveSingleUserWindowNodes() +void WindowNodeContainer::RemoveSingleUserWindowNodes(int accountId) { std::vector> windowNodes; TraverseContainer(windowNodes); + WLOGFI("%{public}d", accountId); for (auto& windowNode : windowNodes) { - if (windowNode->GetWindowType() == WindowType::WINDOW_TYPE_DESKTOP || - windowNode->GetWindowType() == WindowType::WINDOW_TYPE_STATUS_BAR || - windowNode->GetWindowType() == WindowType::WINDOW_TYPE_NAVIGATION_BAR || - windowNode->GetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD || - windowNode->GetWindowType() == WindowType::WINDOW_TYPE_POINTER || - windowNode->GetWindowType() == WindowType::WINDOW_TYPE_BOOT_ANIMATION) { + int windowAccountId = windowNode->GetCallingUid() / UID_TRANSFROM_DIVISOR; + if (windowAccountId < UID_MIN || windowAccountId == accountId) { + WLOGFI("skiped window %{public}s, windowId %{public}d uid %{public}d", + windowNode->GetWindowName().c_str(), windowNode->GetWindowId(), windowNode->GetCallingUid()); continue; } - WLOGFI("remove window %{public}s, windowId %{public}d", - windowNode->GetWindowName().c_str(), windowNode->GetWindowId()); + WLOGFI("remove window %{public}s, windowId %{public}d uid %{public}d", + windowNode->GetWindowName().c_str(), windowNode->GetWindowId(), windowNode->GetCallingUid()); windowNode->GetWindowProperty()->SetAnimationFlag(static_cast(WindowAnimation::NONE)); RemoveWindowNode(windowNode); } diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index d0cf985a..f00799a0 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -1333,7 +1333,7 @@ WMError WindowRoot::GetModeChangeHotZones(DisplayId displayId, return WMError::WM_OK; } -void WindowRoot::RemoveSingleUserWindowNodes() +void WindowRoot::RemoveSingleUserWindowNodes(int accountId) { std::vector displayIds = GetAllDisplayIds(); for (auto id : displayIds) { @@ -1342,7 +1342,7 @@ void WindowRoot::RemoveSingleUserWindowNodes() WLOGFI("get container failed %{public}" PRIu64"", id); continue; } - container->RemoveSingleUserWindowNodes(); + container->RemoveSingleUserWindowNodes(accountId); } }