Merge branch 'master' of gitee.com:openharmony/window_window_manager into master

Signed-off-by: 匡梅 <kuangmei1@huawei.com>
This commit is contained in:
匡梅 2024-10-26 08:41:58 +00:00 committed by kuangmei
commit b0cf41d11e
113 changed files with 3813 additions and 1083 deletions

View File

@ -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"

View File

@ -98,6 +98,8 @@ public:
virtual std::vector<DisplayPhysicalResolution> GetAllDisplayPhysicalResolution();
virtual DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
std::vector<uint64_t>& windowIdList);
virtual std::shared_ptr<Media::PixelMap> GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode = nullptr);
private:
static inline SingletonDelegator<DisplayManagerAdapter> delegator;

View File

@ -613,12 +613,38 @@ sptr<Display> DisplayManager::Impl::GetDefaultDisplaySync()
sptr<Display> DisplayManager::Impl::GetDisplayById(DisplayId displayId)
{
WLOGFD("GetDisplayById start, displayId: %{public}" PRIu64" ", displayId);
auto displayInfo = SingletonContainer::Get<DisplayManagerAdapter>().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<std::chrono::microseconds>(currentTime - lastRequestTime).count();
if (displayId != DISPLAY_ID_INVALID && interval < MAX_INTERVAL_US) {
std::lock_guard<std::recursive_mutex> 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> displayInfo = nullptr;
while (retryTimes < MAX_RETRY_NUM) {
displayInfo = SingletonContainer::Get<DisplayManagerAdapter>().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<std::recursive_mutex> 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<std::recursive_mutex> 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<DisplayId> 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<DisplayManagerAdapter>().SetFreeze(displayIds, true);
@ -1951,11 +1976,11 @@ bool DisplayManager::Unfreeze(std::vector<DisplayId> 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<DisplayManagerAdapter>().SetFreeze(displayIds, false);
@ -2060,5 +2085,22 @@ DMError DisplayManager::Impl::SetVirtualScreenSecurityExemption(ScreenId screenI
return SingletonContainer::Get<DisplayManagerAdapter>().SetVirtualScreenSecurityExemption(
screenId, pid, windowIdList);
}
sptr<Display> DisplayManager::GetPrimaryDisplaySync()
{
return pImpl_->GetDefaultDisplaySync();
}
std::shared_ptr<Media::PixelMap> DisplayManager::GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode)
{
std::shared_ptr<Media::PixelMap> screenCapture =
SingletonContainer::Get<DisplayManagerAdapter>().GetScreenCapture(captureOption, errorCode);
if (screenCapture == nullptr) {
WLOGFE("screen capture failed!");
return nullptr;
}
return screenCapture;
}
} // namespace OHOS::Rosen

View File

@ -850,4 +850,10 @@ DMError ScreenManagerAdapter::SetVirtualScreenMaxRefreshRate(ScreenId id, uint32
return displayManagerServiceProxy_->SetVirtualScreenMaxRefreshRate(id, refreshRate, actualRefreshRate);
}
std::shared_ptr<Media::PixelMap> DisplayManagerAdapter::GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode)
{
INIT_PROXY_CHECK_RETURN(nullptr);
return displayManagerServiceProxy_->GetScreenCapture(captureOption, errorCode);
}
} // namespace OHOS::Rosen

View File

