From 2f87313513cb20dcab149761cb266991c27a09c8 Mon Sep 17 00:00:00 2001 From: chenpeng Date: Mon, 8 Sep 2025 16:47:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E5=91=8A=E8=AD=A6=E6=95=B4?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E6=B7=BB=E5=8A=A0IPC=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenpeng --- .../include/screen_session_manager.h | 1 + .../src/screen_session_manager.cpp | 31 ++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/window_scene/screen_session_manager/include/screen_session_manager.h b/window_scene/screen_session_manager/include/screen_session_manager.h index 4b72ed6fa6..bc2ba00bf0 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -625,6 +625,7 @@ private: sptr& secondScreenSession, MultiScreenPositionOptions mainScreenOptions, MultiScreenPositionOptions secondScreenOption); void HandleSuperFoldStatusLocked(bool isLocked); + void SetDisplayRegionAndAreaFixed(Rotation rotation, DMRect& displayRegion, DMRect& displayAreaFixed); void CalculateRotatedDisplay(Rotation rotation, const DMRect& screenRegion, DMRect& displayRegion, DMRect& displayArea); void CalculateScreenArea(const DMRect& displayRegion, const DMRect& displayArea, const DMRect& screenRegion, DMRect& screenArea); void DisconnectScreenIfScreenInfoNull(sptr& screenSession); diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 7ad286ec41..693884c894 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -7993,6 +7993,11 @@ SuperFoldStatus ScreenSessionManager::GetSuperFoldStatus() float ScreenSessionManager::GetSuperRotation() { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::DMS, "permission denied! calling: %{public}s, pid: %{public}d", + SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); + return -1.f; + } DmsXcollie dmsXcollie("DMS:GetSuperRotation", XCOLLIE_TIMEOUT_10S); if (!FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { return -1.f; @@ -11295,7 +11300,7 @@ void ScreenSessionManager::OnScreenModeChange(ScreenModeChangeEvent screenModeCh void ScreenSessionManager::NotifyScreenMaskAppear() { - if (!SessionPermission::IsSystemCalling()) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::DMS, "Permission Denied.calling: %{public}s, pid: %{public}d", SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); return; @@ -11319,6 +11324,11 @@ bool ScreenSessionManager::GetKeyboardState() DMError ScreenSessionManager::GetScreenAreaOfDisplayArea(DisplayId displayId, const DMRect& displayArea, ScreenId& screenId, DMRect& screenArea) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::DMS, "Permission Denied! calling: %{public}s, calling pid: %{public}d", + SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); + return DMError::DM_ERROR_NOT_SYSTEM_APP; + } TLOGI(WmsLogTag::DMS, "displayId:%{public}" PRIu64 ",displayArea:%{public}d,%{public}d,%{public}d,%{public}d", displayId, displayArea.posX_, displayArea.posY_, displayArea.width_, displayArea.height_); auto displayInfo = GetDisplayInfoById(displayId); @@ -11348,7 +11358,18 @@ DMError ScreenSessionManager::GetScreenAreaOfDisplayArea(DisplayId displayId, co } displayRegion.height_ = screenRegion.height_; } else if (FoldScreenStateInternel::IsSecondaryDisplayFoldDevice() && GetFoldDisplayMode() == FoldDisplayMode::FULL) { - switch (displayInfo->GetRotation()) { + SetDisplayRegionAndAreaFixed(displayInfo->GetRotation(), displayRegion, displayAreaFixed); + } + CalculateRotatedDisplay(displayInfo->GetRotation(), screenRegion, displayRegion, displayAreaFixed); + CalculateScreenArea(displayRegion, displayAreaFixed, screenRegion, screenArea); + TLOGI(WmsLogTag::DMS, "screenId:%{public}" PRIu64 ",screenArea:%{public}d,%{public}d,%{public}d,%{public}d", + screenId, screenArea.posX_, screenArea.posY_, screenArea.width_, screenArea.height_); + return DMError::DM_OK; +} +void ScreenSessionManager::SetDisplayRegionAndAreaFixed(Rotation rotation, DMRect& displayRegion, + DMRect& displayAreaFixed) +{ + switch (rotation) { case Rotation::ROTATION_0: displayRegion.posX_ = FULL_STATUS_OFFSET_X; displayAreaFixed.posX_ += FULL_STATUS_OFFSET_X; @@ -11359,13 +11380,7 @@ DMError ScreenSessionManager::GetScreenAreaOfDisplayArea(DisplayId displayId, co break; default: break; - } } - CalculateRotatedDisplay(displayInfo->GetRotation(), screenRegion, displayRegion, displayAreaFixed); - CalculateScreenArea(displayRegion, displayAreaFixed, screenRegion, screenArea); - TLOGI(WmsLogTag::DMS, "screenId:%{public}" PRIu64 ",screenArea:%{public}d,%{public}d,%{public}d,%{public}d", - screenId, screenArea.posX_, screenArea.posY_, screenArea.width_, screenArea.height_); - return DMError::DM_OK; } void ScreenSessionManager::CalculateRotatedDisplay(Rotation rotation, const DMRect& screenRegion, -- Gitee