From b5f3cd7d96a96c45cba15b9e8b490289c4e9116c Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Mon, 25 Aug 2025 17:01:28 +0800 Subject: [PATCH 01/13] add screen display get Signed-off-by: ZhaoLiang --- dmserver/include/abstract_screen.h | 2 + dmserver/include/display_manager_service.h | 1 + dmserver/src/abstract_screen.cpp | 43 ++++++++++++++++++++++ dmserver/src/display_manager_service.cpp | 19 ++++++++++ 4 files changed, 65 insertions(+) diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index 54ec30d80d..ec715e2fd9 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -138,6 +138,8 @@ public: size_t GetChildCount() const; sptr ConvertToScreenGroupInfo() const; ScreenCombination GetScreenCombination() const; + sptr ScreenInfoConvertToDisplayInfo(sptr info); + void FillDisplayInfoByScreenInfo(sptr displayInfo, sptr info); ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE }; ScreenId mirrorScreenId_ { SCREEN_ID_INVALID }; diff --git a/dmserver/include/display_manager_service.h b/dmserver/include/display_manager_service.h index ac93c4ffc8..08061a197e 100644 --- a/dmserver/include/display_manager_service.h +++ b/dmserver/include/display_manager_service.h @@ -104,6 +104,7 @@ public: DMError StopExpand(const std::vector& expandScreenIds); void RemoveVirtualScreenFromGroup(std::vector screens); sptr GetScreenInfoById(ScreenId screenId); + sptr GetDisplayInfoByScreenId(ScreenId screenId); sptr GetScreenGroupInfoById(ScreenId screenId); ScreenId GetScreenGroupIdByScreenId(ScreenId screenId); DMError GetAllScreenInfos(std::vector>& screenInfos); diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 0bf600ec5f..72a6b69d03 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -72,6 +72,49 @@ sptr AbstractScreen::ConvertToScreenInfo() const return info; } +sptr AbstractScreen::ScreenInfoConvertToDisplayInfo(sptr info) +{ + sptr displayInfo = new(std::nothrow) DisplayInfo(); + if (displayInfo == nullptr) { + return nullptr; + } + FillDisplayInfoByScreenInfo(displayInfo, info); + return displayInfo; +} + +void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, sptr info) +{ + if (displayInfo == nullptr || info == nullptr) { + TLOGE(WmsLogTag::DMS, "displayInfo is nullptr"); + return; + } + sptr abstractScreenModes = GetActiveScreenMode(); + if (abstractScreenModes != nullptr) { + displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); + } + + displayInfo->name_ = name_; + displayInfo->SetDisplayId(info->id_); + displayInfo->SetWidth(info->virtualWidth_); + displayInfo->SetHeight(info->virtualHeight_); + displayInfo->SetScreenId(info->id_); + displayInfo->SetVirtualPixelRatio(info->virtualPixelRatio_); + displayInfo->SetXDpi(0); + displayInfo->SetYDpi(0); + displayInfo->SetDpi(info->virtualPixelRatio_ * DOT_PER_INCH); + displayInfo->SetRotation(info->rotation_); + displayInfo->SetOrientation(info->orientation_); + displayInfo->SetWaterfallDisplayCompressionStatus(false); + displayInfo->SetDisplayOrientation(info->orientation_); + if (id_ == 0) { + displayInfo->SetDisplaySourceMode(DisplaySourceMode::MAIN); + } else { + displayInfo->SetDisplaySourceMode(DisplaySourceMode::NONE); + } + +} + + void AbstractScreen::UpdateRSTree(std::shared_ptr& surfaceNode, bool isAdd, bool needToUpdate) { if (rsDisplayNode_ == nullptr || surfaceNode == nullptr) { diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index 2fab87697c..978400d8f8 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -185,6 +185,11 @@ sptr DisplayManagerService::GetDisplayInfoById(DisplayId displayId) sptr display = abstractDisplayController_->GetAbstractDisplay(displayId); if (display == nullptr) { TLOGE(WmsLogTag::DMS, "fail to get displayInfo by id: invalid display"); + sptr displayInfo = GetDisplayInfoByScreenId(displayId); + if (displayInfo != nullptr) { + return displayInfo; + } + TLOGE(WmsLogTag::DMS, "fail to get displayInfo by id: invalid screen"); return nullptr; } return display->ConvertToDisplayInfo(); @@ -646,6 +651,20 @@ sptr DisplayManagerService::GetScreenInfoById(ScreenId screenId) return screen->ConvertToScreenInfo(); } +sptr DisplayManagerService::GetDisplayInfoByScreenId(ScreenId screenId) +{ + auto screen = abstractScreenController_->GetAbstractScreen(screenId); + if (screen == nullptr) { + TLOGE(WmsLogTag::DMS, "cannot find screenInfo: %{public}" PRIu64, screenId); + return nullptr; + } + sptr screenInfo = screen->ConvertToScreenInfo(); + if (screenInfo == nullptr) { + return nullptr; + } + return screen->ScreenInfoConvertToDisplayInfo(screenInfo); +} + sptr DisplayManagerService::GetScreenGroupInfoById(ScreenId screenId) { auto screenGroup = abstractScreenController_->GetAbstractScreenGroup(screenId); -- Gitee From 7e8ed22e9d1986f42653ef3da6253a03af45ec2a Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Mon, 25 Aug 2025 21:21:48 +0800 Subject: [PATCH 02/13] dd Signed-off-by: ZhaoLiang --- dmserver/include/abstract_screen.h | 1 + dmserver/src/abstract_screen.cpp | 8 ++++---- utils/include/display_info.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index ec715e2fd9..2be25f67eb 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -31,6 +31,7 @@ #include "screen_group.h" #include "screen_group_info.h" #include "screen_info.h" +#include "display_info.h" namespace OHOS::Rosen { class AbstractScreenGroup; diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 72a6b69d03..9d6a788d78 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -21,6 +21,7 @@ #include "dm_common.h" #include "rs_adapter.h" #include "window_manager_hilog.h" +#include "screen_rotation_controller.h" namespace OHOS::Rosen { namespace { @@ -93,7 +94,7 @@ void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); } - displayInfo->name_ = name_; + displayInfo->SetName(info->name_); displayInfo->SetDisplayId(info->id_); displayInfo->SetWidth(info->virtualWidth_); displayInfo->SetHeight(info->virtualHeight_); @@ -105,16 +106,15 @@ void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, displayInfo->SetRotation(info->rotation_); displayInfo->SetOrientation(info->orientation_); displayInfo->SetWaterfallDisplayCompressionStatus(false); - displayInfo->SetDisplayOrientation(info->orientation_); + displayInfo->SetDisplayOrientation( + ScreenRotationController::ConvertRotationToDisplayOrientation(info->rotation_)); if (id_ == 0) { displayInfo->SetDisplaySourceMode(DisplaySourceMode::MAIN); } else { displayInfo->SetDisplaySourceMode(DisplaySourceMode::NONE); } - } - void AbstractScreen::UpdateRSTree(std::shared_ptr& surfaceNode, bool isAdd, bool needToUpdate) { if (rsDisplayNode_ == nullptr || surfaceNode == nullptr) { diff --git a/utils/include/display_info.h b/utils/include/display_info.h index fdad57e343..79be7416da 100644 --- a/utils/include/display_info.h +++ b/utils/include/display_info.h @@ -36,7 +36,7 @@ public: virtual bool Marshalling(Parcel& parcel) const override; static DisplayInfo *Unmarshalling(Parcel& parcel); - DEFINE_VAR_DEFAULT_FUNC_GET(std::string, Name, name, ""); + DEFINE_VAR_DEFAULT_FUNC_GET_SET(std::string, Name, name, ""); DEFINE_VAR_DEFAULT_FUNC_GET_SET(DisplayId, DisplayId, id, DISPLAY_ID_INVALID); DEFINE_VAR_DEFAULT_FUNC_GET_SET(DisplayType, DisplayType, type, DisplayType::DEFAULT); DEFINE_VAR_DEFAULT_FUNC_GET_SET(int32_t, Width, width, 0); -- Gitee From f5f19117731192fa7a9ca82e430ddb817420eaf4 Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Mon, 25 Aug 2025 22:43:55 +0800 Subject: [PATCH 03/13] aa1 Signed-off-by: ZhaoLiang --- dmserver/include/abstract_screen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index 2be25f67eb..3acd821eb4 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -63,6 +63,8 @@ public: void InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); void UpdateRSDisplayNode(Point startPoint, const sptr& absScreen); ScreenId GetScreenGroupId() const; + sptr ScreenInfoConvertToDisplayInfo(sptr info); + void FillDisplayInfoByScreenInfo(sptr displayInfo, sptr info); // colorspace, gamut DMError GetScreenSupportedColorGamuts(std::vector& colorGamuts); @@ -139,8 +141,6 @@ public: size_t GetChildCount() const; sptr ConvertToScreenGroupInfo() const; ScreenCombination GetScreenCombination() const; - sptr ScreenInfoConvertToDisplayInfo(sptr info); - void FillDisplayInfoByScreenInfo(sptr displayInfo, sptr info); ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE }; ScreenId mirrorScreenId_ { SCREEN_ID_INVALID }; -- Gitee From a5f88dfc1538ce65cc6c69402d0d7e8f3121fbee Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Tue, 26 Aug 2025 09:06:56 +0800 Subject: [PATCH 04/13] remove judge Signed-off-by: ZhaoLiang --- dmserver/src/abstract_screen.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 9d6a788d78..277c0eb13f 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -108,11 +108,7 @@ void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, displayInfo->SetWaterfallDisplayCompressionStatus(false); displayInfo->SetDisplayOrientation( ScreenRotationController::ConvertRotationToDisplayOrientation(info->rotation_)); - if (id_ == 0) { - displayInfo->SetDisplaySourceMode(DisplaySourceMode::MAIN); - } else { - displayInfo->SetDisplaySourceMode(DisplaySourceMode::NONE); - } + displayInfo->SetDisplaySourceMode(DisplaySourceMode::NONE); } void AbstractScreen::UpdateRSTree(std::shared_ptr& surfaceNode, bool isAdd, bool needToUpdate) -- Gitee From 0cd41f41a9dcde9790d180520a9bc27eaca8b646 Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Tue, 26 Aug 2025 16:29:09 +0800 Subject: [PATCH 05/13] delete virtual Signed-off-by: ZhaoLiang --- interfaces/kits/napi/display_runtime/js_display_manager.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interfaces/kits/napi/display_runtime/js_display_manager.cpp b/interfaces/kits/napi/display_runtime/js_display_manager.cpp index 489cbd54dd..2109648811 100644 --- a/interfaces/kits/napi/display_runtime/js_display_manager.cpp +++ b/interfaces/kits/napi/display_runtime/js_display_manager.cpp @@ -953,9 +953,6 @@ napi_value CreateJsCreaseRectsArrayObject(napi_env env, std::vector crea napi_value OnCreateVirtualScreen(napi_env env, napi_callback_info info) { TLOGI(WmsLogTag::DMS, "called"); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - return NapiThrowError(env, DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT, "Device not support."); - } DmErrorCode errCode = DmErrorCode::DM_OK; VirtualScreenOption option; size_t argc = 4; -- Gitee From 33f8cb947c508255a1ac6ebbb26a83f9f0f5384a Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Tue, 26 Aug 2025 19:16:24 +0800 Subject: [PATCH 06/13] remove permission Signed-off-by: ZhaoLiang --- dmserver/src/display_manager_service.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index 978400d8f8..4b9ccf9173 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -218,10 +218,6 @@ sptr DisplayManagerService::GetDisplayInfoByScreen(ScreenId screenI ScreenId DisplayManagerService::CreateVirtualScreen(VirtualScreenOption option, const sptr& displayManagerAgent) { - if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd() && - !Permission::CheckCallingPermission(ACCESS_VIRTUAL_SCREEN_PERMISSION)) { - return ERROR_ID_NOT_SYSTEM_APP; - } if (displayManagerAgent == nullptr) { TLOGE(WmsLogTag::DMS, "displayManagerAgent invalid"); return SCREEN_ID_INVALID; @@ -241,11 +237,6 @@ ScreenId DisplayManagerService::CreateVirtualScreen(VirtualScreenOption option, DMError DisplayManagerService::DestroyVirtualScreen(ScreenId screenId) { bool isCallingByThirdParty = Permission::CheckCallingPermission(ACCESS_VIRTUAL_SCREEN_PERMISSION); - if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd() && - !isCallingByThirdParty) { - TLOGE(WmsLogTag::DMS, "destroy virtual screen permission denied!"); - return DMError::DM_ERROR_NOT_SYSTEM_APP; - } if (!accessTokenIdMaps_.isExistAndRemove(screenId, IPCSkeleton::GetCallingTokenID())) { if (isCallingByThirdParty) { return DMError::DM_ERROR_NULLPTR; -- Gitee From 26081b352a0d10323a128fb6661d75366210ab35 Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Thu, 28 Aug 2025 11:02:45 +0800 Subject: [PATCH 07/13] add source mode Signed-off-by: ZhaoLiang --- dmserver/src/abstract_screen.cpp | 48 +++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 277c0eb13f..4d06990735 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -108,7 +108,7 @@ void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, displayInfo->SetWaterfallDisplayCompressionStatus(false); displayInfo->SetDisplayOrientation( ScreenRotationController::ConvertRotationToDisplayOrientation(info->rotation_)); - displayInfo->SetDisplaySourceMode(DisplaySourceMode::NONE); + displayInfo->SetDisplaySourceMode(GetDisplaySourceMode()); } void AbstractScreen::UpdateRSTree(std::shared_ptr& surfaceNode, bool isAdd, bool needToUpdate) @@ -751,4 +751,50 @@ ScreenCombination AbstractScreenGroup::GetScreenCombination() const { return combination_; } + +DisplaySourceMode AbstractScreen::GetDisplaySourceMode() const +{ + sptr abstractScreenGroup = GetGroup(); + TLOGI(WmsLogTag::DMS, "in"); + if (abstractScreenGroup == nullptr || screenController_ == nullptr) { + TLOGE(WmsLogTag::DMS, "err ALONE"); + return DisplaySourceMode::ALONE; + } + ScreenId defaultId = screenController_->GetDefaultAbstractScreenId(); + if (dmsId_ == defaultId) { + TLOGE(WmsLogTag::DMS, "err MAIN"); + return DisplaySourceMode::MAIN; + } + ScreenCombination combination = abstractScreenGroup->GetScreenCombination(); + switch (combination) { + case ScreenCombination::SCREEN_MAIN: { + TLOGI(WmsLogTag::DMS, "combination SCREEN_MAIN"); + return DisplaySourceMode::MAIN; + } + case ScreenCombination::SCREEN_MIRROR: { + TLOGI(WmsLogTag::DMS, "combination SCREEN_MIRROR"); + return DisplaySourceMode::MIRROR; + } + case ScreenCombination::SCREEN_EXPAND: { + TLOGI(WmsLogTag::DMS, "combination SCREEN_EXPAND"); + return DisplaySourceMode::EXTEND; + } + case ScreenCombination::SCREEN_EXTEND: { + TLOGI(WmsLogTag::DMS, "combination SCREEN_EXTEND"); + return DisplaySourceMode::EXTEND; + } + case ScreenCombination::SCREEN_UNIQUE: { + TLOGI(WmsLogTag::DMS, "combination SCREEN_UNIQUE"); + return DisplaySourceMode::ALONE; + } + case ScreenCombination::SCREEN_ALONE: { + TLOGI(WmsLogTag::DMS, "combination SCREEN_ALONE"); + return DisplaySourceMode::NONE; + } + default: { + TLOGE(WmsLogTag::DMS, "default NONE"); + return DisplaySourceMode::NONE; + } + } +} } // namespace OHOS::Rosen -- Gitee From fc067121c892f5bdd25b8eae8cd85069c9e1ac2c Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Thu, 28 Aug 2025 16:52:54 +0800 Subject: [PATCH 08/13] add Signed-off-by: ZhaoLiang --- dmserver/src/abstract_screen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 4d06990735..6bd9481bf4 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -758,7 +758,7 @@ DisplaySourceMode AbstractScreen::GetDisplaySourceMode() const TLOGI(WmsLogTag::DMS, "in"); if (abstractScreenGroup == nullptr || screenController_ == nullptr) { TLOGE(WmsLogTag::DMS, "err ALONE"); - return DisplaySourceMode::ALONE; + return DisplaySourceMode::NONE; } ScreenId defaultId = screenController_->GetDefaultAbstractScreenId(); if (dmsId_ == defaultId) { -- Gitee From da5406e220b8c6492a7e5c414b41236013a7edd7 Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Thu, 28 Aug 2025 18:10:39 +0800 Subject: [PATCH 09/13] add refresh rate Signed-off-by: ZhaoLiang --- dmserver/src/abstract_screen.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 6bd9481bf4..aaaa57241c 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -92,7 +92,19 @@ void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, sptr abstractScreenModes = GetActiveScreenMode(); if (abstractScreenModes != nullptr) { displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); + } else { + if (static_cast(info->modes_.size()) != 0) { + TLOGE(WmsLogTag::DMS, "set supported modes_"); + abstractScreenModes = info->modes_[activeIdx_]; + displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); + std::vector supportedRefreshRate = {}; + supportedRefreshRate.push_back(abstractScreenModes->refreshRate_); + displayInfo->SetSupportedRefreshRate(supportedRefreshRate); + } else { + TLOGE(WmsLogTag::DMS, "modes_ is nullptr"); + } } + displayInfo->SetName(info->name_); displayInfo->SetDisplayId(info->id_); -- Gitee From 409ed458a43cae797403be98ba3231234bcc3933 Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Thu, 28 Aug 2025 18:13:56 +0800 Subject: [PATCH 10/13] add log Signed-off-by: ZhaoLiang --- dmserver/src/abstract_screen.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index aaaa57241c..e3938c7775 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -91,11 +91,12 @@ void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, } sptr abstractScreenModes = GetActiveScreenMode(); if (abstractScreenModes != nullptr) { + TLOGE(WmsLogTag::DMS, "set supported modes_ not null "); displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); } else { if (static_cast(info->modes_.size()) != 0) { TLOGE(WmsLogTag::DMS, "set supported modes_"); - abstractScreenModes = info->modes_[activeIdx_]; + abstractScreenModes = info->modes_[0]; displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); std::vector supportedRefreshRate = {}; supportedRefreshRate.push_back(abstractScreenModes->refreshRate_); -- Gitee From 6e711d1e894cc74731f2c66f3eb56988ef74e06f Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Thu, 28 Aug 2025 20:17:52 +0800 Subject: [PATCH 11/13] add adapter Signed-off-by: ZhaoLiang --- dm/src/display_manager.cpp | 6 ++++++ dmserver/src/abstract_screen.cpp | 15 +++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/dm/src/display_manager.cpp b/dm/src/display_manager.cpp index bd65da5f9d..1f9469d715 100644 --- a/dm/src/display_manager.cpp +++ b/dm/src/display_manager.cpp @@ -2629,6 +2629,12 @@ DMError DisplayManager::Impl::ConvertRelativeCoordinateToGlobal(const RelativePo return DMError::DM_ERROR_NULLPTR; } + if (displayInfo->GetDisplaySourceMode() != DisplaySourceMode::MAIN && + displayInfo->GetDisplaySourceMode() != DisplaySourceMode::EXTEND) { + TLOGE(WmsLogTag::DMS, "Display is not main or extend mode:%u", displayInfo->GetDisplaySourceMode()); + return DMError::DM_ERROR_ILLEGAL_PARAM; + } + int32_t startX = displayInfo->GetX(); int32_t startY = displayInfo->GetY(); if (IsInt32AddOverflow(relativePosition.position.x, startX) || diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index e3938c7775..cf5a477ad5 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -93,19 +93,10 @@ void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, if (abstractScreenModes != nullptr) { TLOGE(WmsLogTag::DMS, "set supported modes_ not null "); displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); - } else { - if (static_cast(info->modes_.size()) != 0) { - TLOGE(WmsLogTag::DMS, "set supported modes_"); - abstractScreenModes = info->modes_[0]; - displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); - std::vector supportedRefreshRate = {}; - supportedRefreshRate.push_back(abstractScreenModes->refreshRate_); - displayInfo->SetSupportedRefreshRate(supportedRefreshRate); - } else { - TLOGE(WmsLogTag::DMS, "modes_ is nullptr"); - } + std::vector supportedRefreshRate = {}; + supportedRefreshRate.push_back(abstractScreenModes->refreshRate_); + displayInfo->SetSupportedRefreshRate(supportedRefreshRate); } - displayInfo->SetName(info->name_); displayInfo->SetDisplayId(info->id_); -- Gitee From 3d79c7b122c3a6c03334c04f46902d2f93fbdcdf Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Thu, 28 Aug 2025 22:04:22 +0800 Subject: [PATCH 12/13] add permission Signed-off-by: ZhaoLiang --- dmserver/src/display_manager_service.cpp | 9 +++++++++ interfaces/kits/napi/display_runtime/js_display.cpp | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index 4b9ccf9173..978400d8f8 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -218,6 +218,10 @@ sptr DisplayManagerService::GetDisplayInfoByScreen(ScreenId screenI ScreenId DisplayManagerService::CreateVirtualScreen(VirtualScreenOption option, const sptr& displayManagerAgent) { + if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd() && + !Permission::CheckCallingPermission(ACCESS_VIRTUAL_SCREEN_PERMISSION)) { + return ERROR_ID_NOT_SYSTEM_APP; + } if (displayManagerAgent == nullptr) { TLOGE(WmsLogTag::DMS, "displayManagerAgent invalid"); return SCREEN_ID_INVALID; @@ -237,6 +241,11 @@ ScreenId DisplayManagerService::CreateVirtualScreen(VirtualScreenOption option, DMError DisplayManagerService::DestroyVirtualScreen(ScreenId screenId) { bool isCallingByThirdParty = Permission::CheckCallingPermission(ACCESS_VIRTUAL_SCREEN_PERMISSION); + if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd() && + !isCallingByThirdParty) { + TLOGE(WmsLogTag::DMS, "destroy virtual screen permission denied!"); + return DMError::DM_ERROR_NOT_SYSTEM_APP; + } if (!accessTokenIdMaps_.isExistAndRemove(screenId, IPCSkeleton::GetCallingTokenID())) { if (isCallingByThirdParty) { return DMError::DM_ERROR_NULLPTR; diff --git a/interfaces/kits/napi/display_runtime/js_display.cpp b/interfaces/kits/napi/display_runtime/js_display.cpp index ba26aede6e..8d9315d501 100644 --- a/interfaces/kits/napi/display_runtime/js_display.cpp +++ b/interfaces/kits/napi/display_runtime/js_display.cpp @@ -859,7 +859,7 @@ void NapiSetNamedProperty(napi_env env, napi_value objValue, sptr i napi_set_named_property(env, objValue, "y", NapiGetUndefined(env)); } napi_set_named_property(env, objValue, "sourceMode", CreateJsValue(env, info->GetDisplaySourceMode())); - napi_set_named_property(env, objValue, "supportedRefreshRate", CreateJsSupportedRefreshRateArray( + napi_set_named_property(env, objValue, "supportedRefreshRates", CreateJsSupportedRefreshRateArray( env, info->GetSupportedRefreshRate())); } -- Gitee From d4c6d9e0d571808259bcaeeef1d64fa67872c1f6 Mon Sep 17 00:00:00 2001 From: ZhaoLiang Date: Fri, 29 Aug 2025 10:52:08 +0800 Subject: [PATCH 13/13] edit code Signed-off-by: ZhaoLiang --- dmserver/src/abstract_screen.cpp | 14 ++------------ dmserver/src/display_manager_service.cpp | 4 ++-- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index cf5a477ad5..efb337209e 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -91,9 +91,8 @@ void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, } sptr abstractScreenModes = GetActiveScreenMode(); if (abstractScreenModes != nullptr) { - TLOGE(WmsLogTag::DMS, "set supported modes_ not null "); displayInfo->SetRefreshRate(abstractScreenModes->refreshRate_); - std::vector supportedRefreshRate = {}; + std::vector supportedRefreshRate; supportedRefreshRate.push_back(abstractScreenModes->refreshRate_); displayInfo->SetSupportedRefreshRate(supportedRefreshRate); } @@ -104,12 +103,9 @@ void AbstractScreen::FillDisplayInfoByScreenInfo(sptr displayInfo, displayInfo->SetHeight(info->virtualHeight_); displayInfo->SetScreenId(info->id_); displayInfo->SetVirtualPixelRatio(info->virtualPixelRatio_); - displayInfo->SetXDpi(0); - displayInfo->SetYDpi(0); displayInfo->SetDpi(info->virtualPixelRatio_ * DOT_PER_INCH); displayInfo->SetRotation(info->rotation_); displayInfo->SetOrientation(info->orientation_); - displayInfo->SetWaterfallDisplayCompressionStatus(false); displayInfo->SetDisplayOrientation( ScreenRotationController::ConvertRotationToDisplayOrientation(info->rotation_)); displayInfo->SetDisplaySourceMode(GetDisplaySourceMode()); @@ -761,7 +757,7 @@ DisplaySourceMode AbstractScreen::GetDisplaySourceMode() const sptr abstractScreenGroup = GetGroup(); TLOGI(WmsLogTag::DMS, "in"); if (abstractScreenGroup == nullptr || screenController_ == nullptr) { - TLOGE(WmsLogTag::DMS, "err ALONE"); + TLOGE(WmsLogTag::DMS, "default NONE"); return DisplaySourceMode::NONE; } ScreenId defaultId = screenController_->GetDefaultAbstractScreenId(); @@ -772,27 +768,21 @@ DisplaySourceMode AbstractScreen::GetDisplaySourceMode() const ScreenCombination combination = abstractScreenGroup->GetScreenCombination(); switch (combination) { case ScreenCombination::SCREEN_MAIN: { - TLOGI(WmsLogTag::DMS, "combination SCREEN_MAIN"); return DisplaySourceMode::MAIN; } case ScreenCombination::SCREEN_MIRROR: { - TLOGI(WmsLogTag::DMS, "combination SCREEN_MIRROR"); return DisplaySourceMode::MIRROR; } case ScreenCombination::SCREEN_EXPAND: { - TLOGI(WmsLogTag::DMS, "combination SCREEN_EXPAND"); return DisplaySourceMode::EXTEND; } case ScreenCombination::SCREEN_EXTEND: { - TLOGI(WmsLogTag::DMS, "combination SCREEN_EXTEND"); return DisplaySourceMode::EXTEND; } case ScreenCombination::SCREEN_UNIQUE: { - TLOGI(WmsLogTag::DMS, "combination SCREEN_UNIQUE"); return DisplaySourceMode::ALONE; } case ScreenCombination::SCREEN_ALONE: { - TLOGI(WmsLogTag::DMS, "combination SCREEN_ALONE"); return DisplaySourceMode::NONE; } default: { diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index 978400d8f8..02b13e080d 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -184,12 +184,12 @@ sptr DisplayManagerService::GetDisplayInfoById(DisplayId displayId) { sptr display = abstractDisplayController_->GetAbstractDisplay(displayId); if (display == nullptr) { - TLOGE(WmsLogTag::DMS, "fail to get displayInfo by id: invalid display"); + TLOGI(WmsLogTag::DMS, "fail to get displayInfo by id: %{public}" PRIu64" invalid display", displayId); sptr displayInfo = GetDisplayInfoByScreenId(displayId); if (displayInfo != nullptr) { return displayInfo; } - TLOGE(WmsLogTag::DMS, "fail to get displayInfo by id: invalid screen"); + TLOGW(WmsLogTag::DMS, "fail to get displayInfo by screen id: %{public}" PRIu64" invalid screen", displayId); return nullptr; } return display->ConvertToDisplayInfo(); -- Gitee