@ -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<std::shared_mutex> 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<std::shared_mutex> lock(displayChangeMutex);
@ -554,13 +555,13 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeList
static std::atomic<uint32_t> 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<std::shared_mutex> 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<DisplayInfo> info)
{
std::vector<uint32_t> 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<void *>(displayInfo->colorSpace));
return;
}
displayInfo->colorSpace->colorSpaceLength = static_cast<uint32_t>(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<void *>(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<void *>(displayInfo->colorSpace->colorSpaces));
NativeDisplayManager_FreeMemory(static_cast<void *>(displayInfo->colorSpace));
return;
}
uint32_t colorLoop = 0;
for (const auto colorSpace : colorSpaces) {
DM_GraphicCM_ColorSpaceType colorSpaceValue = static_cast<DM_GraphicCM_ColorSpaceType>(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<uint32_t>(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<DisplayInfo> info)
{
std::vector<uint32_t> 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<void *>(displayInfo->hdrFormat));
return;
}
displayInfo->hdrFormat->hdrFormatLength = static_cast<uint32_t>(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<void *>(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<void *>(displayInfo->hdrFormat->hdrFormats));
NativeDisplayManager_FreeMemory(static_cast<void *>(displayInfo->hdrFormat));
return;
}
uint32_t hdrLoop = 0;
for (const auto hdrFormat : hdrFormats) {
DM_ScreenHDRFormat hdrFormatValue = static_cast<DM_ScreenHDRFormat>(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<uint32_t>(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<DisplayInfo> info)
{
displayInfo->id = static_cast<uint32_t>(info->GetDisplayId());
displayInfo->width = info->GetWidth();
displayInfo->height = info->GetHeight();
displayInfo->orientation = static_cast<NativeDisplayManager_Orientation>(info->GetDisplayOrientation());
displayInfo->rotation = static_cast<NativeDisplayManager_Rotation>(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<NativeDisplayManager_DisplayState>(
DM_NATIVE_TO_NDK_DISPLAY_STATE_MAP.at(info->GetDisplayState()));
} else {
displayInfo->state = static_cast<NativeDisplayManager_DisplayState>(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<sptr<Display>>& 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<void *>(displayItem.colorSpace->colorSpaces));
}
NativeDisplayManager_FreeMemory(static_cast<void *>(displayItem.colorSpace));
}
if (displayItem.hdrFormat != nullptr) {
if (displayItem.hdrFormat->hdrFormats != nullptr) {
NativeDisplayManager_FreeMemory(static_cast<void *>(displayItem.hdrFormat->hdrFormats));
}
NativeDisplayManager_FreeMemory(static_cast<void *>(displayItem.hdrFormat));
}
}
NativeDisplayManager_FreeMemory(static_cast<void *>(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<sptr<Display>> 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<void *>(displaysInner));
return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL;
}
size_t displaySize = displays.size();
displaysInner->displaysLength = static_cast<uint32_t>(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<void *>(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<void *>(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<void *>(allDisplays));
return;
}
NativeDisplayManager_DestroyDisplaysInfoInner(allDisplays->displaysLength, allDisplays->displaysInfo);
NativeDisplayManager_FreeMemory(static_cast<void *>(allDisplays));
}
static NativeDisplayManager_DisplayInfo* NativeDisplayManager_FillDisplayInfo(sptr<Display> display,
NativeDisplayManager_ErrorCode *errCode)
{
sptr<DisplayInfo> 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<void *>(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<void *>(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> display = DisplayManager::GetInstance().GetDisplayById(static_cast<DisplayId>(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> 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<void *>(displayInfo->colorSpace->colorSpaces));
}
NativeDisplayManager_FreeMemory(static_cast<void *>(displayInfo->colorSpace));
}
if (displayInfo->hdrFormat != nullptr) {
if (displayInfo->hdrFormat->hdrFormats != nullptr) {
NativeDisplayManager_FreeMemory(static_cast<void *>(displayInfo->hdrFormat->hdrFormats));
}
NativeDisplayManager_FreeMemory(static_cast<void *>(displayInfo->hdrFormat));
}
NativeDisplayManager_FreeMemory(static_cast<void *>(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>(displayId);
option.isNeedNotify_ = true;
DmErrorCode errCode = DmErrorCode::DM_OK;
std::shared_ptr<Media::PixelMap> 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;
}

View File

@ -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 <cstdint>
#include <map>
#include <set>
#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<DisplayState, DM_DisplayStateMode> 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_GraphicCM_ColorSpaceType, DM_ColorSpace> 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_ScreenHDRFormat, DM_HDRFormat> 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

View File

@ -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<sptr<ScreenInfo>>& screenInfos);
bool UpdateScreenInfoLocked(sptr<ScreenInfo>);
std::string GetScreenInfoSrting(sptr<ScreenInfo> 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<ExpandOption>& 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<ScreenId> screenIds;
@ -465,7 +471,7 @@ DMError ScreenManager::MakeUniqueScreen(const std::vector<ScreenId>& 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<ScreenManagerAdapter>().MakeUniqueScreen(screenIds);
@ -476,7 +482,7 @@ DMError ScreenManager::MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> 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<ScreenManagerAdapter>().MakeMirror(mainScreenId, mirrorScreenId,
@ -540,7 +546,7 @@ DMError ScreenManager::RemoveVirtualScreenFromGroup(std::vector<ScreenId> 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<ScreenManagerAdapter>().RemoveVirtualScreenFromGroup(screens);

View File

@ -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> display = DisplayManager::GetInstance().GetDefaultDisplay();
ASSERT_NE(display, nullptr);
captureOption.displayId_ = display->GetId();
DmErrorCode errCode;
std::shared_ptr<Media::PixelMap> 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> display = DisplayManager::GetInstance().GetPrimaryDisplaySync();
ASSERT_NE(display, nullptr);
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -619,7 +619,6 @@ bool DisplayManagerLite::Impl::SetDisplayState(DisplayState state, DisplayStateC
{
std::lock_guard<std::recursive_mutex> 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");
}

View File

@ -232,6 +232,13 @@ public:
{
return DMError::DM_OK;
}
virtual std::shared_ptr<Media::PixelMap> GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode = nullptr)
{
*errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
return nullptr;
}
};
} // namespace OHOS::Rosen

View File

@ -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

View File

@ -699,6 +699,23 @@ public:
*/
void RemoveDisplayIdFromAms(const wptr<IRemoteObject>& abilityToken);
/**
* @brief Get primary display object by means of sync.
*
* @return primary display.
*/
sptr<Display> 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<Media::PixelMap> GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode = nullptr);
private:
DisplayManager();
~DisplayManager();

View File

@ -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_;

View File

@ -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; }
};
}
}

View File

@ -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",
]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"
}
]

View File

@ -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<void>(napi_delete_reference(env, callbackRef));

View File

@ -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<JsDisplayManager>(env, info);
return (me != nullptr) ? me->OnGetPrimaryDisplaySync(env, info) : nullptr;
}
static napi_value GetDisplayByIdSync(napi_env env, napi_callback_info info)
{
JsDisplayManager* me = CheckParamsAndGetThis<JsDisplayManager>(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> display = SingletonContainer::Get<DisplayManager>().GetPrimaryDisplaySync();
if (display == nullptr) {
WLOGFE("[NAPI]Display info is nullptr, js error will be happen");
napi_throw(env, CreateJsError(env, static_cast<int32_t>(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);

View File

@ -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<Param> &param, napi_value
}
}
static void IsNeedNotify(napi_env env, std::unique_ptr<Param> &param, 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, &param->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<Param> &param, 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, &param->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<Param> &param, napi_value &argv)
{
if (param == nullptr) {
@ -173,6 +201,8 @@ static void GetScreenshotParam(napi_env env, std::unique_ptr<Param> &param, 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<Param> &param)
@ -290,6 +320,46 @@ napi_value PickFunc(napi_env env, napi_callback_info info)
return AsyncProcess<Param>(env, __PRETTY_FUNCTION__, AsyncGetScreenshot, Resolve, ref, param);
}
static void AsyncGetScreenCapture(napi_env env, std::unique_ptr<Param> &param)
{
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, &param->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<Param>();
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<Param>(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),
};

View File

@ -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<WmErrorCode> errCodePtr = std::make_shared<WmErrorCode>(WmErrorCode::WM_OK);
auto execute = [weakToken = wptr<Window>(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<Window>& 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

View File

@ -445,7 +445,7 @@ napi_value CreateJsWindowPropertiesObject(napi_env env, sptr<Window>& 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::vector<sptr<Wi
for (size_t i = 0; i < infos.size(); i++) {
auto info = infos[i];
auto windowType = info->GetWindowType();
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));
}
}

View File

@ -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; }
};
}
}

View File

