diff --git a/dm/BUILD.gn b/dm/BUILD.gn index b78cc5f439..145fb73dcf 100644 --- a/dm/BUILD.gn +++ b/dm/BUILD.gn @@ -36,10 +36,6 @@ config("libdm_public_config") { ] } -config("libdm_ndk_public_config") { - include_dirs = [ "../interfaces/kits/dmndk/dm" ] -} - config("for_libdm_public_config") { include_dirs = [ "../../../multimedia/image_framework/interfaces/innerkits/include" ] @@ -160,6 +156,10 @@ group("test") { } ## Build libdm_ndk.so +config("libdm_ndk_public_config") { + include_dirs = [ "../interfaces/kits/dmndk/dm" ] +} + ohos_shared_library("libdm_ndk") { branch_protector_ret = "pac_ret" output_name = "libnative_display_manager" @@ -175,6 +175,7 @@ ohos_shared_library("libdm_ndk") { public_configs = [ ":libdm_ndk_public_config" ] include_dirs = [ + ".", "${window_base_path}/interfaces/kits/dmndk/dm", "${window_base_path}/interfaces/inner_kits/dm", ] @@ -187,6 +188,7 @@ ohos_shared_library("libdm_ndk") { external_deps = [ "c_utils:utils", "hilog:libhilog", + "image_framework:pixelmap", ] part_name = "window_manager" diff --git a/dm/include/display_manager_adapter.h b/dm/include/display_manager_adapter.h index 3d1ceda578..11e30baaee 100644 --- a/dm/include/display_manager_adapter.h +++ b/dm/include/display_manager_adapter.h @@ -98,6 +98,8 @@ public: virtual std::vector GetAllDisplayPhysicalResolution(); virtual DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, std::vector& windowIdList); + virtual std::shared_ptr GetScreenCapture(const CaptureOption& captureOption, + DmErrorCode* errorCode = nullptr); private: static inline SingletonDelegator delegator; diff --git a/dm/src/display_manager.cpp b/dm/src/display_manager.cpp index ae5101c1a4..87db7d097b 100644 --- a/dm/src/display_manager.cpp +++ b/dm/src/display_manager.cpp @@ -613,12 +613,38 @@ sptr DisplayManager::Impl::GetDefaultDisplaySync() sptr DisplayManager::Impl::GetDisplayById(DisplayId displayId) { WLOGFD("GetDisplayById start, displayId: %{public}" PRIu64" ", displayId); - auto displayInfo = SingletonContainer::Get().GetDisplayInfo(displayId); + static std::chrono::steady_clock::time_point lastRequestTime = std::chrono::steady_clock::now(); + auto currentTime = std::chrono::steady_clock::now(); + auto interval = std::chrono::duration_cast(currentTime - lastRequestTime).count(); + if (displayId != DISPLAY_ID_INVALID && interval < MAX_INTERVAL_US) { + std::lock_guard lock(mutex_); + auto iter = displayMap_.find(displayId); + if (iter != displayMap_.end()) { + WLOGFI("Get display from displayMap_"); + return displayMap_[displayId]; + } + } + uint32_t retryTimes = 0; + sptr displayInfo = nullptr; + while (retryTimes < MAX_RETRY_NUM) { + displayInfo = SingletonContainer::Get().GetDisplayInfo(displayId); + if (displayInfo != nullptr) { + break; + } + retryTimes++; + WLOGFW("Current get display info is null, retry %{public}u times", retryTimes); + std::this_thread::sleep_for(std::chrono::milliseconds(RETRY_WAIT_MS)); + } + if (retryTimes >= MAX_RETRY_NUM || displayInfo == nullptr) { + WLOGFE("Get display info failed, please check whether the onscreenchange event is triggered"); + return nullptr; + } std::lock_guard lock(mutex_); if (!UpdateDisplayInfoLocked(displayInfo)) { displayMap_.erase(displayId); return nullptr; } + lastRequestTime = currentTime; return displayMap_[displayId]; } @@ -1871,7 +1897,6 @@ bool DisplayManager::Impl::SetDisplayState(DisplayState state, DisplayStateCallb { std::lock_guard lock(mutex_); if (displayStateCallback_ != nullptr || callback == nullptr) { - WLOGFI("[UL_POWER]previous callback not called or callback invalid"); if (displayStateCallback_ != nullptr) { WLOGFI("[UL_POWER]previous callback not called, the displayStateCallback_ is not null"); } @@ -1937,11 +1962,11 @@ bool DisplayManager::Freeze(std::vector displayIds) { WLOGFD("freeze display"); if (displayIds.size() == 0) { - WLOGFE("freeze display fail, num of display is 0"); + WLOGFE("freeze fail, num of display is 0"); return false; } if (displayIds.size() > MAX_DISPLAY_SIZE) { - WLOGFE("freeze display fail, displayIds size is bigger than %{public}u.", MAX_DISPLAY_SIZE); + WLOGFE("freeze fail, displayIds size is bigger than %{public}u.", MAX_DISPLAY_SIZE); return false; } return SingletonContainer::Get().SetFreeze(displayIds, true); @@ -1951,11 +1976,11 @@ bool DisplayManager::Unfreeze(std::vector displayIds) { WLOGFD("unfreeze display"); if (displayIds.size() == 0) { - WLOGFE("unfreeze display fail, num of display is 0"); + WLOGFE("unfreeze fail, num of display is 0"); return false; } if (displayIds.size() > MAX_DISPLAY_SIZE) { - WLOGFE("unfreeze display fail, displayIds size is bigger than %{public}u.", MAX_DISPLAY_SIZE); + WLOGFE("unfreeze fail, displayIds size is bigger than %{public}u.", MAX_DISPLAY_SIZE); return false; } return SingletonContainer::Get().SetFreeze(displayIds, false); @@ -2060,5 +2085,22 @@ DMError DisplayManager::Impl::SetVirtualScreenSecurityExemption(ScreenId screenI return SingletonContainer::Get().SetVirtualScreenSecurityExemption( screenId, pid, windowIdList); } + +sptr DisplayManager::GetPrimaryDisplaySync() +{ + return pImpl_->GetDefaultDisplaySync(); +} + +std::shared_ptr DisplayManager::GetScreenCapture(const CaptureOption& captureOption, + DmErrorCode* errorCode) +{ + std::shared_ptr screenCapture = + SingletonContainer::Get().GetScreenCapture(captureOption, errorCode); + if (screenCapture == nullptr) { + WLOGFE("screen capture failed!"); + return nullptr; + } + return screenCapture; +} } // namespace OHOS::Rosen diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index 679c849209..b55b94c5d3 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -850,4 +850,10 @@ DMError ScreenManagerAdapter::SetVirtualScreenMaxRefreshRate(ScreenId id, uint32 return displayManagerServiceProxy_->SetVirtualScreenMaxRefreshRate(id, refreshRate, actualRefreshRate); } +std::shared_ptr DisplayManagerAdapter::GetScreenCapture(const CaptureOption& captureOption, + DmErrorCode* errorCode) +{ + INIT_PROXY_CHECK_RETURN(nullptr); + return displayManagerServiceProxy_->GetScreenCapture(captureOption, errorCode); +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/dm/src/oh_display_manager.cpp b/dm/src/oh_display_manager.cpp index 158dd4c39d..961a8c30e3 100644 --- a/dm/src/oh_display_manager.cpp +++ b/dm/src/oh_display_manager.cpp @@ -20,9 +20,10 @@ #include "display.h" #include "display_info.h" #include "display_manager.h" -#include "dm_common.h" -#include "oh_display_info.h" +#include "oh_display_capture.h" #include "oh_display_manager.h" +#include "oh_display_manager_inner.h" +#include "pixelmap_native_impl.h" #include "window_manager_hilog.h" using namespace OHOS; @@ -39,7 +40,7 @@ public: void OnDisplayModeChanged(FoldDisplayMode displayMode) { if (innerDisplayModeChangeFunc_ == NULL) { - TLOGI(WmsLogTag::DMS, "[DMNDK] OnDisplayModeChanged callback is null"); + TLOGI(WmsLogTag::DMS, "[DMNDK] callback is null"); return; } TLOGI(WmsLogTag::DMS, "[DMNDK] displayMode callback displayMode=%{public}d", displayMode); @@ -501,7 +502,7 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayMode std::unique_lock lock(foldChangeMutex); auto iter = g_foldDisplayModeChangeListenerMap.find(listenerIndex); if (iter == g_foldDisplayModeChangeListenerMap.end()) { - TLOGE(WmsLogTag::DMS, "[DMNDK] unregister fold change listener fail(not find register info)."); + TLOGE(WmsLogTag::DMS, "[DMNDK] unregister listener fail(not find register info)."); return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_INVALID_PARAM; } DMError ret = DMError::DM_OK; @@ -509,7 +510,7 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayMode ret = DisplayManager::GetInstance().UnregisterDisplayModeListener(iter->second); g_foldDisplayModeChangeListenerMap.erase(listenerIndex); g_foldChangeCallbackMap.erase(listenerIndex); - TLOGI(WmsLogTag::DMS, "[DMNDK] unregister fold change listener ert=%{public}d", ret); + TLOGI(WmsLogTag::DMS, "[DMNDK] unregister listener ert=%{public}d", ret); } return ret == DMError::DM_OK ? NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK : NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; @@ -537,7 +538,7 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeList { TLOGI(WmsLogTag::DMS, "[DMNDK] register display change listener."); if (displayChangeCallback == NULL || listenerIndex == NULL) { - TLOGE(WmsLogTag::DMS, "[DMNDK] register display change listener fail(input params null)."); + TLOGE(WmsLogTag::DMS, "[DMNDK] register fail(input params null)."); return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_INVALID_PARAM; } std::unique_lock lock(displayChangeMutex); @@ -554,13 +555,13 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeList static std::atomic registerCount = 1; DMError ret = DisplayManager::GetInstance().RegisterDisplayListener(displayListener); if (ret != DMError::DM_OK) { - TLOGE(WmsLogTag::DMS, "[DMNDK] display change listener register failed ret=%{public}d.", ret); + TLOGE(WmsLogTag::DMS, "[DMNDK] register failed ret=%{public}d.", ret); return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; } *listenerIndex = registerCount++; g_displayChangeCallbackMap.emplace(*listenerIndex, displayChangeCallback); g_displayChangeListenerMap.emplace(*listenerIndex, displayListener); - TLOGI(WmsLogTag::DMS, "[DMNDK] register display change success and listenerIndex= %{public}d.", *listenerIndex); + TLOGI(WmsLogTag::DMS, "[DMNDK] register listenerIndex= %{public}d.", *listenerIndex); return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK; } @@ -570,7 +571,7 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeLi std::unique_lock lock(displayChangeMutex); auto iter = g_displayChangeListenerMap.find(listenerIndex); if (iter == g_displayChangeListenerMap.end()) { - TLOGE(WmsLogTag::DMS, "[DMNDK] unregister display change listener fail(not find register info)."); + TLOGE(WmsLogTag::DMS, "[DMNDK] unregister fail(not find register info)."); return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_INVALID_PARAM; } DMError ret = DMError::DM_OK; @@ -578,8 +579,388 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeLi ret = DisplayManager::GetInstance().UnregisterDisplayListener(iter->second); g_displayChangeListenerMap.erase(listenerIndex); g_displayChangeCallbackMap.erase(listenerIndex); - TLOGI(WmsLogTag::DMS, "[DMNDK] unregister display change listener ert=%{public}d", ret); + TLOGI(WmsLogTag::DMS, "[DMNDK] unregister listener ret=%{public}d", ret); } return ret == DMError::DM_OK ? NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK : NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; } + +static void NativeDisplayManager_FreeMemory(void *memPtr) +{ + if (memPtr == nullptr) { + TLOGW(WmsLogTag::DMS, "[DMNDK] param is null. no need to free."); + return; + } + free(memPtr); + memPtr = nullptr; +} + +static void NativeDisplayManager_SetColorSpace(NativeDisplayManager_DisplayInfo *displayInfo, sptr info) +{ + std::vector colorSpaces = info->GetColorSpaces(); + if (colorSpaces.empty()) { + TLOGW(WmsLogTag::DMS, "[DMNDK] colorSpaces is empty displayId=%{public}d", displayInfo->id); + return; + } + displayInfo->colorSpace = (NativeDisplayManager_DisplayColorSpace*)malloc( + sizeof(NativeDisplayManager_DisplayColorSpace)); + if (displayInfo->colorSpace == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] malloc color space failed"); + return; + } + auto retMemset = memset_s(displayInfo->colorSpace, sizeof(NativeDisplayManager_DisplayColorSpace), 0, + sizeof(NativeDisplayManager_DisplayColorSpace)); + if (retMemset != EOK) { + TLOGE(WmsLogTag::DMS, "[DMNDK] memset color space failed"); + NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace)); + return; + } + displayInfo->colorSpace->colorSpaceLength = static_cast(colorSpaces.size()); + displayInfo->colorSpace->colorSpaces = (uint32_t*)malloc(sizeof(uint32_t) * colorSpaces.size()); + if (displayInfo->colorSpace->colorSpaces == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] malloc color spaces failed"); + NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace)); + return; + } + retMemset = memset_s(displayInfo->colorSpace->colorSpaces, sizeof(uint32_t) * colorSpaces.size(), 0, + sizeof(uint32_t) * colorSpaces.size()); + if (retMemset != EOK) { + TLOGE(WmsLogTag::DMS, "[DMNDK] memset color spaces failed"); + NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace->colorSpaces)); + NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace)); + return; + } + + uint32_t colorLoop = 0; + for (const auto colorSpace : colorSpaces) { + DM_GraphicCM_ColorSpaceType colorSpaceValue = static_cast(colorSpace); + if (DM_NATIVE_TO_NDK_COLOR_SPACE_TYPE_MAP.find(colorSpaceValue) == + DM_NATIVE_TO_NDK_COLOR_SPACE_TYPE_MAP.end()) { + TLOGW(WmsLogTag::DMS, "[DMNDK] color spaces[%{public}d] not in map.", colorSpace); + continue; + } + displayInfo->colorSpace->colorSpaces[colorLoop] = + static_cast(DM_NATIVE_TO_NDK_COLOR_SPACE_TYPE_MAP.at(colorSpaceValue)); + colorLoop++; + } + TLOGI(WmsLogTag::DMS, "[DMNDK] color spaces count:%{public}d.", colorLoop); +} + +static void NativeDisplayManager_SetHdrFormat(NativeDisplayManager_DisplayInfo *displayInfo, sptr info) +{ + std::vector hdrFormats = info->GetHdrFormats(); + if (hdrFormats.empty()) { + TLOGW(WmsLogTag::DMS, "[DMNDK] hdrFormats is empty displayId=%{public}d", displayInfo->id); + return; + } + displayInfo->hdrFormat = (NativeDisplayManager_DisplayHdrFormat*)malloc( + sizeof(NativeDisplayManager_DisplayHdrFormat)); + if (displayInfo->hdrFormat == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] malloc hdr format failed"); + return; + } + auto retMemset = memset_s(displayInfo->hdrFormat, sizeof(NativeDisplayManager_DisplayHdrFormat), 0, + sizeof(NativeDisplayManager_DisplayHdrFormat)); + if (retMemset != EOK) { + TLOGE(WmsLogTag::DMS, "[DMNDK] memset hdr format failed"); + NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat)); + return; + } + displayInfo->hdrFormat->hdrFormatLength = static_cast(hdrFormats.size()); + displayInfo->hdrFormat->hdrFormats = (uint32_t*)malloc(sizeof(uint32_t) * hdrFormats.size()); + if (displayInfo->hdrFormat->hdrFormats == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] malloc hdr format failed"); + NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat)); + return; + } + retMemset = memset_s(displayInfo->hdrFormat->hdrFormats, sizeof(uint32_t) * hdrFormats.size(), 0, + sizeof(uint32_t) * hdrFormats.size()); + if (retMemset != EOK) { + TLOGE(WmsLogTag::DMS, "[DMNDK] memset hdr format failed"); + NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat->hdrFormats)); + NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat)); + return; + } + + uint32_t hdrLoop = 0; + for (const auto hdrFormat : hdrFormats) { + DM_ScreenHDRFormat hdrFormatValue = static_cast(hdrFormat); + if (DM_NATIVE_TO_NDK_HDR_FORMAT_TYPE_MAP.find(hdrFormatValue) == DM_NATIVE_TO_NDK_HDR_FORMAT_TYPE_MAP.end()) { + TLOGW(WmsLogTag::DMS, "[DMNDK] hdr format[%{public}d] not in map.", hdrFormat); + continue; + } + displayInfo->hdrFormat->hdrFormats[hdrLoop] = + static_cast(DM_NATIVE_TO_NDK_HDR_FORMAT_TYPE_MAP.at(hdrFormatValue)); + hdrLoop++; + } + TLOGI(WmsLogTag::DMS, "[DMNDK] hdr format count:%{public}d", hdrLoop); +} + +static void NativeDisplayManager_SetDisplayInfo(NativeDisplayManager_DisplayInfo *displayInfo, + sptr info) +{ + displayInfo->id = static_cast(info->GetDisplayId()); + displayInfo->width = info->GetWidth(); + displayInfo->height = info->GetHeight(); + displayInfo->orientation = static_cast(info->GetDisplayOrientation()); + displayInfo->rotation = static_cast(info->GetRotation()); + displayInfo->refreshRate = info->GetRefreshRate(); + displayInfo->availableWidth = info->GetAvailableWidth(); + displayInfo->availableHeight = info->GetAvailableHeight(); + displayInfo->densityDPI = info->GetVirtualPixelRatio() * DOT_PER_INCH; + displayInfo->densityPixels = info->GetVirtualPixelRatio(); + displayInfo->scaledDensity = info->GetVirtualPixelRatio(); + displayInfo->xDPI = info->GetXDpi(); + displayInfo->yDPI = info->GetYDpi(); + displayInfo->isAlive = info->GetAliveStatus(); + if (DM_NATIVE_TO_NDK_DISPLAY_STATE_MAP.find(info->GetDisplayState()) != DM_NATIVE_TO_NDK_DISPLAY_STATE_MAP.end()) { + displayInfo->state = static_cast( + DM_NATIVE_TO_NDK_DISPLAY_STATE_MAP.at(info->GetDisplayState())); + } else { + displayInfo->state = static_cast(DM_DisplayStateMode::STATE_UNKNOWN); + } + /* color space */ + NativeDisplayManager_SetColorSpace(displayInfo, info); + /* hdr format */ + NativeDisplayManager_SetHdrFormat(displayInfo, info); + TLOGI(WmsLogTag::DMS, "[DMNDK] set display id[%{public}d] finish.", displayInfo->id); +} + +static NativeDisplayManager_ErrorCode NativeDisplayManager_SetDisplaysInfo(const std::vector>& displays, + NativeDisplayManager_DisplayInfo *displaysInfo) +{ + uint32_t i = 0; + for (auto& display : displays) { + if (display == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] get display null."); + continue; + } + auto info = display->GetDisplayInfo(); + if (info == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] get display id[%{public}" PRIu64"] info null.", display->GetId()); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + int ret = memcpy_s(displaysInfo[i].name, OH_DISPLAY_NAME_LENGTH, info->GetName().c_str(), + OH_DISPLAY_NAME_LENGTH); + if (ret != EOK) { + TLOGE(WmsLogTag::DMS, "[DMNDK] failed to memcpy name."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + NativeDisplayManager_SetDisplayInfo(displaysInfo + i, info); + i++; + } + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK; +} + +static void NativeDisplayManager_DestroyDisplaysInfoInner(uint32_t displaysLength, + NativeDisplayManager_DisplayInfo *displaysInfo) +{ + if (displaysLength == 0 || displaysInfo == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] param is null."); + return; + } + for (uint32_t i = 0; i < displaysLength; i++) { + NativeDisplayManager_DisplayInfo displayItem = displaysInfo[i]; + if (displayItem.colorSpace != nullptr) { + if (displayItem.colorSpace->colorSpaces != nullptr) { + NativeDisplayManager_FreeMemory(static_cast(displayItem.colorSpace->colorSpaces)); + } + NativeDisplayManager_FreeMemory(static_cast(displayItem.colorSpace)); + } + if (displayItem.hdrFormat != nullptr) { + if (displayItem.hdrFormat->hdrFormats != nullptr) { + NativeDisplayManager_FreeMemory(static_cast(displayItem.hdrFormat->hdrFormats)); + } + NativeDisplayManager_FreeMemory(static_cast(displayItem.hdrFormat)); + } + } + NativeDisplayManager_FreeMemory(static_cast(displaysInfo)); +} + +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays( + NativeDisplayManager_DisplaysInfo **allDisplays) +{ + if (allDisplays == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] param is null."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_INVALID_PARAM; + } + /* displays is not null make sure by GetAllDisplays*/ + std::vector> displays = DisplayManager::GetInstance().GetAllDisplays(); + if (displays.empty()) { + TLOGE(WmsLogTag::DMS, "[DMNDK] displays is empty."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + NativeDisplayManager_DisplaysInfo *displaysInner = + (NativeDisplayManager_DisplaysInfo*)malloc(sizeof(NativeDisplayManager_DisplaysInfo)); + if (displaysInner == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] malloc displays inner failed."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + int32_t retMemset = memset_s(displaysInner, sizeof(NativeDisplayManager_DisplaysInfo), 0, + sizeof(NativeDisplayManager_DisplaysInfo)); + if (retMemset != EOK) { + TLOGE(WmsLogTag::DMS, "[DMNDK] memset displays failed."); + NativeDisplayManager_FreeMemory(static_cast(displaysInner)); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + size_t displaySize = displays.size(); + displaysInner->displaysLength = static_cast(displaySize); + NativeDisplayManager_DisplayInfo *displaysInfo = + (NativeDisplayManager_DisplayInfo*)malloc(sizeof(NativeDisplayManager_DisplayInfo) * displaySize); + if (displaysInfo == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] malloc displaysInfo failed."); + NativeDisplayManager_FreeMemory(static_cast(displaysInner)); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + retMemset = memset_s(displaysInfo, sizeof(NativeDisplayManager_DisplayInfo) * displaySize, 0, + sizeof(NativeDisplayManager_DisplayInfo) * displaySize); + NativeDisplayManager_ErrorCode setRet = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK; + if (retMemset == EOK) { + setRet = NativeDisplayManager_SetDisplaysInfo(displays, displaysInfo); + } + if (retMemset != EOK || setRet != NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK) { + TLOGE(WmsLogTag::DMS, "[DMNDK] memset or set displaysInfo failed setRet=%{public}d.", setRet); + NativeDisplayManager_FreeMemory(static_cast(displaysInner)); + NativeDisplayManager_DestroyDisplaysInfoInner(displaysInner->displaysLength, displaysInfo); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + displaysInner->displaysInfo = displaysInfo; + *allDisplays = displaysInner; + return setRet; +} + +void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInfo *allDisplays) +{ + if (allDisplays == nullptr) { + TLOGI(WmsLogTag::DMS, "[DMNDK] param is null."); + return; + } + if (allDisplays->displaysInfo == nullptr) { + NativeDisplayManager_FreeMemory(static_cast(allDisplays)); + return; + } + NativeDisplayManager_DestroyDisplaysInfoInner(allDisplays->displaysLength, allDisplays->displaysInfo); + NativeDisplayManager_FreeMemory(static_cast(allDisplays)); +} + +static NativeDisplayManager_DisplayInfo* NativeDisplayManager_FillDisplayInfo(sptr display, + NativeDisplayManager_ErrorCode *errCode) +{ + sptr info = display->GetDisplayInfo(); + if (info == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] get display info null."); + *errCode = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + return nullptr; + } + NativeDisplayManager_DisplayInfo *displayInner = + (NativeDisplayManager_DisplayInfo*)malloc(sizeof(NativeDisplayManager_DisplayInfo)); + if (displayInner == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] malloc display info null."); + *errCode = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + return nullptr; + } + auto retMemset = memset_s(displayInner, sizeof(NativeDisplayManager_DisplayInfo), 0, + sizeof(NativeDisplayManager_DisplayInfo)); + if (retMemset != EOK) { + TLOGE(WmsLogTag::DMS, "[DMNDK] memset display info null."); + NativeDisplayManager_FreeMemory(static_cast(displayInner)); + *errCode = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + return nullptr; + } + int ret = memcpy_s(displayInner->name, OH_DISPLAY_NAME_LENGTH, info->GetName().c_str(), OH_DISPLAY_NAME_LENGTH); + if (ret != EOK) { + TLOGE(WmsLogTag::DMS, "[DMNDK] memcpy display name failed."); + NativeDisplayManager_FreeMemory(static_cast(displayInner)); + *errCode = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + return nullptr; + } + NativeDisplayManager_SetDisplayInfo(displayInner, info); + *errCode = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK; + return displayInner; +} + +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayInfoById(uint32_t id, + NativeDisplayManager_DisplayInfo **displayInfo) +{ + if (displayInfo == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] param is null."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_INVALID_PARAM; + } + sptr display = DisplayManager::GetInstance().GetDisplayById(static_cast(id)); + if (display == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] get display by id null."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + TLOGI(WmsLogTag::DMS, "[DMNDK] get display id[%{public}" PRIu64"] info", display->GetId()); + NativeDisplayManager_ErrorCode errorCode = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK; + *displayInfo = NativeDisplayManager_FillDisplayInfo(display, &errorCode); + return errorCode; +} + +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay( + NativeDisplayManager_DisplayInfo **displayInfo) +{ + if (displayInfo == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] param is null."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_INVALID_PARAM; + } + sptr display = DisplayManager::GetInstance().GetPrimaryDisplaySync(); + if (display == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] get primary display id[%{public}" PRIu64"] null.", display->GetId()); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + TLOGI(WmsLogTag::DMS, "[DMNDK] get primary display id[%{public}" PRIu64"].", display->GetId()); + NativeDisplayManager_ErrorCode errorCode = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK; + *displayInfo = NativeDisplayManager_FillDisplayInfo(display, &errorCode); + return errorCode; +} + +void OH_NativeDisplayManager_DestroyDisplayInfo(NativeDisplayManager_DisplayInfo *displayInfo) +{ + if (displayInfo == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] free display info is null."); + return; + } + if (displayInfo->colorSpace != nullptr) { + if (displayInfo->colorSpace->colorSpaces != nullptr) { + NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace->colorSpaces)); + } + NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace)); + } + if (displayInfo->hdrFormat != nullptr) { + if (displayInfo->hdrFormat->hdrFormats != nullptr) { + NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat->hdrFormats)); + } + NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat)); + } + NativeDisplayManager_FreeMemory(static_cast(displayInfo)); +} + +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateScreenCapture(uint32_t displayId, + OH_PixelmapNative **pixelMap) +{ + if (pixelMap == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] pixelMap is null."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_INVALID_PARAM; + } + CaptureOption option; + option.displayId_ = static_cast(displayId); + option.isNeedNotify_ = true; + DmErrorCode errCode = DmErrorCode::DM_OK; + std::shared_ptr captureImage = DisplayManager::GetInstance().GetScreenCapture(option, &errCode); + if (errCode == DmErrorCode::DM_ERROR_NO_PERMISSION) { + TLOGE(WmsLogTag::DMS, "[DMNDK] pixelMap no permission."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_NO_PERMISSION; + } + if (captureImage == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] pixelMap is null."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + *pixelMap = new OH_PixelmapNative(captureImage); + if (*pixelMap == nullptr) { + TLOGE(WmsLogTag::DMS, "[DMNDK] pixelMap convert pixelMapNative null."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; + } + TLOGI(WmsLogTag::DMS, "[DMNDK] get screen capture end."); + return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK; +} \ No newline at end of file diff --git a/dm/src/oh_display_manager_inner.h b/dm/src/oh_display_manager_inner.h new file mode 100644 index 0000000000..6d91790d2f --- /dev/null +++ b/dm/src/oh_display_manager_inner.h @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2024 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_OH_NATIVE_DISPLAY_MANAGER_INNER_H +#define OHOS_OH_NATIVE_DISPLAY_MANAGER_INNER_H + +#include +#include +#include + +#include "dm_common.h" + +namespace OHOS { +namespace Rosen { +enum class DM_DisplayStateMode : uint32_t { + STATE_UNKNOWN = 0, + STATE_OFF, + STATE_ON, + STATE_DOZE, + STATE_DOZE_SUSPEND, + STATE_VR, + STATE_ON_SUSPEND +}; + +enum class DM_ColorSpace : uint32_t { + UNKNOWN = 0, + ADOBE_RGB = 1, + BT2020_HLG = 2, + BT2020_PQ = 3, + BT601_EBU = 4, + BT601_SMPTE_C = 5, + BT709 = 6, + P3_HLG = 7, + P3_PQ = 8, + DISPLAY_P3 = 9, + SRGB = 10, + LINEAR_SRGB = 11, + LINEAR_P3 = 12, + LINEAR_BT2020 = 13, +}; + +enum class DM_HDRFormat : uint32_t { + NONE = 0, + VIDEO_HLG = 1, + VIDEO_HDR10 = 2, + VIDEO_HDR_VIVID = 3, + IMAGE_HDR_VIVID_DUAL = 4, + IMAGE_HDR_VIVID_SINGLE = 5, + IMAGE_HDR_ISO_DUAL = 6, + IMAGE_HDR_ISO_SINGLE = 7, +}; + +const std::map DM_NATIVE_TO_NDK_DISPLAY_STATE_MAP { + { DisplayState::UNKNOWN, DM_DisplayStateMode::STATE_UNKNOWN }, + { DisplayState::OFF, DM_DisplayStateMode::STATE_OFF }, + { DisplayState::ON, DM_DisplayStateMode::STATE_ON }, + { DisplayState::DOZE, DM_DisplayStateMode::STATE_DOZE }, + { DisplayState::DOZE_SUSPEND, DM_DisplayStateMode::STATE_DOZE_SUSPEND }, + { DisplayState::VR, DM_DisplayStateMode::STATE_VR }, + { DisplayState::ON_SUSPEND, DM_DisplayStateMode::STATE_ON_SUSPEND }, +}; + +enum class DM_GraphicCM_ColorSpaceType : uint32_t { + GRAPHIC_CM_COLORSPACE_NONE, + + // COLORPRIMARIES_BT601_P | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_P << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_BT601_EBU_FULL = 2 | (1 << 8) | (2 << 16) | (1 << 21), + + // COLORPRIMARIES_BT601_N | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_N << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_BT601_SMPTE_C_FULL = 3 | (1 << 8) | (3 << 16) | (1 << 21), + + // COLORPRIMARIES_BT709 | (TRANSFUNC_BT709 << 8) | (MATRIX_BT709 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_BT709_FULL = 1 | (1 << 8) | (1 << 16) | (1 << 21), + + // COLORPRIMARIES_BT2020 | (TRANSFUNC_HLG << 8) | (MATRIX_BT2020 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_BT2020_HLG_FULL = 4 | (5 << 8) | (4 << 16) | (1 << 21), + + // COLORPRIMARIES_BT2020 | (TRANSFUNC_PQ << 8) | (MATRIX_BT2020 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_BT2020_PQ_FULL = 4 | (4 << 8) | (4 << 16) | (1 << 21), + + // COLORPRIMARIES_BT601_P | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_P << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_BT601_EBU_LIMIT = 2 | (1 << 8) | (2 << 16) | (2 << 21), + + // COLORPRIMARIES_BT601_N | (TRANSFUNC_BT709 << 8) | (MATRIX_BT601_N << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_BT601_SMPTE_C_LIMIT = 3 | (1 << 8) | (3 << 16) | (2 << 21), + + // COLORPRIMARIES_BT709 | (TRANSFUNC_BT709 << 8) | (MATRIX_BT709 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_BT709_LIMIT = 1 | (1 << 8) | (1 << 16) | (2 << 21), + + // COLORPRIMARIES_BT2020 | (TRANSFUNC_HLG << 8) | (MATRIX_BT2020 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_BT2020_HLG_LIMIT = 4 | (5 << 8) | (4 << 16) | (2 << 21), + + // COLORPRIMARIES_BT2020 | (TRANSFUNC_PQ << 8) | (MATRIX_BT2020 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_BT2020_PQ_LIMIT = 4 | (4 << 8) | (4 << 16) | (2 << 21), + + // COLORPRIMARIES_SRGB | (TRANSFUNC_SRGB << 8) | (MATRIX_BT601_N << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_SRGB_FULL = 1 | (2 << 8) | (3 << 16) | (1 << 21), + + // COLORPRIMARIES_P3_D65 | (TRANSFUNC_SRGB << 8) | (MATRIX_P3 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_P3_FULL = 6 | (2 << 8) | (3 << 16) | (1 << 21), + + // COLORPRIMARIES_P3_D65 | (TRANSFUNC_HLG << 8) | (MATRIX_P3 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_P3_HLG_FULL = 6 | (5 << 8) | (3 << 16) | (1 << 21), + + // COLORPRIMARIES_P3_D65 | (TRANSFUNC_PQ << 8) | (MATRIX_P3 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_P3_PQ_FULL = 6 | (4 << 8) | (3 << 16) | (1 << 21), + + // COLORPRIMARIES_ADOBERGB | (TRANSFUNC_ADOBERGB << 8) | (MATRIX_ADOBERGB << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_ADOBERGB_FULL = 23 | (6 << 8) | (0 << 16) | (1 << 21), + + // COLORPRIMARIES_SRGB | (TRANSFUNC_SRGB << 8) | (MATRIX_BT601_N << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_SRGB_LIMIT = 1 | (2 << 8) | (3 << 16) | (2 << 21), + + // COLORPRIMARIES_P3_D65 | (TRANSFUNC_SRGB << 8) | (MATRIX_P3 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_P3_LIMIT = 6 | (2 << 8) | (3 << 16) | (2 << 21), + + // COLORPRIMARIES_P3_D65 | (TRANSFUNC_HLG << 8) | (MATRIX_P3 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_P3_HLG_LIMIT = 6 | (5 << 8) | (3 << 16) | (2 << 21), + + // COLORPRIMARIES_P3_D65 | (TRANSFUNC_PQ << 8) | (MATRIX_P3 << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_P3_PQ_LIMIT = 6 | (4 << 8) | (3 << 16) | (2 << 21), + + // COLORPRIMARIES_ADOBERGB | (TRANSFUNC_ADOBERGB << 8) | (MATRIX_ADOBERGB << 16) | (RANGE_LIMITED << 21) + GRAPHIC_CM_ADOBERGB_LIMIT = 23 | (6 << 8) | (0 << 16) | (2 << 21), + + // COLORPRIMARIES_SRGB | (TRANSFUNC_LINEAR << 8) + GRAPHIC_CM_LINEAR_SRGB = 1 | (3 << 8), + + // equal to GRAPHIC_CM_LINEAR_SRGB + GRAPHIC_CM_LINEAR_BT709 = 1 | (3 << 8), + + // COLORPRIMARIES_P3_D65 | (TRANSFUNC_LINEAR << 8) + GRAPHIC_CM_LINEAR_P3 = 6 | (3 << 8), + + // COLORPRIMARIES_BT2020 | (TRANSFUNC_LINEAR << 8) + GRAPHIC_CM_LINEAR_BT2020 = 4 | (3 << 8), + + // equal to GRAPHIC_CM_SRGB_FULL + GRAPHIC_CM_DISPLAY_SRGB = 1 | (2 << 8) | (3 << 16) | (1 << 21), + + // equal to GRAPHIC_CM_P3_FULL + GRAPHIC_CM_DISPLAY_P3_SRGB = 6 | (2 << 8) | (3 << 16) | (1 << 21), + + // equal to GRAPHIC_CM_P3_HLG_FULL + GRAPHIC_CM_DISPLAY_P3_HLG = 6 | (5 << 8) | (3 << 16) | (1 << 21), + + // equal to GRAPHIC_CM_P3_PQ_FULL + GRAPHIC_CM_DISPLAY_P3_PQ = 6 | (4 << 8) | (3 << 16) | (1 << 21), + + // COLORPRIMARIES_BT2020 | (TRANSFUNC_SRGB << 8) | (MATRIX_BT2020 << 16) | (RANGE_FULL << 21) + GRAPHIC_CM_DISPLAY_BT2020_SRGB = 4 | (2 << 8) | (4 << 16) | (1 << 21), + + // equal to GRAPHIC_CM_BT2020_HLG_FULL + GRAPHIC_CM_DISPLAY_BT2020_HLG = 4 | (5 << 8) | (4 << 16) | (1 << 21), + + // equal to GRAPHIC_CM_BT2020_PQ_FULL + GRAPHIC_CM_DISPLAY_BT2020_PQ = 4 | (4 << 8) | (4 << 16) | (1 << 21) +}; + +enum class DM_ScreenHDRFormat : uint32_t { + NOT_SUPPORT_HDR = 0, + VIDEO_HLG, + VIDEO_HDR10, + VIDEO_HDR_VIVID, + IMAGE_HDR_VIVID_DUAL, + IMAGE_HDR_VIVID_SINGLE, + IMAGE_HDR_ISO_DUAL, + IMAGE_HDR_ISO_SINGLE, +}; + +const std::map DM_NATIVE_TO_NDK_COLOR_SPACE_TYPE_MAP { + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_COLORSPACE_NONE, DM_ColorSpace::UNKNOWN }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_ADOBERGB_FULL, DM_ColorSpace::ADOBE_RGB }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_ADOBERGB_LIMIT, DM_ColorSpace::ADOBE_RGB }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_BT2020_HLG_FULL, DM_ColorSpace::BT2020_HLG }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_BT2020_HLG_LIMIT, DM_ColorSpace::BT2020_HLG }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_BT2020_HLG, DM_ColorSpace::BT2020_HLG }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_BT2020_PQ_FULL, DM_ColorSpace::BT2020_PQ }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_BT2020_PQ_LIMIT, DM_ColorSpace::BT2020_PQ }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_BT2020_PQ, DM_ColorSpace::BT2020_PQ }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_BT601_EBU_FULL, DM_ColorSpace::BT601_EBU }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_BT601_EBU_LIMIT, DM_ColorSpace::BT601_EBU }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_BT601_SMPTE_C_FULL, DM_ColorSpace::BT601_SMPTE_C }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_BT601_SMPTE_C_LIMIT, DM_ColorSpace::BT601_SMPTE_C }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_BT709_FULL, DM_ColorSpace::BT709 }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_BT709_LIMIT, DM_ColorSpace::BT709 }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_HLG_FULL, DM_ColorSpace::P3_HLG }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_HLG_LIMIT, DM_ColorSpace::P3_HLG }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_P3_HLG, DM_ColorSpace::P3_HLG }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_PQ_FULL, DM_ColorSpace::P3_PQ }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_PQ_LIMIT, DM_ColorSpace::P3_PQ }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_P3_PQ, DM_ColorSpace::P3_PQ }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_FULL, DM_ColorSpace::DISPLAY_P3 }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_P3_LIMIT, DM_ColorSpace::DISPLAY_P3 }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_P3_SRGB, DM_ColorSpace::DISPLAY_P3 }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_SRGB_FULL, DM_ColorSpace::SRGB }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_SRGB_LIMIT, DM_ColorSpace::SRGB }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_DISPLAY_SRGB, DM_ColorSpace::SRGB }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_LINEAR_SRGB, DM_ColorSpace::LINEAR_SRGB }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_LINEAR_BT709, DM_ColorSpace::LINEAR_SRGB }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_LINEAR_P3, DM_ColorSpace::LINEAR_P3 }, + { DM_GraphicCM_ColorSpaceType::GRAPHIC_CM_LINEAR_BT2020, DM_ColorSpace::LINEAR_BT2020 }, +}; + +const std::map DM_NATIVE_TO_NDK_HDR_FORMAT_TYPE_MAP { + { DM_ScreenHDRFormat::NOT_SUPPORT_HDR, DM_HDRFormat::NONE }, + { DM_ScreenHDRFormat::VIDEO_HLG, DM_HDRFormat::VIDEO_HLG }, + { DM_ScreenHDRFormat::VIDEO_HDR10, DM_HDRFormat::VIDEO_HDR10 }, + { DM_ScreenHDRFormat::VIDEO_HDR_VIVID, DM_HDRFormat::VIDEO_HDR_VIVID }, + { DM_ScreenHDRFormat::IMAGE_HDR_VIVID_DUAL, DM_HDRFormat::IMAGE_HDR_VIVID_DUAL }, + { DM_ScreenHDRFormat::IMAGE_HDR_VIVID_SINGLE, DM_HDRFormat::IMAGE_HDR_VIVID_SINGLE }, + { DM_ScreenHDRFormat::IMAGE_HDR_ISO_DUAL, DM_HDRFormat::IMAGE_HDR_ISO_DUAL }, + { DM_ScreenHDRFormat::IMAGE_HDR_ISO_SINGLE, DM_HDRFormat::IMAGE_HDR_ISO_SINGLE }, +}; +} // namespace Rosen +} // namespace OHOS +#endif // OHOS_OH_NATIVE_DISPLAY_MANAGER_INNER_H diff --git a/dm/src/screen_manager.cpp b/dm/src/screen_manager.cpp index 182f0428c8..6b28c599fa 100644 --- a/dm/src/screen_manager.cpp +++ b/dm/src/screen_manager.cpp @@ -29,6 +29,7 @@ namespace OHOS::Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenManager"}; const static uint32_t MAX_SCREEN_SIZE = 32; +const static uint32_t DLCLOSE_TIMEOUT = 300000; } class ScreenManager::Impl : public RefBase { public: @@ -57,6 +58,7 @@ private: void NotifyScreenChange(const std::vector>& screenInfos); bool UpdateScreenInfoLocked(sptr); std::string GetScreenInfoSrting(sptr screenInfo); + void DlcloseTimeout(); bool isAllListenersRemoved() const; @@ -202,6 +204,10 @@ private: }; WM_IMPLEMENT_SINGLE_INSTANCE(ScreenManager) +extern "C" __attribute__((destructor)) void ScreenManager::Impl::DlcloseTimeout() +{ + usleep(DLCLOSE_TIMEOUT); +} ScreenManager::ScreenManager() { @@ -438,7 +444,7 @@ DMError ScreenManager::MakeExpand(const std::vector& options, Scre return DMError::DM_ERROR_INVALID_PARAM; } if (options.size() > MAX_SCREEN_SIZE) { - WLOGFW("Make expand failed. The options size is bigger than %{public}u.", MAX_SCREEN_SIZE); + WLOGFW("Make expand failed. Options size bigger than %{public}u.", MAX_SCREEN_SIZE); return DMError::DM_ERROR_INVALID_PARAM; } std::vector screenIds; @@ -465,7 +471,7 @@ DMError ScreenManager::MakeUniqueScreen(const std::vector& screenIds) return DMError::DM_ERROR_INVALID_PARAM; } if (screenIds.size() > MAX_SCREEN_SIZE) { - WLOGFW("Make UniqueScreen failed. The screenIds size is bigger than %{public}u.", MAX_SCREEN_SIZE); + WLOGFW("Make UniqueScreen failed. ScreenIds size bigger than %{public}u.", MAX_SCREEN_SIZE); return DMError::DM_ERROR_INVALID_PARAM; } DMError ret = SingletonContainer::Get().MakeUniqueScreen(screenIds); @@ -476,7 +482,7 @@ DMError ScreenManager::MakeMirror(ScreenId mainScreenId, std::vector m { WLOGFI("Make mirror for screen: %{public}" PRIu64"", mainScreenId); if (mirrorScreenId.size() > MAX_SCREEN_SIZE) { - WLOGFW("Make Mirror failed. The mirrorScreenId size is bigger than %{public}u.", MAX_SCREEN_SIZE); + WLOGFW("Make Mirror failed. MirrorScreenId size bigger than %{public}u.", MAX_SCREEN_SIZE); return DMError::DM_ERROR_INVALID_PARAM; } DMError ret = SingletonContainer::Get().MakeMirror(mainScreenId, mirrorScreenId, @@ -540,7 +546,7 @@ DMError ScreenManager::RemoveVirtualScreenFromGroup(std::vector screen return DMError::DM_ERROR_INVALID_PARAM; } if (screens.size() > MAX_SCREEN_SIZE) { - WLOGFW("RemoveVirtualScreenFromGroup failed. The screens size is bigger than %{public}u.", MAX_SCREEN_SIZE); + WLOGFW("RemoveVirtualScreenFromGroup failed. Screens size bigger than %{public}u.", MAX_SCREEN_SIZE); return DMError::DM_ERROR_INVALID_PARAM; } SingletonContainer::Get().RemoveVirtualScreenFromGroup(screens); diff --git a/dm/test/unittest/display_manager_test.cpp b/dm/test/unittest/display_manager_test.cpp index 88b0280826..36281924f8 100644 --- a/dm/test/unittest/display_manager_test.cpp +++ b/dm/test/unittest/display_manager_test.cpp @@ -1657,6 +1657,34 @@ HWTEST_F(DisplayManagerTest, Clear04, Function | SmallTest | Level1) DisplayManager::GetInstance().pImpl_->Clear(); ASSERT_EQ(DisplayManager::GetInstance().pImpl_->powerEventListenerAgent_, nullptr); } + +/** + * @tc.name: GetScreenCapture + * @tc.desc: GetScreenCapture test + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerTest, GetScreenCapture, Function | SmallTest | Level1) +{ + CaptureOption captureOption; + sptr display = DisplayManager::GetInstance().GetDefaultDisplay(); + ASSERT_NE(display, nullptr); + captureOption.displayId_ = display->GetId(); + DmErrorCode errCode; + std::shared_ptr pixelMap = DisplayManager::GetInstance().GetScreenCapture(captureOption, + &errCode); + ASSERT_NE(pixelMap, nullptr); +} + +/** + * @tc.name: GetPrimaryDisplaySync + * @tc.desc: GetPrimaryDisplaySync test + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerTest, GetPrimaryDisplaySync, Function | SmallTest | Level1) +{ + sptr display = DisplayManager::GetInstance().GetPrimaryDisplaySync(); + ASSERT_NE(display, nullptr); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/dm_lite/src/display_manager_lite.cpp b/dm_lite/src/display_manager_lite.cpp index 2646fa7a1a..ef36b13868 100644 --- a/dm_lite/src/display_manager_lite.cpp +++ b/dm_lite/src/display_manager_lite.cpp @@ -619,7 +619,6 @@ bool DisplayManagerLite::Impl::SetDisplayState(DisplayState state, DisplayStateC { std::lock_guard lock(mutex_); if (displayStateCallback_ != nullptr || callback == nullptr) { - WLOGFI("[UL_POWER]previous callback not called or callback invalid"); if (displayStateCallback_ != nullptr) { WLOGFI("[UL_POWER]previous callback not called, the displayStateCallback_ is not null"); } diff --git a/dmserver/include/display_manager_interface.h b/dmserver/include/display_manager_interface.h index 8dadfd35ea..4257ca40a7 100644 --- a/dmserver/include/display_manager_interface.h +++ b/dmserver/include/display_manager_interface.h @@ -232,6 +232,13 @@ public: { return DMError::DM_OK; } + + virtual std::shared_ptr GetScreenCapture(const CaptureOption& captureOption, + DmErrorCode* errorCode = nullptr) + { + *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; + return nullptr; + } }; } // namespace OHOS::Rosen diff --git a/dmserver/include/display_manager_interface_code.h b/dmserver/include/display_manager_interface_code.h index 8e387c9f10..72d4b67951 100644 --- a/dmserver/include/display_manager_interface_code.h +++ b/dmserver/include/display_manager_interface_code.h @@ -133,6 +133,7 @@ enum class DisplayManagerMessage : unsigned int { TRANS_ID_SET_VIRTUAL_SCREEN_STATUS, TRANS_ID_SET_VIRTUAL_SCREEN_SECURITY_EXEMPTION, TRANS_ID_SET_VIRTUAL_SCREEN_MAX_REFRESHRATE, + TRANS_ID_GET_DISPLAY_CAPTURE, }; } #endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_CODE_H \ No newline at end of file diff --git a/interfaces/innerkits/dm/display_manager.h b/interfaces/innerkits/dm/display_manager.h index 5d2031adb6..bc32a0cf01 100644 --- a/interfaces/innerkits/dm/display_manager.h +++ b/interfaces/innerkits/dm/display_manager.h @@ -699,6 +699,23 @@ public: */ void RemoveDisplayIdFromAms(const wptr& abilityToken); + /** + * @brief Get primary display object by means of sync. + * + * @return primary display. + */ + sptr GetPrimaryDisplaySync(); + + /** + * @brief Get screen capture of the target display. + * + * @param captureOption screen capture option. + * @param errorCode error code. + * @return PixelMap object of screen capture. + */ + std::shared_ptr GetScreenCapture(const CaptureOption& captureOption, + DmErrorCode* errorCode = nullptr); + private: DisplayManager(); ~DisplayManager(); diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index 0bd2f1f779..ff4a37d91e 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -397,6 +397,12 @@ struct SupportedScreenModes : public RefBase { uint32_t refreshRate_; }; +struct CaptureOption { + DisplayId displayId_ = DISPLAY_ID_INVALID; + bool isNeedNotify_ = true; + bool isNeedPointer_ = true; +}; + struct ExpandOption { ScreenId screenId_; uint32_t startX_; diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index e0d56e5006..418daf23db 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -2402,11 +2402,11 @@ public: virtual WMError SetGestureBackEnabled(bool enable) { return WMError::WM_OK; } /** - * @brief Get whether the gesture back is enabled or not. - * - * @return the value true means to enable gesture back, and false means the opposite. + * @brief Get whether to enable gesture back. + * @param enable the value true means to enable gesture back, and false means the opposite. + * @return WM_OK means get success, others means get failed. */ - virtual bool GetGestureBackEnabled() const { return true; } + virtual WMError GetGestureBackEnabled(bool& enable) { return WMError::WM_OK; } }; } } diff --git a/interfaces/kits/dmndk/BUILD.gn b/interfaces/kits/dmndk/BUILD.gn index c4f040ce19..8ed71e7ad0 100644 --- a/interfaces/kits/dmndk/BUILD.gn +++ b/interfaces/kits/dmndk/BUILD.gn @@ -18,6 +18,7 @@ import("../../../windowmanager_aafwk.gni") ohos_ndk_headers("display_manager_header") { dest_dir = "$ndk_headers_out_dir/window_manager" sources = [ + "oh_display_capture.h", "oh_display_info.h", "oh_display_manager.h", ] @@ -29,6 +30,7 @@ ohos_ndk_library("native_display_manager") { ndk_description_file = "./libdm.ndk.json" system_capability = "SystemCapability.Window.SessionManager" system_capability_headers = [ + "oh_display_capture.h", "oh_display_info.h", "oh_display_manager.h", ] diff --git a/interfaces/kits/dmndk/dm/oh_display_capture.h b/interfaces/kits/dmndk/dm/oh_display_capture.h new file mode 100644 index 0000000000..5ff2edfbbe --- /dev/null +++ b/interfaces/kits/dmndk/dm/oh_display_capture.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 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 OH_NATIVE_DISPLAY_CAPTURE_H +#define OH_NATIVE_DISPLAY_CAPTURE_H + +/** + * @addtogroup OH_DisplayManager + * @{ + * + * @brief Defines the data structures for the C APIs of the display capture. + * + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 14 + * @version 1.0 + */ + +/** + * @file oh_display_capture.h + * + * @brief Defines the data structures for the C APIs of the display capture. + * + * @kit ArkUI + * @library libnative_display_manager.so. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 14 + * @version 1.0 + */ + +#include "image/pixelmap_native.h" +#include "oh_display_info.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Obtain screen capture. + * + * @param { displayId } this display to be captured. + * @param { pixelMap } the pixelMap of the display by id. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_NO_PERMISSION } If no permission. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateScreenCapture(uint32_t displayId, + OH_PixelmapNative **pixelMap); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_NATIVE_DISPLAY_CAPTURE_H diff --git a/interfaces/kits/dmndk/dm/oh_display_info.h b/interfaces/kits/dmndk/dm/oh_display_info.h index 3b61758845..15fcfe51fd 100644 --- a/interfaces/kits/dmndk/dm/oh_display_info.h +++ b/interfaces/kits/dmndk/dm/oh_display_info.h @@ -45,6 +45,9 @@ extern "C" { #endif +/* display name length */ +#define OH_DISPLAY_NAME_LENGTH 32 + /** * @brief Enumerates rotations. * @@ -197,6 +200,145 @@ typedef struct { NativeDisplayManager_WaterfallDisplayAreaRects waterfallDisplayAreaRects; } NativeDisplayManager_CutoutInfo; +/** + * @brief Enumerates of the display state. + * + * @since 14 + * @version 1.0 + */ +typedef enum { + /** display state unknown */ + DISPLAY_MANAGER_DISPLAY_STATE_UNKNOWN = 0, + + /** display state off */ + DISPLAY_MANAGER_DISPLAY_STATE_OFF = 1, + + /** display state on */ + DISPLAY_MANAGER_DISPLAY_STATE_ON = 2, + + /** display state doze */ + DISPLAY_MANAGER_DISPLAY_STATE_DOZE = 3, + + /** display state doze suspend */ + DISPLAY_MANAGER_DISPLAY_STATE_DOZE_SUSPEND = 4, + + /** display state vr */ + DISPLAY_MANAGER_DISPLAY_STATE_VR = 5, + + /** display state on suspend */ + DISPLAY_MANAGER_DISPLAY_STATE_ON_SUSPEND = 6, +} NativeDisplayManager_DisplayState; + +/** + * @brief Defines the display hdr structure. + * + * @since 14 + * @version 1.0 + */ +typedef struct { + /* hdrFormat length */ + uint32_t hdrFormatLength; + + /* hdrFormat pointer */ + uint32_t *hdrFormats; +} NativeDisplayManager_DisplayHdrFormat; + +/** + * @brief Defines the display color space structure. + * + * @since 14 + * @version 1.0 + */ +typedef struct { + /* color space length */ + uint32_t colorSpaceLength; + + /* color space pointer */ + uint32_t *colorSpaces; +} NativeDisplayManager_DisplayColorSpace; + +/** + * @brief Defines the display structure. + * + * @since 14 + * @version 1.0 + */ +typedef struct { + /* display id */ + uint32_t id; + + /* display name */ + char name[OH_DISPLAY_NAME_LENGTH + 1]; + + /* display is alive */ + bool isAlive; + + /* display width */ + int32_t width; + + /* display height */ + int32_t height; + + /* display physical width */ + int32_t physicalWidth; + + /* display physical height */ + int32_t physicalHeight; + + /* display refresh rate */ + uint32_t refreshRate; + + /* display available width */ + uint32_t availableWidth; + + /* display available height */ + uint32_t availableHeight; + + /* display density dpi */ + float densityDPI; + + /* display density pixels */ + float densityPixels; + + /* display scale density */ + float scaledDensity; + + /* display xdpi*/ + float xDPI; + + /* display ydpi */ + float yDPI; + + /* display rotation */ + NativeDisplayManager_Rotation rotation; + + /* display state */ + NativeDisplayManager_DisplayState state; + + /* display orientation */ + NativeDisplayManager_Orientation orientation; + + /* display hdr format */ + NativeDisplayManager_DisplayHdrFormat *hdrFormat; + + /* display color space */ + NativeDisplayManager_DisplayColorSpace *colorSpace; +} NativeDisplayManager_DisplayInfo; + +/** + * @brief Defines the display structure. + * + * @since 14 + * @version 1.0 + */ +typedef struct { + /* displays length */ + uint32_t displaysLength; + + /* displays pointer */ + NativeDisplayManager_DisplayInfo *displaysInfo; +} NativeDisplayManager_DisplaysInfo; + #ifdef __cplusplus } #endif diff --git a/interfaces/kits/dmndk/dm/oh_display_manager.h b/interfaces/kits/dmndk/dm/oh_display_manager.h index a3b9f3444d..4e661fbff1 100644 --- a/interfaces/kits/dmndk/dm/oh_display_manager.h +++ b/interfaces/kits/dmndk/dm/oh_display_manager.h @@ -311,6 +311,64 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeCh */ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener(uint32_t listenerIndex); +/** + * @brief Obtain all displays. + * + * @param { allDisplays } the result of all displays. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful. + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays( + NativeDisplayManager_DisplaysInfo **allDisplays); + +/** + * @brief Destroy all displays. + * + * @param { allDisplays } all displays to be free. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInfo *allDisplays); + +/** + * @brief Obtain the target display by display id. + * + * @param { displayId } the display id. + * @param { displayInfo } the result of all displays. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful. + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayInfoById(uint32_t displayId, + NativeDisplayManager_DisplayInfo **displayInfo); + +/** + * @brief Destroy the target display. + * + * @param { displayInfo } the target display to be free. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +void OH_NativeDisplayManager_DestroyDisplayInfo(NativeDisplayManager_DisplayInfo *displayInfo); + +/** + * @brief Obtain the primary display. + * + * @param { displayInfo } the result of primary display. + * @return { @link DISPLAY_MANAGER_OK } If the operation is successful. + * { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error. + * { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager.Core + * @since 14 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay( + NativeDisplayManager_DisplayInfo **displayInfo); + #ifdef __cplusplus } #endif diff --git a/interfaces/kits/dmndk/libdm.ndk.json b/interfaces/kits/dmndk/libdm.ndk.json index 5efd535618..4683811e51 100644 --- a/interfaces/kits/dmndk/libdm.ndk.json +++ b/interfaces/kits/dmndk/libdm.ndk.json @@ -78,5 +78,29 @@ { "first_instroduced":"12", "name":"OH_NativeDisplayManager_UnregisterDisplayChangeListener" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreatePrimaryDisplay" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreateDisplayInfoById" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_DestroyDisplayInfo" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreateAllDisplays" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_DestroyAllDisplays" + }, + { + "first_instroduced":"14", + "name":"OH_NativeDisplayManager_CreateScreenCapture" } ] \ No newline at end of file diff --git a/interfaces/kits/napi/common/dm_napi_common.h b/interfaces/kits/napi/common/dm_napi_common.h index d5ff4d5d2f..3bee247b3c 100644 --- a/interfaces/kits/napi/common/dm_napi_common.h +++ b/interfaces/kits/napi/common/dm_napi_common.h @@ -26,6 +26,7 @@ #include "js_native_api_types.h" #include "window_manager_hilog.h" #include "dm_common.h" +#include "napi/native_api.h" constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, OHOS::Rosen::HILOG_DOMAIN_WINDOW, "NapiWindowManagerCommonLayer" }; @@ -164,7 +165,7 @@ napi_value AsyncProcess(napi_env env, } return nullptr; } - if (!NAPICall(env, napi_queue_async_work(env, info->asyncWork))) { + if (!NAPICall(env, napi_queue_async_work_with_qos(env, info->asyncWork, napi_qos_user_initiated))) { delete info; if (callbackRef != nullptr) { static_cast(napi_delete_reference(env, callbackRef)); diff --git a/interfaces/kits/napi/display_runtime/js_display_manager.cpp b/interfaces/kits/napi/display_runtime/js_display_manager.cpp index 16634e08b1..7d46a1bca2 100644 --- a/interfaces/kits/napi/display_runtime/js_display_manager.cpp +++ b/interfaces/kits/napi/display_runtime/js_display_manager.cpp @@ -61,6 +61,12 @@ static napi_value GetDefaultDisplaySync(napi_env env, napi_callback_info info) return (me != nullptr) ? me->OnGetDefaultDisplaySync(env, info) : nullptr; } +static napi_value GetPrimaryDisplaySync(napi_env env, napi_callback_info info) +{ + JsDisplayManager* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetPrimaryDisplaySync(env, info) : nullptr; +} + static napi_value GetDisplayByIdSync(napi_env env, napi_callback_info info) { JsDisplayManager* me = CheckParamsAndGetThis(env, info); @@ -187,6 +193,20 @@ napi_value OnGetDefaultDisplay(napi_env env, napi_callback_info info) return result; } +napi_value OnGetPrimaryDisplaySync(napi_env env, napi_callback_info info) +{ + WLOGD("OnGetPrimaryDisplaySync called"); + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "Sync:OnGetPrimaryDisplaySync"); + sptr display = SingletonContainer::Get().GetPrimaryDisplaySync(); + if (display == nullptr) { + WLOGFE("[NAPI]Display info is nullptr, js error will be happen"); + napi_throw(env, CreateJsError(env, static_cast(DmErrorCode::DM_ERROR_INVALID_SCREEN), + "invalid screen id")); + return NapiGetUndefined(env); + } + return CreateJsDisplayObject(env, display); +} + napi_value OnGetDefaultDisplaySync(napi_env env, napi_callback_info info) { WLOGD("GetDefaultDisplaySync called"); @@ -1167,6 +1187,7 @@ napi_value JsDisplayManagerInit(napi_env env, napi_value exportObj) const char *moduleName = "JsDisplayManager"; BindNativeFunction(env, exportObj, "getDefaultDisplay", moduleName, JsDisplayManager::GetDefaultDisplay); BindNativeFunction(env, exportObj, "getDefaultDisplaySync", moduleName, JsDisplayManager::GetDefaultDisplaySync); + BindNativeFunction(env, exportObj, "getPrimaryDisplaySync", moduleName, JsDisplayManager::GetPrimaryDisplaySync); BindNativeFunction(env, exportObj, "getDisplayByIdSync", moduleName, JsDisplayManager::GetDisplayByIdSync); BindNativeFunction(env, exportObj, "getAllDisplay", moduleName, JsDisplayManager::GetAllDisplay); BindNativeFunction(env, exportObj, "getAllDisplays", moduleName, JsDisplayManager::GetAllDisplays); diff --git a/interfaces/kits/napi/screenshot/native_screenshot_module.cpp b/interfaces/kits/napi/screenshot/native_screenshot_module.cpp index 88717ad133..b1cae14448 100644 --- a/interfaces/kits/napi/screenshot/native_screenshot_module.cpp +++ b/interfaces/kits/napi/screenshot/native_screenshot_module.cpp @@ -41,6 +41,8 @@ struct Option { Media::Size size; int rotation = 0; DisplayId displayId = 0; + bool isNeedNotify = true; + bool isNeedPointer = true; }; struct Param { @@ -163,6 +165,32 @@ static void GetImageSize(napi_env env, std::unique_ptr ¶m, napi_value } } +static void IsNeedNotify(napi_env env, std::unique_ptr ¶m, napi_value &argv) +{ + GNAPI_LOG("Get Screenshot Option: IsNeedNotify"); + napi_value isNeedNotify; + NAPI_CALL_RETURN_VOID(env, napi_get_named_property(env, argv, "isNeedNotify", &isNeedNotify)); + if (isNeedNotify != nullptr && GetType(env, isNeedNotify) == napi_boolean) { + NAPI_CALL_RETURN_VOID(env, napi_get_value_bool(env, isNeedNotify, ¶m->option.isNeedNotify)); + GNAPI_LOG("IsNeedNotify: %{public}d", param->option.isNeedNotify); + } else { + GNAPI_LOG("IsNeedNotify failed, invalid param, use default true."); + } +} + +static void IsNeedPointer(napi_env env, std::unique_ptr ¶m, napi_value &argv) +{ + GNAPI_LOG("Get Screenshot Option: IsNeedPointer"); + napi_value isNeedPointer; + NAPI_CALL_RETURN_VOID(env, napi_get_named_property(env, argv, "isNeedPointer", &isNeedPointer)); + if (isNeedPointer != nullptr && GetType(env, isNeedPointer) == napi_boolean) { + NAPI_CALL_RETURN_VOID(env, napi_get_value_bool(env, isNeedPointer, ¶m->option.isNeedPointer)); + GNAPI_LOG("IsNeedPointer: %{public}d", param->option.isNeedPointer); + } else { + GNAPI_LOG("IsNeedPointer failed, invalid param, use default true."); + } +} + static void GetScreenshotParam(napi_env env, std::unique_ptr ¶m, napi_value &argv) { if (param == nullptr) { @@ -173,6 +201,8 @@ static void GetScreenshotParam(napi_env env, std::unique_ptr ¶m, napi GetRotation(env, param, argv); GetScreenRect(env, param, argv); GetImageSize(env, param, argv); + IsNeedNotify(env, param, argv); + IsNeedPointer(env, param, argv); } static void AsyncGetScreenshot(napi_env env, std::unique_ptr ¶m) @@ -290,6 +320,46 @@ napi_value PickFunc(napi_env env, napi_callback_info info) return AsyncProcess(env, __PRETTY_FUNCTION__, AsyncGetScreenshot, Resolve, ref, param); } +static void AsyncGetScreenCapture(napi_env env, std::unique_ptr ¶m) +{ + CaptureOption captureOption; + captureOption.displayId_ = param->option.displayId; + captureOption.isNeedNotify_ = param->option.isNeedNotify; + captureOption.isNeedPointer_ = param->option.isNeedPointer; + GNAPI_LOG("capture option isNeedNotify=%{public}d isNeedPointer=%{public}d", captureOption.isNeedNotify_, + captureOption.isNeedPointer_); + param->image = DisplayManager::GetInstance().GetScreenCapture(captureOption, ¶m->wret); + if (param->image == nullptr && param->wret == DmErrorCode::DM_OK) { + GNAPI_LOG("screen capture failed!"); + param->wret = DmErrorCode::DM_ERROR_SYSTEM_INNORMAL; + param->errMessage = "ScreenCapture failed: image is null."; + return; + } +} + +napi_value CaptureFunc(napi_env env, napi_callback_info info) +{ + GNAPI_LOG("%{public}s called", __PRETTY_FUNCTION__); + napi_value argv[1] = { nullptr }; + size_t argc = 1; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr)); + + auto param = std::make_unique(); + if (param == nullptr) { + WLOGFE("Create param failed."); + return nullptr; + } + param->option.displayId = DisplayManager::GetInstance().GetDefaultDisplayId(); + napi_ref ref = nullptr; + if (argc > 0 && GetType(env, argv[0]) == napi_object) { + GNAPI_LOG("argv[0]'s type is napi_object"); + GetScreenshotParam(env, param, argv[0]); + } else { + GNAPI_LOG("use default."); + } + return AsyncProcess(env, __PRETTY_FUNCTION__, AsyncGetScreenCapture, Resolve, ref, param); +} + napi_value MainFunc(napi_env env, napi_callback_info info) { GNAPI_LOG("%{public}s called", __PRETTY_FUNCTION__); @@ -392,6 +462,7 @@ napi_value ScreenshotModuleInit(napi_env env, napi_value exports) napi_property_descriptor properties[] = { DECLARE_NAPI_FUNCTION("save", save::MainFunc), DECLARE_NAPI_FUNCTION("pick", save::PickFunc), + DECLARE_NAPI_FUNCTION("capture", save::CaptureFunc), DECLARE_NAPI_PROPERTY("DMError", errorCode), DECLARE_NAPI_PROPERTY("DmErrorCode", dmErrorCode), }; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index b0c1221ea1..701f74b3ac 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -6779,45 +6779,66 @@ napi_value JsWindow::OnSetGestureBackEnabled(napi_env env, napi_callback_info in size_t argc = FOUR_PARAMS_SIZE; napi_value argv[FOUR_PARAMS_SIZE] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc != INDEX_ONE) { - TLOGE(WmsLogTag::WMS_IMMS, "Argc is invalid: %{public}zu", argc); + if (argc < INDEX_ONE) { + TLOGE(WmsLogTag::WMS_IMMS, "argc is invalid: %{public}zu.", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - if (windowToken_ == nullptr) { - TLOGE(WmsLogTag::WMS_IMMS, "windowToken is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + bool enabled = true; + if (argv[INDEX_ZERO] == nullptr || napi_get_value_bool(env, argv[INDEX_ZERO], &enabled) != napi_ok) { + TLOGE(WmsLogTag::WMS_IMMS, "failed to convert parameter to enabled."); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - if (!WindowHelper::IsMainWindow(windowToken_->GetType()) && - !WindowHelper::IsSubWindow(windowToken_->GetType())) { - TLOGE(WmsLogTag::WMS_IMMS, "[NAPI]set failed since invalid window type"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); - } - bool enable = true; - napi_get_value_bool(env, argv[INDEX_ZERO], &enable); - TLOGI(WmsLogTag::WMS_IMMS, "[NAPI]enable: %{public}d", enable); - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetGestureBackEnabled(enable)); - if (ret != WmErrorCode::WM_OK) { - TLOGE(WmsLogTag::WMS_IMMS, "set failed, ret = %{public}d", ret); - return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY); - } - return NapiGetUndefined(env); + std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); + auto execute = [weakToken = wptr(windowToken_), errCodePtr, enabled] { + auto window = weakToken.promote(); + if (window == nullptr) { + TLOGNE(WmsLogTag::WMS_IMMS, "window is nullptr."); + *errCodePtr = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + return; + } + if (!WindowHelper::IsMainWindow(window->GetType())) { + TLOGNE(WmsLogTag::WMS_IMMS, "invalid window type."); + *errCodePtr = WmErrorCode::WM_ERROR_INVALID_CALLING; + return; + } + *errCodePtr = WM_JS_TO_ERROR_CODE_MAP.at(window->SetGestureBackEnabled(enabled)); + }; + auto complete = [errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { + if (*errCodePtr == WmErrorCode::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + TLOGNE(WmsLogTag::WMS_IMMS, "set failed, ret = %{public}d.", *errCodePtr); + task.Reject(env, JsErrUtils::CreateJsError(env, *errCodePtr, "set failed.")); + } + }; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnSetGestureBackEnabled", + env, CreateAsyncTaskWithLastParam(env, nullptr, std::move(execute), std::move(complete), &result)); + return result; } - + napi_value JsWindow::OnGetGestureBackEnabled(napi_env env, napi_callback_info info) { if (windowToken_ == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "windowToken is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } - if (!WindowHelper::IsMainWindow(windowToken_->GetType()) && - !WindowHelper::IsSubWindow(windowToken_->GetType())) { + if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { TLOGE(WmsLogTag::WMS_IMMS, "[NAPI] get failed since invalid window type"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); } - bool isEnabled = windowToken_->GetGestureBackEnabled(); + bool enable = true; + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->GetGestureBackEnabled(enable)); + if (ret == WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT) { + TLOGE(WmsLogTag::WMS_IMMS, "device is not support."); + return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); + } else if (ret != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "get failed, ret = %{public}d", ret); + return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY); + } TLOGI(WmsLogTag::WMS_IMMS, "window [%{public}u, %{public}s], enable = %{public}u", - windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), isEnabled); - return CreateJsValue(env, isEnabled); + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), enable); + return CreateJsValue(env, enable); } static void CreateNewSubWindowTask(const sptr& windowToken, const std::string& windowName, @@ -7039,7 +7060,7 @@ void BindFunctions(napi_env env, napi_value object, const char* moduleName) BindNativeFunction(env, object, "requestFocus", moduleName, JsWindow::RequestFocus); BindNativeFunction(env, object, "createSubWindowWithOptions", moduleName, JsWindow::CreateSubWindowWithOptions); BindNativeFunction(env, object, "setGestureBackEnabled", moduleName, JsWindow::SetGestureBackEnabled); - BindNativeFunction(env, object, "getGestureBackEnabled", moduleName, JsWindow::GetGestureBackEnabled); + BindNativeFunction(env, object, "isGestureBackEnabled", moduleName, JsWindow::GetGestureBackEnabled); } } // namespace Rosen } // namespace OHOS diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 80bc91c215..7d27c43d61 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -445,7 +445,7 @@ napi_value CreateJsWindowPropertiesObject(napi_env env, sptr& window, co WLOGFE("GetDrawableRect failed!"); } napi_set_named_property(env, objValue, "drawableRect", drawableRectObj); - + WindowType type = window->GetType(); if (NATIVE_JS_TO_WINDOW_TYPE_MAP.count(type) != 0) { napi_set_named_property(env, objValue, "type", CreateJsValue(env, NATIVE_JS_TO_WINDOW_TYPE_MAP.at(type))); @@ -546,9 +546,7 @@ napi_value CreateJsWindowInfoArrayObject(napi_env env, const std::vectorGetWindowType(); - auto windowVisibilityState = info->GetWindowVisibilityState(); - if (windowType >= WindowType::APP_MAIN_WINDOW_BASE && windowType < WindowType::APP_MAIN_WINDOW_END && - windowVisibilityState != WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { + if (windowType >= WindowType::APP_MAIN_WINDOW_BASE && windowType < WindowType::APP_MAIN_WINDOW_END) { napi_set_element(env, arrayValue, index++, CreateJsWindowInfoObject(env, info)); } } diff --git a/previewer/include/window.h b/previewer/include/window.h index 42d8bca27a..c0e3fd5aa0 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -397,11 +397,11 @@ public: virtual WMError SetGestureBackEnabled(bool enable) { return WMError::WM_OK; } /** - * @brief Get whether the gesture back is enabled or not. - * - * @return the value true means to enable gesture back, and false means the opposite. + * @brief Get whether to enable gesture back. + * @param enable the value true means to enable gesture back, and false means the opposite. + * @return WM_OK means get success, others means get failed. */ - virtual bool GetGestureBackEnabled() const { return true; } + virtual WMError GetGestureBackEnabled(bool& enable) { return WMError::WM_OK; } }; } } diff --git a/test/systemtest/wms/BUILD.gn b/test/systemtest/wms/BUILD.gn index b600bee826..b83a06c86d 100644 --- a/test/systemtest/wms/BUILD.gn +++ b/test/systemtest/wms/BUILD.gn @@ -484,7 +484,12 @@ ohos_systemtest("wms_window_system_toast_window_test") { ohos_systemtest("wms_window_animation_transition_test") { module_out_path = module_out_path - + sanitize = { + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } sources = [ "window_animation_transition_test.cpp" ] deps = [ diff --git a/test/systemtest/wms/window_input_method_test.cpp b/test/systemtest/wms/window_input_method_test.cpp index 30294cbd5d..7273f979c9 100644 --- a/test/systemtest/wms/window_input_method_test.cpp +++ b/test/systemtest/wms/window_input_method_test.cpp @@ -80,7 +80,6 @@ HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Lev window->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_FLOAT, 0); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WMError::WM_OK, window->Hide()); - window->Destroy(); } /** @@ -112,7 +111,6 @@ HWTEST_F(WindowInputMethodTest, InputMethodWindow02, Function | MediumTest | Lev ASSERT_EQ(inputMethodWindow->GetRect().height_, Utils::customAppRect_.height_); } inputMethodWindow->Hide(); - inputMethodWindow->Destroy(); } } // namespace } // namespace Rosen diff --git a/window_scene/intention_event/src/intention_event_manager.cpp b/window_scene/intention_event/src/intention_event_manager.cpp index 79cd00d99d..cd4006fbba 100644 --- a/window_scene/intention_event/src/intention_event_manager.cpp +++ b/window_scene/intention_event/src/intention_event_manager.cpp @@ -86,11 +86,11 @@ bool IntentionEventManager::EnableInputEventListener(Ace::UIContent* uiContent, std::shared_ptr eventHandler) { if (uiContent == nullptr) { - TLOGE(WmsLogTag::WMS_EVENT, "EnableInputEventListener uiContent is null"); + TLOGE(WmsLogTag::WMS_EVENT, "uiContent is null"); return false; } if (eventHandler == nullptr) { - TLOGE(WmsLogTag::WMS_EVENT, "EnableInputEventListener eventHandler is null"); + TLOGE(WmsLogTag::WMS_EVENT, "eventHandler is null"); return false; } auto listener = @@ -109,7 +109,7 @@ void IntentionEventManager::InputEventListener::UpdateLastMouseEvent( std::shared_ptr pointerEvent) const { if (pointerEvent == nullptr) { - TLOGE(WmsLogTag::WMS_EVENT, "UpdateLastMouseEvent pointerEvent is null"); + TLOGE(WmsLogTag::WMS_EVENT, "pointerEvent is null"); return; } g_lastLeaveWindowId = -1; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 4baab548ad..b1b2014afb 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -352,6 +352,8 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c JsSceneSession::SetCompatibleModeEnableInPad); BindNativeFunction(env, objValue, "setStartingWindowExitAnimationFlag", moduleName, JsSceneSession::SetStartingWindowExitAnimationFlag); + BindNativeFunction(env, objValue, "setWindowEnableDragBySystem", moduleName, + JsSceneSession::SetWindowEnableDragBySystem); } void JsSceneSession::BindNativeMethodForKeyboard(napi_env env, napi_value objValue, const char* moduleName) @@ -2021,6 +2023,13 @@ napi_value JsSceneSession::UnSyncScenePanelGlobalPosition(napi_env env, napi_cal return (me != nullptr) ? me->OnUnSyncScenePanelGlobalPosition(env, info) : nullptr; } +napi_value JsSceneSession::SetWindowEnableDragBySystem(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::WMS_SCB, "[NAPI]"); + JsSceneSession* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetWindowEnableDragBySystem(env, info) : nullptr; +} + bool JsSceneSession::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsSceneSession::IsCallbackRegistered[%s]", type.c_str()); @@ -4792,6 +4801,34 @@ napi_value JsSceneSession::OnCompatibleFullScreenClose(napi_env env, napi_callba return NapiGetUndefined(env); } +napi_value JsSceneSession::OnSetWindowEnableDragBySystem(napi_env env, napi_callback_info info) +{ + size_t argc = ARGC_FOUR; + napi_value argv[ARGC_FOUR] = { nullptr }; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + if (argc != ARGC_ONE) { + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + + bool enableDrag = true; + if (!ConvertFromJsValue(env, argv[0], enableDrag)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Failed to convert parameter to bool"); + return NapiGetUndefined(env); + } + + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]session is nullptr, id:%{public}d", persistentId_); + return NapiGetUndefined(env); + } + session->SetWindowEnableDragBySystem(enableDrag); + return NapiGetUndefined(env); +} + napi_value JsSceneSession::OnSyncScenePanelGlobalPosition(napi_env env, napi_callback_info info) { size_t argc = ARGC_FOUR; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h index 774c25615b..51a549099f 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h @@ -148,6 +148,7 @@ private: static napi_value CompatibleFullScreenRecover(napi_env env, napi_callback_info info); static napi_value CompatibleFullScreenMinimize(napi_env env, napi_callback_info info); static napi_value CompatibleFullScreenClose(napi_env env, napi_callback_info info); + static napi_value SetWindowEnableDragBySystem(napi_env env, napi_callback_info info); napi_value OnRegisterCallback(napi_env env, napi_callback_info info); napi_value OnUpdateNativeVisibility(napi_env env, napi_callback_info info); @@ -200,6 +201,7 @@ private: napi_value OnCompatibleFullScreenClose(napi_env env, napi_callback_info info); napi_value OnSyncScenePanelGlobalPosition(napi_env env, napi_callback_info info); napi_value OnUnSyncScenePanelGlobalPosition(napi_env env, napi_callback_info info); + napi_value OnSetWindowEnableDragBySystem(napi_env env, napi_callback_info info); bool IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject); void ProcessChangeSessionVisibilityWithStatusBarRegister(); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index ca944d44bd..8ddf167745 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -2951,7 +2951,7 @@ napi_value JsSceneSessionManager::OnGetSessionSnapshotPixelMap(napi_env env, nap }; napi_value result = nullptr; napi_value lastParam = argv[1]; - NapiAsyncTask::Schedule("JsSceneSessionManager::OnGetSessionSnapshotPixelMap", + NapiAsyncTask::ScheduleHighQos("JsSceneSessionManager::OnGetSessionSnapshotPixelMap", env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result)); return result; } diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp index 712bcaef31..4f9fb87e08 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp @@ -38,6 +38,7 @@ const std::string ON_SCREEN_ROTATION_LOCKED_CHANGE = "screenRotationLockedChange const std::string ON_SCREEN_DENSITY_CHANGE = "screenDensityChange"; const std::string ON_SCREEN_EXTEND_CHANGE = "screenExtendChange"; const std::string ON_HOVER_STATUS_CHANGE_CALLBACK = "hoverStatusChange"; +const std::string ON_SCREEN_CAPTURE_NOTIFY = "screenCaptureNotify"; constexpr size_t ARGC_ONE = 1; } // namespace @@ -688,4 +689,39 @@ void JsScreenSession::OnHoverStatusChange(int32_t hoverStatus, ScreenId screenId WLOGFE("OnHoverStatusChange: env is nullptr"); } } + +void JsScreenSession::OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) +{ + const std::string callbackType = ON_SCREEN_CAPTURE_NOTIFY; + if (mCallback_.count(callbackType) == 0) { + WLOGFW("Callback is unregistered!"); + return; + } + auto jsCallbackRef = mCallback_[callbackType]; + auto asyncTask = [jsCallbackRef, callbackType, mainScreenId, uid, clientName, env = env_]() { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "jsScreenSession::OnScreenCaptureNotify"); + if (jsCallbackRef == nullptr) { + WLOGFE("Call js callback failed, jsCallbackRef is null!"); + return; + } + auto method = jsCallbackRef->GetNapiValue(); + if (method == nullptr) { + WLOGFE("Call js callback failed, method is null!"); + return; + } + napi_value mainId = CreateJsValue(env, static_cast(mainScreenId)); + napi_value clientUid = CreateJsValue(env, uid); + napi_value client = CreateJsValue(env, clientName); + napi_value argv[] = { mainId, clientUid, client }; + napi_call_function(env, NapiGetUndefined(env), method, ArraySize(argv), argv, nullptr); + }; + if (env_ != nullptr) { + napi_status ret = napi_send_event(env_, asyncTask, napi_eprio_immediate); + if (ret != napi_status::napi_ok) { + WLOGFE("OnScreenCaptureNotify: Failed to SendEvent."); + } + } else { + WLOGFE("OnScreenCaptureNotify: env is nullptr"); + } +} } // namespace OHOS::Rosen diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h index d9ad8c5535..a72e129ebc 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h @@ -58,6 +58,7 @@ private: void OnScreenDensityChange(); void OnScreenExtendChange(ScreenId mainScreenId, ScreenId extendScreenId) override; void OnHoverStatusChange(int32_t hoverStatus, ScreenId screenId) override; + void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override; napi_env env_; sptr screenSession_; diff --git a/window_scene/screen_session_manager/include/multi_screen_manager.h b/window_scene/screen_session_manager/include/multi_screen_manager.h index 0175581f76..15e578f0c1 100644 --- a/window_scene/screen_session_manager/include/multi_screen_manager.h +++ b/window_scene/screen_session_manager/include/multi_screen_manager.h @@ -40,7 +40,7 @@ public: void MultiScreenModeChange(ScreenId mainScreenId, ScreenId secondaryScreenId, const std::string& operateType); - void SetMultiScreenStatus(ScreenId mainScreenId, const std::string& status); + void SetLastScreenMode(ScreenId mainScreenId, MultiScreenMode secondaryScreenMode); void InternalScreenOnChange(sptr internalSession, sptr externalSession); @@ -83,7 +83,7 @@ private: void DoFirstExtendChangeExtend(sptr firstSession, sptr secondarySession); void DoFirstExtendChangeMirror(sptr firstSession, sptr secondarySession); - std::pair multiScreenStatus_; // main screen id & other screen status + std::pair lastScreenMode_; // main screen id & secondary screen mode }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_MULTI_SCREEN_MANAGER_H diff --git a/window_scene/screen_session_manager/include/screen_session_manager.h b/window_scene/screen_session_manager/include/screen_session_manager.h index b70899adcb..d458d33635 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -301,6 +301,7 @@ public: DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate, uint32_t& actualRefreshRate) override; + void SetLastScreenMode(sptr firstSession, sptr secondarySession); /* * multi user */ @@ -310,7 +311,10 @@ public: void ScbClientDeathCallback(int32_t deathScbPid); void ScbStatusRecoveryWhenSwitchUser(std::vector oldScbPids, int32_t newScbPid); - void SetMultiScreenStatus(sptr firstSession, sptr secondarySession); + std::shared_ptr GetScreenCapture(const CaptureOption& captureOption, + DmErrorCode* errorCode = nullptr) override; + void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override; + protected: ScreenSessionManager(); virtual ~ScreenSessionManager() = default; @@ -367,6 +371,7 @@ private: sptr HookDisplayInfoByUid(sptr displayInfo, const sptr& screenSession); DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, std::vector& windowIdList) override; + void GetInternalAndExternalSession(sptr& internalSession, sptr& externalSession); #ifdef DEVICE_STATUS_ENABLE void SetDragWindowScreenId(ScreenId screenId, ScreenId displayNodeScreenId); #endif // DEVICE_STATUS_ENABLE 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 761cb70946..cecbefa7c9 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 @@ -199,6 +199,13 @@ public: { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } + + virtual std::shared_ptr GetScreenCapture(const CaptureOption& captureOption, + DmErrorCode* errorCode = nullptr) override + { + *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; + return nullptr; + } }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h index 8c5f0894ff..c00085ee9d 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h @@ -180,6 +180,8 @@ public: std::vector& windowIdList) override; DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate, uint32_t& actualRefreshRate) override; + std::shared_ptr GetScreenCapture(const CaptureOption& captureOption, + DmErrorCode* errorCode = nullptr) override; private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_stub.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_stub.h index 58d39905ba..ec9d1c3442 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_stub.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_stub.h @@ -38,6 +38,7 @@ private: void ProcProxyForFreeze(MessageParcel& data, MessageParcel& reply); void ProcGetAllDisplayPhysicalResolution(MessageParcel& data, MessageParcel& reply); void ProcSetVirtualScreenSecurityExemption(MessageParcel& data, MessageParcel& reply); + void ProcGetScreenCapture(MessageParcel& data, MessageParcel& reply); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/screen_session_manager/src/multi_screen_manager.cpp b/window_scene/screen_session_manager/src/multi_screen_manager.cpp index abd5bdc2b8..e0e9e9132e 100644 --- a/window_scene/screen_session_manager/src/multi_screen_manager.cpp +++ b/window_scene/screen_session_manager/src/multi_screen_manager.cpp @@ -20,23 +20,22 @@ WM_IMPLEMENT_SINGLE_INSTANCE(MultiScreenManager) namespace { const std::string SCREEN_EXTEND = "extend"; const std::string SCREEN_MIRROR = "mirror"; -const std::string SCREEN_UNKNOWN = "unknown"; } MultiScreenManager::MultiScreenManager() { - TLOGI(WmsLogTag::DMS, "init multi screen manager"); - multiScreenStatus_ = std::make_pair(SCREEN_ID_INVALID, SCREEN_UNKNOWN); + TLOGI(WmsLogTag::DMS, "init"); + lastScreenMode_ = std::make_pair(SCREEN_ID_INVALID, MultiScreenMode::SCREEN_MIRROR); } MultiScreenManager::~MultiScreenManager() { - TLOGI(WmsLogTag::DMS, "destructor multi screen manager"); + TLOGI(WmsLogTag::DMS, "destructor"); } void MultiScreenManager::FilterPhysicalAndVirtualScreen(const std::vector& allScreenIds, std::vector& physicalScreenIds, std::vector& virtualScreenIds) { - TLOGI(WmsLogTag::DMS, "filter physical and virtual screen enter allScreen size: %{public}u", + TLOGI(WmsLogTag::DMS, "enter allScreen size: %{public}u", static_cast(allScreenIds.size())); sptr defaultSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession(); if (defaultSession == nullptr) { @@ -60,13 +59,13 @@ void MultiScreenManager::FilterPhysicalAndVirtualScreen(const std::vector& screenIds, ScreenId& screenGroupId) { - TLOGI(WmsLogTag::DMS, "virtual screen mirror switch enter size: %{public}u", + TLOGI(WmsLogTag::DMS, "enter size: %{public}u", static_cast(screenIds.size())); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:VirtualScreenMirrorSwitch start"); auto mainScreen = ScreenSessionManager::GetInstance().GetScreenSession(mainScreenId); @@ -76,7 +75,7 @@ DMError MultiScreenManager::VirtualScreenMirrorSwitch(const ScreenId mainScreenI } DMError ret = ScreenSessionManager::GetInstance().SetMirror(mainScreenId, screenIds); if (ret != DMError::DM_OK) { - TLOGE(WmsLogTag::DMS, "virtual screen mirror switch error: %{public}d", ret); + TLOGE(WmsLogTag::DMS, "error: %{public}d", ret); return ret; } if (ScreenSessionManager::GetInstance().GetAbstractScreenGroup(mainScreen->groupSmsId_) == nullptr) { @@ -84,7 +83,7 @@ DMError MultiScreenManager::VirtualScreenMirrorSwitch(const ScreenId mainScreenI return DMError::DM_ERROR_NULLPTR; } screenGroupId = mainScreen->groupSmsId_; - TLOGI(WmsLogTag::DMS, "virtual screen mirror switch end"); + TLOGI(WmsLogTag::DMS, "end"); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:VirtualScreenMirrorSwitch end"); return ret; } @@ -121,7 +120,7 @@ DMError MultiScreenManager::PhysicalScreenMirrorSwitch(const std::vector& screenIds) { - TLOGI(WmsLogTag::DMS, "enter physical screen unique switch screen size: %{public}u", + TLOGI(WmsLogTag::DMS, "enter screen size: %{public}u", static_cast(screenIds.size())); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:PhysicalScreenUniqueSwitch start"); for (ScreenId physicalScreenId : screenIds) { @@ -139,7 +138,7 @@ DMError MultiScreenManager::PhysicalScreenUniqueSwitch(const std::vectorCreateDisplayNode(config); ScreenSessionManager::GetInstance().OnVirtualScreenChange(physicalScreenId, ScreenEvent::CONNECTED); } - TLOGI(WmsLogTag::DMS, "physical screen unique switch end"); + TLOGI(WmsLogTag::DMS, "end"); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:PhysicalScreenUniqueSwitch end"); return DMError::DM_OK; } @@ -152,7 +151,7 @@ DMError MultiScreenManager::VirtualScreenUniqueSwitch(sptr screen return DMError::DM_ERROR_NULLPTR; } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:VirtualScreenUniqueSwitch start"); - TLOGI(WmsLogTag::DMS, "start virtual screen unique switch size: %{public}u", + TLOGI(WmsLogTag::DMS, "start size: %{public}u", static_cast(screenIds.size())); auto group = ScreenSessionManager::GetInstance().GetAbstractScreenGroup(screenSession->groupSmsId_); if (group == nullptr) { @@ -181,7 +180,7 @@ DMError MultiScreenManager::VirtualScreenUniqueSwitch(sptr screen ScreenSessionManager::GetInstance().OnVirtualScreenChange(uniqueScreenId, ScreenEvent::CONNECTED); } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "dms:VirtualScreenUniqueSwitch end"); - TLOGI(WmsLogTag::DMS, "virtual screen switch to unique and notify scb end"); + TLOGI(WmsLogTag::DMS, "to unique and notify scb end"); return DMError::DM_OK; } @@ -191,10 +190,10 @@ DMError MultiScreenManager::UniqueSwitch(const std::vector& screenIds) std::vector virtualScreenIds; std::vector physicalScreenIds; if (screenIds.empty()) { - TLOGI(WmsLogTag::DMS, "mirror to unique switch screen size empty"); + TLOGI(WmsLogTag::DMS, "mirror to screen size empty"); return switchStatus; } - TLOGI(WmsLogTag::DMS, "enter mirror to unique switch screen size: %{public}u", + TLOGI(WmsLogTag::DMS, "enter mirror to screen size: %{public}u", static_cast(screenIds.size())); FilterPhysicalAndVirtualScreen(screenIds, physicalScreenIds, virtualScreenIds); @@ -217,10 +216,10 @@ DMError MultiScreenManager::MirrorSwitch(const ScreenId mainScreenId, const std: std::vector virtualScreenIds; std::vector physicalScreenIds; if (screenIds.empty()) { - TLOGI(WmsLogTag::DMS, "mirror switch screen size empty"); + TLOGI(WmsLogTag::DMS, "screen size empty"); return switchStatus; } - TLOGI(WmsLogTag::DMS, "enter mirror switch screen size: %{public}u", static_cast(screenIds.size())); + TLOGI(WmsLogTag::DMS, "enter screen size: %{public}u", static_cast(screenIds.size())); FilterPhysicalAndVirtualScreen(screenIds, physicalScreenIds, virtualScreenIds); if (!virtualScreenIds.empty()) { @@ -232,7 +231,7 @@ DMError MultiScreenManager::MirrorSwitch(const ScreenId mainScreenId, const std: switchStatus = PhysicalScreenMirrorSwitch(physicalScreenIds); TLOGI(WmsLogTag::DMS, "physical screen switch to mirror result: %{public}d", switchStatus); } - TLOGI(WmsLogTag::DMS, "mirror switch end switchStatus: %{public}d", switchStatus); + TLOGI(WmsLogTag::DMS, "end switchStatus: %{public}d", switchStatus); return switchStatus; } @@ -488,12 +487,12 @@ void MultiScreenManager::DoFirstExtendChange(sptr firstSession, s } } -void MultiScreenManager::SetMultiScreenStatus(ScreenId mainScreenId, const std::string& status) +void MultiScreenManager::SetLastScreenMode(ScreenId mainScreenId, MultiScreenMode secondaryScreenMode) { - multiScreenStatus_.first = mainScreenId; - multiScreenStatus_.second = status; - TLOGI(WmsLogTag::DMS, "Set multiScreenStatus_ done, mainScreenId = %{public}" PRIu64 ", status = %{public}s", - multiScreenStatus_.first, multiScreenStatus_.second.c_str()); + lastScreenMode_.first = mainScreenId; + lastScreenMode_.second = secondaryScreenMode; + TLOGI(WmsLogTag::DMS, "success, mainScreenId = %{public}" PRIu64 + ", secondaryScreenMode = %{public}d", lastScreenMode_.first, lastScreenMode_.second); } void MultiScreenManager::InternalScreenOnChange(sptr internalSession, @@ -503,39 +502,27 @@ void MultiScreenManager::InternalScreenOnChange(sptr internalSess TLOGE(WmsLogTag::DMS, "internal or external screen is null!"); return; } - - sptr scbClient = ScreenSessionManager::GetInstance().GetClientProxy(); - if (scbClient == nullptr) { - TLOGE(WmsLogTag::DMS, "scbClient null"); + ScreenId mainScreenId = lastScreenMode_.first; + MultiScreenMode secondaryScreenMode = lastScreenMode_.second; + if (mainScreenId == SCREEN_ID_INVALID) { + TLOGW(WmsLogTag::DMS, "mode not restored, reset last screen mode"); + ScreenSessionManager::GetInstance().SetLastScreenMode(internalSession, externalSession); return; } - ScreenId mainScreenId = multiScreenStatus_.first; - std::string status = multiScreenStatus_.second; - - if (mainScreenId == SCREEN_ID_INVALID || status == SCREEN_UNKNOWN) { - TLOGW(WmsLogTag::DMS, "previous state not found, no mode change"); - ScreenSessionManager::GetInstance().SetMultiScreenStatus(internalSession, externalSession); + ScreenId internalScreenId = ScreenSessionManager::GetInstance().GetInternalScreenId(); + if (mainScreenId == internalScreenId && secondaryScreenMode == MultiScreenMode::SCREEN_MIRROR) { + DoFirstMirrorChange(internalSession, externalSession, SCREEN_MIRROR); + TLOGI(WmsLogTag::DMS, "5: external mirror to internal mirror"); + } else if (mainScreenId == internalScreenId && secondaryScreenMode == MultiScreenMode::SCREEN_EXTEND) { + DoFirstMirrorChange(internalSession, externalSession, SCREEN_EXTEND); + TLOGI(WmsLogTag::DMS, "7: external mirror to internal extend"); + } else if (mainScreenId != internalScreenId && secondaryScreenMode == MultiScreenMode::SCREEN_EXTEND) { + DoFirstMainChange(externalSession, internalSession, SCREEN_EXTEND); + TLOGI(WmsLogTag::DMS, "6: external mirror to external extend"); } else { - TLOGI(WmsLogTag::DMS, "found previous state, recover from storage"); - if (mainScreenId == ScreenSessionManager::GetInstance().GetInternalScreenId() && - status == SCREEN_MIRROR) { - DoFirstMirrorChangeMirror(scbClient, internalSession, externalSession); - TLOGI(WmsLogTag::DMS, "5: external mirror to internal mirror"); - } else if (mainScreenId == ScreenSessionManager::GetInstance().GetInternalScreenId() && - status == SCREEN_EXTEND) { - DoFirstMirrorChangeExtend(scbClient, internalSession, externalSession); - TLOGI(WmsLogTag::DMS, "7: external mirror to internal extend"); - } else if (mainScreenId != ScreenSessionManager::GetInstance().GetInternalScreenId() && - status == SCREEN_EXTEND) { - DoFirstMainChangeExtend(scbClient, externalSession, internalSession); - TLOGI(WmsLogTag::DMS, "6: external mirror to external extend"); - } else { - TLOGE(WmsLogTag::DMS, "paramater error!"); - return; - } + TLOGE(WmsLogTag::DMS, "paramater error!"); + return; } - TLOGI(WmsLogTag::DMS, "current restored mainScreenId = %{public}" PRIu64 ", status = %{public}s", - multiScreenStatus_.first, multiScreenStatus_.second.c_str()); } void MultiScreenManager::InternalScreenOffChange(sptr internalSession, @@ -545,37 +532,23 @@ void MultiScreenManager::InternalScreenOffChange(sptr internalSes TLOGE(WmsLogTag::DMS, "internal or external screen is null!"); return; } - - sptr scbClient = ScreenSessionManager::GetInstance().GetClientProxy(); - if (scbClient == nullptr) { - TLOGE(WmsLogTag::DMS, "scbClient null"); - return; - } - ScreenSessionManager::GetInstance().SetMultiScreenStatus(internalSession, externalSession); - ScreenId mainScreenId = multiScreenStatus_.first; - std::string status = multiScreenStatus_.second; - TLOGI(WmsLogTag::DMS, "restored mainScreenId = %{public}" PRIu64 ", status = %{public}s", - multiScreenStatus_.first, multiScreenStatus_.second.c_str()); - - if (mainScreenId == ScreenSessionManager::GetInstance().GetInternalScreenId() && - status == SCREEN_MIRROR) { - DoFirstMirrorChangeMirror(scbClient, externalSession, internalSession); + ScreenSessionManager::GetInstance().SetLastScreenMode(internalSession, externalSession); + ScreenId mainScreenId = lastScreenMode_.first; + MultiScreenMode secondaryScreenMode = lastScreenMode_.second; + ScreenId internalScreenId = ScreenSessionManager::GetInstance().GetInternalScreenId(); + if (mainScreenId == internalScreenId && secondaryScreenMode == MultiScreenMode::SCREEN_MIRROR) { + DoFirstMirrorChange(externalSession, internalSession, SCREEN_MIRROR); TLOGI(WmsLogTag::DMS, "3: internal mirror to external mirror"); - } else if (mainScreenId == ScreenSessionManager::GetInstance().GetInternalScreenId() && - status == SCREEN_EXTEND) { - DoFirstExtendChangeMirror(externalSession, internalSession); + } else if (mainScreenId == internalScreenId && secondaryScreenMode == MultiScreenMode::SCREEN_EXTEND) { + DoFirstExtendChange(externalSession, internalSession, SCREEN_EXTEND); TLOGI(WmsLogTag::DMS, "10: internal extend to external mirror"); - } else if (mainScreenId != ScreenSessionManager::GetInstance().GetInternalScreenId() && - status == SCREEN_EXTEND) { - DoFirstMainChangeMirror(scbClient, externalSession, internalSession); + } else if (mainScreenId != internalScreenId && secondaryScreenMode == MultiScreenMode::SCREEN_EXTEND) { + DoFirstMainChange(externalSession, internalSession, SCREEN_EXTEND); TLOGI(WmsLogTag::DMS, "14: external extend to external mirror"); } else { TLOGE(WmsLogTag::DMS, "paramater error!"); return; } - - TLOGI(WmsLogTag::DMS, "current mainScreenId = %{public}" PRIu64 ", status = %{public}s", - multiScreenStatus_.first, multiScreenStatus_.second.c_str()); } void MultiScreenManager::ExternalScreenDisconnectChange(sptr internalSession, @@ -585,20 +558,22 @@ void MultiScreenManager::ExternalScreenDisconnectChange(sptr inte TLOGE(WmsLogTag::DMS, "internal or external screen is null!"); return; } - if (externalSession->GetScreenCombination() == ScreenCombination::SCREEN_MAIN) { - if (internalSession->GetScreenCombination() == ScreenCombination::SCREEN_MIRROR) { - DoFirstMirrorChange(internalSession, externalSession, SCREEN_MIRROR); - TLOGI(WmsLogTag::DMS, "8: external mirror to internal mirror"); - } else if (internalSession->GetScreenCombination() == ScreenCombination::SCREEN_EXTEND) { - DoFirstExtendChange(internalSession, externalSession, SCREEN_MIRROR); - TLOGI(WmsLogTag::DMS, "16: external extend to internal mirror"); - } else { - TLOGE(WmsLogTag::DMS, "paramater error!"); - return; - } - } else { + ScreenCombination internalCombination = internalSession->GetScreenCombination(); + ScreenCombination externalCombination = externalSession->GetScreenCombination(); + if (externalCombination != ScreenCombination::SCREEN_MAIN) { DoFirstMainChange(internalSession, externalSession, SCREEN_MIRROR); TLOGI(WmsLogTag::DMS, "12: internal extend to internal mirror"); + return; + } + if (internalCombination == ScreenCombination::SCREEN_MIRROR) { + DoFirstMirrorChange(internalSession, externalSession, SCREEN_MIRROR); + TLOGI(WmsLogTag::DMS, "8: external mirror to internal mirror"); + } else if (internalCombination == ScreenCombination::SCREEN_EXTEND) { + DoFirstExtendChange(internalSession, externalSession, SCREEN_MIRROR); + TLOGI(WmsLogTag::DMS, "16: external extend to internal mirror"); + } else { + TLOGE(WmsLogTag::DMS, "paramater error!"); + return; } } } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp index fb3472621c..9c27426ecd 100644 --- a/window_scene/screen_session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/screen_session_manager/src/screen_cutout_controller.cpp @@ -34,7 +34,7 @@ std::map ScreenCutoutController::deviceToDisplayR sptr ScreenCutoutController::GetScreenCutoutInfo(DisplayId displayId) { - TLOGD(WmsLogTag::DMS, "get screen cutout info."); + TLOGD(WmsLogTag::DMS, "start"); std::vector boundaryRects; if (!ScreenSceneConfig::GetCutoutBoundaryRect(displayId).empty()) { ConvertBoundaryRectsByRotation(boundaryRects, displayId); @@ -250,7 +250,7 @@ DMRect ScreenCutoutController::CreateWaterfallRect(uint32_t left, uint32_t top, RectF ScreenCutoutController::CalculateCurvedCompression(const ScreenProperty& screenProperty) { - TLOGI(WmsLogTag::DMS, "calculate curved compression"); + TLOGI(WmsLogTag::DMS, "start"); RectF finalRect = RectF(0, 0, 0, 0); sptr displayInfo = ScreenSessionManager::GetInstance().GetDefaultDisplayInfo(); uint32_t iCurvedSize = 0; diff --git a/window_scene/screen_session_manager/src/screen_scene_config.cpp b/window_scene/screen_session_manager/src/screen_scene_config.cpp index bf7a098ea2..ca879d35c3 100644 --- a/window_scene/screen_session_manager/src/screen_scene_config.cpp +++ b/window_scene/screen_session_manager/src/screen_scene_config.cpp @@ -134,7 +134,7 @@ std::string ScreenSceneConfig::GetConfigPath(const std::string& configFileName) char* configPath = GetOneCfgFile(configFileName.c_str(), buf, PATH_MAX + 1); char tmpPath[PATH_MAX + 1] = { 0 }; if (!configPath || strlen(configPath) == 0 || strlen(configPath) > PATH_MAX || !realpath(configPath, tmpPath)) { - TLOGI(WmsLogTag::DMS, "[SsConfig] can not get customization config file"); + TLOGI(WmsLogTag::DMS, "can not get customization config file"); return "/system/" + configFileName; } return std::string(tmpPath); @@ -148,21 +148,21 @@ bool ScreenSceneConfig::LoadConfigXml() std::lock_guard lock(mutex_); docPtr = xmlReadFile(configFilePath.c_str(), nullptr, XML_PARSE_NOBLANKS); } - TLOGI(WmsLogTag::DMS, "[SsConfig] filePath: %{public}s", configFilePath.c_str()); + TLOGI(WmsLogTag::DMS, "filePath: %{public}s", configFilePath.c_str()); if (docPtr == nullptr) { - TLOGE(WmsLogTag::DMS, "[SsConfig] load xml error!"); + TLOGE(WmsLogTag::DMS, "load xml error!"); return false; } xmlNodePtr rootPtr = xmlDocGetRootElement(docPtr); if (rootPtr == nullptr || rootPtr->name == nullptr || xmlStrcmp(rootPtr->name, reinterpret_cast("Configs"))) { - TLOGE(WmsLogTag::DMS, "[SsConfig] get root element failed!"); + TLOGE(WmsLogTag::DMS, "get root element failed!"); xmlFreeDoc(docPtr); return false; } for (xmlNodePtr curNodePtr = rootPtr->xmlChildrenNode; curNodePtr != nullptr; curNodePtr = curNodePtr->next) { if (!IsValidNode(*curNodePtr)) { - TLOGE(WmsLogTag::DMS, "SsConfig]: invalid node!"); + TLOGE(WmsLogTag::DMS, ":invalid node!"); continue; } ParseNodeConfig(curNodePtr); @@ -221,7 +221,7 @@ void ScreenSceneConfig::ReadIntNumbersConfigInfo(const xmlNodePtr& currNode) { xmlChar* context = xmlNodeGetContent(currNode); if (context == nullptr) { - TLOGE(WmsLogTag::DMS, "[SsConfig] read xml node error: nodeName:(%{public}s)", currNode->name); + TLOGE(WmsLogTag::DMS, "read xml node error: nodeName:(%{public}s)", currNode->name); return; } @@ -234,7 +234,7 @@ void ScreenSceneConfig::ReadIntNumbersConfigInfo(const xmlNodePtr& currNode) auto numbers = Split(numbersStr, " "); for (auto& num : numbers) { if (!IsNumber(num)) { - TLOGE(WmsLogTag::DMS, "[SsConfig] read number error: nodeName:(%{public}s)", currNode->name); + TLOGE(WmsLogTag::DMS, "read number error: nodeName:(%{public}s)", currNode->name); xmlFree(context); return; } @@ -250,12 +250,12 @@ void ScreenSceneConfig::ReadPhysicalDisplayConfigInfo(const xmlNodePtr& currNode { xmlChar* displayMode = xmlGetProp(currNode, reinterpret_cast("displayMode")); if (displayMode == nullptr) { - TLOGE(WmsLogTag::DMS, "[SsConfig] read xml node error: nodeName:(%{public}s)", currNode->name); + TLOGE(WmsLogTag::DMS, "read xml node error: nodeName:(%{public}s)", currNode->name); return; } xmlChar* displayModeContext = xmlNodeGetContent(currNode); if (displayModeContext == nullptr) { - TLOGE(WmsLogTag::DMS, "[SsConfig] read xml nodeName:(%{public}s) context null", currNode->name); + TLOGE(WmsLogTag::DMS, "read xml nodeName:(%{public}s) context null", currNode->name); xmlFree(displayMode); return; } @@ -299,12 +299,12 @@ void ScreenSceneConfig::ReadScrollableParam(const xmlNodePtr& currNode) { xmlChar* displayModeXml = xmlGetProp(currNode, reinterpret_cast("displayMode")); if (displayModeXml == nullptr) { - TLOGE(WmsLogTag::DMS, "[SsConfig] read xml node error: nodeName:(%{public}s)", currNode->name); + TLOGE(WmsLogTag::DMS, "read xml node error: nodeName:(%{public}s)", currNode->name); return; } xmlChar* displayModeContext = xmlNodeGetContent(currNode); if (displayModeContext == nullptr) { - TLOGE(WmsLogTag::DMS, "[SsConfig] read xml nodeName:(%{public}s) context null", currNode->name); + TLOGE(WmsLogTag::DMS, "read xml nodeName:(%{public}s) context null", currNode->name); xmlFree(displayModeXml); return; } @@ -349,7 +349,7 @@ void ScreenSceneConfig::ReadEnableConfigInfo(const xmlNodePtr& currNode) { xmlChar* enable = xmlGetProp(currNode, reinterpret_cast("enable")); if (enable == nullptr) { - TLOGE(WmsLogTag::DMS, "[SsConfig] read xml node error: nodeName:(%{public}s)", currNode->name); + TLOGE(WmsLogTag::DMS, "read xml node error: nodeName:(%{public}s)", currNode->name); return; } @@ -371,7 +371,7 @@ void ScreenSceneConfig::ReadStringConfigInfo(const xmlNodePtr& currNode) { xmlChar* context = xmlNodeGetContent(currNode); if (context == nullptr) { - TLOGE(WmsLogTag::DMS, "[SsConfig] read xml node error: nodeName:(%{public}s)", currNode->name); + TLOGE(WmsLogTag::DMS, "read xml node error: nodeName:(%{public}s)", currNode->name); return; } @@ -384,7 +384,7 @@ void ScreenSceneConfig::ReadStringConfigInfo(const xmlNodePtr& currNode) void ScreenSceneConfig::ReadStringListConfigInfo(const xmlNodePtr& rootNode, std::string name) { if (rootNode == nullptr || rootNode->name == nullptr) { - TLOGE(WmsLogTag::DMS, "[SsConfig] get root element failed!"); + TLOGE(WmsLogTag::DMS, "get root element failed!"); return; } xmlChar* rootContext = xmlNodeGetContent(rootNode); @@ -395,7 +395,7 @@ void ScreenSceneConfig::ReadStringListConfigInfo(const xmlNodePtr& rootNode, std std::vector stringVec; for (xmlNodePtr curNodePtr = rootNode->xmlChildrenNode; curNodePtr != nullptr; curNodePtr = curNodePtr->next) { if (!IsValidNode(*curNodePtr)) { - TLOGE(WmsLogTag::DMS, "[SsConfig]: invalid node!"); + TLOGE(WmsLogTag::DMS, "invalid node!"); continue; } xmlChar* context = xmlNodeGetContent(curNodePtr); @@ -430,17 +430,17 @@ const std::map>& ScreenSceneConfig::GetStr void ScreenSceneConfig::DumpConfig() { for (auto& enable : enableConfig_) { - TLOGI(WmsLogTag::DMS, "[SsConfig] Enable: %{public}s %{public}u", enable.first.c_str(), enable.second); + TLOGI(WmsLogTag::DMS, "Enable: %{public}s %{public}u", enable.first.c_str(), enable.second); } for (auto& numbers : intNumbersConfig_) { - TLOGI(WmsLogTag::DMS, "[SsConfig] Numbers: %{public}s %{public}zu", + TLOGI(WmsLogTag::DMS, "Numbers: %{public}s %{public}zu", numbers.first.c_str(), numbers.second.size()); for (auto& num : numbers.second) { - TLOGI(WmsLogTag::DMS, "[SsConfig] Num: %{public}d", num); + TLOGI(WmsLogTag::DMS, "Num: %{public}d", num); } } for (auto& string : stringConfig_) { - TLOGI(WmsLogTag::DMS, "[SsConfig] String: %{public}s", string.first.c_str()); + TLOGI(WmsLogTag::DMS, "String: %{public}s", string.first.c_str()); } } diff --git a/window_scene/screen_session_manager/src/screen_sensor_connector.cpp b/window_scene/screen_session_manager/src/screen_sensor_connector.cpp index 144dfedf5c..f3a93855b4 100644 --- a/window_scene/screen_session_manager/src/screen_sensor_connector.cpp +++ b/window_scene/screen_session_manager/src/screen_sensor_connector.cpp @@ -40,7 +40,7 @@ sptr MotionTentSubscriber::motionEventCallback_ = nullp void ScreenSensorConnector::SubscribeRotationSensor() { - TLOGD(WmsLogTag::DMS, "dms: subscribe rotation-related sensor"); + TLOGD(WmsLogTag::DMS, "subscribe rotation-related sensor"); #ifdef WM_SUBSCRIBE_MOTION_ENABLE MotionSubscriber::SubscribeMotionSensor(); if (MotionSubscriber::isMotionSensorSubscribed_) { @@ -58,7 +58,7 @@ void ScreenSensorConnector::UnsubscribeRotationSensor() void ScreenSensorConnector::SubscribeTentSensor() { - TLOGD(WmsLogTag::DMS, "dms: subscribe tent sensor"); + TLOGD(WmsLogTag::DMS, "start"); #ifdef WM_SUBSCRIBE_MOTION_ENABLE MotionTentSubscriber::SubscribeMotionSensor(); #endif @@ -75,9 +75,9 @@ void ScreenSensorConnector::UnsubscribeTentSensor() #ifdef WM_SUBSCRIBE_MOTION_ENABLE void MotionSubscriber::SubscribeMotionSensor() { - TLOGI(WmsLogTag::DMS, "dms: Subscribe motion Sensor"); + TLOGI(WmsLogTag::DMS, "start"); if (isMotionSensorSubscribed_) { - TLOGE(WmsLogTag::DMS, "dms: motion sensor's already subscribed"); + TLOGE(WmsLogTag::DMS, "motion sensor's already subscribed"); return; } sptr callback = new (std::nothrow) RotationMotionEventCallback(); @@ -95,7 +95,7 @@ void MotionSubscriber::SubscribeMotionSensor() void MotionSubscriber::UnsubscribeMotionSensor() { if (!isMotionSensorSubscribed_) { - TLOGI(WmsLogTag::DMS, "dms: Unsubscribe motion sensor"); + TLOGI(WmsLogTag::DMS, "start"); return; } int32_t ret = OHOS::Msdp::UnsubscribeCallback(OHOS::Msdp::MOTION_TYPE_ROTATION, motionEventCallback_); @@ -135,19 +135,19 @@ void RotationMotionEventCallback::OnMotionChanged(const MotionEvent& motionData) void MotionTentSubscriber::SubscribeMotionSensor() { - TLOGI(WmsLogTag::DMS, "dms: Subscribe tent motion Sensor"); + TLOGI(WmsLogTag::DMS, "Subscribe tent motion Sensor"); if (isMotionSensorSubscribed_) { - TLOGE(WmsLogTag::DMS, "dms: tent motion sensor's already subscribed"); + TLOGE(WmsLogTag::DMS, "tent motion sensor's already subscribed"); return; } sptr callback = new (std::nothrow) TentMotionEventCallback(); if (callback == nullptr) { - TLOGE(WmsLogTag::DMS, "dms: malloc tent motion callback failed"); + TLOGE(WmsLogTag::DMS, "malloc tent motion callback failed"); return; } int32_t ret = OHOS::Msdp::SubscribeCallback(OHOS::Msdp::MOTION_TYPE_TENT, callback); if (ret != 0) { - TLOGE(WmsLogTag::DMS, "dms: SubscribeCallback type:%{public}d failed", OHOS::Msdp::MOTION_TYPE_TENT); + TLOGE(WmsLogTag::DMS, "SubscribeCallback type:%{public}d failed", OHOS::Msdp::MOTION_TYPE_TENT); return; } motionEventCallback_ = callback; @@ -157,7 +157,7 @@ void MotionTentSubscriber::SubscribeMotionSensor() void MotionTentSubscriber::UnsubscribeMotionSensor() { if (!isMotionSensorSubscribed_) { - TLOGI(WmsLogTag::DMS, "dms: Unsubscribe tent motion sensor"); + TLOGI(WmsLogTag::DMS, "start"); return; } int32_t ret = OHOS::Msdp::UnsubscribeCallback(OHOS::Msdp::MOTION_TYPE_TENT, motionEventCallback_); @@ -175,7 +175,7 @@ void TentMotionEventCallback::OnMotionChanged(const MotionEvent& motionData) } else if (motionData.status == MOTION_ACTION_TENT_MODE_OFF) { ScreenTentProperty::HandleSensorEventInput(false); } else { - TLOGI(WmsLogTag::DMS, "dms: tent motion:%{public}d invalid", motionData.status); + TLOGI(WmsLogTag::DMS, "tent motion:%{public}d invalid", motionData.status); } } #endif diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index c1b2b9649f..33eccdb768 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -61,6 +61,7 @@ namespace { const std::string SCREEN_SESSION_MANAGER_THREAD = "OS_ScreenSessionManager"; const std::string SCREEN_SESSION_MANAGER_SCREEN_POWER_THREAD = "OS_ScreenSessionManager_ScreenPower"; const std::string SCREEN_CAPTURE_PERMISSION = "ohos.permission.CAPTURE_SCREEN"; +const std::string CUSTOM_SCREEN_CAPTURE_PERMISSION = "ohos.permission.CUSTOM_CAPTURE_SCREEN"; const std::string BOOTEVENT_BOOT_COMPLETED = "bootevent.boot.completed"; const int32_t CV_WAIT_SCREENON_MS = 300; const int32_t CV_WAIT_SCREENOFF_MS = 1500; @@ -301,7 +302,7 @@ void ScreenSessionManager::Init() RegisterScreenChangeListener(); if (!ScreenSceneConfig::IsSupportRotateWithSensor()) { - TLOGI(WmsLogTag::DMS, "Current device type not support SetSensorSubscriptionEnabled."); + TLOGI(WmsLogTag::DMS, "Current type not support SetSensorSubscriptionEnabled."); } else if (GetScreenPower(SCREEN_ID_FULL) == ScreenPowerState::POWER_ON) { // 多屏设备只要有屏幕亮,GetScreenPower获取的任意一块屏幕状态均是ON SetSensorSubscriptionEnabled(); @@ -314,7 +315,7 @@ void ScreenSessionManager::Init() void ScreenSessionManager::OnStart() { - TLOGI(WmsLogTag::DMS, "DMS SA OnStart"); + TLOGI(WmsLogTag::DMS, "start"); DmsXcollie dmsXcollie("DMS:OnStart", XCOLLIE_TIMEOUT_10S, [this](void *) { screenEventTracker_.LogWarningAllInfos(); }); Init(); @@ -324,7 +325,7 @@ void ScreenSessionManager::OnStart() TLOGE(WmsLogTag::DMS, "Publish DMS failed"); return; } - TLOGI(WmsLogTag::DMS, "DMS SA OnStart end"); + TLOGI(WmsLogTag::DMS, "end"); screenEventTracker_.RecordEvent("Dms onstart end."); } @@ -375,7 +376,7 @@ DMError ScreenSessionManager::UnregisterDisplayManagerAgent( ret = CheckDisplayMangerAgentTypeAndPermission(displayManagerAgent, type); if (ret != DMError::DM_OK) { - TLOGE(WmsLogTag::DMS, "UnregisterDisplayManagerAgent call CheckDisplayMangerAgentTypeAndPermission fail!"); + TLOGE(WmsLogTag::DMS, "call CheckDisplayMangerAgentTypeAndPermission fail!"); return ret; } return dmAgentContainer_.UnregisterAgent(displayManagerAgent, type) ? DMError::DM_OK :DMError::DM_ERROR_NULLPTR; @@ -505,7 +506,7 @@ void ScreenSessionManager::ConfigureScreenSnapshotParams() void ScreenSessionManager::RegisterScreenChangeListener() { - TLOGI(WmsLogTag::DMS, "Register screen change listener."); + TLOGI(WmsLogTag::DMS, "start"); auto res = rsInterface_.SetScreenChangeCallback( [this](ScreenId screenId, ScreenEvent screenEvent) { OnScreenChange(screenId, screenEvent); }); if (res != StatusCode::SUCCESS) { @@ -524,7 +525,7 @@ void ScreenSessionManager::RegisterRefreshRateChangeListener() auto res = rsInterface_.RegisterHgmRefreshRateUpdateCallback( [this](uint32_t refreshRate) { OnHgmRefreshRateChange(refreshRate); }); if (res != StatusCode::SUCCESS) { - TLOGE(WmsLogTag::DMS, "Register refresh rate mode change listener failed."); + TLOGE(WmsLogTag::DMS, "failed"); screenEventTracker_.RecordEvent("Dms RefreshRateChange register failed."); } else { isRegisterRefreshRateListener = true; @@ -932,20 +933,20 @@ sptr ScreenSessionManager::GetDefaultDisplayInfo() displayInfo = HookDisplayInfoByUid(displayInfo, screenSession); return displayInfo; } else { - TLOGE(WmsLogTag::DMS, "Get default screen session failed."); + TLOGE(WmsLogTag::DMS, "failed"); return nullptr; } } sptr ScreenSessionManager::GetDisplayInfoById(DisplayId displayId) { - TLOGD(WmsLogTag::DMS, "GetDisplayInfoById enter, displayId: %{public}" PRIu64" ", displayId); + TLOGD(WmsLogTag::DMS, "enter, displayId: %{public}" PRIu64" ", displayId); DmsXcollie dmsXcollie("DMS:GetDisplayInfoById", XCOLLIE_TIMEOUT_10S); std::lock_guard lock(screenSessionMapMutex_); for (auto sessionIt : screenSessionMap_) { auto screenSession = sessionIt.second; if (screenSession == nullptr) { - TLOGI(WmsLogTag::DMS, "GetDisplayInfoById screenSession is nullptr, ScreenId: %{public}" PRIu64 "", + TLOGI(WmsLogTag::DMS, "screenSession is nullptr, ScreenId: %{public}" PRIu64 "", sessionIt.first); continue; } @@ -955,7 +956,7 @@ sptr ScreenSessionManager::GetDisplayInfoById(DisplayId displayId) continue; } if (displayId == displayInfo->GetDisplayId()) { - TLOGD(WmsLogTag::DMS, "GetDisplayInfoById success"); + TLOGD(WmsLogTag::DMS, "success"); displayInfo = HookDisplayInfoByUid(displayInfo, screenSession); return displayInfo; } @@ -971,38 +972,38 @@ sptr ScreenSessionManager::GetDisplayInfoByScreen(ScreenId screenId for (auto sessionIt : screenSessionMap_) { auto screenSession = sessionIt.second; if (screenSession == nullptr) { - TLOGI(WmsLogTag::DMS, "GetDisplayInfoByScreen screenSession is nullptr, ScreenId:%{public}" PRIu64"", + TLOGI(WmsLogTag::DMS, "screenSession is nullptr, ScreenId:%{public}" PRIu64"", sessionIt.first); continue; } sptr displayInfo = screenSession->ConvertToDisplayInfo(); if (displayInfo == nullptr) { - TLOGI(WmsLogTag::DMS, "GetDisplayInfoByScreen error, displayInfo is nullptr."); + TLOGI(WmsLogTag::DMS, "error, displayInfo is nullptr."); continue; } if (screenId == displayInfo->GetScreenId()) { return displayInfo; } } - TLOGE(WmsLogTag::DMS, "GetDisplayInfoByScreen failed. screenId: %{public}" PRIu64" ", screenId); + TLOGE(WmsLogTag::DMS, "failed. screenId: %{public}" PRIu64" ", screenId); return nullptr; } std::vector ScreenSessionManager::GetAllDisplayIds() { - TLOGI(WmsLogTag::DMS, "GetAllDisplayIds enter"); + TLOGI(WmsLogTag::DMS, "enter"); std::vector res; std::lock_guard lock(screenSessionMapMutex_); for (auto sessionIt : screenSessionMap_) { auto screenSession = sessionIt.second; if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "GetAllDisplayIds screenSession is nullptr, ScreenId:%{public}" PRIu64"", + TLOGE(WmsLogTag::DMS, "screenSession is nullptr, ScreenId:%{public}" PRIu64"", sessionIt.first); continue; } sptr displayInfo = screenSession->ConvertToDisplayInfo(); if (displayInfo == nullptr) { - TLOGE(WmsLogTag::DMS, "GetAllDisplayIds error, displayInfo is nullptr."); + TLOGE(WmsLogTag::DMS, "error, displayInfo is nullptr."); continue; } DisplayId displayId = displayInfo->GetDisplayId(); @@ -1021,7 +1022,7 @@ sptr ScreenSessionManager::GetScreenInfoById(ScreenId screenId) } auto screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "GetScreenInfoById cannot find screenInfo: %{public}" PRIu64"", screenId); + TLOGE(WmsLogTag::DMS, "cannot find screenInfo: %{public}" PRIu64"", screenId); return nullptr; } return screenSession->ConvertToScreenInfo(); @@ -1029,24 +1030,24 @@ sptr ScreenSessionManager::GetScreenInfoById(ScreenId screenId) DMError ScreenSessionManager::SetScreenActiveMode(ScreenId screenId, uint32_t modeId) { - TLOGI(WmsLogTag::DMS, "SetScreenActiveMode: ScreenId: %{public}" PRIu64", modeId: %{public}u", screenId, modeId); + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64", modeId: %{public}u", screenId, modeId); if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d", SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); return DMError::DM_ERROR_NOT_SYSTEM_APP; } if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "SetScreenActiveMode: invalid screenId"); + TLOGE(WmsLogTag::DMS, "invalid screenId"); return DMError::DM_ERROR_NULLPTR; } sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "SetScreenActiveMode: Get ScreenSession failed"); + TLOGE(WmsLogTag::DMS, "Get ScreenSession failed"); return DMError::DM_ERROR_NULLPTR; } ScreenId rsScreenId = SCREEN_ID_INVALID; if (!screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId)) { - TLOGE(WmsLogTag::DMS, "SetScreenActiveMode: No corresponding rsId"); + TLOGE(WmsLogTag::DMS, "No corresponding rsId"); return DMError::DM_ERROR_NULLPTR; } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:SetScreenActiveMode(%" PRIu64", %u)", screenId, modeId); @@ -1070,7 +1071,7 @@ void ScreenSessionManager::UpdateDisplayHookInfo(int32_t uid, bool enable, const { TLOGD(WmsLogTag::DMS, "DisplayHookInfo will update"); if (!SessionPermission::IsSystemCalling()) { - TLOGE(WmsLogTag::DMS, "UpdateDisplayHookInfo permission denied!"); + TLOGE(WmsLogTag::DMS, "permission denied!"); return; } @@ -1104,7 +1105,7 @@ bool ScreenSessionManager::IsFreezed(const int32_t& agentPid, const DisplayManag void ScreenSessionManager::NotifyScreenChanged(sptr screenInfo, ScreenChangeEvent event) { if (screenInfo == nullptr) { - TLOGE(WmsLogTag::DMS, "NotifyScreenChanged error, screenInfo is nullptr."); + TLOGE(WmsLogTag::DMS, "error, screenInfo is nullptr."); return; } { @@ -1112,10 +1113,10 @@ void ScreenSessionManager::NotifyScreenChanged(sptr screenInfo, Scre lastScreenChangeEvent_ = event; } auto task = [=] { - TLOGI(WmsLogTag::DMS, "NotifyScreenChanged, screenId:%{public}" PRIu64"", screenInfo->GetScreenId()); + TLOGI(WmsLogTag::DMS, "screenId:%{public}" PRIu64"", screenInfo->GetScreenId()); auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER); if (agents.empty()) { - TLOGI(WmsLogTag::DMS, "NotifyScreenChanged agents is empty"); + TLOGI(WmsLogTag::DMS, "agents is empty"); return; } for (auto& agent : agents) { @@ -1181,20 +1182,20 @@ DMError ScreenSessionManager::SetVirtualPixelRatioSystem(ScreenId screenId, floa DMError ScreenSessionManager::SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio) { TLOGI(WmsLogTag::DMS, - "SetResolution ScreenId: %{public}" PRIu64 ", w: %{public}u, h: %{public}u, virtualPixelRatio: %{public}f", + "ScreenId: %{public}" PRIu64 ", w: %{public}u, h: %{public}u, virtualPixelRatio: %{public}f", screenId, width, height, virtualPixelRatio); if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::DMS, "SetResolution permission denied! calling clientName: %{public}s, pid: %{public}d", + TLOGE(WmsLogTag::DMS, "permission denied! calling clientName: %{public}s, pid: %{public}d", SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); return DMError::DM_ERROR_NOT_SYSTEM_APP; } if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "SetResolution: invalid screenId"); + TLOGE(WmsLogTag::DMS, "invalid screenId"); return DMError::DM_ERROR_NULLPTR; } sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "SetResolution: Get ScreenSession failed"); + TLOGE(WmsLogTag::DMS, "Get ScreenSession failed"); return DMError::DM_ERROR_NULLPTR; } sptr screenSessionModes = screenSession->GetActiveScreenMode(); @@ -1205,7 +1206,7 @@ DMError ScreenSessionManager::SetResolution(ScreenId screenId, uint32_t width, u height <= 0 || height > screenSessionModes->height_ || virtualPixelRatio < (static_cast(DOT_PER_INCH_MINIMUM_VALUE) / DOT_PER_INCH) || virtualPixelRatio > (static_cast(DOT_PER_INCH_MAXIMUM_VALUE) / DOT_PER_INCH)) { - TLOGE(WmsLogTag::DMS, "SetResolution invalid param! w:%{public}u h:%{public}u min:%{public}f max:%{public}f", + TLOGE(WmsLogTag::DMS, "invalid param! w:%{public}u h:%{public}u min:%{public}f max:%{public}f", screenSessionModes->width_, screenSessionModes->height_, static_cast(DOT_PER_INCH_MINIMUM_VALUE) / DOT_PER_INCH, @@ -1233,7 +1234,7 @@ DMError ScreenSessionManager::GetDensityInCurResolution(ScreenId screenId, float DmsXcollie dmsXcollie("DMS:GetDensityInCurResolution", XCOLLIE_TIMEOUT_10S); sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "GetDensityInCurResolution: Get ScreenSession failed"); + TLOGE(WmsLogTag::DMS, "Get ScreenSession failed"); return DMError::DM_ERROR_NULLPTR; } @@ -1243,14 +1244,14 @@ DMError ScreenSessionManager::GetDensityInCurResolution(ScreenId screenId, float DMError ScreenSessionManager::GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) { - TLOGI(WmsLogTag::DMS, "GetScreenColorGamut::ScreenId: %{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64 "", screenId); if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "GetScreenColorGamut screenId invalid"); + TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "GetScreenColorGamut: Get ScreenSession failed"); + TLOGE(WmsLogTag::DMS, "Get ScreenSession failed"); return DMError::DM_ERROR_INVALID_PARAM; } return screenSession->GetScreenColorGamut(colorGamut); @@ -1259,19 +1260,19 @@ DMError ScreenSessionManager::GetScreenColorGamut(ScreenId screenId, ScreenColor DMError ScreenSessionManager::SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::DMS, "set screen color gamut permission denied!"); + TLOGE(WmsLogTag::DMS, "permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } - TLOGI(WmsLogTag::DMS, "SetScreenColorGamut::ScreenId: %{public}" PRIu64 ", colorGamutIdx %{public}d", + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64 ", colorGamutIdx %{public}d", screenId, colorGamutIdx); if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "SetScreenColorGamut screenId invalid"); + TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "SetScreenColorGamut: Get ScreenSession failed"); + TLOGE(WmsLogTag::DMS, "Get ScreenSession failed"); return DMError::DM_ERROR_INVALID_PARAM; } return screenSession->SetScreenColorGamut(colorGamutIdx); @@ -1279,14 +1280,14 @@ DMError ScreenSessionManager::SetScreenColorGamut(ScreenId screenId, int32_t col DMError ScreenSessionManager::GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) { - TLOGI(WmsLogTag::DMS, "GetScreenGamutMap::ScreenId: %{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64 "", screenId); if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "GetScreenGamutMap screenId invalid"); + TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "GetScreenGamutMap: Get ScreenSession failed"); + TLOGE(WmsLogTag::DMS, "Get ScreenSession failed"); return DMError::DM_ERROR_INVALID_PARAM; } return screenSession->GetScreenGamutMap(gamutMap); @@ -1295,19 +1296,19 @@ DMError ScreenSessionManager::GetScreenGamutMap(ScreenId screenId, ScreenGamutMa DMError ScreenSessionManager::SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::DMS, "set screen gamut map permission denied!"); + TLOGE(WmsLogTag::DMS, "permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } - TLOGI(WmsLogTag::DMS, "SetScreenGamutMap::ScreenId: %{public}" PRIu64 ", ScreenGamutMap %{public}u", + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64 ", ScreenGamutMap %{public}u", screenId, static_cast(gamutMap)); if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "SetScreenGamutMap screenId invalid"); + TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "SetScreenGamutMap: Get ScreenSession failed"); + TLOGE(WmsLogTag::DMS, "Get ScreenSession failed"); return DMError::DM_ERROR_INVALID_PARAM; } return screenSession->SetScreenGamutMap(gamutMap); @@ -1316,18 +1317,18 @@ DMError ScreenSessionManager::SetScreenGamutMap(ScreenId screenId, ScreenGamutMa DMError ScreenSessionManager::SetScreenColorTransform(ScreenId screenId) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::DMS, "set Screen color transform permission denied!"); + TLOGE(WmsLogTag::DMS, "permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } - TLOGI(WmsLogTag::DMS, "SetScreenColorTransform::ScreenId: %{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64 "", screenId); if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "SetScreenColorTransform screenId invalid"); + TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "SetScreenColorTransform: Get ScreenSession failed"); + TLOGE(WmsLogTag::DMS, "Get ScreenSession failed"); return DMError::DM_ERROR_INVALID_PARAM; } return screenSession->SetScreenColorTransform(); @@ -1379,7 +1380,7 @@ sptr ScreenSessionManager::CreatePhysicalMirrorSessionInner(Scree sptr ScreenSessionManager::GetScreenSessionInner(ScreenId screenId, ScreenProperty property) { ScreenId defScreenId = GetDefaultScreenId(); - TLOGI(WmsLogTag::DMS, "GetScreenSessionInner: screenId:%{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "screenId:%{public}" PRIu64 "", screenId); if (IsDefaultMirrorMode(screenId)) { return CreatePhysicalMirrorSessionInner(screenId, defScreenId, property); } @@ -1471,8 +1472,9 @@ float ScreenSessionManager::CalcDefaultExtendScreenDensity(const ScreenProperty& int32_t width = phyBounds.rect_.GetWidth(); int32_t height = phyBounds.rect_.GetHeight(); float PPI = std::sqrt(static_cast(width * width + height * height)) * INCH_TO_MM / phyDiagonal; - float density = PPI * PHYSICAL_MASS / BASELINE_DENSITY; - TLOGI(WmsLogTag::DMS, "PPI:%{public}f", PPI); + float DPI = std::ceil(PPI * PHYSICAL_MASS); + TLOGI(WmsLogTag::DMS, "DPI:%{public}f", DPI); + float density = DPI / BASELINE_DENSITY; return density; } else { return densityDpi_; @@ -1481,7 +1483,7 @@ float ScreenSessionManager::CalcDefaultExtendScreenDensity(const ScreenProperty& sptr ScreenSessionManager::GetOrCreateScreenSession(ScreenId screenId) { - TLOGI(WmsLogTag::DMS, "GetOrCreateScreenSession ENTER. ScreenId: %{public}" PRIu64 "", screenId); + TLOGI(WmsLogTag::DMS, "ENTER. ScreenId: %{public}" PRIu64 "", screenId); sptr screenSession = GetScreenSession(screenId); if (screenSession) { TLOGI(WmsLogTag::DMS, "screenSession Exist ScreenId: %{public}" PRIu64 "", screenId); @@ -1557,7 +1559,7 @@ void ScreenSessionManager::SetHdrFormats(ScreenId screenId, sptr& void ScreenSessionManager::SetColorSpaces(ScreenId screenId, sptr& session) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::DMS, "set Screen color spaces permission denied!"); + TLOGE(WmsLogTag::DMS, "spaces permission denied!"); return; } @@ -1659,7 +1661,7 @@ bool ScreenSessionManager::SuspendEnd() SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); return false; } - TLOGI(WmsLogTag::DMS, "[UL_POWER]SuspendEnd enter"); + TLOGI(WmsLogTag::DMS, "[UL_POWER] enter"); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:SuspendEnd"); // 多屏协作灭屏不通知锁屏 if (isMultiScreenCollaboration_) { @@ -1689,6 +1691,30 @@ ScreenId ScreenSessionManager::GetInternalScreenId() return screenId; } +void ScreenSessionManager::GetInternalAndExternalSession(sptr& internalSession, + sptr& externalSession) +{ + std::lock_guard lock(screenSessionMapMutex_); + for (auto sessionIt : screenSessionMap_) { + auto screenSession = sessionIt.second; + if (screenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screenSession is nullptr!"); + continue; + } + if (!screenSession->GetIsCurrentInUse()) { + TLOGE(WmsLogTag::DMS, "screenSession not in use!"); + continue; + } + if (screenSession->GetScreenProperty().GetScreenType() == ScreenType::REAL && screenSession->isInternal_) { + TLOGI(WmsLogTag::DMS, "found internalSession, screenId = %{public}" PRIu64, sessionIt.first); + internalSession = screenSession; + } else { + TLOGI(WmsLogTag::DMS, "found externalSession, screenId = %{public}" PRIu64, sessionIt.first); + externalSession = screenSession; + } + } +} + bool ScreenSessionManager::SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) { @@ -1698,29 +1724,12 @@ bool ScreenSessionManager::SetScreenPowerById(ScreenId screenId, ScreenPowerStat return false; } - TLOGI(WmsLogTag::DMS, "[UL_POWER]SetScreenPowerById: screen id:%{public}" PRIu64 + TLOGI(WmsLogTag::DMS, "screen id:%{public}" PRIu64 ", state:%{public}u, reason:%{public}u", screenId, state, static_cast(reason)); sptr internalSession; sptr externalSession; - { - std::lock_guard lock(screenSessionMapMutex_); - for (auto sessionIt : screenSessionMap_) { - auto screenSession = sessionIt.second; - if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "screenSession is nullptr!"); - continue; - } - if (screenSession->GetScreenProperty().GetScreenType() == ScreenType::REAL && screenSession->isInternal_) { - TLOGI(WmsLogTag::DMS, "found internalSession, screenId = %{public}" PRIu64, sessionIt.first); - internalSession = screenSession; - } else { - TLOGI(WmsLogTag::DMS, "found externalSession, screenId = %{public}" PRIu64, sessionIt.first); - externalSession = screenSession; - } - } - } - + GetInternalAndExternalSession(internalSession, externalSession); ScreenPowerStatus status; switch (state) { case ScreenPowerState::POWER_ON: { @@ -1745,7 +1754,7 @@ bool ScreenSessionManager::SetScreenPowerById(ScreenId screenId, ScreenPowerStat return true; } -void ScreenSessionManager::SetMultiScreenStatus(sptr firstSession, sptr secondarySession) +void ScreenSessionManager::SetLastScreenMode(sptr firstSession, sptr secondarySession) { if (firstSession == nullptr || secondarySession == nullptr) { TLOGE(WmsLogTag::DMS, "first or second screen is null"); @@ -1753,7 +1762,7 @@ void ScreenSessionManager::SetMultiScreenStatus(sptr firstSession } ScreenId mainScreenId = SCREEN_ID_INVALID; - std::string status = SCREEN_UNKNOWN; + MultiScreenMode secondaryScreenMode = MultiScreenMode::SCREEN_MIRROR; { std::lock_guard lock(screenSessionMapMutex_); for (auto sessionIt : screenSessionMap_) { @@ -1762,31 +1771,34 @@ void ScreenSessionManager::SetMultiScreenStatus(sptr firstSession TLOGW(WmsLogTag::DMS, "screenSession is nullptr!"); continue; } - if (screenSession == firstSession || screenSession == secondarySession) { - ScreenCombination screenCombination = screenSession->GetScreenCombination(); - if (screenCombination == ScreenCombination::SCREEN_MAIN) { - mainScreenId = sessionIt.first; - TLOGI(WmsLogTag::DMS, "found main screen"); - } else if (screenCombination == ScreenCombination::SCREEN_MIRROR) { - status = SCREEN_MIRROR; - TLOGI(WmsLogTag::DMS, "found mirror screen"); - } else if (screenCombination == ScreenCombination::SCREEN_EXTEND) { - status = SCREEN_EXTEND; - TLOGI(WmsLogTag::DMS, "found extend screen"); - } else { - TLOGE(WmsLogTag::DMS, "screen id or status error"); - } + if (screenSession != firstSession && screenSession != secondarySession) { + continue; + } + if (!screenSession->GetIsCurrentInUse()) { + TLOGE(WmsLogTag::DMS, "screenSession not in use!"); + continue; + } + ScreenCombination screenCombination = screenSession->GetScreenCombination(); + if (screenCombination == ScreenCombination::SCREEN_MAIN) { + mainScreenId = sessionIt.first; + TLOGI(WmsLogTag::DMS, "found main screen"); + } else if (screenCombination == ScreenCombination::SCREEN_MIRROR) { + secondaryScreenMode = MultiScreenMode::SCREEN_MIRROR; + TLOGI(WmsLogTag::DMS, "found mirror screen"); + } else if (screenCombination == ScreenCombination::SCREEN_EXTEND) { + secondaryScreenMode = MultiScreenMode::SCREEN_EXTEND; + TLOGI(WmsLogTag::DMS, "found extend screen"); + } else { + TLOGE(WmsLogTag::DMS, "screen id or screen mode error"); } } } - if (mainScreenId != SCREEN_ID_INVALID && status != SCREEN_UNKNOWN) { - MultiScreenManager::GetInstance().SetMultiScreenStatus(mainScreenId, status); - TLOGI(WmsLogTag::DMS, "Set multi screen status done, mainScreenId = %{public}" PRIu64 - ", status = %{public}s", mainScreenId, status.c_str()); - } else { - TLOGE(WmsLogTag::DMS, "Set multi screen status failed!"); + if (mainScreenId == SCREEN_ID_INVALID) { + TLOGE(WmsLogTag::DMS, "param error!"); + return; } + MultiScreenManager::GetInstance().SetLastScreenMode(mainScreenId, secondaryScreenMode); } bool ScreenSessionManager::IsPreBrightAuthFail(void) @@ -1811,7 +1823,7 @@ bool ScreenSessionManager::SetDisplayState(DisplayState state) TLOGE(WmsLogTag::DMS, "[UL_POWER]sessionDisplayPowerController_ is null"); return false; } - TLOGI(WmsLogTag::DMS, "[UL_POWER]SetDisplayState enter"); + TLOGI(WmsLogTag::DMS, "[UL_POWER] enter"); auto screenIds = GetAllScreenIds(); if (screenIds.empty()) { TLOGI(WmsLogTag::DMS, "[UL_POWER]no screen info"); @@ -1833,7 +1845,7 @@ void ScreenSessionManager::UpdateDisplayState(std::vector screenIds, D for (auto screenId : screenIds) { sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGW(WmsLogTag::DMS, "[UL_POWER]SetDisplayState cannot get ScreenSession, screenId: %{public}" PRIu64"", + TLOGW(WmsLogTag::DMS, "[UL_POWER] cannot get ScreenSession, screenId: %{public}" PRIu64"", screenId); continue; } @@ -1897,7 +1909,7 @@ bool ScreenSessionManager::TryToCancelScreenOff() bool ScreenSessionManager::SetScreenBrightness(uint64_t screenId, uint32_t level) { - TLOGI(WmsLogTag::DMS, "SetScreenBrightness screenId:%{public}" PRIu64", level:%{public}u,", screenId, level); + TLOGI(WmsLogTag::DMS, "screenId:%{public}" PRIu64", level:%{public}u,", screenId, level); RSInterfaces::GetInstance().SetScreenBacklight(screenId, level); return true; } @@ -1905,7 +1917,7 @@ bool ScreenSessionManager::SetScreenBrightness(uint64_t screenId, uint32_t level uint32_t ScreenSessionManager::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, "screenId:%{public}" PRIu64", level:%{public}u,", screenId, level); return level; } @@ -1924,7 +1936,7 @@ int32_t ScreenSessionManager::SetScreenOffDelayTime(int32_t delay) } else { screenOffDelay_ = delay; } - TLOGI(WmsLogTag::DMS, "SetScreenOffDelayTime, delay:%{public}d, screenOffDelay_:%{public}d", + TLOGI(WmsLogTag::DMS, "delay:%{public}d, screenOffDelay_:%{public}d", delay, screenOffDelay_); return screenOffDelay_; } @@ -1957,7 +1969,7 @@ bool ScreenSessionManager::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowe SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); return false; } - TLOGI(WmsLogTag::DMS, "[UL_POWER]SetSpecifiedScreenPower: screen id:%{public}" PRIu64 ", state:%{public}u", + TLOGI(WmsLogTag::DMS, "screen id:%{public}" PRIu64 ", state:%{public}u", screenId, state); ScreenPowerStatus status; @@ -2000,7 +2012,7 @@ bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerSta } gotScreenOffNotify_ = false; keyguardDrawnDone_ = false; - TLOGI(WmsLogTag::DMS, "[UL_POWER]SetScreenPowerForAll keyguardDrawnDone_ is false"); + TLOGI(WmsLogTag::DMS, "keyguardDrawnDone_ is false"); prePowerStateChangeReason_ = reason; return SetScreenPower(status, reason); } @@ -2052,17 +2064,17 @@ void ScreenSessionManager::ExitCoordination(const std::string& reason) return; } if (foldScreenController_ != nullptr) { - TLOGI(WmsLogTag::DMS, "[UL_POWER]ExitCoordination, reason:%{public}s", reason.c_str()); + TLOGI(WmsLogTag::DMS, "[UL_POWER] reason:%{public}s", reason.c_str()); foldScreenController_->ExitCoordination(); } } bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateChangeReason reason) { - TLOGI(WmsLogTag::DMS, "[UL_POWER]SetScreenPower enter status:%{public}u", status); + TLOGI(WmsLogTag::DMS, "[UL_POWER] enter status:%{public}u", status); auto screenIds = GetAllScreenIds(); if (screenIds.empty()) { - TLOGI(WmsLogTag::DMS, "[UL_POWER]SetScreenPower screenIds empty"); + TLOGI(WmsLogTag::DMS, "[UL_POWER] screenIds empty"); return false; } @@ -2074,7 +2086,7 @@ bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateCh gotScreenlockFingerprint_ == true) && prePowerStateChangeReason_ != PowerStateChangeReason::STATE_CHANGE_REASON_SHUT_DOWN) { gotScreenlockFingerprint_ = false; - TLOGI(WmsLogTag::DMS, "[UL_POWER]SetScreenPower screenlockFingerprint or shutdown"); + TLOGI(WmsLogTag::DMS, "[UL_POWER] screenlockFingerprint or shutdown"); return NotifyDisplayPowerEvent(status == ScreenPowerStatus::POWER_STATUS_ON ? DisplayPowerEvent::DISPLAY_ON : DisplayPowerEvent::DISPLAY_OFF, EventStatus::END, reason); } @@ -2174,7 +2186,7 @@ void ScreenSessionManager::HandlerSensor(ScreenPowerStatus status, PowerStateCha void ScreenSessionManager::BootFinishedCallback(const char *key, const char *value, void *context) { if (strcmp(key, BOOTEVENT_BOOT_COMPLETED.c_str()) == 0 && strcmp(value, "true") == 0) { - TLOGI(WmsLogTag::DMS, "BootFinishedCallback boot animation finished"); + TLOGI(WmsLogTag::DMS, "boot animation finished"); auto &that = *reinterpret_cast(context); that.SetRotateLockedFromSettingData(); that.SetDpiFromSettingData(); @@ -2218,7 +2230,7 @@ void ScreenSessionManager::SetRotateLockedFromSettingData() void ScreenSessionManager::RegisterSettingDpiObserver() { - TLOGI(WmsLogTag::DMS, "Register Setting Dpi Observer"); + TLOGI(WmsLogTag::DMS, "start"); if (ScreenSceneConfig::GetExternalScreenDefaultMode() == "mirror") { SettingObserver::UpdateFunc updateFunc = [&](const std::string& key) { SetDpiFromSettingData(); }; ScreenSettingHelper::RegisterSettingDpiObserver(updateFunc); @@ -2230,7 +2242,7 @@ void ScreenSessionManager::RegisterSettingDpiObserver() void ScreenSessionManager::RegisterExtendSettingDpiObserver() { - TLOGI(WmsLogTag::DMS, "Register Extend Setting Dpi Observer"); + TLOGI(WmsLogTag::DMS, "start"); SettingObserver::UpdateFunc updateFunc = [&](const std::string& key) { SetDpiFromSettingData(false); }; ScreenSettingHelper::RegisterExtendSettingDpiObserver(updateFunc); } @@ -2306,7 +2318,7 @@ DisplayState ScreenSessionManager::GetDisplayState(DisplayId displayId) void ScreenSessionManager::NotifyDisplayEvent(DisplayEvent event) { - TLOGI(WmsLogTag::DMS, "[UL_POWER]NotifyDisplayEvent receive keyguardDrawnDone"); + TLOGI(WmsLogTag::DMS, "[UL_POWER] receive keyguardDrawnDone"); if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::DMS, "permission denied! calling clientName: %{public}s, calling pid: %{public}d", SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); @@ -2394,7 +2406,7 @@ DMError ScreenSessionManager::IsScreenRotationLocked(bool& isLocked) return DMError::DM_ERROR_INVALID_PARAM; } isLocked = screenSession->IsScreenRotationLocked(); - TLOGI(WmsLogTag::DMS, "IsScreenRotationLocked:isLocked: %{public}u", isLocked); + TLOGI(WmsLogTag::DMS, "isLocked: %{public}u", isLocked); return DMError::DM_OK; } @@ -2411,7 +2423,7 @@ DMError ScreenSessionManager::SetScreenRotationLocked(bool isLocked) return DMError::DM_ERROR_INVALID_PARAM; } screenSession->SetScreenRotationLocked(isLocked); - TLOGI(WmsLogTag::DMS, "SetScreenRotationLocked: isLocked: %{public}u", isLocked); + TLOGI(WmsLogTag::DMS, "isLocked: %{public}u", isLocked); return DMError::DM_OK; } @@ -2436,7 +2448,7 @@ void ScreenSessionManager::NotifyAndPublishEvent(sptr displayInfo, sptr screenSession) { if (displayInfo == nullptr || screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "NotifyAndPublishEvent error, displayInfo or screenSession is nullptr"); + TLOGE(WmsLogTag::DMS, "error, displayInfo or screenSession is nullptr"); return; } NotifyDisplayChanged(displayInfo, DisplayChangeEvent::UPDATE_ROTATION); @@ -2455,7 +2467,7 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const ScreenPropertyChangeType screenPropertyChangeType) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::DMS, "update screen rotation property permission denied!"); + TLOGE(WmsLogTag::DMS, "permission denied!"); return; } sptr screenSession = GetScreenSession(screenId); @@ -2472,7 +2484,7 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const return; } else if (screenPropertyChangeType == ScreenPropertyChangeType::ROTATION_UPDATE_PROPERTY_ONLY) { if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "fail to update screen rotation property, cannot find screen " + TLOGE(WmsLogTag::DMS, "fail, cannot find screen " "%{public}" PRIu64"", screenId); return; } @@ -2488,7 +2500,7 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const } } if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "fail to update screen rotation property, cannot find screen %{public}" PRIu64"", + TLOGE(WmsLogTag::DMS, "fail, cannot find screen %{public}" PRIu64"", screenId); return; } @@ -2504,7 +2516,7 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const void ScreenSessionManager::NotifyDisplayChanged(sptr displayInfo, DisplayChangeEvent event) { if (displayInfo == nullptr) { - TLOGE(WmsLogTag::DMS, "NotifyDisplayChanged error, displayInfo is nullptr."); + TLOGE(WmsLogTag::DMS, "error, displayInfo is nullptr."); return; } auto task = [=] { @@ -2517,7 +2529,7 @@ void ScreenSessionManager::NotifyDisplayChanged(sptr displayInfo, D } auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_EVENT_LISTENER); if (agents.empty()) { - TLOGI(WmsLogTag::DMS, "NotifyDisplayChanged agents is empty"); + TLOGI(WmsLogTag::DMS, "agents is empty"); return; } for (auto& agent : agents) { @@ -2538,13 +2550,13 @@ DMError ScreenSessionManager::SetOrientation(ScreenId screenId, Orientation orie return DMError::DM_ERROR_NOT_SYSTEM_APP; } if (orientation < Orientation::UNSPECIFIED || orientation > Orientation::REVERSE_HORIZONTAL) { - TLOGE(WmsLogTag::DMS, "set orientation: %{public}u", static_cast(orientation)); + TLOGE(WmsLogTag::DMS, "set: %{public}u", static_cast(orientation)); return DMError::DM_ERROR_INVALID_PARAM; } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:SetOrientation"); sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "fail to set orientation, cannot find screen %{public}" PRIu64"", screenId); + TLOGE(WmsLogTag::DMS, "fail, cannot find screen %{public}" PRIu64"", screenId); return DMError::DM_ERROR_NULLPTR; } // just for get orientation test @@ -2556,11 +2568,11 @@ DMError ScreenSessionManager::SetOrientation(ScreenId screenId, Orientation orie bool ScreenSessionManager::SetRotation(ScreenId screenId, Rotation rotationAfter, bool isFromWindow) { TLOGI(WmsLogTag::DMS, - "Enter SetRotation, screenId: %{public}" PRIu64 ", rotation: %{public}u, isFromWindow: %{public}u,", + "Enter, screenId: %{public}" PRIu64 ", rotation: %{public}u, isFromWindow: %{public}u,", screenId, rotationAfter, isFromWindow); sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "SetRotation error, cannot get screen with screenId: %{public}" PRIu64, screenId); + TLOGE(WmsLogTag::DMS, "error, cannot get screen with screenId: %{public}" PRIu64, screenId); return false; } if (rotationAfter == screenSession->GetRotation()) { @@ -2597,7 +2609,7 @@ void ScreenSessionManager::SetPostureAndHallSensorEnabled() } FoldScreenSensorManager::GetInstance().RegisterPostureCallback(); FoldScreenSensorManager::GetInstance().RegisterHallCallback(); - TLOGI(WmsLogTag::DMS, "subscribe Posture and Hall sensor successful"); + TLOGI(WmsLogTag::DMS, "successful"); #endif } @@ -2667,10 +2679,10 @@ bool ScreenSessionManager::NotifyDisplayPowerEvent(DisplayPowerEvent event, Even { auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER); if (agents.empty()) { - TLOGI(WmsLogTag::DMS, "[UL_POWER]NotifyDisplayPowerEvent agents is empty"); + TLOGI(WmsLogTag::DMS, "[UL_POWER] agents is empty"); return false; } - TLOGD(WmsLogTag::DMS, "[UL_POWER]NotifyDisplayPowerEvent"); + TLOGD(WmsLogTag::DMS, "[UL_POWER] start"); for (auto& agent : agents) { agent->NotifyDisplayPowerEvent(event, status); } @@ -2725,7 +2737,7 @@ DMError ScreenSessionManager::GetAllScreenInfos(std::vector>& s for (auto screenId : screenIds) { auto screenInfo = GetScreenInfoById(screenId); if (screenInfo == nullptr) { - TLOGE(WmsLogTag::DMS, "GetAllScreenInfos cannot find screenInfo: %{public}" PRIu64"", screenId); + TLOGE(WmsLogTag::DMS, "cannot find screenInfo: %{public}" PRIu64"", screenId); continue; } screenInfos.emplace_back(screenInfo); @@ -2746,7 +2758,7 @@ std::vector ScreenSessionManager::GetAllScreenIds() const DMError ScreenSessionManager::GetScreenSupportedColorGamuts(ScreenId screenId, std::vector& colorGamuts) { - TLOGI(WmsLogTag::DMS, "GetScreenSupportedColorGamuts ENTER"); + TLOGI(WmsLogTag::DMS, "ENTER"); if (!SessionPermission::IsSystemCalling()) { TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d", SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); @@ -2754,7 +2766,7 @@ DMError ScreenSessionManager::GetScreenSupportedColorGamuts(ScreenId screenId, } sptr screen = GetScreenSession(screenId); if (screen == nullptr) { - TLOGE(WmsLogTag::DMS, "GetScreenSupportedColorGamuts nullptr"); + TLOGE(WmsLogTag::DMS, "nullptr"); return DMError::DM_ERROR_INVALID_PARAM; } return screen->GetScreenSupportedColorGamuts(colorGamuts); @@ -2762,9 +2774,9 @@ DMError ScreenSessionManager::GetScreenSupportedColorGamuts(ScreenId screenId, DMError ScreenSessionManager::GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat) { - TLOGI(WmsLogTag::DMS, "GetPixelFormat::ScreenId: %{public}" PRIu64, screenId); + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64, screenId); if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "GetPixelFormat screenId invalid"); + TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screenSession = GetScreenSession(screenId); @@ -2777,14 +2789,14 @@ DMError ScreenSessionManager::GetPixelFormat(ScreenId screenId, GraphicPixelForm DMError ScreenSessionManager::SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::DMS, "set pixel format permission denied!"); + TLOGE(WmsLogTag::DMS, "permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } - TLOGI(WmsLogTag::DMS, "SetPixelFormat::ScreenId: %{public}" PRIu64 ", pixelFormat %{public}d", + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64 ", pixelFormat %{public}d", screenId, pixelFormat); if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "SetPixelFormat screenId invalid"); + TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screenSession = GetScreenSession(screenId); @@ -2797,14 +2809,14 @@ DMError ScreenSessionManager::SetPixelFormat(ScreenId screenId, GraphicPixelForm DMError ScreenSessionManager::GetSupportedHDRFormats(ScreenId screenId, std::vector& hdrFormats) { - TLOGI(WmsLogTag::DMS, "GetSupportedHDRFormats %{public}" PRIu64, screenId); + TLOGI(WmsLogTag::DMS, "start %{public}" PRIu64, screenId); if (screenId == SCREEN_ID_INVALID) { TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screen = GetScreenSession(screenId); if (screen == nullptr) { - TLOGE(WmsLogTag::DMS, "GetSupportedHDRFormats nullptr"); + TLOGE(WmsLogTag::DMS, "nullptr"); return DMError::DM_ERROR_INVALID_PARAM; } return screen->GetSupportedHDRFormats(hdrFormats); @@ -2812,7 +2824,7 @@ DMError ScreenSessionManager::GetSupportedHDRFormats(ScreenId screenId, DMError ScreenSessionManager::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat) { - TLOGI(WmsLogTag::DMS, "GetScreenHDRFormat::ScreenId: %{public}" PRIu64, screenId); + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64, screenId); if (screenId == SCREEN_ID_INVALID) { TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; @@ -2827,13 +2839,13 @@ DMError ScreenSessionManager::GetScreenHDRFormat(ScreenId screenId, ScreenHDRFor DMError ScreenSessionManager::SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::DMS, "set screen HDR format permission denied!"); + TLOGE(WmsLogTag::DMS, "permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } - TLOGI(WmsLogTag::DMS, "SetScreenHDRFormat::ScreenId: %{public}" PRIu64 ", modeIdx %{public}d", screenId, modeIdx); + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64 ", modeIdx %{public}d", screenId, modeIdx); if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "SetScreenHDRFormat screenId invalid"); + TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screenSession = GetScreenSession(screenId); @@ -2846,14 +2858,14 @@ DMError ScreenSessionManager::SetScreenHDRFormat(ScreenId screenId, int32_t mode DMError ScreenSessionManager::GetSupportedColorSpaces(ScreenId screenId, std::vector& colorSpaces) { - TLOGI(WmsLogTag::DMS, "GetSupportedColorSpaces %{public}" PRIu64, screenId); + TLOGI(WmsLogTag::DMS, "start %{public}" PRIu64, screenId); if (screenId == SCREEN_ID_INVALID) { TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screenSession = GetScreenSession(screenId); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "GetSupportedColorSpaces nullptr"); + TLOGE(WmsLogTag::DMS, "nullptr"); return DMError::DM_ERROR_INVALID_PARAM; } return screenSession->GetSupportedColorSpaces(colorSpaces); @@ -2861,7 +2873,7 @@ DMError ScreenSessionManager::GetSupportedColorSpaces(ScreenId screenId, DMError ScreenSessionManager::GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace) { - TLOGI(WmsLogTag::DMS, "GetScreenColorSpace::ScreenId: %{public}" PRIu64, screenId); + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64, screenId); if (screenId == SCREEN_ID_INVALID) { TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; @@ -2876,14 +2888,14 @@ DMError ScreenSessionManager::GetScreenColorSpace(ScreenId screenId, GraphicCM_C DMError ScreenSessionManager::SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::DMS, "set screen color space permission denied!"); + TLOGE(WmsLogTag::DMS, "permission denied!"); return DMError::DM_ERROR_NOT_SYSTEM_APP; } - TLOGI(WmsLogTag::DMS, "SetScreenColorSpace::ScreenId: %{public}" PRIu64 ", colorSpace %{public}d", + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64 ", colorSpace %{public}d", screenId, colorSpace); if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "SetScreenColorSpace screenId invalid"); + TLOGE(WmsLogTag::DMS, "screenId invalid"); return DMError::DM_ERROR_INVALID_PARAM; } sptr screenSession = GetScreenSession(screenId); @@ -3054,7 +3066,7 @@ DMError ScreenSessionManager::SetVirtualMirrorScreenCanvasRotation(ScreenId scre TLOGE(WmsLogTag::DMS, "failed in RenderService"); return DMError::DM_ERROR_RENDER_SERVICE_FAILED; } - TLOGI(WmsLogTag::DMS, "set virtual mirror screen canvas rotation success"); + TLOGI(WmsLogTag::DMS, "success"); return DMError::DM_OK; } @@ -3092,7 +3104,7 @@ DMError ScreenSessionManager::DestroyVirtualScreen(ScreenId screenId) return DMError::DM_ERROR_NOT_SYSTEM_APP; } // virtual screen destroy callback to notify scb - TLOGI(WmsLogTag::DMS, "destroy virtual screen"); + TLOGI(WmsLogTag::DMS, "start"); OnVirtualScreenChange(screenId, ScreenEvent::DISCONNECTED); ScreenId rsScreenId = SCREEN_ID_INVALID; { @@ -3130,7 +3142,7 @@ DMError ScreenSessionManager::DestroyVirtualScreen(ScreenId screenId) virtualScreenCount_ = virtualScreenCount_ > 0 ? virtualScreenCount_ - 1 : 0; NotifyCaptureStatusChanged(); if (rsScreenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "DestroyVirtualScreen: No corresponding rsScreenId"); + TLOGE(WmsLogTag::DMS, "No corresponding rsScreenId"); return DMError::DM_ERROR_INVALID_PARAM; } rsInterface_.RemoveVirtualScreen(rsScreenId); @@ -3139,13 +3151,13 @@ DMError ScreenSessionManager::DestroyVirtualScreen(ScreenId screenId) DMError ScreenSessionManager::DisableMirror(bool disableOrNot) { - TLOGI(WmsLogTag::DMS, "DisableMirror %{public}d", disableOrNot); + TLOGI(WmsLogTag::DMS, "start %{public}d", disableOrNot); if (!SessionPermission::IsSystemCalling()) { TLOGE(WmsLogTag::DMS, "Permission Denied! calling clientName: %{public}s, calling pid: %{public}d", SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); return DMError::DM_ERROR_NOT_SYSTEM_APP; } - TLOGI(WmsLogTag::DMS, "DisableMirror enter %{public}d", disableOrNot); + TLOGI(WmsLogTag::DMS, "enter %{public}d", disableOrNot); if (disableOrNot) { std::vector screenIds; auto allScreenIds = GetAllScreenIds(); @@ -3238,7 +3250,7 @@ void ScreenSessionManager::SetCastFromSettingData() void ScreenSessionManager::RegisterSettingRotationObserver() { - TLOGI(WmsLogTag::DMS, "Register setting rotation observer"); + TLOGI(WmsLogTag::DMS, "start"); SettingObserver::UpdateFunc updateFunc = [&](const std::string& key) { int32_t rotation = -1; int32_t screenId = -1; @@ -3262,14 +3274,14 @@ DMError ScreenSessionManager::StopMirror(const std::vector& mirrorScre } auto allMirrorScreenIds = GetAllValidScreenIds(mirrorScreenIds); if (allMirrorScreenIds.empty()) { - TLOGI(WmsLogTag::DMS, "StopMirror done. screens' size:%{public}u", + TLOGI(WmsLogTag::DMS, "done. screens' size:%{public}u", static_cast(allMirrorScreenIds.size())); return DMError::DM_OK; } DMError ret = StopScreens(allMirrorScreenIds, ScreenCombination::SCREEN_MIRROR); if (ret != DMError::DM_OK) { - TLOGE(WmsLogTag::DMS, "StopMirror failed."); + TLOGE(WmsLogTag::DMS, "failed."); return ret; } ScreenSettingHelper::UnregisterSettingCastObserver(); @@ -3280,25 +3292,25 @@ DMError ScreenSessionManager::StopMirror(const std::vector& mirrorScre DMError ScreenSessionManager::StopScreens(const std::vector& screenIds, ScreenCombination stopCombination) { for (ScreenId screenId : screenIds) { - TLOGI(WmsLogTag::DMS, "StopScreens ScreenId: %{public}" PRIu64"", screenId); + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64"", screenId); auto screen = GetScreenSession(screenId); if (screen == nullptr) { - TLOGW(WmsLogTag::DMS, "StopScreens screen:%{public}" PRIu64" is nullptr", screenId); + TLOGW(WmsLogTag::DMS, "screen:%{public}" PRIu64" is nullptr", screenId); continue; } sptr screenGroup = GetAbstractScreenGroup(screen->groupSmsId_); if (!screenGroup) { - TLOGW(WmsLogTag::DMS, "StopScreens groupDmsId:%{public}" PRIu64"is not in smsScreenGroupMap_", + TLOGW(WmsLogTag::DMS, "groupDmsId:%{public}" PRIu64"is not in smsScreenGroupMap_", screen->groupSmsId_); continue; } if (screenGroup->combination_ != stopCombination) { - TLOGW(WmsLogTag::DMS, "StopScreens try to stop screen in another combination"); + TLOGW(WmsLogTag::DMS, "try to stop screen in another combination"); continue; } if (screenGroup->combination_ == ScreenCombination::SCREEN_MIRROR && screen->screenId_ == screenGroup->mirrorScreenId_) { - TLOGW(WmsLogTag::DMS, "StopScreens try to stop main mirror screen"); + TLOGW(WmsLogTag::DMS, "try to stop main mirror screen"); continue; } bool res = RemoveChildFromGroup(screen, screenGroup); @@ -3318,7 +3330,7 @@ VirtualScreenFlag ScreenSessionManager::GetVirtualScreenFlag(ScreenId screenId) } auto screen = GetScreenSession(screenId); if (screen == nullptr) { - TLOGE(WmsLogTag::DMS, "get virtual screen flag screen session null"); + TLOGE(WmsLogTag::DMS, "screen session null"); return VirtualScreenFlag::DEFAULT; } return screen->GetVirtualScreenFlag(); @@ -3332,12 +3344,12 @@ DMError ScreenSessionManager::SetVirtualScreenFlag(ScreenId screenId, VirtualScr return DMError::DM_ERROR_NOT_SYSTEM_APP; } if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) { - TLOGE(WmsLogTag::DMS, "set virtual screen flag range error"); + TLOGE(WmsLogTag::DMS, "range error"); return DMError::DM_ERROR_INVALID_PARAM; } auto screen = GetScreenSession(screenId); if (screen == nullptr) { - TLOGE(WmsLogTag::DMS, "set virtual screen flag screen session null"); + TLOGE(WmsLogTag::DMS, "screen session null"); return DMError::DM_ERROR_INVALID_PARAM; } screen->SetVirtualScreenFlag(screenFlag); @@ -3351,7 +3363,7 @@ DMError ScreenSessionManager::SetVirtualScreenRefreshRate(ScreenId screenId, uin SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); return DMError::DM_ERROR_NOT_SYSTEM_APP; } - TLOGI(WmsLogTag::DMS, "SetVirtualScreenRefreshRate, screenId: %{public}" PRIu64", refreshInterval: %{public}u", + TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64", refreshInterval: %{public}u", screenId, refreshInterval); if (screenId == GetDefaultScreenId()) { TLOGE(WmsLogTag::DMS, @@ -3359,23 +3371,23 @@ DMError ScreenSessionManager::SetVirtualScreenRefreshRate(ScreenId screenId, uin return DMError::DM_ERROR_INVALID_PARAM; } if (refreshInterval == 0) { - TLOGE(WmsLogTag::DMS, "SetVirtualScreenRefreshRate, refresh interval is 0."); + TLOGE(WmsLogTag::DMS, "refresh interval is 0."); return DMError::DM_ERROR_INVALID_PARAM; } auto screenSession = GetScreenSession(screenId); auto defaultScreenSession = GetDefaultScreenSession(); if (screenSession == nullptr || defaultScreenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "SetVirtualScreenRefreshRate, screenSession is null."); + TLOGE(WmsLogTag::DMS, "screenSession is null."); return DMError::DM_ERROR_INVALID_PARAM; } ScreenId rsScreenId; if (!screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId)) { - TLOGE(WmsLogTag::DMS, "SetVirtualScreenRefreshRate, No corresponding rsId."); + TLOGE(WmsLogTag::DMS, "No corresponding rsId."); return DMError::DM_ERROR_INVALID_PARAM; } int32_t res = rsInterface_.SetScreenSkipFrameInterval(rsScreenId, refreshInterval); if (res != StatusCode::SUCCESS) { - TLOGE(WmsLogTag::DMS, "SetVirtualScreenRefreshRate, rsInterface error: %{public}d", res); + TLOGE(WmsLogTag::DMS, "rsInterface error: %{public}d", res); return DMError::DM_ERROR_INVALID_PARAM; } // when skipFrameInterval > 10 means the skipFrameInterval is the virtual screen refresh rate @@ -3403,7 +3415,7 @@ DMError ScreenSessionManager::VirtualScreenUniqueSwitch(const std::vector screenId, std::vector startPoint, ScreenId& screenGroupId) { - TLOGI(WmsLogTag::DMS, "MakeExpand enter!"); + TLOGI(WmsLogTag::DMS, "enter!"); if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::DMS, "MakeExpand permission denied! pid: %{public}d", IPCSkeleton::GetCallingPid()); + TLOGE(WmsLogTag::DMS, "permission denied! pid: %{public}d", IPCSkeleton::GetCallingPid()); return DMError::DM_ERROR_NOT_SYSTEM_APP; } if (screenId.empty() || startPoint.empty() || screenId.size() != startPoint.size()) { @@ -3512,10 +3524,10 @@ DMError ScreenSessionManager::MakeExpand(std::vector screenId, bool ScreenSessionManager::OnMakeExpand(std::vector screenId, std::vector startPoint) { ScreenId defaultScreenId = GetDefaultScreenId(); - TLOGI(WmsLogTag::DMS, "OnMakeExpand, defaultScreenId:%{public}" PRIu64"", defaultScreenId); + TLOGI(WmsLogTag::DMS, "defaultScreenId:%{public}" PRIu64"", defaultScreenId); auto defaultScreen = GetScreenSession(defaultScreenId); if (defaultScreen == nullptr) { - TLOGI(WmsLogTag::DMS, "OnMakeExpand failed."); + TLOGI(WmsLogTag::DMS, "failed."); return false; } auto group = GetAbstractScreenGroup(defaultScreen->groupSmsId_); @@ -3529,7 +3541,7 @@ bool ScreenSessionManager::OnMakeExpand(std::vector screenId, std::vec } bool filterExpandScreen = group->combination_ == ScreenCombination::SCREEN_EXPAND; ChangeScreenGroup(group, screenId, startPoint, filterExpandScreen, ScreenCombination::SCREEN_EXPAND); - TLOGI(WmsLogTag::DMS, "OnMakeExpand success"); + TLOGI(WmsLogTag::DMS, "success"); return true; } @@ -3542,14 +3554,14 @@ DMError ScreenSessionManager::StopExpand(const std::vector& expandScre } auto allExpandScreenIds = GetAllValidScreenIds(expandScreenIds); if (allExpandScreenIds.empty()) { - TLOGI(WmsLogTag::DMS, "StopExpand done. screens' size:%{public}u", + TLOGI(WmsLogTag::DMS, "done. screens' size:%{public}u", static_cast(allExpandScreenIds.size())); return DMError::DM_OK; } DMError ret = StopScreens(allExpandScreenIds, ScreenCombination::SCREEN_EXPAND); if (ret != DMError::DM_OK) { - TLOGE(WmsLogTag::DMS, "StopExpand stop expand failed."); + TLOGE(WmsLogTag::DMS, "stop expand failed."); return ret; } @@ -3596,16 +3608,16 @@ ScreenId ScreenSessionManager::ScreenIdManager::CreateAndGetNewScreenId(ScreenId { std::unique_lock lock(screenIdMapMutex_); ScreenId smsScreenId = smsScreenCount_++; - TLOGI(WmsLogTag::DMS, "CreateAndGetNewScreenId screenId: %{public}" PRIu64"", smsScreenId); + TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64"", smsScreenId); if (sms2RsScreenIdMap_.find(smsScreenId) != sms2RsScreenIdMap_.end()) { - TLOGW(WmsLogTag::DMS, "CreateAndGetNewScreenId screenId: %{public}" PRIu64" exit", smsScreenId); + TLOGW(WmsLogTag::DMS, "screenId: %{public}" PRIu64" exit", smsScreenId); } sms2RsScreenIdMap_[smsScreenId] = rsScreenId; if (rsScreenId == SCREEN_ID_INVALID) { return smsScreenId; } if (rs2SmsScreenIdMap_.find(rsScreenId) != rs2SmsScreenIdMap_.end()) { - TLOGW(WmsLogTag::DMS, "CreateAndGetNewScreenId rsScreenId: %{public}" PRIu64" exit", rsScreenId); + TLOGW(WmsLogTag::DMS, "rsScreenId: %{public}" PRIu64" exit", rsScreenId); } rs2SmsScreenIdMap_[rsScreenId] = smsScreenId; return smsScreenId; @@ -3640,7 +3652,7 @@ bool ScreenSessionManager::ScreenIdManager::HasRsScreenId(ScreenId smsScreenId) sptr ScreenSessionManager::InitVirtualScreen(ScreenId smsScreenId, ScreenId rsId, VirtualScreenOption option) { - TLOGI(WmsLogTag::DMS, "InitVirtualScreen: Enter"); + TLOGI(WmsLogTag::DMS, "Enter"); ScreenSessionConfig config = { .screenId = smsScreenId, .rsId = rsId, @@ -3651,7 +3663,7 @@ sptr ScreenSessionManager::InitVirtualScreen(ScreenId smsScreenId new(std::nothrow) ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); sptr info = new(std::nothrow) SupportedScreenModes(); if (screenSession == nullptr || info == nullptr) { - TLOGI(WmsLogTag::DMS, "InitVirtualScreen: new screenSession or info failed"); + TLOGI(WmsLogTag::DMS, "new screenSession or info failed"); screenIdManager_.DeleteScreenId(smsScreenId); rsInterface_.RemoveVirtualScreen(rsId); return nullptr; @@ -3722,16 +3734,16 @@ sptr ScreenSessionManager::InitAndGetScreen(ScreenId rsScreenId) sptr screenSession = new(std::nothrow) ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "InitAndGetScreen: screenSession == nullptr."); + TLOGE(WmsLogTag::DMS, "screenSession == nullptr."); screenIdManager_.DeleteScreenId(smsScreenId); return nullptr; } if (!InitAbstractScreenModesInfo(screenSession)) { screenIdManager_.DeleteScreenId(smsScreenId); - TLOGE(WmsLogTag::DMS, "InitAndGetScreen: InitAndGetScreen failed."); + TLOGE(WmsLogTag::DMS, "failed."); return nullptr; } - TLOGI(WmsLogTag::DMS, "InitAndGetScreen: screenSessionMap_ add screenId=%{public}" PRIu64"", smsScreenId); + TLOGI(WmsLogTag::DMS, "screenSessionMap_ add screenId=%{public}" PRIu64"", smsScreenId); screenSessionMap_.insert(std::make_pair(smsScreenId, screenSession)); return screenSession; } @@ -3822,7 +3834,7 @@ sptr ScreenSessionManager::AddAsSuccedentScreenLocked(sptr ScreenSessionManager::RemoveFromGroupLocked(sptr screen) { - TLOGI(WmsLogTag::DMS, "RemoveFromGroupLocked."); + TLOGI(WmsLogTag::DMS, "start"); auto groupSmsId = screen->groupSmsId_; sptr screenGroup = GetAbstractScreenGroup(groupSmsId); if (!screenGroup) { @@ -3861,10 +3873,10 @@ bool ScreenSessionManager::RemoveChildFromGroup(sptr screen, sptr DMError ScreenSessionManager::SetMirror(ScreenId screenId, std::vector screens) { - TLOGI(WmsLogTag::DMS, "SetMirror, screenId:%{public}" PRIu64"", screenId); + TLOGI(WmsLogTag::DMS, "screenId:%{public}" PRIu64"", screenId); sptr screen = GetScreenSession(screenId); if (screen == nullptr || screen->GetScreenProperty().GetScreenType() != ScreenType::REAL) { - TLOGE(WmsLogTag::DMS, "SetMirror screen is nullptr, or screenType is not real."); + TLOGE(WmsLogTag::DMS, "screen is nullptr, or screenType is not real."); return DMError::DM_ERROR_NULLPTR; } screen->groupSmsId_ = 1; @@ -3872,7 +3884,7 @@ DMError ScreenSessionManager::SetMirror(ScreenId screenId, std::vector if (group == nullptr) { group = AddToGroupLocked(screen); if (group == nullptr) { - TLOGE(WmsLogTag::DMS, "SetMirror group is nullptr"); + TLOGE(WmsLogTag::DMS, "group is nullptr"); return DMError::DM_ERROR_NULLPTR; } NotifyScreenGroupChanged(screen->ConvertToScreenInfo(), ScreenGroupChangeEvent::ADD_TO_GROUP); @@ -3884,7 +3896,7 @@ DMError ScreenSessionManager::SetMirror(ScreenId screenId, std::vector group->combination_ == ScreenCombination::SCREEN_MIRROR && group->mirrorScreenId_ == screen->screenId_; group->mirrorScreenId_ = screen->screenId_; ChangeScreenGroup(group, screens, startPoints, filterMirroredScreen, ScreenCombination::SCREEN_MIRROR); - TLOGI(WmsLogTag::DMS, "SetMirror success"); + TLOGI(WmsLogTag::DMS, "success"); return DMError::DM_OK; } @@ -3924,13 +3936,13 @@ void ScreenSessionManager::ChangeScreenGroup(sptr group, con std::vector addChildPos; for (uint64_t i = 0; i != screens.size(); i++) { ScreenId screenId = screens[i]; - TLOGI(WmsLogTag::DMS, "ChangeScreenGroup ScreenId: %{public}" PRIu64"", screenId); + TLOGI(WmsLogTag::DMS, "ScreenId: %{public}" PRIu64"", screenId); auto screen = GetScreenSession(screenId); if (screen == nullptr) { - TLOGE(WmsLogTag::DMS, "ChangeScreenGroup screen:%{public}" PRIu64" is nullptr", screenId); + TLOGE(WmsLogTag::DMS, "screen:%{public}" PRIu64" is nullptr", screenId); continue; } - TLOGI(WmsLogTag::DMS, "ChangeScreenGroup Screen->groupSmsId_: %{public}" PRIu64"", screen->groupSmsId_); + TLOGI(WmsLogTag::DMS, "Screen->groupSmsId_: %{public}" PRIu64"", screen->groupSmsId_); screen->groupSmsId_ = 1; if (filterScreen && screen->groupSmsId_ == group->screenId_ && group->HasChild(screen->screenId_)) { continue; @@ -3961,7 +3973,7 @@ void ScreenSessionManager::AddScreenToGroup(sptr group, continue; } Point expandPoint = addChildPos[i]; - TLOGI(WmsLogTag::DMS, "AddScreenToGroup screenId: %{public}" PRIu64", Point: %{public}d, %{public}d", + TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64", Point: %{public}d, %{public}d", screen->screenId_, expandPoint.posX_, expandPoint.posY_); bool addChildRes = group->AddChild(screen, expandPoint, GetScreenSession(GetDefaultScreenId())); if (removeChildResMap[screenId] && addChildRes) { @@ -3986,7 +3998,7 @@ void ScreenSessionManager::AddScreenToGroup(sptr group, void ScreenSessionManager::RemoveVirtualScreenFromGroup(std::vector screens) { - TLOGI(WmsLogTag::DMS, "RemoveVirtualScreenFromGroup enter!"); + TLOGI(WmsLogTag::DMS, "enter!"); if (!SessionPermission::IsSystemCalling()) { TLOGE(WmsLogTag::DMS, "permission denied calling clientName: %{public}s, calling pid: %{public}d", SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); @@ -4019,14 +4031,14 @@ const std::shared_ptr ScreenSessionManager::GetRSDisplayNodeByScr static std::shared_ptr notFound = nullptr; sptr screen = GetScreenSession(smsScreenId); if (screen == nullptr) { - TLOGE(WmsLogTag::DMS, "GetRSDisplayNodeByScreenId screen == nullptr!"); + TLOGE(WmsLogTag::DMS, "screen == nullptr!"); return notFound; } if (screen->GetDisplayNode() == nullptr) { - TLOGE(WmsLogTag::DMS, "GetRSDisplayNodeByScreenId displayNode_ == nullptr!"); + TLOGE(WmsLogTag::DMS, "displayNode_ == nullptr!"); return notFound; } - TLOGI(WmsLogTag::DMS, "GetRSDisplayNodeByScreenId: screen: %{public}" PRIu64", nodeId: %{public}" PRIu64" ", + TLOGI(WmsLogTag::DMS, "screen: %{public}" PRIu64", nodeId: %{public}" PRIu64" ", screen->screenId_, screen->GetDisplayNode()->GetId()); return screen->GetDisplayNode(); } @@ -4040,15 +4052,15 @@ std::shared_ptr ScreenSessionManager::GetScreenSnapshot(Display for (auto sessionIt : screenSessionMap_) { auto screenSession = sessionIt.second; if (screenSession == nullptr) { - TLOGE(WmsLogTag::DMS, "GetScreenSnapshot screenSession is nullptr!"); + TLOGE(WmsLogTag::DMS, "screenSession is nullptr!"); continue; } sptr displayInfo = screenSession->ConvertToDisplayInfo(); if (displayInfo == nullptr) { - TLOGE(WmsLogTag::DMS, "GetScreenSnapshot displayInfo is nullptr!"); + TLOGE(WmsLogTag::DMS, "displayInfo is nullptr!"); continue; } - TLOGI(WmsLogTag::DMS, "GetScreenSnapshot: displayId %{public}" PRIu64"", displayInfo->GetDisplayId()); + TLOGI(WmsLogTag::DMS, "displayId %{public}" PRIu64"", displayInfo->GetDisplayId()); if (displayId == displayInfo->GetDisplayId()) { displayNode = screenSession->GetDisplayNode(); screenId = sessionIt.first; @@ -4057,17 +4069,17 @@ std::shared_ptr ScreenSessionManager::GetScreenSnapshot(Display } } if (screenId == SCREEN_ID_INVALID) { - TLOGE(WmsLogTag::DMS, "GetScreenSnapshot screenId == SCREEN_ID_INVALID!"); + TLOGE(WmsLogTag::DMS, "screenId == SCREEN_ID_INVALID!"); return nullptr; } if (displayNode == nullptr) { - TLOGE(WmsLogTag::DMS, "GetScreenSnapshot displayNode == nullptr!"); + TLOGE(WmsLogTag::DMS, "displayNode == nullptr!"); return nullptr; } std::shared_ptr callback = std::make_shared(); bool ret = rsInterface_.TakeSurfaceCapture(displayNode, callback); if (!ret) { - TLOGE(WmsLogTag::DMS, "GetScreenSnapshot TakeSurfaceCapture failed"); + TLOGE(WmsLogTag::DMS, "TakeSurfaceCapture failed"); return nullptr; } std::shared_ptr screenshot = callback->GetResult(2000); // wait for <= 2000ms @@ -4225,7 +4237,7 @@ sptr ScreenSessionManager::GetScreenGroupInfoById(ScreenId scre } auto screenSessionGroup = GetAbstractScreenGroup(screenId); if (screenSessionGroup == nullptr) { - TLOGE(WmsLogTag::DMS, "GetScreenGroupInfoById cannot find screenGroupInfo: %{public}" PRIu64"", screenId); + TLOGE(WmsLogTag::DMS, "cannot find screenGroupInfo: %{public}" PRIu64"", screenId); return nullptr; } return screenSessionGroup->ConvertToScreenGroupInfo(); @@ -4234,11 +4246,11 @@ sptr ScreenSessionManager::GetScreenGroupInfoById(ScreenId scre void ScreenSessionManager::NotifyScreenConnected(sptr screenInfo) { if (screenInfo == nullptr) { - TLOGE(WmsLogTag::DMS, "NotifyScreenConnected error, screenInfo is nullptr."); + TLOGE(WmsLogTag::DMS, "error, screenInfo is nullptr."); return; } auto task = [=] { - TLOGI(WmsLogTag::DMS, "NotifyScreenConnected, screenId:%{public}" PRIu64"", screenInfo->GetScreenId()); + TLOGI(WmsLogTag::DMS, "screenId:%{public}" PRIu64"", screenInfo->GetScreenId()); OnScreenConnect(screenInfo); }; taskScheduler_->PostAsyncTask(task, "NotifyScreenConnected"); @@ -4262,7 +4274,7 @@ void ScreenSessionManager::NotifyDisplayCreate(sptr displayInfo) if (agents.empty()) { return; } - TLOGI(WmsLogTag::DMS, "NotifyDisplayCreate"); + TLOGI(WmsLogTag::DMS, "start"); for (auto& agent : agents) { int32_t agentPid = dmAgentContainer_.GetAgentPid(agent); if (!IsFreezed(agentPid, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER)) { @@ -4277,7 +4289,7 @@ void ScreenSessionManager::NotifyDisplayDestroy(DisplayId displayId) if (agents.empty()) { return; } - TLOGI(WmsLogTag::DMS, "NotifyDisplayDestroy"); + TLOGI(WmsLogTag::DMS, "start"); for (auto& agent : agents) { int32_t agentPid = dmAgentContainer_.GetAgentPid(agent); if (!IsFreezed(agentPid, DisplayManagerAgentType::DISPLAY_EVENT_LISTENER)) { @@ -4340,7 +4352,7 @@ void ScreenSessionManager::SetScreenPrivacyState(bool hasPrivate) SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); return; } - TLOGI(WmsLogTag::DMS, "SetScreenPrivacyState enter, hasPrivate: %{public}d", hasPrivate); + TLOGI(WmsLogTag::DMS, "enter, hasPrivate: %{public}d", hasPrivate); ScreenId id = GetDefaultScreenId(); auto screenSession = GetScreenSession(id); if (screenSession == nullptr) { @@ -4358,11 +4370,11 @@ void ScreenSessionManager::SetPrivacyStateByDisplayId(DisplayId id, bool hasPriv SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); return; } - TLOGI(WmsLogTag::DMS, "SetPrivacyStateByDisplayId enter, hasPrivate: %{public}d", hasPrivate); + TLOGI(WmsLogTag::DMS, "enter, hasPrivate: %{public}d", hasPrivate); std::vector screenIds = GetAllScreenIds(); auto iter = std::find(screenIds.begin(), screenIds.end(), id); if (iter == screenIds.end()) { - TLOGE(WmsLogTag::DMS, "SetPrivacyStateByDisplayId invalid displayId"); + TLOGE(WmsLogTag::DMS, "invalid displayId"); return; } auto screenSession = GetScreenSession(id); @@ -4381,11 +4393,11 @@ void ScreenSessionManager::SetScreenPrivacyWindowList(DisplayId id, std::vector< SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); return; } - TLOGI(WmsLogTag::DMS, "SetScreenPrivacyWindowList enter"); + TLOGI(WmsLogTag::DMS, "enter"); std::vector screenIds = GetAllScreenIds(); auto iter = std::find(screenIds.begin(), screenIds.end(), id); if (iter == screenIds.end()) { - TLOGE(WmsLogTag::DMS, "SetScreenPrivacyWindowList invalid displayId"); + TLOGE(WmsLogTag::DMS, "invalid displayId"); return; } auto screenSession = GetScreenSession(id); @@ -4418,7 +4430,7 @@ DMError ScreenSessionManager::HasPrivateWindow(DisplayId id, bool& hasPrivateWin std::vector screenIds = GetAllScreenIds(); auto iter = std::find(screenIds.begin(), screenIds.end(), id); if (iter == screenIds.end()) { - TLOGE(WmsLogTag::DMS, "HasPrivateWindow invalid displayId"); + TLOGE(WmsLogTag::DMS, "invalid displayId"); return DMError::DM_ERROR_INVALID_PARAM; } auto screenSession = GetScreenSession(id); @@ -4463,15 +4475,15 @@ void ScreenSessionManager::OnScreenGroupChange(const std::string& trigger, void ScreenSessionManager::OnScreenConnect(const sptr screenInfo) { if (screenInfo == nullptr) { - TLOGE(WmsLogTag::DMS, "OnScreenConnect screenInfo nullptr"); + TLOGE(WmsLogTag::DMS, "screenInfo nullptr"); return; } auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER); if (agents.empty()) { - TLOGI(WmsLogTag::DMS, "OnScreenConnect agents empty"); + TLOGI(WmsLogTag::DMS, "agents empty"); return; } - TLOGI(WmsLogTag::DMS, "OnScreenConnect"); + TLOGI(WmsLogTag::DMS, "start"); for (auto& agent : agents) { agent->OnScreenConnect(screenInfo); } @@ -4481,10 +4493,10 @@ void ScreenSessionManager::OnScreenDisconnect(ScreenId screenId) { auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREEN_EVENT_LISTENER); if (agents.empty()) { - TLOGI(WmsLogTag::DMS, "OnScreenDisconnect agents empty"); + TLOGI(WmsLogTag::DMS, "agents empty"); return; } - TLOGI(WmsLogTag::DMS, "OnScreenDisconnect"); + TLOGI(WmsLogTag::DMS, "start"); for (auto& agent : agents) { agent->OnScreenDisconnect(screenId); } @@ -4493,7 +4505,7 @@ void ScreenSessionManager::OnScreenDisconnect(ScreenId screenId) void ScreenSessionManager::OnScreenshot(sptr info) { if (info == nullptr) { - TLOGE(WmsLogTag::DMS, "OnScreenshot info is null"); + TLOGE(WmsLogTag::DMS, "info is null"); return; } auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER); @@ -4501,7 +4513,7 @@ void ScreenSessionManager::OnScreenshot(sptr info) TLOGD(WmsLogTag::DMS, "agents empty"); return; } - TLOGI(WmsLogTag::DMS, "onScreenshot"); + TLOGI(WmsLogTag::DMS, "start"); for (auto& agent : agents) { agent->OnScreenshot(info); } @@ -4662,11 +4674,11 @@ void ScreenSessionManager::SetFoldDisplayMode(const FoldDisplayMode displayMode) return; } if (foldScreenController_ == nullptr) { - TLOGI(WmsLogTag::DMS, "SetFoldDisplayMode foldScreenController_ is null"); + TLOGI(WmsLogTag::DMS, "foldScreenController_ is null"); return; } if (!SessionPermission::IsSystemCalling()) { - TLOGE(WmsLogTag::DMS, "SetFoldDisplayMode permission denied!"); + TLOGE(WmsLogTag::DMS, "permission denied!"); return; } foldScreenController_->SetDisplayMode(displayMode); @@ -4847,7 +4859,7 @@ void ScreenSessionManager::SetFoldStatusLocked(bool locked) return; } if (foldScreenController_ == nullptr) { - TLOGI(WmsLogTag::DMS, "SetFoldStatusLocked foldScreenController_ is null"); + TLOGI(WmsLogTag::DMS, "foldScreenController_ is null"); return; } if (!SessionPermission::IsSystemCalling()) { @@ -4876,7 +4888,7 @@ FoldDisplayMode ScreenSessionManager::GetFoldDisplayMode() return FoldDisplayMode::UNKNOWN; } if (foldScreenController_ == nullptr) { - TLOGD(WmsLogTag::DMS, "GetFoldDisplayMode foldScreenController_ is null"); + TLOGD(WmsLogTag::DMS, "foldScreenController_ is null"); return FoldDisplayMode::UNKNOWN; } return foldScreenController_->GetDisplayMode(); @@ -4954,7 +4966,7 @@ uint32_t ScreenSessionManager::GetCurvedCompressionArea() void ScreenSessionManager::NotifyFoldStatusChanged(FoldStatus foldStatus) { - TLOGI(WmsLogTag::DMS, "NotifyFoldStatusChanged foldStatus:%{public}d", foldStatus); + TLOGI(WmsLogTag::DMS, "foldStatus:%{public}d", foldStatus); sptr screenSession = GetDefaultScreenSession(); if (screenSession != nullptr) { if (foldStatus == FoldStatus::FOLDED) { @@ -4977,7 +4989,7 @@ void ScreenSessionManager::NotifyFoldStatusChanged(FoldStatus foldStatus) } auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::FOLD_STATUS_CHANGED_LISTENER); if (agents.empty()) { - TLOGI(WmsLogTag::DMS, "NotifyFoldStatusChanged agents is empty"); + TLOGI(WmsLogTag::DMS, "agents is empty"); return; } for (auto& agent : agents) { @@ -4992,7 +5004,7 @@ void ScreenSessionManager::NotifyFoldAngleChanged(std::vector foldAngles) { auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::FOLD_ANGLE_CHANGED_LISTENER); if (agents.empty()) { - TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged agents is empty"); + TLOGI(WmsLogTag::DMS, "agents is empty"); return; } { @@ -5067,7 +5079,7 @@ void ScreenSessionManager::SetDisplayNodeScreenId(ScreenId screenId, ScreenId di screenId, displayNodeScreenId); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:SetDisplayNodeScreenId"); if (!clientProxy_) { - TLOGI(WmsLogTag::DMS, "SetDisplayNodeScreenId clientProxy_ is null"); + TLOGI(WmsLogTag::DMS, "clientProxy_ is null"); return; } clientProxy_->SetDisplayNodeScreenId(screenId, displayNodeScreenId); @@ -5091,7 +5103,7 @@ void ScreenSessionManager::OnPropertyChange(const ScreenProperty& newProperty, S { TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " reason: %{public}d", screenId, static_cast(reason)); if (!clientProxy_) { - TLOGI(WmsLogTag::DMS, "OnPropertyChange clientProxy_ is null"); + TLOGI(WmsLogTag::DMS, "clientProxy_ is null"); return; } clientProxy_->OnPropertyChanged(screenId, newProperty, reason); @@ -5104,7 +5116,7 @@ void ScreenSessionManager::OnPowerStatusChange(DisplayPowerEvent event, EventSta static_cast(event), static_cast(status), static_cast(reason)); if (!clientProxy_) { - TLOGI(WmsLogTag::DMS, "[UL_POWER]OnPowerStatusChange clientProxy_ is null"); + TLOGI(WmsLogTag::DMS, "[UL_POWER] clientProxy_ is null"); return; } clientProxy_->OnPowerStatusChanged(event, status, reason); @@ -5114,7 +5126,7 @@ void ScreenSessionManager::OnSensorRotationChange(float sensorRotation, ScreenId { TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " sensorRotation: %{public}f", screenId, sensorRotation); if (!clientProxy_) { - TLOGI(WmsLogTag::DMS, "OnSensorRotationChange clientProxy_ is null"); + TLOGI(WmsLogTag::DMS, "clientProxy_ is null"); return; } clientProxy_->OnSensorRotationChanged(screenId, sensorRotation); @@ -5124,7 +5136,7 @@ void ScreenSessionManager::OnHoverStatusChange(int32_t hoverStatus, ScreenId scr { TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64 " hoverStatus: %{public}d", screenId, hoverStatus); if (!clientProxy_) { - TLOGI(WmsLogTag::DMS, "OnHoverStatusChange clientProxy_ is null"); + TLOGI(WmsLogTag::DMS, "clientProxy_ is null"); return; } clientProxy_->OnHoverStatusChanged(screenId, hoverStatus); @@ -5153,7 +5165,7 @@ void ScreenSessionManager::OnScreenRotationLockedChange(bool isLocked, ScreenId void ScreenSessionManager::NotifyClientProxyUpdateFoldDisplayMode(FoldDisplayMode displayMode) { if (clientProxy_) { - TLOGI(WmsLogTag::DMS, "NotifyClientProxyUpdateFoldDisplayMode displayMode = %{public}d", + TLOGI(WmsLogTag::DMS, "displayMode = %{public}d", static_cast(displayMode)); clientProxy_->OnUpdateFoldDisplayMode(displayMode); } @@ -5390,7 +5402,7 @@ ScreenProperty ScreenSessionManager::GetScreenProperty(ScreenId screenId) DmsXcollie dmsXcollie("DMS:GetScreenProperty", XCOLLIE_TIMEOUT_10S); auto screenSession = GetScreenSession(screenId); if (!screenSession) { - TLOGI(WmsLogTag::DMS, "GetScreenProperty screenSession is null"); + TLOGI(WmsLogTag::DMS, "screenSession is null"); return {}; } return screenSession->GetScreenProperty(); @@ -5401,7 +5413,7 @@ std::shared_ptr ScreenSessionManager::GetDisplayNode(ScreenId scr DmsXcollie dmsXcollie("DMS:GetDisplayNode", XCOLLIE_TIMEOUT_10S); auto screenSession = GetScreenSession(screenId); if (!screenSession) { - TLOGE(WmsLogTag::DMS, "GetDisplayNode screenSession is null"); + TLOGE(WmsLogTag::DMS, "screenSession is null"); return nullptr; } return screenSession->GetDisplayNode(); @@ -5425,7 +5437,7 @@ int ScreenSessionManager::Dump(int fd, const std::vector& args) int ScreenSessionManager::NotifyFoldStatusChanged(const std::string& statusParam) { - TLOGI(WmsLogTag::DMS, "NotifyFoldStatusChanged is dump log"); + TLOGI(WmsLogTag::DMS, "is dump log"); if (statusParam.empty()) { return -1; } @@ -5441,7 +5453,7 @@ int ScreenSessionManager::NotifyFoldStatusChanged(const std::string& statusParam foldStatus = FoldStatus::FOLDED; displayMode = FoldDisplayMode::MAIN; } else { - TLOGW(WmsLogTag::DMS, "NotifyFoldStatusChanged status not support"); + TLOGW(WmsLogTag::DMS, "status not support"); return -1; } SetFoldDisplayMode(displayMode); @@ -5454,10 +5466,10 @@ int ScreenSessionManager::NotifyFoldStatusChanged(const std::string& statusParam void ScreenSessionManager::NotifyAvailableAreaChanged(DMRect area) { - TLOGI(WmsLogTag::DMS, "NotifyAvailableAreaChanged call"); + TLOGI(WmsLogTag::DMS, "call"); auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::AVAILABLE_AREA_CHANGED_LISTENER); if (agents.empty()) { - TLOGI(WmsLogTag::DMS, "NotifyAvailableAreaChanged agents is empty"); + TLOGI(WmsLogTag::DMS, "agents is empty"); return; } for (auto& agent : agents) { @@ -5978,4 +5990,57 @@ DMError ScreenSessionManager::SetVirtualScreenMaxRefreshRate(ScreenId id, uint32 screenSession->UpdateRefreshRate(actualRefreshRate); return DMError::DM_OK; } + +void ScreenSessionManager::OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) +{ + if (!clientProxy_) { + TLOGI(WmsLogTag::DMS, "clientProxy_ is null"); + return; + } + clientProxy_->ScreenCaptureNotify(mainScreenId, uid, clientName); +} + +std::shared_ptr ScreenSessionManager::GetScreenCapture(const CaptureOption& captureOption, + DmErrorCode* errorCode) +{ + TLOGI(WmsLogTag::DMS, "enter!"); + if (errorCode == nullptr) { + TLOGE(WmsLogTag::DMS, "param is null."); + return nullptr; + } + if (system::GetBoolParameter("persist.edm.disallow_screenshot", false)) { + TLOGW(WmsLogTag::DMS, "capture disabled by edm!"); + *errorCode = DmErrorCode::DM_ERROR_NO_PERMISSION; + return nullptr; + } + if (!Permission::CheckCallingPermission(CUSTOM_SCREEN_CAPTURE_PERMISSION) && !SessionPermission::IsShellCall()) { + TLOGE(WmsLogTag::DMS, "Permission Denied! clientName: %{public}s, pid: %{public}d.", + SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingRealPid()); + *errorCode = DmErrorCode::DM_ERROR_NO_PERMISSION; + return nullptr; + } + if (captureOption.displayId_ == DISPLAY_ID_INVALID) { + TLOGE(WmsLogTag::DMS, "display id invalid."); + *errorCode = DmErrorCode::DM_ERROR_INVALID_PARAM; + return nullptr; + } + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetScreenCapture(%" PRIu64")", captureOption.displayId_); + auto res = GetScreenSnapshot(captureOption.displayId_); + if (res == nullptr) { + TLOGE(WmsLogTag::DMS, "get capture null."); + *errorCode = DmErrorCode::DM_ERROR_SYSTEM_INNORMAL; + return nullptr; + } + NotifyScreenshot(captureOption.displayId_); + if (SessionPermission::IsBetaVersion()) { + CheckAndSendHiSysEvent("GET_DISPLAY_SNAPSHOT", "hmos.screenshot"); + } + *errorCode = DmErrorCode::DM_OK; + isScreenShot_ = true; + /* notify scb to do toast */ + OnScreenCaptureNotify(GetDefaultScreenId(), IPCSkeleton::GetCallingUid(), SysCapUtil::GetClientName()); + /* notify application capture happend */ + NotifyCaptureStatusChanged(); + return res; +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/screen_session_manager/src/screen_session_manager_lite.cpp b/window_scene/screen_session_manager/src/screen_session_manager_lite.cpp index 7b42aecc21..ae7ba3fe4d 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager_lite.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager_lite.cpp @@ -26,7 +26,7 @@ std::recursive_mutex g_instanceMutex; ScreenSessionManagerLite::~ScreenSessionManagerLite() { - TLOGD(WmsLogTag::DMS, "ScreenSessionManagerLite destroy"); + TLOGD(WmsLogTag::DMS, "destroy"); std::lock_guard lock(mutex_); destroyed_ = true; } diff --git a/window_scene/screen_session_manager/src/screen_setting_helper.cpp b/window_scene/screen_session_manager/src/screen_setting_helper.cpp index 26f7c71bde..5213242063 100644 --- a/window_scene/screen_session_manager/src/screen_setting_helper.cpp +++ b/window_scene/screen_session_manager/src/screen_setting_helper.cpp @@ -35,14 +35,14 @@ constexpr int32_t RESOLVED_DATA_INDEX_TWO = 2; void ScreenSettingHelper::RegisterSettingDpiObserver(SettingObserver::UpdateFunc func) { if (dpiObserver_) { - TLOGD(WmsLogTag::DMS, "setting dpi observer is already registered"); + TLOGD(WmsLogTag::DMS, "setting dpi observer is registered"); return; } SettingProvider& provider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); dpiObserver_ = provider.CreateObserver(SETTING_DPI_KEY, func); ErrCode ret = provider.RegisterObserver(dpiObserver_); if (ret != ERR_OK) { - TLOGW(WmsLogTag::DMS, "register setting dpi observer failed, ret=%{public}d", ret); + TLOGW(WmsLogTag::DMS, "failed, ret=%{public}d", ret); dpiObserver_ = nullptr; } } @@ -50,14 +50,14 @@ void ScreenSettingHelper::RegisterSettingDpiObserver(SettingObserver::UpdateFunc void ScreenSettingHelper::RegisterExtendSettingDpiObserver(SettingObserver::UpdateFunc func) { if (extendDpiObserver_) { - TLOGD(WmsLogTag::DMS, "setting extend dpi observer is already registered"); + TLOGD(WmsLogTag::DMS, "setting extend dpi observer is registered"); return; } SettingProvider& provider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); extendDpiObserver_ = provider.CreateObserver(SETTING_DPI_KEY_EXTEND, func); ErrCode ret = provider.RegisterObserver(extendDpiObserver_); if (ret != ERR_OK) { - TLOGW(WmsLogTag::DMS, "register extend setting dpi observer failed, ret=%{public}d", ret); + TLOGW(WmsLogTag::DMS, "failed, ret=%{public}d", ret); extendDpiObserver_ = nullptr; } } @@ -65,13 +65,13 @@ void ScreenSettingHelper::RegisterExtendSettingDpiObserver(SettingObserver::Upda void ScreenSettingHelper::UnregisterSettingDpiObserver() { if (dpiObserver_ == nullptr) { - TLOGD(WmsLogTag::DMS, "dpiObserver_ is nullptr, no need to unregister"); + TLOGD(WmsLogTag::DMS, "dpiObserver_ is nullptr"); return; } SettingProvider& provider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); ErrCode ret = provider.UnregisterObserver(dpiObserver_); if (ret != ERR_OK) { - TLOGW(WmsLogTag::DMS, "unregister setting dpi observer failed, ret=%{public}d", ret); + TLOGW(WmsLogTag::DMS, "failed, ret=%{public}d", ret); } dpiObserver_ = nullptr; } @@ -79,13 +79,13 @@ void ScreenSettingHelper::UnregisterSettingDpiObserver() void ScreenSettingHelper::UnregisterExtendSettingDpiObserver() { if (extendDpiObserver_ == nullptr) { - TLOGD(WmsLogTag::DMS, "extendDpiObserver_ is nullptr, no need to unregister"); + TLOGD(WmsLogTag::DMS, "extendDpiObserver_ is nullptr"); return; } SettingProvider& provider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); ErrCode ret = provider.UnregisterObserver(extendDpiObserver_); if (ret != ERR_OK) { - TLOGW(WmsLogTag::DMS, "unregister extend setting dpi observer failed, ret=%{public}d", ret); + TLOGW(WmsLogTag::DMS, "failed, ret=%{public}d", ret); } extendDpiObserver_ = nullptr; } @@ -101,7 +101,7 @@ bool ScreenSettingHelper::GetSettingValue(uint32_t& value, const std::string& ke int32_t getValue; ErrCode ret = settingData.GetIntValue(key, getValue); if (ret != ERR_OK) { - TLOGW(WmsLogTag::DMS, "get setting value failed, ret=%{public}d", ret); + TLOGW(WmsLogTag::DMS, "failed, ret=%{public}d", ret); return false; } value = static_cast(getValue); @@ -122,14 +122,14 @@ bool ScreenSettingHelper::SetSettingDefaultDpi(uint32_t& dpi, const std::string& void ScreenSettingHelper::RegisterSettingCastObserver(SettingObserver::UpdateFunc func) { if (castObserver_) { - TLOGD(WmsLogTag::DMS, "setting cast observer is already registered"); + TLOGD(WmsLogTag::DMS, "setting cast observer is registered"); return; } SettingProvider& castProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); castObserver_ = castProvider.CreateObserver(SETTING_CAST_KEY, func); ErrCode ret = castProvider.RegisterObserver(castObserver_); if (ret != ERR_OK) { - TLOGW(WmsLogTag::DMS, "register setting cast observer failed, ret=%{public}d", ret); + TLOGW(WmsLogTag::DMS, "failed, ret=%{public}d", ret); castObserver_ = nullptr; } } @@ -137,13 +137,13 @@ void ScreenSettingHelper::RegisterSettingCastObserver(SettingObserver::UpdateFun void ScreenSettingHelper::UnregisterSettingCastObserver() { if (castObserver_ == nullptr) { - TLOGD(WmsLogTag::DMS, "castObserver_ is nullptr, no need to unregister"); + TLOGD(WmsLogTag::DMS, "castObserver_ is nullptr"); return; } SettingProvider& castProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); ErrCode ret = castProvider.UnregisterObserver(castObserver_); if (ret != ERR_OK) { - TLOGW(WmsLogTag::DMS, "unregister setting cast observer failed, ret=%{public}d", ret); + TLOGW(WmsLogTag::DMS, "failed, ret=%{public}d", ret); } castObserver_ = nullptr; } @@ -153,7 +153,7 @@ bool ScreenSettingHelper::GetSettingCast(bool& enable, const std::string& key) SettingProvider& castProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); ErrCode ret = castProvider.GetBoolValue(key, enable); if (ret != ERR_OK) { - TLOGW(WmsLogTag::DMS, "get setting dpi failed, ret=%{public}d", ret); + TLOGW(WmsLogTag::DMS, "failed, ret=%{public}d", ret); return false; } return true; @@ -162,14 +162,14 @@ bool ScreenSettingHelper::GetSettingCast(bool& enable, const std::string& key) void ScreenSettingHelper::RegisterSettingRotationObserver(SettingObserver::UpdateFunc func) { if (rotationObserver_ != nullptr) { - TLOGI(WmsLogTag::DMS, "setting rotation observer is already registered"); + TLOGI(WmsLogTag::DMS, "setting rotation observer is registered"); return; } SettingProvider& settingProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); rotationObserver_ = settingProvider.CreateObserver(SETTING_ROTATION_KEY, func); ErrCode ret = settingProvider.RegisterObserver(rotationObserver_); if (ret != ERR_OK) { - TLOGE(WmsLogTag::DMS, "register setting rotation observer failed, ret:%{public}d", ret); + TLOGE(WmsLogTag::DMS, "failed, ret:%{public}d", ret); rotationObserver_ = nullptr; } } @@ -177,13 +177,13 @@ void ScreenSettingHelper::RegisterSettingRotationObserver(SettingObserver::Updat void ScreenSettingHelper::UnregisterSettingRotationObserver() { if (rotationObserver_ == nullptr) { - TLOGI(WmsLogTag::DMS, "rotationObserver_ is nullptr, no need to unregister"); + TLOGI(WmsLogTag::DMS, "rotationObserver_ is nullptr"); return; } SettingProvider& settingProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); ErrCode ret = settingProvider.UnregisterObserver(rotationObserver_); if (ret != ERR_OK) { - TLOGE(WmsLogTag::DMS, "unregister setting rotation observer failed, ret:%{public}d", ret); + TLOGE(WmsLogTag::DMS, "failed, ret:%{public}d", ret); } rotationObserver_ = nullptr; } @@ -193,10 +193,10 @@ void ScreenSettingHelper::SetSettingRotation(int32_t rotation) SettingProvider& settingProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); ErrCode ret = settingProvider.PutIntValue(SETTING_ROTATION_KEY, rotation, true); if (ret != ERR_OK) { - TLOGE(WmsLogTag::DMS, "set setting rotation failed, ret:%{public}d", ret); + TLOGE(WmsLogTag::DMS, "failed, ret:%{public}d", ret); return; } - TLOGE(WmsLogTag::DMS, "set setting rotation succeed, ret:%{public}d", ret); + TLOGE(WmsLogTag::DMS, "succeed, ret:%{public}d", ret); } bool ScreenSettingHelper::GetSettingRotation(int32_t& rotation, const std::string& key) @@ -204,7 +204,7 @@ bool ScreenSettingHelper::GetSettingRotation(int32_t& rotation, const std::strin SettingProvider& settingProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); ErrCode ret = settingProvider.GetIntValue(key, rotation); if (ret != ERR_OK) { - TLOGE(WmsLogTag::DMS, "get setting rotation failed, ret:%{public}d", ret); + TLOGE(WmsLogTag::DMS, "failed, ret:%{public}d", ret); return false; } TLOGE(WmsLogTag::DMS, "current rotation:%{public}d", rotation); @@ -216,10 +216,10 @@ void ScreenSettingHelper::SetSettingRotationScreenId(int32_t screenId) SettingProvider& settingProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); ErrCode ret = settingProvider.PutIntValue(SETTING_ROTATION_SCREEN_ID_KEY, screenId, false); if (ret != ERR_OK) { - TLOGE(WmsLogTag::DMS, "set setting rotation screen id failed, ret:%{public}d", ret); + TLOGE(WmsLogTag::DMS, "failed, ret:%{public}d", ret); return; } - TLOGE(WmsLogTag::DMS, "set setting rotation screen id succeed, ret:%{public}d", ret); + TLOGE(WmsLogTag::DMS, "ssucceed, ret:%{public}d", ret); } bool ScreenSettingHelper::GetSettingRotationScreenID(int32_t& screenId, const std::string& key) @@ -227,7 +227,7 @@ bool ScreenSettingHelper::GetSettingRotationScreenID(int32_t& screenId, const st SettingProvider& settingProvider = SettingProvider::GetInstance(DISPLAY_MANAGER_SERVICE_SA_ID); ErrCode ret = settingProvider.GetIntValue(key, screenId); if (ret != ERR_OK) { - TLOGE(WmsLogTag::DMS, "get setting rotation screen id failed, ret:%{public}d", ret); + TLOGE(WmsLogTag::DMS, "failed, ret:%{public}d", ret); return false; } TLOGE(WmsLogTag::DMS, "current rotation screen id:%{public}d", screenId); diff --git a/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp index 558b331684..7e81949b60 100644 --- a/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -609,7 +609,7 @@ DMError ScreenSessionManagerProxy::RegisterDisplayManagerAgent(const sptrAsObject())) { WLOGFE("Write IDisplayManagerAgent failed"); return DMError::DM_ERROR_IPC_FAILED; @@ -3050,6 +3050,7 @@ void OHOS::Rosen::ScreenSessionManagerProxy::UpdateDisplayHookInfo(int32_t uid, return; } } + DMError ScreenSessionManagerProxy::SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, std::vector& windowIdList) { @@ -3191,4 +3192,41 @@ DMError ScreenSessionManagerProxy::SetVirtualScreenMaxRefreshRate(ScreenId id, u actualRefreshRate = reply.ReadUint32(); return static_cast(reply.ReadInt32()); } + +std::shared_ptr ScreenSessionManagerProxy::GetScreenCapture(const CaptureOption& captureOption, + DmErrorCode* errorCode) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return nullptr; + } + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return nullptr; + } + if (!data.WriteUint64(captureOption.displayId_) || + !data.WriteBool(captureOption.isNeedNotify_) || !data.WriteBool(captureOption.isNeedPointer_)) { + WLOGFE("Write displayId or isNeedNotify or isNeedPointer failed"); + return nullptr; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_CAPTURE), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return nullptr; + } + std::shared_ptr pixelMap(reply.ReadParcelable()); + DmErrorCode replyErrorCode = static_cast(reply.ReadInt32()); + if (errorCode) { + *errorCode = replyErrorCode; + } + if (pixelMap == nullptr) { + WLOGFE("Send pixelMap nullptr."); + return nullptr; + } + return pixelMap; +} } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp b/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp index 8af81b19ef..0f314c3942 100644 --- a/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp +++ b/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp @@ -864,6 +864,10 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& reply.WriteInt32(static_cast(ret)); break; } + case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_CAPTURE: { + ProcGetScreenCapture(data, reply); + break; + } default: WLOGFW("unknown transaction code"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -964,4 +968,16 @@ void ScreenSessionManagerStub::ProcSetVirtualScreenSecurityExemption(MessageParc DMError ret = SetVirtualScreenSecurityExemption(screenId, pid, windowIdList); static_cast(reply.WriteInt32(static_cast(ret))); } + +void ScreenSessionManagerStub::ProcGetScreenCapture(MessageParcel& data, MessageParcel& reply) +{ + CaptureOption option; + option.displayId_ = static_cast(data.ReadUint64()); + option.isNeedNotify_ = static_cast(data.ReadBool()); + option.isNeedPointer_ = static_cast(data.ReadBool()); + DmErrorCode errCode = DmErrorCode::DM_OK; + std::shared_ptr capture = GetScreenCapture(option, &errCode); + reply.WriteParcelable(capture == nullptr ? nullptr : capture.get()); + static_cast(reply.WriteInt32(static_cast(errCode))); +} } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h index 0fddbccc4c..8679ea6c30 100644 --- a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h +++ b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h @@ -105,6 +105,7 @@ private: void OnScreenExtendChanged(ScreenId mainScreenId, ScreenId extendScreenId) override; void SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId) override; + void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override; mutable std::mutex screenSessionMapMutex_; std::map> screenSessionMap_; diff --git a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h index 3e84d0936b..db26baf4b7 100644 --- a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h +++ b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_interface.h @@ -45,6 +45,7 @@ public: TRANS_ID_ON_FOLDSTATUS_CHANGED_REPORT_UE, TRANS_ID_ON_SCREEN_EXTEND_CHANGED, TRANS_ID_ON_HOVER_STATUS_CHANGED, + TRANS_ID_ON_SCREEN_CAPTURE_NOTIFY, }; virtual void SwitchUserCallback(std::vector oldScbPids, int32_t currentScbPid) = 0; @@ -70,6 +71,7 @@ public: virtual void OnUpdateFoldDisplayMode(FoldDisplayMode displayMode) = 0; virtual void SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) = 0; virtual void OnFoldStatusChangedReportUE(const std::vector& screenFoldInfo) = 0; + virtual void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) = 0; }; } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h index beecf6ef61..7ab1d2d31a 100644 --- a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h +++ b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_proxy.h @@ -49,6 +49,7 @@ public: void OnUpdateFoldDisplayMode(FoldDisplayMode displayMode) override; void SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) override; void OnFoldStatusChangedReportUE(const std::vector& screenFoldInfo) override; + void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override; private: static inline BrokerDelegator delegator_; diff --git a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h index ba7ad146d9..77b88ae0a7 100644 --- a/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h +++ b/window_scene/screen_session_manager_client/include/zidl/screen_session_manager_client_stub.h @@ -25,12 +25,15 @@ namespace OHOS::Rosen { class ScreenSessionManagerClientStub : public IRemoteStub { public: - ScreenSessionManagerClientStub() = default; + ScreenSessionManagerClientStub(); virtual ~ScreenSessionManagerClientStub() = default; int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; private: + using HandleScreenChange = std::function; + using HandleScreenChangeMap = std::map; + void InitScreenChangeMap(); int HandleOnScreenConnectionChanged(MessageParcel& data, MessageParcel& reply); int HandleOnPropertyChanged(MessageParcel& data, MessageParcel& reply); int HandleOnPowerStatusChanged(MessageParcel& data, MessageParcel& reply); @@ -48,6 +51,9 @@ private: int HandleOnFoldStatusChangedReportUE(MessageParcel& data, MessageParcel& reply); int HandleOnScreenExtendChanged(MessageParcel& data, MessageParcel& reply); int HandleOnHoverStatusChanged(MessageParcel& data, MessageParcel& reply); + int HandleScreenCaptureNotify(MessageParcel& data, MessageParcel& reply); + + HandleScreenChangeMap HandleScreenChangeMap_ {}; }; } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp b/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp index 149fa3fb80..b102b64a65 100644 --- a/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp +++ b/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp @@ -591,4 +591,15 @@ void ScreenSessionManagerClient::UpdateDisplayScale(ScreenId id, float scaleX, f } session->SetScreenScale(scaleX, scaleY, pivotX, pivotY, translateX, translateY); } + +void ScreenSessionManagerClient::ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) +{ + sptr screenSession = GetScreenSession(mainScreenId); + if (!screenSession) { + WLOGFE("screen session is null"); + return; + } + WLOGFI("capture screenId: %{public}" PRIu64", uid=%{public}d", mainScreenId, uid); + screenSession->ScreenCaptureNotify(mainScreenId, uid, clientName); +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp index 6584879391..527d8149b4 100644 --- a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp +++ b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_proxy.cpp @@ -575,4 +575,31 @@ void ScreenSessionManagerClientProxy::OnFoldStatusChangedReportUE(const std::vec return; } } + +void ScreenSessionManagerClientProxy::ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, + const std::string& clientName) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGE("remote is nullptr"); + return; + } + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return; + } + if (!data.WriteUint64(mainScreenId) || !data.WriteInt32(uid) || !data.WriteString(clientName)) { + WLOGFE("Write screenId or uid or client failed"); + return; + } + if (remote->SendRequest( + static_cast(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CAPTURE_NOTIFY), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return; + } +} } // namespace OHOS::Rosen diff --git a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp index ef988c66e4..d35c6fe9c6 100644 --- a/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp +++ b/window_scene/screen_session_manager_client/src/zidl/screen_session_manager_client_stub.cpp @@ -20,75 +20,111 @@ namespace OHOS::Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenSessionManagerClientStub" }; -} // namespace +} // namespace + +void ScreenSessionManagerClientStub::InitScreenChangeMap() +{ + if (HandleScreenChangeMap_.size() != 0) { + WLOGFI("screen change map has init!"); + return; + } + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CONNECTION_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnScreenConnectionChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_PROPERTY_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnPropertyChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_POWER_STATUS_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnPowerStatusChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_EXTEND_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnScreenExtendChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_SENSOR_ROTATION_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnSensorRotationChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_HOVER_STATUS_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnHoverStatusChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_ORIENTATION_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnScreenOrientationChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_ROTATION_LOCKED_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnScreenRotationLockedChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_DISPLAY_STATE_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnDisplayStateChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_SHOT] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnScreenshot(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_IMMERSIVE_STATE_CHANGED] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnImmersiveStateChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_SET_DISPLAY_NODE_SCREEN_ID] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnSetDisplayNodeScreenId(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_GET_SURFACENODEID_FROM_MISSIONID] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnGetSurfaceNodeIdsFromMissionIdsChanged(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_SET_FOLD_DISPLAY_MODE] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnUpdateFoldDisplayMode(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_SWITCH_USER_CMD] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleSwitchUserCallback(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleSetVirtualPixelRatioSystem(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_FOLDSTATUS_CHANGED_REPORT_UE] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleOnFoldStatusChangedReportUE(data, reply); + }; + HandleScreenChangeMap_[ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CAPTURE_NOTIFY] = + [this](MessageParcel& data, MessageParcel& reply) { + return HandleScreenCaptureNotify(data, reply); + }; +} + +ScreenSessionManagerClientStub::ScreenSessionManagerClientStub() +{ + InitScreenChangeMap(); +} int ScreenSessionManagerClientStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { + int handleRet = ERR_INVALID_STATE; if (data.ReadInterfaceToken() != GetDescriptor()) { WLOGFE("Failed to check interface token!"); - return ERR_INVALID_STATE; + return handleRet; } ScreenSessionManagerClientMessage msgId = static_cast(code); - switch (msgId) { - case ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CONNECTION_CHANGED: { - return HandleOnScreenConnectionChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_PROPERTY_CHANGED: { - return HandleOnPropertyChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_POWER_STATUS_CHANGED: { - return HandleOnPowerStatusChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_EXTEND_CHANGED: { - return HandleOnScreenExtendChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_SENSOR_ROTATION_CHANGED: { - return HandleOnSensorRotationChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_HOVER_STATUS_CHANGED: { - return HandleOnHoverStatusChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_ORIENTATION_CHANGED: { - return HandleOnScreenOrientationChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_ROTATION_LOCKED_CHANGED: { - return HandleOnScreenRotationLockedChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_DISPLAY_STATE_CHANGED: { - return HandleOnDisplayStateChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_SHOT: { - return HandleOnScreenshot(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_IMMERSIVE_STATE_CHANGED: { - return HandleOnImmersiveStateChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_SET_DISPLAY_NODE_SCREEN_ID: { - return HandleOnSetDisplayNodeScreenId(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_GET_SURFACENODEID_FROM_MISSIONID: { - return HandleOnGetSurfaceNodeIdsFromMissionIdsChanged(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_SET_FOLD_DISPLAY_MODE: { - return HandleOnUpdateFoldDisplayMode(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_SWITCH_USER_CMD: { - return HandleSwitchUserCallback(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_SET_VIRTUAL_PIXEL_RATIO_SYSTEM: { - return HandleSetVirtualPixelRatioSystem(data, reply); - } - case ScreenSessionManagerClientMessage::TRANS_ID_ON_FOLDSTATUS_CHANGED_REPORT_UE: { - return HandleOnFoldStatusChangedReportUE(data, reply); - } - default: { - WLOGFE("Failed to find function handler!"); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } + auto handleCall = HandleScreenChangeMap_.find(msgId); + if (handleCall != HandleScreenChangeMap_.end() && handleCall->second != nullptr) { + auto handleFunc = handleCall->second; + handleRet = handleFunc(data, reply); + } else { + WLOGFE("Failed to find function handler!"); + handleRet = IPCObjectStub::OnRemoteRequest(code, data, reply, option); } - - return 0; + return handleRet; } int ScreenSessionManagerClientStub::HandleSwitchUserCallback(MessageParcel& data, MessageParcel& reply) @@ -269,4 +305,14 @@ int ScreenSessionManagerClientStub::HandleOnHoverStatusChanged(MessageParcel& da OnHoverStatusChanged(screenId, hoverStatus); return ERR_NONE; } + +int ScreenSessionManagerClientStub::HandleScreenCaptureNotify(MessageParcel& data, MessageParcel& reply) +{ + auto screenId = static_cast(data.ReadUint64()); + auto uid = data.ReadInt32(); + auto clientName = data.ReadString(); + WLOGI("notify scb capture screenId=%{public}" PRIu64", uid=%{public}d.", screenId, uid); + ScreenCaptureNotify(screenId, uid, clientName); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index 15c9e6ccd8..ca2d179e79 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -206,6 +206,8 @@ public: return WSError::WS_OK; } virtual WSError SetSplitButtonVisible(bool isVisible) = 0; + + virtual WSError SetEnableDragBySystem(bool dragEnable) = 0; }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 0648e5d473..ffe6d7b914 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -62,6 +62,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_NOTIFY_DUMP_INFO, TRANS_ID_SET_SPLIT_BUTTON_VISIBLE, TRANS_ID_NOTIFY_COMPATIBLE_MODE_ENABLE, + TRANS_ID_SET_ENABLE_DRAG_BY_SYSTEM, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index 1be3d64d1a..c748d9f665 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -75,6 +75,7 @@ public: void NotifySessionFullScreen(bool fullScreen) override; WSError NotifyDumpInfo(const std::vector& params, std::vector& info) override; WSError SetSplitButtonVisible(bool isVisible) override; + WSError SetEnableDragBySystem(bool dragEnable) override; private: bool ReadSmallStringVectorFromParcel( diff --git a/window_scene/session/container/include/zidl/session_stage_stub.h b/window_scene/session/container/include/zidl/session_stage_stub.h index a1ada4a34b..d7cb13ceea 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -80,6 +80,7 @@ private: const std::vector& infos, MessageParcel& reply); int HandleNotifyDumpInfo(MessageParcel& data, MessageParcel& reply); int HandleSetSplitButtonVisible(MessageParcel& data, MessageParcel& reply); + int HandleSetEnableDragBySystem(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index 082e772d45..5de0d10e12 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -28,7 +28,7 @@ namespace OHOS::Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionStageProxy"}; -constexpr int32_t MAX_INFOS_SIZE = 50; +constexpr int32_t MAX_INFO_SIZE = 50; constexpr size_t MAX_PARCEL_CAPACITY = 100 * 1024 * 1024; // 100M bool CopyBufferFromRawData(void *&buffer, size_t size, const void *data) @@ -1226,7 +1226,7 @@ void SessionStageProxy::SetUniqueVirtualPixelRatio(bool useUniqueDensity, float bool SessionStageProxy::ReadSmallStringVectorFromParcel( MessageParcel& reply, std::vector& infos) { - TLOGD(WmsLogTag::WMS_UIEXT, "ReadSmallStringVectorFromParcel entry"); + TLOGD(WmsLogTag::WMS_UIEXT, "entry"); if (!reply.ReadStringVector(&infos)) { TLOGE(WmsLogTag::WMS_UIEXT, "Read string vector failed"); return false; @@ -1238,7 +1238,6 @@ bool SessionStageProxy::ReadSmallStringVectorFromParcel( bool SessionStageProxy::ReadBigStringVectorFromParcel( MessageParcel& reply, std::vector& infos) { - TLOGD(WmsLogTag::WMS_UIEXT, "ReadBigStringVectorFromParcel entry"); int32_t dataSizeInt = 0; if (!reply.ReadInt32(dataSizeInt) || dataSizeInt == 0) { TLOGE(WmsLogTag::WMS_UIEXT, "Read dataSize failed"); @@ -1264,9 +1263,8 @@ bool SessionStageProxy::ReadBigStringVectorFromParcel( return false; } - TLOGD(WmsLogTag::WMS_UIEXT, "ReadBigStringVectorFromParcel dataSize: %{public}zu," - " infoSize: %{public}d", dataSize, infoSize); - if (infoSize >= MAX_INFOS_SIZE) { + TLOGD(WmsLogTag::WMS_UIEXT, "dataSize: %{public}zu, infoSize: %{public}d", dataSize, infoSize); + if (infoSize >= MAX_INFO_SIZE) { TLOGE(WmsLogTag::WMS_UIEXT, "Too big infos, infoSize: %{public}d", infoSize); return false; } @@ -1356,4 +1354,29 @@ WSError SessionStageProxy::SetSplitButtonVisible(bool isVisible) return WSError::WS_OK; } +WSError SessionStageProxy::SetEnableDragBySystem(bool dragEnable) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteBool(dragEnable)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Write params failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(SessionStageInterfaceCode::TRANS_ID_SET_ENABLE_DRAG_BY_SYSTEM), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + return WSError::WS_OK; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index 1ed80d72a3..e7869afff5 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -121,6 +121,8 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleNotifyDumpInfo(data, reply); case static_cast(SessionStageInterfaceCode::TRANS_ID_SET_SPLIT_BUTTON_VISIBLE): return HandleSetSplitButtonVisible(data, reply); + case static_cast(SessionStageInterfaceCode::TRANS_ID_SET_ENABLE_DRAG_BY_SYSTEM): + return HandleSetEnableDragBySystem(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -580,7 +582,7 @@ bool SessionStageStub::CalculateDataSize(const std::vector& infos) bool SessionStageStub::WriteSmallStringVector( const std::vector& infos, MessageParcel& reply) { - TLOGD(WmsLogTag::WMS_UIEXT, "WriteSmallStringVector entry"); + TLOGD(WmsLogTag::WMS_UIEXT, "entry"); reply.SetMaxCapacity(CAPACITY_THRESHOLD); if (!reply.WriteStringVector(infos)) { TLOGE(WmsLogTag::WMS_UIEXT, "HandleNotifyDumpInfo write infos failed"); @@ -593,7 +595,6 @@ bool SessionStageStub::WriteSmallStringVector( bool SessionStageStub::WriteBigStringVector( const std::vector& infos, MessageParcel& reply) { - TLOGD(WmsLogTag::WMS_UIEXT, "WriteBigStringVector entry"); Parcel tempParcel; tempParcel.SetMaxCapacity(MAX_PARCEL_CAPACITY); if (!tempParcel.WriteInt32(static_cast(infos.size()))) { @@ -609,7 +610,7 @@ bool SessionStageStub::WriteBigStringVector( } size_t dataSize = tempParcel.GetDataSize(); - TLOGD(WmsLogTag::WMS_UIEXT, "write big data, dataSize: %{public}zu", dataSize); + TLOGD(WmsLogTag::WMS_UIEXT, "dataSize: %{public}zu", dataSize); if (!reply.WriteInt32(static_cast(dataSize))) { TLOGE(WmsLogTag::WMS_UIEXT, "write dataSize failed"); return false; @@ -671,4 +672,16 @@ int SessionStageStub::HandleSetSplitButtonVisible(MessageParcel& data, MessagePa SetSplitButtonVisible(isVisible); return ERR_NONE; } + +int SessionStageStub::HandleSetEnableDragBySystem(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_LAYOUT, "in"); + bool enableDrag = true; + if (!data.ReadBool(enableDrag)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Read enableDrag failed."); + return ERR_INVALID_DATA; + } + SetEnableDragBySystem(enableDrag); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/main_session.h b/window_scene/session/host/include/main_session.h index c68d46c6e2..3bf925333f 100644 --- a/window_scene/session/host/include/main_session.h +++ b/window_scene/session/host/include/main_session.h @@ -42,6 +42,8 @@ public: void SetExitSplitOnBackground(bool isExitSplitOnBackground) override; bool IsExitSplitOnBackground() const override; + WSError OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true, + bool isDockHoverShown = true) override; WSError OnRestoreMainWindow() override; protected: diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 66a4182b27..c5f59e21a5 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -183,8 +183,6 @@ public: WSError OnSessionEvent(SessionEvent event) override; WSError OnSystemSessionEvent(SessionEvent event) override; WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) override; - WSError OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true, - bool isDockHoverShown = true) override; WSError RaiseToAppTop() override; WSError UpdateSizeChangeReason(SizeChangeReason reason) override; virtual void OpenKeyboardSyncTransaction() {}; @@ -241,7 +239,8 @@ public: void SetForegroundInteractiveStatus(bool interactive) override; WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; WMError SetSystemWindowEnableDrag(bool enableDrag) override; - + // Provide the ability to prohibit dragging for scb + WMError SetWindowEnableDragBySystem(bool enableDrag); WSError SetKeepScreenOn(bool keepScreenOn); void SetParentPersistentId(int32_t parentId); WSError SetTurnScreenOn(bool turnScreenOn); @@ -284,6 +283,7 @@ public: bool CheckGetAvoidAreaAvailable(AvoidAreaType type) override; bool GetIsDisplayStatusBarTemporarily() const; void SetIsDisplayStatusBarTemporarily(bool isTemporary); + NotifyTitleAndDockHoverShowChangeFunc onTitleAndDockHoverShowChangeFunc_; void SetAbilitySessionInfo(std::shared_ptr abilityInfo); void SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func); @@ -671,11 +671,6 @@ private: ExtensionWindowFlags combinedExtWindowFlags_ { 0 }; std::map extWindowFlagsMap_; - /** - * Window Immersive - */ - NotifyTitleAndDockHoverShowChangeFunc onTitleAndDockHoverShowChangeFunc_; - /* * Window Decor */ diff --git a/window_scene/session/host/src/main_session.cpp b/window_scene/session/host/src/main_session.cpp index 2b9159f29c..e0454bb290 100644 --- a/window_scene/session/host/src/main_session.cpp +++ b/window_scene/session/host/src/main_session.cpp @@ -236,6 +236,25 @@ void MainSession::NotifyClientToUpdateInteractive(bool interactive) } } +WSError MainSession::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool isDockHoverShown) +{ + const char* const funcName = __func__; + auto task = [weakThis = wptr(this), isTitleHoverShown, isDockHoverShown, funcName] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s session is null", funcName); + return; + } + TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s isTitleHoverShown: %{public}d, isDockHoverShown: %{public}d", funcName, + isTitleHoverShown, isDockHoverShown); + if (session->onTitleAndDockHoverShowChangeFunc_) { + session->onTitleAndDockHoverShowChangeFunc_(isTitleHoverShown, isDockHoverShown); + } + }; + PostTask(task, funcName); + return WSError::WS_OK; +} + WSError MainSession::OnRestoreMainWindow() { auto task = [weakThis = wptr(this)] { diff --git a/window_scene/session/host/src/move_drag_controller.cpp b/window_scene/session/host/src/move_drag_controller.cpp index 98961e1feb..f8bc5e70a4 100644 --- a/window_scene/session/host/src/move_drag_controller.cpp +++ b/window_scene/session/host/src/move_drag_controller.cpp @@ -263,8 +263,9 @@ WSRect MoveDragController::GetFullScreenToFloatingRect(const WSRect& originalRec WLOGE("original rect witch is zero"); return windowRect; } + // Drag and drop to full screen in proportion float newPosX = static_cast(windowRect.width_) / static_cast(originalRect.width_) * - static_cast(moveTempProperty_.lastDownPointerPosX_); + static_cast(moveTempProperty_.lastDownPointerPosX_ - originalRect.posX_); WSRect targetRect = { moveTempProperty_.lastDownPointerPosX_ - static_cast(newPosX), originalRect.posY_, diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 0a23faaee9..c58cc6c4f9 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4587,25 +4587,6 @@ WSError SceneSession::OnLayoutFullScreenChange(bool isLayoutFullScreen) return WSError::WS_OK; } -WSError SceneSession::OnTitleAndDockHoverShowChange(bool isTitleHoverShown, bool isDockHoverShown) -{ - const char* const funcName = __func__; - auto task = [weakThis = wptr(this), isTitleHoverShown, isDockHoverShown, funcName] { - auto session = weakThis.promote(); - if (!session) { - TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s session is null", funcName); - return; - } - TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s isTitleHoverShown: %{public}d, isDockHoverShown: %{public}d", funcName, - isTitleHoverShown, isDockHoverShown); - if (session->onTitleAndDockHoverShowChangeFunc_) { - session->onTitleAndDockHoverShowChangeFunc_(isTitleHoverShown, isDockHoverShown); - } - }; - PostTask(task, funcName); - return WSError::WS_OK; -} - void SceneSession::SetForceHideState(ForceHideState forceHideState) { forceHideState_ = forceHideState; @@ -4736,6 +4717,32 @@ WMError SceneSession::SetSystemWindowEnableDrag(bool enableDrag) return WMError::WM_OK; } +WMError SceneSession::SetWindowEnableDragBySystem(bool enableDrag) +{ + TLOGI(WmsLogTag::WMS_LAYOUT, "enableDrag : %{public}d", enableDrag); + + auto task = [weakThis = wptr(this), enableDrag]() { + auto session = weakThis.promote(); + if (!session) { + TLOGE(WmsLogTag::WMS_LAYOUT, "session is null"); + return; + } + TLOGI(WmsLogTag::WMS_LAYOUT, "task id: %{public}d, enableDrag: %{public}d", + session->GetPersistentId(), enableDrag); + auto sessionProperty = session->GetSessionProperty(); + if (!sessionProperty) { + TLOGE(WmsLogTag::WMS_LAYOUT, "sessionProperty is null"); + return; + } + sessionProperty->SetDragEnabled(enableDrag); + if (session->sessionStage_) { + session->sessionStage_->SetEnableDragBySystem(enableDrag); + } + }; + PostTask(task, "SetWindowEnableDragBySystem"); + return WMError::WM_OK; +} + WMError SceneSession::HandleActionUpdateModeSupportInfo(const sptr& property, WSPropertyChangeAction action) { diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 761e570c6f..b126ce739d 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1062,6 +1062,7 @@ void Session::InitSessionPropertyWhenConnect(const sptr& property->SetCompatibleWindowSizeInPc(sessionProperty->GetCompatibleInPcPortraitWidth(), sessionProperty->GetCompatibleInPcPortraitHeight(), sessionProperty->GetCompatibleInPcLandscapeWidth(), sessionProperty->GetCompatibleInPcLandscapeHeight()); + property->SetDragEnabled(sessionProperty->GetDragEnabled()); } if (sessionProperty && SessionHelper::IsMainWindow(GetWindowType())) { property->SetIsPcAppInPad(sessionProperty->GetIsPcAppInPad()); @@ -1159,7 +1160,6 @@ void Session::HandleDialogBackground() } TLOGI(WmsLogTag::WMS_DIALOG, "Background dialog, id: %{public}d, dialogId: %{public}d", GetPersistentId(), dialog->GetPersistentId()); - dialog->SetSessionState(SessionState::STATE_BACKGROUND); if (!dialog->sessionStage_) { TLOGE(WmsLogTag::WMS_DIALOG, "dialog session stage is nullptr"); return; @@ -1184,7 +1184,6 @@ void Session::HandleDialogForeground() } TLOGI(WmsLogTag::WMS_DIALOG, "Foreground dialog, id: %{public}d, dialogId: %{public}d", GetPersistentId(), dialog->GetPersistentId()); - dialog->SetSessionState(SessionState::STATE_ACTIVE); if (!dialog->sessionStage_) { TLOGE(WmsLogTag::WMS_DIALOG, "dialog session stage is nullptr"); return; diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 92869b6e85..2e99911156 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -308,6 +308,7 @@ WSError SessionProxy::Connect(const sptr& sessionStage, const spt property->SetCompatibleModeEnableInPad(reply.ReadBool()); property->SetRequestedOrientation(static_cast(reply.ReadUint32())); property->SetAppInstanceKey(reply.ReadString()); + property->SetDragEnabled(reply.ReadBool()); } int32_t ret = reply.ReadInt32(); return static_cast(ret); diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 57dcfbf077..dcfc9783dd 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -380,6 +380,7 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply) reply.WriteBool(property->GetCompatibleModeEnableInPad()); reply.WriteUint32(static_cast(property->GetRequestedOrientation())); reply.WriteString(property->GetAppInstanceKey()); + reply.WriteBool(property->GetDragEnabled()); } reply.WriteUint32(static_cast(errCode)); return ERR_NONE; @@ -1113,6 +1114,11 @@ int SessionStub::HandleUpdatePropertyByAction(MessageParcel& data, MessageParcel TLOGE(WmsLogTag::DEFAULT, "read action error"); return ERR_INVALID_DATA; } + if (actionValue < static_cast(WSPropertyChangeAction::ACTION_UPDATE_RECT) || + actionValue > static_cast(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST)) { + TLOGE(WmsLogTag::DEFAULT, "invalid action"); + return ERR_INVALID_DATA; + } auto action = static_cast(actionValue); TLOGD(WmsLogTag::DEFAULT, "action:%{public}u", action); sptr property = nullptr; diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index c15f25bdf3..01dbb8dba7 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -51,6 +51,7 @@ public: virtual void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) = 0; virtual void OnScreenExtendChange(ScreenId mainScreenId, ScreenId extendScreenId) = 0; virtual void OnHoverStatusChange(int32_t hoverStatus, ScreenId extendScreenId) = 0; + virtual void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) = 0; }; enum class MirrorScreenType : int32_t { @@ -239,6 +240,7 @@ public: Rotation ConvertIntToRotation(int rotation); void SetPhysicalRotation(int rotation, FoldStatus foldStatus); void SetStartPosition(uint32_t startX, uint32_t startY); + void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName); private: ScreenProperty property_; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 339641900c..422c17eaf3 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -1472,4 +1472,14 @@ void ScreenSession::SetStartPosition(uint32_t startX, uint32_t startY) { property_.SetStartPosition(startX, startY); } + +void ScreenSession::ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) +{ + for (auto& listener : screenChangeListenerList_) { + if (!listener) { + continue; + } + listener->OnScreenCaptureNotify(mainScreenId, uid, clientName); + } +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 9aad064386..e8fb654313 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -153,8 +153,8 @@ public: const bool isToDesktop = false, const bool isSaveSnapshot = true); WSError RequestSceneSessionDestruction(const sptr& sceneSession, bool needRemoveSession = true, bool isSaveSnapshot = true, const bool isForceClean = false); - WSError RequestSceneSessionDestructionInner(sptr& scnSession, sptr scnSessionInfo, - const bool needRemoveSession, const bool isForceClean = false); + WSError RequestSceneSessionDestructionInner(sptr& sceneSession, + sptr sceneSessionInfo, const bool needRemoveSession, const bool isForceClean = false); void NotifyForegroundInteractiveStatus(const sptr& sceneSession, bool interactive); WSError RequestSceneSessionByCall(const sptr& sceneSession); void StartAbilityBySpecified(const SessionInfo& sessionInfo); @@ -585,8 +585,8 @@ private: void InitSceneSession(sptr& sceneSession, const SessionInfo& sessionInfo, const sptr& property); - sptr SetAbilitySessionInfo(const sptr& scnSession); - WSError DestroyDialogWithMainWindow(const sptr& scnSession); + sptr SetAbilitySessionInfo(const sptr& sceneSession); + WSError DestroyDialogWithMainWindow(const sptr& sceneSession); sptr FindMainWindowWithToken(sptr targetToken); WSError UpdateParentSessionForDialog(const sptr& sceneSession, sptr property); void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); @@ -622,7 +622,7 @@ private: WSError GetTotalUITreeInfo(const std::string& strId, std::string& dumpInfo); void PerformRegisterInRequestSceneSession(sptr& sceneSession); - WSError RequestSceneSessionActivationInner(sptr& scnSession, bool isNewActive); + WSError RequestSceneSessionActivationInner(sptr& sceneSession, bool isNewActive); WSError SetBrightness(const sptr& sceneSession, float brightness); WSError UpdateBrightness(int32_t persistentId); void SetDisplayBrightness(float brightness); @@ -657,7 +657,7 @@ private: void RegisterAcquireRotateAnimationConfigFunc(const sptr& sceneSession); void RegisterVisibilityChangedDetectFunc(const sptr& sceneSession); - void NotifySessionForCallback(const sptr& scnSession, const bool needRemoveSession); + void NotifySessionForCallback(const sptr& sceneSession, const bool needRemoveSession); void AddClientDeathRecipient(const sptr& sessionStage, const sptr& sceneSession); void DestroySpecificSession(const sptr& remoteObject); bool GetExtensionWindowIds(const sptr& token, int32_t& persistentId, int32_t& parentId); @@ -827,7 +827,7 @@ private: [this](const sptr& remoteExtSession) { this->DestroyExtensionSession(remoteExtSession); }); WSError ClearSession(sptr sceneSession); - bool IsSessionClearable(sptr scnSession); + bool IsSessionClearable(sptr sceneSession); void GetAllClearableSessions(std::vector>& sessionVector); int GetRemoteSessionSnapshotInfo(const std::string& deviceId, int32_t sessionId, AAFwk::MissionSnapshot& sessionSnapshot); @@ -858,7 +858,7 @@ private: void NotifyMoveSessionToForeground(int32_t collaboratorType, int32_t persistentId); bool PreHandleCollaboratorStartAbility(sptr& sceneSession, int32_t persistentId = 0); bool PreHandleCollaborator(sptr& sceneSession, int32_t persistentId = 0); - void NotifyCollaboratorAfterStart(sptr& scnSession, sptr& scnSessionInfo); + void NotifyCollaboratorAfterStart(sptr& sceneSession, sptr& sceneSessionInfo); void UpdateCollaboratorSessionWant(sptr& session, int32_t persistentId = 0); bool CheckSystemWindowPermission(const sptr& property); bool CheckModalSubWindowPermission(const sptr& property); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 4626ee48c5..8ba78d9de6 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -9501,25 +9501,16 @@ std::shared_ptr SceneSessionManager::GetSessionSnapshotPixelMap return nullptr; } - wptr weakSceneSession(sceneSession); - auto task = [this, persistentId, scaleParam, weakSceneSession]() { - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetSessionSnapshotPixelMap(%d )", persistentId); - auto sceneSession = weakSceneSession.promote(); - std::shared_ptr pixelMap = nullptr; - if (sceneSession == nullptr) { - WLOGFE("session is nullptr"); - return pixelMap; - } + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetSessionSnapshotPixelMap(%d )", persistentId); + std::shared_ptr pixelMap = nullptr; - bool isPc = systemConfig_.IsPcWindow() || systemConfig_.IsFreeMultiWindowMode(); - pixelMap = sceneSession->Snapshot(false, scaleParam, isPc); - if (!pixelMap) { - WLOGFI("get local snapshot pixelmap start"); - pixelMap = sceneSession->GetSnapshotPixelMap(snapshotScale_, scaleParam); - } - return pixelMap; - }; - return taskScheduler_->PostSyncTask(task, "GetSessionSnapshotPixelMap" + std::to_string(persistentId)); + bool isPc = systemConfig_.IsPcWindow() || systemConfig_.IsFreeMultiWindowMode(); + pixelMap = sceneSession->Snapshot(true, scaleParam, isPc); + if (!pixelMap) { + WLOGFI("get local snapshot pixelmap start"); + pixelMap = sceneSession->GetSnapshotPixelMap(snapshotScale_, scaleParam); + } + return pixelMap; } const std::map> SceneSessionManager::GetSceneSessionMap() diff --git a/window_scene/session_manager/src/session_manager_lite.cpp b/window_scene/session_manager/src/session_manager_lite.cpp index e6c6214626..5539c39c08 100644 --- a/window_scene/session_manager/src/session_manager_lite.cpp +++ b/window_scene/session_manager/src/session_manager_lite.cpp @@ -171,7 +171,7 @@ void SessionManagerLite::SaveSessionListener(const sptr& liste return (item && item->AsObject() == listener->AsObject()); }); if (it != sessionListeners_.end()) { - TLOGW(WmsLogTag::DEFAULT, "listener was already added, do not add again"); + TLOGW(WmsLogTag::DEFAULT, "listener was already added"); return; } sessionListeners_.emplace_back(listener); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index b1b80a6183..05b5734be8 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -393,10 +393,23 @@ int SceneSessionManagerLiteStub::HandleSetSessionContinueState(MessageParcel& da int SceneSessionManagerLiteStub::HandleGetSessionSnapshot(MessageParcel& data, MessageParcel& reply) { - WLOGFD("run HandleGetSessionSnapshot!"); - std::string deviceId = Str16ToStr8(data.ReadString16()); - int32_t persistentId = data.ReadInt32(); - bool isLowResolution = data.ReadBool(); + TLOGD(WmsLogTag::WMS_SYSTEM, "Handled!"); + std::u16string deviceIdData; + if (!data.ReadString16(deviceIdData)) { + TLOGE(WmsLogTag::WMS_SYSTEM, "read deviceId fail"); + return ERR_INVALID_DATA; + } + std::string deviceId = Str16ToStr8(deviceIdData); + int32_t persistentId = 0; + if (!data.ReadInt32(persistentId)) { + TLOGE(WmsLogTag::WMS_SYSTEM, "read persistentId fail"); + return ERR_INVALID_DATA; + } + bool isLowResolution = false; + if (!data.ReadBool(isLowResolution)) { + TLOGE(WmsLogTag::WMS_SYSTEM, "read isLowResolution fail"); + return ERR_INVALID_DATA; + } std::shared_ptr snapshot = std::make_shared(); WSError ret = GetSessionSnapshot(deviceId, persistentId, *snapshot, isLowResolution); reply.WriteParcelable(snapshot.get()); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index df2bc7c3af..cddd0aa543 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -732,10 +732,23 @@ int SceneSessionManagerStub::HandleUpdateSessionAvoidAreaListener(MessageParcel& int SceneSessionManagerStub::HandleGetSessionSnapshot(MessageParcel& data, MessageParcel& reply) { - WLOGFI("run HandleGetSessionSnapshot!"); - std::string deviceId = Str16ToStr8(data.ReadString16()); - int32_t persistentId = data.ReadInt32(); - bool isLowResolution = data.ReadBool(); + TLOGD(WmsLogTag::WMS_SYSTEM, "Handled!"); + std::u16string deviceIdData; + if (!data.ReadString16(deviceIdData)) { + TLOGE(WmsLogTag::WMS_SYSTEM, "read deviceId fail"); + return ERR_INVALID_DATA; + } + std::string deviceId = Str16ToStr8(deviceIdData); + int32_t persistentId = 0; + if (!data.ReadInt32(persistentId)) { + TLOGE(WmsLogTag::WMS_SYSTEM, "read persistentId fail"); + return ERR_INVALID_DATA; + } + bool isLowResolution = false; + if (!data.ReadBool(isLowResolution)) { + TLOGE(WmsLogTag::WMS_SYSTEM, "read isLowResolution fail"); + return ERR_INVALID_DATA; + } std::shared_ptr snapshot = std::make_shared(); WSError ret = GetSessionSnapshot(deviceId, persistentId, *snapshot, isLowResolution); reply.WriteParcelable(snapshot.get()); @@ -745,8 +758,12 @@ int SceneSessionManagerStub::HandleGetSessionSnapshot(MessageParcel& data, Messa int SceneSessionManagerStub::HandleGetSessionSnapshotById(MessageParcel& data, MessageParcel& reply) { - TLOGI(WmsLogTag::WMS_SYSTEM, "Handled!"); - int32_t persistentId = data.ReadInt32(); + TLOGD(WmsLogTag::WMS_SYSTEM, "Handled!"); + int32_t persistentId = 0; + if (!data.ReadInt32(persistentId)) { + TLOGE(WmsLogTag::WMS_SYSTEM, "read persistentId fail"); + return ERR_INVALID_DATA; + } std::shared_ptr snapshot = std::make_shared(); const WMError ret = GetSessionSnapshotById(persistentId, *snapshot); reply.WriteParcelable(snapshot.get()); @@ -944,8 +961,17 @@ int SceneSessionManagerStub::HandleGetParentMainWindowId(MessageParcel& data, Me int SceneSessionManagerStub::HandleUpdateSessionWindowVisibilityListener(MessageParcel& data, MessageParcel& reply) { - int32_t persistentId = data.ReadInt32(); - bool haveListener = data.ReadBool(); + TLOGD(WmsLogTag::DEFAULT, "Handled!"); + int32_t persistentId = 0; + if (!data.ReadInt32(persistentId)) { + TLOGE(WmsLogTag::DEFAULT, "read persistentId fail"); + return ERR_INVALID_DATA; + } + bool haveListener = false; + if (!data.ReadBool(haveListener)) { + TLOGE(WmsLogTag::DEFAULT, "read haveListener fail"); + return ERR_INVALID_DATA; + } WSError ret = UpdateSessionWindowVisibilityListener(persistentId, haveListener); reply.WriteUint32(static_cast(ret)); return ERR_NONE; @@ -1057,8 +1083,12 @@ int SceneSessionManagerStub::HandleUpdateExtWindowFlags(MessageParcel& data, Mes int SceneSessionManagerStub::HandleGetHostWindowRect(MessageParcel& data, MessageParcel& reply) { - TLOGD(WmsLogTag::WMS_UIEXT, "run HandleGetHostWindowRect!"); - int32_t hostWindowId = data.ReadInt32(); + TLOGD(WmsLogTag::WMS_UIEXT, "Handled!"); + int32_t hostWindowId = 0; + if (!data.ReadInt32(hostWindowId)) { + TLOGE(WmsLogTag::WMS_UIEXT, "read hostWindowId fail"); + return ERR_INVALID_DATA; + } Rect rect; WSError ret = GetHostWindowRect(hostWindowId, rect); reply.WriteInt32(rect.posX_); @@ -1138,9 +1168,17 @@ int SceneSessionManagerStub::HandleGetWindowStyleType(MessageParcel& data, Messa int SceneSessionManagerStub::HandleGetProcessSurfaceNodeIdByPersistentId(MessageParcel& data, MessageParcel& reply) { - int32_t pid = data.ReadInt32(); + TLOGD(WmsLogTag::DEFAULT, "Handled!"); + int32_t pid = 0; + if (!data.ReadInt32(pid)) { + TLOGE(WmsLogTag::DEFAULT, "Failed to readInt32 pid"); + return ERR_INVALID_DATA; + } std::vector persistentIds; - data.ReadInt32Vector(&persistentIds); + if (!data.ReadInt32Vector(&persistentIds)) { + TLOGE(WmsLogTag::DEFAULT, "Failed to readInt32Vector persistentIds"); + return ERR_INVALID_DATA; + } std::vector surfaceNodeIds; WMError errCode = GetProcessSurfaceNodeIdByPersistentId(pid, persistentIds, surfaceNodeIds); if (!reply.WriteUInt64Vector(surfaceNodeIds)) { diff --git a/window_scene/test/dms_unittest/multi_screen_manager_test.cpp b/window_scene/test/dms_unittest/multi_screen_manager_test.cpp index 0c3ec3cc3a..7cab2be404 100644 --- a/window_scene/test/dms_unittest/multi_screen_manager_test.cpp +++ b/window_scene/test/dms_unittest/multi_screen_manager_test.cpp @@ -16,6 +16,9 @@ #include #include "multi_screen_manager.h" +#include "screen_session_manager/include/screen_session_manager.h" +#include "display_manager_agent_default.h" +#include "zidl/screen_session_manager_client_interface.h" using namespace testing; using namespace testing::ext; @@ -25,12 +28,42 @@ namespace Rosen { namespace { constexpr uint32_t SLEEP_TIME_IN_US = 100000; // 100ms } +class TestClient : public IScreenSessionManagerClient { +public: + void SwitchUserCallback(std::vector oldScbPids, int32_t currentScbPid) override {}; + void OnScreenConnectionChanged(ScreenId screenId, ScreenEvent screenEvent, + ScreenId rsId, const std::string& name, bool isExtend) override {}; + void OnPropertyChanged(ScreenId screenId, + const ScreenProperty& property, ScreenPropertyChangeReason reason) override {}; + void OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status, + PowerStateChangeReason reason) override {}; + void OnSensorRotationChanged(ScreenId screenId, float sensorRotation) override {}; + void OnHoverStatusChanged(ScreenId screenId, int32_t hoverStatus) override {}; + void OnScreenOrientationChanged(ScreenId screenId, float screenOrientation) override {}; + void OnScreenRotationLockedChanged(ScreenId screenId, bool isLocked) override {}; + void OnScreenExtendChanged(ScreenId mainScreenId, ScreenId extendScreenId) override {}; + + void OnDisplayStateChanged(DisplayId defaultDisplayId, sptr displayInfo, + const std::map>& displayInfoMap, DisplayStateChangeType type) override {}; + void OnScreenshot(DisplayId displayId) override {}; + void OnImmersiveStateChanged(ScreenId screenId, bool& immersive) override {}; + void SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId) override {}; + void OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector& missionIds, + std::vector& surfaceNodeIds, bool isBlackList = false) override {}; + void OnUpdateFoldDisplayMode(FoldDisplayMode displayMode) override {}; + void SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) override {}; + void OnFoldStatusChangedReportUE(const std::vector& screenFoldInfo) override {}; + void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override {}; + sptr AsObject() override {return testPtr;}; + sptr testPtr; +}; class MultiScreenManagerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp() override; void TearDown() override; + sptr testClient_; }; void MultiScreenManagerTest::SetUpTestCase() @@ -59,7 +92,7 @@ namespace { */ HWTEST_F(MultiScreenManagerTest, FilterPhysicalAndVirtualScreen, Function | SmallTest | Level1) { - std::vector allScreenIds = {1, 2, 3}; + std::vector allScreenIds = {2000, 2001, 0}; std::vector physicalScreenIds; std::vector virtualScreenIds; MultiScreenManager::GetInstance().FilterPhysicalAndVirtualScreen(allScreenIds, @@ -559,6 +592,456 @@ HWTEST_F(MultiScreenManagerTest, MirrorSwitch04, Function | SmallTest | Level1) DMError ret = MultiScreenManager::GetInstance().MirrorSwitch(1, screenIds, screenGroupId); EXPECT_EQ(ret, DMError::DM_OK); } + +/** + * @tc.name: MultiScreenModeChange + * @tc.desc: firstSession == nullptr,secondarySession == nullptr + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, MultiScreenModeChange01, Function | SmallTest | Level1) +{ + sptr firstSession = nullptr; + sptr secondarySession = nullptr; + MultiScreenManager::GetInstance().MultiScreenModeChange(firstSession, secondarySession, "mirror"); + + secondarySession = new ScreenSession(); + MultiScreenManager::GetInstance().MultiScreenModeChange(firstSession, secondarySession, "mirror"); + + firstSession = new ScreenSession(); + MultiScreenManager::GetInstance().MultiScreenModeChange(firstSession, secondarySession, "mirror"); + EXPECT_NE(secondarySession, nullptr); +} + +/** + * @tc.name: MultiScreenModeChange + * @tc.desc: firstSession == nullptr,secondarySession == nullptr + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, MultiScreenModeChange02, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + + testClient_ = new TestClient(); + ScreenSessionManager::GetInstance().SetClient(testClient_); + ASSERT_NE(ScreenSessionManager::GetInstance().GetClientProxy(), nullptr); + + firstSession->SetScreenCombination(ScreenCombination::SCREEN_MAIN); + secondarySession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); + MultiScreenManager::GetInstance().MultiScreenModeChange(firstSession, secondarySession, "extend"); + ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_EXTEND); + + firstSession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); + MultiScreenManager::GetInstance().MultiScreenModeChange(firstSession, secondarySession, "mirror"); + ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_MIRROR); + + firstSession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); + MultiScreenManager::GetInstance().MultiScreenModeChange(firstSession, secondarySession, "extend"); + ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_EXTEND); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstMainChange + * @tc.desc: scbClient null + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstMainChange01, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + ScreenCombination secondaryCombination = secondarySession->GetScreenCombination(); + + ScreenSessionManager::GetInstance().clientProxy_ = nullptr; + MultiScreenManager::GetInstance().DoFirstMainChange(firstSession, secondarySession, "unknown"); + ASSERT_EQ(secondarySession->GetScreenCombination(), secondaryCombination); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstMainChange + * @tc.desc: param error + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstMainChange02, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + ScreenCombination secondaryCombination = secondarySession->GetScreenCombination(); + + testClient_ = new TestClient(); + ScreenSessionManager::GetInstance().SetClient(testClient_); + ASSERT_NE(ScreenSessionManager::GetInstance().GetClientProxy(), nullptr); + MultiScreenManager::GetInstance().DoFirstMainChange(firstSession, secondarySession, "unknown"); + ASSERT_EQ(secondarySession->GetScreenCombination(), secondaryCombination); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstMainChange + * @tc.desc: DoFirstMainChangeExtend + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstMainChange03, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + secondarySession->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); + + ASSERT_NE(ScreenSessionManager::GetInstance().GetClientProxy(), nullptr); + MultiScreenManager::GetInstance().DoFirstMainChange(firstSession, secondarySession, "extend"); + ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_EXTEND); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstMainChange + * @tc.desc: main change extend, no need to change + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstMainChange04, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + secondarySession->SetScreenCombination(ScreenCombination::SCREEN_ALONE); + + ASSERT_NE(ScreenSessionManager::GetInstance().GetClientProxy(), nullptr); + MultiScreenManager::GetInstance().DoFirstMainChange(firstSession, secondarySession, "extend"); + ASSERT_NE(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_EXTEND); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstMainChange + * @tc.desc: DoFirstMainChangeMirror + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstMainChange05, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + secondarySession->SetScreenCombination(ScreenCombination::SCREEN_EXTEND); + + ASSERT_NE(ScreenSessionManager::GetInstance().GetClientProxy(), nullptr); + MultiScreenManager::GetInstance().DoFirstMainChange(firstSession, secondarySession, "mirror"); + ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_MIRROR); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstMainChange + * @tc.desc: main change mirror, no need to change + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstMainChange06, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + secondarySession->SetScreenCombination(ScreenCombination::SCREEN_ALONE); + + ASSERT_NE(ScreenSessionManager::GetInstance().GetClientProxy(), nullptr); + MultiScreenManager::GetInstance().DoFirstMainChange(firstSession, secondarySession, "mirror"); + ASSERT_NE(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_MIRROR); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstMirrorChange + * @tc.desc: scbClient null + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstMirrorChange01, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + ScreenCombination secondaryCombination = secondarySession->GetScreenCombination(); + + ScreenSessionManager::GetInstance().clientProxy_ = nullptr; + MultiScreenManager::GetInstance().DoFirstMirrorChange(firstSession, secondarySession, "unknown"); + ASSERT_EQ(secondarySession->GetScreenCombination(), secondaryCombination); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstMirrorChange + * @tc.desc: param error + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstMirrorChange02, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + ScreenCombination secondaryCombination = secondarySession->GetScreenCombination(); + + testClient_ = new TestClient(); + ScreenSessionManager::GetInstance().SetClient(testClient_); + ASSERT_NE(ScreenSessionManager::GetInstance().GetClientProxy(), nullptr); + MultiScreenManager::GetInstance().DoFirstMirrorChange(firstSession, secondarySession, "unknown"); + ASSERT_EQ(secondarySession->GetScreenCombination(), secondaryCombination); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + + +/** + * @tc.name: DoFirstMirrorChange + * @tc.desc: DoFirstMirrorChangeExtend + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstMirrorChange03, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + + ASSERT_NE(ScreenSessionManager::GetInstance().GetClientProxy(), nullptr); + MultiScreenManager::GetInstance().DoFirstMirrorChange(firstSession, secondarySession, "extend"); + ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_EXTEND); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstMirrorChange + * @tc.desc: DoFirstMirrorChangeMirror + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstMirrorChange04, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + + ASSERT_NE(ScreenSessionManager::GetInstance().GetClientProxy(), nullptr); + MultiScreenManager::GetInstance().DoFirstMirrorChange(firstSession, secondarySession, "mirror"); + ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_MIRROR); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + + +/** + * @tc.name: DoFirstExtendChange + * @tc.desc: param error + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstExtendChange01, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + ScreenCombination secondaryCombination = secondarySession->GetScreenCombination(); + + MultiScreenManager::GetInstance().DoFirstExtendChange(firstSession, secondarySession, "unknown"); + ASSERT_EQ(secondarySession->GetScreenCombination(), secondaryCombination); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstExtendChange + * @tc.desc: extend change extend + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstExtendChange02, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + + MultiScreenManager::GetInstance().DoFirstExtendChange(firstSession, secondarySession, "extend"); + ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_EXTEND); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} + +/** + * @tc.name: DoFirstExtendChange + * @tc.desc: extend change mirror + * @tc.type: FUNC + */ +HWTEST_F(MultiScreenManagerTest, DoFirstExtendChange03, Function | SmallTest | Level1) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption, displayManagerAgent->AsObject()); + auto firstSession = ScreenSessionManager::GetInstance().GetScreenSession(screenId); + + sptr displayManagerAgent1 = new(std::nothrow) DisplayManagerAgentDefault(); + VirtualScreenOption virtualOption1; + virtualOption1.name_ = "createVirtualOption"; + auto screenId1 = ScreenSessionManager::GetInstance().CreateVirtualScreen( + virtualOption1, displayManagerAgent1->AsObject()); + auto secondarySession = ScreenSessionManager::GetInstance().GetScreenSession(screenId1); + + MultiScreenManager::GetInstance().DoFirstExtendChange(firstSession, secondarySession, "mirror"); + ASSERT_EQ(secondarySession->GetScreenCombination(), ScreenCombination::SCREEN_MIRROR); + + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId); + ScreenSessionManager::GetInstance().DestroyVirtualScreen(screenId1); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/dms_unittest/screen_session_dumper_test.cpp b/window_scene/test/dms_unittest/screen_session_dumper_test.cpp index ff9b6b49e8..e4251e8643 100644 --- a/window_scene/test/dms_unittest/screen_session_dumper_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_dumper_test.cpp @@ -799,7 +799,7 @@ HWTEST_F(ScreenSessionDumperTest, SetEnterOrExitTentMode, Function | SmallTest | sptr dumper = new ScreenSessionDumper(fd, args); dumper->SetEnterOrExitTentMode("-offtent"); - bool tentMode = ScreenSession::GetInstance().GetTentMode(); + bool tentMode = ScreenSessionManager::GetInstance().GetTentMode(); ASSERT_EQ(tentMode, false); } } diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp index c9973bf2b3..2d448aaa33 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_proxy_test.cpp @@ -297,5 +297,20 @@ HWTEST_F(ScreenSessionManagerClientProxyTest, OnFoldStatusChangedReportUE, Funct ASSERT_TRUE(screenSessionManagerClientProxy_ != nullptr); screenSessionManagerClientProxy_->OnFoldStatusChangedReportUE(screenFoldInfo); } + +/** + * @tc.name: ScreenCaptureNotify + * @tc.desc: ScreenCaptureNotify test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientProxyTest, ScreenCaptureNotify, Function | SmallTest | Level2) +{ + ScreenId screenId = 0; + int32_t uid = 0; + std::string clientName = "test"; + + ASSERT_TRUE(screenSessionManagerClientProxy_ != nullptr); + screenSessionManagerClientProxy_->ScreenCaptureNotify(screenId, uid, clientName); +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp index 307f5a2831..6c75808c9e 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_stub_test.cpp @@ -785,5 +785,26 @@ HWTEST_F(ScreenSessionManagerClientStubTest, HandleOnFoldStatusChangedReportUE, int ret = screenSessionManagerClientStub_->HandleOnFoldStatusChangedReportUE(data, reply); EXPECT_EQ(ret, 0); } + +/** + * @tc.name: HandleScreenCaptureNotify + * @tc.desc: HandleScreenCaptureNotify test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientStubTest, HandleScreenCaptureNotify, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + + data.WriteInterfaceToken(ScreenSessionManagerClientStub::GetDescriptor()); + + ScreenId screenId = 0; + data.WriteUint64(screenId); + data.WriteInt32(0); + data.WriteString("test"); + ASSERT_TRUE(screenSessionManagerClientStub_ != nullptr); + int ret = screenSessionManagerClientStub_->HandleScreenCaptureNotify(data, reply); + EXPECT_EQ(ret, 0); +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp index e3dd592c3f..d6947864d1 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp @@ -1284,5 +1284,19 @@ HWTEST_F(ScreenSessionManagerClientTest, UpdateScreenRotationProperty02, Functio sptr screenSession1 = screenSessionManagerClient_->GetScreenSession(screenId); EXPECT_NE(screenSession1, nullptr); } + +/** + * @tc.name: ScreenCaptureNotify + * @tc.desc: ScreenCaptureNotify test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerClientTest, ScreenCaptureNotify, Function | SmallTest | Level2) +{ + ScreenId screenId = 0; + int32_t uid = 0; + std::string clientName = "test"; + ASSERT_TRUE(screenSessionManagerClient_ != nullptr); + screenSessionManagerClient_->ScreenCaptureNotify(screenId, uid, clientName); +} } // namespace Rosen } // namespace OHOS 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 e6f148da0d..24acd0b06e 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 @@ -2127,6 +2127,33 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetScreenColorSpace, Function | SmallTes func(); EXPECT_EQ(resultValue, 1); } + +/** + * @tc.name: GetScreenCapture + * @tc.desc: GetScreenCapture test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerProxyTest, GetScreenCapture, Function | SmallTest | Level1) +{ + SingletonContainer::Get().InitDMSProxy(); + sptr impl = SingletonContainer::Get().displayManagerServiceProxy_->AsObject(); + sptr screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); + ASSERT_TRUE(screenSessionManagerProxy != nullptr); + + std::shared_ptr res = nullptr; + CaptureOption option; + option.displayId_ = 0; + DmErrorCode* errorCode = nullptr; + std::function func = [&]() { + res = screenSessionManagerProxy->GetScreenCapture(option, errorCode); + }; + func(); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(res, nullptr); + } else { + ASSERT_EQ(res, nullptr); + } +} } } } \ No newline at end of file diff --git a/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp index 26dca8c010..fb00fbcaa8 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp @@ -2836,6 +2836,27 @@ HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest132, Function | SmallTest int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + +/** + * @tc.name: OnRemoteRequest133 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest133, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + ScreenId id = 0; + data.WriteUint64(static_cast(id)); + data.WriteBool(true); + data.WriteBool(true); + uint32_t code = static_cast(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_CAPTURE); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} } } } \ No newline at end of file diff --git a/window_scene/test/dms_unittest/screen_session_manager_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_test.cpp index 1660d7216e..70c5bf8603 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_test.cpp @@ -3106,6 +3106,36 @@ HWTEST_F(ScreenSessionManagerTest, OnTentModeChanged, Function | SmallTest | Lev ssm_->OnTentModeChanged(isTentMode); ASSERT_EQ(ssm_->GetTentMode(), false); } +/** + * @tc.name: GetScreenCapture + * @tc.desc: GetScreenCapture + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, GetScreenCapture, Function | SmallTest | Level3) +{ + ScreenSessionManager* ssm = new ScreenSessionManager(); + ASSERT_NE(ssm, nullptr); + CaptureOption option; + option.displayId_ = 0; + DmErrorCode errCode; + std::shared_ptr bitMap = ssm->GetScreenCapture(option, &errCode); + ASSERT_NE(bitMap, nullptr); +} + +/** + * @tc.name: OnScreenCaptureNotify + * @tc.desc: OnScreenCaptureNotify + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, OnScreenCaptureNotify, Function | SmallTest | Level3) +{ + ScreenSessionManager* ssm = new ScreenSessionManager(); + ASSERT_NE(ssm, nullptr); + ScreenId screenId = 0; + int32_t uid = 0; + std::string clientName = "test"; + ssm->OnScreenCaptureNotify(screenId, uid, clientName); +} } } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index 8b65533a15..757fa475ce 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -35,6 +35,7 @@ public: void OnScreenRotationLockedChange(bool isLocked, ScreenId screenId) override {} void OnScreenExtendChange(ScreenId mainScreenId, ScreenId extendScreenId) override {} void OnHoverStatusChange(int32_t hoverStatus, ScreenId screenId) override {} + void OnScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override {} }; class ScreenSessionTest : public testing::Test { public: @@ -2260,6 +2261,21 @@ HWTEST_F(ScreenSessionTest, HandleHoverStatusChange01, Function | SmallTest | Le int32_t hoverStatus = 0; session->HandleHoverStatusChange(hoverStatus); } + +/** + * @tc.name: ScreenCaptureNotify + * @tc.desc: ScreenCaptureNotify test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, ScreenCaptureNotify, Function | SmallTest | Level2) +{ + sptr session = new ScreenSession(); + ASSERT_NE(session, nullptr); + ScreenId screenId = 0; + int32_t uid = 0; + std::string clientName = "test"; + session->ScreenCaptureNotify(screenId, uid, clientName); +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/mock/mock_resource_manager.h b/window_scene/test/mock/mock_resource_manager.h new file mode 100644 index 0000000000..38cfc065d6 --- /dev/null +++ b/window_scene/test/mock/mock_resource_manager.h @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2024 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 MOCK_RESOURCE_MANAGER_H +#define MOCK_RESOURCE_MANAGER_H + +#include +#include "session_manager/include/scene_session_manager.h" + +namespace OHOS { +namespace Global { +namespace Resource { +ResourceManager::~ResourceManager() {}; +class ResourceManagerMocker : public Resource::ResourceManager { +public: + ResourceManagerMocker() {}; + ~ResourceManagerMocker() {}; + + MOCK_METHOD2(GetColorById, RState(uint32_t id, uint32_t& outValue)); + MOCK_METHOD3(GetMediaById, RState(uint32_t id, std::string& outValue, uint32_t density)); + MOCK_METHOD2(AddResource, bool(const char* path, const uint32_t& selectedTypes)); + MOCK_METHOD1(GetResConfig, void(ResConfig& resconfig)); + MOCK_METHOD2(GetStringById, RState(uint32_t id, std::string& outValue)); + MOCK_METHOD2(GetStringByName, RState(const char* name, std::string& outValue)); + MOCK_METHOD2(GetStringArrayById, RState(uint32_t id, std::vector& outValue)); + MOCK_METHOD2(GetStringArrayByName, RState(const char* name, std::vector& outValue)); + MOCK_METHOD2(GetPatternById, RState(uint32_t id, std::map& outValue)); + MOCK_METHOD2(GetPatternByName, RState(const char* name, std::map& outValue)); + MOCK_METHOD3(GetPluralStringById, RState(uint32_t id, int quantity, std::string& outValue)); + MOCK_METHOD3(GetPluralStringByName, RState(const char* name, int quantity, std::string& outValue)); + MOCK_METHOD2(GetThemeById, RState(uint32_t id, std::map& outValue)); + MOCK_METHOD2(GetThemeByName, RState(const char* name, std::map& outValue)); + MOCK_METHOD2(UpdateResConfig, RState(ResConfig& resConfig, bool isUpdateTheme)); + RState GetStringFormatById(std::string& outValue, uint32_t id, ...) { return RState::ERROR; }; + RState GetStringFormatByName(std::string& outValue, const char* name, ...) { return RState::ERROR; }; + RState GetPluralStringByIdFormat(std::string& outValue, uint32_t id, int quantity, ...) { return RState::ERROR; }; + RState GetPluralStringByNameFormat(std::string& outValue, const char* name, int quantity, ...) + { + return RState::ERROR; + }; + RState GetBooleanById(uint32_t id, bool& outValue) { return RState::ERROR; }; + RState GetBooleanByName(const char* name, bool& outValue) { return RState::ERROR; }; + RState GetIntegerById(uint32_t id, int& outValue) { return RState::ERROR; }; + RState GetIntegerByName(const char* name, int& outValue) { return RState::ERROR; }; + RState GetFloatById(uint32_t id, float& outValue) { return RState::ERROR; }; + RState GetFloatById(uint32_t id, float& outValue, std::string& unit) { return RState::ERROR; }; + RState GetFloatByName(const char* name, float& outValue) { return RState::ERROR; }; + RState GetFloatByName(const char* name, float& outValue, std::string& unit) { return RState::ERROR; }; + RState GetIntArrayById(uint32_t id, std::vector& outValue) { return RState::ERROR; }; + RState GetIntArrayByName(const char* name, std::vector& outValue) { return RState::ERROR; }; + RState GetColorByName(const char* name, uint32_t& outValue) { return RState::ERROR; }; + RState GetProfileById(uint32_t id, std::string& outValue) { return RState::ERROR; }; + RState GetProfileByName(const char* name, std::string& outValue) { return RState::ERROR; }; + RState GetMediaByName(const char* name, std::string& outValue, uint32_t density) { return RState::ERROR; }; + RState GetRawFilePathByName(const std::string& name, std::string& outValue) { return RState::ERROR; }; + RState GetRawFileDescriptor(const std::string& name, RawFileDescriptor& descriptor) { return RState::ERROR; }; + RState CloseRawFileDescriptor(const std::string& name) { return RState::ERROR; }; + RState GetMediaDataById(uint32_t id, size_t& len, std::unique_ptr& outValue, uint32_t density) + { + return RState::ERROR; + }; + RState GetMediaDataByName(const char* name, size_t& len, std::unique_ptr& outValue, uint32_t density) + { + return RState::ERROR; + }; + RState GetMediaBase64DataById(uint32_t id, std::string& outValue, uint32_t density) { return RState::ERROR; }; + RState GetMediaBase64DataByName(const char* name, std::string& outValue, uint32_t density) + { + return RState::ERROR; + }; + RState GetProfileDataById(uint32_t id, size_t& len, std::unique_ptr& outValue) { return RState::ERROR; }; + RState GetProfileDataByName(const char* name, size_t& len, std::unique_ptr& outValue) + { + return RState::ERROR; + }; + RState GetRawFileFromHap(const std::string& rawFileName, size_t& len, std::unique_ptr& outValue) + { + return RState::ERROR; + }; + RState GetRawFileDescriptorFromHap(const std::string& rawFileName, RawFileDescriptor& descriptor) + { + return RState::ERROR; + }; + RState IsLoadHap(std::string& hapPath) { return RState::ERROR; }; + RState GetRawFileList(const std::string& rawDirPath, std::vector& rawfileList) + { + return RState::ERROR; + }; + RState GetDrawableInfoById(uint32_t id, std::string& type, size_t& len, + std::unique_ptr& outValue, uint32_t density) + { + return RState::ERROR; + }; + RState GetDrawableInfoByName(const char* name, std::string& type, size_t& len, + std::unique_ptr& outValue, uint32_t density) + { + return RState::ERROR; + }; + bool AddResource(const std::string& path, const std::vector& overlayPaths) + { + return true; + }; + bool RemoveResource(const std::string& path, const std::vector& overlayPaths) + { + return true; + }; + RState GetStringFormatById(uint32_t id, std::string& outValue, + std::vector>& jsParams) + { + return RState::ERROR; + }; + RState GetStringFormatByName(const char* name, std::string& outValue, + std::vector>& jsParams) + { + return RState::ERROR; + }; + uint32_t GetResourceLimitKeys() { return 0; }; + bool AddAppOverlay(const std::string& path) { return true; }; + bool RemoveAppOverlay(const std::string& path) { return true; }; + RState GetRawFdNdkFromHap(const std::string& rawFileName, RawFileDescriptor& descriptor) + { + return RState::ERROR; + }; + RState GetResId(const std::string& resTypeName, uint32_t& resId) { return RState::ERROR; }; + void GetLocales(std::vector& outValue, bool includeSystem = false) {}; + RState GetDrawableInfoById(uint32_t id, std::tuple& drawableInfo, + std::unique_ptr& outValue, uint32_t iconType, uint32_t density) + { + return RState::ERROR; + }; + RState GetDrawableInfoByName(const char* name, std::tuple& drawableInfo, + std::unique_ptr& outValue, uint32_t iconType, uint32_t density) + { + return RState::ERROR; + }; + RState GetSymbolById(uint32_t id, uint32_t& outValue) { return RState::ERROR; }; + RState GetSymbolByName(const char* name, uint32_t& outValue) { return RState::ERROR; }; + RState GetThemeIcons(uint32_t resId, std::pair, size_t>& foregroundInfo, + std::pair, size_t>& backgroundInfo, uint32_t density, + const std::string& abilityName) + { + return RState::ERROR; + }; + std::string GetThemeMask() { return ""; }; + bool HasIconInTheme(const std::string& bundleName) { return true; }; + RState GetOtherIconsInfo(const std::string & iconName, std::unique_ptr& outValue, + size_t& len, bool isGlobalMask) + { + return RState::ERROR; + }; + RState IsRawDirFromHap(const std::string& pathName, bool& outValue) + { + return RState::ERROR; + }; + std::shared_ptr GetOverrideResourceManager(std::shared_ptr overrideResConfig) + { + return std::shared_ptr(); + }; + RState UpdateOverrideResConfig(ResConfig& resConfig) { return RState::ERROR; }; + void GetOverrideResConfig(ResConfig& resConfig) {}; + RState GetDynamicIcon(const std::string& resName, std::pair, size_t>& iconInfo, + uint32_t density) + { + return RState::ERROR; + }; + RState GetStringFormatById(std::string& outValue, uint32_t id, va_list args) { return RState::ERROR; }; + RState GetStringFormatByName(std::string& outValue, const char* name, va_list args) { return RState::ERROR; }; + RState GetFormatPluralStringById(std::string& outValue, uint32_t id, int quantity, + std::vector>& jsParams) + { + return RState::ERROR; + }; + RState GetFormatPluralStringByName(std::string& outValue, const char* name, int quantity, + std::vector>& jsParams) + { + return RState::ERROR; + }; + bool AddPatchResource(const char* path, const char* patchPath) { return true; }; +}; +} // namespace Resource +} // namespace Global +} // namespace OHOS +#endif diff --git a/window_scene/test/mock/mock_root_scene_context.h b/window_scene/test/mock/mock_root_scene_context.h new file mode 100644 index 0000000000..7b758de7c1 --- /dev/null +++ b/window_scene/test/mock/mock_root_scene_context.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 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 MOCK_ROOT_SCENE_CONTEXT_H +#define MOCK_ROOT_SCENE_CONTEXT_H + +#include +#include "session_manager/include/scene_session_manager.h" + +namespace OHOS { +namespace AbilityRuntime { +const size_t Context::CONTEXT_TYPE_ID(std::hash {} ("MockContext")); +class RootSceneContextMocker : public AbilityRuntime::Context { +public: + RootSceneContextMocker() {}; + ~RootSceneContextMocker() {}; + + MOCK_CONST_METHOD0(GetResourceManager, std::shared_ptr()); + MOCK_CONST_METHOD0(GetBundleName, std::string()); + MOCK_METHOD1(CreateBundleContext, std::shared_ptr(const std::string& bundleName)); + MOCK_CONST_METHOD0(GetApplicationInfo, std::shared_ptr()); + MOCK_CONST_METHOD0(GetBundleCodePath, std::string()); + MOCK_CONST_METHOD0(GetHapModuleInfo, std::shared_ptr()); + MOCK_METHOD0(GetBundleCodeDir, std::string()); + MOCK_METHOD0(GetCacheDir, std::string()); + MOCK_METHOD0(GetTempDir, std::string()); + MOCK_METHOD0(GetFilesDir, std::string()); + MOCK_METHOD0(GetResourceDir, std::string()); + MOCK_METHOD0(GetDatabaseDir, std::string()); + MOCK_METHOD0(GetPreferencesDir, std::string()); + MOCK_METHOD0(IsUpdatingConfigurations, bool()); + MOCK_METHOD0(PrintDrawnCompleted, bool()); + MOCK_METHOD3(GetSystemDatabaseDir, int32_t(const std::string& groupId, bool checkExist, + std::string& databaseDir)); + MOCK_METHOD3(GetSystemPreferencesDir, int32_t(const std::string& groupId, bool checkExist, + std::string& preferencesDir)); + MOCK_METHOD1(GetGroupDir, std::string(std::string groupId)); + MOCK_METHOD0(GetDistributedFilesDir, std::string()); + MOCK_METHOD0(GetCloudFileDir, std::string()); + MOCK_METHOD0(GetToken, sptr()); + MOCK_METHOD1(SetToken, void(const sptr& token)); + MOCK_METHOD1(SwitchArea, void(int mode)); + MOCK_METHOD1(CreateModuleContext, std::shared_ptr(const std::string& moduleName)); + MOCK_METHOD2(CreateModuleContext, std::shared_ptr(const std::string& bundleName, + const std::string& moduleName)); + MOCK_METHOD2(CreateModuleResourceManager, std::shared_ptr + (const std::string& bundleName, const std::string& moduleName)); + MOCK_METHOD3(CreateSystemHspModuleResourceManager, int32_t(const std::string& bundleName, + const std::string& moduleName, std::shared_ptr& ResourceManager)); + MOCK_METHOD0(GetArea, int()); + MOCK_CONST_METHOD0(GetConfiguration, std::shared_ptr()); + MOCK_CONST_METHOD0(GetBaseDir, std::string()); + MOCK_CONST_METHOD0(GetDeviceType, Global::Resource::DeviceType()); +}; +} // namespace AbilityRuntime +} // namespace OHOS +#endif diff --git a/window_scene/test/mock/mock_session_stage.h b/window_scene/test/mock/mock_session_stage.h index 570e28acc1..4cef935c86 100644 --- a/window_scene/test/mock/mock_session_stage.h +++ b/window_scene/test/mock/mock_session_stage.h @@ -71,6 +71,7 @@ public: MOCK_METHOD2(NotifyDumpInfo, WSError(const std::vector& params, std::vector& info)); MOCK_METHOD1(SetSplitButtonVisible, WSError(bool isVisible)); + MOCK_METHOD1(SetEnableDragBySystem, WSError(bool enableDrag)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index 78e62b7e3c..1dd4ae6fc8 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -55,6 +55,7 @@ group("unittest") { ":ws_scene_session_manager_test", ":ws_scene_session_manager_test10", ":ws_scene_session_manager_test11", + ":ws_scene_session_manager_test12", ":ws_scene_session_manager_test2", ":ws_scene_session_manager_test3", ":ws_scene_session_manager_test4", @@ -779,6 +780,26 @@ ohos_unittest("ws_scene_session_manager_test11") { ] } +ohos_unittest("ws_scene_session_manager_test12") { + module_out_path = module_out_path + + sources = [ "scene_session_manager_test12.cpp" ] + + deps = [ ":ws_unittest_common" ] + + external_deps = [ + "ability_base:configuration", + "ability_base:session_info", + "ability_runtime:ability_context_native", + "ability_runtime:mission_info", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "eventhandler:libeventhandler", + "hilog:libhilog", + ] +} + ohos_unittest("ws_scene_session_manager_proxy_test") { module_out_path = module_out_path diff --git a/window_scene/test/unittest/main_session_test.cpp b/window_scene/test/unittest/main_session_test.cpp index c659d44b27..22ef115123 100644 --- a/window_scene/test/unittest/main_session_test.cpp +++ b/window_scene/test/unittest/main_session_test.cpp @@ -368,6 +368,25 @@ HWTEST_F(MainSessionTest, NotifyClientToUpdateInteractive02, Function | SmallTes ASSERT_TRUE(true); // exec success } +/** + * @tc.name: OnTitleAndDockHoverShowChange + * @tc.desc: OnTitleAndDockHoverShowChange + * @tc.type: FUNC + */ +HWTEST_F(MainSessionTest, OnTitleAndDockHoverShowChange, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "OnTitleAndDockHoverShowChange"; + info.bundleName_ = "OnTitleAndDockHoverShowChange"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + NotifyTitleAndDockHoverShowChangeFunc func = [](bool isTitleHoverShown, bool isDockHoverShown) { + return; + }; + sceneSession->SetTitleAndDockHoverShowChangeCallback(func); + EXPECT_NE(sceneSession->onTitleAndDockHoverShowChangeFunc_, nullptr); + EXPECT_EQ(sceneSession->OnTitleAndDockHoverShowChange(true, true), WSError::WS_OK); +} + /** * @tc.name: OnRestoreMainWindow * @tc.desc: OnRestoreMainWindow function01 diff --git a/window_scene/test/unittest/scene_session_manager_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_manager_lifecycle_test.cpp index 21b53ac60d..2af4017f75 100644 --- a/window_scene/test/unittest/scene_session_manager_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_lifecycle_test.cpp @@ -430,12 +430,12 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionDestruction, Funct ssm_->RequestSceneSessionDestruction(sceneSession, true); ssm_->RequestSceneSessionDestruction(sceneSession, false); ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId()); - sptr scnSessionInfo = new (std::nothrow) AAFwk::SessionInfo(); - ASSERT_NE(nullptr, scnSessionInfo); - ssm_->RequestSceneSessionDestructionInner(sceneSession, scnSessionInfo, true); - ssm_->RequestSceneSessionDestructionInner(sceneSession, scnSessionInfo, false); - ssm_->RequestSceneSessionDestructionInner(sceneSession, scnSessionInfo, true); - ssm_->RequestSceneSessionDestructionInner(sceneSession, scnSessionInfo, false); + sptr sceneSessionInfo = new (std::nothrow) AAFwk::SessionInfo(); + ASSERT_NE(nullptr, sceneSessionInfo); + ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, true); + ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, false); + ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, true); + ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, false); ssm_->AddClientDeathRecipient(sessionStage, sceneSession); ASSERT_EQ(AncoSceneState::DEFAULT_STATE, sceneSession->GetSessionInfo().ancoSceneState); } diff --git a/window_scene/test/unittest/scene_session_manager_supplement_test.cpp b/window_scene/test/unittest/scene_session_manager_supplement_test.cpp index b3881ff2db..322cf591b0 100644 --- a/window_scene/test/unittest/scene_session_manager_supplement_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_supplement_test.cpp @@ -144,17 +144,17 @@ HWTEST_F(SceneSessionManagerSupplementTest, NotifyCollaboratorAfterStart, { int res = 0; sptr sceneSession; - sptr scnSessionInfo; - ssm_->NotifyCollaboratorAfterStart(sceneSession, scnSessionInfo); + sptr sceneSessionInfo; + ssm_->NotifyCollaboratorAfterStart(sceneSession, sceneSessionInfo); SessionInfo info; info.bundleName_ = "test1"; info.abilityName_ = "test2"; ssm_->RequestSceneSessionBackground(sceneSession, true, true); sceneSession = new (std::nothrow) SceneSession(info, nullptr); - ssm_->NotifyCollaboratorAfterStart(sceneSession, scnSessionInfo); - scnSessionInfo = new AAFwk::SessionInfo(); - ssm_->NotifyCollaboratorAfterStart(sceneSession, scnSessionInfo); - ssm_->NotifyCollaboratorAfterStart(sceneSession, scnSessionInfo); + ssm_->NotifyCollaboratorAfterStart(sceneSession, sceneSessionInfo); + sceneSessionInfo = new AAFwk::SessionInfo(); + ssm_->NotifyCollaboratorAfterStart(sceneSession, sceneSessionInfo); + ssm_->NotifyCollaboratorAfterStart(sceneSession, sceneSessionInfo); ssm_->RequestSceneSessionBackground(sceneSession, true, true); ssm_->RequestSceneSessionBackground(sceneSession, true, false); ssm_->brightnessSessionId_ = sceneSession->GetPersistentId(); diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 9674945cfb..fc6699f850 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -114,20 +114,20 @@ HWTEST_F(SceneSessionManagerTest10, RequestSceneSessionDestructionInner, Functio SessionInfo info; sptr specificCallback = nullptr; - sptr scnSession = new SceneSession(info, specificCallback); - sptr scnSessionInfo = new AAFwk::SessionInfo(); + sptr sceneSession = new SceneSession(info, specificCallback); + sptr sceneSessionInfo = new AAFwk::SessionInfo(); bool needRemoveSession = true; bool isForceClean = true; SessionInfo sessionInfo; sessionInfo.collaboratorType_ = CollaboratorType::RESERVE_TYPE; - ssm_->RequestSceneSessionDestructionInner(scnSession, scnSessionInfo, needRemoveSession, isForceClean); + ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, needRemoveSession, isForceClean); needRemoveSession = false; isForceClean = false; sessionInfo.collaboratorType_ = CollaboratorType::DEFAULT_TYPE; sessionInfo.want = std::make_shared(); - ssm_->RequestSceneSessionDestructionInner(scnSession, scnSessionInfo, needRemoveSession, isForceClean); + ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, needRemoveSession, isForceClean); } /** diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp new file mode 100644 index 0000000000..d7496c91ae --- /dev/null +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2024 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 + +#include "context.h" +#include "interfaces/include/ws_common.h" +#include "iremote_object_mocker.h" +#include "mock/mock_session_stage.h" +#include "mock/mock_resource_manager.h" +#include "mock/mock_root_scene_context.h" +#include "mock/mock_window_event_channel.h" +#include "session_info.h" +#include "session_manager.h" +#include "session_manager/include/scene_session_manager.h" +#include "session/host/include/scene_session.h" +#include "session/host/include/main_session.h" +#include "window_manager_agent.h" +#include "zidl/window_manager_agent_interface.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class SceneSessionManagerTest12 : public testing::Test { +public: + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp() override; + + void TearDown() override; + + static sptr ssm_; + std::shared_ptr mockRootSceneContext_; + std::string path; + uint32_t bgColor; + AppExecFwk::AbilityInfo abilityInfo; + +private: + static constexpr uint32_t WAIT_SYNC_IN_NS = 200000; +}; + +sptr SceneSessionManagerTest12::ssm_ = nullptr; + +void SceneSessionManagerTest12::SetUpTestCase() +{ + ssm_ = &SceneSessionManager::GetInstance(); +} + +void SceneSessionManagerTest12::TearDownTestCase() +{ + ssm_ = nullptr; +} + +void SceneSessionManagerTest12::SetUp() +{ + mockRootSceneContext_ = std::make_shared(); + path = "testPath"; + bgColor = 0; + abilityInfo.bundleName = "testBundle"; + abilityInfo.moduleName = "testmodule"; + abilityInfo.resourcePath = "/test/resource/path"; + abilityInfo.startWindowBackgroundId = 1; + abilityInfo.startWindowIconId = 1; +} + +void SceneSessionManagerTest12::TearDown() +{ + usleep(WAIT_SYNC_IN_NS); +} + +std::shared_ptr + mockResourceManager_ = std::make_shared(); + +class SceneSessionManagerMocker : public SceneSessionManager { +public: + SceneSessionManagerMocker() {}; + ~SceneSessionManagerMocker() {}; + + std::shared_ptr GetResourceManager(const AppExecFwk::AbilityInfo& abilityInfo) + { + return mockResourceManager_; + }; +}; +std::shared_ptr mockSceneSessionManager_ = std::make_shared(); + +namespace { +/** + * @tc.name: GetResourceManager01 + * @tc.desc: GetResourceManager context is nullptr + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetResourceManager01, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + auto result = ssm_->GetResourceManager(abilityInfo); + EXPECT_EQ(result, nullptr); +} + +/** + * @tc.name: GetResourceManager02 + * @tc.desc: GetResourceManager resourceManager is nullptr + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetResourceManager02, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + ASSERT_NE(mockRootSceneContext_, nullptr); + ssm_->rootSceneContextWeak_ = std::weak_ptr(mockRootSceneContext_); + EXPECT_CALL(*mockRootSceneContext_, GetResourceManager()).WillOnce(Return(nullptr)); + auto result = ssm_->GetResourceManager(abilityInfo); + EXPECT_EQ(result, nullptr); +} + +/** + * @tc.name: GetResourceManager03 + * @tc.desc: GetResourceManager + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetResourceManager03, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + ASSERT_NE(mockRootSceneContext_, nullptr); + ssm_->rootSceneContextWeak_ = std::weak_ptr(mockRootSceneContext_); + EXPECT_CALL(*mockRootSceneContext_, GetResourceManager()).WillOnce(Return(mockResourceManager_)); + auto result = ssm_->GetResourceManager(abilityInfo); + EXPECT_NE(result, nullptr); +} + +/** + * @tc.name: GetStartupPageFromResource01 + * @tc.desc: GetStartupPageFromResource ResourceManager nullptr + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetStartupPageFromResource01, Function | SmallTest | Level3) +{ + ASSERT_NE(mockSceneSessionManager_, nullptr); + mockResourceManager_ = nullptr; + EXPECT_EQ(mockSceneSessionManager_->GetResourceManager(abilityInfo), nullptr); + bool result = mockSceneSessionManager_->GetStartupPageFromResource(abilityInfo, path, bgColor); + mockResourceManager_ = std::make_shared(); + EXPECT_EQ(result, false); +} + +/** + * @tc.name: GetStartupPageFromResource02 + * @tc.desc: GetStartupPageFromResource ResourceManager GetColorById ERROR + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetStartupPageFromResource02, Function | SmallTest | Level3) +{ + ASSERT_NE(mockSceneSessionManager_, nullptr); + ASSERT_NE(mockResourceManager_, nullptr); + EXPECT_EQ(mockSceneSessionManager_->GetResourceManager(abilityInfo), mockResourceManager_); + bool result = mockSceneSessionManager_->GetStartupPageFromResource(abilityInfo, path, bgColor); + EXPECT_EQ(result, false); +} + +/** + * @tc.name: GetStartupPageFromResource03 + * @tc.desc: GetStartupPageFromResource ResourceManager GetMediaById ERROR + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetStartupPageFromResource03, Function | SmallTest | Level3) +{ + ASSERT_NE(mockSceneSessionManager_, nullptr); + ASSERT_NE(mockResourceManager_, nullptr); + EXPECT_EQ(mockSceneSessionManager_->GetResourceManager(abilityInfo), mockResourceManager_); + EXPECT_CALL(*mockResourceManager_, GetColorById(abilityInfo.startWindowBackgroundId, + bgColor)).WillOnce(Return(Global::Resource::RState::SUCCESS)); + bool result = mockSceneSessionManager_->GetStartupPageFromResource(abilityInfo, path, bgColor); + EXPECT_EQ(result, false); +} +/** + * @tc.name: GetStartupPageFromResource04 + * @tc.desc: GetStartupPageFromResource + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, GetStartupPageFromResource04, Function | SmallTest | Level3) +{ + ASSERT_NE(mockSceneSessionManager_, nullptr); + ASSERT_NE(mockResourceManager_, nullptr); + EXPECT_EQ(mockSceneSessionManager_->GetResourceManager(abilityInfo), mockResourceManager_); + EXPECT_CALL(*mockResourceManager_, GetColorById(abilityInfo.startWindowBackgroundId, + bgColor)).WillOnce(Return(Global::Resource::RState::SUCCESS)); + EXPECT_CALL(*mockResourceManager_, GetMediaById(abilityInfo.startWindowIconId, path, + 0)).WillOnce(Return(Global::Resource::RState::SUCCESS)); + bool result = mockSceneSessionManager_->GetStartupPageFromResource(abilityInfo, path, bgColor); + EXPECT_EQ(result, false); +} +} +} // namespace Rosen +} // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_test2.cpp b/window_scene/test/unittest/scene_session_manager_test2.cpp index 14faf1ba27..e6ccc17839 100644 --- a/window_scene/test/unittest/scene_session_manager_test2.cpp +++ b/window_scene/test/unittest/scene_session_manager_test2.cpp @@ -2197,6 +2197,28 @@ HWTEST_F(SceneSessionManagerTest2, UpdateGestureBackEnabled, Function | SmallTes sleep(WAIT_SLEEP_TIME); ssm_->sceneSessionMap_.erase(1); } + +/** + * @tc.name: NotifyEnterRecentTask + * @tc.desc: NotifyEnterRecentTask; + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest2, NotifyEnterRecentTask, Function | SmallTest | Level3) +{ + ASSERT_NE(nullptr, ssm_); + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "NotifyEnterRecentTask"; + sessionInfo.abilityName_ = "NotifyEnterRecentTask"; + sptr property = sptr::MakeSptr(); + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + sceneSession->SetSessionProperty(property); + ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->gestureBackEnableWindowIdSet_.insert(1); + ssm_->gestureBackEnableWindowIdSet_.insert(2); + ASSERT_EQ(ssm_->NotifyEnterRecentTask(true), WSError::WS_OK); + ASSERT_EQ(ssm_->NotifyEnterRecentTask(false), WSError::WS_OK); + ssm_->sceneSessionMap_.erase(1); +} } } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index 6c14b5df1b..1090be0c39 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -1250,22 +1250,6 @@ HWTEST_F(SceneSessionManagerTest4, GetSessionSnapshotPixelMap, Function | SmallT EXPECT_EQ(result, nullptr); } -/** - * @tc.name: GetStartupPageFromResource - * @tc.desc: GetStartupPageFromResource - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionManagerTest4, GetStartupPageFromResource, Function | SmallTest | Level3) -{ - ASSERT_NE(ssm_, nullptr); - AppExecFwk::AbilityInfo abilityInfo; - EXPECT_EQ(ssm_->GetResourceManager(abilityInfo), nullptr); - std::string path = "testPath"; - uint32_t bgColor = 0; - bool result = ssm_->GetStartupPageFromResource(abilityInfo, path, bgColor); - EXPECT_EQ(result, false); -} - /** * @tc.name: HandleHideNonSystemFloatingWindows * @tc.desc: HandleHideNonSystemFloatingWindows diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index cf4b4a082e..19e7755228 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -1844,31 +1844,24 @@ HWTEST_F(SceneSessionManagerTest6, IsKeyboardForeground, Function | SmallTest | */ HWTEST_F(SceneSessionManagerTest6, DestroyDialogWithMainWindow, Function | SmallTest | Level3) { - sptr scnSession = nullptr; - auto result = ssm_->DestroyDialogWithMainWindow(scnSession); + sptr sceneSession = nullptr; + auto result = ssm_->DestroyDialogWithMainWindow(sceneSession); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); SessionInfo info; sptr specificCallback = nullptr; - scnSession = new (std::nothrow) SceneSession(info, specificCallback); - ASSERT_NE(scnSession, nullptr); + sceneSession = new (std::nothrow) SceneSession(info, specificCallback); + ASSERT_NE(sceneSession, nullptr); sptr session = new Session(info); ASSERT_NE(session, nullptr); session->GetDialogVector().clear(); - result = ssm_->DestroyDialogWithMainWindow(scnSession); + result = ssm_->DestroyDialogWithMainWindow(sceneSession); ASSERT_EQ(result, WSError::WS_OK); - sptr sceneSession = new (std::nothrow) SceneSession(info, specificCallback); - ASSERT_NE(sceneSession, nullptr); ssm_->sceneSessionMap_.insert({0, sceneSession}); ssm_->GetSceneSession(1); - result = ssm_->DestroyDialogWithMainWindow(scnSession); - ASSERT_EQ(result, WSError::WS_OK); - - WindowVisibilityInfo windowVisibilityInfo; - windowVisibilityInfo.windowType_ = WindowType::APP_WINDOW_BASE; - result = ssm_->DestroyDialogWithMainWindow(scnSession); + result = ssm_->DestroyDialogWithMainWindow(sceneSession); ASSERT_EQ(result, WSError::WS_OK); } diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index cf73aa76b0..35fef273d2 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -72,11 +72,11 @@ HWTEST_F(SceneSessionTest, SetGlobalMaximizeMode01, Function | SmallTest | Level sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->isActive_ = true; - auto result = scensession->SetGlobalMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->isActive_ = true; + auto result = sceneSession->SetGlobalMaximizeMode(MaximizeMode::MODE_AVOID_SYSTEM_BAR); ASSERT_EQ(result, WSError::WS_OK); } @@ -95,12 +95,12 @@ HWTEST_F(SceneSessionTest, GetGlobalMaximizeMode01, Function | SmallTest | Level new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->isActive_ = true; + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->isActive_ = true; MaximizeMode mode; - auto result = scensession->GetGlobalMaximizeMode(mode); + auto result = sceneSession->GetGlobalMaximizeMode(mode); ASSERT_EQ(result, WSError::WS_OK); } @@ -119,14 +119,14 @@ HWTEST_F(SceneSessionTest, SetAndGetPipTemplateInfo, Function | SmallTest | Leve new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->isActive_ = true; + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->isActive_ = true; PiPTemplateInfo pipTemplateInfo; pipTemplateInfo.pipTemplateType = static_cast(PiPTemplateType::VIDEO_CALL); - scensession->SetPiPTemplateInfo(pipTemplateInfo); - ASSERT_EQ(scensession->GetPiPTemplateInfo().pipTemplateType, + sceneSession->SetPiPTemplateInfo(pipTemplateInfo); + ASSERT_EQ(sceneSession->GetPiPTemplateInfo().pipTemplateType, static_cast(PiPTemplateType::VIDEO_CALL)); } @@ -144,13 +144,13 @@ HWTEST_F(SceneSessionTest, UpdateWindowSceneAfterCustomAnimation01, Function | S sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->isActive_ = true; - auto result = scensession->UpdateWindowSceneAfterCustomAnimation(false); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->isActive_ = true; + auto result = sceneSession->UpdateWindowSceneAfterCustomAnimation(false); ASSERT_EQ(result, WSError::WS_OK); - result = scensession->UpdateWindowSceneAfterCustomAnimation(true); + result = sceneSession->UpdateWindowSceneAfterCustomAnimation(true); ASSERT_EQ(result, WSError::WS_OK); } @@ -169,10 +169,10 @@ HWTEST_F(SceneSessionTest, SetZOrder01, Function | SmallTest | Level2) new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); int resultValue = 0; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->SetZOrder(2); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->SetZOrder(2); ASSERT_EQ(0, resultValue); } @@ -190,9 +190,9 @@ HWTEST_F(SceneSessionTest, GetTouchHotAreas01, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); Rect windowRect = {1, 1, 1, 1}; std::vector rects; uint32_t hotAreasNum = 10; @@ -205,7 +205,7 @@ HWTEST_F(SceneSessionTest, GetTouchHotAreas01, Function | SmallTest | Level2) ASSERT_NE(nullptr, property); property->SetTouchHotAreas(rects); - ASSERT_NE(rects, scensession->GetTouchHotAreas()); + ASSERT_NE(rects, sceneSession->GetTouchHotAreas()); } /** @@ -222,15 +222,15 @@ HWTEST_F(SceneSessionTest, SetTurnScreenOn01, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); ASSERT_NE(mockSessionStage, nullptr); - ASSERT_EQ(WSError::WS_OK, scensession->SetTurnScreenOn(false)); - ASSERT_EQ(false, scensession->IsTurnScreenOn()); - ASSERT_EQ(WSError::WS_OK, scensession->SetTurnScreenOn(true)); - ASSERT_EQ(true, scensession->IsTurnScreenOn()); + ASSERT_EQ(WSError::WS_OK, sceneSession->SetTurnScreenOn(false)); + ASSERT_EQ(false, sceneSession->IsTurnScreenOn()); + ASSERT_EQ(WSError::WS_OK, sceneSession->SetTurnScreenOn(true)); + ASSERT_EQ(true, sceneSession->IsTurnScreenOn()); } /** @@ -247,12 +247,12 @@ HWTEST_F(SceneSessionTest, UpdateWindowAnimationFlag01, Function | SmallTest | L sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); ASSERT_NE(mockSessionStage, nullptr); - ASSERT_EQ(WSError::WS_OK, scensession->UpdateWindowAnimationFlag(false)); + ASSERT_EQ(WSError::WS_OK, sceneSession->UpdateWindowAnimationFlag(false)); } /** @@ -269,9 +269,9 @@ HWTEST_F(SceneSessionTest, ClearEnterWindow01, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); int resultValue = 0; SceneSession::ClearEnterWindow(); ASSERT_EQ(resultValue, 0); @@ -291,11 +291,11 @@ HWTEST_F(SceneSessionTest, GetEnterWindow01, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - wptr scenesession_; - ASSERT_EQ(scenesession_, SceneSession::GetEnterWindow()); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + wptr sceneSession_; + ASSERT_EQ(sceneSession_, SceneSession::GetEnterWindow()); } /** @@ -308,36 +308,36 @@ HWTEST_F(SceneSessionTest, SetRequestedOrientation01, Function | SmallTest | Lev SessionInfo info; info.abilityName_ = "Background01"; info.bundleName_ = "SetRequestedOrientation"; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); Orientation ori = Orientation::UNSPECIFIED; - scensession->SetRequestedOrientation(ori); - Orientation ret = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(ori); + Orientation ret = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ori, ret); - scensession->SetRequestedOrientation(Orientation::AUTO_ROTATION_UNSPECIFIED); - Orientation ret1 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::AUTO_ROTATION_UNSPECIFIED); + Orientation ret1 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret1, Orientation::AUTO_ROTATION_UNSPECIFIED); - scensession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT); - Orientation ret2 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT); + Orientation ret2 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret2, Orientation::USER_ROTATION_PORTRAIT); - scensession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE); - Orientation ret3 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE); + Orientation ret3 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret3, Orientation::USER_ROTATION_LANDSCAPE); - scensession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT_INVERTED); - Orientation ret4 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT_INVERTED); + Orientation ret4 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret4, Orientation::USER_ROTATION_PORTRAIT_INVERTED); - scensession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE_INVERTED); - Orientation ret5 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE_INVERTED); + Orientation ret5 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret5, Orientation::USER_ROTATION_LANDSCAPE_INVERTED); - scensession->SetRequestedOrientation(Orientation::FOLLOW_DESKTOP); - Orientation ret6 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::FOLLOW_DESKTOP); + Orientation ret6 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret6, Orientation::FOLLOW_DESKTOP); } @@ -351,36 +351,36 @@ HWTEST_F(SceneSessionTest, GetRequestedOrientation, Function | SmallTest | Level SessionInfo info; info.abilityName_ = "Background01"; info.bundleName_ = "GetRequestedOrientation"; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); Orientation ori = Orientation::HORIZONTAL; - scensession->SetRequestedOrientation(ori); - Orientation ret = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(ori); + Orientation ret = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ori, ret); - scensession->SetRequestedOrientation(Orientation::AUTO_ROTATION_UNSPECIFIED); - Orientation ret1 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::AUTO_ROTATION_UNSPECIFIED); + Orientation ret1 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret1, Orientation::AUTO_ROTATION_UNSPECIFIED); - scensession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT); - Orientation ret2 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT); + Orientation ret2 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret2, Orientation::USER_ROTATION_PORTRAIT); - scensession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE); - Orientation ret3 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE); + Orientation ret3 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret3, Orientation::USER_ROTATION_LANDSCAPE); - scensession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT_INVERTED); - Orientation ret4 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT_INVERTED); + Orientation ret4 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret4, Orientation::USER_ROTATION_PORTRAIT_INVERTED); - scensession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE_INVERTED); - Orientation ret5 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE_INVERTED); + Orientation ret5 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret5, Orientation::USER_ROTATION_LANDSCAPE_INVERTED); - scensession->SetRequestedOrientation(Orientation::FOLLOW_DESKTOP); - Orientation ret6 = scensession->GetRequestedOrientation(); + sceneSession->SetRequestedOrientation(Orientation::FOLLOW_DESKTOP); + Orientation ret6 = sceneSession->GetRequestedOrientation(); ASSERT_EQ(ret6, Orientation::FOLLOW_DESKTOP); } @@ -394,12 +394,12 @@ HWTEST_F(SceneSessionTest, SetDefaultRequestedOrientation, Function | SmallTest SessionInfo info; info.abilityName_ = "Background01"; info.bundleName_ = "SetDefaultRequestedOrientation"; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); Orientation orientation = Orientation::AUTO_ROTATION_UNSPECIFIED; - scensession->SetDefaultRequestedOrientation(orientation); - Orientation ret = scensession->GetRequestedOrientation(); + sceneSession->SetDefaultRequestedOrientation(orientation); + Orientation ret = sceneSession->GetRequestedOrientation(); ASSERT_EQ(orientation, ret); } @@ -418,13 +418,13 @@ HWTEST_F(SceneSessionTest, IsKeepScreenOn, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); ASSERT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - ASSERT_NE(scensession, nullptr); - ASSERT_EQ(WSError::WS_OK, scensession->SetKeepScreenOn(true)); - ASSERT_EQ(true, scensession->IsKeepScreenOn()); - ASSERT_EQ(WSError::WS_OK, scensession->SetKeepScreenOn(false)); - ASSERT_EQ(false, scensession->IsKeepScreenOn()); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + ASSERT_NE(sceneSession, nullptr); + ASSERT_EQ(WSError::WS_OK, sceneSession->SetKeepScreenOn(true)); + ASSERT_EQ(true, sceneSession->IsKeepScreenOn()); + ASSERT_EQ(WSError::WS_OK, sceneSession->SetKeepScreenOn(false)); + ASSERT_EQ(false, sceneSession->IsKeepScreenOn()); } /** @@ -442,10 +442,10 @@ HWTEST_F(SceneSessionTest, IsAppSession01, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - ASSERT_EQ(true, scensession->IsAppSession()); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + ASSERT_EQ(true, sceneSession->IsAppSession()); } /** @@ -463,10 +463,10 @@ HWTEST_F(SceneSessionTest, IsAppSession02, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - ASSERT_EQ(false, scensession->IsAppSession()); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + ASSERT_EQ(false, sceneSession->IsAppSession()); SessionInfo parentInfo; parentInfo.abilityName_ = "testSession1"; @@ -479,13 +479,13 @@ HWTEST_F(SceneSessionTest, IsAppSession02, Function | SmallTest | Level2) EXPECT_NE(property, nullptr); property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); parentSession->SetSessionProperty(property); - scensession->SetParentSession(parentSession); - ASSERT_EQ(false, scensession->IsAppSession()); + sceneSession->SetParentSession(parentSession); + ASSERT_EQ(false, sceneSession->IsAppSession()); property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); parentSession->SetSessionProperty(property); - scensession->SetParentSession(parentSession); - ASSERT_EQ(true, scensession->IsAppSession()); + sceneSession->SetParentSession(parentSession); + ASSERT_EQ(true, sceneSession->IsAppSession()); } /** @@ -500,10 +500,10 @@ HWTEST_F(SceneSessionTest, IsAppOrLowerSystemSession01, Function | SmallTest | L info.bundleName_ = "IsAppOrLowerSystemSession01"; info.windowType_ = 2126; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - ASSERT_EQ(true, scensession->IsAppOrLowerSystemSession()); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + ASSERT_EQ(true, sceneSession->IsAppOrLowerSystemSession()); } /** @@ -518,10 +518,10 @@ HWTEST_F(SceneSessionTest, IsAppOrLowerSystemSession02, Function | SmallTest | L info.bundleName_ = "IsAppOrLowerSystemSession02"; info.windowType_ = 2106; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - ASSERT_EQ(false, scensession->IsAppOrLowerSystemSession()); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + ASSERT_EQ(false, sceneSession->IsAppOrLowerSystemSession()); SessionInfo parentInfo; parentInfo.abilityName_ = "testSession1"; @@ -534,13 +534,13 @@ HWTEST_F(SceneSessionTest, IsAppOrLowerSystemSession02, Function | SmallTest | L EXPECT_NE(property, nullptr); property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); parentSession->SetSessionProperty(property); - scensession->SetParentSession(parentSession); - ASSERT_EQ(false, scensession->IsAppOrLowerSystemSession()); + sceneSession->SetParentSession(parentSession); + ASSERT_EQ(false, sceneSession->IsAppOrLowerSystemSession()); property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); parentSession->SetSessionProperty(property); - scensession->SetParentSession(parentSession); - ASSERT_EQ(true, scensession->IsAppOrLowerSystemSession()); + sceneSession->SetParentSession(parentSession); + ASSERT_EQ(true, sceneSession->IsAppOrLowerSystemSession()); } /** @@ -603,10 +603,10 @@ HWTEST_F(SceneSessionTest, IsSystemSessionAboveApp02, Function | SmallTest | Lev info.bundleName_ = "IsSystemSessionAboveApp05"; info.windowType_ = 1; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - ASSERT_EQ(false, scensession->IsSystemSessionAboveApp()); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + ASSERT_EQ(false, sceneSession->IsSystemSessionAboveApp()); } /** @@ -623,10 +623,10 @@ HWTEST_F(SceneSessionTest, GetWindowName, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - ASSERT_NE("ww", scensession->GetWindowName()); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + ASSERT_NE("ww", sceneSession->GetWindowName()); } /** @@ -644,10 +644,10 @@ HWTEST_F(SceneSessionTest, IsDecorEnable, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - ASSERT_EQ(true, scensession->IsDecorEnable()); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + ASSERT_EQ(true, sceneSession->IsDecorEnable()); SessionInfo info_; info_.abilityName_ = "Background01"; info_.bundleName_ = "IsDecorEnable"; @@ -674,16 +674,16 @@ HWTEST_F(SceneSessionTest, IsDecorEnable01, Function | SmallTest | Level2) new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); sptr property = new (std::nothrow) WindowSessionProperty(); EXPECT_NE(property, nullptr); property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); property->SetDecorEnable(true); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - scensession->property_ = property; - ASSERT_EQ(true, scensession->IsDecorEnable()); + sceneSession->property_ = property; + ASSERT_EQ(true, sceneSession->IsDecorEnable()); sptr scensession_; scensession_ = new (std::nothrow) SceneSession(info, nullptr); @@ -714,17 +714,17 @@ HWTEST_F(SceneSessionTest, UpdateNativeVisibility, Function | SmallTest | Level2 sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->UpdateNativeVisibility(false); - ASSERT_EQ(false, scensession->IsVisible()); - scensession->NotifyWindowVisibility(); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->UpdateNativeVisibility(false); + ASSERT_EQ(false, sceneSession->IsVisible()); + sceneSession->NotifyWindowVisibility(); sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); ASSERT_NE(mockSessionStage, nullptr); - scensession->sessionStage_ = mockSessionStage; - scensession->NotifyWindowVisibility(); + sceneSession->sessionStage_ = mockSessionStage; + sceneSession->NotifyWindowVisibility(); } /** @@ -738,15 +738,15 @@ HWTEST_F(SceneSessionTest, SetPrivacyMode01, Function | SmallTest | Level2) info.abilityName_ = "Background01"; info.bundleName_ = "SetPrivacyMode"; info.windowType_ = 1; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); struct RSSurfaceNodeConfig config; std::shared_ptr surfaceNode = RSSurfaceNode::Create(config); - scensession->surfaceNode_ = surfaceNode; - scensession->SetPrivacyMode(false); - ASSERT_EQ(false, scensession->property_->GetPrivacyMode()); - ASSERT_EQ(false, scensession->property_->GetSystemPrivacyMode()); + sceneSession->surfaceNode_ = surfaceNode; + sceneSession->SetPrivacyMode(false); + ASSERT_EQ(false, sceneSession->property_->GetPrivacyMode()); + ASSERT_EQ(false, sceneSession->property_->GetSystemPrivacyMode()); } /** @@ -760,14 +760,14 @@ HWTEST_F(SceneSessionTest, SetPrivacyMode02, Function | SmallTest | Level2) info.abilityName_ = "Background02"; info.bundleName_ = "SetPrivacyMode"; info.windowType_ = 1; - sptr scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); struct RSSurfaceNodeConfig config; std::shared_ptr surfaceNode = RSSurfaceNode::Create(config); - scensession->surfaceNode_ = surfaceNode; - scensession->SetPrivacyMode(true); - ASSERT_EQ(true, scensession->property_->GetPrivacyMode()); - ASSERT_EQ(true, scensession->property_->GetSystemPrivacyMode()); + sceneSession->surfaceNode_ = surfaceNode; + sceneSession->SetPrivacyMode(true); + ASSERT_EQ(true, sceneSession->property_->GetPrivacyMode()); + ASSERT_EQ(true, sceneSession->property_->GetSystemPrivacyMode()); } /** @@ -785,13 +785,13 @@ HWTEST_F(SceneSessionTest, IsFloatingWindowAppType, Function | SmallTest | Level sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - ASSERT_EQ(false, scensession->IsFloatingWindowAppType()); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + ASSERT_EQ(false, sceneSession->IsFloatingWindowAppType()); - scensession->SetSessionProperty(nullptr); - ASSERT_EQ(false, scensession->IsFloatingWindowAppType()); + sceneSession->SetSessionProperty(nullptr); + ASSERT_EQ(false, sceneSession->IsFloatingWindowAppType()); } /** @@ -809,16 +809,16 @@ HWTEST_F(SceneSessionTest, DumpSessionElementInfo, Function | SmallTest | Level2 sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); ASSERT_NE(mockSessionStage, nullptr); std::vector params; - scensession->DumpSessionElementInfo(params); + sceneSession->DumpSessionElementInfo(params); int ret = 1; - scensession->sessionStage_ = mockSessionStage; - scensession->DumpSessionElementInfo(params); + sceneSession->sessionStage_ = mockSessionStage; + sceneSession->DumpSessionElementInfo(params); ASSERT_EQ(ret, 1); } @@ -833,15 +833,15 @@ HWTEST_F(SceneSessionTest, SaveAspectRatio, Function | SmallTest | Level2) info.abilityName_ = "Background01"; info.bundleName_ = "IsFloatingWindowAppType"; info.windowType_ = 1; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - ASSERT_EQ(true, scensession->SaveAspectRatio(0.1)); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + ASSERT_EQ(true, sceneSession->SaveAspectRatio(0.1)); - scensession->sessionInfo_.bundleName_ = ""; - scensession->sessionInfo_.moduleName_ = ""; - scensession->sessionInfo_.abilityName_ = ""; - ASSERT_EQ(false, scensession->SaveAspectRatio(0.1)); + sceneSession->sessionInfo_.bundleName_ = ""; + sceneSession->sessionInfo_.moduleName_ = ""; + sceneSession->sessionInfo_.abilityName_ = ""; + ASSERT_EQ(false, sceneSession->SaveAspectRatio(0.1)); } /** @@ -859,14 +859,14 @@ HWTEST_F(SceneSessionTest, NotifyIsCustomAnimationPlaying, Function | SmallTest sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->NotifyIsCustomAnimationPlaying(false); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->NotifyIsCustomAnimationPlaying(false); - scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); - scensession->sessionChangeCallback_->onIsCustomAnimationPlaying_ = [](bool status){}; - scensession->NotifyIsCustomAnimationPlaying(false); + sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); + sceneSession->sessionChangeCallback_->onIsCustomAnimationPlaying_ = [](bool status){}; + sceneSession->NotifyIsCustomAnimationPlaying(false); } /** @@ -920,18 +920,18 @@ HWTEST_F(SceneSessionTest, NotifySessionRectChange, Function | SmallTest | Level sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); WSRect overlapRect = { 0, 0, 0, 0 }; - scensession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, -1); - scensession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, 11); - scensession->sessionRectChangeFunc_ = [](const WSRect& rect, + sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, -1); + sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, 11); + sceneSession->sessionRectChangeFunc_ = [](const WSRect& rect, const SizeChangeReason reason, DisplayId displayId) { return; }; - scensession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, -1); - scensession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, 11); + sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, -1); + sceneSession->NotifySessionRectChange(overlapRect, SizeChangeReason::ROTATION, 11); } /** @@ -949,11 +949,11 @@ HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); WSRect originalRect_ = { 0, 0, 0, 0 }; - ASSERT_EQ(false, scensession->FixRectByAspectRatio(originalRect_)); + ASSERT_EQ(false, sceneSession->FixRectByAspectRatio(originalRect_)); } /** @@ -977,18 +977,18 @@ HWTEST_F(SceneSessionTest, GetKeyboardAvoidArea, Function | SmallTest | Level2) return backgroundSession; }; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + EXPECT_NE(sceneSession, nullptr); WSRect overlapRect = {0, 0, 0, 0}; AvoidArea avoidArea; int ret = 1; - scensession->GetKeyboardAvoidArea(overlapRect, avoidArea); + sceneSession->GetKeyboardAvoidArea(overlapRect, avoidArea); ASSERT_EQ(ret, 1); - scensession->SetSessionProperty(nullptr); - scensession->GetKeyboardAvoidArea(overlapRect, avoidArea); - ASSERT_EQ(nullptr, scensession->GetSessionProperty()); + sceneSession->SetSessionProperty(nullptr); + sceneSession->GetKeyboardAvoidArea(overlapRect, avoidArea); + ASSERT_EQ(nullptr, sceneSession->GetSessionProperty()); } /** @@ -1006,13 +1006,13 @@ HWTEST_F(SceneSessionTest, GetCutoutAvoidArea, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); WSRect overlapRect = { 0, 0, 0, 0 }; AvoidArea avoidArea; int ret = 1; - scensession->GetCutoutAvoidArea(overlapRect, avoidArea); + sceneSession->GetCutoutAvoidArea(overlapRect, avoidArea); ASSERT_EQ(ret, 1); } @@ -1032,24 +1032,24 @@ HWTEST_F(SceneSessionTest, SetSystemBarProperty, Function | SmallTest | Level2) new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - EXPECT_NE(scensession, nullptr); - scensession->property_ = nullptr; + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + EXPECT_NE(sceneSession, nullptr); + sceneSession->property_ = nullptr; SystemBarProperty statusBarProperty; - scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty); - ASSERT_EQ(scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty), + sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty); + ASSERT_EQ(sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty), WSError::WS_ERROR_NULLPTR); sptr property = new WindowSessionProperty(); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - scensession->property_ = property; - ASSERT_EQ(scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty), + sceneSession->property_ = property; + ASSERT_EQ(sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty), WSError::WS_OK); - scensession->onSystemBarPropertyChange_ = []( + sceneSession->onSystemBarPropertyChange_ = []( const std::unordered_map& propertyMap){}; - ASSERT_EQ(scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty), + ASSERT_EQ(sceneSession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty), WSError::WS_OK); } @@ -1068,17 +1068,17 @@ HWTEST_F(SceneSessionTest, OnShowWhenLocked, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + EXPECT_NE(sceneSession, nullptr); int ret = 0; - scensession->OnShowWhenLocked(false); + sceneSession->OnShowWhenLocked(false); ASSERT_EQ(ret, 0); - scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); - EXPECT_NE(scensession->sessionChangeCallback_, nullptr); - scensession->sessionChangeCallback_->OnShowWhenLocked_ = [](bool showWhenLocked){}; - ASSERT_EQ(scensession->OnShowWhenLocked(false), WSError::WS_OK); + sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); + EXPECT_NE(sceneSession->sessionChangeCallback_, nullptr); + sceneSession->sessionChangeCallback_->OnShowWhenLocked_ = [](bool showWhenLocked){}; + ASSERT_EQ(sceneSession->OnShowWhenLocked(false), WSError::WS_OK); } /** @@ -1096,22 +1096,22 @@ HWTEST_F(SceneSessionTest, IsShowWhenLocked, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + EXPECT_NE(sceneSession, nullptr); sptr property = new WindowSessionProperty(); EXPECT_NE(property, nullptr); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - ASSERT_EQ(scensession->IsShowWhenLocked(), false); - scensession->property_ = property; - scensession->SetTemporarilyShowWhenLocked(true); - ASSERT_EQ(scensession->IsShowWhenLocked(), true); + ASSERT_EQ(sceneSession->IsShowWhenLocked(), false); + sceneSession->property_ = property; + sceneSession->SetTemporarilyShowWhenLocked(true); + ASSERT_EQ(sceneSession->IsShowWhenLocked(), true); property->SetWindowFlags(4); - scensession->SetTemporarilyShowWhenLocked(false); - ASSERT_EQ(scensession->IsShowWhenLocked(), true); - scensession->SetTemporarilyShowWhenLocked(true); - ASSERT_EQ(scensession->IsShowWhenLocked(), true); + sceneSession->SetTemporarilyShowWhenLocked(false); + ASSERT_EQ(sceneSession->IsShowWhenLocked(), true); + sceneSession->SetTemporarilyShowWhenLocked(true); + ASSERT_EQ(sceneSession->IsShowWhenLocked(), true); } /** @@ -1140,28 +1140,28 @@ HWTEST_F(SceneSessionTest, GetAvoidAreaByType, Function | SmallTest | Level2) backgroundSession.push_back(session2); return backgroundSession; }; - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + EXPECT_NE(sceneSession, nullptr); WSRect rect = { 0, 0, 320, 240}; // width: 320, height: 240 - scensession->SetSessionRect(rect); + sceneSession->SetSessionRect(rect); sptr property = new WindowSessionProperty(); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - scensession->property_ = property; + sceneSession->property_ = property; AvoidArea avoidArea; - scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT); - scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM); - scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD); - scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM_GESTURE); - EXPECT_NE(scensession, nullptr); + sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT); + sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM); + sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD); + sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM_GESTURE); + EXPECT_NE(sceneSession, nullptr); property->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - scensession->property_ = property; - scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT); - scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM); - scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD); - scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM_GESTURE); - EXPECT_NE(scensession, nullptr); + sceneSession->property_ = property; + sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT); + sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM); + sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD); + sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM_GESTURE); + EXPECT_NE(sceneSession, nullptr); } /** @@ -1179,19 +1179,19 @@ HWTEST_F(SceneSessionTest, TransferPointerEvent, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + EXPECT_NE(sceneSession, nullptr); std::shared_ptr pointerEvent = nullptr; - ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent), WSError::WS_ERROR_NULLPTR); + ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent), WSError::WS_ERROR_NULLPTR); std::shared_ptr pointerEvent_ = MMI::PointerEvent::Create(); sptr property = new WindowSessionProperty(); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); property->SetMaximizeMode(MaximizeMode::MODE_FULL_FILL); property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); property->SetPersistentId(11); - scensession->property_ = property; - ASSERT_EQ(scensession->TransferPointerEvent(pointerEvent_), WSError::WS_ERROR_INVALID_SESSION); + sceneSession->property_ = property; + ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent_), WSError::WS_ERROR_INVALID_SESSION); } /** @@ -1207,10 +1207,10 @@ HWTEST_F(SceneSessionTest, TransferPointerEventDecorDialog, Function | SmallTest info.windowType_ = 2122; sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); - sptr scensession = + sptr sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); - scensession->moveDragController_ = new MoveDragController(12); - scensession->SetSessionState(SessionState::STATE_ACTIVE); + sceneSession->moveDragController_ = new MoveDragController(12); + sceneSession->SetSessionState(SessionState::STATE_ACTIVE); std::shared_ptr pointerEvent_ = MMI::PointerEvent::Create(); sptr property = new WindowSessionProperty(); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); @@ -1219,8 +1219,8 @@ HWTEST_F(SceneSessionTest, TransferPointerEventDecorDialog, Function | SmallTest property->SetDecorEnable(true); property->SetDragEnabled(true); property->SetPersistentId(12); - scensession->property_ = property; - EXPECT_NE(scensession, nullptr); + sceneSession->property_ = property; + EXPECT_NE(sceneSession, nullptr); } /** @@ -1236,10 +1236,10 @@ HWTEST_F(SceneSessionTest, TransferPointerEventSystemDialog, Function | SmallTes info.windowType_ = 2123; sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); - sptr scensession = + sptr sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); - scensession->moveDragController_ = new MoveDragController(12); - scensession->SetSessionState(SessionState::STATE_ACTIVE); + sceneSession->moveDragController_ = new MoveDragController(12); + sceneSession->SetSessionState(SessionState::STATE_ACTIVE); std::shared_ptr pointerEvent_ = MMI::PointerEvent::Create(); sptr property = new WindowSessionProperty(); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); @@ -1248,8 +1248,8 @@ HWTEST_F(SceneSessionTest, TransferPointerEventSystemDialog, Function | SmallTes property->SetDecorEnable(true); property->SetDragEnabled(true); property->SetPersistentId(13); - scensession->property_ = property; - EXPECT_NE(scensession, nullptr); + sceneSession->property_ = property; + EXPECT_NE(sceneSession, nullptr); } /** @@ -1267,17 +1267,17 @@ HWTEST_F(SceneSessionTest, CalculateAvoidAreaRect, Function | SmallTest | Level2 sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + EXPECT_NE(sceneSession, nullptr); int ret = 0; WSRect overlapRect = { 0, 0, 0, 0 }; WSRect avoidRect = { 0, 0, 0, 0 }; AvoidArea avoidArea; - scensession->CalculateAvoidAreaRect(overlapRect, avoidRect, avoidArea); + sceneSession->CalculateAvoidAreaRect(overlapRect, avoidRect, avoidArea); WSRect overlapRect_ = { 1, 1, 1, 1 }; WSRect avoidRect_ = { 1, 1, 1, 1 }; - scensession->CalculateAvoidAreaRect(overlapRect_, avoidRect_, avoidArea); + sceneSession->CalculateAvoidAreaRect(overlapRect_, avoidRect_, avoidArea); ASSERT_EQ(ret, 0); } @@ -1296,15 +1296,15 @@ HWTEST_F(SceneSessionTest, OnNeedAvoid, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - EXPECT_NE(scensession, nullptr); - ASSERT_EQ(scensession->OnNeedAvoid(false), WSError::WS_OK); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + EXPECT_NE(sceneSession, nullptr); + ASSERT_EQ(sceneSession->OnNeedAvoid(false), WSError::WS_OK); - scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); - EXPECT_NE(scensession->sessionChangeCallback_, nullptr); - scensession->sessionChangeCallback_->OnNeedAvoid_ = [](bool state){}; - ASSERT_EQ(scensession->OnNeedAvoid(false), WSError::WS_OK); + sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); + EXPECT_NE(sceneSession->sessionChangeCallback_, nullptr); + sceneSession->sessionChangeCallback_->OnNeedAvoid_ = [](bool state){}; + ASSERT_EQ(sceneSession->OnNeedAvoid(false), WSError::WS_OK); } /** @@ -1322,11 +1322,11 @@ HWTEST_F(SceneSessionTest, SetCollaboratorType, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - EXPECT_NE(scensession, nullptr); - scensession->SetCollaboratorType(2); - ASSERT_EQ(scensession->GetCollaboratorType(), 2); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + EXPECT_NE(sceneSession, nullptr); + sceneSession->SetCollaboratorType(2); + ASSERT_EQ(sceneSession->GetCollaboratorType(), 2); } /** @@ -1344,12 +1344,12 @@ HWTEST_F(SceneSessionTest, GetAbilityInfo, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + EXPECT_NE(sceneSession, nullptr); std::shared_ptr abilityInfo; - scensession->SetAbilitySessionInfo(abilityInfo); - ASSERT_EQ(scensession->GetAbilityInfo(), abilityInfo); + sceneSession->SetAbilitySessionInfo(abilityInfo); + ASSERT_EQ(sceneSession->GetAbilityInfo(), abilityInfo); } /** @@ -1410,19 +1410,19 @@ HWTEST_F(SceneSessionTest, GetRatioPreferenceKey, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - ASSERT_EQ(key, scensession->GetRatioPreferenceKey()); + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + ASSERT_EQ(key, sceneSession->GetRatioPreferenceKey()); std::string key2(30, 'a'); std::string key3(80, 'a'); - scensession->sessionInfo_.bundleName_ = key2; - scensession->sessionInfo_.moduleName_ = key2; - scensession->sessionInfo_.abilityName_ = key2; - ASSERT_EQ(key3, scensession->GetRatioPreferenceKey()); + sceneSession->sessionInfo_.bundleName_ = key2; + sceneSession->sessionInfo_.moduleName_ = key2; + sceneSession->sessionInfo_.abilityName_ = key2; + ASSERT_EQ(key3, sceneSession->GetRatioPreferenceKey()); } /** @@ -1441,22 +1441,22 @@ HWTEST_F(SceneSessionTest, NotifyPropertyWhenConnect, Function | SmallTest | Lev sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession; - scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); int ret = 1; std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_; - scensession = new (std::nothrow) SceneSession(info, specificCallback_); - scensession->NotifyPropertyWhenConnect(); + sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + sceneSession->NotifyPropertyWhenConnect(); sptr property = new WindowSessionProperty(); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - scensession->property_ = property; - scensession->NotifyPropertyWhenConnect(); + sceneSession->property_ = property; + sceneSession->NotifyPropertyWhenConnect(); ASSERT_EQ(ret, 1); - scensession->SetSessionProperty(nullptr); - scensession->NotifyPropertyWhenConnect(); - ASSERT_EQ(scensession->GetSessionProperty(), nullptr); + sceneSession->SetSessionProperty(nullptr); + sceneSession->NotifyPropertyWhenConnect(); + ASSERT_EQ(sceneSession->GetSessionProperty(), nullptr); } /** @@ -1470,10 +1470,10 @@ HWTEST_F(SceneSessionTest, DumpSessionInfo, Function | SmallTest | Level2) info.bundleName_ = "SceneSessionTest"; info.abilityName_ = "DumpSessionInfo"; info.windowType_ = 1; - sptr scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); std::vector infos; - scensession->DumpSessionInfo(infos); + sceneSession->DumpSessionInfo(infos); ASSERT_FALSE(infos.empty()); } @@ -1511,40 +1511,19 @@ HWTEST_F(SceneSessionTest, OnSystemSessionEvent, Function | SmallTest | Level2) info.abilityName_ = "OnSystemSessionEvent"; info.bundleName_ = "OnSystemSessionEvent"; sptr session_; - sptr scensession = new (std::nothrow) SceneSession(info, nullptr); - ASSERT_NE(scensession, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + ASSERT_NE(sceneSession, nullptr); sptr property = new(std::nothrow) WindowSessionProperty(); property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH); - scensession->SetSessionProperty(property); - scensession->isActive_ = false; + sceneSession->SetSessionProperty(property); + sceneSession->isActive_ = false; SessionEvent event = SessionEvent::EVENT_START_MOVE; - auto result = scensession->OnSystemSessionEvent(event); + auto result = sceneSession->OnSystemSessionEvent(event); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); } -/** - * @tc.name: OnTitleAndDockHoverShowChange - * @tc.desc: normal function - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionTest, OnTitleAndDockHoverShowChange, Function | SmallTest | Level2) -{ - SessionInfo info; - info.abilityName_ = "OnTitleAndDockHoverShowChange"; - info.bundleName_ = "OnTitleAndDockHoverShowChange"; - sptr session; - sptr sceneSession = sptr::MakeSptr(info, nullptr); - ASSERT_NE(sceneSession, nullptr); - - sptr property = sptr::MakeSptr(); - property->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH); - sceneSession->SetSessionProperty(property); - auto result = sceneSession->OnTitleAndDockHoverShowChange(true, true); - EXPECT_EQ(result, WSError::WS_OK); -} - /** * @tc.name: SetTopmost * @tc.desc: normal function @@ -1556,14 +1535,14 @@ HWTEST_F(SceneSessionTest, SetTopmost, Function | SmallTest | Level2) info.abilityName_ = "SetTopmost"; info.bundleName_ = "SetTopmost"; sptr session_; - sptr scenesession = new (std::nothrow) MainSession(info, nullptr); - EXPECT_NE(scenesession, nullptr); + sptr sceneSession = new (std::nothrow) MainSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); sptr property = new(std::nothrow) WindowSessionProperty(); - scenesession->SetSessionProperty(property); - auto result = scenesession->SetTopmost(false); + sceneSession->SetSessionProperty(property); + auto result = sceneSession->SetTopmost(false); ASSERT_EQ(result, WSError::WS_OK); - ASSERT_FALSE(scenesession->IsTopmost()); + ASSERT_FALSE(sceneSession->IsTopmost()); } /** @@ -1749,17 +1728,17 @@ HWTEST_F(SceneSessionTest, UpdateRect, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->isActive_ = true; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->isActive_ = true; sptr property = new(std::nothrow) WindowSessionProperty(); property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - scensession->SetSessionProperty(property); + sceneSession->SetSessionProperty(property); WSRect rect({1, 1, 1, 1}); SizeChangeReason reason = SizeChangeReason::UNDEFINED; - WSError result = scensession->UpdateRect(rect, reason, "SceneSessionTest"); + WSError result = sceneSession->UpdateRect(rect, reason, "SceneSessionTest"); ASSERT_EQ(result, WSError::WS_OK); } @@ -1817,19 +1796,19 @@ HWTEST_F(SceneSessionTest, UpdateSessionRect, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->isActive_ = true; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->isActive_ = true; sptr property = new(std::nothrow) WindowSessionProperty(); property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); uint32_t p = 10; property->SetKeyboardSessionGravity(SessionGravity::SESSION_GRAVITY_BOTTOM, p); - scensession->SetSessionProperty(property); + sceneSession->SetSessionProperty(property); WSRect rect({1, 1, 1, 1}); SizeChangeReason reason = SizeChangeReason::MOVE; - WSError result = scensession->UpdateSessionRect(rect, reason); + WSError result = sceneSession->UpdateSessionRect(rect, reason); ASSERT_EQ(result, WSError::WS_OK); } @@ -1847,19 +1826,19 @@ HWTEST_F(SceneSessionTest, UpdateSessionRect1, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->isActive_ = true; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->isActive_ = true; sptr property = new(std::nothrow) WindowSessionProperty(); property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); uint32_t p = 10; property->SetKeyboardSessionGravity(SessionGravity::SESSION_GRAVITY_BOTTOM, p); - scensession->SetSessionProperty(property); + sceneSession->SetSessionProperty(property); WSRect rect({1, 1, 1, 1}); SizeChangeReason reason = SizeChangeReason::RESIZE; - WSError result = scensession->UpdateSessionRect(rect, reason); + WSError result = sceneSession->UpdateSessionRect(rect, reason); ASSERT_EQ(result, WSError::WS_OK); } @@ -1877,19 +1856,19 @@ HWTEST_F(SceneSessionTest, UpdateSessionRect2, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr scensession = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(scensession, nullptr); - scensession->isActive_ = true; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->isActive_ = true; sptr property = new(std::nothrow) WindowSessionProperty(); property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); uint32_t p = 10; property->SetKeyboardSessionGravity(SessionGravity::SESSION_GRAVITY_BOTTOM, p); - scensession->SetSessionProperty(property); + sceneSession->SetSessionProperty(property); WSRect rect({1, 1, 1, 1}); SizeChangeReason reason = SizeChangeReason::UNDEFINED; - WSError result = scensession->UpdateSessionRect(rect, reason); + WSError result = sceneSession->UpdateSessionRect(rect, reason); ASSERT_EQ(result, WSError::WS_OK); } diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index 888fd45474..b7d6ec54d9 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -2089,25 +2089,6 @@ HWTEST_F(SceneSessionTest2, SetTitleAndDockHoverShowChangeCallback, Function | S sceneSession->SetTitleAndDockHoverShowChangeCallback(func); EXPECT_NE(sceneSession->onTitleAndDockHoverShowChangeFunc_, nullptr); } - -/** - * @tc.name: OnTitleAndDockHoverShowChange - * @tc.desc: OnTitleAndDockHoverShowChange - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionTest2, OnTitleAndDockHoverShowChange, Function | SmallTest | Level2) -{ - SessionInfo info; - info.abilityName_ = "OnTitleAndDockHoverShowChange"; - info.bundleName_ = "OnTitleAndDockHoverShowChange"; - sptr sceneSession = sptr::MakeSptr(info, nullptr); - NotifyTitleAndDockHoverShowChangeFunc func = [](bool isTitleHoverShown, bool isDockHoverShown) { - return; - }; - sceneSession->SetTitleAndDockHoverShowChangeCallback(func); - EXPECT_NE(sceneSession->onTitleAndDockHoverShowChangeFunc_, nullptr); - EXPECT_EQ(sceneSession->OnTitleAndDockHoverShowChange(true, true), WSError::WS_OK); -} } } } \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index a972e54d62..84e38733b1 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -1137,7 +1137,22 @@ HWTEST_F(SceneSessionTest5, SetSystemWindowEnableDrag, Function | SmallTest | Le info.bundleName_ = "SetSystemWindowEnableDrag"; info.windowType_ = static_cast(WindowType::WINDOW_TYPE_DESKTOP); sptr session = sptr::MakeSptr(info, nullptr); - auto ret = session->SetSystemWindowEnableDrag(true); + auto ret = session->SetWindowEnableDragBySystem(true); + EXPECT_EQ(WMError::WM_OK, ret); +} + +/** + * @tc.name: SetWindowEnableDragBySystem + * @tc.desc: SetWindowEnableDragBySystem function + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest5, SetWindowEnableDragBySystem, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "SetWindowEnableDrag"; + info.bundleName_ = "SetWindowEnableDrag"; + sptr session = sptr::MakeSptr(info, nullptr); + auto ret = session->SetWindowEnableDragBySystem(true); EXPECT_EQ(WMError::WM_OK, ret); } diff --git a/window_scene/test/unittest/session_stage_proxy_test.cpp b/window_scene/test/unittest/session_stage_proxy_test.cpp index da30117c95..9047f34c68 100644 --- a/window_scene/test/unittest/session_stage_proxy_test.cpp +++ b/window_scene/test/unittest/session_stage_proxy_test.cpp @@ -620,6 +620,18 @@ HWTEST_F(SessionStageProxyTest, SetSplitButtonVisible, Function | SmallTest | Le WSError res = sessionStage_->SetSplitButtonVisible(false); ASSERT_EQ(WSError::WS_OK, res); } + +/** + * @tc.name: SetEnableDragBySystem + * @tc.desc: test function : SetEnableDragBySystem + * @tc.type: FUNC + */ +HWTEST_F(SessionStageProxyTest, SetEnableDragBySystem, Function | SmallTest | Level1) +{ + ASSERT_TRUE(sessionStage_ != nullptr); + WSError res = sessionStage_->SetEnableDragBySystem(false); + ASSERT_EQ(WSError::WS_OK, res); +} } } } \ No newline at end of file diff --git a/window_scene/test/unittest/session_stage_stub_test.cpp b/window_scene/test/unittest/session_stage_stub_test.cpp index abfe9ca8c7..d82449179d 100644 --- a/window_scene/test/unittest/session_stage_stub_test.cpp +++ b/window_scene/test/unittest/session_stage_stub_test.cpp @@ -813,6 +813,25 @@ HWTEST_F(SessionStageStubTest, HandleSetSplitButtonVisible, Function | SmallTest data.WriteBool(false); ASSERT_EQ(0, sessionStageStub_->HandleSetSplitButtonVisible(data, reply)); } + +/** + * @tc.name: HandleSetEnableDragBySystem + * @tc.desc: test function : HandleSetEnableDragBySystem + * @tc.type: FUNC + */ +HWTEST_F(SessionStageStubTest, HandleSetEnableDragBySystem, Function | SmallTest | Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + uint32_t code = static_cast(SessionStageInterfaceCode::TRANS_ID_SET_ENABLE_DRAG_BY_SYSTEM); + data.WriteInterfaceToken(SessionStageStub::GetDescriptor()); + data.WriteBool(true); + ASSERT_TRUE(sessionStageStub_ != nullptr); + ASSERT_EQ(0, sessionStageStub_->OnRemoteRequest(code, data, reply, option)); + data.WriteBool(false); + ASSERT_EQ(0, sessionStageStub_->HandleSetEnableDragBySystem(data, reply)); +} } } } \ No newline at end of file diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index a9ffb460a6..a5ebf90d1a 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -196,14 +196,6 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest02, Function | SmallTest | Lev res = session_->ProcessRemoteRequest( static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_TIMEOUT), data, reply, option); ASSERT_EQ(ERR_INVALID_DATA, res); - data.WriteBool(true); - data.WriteBool(true); - res = session_->ProcessRemoteRequest( - static_cast(SessionInterfaceCode::TRANS_ID_TITLE_AND_DOCK_HOVER_SHOW_CHANGE), data, reply, option); - ASSERT_EQ(ERR_NONE, res); - res = session_->ProcessRemoteRequest( - static_cast(SessionInterfaceCode::TRANS_ID_RESTORE_MAIN_WINDOW), data, reply, option); - ASSERT_EQ(ERR_NONE, res); } /** @@ -332,6 +324,14 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest05, Function | SmallTest | Lev res = session_->ProcessRemoteRequest( static_cast(SessionInterfaceCode::TRANS_ID_LAYOUT_FULL_SCREEN_CHANGE), data, reply, option); ASSERT_EQ(ERR_NONE, res); + data.WriteBool(true); + data.WriteBool(true); + res = session_->ProcessRemoteRequest( + static_cast(SessionInterfaceCode::TRANS_ID_TITLE_AND_DOCK_HOVER_SHOW_CHANGE), data, reply, option); + ASSERT_EQ(ERR_NONE, res); + res = session_->ProcessRemoteRequest( + static_cast(SessionInterfaceCode::TRANS_ID_RESTORE_MAIN_WINDOW), data, reply, option); + ASSERT_EQ(ERR_NONE, res); res = session_->ProcessRemoteRequest( static_cast(SessionInterfaceCode::TRANS_ID_SET_DIALOG_SESSION_BACKGESTURE_ENABLE), data, diff --git a/window_scene/test/unittest/task_scheduler_test.cpp b/window_scene/test/unittest/task_scheduler_test.cpp index 7e8f566bd1..237a5a618d 100644 --- a/window_scene/test/unittest/task_scheduler_test.cpp +++ b/window_scene/test/unittest/task_scheduler_test.cpp @@ -20,10 +20,10 @@ using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { -class TaskSchedulerText : public testing::Test { +class TaskSchedulerTest : public testing::Test { public: - TaskSchedulerText() {} - ~TaskSchedulerText() {} + TaskSchedulerTest() {} + ~TaskSchedulerTest() {} }; namespace { @@ -32,9 +32,9 @@ namespace { * @tc.desc: normal function * @tc.type: FUNC */ -HWTEST_F(TaskSchedulerText, task_scheduler_test001, Function | SmallTest | Level2) +HWTEST_F(TaskSchedulerTest, task_scheduler_test001, Function | SmallTest | Level2) { - GTEST_LOG_(INFO) << "TaskSchedulerText: task_scheduler_test001 start"; + GTEST_LOG_(INFO) << "TaskSchedulerTest: task_scheduler_test001 start"; std::string threadName = "threadName"; std::string name = "name"; TaskScheduler* taskScheduler = new(std::nothrow) TaskScheduler(threadName); @@ -42,7 +42,7 @@ HWTEST_F(TaskSchedulerText, task_scheduler_test001, Function | SmallTest | Level taskScheduler->RemoveTask(name); ASSERT_EQ(res, 0); delete taskScheduler; - GTEST_LOG_(INFO) << "TaskSchedulerText: task_scheduler_test001 end"; + GTEST_LOG_(INFO) << "TaskSchedulerTest: task_scheduler_test001 end"; } /** @@ -50,7 +50,7 @@ HWTEST_F(TaskSchedulerText, task_scheduler_test001, Function | SmallTest | Level * @tc.desc: GetEventHandler function * @tc.type: FUNC */ -HWTEST_F(TaskSchedulerText, GetEventHandler, Function | SmallTest | Level2) +HWTEST_F(TaskSchedulerTest, GetEventHandler, Function | SmallTest | Level2) { std::string threadName = "threadName"; std::shared_ptr taskScheduler = std::make_shared(threadName); @@ -63,7 +63,7 @@ HWTEST_F(TaskSchedulerText, GetEventHandler, Function | SmallTest | Level2) * @tc.desc: PostTask function * @tc.type: FUNC */ -HWTEST_F(TaskSchedulerText, PostTask, Function | SmallTest | Level2) +HWTEST_F(TaskSchedulerTest, PostTask, Function | SmallTest | Level2) { std::string threadName = "threadName"; std::shared_ptr taskScheduler = std::make_shared(threadName); @@ -83,7 +83,7 @@ HWTEST_F(TaskSchedulerText, PostTask, Function | SmallTest | Level2) EXPECT_EQ(resultValue, 0); } -HWTEST_F(TaskSchedulerText, AddExportTask1, Function | SmallTest | Level2) +HWTEST_F(TaskSchedulerTest, AddExportTask1, Function | SmallTest | Level2) { std::string threadName = "threadName"; std::string funcName = "funcName"; @@ -102,7 +102,7 @@ HWTEST_F(TaskSchedulerText, AddExportTask1, Function | SmallTest | Level2) } -HWTEST_F(TaskSchedulerText, AddExportTask2, Function | SmallTest | Level2) +HWTEST_F(TaskSchedulerTest, AddExportTask2, Function | SmallTest | Level2) { std::string threadName = "threadName"; std::string funcName = "funcName"; @@ -121,7 +121,7 @@ HWTEST_F(TaskSchedulerText, AddExportTask2, Function | SmallTest | Level2) ASSERT_NE(taskScheduler->exportFuncMap_.size(), 0); } -HWTEST_F(TaskSchedulerText, SetExportHandler, Function | SmallTest | Level2) +HWTEST_F(TaskSchedulerTest, SetExportHandler, Function | SmallTest | Level2) { std::string exportThreadName = "exportThread"; auto eventRunner = AppExecFwk::EventRunner::Create(exportThreadName); @@ -132,7 +132,7 @@ HWTEST_F(TaskSchedulerText, SetExportHandler, Function | SmallTest | Level2) ASSERT_EQ(eventHandler.get(), taskScheduler->exportHandler_.lock().get()); } -HWTEST_F(TaskSchedulerText, ExecuteExportTask, Function | SmallTest | Level2) +HWTEST_F(TaskSchedulerTest, ExecuteExportTask, Function | SmallTest | Level2) { std::string threadName = "threadName"; std::shared_ptr taskScheduler = std::make_shared(threadName); diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 683bc74426..3a6081ab49 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -175,7 +175,7 @@ public: * Gesture Back */ WMError SetGestureBackEnabled(bool enable) override; - bool GetGestureBackEnabled() const override; + WMError GetGestureBackEnabled(bool& enable) override; protected: WMError CreateAndConnectSpecificSession(); diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 39ad1b2e3e..c79b9c7453 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -285,6 +285,7 @@ public: * Multi Window */ WSError SetSplitButtonVisible(bool isVisible) override; + WSError SetEnableDragBySystem(bool enableDrag) override; protected: WMError Connect(); diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 173400d795..f1fb3562ce 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -345,7 +345,7 @@ WMError WindowExtensionSessionImpl::HidePrivacyContentForHost(bool needHide) ss << "ID: " << persistentId << ", needHide: " << needHide; if (surfaceNode_ == nullptr) { - TLOGI(WmsLogTag::WMS_UIEXT, "surfaceNode is null, %{public}s", ss.str().c_str()); + TLOGE(WmsLogTag::WMS_UIEXT, "surfaceNode is null, %{public}s", ss.str().c_str()); return WMError::WM_ERROR_NULLPTR; } @@ -353,11 +353,10 @@ WMError WindowExtensionSessionImpl::HidePrivacyContentForHost(bool needHide) auto errCode = surfaceNode_->SetHidePrivacyContent(needHide); TLOGI(WmsLogTag::WMS_UIEXT, "Notify Render Service client finished, %{public}s, err: %{public}u", ss.str().c_str(), errCode); - if (errCode == RSInterfaceErrorCode::NONSYSTEM_CALLING) { // not system app calling + if (errCode == RSInterfaceErrorCode::NONSYSTEM_CALLING) { // not system app calling return WMError::WM_ERROR_NOT_SYSTEM_APP; - } else if (errCode != RSInterfaceErrorCode::NO_ERROR) { // other error + } else if (errCode != RSInterfaceErrorCode::NO_ERROR) { // other error return WMError::WM_ERROR_SYSTEM_ABNORMALLY; - } else { // notify Render Service ok } return WMError::WM_OK; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index cc399a67ad..71d40c45c2 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1219,7 +1219,10 @@ WMError WindowSceneSessionImpl::Hide(uint32_t reason, bool withAnimation, bool i auto hostSession = GetHostSession(); CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); - WindowState validState = WindowHelper::IsSubWindow(type) ? requestState_ : state_; + WindowState validState = state_; + if (WindowHelper::IsSubWindow(type) || WindowHelper::IsDialogWindow(type)) { + validState = requestState_; + } if (validState == WindowState::STATE_HIDDEN || state_ == WindowState::STATE_CREATED) { TLOGD(WmsLogTag::WMS_LIFE, "window is alreay hidden, id:%{public}d", property_->GetPersistentId()); NotifyBackgroundFailed(WMError::WM_DO_NOTHING); @@ -3754,9 +3757,8 @@ WSError WindowSceneSessionImpl::NotifyDialogStateChange(bool isForeground) if (state_ == WindowState::STATE_SHOWN) { return WSError::WS_OK; } - if (state_ == WindowState::STATE_HIDDEN) { + if (state_ == WindowState::STATE_HIDDEN && requestState_ == WindowState::STATE_SHOWN) { state_ = WindowState::STATE_SHOWN; - requestState_ = WindowState::STATE_SHOWN; NotifyAfterForeground(); } } else { @@ -3765,7 +3767,6 @@ WSError WindowSceneSessionImpl::NotifyDialogStateChange(bool isForeground) } if (state_ == WindowState::STATE_SHOWN) { state_ = WindowState::STATE_HIDDEN; - requestState_ = WindowState::STATE_HIDDEN; NotifyAfterBackground(); } } @@ -4353,19 +4354,19 @@ WMError WindowSceneSessionImpl::SetGestureBackEnabled(bool enable) return hostSession->SetGestureBackEnabled(enable); } -bool WindowSceneSessionImpl::GetGestureBackEnabled() const +WMError WindowSceneSessionImpl::GetGestureBackEnabled(bool& enable) { if (windowSystemConfig_.IsPcWindow()) { TLOGI(WmsLogTag::WMS_IMMS, "device is not support."); - return true; + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } - if (!WindowHelper::IsMainFullScreenWindow(GetType(), property_->GetWindowMode())) { + if (!WindowHelper::IsMainFullScreenWindow(GetType(), property_->GetWindowMode()) || IsFreeMultiWindowMode()) { TLOGI(WmsLogTag::WMS_IMMS, "not full screen main window."); - return true; + return WMError::WM_ERROR_INVALID_TYPE; } - TLOGD(WmsLogTag::WMS_IMMS, "id: %{public}u, enable: %{public}u", - GetWindowId(), gestureBackEnabled_); - return gestureBackEnabled_; + enable = gestureBackEnabled_; + TLOGD(WmsLogTag::WMS_IMMS, "id: %{public}u, enable: %{public}u", GetWindowId(), enable); + return WMError::WM_OK; } } // namespace Rosen diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index da0fccddbc..f444bef41b 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1389,8 +1389,8 @@ void WindowSessionImpl::UpdateDecorEnableToAce(bool isDecorEnable) WLOGFD("decorVisible:%{public}d", decorVisible); if (windowSystemConfig_.freeMultiWindowSupport_) { auto isSubWindow = WindowHelper::IsSubWindow(GetType()); - decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || - (property_->GetIsPcAppInPad() && isSubWindow)); + decorVisible = decorVisible && ((property_->GetIsPcAppInPad() && isSubWindow) || + (windowSystemConfig_.freeMultiWindowEnable_ && mode != WindowMode::WINDOW_MODE_FULLSCREEN)); } uiContent->UpdateDecorVisible(decorVisible, isDecorEnable); return; @@ -1417,8 +1417,8 @@ void WindowSessionImpl::UpdateDecorEnable(bool needNotify, WindowMode mode) (mode == WindowMode::WINDOW_MODE_FULLSCREEN && !property_->IsLayoutFullScreen()); if (windowSystemConfig_.freeMultiWindowSupport_) { auto isSubWindow = WindowHelper::IsSubWindow(GetType()); - decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || - (property_->GetIsPcAppInPad() && isSubWindow)); + decorVisible = decorVisible && ((property_->GetIsPcAppInPad() && isSubWindow) || + (windowSystemConfig_.freeMultiWindowEnable_ && mode != WindowMode::WINDOW_MODE_FULLSCREEN)); } WLOGFD("decorVisible:%{public}d", decorVisible); uiContent->UpdateDecorVisible(decorVisible, IsDecorEnable()); @@ -2533,12 +2533,12 @@ WMError WindowSessionImpl::SetTitleButtonVisible(bool isMaximizeVisible, bool is if (!WindowHelper::IsMainWindow(GetType())) { return WMError::WM_ERROR_INVALID_CALLING; } - if (GetUIContentSharedPtr() == nullptr || !IsDecorEnable()) { - return WMError::WM_ERROR_INVALID_WINDOW; - } if (!IsPcOrPadCapabilityEnabled()) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + if (GetUIContentSharedPtr() == nullptr || !IsDecorEnable()) { + return WMError::WM_ERROR_INVALID_WINDOW; + } windowTitleVisibleFlags_ = { isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible}; UpdateTitleButtonVisibility(); return WMError::WM_OK; @@ -3455,7 +3455,7 @@ void WindowSessionImpl::DispatchKeyEventCallback(const std::shared_ptrProcessKeyEvent(keyEvent); if (!isConsumed && keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_ESCAPE && property_->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && - property_->GetMaximizeMode() == MaximizeMode::MODE_FULL_FILL && + GetImmersiveModeEnabledState() && keyAction == MMI::KeyEvent::KEY_ACTION_DOWN && !escKeyEventTriggered_) { WLOGI("recover from fullscreen cause KEYCODE_ESCAPE"); Recover(); @@ -4125,5 +4125,12 @@ void WindowSessionImpl::NotifySetUIContentComplete() } } } + +WSError WindowSessionImpl::SetEnableDragBySystem(bool enableDrag) +{ + TLOGE(WmsLogTag::WMS_LAYOUT, "enableDrag:%{publlic}d", enableDrag); + property_->SetDragEnabled(enableDrag); + return WSError::WS_OK; +} } // namespace Rosen } // namespace OHOS diff --git a/wm/src/zidl/window_stub.cpp b/wm/src/zidl/window_stub.cpp index 8f27dc7efe..8952c28db0 100644 --- a/wm/src/zidl/window_stub.cpp +++ b/wm/src/zidl/window_stub.cpp @@ -89,6 +89,11 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParce TLOGE(WmsLogTag::WMS_LAYOUT, "read windowMode failed"); return ERR_INVALID_DATA; } + if (windowMode < static_cast(WindowMode::WINDOW_MODE_UNDEFINED) || + windowMode > static_cast(WindowMode::WINDOW_MODE_PIP)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "invalid windowMode: %{public}d", windowMode); + return ERR_INVALID_DATA; + } WindowMode mode = static_cast(windowMode); UpdateWindowMode(mode); break; diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index d3fba7801b..11491ff35f 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1752,10 +1752,13 @@ HWTEST_F(WindowSceneSessionImplTest, SetGestureBackEnabled, Function | SmallTest ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetGestureBackEnabled(false)); window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - ASSERT_EQ(WMError::WM_OK, window->SetGestureBackEnabled(true)); - ASSERT_EQ(true, window->GetGestureBackEnabled()); ASSERT_EQ(WMError::WM_OK, window->SetGestureBackEnabled(false)); - ASSERT_EQ(false, window->GetGestureBackEnabled()); + bool enable = true; + ASSERT_EQ(WMError::WM_OK, window->GetGestureBackEnabled(enable)); + ASSERT_EQ(false, enable); + ASSERT_EQ(WMError::WM_OK, window->SetGestureBackEnabled(true)); + ASSERT_EQ(WMError::WM_OK, window->GetGestureBackEnabled(enable)); + ASSERT_EQ(true, enable); } /* diff --git a/wm/test/unittest/window_scene_session_impl_test2.cpp b/wm/test/unittest/window_scene_session_impl_test2.cpp index f0ed7d6579..2091c3db55 100644 --- a/wm/test/unittest/window_scene_session_impl_test2.cpp +++ b/wm/test/unittest/window_scene_session_impl_test2.cpp @@ -1798,12 +1798,15 @@ HWTEST_F(WindowSceneSessionImplTest2, SetTitleButtonVisible03, Function | SmallT window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); window->uiContent_ = std::make_unique(); window->windowSystemConfig_.freeMultiWindowSupport_ = true; - window->windowSystemConfig_.isSystemDecorEnable_ = true; + window->windowSystemConfig_.isSystemDecorEnable_ = false; window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; WMError res = window->SetTitleButtonVisible(false, false, false, true); ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT); window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; res = window->SetTitleButtonVisible(false, false, false, true); + ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); + window->windowSystemConfig_.isSystemDecorEnable_ = true; + res = window->SetTitleButtonVisible(false, false, false, true); ASSERT_EQ(res, WMError::WM_OK); } diff --git a/wm/test/unittest/window_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index 159bfbd807..5b59e18b13 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -1628,6 +1628,24 @@ HWTEST_F(WindowSessionImplTest4, NotifyRotationAnimationEnd001, Function | Small window->NotifyRotationAnimationEnd(); } +/** + * @tc.name: SetEnableDragBySystem + * @tc.desc: test SetEnableDragBySystem + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest4, SetEnableDragBySystem, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetSubWindow start"; + sptr option = sptr::MakeSptr(); + option->SetWindowName("GetSubWindow"); + sptr window = sptr::MakeSptr(option); + ASSERT_NE(nullptr, window); + ASSERT_NE(nullptr, window->property_); + window->property_->SetDragEnabled(true); + window->SetEnableDragBySystem(false); + ASSERT_FALSE(window->property_->GetDragEnabled()); +} + /** * @tc.name: GetSubWindow * @tc.desc: test GetSubWindow diff --git a/wmserver/src/zidl/mock_session_manager_service_stub.cpp b/wmserver/src/zidl/mock_session_manager_service_stub.cpp index 6d20b6ad7e..77067e1273 100644 --- a/wmserver/src/zidl/mock_session_manager_service_stub.cpp +++ b/wmserver/src/zidl/mock_session_manager_service_stub.cpp @@ -91,7 +91,11 @@ int32_t MockSessionManagerServiceStub::OnRemoteRequest(uint32_t code, MessagePar int32_t MockSessionManagerServiceStub::HandleSetSnapshotSkipByUserIdAndBundleNames( MessageParcel& data, MessageParcel& reply) { - int32_t userId = data.ReadInt32(); + int32_t userId = 0; + if (!data.ReadInt32(userId)) { + TLOGE(WmsLogTag::WMS_MULTI_USER, "Failed to readInt32 userId"); + return ERR_INVALID_DATA; + } std::vector bundleNameList; if (!data.ReadStringVector(&bundleNameList)) { TLOGE(WmsLogTag::WMS_MULTI_USER, "Fail to read bundleNameList"); @@ -104,7 +108,11 @@ int32_t MockSessionManagerServiceStub::HandleSetSnapshotSkipByUserIdAndBundleNam int32_t MockSessionManagerServiceStub::HandleSetSnapshotSkipByIdNamesMap(MessageParcel& data, MessageParcel& reply) { - int32_t mapSize = data.ReadInt32(); + int32_t mapSize = 0; + if (!data.ReadInt32(mapSize)) { + TLOGE(WmsLogTag::WMS_MULTI_USER, "Fail to read mapSize"); + return ERR_INVALID_DATA; + } std::unordered_map> idBundlesMap; if (mapSize > MAX_USER_SIZE) { TLOGE(WmsLogTag::WMS_MULTI_USER, "Too many users!");