From 573e474ca8f422ee0877e8b80f7f917f4d1937eb Mon Sep 17 00:00:00 2001 From: dubj Date: Wed, 13 Jul 2022 11:30:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=A6=E6=88=B7=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E5=88=A4=E6=96=AD=E6=96=B9=E5=BC=8F=EF=BC=8C=E9=80=9A?= =?UTF-8?q?=E8=BF=87uid=E6=9D=A5=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dubj Change-Id: I52bf1465f0558fadf7ef21dd19a4aed79ab5f87b --- wmserver/include/window_manager_service.h | 2 +- wmserver/include/window_node_container.h | 2 +- wmserver/include/window_root.h | 2 +- wmserver/src/window_common_event.cpp | 3 ++- wmserver/src/window_manager_service.cpp | 6 +++--- wmserver/src/window_node_container.cpp | 19 ++++++++++--------- wmserver/src/window_root.cpp | 4 ++-- 7 files changed, 20 insertions(+), 18 deletions(-) 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); } }