@ -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 = [

View File

@ -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

View File

@ -86,11 +86,11 @@ bool IntentionEventManager::EnableInputEventListener(Ace::UIContent* uiContent,
std::shared_ptr<AppExecFwk::EventHandler> 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<MMI::PointerEvent> pointerEvent) const
{
if (pointerEvent == nullptr) {
TLOGE(WmsLogTag::WMS_EVENT, "UpdateLastMouseEvent pointerEvent is null");
TLOGE(WmsLogTag::WMS_EVENT, "pointerEvent is null");
return;
}
g_lastLeaveWindowId = -1;

View File

@ -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<JsSceneSession>(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<int32_t>(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;

View File

@ -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();

View File

@ -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;
}

View File

@ -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<int64_t>(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

View File

@ -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> screenSession_;

View File

@ -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<ScreenSession> internalSession, sptr<ScreenSession> externalSession);
@ -83,7 +83,7 @@ private:
void DoFirstExtendChangeExtend(sptr<ScreenSession> firstSession, sptr<ScreenSession> secondarySession);
void DoFirstExtendChangeMirror(sptr<ScreenSession> firstSession, sptr<ScreenSession> secondarySession);
std::pair<ScreenId, std::string> multiScreenStatus_; // main screen id & other screen status
std::pair<ScreenId, MultiScreenMode> lastScreenMode_; // main screen id & secondary screen mode
};
} // namespace OHOS::Rosen
#endif // OHOS_ROSEN_MULTI_SCREEN_MANAGER_H

View File

@ -301,6 +301,7 @@ public:
DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate,
uint32_t& actualRefreshRate) override;
void SetLastScreenMode(sptr<ScreenSession> firstSession, sptr<ScreenSession> secondarySession);
/*
* multi user
*/
@ -310,7 +311,10 @@ public:
void ScbClientDeathCallback(int32_t deathScbPid);
void ScbStatusRecoveryWhenSwitchUser(std::vector<int32_t> oldScbPids, int32_t newScbPid);
void SetMultiScreenStatus(sptr<ScreenSession> firstSession, sptr<ScreenSession> secondarySession);
std::shared_ptr<Media::PixelMap> 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<DisplayInfo> HookDisplayInfoByUid(sptr<DisplayInfo> displayInfo, const sptr<ScreenSession>& screenSession);
DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
std::vector<uint64_t>& windowIdList) override;
void GetInternalAndExternalSession(sptr<ScreenSession>& internalSession, sptr<ScreenSession>& externalSession);
#ifdef DEVICE_STATUS_ENABLE
void SetDragWindowScreenId(ScreenId screenId, ScreenId displayNodeScreenId);
#endif // DEVICE_STATUS_ENABLE

View File

@ -199,6 +199,13 @@ public:
{
return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
}
virtual std::shared_ptr<Media::PixelMap> GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode = nullptr) override
{
*errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
return nullptr;
}
};
} // namespace Rosen
} // namespace OHOS

View File

@ -180,6 +180,8 @@ public:
std::vector<uint64_t>& windowIdList) override;
DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate,
uint32_t& actualRefreshRate) override;
std::shared_ptr<Media::PixelMap> GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode = nullptr) override;
private:
static inline BrokerDelegator<ScreenSessionManagerProxy> delegator_;
};

View File

@ -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

View File

