diff --git a/bundle.json b/bundle.json index 9340df2dbe..69e5c39d1f 100755 --- a/bundle.json +++ b/bundle.json @@ -73,7 +73,8 @@ "libjpeg-turbo", "libxml2", "bounds_checking_function", - "device_status" + "device_status", + "ets_frontend" ], "third_party": [ ] diff --git a/dm/BUILD.gn b/dm/BUILD.gn index e6ee260292..1415d1664b 100644 --- a/dm/BUILD.gn +++ b/dm/BUILD.gn @@ -133,6 +133,7 @@ ohos_shared_library("libdm") { external_deps = [ "ability_runtime:ability_manager", "c_utils:utils", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "image_framework:image_native", @@ -193,6 +194,7 @@ ohos_shared_library("libdm_ndk") { "c_utils:utils", "hilog:libhilog", "image_framework:pixelmap", + "ipc:ipc_core", ] part_name = "window_manager" diff --git a/dm/src/oh_display_manager.cpp b/dm/src/oh_display_manager.cpp index 24602acbb1..33c6385d87 100644 --- a/dm/src/oh_display_manager.cpp +++ b/dm/src/oh_display_manager.cpp @@ -585,21 +585,11 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeLi NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; } -static void NativeDisplayManager_FreeMemory(void *memPtr) -{ - if (memPtr == nullptr) { - TLOGW(WmsLogTag::DMS, "[DMNDK] param is null. no need to free."); - return; - } - free(memPtr); - memPtr = nullptr; -} - static void NativeDisplayManager_SetColorSpace(NativeDisplayManager_DisplayInfo *displayInfo, sptr info) { std::vector colorSpaces = info->GetColorSpaces(); if (colorSpaces.empty()) { - TLOGW(WmsLogTag::DMS, "[DMNDK] colorSpaces is empty displayId=%{public}d", displayInfo->id); + TLOGW(WmsLogTag::DMS, "[DMNDK] colorSpaces is empty displayId=%{public}u", displayInfo->id); return; } displayInfo->colorSpace = (NativeDisplayManager_DisplayColorSpace*)malloc( @@ -612,22 +602,22 @@ static void NativeDisplayManager_SetColorSpace(NativeDisplayManager_DisplayInfo sizeof(NativeDisplayManager_DisplayColorSpace)); if (retMemset != EOK) { TLOGE(WmsLogTag::DMS, "[DMNDK] memset color space failed"); - NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->colorSpace); return; } displayInfo->colorSpace->colorSpaceLength = static_cast(colorSpaces.size()); displayInfo->colorSpace->colorSpaces = (uint32_t*)malloc(sizeof(uint32_t) * colorSpaces.size()); if (displayInfo->colorSpace->colorSpaces == nullptr) { TLOGE(WmsLogTag::DMS, "[DMNDK] malloc color spaces failed"); - NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->colorSpace); return; } retMemset = memset_s(displayInfo->colorSpace->colorSpaces, sizeof(uint32_t) * colorSpaces.size(), 0, sizeof(uint32_t) * colorSpaces.size()); if (retMemset != EOK) { TLOGE(WmsLogTag::DMS, "[DMNDK] memset color spaces failed"); - NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace->colorSpaces)); - NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->colorSpace->colorSpaces); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->colorSpace); return; } @@ -643,14 +633,14 @@ static void NativeDisplayManager_SetColorSpace(NativeDisplayManager_DisplayInfo static_cast(DM_NATIVE_TO_NDK_COLOR_SPACE_TYPE_MAP.at(colorSpaceValue)); colorLoop++; } - TLOGI(WmsLogTag::DMS, "[DMNDK] color spaces count:%{public}d.", colorLoop); + TLOGI(WmsLogTag::DMS, "[DMNDK] color spaces count:%{public}u.", colorLoop); } static void NativeDisplayManager_SetHdrFormat(NativeDisplayManager_DisplayInfo *displayInfo, sptr info) { std::vector hdrFormats = info->GetHdrFormats(); if (hdrFormats.empty()) { - TLOGW(WmsLogTag::DMS, "[DMNDK] hdrFormats is empty displayId=%{public}d", displayInfo->id); + TLOGW(WmsLogTag::DMS, "[DMNDK] hdrFormats is empty displayId=%{public}u", displayInfo->id); return; } displayInfo->hdrFormat = (NativeDisplayManager_DisplayHdrFormat*)malloc( @@ -663,22 +653,22 @@ static void NativeDisplayManager_SetHdrFormat(NativeDisplayManager_DisplayInfo * sizeof(NativeDisplayManager_DisplayHdrFormat)); if (retMemset != EOK) { TLOGE(WmsLogTag::DMS, "[DMNDK] memset hdr format failed"); - NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->hdrFormat); return; } displayInfo->hdrFormat->hdrFormatLength = static_cast(hdrFormats.size()); displayInfo->hdrFormat->hdrFormats = (uint32_t*)malloc(sizeof(uint32_t) * hdrFormats.size()); if (displayInfo->hdrFormat->hdrFormats == nullptr) { TLOGE(WmsLogTag::DMS, "[DMNDK] malloc hdr format failed"); - NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->hdrFormat); return; } retMemset = memset_s(displayInfo->hdrFormat->hdrFormats, sizeof(uint32_t) * hdrFormats.size(), 0, sizeof(uint32_t) * hdrFormats.size()); if (retMemset != EOK) { TLOGE(WmsLogTag::DMS, "[DMNDK] memset hdr format failed"); - NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat->hdrFormats)); - NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->hdrFormat->hdrFormats); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->hdrFormat); return; } @@ -693,7 +683,7 @@ static void NativeDisplayManager_SetHdrFormat(NativeDisplayManager_DisplayInfo * static_cast(DM_NATIVE_TO_NDK_HDR_FORMAT_TYPE_MAP.at(hdrFormatValue)); hdrLoop++; } - TLOGI(WmsLogTag::DMS, "[DMNDK] hdr format count:%{public}d", hdrLoop); + TLOGI(WmsLogTag::DMS, "[DMNDK] hdr format count:%{public}u", hdrLoop); } static void NativeDisplayManager_SetDisplayInfo(NativeDisplayManager_DisplayInfo *displayInfo, @@ -723,7 +713,7 @@ static void NativeDisplayManager_SetDisplayInfo(NativeDisplayManager_DisplayInfo NativeDisplayManager_SetColorSpace(displayInfo, info); /* hdr format */ NativeDisplayManager_SetHdrFormat(displayInfo, info); - TLOGI(WmsLogTag::DMS, "[DMNDK] set display id[%{public}d] finish.", displayInfo->id); + TLOGI(WmsLogTag::DMS, "[DMNDK] set display id[%{public}u] finish.", displayInfo->id); } static NativeDisplayManager_ErrorCode NativeDisplayManager_SetDisplaysInfo(const std::vector>& displays, @@ -738,7 +728,7 @@ static NativeDisplayManager_ErrorCode NativeDisplayManager_SetDisplaysInfo(const 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; + continue; } int ret = memcpy_s(displaysInfo[i].name, OH_DISPLAY_NAME_LENGTH, info->GetName().c_str(), OH_DISPLAY_NAME_LENGTH); @@ -763,18 +753,18 @@ static void NativeDisplayManager_DestroyDisplaysInfoInner(uint32_t displaysLengt NativeDisplayManager_DisplayInfo displayItem = displaysInfo[i]; if (displayItem.colorSpace != nullptr) { if (displayItem.colorSpace->colorSpaces != nullptr) { - NativeDisplayManager_FreeMemory(static_cast(displayItem.colorSpace->colorSpaces)); + DISPLAY_MANAGER_FREE_MEMORY(displayItem.colorSpace->colorSpaces); } - NativeDisplayManager_FreeMemory(static_cast(displayItem.colorSpace)); + DISPLAY_MANAGER_FREE_MEMORY(displayItem.colorSpace); } if (displayItem.hdrFormat != nullptr) { if (displayItem.hdrFormat->hdrFormats != nullptr) { - NativeDisplayManager_FreeMemory(static_cast(displayItem.hdrFormat->hdrFormats)); + DISPLAY_MANAGER_FREE_MEMORY(displayItem.hdrFormat->hdrFormats); } - NativeDisplayManager_FreeMemory(static_cast(displayItem.hdrFormat)); + DISPLAY_MANAGER_FREE_MEMORY(displayItem.hdrFormat); } } - NativeDisplayManager_FreeMemory(static_cast(displaysInfo)); + DISPLAY_MANAGER_FREE_MEMORY(displaysInfo); } NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays( @@ -800,7 +790,7 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays( sizeof(NativeDisplayManager_DisplaysInfo)); if (retMemset != EOK) { TLOGE(WmsLogTag::DMS, "[DMNDK] memset displays failed."); - NativeDisplayManager_FreeMemory(static_cast(displaysInner)); + DISPLAY_MANAGER_FREE_MEMORY(displaysInner); return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; } size_t displaySize = displays.size(); @@ -809,7 +799,7 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays( (NativeDisplayManager_DisplayInfo*)malloc(sizeof(NativeDisplayManager_DisplayInfo) * displaySize); if (displaysInfo == nullptr) { TLOGE(WmsLogTag::DMS, "[DMNDK] malloc displaysInfo failed."); - NativeDisplayManager_FreeMemory(static_cast(displaysInner)); + DISPLAY_MANAGER_FREE_MEMORY(displaysInner); return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; } retMemset = memset_s(displaysInfo, sizeof(NativeDisplayManager_DisplayInfo) * displaySize, 0, @@ -820,8 +810,8 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays( } if (retMemset != EOK || setRet != NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_OK) { TLOGE(WmsLogTag::DMS, "[DMNDK] memset or set displaysInfo failed setRet=%{public}d.", setRet); - NativeDisplayManager_FreeMemory(static_cast(displaysInner)); NativeDisplayManager_DestroyDisplaysInfoInner(displaysInner->displaysLength, displaysInfo); + DISPLAY_MANAGER_FREE_MEMORY(displaysInner); return NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; } displaysInner->displaysInfo = displaysInfo; @@ -836,11 +826,11 @@ void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInf return; } if (allDisplays->displaysInfo == nullptr) { - NativeDisplayManager_FreeMemory(static_cast(allDisplays)); + DISPLAY_MANAGER_FREE_MEMORY(allDisplays); return; } NativeDisplayManager_DestroyDisplaysInfoInner(allDisplays->displaysLength, allDisplays->displaysInfo); - NativeDisplayManager_FreeMemory(static_cast(allDisplays)); + DISPLAY_MANAGER_FREE_MEMORY(allDisplays); } static NativeDisplayManager_DisplayInfo* NativeDisplayManager_FillDisplayInfo(sptr display, @@ -863,14 +853,14 @@ static NativeDisplayManager_DisplayInfo* NativeDisplayManager_FillDisplayInfo(sp sizeof(NativeDisplayManager_DisplayInfo)); if (retMemset != EOK) { TLOGE(WmsLogTag::DMS, "[DMNDK] memset display info null."); - NativeDisplayManager_FreeMemory(static_cast(displayInner)); + DISPLAY_MANAGER_FREE_MEMORY(displayInner); *errCode = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; return nullptr; } int ret = memcpy_s(displayInner->name, OH_DISPLAY_NAME_LENGTH, info->GetName().c_str(), OH_DISPLAY_NAME_LENGTH); if (ret != EOK) { TLOGE(WmsLogTag::DMS, "[DMNDK] memcpy display name failed."); - NativeDisplayManager_FreeMemory(static_cast(displayInner)); + DISPLAY_MANAGER_FREE_MEMORY(displayInner); *errCode = NativeDisplayManager_ErrorCode::DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL; return nullptr; } @@ -879,7 +869,7 @@ static NativeDisplayManager_DisplayInfo* NativeDisplayManager_FillDisplayInfo(sp return displayInner; } -NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayInfoById(uint32_t id, +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayById(uint32_t id, NativeDisplayManager_DisplayInfo **displayInfo) { if (displayInfo == nullptr) { @@ -915,7 +905,7 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay( return errorCode; } -void OH_NativeDisplayManager_DestroyDisplayInfo(NativeDisplayManager_DisplayInfo *displayInfo) +void OH_NativeDisplayManager_DestroyDisplay(NativeDisplayManager_DisplayInfo *displayInfo) { if (displayInfo == nullptr) { TLOGE(WmsLogTag::DMS, "[DMNDK] free display info is null."); @@ -923,20 +913,20 @@ void OH_NativeDisplayManager_DestroyDisplayInfo(NativeDisplayManager_DisplayInfo } if (displayInfo->colorSpace != nullptr) { if (displayInfo->colorSpace->colorSpaces != nullptr) { - NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace->colorSpaces)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->colorSpace->colorSpaces); } - NativeDisplayManager_FreeMemory(static_cast(displayInfo->colorSpace)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->colorSpace); } if (displayInfo->hdrFormat != nullptr) { if (displayInfo->hdrFormat->hdrFormats != nullptr) { - NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat->hdrFormats)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->hdrFormat->hdrFormats); } - NativeDisplayManager_FreeMemory(static_cast(displayInfo->hdrFormat)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo->hdrFormat); } - NativeDisplayManager_FreeMemory(static_cast(displayInfo)); + DISPLAY_MANAGER_FREE_MEMORY(displayInfo); } -NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateScreenCapture(uint32_t displayId, +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CaptureScreenPixelmap(uint32_t displayId, OH_PixelmapNative **pixelMap) { if (pixelMap == nullptr) { diff --git a/dm/src/oh_display_manager_inner.h b/dm/src/oh_display_manager_inner.h index 6d91790d2f..6a16f66d0d 100644 --- a/dm/src/oh_display_manager_inner.h +++ b/dm/src/oh_display_manager_inner.h @@ -224,6 +224,15 @@ const std::map DM_NATIVE_TO_NDK_HDR_FORMAT_TYP { DM_ScreenHDRFormat::IMAGE_HDR_ISO_DUAL, DM_HDRFormat::IMAGE_HDR_ISO_DUAL }, { DM_ScreenHDRFormat::IMAGE_HDR_ISO_SINGLE, DM_HDRFormat::IMAGE_HDR_ISO_SINGLE }, }; + +#define DISPLAY_MANAGER_FREE_MEMORY(ptr) \ + do { \ + if ((ptr)) { \ + free((ptr)); \ + (ptr) = NULL; \ + } \ + } while (0) + } // namespace Rosen } // namespace OHOS #endif // OHOS_OH_NATIVE_DISPLAY_MANAGER_INNER_H diff --git a/dmserver/BUILD.gn b/dmserver/BUILD.gn index f77c9761a9..d8debae973 100644 --- a/dmserver/BUILD.gn +++ b/dmserver/BUILD.gn @@ -70,6 +70,7 @@ ohos_shared_library("libdms") { "c_utils:utils", "config_policy:configpolicy_util", "eventhandler:libeventhandler", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "graphic_surface:surface", "hilog:libhilog", @@ -77,6 +78,7 @@ ohos_shared_library("libdms") { "ipc:ipc_single", "libxml2:libxml2", "safwk:system_ability_fwk", + "samgr:samgr_proxy", ] defines = [] diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index 2f04ce4560..a1aaf053fe 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -598,6 +598,10 @@ sptr AbstractScreenController::AddAsSuccedentScreenLocked(s if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) { for (auto& child : screenGroup->GetChildren()) { WLOGD("AddAsSuccedentScreenLocked. defaultScreen rotation:%d", child->rotation_); + if (child->GetActiveScreenMode() == nullptr) { + WLOGE("active screen mode is nullptr"); + continue; + } if (child->rotation_ == Rotation::ROTATION_90 || child->rotation_ == Rotation::ROTATION_270) { point.posX_ += static_cast(child->GetActiveScreenMode()->height_); } else { diff --git a/extension/extension_connection/BUILD.gn b/extension/extension_connection/BUILD.gn index 9a3351e0d0..168f8ed8cc 100644 --- a/extension/extension_connection/BUILD.gn +++ b/extension/extension_connection/BUILD.gn @@ -62,6 +62,7 @@ ohos_shared_library("libwindow_extension_client") { "ability_runtime:ability_connect_callback_stub", "ability_runtime:ability_manager", "c_utils:utils", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "hitrace:hitrace_meter", diff --git a/extension/window_extension/BUILD.gn b/extension/window_extension/BUILD.gn index 4edcfc5094..2d3d3d6e9f 100644 --- a/extension/window_extension/BUILD.gn +++ b/extension/window_extension/BUILD.gn @@ -71,13 +71,16 @@ ohos_shared_library("libwindow_extension") { "ability_runtime:extensionkit_native", "ability_runtime:napi_common", "ability_runtime:runtime", + "ability_runtime:wantagent_innerkits", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "hitrace:hitrace_meter", "input:libmmi-client", + "ipc:ipc_napi", "ipc:ipc_single", "napi:ace_napi", ] diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index e8d9f845dc..9ff4cecee6 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -364,8 +364,6 @@ enum class SuperFoldStatusChangeEvents : uint32_t { ANGLE_CHANGE_FOLDED, KEYBOARD_ON, KEYBOARD_OFF, - SOFT_KEYBOARD_ON, - SOFT_KEYBOARD_OFF, INVALID, }; @@ -378,7 +376,6 @@ enum class SuperFoldStatus : uint32_t { HALF_FOLDED, EXPANDED, KEYBOARD, - SOFT_KEYBOARD, }; /** diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 400e73081b..da7dce823a 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -882,6 +882,12 @@ public: * @return WMError */ virtual WMError NotifyDrawingCompleted() { return WMError::WM_OK; } + /** + * @brief notify window remove starting window. + * + * @return WMError + */ + virtual WMError NotifyRemoveStartingWindow() { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } /** * @brief move the window to (x, y) * @@ -1962,6 +1968,14 @@ public: */ virtual WMError SetDecorVisible(bool isVisible) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Enable or disable move window by title bar. + * + * @param enable The value true means to enable window moving, and false means the opposite. + * @return Errorcode of window. + */ + virtual WMError SetWindowTitleMoveEnabled(bool enable) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** * @brief Set window container color. * @@ -2067,7 +2081,7 @@ public: * * @return Value of PixelRatio obtained from displayInfo. */ - virtual float GetVirtualPixelRatio() { return 0.0f; } + virtual float GetVirtualPixelRatio() { return 1.0f; } /** * @brief Hide None Secure Windows. @@ -2404,7 +2418,7 @@ public: virtual void NotifyExtensionEventAsync(uint32_t notifyEvent) {} /** - * @brief Get isUIExtFirstSubWindow flag + * @brief Get whether this window is the first level sub window of UIExtension. * * @return true - is the first sub window of UIExtension, false - is not the first sub window of UIExtension */ diff --git a/interfaces/innerkits/wm/window_option.h b/interfaces/innerkits/wm/window_option.h index 9cb5964861..4cda3d7599 100644 --- a/interfaces/innerkits/wm/window_option.h +++ b/interfaces/innerkits/wm/window_option.h @@ -231,7 +231,7 @@ public: void SetOnlySupportSceneBoard(bool onlySupportSceneBoard); /** - * @brief Set whether this window is the first sub window of UIExtension. + * @brief Set whether this window is the first level sub window of UIExtension. * * @param isUIExtFirstSubWindow whether is the first sub window of UIExtension. */ @@ -427,7 +427,7 @@ public: bool GetOnlySupportSceneBoard() const; /** - * @brief Get isUIExtFirstSubWindow flag + * @brief Get whether this window is the first level sub window of UIExtension. * * @return true - is the first sub window of UIExtension, false - is not the first sub window of UIExtension */ diff --git a/interfaces/kits/cj/display_runtime/BUILD.gn b/interfaces/kits/cj/display_runtime/BUILD.gn index f3393a176d..ee1e60b828 100644 --- a/interfaces/kits/cj/display_runtime/BUILD.gn +++ b/interfaces/kits/cj/display_runtime/BUILD.gn @@ -50,6 +50,7 @@ ohos_shared_library("cj_display_ffi") { "ability_runtime:runtime", "bounds_checking_function:libsec_shared", "c_utils:utils", + "graphic_2d:2d_graphics_new", "hilog:libhilog", "hitrace:hitrace_meter", "napi:ace_napi", diff --git a/interfaces/kits/cj/window_runtime/BUILD.gn b/interfaces/kits/cj/window_runtime/BUILD.gn index 17d9149bb4..bc56663880 100644 --- a/interfaces/kits/cj/window_runtime/BUILD.gn +++ b/interfaces/kits/cj/window_runtime/BUILD.gn @@ -52,12 +52,14 @@ ohos_shared_library("cj_window_ffi") { "ability_runtime:dialog_request_info", "ability_runtime:extensionkit_native", "ability_runtime:runtime", + "ability_runtime:wantagent_innerkits", "access_token:libaccesstoken_sdk", "ace_engine:ace_uicontent", "bundle_framework:appexecfwk_base", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "hitrace:hitrace_meter", diff --git a/interfaces/kits/dmndk/dm/oh_display_capture.h b/interfaces/kits/dmndk/dm/oh_display_capture.h index 87ac114785..11bca77e83 100644 --- a/interfaces/kits/dmndk/dm/oh_display_capture.h +++ b/interfaces/kits/dmndk/dm/oh_display_capture.h @@ -47,7 +47,7 @@ extern "C" { #endif /** - * @brief Creates a screen capture of the specified display. + * @brief Capture a screen pixelmap of the specified display. * * @param displayId The ID of the display to be captured. * @param pixelMap The output pixel map of the captured display. @@ -59,7 +59,7 @@ extern "C" { * @syscap SystemCapability.Window.SessionManager.Core * @since 14 */ -NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateScreenCapture(uint32_t displayId, +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CaptureScreenPixelmap(uint32_t displayId, OH_PixelmapNative **pixelMap); #ifdef __cplusplus diff --git a/interfaces/kits/dmndk/dm/oh_display_manager.h b/interfaces/kits/dmndk/dm/oh_display_manager.h index 6145636dbe..caf6480af5 100644 --- a/interfaces/kits/dmndk/dm/oh_display_manager.h +++ b/interfaces/kits/dmndk/dm/oh_display_manager.h @@ -325,7 +325,7 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays( NativeDisplayManager_DisplaysInfo **allDisplays); /** - * @brief Destroys all displays. + * @brief Destroy all displays. * * @param allDisplays all displays to be free. * @syscap SystemCapability.Window.SessionManager.Core @@ -335,6 +335,7 @@ void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInf /** * @brief Create display information by display id. + * * @param displayId The display id. * @param displayInfo The pointer to the display information. * @return { @link DISPLAY_MANAGER_OK } If the operation is successful. @@ -343,7 +344,7 @@ void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInf * @syscap SystemCapability.Window.SessionManager.Core * @since 14 */ -NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayInfoById(uint32_t displayId, +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayById(uint32_t displayId, NativeDisplayManager_DisplayInfo **displayInfo); /** @@ -353,10 +354,10 @@ NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayInfoById(uin * @syscap SystemCapability.Window.SessionManager.Core * @since 14 */ -void OH_NativeDisplayManager_DestroyDisplayInfo(NativeDisplayManager_DisplayInfo *displayInfo); +void OH_NativeDisplayManager_DestroyDisplay(NativeDisplayManager_DisplayInfo *displayInfo); /** - * @brief Creates a primary display. + * @brief Create a primary display. * * @param displayInfo The information of the created display. * @return { @link DISPLAY_MANAGER_OK } If the operation is successful. diff --git a/interfaces/kits/dmndk/libdm.ndk.json b/interfaces/kits/dmndk/libdm.ndk.json index 4683811e51..c86ff6a93d 100644 --- a/interfaces/kits/dmndk/libdm.ndk.json +++ b/interfaces/kits/dmndk/libdm.ndk.json @@ -85,11 +85,11 @@ }, { "first_instroduced":"14", - "name":"OH_NativeDisplayManager_CreateDisplayInfoById" + "name":"OH_NativeDisplayManager_CreateDisplayById" }, { "first_instroduced":"14", - "name":"OH_NativeDisplayManager_DestroyDisplayInfo" + "name":"OH_NativeDisplayManager_DestroyDisplay" }, { "first_instroduced":"14", @@ -101,6 +101,6 @@ }, { "first_instroduced":"14", - "name":"OH_NativeDisplayManager_CreateScreenCapture" + "name":"OH_NativeDisplayManager_CaptureScreenPixelmap" } ] \ No newline at end of file diff --git a/interfaces/kits/napi/extension_window/BUILD.gn b/interfaces/kits/napi/extension_window/BUILD.gn index 790447e586..cb3a51d445 100644 --- a/interfaces/kits/napi/extension_window/BUILD.gn +++ b/interfaces/kits/napi/extension_window/BUILD.gn @@ -100,8 +100,10 @@ ohos_shared_library("extensionwindow_napi") { ] external_deps = [ + "ability_runtime:ability_manager", "ability_runtime:runtime", "ace_engine:ace_uicontent", + "bundle_framework:appexecfwk_base", "c_utils:utils", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/interfaces/kits/napi/screen_runtime/BUILD.gn b/interfaces/kits/napi/screen_runtime/BUILD.gn index c84e4781dd..10d42009c5 100644 --- a/interfaces/kits/napi/screen_runtime/BUILD.gn +++ b/interfaces/kits/napi/screen_runtime/BUILD.gn @@ -49,6 +49,7 @@ ohos_shared_library("screen_napi") { external_deps = [ "ability_runtime:runtime", "c_utils:utils", + "graphic_2d:librender_service_base", "graphic_surface:surface", # use for SurfaceUtils "hilog:libhilog", "hitrace:hitrace_meter", diff --git a/interfaces/kits/napi/screenshot/native_screenshot_module.cpp b/interfaces/kits/napi/screenshot/native_screenshot_module.cpp index 99e90dcb48..6c34bf30c1 100644 --- a/interfaces/kits/napi/screenshot/native_screenshot_module.cpp +++ b/interfaces/kits/napi/screenshot/native_screenshot_module.cpp @@ -169,7 +169,7 @@ static void IsNeedNotify(napi_env env, std::unique_ptr ¶m, napi_value { GNAPI_LOG("Get Screenshot Option: IsNeedNotify"); napi_value isNeedNotify; - NAPI_CALL_RETURN_VOID(env, napi_get_named_property(env, argv, "isNeedNotify", &isNeedNotify)); + NAPI_CALL_RETURN_VOID(env, napi_get_named_property(env, argv, "isNotificationNeeded", &isNeedNotify)); if (isNeedNotify != nullptr && GetType(env, isNeedNotify) == napi_boolean) { NAPI_CALL_RETURN_VOID(env, napi_get_value_bool(env, isNeedNotify, ¶m->option.isNeedNotify)); GNAPI_LOG("IsNeedNotify: %{public}d", param->option.isNeedNotify); @@ -182,7 +182,7 @@ static void IsNeedPointer(napi_env env, std::unique_ptr ¶m, napi_valu { GNAPI_LOG("Get Screenshot Option: IsNeedPointer"); napi_value isNeedPointer; - NAPI_CALL_RETURN_VOID(env, napi_get_named_property(env, argv, "isNeedPointer", &isNeedPointer)); + NAPI_CALL_RETURN_VOID(env, napi_get_named_property(env, argv, "isPointerNeeded", &isNeedPointer)); if (isNeedPointer != nullptr && GetType(env, isNeedPointer) == napi_boolean) { NAPI_CALL_RETURN_VOID(env, napi_get_value_bool(env, isNeedPointer, ¶m->option.isNeedPointer)); GNAPI_LOG("IsNeedPointer: %{public}d", param->option.isNeedPointer); diff --git a/interfaces/kits/napi/window_runtime/BUILD.gn b/interfaces/kits/napi/window_runtime/BUILD.gn index bca28858c0..92807d3223 100644 --- a/interfaces/kits/napi/window_runtime/BUILD.gn +++ b/interfaces/kits/napi/window_runtime/BUILD.gn @@ -114,6 +114,7 @@ ohos_shared_library("window_napi") { cfi_vcall_icall_only = true debug = false } + defines = [ "SUPPORT_SCREEN" ] sources = [ "window_manager_napi/js_window_manager.cpp", "window_manager_napi/window_manager_module.cpp", @@ -137,8 +138,10 @@ ohos_shared_library("window_napi") { "ability_runtime:ability_context_native", "ability_runtime:abilitykit_native", "ability_runtime:runtime", + "ability_runtime:wantagent_innerkits", "c_utils:utils", "common_event_service:cesfwk_innerkits", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "hitrace:hitrace_meter", @@ -177,6 +180,7 @@ ohos_shared_library("windowstage_kit") { ] external_deps = [ + "ability_runtime:ability_manager", "ability_runtime:runtime", "c_utils:utils", "hilog:libhilog", diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/window_manager_module.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/window_manager_module.cpp index 5e488a09af..a7ab4dbf23 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/window_manager_module.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/window_manager_module.cpp @@ -14,7 +14,6 @@ */ #include "js_window_manager.h" -#include "native_engine/native_engine.h" static napi_module g_winManagerModule = { .nm_filename = "module/libwindow_napi.so/window.js", diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 37819e5de0..f770d67099 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -851,6 +851,13 @@ napi_value JsWindow::SetWindowDecorVisible(napi_env env, napi_callback_info info return (me != nullptr) ? me->OnSetWindowDecorVisible(env, info) : nullptr; } +napi_value JsWindow::SetWindowTitleMoveEnabled(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetWindowTitleMoveEnabled(env, info) : nullptr; +} + napi_value JsWindow::SetSubWindowModal(napi_env env, napi_callback_info info) { TLOGI(WmsLogTag::WMS_SUB, "[NAPI]"); @@ -2688,7 +2695,14 @@ napi_value JsWindow::OnSetWindowLayoutFullScreen(napi_env env, napi_callback_inf if (errCode != WmErrorCode::WM_OK) { 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); + } + if (windowToken_->IsPcOrPadFreeMultiWindowMode()) { + TLOGE(WmsLogTag::WMS_IMMS, "device not support"); + return NapiGetUndefined(env); + } wptr weakToken(windowToken_); NapiAsyncTask::CompleteCallback complete = [weakToken, isLayoutFullScreen](napi_env env, NapiAsyncTask& task, int32_t status) { @@ -6265,6 +6279,34 @@ napi_value JsWindow::OnSetWindowDecorVisible(napi_env env, napi_callback_info in return NapiGetUndefined(env); } +napi_value JsWindow::OnSetWindowTitleMoveEnabled(napi_env env, napi_callback_info info) +{ + 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 != 1) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + bool enable = true; + if (!ConvertFromJsValue(env, argv[INDEX_ZERO], enable)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to enable"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + if (windowToken_ == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "windowToken is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetWindowTitleMoveEnabled(enable)); + if (ret != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Window set title move enable failed"); + return NapiThrowError(env, ret); + } + TLOGI(WmsLogTag::WMS_LAYOUT, "Window [%{public}u, %{public}s] end", + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str()); + return NapiGetUndefined(env); +} + napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) { size_t argc = 4; @@ -6701,6 +6743,10 @@ napi_value JsWindow::OnSetImmersiveModeEnabledState(napi_env env, napi_callback_ TLOGE(WmsLogTag::WMS_IMMS, "[NAPI]OnSetImmersiveModeEnabledState is not allowed since invalid window type"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); } + if (windowToken_->IsPcOrPadFreeMultiWindowMode()) { + TLOGE(WmsLogTag::WMS_IMMS, "device not support"); + return NapiGetUndefined(env); + } napi_value nativeVal = argv[0]; if (nativeVal == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to enable"); @@ -7161,6 +7207,7 @@ void BindFunctions(napi_env env, napi_value object, const char* moduleName) BindNativeFunction(env, object, "enableLandscapeMultiWindow", moduleName, JsWindow::EnableLandscapeMultiWindow); BindNativeFunction(env, object, "disableLandscapeMultiWindow", moduleName, JsWindow::DisableLandscapeMultiWindow); BindNativeFunction(env, object, "setWindowDecorVisible", moduleName, JsWindow::SetWindowDecorVisible); + BindNativeFunction(env, object, "setWindowTitleMoveEnabled", moduleName, JsWindow::SetWindowTitleMoveEnabled); BindNativeFunction(env, object, "setSubWindowModal", moduleName, JsWindow::SetSubWindowModal); BindNativeFunction(env, object, "enableDrag", moduleName, JsWindow::EnableDrag); BindNativeFunction(env, object, "setWindowDecorHeight", moduleName, JsWindow::SetWindowDecorHeight); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 8b216a15fe..0a668e51a3 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -160,6 +160,7 @@ public: static napi_value SetWaterMarkFlag(napi_env env, napi_callback_info info); static napi_value SetHandwritingFlag(napi_env env, napi_callback_info info); static napi_value SetWindowDecorVisible(napi_env env, napi_callback_info info); + static napi_value SetWindowTitleMoveEnabled(napi_env env, napi_callback_info info); static napi_value SetSubWindowModal(napi_env env, napi_callback_info info); static napi_value SetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetWindowDecorHeight(napi_env env, napi_callback_info info); @@ -247,6 +248,7 @@ private: napi_value OnGetWindowLimits(napi_env env, napi_callback_info info); napi_value OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_info info); napi_value OnSetWindowDecorVisible(napi_env env, napi_callback_info info); + napi_value OnSetWindowTitleMoveEnabled(napi_env env, napi_callback_info info); napi_value OnSetSubWindowModal(napi_env env, napi_callback_info info); napi_value OnSetWindowDecorHeight(napi_env env, napi_callback_info info); napi_value OnGetWindowDecorHeight(napi_env env, napi_callback_info info); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index a8525c1d2f..f3e538a7b2 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -33,6 +33,13 @@ JsWindowListener::~JsWindowListener() WLOGI("[NAPI]~JsWindowListener"); } +void JsWindowListener::OnLastStrongRef(const void *) +{ + if (napi_status::napi_ok != napi_send_event(env_, [jsCallBack = std::move(jsCallBack_)] {}, napi_eprio_immediate)) { + TLOGE(WmsLogTag::WMS_LIFE, "Failed to send event"); + } +} + void JsWindowListener::SetMainEventHandler() { auto mainRunner = AppExecFwk::EventRunner::GetMainEventRunner(); @@ -120,7 +127,6 @@ void JsWindowListener::OnSystemBarPropertyChange(DisplayId displayId, const Syst std::unique_ptr complete = std::make_unique ( [self = weakRef_, displayId, tints, eng = env_] (napi_env env, NapiAsyncTask& task, int32_t status) { - auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { WLOGFE("[NAPI]this listener or eng is nullptr"); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h index dfbb6294da..dbc9ff3be7 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h @@ -108,6 +108,8 @@ public: void OnMainWindowClose(bool& terminateCloseProcess) override; private: + void OnLastStrongRef(const void *) override; + Rect currRect_ = {0, 0, 0, 0}; WindowState state_ {WindowState::STATE_INITIAL}; void LifeCycleCallBack(LifeCycleEventType eventType); @@ -115,7 +117,7 @@ private: napi_env env_ = nullptr; std::shared_ptr jsCallBack_; CaseType caseType_ = CaseType::CASE_WINDOW; - wptr weakRef_ = nullptr; + wptr weakRef_ = nullptr; std::shared_ptr eventHandler_ = nullptr; DEFINE_VAR_DEFAULT_FUNC_SET(bool, IsDeprecatedInterface, isDeprecatedInterface, false) RectChangeReason currentReason_ = RectChangeReason::UNDEFINED; diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index 6bdd876a07..8e155d9948 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -15,11 +15,7 @@ #include "js_err_utils.h" #include "js_window_stage.h" -#include -#include "js_runtime_utils.h" #include "js_window.h" -#include "js_window_register_manager.h" -#include "js_window_utils.h" #include "window_manager_hilog.h" #include "permission.h" @@ -28,6 +24,8 @@ namespace Rosen { using namespace AbilityRuntime; namespace { const int CONTENT_STORAGE_ARG = 2; +constexpr size_t INDEX_ZERO = 0; +constexpr size_t FOUR_PARAMS_SIZE = 4; constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsWindowStage"}; } // namespace @@ -146,6 +144,13 @@ napi_value JsWindowStage::SetDefaultDensityEnabled(napi_env env, napi_callback_i return (me != nullptr) ? me->OnSetDefaultDensityEnabled(env, info) : nullptr; } +napi_value JsWindowStage::RemoveStartingWindow(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::WMS_MAIN, "[NAPI]"); + JsWindowStage* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnRemoveStartingWindow(env, info) : nullptr; +} + napi_value JsWindowStage::OnSetUIContent(napi_env env, napi_callback_info info) { size_t argc = 4; @@ -691,6 +696,44 @@ napi_value JsWindowStage::OnCreateSubWindowWithOptions(napi_env env, napi_callba return result; } +napi_value JsWindowStage::OnRemoveStartingWindow(napi_env env, napi_callback_info info) +{ + auto windowScene = windowScene_.lock(); + if (windowScene == nullptr) { + TLOGE(WmsLogTag::WMS_MAIN, "windowScene is null"); + napi_throw(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + return NapiGetUndefined(env); + } + + const char* const where = __func__; + NapiAsyncTask::CompleteCallback complete = + [where, windowScene](napi_env env, NapiAsyncTask& task, int32_t status) { + auto window = windowScene->GetMainWindow(); + if (window == nullptr) { + TLOGNE(WmsLogTag::WMS_MAIN, "%{public}s [NAPI]Get main window failed", where); + task.Reject(env, + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "Get main window failed")); + return; + } + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->NotifyRemoveStartingWindow()); + if (ret == WmErrorCode::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, JsErrUtils::CreateJsError(env, ret, "Notify remove starting window failed")); + } + }; + + size_t argc = FOUR_PARAMS_SIZE; + napi_value argv[FOUR_PARAMS_SIZE] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + napi_value lastParam = (argc == 0) ? nullptr : + (argv[INDEX_ZERO] != nullptr && GetType(env, argv[INDEX_ZERO]) == napi_function ? argv[INDEX_ZERO] : nullptr); + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnRemoveStartingWindow", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} + napi_value CreateJsWindowStage(napi_env env, std::shared_ptr windowScene) { WLOGFD("[NAPI]CreateJsWindowStage"); @@ -727,7 +770,8 @@ napi_value CreateJsWindowStage(napi_env env, std::shared_ptr objValue, "disableWindowDecor", moduleName, JsWindowStage::DisableWindowDecor); BindNativeFunction(env, objValue, "setDefaultDensityEnabled", moduleName, JsWindowStage::SetDefaultDensityEnabled); - + BindNativeFunction(env, + objValue, "removeStartingWindow", moduleName, JsWindowStage::RemoveStartingWindow); return objValue; } } // namespace Rosen diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.h b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.h index 486826ca3b..a03f7da56a 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.h +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.h @@ -49,6 +49,7 @@ public: static napi_value SetShowOnLockScreen(napi_env env, napi_callback_info info); static napi_value DisableWindowDecor(napi_env env, napi_callback_info info); static napi_value SetDefaultDensityEnabled(napi_env env, napi_callback_info info); + static napi_value RemoveStartingWindow(napi_env env, napi_callback_info info); private: napi_value OnSetUIContent(napi_env env, napi_callback_info info); @@ -64,6 +65,7 @@ private: napi_value OnSetShowOnLockScreen(napi_env env, napi_callback_info info); napi_value OnDisableWindowDecor(napi_env env, napi_callback_info info); napi_value OnSetDefaultDensityEnabled(napi_env env, napi_callback_info info); + napi_value OnRemoveStartingWindow(napi_env env, napi_callback_info info); std::weak_ptr windowScene_; }; diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/window_stage.js b/interfaces/kits/napi/window_runtime/window_stage_napi/window_stage.js index 8944d0a5e3..8f879e6b3d 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/window_stage.js +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/window_stage.js @@ -73,6 +73,10 @@ class WindowStage { setDefaultDensityEnabled(enabled) { return this.__window_stage__.setDefaultDensityEnabled(enabled); } + + removeStartingWindow() { + return this.__window_stage__.removeStartingWindow(); + } } export default WindowStage; diff --git a/previewer/BUILD.gn b/previewer/BUILD.gn index 4b24e14bd4..6be277e026 100644 --- a/previewer/BUILD.gn +++ b/previewer/BUILD.gn @@ -146,6 +146,10 @@ if (!ispreview) { "napi:ace_napi", ] + if (!build_ohos_sdk && !is_mingw) { + external_deps += [ "ability_runtime:ability_manager" ] + } + cflags_cc = [ "-DWINDOW_PREVIEW" ] cflags = [ "-std=c++11" ] diff --git a/previewer/include/window.h b/previewer/include/window.h index 483913517b..1c9a119e0c 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -296,7 +296,7 @@ public: virtual void SetDensity(float density) = 0; virtual WMError SetDefaultDensityEnabled(bool enabled) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual bool GetDefaultDensityEnabled() { return false; } - virtual float GetVirtualPixelRatio() { return 0.0f; } + virtual float GetVirtualPixelRatio() { return 1.0f; } virtual void UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type); virtual void CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback) = 0; virtual void SetContentInfoCallback(const ContentInfoCallback& callback) = 0; @@ -328,6 +328,7 @@ public: virtual WMError SetSingleFrameComposerEnabled(bool enable) = 0; virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) = 0; virtual WMError SetDecorVisible(bool isVisible) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + virtual WMError SetWindowTitleMoveEnabled(bool enable) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual WMError SetTitleButtonVisible(bool isMaximizeVisible, bool isMinimizeVisible, bool isSplitVisible, bool isCloseVisible) { @@ -412,6 +413,13 @@ public: * @param height The height after layout */ virtual void FlushLayoutSize(int32_t width, int32_t height) {} + + /** + * @brief notify window remove starting window. + * + * @return WMError + */ + virtual WMError NotifyRemoveStartingWindow() { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } }; } } diff --git a/setresolution/BUILD.gn b/setresolution/BUILD.gn index ee6a7bd382..f4479c78a7 100644 --- a/setresolution/BUILD.gn +++ b/setresolution/BUILD.gn @@ -40,6 +40,7 @@ ohos_executable("setresolution_screen") { external_deps = [ "c_utils:utils", + "graphic_2d:librender_service_base", "graphic_surface:surface", "init:libbegetutil", ] diff --git a/test/systemtest/wms/window_multi_ability_test.cpp b/test/systemtest/wms/window_multi_ability_test.cpp index 33e41e860f..a940a402d2 100644 --- a/test/systemtest/wms/window_multi_ability_test.cpp +++ b/test/systemtest/wms/window_multi_ability_test.cpp @@ -217,17 +217,25 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow2, Function | MediumTest | Le HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow03, Function | MediumTest | Level3) { sptr scene1 = Utils::CreateWindowScene(); - ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene1->GoForeground()); + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_EQ(WMError::WM_OK, scene1->GoForeground()); + } else { + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene1->GoForeground()); + } sptr scene2 = Utils::CreateWindowScene(); sptr scene3 = Utils::CreateWindowScene(); - ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene3->GoForeground()); + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_EQ(WMError::WM_OK, scene3->GoForeground()); + } else { + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene3->GoForeground()); + } DoSceneResource(scene1); sptr scene4 = Utils::CreateWindowScene(); if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene3->GoBackground()); - ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene2->GoForeground()); - ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene4->GoForeground()); - ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene2->GoBackground()); + ASSERT_EQ(WMError::WM_OK, scene3->GoBackground()); + ASSERT_EQ(WMError::WM_OK, scene2->GoForeground()); + ASSERT_EQ(WMError::WM_OK, scene4->GoForeground()); + ASSERT_EQ(WMError::WM_OK, scene2->GoBackground()); } else { ASSERT_NE(WMError::WM_OK, scene3->GoBackground()); ASSERT_NE(WMError::WM_OK, scene2->GoForeground()); diff --git a/utils/BUILD.gn b/utils/BUILD.gn index db7bafa9e5..6d086bda8d 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -199,6 +199,7 @@ ohos_shared_library("libwmutil") { "c_utils:utils", "eventhandler:libeventhandler", "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "graphic_surface:surface", "hicollie:libhicollie", diff --git a/utils/include/vsync_station.h b/utils/include/vsync_station.h index 6d50a995f0..c1b570dda3 100644 --- a/utils/include/vsync_station.h +++ b/utils/include/vsync_station.h @@ -28,6 +28,7 @@ namespace OHOS { namespace Rosen { class RSFrameRateLinker; class VSyncReceiver; +class FrameRateRange; using FrameRateLinkerId = uint64_t; using NodeId = uint64_t; @@ -64,6 +65,9 @@ private: std::shared_ptr vsyncHandler_ = nullptr; std::string vsyncTimeoutTaskName_; + std::shared_ptr lastFrameRateRange_ = nullptr; + int32_t lastAnimatorExpectedFrameRate_ = 0; + std::mutex mutex_; bool isFirstVsyncRequest_ = true; bool isFirstVsyncBack_ = true; diff --git a/utils/include/window_transition_info.h b/utils/include/window_transition_info.h index 43b55529ca..c1a48f367e 100644 --- a/utils/include/window_transition_info.h +++ b/utils/include/window_transition_info.h @@ -15,6 +15,9 @@ #ifndef OHOS_ROSEN_WINDOW_TRANSITION_INFO_H #define OHOS_ROSEN_WINDOW_TRANSITION_INFO_H +#ifndef SUPPORT_GRAPHICS +#define SUPPORT_GRAPHICS +#endif #include #include diff --git a/utils/src/unreliable_window_info.cpp b/utils/src/unreliable_window_info.cpp index 4548fe599a..0796483fe1 100644 --- a/utils/src/unreliable_window_info.cpp +++ b/utils/src/unreliable_window_info.cpp @@ -14,7 +14,6 @@ */ #include "window_manager.h" -#include "wm_common.h" namespace OHOS { namespace Rosen { diff --git a/utils/src/vsync_station.cpp b/utils/src/vsync_station.cpp index e815859b85..5348ba213d 100644 --- a/utils/src/vsync_station.cpp +++ b/utils/src/vsync_station.cpp @@ -222,10 +222,15 @@ FrameRateLinkerId VsyncStation::GetFrameRateLinkerId() void VsyncStation::FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRate, uint32_t rateType) { if (auto frameRateLinker = GetFrameRateLinker()) { + if (lastFrameRateRange_ == nullptr) { + lastFrameRateRange_ = std::make_shared(0, RANGE_MAX_REFRESHRATE, rate, rateType); + } else { + lastFrameRateRange_->Set(0, RANGE_MAX_REFRESHRATE, rate, rateType); + } + lastAnimatorExpectedFrameRate_ = animatorExpectedFrameRate; if (frameRateLinker->IsEnable()) { TLOGD(WmsLogTag::WMS_MAIN, "rate %{public}d, linkerId %{public}" PRIu64, rate, frameRateLinker->GetId()); - FrameRateRange range = {0, RANGE_MAX_REFRESHRATE, rate, rateType}; - frameRateLinker->UpdateFrameRateRange(range, animatorExpectedFrameRate); + frameRateLinker->UpdateFrameRateRange(*lastFrameRateRange_, lastAnimatorExpectedFrameRate_); } } } @@ -234,11 +239,18 @@ void VsyncStation::SetFrameRateLinkerEnable(bool enabled) { if (auto frameRateLinker = GetFrameRateLinker()) { if (!enabled) { + // clear frameRate vote FrameRateRange range = {0, RANGE_MAX_REFRESHRATE, 0}; TLOGI(WmsLogTag::WMS_MAIN, "rate %{public}d, linkerId %{public}" PRIu64, range.preferred_, frameRateLinker->GetId()); frameRateLinker->UpdateFrameRateRange(range); frameRateLinker->UpdateFrameRateRangeImme(range); + } else if (lastFrameRateRange_) { + // to resolve these cases: + // case 1: when app go backGround and haven't cleared the vote itself, the vote will be invalid forever, + // so we restore the vote which is cleared here. + // case 2: when frameRateLinker is disabled, the frameRate vote by app will be delayed until linker enable. + frameRateLinker->UpdateFrameRateRange(*lastFrameRateRange_, lastAnimatorExpectedFrameRate_); } frameRateLinker->SetEnable(enabled); } diff --git a/window_scene/intention_event/BUILD.gn b/window_scene/intention_event/BUILD.gn index 878a577f55..475aa84954 100644 --- a/window_scene/intention_event/BUILD.gn +++ b/window_scene/intention_event/BUILD.gn @@ -46,6 +46,7 @@ ohos_shared_library("libintention_event") { "eventhandler:libeventhandler", "ffrt:libffrt", "graphic_2d:libcomposer", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "graphic_2d:window_animation", "hicollie:libhicollie", @@ -54,6 +55,7 @@ ohos_shared_library("libintention_event") { "hitrace:hitrace_meter", "init:libbegetutil", "input:libmmi-client", + "libxml2:libxml2", ] defines = [] diff --git a/window_scene/intention_event/service/BUILD.gn b/window_scene/intention_event/service/BUILD.gn index fd1cbc6577..cb246bfdd4 100644 --- a/window_scene/intention_event/service/BUILD.gn +++ b/window_scene/intention_event/service/BUILD.gn @@ -47,6 +47,7 @@ ohos_shared_library("intention_event_anr_manager") { public_external_deps = [ "accessibility:accessibility_common" ] external_deps = [ "ability_base:want", + "bundle_framework:appexecfwk_base", "c_utils:utils", "eventhandler:libeventhandler", "hicollie:libhicollie", diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index 278e1a04cc..2c9a77fb49 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -600,6 +600,7 @@ struct AppWindowSceneConfig { struct DeviceScreenConfig { std::string rotationPolicy_ = "11"; // default use phone policy + std::string defaultRotationPolicy_ = "1"; // default unspecified policy bool isRightPowerButton_ = true; }; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/BUILD.gn b/window_scene/interfaces/kits/napi/scene_session_manager/BUILD.gn index 98ce641ac6..1a165ba743 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/scene_session_manager/BUILD.gn @@ -61,6 +61,7 @@ ohos_shared_library("scenesessionmanager_napi") { "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "hitrace:hitrace_meter", @@ -68,7 +69,9 @@ ohos_shared_library("scenesessionmanager_napi") { "image_framework:image_native", "input:libmmi-client", "ipc:ipc_single", + "libxml2:libxml2", "napi:ace_napi", + "preferences:native_preferences", ] defines = [] diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index f931ca6f58..1880395dd1 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -344,6 +344,7 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c BindNativeFunction(env, objValue, "setUniqueDensityDpiFromSCB", moduleName, JsSceneSession::SetUniqueDensityDpiFromSCB); BindNativeFunction(env, objValue, "setBlankFlag", moduleName, JsSceneSession::SetBlankFlag); + BindNativeFunction(env, objValue, "removeBlank", moduleName, JsSceneSession::RemoveBlank); BindNativeFunction(env, objValue, "setBufferAvailableCallbackEnable", moduleName, JsSceneSession::SetBufferAvailableCallbackEnable); BindNativeFunction(env, objValue, "syncDefaultRequestedOrientation", moduleName, @@ -653,12 +654,12 @@ void JsSceneSession::ProcessAdjustKeyboardLayoutRegister() void JsSceneSession::ProcessLayoutFullScreenChangeRegister() { - auto sessionchangeCallback = sessionchangeCallback_.promote(); - if (sessionchangeCallback == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "sessionchangeCallback is nullptr"); + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "session is nullptr, id:%{public}d", persistentId_); return; } - sessionchangeCallback->onLayoutFullScreenChangeFunc_ = [weakThis = wptr(this)](bool isLayoutFullScreen) { + auto layoutFullScreenChangeCallback = [weakThis = wptr(this)](bool isLayoutFullScreen) { auto jsSceneSession = weakThis.promote(); if (!jsSceneSession) { TLOGE(WmsLogTag::WMS_LIFE, "ProcessLayoutFullScreenChangeRegister jsSceneSession is null"); @@ -666,6 +667,7 @@ void JsSceneSession::ProcessLayoutFullScreenChangeRegister() } jsSceneSession->OnLayoutFullScreenChange(isLayoutFullScreen); }; + session->RegisterLayoutFullScreenChangeCallback(layoutFullScreenChangeCallback); TLOGI(WmsLogTag::WMS_LAYOUT, "success"); } @@ -1521,20 +1523,19 @@ void JsSceneSession::ProcessNeedAvoidRegister() void JsSceneSession::ProcessIsCustomAnimationPlaying() { - auto sessionchangeCallback = sessionchangeCallback_.promote(); - if (sessionchangeCallback == nullptr) { - WLOGFE("sessionchangeCallback is nullptr"); + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr"); return; } - sessionchangeCallback->onIsCustomAnimationPlaying_ = [weakThis = wptr(this)](bool status) { + session->RegisterIsCustomAnimationPlayingCallback([weakThis = wptr(this)](bool status) { auto jsSceneSession = weakThis.promote(); if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessIsCustomAnimationPlaying jsSceneSession is null"); + TLOGNE(WmsLogTag::WMS_LIFE, "jsSceneSession is null"); return; } jsSceneSession->OnIsCustomAnimationPlaying(status); - }; - WLOGFD("success"); + }); } void JsSceneSession::ProcessShowWhenLockedRegister() @@ -1995,6 +1996,13 @@ napi_value JsSceneSession::SetBlankFlag(napi_env env, napi_callback_info info) return (me != nullptr) ? me->OnSetBlankFlag(env, info) : nullptr; } +napi_value JsSceneSession::RemoveBlank(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::WMS_SCB, "[NAPI]"); + JsSceneSession *me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnRemoveBlank(env, info) : nullptr; +} + napi_value JsSceneSession::SetBufferAvailableCallbackEnable(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::WMS_SCB, "[NAPI]"); @@ -4723,6 +4731,17 @@ napi_value JsSceneSession::OnSetBlankFlag(napi_env env, napi_callback_info info) return NapiGetUndefined(env); } +napi_value JsSceneSession::OnRemoveBlank(napi_env env, napi_callback_info info) +{ + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_SCB, "[NAPI]session is nullptr, id:%{public}d", persistentId_); + return NapiGetUndefined(env); + } + session->NotifyRemoveBlank(); + return NapiGetUndefined(env); +} + napi_value JsSceneSession::OnSetBufferAvailableCallbackEnable(napi_env env, napi_callback_info info) { size_t argc = ARGC_FOUR; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h index d3be4e6d00..f4a0c8b1fd 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h @@ -25,8 +25,6 @@ #include "interfaces/include/ws_common.h" #include "session/host/include/scene_session.h" -#include "js_scene_utils.h" -#include "task_scheduler.h" namespace OHOS::Rosen { enum class ListenerFuncType : uint32_t { @@ -143,6 +141,7 @@ private: static napi_value SetCompatibleModeEnableInPad(napi_env env, napi_callback_info info); static napi_value SetUniqueDensityDpiFromSCB(napi_env env, napi_callback_info info); static napi_value SetBlankFlag(napi_env env, napi_callback_info info); + static napi_value RemoveBlank(napi_env env, napi_callback_info info); static napi_value SetBufferAvailableCallbackEnable(napi_env env, napi_callback_info info); static napi_value SyncDefaultRequestedOrientation(napi_env env, napi_callback_info info); static napi_value SetIsPcAppInPad(napi_env env, napi_callback_info info); @@ -195,6 +194,7 @@ private: napi_value OnSetCompatibleModeEnableInPad(napi_env env, napi_callback_info info); napi_value OnSetUniqueDensityDpiFromSCB(napi_env env, napi_callback_info info); napi_value OnSetBlankFlag(napi_env env, napi_callback_info info); + napi_value OnRemoveBlank(napi_env env, napi_callback_info info); napi_value OnSetBufferAvailableCallbackEnable(napi_env env, napi_callback_info info); napi_value OnSyncDefaultRequestedOrientation(napi_env env, napi_callback_info info); napi_value OnSetIsPcAppInPad(napi_env env, napi_callback_info info); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 958b8576de..75465e8350 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -3389,10 +3389,10 @@ napi_value JsSceneSessionManager::OnGetWindowPid(napi_env env, napi_callback_inf void JsSceneSessionManager::OnCloseTargetFloatWindow(const std::string& bundleName) { - TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "[NAPI]in"); - auto task = [this, bundleName, jsCallBack = GetJSCallback(CLOSE_TARGET_FLOAT_WINDOW_CB), env = env_]() { + TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "[NAPI]"); + auto task = [this, bundleName, jsCallBack = GetJSCallback(CLOSE_TARGET_FLOAT_WINDOW_CB), env = env_] { if (jsCallBack == nullptr) { - TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "[NAPI]jsCallBack is nullptr"); + TLOGNE(WmsLogTag::WMS_MULTI_WINDOW, "[NAPI]jsCallBack is nullptr"); return; } napi_value jsBundleNameObj = CreateJsValue(env, bundleName); @@ -3405,7 +3405,7 @@ void JsSceneSessionManager::OnCloseTargetFloatWindow(const std::string& bundleNa void JsSceneSessionManager::ProcessCloseTargetFloatWindow() { ProcessCloseTargetFloatWindowFunc func = [this](const std::string& bundleName) { - TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "ProcessCloseTargetFloatWindow. bundleName:%{public}s", bundleName.c_str()); + TLOGND(WmsLogTag::WMS_MULTI_WINDOW, "ProcessCloseTargetFloatWindow. bundleName:%{public}s", bundleName.c_str()); this->OnCloseTargetFloatWindow(bundleName); }; SceneSessionManager::GetInstance().SetCloseTargetFloatWindowFunc(func); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp index 8ee1c2af55..f3616bb9fc 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp @@ -970,6 +970,7 @@ napi_value CreateJsSessionRecoverInfo( Rect rect = property->GetWindowRect(); WSRect wsRect = { rect.posX_, rect.posY_, rect.width_, rect.height_ }; napi_set_named_property(env, objValue, "recoverRect", CreateJsSessionRect(env, wsRect)); + napi_set_named_property(env, objValue, "layoutFullScreen", CreateJsValue(env, property->IsLayoutFullScreen())); return objValue; } diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn b/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn index fb3e6e352e..bc66263aa1 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn @@ -47,6 +47,7 @@ ohos_shared_library("screensessionmanager_napi") { "ability_runtime:runtime", "c_utils:utils", "eventhandler:libeventhandler", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "hitrace:hitrace_meter", diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_device_screen_config.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_device_screen_config.cpp index 962e28f99e..7541a1eb4f 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_device_screen_config.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_device_screen_config.cpp @@ -22,7 +22,8 @@ using namespace AbilityRuntime; napi_value JsDeviceScreenConfig::CreateDeviceScreenConfig(napi_env env, const DeviceScreenConfig& config) { - TLOGI(WmsLogTag::DMS, "DeviceScreenConfig rotationPolicy:%{public}s.", config.rotationPolicy_.c_str()); + TLOGI(WmsLogTag::DMS, "DeviceScreenConfig rotationPolicy:%{public}s, defaultRotationPolicy:%{public}s.", + config.rotationPolicy_.c_str(), config.defaultRotationPolicy_.c_str()); napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { @@ -30,6 +31,7 @@ napi_value JsDeviceScreenConfig::CreateDeviceScreenConfig(napi_env env, const De return NapiGetUndefined(env); } napi_set_named_property(env, objValue, "rotationPolicy", CreateJsValue(env, config.rotationPolicy_)); + napi_set_named_property(env, objValue, "defaultRotationPolicy", CreateJsValue(env, config.defaultRotationPolicy_)); napi_set_named_property(env, objValue, "isRightPowerButton", CreateJsValue(env, config.isRightPowerButton_)); return objValue; } diff --git a/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn b/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn index 1f377f5263..b320d56868 100644 --- a/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn @@ -48,8 +48,10 @@ ohos_shared_library("transactionmanager_napi") { "ability_runtime:runtime", "c_utils:utils", "ffrt:libffrt", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", + "libxml2:libxml2", "napi:ace_napi", ] diff --git a/window_scene/screen_session_manager/BUILD.gn b/window_scene/screen_session_manager/BUILD.gn index 6e31619d2d..5645bc9c02 100644 --- a/window_scene/screen_session_manager/BUILD.gn +++ b/window_scene/screen_session_manager/BUILD.gn @@ -123,12 +123,14 @@ ohos_shared_library("screen_session_manager") { "ability_runtime:app_manager", "ability_runtime:dataobs_manager", "ability_runtime:extension_manager", + "bundle_framework:appexecfwk_base", "c_utils:utils", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "data_share:datashare_common", "data_share:datashare_consumer", "eventhandler:libeventhandler", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hicollie:libhicollie", "hilog:libhilog", diff --git a/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_sensor_manager.h b/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_sensor_manager.h index 158b0b6296..a258379792 100644 --- a/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_sensor_manager.h +++ b/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_sensor_manager.h @@ -16,8 +16,6 @@ #ifndef OHOS_ROSEN_SUPER_FOLD_SENSOR_MANAGER_H #define OHOS_ROSEN_SUPER_FOLD_SENSOR_MANAGER_H -#ifdef SENSOR_ENABLE - #include #include #include @@ -46,16 +44,12 @@ public: void RegisterHallCallback(); // 磁吸键盘 - void RegisterSoftKeyboardCallback(); - void UnregisterPostureCallback(); void UnregisterHallCallback(); void HandlePostureData(const SensorEvent * const event); - void HandleSoftKeyboardData(); - void HandleHallData(const SensorEvent * const event); void HandleSuperSensorChange(); @@ -66,17 +60,15 @@ private: std::recursive_mutex mutex_; - bool hasKeyboard_ = false; - SuperFoldStatusChangeEvents events_ = SuperFoldStatusChangeEvents::UNDEFINED; SensorUser postureUser {}; SensorUser hallUser {}; - float globalAngle = 170.0F; + float curAngle_ = 170.0F; - uint16_t globalHall = USHRT_MAX; + uint16_t curHall_ = USHRT_MAX; void NotifyFoldAngleChanged(float foldAngle); @@ -90,6 +82,5 @@ private: }; } } - -#endif // SENSOR_ENABLE + #endif // OHOS_ROSEN_SUPER_FOLD_SENSOR_MANAGER_H \ No newline at end of file diff --git a/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_state_manager.h b/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_state_manager.h index 9fd06e7b59..47a15aea53 100644 --- a/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_state_manager.h +++ b/window_scene/screen_session_manager/include/fold_screen_controller/super_fold_state_manager.h @@ -21,6 +21,7 @@ #include #include #include +#include #include "dm_common.h" #include "wm_single_instance.h" @@ -35,45 +36,44 @@ public: SuperFoldStateManager(); ~SuperFoldStateManager(); - void initStateManagerMap(SuperFoldStatus curState, + void AddStateManagerMap(SuperFoldStatus curState, SuperFoldStatusChangeEvents event, SuperFoldStatus nextState, - std::function action); + std::function action); - void transferState(SuperFoldStatus nextState); + void TransferState(SuperFoldStatus nextState); void HandleSuperFoldStatusChange(SuperFoldStatusChangeEvents events); SuperFoldStatus GetCurrentStatus(); - - void SetCurrentStatus(SuperFoldStatus curState); + FoldStatus MatchSuperFoldStatusToFoldStatus(SuperFoldStatus superFoldStatus); private: - SuperFoldStatus curState_ = SuperFoldStatus::HALF_FOLDED; + std::atomic curState_ = SuperFoldStatus::HALF_FOLDED; struct Transition { SuperFoldStatus nextState; - std::function action; + std::function action; }; using transEvent = std::pair; std::map stateManagerMap_; - static void DoAngleChangeFolded(); + static void DoAngleChangeFolded(SuperFoldStatusChangeEvents event); - static void DoAngleChangeHalfFolded(); + static void DoAngleChangeHalfFolded(SuperFoldStatusChangeEvents event); - static void DoAngleChangeExpanded(); + static void DoAngleChangeExpanded(SuperFoldStatusChangeEvents event); - static void DoKeyboardOn(); + static void DoKeyboardOn(SuperFoldStatusChangeEvents event); - static void DoKeyboardOff(); + static void DoKeyboardOff(SuperFoldStatusChangeEvents event); - static void DoSoftKeyboardOn(); + static void DoFoldedToHalfFolded(SuperFoldStatusChangeEvents event); - static void DoSoftKeyboardOff(); + static void DoExpandedToKeyboard(SuperFoldStatusChangeEvents event); - static void DoExpandedToKeyboard(); + void SetCurrentStatus(SuperFoldStatus curState); }; } // Rosen } // OHOS diff --git a/window_scene/screen_session_manager/include/screen_session_dumper.h b/window_scene/screen_session_manager/include/screen_session_dumper.h index cd81b47b9f..c475a5c49e 100644 --- a/window_scene/screen_session_manager/include/screen_session_dumper.h +++ b/window_scene/screen_session_manager/include/screen_session_dumper.h @@ -37,6 +37,7 @@ public: ScreenSessionDumper(int fd, const std::vector& args); ~ScreenSessionDumper() = default; + bool IsNumber(std::string str); void ExcuteDumpCmd(); void DumpEventTracker(EventTracker& tracker); void DumpFreezedPidList(std::set pidList); @@ -57,6 +58,7 @@ private: void DumpScreenInfoById(ScreenId id); void DumpScreenPropertyById(ScreenId id); void ExcuteInjectCmd(); + void ExcuteInjectCmd2(); /* hidumper 命令注入隔离 */ @@ -71,11 +73,21 @@ private: bool IsValidDisplayModeCommand(std::string command); int SetFoldDisplayMode(); int SetFoldStatusLocked(); + void SetHallAndPostureValue(std::string input); + void SetHallAndPostureStatus(std::string input); private: int fd_; std::vector params_; std::string dumpInfo_; +/* + 依赖的外部定义 +*/ +private: + typedef struct EXTHALLData { + float flag = 0.0; + float hall = 0.0; + } ExtHallData; }; } // Rosen } // OHOS diff --git a/window_scene/screen_session_manager/include/screen_session_manager.h b/window_scene/screen_session_manager/include/screen_session_manager.h index eb895f53ff..8023bc974c 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -473,6 +473,7 @@ private: std::atomic cachedSettingDpi_ {0}; uint32_t defaultDpi {0}; + uint32_t extendDefaultDpi_ {0}; uint32_t defaultDeviceRotationOffset_ { 0 }; bool isMultiScreenCollaboration_ = false; diff --git a/window_scene/screen_session_manager/include/screen_setting_helper.h b/window_scene/screen_session_manager/include/screen_setting_helper.h index bc7254ec08..74764551cf 100644 --- a/window_scene/screen_session_manager/include/screen_setting_helper.h +++ b/window_scene/screen_session_manager/include/screen_setting_helper.h @@ -17,6 +17,7 @@ #include #include +#include #include "setting_observer.h" @@ -40,8 +41,8 @@ public: static void SetSettingRotationScreenId(int32_t screenId); static bool GetSettingRotation(int32_t& rotation, const std::string& key = SETTING_ROTATION_KEY); static bool GetSettingRotationScreenID(int32_t& screenId, const std::string& key = SETTING_ROTATION_SCREEN_ID_KEY); - static void RemoveInvalidChar(std::string& dataStr, const std::string& inputString); - static bool SplitString(std::vector& splitValues, const std::string& inputString); + static std::string RemoveInvalidChar(const std::string& input); + static bool SplitString(std::vector& splitValues, const std::string& input, char delimiter = ','); static int32_t GetDataFromString(std::vector& datas, const std::string& inputString); static bool GetSettingRecoveryResolutionString(std::vector& resolutionStrings, const std::string& key = SETTING_RECOVERY_RESOLUTION_KEY); diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp index c4e7318205..75876a5d57 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/dual_display_fold_policy.cpp @@ -132,14 +132,12 @@ void DualDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMode) ReportFoldDisplayModeChange(displayMode); ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode); ChangeScreenDisplayModeProc(screenSession, displayMode); - if (currentDisplayMode_ != displayMode) { - ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode); - } { std::lock_guard lock_mode(displayModeMutex_); currentDisplayMode_ = displayMode; lastDisplayMode_ = displayMode; } + ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode); SetdisplayModeChangeStatus(false); } diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp index f26b7ac42f..bc4fa533df 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.cpp @@ -48,7 +48,7 @@ void SensorFoldStateManager::HandleSensorChange(FoldStatus nextState, float angl WLOGFW("fold state is UNKNOWN"); return; } - if (mState_ == nextState && !IsTentMode()) { + if (mState_ == nextState) { WLOGFD("fold state doesn't change, foldState = %{public}d.", mState_); return; } @@ -57,7 +57,7 @@ void SensorFoldStateManager::HandleSensorChange(FoldStatus nextState, float angl PowerMgr::PowerMgrClient::GetInstance().RefreshActivity(); NotifyReportFoldStatusToScb(mState_, nextState, angle); - + mState_ = nextState; if (foldScreenPolicy != nullptr) { foldScreenPolicy->SetFoldStatus(mState_); diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp index 92335fb42d..4bb06fd13b 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_fold_policy.cpp @@ -125,12 +125,12 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode displayMod break; } } - ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode); { std::lock_guard lock_mode(displayModeMutex_); currentDisplayMode_ = displayMode; lastDisplayMode_ = displayMode; } + ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode); } void SingleDisplayFoldPolicy::SendSensorResult(FoldStatus foldStatus) diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp index d95bd924b3..6fa73dc206 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/single_display_pocket_fold_policy.cpp @@ -109,12 +109,12 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayMode(FoldDisplayMode disp ReportFoldDisplayModeChange(displayMode); ScreenSessionManager::GetInstance().SwitchScrollParam(displayMode); ChangeScreenDisplayModeProc(screenSession, displayMode); - ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode); { std::lock_guard lock_mode(displayModeMutex_); currentDisplayMode_ = displayMode; lastDisplayMode_ = displayMode; } + ScreenSessionManager::GetInstance().NotifyDisplayModeChanged(displayMode); } void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeProc(sptr screenSession, diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_sensor_manager.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_sensor_manager.cpp index 3a6c9450ee..133b336de9 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_sensor_manager.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_sensor_manager.cpp @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifdef SENSOR_ENABLE #include #include @@ -34,9 +33,9 @@ constexpr float ANGLE_MIN_VAL = 30.0F; constexpr float ANGLE_MAX_VAL = 180.0F; constexpr float ANGLE_FLAT_THRESHOLD = 150.0F; constexpr float ANGLE_HALF_FOLD_THRESHOLD = 135.0F; -constexpr int32_t HALL_HAVE_KEYBOARD_THRESHOLD = 0x0100; -constexpr int32_t HALL_REMOVE_KEYBOARD_THRESHOLD = 0; -constexpr int32_t HALL_ACTIVE = 1 << 2; +constexpr uint16_t HALL_HAVE_KEYBOARD_THRESHOLD = 0B0100; +constexpr uint16_t HALL_REMOVE_KEYBOARD_THRESHOLD = 0B0000; +constexpr uint16_t HALL_ACTIVE = 1 << 2; constexpr int32_t SENSOR_SUCCESS = 0; constexpr int32_t POSTURE_INTERVAL = 100000000; constexpr uint16_t SENSOR_EVENT_FIRST_DATA = 0; @@ -109,8 +108,6 @@ void SuperFoldSensorManager::UnregisterHallCallback() } } -void SuperFoldSensorManager::RegisterSoftKeyboardCallback() {} - void SuperFoldSensorManager::HandlePostureData(const SensorEvent * const event) { if (event == nullptr) { @@ -126,28 +123,29 @@ void SuperFoldSensorManager::HandlePostureData(const SensorEvent * const event) return; } PostureData *postureData = reinterpret_cast(event[SENSOR_EVENT_FIRST_DATA].data); - globalAngle = (*postureData).angle; - if (std::isless(globalAngle, ANGLE_MIN_VAL) || - std::isgreater(globalAngle, ANGLE_MAX_VAL + ACCURACY_ERROR_FOR_PC)) { - TLOGI(WmsLogTag::DMS, "Invalid value, angle value is: %{public}f.", globalAngle); + curAngle_ = (*postureData).angle; + if (std::isgreater(curAngle_, ANGLE_MAX_VAL + ACCURACY_ERROR_FOR_PC)) { + TLOGI(WmsLogTag::DMS, "Invalid value, angle value is: %{public}f.", curAngle_); return; } - TLOGI(WmsLogTag::DMS, "angle value is: %{public}f.", globalAngle); - NotifyFoldAngleChanged(globalAngle); + TLOGI(WmsLogTag::DMS, "angle value is: %{public}f.", curAngle_); + NotifyFoldAngleChanged(curAngle_); } void SuperFoldSensorManager::NotifyFoldAngleChanged(float foldAngle) { - if (std::isgreater(foldAngle, ANGLE_FLAT_THRESHOLD)) { - TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged is not Folded"); + if (std::isgreaterequal(foldAngle, ANGLE_FLAT_THRESHOLD)) { + TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged is Expanded"); events_ = SuperFoldStatusChangeEvents::ANGLE_CHANGE_EXPANDED; } else if (std::isless(foldAngle, ANGLE_HALF_FOLD_THRESHOLD) && std::isgreater(foldAngle, ANGLE_MIN_VAL)) { - TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged is folded"); + TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged is Half Folded"); events_ = SuperFoldStatusChangeEvents::ANGLE_CHANGE_HALF_FOLDED; - } else { - TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged"); + } else if (std::islessequal(foldAngle, ANGLE_MIN_VAL)) { + TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged is Folded"); events_ = SuperFoldStatusChangeEvents::ANGLE_CHANGE_FOLDED; + } else { + TLOGI(WmsLogTag::DMS, "Angle Don't Change!"); return; } // notify @@ -175,55 +173,39 @@ void SuperFoldSensorManager::HandleHallData(const SensorEvent * const event) auto status = static_cast(data->status); TLOGI(WmsLogTag::DMS, "HallData status is: %{public}u.", status); - if (globalHall == (status & HALL_ACTIVE)) { - TLOGI(WmsLogTag::DMS, "Hall don't change, hall = %{public}u", globalHall); + if (curHall_ == (status & HALL_ACTIVE)) { + TLOGI(WmsLogTag::DMS, "Hall don't change, hall = %{public}u", curHall_); return; } - globalHall = (status & HALL_ACTIVE); - TLOGI(WmsLogTag::DMS, "Hall change, hall = %{public}u", globalHall); - NotifyHallChanged(globalHall); + curHall_ = (status & HALL_ACTIVE); + TLOGI(WmsLogTag::DMS, "Hall change, hall = %{public}u", curHall_); + NotifyHallChanged(curHall_); } void SuperFoldSensorManager::NotifyHallChanged(uint16_t Hall) { if (Hall == HALL_REMOVE_KEYBOARD_THRESHOLD) { - TLOGI(WmsLogTag::DMS, "NotifyHallChanged is not hasPhysicalKeyboard"); - hasKeyboard_ = false; + TLOGI(WmsLogTag::DMS, "NotifyHallChanged: Keyboard off!"); events_ = SuperFoldStatusChangeEvents::KEYBOARD_OFF; } else if (Hall == HALL_HAVE_KEYBOARD_THRESHOLD) { - TLOGI(WmsLogTag::DMS, "NotifyHallChanged is hasPhysicalKeyboard"); - hasKeyboard_ = true; + TLOGI(WmsLogTag::DMS, "NotifyHallChanged: Keyboard on!"); events_ = SuperFoldStatusChangeEvents::KEYBOARD_ON; } else { - TLOGI(WmsLogTag::DMS, "NotifyHallChanged invalide hall value"); + TLOGI(WmsLogTag::DMS, "NotifyHallChanged: Invalid Hall Value!"); return; } // notify HandleSuperSensorChange(); } -void SuperFoldSensorManager::HandleSoftKeyboardData() {} - -void SuperFoldSensorManager::NotifySoftKeyboardChanged() {} - void SuperFoldSensorManager::HandleSuperSensorChange() { // trigger events - if (hasKeyboard_ && events_ != SuperFoldStatusChangeEvents::KEYBOARD_OFF) { - TLOGI(WmsLogTag::DMS, "Don't Change!"); - return; - } SuperFoldStateManager::GetInstance().HandleSuperFoldStatusChange(events_); } -void SuperFoldSensorManager::SetHasKeyboard(bool flag) -{ - hasKeyboard_ = flag; -} - SuperFoldSensorManager::SuperFoldSensorManager() {} SuperFoldSensorManager::~SuperFoldSensorManager() {} } // Rosen -} // OHOS -#endif \ No newline at end of file +} // OHOS \ No newline at end of file diff --git a/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp b/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp index 8266c592a1..fd87f7f132 100644 --- a/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp +++ b/window_scene/screen_session_manager/src/fold_screen_controller/super_fold_state_manager.cpp @@ -24,111 +24,117 @@ namespace Rosen { WM_IMPLEMENT_SINGLE_INSTANCE(SuperFoldStateManager) -void SuperFoldStateManager::DoAngleChangeFolded() +void SuperFoldStateManager::DoAngleChangeFolded(SuperFoldStatusChangeEvents event) { TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoAngleChangeFolded()"); } -void SuperFoldStateManager::DoAngleChangeHalfFolded() +void SuperFoldStateManager::DoAngleChangeHalfFolded(SuperFoldStatusChangeEvents event) { TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoAngleChangeHalfFolded())"); } -void SuperFoldStateManager::DoAngleChangeExpanded() +void SuperFoldStateManager::DoAngleChangeExpanded(SuperFoldStatusChangeEvents event) { TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoAngleChangeExpanded()"); } -void SuperFoldStateManager::DoKeyboardOn() +void SuperFoldStateManager::DoKeyboardOn(SuperFoldStatusChangeEvents event) { TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOn()"); } -void SuperFoldStateManager::DoKeyboardOff() +void SuperFoldStateManager::DoKeyboardOff(SuperFoldStatusChangeEvents event) { TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOff()"); } -void SuperFoldStateManager::DoSoftKeyboardOn() +void SuperFoldStateManager::DoFoldedToHalfFolded(SuperFoldStatusChangeEvents event) { - TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoSoftKeyboardOn()"); + TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoFoldedToHalfFolded()"); } -void SuperFoldStateManager::DoSoftKeyboardOff() -{ - TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoSoftKeyboardOff()"); -} - -void SuperFoldStateManager::DoExpandedToKeyboard() +void SuperFoldStateManager::DoExpandedToKeyboard(SuperFoldStatusChangeEvents event) { TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoExpandedToKeyboard()"); } SuperFoldStateManager::SuperFoldStateManager() { - initStateManagerMap(SuperFoldStatus::HALF_FOLDED, + AddStateManagerMap(SuperFoldStatus::HALF_FOLDED, SuperFoldStatusChangeEvents::ANGLE_CHANGE_EXPANDED, SuperFoldStatus::EXPANDED, &SuperFoldStateManager::DoAngleChangeExpanded); + + AddStateManagerMap(SuperFoldStatus::FOLDED, + SuperFoldStatusChangeEvents::ANGLE_CHANGE_HALF_FOLDED, + SuperFoldStatus::HALF_FOLDED, + &SuperFoldStateManager::DoFoldedToHalfFolded); - initStateManagerMap(SuperFoldStatus::EXPANDED, + AddStateManagerMap(SuperFoldStatus::EXPANDED, SuperFoldStatusChangeEvents::ANGLE_CHANGE_HALF_FOLDED, SuperFoldStatus::HALF_FOLDED, &SuperFoldStateManager::DoAngleChangeHalfFolded); - initStateManagerMap(SuperFoldStatus::HALF_FOLDED, + AddStateManagerMap(SuperFoldStatus::HALF_FOLDED, SuperFoldStatusChangeEvents::ANGLE_CHANGE_FOLDED, SuperFoldStatus::FOLDED, &SuperFoldStateManager::DoAngleChangeFolded); - initStateManagerMap(SuperFoldStatus::HALF_FOLDED, + AddStateManagerMap(SuperFoldStatus::HALF_FOLDED, SuperFoldStatusChangeEvents::KEYBOARD_ON, SuperFoldStatus::KEYBOARD, &SuperFoldStateManager::DoKeyboardOn); - initStateManagerMap(SuperFoldStatus::EXPANDED, + AddStateManagerMap(SuperFoldStatus::EXPANDED, SuperFoldStatusChangeEvents::KEYBOARD_ON, SuperFoldStatus::KEYBOARD, &SuperFoldStateManager::DoExpandedToKeyboard); - initStateManagerMap(SuperFoldStatus::KEYBOARD, + AddStateManagerMap(SuperFoldStatus::KEYBOARD, SuperFoldStatusChangeEvents::KEYBOARD_OFF, SuperFoldStatus::HALF_FOLDED, &SuperFoldStateManager::DoKeyboardOff); - - initStateManagerMap(SuperFoldStatus::HALF_FOLDED, - SuperFoldStatusChangeEvents::SOFT_KEYBOARD_ON, - SuperFoldStatus::SOFT_KEYBOARD, - &SuperFoldStateManager::DoSoftKeyboardOn); - - initStateManagerMap(SuperFoldStatus::SOFT_KEYBOARD, - SuperFoldStatusChangeEvents::SOFT_KEYBOARD_OFF, - SuperFoldStatus::HALF_FOLDED, - &SuperFoldStateManager::DoSoftKeyboardOff); } SuperFoldStateManager::~SuperFoldStateManager() = default; -void SuperFoldStateManager::initStateManagerMap(SuperFoldStatus curState, +void SuperFoldStateManager::AddStateManagerMap(SuperFoldStatus curState, SuperFoldStatusChangeEvents event, SuperFoldStatus nextState, - std::function action) + std::function action) { stateManagerMap_[{curState, event}] = {nextState, action}; } -void SuperFoldStateManager::transferState(SuperFoldStatus nextState) +void SuperFoldStateManager::TransferState(SuperFoldStatus nextState) { - TLOGI(WmsLogTag::DMS, "transferState from %{public}d to %{public}d", curState_, nextState); - curState_ = nextState; + TLOGI(WmsLogTag::DMS, "TransferState from %{public}d to %{public}d", curState_.load(), nextState); + curState_ .store(nextState); +} + +FoldStatus SuperFoldStateManager::MatchSuperFoldStatusToFoldStatus(SuperFoldStatus superFoldStatus) +{ + switch (superFoldStatus) { + case SuperFoldStatus::EXPANDED: + return FoldStatus::EXPAND; + case SuperFoldStatus::HALF_FOLDED: + return FoldStatus::HALF_FOLD; + case SuperFoldStatus::FOLDED: + return FoldStatus::FOLDED; + case SuperFoldStatus::KEYBOARD: + return FoldStatus::HALF_FOLD; + default: + return FoldStatus::UNKNOWN; + } } void SuperFoldStateManager::HandleSuperFoldStatusChange(SuperFoldStatusChangeEvents event) { - SuperFoldStatus curState = curState_; + SuperFoldStatus curState = curState_.load(); SuperFoldStatus nextState = SuperFoldStatus::UNKNOWN; bool isTransfer = false; - std::function action; + std::function action; auto item = stateManagerMap_.find({curState, event}); if (item != stateManagerMap_.end()) { @@ -138,8 +144,8 @@ void SuperFoldStateManager::HandleSuperFoldStatusChange(SuperFoldStatusChangeEve } if (isTransfer && action) { - action(); - transferState(nextState); + action(event); + TransferState(nextState); // notify auto screenSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession(); if (screenSession == nullptr) { @@ -148,17 +154,19 @@ void SuperFoldStateManager::HandleSuperFoldStatusChange(SuperFoldStatusChangeEve } ScreenId screenId = screenSession->GetScreenId(); ScreenSessionManager::GetInstance().OnSuperFoldStatusChange(screenId, curState_); + ScreenSessionManager::GetInstance().NotifyFoldStatusChanged( + MatchSuperFoldStatusToFoldStatus(curState_.load())); } } SuperFoldStatus SuperFoldStateManager::GetCurrentStatus() { - return curState_; + return curState_.load(); } void SuperFoldStateManager::SetCurrentStatus(SuperFoldStatus curState) { - curState_ = curState; + curState_.store(curState); } } // Rosen diff --git a/window_scene/screen_session_manager/src/multi_screen_manager.cpp b/window_scene/screen_session_manager/src/multi_screen_manager.cpp index b4f2359769..3a1b67165b 100644 --- a/window_scene/screen_session_manager/src/multi_screen_manager.cpp +++ b/window_scene/screen_session_manager/src/multi_screen_manager.cpp @@ -540,13 +540,13 @@ void MultiScreenManager::InternalScreenOffChange(sptr internalSes DoFirstMirrorChange(externalSession, internalSession, SCREEN_MIRROR); TLOGI(WmsLogTag::DMS, "3: internal mirror to external mirror"); } else if (mainScreenId == internalScreenId && secondaryScreenMode == MultiScreenMode::SCREEN_EXTEND) { - DoFirstExtendChange(externalSession, internalSession, SCREEN_EXTEND); + DoFirstExtendChange(externalSession, internalSession, SCREEN_MIRROR); TLOGI(WmsLogTag::DMS, "10: internal extend to external mirror"); } else if (mainScreenId != internalScreenId && secondaryScreenMode == MultiScreenMode::SCREEN_EXTEND) { - DoFirstMainChange(externalSession, internalSession, SCREEN_EXTEND); + DoFirstMainChange(externalSession, internalSession, SCREEN_MIRROR); TLOGI(WmsLogTag::DMS, "14: external extend to external mirror"); } else { - TLOGE(WmsLogTag::DMS, "paramater error!"); + TLOGE(WmsLogTag::DMS, "no need to change or paramater error!"); return; } } diff --git a/window_scene/screen_session_manager/src/screen_scene_config.cpp b/window_scene/screen_session_manager/src/screen_scene_config.cpp index b98fa1850c..03614ff247 100644 --- a/window_scene/screen_session_manager/src/screen_scene_config.cpp +++ b/window_scene/screen_session_manager/src/screen_scene_config.cpp @@ -50,6 +50,7 @@ enum XmlNodeElement { HALL_SWITCH_APP, PACKAGE_NAME, ROTATION_POLICY, + DEFAULT_ROTATION_POLICY, SCREEN_SNAPSHOT_BUNDLE_NAME, SCREEN_SNAPSHOT_ABILITY_NAME, IS_RIGHT_POWER_BUTTON, @@ -89,6 +90,7 @@ std::map ScreenSceneConfig::xmlNodeMap_ = { {HALL_SWITCH_APP, "hallSwitchApp"}, {PACKAGE_NAME, "packageName"}, {ROTATION_POLICY, "rotationPolicy"}, + {DEFAULT_ROTATION_POLICY, "defaultRotationPolicy"}, {SCREEN_SNAPSHOT_BUNDLE_NAME, "screenSnapshotBundleName"}, {SCREEN_SNAPSHOT_ABILITY_NAME, "screenSnapshotAbilityName"}, {IS_RIGHT_POWER_BUTTON, "isRightPowerButton"}, @@ -191,6 +193,7 @@ void ScreenSceneConfig::ParseNodeConfig(const xmlNodePtr& currNode) bool stringConfigCheck = (xmlNodeMap_[DEFAULT_DISPLAY_CUTOUT_PATH] == nodeName) || (xmlNodeMap_[SUB_DISPLAY_CUTOUT_PATH] == nodeName) || (xmlNodeMap_[ROTATION_POLICY] == nodeName) || + (xmlNodeMap_[DEFAULT_ROTATION_POLICY] == nodeName) || (xmlNodeMap_[SCREEN_SNAPSHOT_BUNDLE_NAME] == nodeName) || (xmlNodeMap_[SCREEN_SNAPSHOT_ABILITY_NAME] == nodeName) || (xmlNodeMap_[EXTERNAL_SCREEN_DEFAULT_MODE] == nodeName) || diff --git a/window_scene/screen_session_manager/src/screen_session_dumper.cpp b/window_scene/screen_session_manager/src/screen_session_dumper.cpp index 1b0d93b04d..bebaeb1d9e 100644 --- a/window_scene/screen_session_manager/src/screen_session_dumper.cpp +++ b/window_scene/screen_session_manager/src/screen_session_dumper.cpp @@ -22,6 +22,7 @@ #include "screen_session_manager.h" #include "session_permission.h" #include "screen_rotation_property.h" +#include "screen_sensor_connector.h" #include "parameters.h" #include "fold_screen_controller/super_fold_state_manager.h" @@ -55,6 +56,8 @@ const std::string ARG_SET_ON_TENT_MODE = "-ontent"; const std::string ARG_SET_OFF_TENT_MODE = "-offtent"; const std::string ARG_SET_HOVER_STATUS = "-hoverstatus"; const std::string ARG_SET_SUPER_FOLD_STATUS = "-supertrans"; +const std::string ARG_SET_POSTURE_HALL = "-posture"; +const std::string ARG_SET_POSTURE_HALL_STATUS = "-registerhall"; // 关闭开合sensor报值 } static std::string GetProcessNameByPid(int32_t pid) @@ -87,6 +90,19 @@ ScreenSessionDumper::ScreenSessionDumper(int fd, const std::vector(str.size()); i++) { + if (str.at(i) < '0' || str.at(i) > '9') { + return false; + } + } + return true; +} + void ScreenSessionDumper::OutputDumpInfo() { if (fd_ < 0) { @@ -142,30 +158,46 @@ void ScreenSessionDumper::ExcuteInjectCmd() } if (params_[0] == STATUS_FOLD_HALF || params_[0] == STATUS_EXPAND || params_[0] == STATUS_FOLD) { ShowNotifyFoldStatusChangedInfo(); + return; } else if (params_[0].find(ARG_SET_ROTATION_SENSOR) != std::string::npos) { SetMotionSensorvalue(params_[0]); + return; } else if (params_[0].find(ARG_SET_ROTATION_LOCK) != std::string::npos) { SetRotationLockedvalue(params_[0]); + return; } else if (params_[0].find(ARG_PUBLISH_CAST_EVENT) != std::string::npos) { MockSendCastPublishEvent(params_[0]); + return; } else if (params_.size() == 1 && IsValidDisplayModeCommand(params_[0])) { int errCode = SetFoldDisplayMode(); if (errCode != 0) { ShowIllegalArgsInfo(); } + return; } else if (params_.size() == 1 && (params_[0] == ARG_LOCK_FOLD_DISPLAY_STATUS || params_[0] == ARG_UNLOCK_FOLD_DISPLAY_STATUS)) { int errCode = SetFoldStatusLocked(); if (errCode != 0) { ShowIllegalArgsInfo(); } - } else if (params_[0].find(ARG_SET_ON_TENT_MODE) != std::string::npos || + return; + } + ExcuteInjectCmd2(); +} + +void ScreenSessionDumper::ExcuteInjectCmd2() +{ + if (params_[0].find(ARG_SET_ON_TENT_MODE) != std::string::npos || params_[0].find(ARG_SET_OFF_TENT_MODE) != std::string::npos) { SetEnterOrExitTentMode(params_[0]); } else if (params_[0].find(ARG_SET_HOVER_STATUS) != std::string::npos) { SetHoverStatusChange(params_[0]); } else if (params_[0].find(ARG_SET_SUPER_FOLD_STATUS) != std::string::npos) { SetSuperFoldStatusChange(params_[0]); + } else if (params_[0].find(ARG_SET_POSTURE_HALL) != std::string::npos) { + SetHallAndPostureValue(params_[0]); + } else if (params_[0].find(ARG_SET_POSTURE_HALL_STATUS) != std::string::npos) { + SetHallAndPostureStatus(params_[0]); } } @@ -663,6 +695,10 @@ void ScreenSessionDumper::SetHoverStatusChange(std::string input) { size_t commaPos = input.find_last_of(','); auto screenSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession(); + if (screenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screenSession is nullptr"); + return; + } if ((commaPos != std::string::npos) && (input.substr(0, commaPos) == ARG_SET_HOVER_STATUS)) { std::string valueStr = input.substr(commaPos + 1); int32_t value = std::stoi(valueStr); @@ -676,6 +712,63 @@ void ScreenSessionDumper::SetHoverStatusChange(std::string input) } } +void ScreenSessionDumper::SetHallAndPostureValue(std::string input) +{ + std::string token; + std::istringstream ss(input); + std::vector tokens; + while (std::getline(ss, token, ',')) { + tokens.push_back(token); + } + if (tokens.size() != DUMPER_PARAM_INDEX_THREE && tokens[0] != ARG_SET_POSTURE_HALL) { + TLOGE(WmsLogTag::DMS, "param error: %{public}s", input.c_str()); + return; + } + if (!IsNumber(tokens[DUMPER_PARAM_INDEX_ONE]) || !IsNumber(tokens[DUMPER_PARAM_INDEX_TWO])) { + TLOGE(WmsLogTag::DMS, "param error: %{public}s", input.c_str()); + return; + } + int hallVal = stoi(tokens[DUMPER_PARAM_INDEX_ONE]); + int postureVal = stoi(tokens[DUMPER_PARAM_INDEX_TWO]); + ExtHallData hallData = {(1 << 1), hallVal}; + PostureData postureData = { + .angle = postureVal, + }; + SensorEvent hallEvent = { + .dataLen = sizeof(ExtHallData), + .data = reinterpret_cast(&hallData), + }; + SensorEvent postureEvent = { + .dataLen = sizeof(PostureData), + .data = reinterpret_cast(&postureData), + }; + OHOS::Rosen::FoldScreenSensorManager::GetInstance().HandleHallData(&hallEvent); + OHOS::Rosen::FoldScreenSensorManager::GetInstance().HandlePostureData(&postureEvent); + TLOGI(WmsLogTag::DMS, "mock posture: %{public}d, hall: %{public}d ", postureVal, hallVal); +} + +void ScreenSessionDumper::SetHallAndPostureStatus(std::string input) +{ + size_t commaPos = input.find_last_of(','); + if ((commaPos != std::string::npos) && (input.substr(0, commaPos) == ARG_SET_POSTURE_HALL_STATUS)) { + std::string valueStr = input.substr(commaPos + 1, DUMPER_PARAM_INDEX_ONE); + if (valueStr.size() != DUMPER_PARAM_INDEX_ONE && !std::isdigit(valueStr[0])) { + return; + } + int32_t value = std::stoi(valueStr); + if (value) { + OHOS::Rosen::FoldScreenSensorManager::GetInstance().RegisterHallCallback(); + OHOS::Rosen::FoldScreenSensorManager::GetInstance().RegisterPostureCallback(); + OHOS::Rosen::ScreenSensorConnector::SubscribeRotationSensor(); + } else { + OHOS::Rosen::FoldScreenSensorManager::GetInstance().UnRegisterHallCallback(); + OHOS::Rosen::FoldScreenSensorManager::GetInstance().UnRegisterPostureCallback(); + OHOS::Rosen::ScreenSensorConnector::UnsubscribeRotationSensor(); + } + TLOGI(WmsLogTag::DMS, "hall and posture register status: %{public}d", value); + } +} + void ScreenSessionDumper::SetSuperFoldStatusChange(std::string input) { size_t commaPos = input.find_last_of(','); diff --git a/window_scene/screen_session_manager/src/screen_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 4eae711eed..b3ba63e1ac 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -432,6 +432,11 @@ void ScreenSessionManager::ConfigureScreenScene() TLOGD(WmsLogTag::DMS, "rotationPolicy = %{public}s.", rotationPolicy.c_str()); deviceScreenConfig_.rotationPolicy_ = rotationPolicy; } + if (stringConfig.count("defaultRotationPolicy") != 0) { + std::string defaultRotationPolicy = stringConfig["defaultRotationPolicy"]; + TLOGD(WmsLogTag::DMS, "defaultRotationPolicy = %{public}s.", defaultRotationPolicy.c_str()); + deviceScreenConfig_.defaultRotationPolicy_ = defaultRotationPolicy; + } if (enableConfig.count("isRightPowerButton") != 0) { bool isRightPowerButton = static_cast(enableConfig["isRightPowerButton"]); TLOGD(WmsLogTag::DMS, "isRightPowerButton = %d", isRightPowerButton); @@ -1508,6 +1513,7 @@ void ScreenSessionManager::InitExtendScreenDensity(sptr session, } float extendDensity = CalcDefaultExtendScreenDensity(property); TLOGI(WmsLogTag::DMS, "extendDensity = %{public}f", extendDensity); + extendDefaultDpi_ = static_cast(extendDensity * BASELINE_DENSITY); session->SetVirtualPixelRatio(extendDensity); session->SetDefaultDensity(extendDensity); session->SetDensityInCurResolution(extendDensity); @@ -2352,7 +2358,11 @@ void ScreenSessionManager::SetDpiFromSettingData(bool isInternal) } if (!ret) { TLOGW(WmsLogTag::DMS, "get setting dpi failed,use default dpi"); - settingDpi = defaultDpi; + if (isInternal) { + settingDpi = defaultDpi; + } else { + settingDpi = extendDefaultDpi_; + } } else { TLOGI(WmsLogTag::DMS, "get setting dpi success,settingDpi: %{public}u", settingDpi); } @@ -5374,7 +5384,7 @@ void ScreenSessionManager::ScbStatusRecoveryWhenSwitchUser(std::vector TLOGE(WmsLogTag::DMS, "unsupport foldStatus: %{public}u", foldStatus); } } else { - screenSession->UpdateRotationAfterBoot(true); + screenSession->UpdateValidRotationToScb(); } auto task = [=] { clientProxy_->SwitchUserCallback(oldScbPids, newScbPid); diff --git a/window_scene/screen_session_manager/src/screen_setting_helper.cpp b/window_scene/screen_session_manager/src/screen_setting_helper.cpp index 5213242063..e75736d7b9 100644 --- a/window_scene/screen_session_manager/src/screen_setting_helper.cpp +++ b/window_scene/screen_session_manager/src/screen_setting_helper.cpp @@ -234,42 +234,30 @@ bool ScreenSettingHelper::GetSettingRotationScreenID(int32_t& screenId, const st return true; } -void ScreenSettingHelper::RemoveInvalidChar(std::string& dataStr, const std::string& inputString) +std::string ScreenSettingHelper::RemoveInvalidChar(const std::string& input) { - for (char character : inputString) { - if (!std::isdigit(character) && character != ' ' && character != ',' && character != '.') { - continue; + std::string resultString = ""; + for (char character : input) { + if (std::isdigit(character) || character == ' ' || character == ',' || character == '.') { + resultString += character; } - dataStr += character; } - TLOGI(WmsLogTag::DMS, "process done, dataStr: %{public}s", dataStr.c_str()); + TLOGI(WmsLogTag::DMS, "process done, resultString: %{public}s", resultString.c_str()); + return resultString; } -bool ScreenSettingHelper::SplitString(std::vector& splitValues, const std::string& inputString) +bool ScreenSettingHelper::SplitString(std::vector& splitValues, const std::string& input, + char delimiter) { - TLOGI(WmsLogTag::DMS, "input value: %{public}s", inputString.c_str()); - std::string dataStr; - RemoveInvalidChar(dataStr, inputString); - int32_t strLength = dataStr.size(); - int32_t beginIdx = 0; - std::string currentValue; - for (int32_t currentIdx = 0; currentIdx < strLength; currentIdx++) { - if (dataStr[currentIdx] != ',') { - continue; - } - currentValue = dataStr.substr(beginIdx, currentIdx - beginIdx); - if (currentValue.size() > 0) { - splitValues.push_back(currentValue); - TLOGI(WmsLogTag::DMS, "resolving current value success, currentValue: %{public}s", - currentValue.c_str()); - } - beginIdx = currentIdx + 1; + TLOGI(WmsLogTag::DMS, "input string: %{public}s", input.c_str()); + if (input.size() == 0) { + TLOGE(WmsLogTag::DMS, "noting in input string"); + return false; } - currentValue = dataStr.substr(beginIdx, strLength - beginIdx); - if (currentValue.size() > 0) { - splitValues.push_back(currentValue); - TLOGI(WmsLogTag::DMS, "resolving current value success, currentValue: %{public}s", - currentValue.c_str()); + std::stringstream stream(input); + std::string token; + while (std::getline(stream, token, delimiter)) { + splitValues.push_back(token); } if (splitValues.size() == 0) { TLOGE(WmsLogTag::DMS, "resolving split values failed"); @@ -314,7 +302,8 @@ bool ScreenSettingHelper::GetSettingRecoveryResolutionString(std::vector& s TLOGE(WmsLogTag::DMS, "get setting screen mode failed, ret=%{public}d", ret); return false; } - bool ret1 = SplitString(screenModeStrings, value); + std::string validString = RemoveInvalidChar(value); + bool ret1 = SplitString(screenModeStrings, validString); if (!ret1) { TLOGE(WmsLogTag::DMS, "resolving screen mode failed"); return false; @@ -408,7 +398,8 @@ bool ScreenSettingHelper::GetSettingRelativePositionString(std::vector -#include "accessibility_element_info.h" #include "interfaces/include/ws_common.h" #include "session/container/include/zidl/session_stage_interface.h" #include "session/host/include/zidl/session_stub.h" @@ -99,11 +98,13 @@ public: virtual void OnBackground() {} virtual void OnDisconnect() {} virtual void OnLayoutFinished() {} + virtual void OnRemoveBlank() {} virtual void OnDrawingCompleted() {} virtual void OnExtensionDied() {} virtual void OnExtensionTimeout(int32_t errorCode) {} virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) {} + virtual void OnAppRemoveStartingWindow() {} }; enum class LifeCycleTaskType : uint32_t { @@ -161,6 +162,7 @@ public: void NotifyBackground(); void NotifyDisconnect(); void NotifyLayoutFinished(); + void NotifyRemoveBlank(); void NotifyExtensionDied() override; void NotifyExtensionTimeout(int32_t errorCode) override; void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, @@ -288,7 +290,7 @@ public: sptr GetScenePersistence() const; void SetParentSession(const sptr& session); sptr GetParentSession() const; - sptr GetMainSession(); + sptr GetMainSession() const; void BindDialogToParentSession(const sptr& session); void RemoveDialogToParentSession(const sptr& session); std::vector> GetDialogVector() const; @@ -364,6 +366,8 @@ public: virtual void SetSystemFocusable(bool systemFocusable); // Used by SCB bool GetSystemFocusable() const; bool CheckFocusable() const; + void SetStartingBeforeVisible(bool isStartingBeforeVisible); + bool GetStartingBeforeVisible() const; bool IsFocused() const; bool GetFocused() const; virtual WSError UpdateFocus(bool isFocused); @@ -509,6 +513,13 @@ public: void SetAppInstanceKey(const std::string& appInstanceKey); std::string GetAppInstanceKey() const; + /* + * Starting Window + */ + WSError RemoveStartingWindow() override; + void SetEnableRemoveStartingWindow(bool enableRemoveStartingWindow); + bool GetEnableRemoveStartingWindow() const; + protected: class SessionLifeCycleTask : public virtual RefBase { public: @@ -735,6 +746,7 @@ private: bool focusedOnShow_ = true; std::atomic_bool systemFocusable_ = true; bool focusableOnShow_ = true; // if false, ignore request focus when session onAttach + bool isStartingBeforeVisible_ = false; bool showRecent_ = false; bool bufferAvailable_ = false; @@ -767,6 +779,11 @@ private: mutable std::mutex leashWinSurfaceNodeMutex_; DetectTaskInfo detectTaskInfo_; mutable std::shared_mutex detectTaskInfoMutex_; + + /* + * Starting Window + */ + bool enableRemoveStartingWindow_ {false}; }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index 8c38b4726a..3fe2913110 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -44,6 +44,7 @@ public: virtual WSError Show(sptr property) = 0; virtual WSError Hide() = 0; virtual WSError DrawingCompleted() = 0; + virtual WSError RemoveStartingWindow() = 0; // scene session /** diff --git a/window_scene/session/host/include/zidl/session_ipc_interface_code.h b/window_scene/session/host/include/zidl/session_ipc_interface_code.h index cce9c9ecf6..0e786f3892 100644 --- a/window_scene/session/host/include/zidl/session_ipc_interface_code.h +++ b/window_scene/session/host/include/zidl/session_ipc_interface_code.h @@ -31,6 +31,7 @@ enum class SessionInterfaceCode { TRANS_ID_TERMINATE, TRANS_ID_EXCEPTION, TRANS_ID_DRAWING_COMPLETED, + TRANS_ID_APP_REMOVE_STARTING_WINDOW, // Scene TRANS_ID_SESSION_EVENT = 100, diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index c89f06f80b..5ca441b852 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -108,6 +108,11 @@ public: */ WMError SetGestureBackEnabled(bool isEnabled) override; + /* + * Starting Window + */ + WSError RemoveStartingWindow() override; + private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 2e6f4173bf..15d80249da 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -40,6 +40,7 @@ private: int HandleShow(MessageParcel& data, MessageParcel& reply); int HandleHide(MessageParcel& data, MessageParcel& reply); int HandleDrawingCompleted(MessageParcel& data, MessageParcel& reply); + int HandleRemoveStartingWindow(MessageParcel& data, MessageParcel& reply); // scene session int HandleSessionEvent(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session/host/src/main_session.cpp b/window_scene/session/host/src/main_session.cpp index e0454bb290..02e6d7df7d 100644 --- a/window_scene/session/host/src/main_session.cpp +++ b/window_scene/session/host/src/main_session.cpp @@ -15,13 +15,8 @@ #include "session/host/include/main_session.h" -#include - -#include "key_event.h" -#include "pointer_event.h" #include "session_helper.h" #include "session/host/include/scene_persistent_storage.h" -#include "window_manager_hilog.h" namespace OHOS::Rosen { namespace { diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ca552f38aa..7f1ae0d969 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -50,7 +50,6 @@ #include #include "screen_manager.h" #include "screen.h" -#include "singleton_container.h" #include "fold_screen_state_internel.h" #include "session/host/include/multi_instance_manager.h" @@ -1549,10 +1548,6 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) if (Session::GetFloatingScale() <= miniScale) { return; } - if (Session::GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING && - rect.height_ < rect.width_) { - return; - } float vpr = 3.5f; // 3.5f: default pixel ratio auto display = DisplayManager::GetInstance().GetDefaultDisplay(); if (display == nullptr) { @@ -2630,7 +2625,7 @@ void SceneSession::SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool need { TLOGD(WmsLogTag::WMS_LAYOUT, "rect: %{public}s", rect.ToString().c_str()); auto rsTransaction = RSTransactionProxy::GetInstance(); - if (rsTransaction && needFlush) { + if (rsTransaction != nullptr && needFlush) { rsTransaction->Begin(); } auto leashWinSurfaceNode = GetLeashWinSurfaceNode(); @@ -2665,8 +2660,7 @@ void SceneSession::SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool need } else { WLOGE("SetSurfaceBounds surfaceNode is null!"); } - if (rsTransaction && needFlush) { - RSTransaction::FlushImplicitTransaction(); + if (rsTransaction != nullptr && needFlush) { rsTransaction->Commit(); } } @@ -2918,12 +2912,18 @@ void SceneSession::SetSnapshotSkip(bool isSkip) return; } property->SetSnapshotSkip(isSkip); + auto rsTransaction = RSTransactionProxy::GetInstance(); + if (rsTransaction != nullptr) { + rsTransaction->Begin(); + } surfaceNode_->SetSkipLayer(isSkip); auto leashWinSurfaceNode = GetLeashWinSurfaceNode(); if (leashWinSurfaceNode != nullptr) { leashWinSurfaceNode->SetSkipLayer(isSkip); } - RSTransaction::FlushImplicitTransaction(); + if (rsTransaction != nullptr) { + rsTransaction->Commit(); + } } void SceneSession::SetWatermarkEnabled(const std::string& watermarkName, bool isEnabled) @@ -2934,11 +2934,17 @@ void SceneSession::SetWatermarkEnabled(const std::string& watermarkName, bool is } TLOGI(WmsLogTag::DEFAULT, "watermarkName:%{public}s, isEnabled:%{public}d, wid:%{public}d", watermarkName.c_str(), isEnabled, GetPersistentId()); + auto rsTransaction = RSTransactionProxy::GetInstance(); + if (rsTransaction != nullptr) { + rsTransaction->Begin(); + } surfaceNode_->SetWatermarkEnabled(watermarkName, isEnabled); if (auto leashWinSurfaceNode = GetLeashWinSurfaceNode()) { leashWinSurfaceNode->SetWatermarkEnabled(watermarkName, isEnabled); } - RSTransaction::FlushImplicitTransaction(); + if (rsTransaction != nullptr) { + rsTransaction->Commit(); + } } void SceneSession::SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo) @@ -2959,12 +2965,18 @@ void SceneSession::SetSystemSceneOcclusionAlpha(double alpha) } uint8_t alpha8bit = static_cast(alpha * 255); WLOGFI("SetAbilityBGAlpha alpha8bit=%{public}u.", alpha8bit); + auto rsTransaction = RSTransactionProxy::GetInstance(); + if (rsTransaction != nullptr) { + rsTransaction->Begin(); + } surfaceNode_->SetAbilityBGAlpha(alpha8bit); auto leashWinSurfaceNode = GetLeashWinSurfaceNode(); if (leashWinSurfaceNode != nullptr) { leashWinSurfaceNode->SetAbilityBGAlpha(alpha8bit); } - RSTransaction::FlushImplicitTransaction(); + if (rsTransaction != nullptr) { + rsTransaction->Commit(); + } } void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst) @@ -2976,8 +2988,7 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst) return; } auto rsTransaction = RSTransactionProxy::GetInstance(); - if (rsTransaction) { - RSTransaction::FlushImplicitTransaction(); + if (rsTransaction != nullptr) { rsTransaction->Begin(); } if (leashWinSurfaceNode != nullptr) { @@ -2989,7 +3000,7 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst) surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), forceUIFirst); surfaceNode_->SetForceUIFirst(forceUIFirst); } - if (rsTransaction) { + if (rsTransaction != nullptr) { rsTransaction->Commit(); } } @@ -3065,8 +3076,8 @@ bool SceneSession::IsSystemSessionAboveApp() const void SceneSession::NotifyIsCustomAnimationPlaying(bool isPlaying) { WLOGFI("id %{public}d %{public}u", GetPersistentId(), isPlaying); - if (sessionChangeCallback_ != nullptr && sessionChangeCallback_->onIsCustomAnimationPlaying_) { - sessionChangeCallback_->onIsCustomAnimationPlaying_(isPlaying); + if (onIsCustomAnimationPlaying_) { + onIsCustomAnimationPlaying_(isPlaying); } } @@ -3586,7 +3597,6 @@ static bool IsNeedSystemPermissionByAction(WSPropertyChangeAction action, case WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS: case WSPropertyChangeAction::ACTION_UPDATE_TOPMOST: case WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE: - case WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED: case WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED: case WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: return true; @@ -3986,11 +3996,6 @@ WMError SceneSession::HandleActionUpdateWindowLimits(const sptr& property, WSPropertyChangeAction action) { - if (!property->GetSystemCalling()) { - TLOGE(WmsLogTag::DEFAULT, "Update property dragEnabled permission denied!"); - return WMError::WM_ERROR_NOT_SYSTEM_APP; - } - auto sessionProperty = GetSessionProperty(); if (sessionProperty != nullptr) { sessionProperty->SetDragEnabled(property->GetDragEnabled()); @@ -4524,9 +4529,13 @@ WSError SceneSession::SetAutoStartPiP(bool isAutoStart) void SceneSession::SendPointerEventToUI(std::shared_ptr pointerEvent) { - std::lock_guard lock(pointerEventMutex_); - if (systemSessionPointerEventFunc_ != nullptr) { - systemSessionPointerEventFunc_(pointerEvent); + NotifySystemSessionPointerEventFunc systemSessionPointerEventFunc = nullptr; + { + std::lock_guard lock(pointerEventMutex_); + systemSessionPointerEventFunc = systemSessionPointerEventFunc_; + } + if (systemSessionPointerEventFunc != nullptr) { + systemSessionPointerEventFunc(pointerEvent); } else { TLOGE(WmsLogTag::WMS_EVENT, "PointerEventFunc_ nullptr, id:%{public}d", pointerEvent->GetId()); pointerEvent->MarkProcessed(); @@ -4535,9 +4544,13 @@ void SceneSession::SendPointerEventToUI(std::shared_ptr point bool SceneSession::SendKeyEventToUI(std::shared_ptr keyEvent, bool isPreImeEvent) { - std::shared_lock lock(keyEventMutex_); - if (systemSessionKeyEventFunc_ != nullptr) { - return systemSessionKeyEventFunc_(keyEvent, isPreImeEvent); + NotifySystemSessionKeyEventFunc systemSessionKeyEventFunc = nullptr; + { + std::shared_lock lock(keyEventMutex_); + systemSessionKeyEventFunc = systemSessionKeyEventFunc_; + } + if (systemSessionKeyEventFunc != nullptr) { + return systemSessionKeyEventFunc(keyEvent, isPreImeEvent); } return false; } @@ -4727,10 +4740,9 @@ WSError SceneSession::OnLayoutFullScreenChange(bool isLayoutFullScreen) TLOGE(WmsLogTag::WMS_LAYOUT, "session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } - TLOGI(WmsLogTag::WMS_LAYOUT, "OnLayoutFullScreenChange, isLayoutFullScreen: %{public}d", - isLayoutFullScreen); - if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onLayoutFullScreenChangeFunc_) { - session->sessionChangeCallback_->onLayoutFullScreenChangeFunc_(isLayoutFullScreen); + TLOGI(WmsLogTag::WMS_LAYOUT, "isLayoutFullScreen: %{public}d", isLayoutFullScreen); + if (session->onLayoutFullScreenChangeFunc_) { + session->onLayoutFullScreenChangeFunc_(isLayoutFullScreen); } return WSError::WS_OK; }; @@ -4824,12 +4836,18 @@ void SceneSession::SetSkipDraw(bool skip) WLOGFE("surfaceNode_ is null"); return; } + auto rsTransaction = RSTransactionProxy::GetInstance(); + if (rsTransaction != nullptr) { + rsTransaction->Begin(); + } surfaceNode_->SetSkipDraw(skip); auto leashWinSurfaceNode = GetLeashWinSurfaceNode(); if (leashWinSurfaceNode != nullptr) { leashWinSurfaceNode->SetSkipDraw(skip); } - RSTransaction::FlushImplicitTransaction(); + if (rsTransaction != nullptr) { + rsTransaction->Commit(); + } } void SceneSession::SetSkipSelfWhenShowOnVirtualScreen(bool isSkip) @@ -4963,6 +4981,32 @@ void SceneSession::RegisterBindDialogSessionCallback(NotifyBindDialogSessionFunc PostTask(task, __func__); } +void SceneSession::RegisterIsCustomAnimationPlayingCallback(NotifyIsCustomAnimationPlayingCallback&& callback) +{ + auto task = [weakThis = wptr(this), callback = std::move(callback)] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "session is null"); + return; + } + session->onIsCustomAnimationPlaying_ = std::move(callback); + }; + PostTask(task, __func__); +} + +void SceneSession::RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreenChangeFunc&& callback) +{ + auto task = [weakThis = wptr(this), callback = std::move(callback)] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LAYOUT, "session is null"); + return; + } + session->onLayoutFullScreenChangeFunc_ = std::move(callback); + }; + PostTask(task, __func__); +} + WMError SceneSession::GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) { if (forceSplitFunc_ == nullptr) { @@ -5275,12 +5319,10 @@ void SceneSession::UnregisterSessionChangeListeners() session->sessionChangeCallback_->onSessionModalTypeChange_ = nullptr; session->sessionChangeCallback_->onRaiseToTop_ = nullptr; session->sessionChangeCallback_->OnSessionEvent_ = nullptr; - session->sessionChangeCallback_->onIsCustomAnimationPlaying_ = nullptr; session->sessionChangeCallback_->onWindowAnimationFlagChange_ = nullptr; session->sessionChangeCallback_->onRaiseAboveTarget_ = nullptr; session->sessionChangeCallback_->OnTouchOutside_ = nullptr; session->sessionChangeCallback_->onSetLandscapeMultiWindowFunc_ = nullptr; - session->sessionChangeCallback_->onLayoutFullScreenChangeFunc_ = nullptr; } session->Session::UnregisterSessionChangeListeners(); }; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index f6b893e77c..1cb7c5438b 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -16,9 +16,7 @@ #include "session/host/include/session.h" #include "ability_info.h" -#include "ability_start_setting.h" #include "input_manager.h" -#include "ipc_skeleton.h" #include "key_event.h" #include "pointer_event.h" #include @@ -29,15 +27,12 @@ #include "common/include/session_permission.h" #include "session_helper.h" #include "surface_capture_future.h" -#include "util.h" #include "window_helper.h" #include "window_manager_hilog.h" #include "parameters.h" #include #include "hitrace_meter.h" #include "screen_session_manager_client/include/screen_session_manager_client.h" -#include "session/host/include/ws_ffrt_helper.h" -#include "singleton_container.h" #include "perform_reporter.h" namespace OHOS::Rosen { @@ -45,6 +40,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "Session" }; std::atomic g_persistentId = INVALID_SESSION_ID; std::set g_persistentIdSet; +std::mutex g_persistentIdSetMutex; constexpr float INNER_BORDER_VP = 5.0f; constexpr float OUTSIDE_BORDER_VP = 4.0f; constexpr float INNER_ANGLE_VP = 16.0f; @@ -106,7 +102,7 @@ Session::~Session() { TLOGI(WmsLogTag::WMS_LIFE, "id:%{public}d", GetPersistentId()); if (mainHandler_) { - mainHandler_->PostTask([surfaceNode = std::move(surfaceNode_)]() mutable { + mainHandler_->PostTask([surfaceNode = std::move(surfaceNode_)]() { // do nothing }); } @@ -423,6 +419,16 @@ void Session::NotifyLayoutFinished() } } +void Session::NotifyRemoveBlank() +{ + auto lifecycleListeners = GetListeners(); + for (auto& listener : lifecycleListeners) { + if (auto listenerPtr = listener.lock()) { + listenerPtr->OnRemoveBlank(); + } + } +} + void Session::NotifyExtensionDied() { if (!SessionPermission::IsSystemCalling()) { @@ -623,6 +629,16 @@ bool Session::IsFocusedOnShow() const return focusedOnShow_; } +void Session::SetStartingBeforeVisible(bool isStartingBeforeVisible) +{ + isStartingBeforeVisible_ = isStartingBeforeVisible; +} + +bool Session::GetStartingBeforeVisible() const +{ + return isStartingBeforeVisible_; +} + WSError Session::SetTouchable(bool touchable) { SetSystemTouchable(touchable); @@ -1216,6 +1232,7 @@ WSError Session::Background(bool isFromClient, const std::string& identityToken) isActive_ = false; } isStarting_ = false; + isStartingBeforeVisible_ = false; if (state != SessionState::STATE_INACTIVE) { TLOGW(WmsLogTag::WMS_LIFE, "Background state invalid! id: %{public}d, state: %{public}u", GetPersistentId(), state); @@ -1248,6 +1265,7 @@ WSError Session::Disconnect(bool isFromClient, const std::string& identityToken) TLOGI(WmsLogTag::WMS_LIFE, "Disconnect session, id: %{public}d, state: %{public}u", GetPersistentId(), state); isActive_ = false; isStarting_ = false; + isStartingBeforeVisible_ = false; bufferAvailable_ = false; isNeedSyncSessionRect_ = true; if (mainHandler_) { @@ -1292,6 +1310,17 @@ WSError Session::DrawingCompleted() return WSError::WS_OK; } +WSError Session::RemoveStartingWindow() +{ + auto lifecycleListeners = GetListeners(); + for (auto& listener : lifecycleListeners) { + if (auto listenerPtr = listener.lock()) { + listenerPtr->OnAppRemoveStartingWindow(); + } + } + return WSError::WS_OK; +} + WSError Session::SetActive(bool active) { SessionState state = GetSessionState(); @@ -1739,10 +1768,10 @@ sptr Session::GetParentSession() const return parentSession_; } -sptr Session::GetMainSession() +sptr Session::GetMainSession() const { if (SessionHelper::IsMainWindow(GetWindowType())) { - return this; + return const_cast(this); } else if (parentSession_) { return parentSession_->GetMainSession(); } else { @@ -2793,6 +2822,16 @@ WSRect Session::GetClientRect() const return clientRect_; } +void Session::SetEnableRemoveStartingWindow(bool enableRemoveStartingWindow) +{ + enableRemoveStartingWindow_ = enableRemoveStartingWindow; +} + +bool Session::GetEnableRemoveStartingWindow() const +{ + return enableRemoveStartingWindow_; +} + WindowType Session::GetWindowType() const { auto property = GetSessionProperty(); @@ -2843,6 +2882,7 @@ WSError Session::ProcessBackEvent() void Session::GeneratePersistentId(bool isExtension, int32_t persistentId) { + std::lock_guard lock(g_persistentIdSetMutex); if (persistentId != INVALID_SESSION_ID && !g_persistentIdSet.count(persistentId)) { g_persistentIdSet.insert(persistentId); persistentId_ = persistentId; diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index a05c94b131..78cab53c40 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -205,8 +205,9 @@ bool SubSession::IsModal() const bool SubSession::IsVisibleForeground() const { - if (parentSession_ && WindowHelper::IsMainWindow(parentSession_->GetWindowType())) { - return parentSession_->IsVisibleForeground() && Session::IsVisibleForeground(); + const auto& mainSession = GetMainSession(); + if (mainSession && WindowHelper::IsMainWindow(mainSession->GetWindowType())) { + return mainSession->IsVisibleForeground() && Session::IsVisibleForeground(); } return Session::IsVisibleForeground(); } diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 579bdbbbde..991b6dcaac 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -337,6 +337,28 @@ WSError SessionProxy::DrawingCompleted() return static_cast(reply.ReadInt32()); } +WSError SessionProxy::RemoveStartingWindow() +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "remote is null"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(SessionInterfaceCode::TRANS_ID_APP_REMOVE_STARTING_WINDOW), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + return static_cast(reply.ReadInt32()); +} + WSError SessionProxy::ChangeSessionVisibilityWithStatusBar(sptr abilitySessionInfo, bool visible) { if (abilitySessionInfo == nullptr) { diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 585a7cd4b3..f6e31d3bbe 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -104,6 +104,8 @@ int SessionStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleHide(data, reply); case static_cast(SessionInterfaceCode::TRANS_ID_DRAWING_COMPLETED): return HandleDrawingCompleted(data, reply); + case static_cast(SessionInterfaceCode::TRANS_ID_APP_REMOVE_STARTING_WINDOW): + return HandleRemoveStartingWindow(data, reply); case static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_RECTCHANGE_LISTENER_REGISTERED): return HandleUpdateRectChangeListenerRegistered(data, reply); case static_cast(SessionInterfaceCode::TRANS_ID_SESSION_EVENT): @@ -402,6 +404,14 @@ int SessionStub::HandleDrawingCompleted(MessageParcel& data, MessageParcel& repl return ERR_NONE; } +int SessionStub::HandleRemoveStartingWindow(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_LIFE, "Called!"); + WSError errCode = RemoveStartingWindow(); + reply.WriteInt32(static_cast(errCode)); + return ERR_NONE; +} + int SessionStub::HandleSessionEvent(MessageParcel& data, MessageParcel& reply) { uint32_t eventId = 0; diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 91f8e42871..0944adc4a9 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -233,6 +233,7 @@ public: bool UpdateAvailableArea(DMRect area); void SetFoldScreen(bool isFold); void UpdateRotationAfterBoot(bool foldToExpand); + void UpdateValidRotationToScb(); std::shared_ptr GetScreenSnapshot(float scaleX, float scaleY); void SetDefaultDeviceRotationOffset(uint32_t defaultRotationOffset); @@ -258,6 +259,7 @@ private: std::function updateScreenPivotCallback_ = nullptr; bool isFold_ = false; float currentSensorRotation_ { -1.0f }; + float currentValidSensorRotation_ { -1.0f }; std::vector hdrFormats_; std::vector colorSpaces_; MirrorScreenType mirrorScreenType_ { MirrorScreenType::VIRTUAL_MIRROR }; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 5dd4cb3120..057b978a24 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -480,8 +480,9 @@ void ScreenSession::SensorRotationChange(Rotation sensorRotation) void ScreenSession::SensorRotationChange(float sensorRotation) { if (sensorRotation >= 0.0f) { - currentSensorRotation_ = sensorRotation; + currentValidSensorRotation_ = sensorRotation; } + currentSensorRotation_ = sensorRotation; for (auto& listener : screenChangeListenerList_) { listener->OnSensorRotationChange(sensorRotation, screenId_); } @@ -677,6 +678,12 @@ void ScreenSession::UpdateRotationAfterBoot(bool foldToExpand) } } +void ScreenSession::UpdateValidRotationToScb() +{ + TLOGI(WmsLogTag::DMS, "Rotation: %{public}f", currentValidSensorRotation_); + SensorRotationChange(currentValidSensorRotation_); +} + sptr ScreenSession::GetActiveScreenMode() const { if (activeIdx_ < 0 || activeIdx_ >= static_cast(modes_.size())) { diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index ce3a56e6bf..49c13da944 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -108,17 +108,20 @@ ohos_shared_library("scene_session_manager") { "ability_runtime:ability_deps_wrapper", "ability_runtime:ability_manager", "ability_runtime:ability_start_setting", + "ability_runtime:app_context", "ability_runtime:app_manager", "ability_runtime:mission_info", "ability_runtime:session_handler", "ace_engine:ace_uicontent", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", + "bundle_framework:libappexecfwk_common", "c_utils:utils", "config_policy:configpolicy_util", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "ffrt:libffrt", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hicollie:libhicollie", "hilog:libhilog", @@ -130,7 +133,9 @@ ohos_shared_library("scene_session_manager") { "ipc:ipc_single", "libxml2:libxml2", "napi:ace_napi", + "preferences:native_preferences", "resource_management:global_resmgr", + "safwk:system_ability_fwk", "samgr:samgr_proxy", ] @@ -226,6 +231,7 @@ ohos_shared_library("session_manager") { "ability_runtime:app_manager", "ability_runtime:mission_info", "c_utils:utils", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "image_framework:image_native", diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index d20fd06b8c..936e848b1d 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -21,6 +21,12 @@ #include #include +#ifndef OHOS_BUILD_ENABLE_SECURITY_COMPONENT // pointer_envent.h +#define OHOS_BUILD_ENABLE_SECURITY_COMPONENT +#endif +#ifndef SUPPORT_SCREEN +#define SUPPORT_SCREEN +#endif #include "mission_snapshot.h" #include "transaction/rs_interfaces.h" @@ -460,12 +466,6 @@ public: */ void RefreshPcZOrderList(uint32_t startZOrder, std::vector&& persistentIds); - /* - * PiP Window - */ - WMError CloseTargetPiPWindow(const std::string& bundleName); - WMError GetCurrentPiPWindowInfo(std::string& bundleName); - /* * Window Watermark */ @@ -491,6 +491,12 @@ public: */ WMError ReleaseForegroundSessionScreenLock() override; + /* + * PiP Window + */ + WMError CloseTargetPiPWindow(const std::string& bundleName); + WMError GetCurrentPiPWindowInfo(std::string& bundleName); + /* * Window displayId */ @@ -598,6 +604,7 @@ private: bool MissionChanged(sptr& prevSession, sptr& currSession); std::string GetAllSessionFocusInfo(); void RegisterRequestFocusStatusNotifyManagerFunc(sptr& sceneSession); + void ProcessUpdateLastFocusedAppId(const std::vector& zOrderList); void RegisterGetStateFromManagerFunc(sptr& sceneSession); void RegisterSessionChangeByActionNotifyManagerFunc(sptr& sceneSession); @@ -624,6 +631,7 @@ private: void UpdateNormalSessionAvoidArea(const int32_t& persistentId, sptr& sceneSession, bool& needUpdate); void UpdateAvoidArea(int32_t persistentId); void UpdateAvoidAreaByType(int32_t persistentId, AvoidAreaType type); + void UpdateDarkColorModeToRS(); WSError IsLastFrameLayoutFinished(bool& isLayoutFinished); void HandleSpecificSystemBarProperty(WindowType type, const sptr& property, const sptr& sceneSession); @@ -981,7 +989,12 @@ private: /* * Screen Manager */ - bool IsInSecondaryScreen(const sptr& sceneSession); + bool IsInDefaultScreen(const sptr& sceneSession); + + /* + * Window Mode Type + */ + bool IsNeedSkipWindowModeTypeCheck(const sptr& sceneSession, bool isSmallFold); /** * Window Immersive diff --git a/window_scene/session_manager/include/session_listener_controller.h b/window_scene/session_manager/include/session_listener_controller.h index 00bfbb6630..9d54b8ddcd 100644 --- a/window_scene/session_manager/include/session_listener_controller.h +++ b/window_scene/session_manager/include/session_listener_controller.h @@ -20,6 +20,10 @@ #include #include +#include "pixel_map.h" +#ifndef SUPPORT_SCREEN +#define SUPPORT_SCREEN +#endif #include "mission_listener_interface.h" #include "ws_common.h" diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 4310493b45..8a0ec790aa 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -158,13 +158,14 @@ std::string DumpTransformInDisplayInfo(const std::vector& transform) std::string DumpDisplayInfo(const MMI::DisplayInfo& info) { - std::string infoStr = "DisplayInfo: "; - infoStr = infoStr + " id: " + std::to_string(info.id) + " x: " + std::to_string(info.x) + - "y: " + std::to_string(info.y) + " width: " + std::to_string(info.width) + - "height: " + std::to_string(info.height) + " dpi: " + std::to_string(info.dpi) + " name:" + info.name + - " uniq: " + info.uniq + " displayMode: " + std::to_string(static_cast(info.displayMode)) + - " direction: " + std::to_string(static_cast(info.direction)) + - " transform: " + DumpTransformInDisplayInfo(info.transform); + std::ostringstream infoStream("DisplayInfo: "); + infoStream << " id: " << info.id << " x: " << info.x << " y: " << info.y + << " width: " << info.width << " height: " << info.height << " dpi: " << info.dpi + << " name: " << info.name << " uniq: " << info.uniq + << " displayMode: " << static_cast(info.displayMode) + << " direction: " << static_cast(info.direction) + << " transform: " << DumpTransformInDisplayInfo(info.transform); + std::string infoStr = infoStream.str(); return infoStr; } } //namespace @@ -399,7 +400,7 @@ void DumpUIExtentionWindowInfo(const MMI::WindowInfo& windowInfo) void SceneInputManager::PrintWindowInfo(const std::vector& windowInfoList) { int windowListSize = static_cast(windowInfoList.size()); - std::string idList; + std::ostringstream idListStream; static std::string lastIdList; static uint32_t windowEventID = 0; if (windowEventID == UINT32_MAX) { @@ -409,22 +410,18 @@ void SceneInputManager::PrintWindowInfo(const std::vector& wind std::unordered_map currWindowDefaultHotArea; static std::unordered_map lastWindowDefaultHotArea; for (auto& e : windowInfoList) { - idList += std::to_string(e.id) + "|" + std::to_string(e.flags) + "|" + - std::to_string(static_cast(e.zOrder)) + "|" + - std::to_string(e.pid) + "|" + - std::to_string(e.defaultHotAreas.size()); + idListStream << e.id << "|" << e.flags << "|" << static_cast(e.zOrder) << "|" + << e.pid << "|" << e.defaultHotAreas.size(); if (e.defaultHotAreas.size() > 0) { auto iter = lastWindowDefaultHotArea.find(e.id); if (iter == lastWindowDefaultHotArea.end() || iter->second != e.defaultHotAreas[0]) { - idList += "|" + std::to_string(e.defaultHotAreas[0].x) + "|" + - std::to_string(e.defaultHotAreas[0].y) + "|" + - std::to_string(e.defaultHotAreas[0].width) + "|" + - std::to_string(e.defaultHotAreas[0].height); + idListStream << "|" << e.defaultHotAreas[0].x << "|" << e.defaultHotAreas[0].y + << "|" << e.defaultHotAreas[0].width << "|" << e.defaultHotAreas[0].height; } currWindowDefaultHotArea.insert({e.id, e.defaultHotAreas[0]}); } - idList += ","; + idListStream << ","; if ((focusedSessionId_ == e.id) && (e.id == e.agentWindowId)) { UpdateFocusedSessionId(focusedSessionId_); } @@ -433,7 +430,8 @@ void SceneInputManager::PrintWindowInfo(const std::vector& wind } } lastWindowDefaultHotArea = currWindowDefaultHotArea; - idList += std::to_string(focusedSessionId_); + idListStream << focusedSessionId_; + std::string idList = idListStream.str(); if (lastIdList != idList) { windowEventID++; TLOGI(WmsLogTag::WMS_EVENT, "eid:%{public}d,size:%{public}d,idList:%{public}s", @@ -445,19 +443,17 @@ void SceneInputManager::PrintWindowInfo(const std::vector& wind void SceneInputManager::PrintDisplayInfo(const std::vector& displayInfos) { int displayListSize = static_cast(displayInfos.size()); - std::string displayList = ""; + std::ostringstream displayListStream; static std::string lastDisplayList = ""; for (auto& displayInfo : displayInfos) { - displayList += std::to_string(displayInfo.id) + "|" + - std::to_string(displayInfo.x) + "|" + - std::to_string(displayInfo.y) + "|" + - std::to_string(displayInfo.width) + "|" + - std::to_string(displayInfo.height) + "|" + - std::to_string(static_cast(displayInfo.direction)) + "|" + - std::to_string(static_cast(displayInfo.displayDirection)) + "|" + - std::to_string(static_cast(displayInfo.displayMode)); - displayList += ","; + displayListStream << displayInfo.id << "|" << displayInfo.x << "|" << displayInfo.y << "|" + << displayInfo.width << "|" << displayInfo.height << "|" + << static_cast(displayInfo.direction) << "|" + << static_cast(displayInfo.displayDirection) << "|" + << static_cast(displayInfo.displayMode) << ","; } + + std::string displayList = displayListStream.str(); if (lastDisplayList != displayList) { TLOGI(WmsLogTag::WMS_EVENT, "num:%{public}d,displayList:%{public}s", displayListSize, displayList.c_str()); lastDisplayList = displayList; diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 9b1fb77b98..9dbe471cdb 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -871,20 +871,23 @@ void DumpSecSurfaceInfoMap(const std::map> void SceneSessionDirtyManager::UpdateSecSurfaceInfo(const std::map>& secSurfaceInfoMap) { - std::unique_lock lock(secSurfaceInfoMutex_); - if (secSurfaceInfoMap.size() != secSurfaceInfoMap_.size() || secSurfaceInfoMap_ != secSurfaceInfoMap) { - secSurfaceInfoMap_ = secSurfaceInfoMap; + bool updateSecSurfaceInfoNeeded = false; + { + std::unique_lock lock(secSurfaceInfoMutex_); + if (secSurfaceInfoMap_ != secSurfaceInfoMap) { + secSurfaceInfoMap_ = secSurfaceInfoMap; + updateSecSurfaceInfoNeeded = true; + } + } + if (updateSecSurfaceInfoNeeded) { ResetFlushWindowInfoTask(); - DumpSecSurfaceInfoMap(secSurfaceInfoMap_); + DumpSecSurfaceInfoMap(secSurfaceInfoMap); } } std::vector SceneSessionDirtyManager::GetSecSurfaceWindowinfoList( const sptr& sceneSession, const MMI::WindowInfo& hostWindowinfo, const Matrix3f& hostTransform) const { - if (secSurfaceInfoMap_.size() == 0) { - return {}; - } if (sceneSession == nullptr) { TLOGE(WmsLogTag::WMS_EVENT, "sceneSession is nullptr"); return {}; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 499bfdbc12..9ba2ae5080 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -15,11 +15,9 @@ #include "session_manager/include/scene_session_manager.h" -#include -#include - #include #include +#include #include #include #include @@ -62,10 +60,8 @@ #include "perform_reporter.h" #include "dms_reporter.h" #include "res_sched_client.h" -#include "res_type.h" #include "anomaly_detection.h" #include "hidump_controller.h" -#include "window_pid_visibility_info.h" #include "session/host/include/multi_instance_manager.h" #ifdef MEMMGR_WINDOW_ENABLE @@ -123,6 +119,7 @@ const std::string ARG_DUMP_DETAIL = "-c"; constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns const int32_t LOGICAL_DISPLACEMENT_32 = 32; constexpr int32_t GET_TOP_WINDOW_DELAY = 100; +constexpr char SMALL_FOLD_PRODUCT_TYPE = '2'; constexpr int32_t FFRT_USER_INTERACTIVE_MAX_THREAD_NUM = 5; @@ -168,22 +165,24 @@ bool GetSingleIntItem(const WindowSceneConfig::ConfigItem& item, int32_t& value) return false; } -int ConfigFfrtWorkerNum() -{ - ffrt_worker_num_param qosConfig; - (void)memset_s(&qosConfig, sizeof(qosConfig), -1, sizeof(qosConfig)); - qosConfig.effectLen = 1; - qosConfig.qosConfigArray[0].qos = ffrt_qos_user_interactive; - qosConfig.qosConfigArray[0].hardLimit = FFRT_USER_INTERACTIVE_MAX_THREAD_NUM; - return ffrt_set_qos_worker_num(&qosConfig); -} - int32_t GetPid() { static int32_t pid = static_cast(getpid()); return pid; } +bool GetEnableRemoveStartingWindowFromBMS(const std::shared_ptr& abilityInfo) +{ + auto& metadata = abilityInfo->metadata; + for (const auto& item : metadata) { + if (item.name == "enable.remove.starting.window") { + return item.value == "true"; + break; + } + } + return false; +} + class BundleStatusCallback : public IRemoteStub { public: BundleStatusCallback() = default; @@ -270,7 +269,7 @@ void SceneSessionManager::Init() } taskScheduler_->SetExportHandler(eventHandler_); - ret = ConfigFfrtWorkerNum(); + ret = ffrt_set_cpu_worker_max_num(ffrt_qos_user_interactive, FFRT_USER_INTERACTIVE_MAX_THREAD_NUM); TLOGI(WmsLogTag::WMS_MAIN, "FFRT user interactive qos max thread number: %{public}d, retcode: %{public}d", FFRT_USER_INTERACTIVE_MAX_THREAD_NUM, ret); @@ -299,6 +298,7 @@ void SceneSessionManager::Init() MultiInstanceManager::GetInstance().SetCurrentUserId(currentUserId_); } InitVsyncStation(); + UpdateDarkColorModeToRS(); } void SceneSessionManager::InitVsyncStation() @@ -1776,8 +1776,8 @@ sptr SceneSessionManager::SetAbilitySessionInfo(const sptr(sessionProperty->GetDisplayId())); } abilitySessionInfo->instanceKey = sessionInfo.appInstanceKey_; - if (sessionInfo.callState_ >= static_cast(AAFwk::CallToState::UNKNOW) && - sessionInfo.callState_ <= static_cast(AAFwk::CallToState::BACKGROUND)) { + if (sessionInfo.callState_ >= static_cast(AAFwk::CallToState::UNKNOW) && + sessionInfo.callState_ <= static_cast(AAFwk::CallToState::BACKGROUND)) { abilitySessionInfo->state = static_cast(sessionInfo.callState_); } else { TLOGW(WmsLogTag::WMS_LIFE, "Invalid callState:%{public}d", sessionInfo.callState_); @@ -1911,6 +1911,7 @@ WSError SceneSessionManager::RequestSceneSessionActivationInner( RequestInputMethodCloseKeyboard(persistentId); if (WindowHelper::IsMainWindow(sceneSession->GetWindowType())) { sceneSession->SetIsStarting(true); + sceneSession->SetStartingBeforeVisible(true); } if (WindowHelper::IsMainWindow(sceneSession->GetWindowType()) && sceneSession->IsFocusedOnShow()) { if (Session::IsScbCoreEnabled()) { @@ -2188,7 +2189,7 @@ void SceneSessionManager::EraseSceneSessionMapById(int32_t persistentId) EraseSceneSessionAndMarkDirtyLockFree(persistentId); systemTopSceneSessionMap_.erase(persistentId); nonSystemFloatSceneSessionMap_.erase(persistentId); - if (MultiInstanceManager::IsSupportMultiInstance(systemConfig_) && + if (sceneSession && MultiInstanceManager::IsSupportMultiInstance(systemConfig_) && MultiInstanceManager::GetInstance().IsMultiInstance(sceneSession->GetSessionInfo().bundleName_)) { MultiInstanceManager::GetInstance().DecreaseInstanceKeyRefCount(sceneSession); } @@ -2385,7 +2386,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW && property->GetIsUIExtFirstSubWindow()) { WSError err = CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage); if (err != WSError::WS_OK) { @@ -2587,8 +2588,19 @@ bool SceneSessionManager::CheckSystemWindowPermission(const sptrGetParentPersistentId(); + auto parentSession = GetSceneSession(parentId); + if (parentSession != nullptr && parentSession->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT && + SessionPermission::VerifyCallingPermission("ohos.permission.SYSTEM_FLOAT_WINDOW")) { + TLOGI(WmsLogTag::WMS_SYSTEM, "check system subWindow permission success, parentId:%{public}d.", parentId); + return true; + } else { + TLOGW(WmsLogTag::WMS_SYSTEM, "check system subWindow permission warning, parentId:%{public}d.", parentId); + } + } if (SessionPermission::IsSystemCalling() || SessionPermission::IsStartByHdcd()) { - WLOGFD("check create permission success, create with system calling."); + TLOGI(WmsLogTag::WMS_SYSTEM, "check create permission success, create with system calling."); return true; } WLOGFE("check system window permission failed."); @@ -3202,12 +3214,18 @@ WSError SceneSessionManager::ProcessBackEvent() auto task = [this]() { auto session = GetSceneSession(focusedSessionId_); if (!session) { - WLOGFE("session is nullptr: %{public}d", focusedSessionId_); + TLOGNE(WmsLogTag::WMS_MAIN, "session is nullptr: %{public}d", focusedSessionId_); return WSError::WS_ERROR_INVALID_SESSION; } - WLOGFI("ProcessBackEvent session persistentId:%{public}d needBlock::%{public}d", + TLOGNI(WmsLogTag::WMS_MAIN, "ProcessBackEvent session persistentId:%{public}d needBlock:%{public}d", focusedSessionId_, needBlockNotifyFocusStatusUntilForeground_); if (needBlockNotifyFocusStatusUntilForeground_) { + TLOGND(WmsLogTag::WMS_MAIN, "RequestSessionBack when start session"); + if (session->GetSessionInfo().abilityInfo != nullptr && + session->GetSessionInfo().abilityInfo->unclearableMission) { + TLOGNI(WmsLogTag::WMS_MAIN, "backPress unclearableMission"); + return WSError::WS_OK; + } session->RequestSessionBack(true); return WSError::WS_OK; } @@ -3219,7 +3237,7 @@ WSError SceneSessionManager::ProcessBackEvent() return WSError::WS_OK; }; - taskScheduler_->PostAsyncTask(task, "ProcessBackEvent"); + taskScheduler_->PostAsyncTask(task, __func__); return WSError::WS_OK; } @@ -3536,6 +3554,7 @@ void SceneSessionManager::FillSessionInfo(sptr& sceneSession) WLOGFE("abilityInfo is nullptr!"); return; } + sceneSession->SetEnableRemoveStartingWindow(GetEnableRemoveStartingWindowFromBMS(abilityInfo)); sceneSession->SetSessionInfoAbilityInfo(abilityInfo); sceneSession->SetSessionInfoTime(GetCurrentTime()); if (abilityInfo->applicationInfo.codePath == std::to_string(CollaboratorType::RESERVE_TYPE)) { @@ -3830,8 +3849,8 @@ void SceneSessionManager::HandleKeepScreenOn(const sptr& sceneSess return; } bool shouldLock = requireLock && IsSessionVisibleForeground(sceneSession); - TLOGNI(WmsLogTag::DEFAULT, "keep screen on: [%{public}s, %{public}d, %{public}d], %{public}d], %{public}d]", - sceneSession->GetWindowName().c_str(), sceneSession->GetSessionState(), + TLOGNI(WmsLogTag::DEFAULT, "keep screen on: [%{public}s, %{public}d, %{public}d], %{public}d], %{public}d]", + sceneSession->GetWindowName().c_str(), sceneSession->GetSessionState(), sceneSession->IsVisible(), requireLock, shouldLock); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:HandleKeepScreenOn"); ErrCode res; @@ -3861,7 +3880,6 @@ bool SceneSessionManager::NotifyVisibleChange(int32_t persistentId) return false; } HandleKeepScreenOn(sceneSession, sceneSession->IsKeepScreenOn()); - ProcessWindowModeType(); return true; } @@ -4222,21 +4240,23 @@ bool SceneSessionManager::IsSessionVisible(const sptr& session) } const auto& state = session->GetSessionState(); if (WindowHelper::IsSubWindow(session->GetWindowType())) { - const auto& parentSceneSession = session->GetParentSession(); - if (parentSceneSession == nullptr) { - WLOGFW("Can not find parent for this sub window, id: %{public}d", session->GetPersistentId()); + const auto& mainSession = session->GetMainSession(); + if (mainSession == nullptr) { + TLOGE(WmsLogTag::WMS_SUB, "Can not find parent for this sub window, id: %{public}d", + session->GetPersistentId()); return false; } - const auto& parentState = parentSceneSession->GetSessionState(); + const auto mainState = mainSession->GetSessionState(); if (session->IsVisible() || (state == SessionState::STATE_ACTIVE || state == SessionState::STATE_FOREGROUND)) { - if (parentState == SessionState::STATE_INACTIVE || parentState == SessionState::STATE_BACKGROUND) { - WLOGFD("Parent of this sub window is at background, id: %{public}d", session->GetPersistentId()); + if (mainState == SessionState::STATE_INACTIVE || mainState == SessionState::STATE_BACKGROUND) { + TLOGD(WmsLogTag::WMS_SUB, "Parent of this sub window is at background, id: %{public}d", + session->GetPersistentId()); return false; } - WLOGFD("Sub window is at foreground, id: %{public}d", session->GetPersistentId()); + TLOGD(WmsLogTag::WMS_SUB, "Sub window is at foreground, id: %{public}d", session->GetPersistentId()); return true; } - WLOGFD("Sub window is at background, id: %{public}d", session->GetPersistentId()); + TLOGD(WmsLogTag::WMS_SUB, "Sub window is at background, id: %{public}d", session->GetPersistentId()); return false; } @@ -5795,7 +5815,6 @@ __attribute__((no_sanitize("cfi"))) void SceneSessionManager::OnSessionStateChan default: break; } - ProcessWindowModeType(); } void SceneSessionManager::ProcessFocusWhenForeground(sptr& sceneSession) @@ -5853,10 +5872,10 @@ static bool IsSmallFoldProduct() TLOGE(WmsLogTag::DEFAULT, "foldScreenType is empty"); return false; } - return foldScreenType[0] == '2'; + return foldScreenType[0] == SMALL_FOLD_PRODUCT_TYPE; } -bool SceneSessionManager::IsInSecondaryScreen(const sptr& sceneSession) +bool SceneSessionManager::IsInDefaultScreen(const sptr& sceneSession) { auto sessionProperty = sceneSession->GetSessionProperty(); if (sessionProperty == nullptr) { @@ -5864,7 +5883,21 @@ bool SceneSessionManager::IsInSecondaryScreen(const sptr& sceneSes return false; } ScreenId defaultScreenId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId(); - return sessionProperty->GetDisplayId() != defaultScreenId; + return sessionProperty->GetDisplayId() == defaultScreenId; +} + +bool SceneSessionManager::IsNeedSkipWindowModeTypeCheck(const sptr& sceneSession, bool isSmallFold) +{ + if (sceneSession == nullptr || + !WindowHelper::IsMainWindow(sceneSession->GetWindowType()) || + !sceneSession->GetRSVisible() || + !sceneSession->IsSessionForeground()) { + return true; + } + if (isSmallFold && !IsInDefaultScreen(sceneSession)) { + return true; + } + return false; } WindowModeType SceneSessionManager::CheckWindowModeType() @@ -5876,12 +5909,7 @@ WindowModeType SceneSessionManager::CheckWindowModeType() { std::shared_lock lock(sceneSessionMapMutex_); for (const auto& session : sceneSessionMap_) { - if (session.second == nullptr || - !WindowHelper::IsMainWindow(session.second->GetWindowType()) || - !Rosen::SceneSessionManager::GetInstance().IsSessionVisibleForeground(session.second)) { - continue; - } - if (isSmallFold && IsInSecondaryScreen(session.second)) { + if (IsNeedSkipWindowModeTypeCheck(session.second, isSmallFold)) { continue; } auto mode = session.second->GetWindowMode(); @@ -7630,8 +7658,8 @@ std::vector> SceneSessionManager::GetSubSceneSession(int32_t if (sceneSession == nullptr) { continue; } - if (sceneSession->GetParentSession() != nullptr && - sceneSession->GetParentSession()->GetWindowId() == parentWindowId) { + const auto& mainSession = sceneSession->GetMainSession(); + if (mainSession != nullptr && mainSession->GetWindowId() == parentWindowId) { subSessions.push_back(sceneSession); } } @@ -7711,6 +7739,7 @@ void SceneSessionManager::DealwithVisibilityChange(const std::vectorPostSyncTask(task, "UpdateSessionWindowVisibilityListener"); } +void SceneSessionManager::UpdateDarkColorModeToRS() +{ + std::shared_ptr appContext = AbilityRuntime::Context::GetApplicationContext(); + if (appContext == nullptr) { + TLOGE(WmsLogTag::DEFAULT, "app context is nullptr"); + return; + } + std::shared_ptr config = appContext->GetConfiguration(); + if (config == nullptr) { + TLOGE(WmsLogTag::DEFAULT, "app configuration is nullptr"); + return; + } + std::string colorMode = config->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); + bool isDark = (colorMode == AppExecFwk::ConfigurationInner::COLOR_MODE_DARK); + bool ret = RSInterfaces::GetInstance().SetGlobalDarkColorMode(isDark); + TLOGI(WmsLogTag::DEFAULT, "SetGlobalDarkColorMode with colorMode: %{public}s, ret: %{public}d", + colorMode.c_str(), ret); +} + void SceneSessionManager::SetVirtualPixelRatioChangeListener(const ProcessVirtualPixelRatioChangeFunc& func) { processVirtualPixelRatioChangeFunc_ = func; @@ -9226,6 +9274,7 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_map lock(nextFlushCompletedMutex_); nextFlushCompletedCV_.notify_all(); } + std::vector startingAppZOrderList; processingFlushUIParams_.store(true); { std::shared_lock lock(sceneSessionMapMutex_); @@ -9239,6 +9288,12 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapGetPersistentId()); if (iter != uiParams.end()) { + if ((systemConfig_.IsPhoneWindow() || + (systemConfig_.IsPadWindow() && !systemConfig_.IsFreeMultiWindowMode())) && + sceneSession->GetStartingBeforeVisible() && sceneSession->IsAppSession()) { + startingAppZOrderList.push_back(iter->second.zOrder_); + sceneSession->SetStartingBeforeVisible(false); + } sessionMapDirty_ |= sceneSession->UpdateUIParam(iter->second); } else { sessionMapDirty_ |= sceneSession->UpdateUIParam(); @@ -9258,6 +9313,7 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapPostAsyncTask(task, "FlushUIParams"); } -void SceneSessionManager::ProcessFocusZOrderChange(uint32_t dirty) { +void SceneSessionManager::ProcessUpdateLastFocusedAppId(const std::vector& zOrderList) +{ + TLOGD(WmsLogTag::WMS_FOCUS, "last focused app: %{public}d, list size %{public}zu", lastFocusedAppSessionId_, + zOrderList.size()); + if (lastFocusedAppSessionId_ == INVALID_SESSION_ID || zOrderList.empty()) { + return; + } + auto lastFocusedAppSession = GetSceneSession(lastFocusedAppSessionId_); + if (lastFocusedAppSession == nullptr) { + return; + } + uint32_t lastFocusedAppZOrder = lastFocusedAppSession->GetZOrder(); + auto it = std::find_if(zOrderList.begin(), zOrderList.end(), [lastFocusedAppZOrder](uint32_t zOrder) { + return zOrder > lastFocusedAppZOrder; + }); + if (it != zOrderList.end()) { + TLOGD(WmsLogTag::WMS_FOCUS, "clear with high zOrder app visible"); + lastFocusedAppSessionId_ = INVALID_SESSION_ID; + } +} + +void SceneSessionManager::ProcessFocusZOrderChange(uint32_t dirty) +{ if (!(dirty & static_cast(SessionUIDirtyFlag::Z_ORDER))) { return; } @@ -9549,10 +9627,9 @@ std::shared_ptr SceneSessionManager::GetSessionSnapshotPixelMap } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetSessionSnapshotPixelMap(%d )", persistentId); - std::shared_ptr pixelMap = nullptr; bool isPc = systemConfig_.IsPcWindow() || systemConfig_.IsFreeMultiWindowMode(); - pixelMap = sceneSession->Snapshot(true, scaleParam, isPc); + std::shared_ptr pixelMap = sceneSession->Snapshot(true, scaleParam, isPc); if (!pixelMap) { WLOGFI("get local snapshot pixelmap start"); pixelMap = sceneSession->GetSnapshotPixelMap(snapshotScale_, scaleParam); @@ -10996,7 +11073,10 @@ void SceneSessionManager::RefreshPcZOrderList(uint32_t startZOrder, std::vector< void SceneSessionManager::SetCloseTargetFloatWindowFunc(const ProcessCloseTargetFloatWindowFunc& func) { TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "in"); - closeTargetFloatWindowFunc_ = func; + auto task = [this, func] { + closeTargetFloatWindowFunc_ = func; + }; + taskScheduler_->PostTask(task, __func__); } WMError SceneSessionManager::CloseTargetFloatWindow(const std::string& bundleName) @@ -11011,7 +11091,7 @@ WMError SceneSessionManager::CloseTargetFloatWindow(const std::string& bundleNam closeTargetFloatWindowFunc_(bundleName); } }; - taskScheduler_->PostTask(task, "CloseTargetFloatWindow"); + taskScheduler_->PostTask(task, __func__); return WMError::WM_OK; } @@ -11027,7 +11107,7 @@ WMError SceneSessionManager::CloseTargetPiPWindow(const std::string& bundleName) return WMError::WM_ERROR_INVALID_PERMISSION; } std::shared_lock lock(sceneSessionMapMutex_); - for (const auto& iter: sceneSessionMap_) { + for (const auto& iter : sceneSessionMap_) { auto& session = iter.second; if (session && session->GetWindowType() == WindowType::WINDOW_TYPE_PIP && session->GetSessionInfo().bundleName_ == bundleName) { @@ -11045,7 +11125,7 @@ WMError SceneSessionManager::GetCurrentPiPWindowInfo(std::string& bundleName) return WMError::WM_ERROR_INVALID_PERMISSION; } std::shared_lock lock(sceneSessionMapMutex_); - for (const auto& iter: sceneSessionMap_) { + for (const auto& iter : sceneSessionMap_) { auto& session = iter.second; if (session && session->GetWindowType() == WindowType::WINDOW_TYPE_PIP) { bundleName = session->GetSessionInfo().bundleName_; diff --git a/window_scene/session_manager/src/session_manager_agent_controller.cpp b/window_scene/session_manager/src/session_manager_agent_controller.cpp index 8c9ebf9de9..e5983f7af8 100644 --- a/window_scene/session_manager/src/session_manager_agent_controller.cpp +++ b/window_scene/session_manager/src/session_manager_agent_controller.cpp @@ -232,7 +232,7 @@ void SessionManagerAgentController::NotifyWindowPidVisibilityChanged( void SessionManagerAgentController::UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground) { - for (auto &agent: smAgentContainer_.GetAgentsByType( + for (auto& agent : smAgentContainer_.GetAgentsByType( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_PIP)) { if (agent != nullptr) { agent->UpdatePiPWindowStateChanged(bundleName, isForeground); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index 3ad7370fbf..a5039762e5 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -12,7 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#ifndef SUPPORT_SCREEN +#define SUPPORT_SCREEN +#endif #include "session_manager/include/zidl/scene_session_manager_proxy.h" #include diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index bc526713cc..7634644005 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -351,7 +351,11 @@ int SceneSessionManagerStub::HandleRequestFocusStatus(MessageParcel& data, Messa TLOGE(WmsLogTag::WMS_FOCUS, "read persistentId failed"); return ERR_INVALID_DATA; } - bool isFocused = data.ReadBool(); + bool isFocused = false; + if (!data.ReadBool(isFocused)) { + TLOGE(WmsLogTag::WMS_FOCUS, "read isFocused failed"); + return ERR_INVALID_DATA; + } WMError ret = RequestFocusStatus(persistentId, isFocused, true, FocusChangeReason::CLIENT_REQUEST); reply.WriteInt32(static_cast(ret)); return ERR_NONE; diff --git a/window_scene/test/dms_unittest/multi_screen_manager_test.cpp b/window_scene/test/dms_unittest/multi_screen_manager_test.cpp index ff39dac8f4..0690f2960d 100644 --- a/window_scene/test/dms_unittest/multi_screen_manager_test.cpp +++ b/window_scene/test/dms_unittest/multi_screen_manager_test.cpp @@ -1425,7 +1425,7 @@ HWTEST_F(MultiScreenManagerTest, InternalScreenOffChange01, Function | SmallTest /** * @tc.name: InternalScreenOffChange02 - * @tc.desc: internal extend to external mirror + * @tc.desc: no need to change or paramater error * @tc.type: FUNC */ HWTEST_F(MultiScreenManagerTest, InternalScreenOffChange02, Function | SmallTest | Level1) @@ -1478,7 +1478,7 @@ HWTEST_F(MultiScreenManagerTest, InternalScreenOffChange02, Function | SmallTest /** * @tc.name: InternalScreenOffChange03 - * @tc.desc: paramater error + * @tc.desc: internal extend to external mirror * @tc.type: FUNC */ HWTEST_F(MultiScreenManagerTest, InternalScreenOffChange03, Function | SmallTest | Level1) @@ -1519,7 +1519,7 @@ HWTEST_F(MultiScreenManagerTest, InternalScreenOffChange03, Function | SmallTest EXPECT_EQ(true, internalSession->GetIsExtend()); EXPECT_EQ(false, externalSession->GetIsExtend()); - EXPECT_EQ(ScreenCombination::SCREEN_EXTEND, internalSession->GetScreenCombination()); + EXPECT_EQ(ScreenCombination::SCREEN_MIRROR, internalSession->GetScreenCombination()); EXPECT_EQ(ScreenCombination::SCREEN_MAIN, externalSession->GetScreenCombination()); { std::lock_guard @@ -1572,7 +1572,7 @@ HWTEST_F(MultiScreenManagerTest, InternalScreenOffChange04, Function | SmallTest EXPECT_EQ(true, internalSession->GetIsExtend()); EXPECT_EQ(false, externalSession->GetIsExtend()); - EXPECT_EQ(ScreenCombination::SCREEN_EXTEND, internalSession->GetScreenCombination()); + EXPECT_EQ(ScreenCombination::SCREEN_MIRROR, internalSession->GetScreenCombination()); EXPECT_EQ(ScreenCombination::SCREEN_MAIN, externalSession->GetScreenCombination()); { std::lock_guard diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index 1bfb57f7a2..319f5e2fce 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -497,6 +497,25 @@ HWTEST_F(ScreenSessionTest, UpdateRotationAfterBoot02, Function | SmallTest | Le GTEST_LOG_(INFO) << "UpdateRotationAfterBoot end"; } +/** + * @tc.name: UpdateValidRotationToScb + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, UpdateValidRotationToScb, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "UpdateValidRotationToScb start"; + ScreenSessionConfig config = { + .screenId = 100, + .rsId = 101, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); + EXPECT_NE(nullptr, screenSession); + screenSession->UpdateValidRotationToScb(); + GTEST_LOG_(INFO) << "UpdateValidRotationToScb end"; +} + /** * @tc.name: SetScreenSceneDpiChangeListener * @tc.desc: normal function diff --git a/window_scene/test/mock/mock_session_stub.h b/window_scene/test/mock/mock_session_stub.h index b4e730ed99..b76c4a0fde 100644 --- a/window_scene/test/mock/mock_session_stub.h +++ b/window_scene/test/mock/mock_session_stub.h @@ -41,6 +41,7 @@ public: MOCK_METHOD1(Show, WSError(sptr property)); MOCK_METHOD0(Hide, WSError(void)); MOCK_METHOD0(DrawingCompleted, WSError(void)); + MOCK_METHOD0(RemoveStartingWindow, WSError(void)); MOCK_METHOD4(OnRemoteRequest, int(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)); diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index facbcf92ae..4ccecf4095 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -616,6 +616,7 @@ ohos_unittest("ws_scene_session_manager_test4") { "ability_base:configuration", "ability_base:session_info", "ability_runtime:ability_context_native", + "ability_runtime:app_context", "ability_runtime:mission_info", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", @@ -893,10 +894,13 @@ ohos_unittest("ws_scene_session_manager_stub_test") { ohos_unittest("ws_scene_session_manager_supplement_test") { module_out_path = module_out_path - + include_dirs = [ "${window_base_path}/test/common/utils/include/" ] sources = [ "scene_session_manager_supplement_test.cpp" ] - deps = [ ":ws_unittest_common" ] + deps = [ + ":ws_unittest_common", + "${window_base_path}/test/common/utils:libtestutil", + ] external_deps = [ "ability_base:configuration", diff --git a/window_scene/test/unittest/intention_event_manager_test.cpp b/window_scene/test/unittest/intention_event_manager_test.cpp index 00bbb74473..8ba0a5cd28 100644 --- a/window_scene/test/unittest/intention_event_manager_test.cpp +++ b/window_scene/test/unittest/intention_event_manager_test.cpp @@ -137,6 +137,7 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent0, Function | MediumTest | Level property->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_FLOAT); sceneSession1->SetSessionProperty(property); inputEventListener_->OnInputEvent(pointerEvent); + EXPECT_EQ(200010, pointerEvent->GetPointerId()); } /** @@ -181,7 +182,9 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent1, Function | MediumTest | Level SceneSessionManager::GetInstance().sceneSessionMap_.emplace(std::make_pair(2, sceneSession1)); SceneSessionManager::GetInstance().SetFocusedSessionId(2); EXPECT_EQ(2, SceneSessionManager::GetInstance().GetFocusedSessionId()); + auto focusedSceneSession = SceneSessionManager::GetInstance().GetSceneSession(2); inputEventListener_->OnInputEvent(keyEvent); + EXPECT_NE(nullptr, focusedSceneSession); } /** @@ -214,7 +217,9 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent2, Function | MediumTest | Level sceneSession->SetNotifySystemSessionKeyEventFunc(nullptr); keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_FN); EXPECT_EQ(MMI::KeyEvent::KEYCODE_FN, keyEvent->GetKeyCode()); + auto focusedSceneSession = SceneSessionManager::GetInstance().GetSceneSession(1); inputEventListener_->OnInputEvent(keyEvent); + EXPECT_NE(nullptr, focusedSceneSession); } /** @@ -246,7 +251,9 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent3, Function | MediumTest | Level keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_UNKNOWN); EXPECT_EQ(MMI::KeyEvent::KEYCODE_UNKNOWN, keyEvent->GetKeyCode()); inputEventListener->OnInputEvent(keyEvent); + auto focusedSceneSession = SceneSessionManager::GetInstance().GetSceneSession(1); inputEventListener_->OnInputEvent(keyEvent); + EXPECT_NE(nullptr, focusedSceneSession); } /** diff --git a/window_scene/test/unittest/scene_session_dirty_manager_test.cpp b/window_scene/test/unittest/scene_session_dirty_manager_test.cpp index dfd195238b..31918df38a 100644 --- a/window_scene/test/unittest/scene_session_dirty_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_dirty_manager_test.cpp @@ -801,12 +801,22 @@ HWTEST_F(SceneSessionDirtyManagerTest, UpdateSecSurfaceInfo, Function | SmallTes */ HWTEST_F(SceneSessionDirtyManagerTest, ResetFlushWindowInfoTask, Function | SmallTest | Level2) { - int ret = 0; auto preFlushWindowInfoCallback = manager_->flushWindowInfoCallback_; manager_->flushWindowInfoCallback_ = nullptr; manager_->ResetFlushWindowInfoTask(); + EXPECT_TRUE(manager_->hasPostTask_.load()); manager_->flushWindowInfoCallback_ = preFlushWindowInfoCallback; - ASSERT_EQ(ret, 0); +} + +/** + * @tc.name: ResetFlushWindowInfoTask1 + * @tc.desc: ResetFlushWindowInfoTask1 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionDirtyManagerTest, ResetFlushWindowInfoTask1, Function | SmallTest | Level2) +{ + manager_->ResetFlushWindowInfoTask(); + EXPECT_TRUE(manager_->hasPostTask_.load()); } /** diff --git a/window_scene/test/unittest/scene_session_manager_supplement_test.cpp b/window_scene/test/unittest/scene_session_manager_supplement_test.cpp index 9a6c401f62..2a6e265d12 100644 --- a/window_scene/test/unittest/scene_session_manager_supplement_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_supplement_test.cpp @@ -25,6 +25,7 @@ #include "window_manager_agent.h" #include "session_manager.h" #include "zidl/window_manager_agent_interface.h" +#include "common_test_utils.h" #include "mock/mock_session_stage.h" #include "mock/mock_window_event_channel.h" #include "context.h" @@ -244,6 +245,7 @@ HWTEST_F(SceneSessionManagerSupplementTest, CreateAndConnectSpecificSession, Fun property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, systemConfig, token); + CommonTestUtils::GuaranteeFloatWindowPermission("ws_scene_session_manager_supplement_test"); property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); property->SetFloatingWindowAppType(true); ssm_->CreateAndConnectSpecificSession(sessionStage, eventChannel, node, property, id, session, diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 44ebf466be..97b8ae80b5 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -587,11 +587,11 @@ HWTEST_F(SceneSessionManagerTest10, NotifyVisibleChange, Function | SmallTest | } /** - * @tc.name: IsInSecondaryScreen - * @tc.desc: test IsInSecondaryScreen + * @tc.name: IsInDefaultScreen + * @tc.desc: test IsInDefaultScreen * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest10, IsInSecondaryScreen, Function | SmallTest | Level3) +HWTEST_F(SceneSessionManagerTest10, IsInDefaultScreen, Function | SmallTest | Level3) { SessionInfo info; info.abilityName_ = "test"; @@ -603,12 +603,12 @@ HWTEST_F(SceneSessionManagerTest10, IsInSecondaryScreen, Function | SmallTest | DisplayId displayId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId(); property->SetDisplayId(displayId); sceneSession->SetSessionProperty(property); - ASSERT_EQ(ssm_->IsInSecondaryScreen(sceneSession), false); + ASSERT_EQ(ssm_->IsInDefaultScreen(sceneSession), true); displayId = 5; property->SetDisplayId(displayId); sceneSession->SetSessionProperty(property); - ASSERT_EQ(ssm_->IsInSecondaryScreen(sceneSession), true); + ASSERT_EQ(ssm_->IsInDefaultScreen(sceneSession), false); } /** @@ -663,6 +663,102 @@ HWTEST_F(SceneSessionManagerTest10, EraseSceneSessionAndMarkDirtyLockFree, Funct ASSERT_EQ(ssm_->sessionMapDirty_, static_cast(SessionUIDirtyFlag::VISIBLE)); ASSERT_EQ(ssm_->sceneSessionMap_.find(validId), ssm_->sceneSessionMap_.end()); } + +/** + * @tc.name: UpdateAvoidAreaByType + * @tc.desc: test UpdateAvoidAreaByType + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest10, UpdateAvoidAreaByType, Function | SmallTest | Level3) +{ + SessionInfo info; + info.abilityName_ = "test"; + info.bundleName_ = "test"; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + ASSERT_NE(nullptr, sceneSession); + + ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + sceneSession->isVisible_ = true; + sceneSession->state_ = SessionState::STATE_ACTIVE; + ssm_->UpdateAvoidAreaByType(sceneSession->GetPersistentId(), AvoidAreaType::TYPE_NAVIGATION_INDICATOR); + EXPECT_EQ(ssm_->lastUpdatedAvoidArea_.find(sceneSession->GetPersistentId()), ssm_->lastUpdatedAvoidArea_.end()); + ssm_->avoidAreaListenerSessionSet_.insert(sceneSession->GetPersistentId()); + ssm_->UpdateAvoidAreaByType(sceneSession->GetPersistentId(), AvoidAreaType::TYPE_NAVIGATION_INDICATOR); + EXPECT_EQ(ssm_->lastUpdatedAvoidArea_.find(sceneSession->GetPersistentId()), ssm_->lastUpdatedAvoidArea_.end()); + ssm_->avoidAreaListenerSessionSet_.erase(sceneSession->GetPersistentId()); + ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId()); +} + +/** + * @tc.name: NotifyStatusBarShowStatus + * @tc.desc: test NotifyStatusBarShowStatus + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest10, NotifyStatusBarShowStatus, Function | SmallTest | Level3) +{ + SessionInfo info; + info.abilityName_ = "test"; + info.bundleName_ = "test"; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + ASSERT_NE(nullptr, sceneSession); + + ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + sceneSession->isStatusBarVisible_ = true; + EXPECT_EQ(WSError::WS_OK, ssm_->NotifyStatusBarShowStatus(sceneSession->GetPersistentId(), false)); + ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId()); +} + +/** + * @tc.name: ProcessUpdateLastFocusedAppId + * @tc.desc: test ProcessUpdateLastFocusedAppId + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest10, ProcessUpdateLastFocusedAppId, Function | SmallTest | Level1) +{ + ssm_->sceneSessionMap_.clear(); + std::vector zOrderList; + ssm_->lastFocusedAppSessionId_ = INVALID_SESSION_ID; + ssm_->ProcessUpdateLastFocusedAppId(zOrderList); + + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "lastFocusedAppSession"; + sessionInfo.abilityName_ = "lastFocusedAppSession"; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ssm_->sceneSessionMap_.emplace(1, sceneSession); + ssm_->lastFocusedAppSessionId_ = 1; + sceneSession->zOrder_ = 101; + + ssm_->ProcessUpdateLastFocusedAppId(zOrderList); + ASSERT_EQ(1, ssm_->lastFocusedAppSessionId_); + + zOrderList.push_back(103); + ssm_->ProcessUpdateLastFocusedAppId(zOrderList); + ASSERT_EQ(INVALID_SESSION_ID, ssm_->lastFocusedAppSessionId_); +} + +/** + * @tc.name: IsNeedSkipWindowModeTypeCheck + * @tc.desc: IsNeedSkipWindowModeTypeCheck + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest10, IsNeedSkipWindowModeTypeCheck, Function | SmallTest | Level3) +{ + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "IsNeedSkipWindowModeTypeCheck"; + sessionInfo.abilityName_ = "IsNeedSkipWindowModeTypeCheck"; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ASSERT_NE(nullptr, sceneSession); + ASSERT_NE(nullptr, sceneSession->property_); + sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + sceneSession->SetRSVisible(false); + sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); + ASSERT_TRUE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, false)); + sceneSession->SetRSVisible(true); + DisplayId displayId = 1001; + sceneSession->property_->SetDisplayId(displayId); + ASSERT_TRUE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, true)); + ASSERT_FALSE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, false)); +} } // namespace } } \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_test2.cpp b/window_scene/test/unittest/scene_session_manager_test2.cpp index 2b156f0060..f42d59cc07 100644 --- a/window_scene/test/unittest/scene_session_manager_test2.cpp +++ b/window_scene/test/unittest/scene_session_manager_test2.cpp @@ -1406,6 +1406,52 @@ HWTEST_F(SceneSessionManagerTest2, UpdateRecoveredSessionInfo, Function | SmallT ssm_->sceneSessionMap_.erase(0); } +/** + * @tc.name: UpdateRecoveredSessionInfo02 + * @tc.desc: Test if failRecoverPersistentSet exist or not exist + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest2, UpdateRecoveredSessionInfo02, Function | SmallTest | Level3) +{ + int ret = 0; + ASSERT_NE(ssm_, nullptr); + std::vector recoveredPersistentIds; + recoveredPersistentIds.push_back(0); + recoveredPersistentIds.push_back(1); + SessionInfo info; + info.abilityName_ = "UpdateRecoveredSessionInfo02"; + info.bundleName_ = "SceneSessionManagerTest2"; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + ASSERT_NE(sceneSession, nullptr); + ssm_->failRecoveredPersistentIdSet_.insert(0); + ssm_->sceneSessionMap_.insert({1, sceneSession}); + ssm_->UpdateRecoveredSessionInfo(recoveredPersistentIds); + ssm_->failRecoveredPersistentIdSet_.erase(0); + ssm_->sceneSessionMap_.erase(1); + ASSERT_EQ(ret, 0); +} + +/** + * @tc.name: NotifyCreateSubSession + * @tc.desc: Test if createSubSessionFuncMap_ exist + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest2, NotifyCreateSubSession, Function | SmallTest | Level3) +{ + int ret = 0; + ASSERT_NE(ssm_, nullptr); + SessionInfo info; + info.abilityName_ = "NotifyCreateSubSession"; + info.bundleName_ = "SceneSessionManagerTest2"; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + ASSERT_NE(sceneSession, nullptr); + NotifyCreateSubSessionFunc func; + ssm_->createSubSessionFuncMap_.insert({1, func}); + ssm_->NotifyCreateSubSession(1, sceneSession, 256); + ssm_->createSubSessionFuncMap_.erase(1); + ASSERT_EQ(ret, 0); +} + /** * @tc.name: ConfigWindowSceneXml * @tc.desc: SceneSesionManager config window scene xml run @@ -2047,6 +2093,33 @@ HWTEST_F(SceneSessionManagerTest2, RecoverAndConnectSpecificSession, Function | ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); } +/** + * @tc.name: RecoverAndConnectSpecificSession02 + * @tc.desc: RecoverAndConnectSpecificSession02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest2, RecoverAndConnectSpecificSession02, Function | SmallTest | Level3) +{ + SessionInfo sessionInfo; + sessionInfo.abilityName_ = "RecoverAndConnectSpecificSession02"; + sessionInfo.bundleName_ = "SceneSessionManagerTest2"; + sessionInfo.windowType_ = static_cast(WindowType::APP_MAIN_WINDOW_END); + sptr property = new (std::nothrow) WindowSessionProperty(); + ASSERT_NE(property, nullptr); + property->SetSessionInfo(sessionInfo); + property->SetPersistentId(1); + property->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + sptr sessionStage; + sptr eventChannel; + std::shared_ptr surfaceNode; + sptr session; + sptr token; + ASSERT_NE(ssm_, nullptr); + auto result = ssm_->RecoverAndConnectSpecificSession(sessionStage, eventChannel, + surfaceNode, property, session, token); + ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); +} + /** * @tc.name: CacheSubSessionForRecovering * @tc.desc: CacheSubSessionForRecovering diff --git a/window_scene/test/unittest/scene_session_manager_test3.cpp b/window_scene/test/unittest/scene_session_manager_test3.cpp index 8a159b1da8..e10dbbfcce 100644 --- a/window_scene/test/unittest/scene_session_manager_test3.cpp +++ b/window_scene/test/unittest/scene_session_manager_test3.cpp @@ -1251,6 +1251,31 @@ HWTEST_F(SceneSessionManagerTest3, QueryAbilityInfoFromBMS, Function | SmallTest ASSERT_NE(sessionInfo_.want, nullptr); } +/** + * @tc.name: NotifyStartAbility + * @tc.desc: SceneSesionManager NotifyStartAbility + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest3, NotifyStartAbility, Function | SmallTest | Level3) +{ + SessionInfo sessionInfo; + sessionInfo.moduleName_ = "SceneSessionManagerTest"; + sessionInfo.bundleName_ = "SceneSessionManagerTest3"; + sessionInfo.abilityName_ = "NotifyStartAbility"; + sptr collaborator = + iface_cast(nullptr); + ssm_->collaboratorMap_.clear(); + ssm_->collaboratorMap_.insert(std::make_pair(1, collaborator)); + int32_t collaboratorType = 1; + auto ret1 = ssm_->NotifyStartAbility(collaboratorType, sessionInfo); + ASSERT_EQ(ret1, BrokerStates::BROKER_UNKOWN); + + sessionInfo.want = std::make_shared(); + auto ret2 = ssm_->NotifyStartAbility(collaboratorType, sessionInfo); + ASSERT_EQ(ret2, BrokerStates::BROKER_UNKOWN); + ssm_->collaboratorMap_.clear(); +} + /** * @tc.name: IsSessionClearable * @tc.desc: SceneSesionManager is session clearable diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index 1090be0c39..63c28938df 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -630,6 +631,27 @@ HWTEST_F(SceneSessionManagerTest4, UpdateSessionWindowVisibilityListener02, Func EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); } +/** + * @tc.name: UpdateDarkColorModeToRS + * @tc.desc: UpdateDarkColorModeToRS + * @tc.type: FUNC + * @tc.require: issueIB1N43 + */ +HWTEST_F(SceneSessionManagerTest4, UpdateDarkColorModeToRS, Function | SmallTest | Level3) +{ + ASSERT_NE(nullptr, ssm_); + AbilityRuntime::ApplicationContext::applicationContext_ = + std::make_shared(); + ASSERT_NE(nullptr, AbilityRuntime::ApplicationContext::applicationContext_); + AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_ = + std::make_shared(); + ASSERT_NE(nullptr, AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_); + AbilityRuntime::ApplicationContext::applicationContext_->contextImpl_->config_ = + std::make_shared(); + ASSERT_NE(nullptr, AbilityRuntime::ApplicationContext::applicationContext_->GetConfiguration()); + ssm_->UpdateDarkColorModeToRS(); +} + /** * @tc.name: NotifySessionAINavigationBarChange * @tc.desc: NotifySessionAINavigationBarChange diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index 8ffc00c86f..0e7d63c833 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -1730,6 +1730,11 @@ HWTEST_F(SceneSessionManagerTest5, RequestSceneSessionBackground03, Function | S sptr sceneSession = sptr::MakeSptr(info, nullptr); session->SetSessionInfoPersistentId(0); ssm_->RequestSceneSessionBackground(sceneSession, false, false, true); + + ssm_->sceneSessionMap_.clear(); + ssm_->sceneSessionMap_.insert({0, sceneSession}); + ssm_->RequestSceneSessionBackground(sceneSession, false, false, true); + ssm_->sceneSessionMap_.clear(); } /** diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index c78a6dfea9..612cf08060 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -405,6 +405,7 @@ HWTEST_F(SceneSessionManagerTest6, CheckWindowModeType, Function | SmallTest | L ASSERT_NE(nullptr, sceneSession->property_); sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); sceneSession->isVisible_ = false; + sceneSession->isRSVisible_ = false; sceneSession->state_ = SessionState::STATE_DISCONNECT; ASSERT_NE(nullptr, ssm_); ret = ssm_->CheckWindowModeType(); @@ -430,6 +431,7 @@ HWTEST_F(SceneSessionManagerTest6, CheckWindowModeType01, Function | SmallTest | sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); sceneSession->property_->SetDisplayId(displayId); sceneSession->isVisible_ = true; + sceneSession->isRSVisible_ = true; sceneSession->state_ = SessionState::STATE_ACTIVE; ASSERT_NE(nullptr, ssm_); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); @@ -444,6 +446,7 @@ HWTEST_F(SceneSessionManagerTest6, CheckWindowModeType01, Function | SmallTest | sceneSession1->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); sceneSession1->property_->SetDisplayId(displayId); sceneSession1->isVisible_ = true; + sceneSession1->isRSVisible_ = true; sceneSession1->state_ = SessionState::STATE_ACTIVE; ASSERT_NE(nullptr, ssm_); ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1)); @@ -477,6 +480,7 @@ HWTEST_F(SceneSessionManagerTest6, CheckWindowModeType02, Function | SmallTest | sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); sceneSession->property_->SetDisplayId(displayId); sceneSession->isVisible_ = true; + sceneSession->isRSVisible_ = true; sceneSession->state_ = SessionState::STATE_ACTIVE; ASSERT_NE(nullptr, ssm_); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); @@ -512,6 +516,7 @@ HWTEST_F(SceneSessionManagerTest6, CheckWindowModeType03, Function | SmallTest | sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); sceneSession->property_->SetDisplayId(displayId); sceneSession->isVisible_ = true; + sceneSession->isRSVisible_ = true; sceneSession->state_ = SessionState::STATE_ACTIVE; ASSERT_NE(nullptr, ssm_); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); @@ -519,6 +524,7 @@ HWTEST_F(SceneSessionManagerTest6, CheckWindowModeType03, Function | SmallTest | ASSERT_NE(nullptr, sceneSession->property_); sceneSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); sceneSession->isVisible_ = true; + sceneSession->isRSVisible_ = true; sceneSession->state_ = SessionState::STATE_ACTIVE; ASSERT_NE(nullptr, ssm_); auto ret = ssm_->CheckWindowModeType(); @@ -1065,43 +1071,91 @@ HWTEST_F(SceneSessionManagerTest6, CheckAndNotifyWaterMarkChangedResult02, Funct } /** - * @tc.name: FillWindowInfo - * @tc.desc: FillWindowInfo + * @tc.name: FillWindowInfo01 + * @tc.desc: FillWindowInfo01 * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest6, FillWindowInfo, Function | SmallTest | Level3) +HWTEST_F(SceneSessionManagerTest6, FillWindowInfo01, Function | SmallTest | Level3) { + ASSERT_NE(nullptr, ssm_); std::vector> infos; sptr sceneSession = nullptr; - ASSERT_NE(nullptr, ssm_); auto ret = ssm_->FillWindowInfo(infos, sceneSession); EXPECT_EQ(false, ret); SessionInfo sessionInfo; sessionInfo.bundleName_ = "SceneSessionManagerTest2"; - sessionInfo.abilityName_ = "DumpSessionWithId"; + sessionInfo.abilityName_ = "FillWindowInfo01"; sceneSession = sptr::MakeSptr(sessionInfo, nullptr); - ASSERT_NE(nullptr, ssm_); ASSERT_NE(nullptr, sceneSession); ret = ssm_->FillWindowInfo(infos, sceneSession); EXPECT_EQ(true, ret); + EXPECT_EQ(1, infos.size()); +} + +/** + * @tc.name: FillWindowInfo02 + * @tc.desc: FillWindowInfo02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, FillWindowInfo02, Function | SmallTest | Level3) +{ + ASSERT_NE(nullptr, ssm_); + std::vector> infos; + SessionInfo sessionInfo; sessionInfo.bundleName_ = "SCBGestureBack"; + sessionInfo.abilityName_ = "FillWindowInfo02"; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ASSERT_NE(nullptr, sceneSession); + auto ret = ssm_->FillWindowInfo(infos, sceneSession); + EXPECT_EQ(false, ret); + EXPECT_EQ(0, infos.size()); +} + +/** + * @tc.name: FillWindowInfo03 + * @tc.desc: FillWindowInfo03 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, FillWindowInfo03, Function | SmallTest | Level3) +{ + ASSERT_NE(nullptr, ssm_); + std::vector> infos; + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "SceneSessionManagerTest2"; + sessionInfo.abilityName_ = "FillWindowInfo03"; sessionInfo.isSystem_ = true; - ASSERT_NE(nullptr, ssm_); - ret = ssm_->FillWindowInfo(infos, sceneSession); + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ASSERT_NE(nullptr, sceneSession); + auto ret = ssm_->FillWindowInfo(infos, sceneSession); EXPECT_EQ(true, ret); - sessionInfo.isSystem_ = false; + EXPECT_EQ(1, infos.size()); + EXPECT_EQ(1, infos[0]->wid_); +} + +/** + * @tc.name: FillWindowInfo04 + * @tc.desc: FillWindowInfo04 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, FillWindowInfo04, Function | SmallTest | Level3) +{ ASSERT_NE(nullptr, ssm_); - ret = ssm_->FillWindowInfo(infos, sceneSession); + std::vector> infos; + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "SceneSessionManagerTest2"; + sessionInfo.abilityName_ = "FillWindowInfo04"; + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ASSERT_NE(nullptr, sceneSession); + sceneSession->property_->SetDisplayId(1); + auto ret = ssm_->FillWindowInfo(infos, sceneSession); EXPECT_EQ(true, ret); + EXPECT_EQ(1, infos.size()); + EXPECT_EQ(1, infos[0]->displayId_); sceneSession->property_ = nullptr; - ASSERT_NE(nullptr, ssm_); - ret = ssm_->FillWindowInfo(infos, sceneSession); - EXPECT_EQ(true, ret); - sceneSession->property_ = sptr::MakeSptr(); - ASSERT_NE(nullptr, sceneSession->property_); - ASSERT_NE(nullptr, ssm_); ret = ssm_->FillWindowInfo(infos, sceneSession); EXPECT_EQ(true, ret); + EXPECT_EQ(2, infos.size()); + EXPECT_NE(1, infos[1]->displayId_); } /** @@ -1615,7 +1669,7 @@ HWTEST_F(SceneSessionManagerTest6, RequestInputMethodCloseKeyboard, Function | S sptr session = new Session(info); session->property_ = nullptr; ssm_->RequestInputMethodCloseKeyboard(persistentId); - + bool enable = true; auto result = ssm_->GetFreeMultiWindowEnableState(enable); ASSERT_EQ(result, WSError::WS_OK); @@ -1716,6 +1770,37 @@ HWTEST_F(SceneSessionManagerTest6, DestroyDialogWithMainWindow, Function | Small ASSERT_EQ(result, WSError::WS_OK); } +/** + * @tc.name: DestroyDialogWithMainWindow02 + * @tc.desc: DestroyDialogWithMainWindow02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, DestroyDialogWithMainWindow02, Function | SmallTest | Level3) +{ + SessionInfo info; + sptr specificCallback = nullptr; + sptr scnSession = new (std::nothrow) SceneSession(info, specificCallback); + ASSERT_NE(scnSession, nullptr); + + sptr dialogSession1 = sptr::MakeSptr(info); + sptr dialogSession2 = sptr::MakeSptr(info); + ASSERT_NE(dialogSession1, nullptr); + ASSERT_NE(dialogSession2, nullptr); + dialogSession1->persistentId_ = 0; + dialogSession2->persistentId_ = 1; + scnSession->dialogVec_.push_back(dialogSession1); + scnSession->dialogVec_.push_back(dialogSession2); + + ASSERT_NE(ssm_, nullptr); + ssm_->sceneSessionMap_.clear(); + ssm_->sceneSessionMap_.insert({0, nullptr}); + ssm_->sceneSessionMap_.insert({0, scnSession}); + + auto ret = ssm_->DestroyDialogWithMainWindow(scnSession); + ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_SESSION); + ssm_->sceneSessionMap_.clear(); +} + /** * @tc.name: RequestSceneSessionDestruction * @tc.desc: RequestSceneSessionDestruction @@ -1789,7 +1874,7 @@ HWTEST_F(SceneSessionManagerTest6, GetProcessSurfaceNodeIdByPersistentId, Functi ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); ssm_->sceneSessionMap_.insert({sceneSession3->GetPersistentId(), sceneSession3}); - + ASSERT_EQ(WMError::WM_OK, ssm_->GetProcessSurfaceNodeIdByPersistentId(pid, persistentIds, surfaceNodeIds)); ASSERT_EQ(0, surfaceNodeIds.size()); } @@ -1942,6 +2027,141 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession, Function | SmallTest | L ssm_->FlushUIParams(screenId, std::move(uiParams)); } +/** + * @tc.name: CheckIfReuseSession02 + * @tc.desc: Test if CollaboratorType not exist and collaboratorMap_ not exist + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession02, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->bundleMgr_ = ssm_->GetBundleManager(); + ssm_->currentUserId_ = 123; + + SessionInfo sessionInfo; + sessionInfo.moduleName_ = "SceneSessionManager"; + sessionInfo.bundleName_ = "SceneSessionManagerTest6"; + sessionInfo.abilityName_ = "CheckIfReuseSession02"; + sessionInfo.want = std::make_shared(); + + SceneSessionManager::SessionInfoList list = { + .uid_ = 123, .bundleName_ = "SceneSessionManagerTest6", + .abilityName_ = "CheckIfReuseSession02", .moduleName_ = "SceneSessionManager" + }; + + std::shared_ptr abilityInfo = std::make_shared(); + ASSERT_NE(abilityInfo, nullptr); + ssm_->abilityInfoMap_[list] = abilityInfo; + auto ret1 = ssm_->CheckIfReuseSession(sessionInfo); + ASSERT_EQ(ret1, BrokerStates::BROKER_UNKOWN); + ssm_->abilityInfoMap_.erase(list); +} + +/** + * @tc.name: CheckIfReuseSession03 + * @tc.desc: Test if CollaboratorType is RESERVE_TYPE and collaboratorMap_ not exist + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession03, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->bundleMgr_ = ssm_->GetBundleManager(); + ssm_->currentUserId_ = 123; + + SessionInfo sessionInfo; + sessionInfo.moduleName_ = "SceneSessionManager"; + sessionInfo.bundleName_ = "SceneSessionManagerTest6"; + sessionInfo.abilityName_ = "CheckIfReuseSession03"; + sessionInfo.want = std::make_shared(); + + SceneSessionManager::SessionInfoList list = { + .uid_ = 123, .bundleName_ = "SceneSessionManagerTest6", + .abilityName_ = "CheckIfReuseSession03", .moduleName_ = "SceneSessionManager" + }; + + std::shared_ptr abilityInfo = std::make_shared(); + ASSERT_NE(abilityInfo, nullptr); + abilityInfo->applicationInfo.codePath = std::to_string(CollaboratorType::RESERVE_TYPE); + ssm_->abilityInfoMap_[list] = abilityInfo; + auto ret2 = ssm_->CheckIfReuseSession(sessionInfo); + ASSERT_EQ(ret2, BrokerStates::BROKER_UNKOWN); + ssm_->abilityInfoMap_.erase(list); +} + +/** + * @tc.name: CheckIfReuseSession04 + * @tc.desc: Test if CollaboratorType is RESERVE_TYPE and collaboratorMap_ exist + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession04, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->bundleMgr_ = ssm_->GetBundleManager(); + ssm_->currentUserId_ = 123; + + SessionInfo sessionInfo; + sessionInfo.moduleName_ = "SceneSessionManager"; + sessionInfo.bundleName_ = "SceneSessionManagerTest6"; + sessionInfo.abilityName_ = "CheckIfReuseSession04"; + sessionInfo.want = std::make_shared(); + + SceneSessionManager::SessionInfoList list = { + .uid_ = 123, .bundleName_ = "SceneSessionManagerTest6", + .abilityName_ = "CheckIfReuseSession04", .moduleName_ = "SceneSessionManager" + }; + + std::shared_ptr abilityInfo = std::make_shared(); + ASSERT_NE(abilityInfo, nullptr); + abilityInfo->applicationInfo.codePath = std::to_string(CollaboratorType::RESERVE_TYPE); + ssm_->abilityInfoMap_[list] = abilityInfo; + + sptr collaborator = + iface_cast(nullptr); + ssm_->collaboratorMap_.insert(std::make_pair(1, collaborator)); + + auto ret3 = ssm_->CheckIfReuseSession(sessionInfo); + ASSERT_EQ(ret3, BrokerStates::BROKER_UNKOWN); + ssm_->abilityInfoMap_.erase(list); + ssm_->collaboratorMap_.erase(1); +} + +/** + * @tc.name: CheckIfReuseSession05 + * @tc.desc: Test if CollaboratorType is OTHERS_TYPE and collaboratorMap_ exist + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession05, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + ssm_->bundleMgr_ = ssm_->GetBundleManager(); + ssm_->currentUserId_ = 123; + + SessionInfo sessionInfo; + sessionInfo.moduleName_ = "SceneSessionManager"; + sessionInfo.bundleName_ = "SceneSessionManagerTest6"; + sessionInfo.abilityName_ = "CheckIfReuseSession05"; + sessionInfo.want = std::make_shared(); + + SceneSessionManager::SessionInfoList list = { + .uid_ = 123, .bundleName_ = "SceneSessionManagerTest6", + .abilityName_ = "CheckIfReuseSession05", .moduleName_ = "SceneSessionManager" + }; + + std::shared_ptr abilityInfo = std::make_shared(); + ASSERT_NE(abilityInfo, nullptr); + abilityInfo->applicationInfo.codePath = std::to_string(CollaboratorType::OTHERS_TYPE); + ssm_->abilityInfoMap_[list] = abilityInfo; + + sptr collaborator = + iface_cast(nullptr); + ssm_->collaboratorMap_.insert(std::make_pair(1, collaborator)); + + auto ret4 = ssm_->CheckIfReuseSession(sessionInfo); + ASSERT_EQ(ret4, BrokerStates::BROKER_UNKOWN); + ssm_->abilityInfoMap_.erase(list); + ssm_->collaboratorMap_.erase(1); +} + /** * @tc.name: UpdateAvoidArea * @tc.desc: UpdateAvoidArea diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index cf4a860843..5d06dbda01 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -601,18 +601,16 @@ HWTEST_F(SceneSessionTest, IsDecorEnable, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); ASSERT_EQ(true, sceneSession->IsDecorEnable()); SessionInfo info_; info_.abilityName_ = "Background01"; info_.bundleName_ = "IsDecorEnable"; info_.windowType_ = 1000; - sptr sceneSession_; - sceneSession_ = new (std::nothrow) SceneSession(info_, nullptr); - EXPECT_NE(sceneSession_, nullptr); - ASSERT_EQ(false, sceneSession_->IsDecorEnable()); + sptr sceneSession1 = new (std::nothrow) SceneSession(info_, nullptr); + EXPECT_NE(sceneSession1, nullptr); + ASSERT_EQ(false, sceneSession1->IsDecorEnable()); } /** @@ -631,8 +629,7 @@ HWTEST_F(SceneSessionTest, IsDecorEnable01, Function | SmallTest | Level2) new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); sptr property = new (std::nothrow) WindowSessionProperty(); EXPECT_NE(property, nullptr); @@ -642,18 +639,17 @@ HWTEST_F(SceneSessionTest, IsDecorEnable01, Function | SmallTest | Level2) sceneSession->property_ = property; ASSERT_EQ(true, sceneSession->IsDecorEnable()); - sptr sceneSession_; - sceneSession_ = new (std::nothrow) SceneSession(info, nullptr); - EXPECT_NE(sceneSession_, nullptr); + sptr sceneSession1 = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession1, nullptr); property = new (std::nothrow) WindowSessionProperty(); EXPECT_NE(property, nullptr); property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); property->SetDecorEnable(false); property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - ASSERT_EQ(true, sceneSession_->IsDecorEnable()); + ASSERT_EQ(true, sceneSession1->IsDecorEnable()); - sceneSession_->SetSessionProperty(nullptr); - ASSERT_EQ(false, sceneSession_->IsDecorEnable()); + sceneSession1->SetSessionProperty(nullptr); + ASSERT_EQ(false, sceneSession1->IsDecorEnable()); } /** @@ -821,8 +817,7 @@ HWTEST_F(SceneSessionTest, NotifyIsCustomAnimationPlaying, Function | SmallTest EXPECT_NE(sceneSession, nullptr); sceneSession->NotifyIsCustomAnimationPlaying(false); - sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); - sceneSession->sessionChangeCallback_->onIsCustomAnimationPlaying_ = [](bool status){}; + sceneSession->onIsCustomAnimationPlaying_ = [](bool status) {}; sceneSession->NotifyIsCustomAnimationPlaying(false); } diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index 0a3d31faad..0dbc2656df 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -120,7 +120,6 @@ HWTEST_F(SceneSessionTest2, BindDialogSessionTarget, Function | SmallTest | Leve sptr property = new(std::nothrow) WindowSessionProperty(); property->SetWindowType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); - property->keyboardLayoutParams_.gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM; sceneSession->SetSessionProperty(property); @@ -149,8 +148,7 @@ HWTEST_F(SceneSessionTest2, NotifyPropertyWhenConnect1, Function | SmallTest | L sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); int ret = 1; std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_; @@ -292,8 +290,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent01, Function | SmallTest | Level sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + sptr sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); EXPECT_NE(sceneSession, nullptr); std::shared_ptr pointerEvent = nullptr; ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent), WSError::WS_ERROR_NULLPTR); @@ -344,8 +341,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent02, Function | SmallTest | Level sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + sptr sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); EXPECT_NE(sceneSession, nullptr); std::shared_ptr pointerEvent = nullptr; ASSERT_EQ(sceneSession->TransferPointerEvent(pointerEvent), WSError::WS_ERROR_NULLPTR); @@ -568,8 +564,7 @@ HWTEST_F(SceneSessionTest2, NotifyClientToUpdateRect01, Function | SmallTest | L sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); ASSERT_NE(mockSessionStage, nullptr); @@ -594,8 +589,7 @@ HWTEST_F(SceneSessionTest2, UpdateSizeChangeReason01, Function | SmallTest | Lev sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); ASSERT_NE(mockSessionStage, nullptr); @@ -719,8 +713,7 @@ HWTEST_F(SceneSessionTest2, SetScale, Function | SmallTest | Level2) new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); int resultValue = 0; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); sceneSession->SetScale(1.0f, 1.0f, 0.0f, 0.0f); ASSERT_EQ(0, resultValue); @@ -741,8 +734,7 @@ HWTEST_F(SceneSessionTest2, RequestHideKeyboard, Function | SmallTest | Level2) new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); int resultValue = 0; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); sceneSession->RequestHideKeyboard(); ASSERT_EQ(0, resultValue); @@ -776,8 +768,7 @@ HWTEST_F(SceneSessionTest2, UpdateAvoidArea, Function | SmallTest | Level2) SessionInfo info; info.abilityName_ = "UpdateAvoidArea"; info.bundleName_ = "UpdateAvoidArea"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession->sessionStage_ = nullptr; WSError result = sceneSession->UpdateAvoidArea(nullptr, AvoidAreaType::TYPE_SYSTEM); EXPECT_EQ(WSError::WS_ERROR_NULLPTR, result); @@ -966,8 +957,7 @@ HWTEST_F(SceneSessionTest2, SaveUpdatedIcon, Function | SmallTest | Level2) SessionInfo info; info.abilityName_ = "SaveUpdatedIcon"; info.bundleName_ = "SaveUpdatedIcon"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession->scenePersistence_ = new ScenePersistence("OpenHarmony", 1); EXPECT_NE(nullptr, sceneSession->scenePersistence_); @@ -984,8 +974,7 @@ HWTEST_F(SceneSessionTest2, NotifyTouchOutside, Function | SmallTest | Level2) SessionInfo info; info.abilityName_ = "NotifyTouchOutside"; info.bundleName_ = "NotifyTouchOutside"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession->sessionStage_ = new SessionStageMocker(); EXPECT_NE(nullptr, sceneSession->sessionStage_); @@ -1016,8 +1005,7 @@ HWTEST_F(SceneSessionTest2, CheckOutTouchOutsideRegister, Function | SmallTest | SessionInfo info; info.abilityName_ = "CheckOutTouchOutsideRegister"; info.bundleName_ = "CheckOutTouchOutsideRegister"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); EXPECT_NE(nullptr, sceneSession->sessionChangeCallback_); @@ -1047,8 +1035,7 @@ HWTEST_F(SceneSessionTest2, UpdateRotationAvoidArea, Function | SmallTest | Leve SessionInfo info; info.abilityName_ = "UpdateRotationAvoidArea"; info.bundleName_ = "UpdateRotationAvoidArea"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession->specificCallback_ = new SceneSession::SpecificSessionCallback(); EXPECT_NE(nullptr, sceneSession->specificCallback_); auto func = [sceneSession](const int32_t& persistentId) { @@ -1076,12 +1063,10 @@ HWTEST_F(SceneSessionTest2, NotifyForceHideChange, Function | SmallTest | Level2 SessionInfo info; info.abilityName_ = "NotifyForceHideChange"; info.bundleName_ = "NotifyForceHideChange"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession->NotifyForceHideChange(true); - sptr session; - session = new (std::nothrow) Session(info); + sptr session = new (std::nothrow) Session(info); sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); auto func = [sceneSession](bool hide) { sceneSession->SetPrivacyMode(hide); @@ -1105,8 +1090,7 @@ HWTEST_F(SceneSessionTest2, RegisterSessionChangeCallback, Function | SmallTest SessionInfo info; info.abilityName_ = "RegisterSessionChangeCallback"; info.bundleName_ = "RegisterSessionChangeCallback"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sptr callback = new SceneSession::SessionChangeCallback(); EXPECT_NE(nullptr, callback); sceneSession->RegisterSessionChangeCallback(callback); @@ -1122,8 +1106,7 @@ HWTEST_F(SceneSessionTest2, ClearSpecificSessionCbMap, Function | SmallTest | Le SessionInfo info; info.abilityName_ = "ClearSpecificSessionCbMap"; info.bundleName_ = "ClearSpecificSessionCbMap"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(nullptr, sceneSession); sceneSession->ClearSpecificSessionCbMap(); } @@ -1138,8 +1121,7 @@ HWTEST_F(SceneSessionTest2, SendPointerEventToUI, Function | SmallTest | Level2) SessionInfo info; info.abilityName_ = "SendPointerEventToUI"; info.bundleName_ = "SendPointerEventToUI"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(nullptr, sceneSession); auto pointerEventFunc = [sceneSession](std::shared_ptr pointerEvent) { sceneSession->NotifyOutsideDownEvent(pointerEvent); @@ -1161,8 +1143,7 @@ HWTEST_F(SceneSessionTest2, SetFloatingScale, Function | SmallTest | Level2) SessionInfo info; info.abilityName_ = "SetFloatingScale"; info.bundleName_ = "SetFloatingScale"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession->specificCallback_ = new SceneSession::SpecificSessionCallback(); auto windowInfoUpdateFun = [sceneSession](int32_t persistentId, WindowUpdateType type) { if (WindowUpdateType::WINDOW_UPDATE_PROPERTY == type) { @@ -1198,8 +1179,7 @@ HWTEST_F(SceneSessionTest2, ProcessPointDownSession, Function | SmallTest | Leve SessionInfo info; info.abilityName_ = "ProcessPointDownSession"; info.bundleName_ = "ProcessPointDownSession"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession->specificCallback_ = new SceneSession::SpecificSessionCallback(); EXPECT_NE(nullptr, sceneSession->specificCallback_); auto sessionTouchOutsideFun = [sceneSession](int32_t persistentId) { @@ -1402,8 +1382,7 @@ HWTEST_F(SceneSessionTest2, ClearSpecificSessionCbMap01, Function | SmallTest | SessionInfo info; info.abilityName_ = "ClearSpecificSessionCbMap01"; info.bundleName_ = "ClearSpecificSessionCbMap01"; - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(nullptr, sceneSession); sptr session; session = new (std::nothrow) Session(info); @@ -1716,7 +1695,6 @@ HWTEST_F(SceneSessionTest2, OnMoveDragCallback01, Function | SmallTest | Level2) sceneSession->SetSystemSceneOcclusionAlpha(alpha); sceneSession->IsNeedDefaultAnimation(); bool isPlaying = true; - sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); sceneSession->NotifyIsCustomAnimationPlaying(isPlaying); sptr abilitySessionInfo = nullptr; @@ -1852,8 +1830,7 @@ HWTEST_F(SceneSessionTest2, GetShowWhenLockedFlagValue, Function | SmallTest | L sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr sceneSession; - sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); + sptr sceneSession = new (std::nothrow) SceneSession(info, specificCallback_); EXPECT_NE(sceneSession, nullptr); sptr property = new WindowSessionProperty(); EXPECT_NE(property, nullptr); diff --git a/window_scene/test/unittest/scene_session_test3.cpp b/window_scene/test/unittest/scene_session_test3.cpp index c0941e42a7..acd30fb49e 100644 --- a/window_scene/test/unittest/scene_session_test3.cpp +++ b/window_scene/test/unittest/scene_session_test3.cpp @@ -753,6 +753,24 @@ HWTEST_F(SceneSessionTest3, CompatibleFullScreenRecover, Function | SmallTest | ASSERT_EQ(WSError::WS_OK, sceneSession->CompatibleFullScreenRecover()); } +/** + * @tc.name: SetIsMidScene + * @tc.desc: SetIsMidScene + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest3, SetIsMidScene, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "SetIsMidScene"; + info.bundleName_ = "SetIsMidScene"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + + sceneSession->SetIsMidScene(true); + bool res = sceneSession->GetIsMidScene(); + EXPECT_EQ(res, true); +} + /** * @tc.name: SetIsPcAppInPad * @tc.desc: SetIsPcAppInPad diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index d9ad6e166c..02dbf5ec80 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -171,10 +171,6 @@ HWTEST_F(SceneSessionTest4, HandleActionUpdateDragenabled, Function | SmallTest session.property_ = property; WMError res = sceneSession->HandleActionUpdateDragenabled(property, action); - ASSERT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, res); - - session.property_->SetSystemCalling(true); - res = sceneSession->HandleActionUpdateDragenabled(property, action); ASSERT_EQ(WMError::WM_OK, res); } diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 8eabcf3664..793cbb40fb 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -401,19 +401,27 @@ HWTEST_F(SceneSessionTest5, OnLayoutFullScreenChange, Function | SmallTest | Lev info.bundleName_ = "OnLayoutFullScreenChange"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); + NotifyLayoutFullScreenChangeFunc func = [](bool isLayoutFullScreen) {}; + session->onLayoutFullScreenChangeFunc_ = func; EXPECT_EQ(WSError::WS_OK, session->OnLayoutFullScreenChange(true)); +} - sptr sessionChangeCallback = - sptr::MakeSptr(); - session->RegisterSessionChangeCallback(sessionChangeCallback); - sessionChangeCallback->onLayoutFullScreenChangeFunc_ = nullptr; - EXPECT_EQ(WSError::WS_OK, session->OnLayoutFullScreenChange(true)); +/** + * @tc.name: RegisterLayoutFullScreenChangeCallback + * @tc.desc: test RegisterLayoutFullScreenChangeCallback + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest5, RegisterLayoutFullScreenChangeCallback, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "RegisterLayoutFullScreenChangeCallback"; + info.bundleName_ = "RegisterLayoutFullScreenChangeCallback"; + sptr sceneSession = new SceneSession(info, nullptr); + sceneSession->onLayoutFullScreenChangeFunc_ = nullptr; + NotifyLayoutFullScreenChangeFunc func = [](bool isLayoutFullScreen) {}; - NotifyLayoutFullScreenChangeFunc func = [](bool isLayoutFullScreen) { - return; - }; - sessionChangeCallback->onLayoutFullScreenChangeFunc_ = func; - EXPECT_EQ(WSError::WS_OK, session->OnLayoutFullScreenChange(true)); + sceneSession->RegisterLayoutFullScreenChangeCallback(std::move(func)); + ASSERT_NE(sceneSession->onLayoutFullScreenChangeFunc_, nullptr); } /** diff --git a/window_scene/test/unittest/session_lifecycle_test.cpp b/window_scene/test/unittest/session_lifecycle_test.cpp index b5178ae384..2f94437742 100644 --- a/window_scene/test/unittest/session_lifecycle_test.cpp +++ b/window_scene/test/unittest/session_lifecycle_test.cpp @@ -70,6 +70,7 @@ private: void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override {} void OnDrawingCompleted() override {} + void OnAppRemoveStartingWindow() override {} }; std::shared_ptr lifecycleListener_ = std::make_shared(); }; diff --git a/window_scene/test/unittest/session_proxy_lifecycle_test.cpp b/window_scene/test/unittest/session_proxy_lifecycle_test.cpp index fb38ab17d7..a1448c2582 100644 --- a/window_scene/test/unittest/session_proxy_lifecycle_test.cpp +++ b/window_scene/test/unittest/session_proxy_lifecycle_test.cpp @@ -110,6 +110,23 @@ HWTEST_F(SessionProxyLifecycleTest, DrawingCompleted, Function | SmallTest | Lev GTEST_LOG_(INFO) << "SessionProxyLifecycleTest: DrawingCompleted end"; } +/** + * @tc.name: RemoveStartingWindow + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(SessionProxyLifecycleTest, RemoveStartingWindow, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "SessionProxyLifecycleTest: RemoveStartingWindow start"; + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + ASSERT_NE(iRemoteObjectMocker, nullptr); + sptr sProxy = new (std::nothrow) SessionProxy(iRemoteObjectMocker); + ASSERT_NE(sProxy, nullptr); + WSError res = sProxy->RemoveStartingWindow(); + ASSERT_EQ(res, WSError::WS_OK); + GTEST_LOG_(INFO) << "SessionProxyLifecycleTest: RemoveStartingWindow end"; +} + /** * @tc.name: PendingSessionActivation * @tc.desc: normal function diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index 3cceb0c70c..d51249fcab 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -226,6 +226,9 @@ HWTEST_F(SessionStubTest, ProcessRemoteRequestTest03, Function | SmallTest | Lev res = session_->ProcessRemoteRequest( static_cast(SessionInterfaceCode::TRANS_ID_DRAWING_COMPLETED), data, reply, option); ASSERT_EQ(ERR_NONE, res); + res = session_->ProcessRemoteRequest( + static_cast(SessionInterfaceCode::TRANS_ID_APP_REMOVE_STARTING_WINDOW), data, reply, option); + ASSERT_EQ(ERR_NONE, res); res = session_->ProcessRemoteRequest( static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_RECTCHANGE_LISTENER_REGISTERED), data, @@ -743,7 +746,7 @@ HWTEST_F(SessionStubTest, HandleSetDialogSessionBackGestureEnabled01, Function | /** * @tc.name: HandleUpdatePropertyByAction01 - * @tc.desc: sessionStub sessionStubTest + * @tc.desc: No error * @tc.type: FUNC * @tc.require: #I6JLSI */ @@ -759,7 +762,7 @@ HWTEST_F(SessionStubTest, HandleUpdatePropertyByAction01, Function | SmallTest | /** * @tc.name: HandleUpdatePropertyByAction02 - * @tc.desc: sessionStub sessionStubTest + * @tc.desc: Invalid data * @tc.type: FUNC * @tc.require: #I6JLSI */ @@ -774,6 +777,21 @@ HWTEST_F(SessionStubTest, HandleUpdatePropertyByAction02, Function | SmallTest | ASSERT_EQ(ERR_INVALID_DATA, res); } +/** + * @tc.name: HandleUpdatePropertyByAction03 + * @tc.desc: No action + * @tc.type: FUNC + * @tc.require: #I6JLSI + */ +HWTEST_F(SessionStubTest, HandleUpdatePropertyByAction03, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + ASSERT_NE(session_, nullptr); + auto res = session_->HandleUpdatePropertyByAction(data, reply); + ASSERT_EQ(ERR_INVALID_DATA, res); +} + /** * @tc.name: HandleRequestFocus * @tc.desc: sessionStub HandleRequestFocusTest diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index e04d7e8df4..8152e89e31 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -68,6 +68,7 @@ private: void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override {} void OnDrawingCompleted() override {} + void OnAppRemoveStartingWindow() override {} }; std::shared_ptr lifecycleListener_ = std::make_shared(); diff --git a/window_scene/test/unittest/session_test2.cpp b/window_scene/test/unittest/session_test2.cpp index 1a071e4652..65a4714a4e 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -70,6 +70,7 @@ private: void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override {} void OnDrawingCompleted() override {} + void OnAppRemoveStartingWindow() override {} }; std::shared_ptr lifecycleListener_ = std::make_shared(); @@ -1433,6 +1434,18 @@ HWTEST_F(WindowSessionTest2, DrawingCompleted, Function | SmallTest | Level2) ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); } +/** + * @tc.name: RemoveStartingWindow + * @tc.desc: RemoveStartingWindow + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest2, RemoveStartingWindow, Function | SmallTest | Level2) +{ + ASSERT_NE(session_, nullptr); + auto result = session_->RemoveStartingWindow(); + ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); +} + /** * @tc.name: IsSystemActive * @tc.desc: IsSystemActive diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index 02816f0ddd..75bc98f148 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -1193,18 +1193,6 @@ HWTEST_F(WindowSessionTest3, SetCompatibleModeEnableInPad, Function | SmallTest ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeEnableInPad(enable)); } -/** - * @tc.name: RectSizeCheckProcess01 - * @tc.desc: RectSizeCheckProcess Test - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionTest3, RectSizeCheckProcess01, Function | SmallTest | Level2) -{ - session_->SetSessionProperty(nullptr); - session_->RectSizeCheckProcess(1, 1, 2, 2, 0); - ASSERT_EQ(session_->property_, nullptr); -} - /** * @tc.name: GetSurfaceNodeForMoveDrag * @tc.desc: GetSurfaceNodeForMoveDrag Test @@ -1306,7 +1294,7 @@ HWTEST_F(WindowSessionTest3, GetSnapshotPixelMap, Function | SmallTest | Level2) HWTEST_F(WindowSessionTest3, ResetDirtyFlags, Function | SmallTest | Level2) { session_->isVisible_ = false; - session_->dirtyFlags_ = 64; + session_->dirtyFlags_ = 96; session_->ResetDirtyFlags(); EXPECT_EQ(64, session_->dirtyFlags_); @@ -1349,6 +1337,23 @@ HWTEST_F(WindowSessionTest3, SetMainSessionUIStateDirty, Function | SmallTest | session_->SetMainSessionUIStateDirty(true); EXPECT_EQ(true, sessionUIState->GetUIStateDirty()); } + +/** + * @tc.name: SetStartingBeforeVisible + * @tc.desc: test SetStartingBeforeVisible + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest3, SetStartingBeforeVisible, Function | SmallTest | Level2) +{ + ASSERT_NE(session_, nullptr); + session_->SetStartingBeforeVisible(true); + ASSERT_EQ(true, session_->isStartingBeforeVisible_); + ASSERT_EQ(true, session_->GetStartingBeforeVisible()); + + session_->SetStartingBeforeVisible(false); + ASSERT_EQ(false, session_->isStartingBeforeVisible_); + ASSERT_EQ(false, session_->GetStartingBeforeVisible()); +} } } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 7940d9191c..f3fcb69d38 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -536,7 +536,8 @@ HWTEST_F(WindowSessionPropertyTest, CopyFrom, Function | SmallTest | Level2) */ HWTEST_F(WindowSessionPropertyTest, SetFocusable, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetFocusable(), true); property->SetFocusable(false); ASSERT_EQ(property->GetFocusable(), false); @@ -549,7 +550,8 @@ HWTEST_F(WindowSessionPropertyTest, SetFocusable, Function | SmallTest | Level2) */ HWTEST_F(WindowSessionPropertyTest, SetTouchable, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetTouchable(), true); property->SetTouchable(false); ASSERT_EQ(property->GetTouchable(), false); @@ -562,7 +564,8 @@ HWTEST_F(WindowSessionPropertyTest, SetTouchable, Function | SmallTest | Level2) */ HWTEST_F(WindowSessionPropertyTest, SetForceHide, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetForceHide(), false); property->SetForceHide(true); ASSERT_EQ(property->GetForceHide(), true); @@ -575,7 +578,8 @@ HWTEST_F(WindowSessionPropertyTest, SetForceHide, Function | SmallTest | Level2) */ HWTEST_F(WindowSessionPropertyTest, SetSystemCalling, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetSystemCalling(), false); property->SetSystemCalling(true); ASSERT_EQ(property->GetSystemCalling(), true); @@ -588,7 +592,8 @@ HWTEST_F(WindowSessionPropertyTest, SetSystemCalling, Function | SmallTest | Lev */ HWTEST_F(WindowSessionPropertyTest, SetIsNeedUpdateWindowMode, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetIsNeedUpdateWindowMode(), false); property->SetIsNeedUpdateWindowMode(true); ASSERT_EQ(property->GetIsNeedUpdateWindowMode(), true); @@ -601,7 +606,8 @@ HWTEST_F(WindowSessionPropertyTest, SetIsNeedUpdateWindowMode, Function | SmallT */ HWTEST_F(WindowSessionPropertyTest, SetIsShaped, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetIsShaped(), false); property->SetIsShaped(true); ASSERT_EQ(property->GetIsShaped(), true); @@ -614,7 +620,8 @@ HWTEST_F(WindowSessionPropertyTest, SetIsShaped, Function | SmallTest | Level2) */ HWTEST_F(WindowSessionPropertyTest, SetHideNonSystemFloatingWindows, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetHideNonSystemFloatingWindows(), false); property->SetHideNonSystemFloatingWindows(true); ASSERT_EQ(property->GetHideNonSystemFloatingWindows(), true); @@ -627,7 +634,8 @@ HWTEST_F(WindowSessionPropertyTest, SetHideNonSystemFloatingWindows, Function | */ HWTEST_F(WindowSessionPropertyTest, KeepKeyboardOnFocus, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetKeepKeyboardFlag(), false); property->KeepKeyboardOnFocus(true); ASSERT_EQ(property->GetKeepKeyboardFlag(), true); @@ -640,7 +648,8 @@ HWTEST_F(WindowSessionPropertyTest, KeepKeyboardOnFocus, Function | SmallTest | */ HWTEST_F(WindowSessionPropertyTest, SetTextFieldPositionY, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); property->SetTextFieldPositionY(5.5); ASSERT_EQ(property->GetTextFieldPositionY(), 5.5); } @@ -652,7 +661,8 @@ HWTEST_F(WindowSessionPropertyTest, SetTextFieldPositionY, Function | SmallTest */ HWTEST_F(WindowSessionPropertyTest, SetTextFieldHeight, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); property->SetTextFieldHeight(5.5); ASSERT_EQ(property->GetTextFieldHeight(), 5.5); } @@ -664,7 +674,8 @@ HWTEST_F(WindowSessionPropertyTest, SetTextFieldHeight, Function | SmallTest | L */ HWTEST_F(WindowSessionPropertyTest, SetIsLayoutFullScreen, Function | SmallTest | Level2) { - WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty(); + sptr property = new WindowSessionProperty(); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->IsLayoutFullScreen(), false); property->SetIsLayoutFullScreen(true); ASSERT_EQ(property->IsLayoutFullScreen(), true); @@ -753,7 +764,6 @@ HWTEST_F(WindowSessionPropertyTest, Write, Function | SmallTest | Level2) property->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO); ASSERT_EQ(property->GetPersistentId(), INVALID_SESSION_ID); } - /** * @tc.name: GetWindowName * @tc.desc: GetWindowName @@ -952,6 +962,35 @@ HWTEST_F(WindowSessionPropertyTest, SetKeepScreenOn, Function | SmallTest | Leve ASSERT_EQ(keepScreenOn, property->IsKeepScreenOn()); } +/** + * @tc.name: MarshallingSessionInfo + * @tc.desc: MarshallingSessionInfo test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionPropertyTest, MarshallingSessionInfo, Function | SmallTest | Level2) +{ + Parcel parcel; + SessionInfo info = { "testBundleName", "testModuleName", "testAbilityName" }; + info.want = std::make_shared(); + sptr property = sptr::MakeSptr(); + bool result = property->MarshallingSessionInfo(parcel); + ASSERT_EQ(result, true); +} + +/** + * @tc.name: UnMarshallingSessionInfo + * @tc.desc: UnMarshallingSessionInfo test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionPropertyTest, UnMarshallingSessionInfo, Function | SmallTest | Level2) +{ + Parcel parcel; + WindowSessionProperty windowSessionProperty; + sptr property = sptr::MakeSptr(); + windowSessionProperty.UnmarshallingWindowLimits(parcel, property); + ASSERT_EQ(property->GetTokenState(), false); +} + /** * @tc.name: SetAccessTokenId * @tc.desc: SetAccessTokenId @@ -1082,35 +1121,6 @@ HWTEST_F(WindowSessionPropertyTest, MarshallingPiPTemplateInfo, Function | Small delete property; } -/** - * @tc.name: MarshallingSessionInfo - * @tc.desc: MarshallingSessionInfo test - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionPropertyTest, MarshallingSessionInfo, Function | SmallTest | Level2) -{ - Parcel parcel; - SessionInfo info = { "testBundleName", "testModuleName", "testAbilityName" }; - info.want = std::make_shared(); - sptr property = sptr::MakeSptr(); - bool result = property->MarshallingSessionInfo(parcel); - ASSERT_EQ(result, true); -} - -/** - * @tc.name: UnMarshallingSessionInfo - * @tc.desc: UnMarshallingSessionInfo test - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionPropertyTest, UnMarshallingSessionInfo, Function | SmallTest | Level2) -{ - Parcel parcel; - WindowSessionProperty windowSessionProperty; - sptr property = sptr::MakeSptr(); - windowSessionProperty.UnmarshallingWindowLimits(parcel, property); - ASSERT_EQ(property->GetTokenState(), false); -} - /** * @tc.name: SetIsPcAppInPad/GetIsPcAppInPad * @tc.desc: SetIsPcAppInPad/GetIsPcAppInPad diff --git a/wm/BUILD.gn b/wm/BUILD.gn index 0da8a8deb0..3aff9a98f8 100644 --- a/wm/BUILD.gn +++ b/wm/BUILD.gn @@ -119,6 +119,7 @@ ohos_static_library("libwm_static") { "ace_engine:ace_uicontent", "ace_engine:ace_xcomponent_controller", "bundle_framework:appexecfwk_core", + "bundle_framework:libappexecfwk_common", "c_utils:utils", "eventhandler:libeventhandler", "graphic_2d:librender_service_client", @@ -255,8 +256,10 @@ ohos_shared_library("libwm") { "ace_engine:ace_uicontent", "ace_engine:ace_xcomponent_controller", "bundle_framework:appexecfwk_core", + "bundle_framework:libappexecfwk_common", "c_utils:utils", "eventhandler:libeventhandler", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "graphic_2d:window_animation", "hilog:libhilog", @@ -427,6 +430,7 @@ ohos_shared_library("libwm_ndk") { "hilog:libhilog", "input:libmmi-client", "input:oh_input_manager", + "ipc:ipc_core", ] part_name = "window_manager" diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 556a2855d7..9e476a0ade 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -31,6 +31,7 @@ public: WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WMError Destroy(bool needNotifyServer, bool needClearListener = true) override; WMError NotifyDrawingCompleted() override; + WMError NotifyRemoveStartingWindow() override; WMError SetTextFieldAvoidInfo(double textFieldPositionY, double textFieldHeight) override; void PreProcessCreate(); void SetDefaultProperty(); diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 7382e931a7..86a0b70f48 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -255,6 +255,7 @@ public: WMError SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) override; virtual WMError SetSubWindowModal(bool isModal, ModalityType modalityType = ModalityType::WINDOW_MODALITY) override; virtual WMError SetDecorVisible(bool isVisible) override; + virtual WMError SetWindowTitleMoveEnabled(bool enable) override; virtual WMError SetDecorHeight(int32_t decorHeight) override; virtual WMError GetDecorHeight(int32_t& height) override; virtual WMError GetTitleButtonArea(TitleButtonRect& titleButtonRect) override; @@ -417,6 +418,7 @@ protected: */ void FlushLayoutSize(int32_t width, int32_t height) override; sptr layoutCallback_ = nullptr; + void UpdateVirtualPixelRatio(const sptr& display); WMError GetVirtualPixelRatio(float& vpr); private: @@ -481,6 +483,8 @@ private: const SceneAnimationConfig& config); void UpdateRectForOtherReason(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason, const std::shared_ptr& rsTransaction = nullptr); + void UpdateRectForOtherReasonTask(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason, + const std::shared_ptr& rsTransaction); void NotifyRotationAnimationEnd(); void SubmitNoInteractionMonitorTask(int32_t eventId, const IWindowNoInteractionListenerSptr& listener); bool IsUserOrientation(Orientation orientation) const; @@ -548,7 +552,7 @@ private: /* * Window Layout */ - std::atomic_bool windowSizeChanged_ = true; + WSRect layoutRect_; std::atomic_bool enableFrameLayoutFinishCb_ = false; WindowSizeChangeReason lastSizeChangeReason_ = WindowSizeChangeReason::END; bool postTaskDone_ = false; diff --git a/wm/src/pattern_detach_callback.cpp b/wm/src/pattern_detach_callback.cpp index ccc4d7be8f..60d0388e59 100644 --- a/wm/src/pattern_detach_callback.cpp +++ b/wm/src/pattern_detach_callback.cpp @@ -15,8 +15,6 @@ #include "pattern_detach_callback.h" -#include "window_manager_hilog.h" - namespace OHOS { namespace Rosen { diff --git a/wm/src/screen_scene.cpp b/wm/src/screen_scene.cpp index ecaf35a358..81b8cfb948 100644 --- a/wm/src/screen_scene.cpp +++ b/wm/src/screen_scene.cpp @@ -50,19 +50,23 @@ ScreenScene::~ScreenScene() WMError ScreenScene::Destroy() { - if (!uiContent_) { - TLOGD(WmsLogTag::DMS, "Destroy uiContent_ is nullptr!"); - return WMError::WM_OK; - } - std::shared_ptr uiContent = std::move(uiContent_); - uiContent_ = nullptr; - vsyncStation_->Destroy(); - auto task = [uiContent]() { - if (uiContent != nullptr) { - uiContent->Destroy(); - TLOGD(WmsLogTag::DMS, "ScreenScene: uiContent destroy success!"); + std::function task; //延长task的生命周期 + { + std::lock_guard lock(mutex_); + if (!uiContent_) { + TLOGD(WmsLogTag::DMS, "Destroy uiContent_ is nullptr!"); + return WMError::WM_OK; } - }; + std::shared_ptr uiContent = std::move(uiContent_); + uiContent_ = nullptr; + vsyncStation_->Destroy(); + task = [uiContent]() { + if (uiContent != nullptr) { + uiContent->Destroy(); + TLOGD(WmsLogTag::DMS, "ScreenScene: uiContent destroy success!"); + } + }; + } if (handler_) { handler_->PostSyncTask(task, "ScreenScene:Destroy"); } else { @@ -82,6 +86,7 @@ void ScreenScene::LoadContent(const std::string& contentUrl, napi_env env, napi_ TLOGE(WmsLogTag::DMS, "context is nullptr!"); return; } + std::lock_guard lock(mutex_); uiContent_ = Ace::UIContent::Create(context, reinterpret_cast(env)); if (uiContent_ == nullptr) { TLOGE(WmsLogTag::DMS, "uiContent_ is nullptr!"); @@ -99,6 +104,7 @@ void ScreenScene::UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason TLOGI(WmsLogTag::DMS, "ScreenScene has been destructed!"); return; } + std::lock_guard lock(mutex_); if (uiContent_ == nullptr) { TLOGE(WmsLogTag::DMS, "uiContent_ is nullptr!"); return; @@ -117,6 +123,7 @@ void ScreenScene::UpdateConfiguration(const std::shared_ptr lock(mutex_); if (uiContent_) { TLOGD(WmsLogTag::DMS, "notify root scene ace"); uiContent_->UpdateConfiguration(configuration); @@ -145,6 +152,7 @@ void ScreenScene::OnBundleUpdated(const std::string& bundleName) return; } TLOGD(WmsLogTag::DMS, "bundle %{public}s updated", bundleName.c_str()); + std::lock_guard lock(mutex_); if (uiContent_) { uiContent_->UpdateResource(); } @@ -157,6 +165,7 @@ void ScreenScene::SetFrameLayoutFinishCallback(std::function&& callback) return; } frameLayoutFinishCb_ = callback; + std::lock_guard lock(mutex_); if (uiContent_) { uiContent_->SetFrameLayoutFinishCallback(std::move(frameLayoutFinishCb_)); frameLayoutFinishCb_ = nullptr; diff --git a/wm/src/window_adapter_lite.cpp b/wm/src/window_adapter_lite.cpp index 5bdde3dd31..5fa81be473 100644 --- a/wm/src/window_adapter_lite.cpp +++ b/wm/src/window_adapter_lite.cpp @@ -298,7 +298,6 @@ WMError WindowAdapterLite::TerminateSessionByPersistentId(int32_t persistentId) WMError WindowAdapterLite::CloseTargetFloatWindow(const std::string& bundleName) { INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); - auto wmsProxy = GetWindowManagerServiceProxy(); CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR); return wmsProxy->CloseTargetFloatWindow(bundleName); diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 98e54cbfa7..56590c6449 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -686,7 +686,7 @@ WMError WindowImpl::SetUIContentInner(const std::string& contentInfo, napi_env e float WindowImpl::GetVirtualPixelRatio() { - float vpr = 0.0f; // This is an abnormal value, which is used to identify abnormal scenarios. + float vpr = 1.0f; // This is an abnormal value, which is used to identify abnormal scenarios. auto display = SingletonContainer::IsDestroyed() ? nullptr : SingletonContainer::Get().GetDisplayById(property_->GetDisplayId()); if (display == nullptr) { diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 4376b9522c..d1853b2f40 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1069,6 +1069,7 @@ void WindowSceneSessionImpl::PreLayoutOnShow(WindowType type, const sptrSetWindowRect(requestRect); hostSession->UpdateClientRect(wsRect); } else { TLOGE(WmsLogTag::DEFAULT, "hostSession is null"); @@ -1259,6 +1260,23 @@ WMError WindowSceneSessionImpl::NotifyDrawingCompleted() return res; } +WMError WindowSceneSessionImpl::NotifyRemoveStartingWindow() +{ + if (IsWindowSessionInvalid()) { + TLOGE(WmsLogTag::WMS_LIFE, "session is invalid, id:%{public}d", GetPersistentId()); + return WMError::WM_ERROR_INVALID_WINDOW; + } + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_INVALID_WINDOW); + WMError res = WindowHelper::IsMainWindow(GetType()) ? + static_cast(hostSession->RemoveStartingWindow()) : + WMError::WM_ERROR_INVALID_WINDOW; + if (res == WMError::WM_OK) { + TLOGI(WmsLogTag::WMS_LIFE, "success id:%{public}d", GetPersistentId()); + } + return res; +} + void WindowSceneSessionImpl::UpdateSubWindowState(const WindowType& type) { UpdateSubWindowStateAndNotify(GetPersistentId(), WindowState::STATE_HIDDEN); @@ -1326,7 +1344,7 @@ WMError WindowSceneSessionImpl::DestroyInner(bool needNotifyServer) if (WindowHelper::IsSystemWindow(GetType())) { // main window no need to notify host, since host knows hide first ret = SyncDestroyAndDisconnectSpecificSession(property_->GetPersistentId()); - } else if (WindowHelper::IsSubWindow(GetType()) && property_->GetIsUIExtFirstSubWindow()) { + } else if (WindowHelper::IsSubWindow(GetType()) && !property_->GetIsUIExtFirstSubWindow()) { auto parentSession = FindParentSessionByParentId(GetParentId()); if (parentSession == nullptr || parentSession->GetHostSession() == nullptr) { return WMError::WM_ERROR_NULLPTR; @@ -2334,6 +2352,9 @@ WMError WindowSceneSessionImpl::Recover() WLOGFW("Recover fail, already MODE_RECOVER"); return WMError::WM_ERROR_REPEAT_OPERATION; } + enableImmersiveMode_ = false; + property_->SetIsLayoutFullScreen(enableImmersiveMode_); + hostSession->OnLayoutFullScreenChange(enableImmersiveMode_); hostSession->OnSessionEvent(SessionEvent::EVENT_RECOVER); SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); property_->SetMaximizeMode(MaximizeMode::MODE_RECOVER); @@ -2396,6 +2417,9 @@ WMError WindowSceneSessionImpl::Recover(uint32_t reason) WLOGFW("Recover fail, already MODE_RECOVER"); return WMError::WM_ERROR_REPEAT_OPERATION; } + enableImmersiveMode_ = false; + property_->SetIsLayoutFullScreen(enableImmersiveMode_); + hostSession->OnLayoutFullScreenChange(enableImmersiveMode_); hostSession->OnSessionEvent(SessionEvent::EVENT_RECOVER); // need notify arkui maximize mode change if (reason == 1 && property_->GetMaximizeMode() == MaximizeMode::MODE_AVOID_SYSTEM_BAR) { diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index b0eaa88bc2..03306533f7 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -679,9 +679,6 @@ WSError WindowSessionImpl::UpdateRect(const WSRect& rect, SizeChangeReason reaso Rect wmRect = { rect.posX_, rect.posY_, rect.width_, rect.height_ }; auto preRect = GetRect(); property_->SetWindowRect(wmRect); - if (preRect.width_ != wmRect.width_ || preRect.height_ != wmRect.height_) { - windowSizeChanged_ = true; - } property_->SetRequestRect(wmRect); TLOGI(WmsLogTag::WMS_LAYOUT, "%{public}s, preRect:%{public}s, reason:%{public}u, hasRSTransaction:%{public}d" @@ -705,6 +702,22 @@ WSError WindowSessionImpl::UpdateRect(const WSRect& rect, SizeChangeReason reaso return WSError::WS_OK; } +/** @note @window.layout */ +void WindowSessionImpl::UpdateVirtualPixelRatio(const sptr& display) +{ + if (display == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "display is null when rotation!"); + return; + } + sptr displayInfo = display->GetDisplayInfo(); + if (displayInfo == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "displayInfo is null when rotation!"); + return; + } + virtualPixelRatio_ = GetVirtualPixelRatio(displayInfo); + TLOGD(WmsLogTag::WMS_LAYOUT, "virtualPixelRatio: %{public}f", virtualPixelRatio_); +} + void WindowSessionImpl::UpdateRectForRotation(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason, const SceneAnimationConfig& config) { @@ -714,6 +727,9 @@ void WindowSessionImpl::UpdateRectForRotation(const Rect& wmRect, const Rect& pr if (!window) { return; } + auto display = SingletonContainer::Get().GetDisplayById(window->property_->GetDisplayId()); + sptr displayInfo = display ? display->GetDisplayInfo() : nullptr; + window->UpdateVirtualPixelRatio(display); const std::shared_ptr& rsTransaction = config.rsTransaction_; if (rsTransaction) { RSTransaction::FlushImplicitTransaction(); @@ -738,7 +754,7 @@ void WindowSessionImpl::UpdateRectForRotation(const Rect& wmRect, const Rect& pr window->NotifySizeChange(wmRect, wmReason); window->lastSizeChangeReason_ = wmReason; } - window->UpdateViewportConfig(wmRect, wmReason, rsTransaction); + window->UpdateViewportConfig(wmRect, wmReason, rsTransaction, displayInfo); RSNode::CloseImplicitAnimation(); if (rsTransaction) { rsTransaction->Commit(); @@ -749,6 +765,18 @@ void WindowSessionImpl::UpdateRectForRotation(const Rect& wmRect, const Rect& pr }, "WMS_WindowSessionImpl_UpdateRectForRotation"); } +void WindowSessionImpl::UpdateRectForOtherReasonTask(const Rect& wmRect, const Rect& preRect, + WindowSizeChangeReason wmReason, const std::shared_ptr& rsTransaction) +{ + if ((wmRect != preRect) || (wmReason != lastSizeChangeReason_) || !postTaskDone_) { + NotifySizeChange(wmRect, wmReason); + lastSizeChangeReason_ = wmReason; + postTaskDone_ = true; + } + UpdateViewportConfig(wmRect, wmReason, rsTransaction); + UpdateFrameLayoutCallbackIfNeeded(wmReason); +} + bool WindowSessionImpl::CheckIfNeedCommitRsTransaction(WindowSizeChangeReason wmReason) { if (wmReason == WindowSizeChangeReason::FULL_TO_SPLIT || @@ -762,14 +790,8 @@ bool WindowSessionImpl::CheckIfNeedCommitRsTransaction(WindowSizeChangeReason wm void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason, const std::shared_ptr& rsTransaction) { - if ((wmRect != preRect) || (wmReason != lastSizeChangeReason_) || !postTaskDone_) { - NotifySizeChange(wmRect, wmReason); - lastSizeChangeReason_ = wmReason; - postTaskDone_ = true; - } if (handler_ == nullptr) { - UpdateViewportConfig(wmRect, wmReason, rsTransaction); - UpdateFrameLayoutCallbackIfNeeded(wmReason); + UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction); return; } @@ -785,12 +807,11 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& rsTransaction->Begin(); } if (wmReason == WindowSizeChangeReason::DRAG) { - window->UpdateViewportConfig(window->GetRect(), wmReason, rsTransaction); + window->UpdateRectForOtherReasonTask(window->GetRect(), preRect, wmReason, rsTransaction); window->isDragTaskUpdateDone_ = true; } else { - window->UpdateViewportConfig(wmRect, wmReason, rsTransaction); + window->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction); } - window->UpdateFrameLayoutCallbackIfNeeded(wmReason); if (rsTransaction && ifNeedCommitRsTransaction) { rsTransaction->Commit(); } @@ -833,8 +854,8 @@ void WindowSessionImpl::FlushLayoutSize(int32_t width, int32_t height) if (!WindowHelper::IsMainWindow(GetType())) { return; } - if (windowSizeChanged_ || enableFrameLayoutFinishCb_) { - WSRect rect = {0, 0, width, height}; + WSRect rect = { 0, 0, width, height }; + if (layoutRect_ != rect || enableFrameLayoutFinishCb_) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "NotifyFrameLayoutFinishFromApp, id: %u, rect: %s, notifyListener: %d", GetWindowId(), rect.ToString().c_str(), enableFrameLayoutFinishCb_.load()); @@ -844,7 +865,7 @@ void WindowSessionImpl::FlushLayoutSize(int32_t width, int32_t height) if (auto session = GetHostSession()) { session->NotifyFrameLayoutFinishFromApp(enableFrameLayoutFinishCb_, rect); } - windowSizeChanged_ = false; + layoutRect_ = rect; enableFrameLayoutFinishCb_ = false; } } @@ -1055,20 +1076,11 @@ WSError WindowSessionImpl::UpdateWindowMode(WindowMode mode) return WSError::WS_OK; } +/** @note @window.layout */ float WindowSessionImpl::GetVirtualPixelRatio() { - float vpr = 0.0f; // This is an abnormal value, which is used to identify abnormal scenarios. - auto display = SingletonContainer::Get().GetDisplayById(property_->GetDisplayId()); - if (display == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "display is null!"); - return vpr; - } - sptr displayInfo = display->GetDisplayInfo(); - if (displayInfo == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "displayInfo is null!"); - return vpr; - } - return GetVirtualPixelRatio(displayInfo); + TLOGD(WmsLogTag::WMS_LAYOUT, "virtualPixelRatio: %{public}f", virtualPixelRatio_); + return virtualPixelRatio_; } float WindowSessionImpl::GetVirtualPixelRatio(sptr displayInfo) @@ -1597,10 +1609,10 @@ WMError WindowSessionImpl::SetResizeByDragEnabled(bool dragEnabled) return WMError::WM_ERROR_INVALID_WINDOW; } - if (WindowHelper::IsMainWindow(GetType())) { + if (WindowHelper::IsMainWindow(GetType()) || WindowHelper::IsSubWindow(GetType())) { property_->SetDragEnabled(dragEnabled); } else { - WLOGFE("This is not main window."); + WLOGFE("This is not main window or sub window."); return WMError::WM_ERROR_INVALID_TYPE; } return UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_DRAGENABLED); @@ -1920,6 +1932,29 @@ WMError WindowSessionImpl::SetDecorVisible(bool isVisible) return WMError::WM_OK; } +WMError WindowSessionImpl::SetWindowTitleMoveEnabled(bool enable) +{ + if (IsWindowSessionInvalid()) { + return WMError::WM_ERROR_INVALID_WINDOW; + } + if (!IsPcOrPadFreeMultiWindowMode()) { + TLOGE(WmsLogTag::WMS_LAYOUT, "The device is not supported"); + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + if (!WindowHelper::IsMainWindow(GetType()) && !WindowHelper::IsSubWindow(GetType())) { + TLOGE(WmsLogTag::WMS_LAYOUT, "called by invalid window type, type:%{public}d", GetType()); + return WMError::WM_ERROR_INVALID_CALLING; + } + std::shared_ptr uiContent = GetUIContentSharedPtr(); + if (uiContent == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "uicontent is null"); + return WMError::WM_ERROR_NULLPTR; + } + uiContent->EnableContainerModalGesture(enable); + TLOGI(WmsLogTag::WMS_LAYOUT, "enable:%{public}d end", enable); + return WMError::WM_OK; +} + WMError WindowSessionImpl::SetSubWindowModal(bool isModal, ModalityType modalityType) { if (IsWindowSessionInvalid()) { diff --git a/wm/src/zidl/pattern_detach_callback_proxy.cpp b/wm/src/zidl/pattern_detach_callback_proxy.cpp index 155bcacde8..3005d77294 100644 --- a/wm/src/zidl/pattern_detach_callback_proxy.cpp +++ b/wm/src/zidl/pattern_detach_callback_proxy.cpp @@ -15,12 +15,6 @@ #include "zidl/pattern_detach_callback_proxy.h" -#include -#include -#include - -#include "window_manager_hilog.h" - namespace OHOS { namespace Rosen { diff --git a/wm/src/zidl/pattern_detach_callback_stub.cpp b/wm/src/zidl/pattern_detach_callback_stub.cpp index 591951c479..bd30484552 100644 --- a/wm/src/zidl/pattern_detach_callback_stub.cpp +++ b/wm/src/zidl/pattern_detach_callback_stub.cpp @@ -15,8 +15,6 @@ #include "zidl/pattern_detach_callback_stub.h" -#include "window_manager_hilog.h" - namespace OHOS { namespace Rosen { diff --git a/wm/test/unittest/input_transfer_station_test.cpp b/wm/test/unittest/input_transfer_station_test.cpp index bea965e0ea..a66799de7d 100644 --- a/wm/test/unittest/input_transfer_station_test.cpp +++ b/wm/test/unittest/input_transfer_station_test.cpp @@ -115,7 +115,10 @@ HWTEST_F(InputTransferStationTest, OnInputEvent1, Function | SmallTest | Level2) keyEvent = nullptr; listener->OnInputEvent(keyEvent); keyEvent = tempKeyEvent; + InputTransferStation::GetInstance().destroyed_ = true; + auto channel = InputTransferStation::GetInstance().GetInputChannel(0); listener->OnInputEvent(keyEvent); + ASSERT_EQ(channel, nullptr); } /** @@ -159,7 +162,10 @@ HWTEST_F(InputTransferStationTest, OnInputEvent3, Function | SmallTest | Level2) pointerEvent->SetAgentWindowId(0); listener->OnInputEvent(pointerEvent); pointerEvent->SetAgentWindowId(static_cast(-1)); + InputTransferStation::GetInstance().destroyed_ = true; + auto channel = InputTransferStation::GetInstance().GetInputChannel(0); listener->OnInputEvent(pointerEvent); + ASSERT_EQ(channel, nullptr); } /** diff --git a/wm/test/unittest/root_scene_test.cpp b/wm/test/unittest/root_scene_test.cpp index b5f36390af..19dedacc1b 100644 --- a/wm/test/unittest/root_scene_test.cpp +++ b/wm/test/unittest/root_scene_test.cpp @@ -219,6 +219,21 @@ HWTEST_F(RootSceneTest, SetUiDvsyncSwitchErr, Function | SmallTest | Level3) rootScene.SetUiDvsyncSwitch(false); ASSERT_EQ(1, rootScene.GetWindowId()); } + +/** + * @tc.name: GetSessionRectByType + * @tc.desc: GetSessionRectByType Test err + * @tc.type: FUNC + */ +HWTEST_F(RootSceneTest, GetSessionRectByTypeErr, Function | SmallTest | Level3) +{ + RootScene rootScene; + AvoidAreaType type = AvoidAreaType::TYPE_SYSTEM_GESTURE; + WSRect rect = WSRectT{0, 0, 0, 0}; + + auto ret = rootScene.GetSessionRectByType(type, rect); + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, ret); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/wm/test/unittest/window_adapter_test.cpp b/wm/test/unittest/window_adapter_test.cpp index 3140683361..f06228439c 100644 --- a/wm/test/unittest/window_adapter_test.cpp +++ b/wm/test/unittest/window_adapter_test.cpp @@ -465,6 +465,59 @@ HWTEST_F(WindowAdapterTest, ReregisterWindowManagerAgent, Function | SmallTest | ASSERT_EQ(WMError::WM_OK, ret); } +/** + * @tc.name: RecoverAndConnectSpecificSession + * @tc.desc: WindowAdapter/RecoverAndConnectSpecificSession + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, RecoverAndConnectSpecificSession, Function | SmallTest | Level2) +{ + WindowAdapter windowAdapter; + sptr iSessionStage; + sptr eventChannel; + sptr session = nullptr; + sptr token = nullptr; + windowAdapter.RecoverAndConnectSpecificSession( + iSessionStage, eventChannel, nullptr, nullptr, session, token); + + windowAdapter.isProxyValid_ = true; + windowAdapter.RecoverAndConnectSpecificSession( + iSessionStage, eventChannel, nullptr, nullptr, session, token); + + sptr remotObject = nullptr; + windowAdapter.windowManagerServiceProxy_ = iface_cast(remotObject); + windowAdapter.RecoverAndConnectSpecificSession( + iSessionStage, eventChannel, nullptr, nullptr, session, token); +} + +/** + * @tc.name: RecoverAndReconnectSceneSession + * @tc.desc: WindowAdapter/RecoverAndReconnectSceneSession + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, RecoverAndReconnectSceneSession, Function | SmallTest | Level2) +{ + WindowAdapter windowAdapter; + sptr iSessionStage; + sptr eventChannel; + sptr session = nullptr; + sptr token = nullptr; + auto ret1 = windowAdapter.RecoverAndReconnectSceneSession( + iSessionStage, eventChannel, nullptr, session, nullptr, token); + ASSERT_EQ(ret1, WMError::WM_DO_NOTHING); + + windowAdapter.isProxyValid_ = true; + auto ret2 = windowAdapter.RecoverAndReconnectSceneSession( + iSessionStage, eventChannel, nullptr, session, nullptr, token); + ASSERT_EQ(ret2, WMError::WM_DO_NOTHING); + + sptr remotObject = nullptr; + windowAdapter.windowManagerServiceProxy_ = iface_cast(remotObject); + auto ret3 = windowAdapter.RecoverAndReconnectSceneSession( + iSessionStage, eventChannel, nullptr, session, nullptr, token); + ASSERT_EQ(ret3, WMError::WM_DO_NOTHING); +} + /** * @tc.name: UpdateProperty * @tc.desc: WindowAdapter/UpdateProperty diff --git a/wm/test/unittest/window_impl_test5.cpp b/wm/test/unittest/window_impl_test5.cpp index 8b939842a4..f5918a9d99 100644 --- a/wm/test/unittest/window_impl_test5.cpp +++ b/wm/test/unittest/window_impl_test5.cpp @@ -1414,14 +1414,14 @@ HWTEST_F(WindowImplTest5, GetVirtualPixelRatio01, Function | SmallTest | Level1) window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - float vpr = -1.0f; + float vpr = 0.0f; window->property_->SetDisplayId(-1); vpr = window->GetVirtualPixelRatio(); - ASSERT_EQ(vpr, 0.0f); + ASSERT_EQ(vpr, 1.0f); window->property_->SetDisplayId(0); vpr = window->GetVirtualPixelRatio(); - ASSERT_NE(vpr, 0.0f); + ASSERT_NE(vpr, 1.0f); } } } // namespace Rosen diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index f45f5d2125..bc29e80b99 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -791,6 +791,29 @@ HWTEST_F(WindowSceneSessionImplTest, NotifyDrawingCompleted, Function | SmallTes window->NotifyDrawingCompleted(); } +/** + * @tc.name: NotifyRemoveStartingWindow + * @tc.desc: NotifyRemoveStartingWindow session + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, NotifyRemoveStartingWindow, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(nullptr, option); + option->SetWindowName("NotifyRemoveStartingWindow"); + option->SetDisplayId(0); + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + window->property_->SetPersistentId(1); + + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(nullptr, session); + + window->hostSession_ = session; + window->NotifyRemoveStartingWindow(); +} + /** * @tc.name: SetTransparent * @tc.desc: SetTransparent test @@ -1411,22 +1434,38 @@ HWTEST_F(WindowSceneSessionImplTest, SetBlur, Function | SmallTest | Level3) } /** - * @tc.name: SetKeepScreenOn - * @tc.desc: SetKeepScreenOn test + * @tc.name: SetKeepScreenOn01 + * @tc.desc: Window is Invalid * @tc.type: FUNC */ -HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn, Function | SmallTest | Level3) +HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn01, Function | SmallTest | Level3) { - sptr option = new (std::nothrow) WindowOption(); - sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + sptr option = new WindowOption(); + ASSERT_NE(nullptr, option); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); window->property_->SetWindowName("SetKeepScreenOn"); window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetKeepScreenOn(false)); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetKeepScreenOn(true)); +} +/** + * @tc.name: SetKeepScreenOn02 + * @tc.desc: Window is Valid + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn02, Function | SmallTest | Level3) +{ + sptr option = new WindowOption(); + ASSERT_NE(nullptr, option); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + window->property_->SetWindowName("SetKeepScreenOn"); + window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; - sptr session = new (std::nothrow) SessionMocker(sessionInfo); + sptr session = new SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; ASSERT_EQ(WMError::WM_OK, window->SetKeepScreenOn(true)); diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 91ce5da637..190f70f334 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -262,9 +262,16 @@ HWTEST_F(WindowSessionImplTest, SetResizeByDragEnabled03, Function | SmallTest | ASSERT_NE(nullptr, session); window->hostSession_ = session; - window->property_->type_ = WindowType::APP_SUB_WINDOW_BASE; - ASSERT_FALSE(WindowHelper::IsMainWindow(window->GetType())); + window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE); WMError retCode = window->SetResizeByDragEnabled(true); + ASSERT_EQ(retCode, WMError::WM_OK); + + window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + retCode = window->SetResizeByDragEnabled(true); + ASSERT_EQ(retCode, WMError::WM_OK); + + window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE); + retCode = window->SetResizeByDragEnabled(true); ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_TYPE); } diff --git a/wm/test/unittest/window_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index 9989ebe7fa..f2d6864c4f 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -260,6 +260,44 @@ HWTEST_F(WindowSessionImplTest4, SetDecorVisible, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetDecorVisibletest01 end"; } +/** + * @tc.name: SetWindowTitleMoveEnabled + * @tc.desc: SetWindowTitleMoveEnabled and check the retCode + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest4, SetWindowTitleMoveEnabled, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetWindowTitleMoveEnabledtest01 start"; + sptr option = sptr::MakeSptr(); + ASSERT_NE(option, nullptr); + option->SetWindowName("SetWindowTitleMoveEnabled"); + sptr window = sptr::MakeSptr(option); + ASSERT_NE(window, nullptr); + WMError res = window->SetWindowTitleMoveEnabled(true); + EXPECT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); + window->property_->SetPersistentId(1); + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; + sptr session = sptr::MakeSptr(sessionInfo); + ASSERT_NE(nullptr, session); + window->hostSession_ = session; + window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + res = window->SetWindowTitleMoveEnabled(true); + EXPECT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); + res = window->SetWindowTitleMoveEnabled(true); + EXPECT_EQ(res, WMError::WM_ERROR_INVALID_CALLING); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + res = window->SetWindowTitleMoveEnabled(true); + EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR); + window->uiContent_ = std::make_unique(); + res = window->SetWindowTitleMoveEnabled(true); + EXPECT_EQ(res, WMError::WM_OK); + res = window->SetWindowTitleMoveEnabled(false); + EXPECT_EQ(res, WMError::WM_OK); + GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetWindowTitleMoveEnabledtest01 end"; +} + /** * @tc.name: SetSubWindowModal * @tc.desc: SetSubWindowModal and check the retCode @@ -1358,6 +1396,32 @@ HWTEST_F(WindowSessionImplTest4, NotifyWindowVisibility01, Function | SmallTest window->UnregisterWindowVisibilityChangeListener(listener); } +/** + * @tc.name: UpdateVirtualPixelRatio + * @tc.desc: test UpdateVirtualPixelRatio + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest4, UpdateVirtualPixelRatio, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest4: UpdateVirtualPixelRatio start"; + sptr option = sptr::MakeSptr(); + option->SetWindowName("UpdateVirtualPixelRatio"); + sptr window = sptr::MakeSptr(option); + window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + + window->property_->SetDisplayId(-1); + sptr display = nullptr; + window->UpdateVirtualPixelRatio(display); + ASSERT_EQ(window->virtualPixelRatio_, 1.0f); + + window->property_->SetDisplayId(0); + display = SingletonContainer::Get().GetDisplayById(window->property_->GetDisplayId()); + window->UpdateVirtualPixelRatio(display); + ASSERT_NE(window->virtualPixelRatio_, 1.0f); + GTEST_LOG_(INFO) << "WindowSessionImplTest4: UpdateVirtualPixelRatio end"; +} + /** * @tc.name: NotifyMainWindowClose01 * @tc.desc: NotifyMainWindowClose @@ -1605,31 +1669,6 @@ HWTEST_F(WindowSessionImplTest4, UpdateSubWindowStateAndNotify01, Function | Sma EXPECT_EQ(WMError::WM_OK, window->Destroy(true)); } -/** - * @tc.name: GetVirtualPixelRatio - * @tc.desc: test GetVirtualPixelRatio - * @tc.type: FUNC - */ -HWTEST_F(WindowSessionImplTest4, GetVirtualPixelRatio, Function | SmallTest | Level2) -{ - GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetVirtualPixelRatio start"; - sptr option = sptr::MakeSptr(); - option->SetWindowName("GetVirtualPixelRatio"); - sptr window = sptr::MakeSptr(option); - window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - - float vpr = -1.0f; - window->property_->SetDisplayId(-1); - vpr = window->GetVirtualPixelRatio(); - ASSERT_EQ(vpr, 0.0f); - - window->property_->SetDisplayId(0); - vpr = window->GetVirtualPixelRatio(); - ASSERT_NE(vpr, 0.0f); - GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetVirtualPixelRatio end"; -} - /** * @tc.name: NotifyRotationAnimationEnd * @tc.desc: test NotifyRotationAnimationEnd diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 2619aa0775..8446328973 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -615,11 +615,11 @@ HWTEST_F(WindowTest, Resize, Function | SmallTest | Level2) } /** - * @tc.name: SetKeepScreenOn - * @tc.desc: get + * @tc.name: SetKeepScreenOn01 + * @tc.desc: SetKeepScreenOn true * @tc.type: FUNC */ -HWTEST_F(WindowTest, SetKeepScreenOn, Function | SmallTest | Level2) +HWTEST_F(WindowTest, SetKeepScreenOn01, Function | SmallTest | Level2) { sptr window = new Window(); ASSERT_NE(nullptr, window); @@ -628,9 +628,23 @@ HWTEST_F(WindowTest, SetKeepScreenOn, Function | SmallTest | Level2) ASSERT_EQ(WMError::WM_OK, window->Destroy()); } +/** + * @tc.name: SetKeepScreenOn02 + * @tc.desc: SetKeepScreenOn false + * @tc.type: FUNC + */ +HWTEST_F(WindowTest, SetKeepScreenOn02, Function | SmallTest | Level2) +{ + sptr window = new Window(); + ASSERT_NE(nullptr, window); + auto ret = window->SetKeepScreenOn(false); + ASSERT_EQ(WMError::WM_OK, ret); + ASSERT_EQ(WMError::WM_OK, window->Destroy()); +} + /** * @tc.name: IsKeepScreenOn - * @tc.desc: get + * @tc.desc: IsKeepScreenOn * @tc.type: FUNC */ HWTEST_F(WindowTest, IsKeepScreenOn, Function | SmallTest | Level2) @@ -2624,6 +2638,7 @@ HWTEST_F(WindowTest, Test01, Function | SmallTest | Level2) SystemBarProperty prop; ASSERT_EQ(WMError::WM_OK, window->SetSpecificBarProperty(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, prop)); ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetDecorVisible(true)); + ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetWindowTitleMoveEnabled(true)); ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetTitleButtonVisible(true, true, true, true)); auto var = 5; ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->SetDecorHeight(var)); diff --git a/wmserver/BUILD.gn b/wmserver/BUILD.gn index 0a20a8eea7..2b027b3ee4 100644 --- a/wmserver/BUILD.gn +++ b/wmserver/BUILD.gn @@ -108,6 +108,7 @@ ohos_shared_library("sms") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "image_framework:image_native", @@ -148,7 +149,10 @@ if (window_manager_use_sceneboard) { cfi_vcall_icall_only = true debug = false } - defines = [] + defines = [ + "SUPPORT_SCREEN", + "SUPPORT_GRAPHICS", + ] if (use_musl) { if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) { defines += [ "CONFIG_USE_JEMALLOC_DFX_INTF" ] @@ -216,6 +220,7 @@ if (window_manager_use_sceneboard) { "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "eventhandler:libeventhandler", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "graphic_2d:window_animation", "hicollie:libhicollie", @@ -226,6 +231,7 @@ if (window_manager_use_sceneboard) { "input:libmmi-client", "ipc:ipc_single", "libxml2:libxml2", + "preferences:native_preferences", "safwk:system_ability_fwk", ] diff --git a/wmserver/src/window_snapshot/snapshot_controller.cpp b/wmserver/src/window_snapshot/snapshot_controller.cpp index 3c8d452fd6..28a17210f2 100644 --- a/wmserver/src/window_snapshot/snapshot_controller.cpp +++ b/wmserver/src/window_snapshot/snapshot_controller.cpp @@ -20,7 +20,6 @@ #include "surface_capture_future.h" #include "surface_draw.h" #include "window_manager_hilog.h" -#include "wm_common.h" namespace OHOS { namespace Rosen { diff --git a/wmserver/src/window_snapshot/snapshot_proxy.cpp b/wmserver/src/window_snapshot/snapshot_proxy.cpp index c96811f5bb..34ed21a797 100644 --- a/wmserver/src/window_snapshot/snapshot_proxy.cpp +++ b/wmserver/src/window_snapshot/snapshot_proxy.cpp @@ -17,7 +17,6 @@ #include "ipc_types.h" #include "pixel_map.h" #include "window_manager_hilog.h" -#include "wm_common.h" namespace OHOS { namespace Rosen {