From 2b71dc6d27bc7acac35575ed29d024a39613e583 Mon Sep 17 00:00:00 2001 From: wenyu Date: Mon, 24 Mar 2025 11:31:13 +0800 Subject: [PATCH] =?UTF-8?q?IDisplayManager=E6=8E=A5=E5=8F=A3=E7=B1=BBIDL?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wenyu --- dm/BUILD.gn | 13 +- dm/include/display_manager_adapter.h | 15 +- dm/include/zidl/display_manager_agent_proxy.h | 4 +- dm/include/zidl/display_manager_agent_stub.h | 4 +- ...t_interface.h => idisplay_manager_agent.h} | 203 +- dm/src/display_manager_adapter.cpp | 991 +++++++-- dm/test/unittest/BUILD.gn | 7 +- .../unittest/display_manager_adapter_test.cpp | 204 +- .../display_manager_adapter_ut_test.cpp | 288 +-- .../display_manager_agent_proxy_test.cpp | 163 +- dm/test/unittest/display_manager_test.cpp | 69 +- dm/test/unittest/screen_manager_test.cpp | 14 +- dm/test/unittest/screenshot_test.cpp | 28 +- dm_lite/BUILD.gn | 6 +- dm_lite/IDisplayManagerLite.idl | 44 + .../include/display_manager_adapter_lite.h | 7 +- dm_lite/include/display_manager_lite_proxy.h | 174 +- dm_lite/src/display_manager_lite_proxy.cpp | 226 +- .../src/display_manager_lite_proxy_idl.cpp | 800 +++++++ dmserver/BUILD.gn | 50 +- dmserver/IDisplayManager.idl | 93 + dmserver/include/abstract_screen_controller.h | 6 +- .../display_manager_agent_controller.h | 4 +- dmserver/include/display_manager_interface.h | 313 --- .../include/display_manager_ipc_service.h | 271 +++ dmserver/include/display_manager_proxy.h | 110 - dmserver/include/display_manager_service.h | 130 +- dmserver/src/display_manager_ipc_service.cpp | 420 ++++ dmserver/src/display_manager_proxy.cpp | 1865 ----------------- dmserver/src/display_manager_service.cpp | 215 +- dmserver/src/display_manager_stub.cpp | 487 ----- dmserver/test/unittest/BUILD.gn | 6 +- .../unittest/display_manager_proxy_test.cpp | 1451 +++++-------- .../unittest/display_manager_service_test.cpp | 29 +- .../unittest/display_manager_stub_test.cpp | 281 ++- .../window_extension/test/unittest/BUILD.gn | 4 +- interfaces/innerkits/dm/dm_common.h | 78 +- snapshot/test/unittest/BUILD.gn | 4 +- .../mock/mock_display_manager_adapter.h | 9 +- test/demo/BUILD.gn | 3 +- test/demo/demo_snapshot_virtual_screen.cpp | 44 +- .../dms/displaymanageripc_fuzzer/BUILD.gn | 3 +- .../displaymanageripc_fuzzer.cpp | 69 +- .../screensessionmgrstubagent_fuzzer.cpp | 16 +- .../screensessionmgrstubstate_fuzzer.cpp | 16 +- .../screensessionmgrstubwakeup_fuzzer.cpp | 16 +- test/systemtest/dms/BUILD.gn | 5 +- test/systemtest/wms/BUILD.gn | 3 +- utils/BUILD.gn | 4 +- utils/include/dm_rs_surface_node.h | 54 + .../include/dm_virtual_screen_option.h | 73 +- utils/src/dm_virtual_screen_option.cpp | 64 + utils/test/unittest/BUILD.gn | 23 +- utils/test/unittest/dm_rs_surface_node.cpp | 58 + .../dm_virtual_screen_option_test.cpp | 66 + .../zidl/screen_session_manager_interface.h | 301 ++- .../screen_session_manager_lite_interface.h | 9 +- window_scene/test/dms_unittest/BUILD.gn | 4 +- .../screen_session_manager_proxy_test.cpp | 503 +---- .../screen_session_manager_proxy_ut_test.cpp | 1344 ++++++++++-- window_scene/test/unittest/BUILD.gn | 9 +- .../session_listener_controller_test.cpp | 30 +- windowmanager_aafwk.gni | 3 +- wm/BUILD.gn | 3 +- wm/test/unittest/BUILD.gn | 8 +- .../window_manager_agent_proxy_test.cpp | 123 +- 66 files changed, 6108 insertions(+), 5832 deletions(-) rename dm/include/zidl/{display_manager_agent_interface.h => idisplay_manager_agent.h} (94%) create mode 100644 dm_lite/IDisplayManagerLite.idl create mode 100644 dm_lite/src/display_manager_lite_proxy_idl.cpp create mode 100644 dmserver/IDisplayManager.idl delete mode 100644 dmserver/include/display_manager_interface.h create mode 100644 dmserver/include/display_manager_ipc_service.h delete mode 100644 dmserver/include/display_manager_proxy.h create mode 100644 dmserver/src/display_manager_ipc_service.cpp delete mode 100644 dmserver/src/display_manager_proxy.cpp delete mode 100644 dmserver/src/display_manager_stub.cpp create mode 100644 utils/include/dm_rs_surface_node.h rename dmserver/include/display_manager_stub.h => utils/include/dm_virtual_screen_option.h (51%) create mode 100644 utils/src/dm_virtual_screen_option.cpp create mode 100644 utils/test/unittest/dm_rs_surface_node.cpp create mode 100644 utils/test/unittest/dm_virtual_screen_option_test.cpp diff --git a/dm/BUILD.gn b/dm/BUILD.gn index d28e782649..d814f229d3 100644 --- a/dm/BUILD.gn +++ b/dm/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -25,6 +25,7 @@ config("libdm_private_config") { "${window_base_path}/window_scene/session_manager/include", "${window_base_path}/window_scene/session_manager_service/include", "${window_base_path}/window_scene/interfaces/innerkits/include", + "${dmserver_gen_path}", ] } @@ -54,7 +55,6 @@ ohos_static_library("libdm_static") { boundary_sanitize = true } sources = [ - "../dmserver/src/display_manager_proxy.cpp", "../window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp", "src/display.cpp", "src/display_manager.cpp", @@ -73,6 +73,7 @@ ohos_static_library("libdm_static") { public_configs = [ ":libdm_public_config" ] deps = [ + "${window_base_path}/dmserver:display_manager_proxy", "${window_base_path}/utils:libwmutil", "${window_base_path}/utils:libwmutil_base", "${window_base_path}/window_scene/interfaces/innerkits:libwsutils", @@ -101,8 +102,13 @@ ohos_static_library("libdm_static") { ## Build libdm.so ohos_shared_library("libdm") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } sources = [ - "../dmserver/src/display_manager_proxy.cpp", "../window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp", "src/display.cpp", "src/display_manager.cpp", @@ -124,6 +130,7 @@ ohos_shared_library("libdm") { ] deps = [ + "${window_base_path}/dmserver:display_manager_proxy", "${window_base_path}/utils:libwmutil", "${window_base_path}/utils:libwmutil_base", "${window_base_path}/window_scene/interfaces/innerkits:libwsutils", diff --git a/dm/include/display_manager_adapter.h b/dm/include/display_manager_adapter.h index 04787aac54..0259b4a871 100644 --- a/dm/include/display_manager_adapter.h +++ b/dm/include/display_manager_adapter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,17 +16,18 @@ #ifndef FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_H #define FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_H -#include #include #include #include "display.h" +#include "dm_common.h" +#include "fold_screen_info.h" +#include "idisplay_manager.h" #include "screen.h" #include "screen_group.h" -#include "dm_common.h" -#include "display_manager_interface.h" -#include "fold_screen_info.h" #include "singleton_delegator.h" +#include "zidl/idisplay_manager_agent.h" +#include "zidl/screen_session_manager_interface.h" namespace OHOS::Rosen { class BaseAdapter { @@ -40,9 +41,11 @@ public: protected: bool InitDMSProxy(); std::recursive_mutex mutex_; + sptr screenSessionManagerServiceProxy_ = nullptr; sptr displayManagerServiceProxy_ = nullptr; sptr dmsDeath_ = nullptr; - bool isProxyValid_ { false }; + bool isProxyValid_ = false; + static inline DMError ConvertToDMError(ErrCode errCode, int32_t dmError); }; class DMSDeathRecipient : public IRemoteObject::DeathRecipient { diff --git a/dm/include/zidl/display_manager_agent_proxy.h b/dm/include/zidl/display_manager_agent_proxy.h index 2027193642..137a34a664 100644 --- a/dm/include/zidl/display_manager_agent_proxy.h +++ b/dm/include/zidl/display_manager_agent_proxy.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,8 +17,8 @@ #define OHOS_ROSEN_DISPLAY_MANAGER_AGRNT_PROXY_H #include -#include "display_manager_agent_interface.h" #include "dm_common.h" +#include "idisplay_manager_agent.h" namespace OHOS { namespace Rosen { diff --git a/dm/include/zidl/display_manager_agent_stub.h b/dm/include/zidl/display_manager_agent_stub.h index 7c7939e600..6e79ab342a 100644 --- a/dm/include/zidl/display_manager_agent_stub.h +++ b/dm/include/zidl/display_manager_agent_stub.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,7 +20,7 @@ #include #include #include -#include "display_manager_agent_interface.h" +#include "idisplay_manager_agent.h" namespace OHOS::Rosen { class DisplayManagerAgentStub : public IRemoteStub { diff --git a/dm/include/zidl/display_manager_agent_interface.h b/dm/include/zidl/idisplay_manager_agent.h similarity index 94% rename from dm/include/zidl/display_manager_agent_interface.h rename to dm/include/zidl/idisplay_manager_agent.h index acbada849f..74d5ec3cb2 100644 --- a/dm/include/zidl/display_manager_agent_interface.h +++ b/dm/include/zidl/idisplay_manager_agent.h @@ -1,101 +1,102 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ROSEN_DISPLAY_MANAGER_AGENT_INTERFACE_H -#define OHOS_ROSEN_DISPLAY_MANAGER_AGENT_INTERFACE_H - -#include -#include "display_info.h" -#include "display_change_info.h" -#include "dm_common.h" -#include "screen_info.h" -#include "screenshot_info.h" - -namespace OHOS { -namespace Rosen { -enum class DisplayManagerAgentType : uint32_t { - DISPLAY_POWER_EVENT_LISTENER, - DISPLAY_STATE_LISTENER, - SCREEN_EVENT_LISTENER, - DISPLAY_EVENT_LISTENER, - SCREENSHOT_EVENT_LISTENER, - PRIVATE_WINDOW_LISTENER, - FOLD_STATUS_CHANGED_LISTENER, - DISPLAY_UPDATE_LISTENER, - AVAILABLE_AREA_CHANGED_LISTENER, - DISPLAY_MODE_CHANGED_LISTENER, - FOLD_ANGLE_CHANGED_LISTENER, - CAPTURE_STATUS_CHANGED_LISTENER, - PRIVATE_WINDOW_LIST_LISTENER, - SCREEN_MAGNETIC_STATE_CHANGED_LISTENER, - SCREEN_MODE_CHANGE_EVENT_LISTENER, - ABNORMAL_SCREEN_CONNECT_CHANGE_LISTENER, - // add listener before - DISPLAY_MANAGER_MAX_AGENT_TYPE, -}; - -class IDisplayManagerAgent : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IDisplayManagerAgent"); - - enum { - TRANS_ID_NOTIFY_DISPLAY_POWER_EVENT = 1, - TRANS_ID_NOTIFY_DISPLAY_STATE_CHANGED, - TRANS_ID_ON_SCREEN_CONNECT, - TRANS_ID_ON_SCREEN_DISCONNECT, - TRANS_ID_ON_SCREEN_CHANGED, - TRANS_ID_ON_SCREENGROUP_CHANGED, - TRANS_ID_ON_DISPLAY_CONNECT, - TRANS_ID_ON_DISPLAY_DISCONNECT, - TRANS_ID_ON_DISPLAY_CHANGED, - TRANS_ID_ON_SCREEN_SHOT, - TRANS_ID_ON_PRIVATE_WINDOW, - TRANS_ID_ON_FOLD_STATUS_CHANGED, - TRANS_ID_ON_DISPLAY_CHANGE_INFO_CHANGED, - TRANS_ID_ON_AVAILABLE_AREA_CHANGED, - TRANS_ID_ON_DISPLAY_MODE_CHANGED, - TRANS_ID_ON_FOLD_ANGLE_CHANGED, - TRANS_ID_ON_CAPTURE_STATUS_CHANGED, - TRANS_ID_ON_PRIVATE_WINDOW_LIST, - TRANS_ID_ON_SCREEN_MAGNETIC_STATE_CHANGED, - TRANS_ID_ON_SCREEN_MODE_CHANGED, - TRANS_ID_NOTIFY_ABNORMAL_SCREEN_CONNECT_CHANGED, - }; - virtual void NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatus status) = 0; - virtual void NotifyDisplayStateChanged(DisplayId id, DisplayState state) = 0; - virtual void OnScreenConnect(sptr) = 0; - virtual void OnScreenDisconnect(ScreenId) = 0; - virtual void OnScreenChange(const sptr&, ScreenChangeEvent) = 0; - virtual void OnScreenGroupChange(const std::string& trigger, - const std::vector>&, ScreenGroupChangeEvent) = 0; - virtual void OnDisplayCreate(sptr) = 0; - virtual void OnDisplayDestroy(DisplayId) = 0; - virtual void OnDisplayChange(sptr, DisplayChangeEvent) = 0; - virtual void OnScreenshot(sptr) = 0; - virtual void NotifyPrivateWindowStateChanged(bool hasPrivate) = 0; - virtual void NotifyPrivateStateWindowListChanged(DisplayId id, std::vector privacyWindowList) = 0; - virtual void NotifyFoldStatusChanged(FoldStatus) = 0; - virtual void NotifyFoldAngleChanged(std::vector foldAngles) = 0; - virtual void NotifyCaptureStatusChanged(bool isCapture) = 0; - virtual void NotifyDisplayChangeInfoChanged(const sptr& info) = 0; - virtual void NotifyDisplayModeChanged(FoldDisplayMode) = 0; - virtual void NotifyAvailableAreaChanged(DMRect, DisplayId displayId) = 0; - virtual void NotifyScreenMagneticStateChanged(bool isMagneticState) = 0; - virtual void NotifyScreenModeChange(const std::vector>& screenInfos) = 0; - virtual void NotifyAbnormalScreenConnectChange(ScreenId screenId) = 0; -}; -} // namespace Rosen -} // namespace OHOS -#endif // OHOS_ROSEN_DISPLAY_MANAGER_AGENT_INTERFACE_H +/* + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ROSEN_DISPLAY_MANAGER_AGENT_INTERFACE_H +#define OHOS_ROSEN_DISPLAY_MANAGER_AGENT_INTERFACE_H + +#include + +#include "display_change_info.h" +#include "display_info.h" +#include "dm_common.h" +#include "screen_info.h" +#include "screenshot_info.h" + +namespace OHOS { +namespace Rosen { +enum class DisplayManagerAgentType : uint32_t { + DISPLAY_POWER_EVENT_LISTENER, + DISPLAY_STATE_LISTENER, + SCREEN_EVENT_LISTENER, + DISPLAY_EVENT_LISTENER, + SCREENSHOT_EVENT_LISTENER, + PRIVATE_WINDOW_LISTENER, + FOLD_STATUS_CHANGED_LISTENER, + DISPLAY_UPDATE_LISTENER, + AVAILABLE_AREA_CHANGED_LISTENER, + DISPLAY_MODE_CHANGED_LISTENER, + FOLD_ANGLE_CHANGED_LISTENER, + CAPTURE_STATUS_CHANGED_LISTENER, + PRIVATE_WINDOW_LIST_LISTENER, + SCREEN_MAGNETIC_STATE_CHANGED_LISTENER, + SCREEN_MODE_CHANGE_EVENT_LISTENER, + ABNORMAL_SCREEN_CONNECT_CHANGE_LISTENER, + // add listener before + DISPLAY_MANAGER_MAX_AGENT_TYPE, +}; + +class IDisplayManagerAgent : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IDisplayManagerAgent"); + + enum { + TRANS_ID_NOTIFY_DISPLAY_POWER_EVENT = 1, + TRANS_ID_NOTIFY_DISPLAY_STATE_CHANGED, + TRANS_ID_ON_SCREEN_CONNECT, + TRANS_ID_ON_SCREEN_DISCONNECT, + TRANS_ID_ON_SCREEN_CHANGED, + TRANS_ID_ON_SCREENGROUP_CHANGED, + TRANS_ID_ON_DISPLAY_CONNECT, + TRANS_ID_ON_DISPLAY_DISCONNECT, + TRANS_ID_ON_DISPLAY_CHANGED, + TRANS_ID_ON_SCREEN_SHOT, + TRANS_ID_ON_PRIVATE_WINDOW, + TRANS_ID_ON_FOLD_STATUS_CHANGED, + TRANS_ID_ON_DISPLAY_CHANGE_INFO_CHANGED, + TRANS_ID_ON_AVAILABLE_AREA_CHANGED, + TRANS_ID_ON_DISPLAY_MODE_CHANGED, + TRANS_ID_ON_FOLD_ANGLE_CHANGED, + TRANS_ID_ON_CAPTURE_STATUS_CHANGED, + TRANS_ID_ON_PRIVATE_WINDOW_LIST, + TRANS_ID_ON_SCREEN_MAGNETIC_STATE_CHANGED, + TRANS_ID_ON_SCREEN_MODE_CHANGED, + TRANS_ID_NOTIFY_ABNORMAL_SCREEN_CONNECT_CHANGED, + }; + virtual void NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatus status) = 0; + virtual void NotifyDisplayStateChanged(DisplayId id, DisplayState state) = 0; + virtual void OnScreenConnect(sptr) = 0; + virtual void OnScreenDisconnect(ScreenId) = 0; + virtual void OnScreenChange(const sptr&, ScreenChangeEvent) = 0; + virtual void OnScreenGroupChange(const std::string& trigger, + const std::vector>&, ScreenGroupChangeEvent) = 0; + virtual void OnDisplayCreate(sptr) = 0; + virtual void OnDisplayDestroy(DisplayId) = 0; + virtual void OnDisplayChange(sptr, DisplayChangeEvent) = 0; + virtual void OnScreenshot(sptr) = 0; + virtual void NotifyPrivateWindowStateChanged(bool hasPrivate) = 0; + virtual void NotifyPrivateStateWindowListChanged(DisplayId id, std::vector privacyWindowList) = 0; + virtual void NotifyFoldStatusChanged(FoldStatus) = 0; + virtual void NotifyFoldAngleChanged(std::vector foldAngles) = 0; + virtual void NotifyCaptureStatusChanged(bool isCapture) = 0; + virtual void NotifyDisplayChangeInfoChanged(const sptr& info) = 0; + virtual void NotifyDisplayModeChanged(FoldDisplayMode) = 0; + virtual void NotifyAvailableAreaChanged(DMRect, DisplayId) = 0; + virtual void NotifyScreenMagneticStateChanged(bool isMagneticState) = 0; + virtual void NotifyScreenModeChange(const std::vector>& screenInfos) = 0; + virtual void NotifyAbnormalScreenConnectChange(ScreenId screenId) = 0; +}; +} // namespace Rosen +} // namespace OHOS +#endif // OHOS_ROSEN_DISPLAY_MANAGER_AGENT_INTERFACE_H diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index d32047ad2f..57f9657466 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -27,32 +27,55 @@ #include "zidl/screen_session_manager_interface.h" namespace OHOS::Rosen { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerAdapter"}; -} WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerAdapter) WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManagerAdapter) #define INIT_PROXY_CHECK_RETURN(ret) \ do { \ if (!InitDMSProxy()) { \ - WLOGFE("InitDMSProxy failed!"); \ + TLOGE(WmsLogTag::DMS, "InitDMSProxy failed!"); \ return ret; \ } \ } while (false) +DMError BaseAdapter::ConvertToDMError(ErrCode errCode, int32_t dmError) +{ + if (FAILED(errCode)) { + return DMError::DM_ERROR_IPC_FAILED; + } + return static_cast(dmError); +} + sptr DisplayManagerAdapter::GetDefaultDisplayInfo() { INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetDefaultDisplayInfo(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetDefaultDisplayInfo(); + } + + sptr displayInfo; + ErrCode errCode = displayManagerServiceProxy_->GetDefaultDisplayInfo(displayInfo); + if (FAILED(errCode) || displayInfo == nullptr) { + return nullptr; + } + return displayInfo; } sptr DisplayManagerAdapter::GetDisplayInfoByScreenId(ScreenId screenId) { INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetDisplayInfoByScreen(screenId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetDisplayInfoByScreen(screenId); + } + + sptr displayInfo; + ErrCode errCode = displayManagerServiceProxy_->GetDisplayInfoByScreen(screenId, displayInfo); + if (FAILED(errCode) || displayInfo == nullptr) { + return nullptr; + } + return displayInfo; } std::shared_ptr DisplayManagerAdapter::GetDisplaySnapshot(DisplayId displayId, @@ -60,14 +83,34 @@ std::shared_ptr DisplayManagerAdapter::GetDisplaySnapshot(Displ { INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetDisplaySnapshot(displayId, errorCode, isUseDma, isCaptureFullOfScreen); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetDisplaySnapshot(displayId, errorCode, isUseDma, + isCaptureFullOfScreen); + } + + auto errorCodeOut = static_cast(DmErrorCode::DM_OK); + std::shared_ptr pixelMap; + ErrCode errCode = displayManagerServiceProxy_->GetDisplaySnapshot(displayId, errorCodeOut, isUseDma, + isCaptureFullOfScreen, pixelMap); + if (errorCode != nullptr) { + *errorCode = static_cast(errorCodeOut); + } + if (FAILED(errCode) || pixelMap == nullptr) { + return nullptr; + } + return pixelMap; } std::shared_ptr DisplayManagerAdapter::GetSnapshotByPicker(Media::Rect &rect, DmErrorCode* errorCode) { INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetSnapshotByPicker(rect, errorCode); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetSnapshotByPicker(rect, errorCode); + } + + *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; + return nullptr; } DMError ScreenManagerAdapter::GetScreenSupportedColorGamuts(ScreenId screenId, @@ -75,58 +118,110 @@ DMError ScreenManagerAdapter::GetScreenSupportedColorGamuts(ScreenId screenId, { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->GetScreenSupportedColorGamuts(screenId, colorGamuts); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetScreenSupportedColorGamuts(screenId, colorGamuts); + } + + std::vector colorGamutsOut; + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->GetScreenSupportedColorGamuts(screenId, colorGamutsOut, dmError); + for (auto colorGamut : colorGamutsOut) { + colorGamuts.push_back(static_cast(colorGamut)); + } + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->GetScreenColorGamut(screenId, colorGamut); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetScreenColorGamut(screenId, colorGamut); + } + + uint32_t colorGamutOut; + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->GetScreenColorGamut(screenId, colorGamutOut, dmError); + colorGamut = static_cast(colorGamutOut); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetScreenColorGamut(screenId, colorGamutIdx); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenColorGamut(screenId, colorGamutIdx); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->SetScreenColorGamut(screenId, colorGamutIdx, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->GetScreenGamutMap(screenId, gamutMap); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetScreenGamutMap(screenId, gamutMap); + } + + uint32_t gamutMapOut; + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->GetScreenGamutMap(screenId, gamutMapOut, dmError); + gamutMap = static_cast(gamutMapOut); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetScreenGamutMap(screenId, gamutMap); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenGamutMap(screenId, gamutMap); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->SetScreenGamutMap(screenId, static_cast(gamutMap), + dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::SetScreenColorTransform(ScreenId screenId) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetScreenColorTransform(screenId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenColorTransform(screenId); + } + + ErrCode errCode = displayManagerServiceProxy_->SetScreenColorTransform(screenId); + return ConvertToDMError(errCode, static_cast(DMError::DM_OK)); } DMError ScreenManagerAdapter::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("ScreenManagerAdapter::GetPixelFormat"); - return displayManagerServiceProxy_->GetPixelFormat(screenId, pixelFormat); + TLOGI(WmsLogTag::DMS, "ScreenManagerAdapter::GetPixelFormat"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetPixelFormat(screenId, pixelFormat); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("ScreenManagerAdapter::SetPixelFormat"); - return displayManagerServiceProxy_->SetPixelFormat(screenId, pixelFormat); + TLOGI(WmsLogTag::DMS, "ScreenManagerAdapter::SetPixelFormat"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetPixelFormat(screenId, pixelFormat); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, @@ -134,24 +229,36 @@ DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("ScreenManagerAdapter::GetSupportedHDRFormats"); - return displayManagerServiceProxy_->GetSupportedHDRFormats(screenId, hdrFormats); + TLOGI(WmsLogTag::DMS, "ScreenManagerAdapter::GetSupportedHDRFormats"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetSupportedHDRFormats(screenId, hdrFormats); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("ScreenManagerAdapter::GetScreenHDRFormat"); - return displayManagerServiceProxy_->GetScreenHDRFormat(screenId, hdrFormat); + TLOGI(WmsLogTag::DMS, "ScreenManagerAdapter::GetScreenHDRFormat"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetScreenHDRFormat(screenId, hdrFormat); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("ScreenManagerAdapter::SetScreenHDRFormat"); - return displayManagerServiceProxy_->SetScreenHDRFormat(screenId, modeIdx); + TLOGI(WmsLogTag::DMS, "ScreenManagerAdapter::SetScreenHDRFormat"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenHDRFormat(screenId, modeIdx); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, @@ -159,8 +266,12 @@ DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("ScreenManagerAdapter::GetSupportedColorSpaces"); - return displayManagerServiceProxy_->GetSupportedColorSpaces(screenId, colorSpaces); + TLOGI(WmsLogTag::DMS, "ScreenManagerAdapter::GetSupportedColorSpaces"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetSupportedColorSpaces(screenId, colorSpaces); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::GetScreenColorSpace(ScreenId screenId, @@ -168,8 +279,12 @@ DMError ScreenManagerAdapter::GetScreenColorSpace(ScreenId screenId, { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("ScreenManagerAdapter::GetScreenColorSpace"); - return displayManagerServiceProxy_->GetScreenColorSpace(screenId, colorSpace); + TLOGI(WmsLogTag::DMS, "ScreenManagerAdapter::GetScreenColorSpace"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetScreenColorSpace(screenId, colorSpace); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetScreenColorSpace(ScreenId screenId, @@ -177,8 +292,12 @@ DMError ScreenManagerAdapter::SetScreenColorSpace(ScreenId screenId, { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("ScreenManagerAdapter::SetScreenColorSpace"); - return displayManagerServiceProxy_->SetScreenColorSpace(screenId, colorSpace); + TLOGI(WmsLogTag::DMS, "ScreenManagerAdapter::SetScreenColorSpace"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenColorSpace(screenId, colorSpace); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, std::vector& hdrFormats) @@ -190,7 +309,7 @@ DMError ScreenManagerAdapter::GetSupportedHDRFormats(ScreenId screenId, std::vec for (auto value : hdrFormatsVec) { hdrFormats.push_back(static_cast(value)); } - WLOGFI("ScreenManagerAdapter::GetSupportedHDRFormats ret %{public}d", static_cast(ret)); + TLOGI(WmsLogTag::DMS, "ScreenManagerAdapter::GetSupportedHDRFormats ret %{public}d", static_cast(ret)); return ret; } @@ -203,7 +322,7 @@ DMError ScreenManagerAdapter::GetSupportedColorSpaces(ScreenId screenId, std::ve for (auto value : colorSpacesVec) { colorSpaces.push_back(static_cast(value)); } - WLOGFI("ScreenManagerAdapter::GetSupportedColorSpaces ret %{public}d", static_cast(ret)); + TLOGI(WmsLogTag::DMS, "ScreenManagerAdapter::GetSupportedColorSpaces ret %{public}d", static_cast(ret)); return ret; } @@ -212,16 +331,39 @@ ScreenId ScreenManagerAdapter::CreateVirtualScreen(VirtualScreenOption option, { INIT_PROXY_CHECK_RETURN(SCREEN_ID_INVALID); - WLOGFI("DisplayManagerAdapter::CreateVirtualScreen"); - return displayManagerServiceProxy_->CreateVirtualScreen(option, displayManagerAgent->AsObject()); + TLOGI(WmsLogTag::DMS, "DisplayManagerAdapter::CreateVirtualScreen"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->CreateVirtualScreen(option, displayManagerAgent->AsObject()); + } + + ErrCode errCode; + ScreenId screenId = SCREEN_ID_INVALID; + DmVirtualScreenOption dmVirtualScreenOption(option); + if (option.surface_ && option.surface_->GetProducer()) { + errCode = displayManagerServiceProxy_->CreateVirtualScreen(dmVirtualScreenOption, + displayManagerAgent->AsObject(), screenId, option.surface_->GetProducer()); + } else { + errCode = displayManagerServiceProxy_->CreateVirtualScreen(dmVirtualScreenOption, + displayManagerAgent->AsObject(), screenId); + } + if (FAILED(errCode)) { + return SCREEN_ID_INVALID; + } + return screenId; } DMError ScreenManagerAdapter::DestroyVirtualScreen(ScreenId screenId) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("DisplayManagerAdapter::DestroyVirtualScreen"); - return displayManagerServiceProxy_->DestroyVirtualScreen(screenId); + TLOGI(WmsLogTag::DMS, "DisplayManagerAdapter::DestroyVirtualScreen"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->DestroyVirtualScreen(screenId); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->DestroyVirtualScreen(screenId, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptr surface) @@ -229,97 +371,177 @@ DMError ScreenManagerAdapter::SetVirtualScreenSurface(ScreenId screenId, sptrSetVirtualScreenSurface(screenId, surface->GetProducer()); + TLOGI(WmsLogTag::DMS, "DisplayManagerAdapter::SetVirtualScreenSurface"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface->GetProducer()); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->SetVirtualScreenSurface(screenId, surface->GetProducer(), + dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::AddVirtualScreenBlockList(const std::vector& persistentIds) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->AddVirtualScreenBlockList(persistentIds); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->AddVirtualScreenBlockList(persistentIds); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::RemoveVirtualScreenBlockList(const std::vector& persistentIds) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->RemoveVirtualScreenBlockList(persistentIds); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->RemoveVirtualScreenBlockList(persistentIds); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetScreenPrivacyMaskImage(ScreenId screenId, const std::shared_ptr& privacyMaskImg) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("DisplayManagerAdapter::SetScreenPrivacyMaskImage"); - return displayManagerServiceProxy_->SetScreenPrivacyMaskImage(screenId, privacyMaskImg); + TLOGI(WmsLogTag::DMS, "DisplayManagerAdapter::SetScreenPrivacyMaskImage"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenPrivacyMaskImage(screenId, privacyMaskImg); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool canvasRotation) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("DisplayManagerAdapter::SetVirtualMirrorScreenCanvasRotation"); - return displayManagerServiceProxy_->SetVirtualMirrorScreenCanvasRotation(screenId, canvasRotation); + TLOGI(WmsLogTag::DMS, "DisplayManagerAdapter::SetVirtualMirrorScreenCanvasRotation"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetVirtualMirrorScreenCanvasRotation(screenId, canvasRotation); + } + + return DMError::DM_OK; } DMError ScreenManagerAdapter::SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("DisplayManagerAdapter::SetVirtualMirrorScreenScaleMode"); - return displayManagerServiceProxy_->SetVirtualMirrorScreenScaleMode(screenId, scaleMode); + TLOGI(WmsLogTag::DMS, "DisplayManagerAdapter::SetVirtualMirrorScreenScaleMode"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetVirtualMirrorScreenScaleMode(screenId, scaleMode); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetScreenRotationLocked(bool isLocked) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("DisplayManagerAdapter::SetScreenRotationLocked"); - return displayManagerServiceProxy_->SetScreenRotationLocked(isLocked); + TLOGI(WmsLogTag::DMS, "DisplayManagerAdapter::SetScreenRotationLocked"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenRotationLocked(isLocked); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->SetScreenRotationLocked(isLocked, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::SetScreenRotationLockedFromJs(bool isLocked) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("DisplayManagerAdapter::SetScreenRotationLockedFromJs"); - return displayManagerServiceProxy_->SetScreenRotationLockedFromJs(isLocked); + TLOGI(WmsLogTag::DMS, "DisplayManagerAdapter::SetScreenRotationLockedFromJs"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenRotationLockedFromJs(isLocked); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->SetScreenRotationLockedFromJs(isLocked, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::IsScreenRotationLocked(bool& isLocked) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - WLOGFI("DisplayManagerAdapter::IsScreenRotationLocked"); - return displayManagerServiceProxy_->IsScreenRotationLocked(isLocked); + TLOGI(WmsLogTag::DMS, "DisplayManagerAdapter::IsScreenRotationLocked"); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->IsScreenRotationLocked(isLocked); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->IsScreenRotationLocked(isLocked, dmError); + return ConvertToDMError(errCode, dmError); } -bool ScreenManagerAdapter::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) +bool ScreenManagerAdapter::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, + PowerStateChangeReason reason) { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->SetSpecifiedScreenPower(screenId, state, reason); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetSpecifiedScreenPower(screenId, state, reason); + } + + bool isSucc = false; + displayManagerServiceProxy_->SetSpecifiedScreenPower(screenId, static_cast(state), + static_cast(reason), isSucc); + return isSucc; } bool ScreenManagerAdapter::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->SetScreenPowerForAll(state, reason); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenPowerForAll(state, reason); + } + + bool isSucc = false; + displayManagerServiceProxy_->SetScreenPowerForAll(static_cast(state), + static_cast(reason), isSucc); + return isSucc; } ScreenPowerState ScreenManagerAdapter::GetScreenPower(ScreenId dmsScreenId) { INIT_PROXY_CHECK_RETURN(ScreenPowerState::INVALID_STATE); - return displayManagerServiceProxy_->GetScreenPower(dmsScreenId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetScreenPower(dmsScreenId); + } + + uint32_t screenPowerState; + ErrCode errCode = displayManagerServiceProxy_->GetScreenPower(dmsScreenId, screenPowerState); + if (FAILED(errCode)) { + return ScreenPowerState::INVALID_STATE; + } + return static_cast(screenPowerState); } ScreenPowerState ScreenManagerAdapter::GetScreenPower() { INIT_PROXY_CHECK_RETURN(ScreenPowerState::INVALID_STATE); - return displayManagerServiceProxy_->GetScreenPower(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetScreenPower(); + } + + return ScreenPowerState::INVALID_STATE; } DMError ScreenManagerAdapter::SetOrientation(ScreenId screenId, Orientation orientation) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetOrientation(screenId, orientation); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetOrientation(screenId, orientation); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->SetOrientation(screenId, static_cast(orientation), + dmError); + return ConvertToDMError(errCode, dmError); } DMError BaseAdapter::RegisterDisplayManagerAgent(const sptr& displayManagerAgent, @@ -327,7 +549,14 @@ DMError BaseAdapter::RegisterDisplayManagerAgent(const sptrRegisterDisplayManagerAgent(displayManagerAgent, type); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->RegisterDisplayManagerAgent(displayManagerAgent, type); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->RegisterDisplayManagerAgent(displayManagerAgent, + static_cast(type), dmError); + return ConvertToDMError(errCode, dmError); } DMError BaseAdapter::UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, @@ -335,126 +564,202 @@ DMError BaseAdapter::UnregisterDisplayManagerAgent(const sptrUnregisterDisplayManagerAgent(displayManagerAgent, type); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->UnregisterDisplayManagerAgent(displayManagerAgent, type); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->UnregisterDisplayManagerAgent(displayManagerAgent, + static_cast(type), dmError); + return ConvertToDMError(errCode, dmError); } bool DisplayManagerAdapter::WakeUpBegin(PowerStateChangeReason reason) { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->WakeUpBegin(reason); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->WakeUpBegin(reason); + } + + bool isSucc = false; + displayManagerServiceProxy_->WakeUpBegin(static_cast(reason), isSucc); + return isSucc; } bool DisplayManagerAdapter::WakeUpEnd() { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->WakeUpEnd(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->WakeUpEnd(); + } + + bool isSucc = false; + displayManagerServiceProxy_->WakeUpEnd(isSucc); + return isSucc; } bool DisplayManagerAdapter::SuspendBegin(PowerStateChangeReason reason) { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->SuspendBegin(reason); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SuspendBegin(reason); + } + + bool isSucc = false; + displayManagerServiceProxy_->SuspendBegin(static_cast(reason), isSucc); + return isSucc; } bool DisplayManagerAdapter::SuspendEnd() { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->SuspendEnd(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SuspendEnd(); + } + + bool isSucc = false; + displayManagerServiceProxy_->SuspendEnd(isSucc); + return isSucc; } ScreenId DisplayManagerAdapter::GetInternalScreenId() { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->GetInternalScreenId(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetInternalScreenId(); + } + + return SCREEN_ID_INVALID; } bool DisplayManagerAdapter::SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) { INIT_PROXY_CHECK_RETURN(false); - - return displayManagerServiceProxy_->SetScreenPowerById(screenId, state, reason); + + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenPowerById(screenId, state, reason); + } + + return false; } bool DisplayManagerAdapter::SetDisplayState(DisplayState state) { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->SetDisplayState(state); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetDisplayState(state); + } + + bool isSucc = false; + displayManagerServiceProxy_->SetDisplayState(static_cast(state), isSucc); + return isSucc; } DisplayState DisplayManagerAdapter::GetDisplayState(DisplayId displayId) { INIT_PROXY_CHECK_RETURN(DisplayState::UNKNOWN); - return displayManagerServiceProxy_->GetDisplayState(displayId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetDisplayState(displayId); + } + + uint32_t displayState; + ErrCode errCode = displayManagerServiceProxy_->GetDisplayState(displayId, displayState); + if (FAILED(errCode)) { + return DisplayState::UNKNOWN; + } + return static_cast(displayState); } bool DisplayManagerAdapter::TryToCancelScreenOff() { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->TryToCancelScreenOff(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->TryToCancelScreenOff(); + } + + bool isSucc = false; + displayManagerServiceProxy_->TryToCancelScreenOff(isSucc); + return isSucc; } void DisplayManagerAdapter::NotifyDisplayEvent(DisplayEvent event) { INIT_PROXY_CHECK_RETURN(); - displayManagerServiceProxy_->NotifyDisplayEvent(event); + if (screenSessionManagerServiceProxy_) { + screenSessionManagerServiceProxy_->NotifyDisplayEvent(event); + } else { + displayManagerServiceProxy_->NotifyDisplayEvent(static_cast(event)); + } } bool DisplayManagerAdapter::SetFreeze(std::vector displayIds, bool isFreeze) { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->SetFreeze(displayIds, isFreeze); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetFreeze(displayIds, isFreeze); + } + + bool isSucc = false; + displayManagerServiceProxy_->SetFreeze(displayIds, isFreeze, isSucc); + return isSucc; } bool BaseAdapter::InitDMSProxy() { std::lock_guard lock(mutex_); - if (!isProxyValid_) { - sptr systemAbilityManager = - SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (!systemAbilityManager) { - WLOGFE("Failed to get system ability mgr."); - return false; - } - - sptr remoteObject - = systemAbilityManager->GetSystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID); - if (!remoteObject) { - WLOGFE("Failed to get display manager service."); - return false; - } - - if (SceneBoardJudgement::IsSceneBoardEnabled()) { - displayManagerServiceProxy_ = iface_cast(remoteObject); - } else { - displayManagerServiceProxy_ = iface_cast(remoteObject); - } - if ((!displayManagerServiceProxy_) || (!displayManagerServiceProxy_->AsObject())) { - WLOGFW("Failed to get system display manager services"); - return false; - } - - dmsDeath_ = new(std::nothrow) DMSDeathRecipient(*this); - if (dmsDeath_ == nullptr) { - WLOGFE("Failed to create death Recipient ptr DMSDeathRecipient"); - return false; - } - if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(dmsDeath_)) { - WLOGFE("Failed to add death recipient"); - return false; - } - isProxyValid_ = true; + if (isProxyValid_) { + return true; } + + sptr systemAbilityManager = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!systemAbilityManager) { + TLOGE(WmsLogTag::DMS, "Failed to get system ability mgr."); + return false; + } + + sptr remoteObject = systemAbilityManager->GetSystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID); + if (!remoteObject) { + TLOGE(WmsLogTag::DMS, "Failed to get display manager service."); + return false; + } + + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + screenSessionManagerServiceProxy_ = iface_cast(remoteObject); + if ((!screenSessionManagerServiceProxy_) || (!screenSessionManagerServiceProxy_->AsObject())) { + TLOGE(WmsLogTag::DMS, "Failed to get remote object of IScreenSessionManager"); + return false; + } + } else { + displayManagerServiceProxy_ = iface_cast(remoteObject); + if ((!displayManagerServiceProxy_) || (!displayManagerServiceProxy_->AsObject())) { + TLOGE(WmsLogTag::DMS, "Failed to get remote object of IDisplayManager"); + return false; + } + } + + dmsDeath_ = new (std::nothrow) DMSDeathRecipient(*this); + if (dmsDeath_ == nullptr) { + TLOGE(WmsLogTag::DMS, "Failed to create death Recipient ptr DMSDeathRecipient"); + return false; + } + if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(dmsDeath_)) { + TLOGE(WmsLogTag::DMS, "Failed to add death recipient"); + return false; + } + + isProxyValid_ = true; return true; } @@ -465,39 +770,42 @@ DMSDeathRecipient::DMSDeathRecipient(BaseAdapter& adapter) : adapter_(adapter) void DMSDeathRecipient::OnRemoteDied(const wptr& wptrDeath) { if (wptrDeath == nullptr) { - WLOGFE("wptrDeath is null"); + TLOGE(WmsLogTag::DMS, "wptrDeath is null"); return; } sptr object = wptrDeath.promote(); if (!object) { - WLOGFE("object is null"); + TLOGE(WmsLogTag::DMS, "object is null"); return; } - WLOGFI("dms OnRemoteDied"); + TLOGI(WmsLogTag::DMS, "dms OnRemoteDied"); adapter_.Clear(); if (SingletonContainer::IsDestroyed()) { - WLOGFE("SingletonContainer is destroyed"); + TLOGE(WmsLogTag::DMS, "SingletonContainer is destroyed"); return; } SingletonContainer::Get().OnRemoteDied(); SingletonContainer::Get().OnRemoteDied(); - return; } BaseAdapter::~BaseAdapter() { - WLOGFI("destory!"); + TLOGI(WmsLogTag::DMS, "destroy!"); std::lock_guard lock(mutex_); Clear(); + screenSessionManagerServiceProxy_ = nullptr; displayManagerServiceProxy_ = nullptr; } void BaseAdapter::Clear() { - WLOGFD("Clear!"); + TLOGD(WmsLogTag::DMS, "Clear!"); std::lock_guard lock(mutex_); + if ((screenSessionManagerServiceProxy_ != nullptr) && (screenSessionManagerServiceProxy_->AsObject() != nullptr)) { + screenSessionManagerServiceProxy_->AsObject()->RemoveDeathRecipient(dmsDeath_); + } if ((displayManagerServiceProxy_ != nullptr) && (displayManagerServiceProxy_->AsObject() != nullptr)) { displayManagerServiceProxy_->AsObject()->RemoveDeathRecipient(dmsDeath_); } @@ -509,7 +817,13 @@ DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vectorMakeMirror(mainScreenId, mirrorScreenId, screenGroupId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId, screenGroupId); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId, screenGroupId, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::MakeMirrorForRecord(ScreenId mainScreenId, std::vector mirrorScreenId, @@ -517,7 +831,11 @@ DMError ScreenManagerAdapter::MakeMirrorForRecord(ScreenId mainScreenId, std::ve { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->MakeMirrorForRecord(mainScreenId, mirrorScreenId, screenGroupId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->MakeMirrorForRecord(mainScreenId, mirrorScreenId, screenGroupId); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenId, @@ -525,7 +843,12 @@ DMError ScreenManagerAdapter::MakeMirror(ScreenId mainScreenId, std::vectorMakeMirror(mainScreenId, mirrorScreenId, mainScreenRegion, screenGroupId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->MakeMirror(mainScreenId, mirrorScreenId, mainScreenRegion, + screenGroupId); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, @@ -533,7 +856,11 @@ DMError ScreenManagerAdapter::SetMultiScreenMode(ScreenId mainScreenId, ScreenId { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetMultiScreenMode(mainScreenId, secondaryScreenId, screenMode); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetMultiScreenMode(mainScreenId, secondaryScreenId, screenMode); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions, @@ -541,97 +868,166 @@ DMError ScreenManagerAdapter::SetMultiScreenRelativePosition(MultiScreenPosition { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetMultiScreenRelativePosition(mainScreenOptions, secondScreenOption); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetMultiScreenRelativePosition(mainScreenOptions, secondScreenOption); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::StopMirror(const std::vector& mirrorScreenIds) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->StopMirror(mirrorScreenIds); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->StopMirror(mirrorScreenIds); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->StopMirror(mirrorScreenIds, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::DisableMirror(bool disableOrNot) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->DisableMirror(disableOrNot); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->DisableMirror(disableOrNot); + } + + return DMError::DM_ERROR_INVALID_PERMISSION; } sptr ScreenManagerAdapter::GetScreenInfo(ScreenId screenId) { if (screenId == SCREEN_ID_INVALID) { - WLOGFE("screen id is invalid"); + TLOGE(WmsLogTag::DMS, "screen id is invalid"); return nullptr; } INIT_PROXY_CHECK_RETURN(nullptr); - sptr screenInfo = displayManagerServiceProxy_->GetScreenInfoById(screenId); + sptr screenInfo; + if (screenSessionManagerServiceProxy_) { + screenInfo = screenSessionManagerServiceProxy_->GetScreenInfoById(screenId); + } else { + ErrCode errCode = displayManagerServiceProxy_->GetScreenInfoById(screenId, screenInfo); + if (FAILED(errCode) || screenInfo == nullptr) { + return nullptr; + } + } return screenInfo; } std::vector DisplayManagerAdapter::GetAllDisplayIds() { - WLOGFD("DisplayManagerAdapter::GetAllDisplayIds enter"); + TLOGD(WmsLogTag::DMS, "DisplayManagerAdapter::GetAllDisplayIds enter"); INIT_PROXY_CHECK_RETURN(std::vector()); - return displayManagerServiceProxy_->GetAllDisplayIds(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetAllDisplayIds(); + } + + std::vector displayIds; + displayManagerServiceProxy_->GetAllDisplayIds(displayIds); + return displayIds; } DMError DisplayManagerAdapter::HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->HasPrivateWindow(displayId, hasPrivateWindow); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->HasPrivateWindow(displayId, hasPrivateWindow); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->HasPrivateWindow(displayId, hasPrivateWindow, dmError); + return ConvertToDMError(errCode, dmError); } bool DisplayManagerAdapter::ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId) { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->ConvertScreenIdToRsScreenId(screenId, rsScreenId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->ConvertScreenIdToRsScreenId(screenId, rsScreenId); + } + + return false; } DMError DisplayManagerAdapter::HasImmersiveWindow(ScreenId screenId, bool& immersive) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->HasImmersiveWindow(screenId, immersive); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->HasImmersiveWindow(screenId, immersive); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } sptr DisplayManagerAdapter::GetDisplayInfo(DisplayId displayId) { - WLOGFD("DisplayManagerAdapter::GetDisplayInfo enter, displayId: %{public}" PRIu64" ", displayId); + TLOGD(WmsLogTag::DMS, "DisplayManagerAdapter::GetDisplayInfo enter, displayId: %{public}" PRIu64" ", displayId); if (displayId == DISPLAY_ID_INVALID) { - WLOGFE("screen id is invalid"); + TLOGE(WmsLogTag::DMS, "screen id is invalid"); return nullptr; } INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetDisplayInfoById(displayId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetDisplayInfoById(displayId); + } + + sptr displayInfo; + ErrCode errCode = displayManagerServiceProxy_->GetDisplayInfoById(displayId, displayInfo); + if (FAILED(errCode) || displayInfo == nullptr) { + return nullptr; + } + return displayInfo; } sptr DisplayManagerAdapter::GetVisibleAreaDisplayInfoById(DisplayId displayId) { - WLOGFD("enter, displayId: %{public}" PRIu64" ", displayId); + TLOGD(WmsLogTag::DMS, "enter, displayId: %{public}" PRIu64" ", displayId); if (displayId == DISPLAY_ID_INVALID) { - WLOGFE("display id is invalid"); + TLOGE(WmsLogTag::DMS, "display id is invalid"); return nullptr; } INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetVisibleAreaDisplayInfoById(displayId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetVisibleAreaDisplayInfoById(displayId); + } + + sptr displayInfo; + ErrCode errCode = displayManagerServiceProxy_->GetVisibleAreaDisplayInfoById(displayId, displayInfo); + if (FAILED(errCode) || displayInfo == nullptr) { + return nullptr; + } + return displayInfo; } sptr DisplayManagerAdapter::GetCutoutInfo(DisplayId displayId) { - WLOGFD("DisplayManagerAdapter::GetCutoutInfo"); + TLOGD(WmsLogTag::DMS, "DisplayManagerAdapter::GetCutoutInfo"); if (displayId == DISPLAY_ID_INVALID) { - WLOGFE("screen id is invalid"); + TLOGE(WmsLogTag::DMS, "screen id is invalid"); return nullptr; } INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetCutoutInfo(displayId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetCutoutInfo(displayId); + } + + sptr cutoutInfo; + ErrCode errCode = displayManagerServiceProxy_->GetCutoutInfo(displayId, cutoutInfo); + if (FAILED(errCode) || cutoutInfo == nullptr) { + return nullptr; + } + return cutoutInfo; } sptr DisplayManagerAdapter::GetCutoutInfoWithRotation(DisplayId displayId, int32_t rotation) @@ -639,75 +1035,116 @@ sptr DisplayManagerAdapter::GetCutoutInfoWithRotation(DisplayId disp TLOGD(WmsLogTag::DMS, "GetCutoutInfoWithRotation enter, rotation: %{public}d, displayId: %{public}" PRIu64" ", rotation, displayId); if (displayId == DISPLAY_ID_INVALID) { - WLOGFE("screen id is invalid"); + TLOGE(WmsLogTag::DMS, "screen id is invalid"); return nullptr; } INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetCutoutInfoWithRotation(displayId, rotation); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetCutoutInfoWithRotation(displayId, rotation); + } + + return nullptr; } DMError DisplayManagerAdapter::AddSurfaceNodeToDisplay(DisplayId displayId, std::shared_ptr& surfaceNode) { if (displayId == DISPLAY_ID_INVALID) { - WLOGFE("screen id is invalid"); + TLOGE(WmsLogTag::DMS, "screen id is invalid"); return DMError::DM_ERROR_INVALID_PARAM; } INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->AddSurfaceNodeToDisplay(displayId, surfaceNode); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->AddSurfaceNodeToDisplay(displayId, surfaceNode); + } + + std::shared_ptr dmRsSurfaceNode = std::make_shared(surfaceNode); + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->AddSurfaceNodeToDisplay(displayId, dmRsSurfaceNode, dmError); + return ConvertToDMError(errCode, dmError); } DMError DisplayManagerAdapter::RemoveSurfaceNodeFromDisplay(DisplayId displayId, std::shared_ptr& surfaceNode) { if (displayId == DISPLAY_ID_INVALID) { - WLOGFE("screen id is invalid"); + TLOGE(WmsLogTag::DMS, "screen id is invalid"); return DMError::DM_ERROR_INVALID_PARAM; } INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->RemoveSurfaceNodeFromDisplay(displayId, surfaceNode); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->RemoveSurfaceNodeFromDisplay(displayId, surfaceNode); + } + + int32_t dmError; + std::shared_ptr dmRsSurfaceNode = std::make_shared(surfaceNode); + ErrCode errCode = displayManagerServiceProxy_->RemoveSurfaceNodeFromDisplay(displayId, dmRsSurfaceNode, + dmError); + return ConvertToDMError(errCode, dmError); } bool DisplayManagerAdapter::IsFoldable() { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->IsFoldable(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->IsFoldable(); + } + + return false; } bool DisplayManagerAdapter::IsCaptured() { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->IsCaptured(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->IsCaptured(); + } + + return false; } FoldStatus DisplayManagerAdapter::GetFoldStatus() { INIT_PROXY_CHECK_RETURN(FoldStatus::UNKNOWN); - return displayManagerServiceProxy_->GetFoldStatus(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetFoldStatus(); + } + + return FoldStatus::UNKNOWN; } FoldDisplayMode DisplayManagerAdapter::GetFoldDisplayMode() { INIT_PROXY_CHECK_RETURN(FoldDisplayMode::UNKNOWN); - return displayManagerServiceProxy_->GetFoldDisplayMode(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetFoldDisplayMode(); + } + + return FoldDisplayMode::UNKNOWN; } void DisplayManagerAdapter::SetFoldDisplayMode(const FoldDisplayMode mode) { INIT_PROXY_CHECK_RETURN(); - return displayManagerServiceProxy_->SetFoldDisplayMode(mode); + if (screenSessionManagerServiceProxy_) { + screenSessionManagerServiceProxy_->SetFoldDisplayMode(mode); + } } DMError DisplayManagerAdapter::SetFoldDisplayModeFromJs(const FoldDisplayMode mode, std::string reason) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetFoldDisplayModeFromJs(mode, reason); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetFoldDisplayModeFromJs(mode, reason); + } + + return DMError::DM_OK; } void DisplayManagerAdapter::SetDisplayScale(ScreenId screenId, @@ -715,46 +1152,73 @@ void DisplayManagerAdapter::SetDisplayScale(ScreenId screenId, { INIT_PROXY_CHECK_RETURN(); - return displayManagerServiceProxy_->SetDisplayScale(screenId, scaleX, scaleY, pivotX, pivotY); + if (screenSessionManagerServiceProxy_) { + screenSessionManagerServiceProxy_->SetDisplayScale(screenId, scaleX, scaleY, pivotX, pivotY); + } } void DisplayManagerAdapter::SetFoldStatusLocked(bool locked) { INIT_PROXY_CHECK_RETURN(); - return displayManagerServiceProxy_->SetFoldStatusLocked(locked); + if (screenSessionManagerServiceProxy_) { + screenSessionManagerServiceProxy_->SetFoldStatusLocked(locked); + } } DMError DisplayManagerAdapter::SetFoldStatusLockedFromJs(bool locked) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetFoldStatusLockedFromJs(locked); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetFoldStatusLockedFromJs(locked); + } + + return DMError::DM_OK; } sptr DisplayManagerAdapter::GetCurrentFoldCreaseRegion() { INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetCurrentFoldCreaseRegion(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetCurrentFoldCreaseRegion(); + } + + return nullptr; } sptr ScreenManagerAdapter::GetScreenGroupInfoById(ScreenId screenId) { if (screenId == SCREEN_ID_INVALID) { - WLOGFE("screenGroup id is invalid"); + TLOGE(WmsLogTag::DMS, "screenGroup id is invalid"); return nullptr; } INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetScreenGroupInfoById(screenId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetScreenGroupInfoById(screenId); + } + + sptr screenGroupInfo; + ErrCode errCode = displayManagerServiceProxy_->GetScreenGroupInfoById(screenId, screenGroupInfo); + if (FAILED(errCode) || screenGroupInfo == nullptr) { + return nullptr; + } + return screenGroupInfo; } DMError ScreenManagerAdapter::GetAllScreenInfos(std::vector>& screenInfos) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->GetAllScreenInfos(screenInfos); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetAllScreenInfos(screenInfos); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->GetAllScreenInfos(screenInfos, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::MakeExpand(std::vector screenId, std::vector startPoint, @@ -762,14 +1226,26 @@ DMError ScreenManagerAdapter::MakeExpand(std::vector screenId, std::ve { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->MakeExpand(screenId, startPoint, screenGroupId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->MakeExpand(screenId, startPoint, screenGroupId); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->MakeExpand(screenId, startPoint, screenGroupId, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::StopExpand(const std::vector& expandScreenIds) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->StopExpand(expandScreenIds); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->StopExpand(expandScreenIds); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->StopExpand(expandScreenIds, dmError); + return ConvertToDMError(errCode, dmError); } @@ -777,56 +1253,97 @@ void ScreenManagerAdapter::RemoveVirtualScreenFromGroup(std::vector sc { INIT_PROXY_CHECK_RETURN(); - displayManagerServiceProxy_->RemoveVirtualScreenFromGroup(screens); + if (screenSessionManagerServiceProxy_) { + screenSessionManagerServiceProxy_->RemoveVirtualScreenFromGroup(screens); + } else { + displayManagerServiceProxy_->RemoveVirtualScreenFromGroup(screens); + } } DMError ScreenManagerAdapter::SetScreenActiveMode(ScreenId screenId, uint32_t modeId) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetScreenActiveMode(screenId, modeId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenActiveMode(screenId, modeId); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->SetScreenActiveMode(screenId, modeId, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetVirtualPixelRatio(screenId, virtualPixelRatio); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetVirtualPixelRatio(screenId, virtualPixelRatio); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->SetVirtualPixelRatio(screenId, virtualPixelRatio, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetVirtualPixelRatioSystem(screenId, virtualPixelRatio); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetVirtualPixelRatioSystem(screenId, virtualPixelRatio); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetDefaultDensityDpi(ScreenId screenId, float virtualPixelRatio) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetDefaultDensityDpi(screenId, virtualPixelRatio); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetDefaultDensityDpi(screenId, virtualPixelRatio); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetResolution(screenId, width, height, virtualPixelRatio); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetResolution(screenId, width, height, virtualPixelRatio); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->SetResolution(screenId, width, height, virtualPixelRatio, + dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->GetDensityInCurResolution(screenId, virtualPixelRatio); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetDensityInCurResolution(screenId, virtualPixelRatio); + } + + int32_t dmError; + ErrCode errCode = displayManagerServiceProxy_->GetDensityInCurResolution(screenId, virtualPixelRatio, dmError); + return ConvertToDMError(errCode, dmError); } DMError ScreenManagerAdapter::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->ResizeVirtualScreen(screenId, width, height); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->ResizeVirtualScreen(screenId, width, height); + } + + return DMError::DM_OK; } DMError ScreenManagerAdapter::MakeUniqueScreen(const std::vector& screenIds, @@ -834,158 +1351,240 @@ DMError ScreenManagerAdapter::MakeUniqueScreen(const std::vector& scre { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->MakeUniqueScreen(screenIds, displayIds); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->MakeUniqueScreen(screenIds, displayIds); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError DisplayManagerAdapter::GetAvailableArea(DisplayId displayId, DMRect& area) { if (displayId == DISPLAY_ID_INVALID) { - WLOGFE("displayId id is invalid"); + TLOGE(WmsLogTag::DMS, "displayId id is invalid"); return DMError::DM_ERROR_INVALID_PARAM; } INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->GetAvailableArea(displayId, area); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetAvailableArea(displayId, area); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError DisplayManagerAdapter::GetExpandAvailableArea(DisplayId displayId, DMRect& area) { if (displayId == DISPLAY_ID_INVALID) { - WLOGFE("displayId id is invalid"); + TLOGE(WmsLogTag::DMS, "displayId id is invalid"); return DMError::DM_ERROR_INVALID_PARAM; } INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->GetExpandAvailableArea(displayId, area); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetExpandAvailableArea(displayId, area); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } VirtualScreenFlag ScreenManagerAdapter::GetVirtualScreenFlag(ScreenId screenId) { INIT_PROXY_CHECK_RETURN(VirtualScreenFlag::DEFAULT); if (screenId == SCREEN_ID_INVALID) { - WLOGFE("screenId id is invalid"); + TLOGE(WmsLogTag::DMS, "screenId id is invalid"); return VirtualScreenFlag::DEFAULT; } - return displayManagerServiceProxy_->GetVirtualScreenFlag(screenId); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetVirtualScreenFlag(screenId); + } + + return VirtualScreenFlag::DEFAULT; } DMError ScreenManagerAdapter::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); if (screenId == SCREEN_ID_INVALID) { - WLOGFE("displayId id is invalid"); + TLOGE(WmsLogTag::DMS, "displayId id is invalid"); return DMError::DM_ERROR_INVALID_PARAM; } if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) { return DMError::DM_ERROR_INVALID_PARAM; } - return displayManagerServiceProxy_->SetVirtualScreenFlag(screenId, screenFlag); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetVirtualScreenFlag(screenId, screenFlag); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetVirtualScreenRefreshRate(screenId, refreshInterval); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetVirtualScreenRefreshRate(screenId, refreshInterval); + } + + return DMError::DM_OK; } void DisplayManagerAdapter::SetVirtualScreenBlackList(ScreenId screenId, std::vector& windowIdList, std::vector surfaceIdList, std::vector typeBlackList) { INIT_PROXY_CHECK_RETURN(); - displayManagerServiceProxy_->SetVirtualScreenBlackList(screenId, windowIdList, surfaceIdList, typeBlackList); + if (screenSessionManagerServiceProxy_) { + screenSessionManagerServiceProxy_->SetVirtualScreenBlackList(screenId, windowIdList, surfaceIdList, + typeBlackList); + } } void DisplayManagerAdapter::SetVirtualDisplayMuteFlag(ScreenId screenId, bool muteFlag) { INIT_PROXY_CHECK_RETURN(); - displayManagerServiceProxy_->SetVirtualDisplayMuteFlag(screenId, muteFlag); + if (screenSessionManagerServiceProxy_) { + screenSessionManagerServiceProxy_->SetVirtualDisplayMuteFlag(screenId, muteFlag); + } } void DisplayManagerAdapter::DisablePowerOffRenderControl(ScreenId screenId) { INIT_PROXY_CHECK_RETURN(); - displayManagerServiceProxy_->DisablePowerOffRenderControl(screenId); + if (screenSessionManagerServiceProxy_) { + screenSessionManagerServiceProxy_->DisablePowerOffRenderControl(screenId); + } } DMError DisplayManagerAdapter::ProxyForFreeze(const std::set& pidList, bool isProxy) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->ProxyForFreeze(pidList, isProxy); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->ProxyForFreeze(pidList, isProxy); + } + + return DMError::DM_OK; } DMError DisplayManagerAdapter::ResetAllFreezeStatus() { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->ResetAllFreezeStatus(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->ResetAllFreezeStatus(); + } + + return DMError::DM_OK; } std::vector DisplayManagerAdapter::GetAllDisplayPhysicalResolution() { INIT_PROXY_CHECK_RETURN(std::vector{}); - return displayManagerServiceProxy_->GetAllDisplayPhysicalResolution(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetAllDisplayPhysicalResolution(); + } + + std::vector displayPhysicalResolutions; + displayManagerServiceProxy_->GetAllDisplayPhysicalResolution(displayPhysicalResolutions); + return displayPhysicalResolutions; } DMError DisplayManagerAdapter::GetDisplayCapability(std::string& capabilitInfo) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->GetDisplayCapability(capabilitInfo); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetDisplayCapability(capabilitInfo); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError DisplayManagerAdapter::SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, std::vector& windowIdList) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetVirtualScreenSecurityExemption(screenId, pid, windowIdList); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetVirtualScreenSecurityExemption(screenId, pid, windowIdList); + } + + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } DMError ScreenManagerAdapter::SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate, uint32_t& actualRefreshRate) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetVirtualScreenMaxRefreshRate(id, refreshRate, actualRefreshRate); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetVirtualScreenMaxRefreshRate(id, refreshRate, actualRefreshRate); + } + + return DMError::DM_OK; } bool ScreenManagerAdapter::SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus) { INIT_PROXY_CHECK_RETURN(false); - return displayManagerServiceProxy_->SetVirtualScreenStatus(screenId, screenStatus); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetVirtualScreenStatus(screenId, screenStatus); + } + + return false; } std::shared_ptr DisplayManagerAdapter::GetScreenCapture(const CaptureOption& captureOption, DmErrorCode* errorCode) { INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetScreenCapture(captureOption, errorCode); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetScreenCapture(captureOption, errorCode); + } + + *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; + return nullptr; } sptr DisplayManagerAdapter::GetPrimaryDisplayInfo() { INIT_PROXY_CHECK_RETURN(nullptr); - if (SceneBoardJudgement::IsSceneBoardEnabled()) { - return displayManagerServiceProxy_->GetPrimaryDisplayInfo(); - } else { - return displayManagerServiceProxy_->GetDefaultDisplayInfo(); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetPrimaryDisplayInfo(); } + + sptr displayInfo; + ErrCode errCode = displayManagerServiceProxy_->GetDefaultDisplayInfo(displayInfo); + if (FAILED(errCode) || displayInfo == nullptr) { + return nullptr; + } + return displayInfo; } std::shared_ptr DisplayManagerAdapter::GetDisplaySnapshotWithOption(const CaptureOption& captureOption, DmErrorCode* errorCode) { INIT_PROXY_CHECK_RETURN(nullptr); - return displayManagerServiceProxy_->GetDisplaySnapshotWithOption(captureOption, errorCode); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->GetDisplaySnapshotWithOption(captureOption, errorCode); + } + + *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; + return nullptr; } void ScreenManagerAdapter::SetFoldStatusExpandAndLocked(bool locked) { INIT_PROXY_CHECK_RETURN(); - return displayManagerServiceProxy_->SetFoldStatusExpandAndLocked(locked); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetFoldStatusExpandAndLocked(locked); + } } DMError ScreenManagerAdapter::SetScreenSkipProtectedWindow(const std::vector& screenIds, bool isEnable) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); - return displayManagerServiceProxy_->SetScreenSkipProtectedWindow(screenIds, isEnable); + if (screenSessionManagerServiceProxy_) { + return screenSessionManagerServiceProxy_->SetScreenSkipProtectedWindow(screenIds, isEnable); + } + + return DMError::DM_OK; } } // namespace OHOS::Rosen diff --git a/dm/test/unittest/BUILD.gn b/dm/test/unittest/BUILD.gn index 75b6cf02e7..e8fed5b33b 100644 --- a/dm/test/unittest/BUILD.gn +++ b/dm/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -214,6 +214,7 @@ ohos_unittest("dm_oh_display_manager_test") { module_out_path = module_out_path include_dirs = [ "../../src" ] + sources = [ "oh_display_manager_test.cpp" ] deps = [ @@ -240,6 +241,9 @@ config("dm_unittest_common_public_config") { "../../../interfaces/innerkits/dm", "../../../test/common/utils/include", "../../../utils/include", + "../../../window_scene/screen_session_manager/include", + "../../../window_scene/screen_session_manager_client/include", + "${dmserver_gen_path}", ] } @@ -265,6 +269,7 @@ ohos_static_library("dm_unittest_common") { ] public_external_deps = [ + "ability_base:want", "c_utils:utils", "googletest:gmock", "googletest:gtest_main", diff --git a/dm/test/unittest/display_manager_adapter_test.cpp b/dm/test/unittest/display_manager_adapter_test.cpp index b02bcb507a..2c02adf476 100644 --- a/dm/test/unittest/display_manager_adapter_test.cpp +++ b/dm/test/unittest/display_manager_adapter_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,18 +14,18 @@ */ #include -#include "display_manager_adapter.h" + #include "display_manager.h" -#include "screen_manager.h" +#include "display_manager_adapter.h" #include "display_manager_proxy.h" -#include "window_scene.h" #include "scene_board_judgement.h" +#include "screen_manager.h" +#include "window_scene.h" using namespace testing; using namespace testing::ext; -namespace OHOS { -namespace Rosen { +namespace OHOS::Rosen { class DisplayManagerAdapterTest : public testing::Test { public: static void SetUpTestCase(); @@ -109,7 +109,6 @@ HWTEST_F(DisplayManagerAdapterTest, GetScreenSupportedColorGamuts, TestSize.Leve */ HWTEST_F(DisplayManagerAdapterTest, SetScreenColorGamut, TestSize.Level1) { - std::vector colorGamuts; DMError err = SingletonContainer::Get().SetScreenColorGamut(0, -1); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); @@ -165,11 +164,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetScreenGamutMap, TestSize.Level1) HWTEST_F(DisplayManagerAdapterTest, SetScreenColorTransform, TestSize.Level1) { DMError err = SingletonContainer::Get().SetScreenColorTransform(0); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_OK); - } else { - ASSERT_EQ(err, DMError::DM_OK); - } + ASSERT_EQ(err, DMError::DM_OK); } /** @@ -230,13 +225,18 @@ HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied01, TestSize.Level1) { - sptr dmsDeath_ = nullptr; - dmsDeath_ = new(std::nothrow) DMSDeathRecipient(SingletonContainer::Get()); + sptr dmsDeath = + new (std::nothrow) DMSDeathRecipient(SingletonContainer::Get()); SingletonContainer::Get().InitDMSProxy(); - sptr obj = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - wptr wptrDeath = obj; - dmsDeath_->OnRemoteDied(wptrDeath); - EXPECT_NE(nullptr, dmsDeath_); + sptr remoteObject; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + remoteObject = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + remoteObject = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } + wptr wptrDeath = remoteObject; + dmsDeath->OnRemoteDied(wptrDeath); + EXPECT_NE(nullptr, dmsDeath); } /** @@ -246,9 +246,15 @@ HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied01, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, Clear, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - SingletonContainer::Get().Clear(); - ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + SingletonContainer::Get().InitDMSProxy(); + SingletonContainer::Get().Clear(); + ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + } else { + SingletonContainer::Get().InitDMSProxy(); + SingletonContainer::Get().Clear(); + ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + } } /** @@ -258,10 +264,17 @@ HWTEST_F(DisplayManagerAdapterTest, Clear, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, Clear01, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - SingletonContainer::Get().displayManagerServiceProxy_ = nullptr; - SingletonContainer::Get().Clear(); - ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + SingletonContainer::Get().InitDMSProxy(); + SingletonContainer::Get().screenSessionManagerServiceProxy_ = nullptr; + SingletonContainer::Get().Clear(); + ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + } else { + SingletonContainer::Get().InitDMSProxy(); + SingletonContainer::Get().displayManagerServiceProxy_ = nullptr; + SingletonContainer::Get().Clear(); + ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + } } /** @@ -272,10 +285,10 @@ HWTEST_F(DisplayManagerAdapterTest, Clear01, TestSize.Level1) HWTEST_F(DisplayManagerAdapterTest, DisableMirror, TestSize.Level1) { DMError ret = SingletonContainer::Get().DisableMirror(false); - if (SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(DMError::DM_OK, ret); + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_EQ(ret, DMError::DM_ERROR_INVALID_PERMISSION); } else { - ASSERT_NE(DMError::DM_OK, ret); + ASSERT_EQ(ret, DMError::DM_OK); } } @@ -302,10 +315,10 @@ HWTEST_F(DisplayManagerAdapterTest, HasImmersiveWindow, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, GetPixelFormat, TestSize.Level1) { - GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8}; + GraphicPixelFormat pixelFormat = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_CLUT8; DMError err = SingletonContainer::Get().GetPixelFormat(0, pixelFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -318,10 +331,10 @@ HWTEST_F(DisplayManagerAdapterTest, GetPixelFormat, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, SetPixelFormat, TestSize.Level1) { - GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8}; + GraphicPixelFormat pixelFormat = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_CLUT8; DMError err = SingletonContainer::Get().SetPixelFormat(0, pixelFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -337,7 +350,7 @@ HWTEST_F(DisplayManagerAdapterTest, GetSupportedHDRFormats, TestSize.Level1) std::vector hdrFormats; DMError err = SingletonContainer::Get().GetSupportedHDRFormats(0, hdrFormats); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -350,10 +363,10 @@ HWTEST_F(DisplayManagerAdapterTest, GetSupportedHDRFormats, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, GetScreenHDRFormat, TestSize.Level1) { - ScreenHDRFormat hdrFormat = ScreenHDRFormat{NOT_SUPPORT_HDR}; + ScreenHDRFormat hdrFormat = ScreenHDRFormat::NOT_SUPPORT_HDR; DMError err = SingletonContainer::Get().GetScreenHDRFormat(0, hdrFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -368,7 +381,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetScreenHDRFormat, TestSize.Level1) { DMError err = SingletonContainer::Get().SetScreenHDRFormat(0, 0); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -384,7 +397,7 @@ HWTEST_F(DisplayManagerAdapterTest, GetSupportedColorSpaces, TestSize.Level1) std::vector colorSpaces; DMError err = SingletonContainer::Get().GetSupportedColorSpaces(0, colorSpaces); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -397,10 +410,10 @@ HWTEST_F(DisplayManagerAdapterTest, GetSupportedColorSpaces, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, GetScreenColorSpace, TestSize.Level1) { - GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE}; + GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType::GRAPHIC_CM_COLORSPACE_NONE; DMError err = SingletonContainer::Get().GetScreenColorSpace(0, colorSpace); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -413,10 +426,10 @@ HWTEST_F(DisplayManagerAdapterTest, GetScreenColorSpace, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, SetScreenColorSpace, TestSize.Level1) { - GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE}; + GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType::GRAPHIC_CM_COLORSPACE_NONE; DMError err = SingletonContainer::Get().SetScreenColorSpace(0, colorSpace); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } @@ -429,7 +442,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetScreenColorSpace, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, DestroyVirtualScreen, TestSize.Level1) { - VirtualScreenOption defaultOption = {"virtualScreen01", 480, 320, 2.0, nullptr, 0}; + VirtualScreenOption defaultOption = { "virtualScreen01", 480, 320, 2.0, nullptr, 0 }; ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); DMError err = SingletonContainer::Get().DestroyVirtualScreen(id); ASSERT_EQ(err, DMError::DM_OK); @@ -444,7 +457,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetVirtualMirrorScreenCanvasRotation, TestSi { bool canvasRotation = false; DMError ret = SingletonContainer::Get(). - SetVirtualMirrorScreenCanvasRotation(0, canvasRotation); + SetVirtualMirrorScreenCanvasRotation(0, canvasRotation); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(ret, DMError::DM_OK); } else { @@ -491,8 +504,8 @@ HWTEST_F(DisplayManagerAdapterTest, IsScreenRotationLocked, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, SetSpecifiedScreenPower, TestSize.Level1) { - ScreenPowerState state = ScreenPowerState{0}; - PowerStateChangeReason reason = PowerStateChangeReason{0}; + ScreenPowerState state = ScreenPowerState::POWER_ON; + PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON; bool ret = SingletonContainer::Get().SetSpecifiedScreenPower(0, state, reason); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); @@ -508,13 +521,9 @@ HWTEST_F(DisplayManagerAdapterTest, SetSpecifiedScreenPower, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, SetOrientation, TestSize.Level1) { - Orientation orientation = Orientation{0}; + Orientation orientation = Orientation::BEGIN; DMError err = SingletonContainer::Get().SetOrientation(0, orientation); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_OK); - } else { - ASSERT_EQ(err, DMError::DM_OK); - } + ASSERT_EQ(err, DMError::DM_OK); } /** @@ -524,13 +533,9 @@ HWTEST_F(DisplayManagerAdapterTest, SetOrientation, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, WakeUpBegin, TestSize.Level1) { - PowerStateChangeReason reason = PowerStateChangeReason{0}; + PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON; bool ret = SingletonContainer::Get().WakeUpBegin(reason); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_TRUE(ret); - } else { - ASSERT_TRUE(ret); - } + ASSERT_TRUE(ret); } /** @@ -541,11 +546,7 @@ HWTEST_F(DisplayManagerAdapterTest, WakeUpBegin, TestSize.Level1) HWTEST_F(DisplayManagerAdapterTest, WakeUpEnd, TestSize.Level1) { bool ret = SingletonContainer::Get().WakeUpEnd(); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_TRUE(ret); - } else { - ASSERT_TRUE(ret); - } + ASSERT_TRUE(ret); } /** @@ -555,13 +556,9 @@ HWTEST_F(DisplayManagerAdapterTest, WakeUpEnd, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, SuspendBegin, TestSize.Level1) { - PowerStateChangeReason reason = PowerStateChangeReason{0}; + PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON; bool ret = SingletonContainer::Get().SuspendBegin(reason); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_TRUE(ret); - } else { - ASSERT_TRUE(ret); - } + ASSERT_TRUE(ret); } /** @@ -572,11 +569,7 @@ HWTEST_F(DisplayManagerAdapterTest, SuspendBegin, TestSize.Level1) HWTEST_F(DisplayManagerAdapterTest, SuspendEnd, TestSize.Level1) { bool ret = SingletonContainer::Get().SuspendEnd(); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_TRUE(ret); - } else { - ASSERT_TRUE(ret); - } + ASSERT_TRUE(ret); } /** @@ -586,7 +579,7 @@ HWTEST_F(DisplayManagerAdapterTest, SuspendEnd, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, SetDisplayState, TestSize.Level1) { - DisplayState state = DisplayState{1}; + DisplayState state = DisplayState::OFF; bool ret = SingletonContainer::Get().SetDisplayState(state); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); @@ -602,8 +595,7 @@ HWTEST_F(DisplayManagerAdapterTest, MakeMirror, TestSize.Level1) { std::vector mirrorScreenId; ScreenId screenGroupId; - DMError err = SingletonContainer::Get().MakeMirror(0, - mirrorScreenId, screenGroupId); + DMError err = SingletonContainer::Get().MakeMirror(0, mirrorScreenId, screenGroupId); ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } @@ -627,13 +619,8 @@ HWTEST_F(DisplayManagerAdapterTest, StopMirror, TestSize.Level1) HWTEST_F(DisplayManagerAdapterTest, HasPrivateWindow, TestSize.Level1) { bool hasPrivateWindow = false; - DMError err = SingletonContainer::Get().HasPrivateWindow(0, - hasPrivateWindow); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(DMError::DM_OK, err); - } else { - ASSERT_EQ(DMError::DM_OK, err); - } + DMError err = SingletonContainer::Get().HasPrivateWindow(0, hasPrivateWindow); + ASSERT_EQ(DMError::DM_OK, err); } /** @@ -643,11 +630,11 @@ HWTEST_F(DisplayManagerAdapterTest, HasPrivateWindow, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, AddSurfaceNodeToDisplay, TestSize.Level1) { - std::shared_ptr surfaceNode; - DMError err = SingletonContainer::Get().AddSurfaceNodeToDisplay(0, - surfaceNode); + RSSurfaceNodeConfig rsSurfaceNodeConfig; + std::shared_ptr surfaceNode = std::make_shared(rsSurfaceNodeConfig, true, 0); + DMError err = SingletonContainer::Get().AddSurfaceNodeToDisplay(0, surfaceNode); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err); + ASSERT_EQ(DMError::DM_ERROR_NULLPTR, err); } else { ASSERT_EQ(DMError::DM_OK, err); } @@ -660,11 +647,11 @@ HWTEST_F(DisplayManagerAdapterTest, AddSurfaceNodeToDisplay, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, RemoveSurfaceNodeFromDisplay, TestSize.Level1) { - std::shared_ptr surfaceNode; - DMError err = SingletonContainer::Get().RemoveSurfaceNodeFromDisplay(0, - surfaceNode); + RSSurfaceNodeConfig rsSurfaceNodeConfig; + std::shared_ptr surfaceNode = std::make_shared(rsSurfaceNodeConfig, true, 0); + DMError err = SingletonContainer::Get().RemoveSurfaceNodeFromDisplay(0, surfaceNode); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err); + ASSERT_EQ(DMError::DM_ERROR_NULLPTR, err); } else { ASSERT_EQ(DMError::DM_OK, err); } @@ -680,8 +667,7 @@ HWTEST_F(DisplayManagerAdapterTest, MakeExpand, TestSize.Level1) std::vector screenId; std::vector startPoint; ScreenId screenGroupId; - DMError err = SingletonContainer::Get().MakeExpand(screenId, - startPoint, screenGroupId); + DMError err = SingletonContainer::Get().MakeExpand(screenId, startPoint, screenGroupId); ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } @@ -752,11 +738,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetResolution, TestSize.Level1) VirtualScreenOption defaultOption = {"virtualScreen04", 480, 320, 2.0, nullptr, 0}; ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); DMError err = SingletonContainer::Get().SetResolution(id, 70, 100, 1); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); - } else { - ASSERT_EQ(err, DMError::DM_OK); - } + ASSERT_EQ(err, DMError::DM_OK); SingletonContainer::Get().DestroyVirtualScreen(id); } @@ -768,11 +750,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetResolution, TestSize.Level1) HWTEST_F(DisplayManagerAdapterTest, ResizeVirtualScreen, TestSize.Level1) { DMError err = SingletonContainer::Get().ResizeVirtualScreen(0, 70, 100); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_OK); - } else { - ASSERT_EQ(err, DMError::DM_OK); - } + ASSERT_EQ(err, DMError::DM_OK); } /** @@ -786,7 +764,7 @@ HWTEST_F(DisplayManagerAdapterTest, MakeUniqueScreen, TestSize.Level1) std::vector displayIds; DMError err = SingletonContainer::Get().MakeUniqueScreen(screenIds, displayIds); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_OK); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } @@ -799,7 +777,7 @@ HWTEST_F(DisplayManagerAdapterTest, MakeUniqueScreen, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, GetAvailableArea, TestSize.Level1) { - DMRect area; + DMRect area{}; DMError err = SingletonContainer::Get().GetAvailableArea(0, area); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); @@ -817,7 +795,7 @@ HWTEST_F(DisplayManagerAdapterTest, GetAllDisplayPhysicalResolution, TestSize.Le { std::vector allSize = SingletonContainer::Get().GetAllDisplayPhysicalResolution(); - ASSERT_TRUE(!allSize.empty()); + ASSERT_FALSE(allSize.empty()); } /** @@ -827,11 +805,11 @@ HWTEST_F(DisplayManagerAdapterTest, GetAllDisplayPhysicalResolution, TestSize.Le */ HWTEST_F(DisplayManagerAdapterTest, SetDisplayScale, TestSize.Level1) { - DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get(); - const float scaleX = 1.0f; - const float scaleY = 1.0f; - const float pivotX = 0.5f; - const float pivotY = 0.5f; + auto& displayManagerAdapter = SingletonContainer::Get(); + constexpr float scaleX = 1.0f; + constexpr float scaleY = 1.0f; + constexpr float pivotX = 0.5f; + constexpr float pivotY = 0.5f; sptr displayInfo = displayManagerAdapter.GetDefaultDisplayInfo(); ASSERT_NE(displayInfo, nullptr); ScreenId screenId = displayInfo->GetScreenId(); @@ -845,8 +823,7 @@ HWTEST_F(DisplayManagerAdapterTest, SetDisplayScale, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterTest, GetPrimaryDisplayInfo, TestSize.Level1) { - DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get(); - sptr displayInfo = displayManagerAdapter.GetPrimaryDisplayInfo(); + sptr displayInfo = SingletonContainer::Get().GetPrimaryDisplayInfo(); ASSERT_NE(displayInfo, nullptr); } @@ -908,4 +885,3 @@ HWTEST_F(DisplayManagerAdapterTest, GetExpandAvailableArea, TestSize.Level1) } } } -} diff --git a/dm/test/unittest/display_manager_adapter_ut_test.cpp b/dm/test/unittest/display_manager_adapter_ut_test.cpp index 4673db366e..3c088a8468 100644 --- a/dm/test/unittest/display_manager_adapter_ut_test.cpp +++ b/dm/test/unittest/display_manager_adapter_ut_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,18 +14,18 @@ */ #include -#include "display_manager_adapter.h" + #include "display_manager.h" -#include "screen_manager.h" +#include "display_manager_adapter.h" #include "display_manager_proxy.h" -#include "window_scene.h" #include "scene_board_judgement.h" +#include "screen_manager.h" +#include "window_scene.h" using namespace testing; using namespace testing::ext; -namespace OHOS { -namespace Rosen { +namespace OHOS::Rosen { class DisplayManagerAdapterUtTest : public testing::Test { public: static void SetUpTestCase(); @@ -73,6 +73,19 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetCutoutInfo, TestSize.Level1) ASSERT_EQ(info, nullptr); } +/** + * @tc.name: GetCutoutInfoWithRotation + * @tc.desc: test nullptr + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterUtTest, GetCutoutInfoWithRotation, Function | SmallTest | Level2) +{ + int32_t rotation = 0; + sptr info = SingletonContainer::Get(). + GetCutoutInfoWithRotation(DISPLAY_ID_INVALID, rotation); + ASSERT_EQ(info, nullptr); +} + /** * @tc.name: GetScreenSupportedColorGamuts * @tc.desc: test success @@ -130,11 +143,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetScreenGamutMap, TestSize.Level1) { ScreenGamutMap gamutMap; DMError err = SingletonContainer::Get().GetScreenGamutMap(0, gamutMap); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); - } else { - ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); - } + ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } /** @@ -145,11 +154,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetScreenGamutMap, TestSize.Level1) HWTEST_F(DisplayManagerAdapterUtTest, SetScreenGamutMap, TestSize.Level1) { DMError err = SingletonContainer::Get().SetScreenGamutMap(0, GAMUT_MAP_CONSTANT); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); - } else { - ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); - } + ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } /** @@ -160,11 +165,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, SetScreenGamutMap, TestSize.Level1) HWTEST_F(DisplayManagerAdapterUtTest, SetScreenColorTransform, TestSize.Level1) { DMError err = SingletonContainer::Get().SetScreenColorTransform(0); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_OK); - } else { - ASSERT_EQ(err, DMError::DM_OK); - } + ASSERT_EQ(err, DMError::DM_OK); } /** @@ -225,13 +226,18 @@ HWTEST_F(DisplayManagerAdapterUtTest, OnRemoteDied, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, OnRemoteDied01, TestSize.Level1) { - sptr dmsDeath_ = nullptr; - dmsDeath_ = new(std::nothrow) DMSDeathRecipient(SingletonContainer::Get()); + sptr dmsDeath = + new (std::nothrow) DMSDeathRecipient(SingletonContainer::Get()); SingletonContainer::Get().InitDMSProxy(); - sptr obj = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - wptr wptrDeath = obj; - dmsDeath_->OnRemoteDied(wptrDeath); - EXPECT_NE(nullptr, dmsDeath_); + sptr remoteObject; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + remoteObject = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + remoteObject = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } + wptr wptrDeath = remoteObject; + dmsDeath->OnRemoteDied(wptrDeath); + EXPECT_NE(nullptr, dmsDeath); } /** @@ -241,9 +247,15 @@ HWTEST_F(DisplayManagerAdapterUtTest, OnRemoteDied01, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, Clear, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - SingletonContainer::Get().Clear(); - ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + SingletonContainer::Get().InitDMSProxy(); + SingletonContainer::Get().Clear(); + ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + } else { + SingletonContainer::Get().InitDMSProxy(); + SingletonContainer::Get().Clear(); + ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + } } /** @@ -253,10 +265,17 @@ HWTEST_F(DisplayManagerAdapterUtTest, Clear, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, Clear01, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - SingletonContainer::Get().displayManagerServiceProxy_ = nullptr; - SingletonContainer::Get().Clear(); - ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + SingletonContainer::Get().InitDMSProxy(); + SingletonContainer::Get().screenSessionManagerServiceProxy_ = nullptr; + SingletonContainer::Get().Clear(); + ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + } else { + SingletonContainer::Get().InitDMSProxy(); + SingletonContainer::Get().displayManagerServiceProxy_ = nullptr; + SingletonContainer::Get().Clear(); + ASSERT_FALSE(SingletonContainer::Get().isProxyValid_); + } } /** @@ -267,10 +286,10 @@ HWTEST_F(DisplayManagerAdapterUtTest, Clear01, TestSize.Level1) HWTEST_F(DisplayManagerAdapterUtTest, DisableMirror, TestSize.Level1) { DMError ret = SingletonContainer::Get().DisableMirror(false); - if (SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(DMError::DM_OK, ret); + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_EQ(ret, DMError::DM_ERROR_INVALID_PERMISSION); } else { - ASSERT_NE(DMError::DM_OK, ret); + ASSERT_EQ(ret, DMError::DM_OK); } } @@ -297,10 +316,10 @@ HWTEST_F(DisplayManagerAdapterUtTest, HasImmersiveWindow, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, GetPixelFormat, TestSize.Level1) { - GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8}; + GraphicPixelFormat pixelFormat = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_CLUT8; DMError err = SingletonContainer::Get().GetPixelFormat(0, pixelFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -313,10 +332,10 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetPixelFormat, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, SetPixelFormat, TestSize.Level1) { - GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT8}; + GraphicPixelFormat pixelFormat = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_CLUT8; DMError err = SingletonContainer::Get().SetPixelFormat(0, pixelFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -332,7 +351,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetSupportedHDRFormats, TestSize.Level1) std::vector hdrFormats; DMError err = SingletonContainer::Get().GetSupportedHDRFormats(0, hdrFormats); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -345,10 +364,10 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetSupportedHDRFormats, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, GetScreenHDRFormat, TestSize.Level1) { - ScreenHDRFormat hdrFormat = ScreenHDRFormat{NOT_SUPPORT_HDR}; + ScreenHDRFormat hdrFormat = ScreenHDRFormat::NOT_SUPPORT_HDR; DMError err = SingletonContainer::Get().GetScreenHDRFormat(0, hdrFormat); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -363,7 +382,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, SetScreenHDRFormat, TestSize.Level1) { DMError err = SingletonContainer::Get().SetScreenHDRFormat(0, 0); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -379,7 +398,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetSupportedColorSpaces, TestSize.Level1) std::vector colorSpaces; DMError err = SingletonContainer::Get().GetSupportedColorSpaces(0, colorSpaces); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -392,10 +411,10 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetSupportedColorSpaces, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, GetScreenColorSpace, TestSize.Level1) { - GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE}; + GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType::GRAPHIC_CM_COLORSPACE_NONE; DMError err = SingletonContainer::Get().GetScreenColorSpace(0, colorSpace); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_OK); } @@ -408,10 +427,10 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetScreenColorSpace, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, SetScreenColorSpace, TestSize.Level1) { - GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType{GRAPHIC_CM_COLORSPACE_NONE}; + GraphicCM_ColorSpaceType colorSpace = GraphicCM_ColorSpaceType::GRAPHIC_CM_COLORSPACE_NONE; DMError err = SingletonContainer::Get().SetScreenColorSpace(0, colorSpace); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED); } @@ -424,7 +443,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, SetScreenColorSpace, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, DestroyVirtualScreen, TestSize.Level1) { - VirtualScreenOption defaultOption = {"virtualScreen01", 480, 320, 2.0, nullptr, 0}; + VirtualScreenOption defaultOption = { "virtualScreen01", 480, 320, 2.0, nullptr, 0 }; ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); DMError err = SingletonContainer::Get().DestroyVirtualScreen(id); ASSERT_EQ(err, DMError::DM_OK); @@ -439,7 +458,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, SetVirtualMirrorScreenCanvasRotation, Test { bool canvasRotation = false; DMError ret = SingletonContainer::Get(). - SetVirtualMirrorScreenCanvasRotation(0, canvasRotation); + SetVirtualMirrorScreenCanvasRotation(0, canvasRotation); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(ret, DMError::DM_OK); } else { @@ -486,8 +505,8 @@ HWTEST_F(DisplayManagerAdapterUtTest, IsScreenRotationLocked, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, SetSpecifiedScreenPower, TestSize.Level1) { - ScreenPowerState state = ScreenPowerState{0}; - PowerStateChangeReason reason = PowerStateChangeReason{0}; + ScreenPowerState state = ScreenPowerState::POWER_ON; + PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON; bool ret = SingletonContainer::Get().SetSpecifiedScreenPower(0, state, reason); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); @@ -503,13 +522,9 @@ HWTEST_F(DisplayManagerAdapterUtTest, SetSpecifiedScreenPower, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, SetOrientation, TestSize.Level1) { - Orientation orientation = Orientation{0}; + Orientation orientation = Orientation::BEGIN; DMError err = SingletonContainer::Get().SetOrientation(0, orientation); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_OK); - } else { - ASSERT_EQ(err, DMError::DM_OK); - } + ASSERT_EQ(err, DMError::DM_OK); } /** @@ -519,13 +534,9 @@ HWTEST_F(DisplayManagerAdapterUtTest, SetOrientation, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, WakeUpBegin, TestSize.Level1) { - PowerStateChangeReason reason = PowerStateChangeReason{0}; + PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON; bool ret = SingletonContainer::Get().WakeUpBegin(reason); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_TRUE(ret); - } else { - ASSERT_TRUE(ret); - } + ASSERT_TRUE(ret); } /** @@ -536,11 +547,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, WakeUpBegin, TestSize.Level1) HWTEST_F(DisplayManagerAdapterUtTest, WakeUpEnd, TestSize.Level1) { bool ret = SingletonContainer::Get().WakeUpEnd(); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_TRUE(ret); - } else { - ASSERT_TRUE(ret); - } + ASSERT_TRUE(ret); } /** @@ -550,13 +557,9 @@ HWTEST_F(DisplayManagerAdapterUtTest, WakeUpEnd, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, SuspendBegin, TestSize.Level1) { - PowerStateChangeReason reason = PowerStateChangeReason{0}; + PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON; bool ret = SingletonContainer::Get().SuspendBegin(reason); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_TRUE(ret); - } else { - ASSERT_TRUE(ret); - } + ASSERT_TRUE(ret); } /** @@ -567,11 +570,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, SuspendBegin, TestSize.Level1) HWTEST_F(DisplayManagerAdapterUtTest, SuspendEnd, TestSize.Level1) { bool ret = SingletonContainer::Get().SuspendEnd(); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_TRUE(ret); - } else { - ASSERT_TRUE(ret); - } + ASSERT_TRUE(ret); } /** @@ -581,12 +580,10 @@ HWTEST_F(DisplayManagerAdapterUtTest, SuspendEnd, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, SetDisplayState, TestSize.Level1) { - DisplayState state = DisplayState{1}; + DisplayState state = DisplayState::OFF; bool ret = SingletonContainer::Get().SetDisplayState(state); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_TRUE(ret); - } else { - ASSERT_FALSE(ret); } } @@ -599,8 +596,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, MakeMirror, TestSize.Level1) { std::vector mirrorScreenId; ScreenId screenGroupId; - DMError err = SingletonContainer::Get().MakeMirror(0, - mirrorScreenId, screenGroupId); + DMError err = SingletonContainer::Get().MakeMirror(0, mirrorScreenId, screenGroupId); ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } @@ -624,13 +620,8 @@ HWTEST_F(DisplayManagerAdapterUtTest, StopMirror, TestSize.Level1) HWTEST_F(DisplayManagerAdapterUtTest, HasPrivateWindow, TestSize.Level1) { bool hasPrivateWindow = false; - DMError err = SingletonContainer::Get().HasPrivateWindow(0, - hasPrivateWindow); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(DMError::DM_OK, err); - } else { - ASSERT_EQ(DMError::DM_OK, err); - } + DMError err = SingletonContainer::Get().HasPrivateWindow(0, hasPrivateWindow); + ASSERT_EQ(DMError::DM_OK, err); } /** @@ -640,11 +631,11 @@ HWTEST_F(DisplayManagerAdapterUtTest, HasPrivateWindow, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, AddSurfaceNodeToDisplay, TestSize.Level1) { - std::shared_ptr surfaceNode; - DMError err = SingletonContainer::Get().AddSurfaceNodeToDisplay(0, - surfaceNode); + RSSurfaceNodeConfig rsSurfaceNodeConfig; + std::shared_ptr surfaceNode = std::make_shared(rsSurfaceNodeConfig, true, 0); + DMError err = SingletonContainer::Get().AddSurfaceNodeToDisplay(0, surfaceNode); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err); + ASSERT_EQ(DMError::DM_ERROR_NULLPTR, err); } else { ASSERT_EQ(DMError::DM_OK, err); } @@ -657,11 +648,11 @@ HWTEST_F(DisplayManagerAdapterUtTest, AddSurfaceNodeToDisplay, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, RemoveSurfaceNodeFromDisplay, TestSize.Level1) { - std::shared_ptr surfaceNode; - DMError err = SingletonContainer::Get().RemoveSurfaceNodeFromDisplay(0, - surfaceNode); + RSSurfaceNodeConfig rsSurfaceNodeConfig; + std::shared_ptr surfaceNode = std::make_shared(rsSurfaceNodeConfig, true, 0); + DMError err = SingletonContainer::Get().RemoveSurfaceNodeFromDisplay(0, surfaceNode); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, err); + ASSERT_EQ(DMError::DM_ERROR_NULLPTR, err); } else { ASSERT_EQ(DMError::DM_OK, err); } @@ -677,8 +668,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, MakeExpand, TestSize.Level1) std::vector screenId; std::vector startPoint; ScreenId screenGroupId; - DMError err = SingletonContainer::Get().MakeExpand(screenId, - startPoint, screenGroupId); + DMError err = SingletonContainer::Get().MakeExpand(screenId, startPoint, screenGroupId); ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } @@ -749,11 +739,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, SetResolution, TestSize.Level1) VirtualScreenOption defaultOption = {"virtualScreen04", 480, 320, 2.0, nullptr, 0}; ScreenId id = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); DMError err = SingletonContainer::Get().SetResolution(id, 70, 100, 1); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_ERROR_IPC_FAILED); - } else { - ASSERT_EQ(err, DMError::DM_OK); - } + ASSERT_EQ(err, DMError::DM_OK); SingletonContainer::Get().DestroyVirtualScreen(id); } @@ -765,11 +751,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, SetResolution, TestSize.Level1) HWTEST_F(DisplayManagerAdapterUtTest, ResizeVirtualScreen, TestSize.Level1) { DMError err = SingletonContainer::Get().ResizeVirtualScreen(0, 70, 100); - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_OK); - } else { - ASSERT_EQ(err, DMError::DM_OK); - } + ASSERT_EQ(err, DMError::DM_OK); } /** @@ -780,9 +762,10 @@ HWTEST_F(DisplayManagerAdapterUtTest, ResizeVirtualScreen, TestSize.Level1) HWTEST_F(DisplayManagerAdapterUtTest, MakeUniqueScreen, TestSize.Level1) { std::vector screenIds; - DMError err = SingletonContainer::Get().MakeUniqueScreen(screenIds); + std::vector displayIds; + DMError err = SingletonContainer::Get().MakeUniqueScreen(screenIds, displayIds); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(err, DMError::DM_OK); + ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); } else { ASSERT_EQ(err, DMError::DM_ERROR_INVALID_PARAM); } @@ -795,7 +778,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, MakeUniqueScreen, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, GetAvailableArea, TestSize.Level1) { - DMRect area; + DMRect area{}; DMError err = SingletonContainer::Get().GetAvailableArea(0, area); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); @@ -813,7 +796,7 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetAllDisplayPhysicalResolution, TestSize. { std::vector allSize = SingletonContainer::Get().GetAllDisplayPhysicalResolution(); - ASSERT_TRUE(!allSize.empty()); + ASSERT_FALSE(allSize.empty()); } /** @@ -823,11 +806,11 @@ HWTEST_F(DisplayManagerAdapterUtTest, GetAllDisplayPhysicalResolution, TestSize. */ HWTEST_F(DisplayManagerAdapterUtTest, SetDisplayScale, TestSize.Level1) { - DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get(); - const float scaleX = 1.0f; - const float scaleY = 1.0f; - const float pivotX = 0.5f; - const float pivotY = 0.5f; + auto& displayManagerAdapter = SingletonContainer::Get(); + constexpr float scaleX = 1.0f; + constexpr float scaleY = 1.0f; + constexpr float pivotX = 0.5f; + constexpr float pivotY = 0.5f; sptr displayInfo = displayManagerAdapter.GetDefaultDisplayInfo(); ASSERT_NE(displayInfo, nullptr); ScreenId screenId = displayInfo->GetScreenId(); @@ -841,10 +824,65 @@ HWTEST_F(DisplayManagerAdapterUtTest, SetDisplayScale, TestSize.Level1) */ HWTEST_F(DisplayManagerAdapterUtTest, GetPrimaryDisplayInfo, TestSize.Level1) { - DisplayManagerAdapter& displayManagerAdapter = SingletonContainer::Get(); - sptr displayInfo = displayManagerAdapter.GetPrimaryDisplayInfo(); + sptr displayInfo = SingletonContainer::Get().GetPrimaryDisplayInfo(); ASSERT_NE(displayInfo, nullptr); } + +/** + * @tc.name: SetScreenSkipProtectedWindow + * @tc.desc: SetScreenSkipProtectedWindow test + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterUtTest, SetScreenSkipProtectedWindow, TestSize.Level1) +{ + const std::vector screenIds = {1001, 1002}; + bool isEnable = true; + auto result = SingletonContainer::Get().SetScreenSkipProtectedWindow(screenIds, isEnable); + ASSERT_EQ(result, DMError::DM_OK); +} + +/** + * @tc.name: GetDisplayCapability + * @tc.desc: GetDisplayCapability test success + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterUtTest, GetDisplayCapability, TestSize.Level1) +{ + std::string capabilitInfo; + auto result = SingletonContainer::Get().GetDisplayCapability(capabilitInfo); + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_EQ(result, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); + } else { + ASSERT_EQ(result, DMError::DM_OK); + } +} + +/** + * @tc.name: GetVisibleAreaDisplayInfoById + * @tc.desc: Test GetVisibleAreaDisplayInfoById function with invalid displayId. + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterUtTest, GetVisibleAreaDisplayInfoById, TestSize.Level1) +{ + sptr info = + SingletonContainer::Get().GetVisibleAreaDisplayInfoById(DISPLAY_ID_INVALID); + EXPECT_EQ(info, nullptr); +} + +/** + * @tc.name: GetExpandAvailableArea + * @tc.desc: test success + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerAdapterUtTest, GetExpandAvailableArea, TestSize.Level1) +{ + DMRect area; + DMError err = SingletonContainer::Get().GetExpandAvailableArea(0, area); + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(err, DMError::DM_ERROR_DEVICE_NOT_SUPPORT); + } else { + EXPECT_EQ(err, DMError::DM_OK); + } } } } diff --git a/dm/test/unittest/display_manager_agent_proxy_test.cpp b/dm/test/unittest/display_manager_agent_proxy_test.cpp index 5b7ceb7223..55c09f29a7 100644 --- a/dm/test/unittest/display_manager_agent_proxy_test.cpp +++ b/dm/test/unittest/display_manager_agent_proxy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,51 +13,53 @@ * limitations under the License. */ -#include "display_manager_proxy.h" -#include "display_manager_adapter.h" -#include "display_manager.h" #include -#include "hilog/log.h" #include #include #include + +#include "display_manager.h" +#include "display_manager_adapter.h" +#include "display_manager_proxy.h" #include "scene_board_judgement.h" -#include "screen_manager.h" -#include "window_manager_hilog.h" #include "window_scene.h" #include "zidl/display_manager_agent_proxy.h" using namespace testing; using namespace testing::ext; -namespace OHOS { -namespace Rosen { - +namespace OHOS::Rosen { class DisplayManagerAgentProxyTest : public testing::Test { public: - static void SetUpTestCase(); - static void TearDownTestCase(); + static void SetUpTestSuite(); void SetUp() override; - void TearDown() override; + sptr displayManagerAgentProxy; }; -void DisplayManagerAgentProxyTest::SetUpTestCase() -{ -} - -void DisplayManagerAgentProxyTest::TearDownTestCase() +void DisplayManagerAgentProxyTest::SetUpTestSuite() { + ASSERT_TRUE(SingletonContainer::Get().InitDMSProxy()); } void DisplayManagerAgentProxyTest::SetUp() { + if (displayManagerAgentProxy) { + return; + } + + sptr impl; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(SingletonContainer::Get().screenSessionManagerServiceProxy_, nullptr); + impl = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + ASSERT_NE(SingletonContainer::Get().displayManagerServiceProxy_, nullptr); + impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } + + displayManagerAgentProxy = new (std::nothrow) DisplayManagerAgentProxy(impl); + ASSERT_NE(displayManagerAgentProxy, nullptr); } -void DisplayManagerAgentProxyTest::TearDown() -{ -} - -namespace { /** * @tc.name: NotifyDisplayPowerEvent * @tc.desc: NotifyDisplayPowerEvent @@ -65,18 +67,13 @@ namespace { */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyDisplayPowerEvent, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - DisplayPowerEvent event = DisplayPowerEvent::DESKTOP_READY; EventStatus status = EventStatus::BEGIN; - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); GTEST_LOG_(INFO) << "WindowSessionImplTest:1"; displayManagerAgentProxy->NotifyDisplayPowerEvent(event, status); int resultValue = 0; - std::function func = [&]() - { + std::function func = [&]() { displayManagerAgentProxy->NotifyDisplayPowerEvent(event, status); resultValue = 1; }; @@ -91,11 +88,8 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyDisplayPowerEvent, TestSize.Level1) */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyDisplayStateChanged, TestSize.Level1) { - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - DisplayId displayId = 0; - DisplayState state = DisplayState{1}; + DisplayState state = DisplayState::OFF; int resultValue = 0; std::function func = [&]() @@ -114,9 +108,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyDisplayStateChanged, TestSize.Level */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyCaptureStatusChanged, TestSize.Level1) { - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -134,9 +125,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyCaptureStatusChanged, TestSize.Leve */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyCaptureStatusChanged01, TestSize.Level1) { - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -154,9 +142,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyCaptureStatusChanged01, TestSize.Le */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyDisplayChangeInfoChanged, TestSize.Level1) { - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - sptr display_change_info = new DisplayChangeInfo(); int resultValue = 0; std::function func = [&]() @@ -175,10 +160,7 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyDisplayChangeInfoChanged, TestSize. */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyDisplayChangeInfoChanged01, TestSize.Level1) { - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - - sptr display_change_info = nullptr; + sptr display_change_info = new DisplayChangeInfo(); int resultValue = 0; std::function func = [&]() { @@ -196,10 +178,7 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyDisplayChangeInfoChanged01, TestSiz */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyDisplayModeChanged, TestSize.Level1) { - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - - FoldDisplayMode mode = FoldDisplayMode{0}; + FoldDisplayMode mode = FoldDisplayMode::UNKNOWN; int resultValue = 0; std::function func = [&]() { @@ -216,10 +195,7 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyDisplayModeChanged, TestSize.Level1 * @tc.type: FUNC */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyAvailableAreaChanged, TestSize.Level1) -{ - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - DisplayId displayId = 0; +{ DisplayId displayId = 0; DMRect rect = {2, 2, 2, 2}; int resultValue = 0; @@ -238,10 +214,7 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyAvailableAreaChanged, TestSize.Leve * @tc.type: FUNC */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyAvailableAreaChanged01, TestSize.Level1) -{ - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - DisplayId displayId = 0; +{ DisplayId displayId = 0; DMRect rect = {1, 1, 1, 1}; int resultValue = 0; @@ -260,10 +233,7 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyAvailableAreaChanged01, TestSize.Le * @tc.type: FUNC */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyAvailableAreaChanged02, TestSize.Level1) -{ - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - DisplayId displayId = 0; +{ DisplayId displayId = 0; DMRect rect = {3, 3, 3, 3}; int resultValue = 0; @@ -284,11 +254,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyAvailableAreaChanged02, TestSize.Le HWTEST_F(DisplayManagerAgentProxyTest, OnScreenConnect, TestSize.Level1) { sptr screenInfo = nullptr; - - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -307,11 +272,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnScreenConnect, TestSize.Level1) HWTEST_F(DisplayManagerAgentProxyTest, OnScreenConnect01, TestSize.Level1) { sptr screenInfo = new ScreenInfo(); - - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -330,10 +290,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnScreenConnect01, TestSize.Level1) HWTEST_F(DisplayManagerAgentProxyTest, OnScreenDisconnect, TestSize.Level1) { ScreenId screenId = 0; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -354,9 +310,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnScreenChange, TestSize.Level1) sptr screenInfo = new ScreenInfo(); ScreenChangeEvent event = ScreenChangeEvent::CHANGE_MODE; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -377,9 +330,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnScreenChange01, TestSize.Level1) sptr screenInfo = nullptr; ScreenChangeEvent event = ScreenChangeEvent::CHANGE_MODE; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -401,9 +351,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnScreenGroupChange, TestSize.Level1) std::vector> screenInfos = {}; ScreenGroupChangeEvent event = ScreenGroupChangeEvent::CHANGE_GROUP; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -422,10 +369,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnScreenGroupChange, TestSize.Level1) HWTEST_F(DisplayManagerAgentProxyTest, OnDisplayCreate, TestSize.Level1) { sptr displayInfo = new DisplayInfo(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -444,10 +387,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnDisplayCreate, TestSize.Level1) HWTEST_F(DisplayManagerAgentProxyTest, OnDisplayCreate01, TestSize.Level1) { sptr displayInfo = nullptr; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -466,10 +405,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnDisplayCreate01, TestSize.Level1) HWTEST_F(DisplayManagerAgentProxyTest, OnDisplayDestroy, TestSize.Level1) { DisplayId displayId = 0; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -489,10 +424,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnDisplayChange, TestSize.Level1) { sptr displayInfo = new DisplayInfo(); DisplayChangeEvent event = DisplayChangeEvent::DISPLAY_FREEZED; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -512,10 +443,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnDisplayChange01, TestSize.Level1) { sptr displayInfo = nullptr; DisplayChangeEvent event = DisplayChangeEvent::DISPLAY_FREEZED; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -534,10 +461,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnDisplayChange01, TestSize.Level1) HWTEST_F(DisplayManagerAgentProxyTest, OnScreenshot, TestSize.Level1) { sptr snapshotInfo = new ScreenshotInfo(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -556,10 +479,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnScreenshot, TestSize.Level1) HWTEST_F(DisplayManagerAgentProxyTest, OnScreenshot01, TestSize.Level1) { sptr snapshotInfo = nullptr; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -578,10 +497,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, OnScreenshot01, TestSize.Level1) HWTEST_F(DisplayManagerAgentProxyTest, NotifyPrivateWindowStateChanged, TestSize.Level1) { bool hasPrivate = false; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -600,10 +515,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyPrivateWindowStateChanged, TestSize HWTEST_F(DisplayManagerAgentProxyTest, NotifyPrivateWindowStateChanged01, TestSize.Level1) { bool hasPrivate = true; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -621,13 +532,8 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyPrivateWindowStateChanged01, TestSi */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyPrivateStateWindowListChanged, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); DisplayId id = 0; std::vector privacyWindowList{"win0", "win1"}; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -645,9 +551,6 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyPrivateStateWindowListChanged, Test */ HWTEST_F(DisplayManagerAgentProxyTest, NotifyFoldStatusChanged, TestSize.Level1) { - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr displayManagerAgentProxy = new DisplayManagerAgentProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -659,5 +562,3 @@ HWTEST_F(DisplayManagerAgentProxyTest, NotifyFoldStatusChanged, TestSize.Level1) ASSERT_EQ(resultValue, 1); } } -} -} diff --git a/dm/test/unittest/display_manager_test.cpp b/dm/test/unittest/display_manager_test.cpp index b6658e6300..f73f5752fa 100644 --- a/dm/test/unittest/display_manager_test.cpp +++ b/dm/test/unittest/display_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,16 +14,15 @@ */ #include + +#include "display_manager.cpp" #include "display_manager.h" #include "display_manager_proxy.h" -#include "window.h" #include "dm_common.h" - #include "mock_display_manager_adapter.h" -#include "singleton_mocker.h" -#include "display_manager.cpp" -#include "window_scene.h" #include "scene_board_judgement.h" +#include "singleton_mocker.h" +#include "window_scene.h" using namespace testing; using namespace testing::ext; @@ -62,8 +61,8 @@ class DisplayManagerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; }; void DisplayManagerTest::SetUpTestCase() @@ -419,7 +418,6 @@ HWTEST_F(DisplayManagerTest, RegisterPrivateWindowListener02, TestSize.Level1) HWTEST_F(DisplayManagerTest, UnregisterPrivateWindowListener, TestSize.Level1) { sptr listener = nullptr; - sptr impl_; auto ret = DisplayManager::GetInstance().UnregisterPrivateWindowListener(listener); ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR); } @@ -1758,7 +1756,11 @@ HWTEST_F(DisplayManagerTest, GetCutoutInfoWithRotation, Function | SmallTest | L { Rotation rotation = Rotation::ROTATION_0; sptr info = DisplayManager::GetInstance().GetCutoutInfoWithRotation(rotation); - ASSERT_NE(nullptr, info); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(nullptr, info); + } else { + ASSERT_EQ(nullptr, info); + } } /** @@ -1931,12 +1933,18 @@ HWTEST_F(DisplayManagerTest, GetCallingAbilityDisplayId_shouldReturnInvalid_When { DisplayManager displayManager; displayManager.displayIdList_.clear(); - SingletonContainer::Get().InitDMSProxy(); - sptr obj = - SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + ASSERT_TRUE(SingletonContainer::Get().InitDMSProxy()); + sptr obj; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(SingletonContainer::Get().screenSessionManagerServiceProxy_, nullptr); + obj = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + ASSERT_NE(SingletonContainer::Get().displayManagerServiceProxy_, nullptr); + obj = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } sptr weakPtr = obj; DisplayId displayId = DISPLAY_ID_INVALID; - displayManager.displayIdList_.push_back(std::make_pair(weakPtr, displayId)); + displayManager.displayIdList_.emplace_back(weakPtr, displayId); EXPECT_EQ(displayManager.GetCallingAbilityDisplayId(), DISPLAY_ID_INVALID); } @@ -1950,18 +1958,33 @@ HWTEST_F(DisplayManagerTest, GetCallingAbilityDisplayId_shouldReturnInvalid_When { DisplayManager displayManager; displayManager.displayIdList_.clear(); - SingletonContainer::Get().InitDMSProxy(); - sptr obj = - SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + + ASSERT_TRUE(SingletonContainer::Get().InitDMSProxy()); + sptr obj; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(SingletonContainer::Get().screenSessionManagerServiceProxy_, nullptr); + obj = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + ASSERT_NE(SingletonContainer::Get().displayManagerServiceProxy_, nullptr); + obj = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } sptr weakPtr = obj; DisplayId displayId = DISPLAY_ID_INVALID; - displayManager.displayIdList_.push_back(std::make_pair(weakPtr, displayId)); - SingletonContainer::Get().InitDMSProxy(); - sptr obj_01 = - SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + displayManager.displayIdList_.emplace_back(weakPtr, displayId); + + ASSERT_TRUE(SingletonContainer::Get().InitDMSProxy()); + sptr obj_01; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(SingletonContainer::Get().screenSessionManagerServiceProxy_, nullptr); + obj_01 = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + ASSERT_NE(SingletonContainer::Get().displayManagerServiceProxy_, nullptr); + obj_01 = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } sptr weakPtr_01 = obj_01; DisplayId displayId_01 = 2; - displayManager.displayIdList_.push_back(std::make_pair(weakPtr_01, displayId_01)); + displayManager.displayIdList_.emplace_back(weakPtr_01, displayId_01); + EXPECT_EQ(displayManager.GetCallingAbilityDisplayId(), DISPLAY_ID_INVALID); } @@ -2173,4 +2196,4 @@ HWTEST_F(DisplayManagerTest, ShouldReturnNullptrWhenScreenshotCaptureFailes, Tes } } } // namespace Rosen -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/dm/test/unittest/screen_manager_test.cpp b/dm/test/unittest/screen_manager_test.cpp index 901eb42da3..37635aba1a 100644 --- a/dm/test/unittest/screen_manager_test.cpp +++ b/dm/test/unittest/screen_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,15 +14,15 @@ */ #include + #include "display_manager.h" #include "display_manager_proxy.h" +#include "mock_display_manager_adapter.h" +#include "scene_board_judgement.h" +#include "screen_manager.cpp" #include "screen_manager.h" #include "screen_manager_utils.h" -#include "mock_display_manager_adapter.h" #include "singleton_mocker.h" -#include "screen_manager.cpp" -#include "window_manager_hilog.h" -#include "scene_board_judgement.h" using namespace testing; using namespace testing::ext; @@ -809,6 +809,6 @@ HWTEST_F(ScreenManagerTest, MakeMirrorForRecord03, TestSize.Level1) EXPECT_EQ(result, DMError::DM_ERROR_NULLPTR); } -} +} // namespace } // namespace Rosen -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/dm/test/unittest/screenshot_test.cpp b/dm/test/unittest/screenshot_test.cpp index d739b56cc5..dea8c1a417 100644 --- a/dm/test/unittest/screenshot_test.cpp +++ b/dm/test/unittest/screenshot_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,14 +14,12 @@ */ #include -#include "display_manager.h" -#include "pixel_map.h" - #include - -#include "mock_display_manager_adapter.h" -#include "singleton_mocker.h" #include "common_test_utils.h" +#include "display_manager.h" +#include "mock_display_manager_adapter.h" +#include "pixel_map.h" +#include "singleton_mocker.h" using namespace testing; using namespace testing::ext; @@ -38,10 +36,6 @@ public: }; void ScreenshotTest::SetUpTestCase() { - CommonTestUtils::InjectTokenInfoByHapName(0, "com.ohos.systemui", 0); - const char** perms = new const char *[1]; - perms[0] = "ohos.permission.CAPTURE_SCREEN"; - CommonTestUtils::SetAceessTokenPermission("DisplayManagerServiceTest", perms, 1); } void ScreenshotTest::TearDownTestCase() @@ -67,11 +61,9 @@ HWTEST_F(ScreenshotTest, GetScreenshot_default, TestSize.Level1) std::unique_ptr m = std::make_unique(); EXPECT_CALL(m->Mock(), GetDefaultDisplayInfo()).Times(1).WillOnce(Return(nullptr)); - - DisplayManager::GetInstance().GetDefaultDisplayId(); + EXPECT_EQ(DISPLAY_ID_INVALID, DisplayManager::GetInstance().GetDefaultDisplayId()); EXPECT_CALL(m->Mock(), GetDisplaySnapshot(_, _, _, _)).Times(1).WillOnce(Return(nullptr)); - ASSERT_EQ(nullptr, DisplayManager::GetInstance().GetScreenshot(0)); } @@ -80,9 +72,13 @@ HWTEST_F(ScreenshotTest, GetScreenshot_01, TestSize.Level1) std::unique_ptr m = std::make_unique(); EXPECT_CALL(m->Mock(), GetDefaultDisplayInfo()).Times(1).WillOnce(Return(nullptr)); - DisplayManager::GetInstance().GetDefaultDisplayId(); + EXPECT_EQ(DISPLAY_ID_INVALID, DisplayManager::GetInstance().GetDefaultDisplayId()); - EXPECT_CALL(m->Mock(), GetDisplaySnapshot(_, _, _, _)).Times(1).WillOnce(Return(CommonTestUtils::CreatePixelMap())); + Media::InitializationOptions opt; + opt.size.width = CommonTestUtils::TEST_IMAGE_WIDTH; + opt.size.height = CommonTestUtils::TEST_IMAGE_HEIGHT; + std::shared_ptr pixelMap = Media::PixelMap::Create(opt); + EXPECT_CALL(m->Mock(), GetDisplaySnapshot(_, _, _, _)).Times(1).WillOnce(Return(pixelMap)); auto screenshot = DisplayManager::GetInstance().GetScreenshot(0); ASSERT_NE(nullptr, screenshot); diff --git a/dm_lite/BUILD.gn b/dm_lite/BUILD.gn index 8fb2ca3ab5..f50e370080 100644 --- a/dm_lite/BUILD.gn +++ b/dm_lite/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at, @@ -42,6 +42,7 @@ ohos_shared_library("libdm_lite") { cfi_vcall_icall_only = true debug = false } + sources = [ "../dm/src/zidl/display_manager_agent_stub.cpp", "src/display_lite.cpp", @@ -50,6 +51,9 @@ ohos_shared_library("libdm_lite") { "src/display_manager_lite_proxy.cpp", "src/screen_manager_lite.cpp", ] + if (!window_manager_use_sceneboard) { + sources += [ "src/display_manager_lite_proxy_idl.cpp" ] + } configs = [ ":libdm_private_config", diff --git a/dm_lite/IDisplayManagerLite.idl b/dm_lite/IDisplayManagerLite.idl new file mode 100644 index 0000000000..8eb5e1ccaf --- /dev/null +++ b/dm_lite/IDisplayManagerLite.idl @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +sequenceable OHOS.Rosen.DisplayInfo; +sequenceable OHOS.Rosen.CutoutInfo; +sequenceable OHOS.Rosen.ScreenInfo; +interface zidl..OHOS.Rosen.IDisplayManagerAgent; + +interface OHOS.Rosen.IDisplayManagerLite { + void RegisterDisplayManagerAgent([in] IDisplayManagerAgent displayManagerAgent, [in] unsigned int type, + [out] int dmError); + void UnregisterDisplayManagerAgent([in] IDisplayManagerAgent displayManagerAgent, [in] unsigned int type, + [out] int dmError); + void GetDefaultDisplayInfo([out] sptr displayInfo); + void GetDisplayInfoById([in] unsigned long displayId, [out] sptr displayInfo); + void GetCutoutInfo([in] unsigned long displayId, [out] sptr cutoutInfo); + void WakeUpBegin([in] unsigned int reason, [out] boolean isSucc); + void WakeUpEnd([out] boolean isSucc); + void SuspendBegin([in] unsigned int reason, [out] boolean isSucc); + void SuspendEnd([out] boolean isSucc); + void SetSpecifiedScreenPower([in] unsigned long screenId, [in] unsigned int screenPowerState, + [in] unsigned int reason, [out] boolean isSucc); + void SetScreenPowerForAll([in] unsigned int screenPowerState, [in] unsigned int reason, [out] boolean isSucc); + void GetScreenPower([in] unsigned long dmsScreenId, [out] unsigned int screenPowerState); + void GetScreenPower([out] unsigned int screenPowerState); + void SetDisplayState([in] unsigned int displayState, [out] boolean isSucc); + void GetDisplayState([in] unsigned long displayId, [out] unsigned int displayState); + void TryToCancelScreenOff([out] boolean isSucc); + void GetAllDisplayIds([out] unsigned long[] displayIds); + void GetAllScreenInfos([out] sptr[] screenInfos, [out] int dmError); + void GetScreenInfoById([in] unsigned long screenId, [out] sptr screenInfo); +} diff --git a/dm_lite/include/display_manager_adapter_lite.h b/dm_lite/include/display_manager_adapter_lite.h index d1b8f06a8e..1c89fc9816 100644 --- a/dm_lite/include/display_manager_adapter_lite.h +++ b/dm_lite/include/display_manager_adapter_lite.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at, @@ -20,10 +20,10 @@ #include #include "display_lite.h" +#include "display_manager_lite_proxy.h" #include "dm_common.h" #include "singleton_delegator.h" -#include "display_manager_lite_proxy.h" -#include "zidl/display_manager_agent_interface.h" +#include "zidl/idisplay_manager_agent.h" namespace OHOS::Rosen { class BaseAdapterLite { @@ -98,6 +98,5 @@ private: static inline SingletonDelegator delegator; }; - } // namespace OHOS::Rosen #endif // FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_LITE_H diff --git a/dm_lite/include/display_manager_lite_proxy.h b/dm_lite/include/display_manager_lite_proxy.h index 082acd1078..6e61e51102 100644 --- a/dm_lite/include/display_manager_lite_proxy.h +++ b/dm_lite/include/display_manager_lite_proxy.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,74 +16,156 @@ #ifndef OHOS_ROSEN_DISPLAY_MANAGER_LITE_PROXY_H #define OHOS_ROSEN_DISPLAY_MANAGER_LITE_PROXY_H -#include "display_manager_interface_code.h" - #include #include -#include -#include "dm_common.h" -#include "zidl/display_manager_agent_interface.h" +#include "cutout_info.h" #include "display_info.h" -#include "fold_screen_info.h" -#include "screen_group_info.h" - -namespace OHOS { -namespace Rosen { +#include "dm_common.h" +#include "window_manager_hilog.h" +#include "zidl/idisplay_manager_agent.h" +namespace OHOS::Rosen { class DisplayManagerLiteProxy : public IRemoteBroker { public: #ifdef SCENE_BOARD_ENABLED DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IScreenSessionManager"); #else - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IDisplayManager"); + DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Rosen.IDisplayManager"); // generated by IDisplayManager.idl #endif explicit DisplayManagerLiteProxy(const sptr& impl) : remoteObject(impl) {} - ~DisplayManagerLiteProxy() = default; + sptr AsObject() override + { + return remoteObject; + } - sptr AsObject() { return remoteObject; }; - virtual DMError RegisterDisplayManagerAgent(const sptr& displayManagerAgent, + DMError RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type); - virtual DMError UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, + DMError UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type); - virtual FoldDisplayMode GetFoldDisplayMode(); - virtual void SetFoldDisplayMode(const FoldDisplayMode displayMode); - virtual bool IsFoldable(); + FoldDisplayMode GetFoldDisplayMode(); + void SetFoldDisplayMode(const FoldDisplayMode displayMode); + bool IsFoldable(); FoldStatus GetFoldStatus(); - virtual sptr GetDefaultDisplayInfo(); - virtual sptr GetDisplayInfoById(DisplayId displayId); - virtual sptr GetCutoutInfo(DisplayId displayId); - virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId); + sptr GetDefaultDisplayInfo(); + sptr GetDisplayInfoById(DisplayId displayId); + sptr GetCutoutInfo(DisplayId displayId); + VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId); /* * used by powermgr */ - virtual bool WakeUpBegin(PowerStateChangeReason reason); - virtual bool WakeUpEnd(); - virtual bool SuspendBegin(PowerStateChangeReason reason); - virtual bool SuspendEnd(); - virtual ScreenId GetInternalScreenId(); - virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason); - virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason); - virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason); - virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId); - virtual ScreenPowerState GetScreenPower(); - virtual bool SetDisplayState(DisplayState state); - virtual DisplayState GetDisplayState(DisplayId displayId); - virtual bool TryToCancelScreenOff(); - virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level); - virtual uint32_t GetScreenBrightness(uint64_t screenId); - virtual std::vector GetAllDisplayIds(); - virtual DMError GetAllScreenInfos(std::vector>& screenInfos); - virtual DMError SetSystemKeyboardStatus(bool isTpKeyboardOn = false); + bool WakeUpBegin(PowerStateChangeReason reason); + bool WakeUpEnd(); + bool SuspendBegin(PowerStateChangeReason reason); + bool SuspendEnd(); + ScreenId GetInternalScreenId(); + bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason); + bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason); + bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason); + ScreenPowerState GetScreenPower(ScreenId dmsScreenId); + ScreenPowerState GetScreenPower(); + bool SetDisplayState(DisplayState state); + DisplayState GetDisplayState(DisplayId displayId); + bool TryToCancelScreenOff(); + bool SetScreenBrightness(uint64_t screenId, uint32_t level); + uint32_t GetScreenBrightness(uint64_t screenId); + std::vector GetAllDisplayIds(); + DMError GetAllScreenInfos(std::vector>& screenInfos); + DMError SetSystemKeyboardStatus(bool isTpKeyboardOn = false); sptr GetScreenInfoById(ScreenId screenId); virtual bool GetKeyboardState(); private: - sptr Remote() { return remoteObject; }; + static inline DMError ConvertToDMError(ErrCode errCode, int32_t dmError); + sptr Remote() + { + return remoteObject; + } sptr remoteObject = nullptr; -}; -} // namespace Rosen -} // namespace OHOS + static constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerLiteProxy"}; -#endif // OHOS_ROSEN_SCREEN_SESSION_MANAGER_LITE_PROXY_H \ No newline at end of file +#ifndef SCENE_BOARD_ENABLED + // generated by IDisplayManager.idl + enum class IDisplayManagerIpcCode { + COMMAND_GET_DEFAULT_DISPLAY_INFO = MIN_TRANSACTION_ID, + COMMAND_GET_DISPLAY_INFO_BY_ID, + COMMAND_GET_VISIBLE_AREA_DISPLAY_INFO_BY_ID, + COMMAND_GET_DISPLAY_INFO_BY_SCREEN, + COMMAND_CREATE_VIRTUAL_SCREEN, + COMMAND_CREATE_VIRTUAL_SCREEN_IN_VIRTUALSCREENOPTION_IN_IREMOTEOBJECT_OUT_UNSIGNED_LONG_IN_IBUFFERPRODUCER, + COMMAND_DESTROY_VIRTUAL_SCREEN, + COMMAND_SET_VIRTUAL_SCREEN_SURFACE, + COMMAND_SET_ORIENTATION, + COMMAND_GET_DISPLAY_SNAPSHOT, + COMMAND_GET_SCREEN_SUPPORTED_COLOR_GAMUTS, + COMMAND_GET_SCREEN_COLOR_GAMUT, + COMMAND_SET_SCREEN_COLOR_GAMUT, + COMMAND_GET_SCREEN_GAMUT_MAP, + COMMAND_SET_SCREEN_GAMUT_MAP, + COMMAND_SET_SCREEN_COLOR_TRANSFORM, + COMMAND_REGISTER_DISPLAY_MANAGER_AGENT, + COMMAND_UNREGISTER_DISPLAY_MANAGER_AGENT, + COMMAND_WAKE_UP_BEGIN, + COMMAND_WAKE_UP_END, + COMMAND_SUSPEND_BEGIN, + COMMAND_SUSPEND_END, + COMMAND_SET_SCREEN_POWER_FOR_ALL, + COMMAND_SET_SPECIFIED_SCREEN_POWER, + COMMAND_GET_SCREEN_POWER, + COMMAND_SET_DISPLAY_STATE, + COMMAND_GET_DISPLAY_STATE, + COMMAND_TRY_TO_CANCEL_SCREEN_OFF, + COMMAND_GET_ALL_DISPLAY_IDS, + COMMAND_GET_CUTOUT_INFO, + COMMAND_ADD_SURFACE_NODE_TO_DISPLAY, + COMMAND_REMOVE_SURFACE_NODE_FROM_DISPLAY, + COMMAND_HAS_PRIVATE_WINDOW, + COMMAND_NOTIFY_DISPLAY_EVENT, + COMMAND_SET_FREEZE, + COMMAND_MAKE_MIRROR, + COMMAND_STOP_MIRROR, + COMMAND_GET_SCREEN_INFO_BY_ID, + COMMAND_GET_SCREEN_GROUP_INFO_BY_ID, + COMMAND_GET_ALL_SCREEN_INFOS, + COMMAND_MAKE_EXPAND, + COMMAND_STOP_EXPAND, + COMMAND_REMOVE_VIRTUAL_SCREEN_FROM_GROUP, + COMMAND_SET_SCREEN_ACTIVE_MODE, + COMMAND_SET_VIRTUAL_PIXEL_RATIO, + COMMAND_SET_RESOLUTION, + COMMAND_GET_DENSITY_IN_CUR_RESOLUTION, + COMMAND_IS_SCREEN_ROTATION_LOCKED, + COMMAND_SET_SCREEN_ROTATION_LOCKED, + COMMAND_SET_SCREEN_ROTATION_LOCKED_FROM_JS, + COMMAND_GET_ALL_DISPLAY_PHYSICAL_RESOLUTION, + }; + + // generated by IDisplayManagerLite.idl + static constexpr int VECTOR_MAX_SIZE = 102400; + + ErrCode RegisterDisplayManagerAgent(const sptr& displayManagerAgent, uint32_t type, + int32_t& dmError); + ErrCode UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, uint32_t type, + int32_t& dmError); + ErrCode GetDefaultDisplayInfo(sptr& displayInfo); + ErrCode GetDisplayInfoById(uint64_t displayId, sptr& displayInfo); + ErrCode GetCutoutInfo(uint64_t displayId, sptr& cutoutInfo); + ErrCode WakeUpBegin(uint32_t reason, bool& isSucc); + ErrCode WakeUpEnd(bool& isSucc); + ErrCode SuspendBegin(uint32_t reason, bool& isSucc); + ErrCode SuspendEnd(bool& isSucc); + ErrCode SetSpecifiedScreenPower(uint64_t screenId, uint32_t screenPowerState, uint32_t reason, bool& isSucc); + ErrCode SetScreenPowerForAll(uint32_t screenPowerState, uint32_t reason, bool& isSucc); + ErrCode GetScreenPower(uint64_t dmsScreenId, uint32_t& screenPowerState); + ErrCode SetDisplayState(uint32_t displayState, bool& isSucc); + ErrCode GetDisplayState(uint64_t displayId, uint32_t& displayState); + ErrCode TryToCancelScreenOff(bool& isSucc); + ErrCode GetAllDisplayIds(std::vector& displayIds); + ErrCode GetAllScreenInfos(std::vector>& screenInfos, int32_t& dmError); + ErrCode GetScreenInfoById(uint64_t screenId, sptr& screenInfo); +#endif +}; +} // namespace OHOS::Rosen + +#endif // OHOS_ROSEN_DISPLAY_MANAGER_LITE_PROXY_H diff --git a/dm_lite/src/display_manager_lite_proxy.cpp b/dm_lite/src/display_manager_lite_proxy.cpp index 20175ead8a..8509e9462b 100644 --- a/dm_lite/src/display_manager_lite_proxy.cpp +++ b/dm_lite/src/display_manager_lite_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,24 +19,30 @@ #include #include +#include "display_manager_interface_code.h" #include "dm_common.h" #include "marshalling_helper.h" #include "window_manager_hilog.h" namespace OHOS::Rosen { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerLiteProxy" }; +DMError DisplayManagerLiteProxy::ConvertToDMError(ErrCode errCode, int32_t dmError) +{ + if (FAILED(errCode)) { + return DMError::DM_ERROR_IPC_FAILED; + } + return static_cast(dmError); } DMError DisplayManagerLiteProxy::RegisterDisplayManagerAgent( - const sptr& displayManagerAgent, DisplayManagerAgentType type) + const sptr& displayManagerAgent, + DisplayManagerAgentType type) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("remote is null"); return DMError::DM_ERROR_IPC_FAILED; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -45,39 +51,41 @@ DMError DisplayManagerLiteProxy::RegisterDisplayManagerAgent( WLOGFE("RegisterDisplayManagerAgent WriteInterfaceToken failed"); return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; } - if (displayManagerAgent == nullptr) { WLOGFE("IDisplayManagerAgent is null"); return DMError::DM_ERROR_INVALID_PARAM; } - if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) { WLOGFE("Write IDisplayManagerAgent failed"); return DMError::DM_ERROR_IPC_FAILED; } - if (!data.WriteUint32(static_cast(type))) { WLOGFE("Write DisplayManagerAgent type failed"); return DMError::DM_ERROR_IPC_FAILED; } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return DMError::DM_ERROR_IPC_FAILED; } return static_cast(reply.ReadInt32()); +#else + int32_t dmError; + ErrCode errCode = RegisterDisplayManagerAgent(displayManagerAgent, static_cast(type), dmError); + return ConvertToDMError(errCode, dmError); +#endif } DMError DisplayManagerLiteProxy::UnregisterDisplayManagerAgent( - const sptr& displayManagerAgent, DisplayManagerAgentType type) + const sptr& displayManagerAgent, + DisplayManagerAgentType type) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("remote is null"); return DMError::DM_ERROR_IPC_FAILED; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -86,32 +94,34 @@ DMError DisplayManagerLiteProxy::UnregisterDisplayManagerAgent( WLOGFE("UnregisterDisplayManagerAgent WriteInterfaceToken failed"); return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; } - if (displayManagerAgent == nullptr) { WLOGFE("IDisplayManagerAgent is null"); return DMError::DM_ERROR_INVALID_PARAM; } - if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) { WLOGFE("Write IWindowManagerAgent failed"); return DMError::DM_ERROR_IPC_FAILED; } - if (!data.WriteUint32(static_cast(type))) { WLOGFE("Write DisplayManagerAgent type failed"); return DMError::DM_ERROR_IPC_FAILED; } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return DMError::DM_ERROR_IPC_FAILED; } return static_cast(reply.ReadInt32()); +#else + int32_t dmError; + ErrCode errCode = UnregisterDisplayManagerAgent(displayManagerAgent, static_cast(type), dmError); + return ConvertToDMError(errCode, dmError); +#endif } FoldDisplayMode DisplayManagerLiteProxy::GetFoldDisplayMode() { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("remote is null"); @@ -130,10 +140,14 @@ FoldDisplayMode DisplayManagerLiteProxy::GetFoldDisplayMode() return FoldDisplayMode::UNKNOWN; } return static_cast(reply.ReadUint32()); +#else + return FoldDisplayMode::UNKNOWN; +#endif } void DisplayManagerLiteProxy::SetFoldDisplayMode(const FoldDisplayMode displayMode) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("remote is null"); @@ -154,16 +168,17 @@ void DisplayManagerLiteProxy::SetFoldDisplayMode(const FoldDisplayMode displayMo data, reply, option) != ERR_NONE) { WLOGFE("Send TRANS_ID_SCENE_BOARD_SET_FOLD_DISPLAY_MODE request failed"); } +#endif } bool DisplayManagerLiteProxy::IsFoldable() { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("remote is null"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -177,16 +192,19 @@ bool DisplayManagerLiteProxy::IsFoldable() return false; } return reply.ReadBool(); +#else + return false; +#endif } FoldStatus DisplayManagerLiteProxy::GetFoldStatus() { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("remote is null"); return FoldStatus::UNKNOWN; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -200,16 +218,19 @@ FoldStatus DisplayManagerLiteProxy::GetFoldStatus() return FoldStatus::UNKNOWN; } return static_cast(reply.ReadUint32()); +#else + return FoldStatus::UNKNOWN; +#endif } sptr OHOS::Rosen::DisplayManagerLiteProxy::GetDefaultDisplayInfo() { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("remote is null"); return nullptr; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -222,22 +243,29 @@ sptr OHOS::Rosen::DisplayManagerLiteProxy::GetDefaultDisplayInfo() WLOGFE("SendRequest failed"); return nullptr; } - sptr info = reply.ReadParcelable(); if (info == nullptr) { WLOGFW("read display info failed, info is nullptr."); } return info; +#else + sptr displayInfo; + ErrCode errCode = GetDefaultDisplayInfo(displayInfo); + if (FAILED(errCode) || displayInfo == nullptr) { + return nullptr; + } + return displayInfo; +#endif } sptr DisplayManagerLiteProxy::GetDisplayInfoById(DisplayId displayId) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("GetDisplayInfoById: remote is nullptr"); return nullptr; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -254,17 +282,25 @@ sptr DisplayManagerLiteProxy::GetDisplayInfoById(DisplayId displayI WLOGFW("GetDisplayInfoById: SendRequest failed"); return nullptr; } - sptr info = reply.ReadParcelable(); if (info == nullptr) { WLOGFW("DisplayManagerProxy::GetDisplayInfoById SendRequest nullptr."); return nullptr; } return info; +#else + sptr displayInfo; + ErrCode errCode = GetDisplayInfoById(displayId, displayInfo); + if (FAILED(errCode) || displayInfo == nullptr) { + return nullptr; + } + return displayInfo; +#endif } sptr DisplayManagerLiteProxy::GetCutoutInfo(DisplayId displayId) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("get cutout info : remote is null"); @@ -288,16 +324,24 @@ sptr DisplayManagerLiteProxy::GetCutoutInfo(DisplayId displayId) } sptr info = reply.ReadParcelable(); return info; +#else + sptr cutoutInfo; + ErrCode errCode = GetCutoutInfo(displayId, cutoutInfo); + if (FAILED(errCode) || cutoutInfo == nullptr) { + return nullptr; + } + return cutoutInfo; +#endif } VirtualScreenFlag DisplayManagerLiteProxy::GetVirtualScreenFlag(ScreenId screenId) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("GetVirtualScreenFlag: remote is null"); return VirtualScreenFlag::DEFAULT; } - if (screenId == SCREEN_ID_INVALID) { return VirtualScreenFlag::DEFAULT; } @@ -318,6 +362,9 @@ VirtualScreenFlag DisplayManagerLiteProxy::GetVirtualScreenFlag(ScreenId screenI return VirtualScreenFlag::DEFAULT; } return static_cast(reply.ReadUint32()); +#else + return VirtualScreenFlag::DEFAULT; +#endif } /* @@ -325,16 +372,15 @@ VirtualScreenFlag DisplayManagerLiteProxy::GetVirtualScreenFlag(ScreenId screenI */ bool DisplayManagerLiteProxy::WakeUpBegin(PowerStateChangeReason reason) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]WakeUpBegin remote is nullptr"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { WLOGFE("[UL_POWER]WakeUpBegin: WriteInterfaceToken failed"); return false; @@ -349,20 +395,24 @@ bool DisplayManagerLiteProxy::WakeUpBegin(PowerStateChangeReason reason) return false; } return reply.ReadBool(); +#else + bool isSucc = false; + WakeUpBegin(static_cast(reason), isSucc); + return isSucc; +#endif } bool DisplayManagerLiteProxy::WakeUpEnd() { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]WakeUpEnd remote is nullptr"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { WLOGFE("[UL_POWER]WakeUpEnd: WriteInterfaceToken failed"); return false; @@ -373,20 +423,24 @@ bool DisplayManagerLiteProxy::WakeUpEnd() return false; } return reply.ReadBool(); +#else + bool isSucc = false; + WakeUpEnd(isSucc); + return isSucc; +#endif } bool DisplayManagerLiteProxy::SuspendBegin(PowerStateChangeReason reason) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]SuspendBegin remote is nullptr"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { WLOGFE("[UL_POWER]SuspendBegin: WriteInterfaceToken failed"); return false; @@ -401,20 +455,24 @@ bool DisplayManagerLiteProxy::SuspendBegin(PowerStateChangeReason reason) return false; } return reply.ReadBool(); +#else + bool isSucc = false; + SuspendBegin(static_cast(reason), isSucc); + return isSucc; +#endif } bool DisplayManagerLiteProxy::SuspendEnd() { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]SuspendEnd remote is nullptr"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { WLOGFE("[UL_POWER]SuspendEnd: WriteInterfaceToken failed"); return false; @@ -425,20 +483,24 @@ bool DisplayManagerLiteProxy::SuspendEnd() return false; } return reply.ReadBool(); +#else + bool isSucc = false; + SuspendEnd(isSucc); + return isSucc; +#endif } ScreenId DisplayManagerLiteProxy::GetInternalScreenId() { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]GetInternalScreenId remote is nullptr"); return SCREEN_ID_INVALID; } - MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - if (!data.WriteInterfaceToken(GetDescriptor())) { WLOGFE("[UL_POWER]GetInternalScreenId: WriteInterfaceToken failed"); return SCREEN_ID_INVALID; @@ -449,17 +511,20 @@ ScreenId DisplayManagerLiteProxy::GetInternalScreenId() return SCREEN_ID_INVALID; } return reply.ReadUint64(); +#else + return SCREEN_ID_INVALID; +#endif } bool DisplayManagerLiteProxy::SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]SetScreenPowerById remote is nullptr"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); @@ -485,17 +550,20 @@ bool DisplayManagerLiteProxy::SetScreenPowerById(ScreenId screenId, ScreenPowerS return false; } return reply.ReadBool(); +#else + return false; +#endif } bool DisplayManagerLiteProxy::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]SetSpecifiedScreenPower remote is nullptr"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -521,16 +589,21 @@ bool DisplayManagerLiteProxy::SetSpecifiedScreenPower(ScreenId screenId, ScreenP return false; } return reply.ReadBool(); +#else + bool isSucc = false; + SetSpecifiedScreenPower(screenId, static_cast(state), static_cast(reason), isSucc); + return isSucc; +#endif } bool DisplayManagerLiteProxy::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]SetScreenPowerForAll remote is nullptr"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -552,16 +625,21 @@ bool DisplayManagerLiteProxy::SetScreenPowerForAll(ScreenPowerState state, Power return false; } return reply.ReadBool(); +#else + bool isSucc = false; + SetScreenPowerForAll(static_cast(state), static_cast(reason), isSucc); + return isSucc; +#endif } ScreenPowerState DisplayManagerLiteProxy::GetScreenPower(ScreenId dmsScreenId) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("GetScreenPower remote is nullptr"); return ScreenPowerState::INVALID_STATE; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -579,16 +657,24 @@ ScreenPowerState DisplayManagerLiteProxy::GetScreenPower(ScreenId dmsScreenId) return ScreenPowerState::INVALID_STATE; } return static_cast(reply.ReadUint32()); +#else + uint32_t screenPowerState; + ErrCode errCode = GetScreenPower(dmsScreenId, screenPowerState); + if (FAILED(errCode)) { + return ScreenPowerState::INVALID_STATE; + } + return static_cast(screenPowerState); +#endif } ScreenPowerState DisplayManagerLiteProxy::GetScreenPower() { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("GetScreenPower remote is nullptr"); return ScreenPowerState::INVALID_STATE; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -602,16 +688,19 @@ ScreenPowerState DisplayManagerLiteProxy::GetScreenPower() return ScreenPowerState::INVALID_STATE; } return static_cast(reply.ReadUint32()); +#else + return ScreenPowerState::INVALID_STATE; +#endif } bool DisplayManagerLiteProxy::SetDisplayState(DisplayState state) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]SetDisplayState remote is nullptr"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -629,16 +718,21 @@ bool DisplayManagerLiteProxy::SetDisplayState(DisplayState state) return false; } return reply.ReadBool(); +#else + bool isSucc = false; + SetDisplayState(static_cast(state), isSucc); + return isSucc; +#endif } DisplayState DisplayManagerLiteProxy::GetDisplayState(DisplayId displayId) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("GetDisplayState remote is nullptr"); return DisplayState::UNKNOWN; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -656,20 +750,27 @@ DisplayState DisplayManagerLiteProxy::GetDisplayState(DisplayId displayId) return DisplayState::UNKNOWN; } return static_cast(reply.ReadUint32()); +#else + uint32_t displayState; + ErrCode errCode = GetDisplayState(displayId, displayState); + if (FAILED(errCode)) { + return DisplayState::UNKNOWN; + } + return static_cast(displayState); +#endif } bool DisplayManagerLiteProxy::TryToCancelScreenOff() { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]TryToCancelScreenOff remote is nullptr"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { WLOGFE("[UL_POWER]TryToCancelScreenOff: WriteInterfaceToken failed"); return false; @@ -680,16 +781,21 @@ bool DisplayManagerLiteProxy::TryToCancelScreenOff() return false; } return reply.ReadBool(); +#else + bool isSucc = false; + TryToCancelScreenOff(isSucc); + return isSucc; +#endif } bool DisplayManagerLiteProxy::SetScreenBrightness(uint64_t screenId, uint32_t level) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("SetScreenBrightness remote is nullptr"); return false; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -711,16 +817,19 @@ bool DisplayManagerLiteProxy::SetScreenBrightness(uint64_t screenId, uint32_t le return false; } return reply.ReadBool(); +#else + return false; +#endif } uint32_t DisplayManagerLiteProxy::GetScreenBrightness(uint64_t screenId) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("GetScreenBrightness remote is nullptr"); return 0; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -738,16 +847,19 @@ uint32_t DisplayManagerLiteProxy::GetScreenBrightness(uint64_t screenId) return 0; } return reply.ReadUint32(); +#else + return 0; +#endif } std::vector DisplayManagerLiteProxy::GetAllDisplayIds() { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFE("[UL_POWER]GetAllDisplayIds remote is nullptr"); return {}; } - std::vector allDisplayIds; MessageParcel data; MessageParcel reply; @@ -763,16 +875,21 @@ std::vector DisplayManagerLiteProxy::GetAllDisplayIds() } reply.ReadUInt64Vector(&allDisplayIds); return allDisplayIds; +#else + std::vector displayIds; + GetAllDisplayIds(displayIds); + return displayIds; +#endif } DMError DisplayManagerLiteProxy::GetAllScreenInfos(std::vector>& screenInfos) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("GetAllScreenInfos: remote is nullptr"); return DMError::DM_ERROR_NULLPTR; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -788,16 +905,21 @@ DMError DisplayManagerLiteProxy::GetAllScreenInfos(std::vector> DMError ret = static_cast(reply.ReadInt32()); static_cast(MarshallingHelper::UnmarshallingVectorParcelableObj(reply, screenInfos)); return ret; +#else + int32_t dmError; + ErrCode errCode = GetAllScreenInfos(screenInfos, dmError); + return ConvertToDMError(errCode, dmError); +#endif } DMError DisplayManagerLiteProxy::SetSystemKeyboardStatus(bool isTpKeyboardOn) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { TLOGW(WmsLogTag::DMS, "remote is nullptr"); return DMError::DM_ERROR_NULLPTR; } - MessageParcel data; MessageParcel reply; MessageOption option; @@ -815,10 +937,14 @@ DMError DisplayManagerLiteProxy::SetSystemKeyboardStatus(bool isTpKeyboardOn) return DMError::DM_ERROR_IPC_FAILED; } return static_cast(reply.ReadInt32()); +#else + return DMError::DM_ERROR_UNKNOWN; +#endif } sptr DisplayManagerLiteProxy::GetScreenInfoById(ScreenId screenId) { +#ifdef SCENE_BOARD_ENABLED sptr remote = Remote(); if (remote == nullptr) { WLOGFW("remote is nullptr"); @@ -852,6 +978,14 @@ sptr DisplayManagerLiteProxy::GetScreenInfoById(ScreenId screenId) mode->id_, mode->width_, mode->height_, mode->refreshRate_); } return info; +#else + sptr screenInfo; + ErrCode errCode = GetScreenInfoById(screenId, screenInfo); + if (FAILED(errCode) || screenInfo == nullptr) { + return nullptr; + } + return screenInfo; +#endif } bool DisplayManagerLiteProxy::GetKeyboardState() diff --git a/dm_lite/src/display_manager_lite_proxy_idl.cpp b/dm_lite/src/display_manager_lite_proxy_idl.cpp new file mode 100644 index 0000000000..c52d9164da --- /dev/null +++ b/dm_lite/src/display_manager_lite_proxy_idl.cpp @@ -0,0 +1,800 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "display_manager_lite_proxy.h" + +namespace OHOS::Rosen { +// generated by IDisplayManagerLite.idl +ErrCode DisplayManagerLiteProxy::RegisterDisplayManagerAgent( + const sptr& displayManagerAgent, + uint32_t type, + int32_t& dmError) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (displayManagerAgent == nullptr) { + TLOGE(WmsLogTag::DMS, "displayManagerAgent is nullptr!"); + return ERR_INVALID_DATA; + } + if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) { + TLOGE(WmsLogTag::DMS, "Write [displayManagerAgent] failed!"); + return ERR_INVALID_DATA; + } + if (!data.WriteUint32(type)) { + TLOGE(WmsLogTag::DMS, "Write [type] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_REGISTER_DISPLAY_MANAGER_AGENT), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_REGISTER_DISPLAY_MANAGER_AGENT)); + return errCode; + } + + dmError = reply.ReadInt32(); + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::UnregisterDisplayManagerAgent( + const sptr& displayManagerAgent, + uint32_t type, + int32_t& dmError) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (displayManagerAgent == nullptr) { + TLOGE(WmsLogTag::DMS, "displayManagerAgent is nullptr!"); + return ERR_INVALID_DATA; + } + if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) { + TLOGE(WmsLogTag::DMS, "Write [displayManagerAgent] failed!"); + return ERR_INVALID_DATA; + } + if (!data.WriteUint32(type)) { + TLOGE(WmsLogTag::DMS, "Write [type] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_UNREGISTER_DISPLAY_MANAGER_AGENT), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_UNREGISTER_DISPLAY_MANAGER_AGENT)); + return errCode; + } + + dmError = reply.ReadInt32(); + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::GetDefaultDisplayInfo( + sptr& displayInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_GET_DEFAULT_DISPLAY_INFO), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_GET_DEFAULT_DISPLAY_INFO)); + return errCode; + } + + displayInfo = sptr(reply.ReadParcelable()); + if (!displayInfo) { + TLOGE(WmsLogTag::DMS, "Read [DisplayInfo] failed!"); + return ERR_INVALID_DATA; + } + + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::GetDisplayInfoById( + uint64_t displayId, + sptr& displayInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint64(displayId)) { + TLOGE(WmsLogTag::DMS, "Write [displayId] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_GET_DISPLAY_INFO_BY_ID), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_GET_DISPLAY_INFO_BY_ID)); + return errCode; + } + + displayInfo = sptr(reply.ReadParcelable()); + if (!displayInfo) { + TLOGE(WmsLogTag::DMS, "Read [DisplayInfo] failed!"); + return ERR_INVALID_DATA; + } + + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::GetCutoutInfo( + uint64_t displayId, + sptr& cutoutInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint64(displayId)) { + TLOGE(WmsLogTag::DMS, "Write [displayId] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_GET_CUTOUT_INFO), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_GET_CUTOUT_INFO)); + return errCode; + } + + cutoutInfo = sptr(reply.ReadParcelable()); + if (!cutoutInfo) { + TLOGE(WmsLogTag::DMS, "Read [CutoutInfo] failed!"); + return ERR_INVALID_DATA; + } + + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::WakeUpBegin( + uint32_t reason, + bool& isSucc) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint32(reason)) { + TLOGE(WmsLogTag::DMS, "Write [reason] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_WAKE_UP_BEGIN), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_WAKE_UP_BEGIN)); + return errCode; + } + + isSucc = reply.ReadInt32() == 1 ? true : false; + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::WakeUpEnd( + bool& isSucc) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_WAKE_UP_END), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_WAKE_UP_END)); + return errCode; + } + + isSucc = reply.ReadInt32() == 1 ? true : false; + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::SuspendBegin( + uint32_t reason, + bool& isSucc) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint32(reason)) { + TLOGE(WmsLogTag::DMS, "Write [reason] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_SUSPEND_BEGIN), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_SUSPEND_BEGIN)); + return errCode; + } + + isSucc = reply.ReadInt32() == 1 ? true : false; + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::SuspendEnd( + bool& isSucc) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_SUSPEND_END), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_SUSPEND_END)); + return errCode; + } + + isSucc = reply.ReadInt32() == 1 ? true : false; + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::SetSpecifiedScreenPower( + uint64_t screenId, + uint32_t screenPowerState, + uint32_t reason, + bool& isSucc) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint64(screenId)) { + TLOGE(WmsLogTag::DMS, "Write [screenId] failed!"); + return ERR_INVALID_DATA; + } + if (!data.WriteUint32(screenPowerState)) { + TLOGE(WmsLogTag::DMS, "Write [screenPowerState] failed!"); + return ERR_INVALID_DATA; + } + if (!data.WriteUint32(reason)) { + TLOGE(WmsLogTag::DMS, "Write [reason] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_SET_SPECIFIED_SCREEN_POWER), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_SET_SPECIFIED_SCREEN_POWER)); + return errCode; + } + + isSucc = reply.ReadInt32() == 1 ? true : false; + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::SetScreenPowerForAll( + uint32_t screenPowerState, + uint32_t reason, + bool& isSucc) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint32(screenPowerState)) { + TLOGE(WmsLogTag::DMS, "Write [screenPowerState] failed!"); + return ERR_INVALID_DATA; + } + if (!data.WriteUint32(reason)) { + TLOGE(WmsLogTag::DMS, "Write [reason] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_SET_SCREEN_POWER_FOR_ALL), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_SET_SCREEN_POWER_FOR_ALL)); + return errCode; + } + + isSucc = reply.ReadInt32() == 1 ? true : false; + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::GetScreenPower( + uint64_t dmsScreenId, + uint32_t& screenPowerState) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint64(dmsScreenId)) { + TLOGE(WmsLogTag::DMS, "Write [dmsScreenId] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_GET_SCREEN_POWER), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_GET_SCREEN_POWER)); + return errCode; + } + + screenPowerState = reply.ReadUint32(); + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::SetDisplayState( + uint32_t displayState, + bool& isSucc) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint32(displayState)) { + TLOGE(WmsLogTag::DMS, "Write [displayState] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_SET_DISPLAY_STATE), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_SET_DISPLAY_STATE)); + return errCode; + } + + isSucc = reply.ReadInt32() == 1 ? true : false; + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::GetDisplayState( + uint64_t displayId, + uint32_t& displayState) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint64(displayId)) { + TLOGE(WmsLogTag::DMS, "Write [displayId] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_GET_DISPLAY_STATE), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_GET_DISPLAY_STATE)); + return errCode; + } + + displayState = reply.ReadUint32(); + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::TryToCancelScreenOff( + bool& isSucc) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_TRY_TO_CANCEL_SCREEN_OFF), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_TRY_TO_CANCEL_SCREEN_OFF)); + return errCode; + } + + isSucc = reply.ReadInt32() == 1 ? true : false; + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::GetAllDisplayIds( + std::vector& displayIds) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_GET_ALL_DISPLAY_IDS), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_GET_ALL_DISPLAY_IDS)); + return errCode; + } + + int32_t displayIdsSize = reply.ReadInt32(); + if (displayIdsSize > static_cast(VECTOR_MAX_SIZE)) { + TLOGE(WmsLogTag::DMS, "The vector/array size exceeds the security limit!"); + return ERR_INVALID_DATA; + } + for (int32_t i1 = 0; i1 < displayIdsSize; ++i1) { + uint64_t value1 = reply.ReadUint64(); + displayIds.push_back(value1); + } + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::GetAllScreenInfos( + std::vector>& screenInfos, + int32_t& dmError) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_GET_ALL_SCREEN_INFOS), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_GET_ALL_SCREEN_INFOS)); + return errCode; + } + + int32_t screenInfosSize = reply.ReadInt32(); + if (screenInfosSize > static_cast(VECTOR_MAX_SIZE)) { + TLOGE(WmsLogTag::DMS, "The vector/array size exceeds the security limit!"); + return ERR_INVALID_DATA; + } + for (int32_t i2 = 0; i2 < screenInfosSize; ++i2) { + sptr value2 = sptr(reply.ReadParcelable()); + if (!value2) { + TLOGE(WmsLogTag::DMS, "Read [ScreenInfo] failed!"); + return ERR_INVALID_DATA; + } + + screenInfos.push_back(value2); + } + dmError = reply.ReadInt32(); + return ERR_OK; +} + +ErrCode DisplayManagerLiteProxy::GetScreenInfoById( + uint64_t screenId, + sptr& screenInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::DMS, "Write interface token failed!"); + return ERR_INVALID_VALUE; + } + + if (!data.WriteUint64(screenId)) { + TLOGE(WmsLogTag::DMS, "Write [screenId] failed!"); + return ERR_INVALID_DATA; + } + + sptr remote = Remote(); + if (!remote) { + TLOGE(WmsLogTag::DMS, "Remote is nullptr!"); + return ERR_INVALID_DATA; + } + int32_t result = remote->SendRequest( + static_cast(IDisplayManagerIpcCode::COMMAND_GET_SCREEN_INFO_BY_ID), data, reply, option); + if (FAILED(result)) { + TLOGE(WmsLogTag::DMS, "Send request failed!"); + return result; + } + + ErrCode errCode = reply.ReadInt32(); + if (FAILED(errCode)) { + TLOGE(WmsLogTag::DMS, "Read result failed, code is: %{public}d.", + static_cast(IDisplayManagerIpcCode::COMMAND_GET_SCREEN_INFO_BY_ID)); + return errCode; + } + + screenInfo = sptr(reply.ReadParcelable()); + if (!screenInfo) { + TLOGE(WmsLogTag::DMS, "Read [ScreenInfo] failed!"); + return ERR_INVALID_DATA; + } + return ERR_OK; +} +} // namespace OHOS::Rosen + diff --git a/dmserver/BUILD.gn b/dmserver/BUILD.gn index d8debae973..d6729d50ff 100644 --- a/dmserver/BUILD.gn +++ b/dmserver/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") import("../windowmanager_aafwk.gni") @@ -19,6 +20,8 @@ config("libdms_private_config") { include_dirs = [ "../dm/include", "../interfaces/innerkits/dm", + "../utils/include", + "${target_gen_dir}", ] } @@ -26,6 +29,48 @@ config("libdms_public_config") { include_dirs = [ "include" ] } +idl_gen_interface("display_manager_interface") { + sources = [ "IDisplayManager.idl" ] + log_domainid = "0xD004201" + log_tag = "IDisplayManager" + part_name = "window_manager" + subsystem_name = "window" +} + +ohos_source_set("display_manager_stub") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + idl_gen_files = get_target_outputs(":display_manager_interface") + sources = filter_include(idl_gen_files, [ "*_stub.cpp" ]) + configs = [ ":libdms_private_config" ] + deps = [ ":display_manager_interface" ] + external_deps = [ "graphic_2d:librender_service_client" ] + part_name = "window_manager" + subsystem_name = "window" +} + +ohos_source_set("display_manager_proxy") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + idl_gen_files = get_target_outputs(":display_manager_interface") + sources = filter_include(idl_gen_files, [ "*_proxy.cpp" ]) + configs = [ ":libdms_private_config" ] + deps = [ ":display_manager_interface" ] + external_deps = [ "graphic_2d:librender_service_client" ] + part_name = "window_manager" + subsystem_name = "window" +} + ohos_shared_library("libdms") { branch_protector_ret = "pac_ret" sanitize = { @@ -44,9 +89,9 @@ ohos_shared_library("libdms") { "src/display_dumper.cpp", "src/display_manager_agent_controller.cpp", "src/display_manager_config.cpp", + "src/display_manager_ipc_service.cpp", "src/display_manager_service.cpp", "src/display_manager_service_inner.cpp", - "src/display_manager_stub.cpp", "src/display_power_controller.cpp", "src/screen_rotation_controller.cpp", "src/sensor_connector.cpp", @@ -61,6 +106,7 @@ ohos_shared_library("libdms") { public_configs = [ ":libdms_public_config" ] deps = [ + ":display_manager_stub", "${window_base_path}/utils:libwmutil_base", "${window_base_path}/window_scene/interfaces/innerkits:libwsutils", "../utils:libwmutil", diff --git a/dmserver/IDisplayManager.idl b/dmserver/IDisplayManager.idl new file mode 100644 index 0000000000..3247ec9489 --- /dev/null +++ b/dmserver/IDisplayManager.idl @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +sequenceable OHOS.IRemoteObject; +sequenceable OHOS.Media.PixelMap; +sequenceable OHOS.Rosen.DisplayInfo; +sequenceable OHOS.Rosen.DmVirtualScreenOption; +sequenceable OHOS.Rosen.CutoutInfo; +sequenceable OHOS.Rosen.DmRsSurfaceNode; +sequenceable OHOS.Rosen.ScreenInfo; +sequenceable OHOS.Rosen.ScreenGroupInfo; +sequenceable dm_common..OHOS.Rosen.Point; +sequenceable dm_common..OHOS.Rosen.DisplayPhysicalResolution; +interface OHOS.IBufferProducer; +interface zidl..OHOS.Rosen.IDisplayManagerAgent; + +interface OHOS.Rosen.IDisplayManager { + void GetDefaultDisplayInfo([out] sptr displayInfo); + void GetDisplayInfoById([in] unsigned long displayId, [out] sptr displayInfo); + void GetVisibleAreaDisplayInfoById([in] unsigned long displayId, [out] sptr displayInfo); + void GetDisplayInfoByScreen([in] unsigned long screenId, [out] sptr displayInfo); + void CreateVirtualScreen([in] DmVirtualScreenOption virtualOption, [in] IRemoteObject displayManagerAgent, + [out] unsigned long screenId); + void CreateVirtualScreen([in] DmVirtualScreenOption virtualOption, [in] IRemoteObject displayManagerAgent, + [out] unsigned long screenId, [in] IBufferProducer surface); + void DestroyVirtualScreen([in] unsigned long screenId, [out] int dmError); + void SetVirtualScreenSurface([in] unsigned long screenId, [in] IBufferProducer surface, [out] int dmError); + void SetOrientation([in] unsigned long screenId, [in] unsigned int orientation, [out] int dmError); + void GetDisplaySnapshot([in] unsigned long displayId, [out] int errorCode, [in] boolean isUseDma, + [in] boolean isCaptureFullOfScreen, [out] sharedptr pixelMap); + void GetScreenSupportedColorGamuts([in] unsigned long screenId, [out] unsigned int[] colorGamuts, + [out] int dmError); + void GetScreenColorGamut([in] unsigned long screenId, [out] unsigned int colorGamut, [out] int dmError); + void SetScreenColorGamut([in] unsigned long screenId, [in] int colorGamutIdx, [out] int dmError); + void GetScreenGamutMap([in] unsigned long screenId, [out] unsigned int gamutMap, [out] int dmError); + void SetScreenGamutMap([in] unsigned long screenId, [in] unsigned int gamutMap, [out] int dmError); + void SetScreenColorTransform([in] unsigned long screenId); + void RegisterDisplayManagerAgent([in] IDisplayManagerAgent displayManagerAgent, [in] unsigned int type, + [out] int dmError); + void UnregisterDisplayManagerAgent([in] IDisplayManagerAgent displayManagerAgent, [in] unsigned int type, + [out] int dmError); + void WakeUpBegin([in] unsigned int reason, [out] boolean isSucc); + void WakeUpEnd([out] boolean isSucc); + void SuspendBegin([in] unsigned int reason, [out] boolean isSucc); + void SuspendEnd([out] boolean isSucc); + void SetScreenPowerForAll([in] unsigned int screenPowerState, [in] unsigned int reason, [out] boolean isSucc); + void SetSpecifiedScreenPower([in] unsigned long screenId, [in] unsigned int screenPowerState, + [in] unsigned int reason, [out] boolean isSucc); + void GetScreenPower([in] unsigned long dmsScreenId, [out] unsigned int screenPowerState); + void SetDisplayState([in] unsigned int displayState, [out] boolean isSucc); + void GetDisplayState([in] unsigned long displayId, [out] unsigned int displayState); + void TryToCancelScreenOff([out] boolean isSucc); + void GetAllDisplayIds([out] unsigned long[] displayIds); + void GetCutoutInfo([in] unsigned long displayId, [out] sptr cutoutInfo); + void AddSurfaceNodeToDisplay([in] unsigned long displayId, [in] sharedptr dmRsSurfaceNode, + [out] int dmError); + void RemoveSurfaceNodeFromDisplay([in] unsigned long displayId, [in] sharedptr dmRsSurfaceNode, + [out] int dmError); + void HasPrivateWindow([in] unsigned long displayId, [out] boolean hasPrivateWindow, [out] int dmError); + void NotifyDisplayEvent([in] unsigned int displayEvent); + void SetFreeze([in] unsigned long[] displayIds, [in] boolean isFreeze, [out] boolean isSucc); + void MakeMirror([in] unsigned long mainScreenId, [in] unsigned long[] mirrorScreenId, + [out] unsigned long screenGroupId, [out] int dmError); + void StopMirror([in] unsigned long[] mirrorScreenIds, [out] int dmError); + void GetScreenInfoById([in] unsigned long screenId, [out] sptr screenInfo); + void GetScreenGroupInfoById([in] unsigned long screenId, [out] sptr screenGroupInfo); + void GetAllScreenInfos([out] sptr[] screenInfos, [out] int dmError); + void MakeExpand([in] unsigned long[] screenId, [in] Point[] startPoint, [out] unsigned long screenGroupId, + [out] int dmError); + void StopExpand([in] unsigned long[] expandScreenIds, [out] int dmError); + void RemoveVirtualScreenFromGroup([in] unsigned long[] screens); + void SetScreenActiveMode([in] unsigned long screenId, [in] unsigned int modeId, [out] int dmError); + void SetVirtualPixelRatio([in] unsigned long screenId, [in] float virtualPixelRatio, [out] int dmError); + void SetResolution([in] unsigned long screenId, [in] unsigned int width, [in] unsigned int height, + [in] float virtualPixelRatio, [out] int dmError); + void GetDensityInCurResolution([in] unsigned long screenId, [out] float virtualPixelRatio, [out] int dmError); + void IsScreenRotationLocked([out] boolean isLocked, [out] int dmError); + void SetScreenRotationLocked([in] boolean isLocked, [out] int dmError); + void SetScreenRotationLockedFromJs([in] boolean isLocked, [out] int dmError); + void GetAllDisplayPhysicalResolution([out] DisplayPhysicalResolution[] displayPhysicalResolutions); +} diff --git a/dmserver/include/abstract_screen_controller.h b/dmserver/include/abstract_screen_controller.h index 0ead42d0ac..ee964678d4 100644 --- a/dmserver/include/abstract_screen_controller.h +++ b/dmserver/include/abstract_screen_controller.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -30,7 +30,7 @@ #include "display_manager_agent_controller.h" #include "dm_common.h" #include "screen.h" -#include "zidl/display_manager_agent_interface.h" +#include "zidl/idisplay_manager_agent.h" namespace OHOS::Rosen { class AbstractScreenController : public RefBase { @@ -164,4 +164,4 @@ struct ScreenRect { }; } // namespace OHOS::Rosen -#endif // FOUNDATION_DMSERVER_ABSTRACT_SCREEN_CONTROLLER_H \ No newline at end of file +#endif // FOUNDATION_DMSERVER_ABSTRACT_SCREEN_CONTROLLER_H diff --git a/dmserver/include/display_manager_agent_controller.h b/dmserver/include/display_manager_agent_controller.h index 2651f70f9d..ad7e515bc6 100644 --- a/dmserver/include/display_manager_agent_controller.h +++ b/dmserver/include/display_manager_agent_controller.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,7 +20,7 @@ #include "dm_common.h" #include "wm_single_instance.h" #include "client_agent_container.h" -#include "zidl/display_manager_agent_interface.h" +#include "zidl/idisplay_manager_agent.h" namespace OHOS { namespace Rosen { diff --git a/dmserver/include/display_manager_interface.h b/dmserver/include/display_manager_interface.h deleted file mode 100644 index 7da6afaf79..0000000000 --- a/dmserver/include/display_manager_interface.h +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H -#define FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H - -#include -#include -#include -#include - -#include "display_cutout_controller.h" -#include "display_info.h" -#include "dm_common.h" -#include "fold_screen_info.h" -#include "screen.h" -#include "screen_info.h" -#include "screen_group_info.h" -#include "display_manager_interface_code.h" -#include "zidl/display_manager_agent_interface.h" - -namespace OHOS::Rosen { -class IDisplayManager : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IDisplayManager"); - - virtual sptr GetDefaultDisplayInfo() = 0; - virtual sptr GetDisplayInfoById(DisplayId displayId) = 0; - virtual sptr GetVisibleAreaDisplayInfoById(DisplayId displayId) = 0; - virtual sptr GetDisplayInfoByScreen(ScreenId screenId) = 0; - virtual DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) = 0; - virtual bool ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId) { return false; }; - virtual void UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo) {}; - virtual void GetDisplayHookInfo(int32_t uid, DMHookInfo& hookInfo) {}; - - virtual ScreenId CreateVirtualScreen(VirtualScreenOption option, - const sptr& displayManagerAgent) = 0; - virtual DMError DestroyVirtualScreen(ScreenId screenId) = 0; - virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr surface) = 0; - virtual DMError AddVirtualScreenBlockList( - const std::vector& persistentIds) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } - virtual DMError RemoveVirtualScreenBlockList( - const std::vector& persistentIds) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } - virtual DMError SetScreenPrivacyMaskImage(ScreenId screenId, const std::shared_ptr& privacyMaskImg) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool rotate) { return DMError::DM_OK; } - virtual DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetOrientation(ScreenId screenId, Orientation orientation) = 0; - virtual std::shared_ptr GetDisplaySnapshot(DisplayId displayId, - DmErrorCode* errorCode = nullptr, bool isUseDma = false, bool isCaptureFullOfScreen = false) = 0; - virtual std::shared_ptr GetSnapshotByPicker(Media::Rect &rect, DmErrorCode* errorCode = nullptr) - { - *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; - return nullptr; - } - virtual DMError SetScreenRotationLocked(bool isLocked) = 0; - virtual DMError SetScreenRotationLockedFromJs(bool isLocked) = 0; - virtual DMError IsScreenRotationLocked(bool& isLocked) = 0; - - // colorspace, gamut - virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector& colorGamuts) = 0; - virtual DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) = 0; - virtual DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) = 0; - virtual DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) = 0; - virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) = 0; - virtual DMError SetScreenColorTransform(ScreenId screenId) = 0; - - virtual DMError GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError GetSupportedHDRFormats(ScreenId screenId, - std::vector& hdrFormats) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError GetSupportedColorSpaces(ScreenId screenId, - std::vector& colorSpaces) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - - virtual DMError RegisterDisplayManagerAgent(const sptr& displayManagerAgent, - DisplayManagerAgentType type) = 0; - virtual DMError UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, - DisplayManagerAgentType type) = 0; - virtual bool WakeUpBegin(PowerStateChangeReason reason) = 0; - virtual bool WakeUpEnd() = 0; - virtual bool SuspendBegin(PowerStateChangeReason reason) = 0; - virtual bool SuspendEnd() = 0; - virtual ScreenId GetInternalScreenId() { return SCREEN_ID_INVALID; } - virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) - { - return false; - } - virtual bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) = 0; - virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) = 0; - virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) = 0; - virtual ScreenPowerState GetScreenPower() { return ScreenPowerState::INVALID_STATE; } - virtual bool SetDisplayState(DisplayState state) = 0; - virtual DisplayState GetDisplayState(DisplayId displayId) = 0; - virtual bool TryToCancelScreenOff() = 0; - virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) { return false; } - virtual uint32_t GetScreenBrightness(uint64_t screenId) { return 0; } - virtual std::vector GetAllDisplayIds() = 0; - virtual sptr GetCutoutInfo(DisplayId displayId) = 0; - virtual sptr GetCutoutInfoWithRotation(DisplayId displayId, int32_t rotation) - { - return nullptr; - } - virtual void NotifyDisplayEvent(DisplayEvent event) = 0; - virtual bool SetFreeze(std::vector displayIds, bool isFreeze) = 0; - virtual sptr GetScreenInfoById(ScreenId screenId) = 0; - virtual sptr GetScreenGroupInfoById(ScreenId screenId) = 0; - virtual DMError GetAllScreenInfos(std::vector>& screenInfos) = 0; - virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - ScreenId& screenGroupId) = 0; - virtual DMError MakeMirrorForRecord(ScreenId mainScreenId, std::vector mirrorScreenIds, - ScreenId& screenGroupId) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - DMRect mainScreenRegion, ScreenId& screenGroupId) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, - MultiScreenMode screenMode) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions, - MultiScreenPositionOptions secondScreenOption) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError MakeExpand(std::vector screenId, std::vector startPoints, - ScreenId& screenGroupId) = 0; - virtual DMError StopMirror(const std::vector& mirrorScreenIds) = 0; - virtual DMError StopExpand(const std::vector& expandScreenIds) = 0; - virtual DMError DisableMirror(bool disableOrNot) { return DMError::DM_ERROR_INVALID_PERMISSION; } - virtual void RemoveVirtualScreenFromGroup(std::vector screens) = 0; - virtual DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) = 0; - virtual DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) = 0; - virtual DMError SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetDefaultDensityDpi(ScreenId screenId, float virtualPixelRatio) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio) = 0; - virtual DMError GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio) = 0; - virtual DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) { return DMError::DM_OK; } - virtual DMError AddSurfaceNodeToDisplay(DisplayId displayId, - std::shared_ptr& surfaceNode, bool onTop = true) = 0; - virtual DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId, - std::shared_ptr& surfaceNode) = 0; - virtual DMError GetAvailableArea(DisplayId displayId, DMRect& area) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } - virtual DMError GetExpandAvailableArea(DisplayId displayId, DMRect& area) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual bool IsFoldable() { return false; } - virtual bool IsCaptured() { return false; } - - virtual FoldStatus GetFoldStatus() { return FoldStatus::UNKNOWN; } - - virtual FoldDisplayMode GetFoldDisplayMode() { return FoldDisplayMode::UNKNOWN; } - - virtual void SetFoldDisplayMode(const FoldDisplayMode) {} - - virtual DMError SetFoldDisplayModeFromJs(const FoldDisplayMode, std::string reason = "") { return DMError::DM_OK; } - - virtual void SetDisplayScale(ScreenId screenId, float scaleX, float scaleY, float pivotX, float pivotY) {} - - virtual void SetFoldStatusLocked(bool locked) {} - - virtual DMError SetFoldStatusLockedFromJs(bool locked) { return DMError::DM_OK; } - - virtual sptr GetCurrentFoldCreaseRegion() { return nullptr; } - - virtual DMError HasImmersiveWindow(ScreenId screenId, bool& immersive) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - - // unique screen - virtual DMError MakeUniqueScreen(const std::vector& screenIds, - std::vector& displayIds) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - - virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) - { - return VirtualScreenFlag::DEFAULT; - } - virtual DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval) - { - return DMError::DM_OK; - } - virtual DMError ProxyForFreeze(const std::set& pidList, bool isProxy) - { - return DMError::DM_OK; - } - virtual DMError ResetAllFreezeStatus() - { - return DMError::DM_OK; - } - virtual void SetVirtualScreenBlackList(ScreenId screenId, std::vector& windowIdList, - std::vector surfaceIdList = {}, std::vector typeBlackList = {}) {} - virtual void SetVirtualDisplayMuteFlag(ScreenId screenId, bool muteFlag) {} - virtual void DisablePowerOffRenderControl(ScreenId screenId) {} - - virtual std::vector GetAllDisplayPhysicalResolution() - { - return std::vector {}; - } - virtual DMError GetDisplayCapability(std::string& capabilitInfo) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual bool SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus) { return false; } - virtual DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, - std::vector& windowIdList) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } - virtual DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate, - uint32_t& actualRefreshRate) - { - return DMError::DM_OK; - } - - virtual std::shared_ptr GetScreenCapture(const CaptureOption& captureOption, - DmErrorCode* errorCode = nullptr) - { - *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; - return nullptr; - } - - virtual sptr GetPrimaryDisplayInfo() - { - return nullptr; - } - virtual std::shared_ptr GetDisplaySnapshotWithOption(const CaptureOption& captureOption, - DmErrorCode* errorCode = nullptr) - { - if (errorCode != nullptr) { - *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; - } - return nullptr; - } - - virtual DMError SetScreenSkipProtectedWindow(const std::vector& screenIds, bool isEnable) - { - return DMError::DM_OK; - } - - virtual void SetFoldStatusExpandAndLocked(bool locked) {} - - virtual DMError SetSystemKeyboardStatus(bool isTpKeyboardOn = false) - { - return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; - } -}; -} // namespace OHOS::Rosen - -#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H diff --git a/dmserver/include/display_manager_ipc_service.h b/dmserver/include/display_manager_ipc_service.h new file mode 100644 index 0000000000..7ac12b993a --- /dev/null +++ b/dmserver/include/display_manager_ipc_service.h @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ROSEN_DISPLAY_MANAGER_IPC_SERVICE_H +#define OHOS_ROSEN_DISPLAY_MANAGER_IPC_SERVICE_H + +#include +#include +#include +#include "display_manager_service.h" +#include "display_manager_stub.h" + +namespace OHOS::Rosen { +class DisplayManagerIpcService : public SystemAbility, public DisplayManagerStub { +DECLARE_SYSTEM_ABILITY(DisplayManagerIpcService); +WM_DECLARE_SINGLE_INSTANCE_BASE(DisplayManagerIpcService); + +protected: + void OnStart() override; + void OnStop() override; + +public: + int Dump(int fd, const std::vector& args) override; + + ErrCode GetDefaultDisplayInfo( + sptr& displayInfo) override; + + ErrCode GetDisplayInfoById( + uint64_t displayId, + sptr& displayInfo) override; + + ErrCode GetVisibleAreaDisplayInfoById( + uint64_t displayId, + sptr& displayInfo) override; + + ErrCode GetDisplayInfoByScreen( + uint64_t screenId, + sptr& displayInfo) override; + + ErrCode CreateVirtualScreen( + const DmVirtualScreenOption& virtualOption, + const sptr& displayManagerAgent, + uint64_t& screenId) override; + + ErrCode CreateVirtualScreen( + const DmVirtualScreenOption& virtualOption, + const sptr& displayManagerAgent, + uint64_t& screenId, + const sptr& surface) override; + + ErrCode DestroyVirtualScreen( + uint64_t screenId, + int32_t& dmError) override; + + ErrCode SetVirtualScreenSurface( + uint64_t screenId, + const sptr& surface, + int32_t& dmError) override; + + ErrCode SetOrientation( + uint64_t screenId, + uint32_t orientation, + int32_t& dmError) override; + + ErrCode GetDisplaySnapshot( + uint64_t displayId, + int32_t& errorCode, + bool isUseDma, + bool isCaptureFullOfScreen, + std::shared_ptr& pixelMap) override; + + ErrCode GetScreenSupportedColorGamuts( + uint64_t screenId, + std::vector& colorGamuts, + int32_t& dmError) override; + + ErrCode GetScreenColorGamut( + uint64_t screenId, + uint32_t& colorGamut, + int32_t& dmError) override; + + ErrCode SetScreenColorGamut( + uint64_t screenId, + int32_t colorGamutIdx, + int32_t& dmError) override; + + ErrCode GetScreenGamutMap( + uint64_t screenId, + uint32_t& gamutMap, + int32_t& dmError) override; + + ErrCode SetScreenGamutMap( + uint64_t screenId, + uint32_t gamutMap, + int32_t& dmError) override; + + ErrCode SetScreenColorTransform( + uint64_t screenId) override; + + ErrCode RegisterDisplayManagerAgent( + const sptr& displayManagerAgent, + uint32_t type, + int32_t& dmError) override; + + ErrCode UnregisterDisplayManagerAgent( + const sptr& displayManagerAgent, + uint32_t type, + int32_t& dmError) override; + + ErrCode WakeUpBegin( + uint32_t reason, + bool& isSucc) override; + + ErrCode WakeUpEnd( + bool& isSucc) override; + + ErrCode SuspendBegin( + uint32_t reason, + bool& isSucc) override; + + ErrCode SuspendEnd( + bool& isSucc) override; + + ErrCode SetScreenPowerForAll( + uint32_t screenPowerState, + uint32_t reason, + bool& isSucc) override; + + ErrCode SetSpecifiedScreenPower( + uint64_t screenId, + uint32_t screenPowerState, + uint32_t reason, + bool& isSucc) override; + + ErrCode GetScreenPower( + uint64_t dmsScreenId, + uint32_t& screenPowerState) override; + + ErrCode SetDisplayState( + uint32_t displayState, + bool& isSucc) override; + + ErrCode GetDisplayState( + uint64_t displayId, + uint32_t& displayState) override; + + ErrCode TryToCancelScreenOff( + bool& isSucc) override; + + ErrCode GetAllDisplayIds( + std::vector& displayIds) override; + + ErrCode GetCutoutInfo( + uint64_t displayId, + sptr& cutoutInfo) override; + + ErrCode AddSurfaceNodeToDisplay( + uint64_t displayId, + const std::shared_ptr& dmRsSurfaceNode, + int32_t& dmError) override; + + ErrCode RemoveSurfaceNodeFromDisplay( + uint64_t displayId, + const std::shared_ptr& dmRsSurfaceNode, + int32_t& dmError) override; + + ErrCode HasPrivateWindow( + uint64_t displayId, + bool& hasPrivateWindow, + int32_t& dmError) override; + + ErrCode NotifyDisplayEvent( + uint32_t displayEvent) override; + + ErrCode SetFreeze( + const std::vector& displayIds, + bool isFreeze, + bool& isSucc) override; + + ErrCode MakeMirror( + uint64_t mainScreenId, + const std::vector& mirrorScreenId, + uint64_t& screenGroupId, + int32_t& dmError) override; + + ErrCode StopMirror( + const std::vector& mirrorScreenIds, + int32_t& dmError) override; + + ErrCode GetScreenInfoById( + uint64_t screenId, + sptr& screenInfo) override; + + ErrCode GetScreenGroupInfoById( + uint64_t screenId, + sptr& screenGroupInfo) override; + + ErrCode GetAllScreenInfos( + std::vector>& screenInfos, + int32_t& dmError) override; + + ErrCode MakeExpand( + const std::vector& screenId, + const std::vector& startPoint, + uint64_t& screenGroupId, + int32_t& dmError) override; + + ErrCode StopExpand( + const std::vector& expandScreenIds, + int32_t& dmError) override; + + ErrCode RemoveVirtualScreenFromGroup( + const std::vector& screens) override; + + ErrCode SetScreenActiveMode( + uint64_t screenId, + uint32_t modeId, + int32_t& dmError) override; + + ErrCode SetVirtualPixelRatio( + uint64_t screenId, + float virtualPixelRatio, + int32_t& dmError) override; + + ErrCode SetResolution( + uint64_t screenId, + uint32_t width, + uint32_t height, + float virtualPixelRatio, + int32_t& dmError) override; + + ErrCode GetDensityInCurResolution( + uint64_t screenId, + float& virtualPixelRatio, + int32_t& dmError) override; + + ErrCode IsScreenRotationLocked( + bool& isLocked, + int32_t& dmError) override; + + ErrCode SetScreenRotationLocked( + bool isLocked, + int32_t& dmError) override; + + ErrCode SetScreenRotationLockedFromJs( + bool isLocked, + int32_t& dmError) override; + + ErrCode GetAllDisplayPhysicalResolution( + std::vector& displayPhysicalResolutions) override; + +private: + DisplayManagerIpcService(); + + static inline SingletonDelegator delegator_; + DisplayManagerService& displayManagerService_; +}; +} // namespace OHOS::Rosen +#endif // OHOS_ROSEN_DISPLAY_MANAGER_IPC_SERVICE_H diff --git a/dmserver/include/display_manager_proxy.h b/dmserver/include/display_manager_proxy.h deleted file mode 100644 index 8ef4e7efa6..0000000000 --- a/dmserver/include/display_manager_proxy.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FOUNDATION_DMSERVER_DISPLAY_MANAGER_PROXY_H -#define FOUNDATION_DMSERVER_DISPLAY_MANAGER_PROXY_H - -#include "display_manager_interface.h" - -#include "dm_common.h" - -#include "screen.h" - -#include - -namespace OHOS::Rosen { -class DisplayManagerProxy : public IRemoteProxy { -public: - explicit DisplayManagerProxy(const sptr &impl) - : IRemoteProxy(impl) {}; - ~DisplayManagerProxy() {}; - - sptr GetDefaultDisplayInfo() override; - sptr GetDisplayInfoById(DisplayId displayId) override; - sptr GetVisibleAreaDisplayInfoById(DisplayId displayId) override; - sptr GetDisplayInfoByScreen(ScreenId screenId) override; - DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) override; - - ScreenId CreateVirtualScreen(VirtualScreenOption option, - const sptr& displayManagerAgent) override; - DMError DestroyVirtualScreen(ScreenId screenId) override; - DMError SetVirtualScreenSurface(ScreenId screenId, sptr surface) override; - DMError SetOrientation(ScreenId screenId, Orientation orientation) override; - std::shared_ptr GetDisplaySnapshot(DisplayId displayId, - DmErrorCode* errorCode = nullptr, bool isUseDma = false, bool isCaptureFullOfScreen = false) override; - DMError IsScreenRotationLocked(bool& isLocked) override; - DMError SetScreenRotationLocked(bool isLocked) override; - DMError SetScreenRotationLockedFromJs(bool isLocked) override; - - // colorspace, gamut - DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector& colorGamuts) override; - DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) override; - DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) override; - DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) override; - DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) override; - DMError SetScreenColorTransform(ScreenId screenId) override; - - DMError GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) override; - DMError SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) override; - DMError GetSupportedHDRFormats(ScreenId screenId, std::vector& hdrFormats) override; - DMError GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) override; - DMError SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) override; - DMError GetSupportedColorSpaces(ScreenId screenId, std::vector& colorSpaces) override; - DMError GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace) override; - DMError SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace) override; - - DMError RegisterDisplayManagerAgent(const sptr& displayManagerAgent, - DisplayManagerAgentType type) override; - DMError UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, - DisplayManagerAgentType type) override; - bool WakeUpBegin(PowerStateChangeReason reason) override; - bool WakeUpEnd() override; - bool SuspendBegin(PowerStateChangeReason reason) override; - bool SuspendEnd() override; - bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override; - bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override; - ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override; - bool SetDisplayState(DisplayState state) override; - bool TryToCancelScreenOff() override; - std::vector GetAllDisplayIds() override; - DisplayState GetDisplayState(DisplayId displayId) override; - sptr GetCutoutInfo(DisplayId displayId) override; - void NotifyDisplayEvent(DisplayEvent event) override; - bool SetFreeze(std::vector displayIds, bool isFreeze) override; - DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenId, ScreenId& screenGroupId) override; - DMError StopMirror(const std::vector& mirrorScreenIds) override; - sptr GetScreenInfoById(ScreenId screenId) override; - sptr GetScreenGroupInfoById(ScreenId screenId) override; - DMError GetAllScreenInfos(std::vector>& screens) override; - DMError MakeExpand(std::vector screenId, std::vector startPoint, ScreenId& screenGroupId) override; - DMError StopExpand(const std::vector& expandScreenIds) override; - void RemoveVirtualScreenFromGroup(std::vector screens) override; - DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) override; - DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) override; - DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio) override; - DMError GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio) override; - DMError AddSurfaceNodeToDisplay(DisplayId displayId, - std::shared_ptr& surfaceNode, bool onTop = true) override; - DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId, - std::shared_ptr& surfaceNode) override; - DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) override; - DMError MakeUniqueScreen(const std::vector& screenIds, std::vector& displayIds) override; - std::vector GetAllDisplayPhysicalResolution() override; -private: - static inline BrokerDelegator delegator_; -}; -} // namespace OHOS::Rosen - -#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_PROXY_H \ No newline at end of file diff --git a/dmserver/include/display_manager_service.h b/dmserver/include/display_manager_service.h index 389da57c79..b18600fe63 100644 --- a/dmserver/include/display_manager_service.h +++ b/dmserver/include/display_manager_service.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,112 +19,108 @@ #include #include -#include #include +#include #include -#include "atomic_map.h" -#include "dm_common.h" -#include "display_dumper.h" -#include "screen.h" #include "abstract_display.h" #include "abstract_display_controller.h" #include "abstract_screen_controller.h" +#include "atomic_map.h" #include "display_change_listener.h" #include "display_cutout_controller.h" +#include "display_dumper.h" #include "display_manager_stub.h" #include "display_power_controller.h" +#include "dm_common.h" +#include "screen.h" #include "singleton_delegator.h" #include "window_info_queried_listener.h" namespace OHOS::Rosen { -class DisplayManagerService : public SystemAbility, public DisplayManagerStub { -DECLARE_SYSTEM_ABILITY(DisplayManagerService); +class DisplayManagerService { WM_DECLARE_SINGLE_INSTANCE_BASE(DisplayManagerService); public: - int Dump(int fd, const std::vector& args) override; - void OnStart() override; - void OnStop() override; + DisplayManagerService(); + bool Init(); + int Dump(int fd, const std::vector& args); ScreenId CreateVirtualScreen(VirtualScreenOption option, - const sptr& displayManagerAgent) override; - DMError DestroyVirtualScreen(ScreenId screenId) override; - DMError SetVirtualScreenSurface(ScreenId screenId, sptr surface) override; - DMError IsScreenRotationLocked(bool& isLocked) override; - DMError SetScreenRotationLocked(bool isLocked) override; - DMError SetScreenRotationLockedFromJs(bool isLocked) override; + const sptr& displayManagerAgent); + DMError DestroyVirtualScreen(ScreenId screenId); + DMError SetVirtualScreenSurface(ScreenId screenId, sptr surface); + DMError IsScreenRotationLocked(bool& isLocked); + DMError SetScreenRotationLocked(bool isLocked); + DMError SetScreenRotationLockedFromJs(bool isLocked); - sptr GetDefaultDisplayInfo() override; - sptr GetDisplayInfoById(DisplayId displayId) override; - sptr GetVisibleAreaDisplayInfoById(DisplayId displayId) override; - sptr GetDisplayInfoByScreen(ScreenId screenId) override; - sptr GetCutoutInfo(DisplayId displayId) override; - DMError SetOrientation(ScreenId screenId, Orientation orientation) override; + sptr GetDefaultDisplayInfo(); + sptr GetDisplayInfoById(DisplayId displayId); + sptr GetVisibleAreaDisplayInfoById(DisplayId displayId); + sptr GetDisplayInfoByScreen(ScreenId screenId); + sptr GetCutoutInfo(DisplayId displayId); + DMError SetOrientation(ScreenId screenId, Orientation orientation); DMError SetOrientationFromWindow(ScreenId screenId, Orientation orientation, bool withAnimation); bool SetRotationFromWindow(ScreenId screenId, Rotation targetRotation, bool withAnimation); void SetGravitySensorSubscriptionEnabled(); std::shared_ptr GetDisplaySnapshot(DisplayId displayId, - DmErrorCode* errorCode, bool isUseDma, bool isCaptureFullOfScreen = false) override; - DMError HasPrivateWindow(DisplayId id, bool& hasPrivateWindow) override; + DmErrorCode* errorCode, bool isUseDma, bool isCaptureFullOfScreen = false); + DMError HasPrivateWindow(DisplayId id, bool& hasPrivateWindow); // colorspace, gamut - DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector& colorGamuts) override; - DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) override; - DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) override; - DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) override; - DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) override; - DMError SetScreenColorTransform(ScreenId screenId) override; + DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector& colorGamuts); + DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut); + DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx); + DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap); + DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap); + DMError SetScreenColorTransform(ScreenId screenId); DMError RegisterDisplayManagerAgent(const sptr& displayManagerAgent, - DisplayManagerAgentType type) override; + DisplayManagerAgentType type); DMError UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, - DisplayManagerAgentType type) override; - bool WakeUpBegin(PowerStateChangeReason reason) override; - bool WakeUpEnd() override; - bool SuspendBegin(PowerStateChangeReason reason) override; - bool SuspendEnd() override; - bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) override; - bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override; - ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override; - bool SetDisplayState(DisplayState state) override; + DisplayManagerAgentType type); + bool WakeUpBegin(PowerStateChangeReason reason); + bool WakeUpEnd(); + bool SuspendBegin(PowerStateChangeReason reason); + bool SuspendEnd(); + bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason); + bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason); + ScreenPowerState GetScreenPower(ScreenId dmsScreenId); + bool SetDisplayState(DisplayState state); void UpdateRSTree(DisplayId displayId, DisplayId parentDisplayId, std::shared_ptr& surfaceNode, bool isAdd, bool isMultiDisplay); DMError AddSurfaceNodeToDisplay(DisplayId displayId, - std::shared_ptr& surfaceNode, bool onTop = true) override; - DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId, std::shared_ptr& surfaceNode) override; - DisplayState GetDisplayState(DisplayId displayId) override; - bool TryToCancelScreenOff() override; - bool SetScreenBrightness(uint64_t screenId, uint32_t level) override; - uint32_t GetScreenBrightness(uint64_t screenId) override; - void NotifyDisplayEvent(DisplayEvent event) override; - bool SetFreeze(std::vector displayIds, bool isFreeze) override; + std::shared_ptr& surfaceNode, bool onTop = true); + DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId, std::shared_ptr& surfaceNode); + DisplayState GetDisplayState(DisplayId displayId); + bool TryToCancelScreenOff(); + bool SetScreenBrightness(uint64_t screenId, uint32_t level); + uint32_t GetScreenBrightness(uint64_t screenId); + void NotifyDisplayEvent(DisplayEvent event); + bool SetFreeze(std::vector displayIds, bool isFreeze); - DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId) override; + DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId); DMError MakeExpand(std::vector screenId, std::vector startPoints, - ScreenId& screenGroupId) override; - DMError StopMirror(const std::vector& mirrorScreenIds) override; - DMError StopExpand(const std::vector& expandScreenIds) override; - void RemoveVirtualScreenFromGroup(std::vector screens) override; - sptr GetScreenInfoById(ScreenId screenId) override; - sptr GetScreenGroupInfoById(ScreenId screenId) override; + ScreenId& screenGroupId); + DMError StopMirror(const std::vector& mirrorScreenIds); + DMError StopExpand(const std::vector& expandScreenIds); + void RemoveVirtualScreenFromGroup(std::vector screens); + sptr GetScreenInfoById(ScreenId screenId); + sptr GetScreenGroupInfoById(ScreenId screenId); ScreenId GetScreenGroupIdByScreenId(ScreenId screenId); - DMError GetAllScreenInfos(std::vector>& screenInfos) override; + DMError GetAllScreenInfos(std::vector>& screenInfos); - std::vector GetAllDisplayIds() override; - DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) override; - DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) override; + std::vector GetAllDisplayIds(); + DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId); + DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio); DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, - float virtualPixelRatio) override { return DMError::DM_OK; } + float virtualPixelRatio) { return DMError::DM_OK; } DMError GetDensityInCurResolution(ScreenId screenId, - float& virtualPixelRatio) override { return DMError::DM_OK; } + float& virtualPixelRatio) { return DMError::DM_OK; } void RegisterDisplayChangeListener(sptr listener); void RegisterWindowInfoQueriedListener(const sptr& listener); void NotifyPrivateWindowStateChanged(bool hasPrivate); - std::vector GetAllDisplayPhysicalResolution() override; + std::vector GetAllDisplayPhysicalResolution(); private: - DisplayManagerService(); - ~DisplayManagerService() = default; - bool Init(); void NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, const std::map>& displayInfoMap, DisplayStateChangeType type); void NotifyScreenshot(DisplayId displayId); @@ -147,4 +143,4 @@ private: }; } // namespace OHOS::Rosen -#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_SERVICE_H \ No newline at end of file +#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_SERVICE_H diff --git a/dmserver/src/display_manager_ipc_service.cpp b/dmserver/src/display_manager_ipc_service.cpp new file mode 100644 index 0000000000..f5c00b1d23 --- /dev/null +++ b/dmserver/src/display_manager_ipc_service.cpp @@ -0,0 +1,420 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "display_manager_ipc_service.h" +#include "scene_board_judgement.h" +#include "window_manager_hilog.h" + +namespace OHOS::Rosen { +WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerIpcService) +const bool REGISTER_RESULT = SceneBoardJudgement::IsSceneBoardEnabled() ? false : + SystemAbility::MakeAndRegisterAbility(&DisplayManagerIpcService::GetInstance()); + +DisplayManagerIpcService::DisplayManagerIpcService() : SystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID, true), + displayManagerService_(DisplayManagerService::GetInstance()) +{ +} + +void DisplayManagerIpcService::OnStart() +{ + TLOGI(WmsLogTag::DMS, "start"); + if (!displayManagerService_.Init()) { + TLOGE(WmsLogTag::DMS, "Init failed"); + return; + } + if (!Publish(this)) { + TLOGE(WmsLogTag::DMS, "Publish failed"); + } + displayManagerService_.SetDisplayState(DisplayState::ON); + TLOGI(WmsLogTag::DMS, "end"); +} + +void DisplayManagerIpcService::OnStop() +{ + TLOGI(WmsLogTag::DMS, "ready to stop display service."); +} + +int DisplayManagerIpcService::Dump(int fd, const std::vector& args) +{ + return displayManagerService_.Dump(fd, args); +} + +ErrCode DisplayManagerIpcService::GetDefaultDisplayInfo(sptr& displayInfo) +{ + displayInfo = displayManagerService_.GetDefaultDisplayInfo(); + if (displayInfo == nullptr) { + return ERR_INVALID_DATA; + } + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetDisplayInfoById(uint64_t displayId, sptr& displayInfo) +{ + displayInfo = displayManagerService_.GetDisplayInfoById(displayId); + if (displayInfo == nullptr) { + return ERR_INVALID_DATA; + } + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetVisibleAreaDisplayInfoById(uint64_t displayId, sptr& displayInfo) +{ + displayInfo = displayManagerService_.GetVisibleAreaDisplayInfoById(displayId); + if (displayInfo == nullptr) { + return ERR_INVALID_DATA; + } + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetDisplayInfoByScreen(uint64_t screenId, sptr& displayInfo) +{ + displayInfo = displayManagerService_.GetDisplayInfoByScreen(screenId); + if (displayInfo == nullptr) { + return ERR_INVALID_DATA; + } + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::CreateVirtualScreen(const DmVirtualScreenOption& virtualOption, + const sptr& displayManagerAgent, uint64_t& screenId) +{ + screenId = displayManagerService_.CreateVirtualScreen(virtualOption.GetOption(), displayManagerAgent); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::CreateVirtualScreen(const DmVirtualScreenOption& virtualOption, + const sptr& displayManagerAgent, uint64_t& screenId, + const sptr& surface) +{ + VirtualScreenOption option = virtualOption.GetOption(); + sptr surfaceCopy = surface; + option.surface_ = Surface::CreateSurfaceAsProducer(surfaceCopy); + screenId = displayManagerService_.CreateVirtualScreen(option, displayManagerAgent); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::DestroyVirtualScreen(uint64_t screenId, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.DestroyVirtualScreen(screenId)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetVirtualScreenSurface(uint64_t screenId, const sptr& surface, + int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.SetVirtualScreenSurface(screenId, surface)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetOrientation(uint64_t screenId, uint32_t orientation, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.SetOrientation(screenId, + static_cast(orientation))); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetDisplaySnapshot(uint64_t displayId, int32_t& errorCode, bool isUseDma, + bool isCaptureFullOfScreen, std::shared_ptr& pixelMap) +{ + DmErrorCode errorCodeOut = DmErrorCode::DM_OK; + pixelMap = displayManagerService_.GetDisplaySnapshot(displayId, &errorCodeOut, isUseDma, isCaptureFullOfScreen); + errorCode = static_cast(errorCodeOut); + if (pixelMap == nullptr) { + return ERR_INVALID_DATA; + } + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetScreenSupportedColorGamuts(uint64_t screenId, std::vector& colorGamuts, + int32_t& dmError) +{ + std::vector colorGamutsOut; + dmError = static_cast(displayManagerService_.GetScreenSupportedColorGamuts(screenId, colorGamutsOut)); + for (auto& colorGamut : colorGamutsOut) { + colorGamuts.push_back(static_cast(colorGamut)); + } + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetScreenColorGamut(uint64_t screenId, uint32_t& colorGamut, int32_t& dmError) +{ + ScreenColorGamut colorGamutOut; + dmError = static_cast(displayManagerService_.GetScreenColorGamut(screenId, colorGamutOut)); + colorGamut = static_cast(colorGamutOut); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetScreenColorGamut(uint64_t screenId, int32_t colorGamutIdx, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.SetScreenColorGamut(screenId, colorGamutIdx)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetScreenGamutMap(uint64_t screenId, uint32_t& gamutMap, int32_t& dmError) +{ + ScreenGamutMap gamutMapOut; + dmError = static_cast(displayManagerService_.GetScreenGamutMap(screenId, gamutMapOut)); + gamutMap = static_cast(gamutMapOut); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetScreenGamutMap(uint64_t screenId, uint32_t gamutMap, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.SetScreenGamutMap(screenId, + static_cast(gamutMap))); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetScreenColorTransform(uint64_t screenId) +{ + (void)displayManagerService_.SetScreenColorTransform(screenId); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::RegisterDisplayManagerAgent(const sptr& displayManagerAgent, + uint32_t type, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.RegisterDisplayManagerAgent(displayManagerAgent, + static_cast(type))); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, + uint32_t type, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.UnregisterDisplayManagerAgent(displayManagerAgent, + static_cast(type))); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::WakeUpBegin(uint32_t reason, bool& isSucc) +{ + isSucc = displayManagerService_.WakeUpBegin(static_cast(reason)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::WakeUpEnd(bool& isSucc) +{ + isSucc = displayManagerService_.WakeUpEnd(); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SuspendBegin(uint32_t reason, bool& isSucc) +{ + isSucc = displayManagerService_.SuspendBegin(static_cast(reason)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SuspendEnd(bool& isSucc) +{ + isSucc = displayManagerService_.SuspendEnd(); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetScreenPowerForAll(uint32_t screenPowerState, uint32_t reason, bool& isSucc) +{ + isSucc = displayManagerService_.SetScreenPowerForAll(static_cast(screenPowerState), + static_cast(reason)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetSpecifiedScreenPower(uint64_t screenId, uint32_t screenPowerState, uint32_t + reason, bool& isSucc) +{ + isSucc = displayManagerService_.SetSpecifiedScreenPower(screenId, static_cast(screenPowerState), + static_cast(reason)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetScreenPower(uint64_t dmsScreenId, uint32_t& screenPowerState) +{ + screenPowerState = static_cast(displayManagerService_.GetScreenPower(dmsScreenId)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetDisplayState(uint32_t displayState, bool& isSucc) +{ + isSucc = displayManagerService_.SetDisplayState(static_cast(displayState)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetDisplayState(uint64_t displayId, uint32_t& displayState) +{ + displayState = static_cast(displayManagerService_.GetDisplayState(displayId)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::TryToCancelScreenOff(bool& isSucc) +{ + isSucc = displayManagerService_.TryToCancelScreenOff(); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetAllDisplayIds(std::vector& displayIds) +{ + displayIds = displayManagerService_.GetAllDisplayIds(); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetCutoutInfo(uint64_t displayId, sptr& cutoutInfo) +{ + cutoutInfo = displayManagerService_.GetCutoutInfo(displayId); + if (cutoutInfo == nullptr) { + return ERR_INVALID_DATA; + } + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::AddSurfaceNodeToDisplay(uint64_t displayId, + const std::shared_ptr& dmRsSurfaceNode, int32_t& dmError) +{ + std::shared_ptr surfaceNode = dmRsSurfaceNode->GetSurfaceNode(); + dmError = static_cast(displayManagerService_.AddSurfaceNodeToDisplay(displayId, surfaceNode, true)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::RemoveSurfaceNodeFromDisplay(uint64_t displayId, + const std::shared_ptr& dmRsSurfaceNode, int32_t& dmError) +{ + std::shared_ptr surfaceNode = dmRsSurfaceNode->GetSurfaceNode(); + dmError = static_cast(displayManagerService_.RemoveSurfaceNodeFromDisplay(displayId, surfaceNode)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::HasPrivateWindow(uint64_t displayId, bool& hasPrivateWindow, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.HasPrivateWindow(displayId, hasPrivateWindow)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::NotifyDisplayEvent(uint32_t displayEvent) +{ + displayManagerService_.NotifyDisplayEvent(static_cast(displayEvent)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetFreeze(const std::vector& displayIds, bool isFreeze, bool& isSucc) +{ + isSucc = displayManagerService_.SetFreeze(displayIds, isFreeze); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::MakeMirror(uint64_t mainScreenId, const std::vector& mirrorScreenId, + uint64_t& screenGroupId, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.MakeMirror(mainScreenId, mirrorScreenId, screenGroupId)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::StopMirror(const std::vector& mirrorScreenIds, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.StopMirror(mirrorScreenIds)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetScreenInfoById(uint64_t screenId, sptr& screenInfo) +{ + screenInfo = displayManagerService_.GetScreenInfoById(screenId); + if (screenInfo == nullptr) { + return ERR_INVALID_DATA; + } + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetScreenGroupInfoById(uint64_t screenId, sptr& screenGroupInfo) +{ + screenGroupInfo = displayManagerService_.GetScreenGroupInfoById(screenId); + if (screenGroupInfo == nullptr) { + return ERR_INVALID_DATA; + } + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetAllScreenInfos(std::vector>& screenInfos, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.GetAllScreenInfos(screenInfos)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::MakeExpand(const std::vector& screenId, + const std::vector& startPoint, uint64_t& screenGroupId, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.MakeExpand(screenId, startPoint, screenGroupId)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::StopExpand(const std::vector& expandScreenIds, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.StopExpand(expandScreenIds)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::RemoveVirtualScreenFromGroup(const std::vector& screens) +{ + displayManagerService_.RemoveVirtualScreenFromGroup(screens); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetScreenActiveMode(uint64_t screenId, uint32_t modeId, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.SetScreenActiveMode(screenId, modeId)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetVirtualPixelRatio(uint64_t screenId, float virtualPixelRatio, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.SetVirtualPixelRatio(screenId, virtualPixelRatio)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetResolution(uint64_t screenId, uint32_t width, uint32_t height, + float virtualPixelRatio, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.SetResolution(screenId, width, height, virtualPixelRatio)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetDensityInCurResolution(uint64_t screenId, float& virtualPixelRatio, + int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.GetDensityInCurResolution(screenId, virtualPixelRatio)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::IsScreenRotationLocked(bool& isLocked, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.IsScreenRotationLocked(isLocked)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetScreenRotationLocked(bool isLocked, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.SetScreenRotationLocked(isLocked)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::SetScreenRotationLockedFromJs(bool isLocked, int32_t& dmError) +{ + dmError = static_cast(displayManagerService_.SetScreenRotationLockedFromJs(isLocked)); + return ERR_OK; +} + +ErrCode DisplayManagerIpcService::GetAllDisplayPhysicalResolution( + std::vector& displayPhysicalResolutions) +{ + displayPhysicalResolutions = displayManagerService_.GetAllDisplayPhysicalResolution(); + return ERR_OK; +} +} // namespace OHOS::Rosen diff --git a/dmserver/src/display_manager_proxy.cpp b/dmserver/src/display_manager_proxy.cpp deleted file mode 100644 index edca9e149f..0000000000 --- a/dmserver/src/display_manager_proxy.cpp +++ /dev/null @@ -1,1865 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "display_manager_proxy.h" - -#include -#include -#include -#include -#include "marshalling_helper.h" -#include "window_manager_hilog.h" - -namespace OHOS::Rosen { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerProxy"}; -} - -sptr DisplayManagerProxy::GetDefaultDisplayInfo() -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetDefaultDisplayInfo: remote is nullptr"); - return nullptr; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("GetDefaultDisplayInfo: WriteInterfaceToken failed"); - return nullptr; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO), - data, reply, option) != ERR_NONE) { - WLOGFW("GetDefaultDisplayInfo: SendRequest failed"); - return nullptr; - } - sptr info = reply.ReadParcelable(); - if (info == nullptr) { - WLOGFW("DisplayManagerProxy::GetDefaultDisplayInfo SendRequest nullptr."); - } - return info; -} - -sptr DisplayManagerProxy::GetDisplayInfoById(DisplayId displayId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetDisplayInfoById: remote is nullptr"); - return nullptr; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("GetDisplayInfoById: WriteInterfaceToken failed"); - return nullptr; - } - if (!data.WriteUint64(displayId)) { - WLOGFW("GetDisplayInfoById: WriteUint64 displayId failed"); - return nullptr; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID), - data, reply, option) != ERR_NONE) { - WLOGFW("GetDisplayInfoById: SendRequest failed"); - return nullptr; - } - - sptr info = reply.ReadParcelable(); - if (info == nullptr) { - WLOGFW("DisplayManagerProxy::GetDisplayInfoById SendRequest nullptr."); - return nullptr; - } - return info; -} - -sptr DisplayManagerProxy::GetVisibleAreaDisplayInfoById(DisplayId displayId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("remote is nullptr"); - return nullptr; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return nullptr; - } - if (!data.WriteUint64(displayId)) { - WLOGFW("WriteUint64 displayId failed"); - return nullptr; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_VISIBLE_AREA_DISPLAY_INFO_BY_ID), - data, reply, option) != ERR_NONE) { - WLOGFW("SendRequest failed"); - return nullptr; - } - - sptr info = reply.ReadParcelable(); - if (info == nullptr) { - WLOGFW("SendRequest nullptr."); - return nullptr; - } - return info; -} - -sptr DisplayManagerProxy::GetDisplayInfoByScreen(ScreenId screenId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("fail to get displayInfo by screenId: remote is null"); - return nullptr; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("fail to get displayInfo by screenId: WriteInterfaceToken failed"); - return nullptr; - } - if (!data.WriteUint64(screenId)) { - WLOGFW("fail to get displayInfo by screenId: WriteUint64 displayId failed"); - return nullptr; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN), - data, reply, option) != ERR_NONE) { - WLOGFW("fail to get displayInfo by screenId: SendRequest failed"); - return nullptr; - } - - sptr info = reply.ReadParcelable(); - if (info == nullptr) { - WLOGFW("fail to get displayInfo by screenId: SendRequest null"); - return nullptr; - } - return info; -} - -ScreenId DisplayManagerProxy::CreateVirtualScreen(VirtualScreenOption virtualOption, - const sptr& displayManagerAgent) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("CreateVirtualScreen: remote is nullptr"); - return SCREEN_ID_INVALID; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("CreateVirtualScreen: WriteInterfaceToken failed"); - return SCREEN_ID_INVALID; - } - bool res = data.WriteString(virtualOption.name_) && data.WriteUint32(virtualOption.width_) && - data.WriteUint32(virtualOption.height_) && data.WriteFloat(virtualOption.density_) && - data.WriteInt32(virtualOption.flags_) && data.WriteBool(virtualOption.isForShot_) && - data.WriteUInt64Vector(virtualOption.missionIds_); - if (virtualOption.surface_ != nullptr && virtualOption.surface_->GetProducer() != nullptr) { - res = res && - data.WriteBool(true) && - data.WriteRemoteObject(virtualOption.surface_->GetProducer()->AsObject()); - } else { - WLOGFW("CreateVirtualScreen: surface is nullptr"); - res = res && data.WriteBool(false); - } - if (displayManagerAgent != nullptr) { - res = res && - data.WriteRemoteObject(displayManagerAgent); - } - if (!res) { - WLOGFE("Write data failed"); - return SCREEN_ID_INVALID; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN), - data, reply, option) != ERR_NONE) { - WLOGFW("CreateVirtualScreen: SendRequest failed"); - return SCREEN_ID_INVALID; - } - - ScreenId screenId = static_cast(reply.ReadUint64()); - WLOGFI("CreateVirtualScreen %" PRIu64"", screenId); - return screenId; -} - -DMError DisplayManagerProxy::DestroyVirtualScreen(ScreenId screenId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("DestroyVirtualScreen: remote is nullptr"); - return DMError::DM_ERROR_REMOTE_CREATE_FAILED; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("DestroyVirtualScreen: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("DestroyVirtualScreen: WriteUint64 screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN), - data, reply, option) != ERR_NONE) { - WLOGFW("DestroyVirtualScreen: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::SetVirtualScreenSurface(ScreenId screenId, sptr surface) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("SetVirtualScreenSurface: remote is nullptr"); - return DMError::DM_ERROR_REMOTE_CREATE_FAILED; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("SetVirtualScreenSurface: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - bool res = data.WriteUint64(static_cast(screenId)); - if (surface != nullptr) { - res = res && - data.WriteBool(true) && - data.WriteRemoteObject(surface->AsObject()); - } else { - WLOGFW("SetVirtualScreenSurface: surface is nullptr"); - res = res && data.WriteBool(false); - } - if (!res) { - WLOGFW("SetVirtualScreenSurface: Write screenId/surface failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE), - data, reply, option) != ERR_NONE) { - WLOGFW("SetVirtualScreenSurface: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::SetOrientation(ScreenId screenId, Orientation orientation) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("fail to set orientation: remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("fail to set orientation: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("fail to set orientation: Write screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (!data.WriteUint32(static_cast(orientation))) { - WLOGFW("fail to set orientation: Write orientation failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_ORIENTATION), - data, reply, option) != ERR_NONE) { - WLOGFW("fail to set orientation: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -std::shared_ptr DisplayManagerProxy::GetDisplaySnapshot(DisplayId displayId, - DmErrorCode* errorCode, bool isUseDma, bool isCaptureFullOfScreen) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetDisplaySnapshot: remote is nullptr"); - return nullptr; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("GetDisplaySnapshot: WriteInterfaceToken failed"); - return nullptr; - } - - if (!data.WriteUint64(displayId)) { - WLOGFE("Write displayId failed"); - return nullptr; - } - - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT), - data, reply, option) != ERR_NONE) { - WLOGFW("GetDisplaySnapshot: SendRequest failed"); - return nullptr; - } - - std::shared_ptr pixelMap(reply.ReadParcelable()); - DmErrorCode replyErrorCode = static_cast(reply.ReadInt32()); - if (errorCode) { - *errorCode = replyErrorCode; - } - if (pixelMap == nullptr) { - WLOGFW("DisplayManagerProxy::GetDisplaySnapshot SendRequest nullptr."); - return nullptr; - } - return pixelMap; -} - -DMError DisplayManagerProxy::GetScreenSupportedColorGamuts(ScreenId screenId, - std::vector& colorGamuts) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: WriteUint64 screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS), - data, reply, option) != ERR_NONE) { - WLOGFW("DisplayManagerProxy::GetScreenSupportedColorGamuts: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - if (ret != DMError::DM_OK) { - return ret; - } - MarshallingHelper::UnmarshallingVectorObj(reply, colorGamuts, - [](Parcel& parcel, ScreenColorGamut& color) { - uint32_t value; - bool res = parcel.ReadUint32(value); - color = static_cast(value); - return res; - } - ); - return ret; -} - -DMError DisplayManagerProxy::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("DisplayManagerProxy::GetScreenColorGamut: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("DisplayManagerProxy::GetScreenColorGamut: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("DisplayManagerProxy::GetScreenColorGamut: WriteUint64 uint64_t failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT), - data, reply, option) != ERR_NONE) { - WLOGFW("DisplayManagerProxy::GetScreenColorGamut: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - if (ret != DMError::DM_OK) { - return ret; - } - colorGamut = static_cast(reply.ReadUint32()); - return ret; -} - -DMError DisplayManagerProxy::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("DisplayManagerProxy::SetScreenColorGamut: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("DisplayManagerProxy::SetScreenColorGamut: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId)) || !data.WriteInt32(colorGamutIdx)) { - WLOGFW("DisplayManagerProxy::SetScreenColorGamut: Write failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT), - data, reply, option) != ERR_NONE) { - WLOGFW("DisplayManagerProxy::SetScreenColorGamut: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("DisplayManagerProxy::GetScreenGamutMap: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("DisplayManagerProxy::GetScreenGamutMap: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("DisplayManagerProxy::GetScreenGamutMap: WriteUint64 screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP), - data, reply, option) != ERR_NONE) { - WLOGFW("DisplayManagerProxy::GetScreenGamutMap: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - if (ret != DMError::DM_OK) { - return ret; - } - gamutMap = static_cast(reply.ReadUint32()); - return ret; -} - -DMError DisplayManagerProxy::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("DisplayManagerProxy::SetScreenGamutMap: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("DisplayManagerProxy::SetScreenGamutMap: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId)) || !data.WriteUint32(static_cast(gamutMap))) { - WLOGFW("DisplayManagerProxy::SetScreenGamutMap: Writ failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP), - data, reply, option) != ERR_NONE) { - WLOGFW("DisplayManagerProxy::SetScreenGamutMap: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::SetScreenColorTransform(ScreenId screenId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("DisplayManagerProxy::SetScreenColorTransform: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("DisplayManagerProxy::SetScreenColorTransform: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("DisplayManagerProxy::SetScreenColorTransform: WriteUint64 screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM), - data, reply, option) != ERR_NONE) { - WLOGFW("DisplayManagerProxy::SetScreenColorTransform: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetPixelFormat: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("GetPixelFormat: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("GetPixelFormat: WriteUint64 uint64_t failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_PIXEL_FORMAT), - data, reply, option) != ERR_NONE) { - WLOGFW("GetPixelFormat: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - if (ret != DMError::DM_OK) { - return ret; - } - pixelFormat = static_cast(reply.ReadUint32()); - return ret; -} - -DMError DisplayManagerProxy::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("SetPixelFormat: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("SetPixelFormat: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId)) || !data.WriteInt32(pixelFormat)) { - WLOGFW("SetPixelFormat: WriteUint64 screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_SET_PIXEL_FORMAT), - data, reply, option) != ERR_NONE) { - WLOGFW("SetPixelFormat: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::GetSupportedHDRFormats(ScreenId screenId, std::vector& hdrFormats) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetSupportedHDRFormats: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("GetSupportedHDRFormats: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("GetSupportedHDRFormats: WriteUint64 screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_HDR_FORMAT), - data, reply, option) != ERR_NONE) { - WLOGFW("GetSupportedHDRFormats: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - if (ret != DMError::DM_OK) { - return ret; - } - MarshallingHelper::UnmarshallingVectorObj(reply, hdrFormats, - [](Parcel& parcel, ScreenHDRFormat& hdrFormat) { - uint32_t value; - bool res = parcel.ReadUint32(value); - hdrFormat = static_cast(value); - return res; - } - ); - return ret; -} - -DMError DisplayManagerProxy::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetScreenHDRFormat: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("GetScreenHDRFormat: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("GetScreenHDRFormat: WriteUint64 uint64_t failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_HDR_FORMAT), - data, reply, option) != ERR_NONE) { - WLOGFW("GetScreenHDRFormat: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - if (ret != DMError::DM_OK) { - return ret; - } - hdrFormat = static_cast(reply.ReadUint32()); - return ret; -} - -DMError DisplayManagerProxy::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("SetScreenHDRFormat: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("SetScreenHDRFormat: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId)) || !data.WriteInt32(modeIdx)) { - WLOGFW("SetScreenHDRFormat: WriteUint64 screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_SET_HDR_FORMAT), - data, reply, option) != ERR_NONE) { - WLOGFW("SetScreenHDRFormat: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::GetSupportedColorSpaces(ScreenId screenId, - std::vector& colorSpaces) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetSupportedColorSpaces: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("GetSupportedColorSpaces: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("GetSupportedColorSpaces: WriteUint64 screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_SPACE), - data, reply, option) != ERR_NONE) { - WLOGFW("GetSupportedColorSpaces: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - if (ret != DMError::DM_OK) { - return ret; - } - MarshallingHelper::UnmarshallingVectorObj(reply, colorSpaces, - [](Parcel& parcel, GraphicCM_ColorSpaceType& color) { - uint32_t value; - bool res = parcel.ReadUint32(value); - color = static_cast(value); - return res; - } - ); - return ret; -} - -DMError DisplayManagerProxy::GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetScreenColorSpace: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("GetScreenColorSpace: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFW("GetScreenColorSpace: WriteUint64 screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_SPACE), - data, reply, option) != ERR_NONE) { - WLOGFW("GetScreenColorSpace: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - if (ret != DMError::DM_OK) { - return ret; - } - colorSpace = static_cast(reply.ReadUint32()); - return ret; -} - -DMError DisplayManagerProxy::SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("SetScreenColorSpace: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFW("SetScreenColorSpace: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId)) || !data.WriteInt32(colorSpace)) { - WLOGFW("SetScreenColorSpace: Write failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_SPACE), - data, reply, option) != ERR_NONE) { - WLOGFW("SetScreenColorSpace: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::RegisterDisplayManagerAgent(const sptr& displayManagerAgent, - DisplayManagerAgentType type) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("RegisterDisplayManagerAgent: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - - if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) { - WLOGFE("Write IDisplayManagerAgent failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - - if (!data.WriteUint32(static_cast(type))) { - WLOGFE("Write DisplayManagerAgent type failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT), - data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, - DisplayManagerAgentType type) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("UnregisterDisplayManagerAgent: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - - if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) { - WLOGFE("Write IWindowManagerAgent failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - - if (!data.WriteUint32(static_cast(type))) { - WLOGFE("Write DisplayManagerAgent type failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT), - data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -bool DisplayManagerProxy::WakeUpBegin(PowerStateChangeReason reason) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("[UL_POWER]WakeUpBegin: remote is nullptr"); - return false; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("[UL_POWER]WriteInterfaceToken failed"); - return false; - } - if (!data.WriteUint32(static_cast(reason))) { - WLOGFE("[UL_POWER]Write PowerStateChangeReason failed"); - return false; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN), - data, reply, option) != ERR_NONE) { - WLOGFW("[UL_POWER]SendRequest failed"); - return false; - } - return reply.ReadBool(); -} - -bool DisplayManagerProxy::WakeUpEnd() -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("[UL_POWER]WakeUpEnd: remote is nullptr"); - return false; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("[UL_POWER]WriteInterfaceToken failed"); - return false; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_WAKE_UP_END), - data, reply, option) != ERR_NONE) { - WLOGFW("[UL_POWER]SendRequest failed"); - return false; - } - return reply.ReadBool(); -} - -bool DisplayManagerProxy::SuspendBegin(PowerStateChangeReason reason) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("[UL_POWER]SuspendBegin: remote is nullptr"); - return false; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("[UL_POWER]WriteInterfaceToken failed"); - return false; - } - if (!data.WriteUint32(static_cast(reason))) { - WLOGFE("[UL_POWER]Write PowerStateChangeReason failed"); - return false; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN), - data, reply, option) != ERR_NONE) { - WLOGFW("[UL_POWER]SendRequest failed"); - return false; - } - return reply.ReadBool(); -} - -bool DisplayManagerProxy::SuspendEnd() -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("[UL_POWER]SuspendEnd: remote is nullptr"); - return false; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("[UL_POWER]WriteInterfaceToken failed"); - return false; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SUSPEND_END), - data, reply, option) != ERR_NONE) { - WLOGFW("[UL_POWER]SendRequest failed"); - return false; - } - return reply.ReadBool(); -} - -bool DisplayManagerProxy::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("[UL_POWER]SetScreenPowerForAll: remote is nullptr"); - return false; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("[UL_POWER]WriteInterfaceToken failed"); - return false; - } - if (!data.WriteUint32(static_cast(state))) { - WLOGFE("[UL_POWER]Write ScreenPowerState failed"); - return false; - } - if (!data.WriteUint32(static_cast(reason))) { - WLOGFE("[UL_POWER]Write PowerStateChangeReason failed"); - return false; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL), - data, reply, option) != ERR_NONE) { - WLOGFW("[UL_POWER]SendRequest failed"); - return false; - } - return reply.ReadBool(); -} - -bool DisplayManagerProxy::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, - PowerStateChangeReason reason) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("[UL_POWER]SetSpecifiedScreenPower: remote is nullptr"); - return false; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("[UL_POWER]WriteInterfaceToken failed"); - return false; - } - if (!data.WriteUint32(static_cast(screenId))) { - WLOGFE("[UL_POWER]Write ScreenId failed"); - return false; - } - if (!data.WriteUint32(static_cast(state))) { - WLOGFE("[UL_POWER]Write ScreenPowerState failed"); - return false; - } - if (!data.WriteUint32(static_cast(reason))) { - WLOGFE("[UL_POWER]Write PowerStateChangeReason failed"); - return false; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER), - data, reply, option) != ERR_NONE) { - WLOGFW("[UL_POWER]SendRequest failed"); - return false; - } - return reply.ReadBool(); -} - -ScreenPowerState DisplayManagerProxy::GetScreenPower(ScreenId dmsScreenId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetScreenPower: remote is nullptr"); - return ScreenPowerState::INVALID_STATE; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return ScreenPowerState::INVALID_STATE; - } - if (!data.WriteUint64(static_cast(dmsScreenId))) { - WLOGFE("Write dmsScreenId failed"); - return ScreenPowerState::INVALID_STATE; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER), - data, reply, option) != ERR_NONE) { - WLOGFW("SendRequest failed"); - return ScreenPowerState::INVALID_STATE; - } - return static_cast(reply.ReadUint32()); -} - -bool DisplayManagerProxy::SetDisplayState(DisplayState state) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("[UL_POWER]SetDisplayState: remote is nullptr"); - return false; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("[UL_POWER]WriteInterfaceToken failed"); - return false; - } - if (!data.WriteUint32(static_cast(state))) { - WLOGFE("[UL_POWER]Write DisplayState failed"); - return false; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE), - data, reply, option) != ERR_NONE) { - WLOGFW("[UL_POWER]SendRequest failed"); - return false; - } - return reply.ReadBool(); -} - -DisplayState DisplayManagerProxy::GetDisplayState(DisplayId displayId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetDisplayState: remote is nullptr"); - return DisplayState::UNKNOWN; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DisplayState::UNKNOWN; - } - if (!data.WriteUint64(displayId)) { - WLOGFE("Write displayId failed"); - return DisplayState::UNKNOWN; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE), - data, reply, option) != ERR_NONE) { - WLOGFW("SendRequest failed"); - return DisplayState::UNKNOWN; - } - return static_cast(reply.ReadUint32()); -} - -bool DisplayManagerProxy::TryToCancelScreenOff() -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("[UL_POWER]TryToCancelScreenOff: remote is nullptr"); - return false; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("[UL_POWER]WriteInterfaceToken failed"); - return false; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_TRY_TO_CANCEL_SCREEN_OFF), - data, reply, option) != ERR_NONE) { - WLOGFW("[UL_POWER]SendRequest failed"); - return false; - } - return reply.ReadBool(); -} - -std::vector DisplayManagerProxy::GetAllDisplayIds() -{ - std::vector allDisplayIds; - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetAllDisplayIds: remote is nullptr"); - return allDisplayIds; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return allDisplayIds; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS), - data, reply, option) != ERR_NONE) { - WLOGFW("SendRequest failed"); - return allDisplayIds; - } - reply.ReadUInt64Vector(&allDisplayIds); - return allDisplayIds; -} - -sptr DisplayManagerProxy::GetCutoutInfo(DisplayId displayId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetCutoutInfo: remote is null"); - return nullptr; - } - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("GetCutoutInfo: GetCutoutInfo failed"); - return nullptr; - } - if (!data.WriteUint64(displayId)) { - WLOGFE("GetCutoutInfo: write displayId failed"); - return nullptr; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_CUTOUT_INFO), - data, reply, option) != ERR_NONE) { - WLOGFW("GetCutoutInfo: GetCutoutInfo failed"); - return nullptr; - } - sptr info = reply.ReadParcelable(); - return info; -} - -DMError DisplayManagerProxy::AddSurfaceNodeToDisplay(DisplayId displayId, - std::shared_ptr& surfaceNode, bool onTop) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("AddSurfaceNodeToDisplay: remote is nullptr"); - return DMError::DM_ERROR_IPC_FAILED; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (!data.WriteUint64(displayId)) { - WLOGFE("write displayId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (surfaceNode == nullptr || !surfaceNode->Marshalling(data)) { - WLOGFE("Write windowProperty failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_ADD_SURFACE_NODE), - data, reply, option) != ERR_NONE) { - WLOGFW("Send request failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadUint32()); - return ret; -} - -DMError DisplayManagerProxy::RemoveSurfaceNodeFromDisplay(DisplayId displayId, - std::shared_ptr& surfaceNode) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("RemoveSurfaceNodeFromDisplay: remote is nullptr"); - return DMError::DM_ERROR_IPC_FAILED; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (!data.WriteUint64(displayId)) { - WLOGFE("write displayId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (surfaceNode == nullptr || !surfaceNode->Marshalling(data)) { - WLOGFE("Write windowProperty failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_REMOVE_SURFACE_NODE), - data, reply, option) != ERR_NONE) { - WLOGFW("Send request failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadUint32()); - return ret; -} - -DMError DisplayManagerProxy::HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("HasPrivateWindow: remote is nullptr"); - return DMError::DM_ERROR_IPC_FAILED; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - return DMError::DM_ERROR_IPC_FAILED; - } - - if (!data.WriteUint64(displayId)) { - return DMError::DM_ERROR_IPC_FAILED; - } - - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_HAS_PRIVATE_WINDOW), - data, reply, option) != ERR_NONE) { - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - hasPrivateWindow = reply.ReadBool(); - return ret; -} - -void DisplayManagerProxy::NotifyDisplayEvent(DisplayEvent event) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("NotifyDisplayEvent: remote is nullptr"); - return; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("[UL_POWER]WriteInterfaceToken failed"); - return; - } - if (!data.WriteUint32(static_cast(event))) { - WLOGFE("[UL_POWER]Write DisplayEvent failed"); - return; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT), - data, reply, option) != ERR_NONE) { - WLOGFW("[UL_POWER]SendRequest failed"); - return; - } -} - -bool DisplayManagerProxy::SetFreeze(std::vector displayIds, bool isFreeze) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("SetFreeze: remote is nullptr"); - return false; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return false; - } - if (!data.WriteUInt64Vector(displayIds)) { - WLOGFE("set freeze fail: write displayId failed."); - return false; - } - if (!data.WriteBool(isFreeze)) { - WLOGFE("set freeze fail: write freeze flag failed."); - return false; - } - - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_FREEZE_EVENT), - data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); - return false; - } - return true; -} - -DMError DisplayManagerProxy::MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenId, - ScreenId& screenGroupId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("create mirror fail: remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("create mirror fail: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - bool res = data.WriteUint64(static_cast(mainScreenId)) && - data.WriteUInt64Vector(mirrorScreenId); - if (!res) { - WLOGFE("create mirror fail: data write failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR), - data, reply, option) != ERR_NONE) { - WLOGFW("create mirror fail: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - screenGroupId = static_cast(reply.ReadUint64()); - return ret; -} - -DMError DisplayManagerProxy::StopMirror(const std::vector& mirrorScreenIds) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("StopMirror fail: remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("StopMirror fail: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - bool res = data.WriteUInt64Vector(mirrorScreenIds); - if (!res) { - WLOGFE("StopMirror fail: data write failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_STOP_MIRROR), - data, reply, option) != ERR_NONE) { - WLOGFW("StopMirror fail: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -sptr DisplayManagerProxy::GetScreenInfoById(ScreenId screenId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetScreenInfoById: remote is nullptr"); - return nullptr; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("GetScreenInfoById: WriteInterfaceToken failed"); - return nullptr; - } - if (!data.WriteUint64(screenId)) { - WLOGFE("GetScreenInfoById: Write screenId failed"); - return nullptr; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID), - data, reply, option) != ERR_NONE) { - WLOGFW("GetScreenInfoById: SendRequest failed"); - return nullptr; - } - - sptr info = reply.ReadStrongParcelable(); - if (info == nullptr) { - WLOGFW("GetScreenInfoById SendRequest nullptr."); - return nullptr; - } - for (auto& mode : info->GetModes()) { - WLOGFI("info modes is id: %{public}u, width: %{public}u, height: %{public}u, refreshRate: %{public}u", - mode->id_, mode->width_, mode->height_, mode->refreshRate_); - } - return info; -} - -sptr DisplayManagerProxy::GetScreenGroupInfoById(ScreenId screenId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetScreenGroupInfoById: remote is nullptr"); - return nullptr; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("GetScreenGroupInfoById: WriteInterfaceToken failed"); - return nullptr; - } - if (!data.WriteUint64(screenId)) { - WLOGFE("GetScreenGroupInfoById: Write screenId failed"); - return nullptr; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID), - data, reply, option) != ERR_NONE) { - WLOGFW("GetScreenGroupInfoById: SendRequest failed"); - return nullptr; - } - - sptr info = reply.ReadStrongParcelable(); - if (info == nullptr) { - WLOGFW("GetScreenGroupInfoById SendRequest nullptr."); - return nullptr; - } - return info; -} - -DMError DisplayManagerProxy::GetAllScreenInfos(std::vector>& screenInfos) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetAllScreenInfos: remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("GetAllScreenInfos: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS), - data, reply, option) != ERR_NONE) { - WLOGFW("GetAllScreenInfos: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - static_cast(MarshallingHelper::UnmarshallingVectorParcelableObj(reply, screenInfos)); - return ret; -} - -DMError DisplayManagerProxy::MakeExpand(std::vector screenId, std::vector startPoint, - ScreenId& screenGroupId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("MakeExpand: remote is null"); - return DMError::DM_ERROR_IPC_FAILED; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("MakeExpand: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUInt64Vector(screenId)) { - WLOGFE("MakeExpand: write screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (!MarshallingHelper::MarshallingVectorObj(data, startPoint, [](Parcel& parcel, const Point& point) { - return parcel.WriteInt32(point.posX_) && parcel.WriteInt32(point.posY_); - })) { - WLOGFE("MakeExpand: write startPoint failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND), - data, reply, option) != ERR_NONE) { - WLOGFE("MakeExpand: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - screenGroupId = static_cast(reply.ReadUint64()); - return ret; -} - -DMError DisplayManagerProxy::StopExpand(const std::vector& expandScreenIds) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("StopExpand fail: remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("StopExpand fail: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - bool res = data.WriteUInt64Vector(expandScreenIds); - if (!res) { - WLOGFE("StopExpand fail: data write failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SCREEN_STOP_EXPAND), - data, reply, option) != ERR_NONE) { - WLOGFW("StopExpand fail: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -void DisplayManagerProxy::RemoveVirtualScreenFromGroup(std::vector screens) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("cancel make mirror or expand fail: remote is null"); - return; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("cancel make mirror or expand fail: WriteInterfaceToken failed"); - return; - } - bool res = data.WriteUInt64Vector(screens); - if (!res) { - WLOGFE("cancel make mirror or expand fail: write screens failed."); - return; - } - if (remote->SendRequest(static_cast( - DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP), - data, reply, option) != ERR_NONE) { - WLOGFW("cancel make mirror or expand fail: SendRequest failed"); - } -} - -DMError DisplayManagerProxy::SetScreenActiveMode(ScreenId screenId, uint32_t modeId) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("SetScreenActiveMode: remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("SetScreenActiveMode: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(screenId) || !data.WriteUint32(modeId)) { - WLOGFE("SetScreenActiveMode: write screenId/modeId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE), - data, reply, option) != ERR_NONE) { - WLOGFE("SetScreenActiveMode: SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("SetVirtualPixelRatio: remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(screenId) || !data.WriteFloat(virtualPixelRatio)) { - WLOGFE("write screenId/modeId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO), - data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("SetResolution: remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(screenId) || !data.WriteUint32(width) || - !data.WriteUint32(height) || !data.WriteFloat(virtualPixelRatio)) { - WLOGFE("write screenId/width/height/virtualPixelRatio failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_RESOLUTION), - data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("GetDensityInCurResolution: remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(screenId)) { - WLOGFE("write screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DENSITY_IN_CURRENT_RESOLUTION), - data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - virtualPixelRatio = reply.ReadFloat(); - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::IsScreenRotationLocked(bool& isLocked) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("remote is nullptr"); - return DMError::DM_ERROR_NULLPTR; - } - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED), - data, reply, option) != ERR_NONE) { - WLOGFW("SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - DMError ret = static_cast(reply.ReadInt32()); - isLocked = reply.ReadBool(); - return ret; -} - -DMError DisplayManagerProxy::SetScreenRotationLocked(bool isLocked) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteBool(isLocked)) { - WLOGFE("write isLocked failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED), - data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::SetScreenRotationLockedFromJs(bool isLocked) -{ - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteBool(isLocked)) { - WLOGFE("write isLocked failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS), - data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) -{ - WLOGFI("DisplayManagerProxy::ResizeVirtualScreen: ENTER"); - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("DisplayManagerProxy::ResizeVirtualScreen: remote is nullptr"); - return DMError::DM_ERROR_REMOTE_CREATE_FAILED; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("DisplayManagerProxy::ResizeVirtualScreen: WriteInterfaceToken failed"); - return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; - } - if (!data.WriteUint64(static_cast(screenId))) { - WLOGFE("DisplayManagerProxy::ResizeVirtualScreen: WriteUnit64 screenId failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (!data.WriteUint32(width)) { - WLOGFE("DisplayManagerProxy::ResizeVirtualScreen: WriteUnit32 width failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (!data.WriteUint32(height)) { - WLOGFE("DisplayManagerProxy::ResizeVirtualScreen: WriteUnit32 height failed"); - return DMError::DM_ERROR_IPC_FAILED; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_RESIZE_VIRTUAL_SCREEN), - data, reply, option) != ERR_NONE) { - WLOGFE("DisplayManagerProxy::ResizeVirtualScreen fail: SendRequest failed"); - return DMError::DM_ERROR_NULLPTR; - } - return static_cast(reply.ReadInt32()); -} - -DMError DisplayManagerProxy::MakeUniqueScreen(const std::vector& screenIds, - std::vector& displayIds) -{ - WLOGFI("DisplayManagerProxy::MakeUniqueScreen"); - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFW("make unique screen failed: remote is null"); - return DMError::DM_ERROR_NULLPTR; - } - - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("MakeUniqueScreen writeInterfaceToken failed"); - return DMError::DM_ERROR_NULLPTR; - } - if (!data.WriteUint32(screenIds.size())) { - WLOGFE("MakeUniqueScreen write screenIds size failed"); - return DMError::DM_ERROR_INVALID_PARAM; - } - bool res = data.WriteUInt64Vector(screenIds); - if (!res) { - WLOGFE("MakeUniqueScreen fail: write screens failed"); - return DMError::DM_ERROR_NULLPTR; - } - if (remote->SendRequest( - static_cast(DisplayManagerMessage::TRANS_ID_SCENE_BOARD_MAKE_UNIQUE_SCREEN), - data, reply, option) != ERR_NONE) { - WLOGFE("MakeUniqueScreen fail: SendRequest failed"); - return DMError::DM_ERROR_NULLPTR; - } - reply.ReadUInt64Vector(&displayIds); - return static_cast(reply.ReadInt32()); -} - -std::vector DisplayManagerProxy::GetAllDisplayPhysicalResolution() -{ - sptr remote = Remote(); - if (remote == nullptr) { - TLOGE(WmsLogTag::DMS, "remote is nullptr"); - return std::vector {}; - } - MessageOption option; - MessageParcel reply; - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed"); - return std::vector {}; - } - if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_ALL_PHYSICAL_DISPLAY_RESOLUTION), - data, reply, option) != ERR_NONE) { - TLOGE(WmsLogTag::DMS, "SendRequest failed"); - return std::vector {}; - } - std::vector allPhysicalSize; - int32_t displayInfoSize = 0; - bool readRet = reply.ReadInt32(displayInfoSize); - if (!readRet || displayInfoSize <= 0) { - TLOGE(WmsLogTag::DMS, "read failed"); - return std::vector {}; - } - for (int32_t i = 0; i < displayInfoSize; i++) { - DisplayPhysicalResolution physicalItem; - physicalItem.foldDisplayMode_ = static_cast(reply.ReadUint32()); - physicalItem.physicalWidth_ = reply.ReadUint32(); - physicalItem.physicalHeight_ = reply.ReadUint32(); - allPhysicalSize.emplace_back(physicalItem); - } - return allPhysicalSize; -} -} // namespace OHOS::Rosen \ No newline at end of file diff --git a/dmserver/src/display_manager_service.cpp b/dmserver/src/display_manager_service.cpp index f5446473c3..166dd7ac72 100644 --- a/dmserver/src/display_manager_service.cpp +++ b/dmserver/src/display_manager_service.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,11 +15,9 @@ #include "display_manager_service.h" -#include #include #include #include -#include "scene_board_judgement.h" #include #include "display_manager_agent_controller.h" @@ -33,24 +31,21 @@ namespace OHOS::Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerService"}; const std::string SCREEN_CAPTURE_PERMISSION = "ohos.permission.CAPTURE_SCREEN"; const std::string ACCESS_VIRTUAL_SCREEN_PERMISSION = "ohos.permission.ACCESS_VIRTUAL_SCREEN"; } WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManagerService) -const bool REGISTER_RESULT = SceneBoardJudgement::IsSceneBoardEnabled() ? false : - SystemAbility::MakeAndRegisterAbility(&SingletonContainer::Get()); #define CHECK_SCREEN_AND_RETURN(screenId, ret) \ do { \ if ((screenId) == SCREEN_ID_INVALID) { \ - WLOGFE("screenId invalid"); \ + TLOGE(WmsLogTag::DMS, "screenId invalid"); \ return ret; \ } \ } while (false) -DisplayManagerService::DisplayManagerService() : SystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID, true), - abstractDisplayController_(new AbstractDisplayController(mutex_, +DisplayManagerService::DisplayManagerService() + : abstractDisplayController_(new AbstractDisplayController(mutex_, std::bind(&DisplayManagerService::NotifyDisplayStateChange, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4))), abstractScreenController_(new AbstractScreenController(mutex_)), @@ -71,32 +66,16 @@ int DisplayManagerService::Dump(int fd, const std::vector& args) return static_cast(displayDumper_->Dump(fd, args)); } -void DisplayManagerService::OnStart() -{ - WLOGFI("start"); - if (!Init()) { - WLOGFE("Init failed"); - return; - } - sptr dms = this; - dms->IncStrongRef(nullptr); - if (!Publish(sptr(this))) { - WLOGFE("Publish failed"); - } - SetDisplayState(DisplayState::ON); - WLOGFI("end"); -} - bool DisplayManagerService::Init() { - WLOGFI("DisplayManagerService::Init start"); + TLOGI(WmsLogTag::DMS, "DisplayManagerService::Init start"); if (DisplayManagerConfig::LoadConfigXml()) { DisplayManagerConfig::DumpConfig(); ConfigureDisplayManagerService(); } abstractScreenController_->Init(); abstractDisplayController_->Init(abstractScreenController_); - WLOGFI("DisplayManagerService::Init success"); + TLOGI(WmsLogTag::DMS, "DisplayManagerService::Init success"); return true; } @@ -145,7 +124,7 @@ void DisplayManagerService::ConfigureWaterfallDisplayCompressionParams() void DisplayManagerService::RegisterDisplayChangeListener(sptr listener) { displayChangeListener_ = listener; - WLOGFD("IDisplayChangeListener registered"); + TLOGD(WmsLogTag::DMS, "IDisplayChangeListener registered"); } void DisplayManagerService::RegisterWindowInfoQueriedListener(const sptr& listener) @@ -156,13 +135,13 @@ void DisplayManagerService::RegisterWindowInfoQueriedListener(const sptr displayIds = GetAllDisplayIds(); auto iter = std::find(displayIds.begin(), displayIds.end(), displayId); if (iter == displayIds.end()) { - WLOGFE("invalid displayId"); + TLOGE(WmsLogTag::DMS, "invalid displayId"); return DMError::DM_ERROR_INVALID_PARAM; } if (windowInfoQueriedListener_ != nullptr) { @@ -176,7 +155,7 @@ void DisplayManagerService::NotifyDisplayStateChange(DisplayId defaultDisplayId, const std::map>& displayInfoMap, DisplayStateChangeType type) { DisplayId id = (displayInfo == nullptr) ? DISPLAY_ID_INVALID : displayInfo->GetDisplayId(); - WLOGFD("DisplayId %{public}" PRIu64"", id); + TLOGD(WmsLogTag::DMS, "DisplayId %{public}" PRIu64, id); if (displayChangeListener_ != nullptr) { displayChangeListener_->OnDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type); } @@ -192,10 +171,10 @@ void DisplayManagerService::NotifyScreenshot(DisplayId displayId) sptr DisplayManagerService::GetDefaultDisplayInfo() { ScreenId dmsScreenId = abstractScreenController_->GetDefaultAbstractScreenId(); - WLOGFD("GetDefaultDisplayInfo %{public}" PRIu64"", dmsScreenId); + TLOGD(WmsLogTag::DMS, "GetDefaultDisplayInfo %{public}" PRIu64, dmsScreenId); sptr display = abstractDisplayController_->GetAbstractDisplayByScreen(dmsScreenId); if (display == nullptr) { - WLOGFE("fail to get displayInfo by id: invalid display"); + TLOGE(WmsLogTag::DMS, "fail to get displayInfo by id: invalid display"); return nullptr; } return display->ConvertToDisplayInfo(); @@ -205,7 +184,7 @@ sptr DisplayManagerService::GetDisplayInfoById(DisplayId displayId) { sptr display = abstractDisplayController_->GetAbstractDisplay(displayId); if (display == nullptr) { - WLOGFE("fail to get displayInfo by id: invalid display"); + TLOGE(WmsLogTag::DMS, "fail to get displayInfo by id: invalid display"); return nullptr; } return display->ConvertToDisplayInfo(); @@ -215,7 +194,7 @@ sptr DisplayManagerService::GetVisibleAreaDisplayInfoById(DisplayId { sptr display = abstractDisplayController_->GetAbstractDisplay(displayId); if (display == nullptr) { - WLOGFE("fail to get displayInfo by id: invalid display"); + TLOGE(WmsLogTag::DMS, "fail to get displayInfo by id: invalid display"); return nullptr; } return display->ConvertToDisplayInfo(); @@ -225,7 +204,7 @@ sptr DisplayManagerService::GetDisplayInfoByScreen(ScreenId screenI { sptr display = abstractDisplayController_->GetAbstractDisplayByScreen(screenId); if (display == nullptr) { - WLOGFE("fail to get displayInfo by screenId: invalid display"); + TLOGE(WmsLogTag::DMS, "fail to get displayInfo by screenId: invalid display"); return nullptr; } return display->ConvertToDisplayInfo(); @@ -235,13 +214,13 @@ ScreenId DisplayManagerService::CreateVirtualScreen(VirtualScreenOption option, const sptr& displayManagerAgent) { if (displayManagerAgent == nullptr) { - WLOGFE("displayManagerAgent invalid"); + TLOGE(WmsLogTag::DMS, "displayManagerAgent invalid"); return SCREEN_ID_INVALID; } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:CreateVirtualScreen(%s)", option.name_.c_str()); if (option.surface_ != nullptr && !Permission::CheckCallingPermission(SCREEN_CAPTURE_PERMISSION) && !Permission::IsStartByHdcd() && !Permission::CheckCallingPermission(ACCESS_VIRTUAL_SCREEN_PERMISSION)) { - WLOGFE("permission denied"); + TLOGE(WmsLogTag::DMS, "permission denied"); return SCREEN_ID_INVALID; } ScreenId screenId = abstractScreenController_->CreateVirtualScreen(option, displayManagerAgent); @@ -255,7 +234,7 @@ DMError DisplayManagerService::DestroyVirtualScreen(ScreenId screenId) bool isCallingByThirdParty = Permission::CheckCallingPermission(ACCESS_VIRTUAL_SCREEN_PERMISSION); if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd() && !isCallingByThirdParty) { - WLOGFE("destory virtual screen permission denied!"); + TLOGE(WmsLogTag::DMS, "destroy virtual screen permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } if (!accessTokenIdMaps_.isExistAndRemove(screenId, IPCSkeleton::GetCallingTokenID())) { @@ -265,16 +244,16 @@ DMError DisplayManagerService::DestroyVirtualScreen(ScreenId screenId) return DMError::DM_ERROR_INVALID_CALLING; } - WLOGFI("DestroyVirtualScreen::ScreenId: %{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "DestroyVirtualScreen::ScreenId: %{public}" PRIu64, screenId); CHECK_SCREEN_AND_RETURN(screenId, DMError::DM_ERROR_INVALID_PARAM); - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:DestroyVirtualScreen(%" PRIu64")", screenId); + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:DestroyVirtualScreen(%" PRIu64 ")", screenId); return abstractScreenController_->DestroyVirtualScreen(screenId); } DMError DisplayManagerService::SetVirtualScreenSurface(ScreenId screenId, sptr surface) { - WLOGFI("SetVirtualScreenSurface::ScreenId: %{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "SetVirtualScreenSurface::ScreenId: %{public}" PRIu64, screenId); bool isCallingByThirdParty = Permission::CheckCallingPermission(ACCESS_VIRTUAL_SCREEN_PERMISSION); CHECK_SCREEN_AND_RETURN(screenId, DMError::DM_ERROR_INVALID_PARAM); if (Permission::CheckCallingPermission(SCREEN_CAPTURE_PERMISSION) || @@ -282,7 +261,7 @@ DMError DisplayManagerService::SetVirtualScreenSurface(ScreenId screenId, sptr pPurface = Surface::CreateSurfaceAsProducer(surface); return abstractScreenController_->SetVirtualScreenSurface(screenId, pPurface); } - WLOGFE("permission denied"); + TLOGE(WmsLogTag::DMS, "permission denied"); if (isCallingByThirdParty) { return DMError::DM_ERROR_NULLPTR; } @@ -292,33 +271,33 @@ DMError DisplayManagerService::SetVirtualScreenSurface(ScreenId screenId, sptr Orientation::REVERSE_HORIZONTAL) { - WLOGFE("SetOrientation::orientation: %{public}u", static_cast(orientation)); + TLOGE(WmsLogTag::DMS, "SetOrientation::orientation: %{public}u", static_cast(orientation)); return DMError::DM_ERROR_INVALID_PARAM; } - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetOrientation(%" PRIu64")", screenId); + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetOrientation(%" PRIu64 ")", screenId); return abstractScreenController_->SetOrientation(screenId, orientation, false); } DMError DisplayManagerService::SetOrientationFromWindow(ScreenId screenId, Orientation orientation, bool withAnimation) { - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetOrientationFromWindow(%" PRIu64")", screenId); + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetOrientationFromWindow(%" PRIu64 ")", screenId); return abstractScreenController_->SetOrientation(screenId, orientation, true, withAnimation); } bool DisplayManagerService::SetRotationFromWindow(ScreenId screenId, Rotation targetRotation, bool withAnimation) { - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetRotationFromWindow(%" PRIu64")", screenId); + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetRotationFromWindow(%" PRIu64 ")", screenId); return abstractScreenController_->SetRotation(screenId, targetRotation, true, withAnimation); } std::shared_ptr DisplayManagerService::GetDisplaySnapshot(DisplayId displayId, DmErrorCode* errorCode, bool isUseDma, bool isCaptureFullOfScreen) { - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:GetDisplaySnapshot(%" PRIu64")", displayId); + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:GetDisplaySnapshot(%" PRIu64 ")", displayId); if ((Permission::IsSystemCalling() && Permission::CheckCallingPermission(SCREEN_CAPTURE_PERMISSION)) || Permission::IsStartByHdcd()) { auto res = abstractDisplayController_->GetScreenSnapshot(displayId); @@ -335,35 +314,36 @@ std::shared_ptr DisplayManagerService::GetDisplaySnapshot(Displ DMError DisplayManagerService::GetScreenSupportedColorGamuts(ScreenId screenId, std::vector& colorGamuts) { - WLOGFI("GetScreenSupportedColorGamuts::ScreenId: %{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "GetScreenSupportedColorGamuts::ScreenId: %{public}" PRIu64, screenId); CHECK_SCREEN_AND_RETURN(screenId, DMError::DM_ERROR_INVALID_PARAM); return abstractScreenController_->GetScreenSupportedColorGamuts(screenId, colorGamuts); } DMError DisplayManagerService::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) { - WLOGFI("GetScreenColorGamut::ScreenId: %{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "GetScreenColorGamut::ScreenId: %{public}" PRIu64, screenId); CHECK_SCREEN_AND_RETURN(screenId, DMError::DM_ERROR_INVALID_PARAM); return abstractScreenController_->GetScreenColorGamut(screenId, colorGamut); } DMError DisplayManagerService::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) { - WLOGFI("SetScreenColorGamut::ScreenId: %{public}" PRIu64 ", colorGamutIdx %{public}d", screenId, colorGamutIdx); + TLOGI(WmsLogTag::DMS, "SetScreenColorGamut::ScreenId: %{public}" PRIu64 ", colorGamutIdx %{public}d", screenId, + colorGamutIdx); CHECK_SCREEN_AND_RETURN(screenId, DMError::DM_ERROR_INVALID_PARAM); return abstractScreenController_->SetScreenColorGamut(screenId, colorGamutIdx); } DMError DisplayManagerService::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) { - WLOGFI("GetScreenGamutMap::ScreenId: %{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "GetScreenGamutMap::ScreenId: %{public}" PRIu64, screenId); CHECK_SCREEN_AND_RETURN(screenId, DMError::DM_ERROR_INVALID_PARAM); return abstractScreenController_->GetScreenGamutMap(screenId, gamutMap); } DMError DisplayManagerService::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) { - WLOGFI("SetScreenGamutMap::ScreenId: %{public}" PRIu64 ", ScreenGamutMap %{public}u", + TLOGI(WmsLogTag::DMS, "SetScreenGamutMap::ScreenId: %{public}" PRIu64 ", ScreenGamutMap %{public}u", screenId, static_cast(gamutMap)); CHECK_SCREEN_AND_RETURN(screenId, DMError::DM_ERROR_INVALID_PARAM); return abstractScreenController_->SetScreenGamutMap(screenId, gamutMap); @@ -371,26 +351,21 @@ DMError DisplayManagerService::SetScreenGamutMap(ScreenId screenId, ScreenGamutM DMError DisplayManagerService::SetScreenColorTransform(ScreenId screenId) { - WLOGFI("SetScreenColorTransform::ScreenId: %{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "SetScreenColorTransform::ScreenId: %{public}" PRIu64, screenId); CHECK_SCREEN_AND_RETURN(screenId, DMError::DM_ERROR_INVALID_PARAM); return abstractScreenController_->SetScreenColorTransform(screenId); } -void DisplayManagerService::OnStop() -{ - WLOGFI("ready to stop display service."); -} - DMError DisplayManagerService::RegisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) { if (type == DisplayManagerAgentType::SCREEN_EVENT_LISTENER && !Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("register display manager agent permission denied!"); + TLOGE(WmsLogTag::DMS, "register display manager agent permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } if ((displayManagerAgent == nullptr) || (displayManagerAgent->AsObject() == nullptr)) { - WLOGFE("displayManagerAgent invalid"); + TLOGE(WmsLogTag::DMS, "displayManagerAgent invalid"); return DMError::DM_ERROR_NULLPTR; } return DisplayManagerAgentController::GetInstance().RegisterDisplayManagerAgent(displayManagerAgent, type); @@ -401,11 +376,11 @@ DMError DisplayManagerService::UnregisterDisplayManagerAgent(const sptrAsObject() == nullptr)) { - WLOGFE("displayManagerAgent invalid"); + TLOGE(WmsLogTag::DMS, "displayManagerAgent invalid"); return DMError::DM_ERROR_NULLPTR; } return DisplayManagerAgentController::GetInstance().UnregisterDisplayManagerAgent(displayManagerAgent, type); @@ -415,7 +390,7 @@ bool DisplayManagerService::WakeUpBegin(PowerStateChangeReason reason) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]dms:WakeUpBegin(%u)", reason); if (!Permission::IsSystemServiceCalling()) { - WLOGFE("[UL_POWER]wake up begin permission denied!"); + TLOGE(WmsLogTag::DMS, "[UL_POWER]wake up begin permission denied!"); return false; } return DisplayManagerAgentController::GetInstance().NotifyDisplayPowerEvent(DisplayPowerEvent::WAKE_UP, @@ -426,7 +401,7 @@ bool DisplayManagerService::WakeUpEnd() { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]dms:WakeUpEnd"); if (!Permission::IsSystemServiceCalling()) { - WLOGFE("[UL_POWER]wake up end permission denied!"); + TLOGE(WmsLogTag::DMS, "[UL_POWER]wake up end permission denied!"); return false; } return DisplayManagerAgentController::GetInstance().NotifyDisplayPowerEvent(DisplayPowerEvent::WAKE_UP, @@ -437,7 +412,7 @@ bool DisplayManagerService::SuspendBegin(PowerStateChangeReason reason) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]dms:SuspendBegin(%u)", reason); if (!Permission::IsSystemServiceCalling()) { - WLOGFE("[UL_POWER]suspend begin permission denied!"); + TLOGE(WmsLogTag::DMS, "[UL_POWER]suspend begin permission denied!"); return false; } displayPowerController_->SuspendBegin(reason); @@ -449,25 +424,26 @@ bool DisplayManagerService::SuspendEnd() { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]dms:SuspendEnd"); if (!Permission::IsSystemServiceCalling()) { - WLOGFE("[UL_POWER]suspend end permission denied!"); + TLOGE(WmsLogTag::DMS, "[UL_POWER]suspend end permission denied!"); return false; } return DisplayManagerAgentController::GetInstance().NotifyDisplayPowerEvent(DisplayPowerEvent::SLEEP, EventStatus::END); } -bool DisplayManagerService::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) +bool DisplayManagerService::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, + PowerStateChangeReason reason) { - WLOGFE("[UL_POWER]DMS not support SetSpecifiedScreenPower: screen:%{public}" PRIu64 ", state:%{public}u", - screenId, state); + TLOGE(WmsLogTag::DMS, "[UL_POWER]DMS not support SetSpecifiedScreenPower: screen:%{public}" PRIu64 + ", state:%{public}u", screenId, state); return false; } bool DisplayManagerService::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) { - WLOGFI("[UL_POWER]SetScreenPowerForAll"); + TLOGI(WmsLogTag::DMS, "[UL_POWER]SetScreenPowerForAll"); if (!Permission::IsSystemServiceCalling()) { - WLOGFE("[UL_POWER]set screen power for all permission denied!"); + TLOGE(WmsLogTag::DMS, "[UL_POWER]set screen power for all permission denied!"); return false; } return abstractScreenController_->SetScreenPowerForAll(state, reason); @@ -481,7 +457,7 @@ ScreenPowerState DisplayManagerService::GetScreenPower(ScreenId dmsScreenId) bool DisplayManagerService::SetDisplayState(DisplayState state) { if (!Permission::IsSystemServiceCalling()) { - WLOGFE("[UL_POWER]set display state permission denied!"); + TLOGE(WmsLogTag::DMS, "[UL_POWER]set display state permission denied!"); return false; } ScreenId dmsScreenId = abstractScreenController_->GetDefaultAbstractScreenId(); @@ -496,7 +472,7 @@ ScreenId DisplayManagerService::GetScreenIdByDisplayId(DisplayId displayId) cons { sptr abstractDisplay = abstractDisplayController_->GetAbstractDisplay(displayId); if (abstractDisplay == nullptr) { - WLOGFE("GetScreenIdByDisplayId: GetAbstractDisplay failed"); + TLOGE(WmsLogTag::DMS, "GetScreenIdByDisplayId: GetAbstractDisplay failed"); return SCREEN_ID_INVALID; } return abstractDisplay->GetAbstractScreenId(); @@ -510,14 +486,14 @@ DisplayState DisplayManagerService::GetDisplayState(DisplayId displayId) bool DisplayManagerService::TryToCancelScreenOff() { - WLOGFE("[UL_POWER]DMS not support TryToCancelScreenOff"); + TLOGE(WmsLogTag::DMS, "[UL_POWER]DMS not support TryToCancelScreenOff"); return false; } bool DisplayManagerService::SetScreenBrightness(uint64_t screenId, uint32_t level) { if (!Permission::IsSystemServiceCalling()) { - TLOGE(WmsLogTag::DMS, "set screen brightness permission denied!"); + TLOGE(WmsLogTag::DMS, "set screen brightness permission denied!"); return false; } RSInterfaces::GetInstance().SetScreenBacklight(screenId, level); @@ -527,14 +503,14 @@ bool DisplayManagerService::SetScreenBrightness(uint64_t screenId, uint32_t leve uint32_t DisplayManagerService::GetScreenBrightness(uint64_t screenId) { uint32_t level = static_cast(RSInterfaces::GetInstance().GetScreenBacklight(screenId)); - TLOGI(WmsLogTag::DMS, "GetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level); + TLOGI(WmsLogTag::DMS, "GetScreenBrightness screenId:%{public}" PRIu64 ", level:%{public}u,", screenId, level); return level; } void DisplayManagerService::NotifyDisplayEvent(DisplayEvent event) { if (!Permission::IsSystemServiceCalling()) { - WLOGFE("[UL_POWER]notify display event permission denied!"); + TLOGE(WmsLogTag::DMS, "[UL_POWER]notify display event permission denied!"); return; } displayPowerController_->NotifyDisplayEvent(event); @@ -543,7 +519,7 @@ void DisplayManagerService::NotifyDisplayEvent(DisplayEvent event) bool DisplayManagerService::SetFreeze(std::vector displayIds, bool isFreeze) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("set freeze permission denied!"); + TLOGE(WmsLogTag::DMS, "set freeze permission denied!"); return false; } abstractDisplayController_->SetFreeze(displayIds, isFreeze); @@ -554,10 +530,10 @@ DMError DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vectorGetAllValidScreenIds(mirrorScreenIds); auto iter = std::find(allMirrorScreenIds.begin(), allMirrorScreenIds.end(), mainScreenId); if (iter != allMirrorScreenIds.end()) { @@ -565,18 +541,18 @@ DMError DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vectorGetAbstractScreen(mainScreenId); if (mainScreen == nullptr || allMirrorScreenIds.empty()) { - WLOGFI("create mirror fail. main screen :%{public}" PRIu64", screens' size:%{public}u", + TLOGI(WmsLogTag::DMS, "create mirror fail. main screen :%{public}" PRIu64 ", screens' size:%{public}u", mainScreenId, static_cast(allMirrorScreenIds.size())); return DMError::DM_ERROR_INVALID_PARAM; } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:MakeMirror"); DMError ret = abstractScreenController_->MakeMirror(mainScreenId, allMirrorScreenIds); if (ret != DMError::DM_OK) { - WLOGFE("make mirror failed."); + TLOGE(WmsLogTag::DMS, "make mirror failed."); return ret; } if (abstractScreenController_->GetAbstractScreenGroup(mainScreen->groupDmsId_) == nullptr) { - WLOGFE("get screen group failed."); + TLOGE(WmsLogTag::DMS, "get screen group failed."); return DMError::DM_ERROR_NULLPTR; } screenGroupId = mainScreen->groupDmsId_; @@ -586,19 +562,20 @@ DMError DisplayManagerService::MakeMirror(ScreenId mainScreenId, std::vector& mirrorScreenIds) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("stop mirror permission denied!"); + TLOGE(WmsLogTag::DMS, "stop mirror permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } auto allMirrorScreenIds = abstractScreenController_->GetAllValidScreenIds(mirrorScreenIds); if (allMirrorScreenIds.empty()) { - WLOGFI("stop mirror done. screens' size:%{public}u", static_cast(allMirrorScreenIds.size())); + TLOGI(WmsLogTag::DMS, "stop mirror done. screens' size:%{public}u", + static_cast(allMirrorScreenIds.size())); return DMError::DM_OK; } DMError ret = abstractScreenController_->StopScreens(allMirrorScreenIds, ScreenCombination::SCREEN_MIRROR); if (ret != DMError::DM_OK) { - WLOGFE("stop mirror failed."); + TLOGE(WmsLogTag::DMS, "stop mirror failed."); return ret; } @@ -613,8 +590,9 @@ void DisplayManagerService::RemoveVirtualScreenFromGroup(std::vector s void DisplayManagerService::UpdateRSTree(DisplayId displayId, DisplayId parentDisplayId, std::shared_ptr& surfaceNode, bool isAdd, bool isMultiDisplay) { - WLOGFD("UpdateRSTree, currentDisplayId: %{public}" PRIu64", isAdd: %{public}d, isMultiDisplay: %{public}d, " - "parentDisplayId: %{public}" PRIu64"", displayId, isAdd, isMultiDisplay, parentDisplayId); + TLOGD(WmsLogTag::DMS, "UpdateRSTree, currentDisplayId: %{public}" PRIu64 + ", isAdd: %{public}d, isMultiDisplay: %{public}d, parentDisplayId: %{public}" PRIu64, + displayId, isAdd, isMultiDisplay, parentDisplayId); ScreenId screenId = GetScreenIdByDisplayId(displayId); ScreenId parentScreenId = GetScreenIdByDisplayId(parentDisplayId); CHECK_SCREEN_AND_RETURN(screenId, void()); @@ -625,9 +603,9 @@ void DisplayManagerService::UpdateRSTree(DisplayId displayId, DisplayId parentDi DMError DisplayManagerService::AddSurfaceNodeToDisplay(DisplayId displayId, std::shared_ptr& surfaceNode, bool onTop) { - WLOGFI("DisplayId: %{public}" PRIu64", onTop: %{public}d", displayId, onTop); + TLOGI(WmsLogTag::DMS, "DisplayId: %{public}" PRIu64 ", onTop: %{public}d", displayId, onTop); if (surfaceNode == nullptr) { - WLOGFW("Surface is null"); + TLOGW(WmsLogTag::DMS, "Surface is null"); return DMError::DM_ERROR_NULLPTR; } ScreenId screenId = GetScreenIdByDisplayId(displayId); @@ -637,9 +615,9 @@ DMError DisplayManagerService::AddSurfaceNodeToDisplay(DisplayId displayId, DMError DisplayManagerService::RemoveSurfaceNodeFromDisplay(DisplayId displayId, std::shared_ptr& surfaceNode) { - WLOGFI("DisplayId: %{public}" PRIu64"", displayId); + TLOGI(WmsLogTag::DMS, "DisplayId: %{public}" PRIu64, displayId); if (surfaceNode == nullptr) { - WLOGFW("Surface is null"); + TLOGW(WmsLogTag::DMS, "Surface is null"); return DMError::DM_ERROR_NULLPTR; } ScreenId screenId = GetScreenIdByDisplayId(displayId); @@ -650,7 +628,7 @@ sptr DisplayManagerService::GetScreenInfoById(ScreenId screenId) { auto screen = abstractScreenController_->GetAbstractScreen(screenId); if (screen == nullptr) { - WLOGE("cannot find screenInfo: %{public}" PRIu64"", screenId); + TLOGE(WmsLogTag::DMS, "cannot find screenInfo: %{public}" PRIu64, screenId); return nullptr; } return screen->ConvertToScreenInfo(); @@ -660,7 +638,7 @@ sptr DisplayManagerService::GetScreenGroupInfoById(ScreenId scr { auto screenGroup = abstractScreenController_->GetAbstractScreenGroup(screenId); if (screenGroup == nullptr) { - WLOGE("cannot find screenGroupInfo: %{public}" PRIu64"", screenId); + TLOGE(WmsLogTag::DMS, "cannot find screenGroupInfo: %{public}" PRIu64, screenId); return nullptr; } return screenGroup->ConvertToScreenGroupInfo(); @@ -670,7 +648,7 @@ ScreenId DisplayManagerService::GetScreenGroupIdByScreenId(ScreenId screenId) { auto screen = abstractScreenController_->GetAbstractScreen(screenId); if (screen == nullptr) { - WLOGE("cannot find screenInfo: %{public}" PRIu64"", screenId); + TLOGE(WmsLogTag::DMS, "cannot find screenInfo: %{public}" PRIu64, screenId); return SCREEN_ID_INVALID; } return screen->GetScreenGroupId(); @@ -684,14 +662,14 @@ std::vector DisplayManagerService::GetAllDisplayIds() DMError DisplayManagerService::GetAllScreenInfos(std::vector>& screenInfos) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("get all screen infos permission denied!"); + TLOGE(WmsLogTag::DMS, "get all screen infos permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } std::vector screenIds = abstractScreenController_->GetAllScreenIds(); for (auto screenId: screenIds) { auto screenInfo = GetScreenInfoById(screenId); if (screenInfo == nullptr) { - WLOGE("cannot find screenInfo: %{public}" PRIu64"", screenId); + TLOGE(WmsLogTag::DMS, "cannot find screenInfo: %{public}" PRIu64, screenId); continue; } screenInfos.emplace_back(screenInfo); @@ -703,11 +681,11 @@ DMError DisplayManagerService::MakeExpand(std::vector expandScreenIds, ScreenId& screenGroupId) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("make expand permission denied!"); + TLOGE(WmsLogTag::DMS, "make expand permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } if (expandScreenIds.empty() || startPoints.empty() || expandScreenIds.size() != startPoints.size()) { - WLOGFE("create expand fail, input params is invalid. " + TLOGE(WmsLogTag::DMS, "create expand fail, input params is invalid. " "screenId vector size :%{public}ud, startPoint vector size :%{public}ud", static_cast(expandScreenIds.size()), static_cast(startPoints.size())); return DMError::DM_ERROR_INVALID_PARAM; @@ -721,14 +699,14 @@ DMError DisplayManagerService::MakeExpand(std::vector expandScreenIds, pointsMap[expandScreenIds[i]] = startPoints[i]; } ScreenId defaultScreenId = abstractScreenController_->GetDefaultAbstractScreenId(); - WLOGFI("MakeExpand, defaultScreenId:%{public}" PRIu64"", defaultScreenId); + TLOGI(WmsLogTag::DMS, "MakeExpand, defaultScreenId:%{public}" PRIu64, defaultScreenId); auto allExpandScreenIds = abstractScreenController_->GetAllValidScreenIds(expandScreenIds); auto iter = std::find(allExpandScreenIds.begin(), allExpandScreenIds.end(), defaultScreenId); if (iter != allExpandScreenIds.end()) { allExpandScreenIds.erase(iter); } if (allExpandScreenIds.empty()) { - WLOGFE("allExpandScreenIds is empty. make expand failed."); + TLOGE(WmsLogTag::DMS, "allExpandScreenIds is empty. make expand failed."); return DMError::DM_ERROR_NULLPTR; } std::shared_ptr rsDisplayNode; @@ -743,12 +721,12 @@ DMError DisplayManagerService::MakeExpand(std::vector expandScreenIds, } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:MakeExpand"); if (!abstractScreenController_->MakeExpand(allExpandScreenIds, points)) { - WLOGFE("make expand failed."); + TLOGE(WmsLogTag::DMS, "make expand failed."); return DMError::DM_ERROR_NULLPTR; } auto screen = abstractScreenController_->GetAbstractScreen(allExpandScreenIds[0]); if (screen == nullptr || abstractScreenController_->GetAbstractScreenGroup(screen->groupDmsId_) == nullptr) { - WLOGFE("get screen group failed."); + TLOGE(WmsLogTag::DMS, "get screen group failed."); return DMError::DM_ERROR_NULLPTR; } screenGroupId = screen->groupDmsId_; @@ -758,18 +736,19 @@ DMError DisplayManagerService::MakeExpand(std::vector expandScreenIds, DMError DisplayManagerService::StopExpand(const std::vector& expandScreenIds) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("stop expand permission denied!"); + TLOGE(WmsLogTag::DMS, "stop expand permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } auto allExpandScreenIds = abstractScreenController_->GetAllValidScreenIds(expandScreenIds); if (allExpandScreenIds.empty()) { - WLOGFI("stop expand done. screens' size:%{public}u", static_cast(allExpandScreenIds.size())); + TLOGI(WmsLogTag::DMS, "stop expand done. screens' size:%{public}u", + static_cast(allExpandScreenIds.size())); return DMError::DM_OK; } DMError ret = abstractScreenController_->StopScreens(allExpandScreenIds, ScreenCombination::SCREEN_EXPAND); if (ret != DMError::DM_OK) { - WLOGFE("stop expand failed."); + TLOGE(WmsLogTag::DMS, "stop expand failed."); return ret; } @@ -779,20 +758,20 @@ DMError DisplayManagerService::StopExpand(const std::vector& expandScr DMError DisplayManagerService::SetScreenActiveMode(ScreenId screenId, uint32_t modeId) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("set screen active permission denied!"); + TLOGE(WmsLogTag::DMS, "set screen active permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetScreenActiveMode(%" PRIu64", %u)", screenId, modeId); + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetScreenActiveMode(%" PRIu64 ", %u)", screenId, modeId); return abstractScreenController_->SetScreenActiveMode(screenId, modeId); } DMError DisplayManagerService::SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("set virtual pixel permission denied!"); + TLOGE(WmsLogTag::DMS, "set virtual pixel permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetVirtualPixelRatio(%" PRIu64", %f)", screenId, + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:SetVirtualPixelRatio(%" PRIu64 ", %f)", screenId, virtualPixelRatio); return abstractScreenController_->SetVirtualPixelRatio(screenId, virtualPixelRatio); } @@ -800,7 +779,7 @@ DMError DisplayManagerService::SetVirtualPixelRatio(ScreenId screenId, float vir DMError DisplayManagerService::IsScreenRotationLocked(bool& isLocked) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("is screen rotation locked permission denied!"); + TLOGE(WmsLogTag::DMS, "is screen rotation locked permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } isLocked = ScreenRotationController::IsScreenRotationLocked(); @@ -810,7 +789,7 @@ DMError DisplayManagerService::IsScreenRotationLocked(bool& isLocked) DMError DisplayManagerService::SetScreenRotationLocked(bool isLocked) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("set screen rotation locked permission denied!"); + TLOGE(WmsLogTag::DMS, "set screen rotation locked permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } return ScreenRotationController::SetScreenRotationLocked(isLocked); @@ -819,7 +798,7 @@ DMError DisplayManagerService::SetScreenRotationLocked(bool isLocked) DMError DisplayManagerService::SetScreenRotationLockedFromJs(bool isLocked) { if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { - WLOGFE("set screen rotation locked from js permission denied!"); + TLOGE(WmsLogTag::DMS, "set screen rotation locked from js permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } return ScreenRotationController::SetScreenRotationLocked(isLocked); @@ -828,7 +807,7 @@ DMError DisplayManagerService::SetScreenRotationLockedFromJs(bool isLocked) void DisplayManagerService::SetGravitySensorSubscriptionEnabled() { if (!isAutoRotationOpen_) { - WLOGFE("autoRotation is not open"); + TLOGE(WmsLogTag::DMS, "autoRotation is not open"); ScreenRotationController::Init(); return; } @@ -850,7 +829,7 @@ std::vector DisplayManagerService::GetAllDisplayPhysi if (allDisplayPhysicalResolution_.empty()) { sptr displayInfo = DisplayManagerService::GetDefaultDisplayInfo(); if (displayInfo == nullptr) { - TLOGE(WmsLogTag::DMS, "default display null"); + TLOGE(WmsLogTag::DMS, "default display null"); return allDisplayPhysicalResolution_; } DisplayPhysicalResolution defaultResolution; @@ -861,4 +840,4 @@ std::vector DisplayManagerService::GetAllDisplayPhysi } return allDisplayPhysicalResolution_; } -} // namespace OHOS::Rosen \ No newline at end of file +} // namespace OHOS::Rosen diff --git a/dmserver/src/display_manager_stub.cpp b/dmserver/src/display_manager_stub.cpp deleted file mode 100644 index 8bb5d83881..0000000000 --- a/dmserver/src/display_manager_stub.cpp +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "display_manager_stub.h" - -#include "dm_common.h" - -#include - -#include "marshalling_helper.h" -#include "window_manager_hilog.h" - -#include "transaction/rs_interfaces.h" - -namespace OHOS::Rosen { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayManagerStub"}; -const static uint32_t MAX_SCREEN_SIZE = 32; -} - -int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - WLOGFD("OnRemoteRequest code is %{public}u", code); - if (data.ReadInterfaceToken() != GetDescriptor()) { - WLOGFE("InterfaceToken check failed"); - return -1; - } - DisplayManagerMessage msgId = static_cast(code); - switch (msgId) { - case DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO: { - auto info = GetDefaultDisplayInfo(); - reply.WriteParcelable(info); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID: { - DisplayId displayId = data.ReadUint64(); - auto info = GetDisplayInfoById(displayId); - reply.WriteParcelable(info); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_VISIBLE_AREA_DISPLAY_INFO_BY_ID: { - DisplayId displayId = static_cast(data.ReadUint64()); - auto info = GetVisibleAreaDisplayInfoById(displayId); - reply.WriteParcelable(info); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN: { - ScreenId screenId = data.ReadUint64(); - auto info = GetDisplayInfoByScreen(screenId); - reply.WriteParcelable(info); - break; - } - case DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN: { - std::string name = data.ReadString(); - uint32_t width = data.ReadUint32(); - uint32_t height = data.ReadUint32(); - float density = data.ReadFloat(); - int32_t flags = data.ReadInt32(); - bool isForShot = data.ReadBool(); - std::vector missionIds; - data.ReadUInt64Vector(&missionIds); - bool isSurfaceValid = data.ReadBool(); - sptr surface = nullptr; - if (isSurfaceValid) { - sptr surfaceObject = data.ReadRemoteObject(); - sptr bp = iface_cast(surfaceObject); - surface = Surface::CreateSurfaceAsProducer(bp); - } - sptr virtualScreenAgent = data.ReadRemoteObject(); - VirtualScreenOption virScrOption = { - .name_ = name, - .width_ = width, - .height_ = height, - .density_ = density, - .surface_ = surface, - .flags_ = flags, - .isForShot_ = isForShot, - .missionIds_ = missionIds - }; - ScreenId screenId = CreateVirtualScreen(virScrOption, virtualScreenAgent); - reply.WriteUint64(static_cast(screenId)); - break; - } - case DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN: { - ScreenId screenId = static_cast(data.ReadUint64()); - DMError result = DestroyVirtualScreen(screenId); - reply.WriteInt32(static_cast(result)); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE: { - ScreenId screenId = static_cast(data.ReadUint64()); - bool isSurfaceValid = data.ReadBool(); - sptr bp = nullptr; - if (isSurfaceValid) { - sptr surfaceObject = data.ReadRemoteObject(); - bp = iface_cast(surfaceObject); - } - DMError result = SetVirtualScreenSurface(screenId, bp); - reply.WriteInt32(static_cast(result)); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_ORIENTATION: { - ScreenId screenId = static_cast(data.ReadUint64()); - Orientation orientation = static_cast(data.ReadUint32()); - DMError ret = SetOrientation(screenId, orientation); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT: { - DisplayId displayId = data.ReadUint64(); - DmErrorCode errorCode = DmErrorCode::DM_OK; - std::shared_ptr displaySnapshot = GetDisplaySnapshot(displayId, &errorCode); - reply.WriteParcelable(displaySnapshot == nullptr ? nullptr : displaySnapshot.get()); - reply.WriteInt32(static_cast(errorCode)); - break; - } - case DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT: { - auto agent = iface_cast(data.ReadRemoteObject()); - if (agent == nullptr) { - WLOGFE("agent is nullptr"); - break; - } - auto type = static_cast(data.ReadUint32()); - DMError ret = RegisterDisplayManagerAgent(agent, type); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT: { - auto agent = iface_cast(data.ReadRemoteObject()); - if (agent == nullptr) { - WLOGFE("agent is nullptr"); - break; - } - auto type = static_cast(data.ReadUint32()); - DMError ret = UnregisterDisplayManagerAgent(agent, type); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN: { - PowerStateChangeReason reason = static_cast(data.ReadUint32()); - reply.WriteBool(WakeUpBegin(reason)); - break; - } - case DisplayManagerMessage::TRANS_ID_WAKE_UP_END: { - reply.WriteBool(WakeUpEnd()); - break; - } - case DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN: { - PowerStateChangeReason reason = static_cast(data.ReadUint32()); - reply.WriteBool(SuspendBegin(reason)); - break; - } - case DisplayManagerMessage::TRANS_ID_SUSPEND_END: { - reply.WriteBool(SuspendEnd()); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER: { - ScreenId screenId = static_cast(data.ReadUint32()); - ScreenPowerState state = static_cast(data.ReadUint32()); - PowerStateChangeReason reason = static_cast(data.ReadUint32()); - reply.WriteBool(SetSpecifiedScreenPower(screenId, state, reason)); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL: { - ScreenPowerState state = static_cast(data.ReadUint32()); - PowerStateChangeReason reason = static_cast(data.ReadUint32()); - reply.WriteBool(SetScreenPowerForAll(state, reason)); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER: { - ScreenId dmsScreenId; - if (!data.ReadUint64(dmsScreenId)) { - WLOGFE("fail to read dmsScreenId."); - break; - } - reply.WriteUint32(static_cast(GetScreenPower(dmsScreenId))); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE: { - DisplayState state = static_cast(data.ReadUint32()); - reply.WriteBool(SetDisplayState(state)); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE: { - DisplayState state = GetDisplayState(data.ReadUint64()); - reply.WriteUint32(static_cast(state)); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_SCREEN_BRIGHTNESS: { - uint64_t screenId = data.ReadUint64(); - uint32_t level = data.ReadUint64(); - reply.WriteBool(SetScreenBrightness(screenId, level)); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_SCREEN_BRIGHTNESS: { - uint64_t screenId = data.ReadUint64(); - reply.WriteUint32(GetScreenBrightness(screenId)); - break; - } - case DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT: { - DisplayEvent event = static_cast(data.ReadUint32()); - NotifyDisplayEvent(event); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_FREEZE_EVENT: { - std::vector ids; - data.ReadUInt64Vector(&ids); - SetFreeze(ids, data.ReadBool()); - break; - } - case DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR: { - ScreenId mainScreenId = static_cast(data.ReadUint64()); - std::vector mirrorScreenId; - if (!data.ReadUInt64Vector(&mirrorScreenId)) { - WLOGE("fail to receive mirror screen in stub. screen:%{public}" PRIu64"", mainScreenId); - break; - } - ScreenId screenGroupId = INVALID_SCREEN_ID; - DMError ret = MakeMirror(mainScreenId, mirrorScreenId, screenGroupId); - reply.WriteInt32(static_cast(ret)); - reply.WriteUint64(static_cast(screenGroupId)); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID: { - ScreenId screenId = static_cast(data.ReadUint64()); - auto screenInfo = GetScreenInfoById(screenId); - reply.WriteStrongParcelable(screenInfo); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID: { - ScreenId screenId = static_cast(data.ReadUint64()); - auto screenGroupInfo = GetScreenGroupInfoById(screenId); - reply.WriteStrongParcelable(screenGroupInfo); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS: { - std::vector> screenInfos; - DMError ret = GetAllScreenInfos(screenInfos); - reply.WriteInt32(static_cast(ret)); - if (!MarshallingHelper::MarshallingVectorParcelableObj(reply, screenInfos)) { - WLOGE("fail to marshalling screenInfos in stub."); - } - break; - } - case DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS: { - std::vector allDisplayIds = GetAllDisplayIds(); - reply.WriteUInt64Vector(allDisplayIds); - break; - } - case DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND: { - std::vector screenId; - if (!data.ReadUInt64Vector(&screenId)) { - WLOGE("fail to receive expand screen in stub."); - break; - } - std::vector startPoint; - if (!MarshallingHelper::UnmarshallingVectorObj(data, startPoint, [](Parcel& parcel, Point& point) { - return parcel.ReadInt32(point.posX_) && parcel.ReadInt32(point.posY_); - })) { - WLOGE("fail to receive startPoint in stub."); - break; - } - ScreenId screenGroupId = INVALID_SCREEN_ID; - DMError ret = MakeExpand(screenId, startPoint, screenGroupId); - reply.WriteInt32(static_cast(ret)); - reply.WriteUint64(static_cast(screenGroupId)); - break; - } - case DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP: { - std::vector screenId; - if (!data.ReadUInt64Vector(&screenId)) { - WLOGE("fail to receive screens in stub."); - break; - } - RemoveVirtualScreenFromGroup(screenId); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE: { - ScreenId screenId = static_cast(data.ReadUint64()); - uint32_t modeId = data.ReadUint32(); - DMError ret = SetScreenActiveMode(screenId, modeId); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO: { - ScreenId screenId = static_cast(data.ReadUint64()); - float virtualPixelRatio = data.ReadFloat(); - DMError ret = SetVirtualPixelRatio(screenId, virtualPixelRatio); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS: { - ScreenId screenId = static_cast(data.ReadUint64()); - std::vector colorGamuts; - DMError ret = GetScreenSupportedColorGamuts(screenId, colorGamuts); - reply.WriteInt32(static_cast(ret)); - if (ret != DMError::DM_OK) { - break; - } - MarshallingHelper::MarshallingVectorObj(reply, colorGamuts, - [](Parcel& parcel, const ScreenColorGamut& color) { - return parcel.WriteUint32(static_cast(color)); - } - ); - break; - } - case DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT: { - ScreenId screenId = static_cast(data.ReadUint64()); - ScreenColorGamut colorGamut; - DMError ret = GetScreenColorGamut(screenId, colorGamut); - reply.WriteInt32(static_cast(ret)); - if (ret != DMError::DM_OK) { - break; - } - reply.WriteUint32(static_cast(colorGamut)); - break; - } - case DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT: { - ScreenId screenId = static_cast(data.ReadUint64()); - int32_t colorGamutIdx = data.ReadInt32(); - DMError ret = SetScreenColorGamut(screenId, colorGamutIdx); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP: { - ScreenId screenId = static_cast(data.ReadUint64()); - ScreenGamutMap gamutMap; - DMError ret = GetScreenGamutMap(screenId, gamutMap); - reply.WriteInt32(static_cast(ret)); - if (ret != DMError::DM_OK) { - break; - } - reply.WriteInt32(static_cast(gamutMap)); - break; - } - case DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP: { - ScreenId screenId = static_cast(data.ReadUint64()); - ScreenGamutMap gamutMap = static_cast(data.ReadUint32()); - DMError ret = SetScreenGamutMap(screenId, gamutMap); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM: { - ScreenId screenId = static_cast(data.ReadUint64()); - DMError ret = SetScreenColorTransform(screenId); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED: { - bool isLocked = false; - DMError ret = IsScreenRotationLocked(isLocked); - reply.WriteInt32(static_cast(ret)); - reply.WriteBool(isLocked); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED: { - bool isLocked = static_cast(data.ReadBool()); - DMError ret = SetScreenRotationLocked(isLocked); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS: { - bool isLocked = static_cast(data.ReadBool()); - DMError ret = SetScreenRotationLockedFromJs(isLocked); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_HAS_PRIVATE_WINDOW: { - DisplayId id = static_cast(data.ReadUint64()); - bool hasPrivateWindow = false; - DMError ret = HasPrivateWindow(id, hasPrivateWindow); - reply.WriteInt32(static_cast(ret)); - reply.WriteBool(hasPrivateWindow); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_CUTOUT_INFO: { - DisplayId displayId = static_cast(data.ReadUint64()); - sptr cutoutInfo = GetCutoutInfo(displayId); - reply.WriteParcelable(cutoutInfo); - break; - } - case DisplayManagerMessage::TRANS_ID_ADD_SURFACE_NODE: { - DisplayId displayId = static_cast(data.ReadUint64()); - std::shared_ptr surfaceNode = RSSurfaceNode::Unmarshalling(data); - auto ret = AddSurfaceNodeToDisplay(displayId, surfaceNode, true); - reply.WriteUint32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_REMOVE_SURFACE_NODE: { - DisplayId displayId = static_cast(data.ReadUint64()); - std::shared_ptr surfaceNode = RSSurfaceNode::Unmarshalling(data); - auto ret = RemoveSurfaceNodeFromDisplay(displayId, surfaceNode); - reply.WriteUint32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_SCREEN_STOP_MIRROR: { - std::vector mirrorScreenIds; - if (!data.ReadUInt64Vector(&mirrorScreenIds)) { - WLOGE("fail to receive mirror screens in stub."); - break; - } - DMError ret = StopMirror(mirrorScreenIds); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_SCREEN_STOP_EXPAND: { - std::vector expandScreenIds; - if (!data.ReadUInt64Vector(&expandScreenIds)) { - WLOGE("fail to receive expand screens in stub."); - break; - } - DMError ret = StopExpand(expandScreenIds); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_RESIZE_VIRTUAL_SCREEN: { - ScreenId screenId = static_cast(data.ReadUint64()); - uint32_t width = data.ReadUint32(); - uint32_t height = data.ReadUint32(); - DMError ret = ResizeVirtualScreen(screenId, width, height); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_SCENE_BOARD_MAKE_UNIQUE_SCREEN: { - std::vector uniqueScreenIds; - uint32_t size = data.ReadUint32(); - if (size > MAX_SCREEN_SIZE) { - WLOGFE("screenIds size is bigger than %{public}u", MAX_SCREEN_SIZE); - break; - } - if (!data.ReadUInt64Vector(&uniqueScreenIds)) { - WLOGFE("failed to receive unique screens in stub"); - break; - } - std::vector displayIds; - DMError ret = MakeUniqueScreen(uniqueScreenIds, displayIds); - reply.WriteUInt64Vector(displayIds); - reply.WriteInt32(static_cast(ret)); - break; - } - case DisplayManagerMessage::TRANS_ID_GET_ALL_PHYSICAL_DISPLAY_RESOLUTION: { - auto physicalInfos = GetAllDisplayPhysicalResolution(); - size_t infoSize = physicalInfos.size(); - bool writeRet = reply.WriteInt32(static_cast(infoSize)); - if (!writeRet) { - WLOGFE("write physical size error"); - break; - } - for (const auto &physicalItem : physicalInfos) { - writeRet = reply.WriteUint32(static_cast(physicalItem.foldDisplayMode_)); - if (!writeRet) { - WLOGFE("write display mode error"); - break; - } - writeRet = reply.WriteUint32(physicalItem.physicalWidth_); - if (!writeRet) { - WLOGFE("write physical width error"); - break; - } - writeRet = reply.WriteUint32(physicalItem.physicalHeight_); - if (!writeRet) { - WLOGFE("write physical height error"); - break; - } - } - break; - } - default: - WLOGFW("unknown transaction code"); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - return 0; -} -} // namespace OHOS::Rosen \ No newline at end of file diff --git a/dmserver/test/unittest/BUILD.gn b/dmserver/test/unittest/BUILD.gn index e6f8f18b09..1da4c7d329 100644 --- a/dmserver/test/unittest/BUILD.gn +++ b/dmserver/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -258,6 +258,9 @@ config("dmserver_unittest_common_public_config") { "../../../test/common/mock", "../../../test/common/utils/include", "../../../utils/include", + "../../../window_scene/screen_session_manager/include", + "../../../window_scene/screen_session_manager_client/include", + "${dmserver_gen_path}", ] } @@ -283,6 +286,7 @@ ohos_static_library("dmserver_unittest_common") { ] public_external_deps = [ + "ability_base:want", "c_utils:utils", "googletest:gmock", "googletest:gtest_main", diff --git a/dmserver/test/unittest/display_manager_proxy_test.cpp b/dmserver/test/unittest/display_manager_proxy_test.cpp index 1823da1f29..ff9edced63 100644 --- a/dmserver/test/unittest/display_manager_proxy_test.cpp +++ b/dmserver/test/unittest/display_manager_proxy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,15 +14,13 @@ */ #include - #include #include + #include "display_manager_agent_default.h" #include "display_manager_proxy.h" -#include "iremote_object_mocker.h" - #include "iconsumer_surface.h" -#include +#include "iremote_object_mocker.h" using namespace testing; using namespace testing::ext; @@ -36,6 +34,7 @@ public: static void TearDownTestCase(); void SetUp() override; void TearDown() override; + int32_t dmError_ = static_cast(DMError::DM_ERROR_UNKNOWN); }; void DisplayManagerProxyTest::SetUpTestCase() @@ -52,6 +51,7 @@ void DisplayManagerProxyTest::SetUp() void DisplayManagerProxyTest::TearDown() { + dmError_ = static_cast(DMError::DM_ERROR_UNKNOWN); } namespace { @@ -64,18 +64,22 @@ HWTEST_F(DisplayManagerProxyTest, GetDefaultDisplayInfo01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); ASSERT_EQ(nullptr, proxy1.remoteObject_); - auto displayInfo1 = proxy1.GetDefaultDisplayInfo(); - ASSERT_EQ(nullptr, displayInfo1); + sptr displayInfo; + ErrCode errCode = proxy1.GetDefaultDisplayInfo(displayInfo); + ASSERT_EQ(nullptr, displayInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - auto displayInfo2 = proxy2.GetDefaultDisplayInfo(); - ASSERT_EQ(nullptr, displayInfo2); + errCode = proxy2.GetDefaultDisplayInfo(displayInfo); + ASSERT_EQ(nullptr, displayInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); remoteMocker->sendRequestResult_ = 1; - auto displayInfo3 = proxy2.GetDefaultDisplayInfo(); - ASSERT_EQ(nullptr, displayInfo3); + errCode = proxy2.GetDefaultDisplayInfo(displayInfo); + ASSERT_EQ(nullptr, displayInfo); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -87,19 +91,22 @@ HWTEST_F(DisplayManagerProxyTest, GetDisplayInfoById01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); ASSERT_EQ(nullptr, proxy1.remoteObject_); - auto displayInfo1 = proxy1.GetDisplayInfoById(0); - ASSERT_EQ(nullptr, displayInfo1); + sptr displayInfo; + ErrCode errCode = proxy1.GetDisplayInfoById(0, displayInfo); + ASSERT_EQ(nullptr, displayInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto displayInfo2 = proxy2.GetDisplayInfoById(0); - ASSERT_EQ(nullptr, displayInfo2); + errCode = proxy2.GetDisplayInfoById(0, displayInfo); + ASSERT_EQ(nullptr, displayInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); remoteMocker->sendRequestResult_ = 1; - auto displayInfo3 = proxy2.GetDisplayInfoById(0); - ASSERT_EQ(nullptr, displayInfo3); + errCode = proxy2.GetDisplayInfoById(0, displayInfo); + ASSERT_EQ(nullptr, displayInfo); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -111,19 +118,22 @@ HWTEST_F(DisplayManagerProxyTest, GetDisplayInfoByScreen01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); ASSERT_EQ(nullptr, proxy1.remoteObject_); - auto displayInfo1 = proxy1.GetDisplayInfoByScreen(0); - ASSERT_EQ(nullptr, displayInfo1); + sptr displayInfo; + ErrCode errCode = proxy1.GetDisplayInfoByScreen(0, displayInfo); + ASSERT_EQ(nullptr, displayInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto displayInfo2 = proxy2.GetDisplayInfoByScreen(0); - ASSERT_EQ(nullptr, displayInfo2); + errCode = proxy2.GetDisplayInfoByScreen(0, displayInfo); + ASSERT_EQ(nullptr, displayInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); remoteMocker->sendRequestResult_ = 1; - auto displayInfo3 = proxy2.GetDisplayInfoByScreen(0); - ASSERT_EQ(nullptr, displayInfo3); + errCode = proxy2.GetDisplayInfoByScreen(0, displayInfo); + ASSERT_EQ(nullptr, displayInfo); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -135,25 +145,71 @@ HWTEST_F(DisplayManagerProxyTest, CreateVirtualScreen01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); ASSERT_EQ(nullptr, proxy1.remoteObject_); - VirtualScreenOption virtualOption1; + VirtualScreenOption virtualOption1{}; virtualOption1.name_ = "testVirtualOption"; - sptr displayManagerAgent1 = new RemoteMocker(); - auto screenId1 = proxy1.CreateVirtualScreen(virtualOption1, displayManagerAgent1); - ASSERT_EQ(SCREEN_ID_INVALID, screenId1); + DmVirtualScreenOption dmVirtualScreenOption1(virtualOption1); + sptr displayManagerAgent = new RemoteMocker(); + ScreenId screenId = SCREEN_ID_INVALID; + ErrCode errCode = proxy1.CreateVirtualScreen(dmVirtualScreenOption1, displayManagerAgent, screenId); + ASSERT_EQ(SCREEN_ID_INVALID, screenId); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - VirtualScreenOption virtualOption2; + VirtualScreenOption virtualOption2{}; virtualOption2.name_ = "testVirtualOption"; - sptr displayManagerAgent2 = new RemoteMocker(); - auto screenId2 = proxy2.CreateVirtualScreen(virtualOption2, displayManagerAgent2); - ASSERT_EQ(0, screenId2); + DmVirtualScreenOption dmVirtualScreenOption2(virtualOption2); + errCode = proxy2.CreateVirtualScreen(dmVirtualScreenOption2, nullptr, screenId); + ASSERT_EQ(SCREEN_ID_INVALID, screenId); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + errCode = proxy2.CreateVirtualScreen(dmVirtualScreenOption2, displayManagerAgent, screenId); + ASSERT_EQ(ERR_OK, errCode); + screenId = SCREEN_ID_INVALID; remoteMocker->sendRequestResult_ = 1; - auto screenId3 = proxy2.CreateVirtualScreen(virtualOption2, displayManagerAgent2); - ASSERT_EQ(SCREEN_ID_INVALID, screenId3); + errCode = proxy2.CreateVirtualScreen(dmVirtualScreenOption2, displayManagerAgent, screenId); + ASSERT_EQ(SCREEN_ID_INVALID, screenId); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); +} + +/** + * @tc.name: CreateVirtualScreen02 + * @tc.desc: test DisplayManagerProxy::CreateVirtualScreen + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, CreateVirtualScreen02, TestSize.Level1) +{ + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + VirtualScreenOption virtualOption1{}; + virtualOption1.name_ = "testVirtualOption"; + DmVirtualScreenOption dmVirtualScreenOption1(virtualOption1); + sptr displayManagerAgent = new RemoteMocker(); + ScreenId screenId = SCREEN_ID_INVALID; + sptr surface = IConsumerSurface::Create(); + ErrCode errCode = proxy1.CreateVirtualScreen(dmVirtualScreenOption1, displayManagerAgent, screenId, + surface->GetProducer()); + ASSERT_EQ(SCREEN_ID_INVALID, screenId); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + VirtualScreenOption virtualOption2{}; + virtualOption2.name_ = "testVirtualOption"; + DmVirtualScreenOption dmVirtualScreenOption2(virtualOption2); + errCode = proxy2.CreateVirtualScreen(dmVirtualScreenOption2, nullptr, screenId, surface->GetProducer()); + ASSERT_EQ(SCREEN_ID_INVALID, screenId); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + errCode = proxy2.CreateVirtualScreen(dmVirtualScreenOption2, displayManagerAgent, screenId, surface->GetProducer()); + ASSERT_EQ(ERR_OK, errCode); + + screenId = SCREEN_ID_INVALID; + remoteMocker->sendRequestResult_ = 1; + errCode = proxy2.CreateVirtualScreen(dmVirtualScreenOption2, displayManagerAgent, screenId, surface->GetProducer()); + ASSERT_EQ(SCREEN_ID_INVALID, screenId); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -165,19 +221,19 @@ HWTEST_F(DisplayManagerProxyTest, DestroyVirtualScreen01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); ASSERT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.DestroyVirtualScreen(0); - ASSERT_EQ(DMError::DM_ERROR_REMOTE_CREATE_FAILED, result1); + ErrCode errCode = proxy1.DestroyVirtualScreen(0, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.DestroyVirtualScreen(0); - ASSERT_EQ(DMError::DM_OK, result2); + errCode = proxy2.DestroyVirtualScreen(0, dmError_); + ASSERT_EQ(static_cast(DMError::DM_OK), dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.DestroyVirtualScreen(0); - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.DestroyVirtualScreen(0, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -189,22 +245,23 @@ HWTEST_F(DisplayManagerProxyTest, SetVirtualScreenSurface01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); ASSERT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.SetVirtualScreenSurface(0, nullptr); - ASSERT_EQ(DMError::DM_ERROR_REMOTE_CREATE_FAILED, result1); + ErrCode errCode = proxy1.SetVirtualScreenSurface(0, nullptr, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetVirtualScreenSurface(0, nullptr, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result2 = proxy2.SetVirtualScreenSurface(0, nullptr); - ASSERT_EQ(DMError::DM_OK, result2); - sptr surface = OHOS::IConsumerSurface::Create(); - auto result3 = proxy2.SetVirtualScreenSurface(0, surface->GetProducer()); - ASSERT_EQ(DMError::DM_OK, result3); + sptr surface = IConsumerSurface::Create(); + errCode = proxy2.SetVirtualScreenSurface(0, surface->GetProducer(), dmError_); + ASSERT_EQ(static_cast(DMError::DM_OK), dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result4 = proxy2.SetVirtualScreenSurface(0, surface->GetProducer()); - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result4); + errCode = proxy2.SetVirtualScreenSurface(0, surface->GetProducer(), dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -216,19 +273,19 @@ HWTEST_F(DisplayManagerProxyTest, SetOrientation01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); ASSERT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.SetOrientation(0, Orientation::VERTICAL); - ASSERT_TRUE(DMError::DM_OK != result1); + ErrCode errCode = proxy1.SetOrientation(0, static_cast(Orientation::VERTICAL), dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetOrientation(0, Orientation::VERTICAL); - ASSERT_TRUE(DMError::DM_OK == result2); + errCode = proxy2.SetOrientation(0, static_cast(Orientation::VERTICAL), dmError_); + ASSERT_EQ(static_cast(DMError::DM_OK), dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetOrientation(0, Orientation::VERTICAL); - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.SetOrientation(0, static_cast(Orientation::VERTICAL), dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -240,18 +297,23 @@ HWTEST_F(DisplayManagerProxyTest, GetDisplaySnapshot01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); ASSERT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.GetDisplaySnapshot(0); - ASSERT_EQ(nullptr, result1); + int32_t errorCode; + std::shared_ptr pixelMap; + ErrCode errCode = proxy1.GetDisplaySnapshot(0, errorCode, false, false, pixelMap); + ASSERT_EQ(nullptr, pixelMap); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.GetDisplaySnapshot(0, errorCode, false, false, pixelMap); + ASSERT_EQ(nullptr, pixelMap); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result2 = proxy2.GetDisplaySnapshot(0); - ASSERT_EQ(nullptr, result2); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetDisplaySnapshot(0); - ASSERT_EQ(nullptr, result3); + errCode = proxy2.GetDisplaySnapshot(0, errorCode, false, false, pixelMap); + ASSERT_EQ(nullptr, pixelMap); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -261,21 +323,23 @@ HWTEST_F(DisplayManagerProxyTest, GetDisplaySnapshot01, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, GetScreenSupportedColorGamuts01, TestSize.Level1) { - std::vector gamutVector; + std::vector gamutVector; DisplayManagerProxy proxy1(nullptr); ASSERT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.GetScreenSupportedColorGamuts(0, gamutVector); - ASSERT_EQ(DMError::DM_ERROR_NULLPTR, result1); + ErrCode errCode = proxy1.GetScreenSupportedColorGamuts(0, gamutVector, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); gamutVector.clear(); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - auto result2 = proxy2.GetScreenSupportedColorGamuts(0, gamutVector); - ASSERT_EQ(DMError::DM_OK, result2); + errCode = proxy2.GetScreenSupportedColorGamuts(0, gamutVector, dmError_); + ASSERT_EQ(static_cast(DMError::DM_OK), dmError_); + ASSERT_EQ(ERR_OK, errCode); + remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetScreenSupportedColorGamuts(0, gamutVector); - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.GetScreenSupportedColorGamuts(0, gamutVector, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -287,23 +351,24 @@ HWTEST_F(DisplayManagerProxyTest, GetScreenColorGamut01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); ASSERT_EQ(nullptr, proxy1.remoteObject_); - ScreenColorGamut screenColorGamut; - auto result1 = proxy1.GetScreenColorGamut(0, screenColorGamut); - ASSERT_EQ(DMError::DM_ERROR_NULLPTR, result1); + uint32_t screenColorGamut; + ErrCode errCode = proxy1.GetScreenColorGamut(0, screenColorGamut, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - screenColorGamut = ScreenColorGamut::COLOR_GAMUT_ADOBE_RGB; - auto result2 = proxy2.GetScreenColorGamut(0, screenColorGamut); - ASSERT_EQ(DMError::DM_OK, result2); - ASSERT_EQ(ScreenColorGamut::COLOR_GAMUT_NATIVE, screenColorGamut); + screenColorGamut = static_cast(ScreenColorGamut::COLOR_GAMUT_ADOBE_RGB); + errCode = proxy2.GetScreenColorGamut(0, screenColorGamut, dmError_); + ASSERT_EQ(static_cast(DMError::DM_OK), dmError_); + ASSERT_EQ(ERR_OK, errCode); + ASSERT_EQ(static_cast(ScreenColorGamut::COLOR_GAMUT_NATIVE), screenColorGamut); - screenColorGamut = ScreenColorGamut::COLOR_GAMUT_ADOBE_RGB; + screenColorGamut = static_cast(ScreenColorGamut::COLOR_GAMUT_ADOBE_RGB); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetScreenColorGamut(0, screenColorGamut); - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); - ASSERT_EQ(ScreenColorGamut::COLOR_GAMUT_ADOBE_RGB, screenColorGamut); + errCode = proxy2.GetScreenColorGamut(0, screenColorGamut, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); + ASSERT_EQ(static_cast(ScreenColorGamut::COLOR_GAMUT_ADOBE_RGB), screenColorGamut); } /** @@ -314,19 +379,19 @@ HWTEST_F(DisplayManagerProxyTest, GetScreenColorGamut01, TestSize.Level1) HWTEST_F(DisplayManagerProxyTest, SetScreenColorGamut01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.SetScreenColorGamut(0, 3); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.SetScreenColorGamut(0, 3, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - auto result2 = proxy2.SetScreenColorGamut(0, 3); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetScreenColorGamut(0, 3, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenColorGamut(0, 3); - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.SetScreenColorGamut(0, 3, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -337,24 +402,25 @@ HWTEST_F(DisplayManagerProxyTest, SetScreenColorGamut01, TestSize.Level1) HWTEST_F(DisplayManagerProxyTest, GetScreenGamutMap01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - ScreenGamutMap gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION; - auto result1 = proxy1.GetScreenGamutMap(0, gamutMap); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + auto gamutMap = static_cast(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION); + ErrCode errCode = proxy1.GetScreenGamutMap(0, gamutMap, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION; - auto result2 = proxy2.GetScreenGamutMap(0, gamutMap); - EXPECT_EQ(DMError::DM_OK, result2); - EXPECT_EQ(ScreenGamutMap::GAMUT_MAP_CONSTANT, gamutMap); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + gamutMap = static_cast(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION); + errCode = proxy2.GetScreenGamutMap(0, gamutMap, dmError_); + ASSERT_EQ(static_cast(DMError::DM_OK), dmError_); + ASSERT_EQ(static_cast(ScreenGamutMap::GAMUT_MAP_CONSTANT), gamutMap); + ASSERT_EQ(ERR_OK, errCode); - gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION; + gamutMap = static_cast(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetScreenGamutMap(0, gamutMap); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); - EXPECT_EQ(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION, gamutMap); + errCode = proxy2.GetScreenGamutMap(0, gamutMap, dmError_); + ASSERT_EQ(static_cast(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION), gamutMap); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -365,24 +431,25 @@ HWTEST_F(DisplayManagerProxyTest, GetScreenGamutMap01, TestSize.Level1) HWTEST_F(DisplayManagerProxyTest, SetScreenGamutMap01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - ScreenGamutMap gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION; - auto result1 = proxy1.SetScreenGamutMap(0, gamutMap); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + auto gamutMap = static_cast(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION); + ErrCode errCode = proxy1.SetScreenGamutMap(0, gamutMap, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION; - auto result2 = proxy2.SetScreenGamutMap(0, gamutMap); - EXPECT_EQ(DMError::DM_OK, result2); - EXPECT_EQ(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION, gamutMap); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + gamutMap = static_cast(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION); + errCode = proxy2.SetScreenGamutMap(0, gamutMap, dmError_); + ASSERT_EQ(static_cast(DMError::DM_OK), dmError_); + ASSERT_EQ(static_cast(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION), gamutMap); + ASSERT_EQ(ERR_OK, errCode); - gamutMap = ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION; + gamutMap = static_cast(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenGamutMap(0, gamutMap); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); - EXPECT_EQ(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION, gamutMap); + errCode = proxy2.SetScreenGamutMap(0, gamutMap, dmError_); + ASSERT_EQ(static_cast(ScreenGamutMap::GAMUT_MAP_HDR_EXTENSION), gamutMap); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -393,20 +460,19 @@ HWTEST_F(DisplayManagerProxyTest, SetScreenGamutMap01, TestSize.Level1) HWTEST_F(DisplayManagerProxyTest, SetScreenColorTransform01, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.SetScreenColorTransform(0); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.SetScreenColorTransform(0); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetScreenColorTransform(0); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetScreenColorTransform(0); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenColorTransform(0); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.SetScreenColorTransform(0); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -416,13 +482,24 @@ HWTEST_F(DisplayManagerProxyTest, SetScreenColorTransform01, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, RegisterDisplayManagerAgent01, TestSize.Level1) { - sptr iRemoteObject = new IRemoteObjectMocker(); - DisplayManagerProxy proxy1(iRemoteObject); - EXPECT_NE(nullptr, proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); sptr displayManagerAgent = new DisplayManagerAgentDefault(); - DisplayManagerAgentType type = DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER; - DMError result01 = proxy1.RegisterDisplayManagerAgent(displayManagerAgent, type); - EXPECT_EQ(result01, DMError::DM_OK); + auto type = static_cast(DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER); + ErrCode errCode = proxy1.RegisterDisplayManagerAgent(displayManagerAgent, type, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.RegisterDisplayManagerAgent(nullptr, type, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + errCode = proxy2.RegisterDisplayManagerAgent(displayManagerAgent, type, dmError_); + ASSERT_EQ(ERR_OK, errCode); + + remoteMocker->sendRequestResult_ = 1; + errCode = proxy2.RegisterDisplayManagerAgent(displayManagerAgent, type, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -432,13 +509,25 @@ HWTEST_F(DisplayManagerProxyTest, RegisterDisplayManagerAgent01, TestSize.Level1 */ HWTEST_F(DisplayManagerProxyTest, UnregisterDisplayManagerAgent01, TestSize.Level1) { - sptr iRemoteObject = new IRemoteObjectMocker(); - DisplayManagerProxy proxy1(iRemoteObject); - EXPECT_NE(nullptr, proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); sptr displayManagerAgent = new DisplayManagerAgentDefault(); - DisplayManagerAgentType type = DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER; - DMError result01 = proxy1.UnregisterDisplayManagerAgent(displayManagerAgent, type); - EXPECT_EQ(result01, DMError::DM_OK); + auto type = static_cast(DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER); + ErrCode errCode = proxy1.UnregisterDisplayManagerAgent(displayManagerAgent, type, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.UnregisterDisplayManagerAgent(nullptr, type, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + errCode = proxy2.UnregisterDisplayManagerAgent(displayManagerAgent, type, dmError_); + ASSERT_EQ(ERR_OK, errCode); + ASSERT_EQ(static_cast(DMError::DM_OK), dmError_); + + remoteMocker->sendRequestResult_ = 1; + errCode = proxy2.UnregisterDisplayManagerAgent(displayManagerAgent, type, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -448,17 +537,22 @@ HWTEST_F(DisplayManagerProxyTest, UnregisterDisplayManagerAgent01, TestSize.Leve */ HWTEST_F(DisplayManagerProxyTest, WakeUpBegin01, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + auto reason = static_cast(PowerStateChangeReason::POWER_BUTTON); + bool isSucc = false; + ErrCode errCode = proxy1.WakeUpBegin(reason, isSucc); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON; - auto result1 = proxy1.WakeUpBegin(reason); - EXPECT_EQ(result1, false); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.WakeUpBegin(reason, isSucc); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.WakeUpBegin(reason); - EXPECT_EQ(result2, false); + errCode = proxy2.WakeUpBegin(reason, isSucc); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -468,215 +562,21 @@ HWTEST_F(DisplayManagerProxyTest, WakeUpBegin01, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, WakeUpEnd01, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); - - auto result1 = proxy1.WakeUpEnd(); - EXPECT_EQ(result1, false); - - remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.WakeUpEnd(); - EXPECT_EQ(result2, false); -} - -/** - * @tc.name: GetPixelFormat - * @tc.desc: test DisplayManagerProxy::GetPixelFormat - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, GetPixelFormat, TestSize.Level1) -{ - GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT1}; DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.GetPixelFormat(0, pixelFormat); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - + ASSERT_EQ(nullptr, proxy1.remoteObject_); + bool isSucc = false; + ErrCode errCode = proxy1.WakeUpEnd(isSucc); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetPixelFormat(0, pixelFormat); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.WakeUpEnd(isSucc); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetPixelFormat(0, pixelFormat); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: SetPixelFormat - * @tc.desc: test DisplayManagerProxy::SetPixelFormat - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, SetPixelFormat, TestSize.Level1) -{ - GraphicPixelFormat pixelFormat = GraphicPixelFormat{GRAPHIC_PIXEL_FMT_CLUT1}; - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.SetPixelFormat(0, pixelFormat); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetPixelFormat(0, pixelFormat); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetPixelFormat(0, pixelFormat); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: GetSupportedHDRFormats - * @tc.desc: test DisplayManagerProxy::GetSupportedHDRFormats - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, GetSupportedHDRFormats, TestSize.Level1) -{ - std::vector hdrFormats; - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.GetSupportedHDRFormats(0, hdrFormats); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetSupportedHDRFormats(0, hdrFormats); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetSupportedHDRFormats(0, hdrFormats); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: SetScreenHDRFormat - * @tc.desc: test DisplayManagerProxy::SetScreenHDRFormat - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, SetScreenHDRFormat, TestSize.Level1) -{ - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.SetScreenHDRFormat(0, 0); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetScreenHDRFormat(0, 0); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenHDRFormat(0, 0); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: GetScreenHDRFormat - * @tc.desc: test DisplayManagerProxy::GetScreenHDRFormat - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, GetScreenHDRFormat, TestSize.Level1) -{ - ScreenHDRFormat hdrFormats = ScreenHDRFormat{VIDEO_HLG}; - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.GetScreenHDRFormat(0, hdrFormats); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetScreenHDRFormat(0, hdrFormats); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetScreenHDRFormat(0, hdrFormats); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: GetSupportedColorSpaces - * @tc.desc: test DisplayManagerProxy::GetSupportedColorSpaces - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, GetSupportedColorSpaces, TestSize.Level1) -{ - std::vector colorSpaces; - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.GetSupportedColorSpaces(0, colorSpaces); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetSupportedColorSpaces(0, colorSpaces); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetSupportedColorSpaces(0, colorSpaces); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: GetScreenColorSpace - * @tc.desc: test DisplayManagerProxy::GetScreenColorSpace - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, GetScreenColorSpace, TestSize.Level1) -{ - GraphicCM_ColorSpaceType colorSpaces; - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.GetScreenColorSpace(0, colorSpaces); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetScreenColorSpace(0, colorSpaces); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetScreenColorSpace(0, colorSpaces); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: SetScreenColorSpace - * @tc.desc: test DisplayManagerProxy::SetScreenColorSpace - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, SetScreenColorSpace, TestSize.Level1) -{ - GraphicCM_ColorSpaceType colorSpaces = GraphicCM_ColorSpaceType{GRAPHIC_CM_BT601_EBU_FULL}; - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.SetScreenColorSpace(0, colorSpaces); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetScreenColorSpace(0, colorSpaces); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenColorSpace(0, colorSpaces); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.WakeUpEnd(isSucc); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -686,17 +586,22 @@ HWTEST_F(DisplayManagerProxyTest, SetScreenColorSpace, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SuspendBegin, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + auto reason = static_cast(PowerStateChangeReason::POWER_BUTTON); + bool isSucc = false; + ErrCode errCode = proxy1.SuspendBegin(reason, isSucc); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - PowerStateChangeReason reason = PowerStateChangeReason{0}; - auto result1 = proxy1.SuspendBegin(reason); - EXPECT_EQ(result1, false); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SuspendBegin(reason, isSucc); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.SuspendBegin(reason); - EXPECT_EQ(result2, false); + errCode = proxy2.SuspendBegin(reason, isSucc); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -706,16 +611,21 @@ HWTEST_F(DisplayManagerProxyTest, SuspendBegin, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SuspendEnd, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + bool isSucc = false; + ErrCode errCode = proxy1.SuspendEnd(isSucc); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.SuspendEnd(); - EXPECT_EQ(result1, false); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SuspendEnd(isSucc); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.SuspendEnd(); - EXPECT_EQ(result2, false); + errCode = proxy2.SuspendEnd(isSucc); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -725,18 +635,23 @@ HWTEST_F(DisplayManagerProxyTest, SuspendEnd, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SetScreenPowerForAll, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + auto state = static_cast(ScreenPowerState::POWER_ON); + auto reason = static_cast(PowerStateChangeReason::POWER_BUTTON); + bool isSucc = false; + ErrCode errCode = proxy1.SetScreenPowerForAll(state, reason, isSucc); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - ScreenPowerState state = ScreenPowerState{0}; - PowerStateChangeReason reason = PowerStateChangeReason{0}; - auto result1 = proxy1.SetScreenPowerForAll(state, reason); - EXPECT_EQ(result1, false); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetScreenPowerForAll(state, reason, isSucc); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.SetScreenPowerForAll(state, reason); - EXPECT_EQ(result2, false); + errCode = proxy2.SetScreenPowerForAll(state, reason, isSucc); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -746,18 +661,23 @@ HWTEST_F(DisplayManagerProxyTest, SetScreenPowerForAll, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SetSpecifiedScreenPower, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + auto state = static_cast(ScreenPowerState::POWER_ON); + auto reason = static_cast(PowerStateChangeReason::POWER_BUTTON); + bool isSucc = false; + ErrCode errCode = proxy1.SetSpecifiedScreenPower(0, state, reason, isSucc); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - ScreenPowerState state = ScreenPowerState{0}; - PowerStateChangeReason reason = PowerStateChangeReason{0}; - auto result1 = proxy1.SetSpecifiedScreenPower(0, state, reason); - EXPECT_EQ(result1, false); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetSpecifiedScreenPower(0, state, reason, isSucc); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.SetSpecifiedScreenPower(0, state, reason); - EXPECT_EQ(result2, false); + errCode = proxy2.SetSpecifiedScreenPower(0, state, reason, isSucc); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -767,17 +687,22 @@ HWTEST_F(DisplayManagerProxyTest, SetSpecifiedScreenPower, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SetDisplayState, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + auto state = static_cast(DisplayState::UNKNOWN); + bool isSucc = false; + ErrCode errCode = proxy1.SetDisplayState(state, isSucc); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - DisplayState state = DisplayState{0}; - auto result1 = proxy1.SetDisplayState(state); - EXPECT_EQ(result1, false); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetDisplayState(state, isSucc); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.SetDisplayState(state); - EXPECT_EQ(result2, false); + errCode = proxy2.SetDisplayState(state, isSucc); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -787,17 +712,23 @@ HWTEST_F(DisplayManagerProxyTest, SetDisplayState, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, AddSurfaceNodeToDisplay, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + RSSurfaceNodeConfig rsSurfaceNodeConfig; + std::shared_ptr surfaceNode = std::make_shared(rsSurfaceNodeConfig, true, 0); + std::shared_ptr dmRsSurfaceNode = std::make_shared(surfaceNode); + ErrCode errCode = proxy1.AddSurfaceNodeToDisplay(0, dmRsSurfaceNode, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - std::shared_ptr surfaceNode; - auto result1 = proxy1.AddSurfaceNodeToDisplay(0, surfaceNode, true); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result1); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.AddSurfaceNodeToDisplay(0, dmRsSurfaceNode, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.AddSurfaceNodeToDisplay(0, surfaceNode, true); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result2); + errCode = proxy2.AddSurfaceNodeToDisplay(0, dmRsSurfaceNode, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -807,17 +738,23 @@ HWTEST_F(DisplayManagerProxyTest, AddSurfaceNodeToDisplay, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, RemoveSurfaceNodeFromDisplay, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + RSSurfaceNodeConfig rsSurfaceNodeConfig; + std::shared_ptr surfaceNode = std::make_shared(rsSurfaceNodeConfig, true, 0); + std::shared_ptr dmRsSurfaceNode = std::make_shared(surfaceNode); + ErrCode errCode = proxy1.RemoveSurfaceNodeFromDisplay(0, dmRsSurfaceNode, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - std::shared_ptr surfaceNode; - auto result1 = proxy1.RemoveSurfaceNodeFromDisplay(0, surfaceNode); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result1); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.RemoveSurfaceNodeFromDisplay(0, dmRsSurfaceNode, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.RemoveSurfaceNodeFromDisplay(0, surfaceNode); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result2); + errCode = proxy2.RemoveSurfaceNodeFromDisplay(0, dmRsSurfaceNode, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -827,17 +764,21 @@ HWTEST_F(DisplayManagerProxyTest, RemoveSurfaceNodeFromDisplay, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, HasPrivateWindow, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + bool hasPrivateWindow = false; + ErrCode errCode = proxy1.HasPrivateWindow(0, hasPrivateWindow, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - bool hasPrivateWindow = true; - auto result1 = proxy1.HasPrivateWindow(0, hasPrivateWindow); - EXPECT_EQ(DMError::DM_OK, result1); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.HasPrivateWindow(0, hasPrivateWindow, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.HasPrivateWindow(0, hasPrivateWindow); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result2); + errCode = proxy2.HasPrivateWindow(0, hasPrivateWindow, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -847,17 +788,23 @@ HWTEST_F(DisplayManagerProxyTest, HasPrivateWindow, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SetFreeze, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + std::vector displayIds; + bool isFreeze = true; + bool isSucc = false; + ErrCode errCode = proxy1.SetFreeze(displayIds, isFreeze, isSucc); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - std::vector displayIds; - auto result1 = proxy1.SetFreeze(displayIds, true); - EXPECT_TRUE(result1); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetFreeze(displayIds, isFreeze, isSucc); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.SetFreeze(displayIds, true); - EXPECT_FALSE(result2); + errCode = proxy2.SetFreeze(displayIds, isFreeze, isSucc); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -867,17 +814,22 @@ HWTEST_F(DisplayManagerProxyTest, SetFreeze, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, GetDisplayState, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); - + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); DisplayId displayId = 0; - auto result1 = proxy1.GetDisplayState(displayId); - EXPECT_EQ(result1, DisplayState::UNKNOWN); + uint32_t displayState = 0; + ErrCode errCode = proxy1.GetDisplayState(displayId, displayState); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.GetDisplayState(displayId, displayState); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.GetDisplayState(displayId); - EXPECT_EQ(result2, DisplayState::UNKNOWN); + errCode = proxy2.GetDisplayState(displayId, displayState); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -887,16 +839,22 @@ HWTEST_F(DisplayManagerProxyTest, GetDisplayState, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, GetScreenPower, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + DisplayId displayId = 0; + uint32_t screenPowerState = 0; + ErrCode errCode = proxy1.GetScreenPower(displayId, screenPowerState); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.GetScreenPower(0); - EXPECT_EQ(result1, ScreenPowerState::POWER_ON); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.GetScreenPower(displayId, screenPowerState); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.GetScreenPower(0); - EXPECT_EQ(result2, ScreenPowerState::INVALID_STATE); + errCode = proxy2.GetScreenPower(displayId, screenPowerState); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -906,16 +864,21 @@ HWTEST_F(DisplayManagerProxyTest, GetScreenPower, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, GetAllDisplayIds, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + std::vector displayIds; + ErrCode errCode = proxy1.GetAllDisplayIds(displayIds); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.GetAllDisplayIds(); - EXPECT_TRUE(result1.empty()); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.GetAllDisplayIds(displayIds); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result2 = proxy1.GetAllDisplayIds(); - EXPECT_TRUE(result2.empty()); + errCode = proxy2.GetAllDisplayIds(displayIds); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -926,20 +889,20 @@ HWTEST_F(DisplayManagerProxyTest, GetAllDisplayIds, TestSize.Level1) HWTEST_F(DisplayManagerProxyTest, GetCutoutInfo, TestSize.Level1) { DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - auto result1 = proxy1.GetCutoutInfo(0); - EXPECT_EQ(nullptr, result1); - + ASSERT_EQ(nullptr, proxy1.remoteObject_); + sptr cutoutInfo; + ErrCode errCode = proxy1.GetCutoutInfo(0, cutoutInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetCutoutInfo(0); - EXPECT_EQ(nullptr, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.GetCutoutInfo(0, cutoutInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetCutoutInfo(0); - EXPECT_EQ(nullptr, result3); + errCode = proxy2.GetCutoutInfo(0, cutoutInfo); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -949,17 +912,21 @@ HWTEST_F(DisplayManagerProxyTest, GetCutoutInfo, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, NotifyDisplayEvent, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy1(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy1.remoteObject_); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + auto event = static_cast(DisplayEvent::UNLOCK); + ErrCode errCode = proxy1.NotifyDisplayEvent(event); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - DisplayEvent event = DisplayEvent::UNLOCK; - proxy1.NotifyDisplayEvent(event); - EXPECT_TRUE(true); + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.NotifyDisplayEvent(event); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - proxy1.NotifyDisplayEvent(event); - EXPECT_TRUE(true); + errCode = proxy2.NotifyDisplayEvent(event); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -969,26 +936,24 @@ HWTEST_F(DisplayManagerProxyTest, NotifyDisplayEvent, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, MakeMirror, TestSize.Level1) { - ScreenId mainScreenId = static_cast(0); + ScreenId mainScreenId = 0; std::vector mirrorScreenId; mirrorScreenId.emplace_back(1001); - ScreenId screenGroupId{0}; + ScreenId screenGroupId = 0; DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.MakeMirror(mainScreenId, mirrorScreenId, screenGroupId, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.MakeMirror(mainScreenId, mirrorScreenId, screenGroupId); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.MakeMirror(mainScreenId, mirrorScreenId, screenGroupId); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.MakeMirror(mainScreenId, mirrorScreenId, screenGroupId, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.MakeMirror(mainScreenId, mirrorScreenId, screenGroupId); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.MakeMirror(mainScreenId, mirrorScreenId, screenGroupId, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1001,21 +966,19 @@ HWTEST_F(DisplayManagerProxyTest, StopMirror, TestSize.Level1) std::vector mirrorScreenId; mirrorScreenId.emplace_back(1001); DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.StopMirror(mirrorScreenId, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.StopMirror(mirrorScreenId); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.StopMirror(mirrorScreenId); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.StopMirror(mirrorScreenId, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.StopMirror(mirrorScreenId); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.StopMirror(mirrorScreenId, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1025,23 +988,22 @@ HWTEST_F(DisplayManagerProxyTest, StopMirror, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, GetScreenInfoById, TestSize.Level1) { - ScreenId screenId = static_cast(0); + ScreenId screenId = 0; + sptr screenInfo; DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.GetScreenInfoById(screenId, screenInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.GetScreenInfoById(screenId); - EXPECT_EQ(nullptr, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetScreenInfoById(screenId); - EXPECT_EQ(nullptr, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.GetScreenInfoById(screenId, screenInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetScreenInfoById(screenId); - EXPECT_EQ(nullptr, result3); + errCode = proxy2.GetScreenInfoById(screenId, screenInfo); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1051,23 +1013,22 @@ HWTEST_F(DisplayManagerProxyTest, GetScreenInfoById, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, GetScreenGroupInfoById, TestSize.Level1) { - ScreenId screenId = static_cast(0); + ScreenId screenId = 0; DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + sptr screenGroupInfo; + ErrCode errCode = proxy1.GetScreenGroupInfoById(screenId, screenGroupInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.GetScreenGroupInfoById(screenId); - EXPECT_EQ(nullptr, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetScreenGroupInfoById(screenId); - EXPECT_EQ(nullptr, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.GetScreenGroupInfoById(screenId, screenGroupInfo); + ASSERT_EQ(ERR_INVALID_DATA, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetScreenGroupInfoById(screenId); - EXPECT_EQ(nullptr, result3); + errCode = proxy2.GetScreenGroupInfoById(screenId, screenGroupInfo); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1077,23 +1038,21 @@ HWTEST_F(DisplayManagerProxyTest, GetScreenGroupInfoById, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, GetAllScreenInfos, TestSize.Level1) { - std::vector> screenInfos{nullptr}; + std::vector> screenInfos; DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.GetAllScreenInfos(screenInfos, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.GetAllScreenInfos(screenInfos); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetAllScreenInfos(screenInfos); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.GetAllScreenInfos(screenInfos, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetAllScreenInfos(screenInfos); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.GetAllScreenInfos(screenInfos, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1103,29 +1062,27 @@ HWTEST_F(DisplayManagerProxyTest, GetAllScreenInfos, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, MakeExpand, TestSize.Level1) { - ScreenId screenId_ = static_cast(0); + ScreenId screenId_ = 0; std::vector screenId; screenId.push_back(screenId_); std::vector startPoint; Point point{0, 0}; startPoint.push_back(point); - ScreenId screenGroupId{0}; + ScreenId screenGroupId = 0; DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.MakeExpand(screenId, startPoint, screenGroupId, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.MakeExpand(screenId, startPoint, screenGroupId); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.MakeExpand(screenId, startPoint, screenGroupId); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.MakeExpand(screenId, startPoint, screenGroupId, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.MakeExpand(screenId, startPoint, screenGroupId); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.MakeExpand(screenId, startPoint, screenGroupId, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1135,25 +1092,22 @@ HWTEST_F(DisplayManagerProxyTest, MakeExpand, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, StopExpand, TestSize.Level1) { - ScreenId screenId_ = static_cast(0); - std::vector screenId; - screenId.push_back(screenId_); + std::vector expandScreenIds; + expandScreenIds.push_back(0); DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.StopExpand(expandScreenIds, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.StopExpand(screenId); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.StopExpand(screenId); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.StopExpand(expandScreenIds, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.StopExpand(screenId); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.StopExpand(expandScreenIds, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1163,25 +1117,22 @@ HWTEST_F(DisplayManagerProxyTest, StopExpand, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, RemoveVirtualScreenFromGroup, TestSize.Level1) { - ScreenId screenId_ = static_cast(0); - std::vector screenId; - screenId.push_back(screenId_); + std::vector screens; + screens.push_back(0); DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.RemoveVirtualScreenFromGroup(screens); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - proxy1.RemoveVirtualScreenFromGroup(screenId); - EXPECT_TRUE(true); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - proxy2.RemoveVirtualScreenFromGroup(screenId); - EXPECT_TRUE(true); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.RemoveVirtualScreenFromGroup(screens); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - proxy2.RemoveVirtualScreenFromGroup(screenId); - EXPECT_TRUE(true); + errCode = proxy2.RemoveVirtualScreenFromGroup(screens); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1191,23 +1142,21 @@ HWTEST_F(DisplayManagerProxyTest, RemoveVirtualScreenFromGroup, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SetScreenActiveMode, TestSize.Level1) { - ScreenId screenId = static_cast(0); + ScreenId screenId = 0; DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.SetScreenActiveMode(screenId, 0, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.SetScreenActiveMode(screenId, 0); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetScreenActiveMode(screenId, 0); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetScreenActiveMode(screenId, 0, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenActiveMode(screenId, 0); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.SetScreenActiveMode(screenId, 0, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1217,24 +1166,22 @@ HWTEST_F(DisplayManagerProxyTest, SetScreenActiveMode, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SetVirtualPixelRatio, TestSize.Level1) { - ScreenId screenId = static_cast(0); + ScreenId screenId = 0; float virtualPixelRatio = 0; DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.SetVirtualPixelRatio(screenId, virtualPixelRatio, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.SetVirtualPixelRatio(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetVirtualPixelRatio(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetVirtualPixelRatio(screenId, virtualPixelRatio, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetVirtualPixelRatio(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.SetVirtualPixelRatio(screenId, virtualPixelRatio, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1244,12 +1191,21 @@ HWTEST_F(DisplayManagerProxyTest, SetVirtualPixelRatio, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SetResolution, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); ScreenId screenId = 0; - auto result = proxy.SetResolution(screenId, 50, 100, 1.00); - EXPECT_EQ(DMError::DM_OK, result); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.SetResolution(screenId, 50, 100, 1.00, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetResolution(screenId, 50, 100, 1.00, dmError_); + ASSERT_EQ(ERR_OK, errCode); + + remoteMocker->sendRequestResult_ = 1; + errCode = proxy2.SetResolution(screenId, 50, 100, 1.00, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1259,24 +1215,22 @@ HWTEST_F(DisplayManagerProxyTest, SetResolution, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, GetDensityInCurResolution, TestSize.Level1) { - ScreenId screenId = static_cast(0); + ScreenId screenId = 0; float virtualPixelRatio = 0; DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.GetDensityInCurResolution(screenId, virtualPixelRatio, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.GetDensityInCurResolution(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetDensityInCurResolution(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.GetDensityInCurResolution(screenId, virtualPixelRatio, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetDensityInCurResolution(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.GetDensityInCurResolution(screenId, virtualPixelRatio, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1286,12 +1240,21 @@ HWTEST_F(DisplayManagerProxyTest, GetDensityInCurResolution, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, IsScreenRotationLocked, TestSize.Level1) { - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); bool isLocked = true; - auto result = proxy.IsScreenRotationLocked(isLocked); - EXPECT_EQ(DMError::DM_OK, result); + DisplayManagerProxy proxy1(nullptr); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.IsScreenRotationLocked(isLocked, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); + + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy2(remoteMocker); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.IsScreenRotationLocked(isLocked, dmError_); + ASSERT_EQ(ERR_OK, errCode); + + remoteMocker->sendRequestResult_ = 1; + errCode = proxy2.IsScreenRotationLocked(isLocked, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1301,22 +1264,21 @@ HWTEST_F(DisplayManagerProxyTest, IsScreenRotationLocked, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SetScreenRotationLocked, TestSize.Level1) { + bool isLocked = true; DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.SetScreenRotationLocked(isLocked, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.SetScreenRotationLocked(true); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetScreenRotationLocked(true); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetScreenRotationLocked(isLocked, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenRotationLocked(true); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); + errCode = proxy2.SetScreenRotationLocked(isLocked, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } /** @@ -1326,273 +1288,22 @@ HWTEST_F(DisplayManagerProxyTest, SetScreenRotationLocked, TestSize.Level1) */ HWTEST_F(DisplayManagerProxyTest, SetScreenRotationLockedFromJs, TestSize.Level1) { - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - - auto result1 = proxy1.SetScreenRotationLockedFromJs(true); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetScreenRotationLockedFromJs(true); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenRotationLockedFromJs(true); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: ResizeVirtualScreen - * @tc.desc: test DisplayManagerProxy::ResizeVirtualScreen - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, ResizeVirtualScreen, TestSize.Level1) -{ - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); - ScreenId screenId = 0; - auto result = proxy.ResizeVirtualScreen(screenId, 50, 100); - EXPECT_EQ(DMError::DM_OK, result); -} - -/** - * @tc.name: MakeUniqueScreen - * @tc.desc: test DisplayManagerProxy::MakeUniqueScreen - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, MakeUniqueScreen, TestSize.Level1) -{ - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); - std::vector screenIds; - std::vector displayIds; - auto result = proxy.MakeUniqueScreen(screenIds, displayIds); - EXPECT_EQ(DMError::DM_OK, result); -} - -/** - * @tc.name: RemoveVirtualScreenFromGroup02 - * @tc.desc: test DisplayManagerProxy::RemoveVirtualScreenFromGroup02 - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, RemoveVirtualScreenFromGroup02, TestSize.Level1) -{ - ScreenId screenId_ = static_cast(0); - std::vector screenId; - screenId.push_back(screenId_); - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - - proxy1.RemoveVirtualScreenFromGroup(screenId); - EXPECT_TRUE(true); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - proxy2.RemoveVirtualScreenFromGroup(screenId); - EXPECT_TRUE(true); - - remoteMocker->sendRequestResult_ = 1; - proxy2.RemoveVirtualScreenFromGroup(screenId); - EXPECT_TRUE(true); -} - -/** - * @tc.name: SetScreenActiveMode02 - * @tc.desc: test DisplayManagerProxy::SetScreenActiveMode02 - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, SetScreenActiveMode02, TestSize.Level1) -{ - ScreenId screenId = static_cast(0); - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - - auto result1 = proxy1.SetScreenActiveMode(screenId, 0); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetScreenActiveMode(screenId, 0); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenActiveMode(screenId, 0); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: SetVirtualPixelRatio02 - * @tc.desc: test DisplayManagerProxy::SetVirtualPixelRatio02 - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, SetVirtualPixelRatio02, TestSize.Level1) -{ - ScreenId screenId = static_cast(0); - float virtualPixelRatio = 0; - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - - auto result1 = proxy1.SetVirtualPixelRatio(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetVirtualPixelRatio(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetVirtualPixelRatio(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: SetResolution02 - * @tc.desc: test DisplayManagerProxy::SetResolution02 - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, SetResolution02, TestSize.Level1) -{ - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); - ScreenId screenId = 0; - auto result = proxy.SetResolution(screenId, 50, 100, 1.00); - EXPECT_EQ(DMError::DM_OK, result); -} - -/** - * @tc.name: GetDensityInCurResolution02 - * @tc.desc: test DisplayManagerProxy::GetDensityInCurResolution02 - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, GetDensityInCurResolution02, TestSize.Level1) -{ - ScreenId screenId = static_cast(0); - float virtualPixelRatio = 0; - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - - auto result1 = proxy1.GetDensityInCurResolution(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.GetDensityInCurResolution(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.GetDensityInCurResolution(screenId, virtualPixelRatio); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: IsScreenRotationLocked02 - * @tc.desc: test DisplayManagerProxy::IsScreenRotationLocked02 - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, IsScreenRotationLocked02, TestSize.Level1) -{ - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); bool isLocked = true; - auto result = proxy.IsScreenRotationLocked(isLocked); - EXPECT_EQ(DMError::DM_OK, result); -} - -/** - * @tc.name: SetScreenRotationLocked02 - * @tc.desc: test DisplayManagerProxy::SetScreenRotationLocked02 - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, SetScreenRotationLocked02, TestSize.Level1) -{ DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); + ASSERT_EQ(nullptr, proxy1.remoteObject_); + ErrCode errCode = proxy1.SetScreenRotationLockedFromJs(isLocked, dmError_); + ASSERT_EQ(ERR_INVALID_DATA, errCode); - auto result1 = proxy1.SetScreenRotationLocked(true); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - sptr remoteMocker = new RemoteMocker(); DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetScreenRotationLocked(true); - EXPECT_EQ(DMError::DM_OK, result2); + ASSERT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); + errCode = proxy2.SetScreenRotationLockedFromJs(isLocked, dmError_); + ASSERT_EQ(ERR_OK, errCode); remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenRotationLocked(true); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: SetScreenRotationLockedFromJs02 - * @tc.desc: test DisplayManagerProxy::SetScreenRotationLockedFromJs02 - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, SetScreenRotationLockedFromJs02, TestSize.Level1) -{ - DisplayManagerProxy proxy1(nullptr); - EXPECT_EQ(nullptr, proxy1.remoteObject_); - - auto result1 = proxy1.SetScreenRotationLockedFromJs(true); - EXPECT_EQ(DMError::DM_ERROR_NULLPTR, result1); - - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy2(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy2.remoteObject_); - - auto result2 = proxy2.SetScreenRotationLockedFromJs(true); - EXPECT_EQ(DMError::DM_OK, result2); - - remoteMocker->sendRequestResult_ = 1; - auto result3 = proxy2.SetScreenRotationLockedFromJs(true); - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, result3); -} - -/** - * @tc.name: ResizeVirtualScreen02 - * @tc.desc: test DisplayManagerProxy::ResizeVirtualScreen02 - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, ResizeVirtualScreen02, TestSize.Level1) -{ - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); - ScreenId screenId = 0; - auto result = proxy.ResizeVirtualScreen(screenId, 50, 100); - EXPECT_EQ(DMError::DM_OK, result); -} - -/** - * @tc.name: MakeUniqueScreen02 - * @tc.desc: test DisplayManagerProxy::MakeUniqueScreen02 - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerProxyTest, MakeUniqueScreen02, TestSize.Level1) -{ - sptr remoteMocker = new RemoteMocker(); - DisplayManagerProxy proxy(remoteMocker); - EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); - std::vector screenIds; - std::vector displayIds; - auto result = proxy.MakeUniqueScreen(screenIds, displayIds); - EXPECT_EQ(DMError::DM_OK, result); + errCode = proxy2.SetScreenRotationLockedFromJs(isLocked, dmError_); + ASSERT_EQ(remoteMocker->sendRequestResult_, errCode); } } } // namespace Rosen -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/dmserver/test/unittest/display_manager_service_test.cpp b/dmserver/test/unittest/display_manager_service_test.cpp index 1d939b164f..af36c72c15 100644 --- a/dmserver/test/unittest/display_manager_service_test.cpp +++ b/dmserver/test/unittest/display_manager_service_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,15 +15,13 @@ #include +#include "common_test_utils.h" #include "display_manager_adapter.h" #include "display_manager_config.h" #include "display_manager_service.h" -#include "display_manager_agent_default.h" -#include "common_test_utils.h" #include "mock_rs_display_node.h" #include "scene_board_judgement.h" - using namespace testing; using namespace testing::ext; @@ -39,17 +37,16 @@ public: void SetUp() override; void TearDown() override; - void SetAceessTokenPermission(const std::string processName); - static sptr dms_; + static std::unique_ptr dms_; static constexpr DisplayId DEFAULT_DISPLAY = 0ULL; static constexpr DisplayId DEFAULT_SCREEN = 0ULL; }; -sptr DisplayManagerServiceTest::dms_ = nullptr; +std::unique_ptr DisplayManagerServiceTest::dms_ = nullptr; void DisplayManagerServiceTest::SetUpTestCase() { - dms_ = new DisplayManagerService(); + dms_ = std::make_unique(); dms_->abstractScreenController_->defaultRsScreenId_ = 0; dms_->abstractScreenController_->screenIdManager_.rs2DmsScreenIdMap_.clear(); @@ -445,7 +442,7 @@ HWTEST_F(DisplayManagerServiceTest, AddAndRemoveSurfaceNode, TestSize.Level1) std::shared_ptr surfaceNode = nullptr; DMError result = dms_->RemoveSurfaceNodeFromDisplay(DEFAULT_DISPLAY, surfaceNode); EXPECT_EQ(result, DMError::DM_ERROR_NULLPTR); - + surfaceNode = std::make_shared(RSSurfaceNodeConfig{}, true); std::shared_ptr displayNode = std::make_shared(RSDisplayNodeConfig{}); sptr info = new SupportedScreenModes; @@ -453,17 +450,6 @@ HWTEST_F(DisplayManagerServiceTest, AddAndRemoveSurfaceNode, TestSize.Level1) new AbstractScreen(nullptr, "", INVALID_SCREEN_ID, INVALID_SCREEN_ID); } -/** - * @tc.name: OnStop - * @tc.desc: DMS on stop - * @tc.type: FUNC - */ -HWTEST_F(DisplayManagerServiceTest, OnStop, TestSize.Level1) -{ - dms_->OnStop(); - ASSERT_TRUE(true); -} - /** * @tc.name: NotifyDisplayEvent * @tc.desc: NotifyDisplayEvent @@ -614,9 +600,6 @@ HWTEST_F(DisplayManagerServiceTest, SetOrientation, TestSize.Level1) Orientation orientation = Orientation::VERTICAL; auto ret = dms_->SetOrientation(screenId, orientation); ASSERT_NE(ret, DMError::DM_ERROR_INVALID_PARAM); - - orientation = Orientation::SENSOR_VERTICAL; - ASSERT_NE(ret, DMError::DM_ERROR_INVALID_PARAM); } /** diff --git a/dmserver/test/unittest/display_manager_stub_test.cpp b/dmserver/test/unittest/display_manager_stub_test.cpp index b024c9d3cf..9871dc0ac0 100644 --- a/dmserver/test/unittest/display_manager_stub_test.cpp +++ b/dmserver/test/unittest/display_manager_stub_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -14,17 +14,14 @@ */ #include - #include #include + #include "display_manager_agent_default.h" #include "display_manager_stub.h" +#include "idisplay_manager.h" #include "iremote_object_mocker.h" -#include "iconsumer_surface.h" -#include -#include "display_manager_interface.h" - using namespace testing; using namespace testing::ext; @@ -61,7 +58,6 @@ void DisplayManagerStubTest::TearDown() { } -namespace { /** * @tc.name: OnRemoteRequest01 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -75,13 +71,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest01, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_DEFAULT_DISPLAY_INFO); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest02 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -95,13 +91,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest02, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_DISPLAY_INFO_BY_ID); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest03 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -115,13 +111,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest03, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_VISIBLE_AREA_DISPLAY_INFO_BY_ID); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest04 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -135,13 +131,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest04, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_DISPLAY_INFO_BY_SCREEN); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest05 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -155,13 +151,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest05, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_CREATE_VIRTUAL_SCREEN); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest06 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -175,13 +171,14 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest06, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE); + auto code = static_cast(IDisplayManagerIpcCode:: + COMMAND_CREATE_VIRTUAL_SCREEN_IN_VIRTUALSCREENOPTION_IN_IREMOTEOBJECT_OUT_UNSIGNED_LONG_IN_IBUFFERPRODUCER); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest07 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -195,13 +192,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest07, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SET_ORIENTATION); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_DESTROY_VIRTUAL_SCREEN); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest08 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -215,13 +212,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest08, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_VIRTUAL_SCREEN_SURFACE); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest09 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -235,13 +232,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest09, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_ORIENTATION); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest10 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -255,13 +252,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest10, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_DISPLAY_SNAPSHOT); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest11 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -275,13 +272,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest11, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_SCREEN_SUPPORTED_COLOR_GAMUTS); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest12 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -295,13 +292,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest12, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_WAKE_UP_END); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_SCREEN_COLOR_GAMUT); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest13 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -315,13 +312,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest13, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_SCREEN_COLOR_GAMUT); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest14 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -335,13 +332,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest14, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SUSPEND_END); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_SCREEN_GAMUT_MAP); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest15 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -355,13 +352,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest15, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_SCREEN_GAMUT_MAP); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest16 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -375,13 +372,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest16, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_SCREEN_COLOR_TRANSFORM); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest17 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -395,13 +392,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest17, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_REGISTER_DISPLAY_MANAGER_AGENT); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest18 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -415,13 +412,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest18, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_UNREGISTER_DISPLAY_MANAGER_AGENT); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest19 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -435,13 +432,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest19, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_WAKE_UP_BEGIN); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest20 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -455,13 +452,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest20, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_WAKE_UP_END); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest21 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -475,13 +472,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest21, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SET_FREEZE_EVENT); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SUSPEND_BEGIN); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest22 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -495,13 +492,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest22, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_MIRROR); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SUSPEND_END); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest23 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -515,13 +512,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest23, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_SCREEN_INFO_BY_ID); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_SCREEN_POWER_FOR_ALL); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest24 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -535,13 +532,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest24, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_SCREEN_GROUP_INFO_BY_ID); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_SPECIFIED_SCREEN_POWER); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest25 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -555,13 +552,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest25, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_ALL_SCREEN_INFOS); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_SCREEN_POWER); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest26 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -575,13 +572,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest26, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_DISPLAY_STATE); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest27 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -595,13 +592,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest27, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCREEN_MAKE_EXPAND); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_DISPLAY_STATE); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest28 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -615,13 +612,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest28, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_REMOVE_VIRTUAL_SCREEN_FROM_SCREEN_GROUP); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_TRY_TO_CANCEL_SCREEN_OFF); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest29 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -635,13 +632,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest29, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SET_SCREEN_ACTIVE_MODE); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_ALL_DISPLAY_IDS); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest30 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -655,13 +652,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest30, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_CUTOUT_INFO); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest31 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -675,13 +672,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest31, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_GAMUTS); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_ADD_SURFACE_NODE_TO_DISPLAY); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest32 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -695,13 +692,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest32, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_REMOVE_SURFACE_NODE_FROM_DISPLAY); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest33 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -715,13 +712,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest33, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_HAS_PRIVATE_WINDOW); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest34 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -735,13 +732,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest34, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_NOTIFY_DISPLAY_EVENT); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest35 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -755,13 +752,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest35, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_FREEZE); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest36 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -775,13 +772,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest36, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_MAKE_MIRROR); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest37 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -795,13 +792,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest37, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_STOP_MIRROR); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest38 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -815,13 +812,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest38, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_SCREEN_INFO_BY_ID); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest39 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -835,13 +832,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest39, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_SCREEN_GROUP_INFO_BY_ID); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest40 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -855,13 +852,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest40, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_HAS_PRIVATE_WINDOW); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_ALL_SCREEN_INFOS); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest41 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -875,13 +872,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest41, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_GET_CUTOUT_INFO); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_MAKE_EXPAND); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest42 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -895,13 +892,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest42, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_ADD_SURFACE_NODE); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_STOP_EXPAND); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest43 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -915,13 +912,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest43, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_REMOVE_SURFACE_NODE); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_REMOVE_VIRTUAL_SCREEN_FROM_GROUP); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest44 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -935,13 +932,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest44, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCREEN_STOP_MIRROR); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_SCREEN_ACTIVE_MODE); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest45 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -955,13 +952,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest45, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCREEN_STOP_EXPAND); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_VIRTUAL_PIXEL_RATIO); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest46 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -975,13 +972,13 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest46, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_RESIZE_VIRTUAL_SCREEN); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_RESOLUTION); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + /** * @tc.name: OnRemoteRequest47 * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest @@ -995,8 +992,87 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest47, TestSize.Level1) data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); - uint32_t code = static_cast( - DisplayManagerMessage::TRANS_ID_SCENE_BOARD_MAKE_UNIQUE_SCREEN); + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_DENSITY_IN_CUR_RESOLUTION); + + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + + +/** + * @tc.name: OnRemoteRequest48 + * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerStubTest, OnRemoteRequest48, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); + + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_IS_SCREEN_ROTATION_LOCKED); + + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + + +/** + * @tc.name: OnRemoteRequest49 + * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerStubTest, OnRemoteRequest49, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); + + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_SCREEN_ROTATION_LOCKED); + + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + + +/** + * @tc.name: OnRemoteRequest50 + * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerStubTest, OnRemoteRequest50, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); + + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_SET_SCREEN_ROTATION_LOCKED_FROM_JS); + + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + + +/** + * @tc.name: OnRemoteRequest51 + * @tc.desc: test DisplayManagerStubTest::OnRemoteRequest + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerStubTest, OnRemoteRequest51, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(DisplayManagerStub::GetDescriptor()); + + auto code = static_cast(IDisplayManagerIpcCode::COMMAND_GET_ALL_DISPLAY_PHYSICAL_RESOLUTION); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); @@ -1021,6 +1097,5 @@ HWTEST_F(DisplayManagerStubTest, OnRemoteRequest48, TestSize.Level1) int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } -} } // namespace Rosen -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/extension/window_extension/test/unittest/BUILD.gn b/extension/window_extension/test/unittest/BUILD.gn index da75e1cb95..4c7769e06f 100644 --- a/extension/window_extension/test/unittest/BUILD.gn +++ b/extension/window_extension/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -112,6 +112,8 @@ config("window_extension_unittest_common_public_config") { "${window_base_path}/window_scene", "${window_base_path}/window_scene/test/mock", "${window_base_path}/window_scene/session/host/include/zidl", + + "${dmserver_gen_path}", ] } diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index 8e981669d6..3a037107e3 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,12 +16,12 @@ #ifndef OHOS_ROSEN_DM_COMMON_H #define OHOS_ROSEN_DM_COMMON_H -#include -#include #include +#include -namespace OHOS { -namespace Rosen { +#include + +namespace OHOS::Rosen { using DisplayId = uint64_t; using ScreenId = uint64_t; @@ -139,7 +139,7 @@ enum class ScreenShape : uint32_t { }; /** - * @brief displayed soure mode + * @brief displayed source mode */ enum class DisplaySourceMode : uint32_t { NONE = 0, @@ -512,11 +512,31 @@ enum class ScreenModeChangeEvent: uint32_t { END, }; -struct Point { - int32_t posX_; - int32_t posY_; - Point() : posX_(0), posY_(0) {}; - Point(int32_t posX, int32_t posY) : posX_(posX), posY_(posY) {}; +class Point : public Parcelable { +public: + int32_t posX_{ 0 }; + int32_t posY_{ 0 }; + + Point() = default; + + Point(int32_t posX, int32_t posY) : posX_(posX), posY_(posY) + {} + + bool Marshalling(Parcel& parcel) const override + { + return parcel.WriteInt32(posX_) && parcel.WriteInt32(posY_); + } + + static Point* Unmarshalling(Parcel& parcel) + { + int32_t posX; + int32_t posY; + if (!(parcel.ReadInt32(posX) && parcel.ReadInt32(posY))) { + return nullptr; + } + + return new (std::nothrow) Point(posX, posY); + } }; struct SupportedScreenModes : public RefBase { @@ -554,10 +574,37 @@ struct MultiScreenPositionOptions { /** * @brief fold display physical resolution */ -struct DisplayPhysicalResolution { - FoldDisplayMode foldDisplayMode_; - uint32_t physicalWidth_; - uint32_t physicalHeight_; +class DisplayPhysicalResolution : public Parcelable { +public: + FoldDisplayMode foldDisplayMode_{FoldDisplayMode::UNKNOWN}; + uint32_t physicalWidth_{0}; + uint32_t physicalHeight_{0}; + + DisplayPhysicalResolution() = default; + + DisplayPhysicalResolution(FoldDisplayMode foldDisplayMode, uint32_t physicalWidth, uint32_t physicalHeight) + : foldDisplayMode_(foldDisplayMode), physicalWidth_(physicalWidth), physicalHeight_(physicalHeight) + {} + + bool Marshalling(Parcel& parcel) const override + { + return parcel.WriteUint32(static_cast(foldDisplayMode_)) && + parcel.WriteUint32(physicalWidth_) && parcel.WriteUint32(physicalHeight_); + } + + static DisplayPhysicalResolution* Unmarshalling(Parcel& parcel) + { + uint32_t foldDisplayMode; + uint32_t physicalWidth; + uint32_t physicalHeight; + if (!(parcel.ReadUint32(foldDisplayMode) && parcel.ReadUint32(physicalWidth) && + parcel.ReadUint32(physicalHeight))) { + return nullptr; + } + + return new (std::nothrow) DisplayPhysicalResolution(static_cast(foldDisplayMode), + physicalWidth, physicalHeight); + } }; /** @@ -635,5 +682,4 @@ enum class DMDeviceStatus: uint32_t { STATUS_GLOBAL_FULL }; } -} #endif // OHOS_ROSEN_DM_COMMON_H diff --git a/snapshot/test/unittest/BUILD.gn b/snapshot/test/unittest/BUILD.gn index 246c4e17e0..51d1a3c17b 100644 --- a/snapshot/test/unittest/BUILD.gn +++ b/snapshot/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -12,6 +12,7 @@ # limitations under the License. import("//build/test.gni") +import("../../../windowmanager_aafwk.gni") module_out_path = "window_manager/OH-DMS/snapshot" @@ -63,6 +64,7 @@ config("utils_unittest_common_public_config") { "../../include", "../../../test/common/utils/include", "../../../utils/include", + "${dmserver_gen_path}", ] } diff --git a/test/common/mock/mock_display_manager_adapter.h b/test/common/mock/mock_display_manager_adapter.h index e6d2b8d8f0..bf18442f33 100644 --- a/test/common/mock/mock_display_manager_adapter.h +++ b/test/common/mock/mock_display_manager_adapter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -43,8 +43,6 @@ public: MOCK_METHOD1(GetDisplayInfo, sptr(DisplayId displayId)); MOCK_METHOD1(GetCutoutInfo, sptr(DisplayId displayId)); MOCK_METHOD2(GetAvailableArea, DMError(ScreenId screenId, DMRect& area)); - MOCK_METHOD2(GetSupportedHDRFormats, DMError(ScreenId screenId, std::vector& hdrFormats)); - MOCK_METHOD2(GetSupportedColorSpaces, DMError(ScreenId screenId, std::vector& colorSpaces)); MOCK_METHOD2(HasImmersiveWindow, DMError(ScreenId screenId, bool& immersive)); }; @@ -55,7 +53,6 @@ public: DisplayManagerAgentType type)); MOCK_METHOD2(UnregisterDisplayManagerAgent, DMError(const sptr& displayManagerAgent, DisplayManagerAgentType type)); - MOCK_METHOD2(RequestRotation, bool(ScreenId screenId, Rotation rotation)); MOCK_METHOD2(CreateVirtualScreen, ScreenId(VirtualScreenOption option, const sptr& displayManagerAgent)); MOCK_METHOD1(DestroyVirtualScreen, DMError(ScreenId screenId)); @@ -94,7 +91,7 @@ public: MOCK_METHOD1(IsScreenRotationLocked, DMError(bool& isLocked)); MOCK_METHOD4(SetResolution, DMError(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio)); }; -} +} // namespace Rosen } // namespace OHOS -#endif // FRAMEWORKS_WM_TEST_UT_MOCK_DISPLAY_MANAGER_ADAPTER_H \ No newline at end of file +#endif // FRAMEWORKS_WM_TEST_UT_MOCK_DISPLAY_MANAGER_ADAPTER_H diff --git a/test/demo/BUILD.gn b/test/demo/BUILD.gn index 7a9ab6fdef..ccc7cff128 100644 --- a/test/demo/BUILD.gn +++ b/test/demo/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -75,6 +75,7 @@ ohos_executable("demo_snapshot_virtual_screen") { "../../utils/include", "../../dmserver/include", "../../dm/include", + "${dmserver_gen_path}", ] deps = [ diff --git a/test/demo/demo_snapshot_virtual_screen.cpp b/test/demo/demo_snapshot_virtual_screen.cpp index 64bdbdb223..2ac12eacff 100644 --- a/test/demo/demo_snapshot_virtual_screen.cpp +++ b/test/demo/demo_snapshot_virtual_screen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -28,40 +28,48 @@ using namespace OHOS::Rosen; using namespace OHOS::Media; namespace { -const int SLEEP_US = 10 * 1000; // 10ms -const int MAX_SNAPSHOT_COUNT = 10; -const int MAX_WAIT_COUNT = 200; -const float DEFAULT_DENSITY = 2.0; +constexpr int SLEEP_US = 10 * 1000; // 10ms +constexpr int MAX_SNAPSHOT_COUNT = 10; +constexpr int MAX_WAIT_COUNT = 200; +constexpr float DEFAULT_DENSITY = 2.0; const std::string FILE_NAME = "/data/local/tmp/snapshot_virtual_screen"; } static ScreenId mainId; static ScreenId virtualScreenId; -static VirtualScreenOption InitOption(ScreenId mainId, SurfaceReader& surfaceReader) +static std::unique_ptr InitOption(ScreenId mainId, const SurfaceReader& surfaceReader) { auto defaultScreen = ScreenManager::GetInstance().GetScreenById(mainId); - VirtualScreenOption option = { - .name_ = "virtualScreen", - .width_ = defaultScreen->GetWidth(), - .height_ = defaultScreen->GetHeight(), - .density_ = DEFAULT_DENSITY, - .surface_ = surfaceReader.GetSurface(), - .flags_ = 0, - .isForShot_ = true, - }; + std::unique_ptr option = std::make_unique(); + if (option == nullptr) { + return option; + } + + option->name_ = "virtualScreen"; + option->width_ = defaultScreen->GetWidth(); + option->height_ = defaultScreen->GetHeight(); + option->density_ = DEFAULT_DENSITY; + option->surface_ = surfaceReader.GetSurface(); + option->flags_ = 0; + option->isForShot_ = true; return option; } -static bool InitMirror(SurfaceReader& surfaceReader) +static bool InitMirror(const SurfaceReader& surfaceReader) { mainId = static_cast(DisplayManager::GetInstance().GetDefaultDisplayId()); if (mainId == SCREEN_ID_INVALID) { std::cout<< "get default display id failed!" << std::endl; return false; } - VirtualScreenOption option = InitOption(mainId, surfaceReader); - virtualScreenId = ScreenManager::GetInstance().CreateVirtualScreen(option); + + std::unique_ptr option = InitOption(mainId, surfaceReader); + if (option == nullptr) { + return false; + } + + virtualScreenId = ScreenManager::GetInstance().CreateVirtualScreen(*option); std::vector mirrorIds; mirrorIds.push_back(virtualScreenId); ScreenId screenGroupId = static_cast(1); diff --git a/test/fuzztest/dms/displaymanageripc_fuzzer/BUILD.gn b/test/fuzztest/dms/displaymanageripc_fuzzer/BUILD.gn index 287831c08d..ab15588625 100644 --- a/test/fuzztest/dms/displaymanageripc_fuzzer/BUILD.gn +++ b/test/fuzztest/dms/displaymanageripc_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -25,6 +25,7 @@ ohos_fuzztest("DisplayManagerIPCFuzzTest") { "../../../../interfaces/innerkits/dm", "../../../../dmserver/include", "../../../../dm/include", + "${dmserver_gen_path}", ] configs = [ diff --git a/test/fuzztest/dms/displaymanageripc_fuzzer/displaymanageripc_fuzzer.cpp b/test/fuzztest/dms/displaymanageripc_fuzzer/displaymanageripc_fuzzer.cpp index 50a00bf6d4..c54f6eddfa 100644 --- a/test/fuzztest/dms/displaymanageripc_fuzzer/displaymanageripc_fuzzer.cpp +++ b/test/fuzztest/dms/displaymanageripc_fuzzer/displaymanageripc_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,8 +20,8 @@ #include #include -#include "display_manager_interface.h" -#include "display_manager_proxy.h" +#include "display_manager_interface_code.h" +#include "idisplay_manager.h" #include "window_manager_hilog.h" namespace OHOS ::Rosen { @@ -83,67 +83,24 @@ bool IPCFuzzTest(const uint8_t* data, size_t size) return true; } -void IPCSpecificInterfaceFuzzTest1(sptr proxy, MessageParcel& sendData, MessageParcel& reply, +void IPCSpecificInterfaceFuzzTest1(const sptr& proxy, MessageParcel& sendData, MessageParcel& reply, MessageOption& option) { - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DEFAULT_DISPLAY_INFO), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_ID), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_BY_SCREEN), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_SNAPSHOT), - sendData, reply, option); - proxy->SendRequest( - static_cast(DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT), - sendData, reply, option); - proxy->SendRequest( - static_cast(DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_WAKE_UP_END), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SUSPEND_END), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_ALL), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_ALL_DISPLAYIDS), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_NOTIFY_DISPLAY_EVENT), - sendData, reply, option); - proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_FREEZE_EVENT), - sendData, reply, option); + for (uint32_t i = 0; + i <= static_cast(IDisplayManagerIpcCode::COMMAND_GET_ALL_DISPLAY_PHYSICAL_RESOLUTION); i++) { + proxy->SendRequest(i, sendData, reply, option); + } } -void IPCSpecificInterfaceFuzzTest2(sptr proxy, MessageParcel& sendData, MessageParcel& reply, - MessageOption& option, sptr manager) +void IPCSpecificInterfaceFuzzTest2(const sptr& proxy, MessageParcel& sendData, MessageParcel& reply, + MessageOption& option, const sptr& manager) { int flags = option.GetFlags(); option.SetFlags(MessageOption::TF_SYNC); proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_CREATE_VIRTUAL_SCREEN), sendData, reply, option); - manager->DestroyVirtualScreen(static_cast(reply.ReadUint64())); + int32_t dmError; + manager->DestroyVirtualScreen(reply.ReadUint64(), dmError); option.SetFlags(flags); proxy->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN), sendData, reply, option); @@ -202,7 +159,7 @@ bool IPCInterfaceFuzzTest(const uint8_t* data, size_t size) MessageParcel sendData; MessageParcel reply; MessageOption option(flags, waitTime); - sendData.WriteInterfaceToken(proxy.first->GetDescriptor()); + sendData.WriteInterfaceToken(IDisplayManager::GetDescriptor()); uint32_t dataSize = (size - startPos) > 1024 * 1024 ? 1024 * 1024 : (size - startPos); sendData.WriteBuffer(data + startPos, dataSize); IPCSpecificInterfaceFuzzTest1(proxy.second, sendData, reply, option); diff --git a/test/fuzztest/window_scene/screensessionmgrstubagent_fuzzer/screensessionmgrstubagent_fuzzer.cpp b/test/fuzztest/window_scene/screensessionmgrstubagent_fuzzer/screensessionmgrstubagent_fuzzer.cpp index 76844cc4b7..2e20b6f5cb 100644 --- a/test/fuzztest/window_scene/screensessionmgrstubagent_fuzzer/screensessionmgrstubagent_fuzzer.cpp +++ b/test/fuzztest/window_scene/screensessionmgrstubagent_fuzzer/screensessionmgrstubagent_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,18 +13,14 @@ * limitations under the License. */ -#include -#include -#include -#include +#include "screensessionmgrstubagent_fuzzer.h" #include +#include + #include "message_option.h" #include "message_parcel.h" -#include "marshalling_helper.h" -#include "display_manager_interface.h" #include "screen_session_manager_stub.h" -#include "screensessionmgrstubagent_fuzzer.h" using namespace OHOS::Rosen; @@ -38,7 +34,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) if (data == nullptr || size < DATA_MIN_SIZE) { return false; } - + MessageParcel parcel; MessageParcel reply; MessageOption option; @@ -66,4 +62,4 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) /* Run your code on data */ OHOS::DoSomethingInterestingWithMyAPI(data, size); return 0; -} \ No newline at end of file +} diff --git a/test/fuzztest/window_scene/screensessionmgrstubstate_fuzzer/screensessionmgrstubstate_fuzzer.cpp b/test/fuzztest/window_scene/screensessionmgrstubstate_fuzzer/screensessionmgrstubstate_fuzzer.cpp index 1159dd2ee1..6bb77f9b31 100644 --- a/test/fuzztest/window_scene/screensessionmgrstubstate_fuzzer/screensessionmgrstubstate_fuzzer.cpp +++ b/test/fuzztest/window_scene/screensessionmgrstubstate_fuzzer/screensessionmgrstubstate_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,18 +13,14 @@ * limitations under the License. */ -#include -#include -#include -#include +#include "screensessionmgrstubstate_fuzzer.h" #include +#include + #include "message_option.h" #include "message_parcel.h" -#include "marshalling_helper.h" -#include "display_manager_interface.h" #include "screen_session_manager_stub.h" -#include "screensessionmgrstubstate_fuzzer.h" using namespace OHOS::Rosen; @@ -38,7 +34,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) if (data == nullptr || size < DATA_MIN_SIZE) { return false; } - + MessageParcel parcel; MessageParcel reply; MessageOption option; @@ -61,4 +57,4 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) /* Run your code on data */ OHOS::DoSomethingInterestingWithMyAPI(data, size); return 0; -} \ No newline at end of file +} diff --git a/test/fuzztest/window_scene/screensessionmgrstubwake_fuzzer/screensessionmgrstubwakeup_fuzzer.cpp b/test/fuzztest/window_scene/screensessionmgrstubwake_fuzzer/screensessionmgrstubwakeup_fuzzer.cpp index aae49a205c..025125d9ed 100644 --- a/test/fuzztest/window_scene/screensessionmgrstubwake_fuzzer/screensessionmgrstubwakeup_fuzzer.cpp +++ b/test/fuzztest/window_scene/screensessionmgrstubwake_fuzzer/screensessionmgrstubwakeup_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,18 +13,14 @@ * limitations under the License. */ -#include -#include -#include -#include +#include "screensessionmgrstubwakeup_fuzzer.h" #include +#include + #include "message_option.h" #include "message_parcel.h" -#include "marshalling_helper.h" -#include "display_manager_interface.h" #include "screen_session_manager_stub.h" -#include "screensessionmgrstubwakeup_fuzzer.h" using namespace OHOS::Rosen; @@ -38,7 +34,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) if (data == nullptr || size < DATA_MIN_SIZE) { return false; } - + MessageParcel parcel; MessageParcel reply; MessageOption option; @@ -65,4 +61,4 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) /* Run your code on data */ OHOS::DoSomethingInterestingWithMyAPI(data, size); return 0; -} \ No newline at end of file +} diff --git a/test/systemtest/dms/BUILD.gn b/test/systemtest/dms/BUILD.gn index 9dfce7db7f..8fb770d5d3 100644 --- a/test/systemtest/dms/BUILD.gn +++ b/test/systemtest/dms/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -144,6 +144,7 @@ config("dms_systemtest_common_public_config") { "../../../interfaces/innerkits/wm", "../../common/utils/include", "../../../utils/include", + "${dmserver_gen_path}", ] } @@ -160,7 +161,7 @@ ohos_static_library("dms_systemtest_common") { ] public_deps = [ - "${window_base_path}/dm:libdm", + "${window_base_path}/dm:libdm_static", "${window_base_path}/utils:libwmutil", "${window_base_path}/utils:libwmutil_base", "${window_base_path}/window_scene/interfaces/innerkits:libwsutils", diff --git a/test/systemtest/wms/BUILD.gn b/test/systemtest/wms/BUILD.gn index ac8d259411..01fe8fdd1f 100644 --- a/test/systemtest/wms/BUILD.gn +++ b/test/systemtest/wms/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -554,6 +554,7 @@ config("wms_systemtest_common_public_config") { "${window_base_path}/interfaces/innerkits/wm", "${window_base_path}/utils/include", "${window_base_path}/test/common/utils/include", + "${dmserver_gen_path}", ] } diff --git a/utils/BUILD.gn b/utils/BUILD.gn index df91551a9d..9939ad3aef 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -46,6 +46,7 @@ ohos_static_library("libwmutil_static") { "src/cutout_info.cpp", "src/display_change_info.cpp", "src/display_info.cpp", + "src/dm_virtual_screen_option.cpp", "src/dms_reporter.cpp", "src/perform_reporter.cpp", "src/permission.cpp", @@ -160,6 +161,7 @@ ohos_shared_library("libwmutil_base") { ohos_shared_library("libwmutil") { branch_protector_ret = "pac_ret" sources = [ + "src/dm_virtual_screen_option.cpp", "src/dms_reporter.cpp", "src/dms_xcollie.cpp", "src/perform_reporter.cpp", diff --git a/utils/include/dm_rs_surface_node.h b/utils/include/dm_rs_surface_node.h new file mode 100644 index 0000000000..ecd6b5fbb1 --- /dev/null +++ b/utils/include/dm_rs_surface_node.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ROSEN_DM_RS_SURFACE_NODE_H +#define OHOS_ROSEN_DM_RS_SURFACE_NODE_H + +#include +#include + +namespace OHOS::Rosen { +class DmRsSurfaceNode : public Parcelable { +public: + DmRsSurfaceNode() = default; + + explicit DmRsSurfaceNode(const std::shared_ptr& surfaceNode) : surfaceNode_(surfaceNode) + {} + + bool Marshalling(Parcel& parcel) const override + { + if (surfaceNode_) { + return surfaceNode_->Marshalling(parcel); + } + return false; + } + + static DmRsSurfaceNode* Unmarshalling(Parcel& parcel) + { + std::shared_ptr surfaceNode = RSSurfaceNode::Unmarshalling(parcel); + return new DmRsSurfaceNode(surfaceNode); + } + + std::shared_ptr GetSurfaceNode() const + { + return surfaceNode_; + } + +private: + std::shared_ptr surfaceNode_; +}; +} // namespace OHOS::Rosen + +#endif /* OHOS_ROSEN_DM_RS_SURFACE_NODE_H */ diff --git a/dmserver/include/display_manager_stub.h b/utils/include/dm_virtual_screen_option.h similarity index 51% rename from dmserver/include/display_manager_stub.h rename to utils/include/dm_virtual_screen_option.h index d88c4a0c65..a676e725a1 100644 --- a/dmserver/include/display_manager_stub.h +++ b/utils/include/dm_virtual_screen_option.h @@ -1,33 +1,40 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FOUNDATION_DMSERVER_DISPLAY_MANAGER_STUB_H -#define FOUNDATION_DMSERVER_DISPLAY_MANAGER_STUB_H - -#include "display_manager_interface.h" - -#include - -namespace OHOS::Rosen { -class DisplayManagerStub : public IRemoteStub { -public: - DisplayManagerStub() = default; - ~DisplayManagerStub() = default; - virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) override; -}; -} // namespace OHOS::Rosen - -#endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_STUB_H \ No newline at end of file +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ROSEN_DM_VIRTUAL_SCREEN_OPTION_H +#define OHOS_ROSEN_DM_VIRTUAL_SCREEN_OPTION_H + +#include +#include "screen.h" + +namespace OHOS::Rosen { +class DmVirtualScreenOption : public Parcelable { +public: + DmVirtualScreenOption() = default; + + explicit DmVirtualScreenOption(VirtualScreenOption option); + + bool Marshalling(Parcel& parcel) const override; + + static DmVirtualScreenOption* Unmarshalling(Parcel& parcel); + + VirtualScreenOption GetOption() const; + +private: + VirtualScreenOption option_{}; +}; +} // namespace OHOS::Rosen + +#endif /* OHOS_ROSEN_DM_VIRTUAL_SCREEN_OPTION_H */ diff --git a/utils/src/dm_virtual_screen_option.cpp b/utils/src/dm_virtual_screen_option.cpp new file mode 100644 index 0000000000..eadea42549 --- /dev/null +++ b/utils/src/dm_virtual_screen_option.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dm_virtual_screen_option.h" + +namespace OHOS::Rosen { +DmVirtualScreenOption::DmVirtualScreenOption(VirtualScreenOption option) : option_(std::move(option)) +{} + +bool DmVirtualScreenOption::Marshalling(Parcel& parcel) const +{ + return parcel.WriteString(option_.name_) && parcel.WriteUint32(option_.width_) && + parcel.WriteUint32(option_.height_) && parcel.WriteFloat(option_.density_) && + parcel.WriteInt32(option_.flags_) && parcel.WriteBool(option_.isForShot_) && + parcel.WriteUInt64Vector(option_.missionIds_); +} + +DmVirtualScreenOption* DmVirtualScreenOption::Unmarshalling(Parcel& parcel) +{ + std::string name; + uint32_t width; + uint32_t height; + float density; + int32_t flags; + bool isForShot; + std::vector missionIds; + if (!(parcel.ReadString(name) && parcel.ReadUint32(width) && parcel.ReadUint32(height) && + parcel.ReadFloat(density) && parcel.ReadInt32(flags) && parcel.ReadBool(isForShot) && + parcel.ReadUInt64Vector(&missionIds))) { + return nullptr; + } + + auto* virScrOption = new (std::nothrow) DmVirtualScreenOption(); + if (virScrOption == nullptr) { + return nullptr; + } + + virScrOption->option_.name_ = name; + virScrOption->option_.width_ = width; + virScrOption->option_.height_ = height; + virScrOption->option_.density_ = density; + virScrOption->option_.flags_ = flags; + virScrOption->option_.isForShot_ = isForShot; + virScrOption->option_.missionIds_ = missionIds; + return virScrOption; +} + +VirtualScreenOption DmVirtualScreenOption::GetOption() const +{ + return option_; +} +} // namespace OHOS::Rosen diff --git a/utils/test/unittest/BUILD.gn b/utils/test/unittest/BUILD.gn index e50d367ff4..417fdca734 100644 --- a/utils/test/unittest/BUILD.gn +++ b/utils/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -274,6 +274,26 @@ ohos_unittest("utils_rs_adapter_test") { external_deps = test_external_deps } +ohos_unittest("utils_dm_virtual_screen_option_test") { + module_out_path = module_out_path + + sources = [ "dm_virtual_screen_option_test.cpp" ] + + deps = [ ":utils_unittest_common" ] + + external_deps = test_external_deps +} + +ohos_unittest("utils_dm_rs_surface_node") { + module_out_path = module_out_path + + sources = [ "dm_rs_surface_node.cpp" ] + + deps = [ ":utils_unittest_common" ] + + external_deps = test_external_deps +} + ## Build dm_unittest_common.a {{{ config("utils_unittest_common_public_config") { include_dirs = [ @@ -284,6 +304,7 @@ config("utils_unittest_common_public_config") { "../../include", "../../../wm/include", "../../../dm/include", + "${dmserver_gen_path}", ] } diff --git a/utils/test/unittest/dm_rs_surface_node.cpp b/utils/test/unittest/dm_rs_surface_node.cpp new file mode 100644 index 0000000000..80a4f0a5c7 --- /dev/null +++ b/utils/test/unittest/dm_rs_surface_node.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "dm_rs_surface_node.h" + +using namespace testing::ext; + +namespace OHOS::Rosen { +/** + * @tc.name: Marshalling01 + * @tc.desc: Marshalling test + * @tc.type: FUNC + */ +HWTEST(DmRsSurfaceNodeTest, Marshalling01, TestSize.Level1) +{ + DmRsSurfaceNode DmRsSurfaceNode; + Parcel parcel; + bool ret = DmRsSurfaceNode.Marshalling(parcel); + ASSERT_FALSE(ret); +} + +/** + * @tc.name: MarshallingUnmarshalling02 + * @tc.desc: MarshallingUnmarshalling test + * @tc.type: FUNC + */ +HWTEST(DmRsSurfaceNodeTest, MarshallingUnmarshalling02, TestSize.Level1) +{ + RSSurfaceNodeConfig rsSurfaceNodeConfig; + std::shared_ptr surfaceNode = std::make_shared(rsSurfaceNodeConfig, true, 10); + DmRsSurfaceNode dmRsSurfaceNode(surfaceNode); + + Parcel parcel; + bool ret = dmRsSurfaceNode.Marshalling(parcel); + ASSERT_TRUE(ret); + + DmRsSurfaceNode* node = DmRsSurfaceNode::Unmarshalling(parcel); + ASSERT_TRUE(node->GetSurfaceNode()->isRenderServiceNode_); + ASSERT_EQ(node->GetSurfaceNode()->id_, 10); + ASSERT_EQ(node->GetSurfaceNode()->isTextureExportNode_, rsSurfaceNodeConfig.isTextureExportNode); + ASSERT_EQ(node->GetSurfaceNode()->name_, rsSurfaceNodeConfig.SurfaceNodeName); + ASSERT_NE(node, nullptr); + delete node; +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/utils/test/unittest/dm_virtual_screen_option_test.cpp b/utils/test/unittest/dm_virtual_screen_option_test.cpp new file mode 100644 index 0000000000..3dab564271 --- /dev/null +++ b/utils/test/unittest/dm_virtual_screen_option_test.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "dm_virtual_screen_option.h" + +using namespace testing::ext; + +namespace OHOS::Rosen { +/** + * @tc.name: MarshallingUnmarshalling01 + * @tc.desc: MarshallingUnmarshalling test + * @tc.type: FUNC + */ +HWTEST(DmVirtualScreenOptionTest, MarshallingUnmarshalling01, TestSize.Level1) +{ + DmVirtualScreenOption dmVirtualScreenOption; + Parcel parcel; + bool ret = dmVirtualScreenOption.Marshalling(parcel); + ASSERT_TRUE(ret); + + DmVirtualScreenOption* option = DmVirtualScreenOption::Unmarshalling(parcel); + ASSERT_NE(option, nullptr); + ASSERT_EQ(option->GetOption().name_, ""); + ASSERT_EQ(option->GetOption().width_, 0); + ASSERT_EQ(option->GetOption().height_, 0); + delete option; +} + +/** + * @tc.name: MarshallingUnmarshalling02 + * @tc.desc: MarshallingUnmarshalling test + * @tc.type: FUNC + */ +HWTEST(DmVirtualScreenOptionTest, MarshallingUnmarshalling02, TestSize.Level1) +{ + VirtualScreenOption virtualOption{}; + virtualOption.name_ = "testVirtualOption"; + virtualOption.width_ = 100; + virtualOption.height_ = 200; + DmVirtualScreenOption dmVirtualScreenOption(virtualOption); + + Parcel parcel; + bool ret = dmVirtualScreenOption.Marshalling(parcel); + ASSERT_TRUE(ret); + + DmVirtualScreenOption* option = DmVirtualScreenOption::Unmarshalling(parcel); + ASSERT_NE(option, nullptr); + ASSERT_EQ(option->GetOption().name_, virtualOption.name_); + ASSERT_EQ(option->GetOption().width_, virtualOption.width_); + ASSERT_EQ(option->GetOption().height_, virtualOption.height_); + delete option; +} +} // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h index bc4367d5da..c217aca6dc 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,10 +18,15 @@ #include -#include "display_manager_interface.h" +#include "display_manager_interface_code.h" #include "dm_common.h" +#include "fold_screen_info.h" #include "interfaces/include/ws_common.h" +#include "screen.h" +#include "screen_group_info.h" #include "session/screen/include/screen_property.h" +#include "window_manager_hilog.h" +#include "zidl/idisplay_manager_agent.h" #include "zidl/screen_session_manager_client_interface.h" namespace OHOS { @@ -29,161 +34,237 @@ namespace Rosen { template class RRectT; -class IScreenSessionManager : public IDisplayManager { +class IScreenSessionManager : public IRemoteBroker { public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IScreenSessionManager"); - virtual sptr GetDefaultDisplayInfo() override { return nullptr; } - virtual sptr GetDisplayInfoById(DisplayId displayId) override { return nullptr; } - virtual sptr GetVisibleAreaDisplayInfoById(DisplayId displayId) override { return nullptr; } - virtual sptr GetDisplayInfoByScreen(ScreenId screenId) override {return nullptr; } - virtual DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) override { return DMError::DM_OK; } - virtual bool ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId) override { return true; } - virtual void UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo) override {}; - void GetDisplayHookInfo(int32_t uid, DMHookInfo& hookInfo) override {}; + virtual sptr GetDefaultDisplayInfo() { return nullptr; } + virtual sptr GetDisplayInfoById(DisplayId displayId) { return nullptr; } + virtual sptr GetVisibleAreaDisplayInfoById(DisplayId displayId) { return nullptr; } + virtual sptr GetDisplayInfoByScreen(ScreenId screenId) {return nullptr; } + virtual DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) { return DMError::DM_OK; } + virtual bool ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId) { return true; } + virtual void UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo) {} + virtual void GetDisplayHookInfo(int32_t uid, DMHookInfo& hookInfo) {} virtual ScreenId CreateVirtualScreen(VirtualScreenOption option, - const sptr& displayManagerAgent) override { return -1; } - virtual DMError DestroyVirtualScreen(ScreenId screenId) override { return DMError::DM_OK; } - virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr surface) override + const sptr& displayManagerAgent) { return -1; } + virtual DMError DestroyVirtualScreen(ScreenId screenId) { return DMError::DM_OK; } + virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr surface) { return DMError::DM_OK; } + + virtual DMError AddVirtualScreenBlockList(const std::vector &persistentIds) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + + virtual DMError RemoveVirtualScreenBlockList(const std::vector &persistentIds) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } virtual DMError SetScreenPrivacyMaskImage(ScreenId screenId, - const std::shared_ptr& privacyMaskImg) override + const std::shared_ptr& privacyMaskImg) { return DMError::DM_OK; } - virtual DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool autoRotate) override + virtual DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool autoRotate) { return DMError::DM_OK; } - virtual DMError SetOrientation(ScreenId screenId, Orientation orientation) override { return DMError::DM_OK; } + + virtual DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual DMError SetOrientation(ScreenId screenId, Orientation orientation) { return DMError::DM_OK; } virtual std::shared_ptr GetDisplaySnapshot(DisplayId displayId, DmErrorCode* errorCode = nullptr, - bool isUseDma = false, bool isCaptureFullOfScreen = false) override { return nullptr; } + bool isUseDma = false, bool isCaptureFullOfScreen = false) { return nullptr; } virtual std::shared_ptr GetSnapshotByPicker(Media::Rect &rect, - DmErrorCode* errorCode = nullptr) override + DmErrorCode* errorCode = nullptr) { *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; return nullptr; } - virtual DMError SetScreenRotationLocked(bool isLocked) override { return DMError::DM_OK; } - virtual DMError SetScreenRotationLockedFromJs(bool isLocked) override { return DMError::DM_OK; } - virtual DMError IsScreenRotationLocked(bool& isLocked) override { return DMError::DM_OK; } + virtual DMError SetScreenRotationLocked(bool isLocked) { return DMError::DM_OK; } + virtual DMError SetScreenRotationLockedFromJs(bool isLocked) { return DMError::DM_OK; } + virtual DMError IsScreenRotationLocked(bool& isLocked) { return DMError::DM_OK; } // colorspace, gamut virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, - std::vector& colorGamuts) override + std::vector& colorGamuts) { return DMError::DM_OK; } - virtual DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) override + virtual DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) { return DMError::DM_OK; } - virtual DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) override { return DMError::DM_OK; } - virtual DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) override { return DMError::DM_OK; } - virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) override { return DMError::DM_OK; } - virtual DMError SetScreenColorTransform(ScreenId screenId) override { return DMError::DM_OK; } + virtual DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) { return DMError::DM_OK; } + virtual DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) { return DMError::DM_OK; } + virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) { return DMError::DM_OK; } + virtual DMError SetScreenColorTransform(ScreenId screenId) { return DMError::DM_OK; } + + virtual DMError GetPixelFormat(ScreenId screenId, GraphicPixelFormat &pixelFormat) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + + virtual DMError SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + + virtual DMError GetSupportedHDRFormats(ScreenId screenId, + std::vector &hdrFormats) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + + virtual DMError GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat &hdrFormat) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + + virtual DMError SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + + virtual DMError GetSupportedColorSpaces(ScreenId screenId, + std::vector &colorSpaces) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + + virtual DMError GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType &colorSpace) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + + virtual DMError SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } virtual DMError RegisterDisplayManagerAgent(const sptr& displayManagerAgent, - DisplayManagerAgentType type) override { return DMError::DM_OK; } + DisplayManagerAgentType type) { return DMError::DM_OK; } virtual DMError UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, - DisplayManagerAgentType type) override { return DMError::DM_OK; } - virtual bool WakeUpBegin(PowerStateChangeReason reason) override { return false; } - virtual bool WakeUpEnd() override { return false; } - virtual bool SuspendBegin(PowerStateChangeReason reason) override { return false; } - virtual bool SuspendEnd() override { return false; } - virtual ScreenId GetInternalScreenId() override { return SCREEN_ID_INVALID; } - virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) override + DisplayManagerAgentType type) { return DMError::DM_OK; } + virtual bool WakeUpBegin(PowerStateChangeReason reason) { return false; } + virtual bool WakeUpEnd() { return false; } + virtual bool SuspendBegin(PowerStateChangeReason reason) { return false; } + virtual bool SuspendEnd() { return false; } + virtual ScreenId GetInternalScreenId() { return SCREEN_ID_INVALID; } + virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) { return false; } - virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) override { return false; } - virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override { return false; } - virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) override { return ScreenPowerState::INVALID_STATE; } - virtual ScreenPowerState GetScreenPower() override { return ScreenPowerState::INVALID_STATE; } - virtual bool SetDisplayState(DisplayState state) override { return false; } - virtual DisplayState GetDisplayState(DisplayId displayId) override {return DisplayState::UNKNOWN; } - virtual bool TryToCancelScreenOff() override { return false; } - virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) override { return false; } - virtual uint32_t GetScreenBrightness(uint64_t screenId) override { return 0; } - virtual std::vector GetAllDisplayIds() override { return std::vector{}; } - virtual sptr GetCutoutInfo(DisplayId displayId) override { return nullptr; } - virtual sptr GetCutoutInfoWithRotation(DisplayId displayId, int32_t rotation) override + virtual bool SetSpecifiedScreenPower(ScreenId, ScreenPowerState, PowerStateChangeReason) { return false; } + virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) { return false; } + virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) { return ScreenPowerState::INVALID_STATE; } + virtual ScreenPowerState GetScreenPower() { return ScreenPowerState::INVALID_STATE; } + virtual bool SetDisplayState(DisplayState state) { return false; } + virtual DisplayState GetDisplayState(DisplayId displayId) {return DisplayState::UNKNOWN; } + virtual bool TryToCancelScreenOff() { return false; } + virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) { return false; } + virtual uint32_t GetScreenBrightness(uint64_t screenId) { return 0; } + virtual std::vector GetAllDisplayIds() { return std::vector{}; } + virtual sptr GetCutoutInfo(DisplayId displayId) { return nullptr; } + virtual sptr GetCutoutInfoWithRotation(DisplayId displayId, int32_t rotation) { return nullptr; } - virtual void NotifyDisplayEvent(DisplayEvent event) override {} - virtual bool SetFreeze(std::vector displayIds, bool isFreeze) override { return false; } - virtual sptr GetScreenInfoById(ScreenId screenId) override { return nullptr; } - virtual sptr GetScreenGroupInfoById(ScreenId screenId) override { return nullptr; } - virtual DMError GetAllScreenInfos(std::vector>& screenInfos) override { return DMError::DM_OK; } + virtual DMError HasImmersiveWindow(ScreenId screenId, bool &immersive) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual void NotifyDisplayEvent(DisplayEvent event) {} + virtual bool SetFreeze(std::vector displayIds, bool isFreeze) { return false; } + virtual sptr GetScreenInfoById(ScreenId screenId) { return nullptr; } + virtual sptr GetScreenGroupInfoById(ScreenId screenId) { return nullptr; } + virtual DMError GetAllScreenInfos(std::vector>& screenInfos) { return DMError::DM_OK; } virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - ScreenId& screenGroupId) override { return DMError::DM_OK; } + ScreenId& screenGroupId) { return DMError::DM_OK; } + + virtual DMError MakeMirrorForRecord(ScreenId mainScreenId, std::vector mirrorScreenIds, + ScreenId &screenGroupId) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, - DMRect mainScreenRegion, ScreenId& screenGroupId) override { return DMError::DM_OK; } + DMRect mainScreenRegion, ScreenId& screenGroupId) { return DMError::DM_OK; } virtual DMError SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, - MultiScreenMode screenMode) override { return DMError::DM_OK; } + MultiScreenMode screenMode) { return DMError::DM_OK; } virtual DMError SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions, - MultiScreenPositionOptions secondScreenOption) override { return DMError::DM_OK; } + MultiScreenPositionOptions secondScreenOption) { return DMError::DM_OK; } virtual DMError MakeExpand(std::vector screenId, std::vector startPoints, - ScreenId& screenGroupId) override { return DMError::DM_OK; } - virtual DMError StopMirror(const std::vector& mirrorScreenIds) override { return DMError::DM_OK; } - virtual DMError StopExpand(const std::vector& expandScreenIds) override { return DMError::DM_OK; } - virtual void RemoveVirtualScreenFromGroup(std::vector screens) override {} - virtual DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) override { return DMError::DM_OK; } - virtual DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) override { return DMError::DM_OK; } - virtual DMError SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) override + ScreenId& screenGroupId) { return DMError::DM_OK; } + virtual DMError StopMirror(const std::vector& mirrorScreenIds) { return DMError::DM_OK; } + virtual DMError DisableMirror(bool disableOrNot) { return DMError::DM_ERROR_INVALID_PERMISSION; } + virtual DMError StopExpand(const std::vector& expandScreenIds) { return DMError::DM_OK; } + virtual void RemoveVirtualScreenFromGroup(std::vector screens) {} + virtual DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) { return DMError::DM_OK; } + virtual DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) { return DMError::DM_OK; } + virtual DMError SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) { return DMError::DM_OK; } - virtual DMError SetDefaultDensityDpi(ScreenId screenId, float virtualPixelRatio) override + virtual DMError SetDefaultDensityDpi(ScreenId screenId, float virtualPixelRatio) { return DMError::DM_OK; } virtual DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, - float virtualPixelRatio) override { return DMError::DM_OK; } + float virtualPixelRatio) { return DMError::DM_OK; } virtual DMError GetDensityInCurResolution(ScreenId screenId, - float& virtualPixelRatio) override { return DMError::DM_OK; } + float& virtualPixelRatio) { return DMError::DM_OK; } virtual DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, - uint32_t height) override { return DMError::DM_OK; } + uint32_t height) { return DMError::DM_OK; } virtual DMError AddSurfaceNodeToDisplay(DisplayId displayId, - std::shared_ptr& surfaceNode, bool onTop = true) override { return DMError::DM_OK; } + std::shared_ptr& surfaceNode, bool onTop = true) { return DMError::DM_OK; } virtual DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId, - std::shared_ptr& surfaceNode) override { return DMError::DM_OK; } + std::shared_ptr& surfaceNode) { return DMError::DM_OK; } virtual void DumpAllScreensInfo(std::string& dumpInfo) {} virtual void DumpSpecialScreenInfo(ScreenId id, std::string& dumpInfo) {} // Fold Screen - void SetFoldDisplayMode(const FoldDisplayMode displayMode) override {} - DMError SetFoldDisplayModeFromJs(const FoldDisplayMode displayMode, - std::string reason = "") override { return DMError::DM_OK; } + virtual void SetFoldDisplayMode(const FoldDisplayMode displayMode) {} + virtual DMError SetFoldDisplayModeFromJs(const FoldDisplayMode displayMode, + std::string reason = "") { return DMError::DM_OK; } - void SetDisplayScale(ScreenId screenId, float scaleX, float scaleY, float pivotX, float pivotY) override {} + virtual void SetDisplayScale(ScreenId screenId, float scaleX, float scaleY, float pivotX, float pivotY) {} - void SetFoldStatusLocked(bool locked) override {} - DMError SetFoldStatusLockedFromJs(bool locked) override { return DMError::DM_OK; } - void SetFoldStatusExpandAndLocked(bool locked) override {} + virtual void SetFoldStatusLocked(bool locked) {} + virtual DMError SetFoldStatusLockedFromJs(bool locked) { return DMError::DM_OK; } + virtual void SetFoldStatusExpandAndLocked(bool locked) {} - FoldDisplayMode GetFoldDisplayMode() override { return FoldDisplayMode::UNKNOWN; } + virtual FoldDisplayMode GetFoldDisplayMode() { return FoldDisplayMode::UNKNOWN; } - bool IsFoldable() override { return false; }; - bool IsCaptured() override { return false; }; + virtual bool IsFoldable() { return false; } + virtual bool IsCaptured() { return false; } - FoldStatus GetFoldStatus() override { return FoldStatus::UNKNOWN; }; - virtual SuperFoldStatus GetSuperFoldStatus() { return SuperFoldStatus::UNKNOWN; }; - virtual float GetSuperRotation() { return -1.f; }; - virtual void SetLandscapeLockStatus(bool isLocked) {}; + virtual FoldStatus GetFoldStatus() { return FoldStatus::UNKNOWN; } + virtual SuperFoldStatus GetSuperFoldStatus() { return SuperFoldStatus::UNKNOWN; } + virtual float GetSuperRotation() { return -1.f; } + virtual void SetLandscapeLockStatus(bool isLocked) {} virtual ExtendScreenConnectStatus GetExtendScreenConnectStatus() { return ExtendScreenConnectStatus::UNKNOWN; } - virtual void SetForceCloseHdr(ScreenId screenid, bool isForceCloseHdr) {}; + virtual void SetForceCloseHdr(ScreenId screenid, bool isForceCloseHdr) {} - sptr GetCurrentFoldCreaseRegion() override { return nullptr; }; + virtual sptr GetCurrentFoldCreaseRegion() { return nullptr; } virtual DMError MakeUniqueScreen(const std::vector& screenIds, - std::vector& displayIds) override { return DMError::DM_OK; }; + std::vector& displayIds) { return DMError::DM_OK; } virtual void SetClient(const sptr& client) {} virtual void SwitchUser() {} + virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) + { + return VirtualScreenFlag::DEFAULT; + } + virtual DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } virtual ScreenProperty GetScreenProperty(ScreenId screenId) { return ScreenProperty(); } virtual std::shared_ptr GetDisplayNode(ScreenId screenId) { return nullptr; } virtual void UpdateScreenRotationProperty(ScreenId screenId, const RRectT& bounds, float rotation, @@ -202,52 +283,71 @@ public: virtual void SetScreenPrivacyState(bool hasPrivate) {} virtual void SetPrivacyStateByDisplayId(DisplayId id, bool hasPrivate) {} virtual void SetScreenPrivacyWindowList(DisplayId id, std::vector privacyWindowList) {} + virtual DMError GetAvailableArea(DisplayId displayId, DMRect& area) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } + virtual DMError GetExpandAvailableArea(DisplayId displayId, DMRect& area) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } virtual void NotifyFoldToExpandCompletion(bool foldToExpand) {} virtual void RecordEventFromScb(std::string description, bool needRecordEvent) {} virtual DeviceScreenConfig GetDeviceScreenConfig() { return {}; } virtual DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate, - uint32_t& actualRefreshRate) override { return DMError::DM_OK; } - DMError SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval) override + uint32_t& actualRefreshRate) { return DMError::DM_OK; } + virtual DMError SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval) { return DMError::DM_OK; } - virtual DMError ProxyForFreeze(const std::set& pidList, bool isProxy) override + virtual DMError ProxyForFreeze(const std::set& pidList, bool isProxy) { return DMError::DM_OK; } - virtual DMError ResetAllFreezeStatus() override + virtual DMError ResetAllFreezeStatus() { return DMError::DM_OK; } virtual void SetVirtualScreenBlackList(ScreenId screenId, std::vector& windowIdList, - std::vector surfaceIdList = {}, std::vector typeBlackList = {}) override {} - virtual void SetVirtualDisplayMuteFlag(ScreenId screenId, bool muteFlag) override {} - virtual void DisablePowerOffRenderControl(ScreenId screenId) override {} + std::vector surfaceIdList = {}, std::vector typeBlackList = {}) {} + virtual void SetVirtualDisplayMuteFlag(ScreenId screenId, bool muteFlag) {} + virtual void DisablePowerOffRenderControl(ScreenId screenId) {} - virtual std::vector GetAllDisplayPhysicalResolution() override + virtual std::vector GetAllDisplayPhysicalResolution() { return std::vector {}; } - virtual DMError GetDisplayCapability(std::string& capabilitInfo) override + virtual DMError GetDisplayCapability(std::string& capabilitInfo) { return DMError::DM_OK; } - virtual bool SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus) override { return false; } + virtual bool SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus) { return false; } virtual DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, - std::vector& windowIdList) override + std::vector& windowIdList) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } virtual std::shared_ptr GetScreenCapture(const CaptureOption& captureOption, - DmErrorCode* errorCode = nullptr) override + DmErrorCode* errorCode = nullptr) { *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; return nullptr; } + virtual sptr GetPrimaryDisplayInfo() + { + return nullptr; + } + virtual std::shared_ptr GetDisplaySnapshotWithOption(const CaptureOption& captureOption, + DmErrorCode* errorCode = nullptr) + { + *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; + return nullptr; + } + virtual DMError SetScreenSkipProtectedWindow(const std::vector &screenIds, bool isEnable) + { + return DMError::DM_OK; + } virtual ScreenCombination GetScreenCombination(ScreenId screenId) { return ScreenCombination::SCREEN_ALONE; } virtual bool GetIsRealScreen(ScreenId screenId) { return false; } - virtual DMError SetSystemKeyboardStatus(bool isTpKeyboardOn = false) override + virtual DMError SetSystemKeyboardStatus(bool isTpKeyboardOn = false) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } @@ -256,6 +356,7 @@ public: virtual void NotifyExtendScreenDestroyFinish() {}; virtual void NotifyScreenMaskAppear() {}; virtual bool GetKeyboardState() { return false; }; + virtual uint32_t GetDeviceStatus() { return 0; } }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_lite_interface.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_lite_interface.h index b9bebb5451..23aac3a704 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_lite_interface.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_lite_interface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,12 +17,11 @@ #define OHOS_ROSEN_SCREEN_SESSION_MANAGER_LITE_INTERFACE_H #include -#include -#include "dm_common.h" -#include "zidl/display_manager_agent_interface.h" + #include "display_info.h" +#include "dm_common.h" #include "fold_screen_info.h" -#include "screen_group_info.h" +#include "zidl/idisplay_manager_agent.h" namespace OHOS { namespace Rosen { diff --git a/window_scene/test/dms_unittest/BUILD.gn b/window_scene/test/dms_unittest/BUILD.gn index 0b1b3e0c9c..e2d3d2287d 100644 --- a/window_scene/test/dms_unittest/BUILD.gn +++ b/window_scene/test/dms_unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -874,6 +874,8 @@ config("ws_unittest_common_public_config") { # for window_manager_hilog "${window_base_path}/utils/include", + + "${dmserver_gen_path}", ] } diff --git a/window_scene/test/dms_unittest/screen_session_manager_proxy_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_proxy_test.cpp index 9bd4029bf8..ef17f58bfa 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_proxy_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_proxy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,49 +13,52 @@ * limitations under the License. */ -#include -#include -#include #include -#include +#include #include -#include "session_manager/include/scene_session_manager.h" -#include "session_manager/include/zidl/scene_session_manager_interface.h" -#include "window_manager_agent.h" -#include "zidl/screen_session_manager_proxy.h" -#include "zidl/window_manager_agent_interface.h" +#include + #include "display_manager_adapter.h" #include "display_manager_agent_default.h" +#include "fold_screen_state_internel.h" #include "scene_board_judgement.h" #include "screen_session_manager/include/screen_session_manager.h" -#include "fold_screen_state_internel.h" +#include "session_manager/include/scene_session_manager.h" +#include "zidl/screen_session_manager_proxy.h" using namespace testing; using namespace testing::ext; -namespace OHOS { -namespace Rosen { + +namespace OHOS::Rosen { class ScreenSessionManagerProxyTest : public testing::Test { public: - static void SetUpTestCase(); - static void TearDownTestCase(); + static void SetUpTestSuite(); void SetUp() override; - void TearDown() override; + sptr screenSessionManagerProxy; }; -void ScreenSessionManagerProxyTest::SetUpTestCase() -{ -} - -void ScreenSessionManagerProxyTest::TearDownTestCase() +void ScreenSessionManagerProxyTest::SetUpTestSuite() { + ASSERT_TRUE(SingletonContainer::Get().InitDMSProxy()); } void ScreenSessionManagerProxyTest::SetUp() { -} + if (screenSessionManagerProxy) { + return; + } -void ScreenSessionManagerProxyTest::TearDown() -{ + sptr impl; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(SingletonContainer::Get().screenSessionManagerServiceProxy_, nullptr); + impl = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + ASSERT_NE(SingletonContainer::Get().displayManagerServiceProxy_, nullptr); + impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } + + screenSessionManagerProxy = new (std::nothrow) ScreenSessionManagerProxy(impl); + ASSERT_NE(screenSessionManagerProxy, nullptr); } namespace { @@ -66,12 +69,8 @@ namespace { */ HWTEST_F(ScreenSessionManagerProxyTest, SetPrivacyStateByDisplayId, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); DisplayId id = 0; bool hasPrivate = false; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); int resultValue = 0; std::function func = [&]() @@ -90,12 +89,8 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetPrivacyStateByDisplayId, TestSize.Lev */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenPrivacyWindowList, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); DisplayId id = 0; std::vector privacyWindowList{"win0", "win1"}; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); int resultValue = 0; std::function func = [&]() @@ -114,13 +109,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenPrivacyWindowList, TestSize.Lev */ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualScreenBlackList, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; std::vector windowIdList{10, 20, 30}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -138,11 +129,8 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualScreenBlackList, TestSize.Leve */ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualDisplayMuteFlag, Function | SmallTest | Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; bool muteFlag = false; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); screenSessionManagerProxy->SetVirtualDisplayMuteFlag(id, muteFlag); auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000); EXPECT_EQ(screenSession, nullptr); @@ -155,13 +143,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualDisplayMuteFlag, Function | Sm */ HWTEST_F(ScreenSessionManagerProxyTest, ProxyForFreeze, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); const std::set& pidList = {1, 2, 3}; bool isProxy = true; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->ProxyForFreeze(pidList, isProxy)); @@ -178,18 +162,14 @@ HWTEST_F(ScreenSessionManagerProxyTest, ProxyForFreeze, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualScreenStatus, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; VirtualScreenStatus screenStatus = VirtualScreenStatus::VIRTUAL_SCREEN_PAUSE; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool expectation = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_NE(expectation, screenSessionManagerProxy->SetVirtualScreenStatus(id, screenStatus)); } else { - EXPECT_EQ(expectation, screenSessionManagerProxy->SetVirtualScreenStatus(id, screenStatus)); + EXPECT_NE(expectation, screenSessionManagerProxy->SetVirtualScreenStatus(id, screenStatus)); } } @@ -200,14 +180,10 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualScreenStatus, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualScreenSecurityExemption, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; uint32_t pid = 1; std::vector windowIdList{10, 20, 30}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->SetVirtualScreenSecurityExemption(id, pid, windowIdList)); @@ -224,10 +200,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualScreenSecurityExemption, TestS */ HWTEST_F(ScreenSessionManagerProxyTest, GetAllDisplayPhysicalResolution, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - std::vector allSize {}; std::function func = [&]() { @@ -248,11 +220,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetAllDisplayPhysicalResolution, TestSiz */ HWTEST_F(ScreenSessionManagerProxyTest, GetDefaultDisplayInfo, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - sptr expectation = nullptr; sptr res = nullptr; std::function func = [&]() @@ -274,13 +241,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetDefaultDisplayInfo, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenActiveMode, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; uint32_t modeId = 1; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -302,13 +265,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenActiveMode, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualPixelRatio, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; float virtualPixelRatio = 1.0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -330,13 +289,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualPixelRatio, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualPixelRatioSystem, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; float virtualPixelRatio = 1.0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -358,13 +313,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualPixelRatioSystem, TestSize.Lev */ HWTEST_F(ScreenSessionManagerProxyTest, SetDefaultDensityDpi, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; float virtualPixelRatio = 1.0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -386,15 +337,11 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetDefaultDensityDpi, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetResolution, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; uint32_t width = 1024; uint32_t height = 1024; float virtualPixelRatio = 1.0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -416,13 +363,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetResolution, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetDensityInCurResolution, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; float virtualPixelRatio = 1.0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -444,13 +387,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetDensityInCurResolution, TestSize.Leve */ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenColorGamut, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; ScreenColorGamut colorGamut {0}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -472,13 +411,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenColorGamut, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenColorGamut, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; uint32_t colorGamut = 0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -500,13 +435,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenColorGamut, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenGamutMap, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; ScreenGamutMap colorGamut; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -528,13 +459,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenGamutMap, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenGamutMap, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; ScreenGamutMap colorGamut {0}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -556,12 +483,8 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenGamutMap, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenColorTransform, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -583,13 +506,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenColorTransform, TestSize.Level1 */ HWTEST_F(ScreenSessionManagerProxyTest, GetPixelFormat, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; GraphicPixelFormat pixelFormat = GraphicPixelFormat {GRAPHIC_PIXEL_FMT_CLUT8}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -611,13 +530,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetPixelFormat, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetPixelFormat, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; GraphicPixelFormat pixelFormat = GraphicPixelFormat {GRAPHIC_PIXEL_FMT_CLUT8}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -639,13 +554,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetPixelFormat, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetSupportedHDRFormats, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; vector hdrFormats; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -667,13 +578,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetSupportedHDRFormats, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenHDRFormat, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; ScreenHDRFormat hdrFormatS {0}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -695,13 +602,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenHDRFormat, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenHDRFormat, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; ScreenHDRFormat hdrFormatS {0}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -723,9 +626,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenHDRFormat, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, RegisterDisplayManagerAgent, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr displayManagerAgent = new DisplayManagerAgentDefault(); DisplayManagerAgentType type = DisplayManagerAgentType::SCREEN_EVENT_LISTENER; if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -745,9 +645,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, RegisterDisplayManagerAgent, TestSize.Le */ HWTEST_F(ScreenSessionManagerProxyTest, UnregisterDisplayManagerAgent, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr displayManagerAgent = new DisplayManagerAgentDefault(); DisplayManagerAgentType type = DisplayManagerAgentType::SCREEN_EVENT_LISTENER; if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -767,10 +664,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, UnregisterDisplayManagerAgent, TestSize. */ HWTEST_F(ScreenSessionManagerProxyTest, WakeUpBegin, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - PowerStateChangeReason reason {0}; bool expectation = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -787,10 +680,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, WakeUpBegin, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, WakeUpEnd, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool expectation = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_EQ(expectation, screenSessionManagerProxy->WakeUpEnd()); @@ -806,10 +695,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, WakeUpEnd, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SuspendBegin, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - PowerStateChangeReason reason {0}; bool expectation = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -826,10 +711,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SuspendBegin, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SuspendEnd, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool expectation = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_EQ(expectation, screenSessionManagerProxy->SuspendEnd()); @@ -845,14 +726,10 @@ HWTEST_F(ScreenSessionManagerProxyTest, SuspendEnd, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenPowerById, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenPowerState state {0}; ScreenId id = 1001; PowerStateChangeReason reason {1}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool expectation = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_EQ(expectation, screenSessionManagerProxy->SetScreenPowerById(id, state, reason)); @@ -868,10 +745,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenPowerById, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetDisplayState, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DisplayState state {1}; screenSessionManagerProxy->SetDisplayState(state); int resultValue = 0; @@ -885,10 +758,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetDisplayState, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetSpecifiedScreenPower, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenPowerState state {0}; ScreenId id = 1001; PowerStateChangeReason reason {1}; @@ -907,10 +776,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetSpecifiedScreenPower, TestSize.Level1 */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenPowerForAll, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenPowerState state {0}; PowerStateChangeReason reason {1}; bool expectation = true; @@ -928,10 +793,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenPowerForAll, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplayState, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DisplayId displayId {0}; if (SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_NE(DisplayState::UNKNOWN, screenSessionManagerProxy->GetDisplayState(displayId)); @@ -947,15 +808,11 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplayState, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, TryToCancelScreenOff, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool expectation = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_NE(expectation, screenSessionManagerProxy->TryToCancelScreenOff()); } else { - EXPECT_EQ(expectation, screenSessionManagerProxy->TryToCancelScreenOff()); + EXPECT_NE(expectation, screenSessionManagerProxy->TryToCancelScreenOff()); } } @@ -966,10 +823,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, TryToCancelScreenOff, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, NotifyDisplayEvent, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DisplayEvent event {0}; int resultValue = 0; std::function func = [&]() @@ -988,10 +841,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, NotifyDisplayEvent, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenPower, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId dmsScreenId = 1001; if (SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_NE(ScreenPowerState::INVALID_STATE, screenSessionManagerProxy->GetScreenPower(dmsScreenId)); @@ -1007,11 +856,12 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenPower, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, AddVirtualScreenBlockList, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); std::vector persistentIds {0, 1, 2}; - EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->AddVirtualScreenBlockList(persistentIds)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->AddVirtualScreenBlockList(persistentIds)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->AddVirtualScreenBlockList(persistentIds)); + } } /** @@ -1021,11 +871,12 @@ HWTEST_F(ScreenSessionManagerProxyTest, AddVirtualScreenBlockList, TestSize.Leve */ HWTEST_F(ScreenSessionManagerProxyTest, RemoveVirtualScreenBlockList, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); std::vector persistentIds {0, 1, 2}; - EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->RemoveVirtualScreenBlockList(persistentIds)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->RemoveVirtualScreenBlockList(persistentIds)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->RemoveVirtualScreenBlockList(persistentIds)); + } } /** @@ -1035,10 +886,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, RemoveVirtualScreenBlockList, TestSize.L */ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualMirrorScreenCanvasRotation, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId ScreenId = 1001; bool canvasRotation = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -1057,10 +904,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualMirrorScreenCanvasRotation, Te */ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualMirrorScreenScaleMode, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId ScreenId = 1001; ScreenScaleMode scaleMode {0}; if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -1079,10 +922,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualMirrorScreenScaleMode, TestSiz */ HWTEST_F(ScreenSessionManagerProxyTest, ResizeVirtualScreen, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId ScreenId = 1001; uint32_t width = 1024; uint32_t height = 1024; @@ -1097,10 +936,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, ResizeVirtualScreen, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, DestroyVirtualScreen, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId ScreenId = 1001; if (SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, @@ -1118,10 +953,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, DestroyVirtualScreen, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, MakeMirror, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId Id = 1001; std::vector mirrorScreenIds = {1003, 1004, 1005}; ScreenId screenGroupId = 1002; @@ -1141,17 +972,11 @@ HWTEST_F(ScreenSessionManagerProxyTest, MakeMirror, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, StopMirror, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - const std::vector mirrorScreenIds = {1003, 1004, 1005}; if (SceneBoardJudgement::IsSceneBoardEnabled()) { - EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->StopMirror(mirrorScreenIds)); + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->StopMirror(mirrorScreenIds)); } else { - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->StopMirror(mirrorScreenIds)); + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->StopMirror(mirrorScreenIds)); } } @@ -1162,17 +987,11 @@ HWTEST_F(ScreenSessionManagerProxyTest, StopMirror, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, DisableMirror, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool disableOrNot = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { - EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->DisableMirror(disableOrNot)); + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->DisableMirror(disableOrNot)); } else { - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->DisableMirror(disableOrNot)); + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->DisableMirror(disableOrNot)); } } @@ -1183,10 +1002,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, DisableMirror, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, MakeExpand, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - std::vector screenId = {1003, 1004, 1005}; std::vector startPoint {}; ScreenId screenGroupId = 1001; @@ -1206,17 +1021,11 @@ HWTEST_F(ScreenSessionManagerProxyTest, MakeExpand, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, StopExpand, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - const std::vector expandScreenIds = {1003, 1004, 1005}; if (SceneBoardJudgement::IsSceneBoardEnabled()) { - EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->StopExpand(expandScreenIds)); + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->StopExpand(expandScreenIds)); } else { - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->StopExpand(expandScreenIds)); + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->StopExpand(expandScreenIds)); } } @@ -1227,11 +1036,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, StopExpand, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenGroupInfoById, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - sptr expectation = nullptr; sptr res = nullptr; ScreenId Id {0}; @@ -1250,10 +1054,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenGroupInfoById, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, RemoveVirtualScreenFromGroup, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); std::vector screens = {1002, 1003, 1004}; screenSessionManagerProxy->RemoveVirtualScreenFromGroup(screens); auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000); @@ -1267,18 +1067,13 @@ HWTEST_F(ScreenSessionManagerProxyTest, RemoveVirtualScreenFromGroup, TestSize.L */ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplaySnapshot, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - std::shared_ptr expectation = nullptr; std::shared_ptr res = nullptr; DisplayId displayId {0}; DmErrorCode* errorCode = nullptr; std::function func = [&]() { - res = screenSessionManagerProxy->GetDisplaySnapshot(displayId, errorCode, false); + res = screenSessionManagerProxy->GetDisplaySnapshot(displayId, errorCode, false, false); }; func(); if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -1295,11 +1090,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplaySnapshot, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplayInfoById, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - sptr expectation = nullptr; sptr res = nullptr; DisplayId displayId {0}; @@ -1322,11 +1112,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplayInfoById, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplayInfoByScreen, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - sptr expectation = nullptr; sptr res = nullptr; ScreenId screenId {0}; @@ -1349,11 +1134,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplayInfoByScreen, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetAllDisplayIds, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -1371,11 +1151,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetAllDisplayIds, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenInfoById, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - sptr expectation = nullptr; sptr res = nullptr; ScreenId Id {0}; @@ -1398,10 +1173,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenInfoById, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetAllScreenInfos, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - std::vector> screenInfos {}; if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, @@ -1419,10 +1190,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetAllScreenInfos, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenSupportedColorGamuts, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId screenId = 1001; std::vector colorGamuts {}; if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -1441,10 +1208,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenSupportedColorGamuts, TestSize. */ HWTEST_F(ScreenSessionManagerProxyTest, SetOrientation, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId screenId = 1001; Orientation orientation = Orientation::BEGIN; if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -1463,10 +1226,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetOrientation, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenRotationLocked, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool isLocked = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, @@ -1484,10 +1243,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenRotationLocked, TestSize.Level1 */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenRotationLockedFromJs, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool isLocked = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, @@ -1505,10 +1260,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenRotationLockedFromJs, TestSize. */ HWTEST_F(ScreenSessionManagerProxyTest, SetMultiScreenMode, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId mainScreenId = 0; ScreenId secondaryScreenId = 1; MultiScreenMode screenMode = MultiScreenMode::SCREEN_EXTEND; @@ -1533,10 +1284,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetMultiScreenMode, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetMultiScreenRelativePosition, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId testId = 2060; ScreenId testId1 = 3060; MultiScreenPositionOptions mainScreenOptions = {testId, 100, 100}; @@ -1562,10 +1309,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetMultiScreenRelativePosition, TestSize */ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualScreenMaxRefreshRate, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId id = 0; uint32_t refreshRate = 12; uint32_t actualRefreshRate = 0; @@ -1579,7 +1322,7 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualScreenMaxRefreshRate, TestSize if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); } else { - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); } } @@ -1590,10 +1333,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetVirtualScreenMaxRefreshRate, TestSize */ HWTEST_F(ScreenSessionManagerProxyTest, IsScreenRotationLocked, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool isLocked = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, @@ -1611,11 +1350,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, IsScreenRotationLocked, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetCutoutInfo, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - sptr expectation = nullptr; sptr res = nullptr; DisplayId displayId = 0; @@ -1638,17 +1372,11 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetCutoutInfo, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, HasImmersiveWindow, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool immersive = true; if (SceneBoardJudgement::IsSceneBoardEnabled()) { - EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->HasImmersiveWindow(0u, immersive)); + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->HasImmersiveWindow(0u, immersive)); } else { - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->HasImmersiveWindow(0u, immersive)); + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->HasImmersiveWindow(0u, immersive)); } } @@ -1659,10 +1387,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, HasImmersiveWindow, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, ConvertScreenIdToRsScreenId, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId screenId = 1001; ScreenId rsScreenId = 1002; auto ret = screenSessionManagerProxy->ConvertScreenIdToRsScreenId(screenId, rsScreenId); @@ -1676,10 +1400,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, ConvertScreenIdToRsScreenId, TestSize.Le */ HWTEST_F(ScreenSessionManagerProxyTest, HasPrivateWindow, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool hasPrivateWindow = true; DisplayId displayId = 0; if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -1698,13 +1418,13 @@ HWTEST_F(ScreenSessionManagerProxyTest, HasPrivateWindow, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, DumpAllScreensInfo, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - std::string dumpInfo; screenSessionManagerProxy->DumpAllScreensInfo(dumpInfo); - EXPECT_NE(dumpInfo, ""); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(dumpInfo, ""); + } else { + EXPECT_EQ(dumpInfo, ""); + } } /** @@ -1714,14 +1434,14 @@ HWTEST_F(ScreenSessionManagerProxyTest, DumpAllScreensInfo, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, DumpSpecialScreenInfo, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenId id = 1001; std::string dumpInfo; screenSessionManagerProxy->DumpSpecialScreenInfo(id, dumpInfo); - EXPECT_NE(dumpInfo, ""); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(dumpInfo, ""); + } else { + EXPECT_EQ(dumpInfo, ""); + } } /** @@ -1731,11 +1451,7 @@ HWTEST_F(ScreenSessionManagerProxyTest, DumpSpecialScreenInfo, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetFoldDisplayMode, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - - const FoldDisplayMode displayMode {0}; + FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN; screenSessionManagerProxy->SetFoldDisplayMode(displayMode); if (screenSessionManagerProxy->IsFoldable() && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { EXPECT_NE(ScreenSessionManager::GetInstance().foldScreenController_, nullptr); @@ -1751,18 +1467,11 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetFoldDisplayMode, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetFoldDisplayModeFromJs, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - const FoldDisplayMode displayMode {0}; - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - + FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN; if (SceneBoardJudgement::IsSceneBoardEnabled()) { - EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->SetFoldDisplayModeFromJs(displayMode)); + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->SetFoldDisplayModeFromJs(displayMode)); } else { - EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->SetFoldDisplayModeFromJs(displayMode)); + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->SetFoldDisplayModeFromJs(displayMode)); } } @@ -1773,10 +1482,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetFoldDisplayModeFromJs, TestSize.Level */ HWTEST_F(ScreenSessionManagerProxyTest, SetFoldStatusLocked, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool locked = true; screenSessionManagerProxy->SetFoldStatusLocked(locked); if (screenSessionManagerProxy->IsFoldable() && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { @@ -1793,12 +1498,7 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetFoldStatusLocked, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetFoldDisplayMode, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - - EXPECT_EQ(FoldDisplayMode::UNKNOWN, - screenSessionManagerProxy->GetFoldDisplayMode()); + EXPECT_EQ(FoldDisplayMode::UNKNOWN, screenSessionManagerProxy->GetFoldDisplayMode()); } /** @@ -1808,9 +1508,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetFoldDisplayMode, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, IsFoldable, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); screenSessionManagerProxy->IsFoldable(); auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000); EXPECT_EQ(screenSession, nullptr); @@ -1823,9 +1520,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, IsFoldable, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, IsCaptured, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); auto ret = screenSessionManagerProxy->IsCaptured(); EXPECT_EQ(ret, false); } @@ -1837,11 +1531,8 @@ HWTEST_F(ScreenSessionManagerProxyTest, IsCaptured, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetFoldStatus, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ASSERT_NE(screenSessionManagerProxy, nullptr); - screenSessionManagerProxy->GetFoldStatus(); + auto foldStatus = screenSessionManagerProxy->GetFoldStatus(); + EXPECT_EQ(foldStatus, FoldStatus::UNKNOWN); } /** @@ -1851,11 +1542,8 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetFoldStatus, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetSuperFoldStatus, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ASSERT_NE(screenSessionManagerProxy, nullptr); - screenSessionManagerProxy->GetSuperFoldStatus(); + auto superFoldStatus = screenSessionManagerProxy->GetSuperFoldStatus(); + EXPECT_EQ(superFoldStatus, SuperFoldStatus::UNKNOWN); } /** @@ -1866,11 +1554,8 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetSuperFoldStatus, TestSize.Level1) HWTEST_F(ScreenSessionManagerProxyTest, SetLandscapeLockStatus, Function | SmallTest | Level1) { bool isLocked = false; - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ASSERT_NE(screenSessionManagerProxy, nullptr); screenSessionManagerProxy->SetLandscapeLockStatus(isLocked); + EXPECT_EQ(isLocked, false); } /** @@ -1880,13 +1565,8 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetLandscapeLockStatus, Function | Small */ HWTEST_F(ScreenSessionManagerProxyTest, GetCurrentFoldCreaseRegion, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ASSERT_NE(screenSessionManagerProxy, nullptr); - - screenSessionManagerProxy->GetCurrentFoldCreaseRegion(); + auto foldCreaseRegion = screenSessionManagerProxy->GetCurrentFoldCreaseRegion(); + EXPECT_EQ(foldCreaseRegion, nullptr); } /** @@ -1896,10 +1576,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetCurrentFoldCreaseRegion, TestSize.Lev */ HWTEST_F(ScreenSessionManagerProxyTest, MakeUniqueScreen, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - const std::vector screenIds {1001, 1002, 1003}; std::vector displayIds; EXPECT_EQ(DMError::DM_ERROR_NULLPTR, screenSessionManagerProxy->MakeUniqueScreen(screenIds, displayIds)); @@ -1912,10 +1588,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, MakeUniqueScreen, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetClient, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - const sptr client = nullptr; screenSessionManagerProxy->SetClient(client); EXPECT_EQ(client, nullptr); @@ -1928,9 +1600,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetClient, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SwitchUser, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); screenSessionManagerProxy->SwitchUser(); auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000); EXPECT_EQ(screenSession, nullptr); @@ -1943,9 +1612,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SwitchUser, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenProperty, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); ScreenId screenId = 1001; screenSessionManagerProxy->GetScreenProperty(screenId); auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000); @@ -1959,10 +1625,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenProperty, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplayHookInfo, Function | SmallTest | Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - int32_t uid = 0; DMHookInfo hookInfo; hookInfo.height_ = 1344; @@ -1973,8 +1635,8 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplayHookInfo, Function | SmallTest }; func(); - EXPECT_EQ(hookInfo.height_, 0); - EXPECT_EQ(hookInfo.width_, 0); + EXPECT_EQ(hookInfo.height_, 1344); + EXPECT_EQ(hookInfo.width_, 2772); } /** @@ -1984,9 +1646,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplayHookInfo, Function | SmallTest */ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenCapture, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); ASSERT_TRUE(screenSessionManagerProxy != nullptr); std::shared_ptr res = nullptr; @@ -2015,9 +1674,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenCapture, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, GetPrimaryDisplayInfo, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); ASSERT_TRUE(screenSessionManagerProxy != nullptr); sptr res = nullptr; @@ -2025,7 +1681,11 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetPrimaryDisplayInfo, TestSize.Level1) res = screenSessionManagerProxy->GetPrimaryDisplayInfo(); }; func(); - ASSERT_NE(res, nullptr); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, nullptr); + } else { + ASSERT_EQ(res, nullptr); + } } /** @@ -2035,9 +1695,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetPrimaryDisplayInfo, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenSkipProtectedWindow, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); ASSERT_TRUE(screenSessionManagerProxy != nullptr); const std::vector screenIds = {1001, 1002}; @@ -2058,9 +1715,6 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenSkipProtectedWindow, TestSize.L */ HWTEST_F(ScreenSessionManagerProxyTest, GetDisplayCapability, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); ASSERT_TRUE(screenSessionManagerProxy != nullptr); std::string capabilitInfo; if (SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -2087,4 +1741,3 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetFoldStatusExpandAndLocked, Function | } } } -} \ No newline at end of file diff --git a/window_scene/test/dms_unittest/screen_session_manager_proxy_ut_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_proxy_ut_test.cpp index ce308cc62a..9247269099 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_proxy_ut_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_proxy_ut_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,45 +16,49 @@ #include #include #include -#include -#include #include #include "display_manager_adapter.h" #include "display_manager_agent_default.h" +#include "fold_screen_state_internel.h" #include "scene_board_judgement.h" +#include "screen_session_manager/include/screen_session_manager.h" #include "session_manager/include/scene_session_manager.h" -#include "session_manager/include/zidl/scene_session_manager_interface.h" -#include "window_manager_agent.h" #include "zidl/screen_session_manager_proxy.h" -#include "zidl/window_manager_agent_interface.h" using namespace testing; using namespace testing::ext; -namespace OHOS { -namespace Rosen { + +namespace OHOS::Rosen { class ScreenSessionManagerProxyUtTest : public testing::Test { public: - static void SetUpTestCase(); - static void TearDownTestCase(); + static void SetUpTestSuite(); void SetUp() override; - void TearDown() override; + sptr screenSessionManagerProxy; }; -void ScreenSessionManagerProxyUtTest::SetUpTestCase() -{ -} - -void ScreenSessionManagerProxyUtTest::TearDownTestCase() +void ScreenSessionManagerProxyUtTest::SetUpTestSuite() { + ASSERT_TRUE(SingletonContainer::Get().InitDMSProxy()); } void ScreenSessionManagerProxyUtTest::SetUp() { -} + if (screenSessionManagerProxy) { + return; + } -void ScreenSessionManagerProxyUtTest::TearDown() -{ + sptr impl; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(SingletonContainer::Get().screenSessionManagerServiceProxy_, nullptr); + impl = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + ASSERT_NE(SingletonContainer::Get().displayManagerServiceProxy_, nullptr); + impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } + + screenSessionManagerProxy = new (std::nothrow) ScreenSessionManagerProxy(impl); + ASSERT_NE(screenSessionManagerProxy, nullptr); } namespace { @@ -65,13 +69,9 @@ namespace { */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetPrivacyStateByDisplayId, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); DisplayId id = 0; bool hasPrivate = false; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -89,13 +89,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetPrivacyStateByDisplayId, TestSize.L */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenPrivacyWindowList, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); DisplayId id = 0; std::vector privacyWindowList{"win0", "win1"}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -113,13 +109,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenPrivacyWindowList, TestSize.L */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenBlackList, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; std::vector windowIdList{10, 20, 30}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - int resultValue = 0; std::function func = [&]() { @@ -130,6 +122,20 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenBlackList, TestSize.Le ASSERT_EQ(resultValue, 1); } +/** + * @tc.name: SetVirtualDisplayMuteFlag + * @tc.desc: SetVirtualDisplayMuteFlag + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualDisplayMuteFlag, Function | SmallTest | Level1) +{ + ScreenId id = 1001; + bool muteFlag = false; + screenSessionManagerProxy->SetVirtualDisplayMuteFlag(id, muteFlag); + auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000); + EXPECT_EQ(screenSession, nullptr); +} + /** * @tc.name: ProxyForFreeze * @tc.desc: ProxyForFreeze @@ -137,15 +143,16 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenBlackList, TestSize.Le */ HWTEST_F(ScreenSessionManagerProxyUtTest, ProxyForFreeze, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); const std::set& pidList = {1, 2, 3}; bool isProxy = true; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->ProxyForFreeze(pidList, isProxy)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->ProxyForFreeze(pidList, isProxy)); + } else { + ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->ProxyForFreeze(pidList, isProxy)); + } } /** @@ -155,19 +162,15 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, ProxyForFreeze, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenStatus, TestSize.Level1) { - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - GTEST_SKIP() << "SceneBoard is not enabled, skipping test."; - } - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; VirtualScreenStatus screenStatus = VirtualScreenStatus::VIRTUAL_SCREEN_PAUSE; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool expectation = true; - - EXPECT_EQ(expectation, screenSessionManagerProxy->SetVirtualScreenStatus(id, screenStatus)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(expectation, screenSessionManagerProxy->SetVirtualScreenStatus(id, screenStatus)); + } else { + EXPECT_NE(expectation, screenSessionManagerProxy->SetVirtualScreenStatus(id, screenStatus)); + } } /** @@ -177,16 +180,17 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenStatus, TestSize.Level */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenSecurityExemption, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; uint32_t pid = 1; std::vector windowIdList{10, 20, 30}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - - ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, - screenSessionManagerProxy->SetVirtualScreenSecurityExemption(id, pid, windowIdList)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetVirtualScreenSecurityExemption(id, pid, windowIdList)); + } else { + ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetVirtualScreenSecurityExemption(id, pid, windowIdList)); + } } /** @@ -196,18 +200,17 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenSecurityExemption, Tes */ HWTEST_F(ScreenSessionManagerProxyUtTest, GetAllDisplayPhysicalResolution, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - std::vector allSize {}; std::function func = [&]() { allSize = screenSessionManagerProxy->GetAllDisplayPhysicalResolution(); }; func(); - - ASSERT_FALSE(!allSize.empty()); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_TRUE(!allSize.empty()); + } else { + ASSERT_FALSE(!allSize.empty()); + } } /** @@ -217,11 +220,6 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetAllDisplayPhysicalResolution, TestS */ HWTEST_F(ScreenSessionManagerProxyUtTest, GetDefaultDisplayInfo, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - sptr expectation = nullptr; sptr res = nullptr; std::function func = [&]() @@ -229,8 +227,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetDefaultDisplayInfo, TestSize.Level1 res = screenSessionManagerProxy->GetDefaultDisplayInfo(); }; func(); - - ASSERT_EQ(res, expectation); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, expectation); + } else { + ASSERT_EQ(res, expectation); + } } /** @@ -240,13 +241,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetDefaultDisplayInfo, TestSize.Level1 */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenActiveMode, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; uint32_t modeId = 1; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -254,8 +251,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenActiveMode, TestSize.Level1) res = screenSessionManagerProxy->SetScreenActiveMode(id, modeId); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -265,13 +265,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenActiveMode, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualPixelRatio, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; float virtualPixelRatio = 1.0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -279,8 +275,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualPixelRatio, TestSize.Level1) res = screenSessionManagerProxy->SetVirtualPixelRatio(id, virtualPixelRatio); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -290,13 +289,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualPixelRatio, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualPixelRatioSystem, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; float virtualPixelRatio = 1.0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -304,8 +299,35 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualPixelRatioSystem, TestSize.L res = screenSessionManagerProxy->SetVirtualPixelRatioSystem(id, virtualPixelRatio); }; func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } +} - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); +/** + * @tc.name: SetDefaultDensityDpi + * @tc.desc: SetDefaultDensityDpi + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetDefaultDensityDpi, TestSize.Level1) +{ + ScreenId id = 1001; + float virtualPixelRatio = 1.0; + + + DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; + std::function func = [&]() + { + res = screenSessionManagerProxy->SetDefaultDensityDpi(id, virtualPixelRatio); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -315,15 +337,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualPixelRatioSystem, TestSize.L */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetResolution, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; uint32_t width = 1024; uint32_t height = 1024; float virtualPixelRatio = 1.0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -331,8 +349,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetResolution, TestSize.Level1) res = screenSessionManagerProxy->SetResolution(id, width, height, virtualPixelRatio); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -342,13 +363,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetResolution, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, GetDensityInCurResolution, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; float virtualPixelRatio = 1.0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -356,8 +373,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetDensityInCurResolution, TestSize.Le res = screenSessionManagerProxy->GetDensityInCurResolution(id, virtualPixelRatio); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -367,13 +387,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetDensityInCurResolution, TestSize.Le */ HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenColorGamut, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; ScreenColorGamut colorGamut {0}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -381,8 +397,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenColorGamut, TestSize.Level1) res = screenSessionManagerProxy->GetScreenColorGamut(id, colorGamut); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -392,13 +411,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenColorGamut, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenColorGamut, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; uint32_t colorGamut = 0; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -406,8 +421,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenColorGamut, TestSize.Level1) res = screenSessionManagerProxy->SetScreenColorGamut(id, colorGamut); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -417,13 +435,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenColorGamut, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenGamutMap, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; ScreenGamutMap colorGamut; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -431,8 +445,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenGamutMap, TestSize.Level1) res = screenSessionManagerProxy->GetScreenGamutMap(id, colorGamut); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -442,13 +459,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenGamutMap, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenGamutMap, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; ScreenGamutMap colorGamut {0}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -456,8 +469,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenGamutMap, TestSize.Level1) res = screenSessionManagerProxy->SetScreenGamutMap(id, colorGamut); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -467,12 +483,8 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenGamutMap, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenColorTransform, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -480,8 +492,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenColorTransform, TestSize.Leve res = screenSessionManagerProxy->SetScreenColorTransform(id); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -491,13 +506,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenColorTransform, TestSize.Leve */ HWTEST_F(ScreenSessionManagerProxyUtTest, GetPixelFormat, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; GraphicPixelFormat pixelFormat = GraphicPixelFormat {GRAPHIC_PIXEL_FMT_CLUT8}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -505,8 +516,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetPixelFormat, TestSize.Level1) res = screenSessionManagerProxy->GetPixelFormat(id, pixelFormat); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -516,13 +530,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetPixelFormat, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetPixelFormat, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; GraphicPixelFormat pixelFormat = GraphicPixelFormat {GRAPHIC_PIXEL_FMT_CLUT8}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -530,8 +540,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetPixelFormat, TestSize.Level1) res = screenSessionManagerProxy->SetPixelFormat(id, pixelFormat); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -541,13 +554,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetPixelFormat, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, GetSupportedHDRFormats, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; vector hdrFormats; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -555,8 +564,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetSupportedHDRFormats, TestSize.Level res = screenSessionManagerProxy->GetSupportedHDRFormats(id, hdrFormats); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -566,13 +578,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetSupportedHDRFormats, TestSize.Level */ HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenHDRFormat, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; ScreenHDRFormat hdrFormatS {0}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -580,8 +588,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenHDRFormat, TestSize.Level1) res = screenSessionManagerProxy->GetScreenHDRFormat(id, hdrFormatS); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -591,13 +602,9 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenHDRFormat, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenHDRFormat, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenId id = 1001; ScreenHDRFormat hdrFormatS {0}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; std::function func = [&]() @@ -605,8 +612,11 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenHDRFormat, TestSize.Level1) res = screenSessionManagerProxy->SetScreenHDRFormat(id, hdrFormatS); }; func(); - - ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } } /** @@ -616,14 +626,13 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenHDRFormat, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, RegisterDisplayManagerAgent, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr displayManagerAgent = new DisplayManagerAgentDefault(); DisplayManagerAgentType type = DisplayManagerAgentType::SCREEN_EVENT_LISTENER; - - EXPECT_NE(DMError::DM_OK, screenSessionManagerProxy->RegisterDisplayManagerAgent(displayManagerAgent, type)); - + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(DMError::DM_OK, screenSessionManagerProxy->RegisterDisplayManagerAgent(displayManagerAgent, type)); + } else { + EXPECT_NE(DMError::DM_OK, screenSessionManagerProxy->RegisterDisplayManagerAgent(displayManagerAgent, type)); + } displayManagerAgent = nullptr; EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, screenSessionManagerProxy->RegisterDisplayManagerAgent(displayManagerAgent, type)); @@ -636,14 +645,13 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, RegisterDisplayManagerAgent, TestSize. */ HWTEST_F(ScreenSessionManagerProxyUtTest, UnregisterDisplayManagerAgent, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr displayManagerAgent = new DisplayManagerAgentDefault(); DisplayManagerAgentType type = DisplayManagerAgentType::SCREEN_EVENT_LISTENER; - - EXPECT_NE(DMError::DM_OK, screenSessionManagerProxy->UnregisterDisplayManagerAgent(displayManagerAgent, type)); - + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(DMError::DM_OK, screenSessionManagerProxy->UnregisterDisplayManagerAgent(displayManagerAgent, type)); + } else { + EXPECT_NE(DMError::DM_OK, screenSessionManagerProxy->UnregisterDisplayManagerAgent(displayManagerAgent, type)); + } displayManagerAgent = nullptr; EXPECT_EQ(DMError::DM_ERROR_INVALID_PARAM, screenSessionManagerProxy->UnregisterDisplayManagerAgent(displayManagerAgent, type)); @@ -656,14 +664,13 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, UnregisterDisplayManagerAgent, TestSiz */ HWTEST_F(ScreenSessionManagerProxyUtTest, WakeUpBegin, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - PowerStateChangeReason reason {0}; bool expectation = true; - - EXPECT_NE(expectation, screenSessionManagerProxy->WakeUpBegin(reason)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(expectation, screenSessionManagerProxy->WakeUpBegin(reason)); + } else { + EXPECT_NE(expectation, screenSessionManagerProxy->WakeUpBegin(reason)); + } } /** @@ -673,12 +680,12 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, WakeUpBegin, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, WakeUpEnd, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool expectation = true; - EXPECT_NE(expectation, screenSessionManagerProxy->WakeUpEnd()); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(expectation, screenSessionManagerProxy->WakeUpEnd()); + } else { + EXPECT_NE(expectation, screenSessionManagerProxy->WakeUpEnd()); + } } /** @@ -688,13 +695,13 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, WakeUpEnd, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SuspendBegin, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - PowerStateChangeReason reason {0}; bool expectation = true; - EXPECT_NE(expectation, screenSessionManagerProxy->SuspendBegin(reason)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(expectation, screenSessionManagerProxy->SuspendBegin(reason)); + } else { + EXPECT_NE(expectation, screenSessionManagerProxy->SuspendBegin(reason)); + } } /** @@ -704,13 +711,12 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SuspendBegin, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SuspendEnd, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool expectation = true; - - EXPECT_NE(expectation, screenSessionManagerProxy->SuspendEnd()); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(expectation, screenSessionManagerProxy->SuspendEnd()); + } else { + EXPECT_NE(expectation, screenSessionManagerProxy->SuspendEnd()); + } } /** @@ -720,17 +726,16 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SuspendEnd, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenPowerById, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); ScreenPowerState state {0}; ScreenId id = 1001; PowerStateChangeReason reason {1}; - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool expectation = true; - - EXPECT_NE(expectation, screenSessionManagerProxy->SetScreenPowerById(id, state, reason)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(expectation, screenSessionManagerProxy->SetScreenPowerById(id, state, reason)); + } else { + EXPECT_NE(expectation, screenSessionManagerProxy->SetScreenPowerById(id, state, reason)); + } } /** @@ -740,10 +745,6 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenPowerById, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetDisplayState, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DisplayState state {1}; screenSessionManagerProxy->SetDisplayState(state); int resultValue = 0; @@ -757,19 +758,15 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetDisplayState, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetSpecifiedScreenPower, TestSize.Level1) { - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - GTEST_SKIP() << "SceneBoard is not enabled, skipping test."; - } - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenPowerState state {0}; ScreenId id = 1001; PowerStateChangeReason reason {1}; bool expectation = true; - - EXPECT_NE(expectation, screenSessionManagerProxy->SetSpecifiedScreenPower(id, state, reason)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(expectation, screenSessionManagerProxy->SetSpecifiedScreenPower(id, state, reason)); + } else { + EXPECT_NE(expectation, screenSessionManagerProxy->SetSpecifiedScreenPower(id, state, reason)); + } } /** @@ -779,15 +776,14 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetSpecifiedScreenPower, TestSize.Leve */ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenPowerForAll, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - ScreenPowerState state {0}; PowerStateChangeReason reason {1}; bool expectation = true; - - EXPECT_NE(expectation, screenSessionManagerProxy->SetScreenPowerForAll(state, reason)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(expectation, screenSessionManagerProxy->SetScreenPowerForAll(state, reason)); + } else { + EXPECT_NE(expectation, screenSessionManagerProxy->SetScreenPowerForAll(state, reason)); + } } /** @@ -797,13 +793,12 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenPowerForAll, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, GetDisplayState, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DisplayId displayId {0}; - - EXPECT_EQ(DisplayState::UNKNOWN, screenSessionManagerProxy->GetDisplayState(displayId)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DisplayState::UNKNOWN, screenSessionManagerProxy->GetDisplayState(displayId)); + } else { + EXPECT_EQ(DisplayState::UNKNOWN, screenSessionManagerProxy->GetDisplayState(displayId)); + } } /** @@ -813,16 +808,12 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, GetDisplayState, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, TryToCancelScreenOff, TestSize.Level1) { - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - GTEST_SKIP() << "SceneBoard is not enabled, skipping test."; - } - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - bool expectation = true; - - EXPECT_EQ(expectation, screenSessionManagerProxy->TryToCancelScreenOff()); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(expectation, screenSessionManagerProxy->TryToCancelScreenOff()); + } else { + EXPECT_NE(expectation, screenSessionManagerProxy->TryToCancelScreenOff()); + } } /** @@ -832,10 +823,6 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, TryToCancelScreenOff, TestSize.Level1) */ HWTEST_F(ScreenSessionManagerProxyUtTest, NotifyDisplayEvent, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); - DisplayEvent event {0}; int resultValue = 0; std::function func = [&]() @@ -846,6 +833,897 @@ HWTEST_F(ScreenSessionManagerProxyUtTest, NotifyDisplayEvent, TestSize.Level1) func(); ASSERT_EQ(resultValue, 1); } + +/** + * @tc.name: GetScreenPower + * @tc.desc: GetScreenPower + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenPower, TestSize.Level1) +{ + ScreenId dmsScreenId = 1001; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(ScreenPowerState::INVALID_STATE, screenSessionManagerProxy->GetScreenPower(dmsScreenId)); + } else { + EXPECT_EQ(ScreenPowerState::INVALID_STATE, screenSessionManagerProxy->GetScreenPower(dmsScreenId)); + } +} + +/** + * @tc.name: AddVirtualScreenBlockList + * @tc.desc: AddVirtualScreenBlockList + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, AddVirtualScreenBlockList, TestSize.Level1) +{ + std::vector persistentIds {0, 1, 2}; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->AddVirtualScreenBlockList(persistentIds)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->AddVirtualScreenBlockList(persistentIds)); + } +} + +/** + * @tc.name: RemoveVirtualScreenBlockList + * @tc.desc: RemoveVirtualScreenBlockList + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, RemoveVirtualScreenBlockList, TestSize.Level1) +{ + std::vector persistentIds {0, 1, 2}; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->RemoveVirtualScreenBlockList(persistentIds)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->RemoveVirtualScreenBlockList(persistentIds)); + } +} + +/** + * @tc.name: SetVirtualMirrorScreenCanvasRotation + * @tc.desc: SetVirtualMirrorScreenCanvasRotation + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualMirrorScreenCanvasRotation, TestSize.Level1) +{ + ScreenId ScreenId = 1001; + bool canvasRotation = true; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetVirtualMirrorScreenCanvasRotation(ScreenId, canvasRotation)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetVirtualMirrorScreenCanvasRotation(ScreenId, canvasRotation)); + } +} + +/** + * @tc.name: SetVirtualMirrorScreenScaleMode + * @tc.desc: SetVirtualMirrorScreenScaleMode + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualMirrorScreenScaleMode, TestSize.Level1) +{ + ScreenId ScreenId = 1001; + ScreenScaleMode scaleMode {0}; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetVirtualMirrorScreenScaleMode(ScreenId, scaleMode)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetVirtualMirrorScreenScaleMode(ScreenId, scaleMode)); + } +} + +/** + * @tc.name: ResizeVirtualScreen + * @tc.desc: ResizeVirtualScreen + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, ResizeVirtualScreen, TestSize.Level1) +{ + ScreenId ScreenId = 1001; + uint32_t width = 1024; + uint32_t height = 1024; + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->ResizeVirtualScreen(ScreenId, width, height)); +} + +/** + * @tc.name: DestroyVirtualScreen + * @tc.desc: DestroyVirtualScreen + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, DestroyVirtualScreen, TestSize.Level1) +{ + ScreenId ScreenId = 1001; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->DestroyVirtualScreen(ScreenId)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->DestroyVirtualScreen(ScreenId)); + } +} + +/** + * @tc.name: MakeMirror + * @tc.desc: MakeMirror + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, MakeMirror, TestSize.Level1) +{ + ScreenId Id = 1001; + std::vector mirrorScreenIds = {1003, 1004, 1005}; + ScreenId screenGroupId = 1002; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->MakeMirror(Id, mirrorScreenIds, screenGroupId)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->MakeMirror(Id, mirrorScreenIds, screenGroupId)); + } +} + +/** + * @tc.name: StopMirror + * @tc.desc: StopMirror + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, StopMirror, TestSize.Level1) +{ + const std::vector mirrorScreenIds = {1003, 1004, 1005}; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->StopMirror(mirrorScreenIds)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->StopMirror(mirrorScreenIds)); + } +} + +/** + * @tc.name: DisableMirror + * @tc.desc: DisableMirror + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, DisableMirror, TestSize.Level1) +{ + bool disableOrNot = true; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->DisableMirror(disableOrNot)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->DisableMirror(disableOrNot)); + } +} + +/** + * @tc.name: MakeExpand + * @tc.desc: MakeExpand + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, MakeExpand, TestSize.Level1) +{ + std::vector screenId = {1003, 1004, 1005}; + std::vector startPoint {}; + ScreenId screenGroupId = 1001; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->MakeExpand(screenId, startPoint, screenGroupId)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->MakeExpand(screenId, startPoint, screenGroupId)); + } +} + +/** + * @tc.name: StopExpand + * @tc.desc: StopExpand + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, StopExpand, TestSize.Level1) +{ + const std::vector expandScreenIds = {1003, 1004, 1005}; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->StopExpand(expandScreenIds)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->StopExpand(expandScreenIds)); + } +} + +/** + * @tc.name: GetScreenGroupInfoById + * @tc.desc: GetScreenGroupInfoById + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenGroupInfoById, TestSize.Level1) +{ + sptr expectation = nullptr; + sptr res = nullptr; + ScreenId Id {0}; + std::function func = [&]() + { + res = screenSessionManagerProxy->GetScreenGroupInfoById(Id); + }; + func(); + ASSERT_EQ(res, expectation); +} + +/** + * @tc.name: RemoveVirtualScreenFromGroup + * @tc.desc: RemoveVirtualScreenFromGroup + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, RemoveVirtualScreenFromGroup, TestSize.Level1) +{ + std::vector screens = {1002, 1003, 1004}; + screenSessionManagerProxy->RemoveVirtualScreenFromGroup(screens); + auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000); + EXPECT_EQ(screenSession, nullptr); +} + +/** + * @tc.name: GetDisplaySnapshot + * @tc.desc: GetDisplaySnapshot + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetDisplaySnapshot, TestSize.Level1) +{ + std::shared_ptr expectation = nullptr; + std::shared_ptr res = nullptr; + DisplayId displayId {0}; + DmErrorCode* errorCode = nullptr; + std::function func = [&]() + { + res = screenSessionManagerProxy->GetDisplaySnapshot(displayId, errorCode, false, false); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, expectation); + } else { + ASSERT_EQ(res, expectation); + } +} + +/** + * @tc.name: GetDisplayInfoById + * @tc.desc: GetDisplayInfoById + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetDisplayInfoById, TestSize.Level1) +{ + sptr expectation = nullptr; + sptr res = nullptr; + DisplayId displayId {0}; + std::function func = [&]() + { + res = screenSessionManagerProxy->GetDisplayInfoById(displayId); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, expectation); + } else { + ASSERT_EQ(res, expectation); + } +} + +/** + * @tc.name: GetDisplayInfoByScreen + * @tc.desc: GetDisplayInfoByScreen + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetDisplayInfoByScreen, TestSize.Level1) +{ + sptr expectation = nullptr; + sptr res = nullptr; + ScreenId screenId {0}; + std::function func = [&]() + { + res = screenSessionManagerProxy->GetDisplayInfoByScreen(screenId); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, expectation); + } else { + ASSERT_EQ(res, expectation); + } +} + +/** + * @tc.name: GetAllDisplayIds + * @tc.desc: GetAllDisplayIds + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetAllDisplayIds, TestSize.Level1) +{ + int resultValue = 0; + std::function func = [&]() + { + screenSessionManagerProxy->GetAllDisplayIds(); + resultValue = 1; + }; + func(); + ASSERT_EQ(resultValue, 1); +} + +/** + * @tc.name: GetScreenInfoById + * @tc.desc: GetScreenInfoById + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenInfoById, TestSize.Level1) +{ + sptr expectation = nullptr; + sptr res = nullptr; + ScreenId Id {0}; + std::function func = [&]() + { + res = screenSessionManagerProxy->GetScreenInfoById(Id); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, expectation); + } else { + ASSERT_EQ(res, expectation); + } +} + +/** + * @tc.name: GetAllScreenInfos + * @tc.desc: GetAllScreenInfos + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetAllScreenInfos, TestSize.Level1) +{ + std::vector> screenInfos {}; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->GetAllScreenInfos(screenInfos)); + } else { + ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->GetAllScreenInfos(screenInfos)); + } +} + +/** + * @tc.name: GetScreenSupportedColorGamuts + * @tc.desc: GetScreenSupportedColorGamuts + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenSupportedColorGamuts, TestSize.Level1) +{ + ScreenId screenId = 1001; + std::vector colorGamuts {}; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->GetScreenSupportedColorGamuts(screenId, colorGamuts)); + } else { + ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->GetScreenSupportedColorGamuts(screenId, colorGamuts)); + } +} + +/** + * @tc.name: SetOrientation + * @tc.desc: SetOrientation + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetOrientation, TestSize.Level1) +{ + ScreenId screenId = 1001; + Orientation orientation = Orientation::BEGIN; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetOrientation(screenId, orientation)); + } else { + ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetOrientation(screenId, orientation)); + } +} + +/** + * @tc.name: SetScreenRotationLocked + * @tc.desc: SetScreenRotationLocked + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenRotationLocked, TestSize.Level1) +{ + bool isLocked = true; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetScreenRotationLocked(isLocked)); + } else { + ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetScreenRotationLocked(isLocked)); + } +} + +/** + * @tc.name: SetScreenRotationLockedFromJs + * @tc.desc: SetScreenRotationLockedFromJs + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenRotationLockedFromJs, TestSize.Level1) +{ + bool isLocked = true; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetScreenRotationLockedFromJs(isLocked)); + } else { + ASSERT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->SetScreenRotationLockedFromJs(isLocked)); + } +} + +/** + * @tc.name: SetMultiScreenMode + * @tc.desc: SetMultiScreenMode + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetMultiScreenMode, TestSize.Level1) +{ + ScreenId mainScreenId = 0; + ScreenId secondaryScreenId = 1; + MultiScreenMode screenMode = MultiScreenMode::SCREEN_EXTEND; + + DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; + std::function func = [&]() + { + res = screenSessionManagerProxy->SetMultiScreenMode(mainScreenId, secondaryScreenId, screenMode); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } +} + +/** + * @tc.name: SetMultiScreenRelativePosition + * @tc.desc: SetMultiScreenRelativePosition + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetMultiScreenRelativePosition, TestSize.Level1) +{ + ScreenId testId = 2060; + ScreenId testId1 = 3060; + MultiScreenPositionOptions mainScreenOptions = {testId, 100, 100}; + MultiScreenPositionOptions secondScreenOption = {testId1, 100, 100}; + + DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; + std::function func = [&]() + { + res = screenSessionManagerProxy->SetMultiScreenRelativePosition(mainScreenOptions, secondScreenOption); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_EQ(res, DMError::DM_ERROR_IPC_FAILED); + } +} + +/** + * @tc.name: SetVirtualScreenMaxRefreshRate + * @tc.desc: SetVirtualScreenMaxRefreshRate + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetVirtualScreenMaxRefreshRate, TestSize.Level1) +{ + ScreenId id = 0; + uint32_t refreshRate = 12; + uint32_t actualRefreshRate = 0; + + DMError res = DMError::DM_ERROR_NOT_SYSTEM_APP; + std::function func = [&]() + { + res = screenSessionManagerProxy->SetVirtualScreenMaxRefreshRate(id, refreshRate, actualRefreshRate); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } else { + ASSERT_NE(res, DMError::DM_ERROR_IPC_FAILED); + } +} + +/** + * @tc.name: IsScreenRotationLocked + * @tc.desc: IsScreenRotationLocked + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, IsScreenRotationLocked, TestSize.Level1) +{ + bool isLocked = true; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->IsScreenRotationLocked(isLocked)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->IsScreenRotationLocked(isLocked)); + } +} + +/** + * @tc.name: GetCutoutInfo + * @tc.desc: GetCutoutInfo + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetCutoutInfo, TestSize.Level1) +{ + sptr expectation = nullptr; + sptr res = nullptr; + DisplayId displayId = 0; + std::function func = [&]() + { + res = screenSessionManagerProxy->GetCutoutInfo(displayId); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, expectation); + } else { + ASSERT_EQ(res, expectation); + } +} + +/** + * @tc.name: HasImmersiveWindow + * @tc.desc: HasImmersiveWindow + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, HasImmersiveWindow, TestSize.Level1) +{ + bool immersive = true; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->HasImmersiveWindow(0u, immersive)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->HasImmersiveWindow(0u, immersive)); + } +} + +/** + * @tc.name: ConvertScreenIdToRsScreenId + * @tc.desc: ConvertScreenIdToRsScreenId + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, ConvertScreenIdToRsScreenId, TestSize.Level1) +{ + ScreenId screenId = 1001; + ScreenId rsScreenId = 1002; + auto ret = screenSessionManagerProxy->ConvertScreenIdToRsScreenId(screenId, rsScreenId); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: HasPrivateWindow + * @tc.desc: HasPrivateWindow + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, HasPrivateWindow, TestSize.Level1) +{ + bool hasPrivateWindow = true; + DisplayId displayId = 0; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->HasPrivateWindow(displayId, hasPrivateWindow)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->HasPrivateWindow(displayId, hasPrivateWindow)); + } +} + +/** + * @tc.name: DumpAllScreensInfo + * @tc.desc: DumpAllScreensInfo + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, DumpAllScreensInfo, TestSize.Level1) +{ + std::string dumpInfo; + screenSessionManagerProxy->DumpAllScreensInfo(dumpInfo); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(dumpInfo, ""); + } else { + EXPECT_EQ(dumpInfo, ""); + } +} + +/** + * @tc.name: DumpSpecialScreenInfo + * @tc.desc: DumpSpecialScreenInfo + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, DumpSpecialScreenInfo, TestSize.Level1) +{ + ScreenId id = 1001; + std::string dumpInfo; + screenSessionManagerProxy->DumpSpecialScreenInfo(id, dumpInfo); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(dumpInfo, ""); + } else { + EXPECT_EQ(dumpInfo, ""); + } +} + +/** + * @tc.name: SetFoldDisplayMode + * @tc.desc: SetFoldDisplayMode + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetFoldDisplayMode, TestSize.Level1) +{ + FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN; + screenSessionManagerProxy->SetFoldDisplayMode(displayMode); + if (screenSessionManagerProxy->IsFoldable() && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + EXPECT_NE(ScreenSessionManager::GetInstance().foldScreenController_, nullptr); + } else { + EXPECT_EQ(ScreenSessionManager::GetInstance().foldScreenController_, nullptr); + } +} + +/** + * @tc.name: SetFoldDisplayModeFromJs + * @tc.desc: SetFoldDisplayModeFromJs + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetFoldDisplayModeFromJs, TestSize.Level1) +{ + FoldDisplayMode displayMode = FoldDisplayMode::UNKNOWN; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->SetFoldDisplayModeFromJs(displayMode)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, screenSessionManagerProxy->SetFoldDisplayModeFromJs(displayMode)); + } +} + +/** + * @tc.name: SetFoldStatusLocked + * @tc.desc: SetFoldStatusLocked + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetFoldStatusLocked, TestSize.Level1) +{ + bool locked = true; + screenSessionManagerProxy->SetFoldStatusLocked(locked); + if (screenSessionManagerProxy->IsFoldable() && !FoldScreenStateInternel::IsSuperFoldDisplayDevice()) { + EXPECT_NE(ScreenSessionManager::GetInstance().foldScreenController_, nullptr); + } else { + EXPECT_EQ(ScreenSessionManager::GetInstance().foldScreenController_, nullptr); + } +} + +/** + * @tc.name: GetFoldDisplayMode + * @tc.desc: GetFoldDisplayMode + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetFoldDisplayMode, TestSize.Level1) +{ + EXPECT_EQ(FoldDisplayMode::UNKNOWN, screenSessionManagerProxy->GetFoldDisplayMode()); +} + +/** + * @tc.name: IsFoldable + * @tc.desc: IsFoldable + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, IsFoldable, TestSize.Level1) +{ + screenSessionManagerProxy->IsFoldable(); + auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000); + EXPECT_EQ(screenSession, nullptr); +} + +/** + * @tc.name: IsCaptured + * @tc.desc: IsCaptured + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, IsCaptured, TestSize.Level1) +{ + auto ret = screenSessionManagerProxy->IsCaptured(); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: GetFoldStatus + * @tc.desc: GetFoldStatus + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetFoldStatus, TestSize.Level1) +{ + auto foldStatus = screenSessionManagerProxy->GetFoldStatus(); + EXPECT_EQ(foldStatus, FoldStatus::UNKNOWN); +} + +/** + * @tc.name: GetSuperFoldStatus + * @tc.desc: GetSuperFoldStatus + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetSuperFoldStatus, TestSize.Level1) +{ + auto superFoldStatus = screenSessionManagerProxy->GetSuperFoldStatus(); + EXPECT_EQ(superFoldStatus, SuperFoldStatus::UNKNOWN); +} + +/** + * @tc.name: SetLandscapeLockStatus + * @tc.desc: SetLandscapeLockStatus + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetLandscapeLockStatus, Function | SmallTest | Level1) +{ + bool isLocked = false; + screenSessionManagerProxy->SetLandscapeLockStatus(isLocked); + EXPECT_EQ(isLocked, false); +} + +/** + * @tc.name: GetCurrentFoldCreaseRegion + * @tc.desc: GetCurrentFoldCreaseRegion + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetCurrentFoldCreaseRegion, TestSize.Level1) +{ + auto foldCreaseRegion = screenSessionManagerProxy->GetCurrentFoldCreaseRegion(); + EXPECT_EQ(foldCreaseRegion, nullptr); +} + +/** + * @tc.name: MakeUniqueScreen + * @tc.desc: MakeUniqueScreen + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, MakeUniqueScreen, TestSize.Level1) +{ + const std::vector screenIds {1001, 1002, 1003}; + std::vector displayIds; + EXPECT_EQ(DMError::DM_ERROR_NULLPTR, screenSessionManagerProxy->MakeUniqueScreen(screenIds, displayIds)); +} + +/** + * @tc.name: SetClient + * @tc.desc: SetClient + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetClient, TestSize.Level1) +{ + const sptr client = nullptr; + screenSessionManagerProxy->SetClient(client); + EXPECT_EQ(client, nullptr); +} + +/** + * @tc.name: SwitchUser + * @tc.desc: SwitchUser + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SwitchUser, TestSize.Level1) +{ + screenSessionManagerProxy->SwitchUser(); + auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000); + EXPECT_EQ(screenSession, nullptr); +} + +/** + * @tc.name: GetScreenProperty + * @tc.desc: GetScreenProperty + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenProperty, TestSize.Level1) +{ + ScreenId screenId = 1001; + screenSessionManagerProxy->GetScreenProperty(screenId); + auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000); + EXPECT_EQ(screenSession, nullptr); +} + +/** + * @tc.name: GetDisplayHookInfo + * @tc.desc: GetDisplayHookInfo + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetDisplayHookInfo, Function | SmallTest | Level1) +{ + int32_t uid = 0; + DMHookInfo hookInfo; + hookInfo.height_ = 1344; + hookInfo.width_ = 2772; + std::function func = [&]() + { + screenSessionManagerProxy->GetDisplayHookInfo(uid, hookInfo); + }; + func(); + + EXPECT_EQ(hookInfo.height_, 1344); + EXPECT_EQ(hookInfo.width_, 2772); +} + +/** + * @tc.name: GetScreenCapture + * @tc.desc: GetScreenCapture test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetScreenCapture, TestSize.Level1) +{ + ASSERT_TRUE(screenSessionManagerProxy != nullptr); + + std::shared_ptr res = nullptr; + CaptureOption option; + option.displayId_ = 0; + DmErrorCode errorCode = DmErrorCode::DM_OK; + std::function func = [&]() { + res = screenSessionManagerProxy->GetScreenCapture(option, &errorCode); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + if (errorCode == DmErrorCode::DM_OK) { + ASSERT_NE(res, nullptr); + } else { + ASSERT_EQ(res, nullptr); + } + } else { + ASSERT_EQ(res, nullptr); + } +} + +/** + * @tc.name: GetPrimaryDisplayInfo + * @tc.desc: GetPrimaryDisplayInfo test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetPrimaryDisplayInfo, TestSize.Level1) +{ + ASSERT_TRUE(screenSessionManagerProxy != nullptr); + + sptr res = nullptr; + std::function func = [&]() { + res = screenSessionManagerProxy->GetPrimaryDisplayInfo(); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, nullptr); + } else { + ASSERT_EQ(res, nullptr); + } +} + +/** + * @tc.name: SetScreenSkipProtectedWindow + * @tc.desc: SetScreenSkipProtectedWindow test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, SetScreenSkipProtectedWindow, TestSize.Level1) +{ + ASSERT_TRUE(screenSessionManagerProxy != nullptr); + + const std::vector screenIds = {1001, 1002}; + bool isEnable = true; + int resultValue = 0; + std::function func = [&]() { + screenSessionManagerProxy->SetScreenSkipProtectedWindow(screenIds, isEnable); + resultValue = 1; + }; + func(); + ASSERT_EQ(resultValue, 1); +} + +/** + * @tc.name: GetDisplayCapability + * @tc.desc: GetDisplayCapability test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyUtTest, GetDisplayCapability, TestSize.Level1) +{ + ASSERT_TRUE(screenSessionManagerProxy != nullptr); + std::string capabilitInfo; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_NE(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->GetDisplayCapability(capabilitInfo)); + } else { + EXPECT_EQ(DMError::DM_ERROR_IPC_FAILED, + screenSessionManagerProxy->GetDisplayCapability(capabilitInfo)); + } +} } } -} \ No newline at end of file diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index 7b4589a2f1..2745299c4f 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -305,7 +305,10 @@ ohos_unittest("ws_session_listener_controller_test") { sources = [ "session_listener_controller_test.cpp" ] - deps = [ ":ws_unittest_common" ] + deps = [ + ":ws_unittest_common", + "${window_base_path}/window_scene/interfaces/innerkits:libwsutils", + ] external_deps = test_external_deps } @@ -1501,6 +1504,8 @@ config("ws_unittest_common_public_config") { # for window_manager_hilog "${window_base_path}/utils/include", + + "${dmserver_gen_path}", ] } diff --git a/window_scene/test/unittest/session_listener_controller_test.cpp b/window_scene/test/unittest/session_listener_controller_test.cpp index 13f54daa8e..caf07cbc71 100644 --- a/window_scene/test/unittest/session_listener_controller_test.cpp +++ b/window_scene/test/unittest/session_listener_controller_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,18 +13,18 @@ * limitations under the License. */ -#include "pixel_map.h" -#include "session_listener_controller.h" - #include +#include #include "display_manager_adapter.h" #include "mission_listener_stub.h" +#include "scene_board_judgement.h" +#include "scene_session_manager.h" +#include "session/host/include/main_session.h" +#include "session/host/include/scene_session.h" +#include "session_listener_controller.h" #include "singleton_container.h" #include "zidl/session_lifecycle_listener_stub.h" -#include "session/host/include/scene_session.h" -#include "session/host/include/main_session.h" -#include "scene_session_manager.h" using namespace testing; using namespace testing::ext; @@ -376,7 +376,11 @@ HWTEST_F(SessionListenerControllerTest, OnListenerDied, TestSize.Level1) EXPECT_EQ(nullptr, remote); if (SingletonContainer::Get().InitDMSProxy()) { - remote = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + remote = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + remote = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } slController->OnListenerDied(remote); EXPECT_NE(nullptr, remote); } @@ -434,7 +438,11 @@ HWTEST_F(SessionListenerControllerTest, ListenerDeathRecipient, TestSize.Level1) if (SingletonContainer::Get().InitDMSProxy()) { sptr remote; - remote = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + remote = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + remote = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } slController->listenerDeathRecipient_->OnRemoteDied(remote); EXPECT_NE(nullptr, remote); } @@ -542,7 +550,6 @@ HWTEST_F(SessionListenerControllerTest, NotifySessionLifecycleEvent02, Function sptr listener = iface_cast(myListener->AsObject()); ASSERT_NE(listener, nullptr); std::vector persistentIdList = { 102 }; - SessionInfo info; info.bundleName_ = "com.example.myapp"; info.abilityName_ = "MainAbility"; @@ -553,11 +560,10 @@ HWTEST_F(SessionListenerControllerTest, NotifySessionLifecycleEvent02, Function sptr sceneSession = sptr::MakeSptr(info, nullptr); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); ssm->sceneSessionMap_.insert({ 102, sceneSession }); - slController->RegisterSessionLifecycleListener(listener, persistentIdList); slController->NotifySessionLifecycleEvent(ISessionLifecycleListener::SessionLifecycleEvent::CREATED, info); ASSERT_EQ(myListener->event_, ISessionLifecycleListener::SessionLifecycleEvent::CREATED); } } // namespace } // namespace Rosen -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/windowmanager_aafwk.gni b/windowmanager_aafwk.gni index 9195d07ec4..0ff5398a04 100644 --- a/windowmanager_aafwk.gni +++ b/windowmanager_aafwk.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -28,6 +28,7 @@ multimedia_path = "//foundation/multimedia/image_framework" multimodalinput_path = "//foundation/multimodalinput" sensor_path = "//base/sensors/sensor" accessibility_path = "//foundation/barrierfree/accessibility" +dmserver_gen_path = "${root_gen_dir}/foundation/window/window_manager/dmserver" declare_args() { device_status_enable = true diff --git a/wm/BUILD.gn b/wm/BUILD.gn index f690d938ef..a37f598005 100644 --- a/wm/BUILD.gn +++ b/wm/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -22,6 +22,7 @@ config("libwm_private_config") { "../wmserver/include", "../wmserver/include/zidl", "../window_scene/session/host/include", + "${dmserver_gen_path}", ] } diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index 7a1ebe8f87..642253ff8e 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -593,7 +593,10 @@ ohos_unittest("wm_window_manager_agent_proxy_test") { sources = [ "window_manager_agent_proxy_test.cpp" ] - deps = [ ":wm_unittest_common" ] + deps = [ + ":wm_unittest_common", + "${window_base_path}/window_scene/interfaces/innerkits:libwsutils", + ] external_deps = test_external_deps } @@ -693,6 +696,7 @@ config("wm_unittest_common_public_config") { "${window_base_path}/window_scene", "${window_base_path}/window_scene/test/mock", "${window_base_path}/window_scene/session/host/include/zidl", + "${dmserver_gen_path}", ] } diff --git a/wm/test/unittest/window_manager_agent_proxy_test.cpp b/wm/test/unittest/window_manager_agent_proxy_test.cpp index d09e41cb72..9c048d9cc7 100644 --- a/wm/test/unittest/window_manager_agent_proxy_test.cpp +++ b/wm/test/unittest/window_manager_agent_proxy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,8 +15,9 @@ #include #include + #include "display_manager_adapter.h" -#include "window_manager_agent.h" +#include "scene_board_judgement.h" #include "window_manager_agent_proxy.h" using namespace testing; @@ -25,20 +26,38 @@ namespace OHOS { namespace Rosen { class WindowManagerAgentProxyTest : public testing::Test { public: - static void SetUpTestCase(); - static void TearDownTestCase(); + static void SetUpTestSuite(); void SetUp() override; void TearDown() override; + sptr windowManagerAgentProxy; private: static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; }; -void WindowManagerAgentProxyTest::SetUpTestCase() {} +void WindowManagerAgentProxyTest::SetUpTestSuite() +{ + ASSERT_TRUE(SingletonContainer::Get().InitDMSProxy()); +} -void WindowManagerAgentProxyTest::TearDownTestCase() {} +void WindowManagerAgentProxyTest::SetUp() +{ + if (windowManagerAgentProxy) { + return; + } -void WindowManagerAgentProxyTest::SetUp() {} + sptr impl; + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(SingletonContainer::Get().screenSessionManagerServiceProxy_, nullptr); + impl = SingletonContainer::Get().screenSessionManagerServiceProxy_->AsObject(); + } else { + ASSERT_NE(SingletonContainer::Get().displayManagerServiceProxy_, nullptr); + impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + } + + windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); + ASSERT_NE(windowManagerAgentProxy, nullptr); +} void WindowManagerAgentProxyTest::TearDown() { @@ -53,15 +72,10 @@ namespace { */ HWTEST_F(WindowManagerAgentProxyTest, UpdateFocusChangeInfo01, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - sptr focusChangeInfo = new (std::nothrow) FocusChangeInfo(); + sptr focusChangeInfo = new(std::nothrow) FocusChangeInfo(); ASSERT_TRUE(focusChangeInfo != nullptr); bool focused = true; - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->UpdateFocusChangeInfo(focusChangeInfo, focused); @@ -78,12 +92,6 @@ HWTEST_F(WindowManagerAgentProxyTest, UpdateFocusChangeInfo01, TestSize.Level1) */ HWTEST_F(WindowManagerAgentProxyTest, UpdateFocusChangeInfo02, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->UpdateFocusChangeInfo(nullptr, false); @@ -100,12 +108,6 @@ HWTEST_F(WindowManagerAgentProxyTest, UpdateFocusChangeInfo02, TestSize.Level1) */ HWTEST_F(WindowManagerAgentProxyTest, UpdateWindowModeTypeInfo, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; WindowModeType type = WindowModeType::WINDOW_MODE_SPLIT_FLOATING; std::function func = [&]() { @@ -123,15 +125,9 @@ HWTEST_F(WindowManagerAgentProxyTest, UpdateWindowModeTypeInfo, TestSize.Level1) */ HWTEST_F(WindowManagerAgentProxyTest, UpdateSystemBarRegionTints, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); DisplayId displayId = 0; SystemBarRegionTints tints = {}; - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->UpdateSystemBarRegionTints(displayId, tints); @@ -148,15 +144,9 @@ HWTEST_F(WindowManagerAgentProxyTest, UpdateSystemBarRegionTints, TestSize.Level */ HWTEST_F(WindowManagerAgentProxyTest, NotifyAccessibilityWindowInfo, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); std::vector> infos = {}; WindowUpdateType type = WindowUpdateType::WINDOW_UPDATE_REMOVED; - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->NotifyAccessibilityWindowInfo(infos, type); @@ -173,14 +163,8 @@ HWTEST_F(WindowManagerAgentProxyTest, NotifyAccessibilityWindowInfo, TestSize.Le */ HWTEST_F(WindowManagerAgentProxyTest, UpdateWindowVisibilityInfo, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); std::vector> visibilityInfos = {}; - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->UpdateWindowVisibilityInfo(visibilityInfos); @@ -197,14 +181,8 @@ HWTEST_F(WindowManagerAgentProxyTest, UpdateWindowVisibilityInfo, TestSize.Level */ HWTEST_F(WindowManagerAgentProxyTest, UpdateWindowDrawingContentInfo, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); std::vector> windowDrawingContentInfos = {}; - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->UpdateWindowDrawingContentInfo(windowDrawingContentInfos); @@ -221,15 +199,9 @@ HWTEST_F(WindowManagerAgentProxyTest, UpdateWindowDrawingContentInfo, TestSize.L */ HWTEST_F(WindowManagerAgentProxyTest, UpdateCameraFloatWindowStatus, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); uint32_t accessTokenId = 0; bool isShowing = true; - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->UpdateCameraFloatWindowStatus(accessTokenId, isShowing); @@ -246,14 +218,8 @@ HWTEST_F(WindowManagerAgentProxyTest, UpdateCameraFloatWindowStatus, TestSize.Le */ HWTEST_F(WindowManagerAgentProxyTest, NotifyWaterMarkFlagChangedResult, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); bool showWaterMark = true; - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->NotifyWaterMarkFlagChangedResult(showWaterMark); @@ -269,13 +235,7 @@ HWTEST_F(WindowManagerAgentProxyTest, NotifyWaterMarkFlagChangedResult, TestSize * @tc.type: FUNC */ HWTEST_F(WindowManagerAgentProxyTest, UpdateVisibleWindowNum, TestSize.Level1) -{ - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; +{ int resultValue = 0; VisibleWindowNumInfo info; info.displayId = 1; info.visibleWindowNum = 1; @@ -296,14 +256,8 @@ HWTEST_F(WindowManagerAgentProxyTest, UpdateVisibleWindowNum, TestSize.Level1) */ HWTEST_F(WindowManagerAgentProxyTest, NotifyGestureNavigationEnabledResult, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); bool enable = true; - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->NotifyGestureNavigationEnabledResult(enable); @@ -320,15 +274,9 @@ HWTEST_F(WindowManagerAgentProxyTest, NotifyGestureNavigationEnabledResult, Test */ HWTEST_F(WindowManagerAgentProxyTest, UpdateCameraWindowStatus, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); uint32_t accessTokenId = 1; bool isShowing = false; - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->UpdateCameraWindowStatus(accessTokenId, isShowing); @@ -345,14 +293,8 @@ HWTEST_F(WindowManagerAgentProxyTest, UpdateCameraWindowStatus, TestSize.Level1) */ HWTEST_F(WindowManagerAgentProxyTest, NotifyWindowStyleChange, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); WindowStyleType type = Rosen::WindowStyleType::WINDOW_STYLE_DEFAULT; - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - int resultValue = 0; std::function func = [&]() { windowManagerAgentProxy->NotifyWindowStyleChange(type); @@ -369,13 +311,6 @@ HWTEST_F(WindowManagerAgentProxyTest, NotifyWindowStyleChange, TestSize.Level1) */ HWTEST_F(WindowManagerAgentProxyTest, NotifyWindowPidVisibilityChanged, TestSize.Level1) { - SingletonContainer::Get().InitDMSProxy(); - sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); - ASSERT_TRUE(impl != nullptr); - - sptr windowManagerAgentProxy = new (std::nothrow) WindowManagerAgentProxy(impl); - ASSERT_TRUE(windowManagerAgentProxy != nullptr); - sptr info = new WindowPidVisibilityInfo(); int resultValue = 0; @@ -389,4 +324,4 @@ HWTEST_F(WindowManagerAgentProxyTest, NotifyWindowPidVisibilityChanged, TestSize } // namespace } // namespace Rosen -} // namespace OHOS \ No newline at end of file +} // namespace OHOS