@ -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<ScreenId>& allScreenIds,
std::vector<ScreenId>& physicalScreenIds, std::vector<ScreenId>& virtualScreenIds)
{
TLOGI(WmsLogTag::DMS, "filter physical and virtual screen enter allScreen size: %{public}u",
TLOGI(WmsLogTag::DMS, "enter allScreen size: %{public}u",
static_cast<uint32_t>(allScreenIds.size()));
sptr<ScreenSession> defaultSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession();
if (defaultSession == nullptr) {
@ -60,13 +59,13 @@ void MultiScreenManager::FilterPhysicalAndVirtualScreen(const std::vector<Screen
TLOGI(WmsLogTag::DMS, "mirror screen type error");
}
}
TLOGI(WmsLogTag::DMS, "filter physical and virtual screen end");
TLOGI(WmsLogTag::DMS, "end");
}
DMError MultiScreenManager::VirtualScreenMirrorSwitch(const ScreenId mainScreenId,
const std::vector<ScreenId>& screenIds, ScreenId& screenGroupId)
{
TLOGI(WmsLogTag::DMS, "virtual screen mirror switch enter size: %{public}u",
TLOGI(WmsLogTag::DMS, "enter size: %{public}u",
static_cast<uint32_t>(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<ScreenI
DMError MultiScreenManager::PhysicalScreenUniqueSwitch(const std::vector<ScreenId>& screenIds)
{
TLOGI(WmsLogTag::DMS, "enter physical screen unique switch screen size: %{public}u",
TLOGI(WmsLogTag::DMS, "enter screen size: %{public}u",
static_cast<uint32_t>(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::vector<ScreenI
screenSession->CreateDisplayNode(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<ScreenSession> 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<uint32_t>(screenIds.size()));
auto group = ScreenSessionManager::GetInstance().GetAbstractScreenGroup(screenSession->groupSmsId_);
if (group == nullptr) {
@ -181,7 +180,7 @@ DMError MultiScreenManager::VirtualScreenUniqueSwitch(sptr<ScreenSession> 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<ScreenId>& screenIds)
std::vector<ScreenId> virtualScreenIds;
std::vector<ScreenId> 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<uint32_t>(screenIds.size()));
FilterPhysicalAndVirtualScreen(screenIds, physicalScreenIds, virtualScreenIds);
@ -217,10 +216,10 @@ DMError MultiScreenManager::MirrorSwitch(const ScreenId mainScreenId, const std:
std::vector<ScreenId> virtualScreenIds;
std::vector<ScreenId> 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<uint32_t>(screenIds.size()));
TLOGI(WmsLogTag::DMS, "enter screen size: %{public}u", static_cast<uint32_t>(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<ScreenSession> 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<ScreenSession> internalSession,
@ -503,39 +502,27 @@ void MultiScreenManager::InternalScreenOnChange(sptr<ScreenSession> internalSess
TLOGE(WmsLogTag::DMS, "internal or external screen is null!");
return;
}
sptr<IScreenSessionManagerClient> 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<ScreenSession> internalSession,
@ -545,37 +532,23 @@ void MultiScreenManager::InternalScreenOffChange(sptr<ScreenSession> internalSes
TLOGE(WmsLogTag::DMS, "internal or external screen is null!");
return;
}
sptr<IScreenSessionManagerClient> 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<ScreenSession> internalSession,
@ -585,20 +558,22 @@ void MultiScreenManager::ExternalScreenDisconnectChange(sptr<ScreenSession> 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

View File

@ -34,7 +34,7 @@ std::map<DeviceRotationValue, Rotation> ScreenCutoutController::deviceToDisplayR
sptr<CutoutInfo> ScreenCutoutController::GetScreenCutoutInfo(DisplayId displayId)
{
TLOGD(WmsLogTag::DMS, "get screen cutout info.");
TLOGD(WmsLogTag::DMS, "start");
std::vector<DMRect> 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> displayInfo = ScreenSessionManager::GetInstance().GetDefaultDisplayInfo();
uint32_t iCurvedSize = 0;

View File

@ -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<std::recursive_mutex> 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<const xmlChar*>("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<const xmlChar*>("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<const xmlChar*>("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<const xmlChar*>("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<std::string> 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<std::string, std::vector<std::string>>& 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());
}
}

View File

@ -40,7 +40,7 @@ sptr<TentMotionEventCallback> 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<RotationMotionEventCallback> 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<TentMotionEventCallback> 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

View File

@ -26,7 +26,7 @@ std::recursive_mutex g_instanceMutex;
ScreenSessionManagerLite::~ScreenSessionManagerLite()
{
TLOGD(WmsLogTag::DMS, "ScreenSessionManagerLite destroy");
TLOGD(WmsLogTag::DMS, "destroy");
std::lock_guard<std::recursive_mutex> lock(mutex_);
destroyed_ = true;
}

View File

@ -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<uint32_t>(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);

View File

@ -609,7 +609,7 @@ DMError ScreenSessionManagerProxy::RegisterDisplayManagerAgent(const sptr<IDispl
WLOGFE("IDisplayManagerAgent is null");
return DMError::DM_ERROR_INVALID_PARAM;
}
if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) {
WLOGFE("Write IDisplayManagerAgent failed");
return DMError::DM_ERROR_IPC_FAILED;
@ -3050,6 +3050,7 @@ void OHOS::Rosen::ScreenSessionManagerProxy::UpdateDisplayHookInfo(int32_t uid,
return;
}
}
DMError ScreenSessionManagerProxy::SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
std::vector<uint64_t>& windowIdList)
{
@ -3191,4 +3192,41 @@ DMError ScreenSessionManagerProxy::SetVirtualScreenMaxRefreshRate(ScreenId id, u
actualRefreshRate = reply.ReadUint32();
return static_cast<DMError>(reply.ReadInt32());
}
std::shared_ptr<Media::PixelMap> ScreenSessionManagerProxy::GetScreenCapture(const CaptureOption& captureOption,
DmErrorCode* errorCode)
{
sptr<IRemoteObject> 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<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_CAPTURE),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return nullptr;
}
std::shared_ptr<Media::PixelMap> pixelMap(reply.ReadParcelable<Media::PixelMap>());
DmErrorCode replyErrorCode = static_cast<DmErrorCode>(reply.ReadInt32());
if (errorCode) {
*errorCode = replyErrorCode;
}
if (pixelMap == nullptr) {
WLOGFE("Send pixelMap nullptr.");
return nullptr;
}
return pixelMap;
}
} // namespace OHOS::Rosen

View File

@ -864,6 +864,10 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
reply.WriteInt32(static_cast<int32_t>(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<void>(reply.WriteInt32(static_cast<int32_t>(ret)));
}
void ScreenSessionManagerStub::ProcGetScreenCapture(MessageParcel& data, MessageParcel& reply)
{
CaptureOption option;
option.displayId_ = static_cast<DisplayId>(data.ReadUint64());
option.isNeedNotify_ = static_cast<bool>(data.ReadBool());
option.isNeedPointer_ = static_cast<bool>(data.ReadBool());
DmErrorCode errCode = DmErrorCode::DM_OK;
std::shared_ptr<Media::PixelMap> capture = GetScreenCapture(option, &errCode);
reply.WriteParcelable(capture == nullptr ? nullptr : capture.get());
static_cast<void>(reply.WriteInt32(static_cast<int32_t>(errCode)));
}
} // namespace OHOS::Rosen

View File

@ -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<ScreenId, sptr<ScreenSession>> screenSessionMap_;

View File

@ -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<int32_t> 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<std::string>& screenFoldInfo) = 0;
virtual void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) = 0;
};
} // namespace OHOS::Rosen

View File

@ -49,6 +49,7 @@ public:
void OnUpdateFoldDisplayMode(FoldDisplayMode displayMode) override;
void SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) override;
void OnFoldStatusChangedReportUE(const std::vector<std::string>& screenFoldInfo) override;
void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override;
private:
static inline BrokerDelegator<ScreenSessionManagerClientProxy> delegator_;

View File

@ -25,12 +25,15 @@
namespace OHOS::Rosen {
class ScreenSessionManagerClientStub : public IRemoteStub<IScreenSessionManagerClient> {
public:
ScreenSessionManagerClientStub() = default;
ScreenSessionManagerClientStub();
virtual ~ScreenSessionManagerClientStub() = default;
int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
private:
using HandleScreenChange = std::function<int(MessageParcel &, MessageParcel &)>;
using HandleScreenChangeMap = std::map<ScreenSessionManagerClientMessage, HandleScreenChange>;
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

View File

@ -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> 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

View File

@ -575,4 +575,31 @@ void ScreenSessionManagerClientProxy::OnFoldStatusChangedReportUE(const std::vec
return;
}
}
void ScreenSessionManagerClientProxy::ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid,
const std::string& clientName)
{
sptr<IRemoteObject> 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<uint32_t>(ScreenSessionManagerClientMessage::TRANS_ID_ON_SCREEN_CAPTURE_NOTIFY),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return;
}
}
} // namespace OHOS::Rosen

View File

@ -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<ScreenSessionManagerClientMessage>(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<ScreenId>(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

View File

@ -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

View File

@ -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

View File

@ -75,6 +75,7 @@ public:
void NotifySessionFullScreen(bool fullScreen) override;
WSError NotifyDumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override;
WSError SetSplitButtonVisible(bool isVisible) override;
WSError SetEnableDragBySystem(bool dragEnable) override;
private:
bool ReadSmallStringVectorFromParcel(

View File

@ -80,6 +80,7 @@ private:
const std::vector<std::string>& 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

View File

@ -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<std::string>& 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<std::string>& 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<IRemoteObject> remote = Remote();
if (remote == nullptr) {
TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
return WSError::WS_ERROR_IPC_FAILED;
}
if (remote->SendRequest(static_cast<uint32_t>(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

View File

@ -121,6 +121,8 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messag
return HandleNotifyDumpInfo(data, reply);
case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_SPLIT_BUTTON_VISIBLE):
return HandleSetSplitButtonVisible(data, reply);
case static_cast<uint32_t>(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<std::string>& infos)
bool SessionStageStub::WriteSmallStringVector(
const std::vector<std::string>& 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<std::string>& infos, MessageParcel& reply)
{
TLOGD(WmsLogTag::WMS_UIEXT, "WriteBigStringVector entry");
Parcel tempParcel;
tempParcel.SetMaxCapacity(MAX_PARCEL_CAPACITY);
if (!tempParcel.WriteInt32(static_cast<int32_t>(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<int32_t>(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

View File

@ -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:

View File

@ -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<AppExecFwk::AbilityInfo> abilityInfo);
void SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func);
@ -671,11 +671,6 @@ private:
ExtensionWindowFlags combinedExtWindowFlags_ { 0 };
std::map<int32_t, ExtensionWindowFlags> extWindowFlagsMap_;
/**
* Window Immersive
*/
NotifyTitleAndDockHoverShowChangeFunc onTitleAndDockHoverShowChangeFunc_;
/*
* Window Decor
*/

View File

@ -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)] {

View File

@ -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<float>(windowRect.width_) / static_cast<float>(originalRect.width_) *
static_cast<float>(moveTempProperty_.lastDownPointerPosX_);
static_cast<float>(moveTempProperty_.lastDownPointerPosX_ - originalRect.posX_);
WSRect targetRect = {
moveTempProperty_.lastDownPointerPosX_ - static_cast<int32_t>(newPosX),
originalRect.posY_,

View File

@ -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<WindowSessionProperty>& property,
WSPropertyChangeAction action)
{

View File

@ -1062,6 +1062,7 @@ void Session::InitSessionPropertyWhenConnect(const sptr<WindowSessionProperty>&
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;

View File

@ -308,6 +308,7 @@ WSError SessionProxy::Connect(const sptr<ISessionStage>& sessionStage, const spt
property->SetCompatibleModeEnableInPad(reply.ReadBool());
property->SetRequestedOrientation(static_cast<Orientation>(reply.ReadUint32()));
property->SetAppInstanceKey(reply.ReadString());
property->SetDragEnabled(reply.ReadBool());
}
int32_t ret = reply.ReadInt32();
return static_cast<WSError>(ret);

View File

@ -380,6 +380,7 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply)
reply.WriteBool(property->GetCompatibleModeEnableInPad());
reply.WriteUint32(static_cast<uint32_t>(property->GetRequestedOrientation()));
reply.WriteString(property->GetAppInstanceKey());
reply.WriteBool(property->GetDragEnabled());
}
reply.WriteUint32(static_cast<uint32_t>(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<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_RECT) ||
actionValue > static_cast<uint32_t>(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST)) {
TLOGE(WmsLogTag::DEFAULT, "invalid action");
return ERR_INVALID_DATA;
}
auto action = static_cast<WSPropertyChangeAction>(actionValue);
TLOGD(WmsLogTag::DEFAULT, "action:%{public}u", action);
sptr<WindowSessionProperty> property = nullptr;

View File

@ -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_;

View File

@ -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

View File

@ -153,8 +153,8 @@ public:
const bool isToDesktop = false, const bool isSaveSnapshot = true);
WSError RequestSceneSessionDestruction(const sptr<SceneSession>& sceneSession, bool needRemoveSession = true,
bool isSaveSnapshot = true, const bool isForceClean = false);
WSError RequestSceneSessionDestructionInner(sptr<SceneSession>& scnSession, sptr<AAFwk::SessionInfo> scnSessionInfo,
const bool needRemoveSession, const bool isForceClean = false);
WSError RequestSceneSessionDestructionInner(sptr<SceneSession>& sceneSession,
sptr<AAFwk::SessionInfo> sceneSessionInfo, const bool needRemoveSession, const bool isForceClean = false);
void NotifyForegroundInteractiveStatus(const sptr<SceneSession>& sceneSession, bool interactive);
WSError RequestSceneSessionByCall(const sptr<SceneSession>& sceneSession);
void StartAbilityBySpecified(const SessionInfo& sessionInfo);
@ -585,8 +585,8 @@ private:
void InitSceneSession(sptr<SceneSession>& sceneSession, const SessionInfo& sessionInfo,
const sptr<WindowSessionProperty>& property);
sptr<AAFwk::SessionInfo> SetAbilitySessionInfo(const sptr<SceneSession>& scnSession);
WSError DestroyDialogWithMainWindow(const sptr<SceneSession>& scnSession);
sptr<AAFwk::SessionInfo> SetAbilitySessionInfo(const sptr<SceneSession>& sceneSession);
WSError DestroyDialogWithMainWindow(const sptr<SceneSession>& sceneSession);
sptr<SceneSession> FindMainWindowWithToken(sptr<IRemoteObject> targetToken);
WSError UpdateParentSessionForDialog(const sptr<SceneSession>& sceneSession, sptr<WindowSessionProperty> 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>& sceneSession);
WSError RequestSceneSessionActivationInner(sptr<SceneSession>& scnSession, bool isNewActive);
WSError RequestSceneSessionActivationInner(sptr<SceneSession>& sceneSession, bool isNewActive);
WSError SetBrightness(const sptr<SceneSession>& sceneSession, float brightness);
WSError UpdateBrightness(int32_t persistentId);
void SetDisplayBrightness(float brightness);
@ -657,7 +657,7 @@ private:
void RegisterAcquireRotateAnimationConfigFunc(const sptr<SceneSession>& sceneSession);
void RegisterVisibilityChangedDetectFunc(const sptr<SceneSession>& sceneSession);
void NotifySessionForCallback(const sptr<SceneSession>& scnSession, const bool needRemoveSession);
void NotifySessionForCallback(const sptr<SceneSession>& sceneSession, const bool needRemoveSession);
void AddClientDeathRecipient(const sptr<ISessionStage>& sessionStage, const sptr<SceneSession>& sceneSession);
void DestroySpecificSession(const sptr<IRemoteObject>& remoteObject);
bool GetExtensionWindowIds(const sptr<IRemoteObject>& token, int32_t& persistentId, int32_t& parentId);
@ -827,7 +827,7 @@ private:
[this](const sptr<IRemoteObject>& remoteExtSession) { this->DestroyExtensionSession(remoteExtSession); });
WSError ClearSession(sptr<SceneSession> sceneSession);
bool IsSessionClearable(sptr<SceneSession> scnSession);
bool IsSessionClearable(sptr<SceneSession> sceneSession);
void GetAllClearableSessions(std::vector<sptr<SceneSession>>& 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>& sceneSession, int32_t persistentId = 0);
bool PreHandleCollaborator(sptr<SceneSession>& sceneSession, int32_t persistentId = 0);
void NotifyCollaboratorAfterStart(sptr<SceneSession>& scnSession, sptr<AAFwk::SessionInfo>& scnSessionInfo);
void NotifyCollaboratorAfterStart(sptr<SceneSession>& sceneSession, sptr<AAFwk::SessionInfo>& sceneSessionInfo);
void UpdateCollaboratorSessionWant(sptr<SceneSession>& session, int32_t persistentId = 0);
bool CheckSystemWindowPermission(const sptr<WindowSessionProperty>& property);
bool CheckModalSubWindowPermission(const sptr<WindowSessionProperty>& property);

View File

@ -9501,25 +9501,16 @@ std::shared_ptr<Media::PixelMap> SceneSessionManager::GetSessionSnapshotPixelMap
return nullptr;
}
wptr<SceneSession> 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<Media::PixelMap> 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<Media::PixelMap> 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<int32_t, sptr<SceneSession>> SceneSessionManager::GetSceneSessionMap()

View File

@ -171,7 +171,7 @@ void SessionManagerLite::SaveSessionListener(const sptr<ISessionListener>& 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);

View File

@ -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<SessionSnapshot> snapshot = std::make_shared<SessionSnapshot>();
WSError ret = GetSessionSnapshot(deviceId, persistentId, *snapshot, isLowResolution);
reply.WriteParcelable(snapshot.get());

View File

@ -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<SessionSnapshot> snapshot = std::make_shared<SessionSnapshot>();
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<SessionSnapshot> snapshot = std::make_shared<SessionSnapshot>();
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<uint32_t>(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<int32_t> persistentIds;
data.ReadInt32Vector(&persistentIds);
if (!data.ReadInt32Vector(&persistentIds)) {
TLOGE(WmsLogTag::DEFAULT, "Failed to readInt32Vector persistentIds");
return ERR_INVALID_DATA;
}
std::vector<uint64_t> surfaceNodeIds;
WMError errCode = GetProcessSurfaceNodeIdByPersistentId(pid, persistentIds, surfaceNodeIds);
if (!reply.WriteUInt64Vector(surfaceNodeIds)) {

View File

@ -16,6 +16,9 @@
#include <gtest/gtest.h>
#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<int32_t> 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> displayInfo,
const std::map<DisplayId, sptr<DisplayInfo>>& 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<uint64_t>& missionIds,
std::vector<uint64_t>& surfaceNodeIds, bool isBlackList = false) override {};
void OnUpdateFoldDisplayMode(FoldDisplayMode displayMode) override {};
void SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) override {};
void OnFoldStatusChangedReportUE(const std::vector<std::string>& screenFoldInfo) override {};
void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override {};
sptr<IRemoteObject> AsObject() override {return testPtr;};
sptr<IRemoteObject> testPtr;
};
class MultiScreenManagerTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
sptr<TestClient> testClient_;
};
void MultiScreenManagerTest::SetUpTestCase()
@ -59,7 +92,7 @@ namespace {
*/
HWTEST_F(MultiScreenManagerTest, FilterPhysicalAndVirtualScreen, Function | SmallTest | Level1)
{
std::vector<ScreenId> allScreenIds = {1, 2, 3};
std::vector<ScreenId> allScreenIds = {2000, 2001, 0};
std::vector<ScreenId> physicalScreenIds;
std::vector<ScreenId> 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<ScreenSession> firstSession = nullptr;
sptr<ScreenSession> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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<IDisplayManagerAgent> 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

View File

@ -799,7 +799,7 @@ HWTEST_F(ScreenSessionDumperTest, SetEnterOrExitTentMode, Function | SmallTest |
sptr<ScreenSessionDumper> dumper = new ScreenSessionDumper(fd, args);
dumper->SetEnterOrExitTentMode("-offtent");
bool tentMode = ScreenSession::GetInstance().GetTentMode();
bool tentMode = ScreenSessionManager::GetInstance().GetTentMode();
ASSERT_EQ(tentMode, false);
}
}

View File

@ -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

View File

@ -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

View File

@ -1284,5 +1284,19 @@ HWTEST_F(ScreenSessionManagerClientTest, UpdateScreenRotationProperty02, Functio
sptr<ScreenSession> 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

View File

@ -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<ScreenManagerAdapter>().InitDMSProxy();
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
ASSERT_TRUE(screenSessionManagerProxy != nullptr);
std::shared_ptr<Media::PixelMap> res = nullptr;
CaptureOption option;
option.displayId_ = 0;
DmErrorCode* errorCode = nullptr;
std::function<void()> func = [&]() {
res = screenSessionManagerProxy->GetScreenCapture(option, errorCode);
};
func();
if (SceneBoardJudgement::IsSceneBoardEnabled()) {
ASSERT_NE(res, nullptr);
} else {
ASSERT_EQ(res, nullptr);
}
}
}
}
}

View File

@ -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<uint64_t>(id));
data.WriteBool(true);
data.WriteBool(true);
uint32_t code = static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_GET_DISPLAY_CAPTURE);
int res = stub_->OnRemoteRequest(code, data, reply, option);
EXPECT_EQ(res, 0);
}
}
}
}

