!1172 通过uid判断是否为当前用户

Merge pull request !1172 from dubingjian/master
This commit is contained in:
openharmony_ci
2022-07-13 06:45:23 +00:00
committed by Gitee
7 changed files with 20 additions and 18 deletions
+1 -1
View File
@@ -108,9 +108,9 @@ public:
void MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
sptr<RSIWindowAnimationFinishedCallback>& 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;
+1 -1
View File
@@ -110,7 +110,7 @@ public:
void BeforeProcessWindowAvoidAreaChangeWhenDisplayChange() const;
void ProcessWindowAvoidAreaChangeWhenDisplayChange() const;
WindowLayoutMode GetCurrentLayoutMode() const;
void RemoveSingleUserWindowNodes();
void RemoveSingleUserWindowNodes(int accountId);
WMError IsTileRectSatisfiedWithSizeLimits(sptr<WindowNode>& node);
private:
+1 -1
View File
@@ -96,8 +96,8 @@ public:
void SetSplitRatios(const std::vector<float>& splitRatioNumbers);
void SetExitSplitRatios(const std::vector<float>& exitSplitRatios);
void MinimizeTargetWindows(std::vector<uint32_t>& windowIds);
void RemoveSingleUserWindowNodes();
WMError UpdateRsTree(uint32_t windowId, bool isAdd);
void RemoveSingleUserWindowNodes(int accountId);
private:
void OnRemoteDied(const sptr<IRemoteObject>& remoteObject);
WMError DestroyWindowInner(sptr<WindowNode>& node);
+2 -1
View File
@@ -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
+3 -3
View File
@@ -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");
}
+10 -9
View File
@@ -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>& displayInfo, ScreenId displayGroupId)
@@ -1898,21 +1900,20 @@ WindowLayoutMode WindowNodeContainer::GetCurrentLayoutMode() const
return layoutMode_;
}
void WindowNodeContainer::RemoveSingleUserWindowNodes()
void WindowNodeContainer::RemoveSingleUserWindowNodes(int accountId)
{
std::vector<sptr<WindowNode>> 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<uint32_t>(WindowAnimation::NONE));
RemoveWindowNode(windowNode);
}
+2 -2
View File
@@ -1333,7 +1333,7 @@ WMError WindowRoot::GetModeChangeHotZones(DisplayId displayId,
return WMError::WM_OK;
}
void WindowRoot::RemoveSingleUserWindowNodes()
void WindowRoot::RemoveSingleUserWindowNodes(int accountId)
{
std::vector<DisplayId> 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);
}
}