View File

@ -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<Media::PixelMap> 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

View File

@ -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<ScreenSession> 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

View File

@ -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 <gmock/gmock.h>
#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<std::string>& outValue));
MOCK_METHOD2(GetStringArrayByName, RState(const char* name, std::vector<std::string>& outValue));
MOCK_METHOD2(GetPatternById, RState(uint32_t id, std::map<std::string, std::string>& outValue));
MOCK_METHOD2(GetPatternByName, RState(const char* name, std::map<std::string, std::string>& 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<std::string, std::string>& outValue));
MOCK_METHOD2(GetThemeByName, RState(const char* name, std::map<std::string, std::string>& 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<int>& outValue) { return RState::ERROR; };
RState GetIntArrayByName(const char* name, std::vector<int>& 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<uint8_t[]>& outValue, uint32_t density)
{
return RState::ERROR;
};
RState GetMediaDataByName(const char* name, size_t& len, std::unique_ptr<uint8_t[]>& 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<uint8_t[]>& outValue) { return RState::ERROR; };
RState GetProfileDataByName(const char* name, size_t& len, std::unique_ptr<uint8_t[]>& outValue)
{
return RState::ERROR;
};
RState GetRawFileFromHap(const std::string& rawFileName, size_t& len, std::unique_ptr<uint8_t[]>& 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<std::string>& rawfileList)
{
return RState::ERROR;
};
RState GetDrawableInfoById(uint32_t id, std::string& type, size_t& len,
std::unique_ptr<uint8_t[]>& outValue, uint32_t density)
{
return RState::ERROR;
};
RState GetDrawableInfoByName(const char* name, std::string& type, size_t& len,
std::unique_ptr<uint8_t[]>& outValue, uint32_t density)
{
return RState::ERROR;
};
bool AddResource(const std::string& path, const std::vector<std::string>& overlayPaths)
{
return true;
};
bool RemoveResource(const std::string& path, const std::vector<std::string>& overlayPaths)
{
return true;
};
RState GetStringFormatById(uint32_t id, std::string& outValue,
std::vector<std::tuple<NapiValueType, std::string>>& jsParams)
{
return RState::ERROR;
};
RState GetStringFormatByName(const char* name, std::string& outValue,
std::vector<std::tuple<NapiValueType, std::string>>& 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<std::string>& outValue, bool includeSystem = false) {};
RState GetDrawableInfoById(uint32_t id, std::tuple<std::string, size_t, std::string>& drawableInfo,
std::unique_ptr<uint8_t[]>& outValue, uint32_t iconType, uint32_t density)
{
return RState::ERROR;
};
RState GetDrawableInfoByName(const char* name, std::tuple<std::string, size_t, std::string>& drawableInfo,
std::unique_ptr<uint8_t[]>& 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<std::unique_ptr<uint8_t[]>, size_t>& foregroundInfo,
std::pair<std::unique_ptr<uint8_t[]>, 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<uint8_t[]>& outValue,
size_t& len, bool isGlobalMask)
{
return RState::ERROR;
};
RState IsRawDirFromHap(const std::string& pathName, bool& outValue)
{
return RState::ERROR;
};
std::shared_ptr<ResourceManager> GetOverrideResourceManager(std::shared_ptr<ResConfig> overrideResConfig)
{
return std::shared_ptr<ResourceManager>();
};
RState UpdateOverrideResConfig(ResConfig& resConfig) { return RState::ERROR; };
void GetOverrideResConfig(ResConfig& resConfig) {};
RState GetDynamicIcon(const std::string& resName, std::pair<std::unique_ptr<uint8_t[]>, 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<std::tuple<ResourceManager::NapiValueType, std::string>>& jsParams)
{
return RState::ERROR;
};
RState GetFormatPluralStringByName(std::string& outValue, const char* name, int quantity,
std::vector<std::tuple<ResourceManager::NapiValueType, std::string>>& jsParams)
{
return RState::ERROR;
};
bool AddPatchResource(const char* path, const char* patchPath) { return true; };
};
} // namespace Resource
} // namespace Global
} // namespace OHOS
#endif

View File

@ -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 <gmock/gmock.h>
#include "session_manager/include/scene_session_manager.h"
namespace OHOS {
namespace AbilityRuntime {
const size_t Context::CONTEXT_TYPE_ID(std::hash<const char*> {} ("MockContext"));
class RootSceneContextMocker : public AbilityRuntime::Context {
public:
RootSceneContextMocker() {};
~RootSceneContextMocker() {};
MOCK_CONST_METHOD0(GetResourceManager, std::shared_ptr<Global::Resource::ResourceManager>());
MOCK_CONST_METHOD0(GetBundleName, std::string());
MOCK_METHOD1(CreateBundleContext, std::shared_ptr<Context>(const std::string& bundleName));
MOCK_CONST_METHOD0(GetApplicationInfo, std::shared_ptr<AppExecFwk::ApplicationInfo>());
MOCK_CONST_METHOD0(GetBundleCodePath, std::string());
MOCK_CONST_METHOD0(GetHapModuleInfo, std::shared_ptr<AppExecFwk::HapModuleInfo>());
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<IRemoteObject>());
MOCK_METHOD1(SetToken, void(const sptr<IRemoteObject>& token));
MOCK_METHOD1(SwitchArea, void(int mode));
MOCK_METHOD1(CreateModuleContext, std::shared_ptr<Context>(const std::string& moduleName));
MOCK_METHOD2(CreateModuleContext, std::shared_ptr<Context>(const std::string& bundleName,
const std::string& moduleName));
MOCK_METHOD2(CreateModuleResourceManager, std::shared_ptr<Global::Resource::ResourceManager>
(const std::string& bundleName, const std::string& moduleName));
MOCK_METHOD3(CreateSystemHspModuleResourceManager, int32_t(const std::string& bundleName,
const std::string& moduleName, std::shared_ptr<Global::Resource::ResourceManager>& ResourceManager));
MOCK_METHOD0(GetArea, int());
MOCK_CONST_METHOD0(GetConfiguration, std::shared_ptr<AppExecFwk::Configuration>());
MOCK_CONST_METHOD0(GetBaseDir, std::string());
MOCK_CONST_METHOD0(GetDeviceType, Global::Resource::DeviceType());
};
} // namespace AbilityRuntime
} // namespace OHOS
#endif

View File

@ -71,6 +71,7 @@ public:
MOCK_METHOD2(NotifyDumpInfo, WSError(const std::vector<std::string>& params,
std::vector<std::string>& info));
MOCK_METHOD1(SetSplitButtonVisible, WSError(bool isVisible));
MOCK_METHOD1(SetEnableDragBySystem, WSError(bool enableDrag));
};
} // namespace Rosen
} // namespace OHOS

View File

@ -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

View File

@ -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> sceneSession = sptr<SceneSession>::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

View File

@ -430,12 +430,12 @@ HWTEST_F(SceneSessionManagerLifecycleTest, RequestSceneSessionDestruction, Funct
ssm_->RequestSceneSessionDestruction(sceneSession, true);
ssm_->RequestSceneSessionDestruction(sceneSession, false);
ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId());
sptr<AAFwk::SessionInfo> 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<AAFwk::SessionInfo> 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);
}

View File

@ -144,17 +144,17 @@ HWTEST_F(SceneSessionManagerSupplementTest, NotifyCollaboratorAfterStart,
{
int res = 0;
sptr<SceneSession> sceneSession;
sptr<AAFwk::SessionInfo> scnSessionInfo;
ssm_->NotifyCollaboratorAfterStart(sceneSession, scnSessionInfo);
sptr<AAFwk::SessionInfo> 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();

View File

@ -114,20 +114,20 @@ HWTEST_F(SceneSessionManagerTest10, RequestSceneSessionDestructionInner, Functio
SessionInfo info;
sptr<SceneSession::SpecificSessionCallback> specificCallback = nullptr;
sptr<SceneSession> scnSession = new SceneSession(info, specificCallback);
sptr<AAFwk::SessionInfo> scnSessionInfo = new AAFwk::SessionInfo();
sptr<SceneSession> sceneSession = new SceneSession(info, specificCallback);
sptr<AAFwk::SessionInfo> 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<AAFwk::Want>();
ssm_->RequestSceneSessionDestructionInner(scnSession, scnSessionInfo, needRemoveSession, isForceClean);
ssm_->RequestSceneSessionDestructionInner(sceneSession, sceneSessionInfo, needRemoveSession, isForceClean);
}
/**

View File

@ -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 <gtest/gtest.h>
#include <regex>
#include <bundle_mgr_interface.h>
#include <bundlemgr/launcher_service.h>
#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<SceneSessionManager> ssm_;
std::shared_ptr<AbilityRuntime::RootSceneContextMocker> mockRootSceneContext_;
std::string path;
uint32_t bgColor;
AppExecFwk::AbilityInfo abilityInfo;
private:
static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
};
sptr<SceneSessionManager> SceneSessionManagerTest12::ssm_ = nullptr;
void SceneSessionManagerTest12::SetUpTestCase()
{
ssm_ = &SceneSessionManager::GetInstance();
}
void SceneSessionManagerTest12::TearDownTestCase()
{
ssm_ = nullptr;
}
void SceneSessionManagerTest12::SetUp()
{
mockRootSceneContext_ = std::make_shared<AbilityRuntime::RootSceneContextMocker>();
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<Global::Resource::ResourceManagerMocker>
mockResourceManager_ = std::make_shared<Global::Resource::ResourceManagerMocker>();
class SceneSessionManagerMocker : public SceneSessionManager {
public:
SceneSessionManagerMocker() {};
~SceneSessionManagerMocker() {};
std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager(const AppExecFwk::AbilityInfo& abilityInfo)
{
return mockResourceManager_;
};
};
std::shared_ptr<SceneSessionManagerMocker> mockSceneSessionManager_ = std::make_shared<SceneSessionManagerMocker>();
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<AbilityRuntime::RootSceneContextMocker>(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<AbilityRuntime::RootSceneContextMocker>(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<Global::Resource::ResourceManagerMocker>();
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

View File

@ -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<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
sptr<SceneSession> sceneSession = sptr<SceneSession>::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

View File

@ -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

View File

@ -1844,31 +1844,24 @@ HWTEST_F(SceneSessionManagerTest6, IsKeyboardForeground, Function | SmallTest |
*/
HWTEST_F(SceneSessionManagerTest6, DestroyDialogWithMainWindow, Function | SmallTest | Level3)
{
sptr<SceneSession> scnSession = nullptr;
auto result = ssm_->DestroyDialogWithMainWindow(scnSession);
sptr<SceneSession> sceneSession = nullptr;
auto result = ssm_->DestroyDialogWithMainWindow(sceneSession);
ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
SessionInfo info;
sptr<SceneSession::SpecificSessionCallback> 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> 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> 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);
}

File diff suppressed because it is too large Load Diff

View File

@ -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> sceneSession = sptr<SceneSession>::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);
}
}
}
}

View File

@ -1137,7 +1137,22 @@ HWTEST_F(SceneSessionTest5, SetSystemWindowEnableDrag, Function | SmallTest | Le
info.bundleName_ = "SetSystemWindowEnableDrag";
info.windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_DESKTOP);
sptr<SceneSession> session = sptr<SceneSession>::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<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
auto ret = session->SetWindowEnableDragBySystem(true);
EXPECT_EQ(WMError::WM_OK, ret);
}

View File

@ -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);
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More