From cd0430ea70d2e34e3a0f22384f3be35dc22e05ea Mon Sep 17 00:00:00 2001 From: thks Date: Fri, 25 Oct 2024 17:21:29 +0800 Subject: [PATCH 001/132] =?UTF-8?q?UiExtFirstFlag=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: thks --- interfaces/innerkits/wm/window.h | 2 +- interfaces/innerkits/wm/window_option.h | 4 ++-- wm/src/window_scene_session_impl.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 8ffe49ab01..821908ea25 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -2381,7 +2381,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 8a350f0706..4d2abf5ee0 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/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 5bb066d4f0..5abb384547 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1355,7 +1355,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; From 90141ab020a020fc33cf27f5fa9666d4c15198ee Mon Sep 17 00:00:00 2001 From: lpf Date: Tue, 29 Oct 2024 21:18:58 +0800 Subject: [PATCH 002/132] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- dm/BUILD.gn | 1 + dmserver/BUILD.gn | 2 ++ extension/extension_connection/BUILD.gn | 1 + extension/window_extension/BUILD.gn | 3 +++ interfaces/kits/cj/window_runtime/BUILD.gn | 2 ++ interfaces/kits/napi/extension_window/BUILD.gn | 2 ++ interfaces/kits/napi/screen_runtime/BUILD.gn | 1 + interfaces/kits/napi/window_runtime/BUILD.gn | 4 ++++ previewer/BUILD.gn | 1 + setresolution/BUILD.gn | 1 + utils/include/window_transition_info.h | 3 +++ window_scene/intention_event/BUILD.gn | 2 ++ window_scene/intention_event/service/BUILD.gn | 1 + .../intention_event/src/intention_event_manager.cpp | 2 +- .../interfaces/kits/napi/scene_session_manager/BUILD.gn | 3 +++ .../interfaces/kits/napi/screen_session_manager/BUILD.gn | 1 + .../interfaces/kits/napi/transaction_manager/BUILD.gn | 2 ++ window_scene/session/BUILD.gn | 2 ++ window_scene/session_manager/BUILD.gn | 5 +++++ .../session_manager/include/scene_session_manager.h | 6 ++++++ .../session_manager/include/session_listener_controller.h | 4 ++++ window_scene/session_manager/src/anomaly_detection.cpp | 2 +- .../session_manager/src/scene_session_dirty_manager.cpp | 2 +- .../session_manager/src/scene_session_manager.cpp | 4 ++-- .../src/zidl/scene_session_manager_lite_stub.cpp | 2 +- .../src/zidl/scene_session_manager_proxy.cpp | 4 +++- wm/BUILD.gn | 4 ++++ wmserver/BUILD.gn | 8 +++++++- 28 files changed, 67 insertions(+), 8 deletions(-) diff --git a/dm/BUILD.gn b/dm/BUILD.gn index e6ee260292..5c68145bb3 100644 --- a/dm/BUILD.gn +++ b/dm/BUILD.gn @@ -138,6 +138,7 @@ ohos_shared_library("libdm") { "image_framework:image_native", "ipc:ipc_single", "samgr:samgr_proxy", + "graphic_2d:librender_service_base", ] innerapi_tags = [ "platformsdk" ] diff --git a/dmserver/BUILD.gn b/dmserver/BUILD.gn index 4d74bf6046..20c32392d1 100644 --- a/dmserver/BUILD.gn +++ b/dmserver/BUILD.gn @@ -76,6 +76,8 @@ ohos_shared_library("libdms") { "ipc:ipc_single", "libxml2:libxml2", "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "graphic_2d:librender_service_base", ] defines = [] diff --git a/extension/extension_connection/BUILD.gn b/extension/extension_connection/BUILD.gn index 9a3351e0d0..4326cfe6f2 100644 --- a/extension/extension_connection/BUILD.gn +++ b/extension/extension_connection/BUILD.gn @@ -67,6 +67,7 @@ ohos_shared_library("libwindow_extension_client") { "hitrace:hitrace_meter", "input:libmmi-client", "ipc:ipc_single", + "graphic_2d:librender_service_base", ] innerapi_tags = [ "platformsdk_indirect" ] diff --git a/extension/window_extension/BUILD.gn b/extension/window_extension/BUILD.gn index 4edcfc5094..a0da237583 100644 --- a/extension/window_extension/BUILD.gn +++ b/extension/window_extension/BUILD.gn @@ -80,6 +80,9 @@ ohos_shared_library("libwindow_extension") { "input:libmmi-client", "ipc:ipc_single", "napi:ace_napi", + "ipc:ipc_napi", + "ability_runtime:wantagent_innerkits", + "graphic_2d:librender_service_base", ] part_name = "window_manager" diff --git a/interfaces/kits/cj/window_runtime/BUILD.gn b/interfaces/kits/cj/window_runtime/BUILD.gn index 17d9149bb4..74d0cd7442 100644 --- a/interfaces/kits/cj/window_runtime/BUILD.gn +++ b/interfaces/kits/cj/window_runtime/BUILD.gn @@ -69,6 +69,8 @@ ohos_shared_library("cj_window_ffi") { "napi:ace_napi", "napi:cj_bind_ffi", "napi:cj_bind_native", + "ability_runtime:wantagent_innerkits", + "graphic_2d:librender_service_base", ] } else { defines += [ "PREVIEWER" ] diff --git a/interfaces/kits/napi/extension_window/BUILD.gn b/interfaces/kits/napi/extension_window/BUILD.gn index 790447e586..5d79d5c57d 100644 --- a/interfaces/kits/napi/extension_window/BUILD.gn +++ b/interfaces/kits/napi/extension_window/BUILD.gn @@ -107,6 +107,8 @@ ohos_shared_library("extensionwindow_napi") { "hilog:libhilog", "hitrace:hitrace_meter", "napi:ace_napi", + "bundle_framework:appexecfwk_base", + "ability_runtime:ability_manager", ] innerapi_tags = [ "platformsdk" ] diff --git a/interfaces/kits/napi/screen_runtime/BUILD.gn b/interfaces/kits/napi/screen_runtime/BUILD.gn index c84e4781dd..70b3c8cecf 100644 --- a/interfaces/kits/napi/screen_runtime/BUILD.gn +++ b/interfaces/kits/napi/screen_runtime/BUILD.gn @@ -50,6 +50,7 @@ ohos_shared_library("screen_napi") { "ability_runtime:runtime", "c_utils:utils", "graphic_surface:surface", # use for SurfaceUtils + "graphic_2d:librender_service_base", "hilog:libhilog", "hitrace:hitrace_meter", "napi:ace_napi", diff --git a/interfaces/kits/napi/window_runtime/BUILD.gn b/interfaces/kits/napi/window_runtime/BUILD.gn index bca28858c0..7d97c6ee88 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", @@ -144,6 +145,8 @@ ohos_shared_library("window_napi") { "hitrace:hitrace_meter", "image_framework:image", "napi:ace_napi", + "ability_runtime:wantagent_innerkits", + "graphic_2d:librender_service_base", ] relative_install_dir = "module" @@ -181,6 +184,7 @@ ohos_shared_library("windowstage_kit") { "c_utils:utils", "hilog:libhilog", "napi:ace_napi", + "ability_runtime:ability_manager", ] innerapi_tags = [ "platformsdk" ] diff --git a/previewer/BUILD.gn b/previewer/BUILD.gn index 4b24e14bd4..0c42bcfae5 100644 --- a/previewer/BUILD.gn +++ b/previewer/BUILD.gn @@ -144,6 +144,7 @@ if (!ispreview) { "ace_engine:ace_uicontent", "hilog:libhilog", "napi:ace_napi", + "ability_runtime:ability_manager", ] cflags_cc = [ "-DWINDOW_PREVIEW" ] 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/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/window_scene/intention_event/BUILD.gn b/window_scene/intention_event/BUILD.gn index 878a577f55..6c1e6955a9 100644 --- a/window_scene/intention_event/BUILD.gn +++ b/window_scene/intention_event/BUILD.gn @@ -54,6 +54,8 @@ ohos_shared_library("libintention_event") { "hitrace:hitrace_meter", "init:libbegetutil", "input:libmmi-client", + "libxml2:libxml2", + "graphic_2d:librender_service_base", ] defines = [] diff --git a/window_scene/intention_event/service/BUILD.gn b/window_scene/intention_event/service/BUILD.gn index fd1cbc6577..38c81c52e3 100644 --- a/window_scene/intention_event/service/BUILD.gn +++ b/window_scene/intention_event/service/BUILD.gn @@ -54,6 +54,7 @@ ohos_shared_library("intention_event_anr_manager") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_single", + "bundle_framework:appexecfwk_base", ] if (defined(global_parts_info) && diff --git a/window_scene/intention_event/src/intention_event_manager.cpp b/window_scene/intention_event/src/intention_event_manager.cpp index 03c73cc6dd..f428d0c696 100644 --- a/window_scene/intention_event/src/intention_event_manager.cpp +++ b/window_scene/intention_event/src/intention_event_manager.cpp @@ -95,7 +95,7 @@ bool IntentionEventManager::EnableInputEventListener(Ace::UIContent* uiContent, TLOGI(WmsLogTag::WMS_EVENT, "SetWindowInputEventConsumer success"); if (IS_BETA) { // Xcollie's SetTimerCounter task is set with the params to record count and time of the input down event - int id = HiviewDFX::XCollie::GetInstance().SetTimerCount("FREQUENT_CLICK_WARNING", FREQUENT_CLICK_TIME_LIMIT, + [[maybe_unused]] int id = HiviewDFX::XCollie::GetInstance().SetTimerCount("FREQUENT_CLICK_WARNING", FREQUENT_CLICK_TIME_LIMIT, FREQUENT_CLICK_COUNT_LIMIT); } return 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..725af7cf38 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/scene_session_manager/BUILD.gn @@ -69,6 +69,9 @@ ohos_shared_library("scenesessionmanager_napi") { "input:libmmi-client", "ipc:ipc_single", "napi:ace_napi", + "libxml2:libxml2", + "preferences:native_preferences", + "graphic_2d:librender_service_base", ] defines = [] 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..75b85cd40a 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn @@ -54,6 +54,7 @@ ohos_shared_library("screensessionmanager_napi") { "image_framework:image_native", "ipc:ipc_core", "napi:ace_napi", + "graphic_2d:librender_service_base", ] defines = [] diff --git a/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn b/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn index 1f377f5263..44ee48d0cf 100644 --- a/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn @@ -48,6 +48,8 @@ ohos_shared_library("transactionmanager_napi") { "ability_runtime:runtime", "c_utils:utils", "ffrt:libffrt", + "libxml2:libxml2", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "napi:ace_napi", diff --git a/window_scene/session/BUILD.gn b/window_scene/session/BUILD.gn index 6c3f705d6d..e420abb8e7 100644 --- a/window_scene/session/BUILD.gn +++ b/window_scene/session/BUILD.gn @@ -94,6 +94,7 @@ ohos_shared_library("scene_session") { "init:libbegetutil", "input:libmmi-client", "ipc:ipc_single", + "graphic_2d:librender_service_base", ] if (!(host_os == "linux" && host_cpu == "arm64")) { external_deps += [ "preferences:native_preferences" ] @@ -183,6 +184,7 @@ ohos_shared_library("screen_session") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "init:libbegetutil", + "graphic_2d:librender_service_base", ] public_external_deps = [ "ability_base:base", diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index ce3a56e6bf..fb53aa2614 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -132,6 +132,10 @@ ohos_shared_library("scene_session_manager") { "napi:ace_napi", "resource_management:global_resmgr", "samgr:samgr_proxy", + "safwk:system_ability_fwk", + "bundle_framework:libappexecfwk_common", + "preferences:native_preferences", + "graphic_2d:librender_service_base", ] defines = [] @@ -232,6 +236,7 @@ ohos_shared_library("session_manager") { "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "graphic_2d:librender_service_base", ] innerapi_tags = [ "platformsdk_indirect" ] diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 8b5829b91c..376b671ce6 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" 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/anomaly_detection.cpp b/window_scene/session_manager/src/anomaly_detection.cpp index 4930d48495..3d3e14291d 100644 --- a/window_scene/session_manager/src/anomaly_detection.cpp +++ b/window_scene/session_manager/src/anomaly_detection.cpp @@ -23,7 +23,7 @@ namespace OHOS { namespace Rosen { namespace { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "AnomalyDetection" }; +[[maybe_unused]] constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "AnomalyDetection" }; } void AnomalyDetection::SceneZOrderCheckProcess() 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 dd97589682..c91d2ec12f 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -256,7 +256,7 @@ void SceneSessionDirtyManager::UpdateHotAreas(sptr sceneSession, s WLOGFE("sceneSession is nullptr"); return; } - WSRect windowRect = sceneSession->GetSessionGlobalRect(); + [[maybe_unused]] WSRect windowRect = sceneSession->GetSessionGlobalRect(); const std::vector& hotAreas = sceneSession->GetTouchHotAreas(); for (auto area : hotAreas) { MMI::Rect rect; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index e7dcffe795..afef006327 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -112,7 +112,7 @@ constexpr int SCALE_MAX_WIDTH = 8; constexpr int PID_MAX_WIDTH = 8; constexpr int PARENT_ID_MAX_WIDTH = 6; constexpr int WINDOW_NAME_MAX_LENGTH = 20; -constexpr int32_t STATUS_BAR_AVOID_AREA = 0; +[[maybe_unused]] constexpr int32_t STATUS_BAR_AVOID_AREA = 0; const std::string ARG_DUMP_ALL = "-a"; const std::string ARG_DUMP_WINDOW = "-w"; const std::string ARG_DUMP_SCREEN = "-s"; @@ -638,7 +638,7 @@ void SceneSessionManager::ConfigDecor(const WindowSceneConfig::ConfigItem& decor } else { systemConfig_.freeMultiWindowConfig_.isSystemDecorEnable_ = item.boolValue_; } - bool decorEnable = item.boolValue_; + [[maybe_unused]] bool decorEnable = item.boolValue_; uint32_t support = 0; std::vector supportedModes; item = decorConfig["supportedMode"]; diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index e8164de63e..9eba3a12a7 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -21,7 +21,7 @@ namespace OHOS::Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionManagerLiteStub"}; -constexpr uint32_t MAX_VECTOR_SIZE = 100; +[[maybe_unused]] constexpr uint32_t MAX_VECTOR_SIZE = 100; constexpr uint32_t MAX_TOPN_INFO_SIZE = 200; } 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/wm/BUILD.gn b/wm/BUILD.gn index 0da8a8deb0..5421314508 100644 --- a/wm/BUILD.gn +++ b/wm/BUILD.gn @@ -132,6 +132,7 @@ ohos_static_library("libwm_static") { "ipc:ipc_single", "napi:ace_napi", "samgr:samgr_proxy", + "bundle_framework:libappexecfwk_common", ] defines = [] @@ -268,6 +269,8 @@ ohos_shared_library("libwm") { "ipc:ipc_single", "napi:ace_napi", "samgr:samgr_proxy", + "bundle_framework:libappexecfwk_common", + "graphic_2d:librender_service_base", ] defines = [] @@ -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/wmserver/BUILD.gn b/wmserver/BUILD.gn index 0a20a8eea7..e316351624 100644 --- a/wmserver/BUILD.gn +++ b/wmserver/BUILD.gn @@ -114,6 +114,7 @@ ohos_shared_library("sms") { "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "graphic_2d:librender_service_base", ] public_external_deps = [ "ability_runtime:ability_manager", @@ -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" ] @@ -223,10 +227,12 @@ if (window_manager_use_sceneboard) { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "image_framework:image_native", + "preferences:native_preferences", "input:libmmi-client", "ipc:ipc_single", "libxml2:libxml2", "safwk:system_ability_fwk", + "graphic_2d:librender_service_base", ] if (defined(global_parts_info) && From 37d93946ed42255b58d9a78e46e77d26b9739cad Mon Sep 17 00:00:00 2001 From: lpf Date: Tue, 29 Oct 2024 21:29:18 +0800 Subject: [PATCH 003/132] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- dm/BUILD.gn | 3 ++- utils/BUILD.gn | 1 + .../intention_event/src/intention_event_manager.cpp | 6 +++--- window_scene/screen_session_manager/BUILD.gn | 2 ++ window_scene/session/BUILD.gn | 6 ++++-- window_scene/session_manager/BUILD.gn | 13 +++++++------ .../session_manager/src/scene_session_manager.cpp | 2 +- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/dm/BUILD.gn b/dm/BUILD.gn index 5c68145bb3..1415d1664b 100644 --- a/dm/BUILD.gn +++ b/dm/BUILD.gn @@ -133,12 +133,12 @@ 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", "ipc:ipc_single", "samgr:samgr_proxy", - "graphic_2d:librender_service_base", ] innerapi_tags = [ "platformsdk" ] @@ -194,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/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/window_scene/intention_event/src/intention_event_manager.cpp b/window_scene/intention_event/src/intention_event_manager.cpp index f428d0c696..0c0a5631c3 100644 --- a/window_scene/intention_event/src/intention_event_manager.cpp +++ b/window_scene/intention_event/src/intention_event_manager.cpp @@ -30,9 +30,9 @@ namespace Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "IntentionEventManager" }; constexpr int32_t TRANSPARENT_FINGER_ID = 10000; -constexpr int32_t DELAY_TIME = 15; -constexpr unsigned int FREQUENT_CLICK_TIME_LIMIT = 3; -constexpr int FREQUENT_CLICK_COUNT_LIMIT = 8; +[[maybe_unused]] constexpr int32_t DELAY_TIME = 15; +[[maybe_unused]] constexpr unsigned int FREQUENT_CLICK_TIME_LIMIT = 3; +[[maybe_unused]] constexpr int FREQUENT_CLICK_COUNT_LIMIT = 8; static const bool IS_BETA = OHOS::system::GetParameter("const.logsystem.versiontype", "").find("beta") != std::string::npos; diff --git a/window_scene/screen_session_manager/BUILD.gn b/window_scene/screen_session_manager/BUILD.gn index 9400c6b5a0..b7f9ca27a6 100644 --- a/window_scene/screen_session_manager/BUILD.gn +++ b/window_scene/screen_session_manager/BUILD.gn @@ -121,12 +121,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/session/BUILD.gn b/window_scene/session/BUILD.gn index e420abb8e7..8cae6801f3 100644 --- a/window_scene/session/BUILD.gn +++ b/window_scene/session/BUILD.gn @@ -83,9 +83,11 @@ ohos_shared_library("scene_session") { "ability_runtime:start_window_option", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", + "bundle_framework:libappexecfwk_common", "c_utils:utils", "eventhandler:libeventhandler", "ffrt:libffrt", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "hisysevent:libhisysevent", @@ -94,7 +96,7 @@ ohos_shared_library("scene_session") { "init:libbegetutil", "input:libmmi-client", "ipc:ipc_single", - "graphic_2d:librender_service_base", + "samgr:samgr_proxy", ] if (!(host_os == "linux" && host_cpu == "arm64")) { external_deps += [ "preferences:native_preferences" ] @@ -178,13 +180,13 @@ ohos_shared_library("screen_session") { external_deps = [ "c_utils:utils", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hicollie:libhicollie", "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "init:libbegetutil", - "graphic_2d:librender_service_base", ] public_external_deps = [ "ability_base:base", diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index fb53aa2614..8fbde9eb55 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -114,11 +114,14 @@ ohos_shared_library("scene_session_manager") { "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_base", "graphic_2d:librender_service_client", "hicollie:libhicollie", "hilog:libhilog", @@ -130,12 +133,10 @@ ohos_shared_library("scene_session_manager") { "ipc:ipc_single", "libxml2:libxml2", "napi:ace_napi", - "resource_management:global_resmgr", - "samgr:samgr_proxy", - "safwk:system_ability_fwk", - "bundle_framework:libappexecfwk_common", "preferences:native_preferences", - "graphic_2d:librender_service_base", + "resource_management:global_resmgr", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", ] defines = [] @@ -230,13 +231,13 @@ 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", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "graphic_2d:librender_service_base", ] innerapi_tags = [ "platformsdk_indirect" ] diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index afef006327..be74c1eb25 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -121,7 +121,7 @@ const std::string ARG_DUMP_PIPLINE = "-p"; const std::string ARG_DUMP_SCB = "-b"; const std::string ARG_DUMP_DETAIL = "-c"; constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns -const int32_t LOGICAL_DISPLACEMENT_32 = 32; +[[maybe_unused]] const int32_t LOGICAL_DISPLACEMENT_32 = 32; constexpr int32_t GET_TOP_WINDOW_DELAY = 100; constexpr int32_t FFRT_USER_INTERACTIVE_MAX_THREAD_NUM = 5; From b2a72db4fd688ef2d0a9bbb0e44f28fcaa009fa6 Mon Sep 17 00:00:00 2001 From: lpf Date: Tue, 29 Oct 2024 21:32:15 +0800 Subject: [PATCH 004/132] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- dmserver/BUILD.gn | 2 +- extension/extension_connection/BUILD.gn | 2 +- extension/window_extension/BUILD.gn | 6 +++--- interfaces/kits/cj/window_runtime/BUILD.gn | 4 ++-- interfaces/kits/napi/extension_window/BUILD.gn | 4 ++-- interfaces/kits/napi/screen_runtime/BUILD.gn | 2 +- interfaces/kits/napi/window_runtime/BUILD.gn | 8 ++++---- previewer/BUILD.gn | 2 +- window_scene/intention_event/BUILD.gn | 2 +- window_scene/intention_event/service/BUILD.gn | 2 +- .../interfaces/kits/napi/scene_session_manager/BUILD.gn | 4 ++-- .../interfaces/kits/napi/screen_session_manager/BUILD.gn | 2 +- .../interfaces/kits/napi/transaction_manager/BUILD.gn | 2 +- wm/BUILD.gn | 6 +++--- wmserver/BUILD.gn | 6 +++--- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/dmserver/BUILD.gn b/dmserver/BUILD.gn index 20c32392d1..a1fe61277e 100644 --- a/dmserver/BUILD.gn +++ b/dmserver/BUILD.gn @@ -69,6 +69,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,7 +78,6 @@ ohos_shared_library("libdms") { "libxml2:libxml2", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "graphic_2d:librender_service_base", ] defines = [] diff --git a/extension/extension_connection/BUILD.gn b/extension/extension_connection/BUILD.gn index 4326cfe6f2..168f8ed8cc 100644 --- a/extension/extension_connection/BUILD.gn +++ b/extension/extension_connection/BUILD.gn @@ -62,12 +62,12 @@ 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", "input:libmmi-client", "ipc:ipc_single", - "graphic_2d:librender_service_base", ] innerapi_tags = [ "platformsdk_indirect" ] diff --git a/extension/window_extension/BUILD.gn b/extension/window_extension/BUILD.gn index a0da237583..2d3d3d6e9f 100644 --- a/extension/window_extension/BUILD.gn +++ b/extension/window_extension/BUILD.gn @@ -71,18 +71,18 @@ 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", - "ipc:ipc_napi", - "ability_runtime:wantagent_innerkits", - "graphic_2d:librender_service_base", ] part_name = "window_manager" diff --git a/interfaces/kits/cj/window_runtime/BUILD.gn b/interfaces/kits/cj/window_runtime/BUILD.gn index 74d0cd7442..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", @@ -69,8 +71,6 @@ ohos_shared_library("cj_window_ffi") { "napi:ace_napi", "napi:cj_bind_ffi", "napi:cj_bind_native", - "ability_runtime:wantagent_innerkits", - "graphic_2d:librender_service_base", ] } else { defines += [ "PREVIEWER" ] diff --git a/interfaces/kits/napi/extension_window/BUILD.gn b/interfaces/kits/napi/extension_window/BUILD.gn index 5d79d5c57d..cb3a51d445 100644 --- a/interfaces/kits/napi/extension_window/BUILD.gn +++ b/interfaces/kits/napi/extension_window/BUILD.gn @@ -100,15 +100,15 @@ 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", "hitrace:hitrace_meter", "napi:ace_napi", - "bundle_framework:appexecfwk_base", - "ability_runtime:ability_manager", ] innerapi_tags = [ "platformsdk" ] diff --git a/interfaces/kits/napi/screen_runtime/BUILD.gn b/interfaces/kits/napi/screen_runtime/BUILD.gn index 70b3c8cecf..10d42009c5 100644 --- a/interfaces/kits/napi/screen_runtime/BUILD.gn +++ b/interfaces/kits/napi/screen_runtime/BUILD.gn @@ -49,8 +49,8 @@ ohos_shared_library("screen_napi") { external_deps = [ "ability_runtime:runtime", "c_utils:utils", - "graphic_surface:surface", # use for SurfaceUtils "graphic_2d:librender_service_base", + "graphic_surface:surface", # use for SurfaceUtils "hilog:libhilog", "hitrace:hitrace_meter", "napi:ace_napi", diff --git a/interfaces/kits/napi/window_runtime/BUILD.gn b/interfaces/kits/napi/window_runtime/BUILD.gn index 7d97c6ee88..92807d3223 100644 --- a/interfaces/kits/napi/window_runtime/BUILD.gn +++ b/interfaces/kits/napi/window_runtime/BUILD.gn @@ -114,7 +114,7 @@ ohos_shared_library("window_napi") { cfi_vcall_icall_only = true debug = false } - defines = ["SUPPORT_SCREEN"] + defines = [ "SUPPORT_SCREEN" ] sources = [ "window_manager_napi/js_window_manager.cpp", "window_manager_napi/window_manager_module.cpp", @@ -138,15 +138,15 @@ 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", "image_framework:image", "napi:ace_napi", - "ability_runtime:wantagent_innerkits", - "graphic_2d:librender_service_base", ] relative_install_dir = "module" @@ -180,11 +180,11 @@ ohos_shared_library("windowstage_kit") { ] external_deps = [ + "ability_runtime:ability_manager", "ability_runtime:runtime", "c_utils:utils", "hilog:libhilog", "napi:ace_napi", - "ability_runtime:ability_manager", ] innerapi_tags = [ "platformsdk" ] diff --git a/previewer/BUILD.gn b/previewer/BUILD.gn index 0c42bcfae5..83b676ff5b 100644 --- a/previewer/BUILD.gn +++ b/previewer/BUILD.gn @@ -141,10 +141,10 @@ if (!ispreview) { ] external_deps = [ + "ability_runtime:ability_manager", "ace_engine:ace_uicontent", "hilog:libhilog", "napi:ace_napi", - "ability_runtime:ability_manager", ] cflags_cc = [ "-DWINDOW_PREVIEW" ] diff --git a/window_scene/intention_event/BUILD.gn b/window_scene/intention_event/BUILD.gn index 6c1e6955a9..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", @@ -55,7 +56,6 @@ ohos_shared_library("libintention_event") { "init:libbegetutil", "input:libmmi-client", "libxml2:libxml2", - "graphic_2d:librender_service_base", ] defines = [] diff --git a/window_scene/intention_event/service/BUILD.gn b/window_scene/intention_event/service/BUILD.gn index 38c81c52e3..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", @@ -54,7 +55,6 @@ ohos_shared_library("intention_event_anr_manager") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_single", - "bundle_framework:appexecfwk_base", ] if (defined(global_parts_info) && 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 725af7cf38..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,10 +69,9 @@ ohos_shared_library("scenesessionmanager_napi") { "image_framework:image_native", "input:libmmi-client", "ipc:ipc_single", - "napi:ace_napi", "libxml2:libxml2", + "napi:ace_napi", "preferences:native_preferences", - "graphic_2d:librender_service_base", ] defines = [] 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 75b85cd40a..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", @@ -54,7 +55,6 @@ ohos_shared_library("screensessionmanager_napi") { "image_framework:image_native", "ipc:ipc_core", "napi:ace_napi", - "graphic_2d:librender_service_base", ] defines = [] diff --git a/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn b/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn index 44ee48d0cf..b320d56868 100644 --- a/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/transaction_manager/BUILD.gn @@ -48,10 +48,10 @@ ohos_shared_library("transactionmanager_napi") { "ability_runtime:runtime", "c_utils:utils", "ffrt:libffrt", - "libxml2:libxml2", "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", + "libxml2:libxml2", "napi:ace_napi", ] diff --git a/wm/BUILD.gn b/wm/BUILD.gn index 5421314508..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", @@ -132,7 +133,6 @@ ohos_static_library("libwm_static") { "ipc:ipc_single", "napi:ace_napi", "samgr:samgr_proxy", - "bundle_framework:libappexecfwk_common", ] defines = [] @@ -256,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", @@ -269,8 +271,6 @@ ohos_shared_library("libwm") { "ipc:ipc_single", "napi:ace_napi", "samgr:samgr_proxy", - "bundle_framework:libappexecfwk_common", - "graphic_2d:librender_service_base", ] defines = [] diff --git a/wmserver/BUILD.gn b/wmserver/BUILD.gn index e316351624..2b027b3ee4 100644 --- a/wmserver/BUILD.gn +++ b/wmserver/BUILD.gn @@ -108,13 +108,13 @@ 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", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "graphic_2d:librender_service_base", ] public_external_deps = [ "ability_runtime:ability_manager", @@ -220,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", @@ -227,12 +228,11 @@ if (window_manager_use_sceneboard) { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "image_framework:image_native", - "preferences:native_preferences", "input:libmmi-client", "ipc:ipc_single", "libxml2:libxml2", + "preferences:native_preferences", "safwk:system_ability_fwk", - "graphic_2d:librender_service_base", ] if (defined(global_parts_info) && From 9c1b353ba6e7744bbda296ce41fb5888b306de88 Mon Sep 17 00:00:00 2001 From: lpf Date: Wed, 30 Oct 2024 09:28:07 +0800 Subject: [PATCH 005/132] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- previewer/BUILD.gn | 5 ++++- .../intention_event/src/intention_event_manager.cpp | 8 ++++---- window_scene/session_manager/BUILD.gn | 1 - 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/previewer/BUILD.gn b/previewer/BUILD.gn index 83b676ff5b..5beeabfbdf 100644 --- a/previewer/BUILD.gn +++ b/previewer/BUILD.gn @@ -85,11 +85,14 @@ if (!ispreview) { ] external_deps = [ - "ace_engine:ace_uicontent", "graphic_2d:librender_service_client", "hilog:libhilog", ] + if (!build_ohos_sdk && !is_mingw) { + external_deps += [ "ace_engine:ace_uicontent" ] + } + cflags = [ "-std=c++11" ] part_name = "window_manager" subsystem_name = "window" diff --git a/window_scene/intention_event/src/intention_event_manager.cpp b/window_scene/intention_event/src/intention_event_manager.cpp index 0c0a5631c3..03c73cc6dd 100644 --- a/window_scene/intention_event/src/intention_event_manager.cpp +++ b/window_scene/intention_event/src/intention_event_manager.cpp @@ -30,9 +30,9 @@ namespace Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "IntentionEventManager" }; constexpr int32_t TRANSPARENT_FINGER_ID = 10000; -[[maybe_unused]] constexpr int32_t DELAY_TIME = 15; -[[maybe_unused]] constexpr unsigned int FREQUENT_CLICK_TIME_LIMIT = 3; -[[maybe_unused]] constexpr int FREQUENT_CLICK_COUNT_LIMIT = 8; +constexpr int32_t DELAY_TIME = 15; +constexpr unsigned int FREQUENT_CLICK_TIME_LIMIT = 3; +constexpr int FREQUENT_CLICK_COUNT_LIMIT = 8; static const bool IS_BETA = OHOS::system::GetParameter("const.logsystem.versiontype", "").find("beta") != std::string::npos; @@ -95,7 +95,7 @@ bool IntentionEventManager::EnableInputEventListener(Ace::UIContent* uiContent, TLOGI(WmsLogTag::WMS_EVENT, "SetWindowInputEventConsumer success"); if (IS_BETA) { // Xcollie's SetTimerCounter task is set with the params to record count and time of the input down event - [[maybe_unused]] int id = HiviewDFX::XCollie::GetInstance().SetTimerCount("FREQUENT_CLICK_WARNING", FREQUENT_CLICK_TIME_LIMIT, + int id = HiviewDFX::XCollie::GetInstance().SetTimerCount("FREQUENT_CLICK_WARNING", FREQUENT_CLICK_TIME_LIMIT, FREQUENT_CLICK_COUNT_LIMIT); } return true; diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index 8fbde9eb55..67372de744 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -121,7 +121,6 @@ ohos_shared_library("scene_session_manager") { "eventhandler:libeventhandler", "ffrt:libffrt", "graphic_2d:librender_service_base", - "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hicollie:libhicollie", "hilog:libhilog", From dec1b1ec598a36985120ecf034d3ae16b8c409c9 Mon Sep 17 00:00:00 2001 From: lpf Date: Wed, 30 Oct 2024 10:33:41 +0800 Subject: [PATCH 006/132] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- previewer/BUILD.gn | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/previewer/BUILD.gn b/previewer/BUILD.gn index 5beeabfbdf..c7237df5c2 100644 --- a/previewer/BUILD.gn +++ b/previewer/BUILD.gn @@ -85,14 +85,11 @@ if (!ispreview) { ] external_deps = [ + "ace_engine:ace_uicontent", "graphic_2d:librender_service_client", "hilog:libhilog", ] - if (!build_ohos_sdk && !is_mingw) { - external_deps += [ "ace_engine:ace_uicontent" ] - } - cflags = [ "-std=c++11" ] part_name = "window_manager" subsystem_name = "window" @@ -145,11 +142,14 @@ if (!ispreview) { external_deps = [ "ability_runtime:ability_manager", - "ace_engine:ace_uicontent", "hilog:libhilog", "napi:ace_napi", ] + if (!build_ohos_sdk && !is_mingw) { + external_deps += [ "ace_engine:ace_uicontent" ] + } + cflags_cc = [ "-DWINDOW_PREVIEW" ] cflags = [ "-std=c++11" ] From 56eb002cbf8e110d002e2ef1d724f6de848ef049 Mon Sep 17 00:00:00 2001 From: lpf Date: Wed, 30 Oct 2024 10:37:27 +0800 Subject: [PATCH 007/132] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- previewer/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/previewer/BUILD.gn b/previewer/BUILD.gn index c7237df5c2..6be277e026 100644 --- a/previewer/BUILD.gn +++ b/previewer/BUILD.gn @@ -141,13 +141,13 @@ if (!ispreview) { ] external_deps = [ - "ability_runtime:ability_manager", + "ace_engine:ace_uicontent", "hilog:libhilog", "napi:ace_napi", ] if (!build_ohos_sdk && !is_mingw) { - external_deps += [ "ace_engine:ace_uicontent" ] + external_deps += [ "ability_runtime:ability_manager" ] } cflags_cc = [ "-DWINDOW_PREVIEW" ] From eb136215a106f59c787c1bb0ac978b090a525400 Mon Sep 17 00:00:00 2001 From: lpf Date: Wed, 30 Oct 2024 10:38:54 +0800 Subject: [PATCH 008/132] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- window_scene/session_manager/src/anomaly_detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/anomaly_detection.cpp b/window_scene/session_manager/src/anomaly_detection.cpp index 3d3e14291d..4930d48495 100644 --- a/window_scene/session_manager/src/anomaly_detection.cpp +++ b/window_scene/session_manager/src/anomaly_detection.cpp @@ -23,7 +23,7 @@ namespace OHOS { namespace Rosen { namespace { -[[maybe_unused]] constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "AnomalyDetection" }; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "AnomalyDetection" }; } void AnomalyDetection::SceneZOrderCheckProcess() From 387552f63ee9df3ae85a61b7f131a0e38edc272d Mon Sep 17 00:00:00 2001 From: lpf Date: Wed, 30 Oct 2024 10:42:57 +0800 Subject: [PATCH 009/132] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- .../session_manager/src/scene_session_dirty_manager.cpp | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++--- .../src/zidl/scene_session_manager_lite_stub.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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 c91d2ec12f..dd97589682 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -256,7 +256,7 @@ void SceneSessionDirtyManager::UpdateHotAreas(sptr sceneSession, s WLOGFE("sceneSession is nullptr"); return; } - [[maybe_unused]] WSRect windowRect = sceneSession->GetSessionGlobalRect(); + WSRect windowRect = sceneSession->GetSessionGlobalRect(); const std::vector& hotAreas = sceneSession->GetTouchHotAreas(); for (auto area : hotAreas) { MMI::Rect rect; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index be74c1eb25..e7dcffe795 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -112,7 +112,7 @@ constexpr int SCALE_MAX_WIDTH = 8; constexpr int PID_MAX_WIDTH = 8; constexpr int PARENT_ID_MAX_WIDTH = 6; constexpr int WINDOW_NAME_MAX_LENGTH = 20; -[[maybe_unused]] constexpr int32_t STATUS_BAR_AVOID_AREA = 0; +constexpr int32_t STATUS_BAR_AVOID_AREA = 0; const std::string ARG_DUMP_ALL = "-a"; const std::string ARG_DUMP_WINDOW = "-w"; const std::string ARG_DUMP_SCREEN = "-s"; @@ -121,7 +121,7 @@ const std::string ARG_DUMP_PIPLINE = "-p"; const std::string ARG_DUMP_SCB = "-b"; const std::string ARG_DUMP_DETAIL = "-c"; constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns -[[maybe_unused]] const int32_t LOGICAL_DISPLACEMENT_32 = 32; +const int32_t LOGICAL_DISPLACEMENT_32 = 32; constexpr int32_t GET_TOP_WINDOW_DELAY = 100; constexpr int32_t FFRT_USER_INTERACTIVE_MAX_THREAD_NUM = 5; @@ -638,7 +638,7 @@ void SceneSessionManager::ConfigDecor(const WindowSceneConfig::ConfigItem& decor } else { systemConfig_.freeMultiWindowConfig_.isSystemDecorEnable_ = item.boolValue_; } - [[maybe_unused]] bool decorEnable = item.boolValue_; + bool decorEnable = item.boolValue_; uint32_t support = 0; std::vector supportedModes; item = decorConfig["supportedMode"]; diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index 9eba3a12a7..e8164de63e 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -21,7 +21,7 @@ namespace OHOS::Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionManagerLiteStub"}; -[[maybe_unused]] constexpr uint32_t MAX_VECTOR_SIZE = 100; +constexpr uint32_t MAX_VECTOR_SIZE = 100; constexpr uint32_t MAX_TOPN_INFO_SIZE = 200; } From 571ae611bf81a7e726af8515c46d206bcc4e2c3d Mon Sep 17 00:00:00 2001 From: lpf Date: Wed, 30 Oct 2024 15:45:25 +0800 Subject: [PATCH 010/132] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- bundle.json | 3 ++- interfaces/kits/cj/display_runtime/BUILD.gn | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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/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", From 5a09f21a3bbc87eae2d4a3ded320b3e3e2b44c95 Mon Sep 17 00:00:00 2001 From: zzhcharmer Date: Wed, 30 Oct 2024 17:49:03 +0800 Subject: [PATCH 011/132] =?UTF-8?q?=E5=85=81=E8=AE=B8=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E6=A1=86=E6=9E=B6/=E5=BA=94=E7=94=A8=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=90=AF=E5=8A=A8=E9=A1=B5=E6=B6=88=E5=A4=B1=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zzhcharmer --- interfaces/innerkits/wm/window.h | 6 +++ .../window_stage_napi/js_window_stage.cpp | 50 ++++++++++++++++++- .../window_stage_napi/js_window_stage.h | 2 + .../window_stage_napi/window_stage.js | 4 ++ previewer/include/window.h | 7 +++ window_scene/session/host/include/session.h | 6 ++- .../host/include/zidl/session_interface.h | 1 + .../include/zidl/session_ipc_interface_code.h | 1 + .../session/host/include/zidl/session_proxy.h | 1 + .../session/host/include/zidl/session_stub.h | 1 + window_scene/session/host/src/session.cpp | 21 ++++++++ .../session/host/src/zidl/session_proxy.cpp | 23 +++++++++ .../session/host/src/zidl/session_stub.cpp | 10 ++++ .../src/scene_session_manager.cpp | 13 +++++ window_scene/test/mock/mock_session_stub.h | 1 + .../test/unittest/session_lifecycle_test.cpp | 1 + .../unittest/session_proxy_lifecycle_test.cpp | 17 +++++++ .../test/unittest/session_stub_test.cpp | 3 ++ window_scene/test/unittest/session_test.cpp | 1 + window_scene/test/unittest/session_test2.cpp | 1 + wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 17 +++++++ .../window_scene_session_impl_test.cpp | 24 +++++++++ 23 files changed, 210 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 66192e95aa..529f35c173 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) * 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 c505a05eed..0272f83234 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 @@ -28,6 +28,8 @@ namespace Rosen { using namespace AbilityRuntime; namespace { const int CONTENT_STORAGE_ARG = 2; +constexpr INDEX_ZERO = 0; +constexpr FOUR_PARAMS_SIZE = 4; constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsWindowStage"}; } // namespace @@ -146,6 +148,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; @@ -685,6 +694,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) { + TLOGE(WmsLogTag::WMS_MAIN, "%{public}s [NAPI]Get main window failed", where); + task.Reject( + 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"); @@ -721,7 +768,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..1a43fae7cc 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); + static 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/include/window.h b/previewer/include/window.h index f6ffcff3e1..e98103a6d4 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -401,6 +401,13 @@ public: * @return the value true means to enable gesture back, and false means the opposite. */ virtual bool GetGestureBackEnabled() const { return true; } + + /** + * @brief Get whether the gesture back is enabled or not. + * + * @return the value true means to enable gesture back, and false means the opposite. + */ + virtual bool NotifyRemoveStartingWindow() const { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } }; } } diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index b778fe3dd6..b26f4acb51 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -101,6 +101,7 @@ public: virtual void OnExtensionTimeout(int32_t errorCode) {} virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) {} + virtual void OnAppRemoveStartingWindow() {} }; enum class LifeCycleTaskType : uint32_t { @@ -143,6 +144,7 @@ public: WSError Show(sptr property) override; WSError Hide() override; WSError DrawingCompleted() override; + WSError RemoveStartingWindow() override; void ResetSessionConnectState(); void ResetIsActive(); @@ -222,6 +224,8 @@ public: WSRect GetLayoutRect() const; void SetClientRect(const WSRect& rect); WSRect GetClientRect() const; + void SetEnableRemoveStartingWindow(bool enableRemoveStartingWindow); + bool GetEnableRemoveStartingWindow() const; virtual WSError SetActive(bool active); virtual WSError UpdateSizeChangeReason(SizeChangeReason reason); @@ -723,7 +727,7 @@ private: bool showRecent_ = false; bool bufferAvailable_ = false; - + bool enableRemoveStartingWindow_ {false}; /* * Multi Window */ diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index a28313093a..cb1a5ce5fb 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 0b5c3f4718..aa95f220fe 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 292f9797d7..6ad9e256ea 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -67,6 +67,7 @@ public: WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override; WSError RaiseAboveTarget(int32_t subWindowId) override; WSError RaiseAppMainWindowToTop() override; + WSError RemoveStartingWindow() override; WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override; WSError TransferExtensionData(const AAFwk::WantParams& wantParams) override; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 672ca71ac8..ca4bb59f4c 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/session.cpp b/window_scene/session/host/src/session.cpp index dd05a12c11..aa018bc1ce 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1277,6 +1277,17 @@ WSError Session::DrawingCompleted() return WSError::WS_OK; } +WSError Session::DrawingCompleted() +{ + 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(); @@ -2734,6 +2745,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(); diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 445853469d..d7ba30794f 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -336,6 +336,29 @@ 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 ab2c548b4b..298be1dadf 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): @@ -401,6 +403,14 @@ int SessionStub::HandleDrawingCompleted(MessageParcel& data, MessageParcel& repl return ERR_NONE; } +int SessionStub::HandleRemoveStartingWindow(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_LIFE, "Called!"); + const 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_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 7ac42e09bd..b652410fdf 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3480,6 +3480,18 @@ void SceneSessionManager::OnConfigurationUpdated(const std::shared_ptr abilityInfo) +{ + auto metadata = abilityInfo->metadata; + for (auto item : metadata) { + if (item.name == "enable.remove.starting.window") { + return item.value == "true" ? true : false; + break; + } + } + return false; +} + void SceneSessionManager::FillSessionInfo(sptr& sceneSession) { auto sessionInfo = sceneSession->GetSessionInfo(); @@ -3497,6 +3509,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)) { 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/session_lifecycle_test.cpp b/window_scene/test/unittest/session_lifecycle_test.cpp index 9a57203f34..580750a613 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 e46df209a8..46941a4b96 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, diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 5fc2a59ef4..d5a21e40e2 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 3f57c01a8d..2746f30fd5 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -69,6 +69,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/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index d904911ce6..4d2dc8aa7b 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/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index c22cf70972..572d2f71e6 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1268,6 +1268,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; + } + const auto type = GetType(); + WMError res = WindowHelper::IsMainWindow(type) ? + static_cast(hostSession->RemoveStartingWindow()) : + WMError::WM_ERROR_INVALID_WINDOW; + if (res == WMError::WM_OK) { + TLOGI(WmsLogTag::WMS_LIFE, "Notify success id:%{public}d, type:%{public}d", + GetPersistentId(), type); + } + return res; +} + void WindowSceneSessionImpl::UpdateSubWindowState(const WindowType& type) { UpdateSubWindowStateAndNotify(GetPersistentId(), WindowState::STATE_HIDDEN); diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 8c3521a10e..5e9e0d5e55 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -767,6 +767,30 @@ 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); + ASSERT_NE(nullptr, window->property_); + 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 From e21d46d277f1e0fca2cb1b025545d4c96f118cca Mon Sep 17 00:00:00 2001 From: zzhcharmer Date: Wed, 30 Oct 2024 17:49:03 +0800 Subject: [PATCH 012/132] =?UTF-8?q?=E5=85=81=E8=AE=B8=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E6=A1=86=E6=9E=B6/=E5=BA=94=E7=94=A8=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=90=AF=E5=8A=A8=E9=A1=B5=E6=B6=88=E5=A4=B1=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zzhcharmer --- interfaces/innerkits/wm/window.h | 6 +++ .../window_stage_napi/js_window_stage.cpp | 50 ++++++++++++++++++- .../window_stage_napi/js_window_stage.h | 2 + .../window_stage_napi/window_stage.js | 4 ++ previewer/include/window.h | 6 +++ window_scene/session/host/include/session.h | 6 ++- .../host/include/zidl/session_interface.h | 1 + .../include/zidl/session_ipc_interface_code.h | 1 + .../session/host/include/zidl/session_proxy.h | 1 + .../session/host/include/zidl/session_stub.h | 1 + window_scene/session/host/src/session.cpp | 21 ++++++++ .../session/host/src/zidl/session_proxy.cpp | 23 +++++++++ .../session/host/src/zidl/session_stub.cpp | 10 ++++ .../src/scene_session_manager.cpp | 13 +++++ window_scene/test/mock/mock_session_stub.h | 1 + .../test/unittest/session_lifecycle_test.cpp | 1 + .../unittest/session_proxy_lifecycle_test.cpp | 17 +++++++ .../test/unittest/session_stub_test.cpp | 3 ++ window_scene/test/unittest/session_test.cpp | 1 + window_scene/test/unittest/session_test2.cpp | 1 + wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 17 +++++++ .../window_scene_session_impl_test.cpp | 24 +++++++++ 23 files changed, 209 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 66192e95aa..529f35c173 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) * 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 c505a05eed..0272f83234 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 @@ -28,6 +28,8 @@ namespace Rosen { using namespace AbilityRuntime; namespace { const int CONTENT_STORAGE_ARG = 2; +constexpr INDEX_ZERO = 0; +constexpr FOUR_PARAMS_SIZE = 4; constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsWindowStage"}; } // namespace @@ -146,6 +148,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; @@ -685,6 +694,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) { + TLOGE(WmsLogTag::WMS_MAIN, "%{public}s [NAPI]Get main window failed", where); + task.Reject( + 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"); @@ -721,7 +768,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..1a43fae7cc 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); + static 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/include/window.h b/previewer/include/window.h index f6ffcff3e1..3139e01086 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -401,6 +401,12 @@ public: * @return the value true means to enable gesture back, and false means the opposite. */ virtual bool GetGestureBackEnabled() const { return true; } + /** + * @brief notify window remove starting window. + * + * @return WMError + */ + virtual bool NotifyRemoveStartingWindow() const { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } }; } } diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index b778fe3dd6..b26f4acb51 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -101,6 +101,7 @@ public: virtual void OnExtensionTimeout(int32_t errorCode) {} virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) {} + virtual void OnAppRemoveStartingWindow() {} }; enum class LifeCycleTaskType : uint32_t { @@ -143,6 +144,7 @@ public: WSError Show(sptr property) override; WSError Hide() override; WSError DrawingCompleted() override; + WSError RemoveStartingWindow() override; void ResetSessionConnectState(); void ResetIsActive(); @@ -222,6 +224,8 @@ public: WSRect GetLayoutRect() const; void SetClientRect(const WSRect& rect); WSRect GetClientRect() const; + void SetEnableRemoveStartingWindow(bool enableRemoveStartingWindow); + bool GetEnableRemoveStartingWindow() const; virtual WSError SetActive(bool active); virtual WSError UpdateSizeChangeReason(SizeChangeReason reason); @@ -723,7 +727,7 @@ private: bool showRecent_ = false; bool bufferAvailable_ = false; - + bool enableRemoveStartingWindow_ {false}; /* * Multi Window */ diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index a28313093a..cb1a5ce5fb 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 0b5c3f4718..aa95f220fe 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 292f9797d7..6ad9e256ea 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -67,6 +67,7 @@ public: WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override; WSError RaiseAboveTarget(int32_t subWindowId) override; WSError RaiseAppMainWindowToTop() override; + WSError RemoveStartingWindow() override; WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override; WSError TransferExtensionData(const AAFwk::WantParams& wantParams) override; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 672ca71ac8..ca4bb59f4c 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/session.cpp b/window_scene/session/host/src/session.cpp index dd05a12c11..aa018bc1ce 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1277,6 +1277,17 @@ WSError Session::DrawingCompleted() return WSError::WS_OK; } +WSError Session::DrawingCompleted() +{ + 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(); @@ -2734,6 +2745,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(); diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 445853469d..d7ba30794f 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -336,6 +336,29 @@ 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 ab2c548b4b..298be1dadf 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): @@ -401,6 +403,14 @@ int SessionStub::HandleDrawingCompleted(MessageParcel& data, MessageParcel& repl return ERR_NONE; } +int SessionStub::HandleRemoveStartingWindow(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_LIFE, "Called!"); + const 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_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 7ac42e09bd..b652410fdf 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3480,6 +3480,18 @@ void SceneSessionManager::OnConfigurationUpdated(const std::shared_ptr abilityInfo) +{ + auto metadata = abilityInfo->metadata; + for (auto item : metadata) { + if (item.name == "enable.remove.starting.window") { + return item.value == "true" ? true : false; + break; + } + } + return false; +} + void SceneSessionManager::FillSessionInfo(sptr& sceneSession) { auto sessionInfo = sceneSession->GetSessionInfo(); @@ -3497,6 +3509,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)) { 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/session_lifecycle_test.cpp b/window_scene/test/unittest/session_lifecycle_test.cpp index 9a57203f34..580750a613 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 e46df209a8..46941a4b96 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, diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 5fc2a59ef4..d5a21e40e2 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 3f57c01a8d..2746f30fd5 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -69,6 +69,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/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index d904911ce6..4d2dc8aa7b 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/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index c22cf70972..572d2f71e6 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1268,6 +1268,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; + } + const auto type = GetType(); + WMError res = WindowHelper::IsMainWindow(type) ? + static_cast(hostSession->RemoveStartingWindow()) : + WMError::WM_ERROR_INVALID_WINDOW; + if (res == WMError::WM_OK) { + TLOGI(WmsLogTag::WMS_LIFE, "Notify success id:%{public}d, type:%{public}d", + GetPersistentId(), type); + } + return res; +} + void WindowSceneSessionImpl::UpdateSubWindowState(const WindowType& type) { UpdateSubWindowStateAndNotify(GetPersistentId(), WindowState::STATE_HIDDEN); diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 8c3521a10e..5e9e0d5e55 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -767,6 +767,30 @@ 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); + ASSERT_NE(nullptr, window->property_); + 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 From 01f44d8ebd7f151751e6c3d829c50bcfb16badaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Thu, 31 Oct 2024 11:14:43 +0800 Subject: [PATCH 013/132] change1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../unittest/scene_session_manager_test8.cpp | 2 +- .../test/unittest/session_stub_test.cpp | 19 ++++++++- .../window_scene_session_impl_test.cpp | 18 ++++++-- wm/test/unittest/window_test.cpp | 41 ++++++++++++++++--- 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test8.cpp b/window_scene/test/unittest/scene_session_manager_test8.cpp index 7a1e42a382..76b5ee03b8 100644 --- a/window_scene/test/unittest/scene_session_manager_test8.cpp +++ b/window_scene/test/unittest/scene_session_manager_test8.cpp @@ -614,7 +614,7 @@ HWTEST_F(SceneSessionManagerTest8, HandleKeepScreenOn, Function | SmallTest | Le sceneSession->keepScreenLock_ = nullptr; ssm_->HandleKeepScreenOn(sceneSession, true); bool enable = true; - EXPECT_EQ(WSError::WS_OK, ssm_->GetFreeMultiWindowEnableState(enable)); + EXPECT_EQ(WSError::WS_OK, ssm_->GetFreeMultiWindowEnableState(enable)); } /** diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index bdc887fe9d..5389e97ae8 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -746,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 */ @@ -762,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 */ @@ -777,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/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index c50295b886..616f0a3a52 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1407,11 +1407,11 @@ 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); @@ -1419,7 +1419,19 @@ HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn, Function | SmallTest | Lev 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 (std::nothrow) WindowOption(); + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + 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); diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 2619aa0775..596b203293 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); @@ -629,11 +629,25 @@ HWTEST_F(WindowTest, SetKeepScreenOn, Function | SmallTest | Level2) } /** - * @tc.name: IsKeepScreenOn - * @tc.desc: get + * @tc.name: SetKeepScreenOn02 + * @tc.desc: SetKeepScreenOn false * @tc.type: FUNC */ -HWTEST_F(WindowTest, IsKeepScreenOn, Function | SmallTest | Level2) +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: IsKeepScreenOn01 + * @tc.desc: IsKeepScreenOn false + * @tc.type: FUNC + */ +HWTEST_F(WindowTest, IsKeepScreenOn01, Function | SmallTest | Level2) { sptr window = new Window(); ASSERT_NE(nullptr, window); @@ -642,6 +656,21 @@ HWTEST_F(WindowTest, IsKeepScreenOn, Function | SmallTest | Level2) ASSERT_EQ(WMError::WM_OK, window->Destroy()); } +/** + * @tc.name: IsKeepScreenOn02 + * @tc.desc: IsKeepScreenOn true + * @tc.type: FUNC + */ +HWTEST_F(WindowTest, IsKeepScreenOn02, Function | SmallTest | Level2) +{ + sptr window = new Window(); + ASSERT_NE(nullptr, window); + window->SetKeepScreenOn(true); + auto ret = window->IsKeepScreenOn(); + ASSERT_EQ(true, ret); + ASSERT_EQ(WMError::WM_OK, window->Destroy()); +} + /** * @tc.name: SetTurnScreenOn * @tc.desc: get From 9f5dc1d7fd823a6bc5e8f1aade79e68cee4c4c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Thu, 31 Oct 2024 14:15:38 +0800 Subject: [PATCH 014/132] change3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- window_scene/test/unittest/scene_session_manager_test8.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test8.cpp b/window_scene/test/unittest/scene_session_manager_test8.cpp index 76b5ee03b8..7a1e42a382 100644 --- a/window_scene/test/unittest/scene_session_manager_test8.cpp +++ b/window_scene/test/unittest/scene_session_manager_test8.cpp @@ -614,7 +614,7 @@ HWTEST_F(SceneSessionManagerTest8, HandleKeepScreenOn, Function | SmallTest | Le sceneSession->keepScreenLock_ = nullptr; ssm_->HandleKeepScreenOn(sceneSession, true); bool enable = true; - EXPECT_EQ(WSError::WS_OK, ssm_->GetFreeMultiWindowEnableState(enable)); + EXPECT_EQ(WSError::WS_OK, ssm_->GetFreeMultiWindowEnableState(enable)); } /** From 59e4bfbe54bab18a27a8e11e227b4eec2338809d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Thu, 31 Oct 2024 15:40:47 +0800 Subject: [PATCH 015/132] change1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- wm/test/unittest/window_test.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 596b203293..4b36ef0feb 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -643,11 +643,11 @@ HWTEST_F(WindowTest, SetKeepScreenOn02, Function | SmallTest | Level2) } /** - * @tc.name: IsKeepScreenOn01 - * @tc.desc: IsKeepScreenOn false + * @tc.name: IsKeepScreenOn + * @tc.desc: IsKeepScreenOn * @tc.type: FUNC */ -HWTEST_F(WindowTest, IsKeepScreenOn01, Function | SmallTest | Level2) +HWTEST_F(WindowTest, IsKeepScreenOn, Function | SmallTest | Level2) { sptr window = new Window(); ASSERT_NE(nullptr, window); @@ -656,21 +656,6 @@ HWTEST_F(WindowTest, IsKeepScreenOn01, Function | SmallTest | Level2) ASSERT_EQ(WMError::WM_OK, window->Destroy()); } -/** - * @tc.name: IsKeepScreenOn02 - * @tc.desc: IsKeepScreenOn true - * @tc.type: FUNC - */ -HWTEST_F(WindowTest, IsKeepScreenOn02, Function | SmallTest | Level2) -{ - sptr window = new Window(); - ASSERT_NE(nullptr, window); - window->SetKeepScreenOn(true); - auto ret = window->IsKeepScreenOn(); - ASSERT_EQ(true, ret); - ASSERT_EQ(WMError::WM_OK, window->Destroy()); -} - /** * @tc.name: SetTurnScreenOn * @tc.desc: get From 848ff27c015fe60c14ccef298a05ebac470f23fc Mon Sep 17 00:00:00 2001 From: jjxxx123 Date: Thu, 31 Oct 2024 15:58:14 +0800 Subject: [PATCH 016/132] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BA=8B=E4=BB=B6TDD?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jjxxx123 --- .../test/unittest/intention_event_manager_test.cpp | 7 +++++++ .../unittest/scene_session_dirty_manager_test.cpp | 14 ++++++++++++-- wm/test/unittest/input_transfer_station_test.cpp | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) 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 7a9f101ffa..aa4a36808c 100644 --- a/window_scene/test/unittest/scene_session_dirty_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_dirty_manager_test.cpp @@ -799,12 +799,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/wm/test/unittest/input_transfer_station_test.cpp b/wm/test/unittest/input_transfer_station_test.cpp index bea965e0ea..c0aead90b1 100644 --- a/wm/test/unittest/input_transfer_station_test.cpp +++ b/wm/test/unittest/input_transfer_station_test.cpp @@ -115,7 +115,9 @@ HWTEST_F(InputTransferStationTest, OnInputEvent1, Function | SmallTest | Level2) keyEvent = nullptr; listener->OnInputEvent(keyEvent); keyEvent = tempKeyEvent; + auto channel = InputTransferStation::GetInstance().GetInputChannel(0); listener->OnInputEvent(keyEvent); + EXPECT_NE(nullptr, channel); } /** @@ -159,7 +161,9 @@ HWTEST_F(InputTransferStationTest, OnInputEvent3, Function | SmallTest | Level2) pointerEvent->SetAgentWindowId(0); listener->OnInputEvent(pointerEvent); pointerEvent->SetAgentWindowId(static_cast(-1)); + auto channel = InputTransferStation::GetInstance().GetInputChannel(0); listener->OnInputEvent(pointerEvent); + EXPECT_NE(nullptr, channel); } /** From b2bbb66d01d9aa82ac51e2708e5a48aefc1a4e29 Mon Sep 17 00:00:00 2001 From: jjxxx123 Date: Thu, 31 Oct 2024 19:37:15 +0800 Subject: [PATCH 017/132] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BA=8B=E4=BB=B6TDD?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jjxxx123 --- wm/test/unittest/input_transfer_station_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/test/unittest/input_transfer_station_test.cpp b/wm/test/unittest/input_transfer_station_test.cpp index c0aead90b1..6f93a2b0db 100644 --- a/wm/test/unittest/input_transfer_station_test.cpp +++ b/wm/test/unittest/input_transfer_station_test.cpp @@ -115,7 +115,7 @@ HWTEST_F(InputTransferStationTest, OnInputEvent1, Function | SmallTest | Level2) keyEvent = nullptr; listener->OnInputEvent(keyEvent); keyEvent = tempKeyEvent; - auto channel = InputTransferStation::GetInstance().GetInputChannel(0); + auto channel = InputTransferStation::GetInstance().GetInputChannel(1); listener->OnInputEvent(keyEvent); EXPECT_NE(nullptr, channel); } @@ -161,7 +161,7 @@ HWTEST_F(InputTransferStationTest, OnInputEvent3, Function | SmallTest | Level2) pointerEvent->SetAgentWindowId(0); listener->OnInputEvent(pointerEvent); pointerEvent->SetAgentWindowId(static_cast(-1)); - auto channel = InputTransferStation::GetInstance().GetInputChannel(0); + auto channel = InputTransferStation::GetInstance().GetInputChannel(1); listener->OnInputEvent(pointerEvent); EXPECT_NE(nullptr, channel); } From f634ff7c76112c225ba710bd87b4454528de5a8c Mon Sep 17 00:00:00 2001 From: kuangmei Date: Wed, 30 Oct 2024 21:44:14 +0800 Subject: [PATCH 018/132] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=A6=81=E6=AD=A2?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=A4=A7=E5=B0=8F=E8=BF=9B=E8=A1=8C=E6=8B=96?= =?UTF-8?q?=E6=8B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kuangmei --- window_scene/session/host/src/scene_session.cpp | 6 ------ window_scene/test/unittest/scene_session_test4.cpp | 4 ---- wm/src/window_session_impl.cpp | 4 ++-- wm/test/unittest/window_session_impl_test.cpp | 11 +++++++++-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 771a3ff49c..364a902e3d 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3508,7 +3508,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; @@ -3908,11 +3907,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()); 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/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 0d01b4d4b0..9a436de789 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1597,10 +1597,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); diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 6c26ae695a..84aa99c6d1 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); } From a4cbcd85d6348090284c186ba98ed394176ffe2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Thu, 31 Oct 2024 20:42:01 +0800 Subject: [PATCH 019/132] change2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- utils/src/unreliable_window_info.cpp | 1 - utils/src/window_visibility_info.cpp | 2 +- wmserver/src/window_snapshot/snapshot_controller.cpp | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) 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/window_visibility_info.cpp b/utils/src/window_visibility_info.cpp index 6fd09537c3..f226f0b864 100644 --- a/utils/src/window_visibility_info.cpp +++ b/utils/src/window_visibility_info.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "window_visibility_info.h" +#include "window_vis ibility_info.h" #include "window_manager_hilog.h" namespace OHOS::Rosen { 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 { From 594b3a424c3c4c8fd467d7e79d219bffb6d0bebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Thu, 31 Oct 2024 20:44:16 +0800 Subject: [PATCH 020/132] change3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- utils/src/window_visibility_info.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/src/window_visibility_info.cpp b/utils/src/window_visibility_info.cpp index f226f0b864..6fd09537c3 100644 --- a/utils/src/window_visibility_info.cpp +++ b/utils/src/window_visibility_info.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "window_vis ibility_info.h" +#include "window_visibility_info.h" #include "window_manager_hilog.h" namespace OHOS::Rosen { From 78b13b93019f09cc5e4517c3c91771943154c997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BE=E9=98=B3=E7=86=A0?= Date: Thu, 31 Oct 2024 20:40:30 +0800 Subject: [PATCH 021/132] =?UTF-8?q?Description:=20=E7=94=A8=E9=94=81?= =?UTF-8?q?=E4=BB=A3=E6=9B=BF=E6=A0=87=E5=BF=97=E4=BD=8D=E5=88=A4=E6=96=AD?= =?UTF-8?q?=20IssueNo:=20https://gitee.com/openharmony/drivers=5Fhdf=5Fcor?= =?UTF-8?q?e/issues/IB18HB=20Signed-off-by:=20qianyangyi=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wm/src/screen_scene.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) 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; From c86a10a54b4e62584f5ecbe8c0295dab26a92a4b Mon Sep 17 00:00:00 2001 From: liusensen Date: Fri, 1 Nov 2024 10:08:03 +0800 Subject: [PATCH 022/132] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E5=A4=B4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- .../window_manager_napi/window_manager_module.cpp | 1 - .../window_runtime/window_stage_napi/js_window_stage.cpp | 4 ---- window_scene/session/host/src/main_session.cpp | 5 ----- window_scene/session_manager/src/scene_session_manager.cpp | 3 --- wm/src/pattern_detach_callback.cpp | 2 -- wm/src/zidl/pattern_detach_callback_proxy.cpp | 5 ----- wm/src/zidl/pattern_detach_callback_stub.cpp | 2 -- 7 files changed, 22 deletions(-) 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_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index 6bdd876a07..ddb505de81 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" diff --git a/window_scene/session/host/src/main_session.cpp b/window_scene/session/host/src/main_session.cpp index 96e857bb7e..774793275d 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_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 499bfdbc12..43375ac182 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -15,7 +15,6 @@ #include "session_manager/include/scene_session_manager.h" -#include #include #include @@ -62,10 +61,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 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/zidl/pattern_detach_callback_proxy.cpp b/wm/src/zidl/pattern_detach_callback_proxy.cpp index 155bcacde8..2245305fa6 100644 --- a/wm/src/zidl/pattern_detach_callback_proxy.cpp +++ b/wm/src/zidl/pattern_detach_callback_proxy.cpp @@ -15,11 +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 { From eeb422009b7edf4af95b8171aab1893739509bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Fri, 1 Nov 2024 10:12:58 +0800 Subject: [PATCH 023/132] change4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- wmserver/src/window_snapshot/snapshot_proxy.cpp | 1 - 1 file changed, 1 deletion(-) 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 { From 12b6db04192be554217dda06d5214beb83cb7cb3 Mon Sep 17 00:00:00 2001 From: c30063259 Date: Fri, 1 Nov 2024 10:13:58 +0800 Subject: [PATCH 024/132] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E7=9B=91=E5=90=AC=E6=8E=A5=E5=8F=A3=E7=A8=B3=E5=AE=9A=E6=80=A7?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20Signed-off-by:=20c30063259=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../window_runtime/window_napi/js_window_listener.cpp | 9 ++++++++- .../napi/window_runtime/window_napi/js_window_listener.h | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) 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..6f54fb2eb5 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,7 @@ 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; From 0a7d4b4d335edb4006a5c9fd1e9495e38daa2f37 Mon Sep 17 00:00:00 2001 From: liusensen Date: Fri, 1 Nov 2024 10:16:33 +0800 Subject: [PATCH 025/132] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E5=A4=B4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- wm/src/zidl/pattern_detach_callback_proxy.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/wm/src/zidl/pattern_detach_callback_proxy.cpp b/wm/src/zidl/pattern_detach_callback_proxy.cpp index 2245305fa6..3005d77294 100644 --- a/wm/src/zidl/pattern_detach_callback_proxy.cpp +++ b/wm/src/zidl/pattern_detach_callback_proxy.cpp @@ -15,7 +15,6 @@ #include "zidl/pattern_detach_callback_proxy.h" - namespace OHOS { namespace Rosen { From 9297c0aaf8a5042aec7b30666b40c5402ee3f303 Mon Sep 17 00:00:00 2001 From: c30063259 Date: Fri, 1 Nov 2024 10:31:51 +0800 Subject: [PATCH 026/132] =?UTF-8?q?windowModeType=E4=B8=8A=E6=8A=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E6=8C=89=E7=85=A7RS=E5=8F=AF?= =?UTF-8?q?=E8=A7=81=E6=80=A7=E8=A7=A6=E5=8F=91=20Signed-off-by:=20c300632?= =?UTF-8?q?59=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../session_manager/src/scene_session_manager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 499bfdbc12..e3a57f3a9f 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2385,7 +2385,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) { @@ -3830,8 +3830,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 +3861,6 @@ bool SceneSessionManager::NotifyVisibleChange(int32_t persistentId) return false; } HandleKeepScreenOn(sceneSession, sceneSession->IsKeepScreenOn()); - ProcessWindowModeType(); return true; } @@ -5795,7 +5794,6 @@ __attribute__((no_sanitize("cfi"))) void SceneSessionManager::OnSessionStateChan default: break; } - ProcessWindowModeType(); } void SceneSessionManager::ProcessFocusWhenForeground(sptr& sceneSession) @@ -5878,7 +5876,8 @@ WindowModeType SceneSessionManager::CheckWindowModeType() for (const auto& session : sceneSessionMap_) { if (session.second == nullptr || !WindowHelper::IsMainWindow(session.second->GetWindowType()) || - !Rosen::SceneSessionManager::GetInstance().IsSessionVisibleForeground(session.second)) { + !session.second->GetRSVisible() || + !session.second->IsSessionForeground()) { continue; } if (isSmallFold && IsInSecondaryScreen(session.second)) { @@ -7711,6 +7710,7 @@ void SceneSessionManager::DealwithVisibilityChange(const std::vector Date: Tue, 29 Oct 2024 16:59:05 +0800 Subject: [PATCH 027/132] =?UTF-8?q?=E4=BF=AE=E5=A4=8Donwindowsizechange?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoukai --- wm/include/window_session_impl.h | 2 ++ wm/src/window_session_impl.cpp | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 2608d55e69..6362f9c6b5 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -459,6 +459,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; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 7dfd04fcfd..49313291e6 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -743,7 +743,7 @@ void WindowSessionImpl::UpdateRectForRotation(const Rect& wmRect, const Rect& pr }, "WMS_WindowSessionImpl_UpdateRectForRotation"); } -void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& preRect, +void WindowSessionImpl::UpdateRectForOtherReasonTask(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason, const std::shared_ptr& rsTransaction) { if ((wmRect != preRect) || (wmReason != lastSizeChangeReason_) || !postTaskDone_) { @@ -751,9 +751,15 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& lastSizeChangeReason_ = wmReason; postTaskDone_ = true; } + UpdateViewportConfig(wmRect, wmReason, rsTransaction); + UpdateFrameLayoutCallbackIfNeeded(wmReason); +} + +void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& preRect, + WindowSizeChangeReason wmReason, const std::shared_ptr& rsTransaction) +{ if (handler_ == nullptr) { - UpdateViewportConfig(wmRect, wmReason, rsTransaction); - UpdateFrameLayoutCallbackIfNeeded(wmReason); + UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction); return; } @@ -768,8 +774,7 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect& RSTransaction::FlushImplicitTransaction(); rsTransaction->Begin(); } - window->UpdateViewportConfig(wmRect, wmReason, rsTransaction); - window->UpdateFrameLayoutCallbackIfNeeded(wmReason); + window->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction); if (rsTransaction && ifNeedCommitRsTransaction) { rsTransaction->Commit(); } From 0d1bfe9b6aadc1a3ba6a6afb8b9be68aa0279a78 Mon Sep 17 00:00:00 2001 From: wangjiaqi Date: Fri, 1 Nov 2024 10:56:30 +0800 Subject: [PATCH 028/132] =?UTF-8?q?=E8=A7=A3=E5=86=B3onIsCustomAnimationPl?= =?UTF-8?q?aying=5F=E5=A4=9A=E7=BA=BF=E7=A8=8B=E8=AF=BB=E5=86=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangjiaqi --- .../scene_session_manager/js_scene_session.cpp | 13 ++++++------- .../session/host/include/scene_session.h | 11 ++++++++++- .../session/host/src/scene_session.cpp | 18 +++++++++++++++--- .../test/unittest/scene_session_test.cpp | 5 ++--- .../test/unittest/scene_session_test2.cpp | 1 - 5 files changed, 33 insertions(+), 15 deletions(-) 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 2ce9dfbb6e..f78ae87536 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 @@ -1518,20 +1518,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() diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 84e3f032ec..7dd2057d23 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -124,7 +124,6 @@ public: NotifySessionModalTypeChangeFunc onSessionModalTypeChange_; NotifyRaiseToTopFunc onRaiseToTop_; NotifySessionEventFunc OnSessionEvent_; - NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_; NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_; NotifyShowWhenLockedFunc OnShowWhenLocked_; NotifyRaiseAboveTargetFunc onRaiseAboveTarget_; @@ -391,6 +390,11 @@ public: */ void RegisterRequestedOrientationChangeCallback(NotifyReqOrientationChangeFunc&& callback); + /** + * Window Animation + */ + void RegisterIsCustomAnimationPlayingCallback(NotifyIsCustomAnimationPlayingCallback&& callback); + /** * Window Visibility */ @@ -783,6 +787,11 @@ private: */ NotifyReqOrientationChangeFunc onRequestedOrientationChange_; + /** + * Window Animation + */ + NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_; + /** * Window Immersive */ diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 2b9115481e..bf01d1bd28 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3012,8 +3012,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); } } @@ -4931,6 +4931,19 @@ 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__); +} + WMError SceneSession::GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) { if (forceSplitFunc_ == nullptr) { @@ -5243,7 +5256,6 @@ 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_->OnShowWhenLocked_ = nullptr; session->sessionChangeCallback_->onRaiseAboveTarget_ = nullptr; diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 3ced7aeeb0..71ec959fb5 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -820,9 +820,8 @@ HWTEST_F(SceneSessionTest, NotifyIsCustomAnimationPlaying, Function | SmallTest sceneSession = new (std::nothrow) SceneSession(info, nullptr); 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 fcfbc5ba6c..e374497c6f 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -1716,7 +1716,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; From e519115e06a0a8136b3dfe15309901bdc6a030d4 Mon Sep 17 00:00:00 2001 From: gaoguanghuione Date: Wed, 30 Oct 2024 13:11:28 +0000 Subject: [PATCH 029/132] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=99=BD=E8=92=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: gaoguanghuione Change-Id: I118002cfd70a9519df596b6155b4d152d54b0cb1 --- .../js_scene_session.cpp | 19 +++++++++++++++++++ .../scene_session_manager/js_scene_session.h | 2 ++ window_scene/session/host/include/session.h | 2 ++ window_scene/session/host/src/session.cpp | 10 ++++++++++ 4 files changed, 33 insertions(+) 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 6af05da536..039cbeef88 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 @@ -331,6 +331,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, @@ -1933,6 +1934,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]"); @@ -4597,6 +4605,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 7830e835e6..6a0d4fe609 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 @@ -140,6 +140,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); @@ -189,6 +190,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/session/host/include/session.h b/window_scene/session/host/include/session.h index 9a078db676..a4a133936f 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -96,6 +96,7 @@ 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) {} @@ -157,6 +158,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, diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 570e5477c5..4fdbc2a487 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -405,6 +405,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()) { From 1bf54e9f64028e5fb35b246f6d3e9dadfe37fcb8 Mon Sep 17 00:00:00 2001 From: wangjiaqi Date: Fri, 1 Nov 2024 04:45:34 +0000 Subject: [PATCH 030/132] update window_scene/test/unittest/scene_session_test.cpp. Signed-off-by: wangjiaqi --- window_scene/test/unittest/scene_session_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 71ec959fb5..4a1e07c177 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -821,7 +821,7 @@ HWTEST_F(SceneSessionTest, NotifyIsCustomAnimationPlaying, Function | SmallTest EXPECT_NE(sceneSession, nullptr); sceneSession->NotifyIsCustomAnimationPlaying(false); - sceneSession->onIsCustomAnimationPlaying_ = [](bool status){}; + sceneSession->onIsCustomAnimationPlaying_ = [](bool status) {}; sceneSession->NotifyIsCustomAnimationPlaying(false); } From 60a07c19cd8092df71b14a680db9ca528868e1b6 Mon Sep 17 00:00:00 2001 From: yxn Date: Thu, 31 Oct 2024 11:00:26 +0800 Subject: [PATCH 031/132] sync from yellowZone Signed-off-by: yxn --- window_scene/test/unittest/BUILD.gn | 7 +++++-- .../unittest/scene_session_manager_supplement_test.cpp | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index facbcf92ae..b1495e0c5c 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -893,10 +893,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/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, From 93b7fb89850d029f8fe161c002f68661a34af8e9 Mon Sep 17 00:00:00 2001 From: ReCoder Date: Thu, 31 Oct 2024 16:05:32 +0800 Subject: [PATCH 032/132] chore: add test cases Signed-off-by: ReCoder --- .../unittest/scene_session_manager_test10.cpp | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 74490ad376..9abdbe0618 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -663,6 +663,50 @@ 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()); +} } // namespace } } \ No newline at end of file From acd84e2a681018bfc46986d7ea3e377ac7a615fc Mon Sep 17 00:00:00 2001 From: h30026439 Date: Fri, 1 Nov 2024 14:27:54 +0800 Subject: [PATCH 033/132] =?UTF-8?q?key=E4=BA=8B=E4=BB=B6=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86=E4=B8=BA=E5=90=8C=E6=AD=A5=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E9=94=81=E7=9A=84=E4=BD=9C=E7=94=A8=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: h30026439 --- .../session/host/src/scene_session.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 406a879f85..d6181abeac 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4510,9 +4510,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(); @@ -4521,9 +4525,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; } From 3645c84b4275e8f63f9236efb20cdaecf970c27b Mon Sep 17 00:00:00 2001 From: jjxxx123 Date: Fri, 1 Nov 2024 14:28:05 +0800 Subject: [PATCH 034/132] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BA=8B=E4=BB=B6TDD?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jjxxx123 --- wm/test/unittest/input_transfer_station_test.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wm/test/unittest/input_transfer_station_test.cpp b/wm/test/unittest/input_transfer_station_test.cpp index 6f93a2b0db..a66799de7d 100644 --- a/wm/test/unittest/input_transfer_station_test.cpp +++ b/wm/test/unittest/input_transfer_station_test.cpp @@ -115,9 +115,10 @@ HWTEST_F(InputTransferStationTest, OnInputEvent1, Function | SmallTest | Level2) keyEvent = nullptr; listener->OnInputEvent(keyEvent); keyEvent = tempKeyEvent; - auto channel = InputTransferStation::GetInstance().GetInputChannel(1); + InputTransferStation::GetInstance().destroyed_ = true; + auto channel = InputTransferStation::GetInstance().GetInputChannel(0); listener->OnInputEvent(keyEvent); - EXPECT_NE(nullptr, channel); + ASSERT_EQ(channel, nullptr); } /** @@ -161,9 +162,10 @@ HWTEST_F(InputTransferStationTest, OnInputEvent3, Function | SmallTest | Level2) pointerEvent->SetAgentWindowId(0); listener->OnInputEvent(pointerEvent); pointerEvent->SetAgentWindowId(static_cast(-1)); - auto channel = InputTransferStation::GetInstance().GetInputChannel(1); + InputTransferStation::GetInstance().destroyed_ = true; + auto channel = InputTransferStation::GetInstance().GetInputChannel(0); listener->OnInputEvent(pointerEvent); - EXPECT_NE(nullptr, channel); + ASSERT_EQ(channel, nullptr); } /** From 67bf64f9ad7319910ac527bf2be28679bc58d1a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Fri, 1 Nov 2024 14:55:27 +0800 Subject: [PATCH 035/132] change5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../kits/napi/scene_session_manager/js_scene_session.cpp | 1 - .../kits/napi/scene_session_manager/js_scene_session.h | 2 -- window_scene/session/host/include/session.h | 1 - window_scene/session/host/src/scene_session.cpp | 1 - window_scene/session/host/src/session.cpp | 5 ----- 5 files changed, 10 deletions(-) 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 52771322e8..2e3794ec95 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 @@ -19,7 +19,6 @@ #include "session/host/include/session.h" #include "session_manager/include/scene_session_manager.h" #include "window_manager_hilog.h" -#include "common/include/session_permission.h" namespace OHOS::Rosen { using namespace AbilityRuntime; 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 d624a9be02..c0d80ef625 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 { diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index ce855f07f8..8f477bd336 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -22,7 +22,6 @@ #include -#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" diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ee07ed4026..49c1fa06b3 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" diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 9484c921d3..6fb5474f9f 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 { From 729ce3d717a42c906fa0e87c240ccf5cd73f903d Mon Sep 17 00:00:00 2001 From: rsyys Date: Fri, 1 Nov 2024 14:29:00 +0800 Subject: [PATCH 036/132] fix dropdown unfocus Signed-off-by: rsyys --- window_scene/session/host/include/session.h | 3 ++ window_scene/session/host/src/session.cpp | 12 +++++++ .../include/scene_session_manager.h | 1 + .../src/scene_session_manager.cpp | 36 ++++++++++++++++++- .../unittest/scene_session_manager_test10.cpp | 29 +++++++++++++++ window_scene/test/unittest/session_test3.cpp | 16 +++++++++ 6 files changed, 96 insertions(+), 1 deletion(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 081abe5097..4d8530a079 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -366,6 +366,8 @@ public: virtual void SetSystemFocusable(bool systemFocusable); // Used by SCB bool GetSystemFocusable() const; bool CheckFocusable() const; + void SetIsStartingBeforeVisible(bool isStartingBeforeVisible); + bool IsStartingBeforeVisible() const; bool IsFocused() const; bool GetFocused() const; virtual WSError UpdateFocus(bool isFocused); @@ -737,6 +739,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; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index c1a3b58e10..cbee51ac4f 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -633,6 +633,16 @@ bool Session::IsFocusedOnShow() const return focusedOnShow_; } +void Session::SetIsStartingBeforeVisible(bool isStartingBeforeVisible) +{ + isStartingBeforeVisible_ = isStartingBeforeVisible; +} + +bool Session::IsStartingBeforeVisible() const +{ + return isStartingBeforeVisible_; +} + WSError Session::SetTouchable(bool touchable) { SetSystemTouchable(touchable); @@ -1226,6 +1236,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); @@ -1258,6 +1269,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_) { diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index d20fd06b8c..c309f203f6 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -598,6 +598,7 @@ private: bool MissionChanged(sptr& prevSession, sptr& currSession); std::string GetAllSessionFocusInfo(); void RegisterRequestFocusStatusNotifyManagerFunc(sptr& sceneSession); + void ProcessUpdateLastFocusedAppId(std::vector zOrderList); void RegisterGetStateFromManagerFunc(sptr& sceneSession); void RegisterSessionChangeByActionNotifyManagerFunc(sptr& sceneSession); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 43375ac182..3f6385155b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1908,6 +1908,7 @@ WSError SceneSessionManager::RequestSceneSessionActivationInner( RequestInputMethodCloseKeyboard(persistentId); if (WindowHelper::IsMainWindow(sceneSession->GetWindowType())) { sceneSession->SetIsStarting(true); + sceneSession->SetIsStartingBeforeVisible(true); } if (WindowHelper::IsMainWindow(sceneSession->GetWindowType()) && sceneSession->IsFocusedOnShow()) { if (Session::IsScbCoreEnabled()) { @@ -9223,6 +9224,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_); @@ -9236,6 +9238,13 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapGetPersistentId()); if (iter != uiParams.end()) { + systemConfig_.IsPhoneWindow() && !systemConfig_.IsPadWindow() + if ((systemConfig_.IsPhoneWindow() || + (systemConfig_.IsPadWindow() && !systemConfig_.IsFreeMultiWindowMode())) && + sceneSession->IsStartingBeforeVisible() && sceneSession->IsAppSession()) { + startingAppZOrderList.push_back(iter->second.zOrder_); + sceneSession->SetIsStartingBeforeVisible(false); + } sessionMapDirty_ |= sceneSession->UpdateUIParam(iter->second); } else { sessionMapDirty_ |= sceneSession->UpdateUIParam(); @@ -9255,6 +9264,7 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapPostAsyncTask(task, "FlushUIParams"); } -void SceneSessionManager::ProcessFocusZOrderChange(uint32_t dirty) { +void SceneSessionManager::ProcessUpdateLastFocusedAppId(std::vector zOrderList) +{ + TLOGD(WmsLogTag::WMS_FOCUS, "last focused app: %{public}d, list size %{public}lu", lastFocusedAppSessionId_, + zOrderList.size()); + if (lastFocusedAppSessionId_ == INVALID_SESSION_ID || zOrderList.size() == 0) { + return; + } + auto lastFocusedAppSession = GetSceneSession(lastFocusedAppSessionId_); + // only when it's from a high zOrder to a low zOrder + if (lastFocusedAppSession == nullptr) { + return; + } + uint32_t lastFocusedAppZOrder = lastFocusedAppSession->GetZOrder(); + auto it = std::find_if(zOrderList.begin(), zOrderList.end(), [this, lastFocusedAppZOrder](uint32_t zOrder) { + return zOrder > lastFocusedAppZOrder; + }); + if (it == zOrderList.end()) { + return; + } + 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; } diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index e7bccbf64c..d5f4c1fab6 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -707,6 +707,35 @@ HWTEST_F(SceneSessionManagerTest10, NotifyStatusBarShowStatus, Function | SmallT 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) +{ + // init + 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); + ASSERT_NE(nullptr, sceneSession); + 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_); +} } // namespace } } \ No newline at end of file diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index 02816f0ddd..2140b39a4d 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -1349,6 +1349,22 @@ HWTEST_F(WindowSessionTest3, SetMainSessionUIStateDirty, Function | SmallTest | session_->SetMainSessionUIStateDirty(true); EXPECT_EQ(true, sessionUIState->GetUIStateDirty()); } +/** + * @tc.name: SetIsStartingBeforeVisible + * @tc.desc: test SetIsStartingBeforeVisible + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest3, SetIsStartingBeforeVisible, Function | SmallTest | Level2) +{ + ASSERT_NE(session_, nullptr); + session_->SetIsStartingBeforeVisible(true); + ASSERT_EQ(true, session_->isStartingBeforeVisible_); + ASSERT_EQ(true, session_->IsStartingBeforeVisible()); + + session_->SetIsStartingBeforeVisible(false); + ASSERT_EQ(false, session_->isStartingBeforeVisible_); + ASSERT_EQ(false, session_->IsStartingBeforeVisible()); +} } } // namespace Rosen } // namespace OHOS From ff708713f34b5b164bcb064980759f6a939da598 Mon Sep 17 00:00:00 2001 From: rsyys Date: Fri, 1 Nov 2024 14:37:13 +0800 Subject: [PATCH 037/132] fix Signed-off-by: rsyys --- window_scene/session_manager/src/scene_session_manager.cpp | 1 - window_scene/test/unittest/scene_session_manager_test10.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3f6385155b..4200b7ef80 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -9301,7 +9301,6 @@ void SceneSessionManager::ProcessUpdateLastFocusedAppId(std::vector zO return; } auto lastFocusedAppSession = GetSceneSession(lastFocusedAppSessionId_); - // only when it's from a high zOrder to a low zOrder if (lastFocusedAppSession == nullptr) { return; } diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index d5f4c1fab6..77a73f77d7 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -714,7 +714,6 @@ HWTEST_F(SceneSessionManagerTest10, NotifyStatusBarShowStatus, Function | SmallT */ HWTEST_F(SceneSessionManagerTest10, ProcessUpdateLastFocusedAppId, Function | SmallTest | Level1) { - // init ssm_->sceneSessionMap_.clear(); std::vector zOrderList; ssm_->lastFocusedAppSessionId_ = INVALID_SESSION_ID; From e91b4fad26474c49e71f38ee50134b7869c9503d Mon Sep 17 00:00:00 2001 From: rsyys Date: Fri, 1 Nov 2024 15:01:46 +0800 Subject: [PATCH 038/132] fix Signed-off-by: rsyys --- window_scene/session_manager/src/scene_session_manager.cpp | 1 - window_scene/test/unittest/scene_session_manager_test10.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 4200b7ef80..06b2f0ec42 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -9238,7 +9238,6 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapGetPersistentId()); if (iter != uiParams.end()) { - systemConfig_.IsPhoneWindow() && !systemConfig_.IsPadWindow() if ((systemConfig_.IsPhoneWindow() || (systemConfig_.IsPadWindow() && !systemConfig_.IsFreeMultiWindowMode())) && sceneSession->IsStartingBeforeVisible() && sceneSession->IsAppSession()) { diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 77a73f77d7..9c7633a894 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -723,7 +723,6 @@ HWTEST_F(SceneSessionManagerTest10, ProcessUpdateLastFocusedAppId, Function | Sm sessionInfo.bundleName_ = "lastFocusedAppSession"; sessionInfo.abilityName_ = "lastFocusedAppSession"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); - ASSERT_NE(nullptr, sceneSession); ssm_->sceneSessionMap_.emplace(1, sceneSession); ssm_->lastFocusedAppSessionId_ = 1; sceneSession->zOrder_ = 101; From d744e97a44d2573541d587ac0a95dcbe266bc975 Mon Sep 17 00:00:00 2001 From: rsyys Date: Fri, 1 Nov 2024 15:16:55 +0800 Subject: [PATCH 039/132] fix Signed-off-by: rsyys --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 06b2f0ec42..3816c53963 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -9294,7 +9294,7 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_map zOrderList) { - TLOGD(WmsLogTag::WMS_FOCUS, "last focused app: %{public}d, list size %{public}lu", lastFocusedAppSessionId_, + TLOGD(WmsLogTag::WMS_FOCUS, "last focused app: %{public}d, list size %{public}zu", lastFocusedAppSessionId_, zOrderList.size()); if (lastFocusedAppSessionId_ == INVALID_SESSION_ID || zOrderList.size() == 0) { return; From a0b362bd84d579c709c2d347903c52b5bd944b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E4=B8=80=E8=B5=AB?= Date: Fri, 1 Nov 2024 15:26:14 +0800 Subject: [PATCH 040/132] edit rs flush MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨一赫 --- .../session/host/src/scene_session.cpp | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 9238a9d997..a30812755f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2571,7 +2571,6 @@ void SceneSession::SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool need WLOGE("SetSurfaceBounds surfaceNode is null!"); } if (rsTransaction && needFlush) { - RSTransaction::FlushImplicitTransaction(); rsTransaction->Commit(); } } @@ -2823,12 +2822,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) @@ -2839,11 +2844,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) @@ -2864,12 +2875,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) @@ -2881,8 +2898,7 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst) return; } auto rsTransaction = RSTransactionProxy::GetInstance(); - if (rsTransaction) { - RSTransaction::FlushImplicitTransaction(); + if (rsTransaction != nullptr) { rsTransaction->Begin(); } if (leashWinSurfaceNode != nullptr) { @@ -2894,7 +2910,7 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst) surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), forceUIFirst); surfaceNode_->SetForceUIFirst(forceUIFirst); } - if (rsTransaction) { + if (rsTransaction != nullptr) { rsTransaction->Commit(); } } @@ -4706,12 +4722,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) From 0e9ee431c744633b40b71e3a5b0374e7bf001e1b Mon Sep 17 00:00:00 2001 From: rsyys Date: Fri, 1 Nov 2024 16:07:28 +0800 Subject: [PATCH 041/132] fix Signed-off-by: rsyys --- window_scene/session/host/include/session.h | 4 ++-- window_scene/session/host/src/session.cpp | 4 ++-- .../session_manager/src/scene_session_manager.cpp | 6 +++--- window_scene/test/unittest/session_test3.cpp | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 4d8530a079..fe131a0d37 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -366,8 +366,8 @@ public: virtual void SetSystemFocusable(bool systemFocusable); // Used by SCB bool GetSystemFocusable() const; bool CheckFocusable() const; - void SetIsStartingBeforeVisible(bool isStartingBeforeVisible); - bool IsStartingBeforeVisible() const; + void SetStartingBeforeVisible(bool isStartingBeforeVisible); + bool GetStartingBeforeVisible() const; bool IsFocused() const; bool GetFocused() const; virtual WSError UpdateFocus(bool isFocused); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index cbee51ac4f..a47ee781ab 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -633,12 +633,12 @@ bool Session::IsFocusedOnShow() const return focusedOnShow_; } -void Session::SetIsStartingBeforeVisible(bool isStartingBeforeVisible) +void Session::SetStartingBeforeVisible(bool isStartingBeforeVisible) { isStartingBeforeVisible_ = isStartingBeforeVisible; } -bool Session::IsStartingBeforeVisible() const +bool Session::GetStartingBeforeVisible() const { return isStartingBeforeVisible_; } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3816c53963..1633d9389e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1908,7 +1908,7 @@ WSError SceneSessionManager::RequestSceneSessionActivationInner( RequestInputMethodCloseKeyboard(persistentId); if (WindowHelper::IsMainWindow(sceneSession->GetWindowType())) { sceneSession->SetIsStarting(true); - sceneSession->SetIsStartingBeforeVisible(true); + sceneSession->SetStartingBeforeVisible(true); } if (WindowHelper::IsMainWindow(sceneSession->GetWindowType()) && sceneSession->IsFocusedOnShow()) { if (Session::IsScbCoreEnabled()) { @@ -9240,9 +9240,9 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapIsStartingBeforeVisible() && sceneSession->IsAppSession()) { + sceneSession->GetStartingBeforeVisible() && sceneSession->IsAppSession()) { startingAppZOrderList.push_back(iter->second.zOrder_); - sceneSession->SetIsStartingBeforeVisible(false); + sceneSession->SetStartingBeforeVisible(false); } sessionMapDirty_ |= sceneSession->UpdateUIParam(iter->second); } else { diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index 2140b39a4d..497fd393ad 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -1357,13 +1357,13 @@ HWTEST_F(WindowSessionTest3, SetMainSessionUIStateDirty, Function | SmallTest | HWTEST_F(WindowSessionTest3, SetIsStartingBeforeVisible, Function | SmallTest | Level2) { ASSERT_NE(session_, nullptr); - session_->SetIsStartingBeforeVisible(true); + session_->SetStartingBeforeVisible(true); ASSERT_EQ(true, session_->isStartingBeforeVisible_); - ASSERT_EQ(true, session_->IsStartingBeforeVisible()); + ASSERT_EQ(true, session_->GetStartingBeforeVisible()); - session_->SetIsStartingBeforeVisible(false); + session_->SetStartingBeforeVisible(false); ASSERT_EQ(false, session_->isStartingBeforeVisible_); - ASSERT_EQ(false, session_->IsStartingBeforeVisible()); + ASSERT_EQ(false, session_->GetStartingBeforeVisible()); } } } // namespace Rosen From 8e3ebffa574237d45375853a1c0950fc408c5f68 Mon Sep 17 00:00:00 2001 From: rsyys Date: Fri, 1 Nov 2024 16:15:47 +0800 Subject: [PATCH 042/132] fix Signed-off-by: rsyys --- window_scene/test/unittest/session_test3.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index 497fd393ad..de96572304 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -1350,11 +1350,11 @@ HWTEST_F(WindowSessionTest3, SetMainSessionUIStateDirty, Function | SmallTest | EXPECT_EQ(true, sessionUIState->GetUIStateDirty()); } /** - * @tc.name: SetIsStartingBeforeVisible - * @tc.desc: test SetIsStartingBeforeVisible + * @tc.name: SetStartingBeforeVisible + * @tc.desc: test SetStartingBeforeVisible * @tc.type: FUNC */ -HWTEST_F(WindowSessionTest3, SetIsStartingBeforeVisible, Function | SmallTest | Level2) +HWTEST_F(WindowSessionTest3, SetStartingBeforeVisible, Function | SmallTest | Level2) { ASSERT_NE(session_, nullptr); session_->SetStartingBeforeVisible(true); From 3652d650f0ac548e3ab260222b55d52e4ef61b2e Mon Sep 17 00:00:00 2001 From: z00899566 Date: Fri, 1 Nov 2024 16:25:41 +0800 Subject: [PATCH 043/132] implement display.on and bugfix SuperFoldStateManager Signed-off-by: z00899566 --- interfaces/innerkits/dm/dm_common.h | 3 - .../super_fold_state_manager.h | 14 ++--- .../super_fold_state_manager.cpp | 62 +++++++++++-------- 3 files changed, 42 insertions(+), 37 deletions(-) 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/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..5fb84e93d7 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 @@ -35,19 +35,17 @@ public: SuperFoldStateManager(); ~SuperFoldStateManager(); - void initStateManagerMap(SuperFoldStatus curState, + void AddStateManagerMap(SuperFoldStatus curState, SuperFoldStatusChangeEvents event, SuperFoldStatus nextState, std::function action); - void transferState(SuperFoldStatus nextState); + void TransferState(SuperFoldStatus nextState); void HandleSuperFoldStatusChange(SuperFoldStatusChangeEvents events); SuperFoldStatus GetCurrentStatus(); - void SetCurrentStatus(SuperFoldStatus curState); - private: SuperFoldStatus curState_ = SuperFoldStatus::HALF_FOLDED; @@ -69,11 +67,13 @@ private: static void DoKeyboardOff(); - static void DoSoftKeyboardOn(); - - static void DoSoftKeyboardOff(); + static void DoFoldedToHalfFolded(); static void DoExpandedToKeyboard(); + + void SetCurrentStatus(SuperFoldStatus curState); + + FoldStatus MatchSuperFoldStatusToFoldStatus(SuperFoldStatus superFoldStatus); }; } // Rosen } // OHOS 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..ab6f790689 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 @@ -49,14 +49,9 @@ void SuperFoldStateManager::DoKeyboardOff() TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOff()"); } -void SuperFoldStateManager::DoSoftKeyboardOn() +void SuperFoldStateManager::DoFoldedToHalfFolded() { - TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoSoftKeyboardOn()"); -} - -void SuperFoldStateManager::DoSoftKeyboardOff() -{ - TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoSoftKeyboardOff()"); + TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoFoldedToHalfFolded()"); } void SuperFoldStateManager::DoExpandedToKeyboard() @@ -66,50 +61,45 @@ void 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) @@ -117,12 +107,28 @@ void SuperFoldStateManager::initStateManagerMap(SuperFoldStatus curState, 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); + TLOGI(WmsLogTag::DMS, "TransferState from %{public}d to %{public}d", curState_, nextState); curState_ = 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_; @@ -139,7 +145,7 @@ void SuperFoldStateManager::HandleSuperFoldStatusChange(SuperFoldStatusChangeEve if (isTransfer && action) { action(); - transferState(nextState); + TransferState(nextState); // notify auto screenSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession(); if (screenSession == nullptr) { @@ -148,6 +154,8 @@ void SuperFoldStateManager::HandleSuperFoldStatusChange(SuperFoldStatusChangeEve } ScreenId screenId = screenSession->GetScreenId(); ScreenSessionManager::GetInstance().OnSuperFoldStatusChange(screenId, curState_); + ScreenSessionManager::GetInstance().NotifyFoldStatusChanged( + MatchSuperFoldStatusToFoldStatus(nextState)); } } From 0783607342391b5d83ff2d41a24eeca71d11a408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Fri, 1 Nov 2024 08:54:34 +0000 Subject: [PATCH 044/132] update window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../kits/napi/scene_session_manager/js_scene_session.cpp | 1 + 1 file changed, 1 insertion(+) 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 2e3794ec95..52771322e8 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 @@ -19,6 +19,7 @@ #include "session/host/include/session.h" #include "session_manager/include/scene_session_manager.h" #include "window_manager_hilog.h" +#include "common/include/session_permission.h" namespace OHOS::Rosen { using namespace AbilityRuntime; From 7f131a0d12f07e784fcfbaac3fea7134153d9385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E4=B8=80=E8=B5=AB?= Date: Fri, 1 Nov 2024 16:59:54 +0800 Subject: [PATCH 045/132] edit format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨一赫 --- window_scene/session/host/src/scene_session.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index a30812755f..be2dfe9686 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2535,7 +2535,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(); @@ -2570,7 +2570,7 @@ void SceneSession::SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool need } else { WLOGE("SetSurfaceBounds surfaceNode is null!"); } - if (rsTransaction && needFlush) { + if (rsTransaction != nullptr && needFlush) { rsTransaction->Commit(); } } From f30b8d9cb38dec0f25d43de3de2b7ec66d7224c1 Mon Sep 17 00:00:00 2001 From: kuangmei Date: Fri, 1 Nov 2024 13:26:54 +0800 Subject: [PATCH 046/132] =?UTF-8?q?PC=E5=92=8CPad=E8=87=AA=E7=94=B1?= =?UTF-8?q?=E5=A4=9A=E7=AA=97=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=A6=81=E7=94=A8?= =?UTF-8?q?setWindowLayoutFullScreen=E3=80=81setImmersiveModeEnabledState?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E7=82=B9=E5=87=BB=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E5=8C=96=E6=8C=89=E9=92=AE=E5=8F=AA=E8=BF=9B=E5=85=A5=E6=9C=80?= =?UTF-8?q?=E5=A4=A7=E5=8C=96=E4=B8=8D=E8=BF=9B=E5=85=A5=E6=B2=89=E6=B5=B8?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kuangmei --- .../napi/window_runtime/window_napi/js_window.cpp | 13 ++++++++++++- wm/src/window_scene_session_impl.cpp | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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 1e07b3015f..e002143f1d 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2688,7 +2688,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) { @@ -6701,6 +6708,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"); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index e1fcf24649..55b5be4a51 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2337,6 +2337,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); @@ -2399,6 +2402,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) { From 8adfcb5b3821ab21ae6a170dc881e708d7de44a1 Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 2 Nov 2024 10:16:53 +0800 Subject: [PATCH 047/132] fix Signed-off-by: francis --- .../test/unittest/scene_session_test2.cpp | 43 ++++++------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index 67a45daf92..520a15d83e 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); @@ -292,8 +291,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 +342,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 +565,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 +590,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 +714,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 +735,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 +769,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); @@ -1047,8 +1039,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) { @@ -1080,8 +1071,7 @@ HWTEST_F(SceneSessionTest2, NotifyForceHideChange, Function | SmallTest | Level2 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 +1095,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); @@ -1138,8 +1127,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 +1149,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 +1185,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 +1388,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); From 4df592c44c6df21cfc346dc4ad638e80efc0a8af Mon Sep 17 00:00:00 2001 From: c30063259 Date: Sat, 2 Nov 2024 10:17:37 +0800 Subject: [PATCH 048/132] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=A9=BA=E8=A1=8C=20?= =?UTF-8?q?Signed-off-by:=20c30063259=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kits/napi/window_runtime/window_napi/js_window_listener.cpp | 1 - 1 file changed, 1 deletion(-) 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 6f54fb2eb5..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 @@ -127,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"); From 75ab5cb4003bf0c545b9ab27bfd8116911589865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Sat, 2 Nov 2024 02:26:54 +0000 Subject: [PATCH 049/132] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=9A=E7=BA=A7?= =?UTF-8?q?=E5=AD=90=E7=AA=97dump=20=E4=BF=A1=E6=81=AF=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- window_scene/session/host/src/sub_session.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index a05c94b131..1495cf101a 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(); + auto mainSession = GetMainSession(); + if (mainSession && WindowHelper::IsMainWindow(mainSession->GetWindowType())) { + return mainSession->IsVisibleForeground() && Session::IsVisibleForeground(); } return Session::IsVisibleForeground(); } From 74639a343a6e12ee891ac52dcc84ace4451785a2 Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 2 Nov 2024 10:38:25 +0800 Subject: [PATCH 050/132] amend Signed-off-by: francis --- .../test/unittest/scene_session_test2.cpp | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index 520a15d83e..d11374ec59 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -148,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_; @@ -958,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_); @@ -976,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_); @@ -1008,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_); @@ -1067,8 +1063,7 @@ 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 = new (std::nothrow) Session(info); @@ -1111,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(); } @@ -1836,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); From 91e0c4ef4b01924fb4acc658502e9f097253f4f6 Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 2 Nov 2024 10:43:09 +0800 Subject: [PATCH 051/132] amend Signed-off-by: francis --- .../test/unittest/scene_session_test.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index b1380497a8..5bf1a11a9f 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -609,10 +609,9 @@ HWTEST_F(SceneSessionTest, IsDecorEnable, Function | SmallTest | Level2) 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 sceneSession = new (std::nothrow) SceneSession(info_, nullptr); + EXPECT_NE(sceneSession, nullptr); + ASSERT_EQ(false, sceneSession->IsDecorEnable()); } /** @@ -642,18 +641,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 sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, 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, sceneSession->IsDecorEnable()); sceneSession_->SetSessionProperty(nullptr); - ASSERT_EQ(false, sceneSession_->IsDecorEnable()); + ASSERT_EQ(false, sceneSession->IsDecorEnable()); } /** From d6fc118835b464d457e394c18dd0b7f3173d1a4c Mon Sep 17 00:00:00 2001 From: c30063259 Date: Sat, 2 Nov 2024 10:49:27 +0800 Subject: [PATCH 052/132] add Signed-off-by: c30063259 --- .../include/scene_session_manager.h | 7 +++- .../src/scene_session_manager.cpp | 29 +++++++++++------ .../unittest/scene_session_manager_test10.cpp | 32 ++++++++++++++++--- 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index d20fd06b8c..2ac8f33006 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -981,7 +981,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/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index e3a57f3a9f..11c68fd4fa 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -123,6 +123,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; @@ -5851,10 +5852,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) { @@ -5862,7 +5863,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() @@ -5874,13 +5889,7 @@ WindowModeType SceneSessionManager::CheckWindowModeType() { std::shared_lock lock(sceneSessionMapMutex_); for (const auto& session : sceneSessionMap_) { - if (session.second == nullptr || - !WindowHelper::IsMainWindow(session.second->GetWindowType()) || - !session.second->GetRSVisible() || - !session.second->IsSessionForeground()) { - continue; - } - if (isSmallFold && IsInSecondaryScreen(session.second)) { + if (IsNeedSkipWindowModeTypeCheck(session.second, isSmallFold)) { continue; } auto mode = session.second->GetWindowMode(); diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 44ebf466be..b4ee3469e4 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,28 @@ HWTEST_F(SceneSessionManagerTest10, EraseSceneSessionAndMarkDirtyLockFree, Funct ASSERT_EQ(ssm_->sessionMapDirty_, static_cast(SessionUIDirtyFlag::VISIBLE)); ASSERT_EQ(ssm_->sceneSessionMap_.find(validId), ssm_->sceneSessionMap_.end()); } + +/** + * @tc.name: IsNeedSkipWindowModeTypeCheck + * @tc.desc: IsNeedSkipWindowModeTypeCheck + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, IsNeedSkipWindowModeTypeCheck, Function | SmallTest | Level3) +{ + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "SceneSessionManagerTest6"; + 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(true); + sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); + ASSERT_TRUE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, false)); + sceneSession->SetRSVisible(false); + ASSERT_TRUE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, true)); + ASSERT_FALSE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, false)); +} } // namespace } } \ No newline at end of file From ac2f62c87c1b127a5ca2cc57d61529680ed1406e Mon Sep 17 00:00:00 2001 From: c30063259 Date: Sat, 2 Nov 2024 10:57:44 +0800 Subject: [PATCH 053/132] add Signed-off-by: c30063259 --- .../unittest/scene_session_manager_test10.cpp | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 28ef25a11d..a44bc8d43a 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -676,7 +676,7 @@ HWTEST_F(SceneSessionManagerTest10, UpdateAvoidAreaByType, Function | SmallTest 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; @@ -707,6 +707,28 @@ HWTEST_F(SceneSessionManagerTest10, NotifyStatusBarShowStatus, Function | SmallT EXPECT_EQ(WSError::WS_OK, ssm_->NotifyStatusBarShowStatus(sceneSession->GetPersistentId(), false)); ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId()); } + +/** + * @tc.name: IsNeedSkipWindowModeTypeCheck + * @tc.desc: IsNeedSkipWindowModeTypeCheck + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, IsNeedSkipWindowModeTypeCheck, Function | SmallTest | Level3) +{ + SessionInfo sessionInfo; + sessionInfo.bundleName_ = "SceneSessionManagerTest6"; + 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(true); + sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); + ASSERT_TRUE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, false)); + sceneSession->SetRSVisible(false); + ASSERT_TRUE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, true)); + ASSERT_FALSE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, false)); +} } // namespace } } \ No newline at end of file From 62893f0fba1e8e5a38aa8c0fb1f206ceb95e50b5 Mon Sep 17 00:00:00 2001 From: rsyys Date: Sat, 2 Nov 2024 10:52:18 +0800 Subject: [PATCH 054/132] fix for comments Signed-off-by: rsyys --- .../session_manager/include/scene_session_manager.h | 2 +- .../session_manager/src/scene_session_manager.cpp | 13 ++++++------- .../test/unittest/scene_session_manager_test10.cpp | 1 + window_scene/test/unittest/session_test3.cpp | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index c309f203f6..92a8e9b4fb 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -598,7 +598,7 @@ private: bool MissionChanged(sptr& prevSession, sptr& currSession); std::string GetAllSessionFocusInfo(); void RegisterRequestFocusStatusNotifyManagerFunc(sptr& sceneSession); - void ProcessUpdateLastFocusedAppId(std::vector zOrderList); + void ProcessUpdateLastFocusedAppId(const std::vector& zOrderList); void RegisterGetStateFromManagerFunc(sptr& sceneSession); void RegisterSessionChangeByActionNotifyManagerFunc(sptr& sceneSession); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1633d9389e..01a18cae5c 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -9292,11 +9292,11 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_mapPostAsyncTask(task, "FlushUIParams"); } -void SceneSessionManager::ProcessUpdateLastFocusedAppId(std::vector zOrderList) +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.size() == 0) { + if (lastFocusedAppSessionId_ == INVALID_SESSION_ID || zOrderList.empty()) { return; } auto lastFocusedAppSession = GetSceneSession(lastFocusedAppSessionId_); @@ -9304,14 +9304,13 @@ void SceneSessionManager::ProcessUpdateLastFocusedAppId(std::vector zO return; } uint32_t lastFocusedAppZOrder = lastFocusedAppSession->GetZOrder(); - auto it = std::find_if(zOrderList.begin(), zOrderList.end(), [this, lastFocusedAppZOrder](uint32_t zOrder) { + auto it = std::find_if(zOrderList.begin(), zOrderList.end(), [lastFocusedAppZOrder](uint32_t zOrder) { return zOrder > lastFocusedAppZOrder; }); - if (it == zOrderList.end()) { - return; + if (it != zOrderList.end()) { + TLOGD(WmsLogTag::WMS_FOCUS, "clear with high zOrder app visible"); + lastFocusedAppSessionId_ = INVALID_SESSION_ID; } - TLOGD(WmsLogTag::WMS_FOCUS, "clear with high zOrder app visible"); - lastFocusedAppSessionId_ = INVALID_SESSION_ID; } void SceneSessionManager::ProcessFocusZOrderChange(uint32_t dirty) diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 9c7633a894..3ef4d9441d 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -707,6 +707,7 @@ HWTEST_F(SceneSessionManagerTest10, NotifyStatusBarShowStatus, Function | SmallT EXPECT_EQ(WSError::WS_OK, ssm_->NotifyStatusBarShowStatus(sceneSession->GetPersistentId(), false)); ssm_->sceneSessionMap_.erase(sceneSession->GetPersistentId()); } + /** * @tc.name: ProcessUpdateLastFocusedAppId * @tc.desc: test ProcessUpdateLastFocusedAppId diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index de96572304..ba87624957 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -1349,6 +1349,7 @@ HWTEST_F(WindowSessionTest3, SetMainSessionUIStateDirty, Function | SmallTest | session_->SetMainSessionUIStateDirty(true); EXPECT_EQ(true, sessionUIState->GetUIStateDirty()); } + /** * @tc.name: SetStartingBeforeVisible * @tc.desc: test SetStartingBeforeVisible From 526d2ae35f4aa001151f7cc6d90fc375cd00d02e Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 2 Nov 2024 11:06:47 +0800 Subject: [PATCH 055/132] fix Signed-off-by: francis --- .../unittest/window_session_property_test.cpp | 91 +++++++++++-------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 7940d9191c..cca34a0f3c 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(); + ASSER_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(); + ASSER_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(); + ASSER_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(); + ASSER_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(); + ASSER_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(); + ASSER_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(); + ASSER_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(); + ASSER_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(); + ASSER_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(); + ASSER_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(); + ASSER_NE(nullptr, property); ASSERT_EQ(property->IsLayoutFullScreen(), false); property->SetIsLayoutFullScreen(true); ASSERT_EQ(property->IsLayoutFullScreen(), true); @@ -952,6 +963,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 +1122,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 From 944ee25dbfef1925e92c874c98eee20ecfa2bb78 Mon Sep 17 00:00:00 2001 From: wangjiaqi Date: Sat, 2 Nov 2024 11:28:02 +0800 Subject: [PATCH 056/132] =?UTF-8?q?=E5=88=A0=E5=8E=BB=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E7=99=BD=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangjiaqi --- window_scene/test/unittest/scene_session_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index b1380497a8..c44f155afa 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -820,7 +820,7 @@ HWTEST_F(SceneSessionTest, NotifyIsCustomAnimationPlaying, Function | SmallTest sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); sceneSession->NotifyIsCustomAnimationPlaying(false); - + sceneSession->onIsCustomAnimationPlaying_ = [](bool status) {}; sceneSession->NotifyIsCustomAnimationPlaying(false); } From a4ad97cc627c69dba881b0847d95dd03d64577e8 Mon Sep 17 00:00:00 2001 From: jjxxx123 Date: Sat, 2 Nov 2024 11:30:24 +0800 Subject: [PATCH 057/132] =?UTF-8?q?ostringstream=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jjxxx123 --- .../src/scene_input_manager.cpp | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 4310493b45..82332a15a7 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -158,13 +158,19 @@ 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.dp + << " 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 +405,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 +415,20 @@ 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 +437,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 +450,21 @@ 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); + displayListStream << ","; } + + std::string displayList = displayListStream.str(); if (lastDisplayList != displayList) { TLOGI(WmsLogTag::WMS_EVENT, "num:%{public}d,displayList:%{public}s", displayListSize, displayList.c_str()); lastDisplayList = displayList; From 7f5a43c4a4780a8c71db431c7ee6da40ad15e302 Mon Sep 17 00:00:00 2001 From: c30063259 Date: Sat, 2 Nov 2024 11:48:28 +0800 Subject: [PATCH 058/132] add Signed-off-by: c30063259 --- window_scene/test/unittest/scene_session_manager_test10.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index a44bc8d43a..dbfbbe86fc 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -713,7 +713,7 @@ HWTEST_F(SceneSessionManagerTest10, NotifyStatusBarShowStatus, Function | SmallT * @tc.desc: IsNeedSkipWindowModeTypeCheck * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest6, IsNeedSkipWindowModeTypeCheck, Function | SmallTest | Level3) +HWTEST_F(SceneSessionManagerTest10, IsNeedSkipWindowModeTypeCheck, Function | SmallTest | Level3) { SessionInfo sessionInfo; sessionInfo.bundleName_ = "SceneSessionManagerTest6"; From 307993b87cf62f2c7322f1df35c5df59c08e8ac7 Mon Sep 17 00:00:00 2001 From: c30063259 Date: Sat, 2 Nov 2024 11:50:04 +0800 Subject: [PATCH 059/132] add Signed-off-by: c30063259 --- window_scene/test/unittest/scene_session_manager_test10.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index dbfbbe86fc..e8bb7af568 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -716,7 +716,7 @@ HWTEST_F(SceneSessionManagerTest10, NotifyStatusBarShowStatus, Function | SmallT HWTEST_F(SceneSessionManagerTest10, IsNeedSkipWindowModeTypeCheck, Function | SmallTest | Level3) { SessionInfo sessionInfo; - sessionInfo.bundleName_ = "SceneSessionManagerTest6"; + sessionInfo.bundleName_ = "IsNeedSkipWindowModeTypeCheck"; sessionInfo.abilityName_ = "IsNeedSkipWindowModeTypeCheck"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(nullptr, sceneSession); From 3ff46cfde06fef4a306ac624c28a2a7c1f9f1fde Mon Sep 17 00:00:00 2001 From: c30063259 Date: Sat, 2 Nov 2024 14:23:36 +0800 Subject: [PATCH 060/132] add Signed-off-by: c30063259 --- window_scene/test/unittest/scene_session_manager_test10.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index e8bb7af568..12594c64ca 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -722,10 +722,12 @@ HWTEST_F(SceneSessionManagerTest10, IsNeedSkipWindowModeTypeCheck, Function | Sm ASSERT_NE(nullptr, sceneSession); ASSERT_NE(nullptr, sceneSession->property_); sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - sceneSession->SetRSVisible(true); + sceneSession->SetRSVisible(false); sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); ASSERT_TRUE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, false)); - sceneSession->SetRSVisible(false); + sceneSession->SetRSVisible(true); + DisplayId displayId = 1001; + sceneSession->property_->SetDisplayId(displayId); ASSERT_TRUE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, true)); ASSERT_FALSE(ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, false)); } From 2049ec166398bfd0e8ada70d1f7b3e6f6e315936 Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 2 Nov 2024 14:32:07 +0800 Subject: [PATCH 061/132] amend Signed-off-by: francis --- .../test/unittest/scene_session_test.cpp | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 5bf1a11a9f..9f681a27af 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -601,17 +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 sceneSessionb = 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 = 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()); } /** @@ -630,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); @@ -641,17 +639,17 @@ HWTEST_F(SceneSessionTest, IsDecorEnable01, Function | SmallTest | Level2) sceneSession->property_ = property; ASSERT_EQ(true, sceneSession->IsDecorEnable()); - sptr 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()); } /** From 060979fa9522e42bc96aad8e1b5f7b254bc366a9 Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 2 Nov 2024 14:57:23 +0800 Subject: [PATCH 062/132] amend Signed-off-by: francis --- window_scene/test/unittest/scene_session_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 9f681a27af..34cb3eb7b6 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -601,7 +601,7 @@ HWTEST_F(SceneSessionTest, IsDecorEnable, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - sptr sceneSessionb = 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_; From 691d8813374f90c606aedc56588b7d6360ea13c6 Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 2 Nov 2024 15:04:00 +0800 Subject: [PATCH 063/132] fix Signed-off-by: francis --- .../unittest/window_session_property_test.cpp | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index cca34a0f3c..f3fcb69d38 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -537,7 +537,7 @@ HWTEST_F(WindowSessionPropertyTest, CopyFrom, Function | SmallTest | Level2) HWTEST_F(WindowSessionPropertyTest, SetFocusable, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetFocusable(), true); property->SetFocusable(false); ASSERT_EQ(property->GetFocusable(), false); @@ -551,7 +551,7 @@ HWTEST_F(WindowSessionPropertyTest, SetFocusable, Function | SmallTest | Level2) HWTEST_F(WindowSessionPropertyTest, SetTouchable, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetTouchable(), true); property->SetTouchable(false); ASSERT_EQ(property->GetTouchable(), false); @@ -565,7 +565,7 @@ HWTEST_F(WindowSessionPropertyTest, SetTouchable, Function | SmallTest | Level2) HWTEST_F(WindowSessionPropertyTest, SetForceHide, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetForceHide(), false); property->SetForceHide(true); ASSERT_EQ(property->GetForceHide(), true); @@ -579,7 +579,7 @@ HWTEST_F(WindowSessionPropertyTest, SetForceHide, Function | SmallTest | Level2) HWTEST_F(WindowSessionPropertyTest, SetSystemCalling, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetSystemCalling(), false); property->SetSystemCalling(true); ASSERT_EQ(property->GetSystemCalling(), true); @@ -593,7 +593,7 @@ HWTEST_F(WindowSessionPropertyTest, SetSystemCalling, Function | SmallTest | Lev HWTEST_F(WindowSessionPropertyTest, SetIsNeedUpdateWindowMode, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetIsNeedUpdateWindowMode(), false); property->SetIsNeedUpdateWindowMode(true); ASSERT_EQ(property->GetIsNeedUpdateWindowMode(), true); @@ -607,7 +607,7 @@ HWTEST_F(WindowSessionPropertyTest, SetIsNeedUpdateWindowMode, Function | SmallT HWTEST_F(WindowSessionPropertyTest, SetIsShaped, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetIsShaped(), false); property->SetIsShaped(true); ASSERT_EQ(property->GetIsShaped(), true); @@ -621,7 +621,7 @@ HWTEST_F(WindowSessionPropertyTest, SetIsShaped, Function | SmallTest | Level2) HWTEST_F(WindowSessionPropertyTest, SetHideNonSystemFloatingWindows, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetHideNonSystemFloatingWindows(), false); property->SetHideNonSystemFloatingWindows(true); ASSERT_EQ(property->GetHideNonSystemFloatingWindows(), true); @@ -635,7 +635,7 @@ HWTEST_F(WindowSessionPropertyTest, SetHideNonSystemFloatingWindows, Function | HWTEST_F(WindowSessionPropertyTest, KeepKeyboardOnFocus, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->GetKeepKeyboardFlag(), false); property->KeepKeyboardOnFocus(true); ASSERT_EQ(property->GetKeepKeyboardFlag(), true); @@ -649,7 +649,7 @@ HWTEST_F(WindowSessionPropertyTest, KeepKeyboardOnFocus, Function | SmallTest | HWTEST_F(WindowSessionPropertyTest, SetTextFieldPositionY, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); property->SetTextFieldPositionY(5.5); ASSERT_EQ(property->GetTextFieldPositionY(), 5.5); } @@ -662,7 +662,7 @@ HWTEST_F(WindowSessionPropertyTest, SetTextFieldPositionY, Function | SmallTest HWTEST_F(WindowSessionPropertyTest, SetTextFieldHeight, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); property->SetTextFieldHeight(5.5); ASSERT_EQ(property->GetTextFieldHeight(), 5.5); } @@ -675,7 +675,7 @@ HWTEST_F(WindowSessionPropertyTest, SetTextFieldHeight, Function | SmallTest | L HWTEST_F(WindowSessionPropertyTest, SetIsLayoutFullScreen, Function | SmallTest | Level2) { sptr property = new WindowSessionProperty(); - ASSER_NE(nullptr, property); + ASSERT_NE(nullptr, property); ASSERT_EQ(property->IsLayoutFullScreen(), false); property->SetIsLayoutFullScreen(true); ASSERT_EQ(property->IsLayoutFullScreen(), true); @@ -764,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 From 0ef411302bb64ed7f93c5d41897f522059fd0045 Mon Sep 17 00:00:00 2001 From: tanchenghao Date: Thu, 31 Oct 2024 14:40:09 +0800 Subject: [PATCH 064/132] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E6=88=96=E4=BD=BF?= =?UTF-8?q?=E8=83=BD=E7=A7=BB=E5=8A=A8=E7=AA=97=E5=8F=A3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanchenghao --- interfaces/innerkits/wm/window.h | 8 ++++ .../window_runtime/window_napi/js_window.cpp | 43 +++++++++++++++++++ .../window_runtime/window_napi/js_window.h | 2 + previewer/include/window.h | 1 + wm/include/window_session_impl.h | 1 + wm/src/window_session_impl.cpp | 23 ++++++++++ .../unittest/window_session_impl_test4.cpp | 34 +++++++++++++++ wm/test/unittest/window_test.cpp | 1 + 8 files changed, 113 insertions(+) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 418daf23db..2c9079a080 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1947,6 +1947,14 @@ public: */ virtual WMError SetDecorVisible(bool isVisible) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Enable or disable move window. + * + * @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. * 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 c92489fe51..309ec4d2ba 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -835,6 +835,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) +{ + TLOGI(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]"); @@ -6152,6 +6159,41 @@ 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 = 4; + napi_value argv[4] = {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); + } + if (windowToken_ == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken_ is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + napi_value nativeVal = argv[0]; + if (nativeVal == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to visible"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + bool enable = true; + WmErrorCode errCode = WmErrorCode::WM_OK; + CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM, + napi_get_value_bool(env, nativeVal, &enable)); + if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + 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; @@ -7045,6 +7087,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 a8896ea421..efd9c64452 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -158,6 +158,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); @@ -243,6 +244,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/previewer/include/window.h b/previewer/include/window.h index c0e3fd5aa0..33660abeca 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -326,6 +326,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) { diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index b1311efed2..989a45aada 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -256,6 +256,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; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index fa9d20e2ed..686aabde80 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1909,6 +1909,29 @@ WMError WindowSessionImpl::SetDecorVisible(bool isVisible) return WMError::WM_OK; } +WMError WindowSessionImpl::SetWindowTitleMoveEnabled(bool enable) +{ + 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; + } + if (IsWindowSessionInvalid()) { + return WMError::WM_ERROR_INVALID_WINDOW; + } + 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, "end"); + return WMError::WM_OK; +} + WMError WindowSessionImpl::SetSubWindowModal(bool isModal, ModalityType modalityType) { if (IsWindowSessionInvalid()) { diff --git a/wm/test/unittest/window_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index 5b59e18b13..89c44d985b 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -259,6 +259,40 @@ 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 = new WindowOption(); + ASSERT_NE(option, nullptr); + option->SetWindowName("SetWindowTitleMoveEnabled"); + sptr window = new (std::nothrow) WindowSessionImpl(option); + ASSERT_NE(window, nullptr); + ASSERT_NE(window->property_, nullptr); + window->property_->SetPersistentId(1); + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; + sptr session = sptr::MakeSptr(sessionInfo); + ASSERT_NE(nullptr, session); + window->hostSession_ = session; + + bool enable = true; + WMError res = window->SetWindowTitleMoveEnabled(enable); + ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); + + window->uiContent_ = std::make_unique(); + res = window->SetWindowTitleMoveEnabled(enable); + ASSERT_EQ(res, WMError::WM_OK); + + enable = false; + res = window->SetWindowTitleMoveEnabled(enable); + ASSERT_EQ(res, WMError::WM_OK); + GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetWindowTitleMoveEnabledtest01 end"; +} + /** * @tc.name: SetSubWindowModal * @tc.desc: SetSubWindowModal and check the retCode diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index d53d2a8d97..a58da2903a 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -2624,6 +2624,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)); From 8bdf7ee26095b60f4959a14a76a9b0cee0c1c09c Mon Sep 17 00:00:00 2001 From: 18 <571095797@qq.com> Date: Sat, 2 Nov 2024 07:30:54 +0000 Subject: [PATCH 065/132] =?UTF-8?q?update=20wm/src/window=5Fscene=5Fsessio?= =?UTF-8?q?n=5Fimpl.cpp.=20=E4=BF=AE=E5=A4=8D=E5=AD=90=E7=AA=97=E4=B8=ADab?= =?UTF-8?q?outToapper=E8=8E=B7=E5=8F=96windowRect=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E4=B8=BA0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18 <571095797@qq.com> --- wm/src/window_scene_session_impl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index faf65aa31d..9e2bd069c6 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 sptr SetWindowRect(requestRect); hostSession->UpdateClientRect(wsRect); } else { TLOGE(WmsLogTag::DEFAULT, "hostSession is null"); From 3466a394b2a77cca869eca4c4a34fd402da33fcb Mon Sep 17 00:00:00 2001 From: huangji731 Date: Sat, 2 Nov 2024 15:32:43 +0800 Subject: [PATCH 066/132] https://gitee.com/openharmony/window_window_manager/issues/IB1LZS Signed-off-by: huangji731 --- dm/src/oh_display_manager.cpp | 78 ++++++++----------- dm/src/oh_display_manager_inner.h | 9 +++ interfaces/kits/dmndk/dm/oh_display_capture.h | 4 +- interfaces/kits/dmndk/dm/oh_display_manager.h | 9 ++- interfaces/kits/dmndk/libdm.ndk.json | 6 +- 5 files changed, 53 insertions(+), 53 deletions(-) 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/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 From 59232c986883c5d8054ebe676c284a5836a9a7c1 Mon Sep 17 00:00:00 2001 From: 18 <571095797@qq.com> Date: Sat, 2 Nov 2024 07:45:25 +0000 Subject: [PATCH 067/132] =?UTF-8?q?update=20wm/src/window=5Fscene=5Fsessio?= =?UTF-8?q?n=5Fimpl.cpp.=20=E4=BF=AE=E5=A4=8D=E5=AD=90=E7=AA=97aboutToappe?= =?UTF-8?q?ar=E4=B8=AD=E8=8E=B7=E5=8F=96windowrect=E4=B8=BA0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18 <571095797@qq.com> --- wm/src/window_scene_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 9e2bd069c6..6882660f80 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1069,7 +1069,7 @@ void WindowSceneSessionImpl::PreLayoutOnShow(WindowType type, const sptr SetWindowRect(requestRect); + property_->SetWindowRect(requestRect); hostSession->UpdateClientRect(wsRect); } else { TLOGE(WmsLogTag::DEFAULT, "hostSession is null"); From 6ac9ab55e61595233f9bd74c85325cf956ff70b1 Mon Sep 17 00:00:00 2001 From: fukun <214202095@qq.com> Date: Sat, 2 Nov 2024 08:10:52 +0000 Subject: [PATCH 068/132] =?UTF-8?q?update=20window=5Fscene/session=5Fmanag?= =?UTF-8?q?er/src/scene=5Fsession=5Fmanager.cpp.=20=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E9=80=9A=E8=AF=9D=E7=9E=AC=E9=97=B4=EF=BC=8C=E4=B8=8D=E5=93=8D?= =?UTF-8?q?=E5=BA=94back=E6=89=8B=E5=8A=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fukun <214202095@qq.com> --- window_scene/session_manager/src/scene_session_manager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5d141b4369..9ed5ae4bd7 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3205,6 +3205,12 @@ WSError SceneSessionManager::ProcessBackEvent() WLOGFI("ProcessBackEvent session persistentId:%{public}d needBlock::%{public}d", focusedSessionId_, needBlockNotifyFocusStatusUntilForeground_); if (needBlockNotifyFocusStatusUntilForeground_) { + WLOGFD("RequestSessionBack when start session"); + if (session->GetSessionInfo().abilityInfo != nullptr && + session->GetSessionInfo().abilityInfo->unclearableMission) { + TLOGI(WmsLogTag::WMS_MAIN, "backPress unclearableMission"); + return WSError::WS_OK; + } session->RequestSessionBack(true); return WSError::WS_OK; } From 85991bdcfa3b18c3a89acab83af081fa639d1989 Mon Sep 17 00:00:00 2001 From: Xiaye Date: Sat, 2 Nov 2024 11:00:35 +0800 Subject: [PATCH 069/132] fix code format Signed-off-by: Xiaye --- .../js_scene_session_manager.cpp | 8 ++++---- .../session_manager/include/scene_session_manager.h | 12 ++++++------ .../session_manager/src/scene_session_manager.cpp | 11 +++++++---- .../src/session_manager_agent_controller.cpp | 2 +- wm/src/window_adapter_lite.cpp | 1 - 5 files changed, 18 insertions(+), 16 deletions(-) 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/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index d20fd06b8c..f1342760ce 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -460,12 +460,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 +485,12 @@ public: */ WMError ReleaseForegroundSessionScreenLock() override; + /* + * PiP Window + */ + WMError CloseTargetPiPWindow(const std::string& bundleName); + WMError GetCurrentPiPWindowInfo(std::string& bundleName); + /* * Window displayId */ diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 43375ac182..b93edb657d 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10993,7 +10993,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) @@ -11008,7 +11011,7 @@ WMError SceneSessionManager::CloseTargetFloatWindow(const std::string& bundleNam closeTargetFloatWindowFunc_(bundleName); } }; - taskScheduler_->PostTask(task, "CloseTargetFloatWindow"); + taskScheduler_->PostTask(task, __func__); return WMError::WM_OK; } @@ -11024,7 +11027,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) { @@ -11042,7 +11045,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/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); From a10c5e88decc9f212da6a183f53ea5c174e06bf4 Mon Sep 17 00:00:00 2001 From: shulssins Date: Fri, 1 Nov 2024 19:57:38 +0800 Subject: [PATCH 070/132] =?UTF-8?q?=E5=BC=80=E5=90=88=E7=9B=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shulssins --- .../include/screen_session_manager.h | 1 + .../include/screen_setting_helper.h | 5 +- .../src/multi_screen_manager.cpp | 6 +- .../src/screen_session_manager.cpp | 7 ++- .../src/screen_setting_helper.cpp | 55 ++++++++----------- .../multi_screen_manager_test.cpp | 8 +-- 6 files changed, 40 insertions(+), 42 deletions(-) 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/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_session_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 4eae711eed..b12e86bf55 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -1508,6 +1508,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 +2353,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); } 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::vectorGetIsExtend()); 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 From ca04458357dee2b17b15f28264ec7527be6c5a91 Mon Sep 17 00:00:00 2001 From: fukun <214202095@qq.com> Date: Sat, 2 Nov 2024 09:24:37 +0000 Subject: [PATCH 071/132] =?UTF-8?q?update=20window=5Fscene/session=5Fmanag?= =?UTF-8?q?er/src/scene=5Fsession=5Fmanager.cpp.=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=AE=8F=E4=B8=BATLOGNI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fukun <214202095@qq.com> --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 9ed5ae4bd7..8706d3f7e9 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3208,7 +3208,7 @@ WSError SceneSessionManager::ProcessBackEvent() WLOGFD("RequestSessionBack when start session"); if (session->GetSessionInfo().abilityInfo != nullptr && session->GetSessionInfo().abilityInfo->unclearableMission) { - TLOGI(WmsLogTag::WMS_MAIN, "backPress unclearableMission"); + TLOGNI(WmsLogTag::WMS_MAIN, "backPress unclearableMission"); return WSError::WS_OK; } session->RequestSessionBack(true); From f31da24f03d151253bdd2de0a774a5c9cee5f4b3 Mon Sep 17 00:00:00 2001 From: tanchenghao Date: Sat, 2 Nov 2024 17:32:01 +0800 Subject: [PATCH 072/132] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E4=BD=BF=E8=83=BD?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AA=97=E5=8F=A3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanchenghao --- interfaces/innerkits/wm/window.h | 2 +- .../window_runtime/window_napi/js_window.cpp | 2 +- wm/src/window_session_impl.cpp | 6 ++-- .../unittest/window_session_impl_test4.cpp | 31 +++++++++++-------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 2c9079a080..bf8fb10895 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1948,7 +1948,7 @@ public: virtual WMError SetDecorVisible(bool isVisible) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } /** - * @brief Enable or disable move window. + * @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. 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 309ec4d2ba..6f0c56d6b7 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -6164,7 +6164,7 @@ napi_value JsWindow::OnSetWindowTitleMoveEnabled(napi_env env, napi_callback_inf size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc < 1) { + if (argc != 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 686aabde80..ab55b07e79 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1911,6 +1911,9 @@ WMError WindowSessionImpl::SetDecorVisible(bool isVisible) 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; @@ -1919,9 +1922,6 @@ WMError WindowSessionImpl::SetWindowTitleMoveEnabled(bool enable) TLOGE(WmsLogTag::WMS_LAYOUT, "called by invalid window type, type:%{public}d", GetType()); return WMError::WM_ERROR_INVALID_CALLING; } - if (IsWindowSessionInvalid()) { - return WMError::WM_ERROR_INVALID_WINDOW; - } std::shared_ptr uiContent = GetUIContentSharedPtr(); if (uiContent == nullptr) { TLOGE(WmsLogTag::WMS_LAYOUT, "uicontent is null"); diff --git a/wm/test/unittest/window_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index 89c44d985b..f15318836d 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -267,29 +267,34 @@ HWTEST_F(WindowSessionImplTest4, SetDecorVisible, Function | SmallTest | Level2) HWTEST_F(WindowSessionImplTest4, SetWindowTitleMoveEnabled, Function | SmallTest | Level2) { GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetWindowTitleMoveEnabledtest01 start"; - sptr option = new WindowOption(); + sptr option = sptr::MakeSptr(); ASSERT_NE(option, nullptr); option->SetWindowName("SetWindowTitleMoveEnabled"); - sptr window = new (std::nothrow) WindowSessionImpl(option); + sptr window = sptr::MakeSptr(option); ASSERT_NE(window, nullptr); + WMError res = window->SetWindowTitleMoveEnabled(true); + EXPECT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); ASSERT_NE(window->property_, nullptr); window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = sptr::MakeSptr(sessionInfo); ASSERT_NE(nullptr, session); window->hostSession_ = session; - - bool enable = true; - WMError res = window->SetWindowTitleMoveEnabled(enable); - ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); - + 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(enable); - ASSERT_EQ(res, WMError::WM_OK); - - enable = false; - res = window->SetWindowTitleMoveEnabled(enable); - ASSERT_EQ(res, WMError::WM_OK); + 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"; } From f6b84d2bc2099c874b4a30c6c1a87862df29a4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Sat, 2 Nov 2024 09:54:57 +0000 Subject: [PATCH 073/132] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E7=AA=97?= =?UTF-8?q?=E9=80=80=E5=90=8E=E5=8F=B0=E6=97=B6=EF=BC=8C=E5=A4=9A=E7=BA=A7?= =?UTF-8?q?=E5=AD=90=E7=AA=97dump=20=E6=98=BE=E7=A4=BA=E5=9C=A8=E5=89=8D?= =?UTF-8?q?=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- window_scene/session/host/include/session.h | 2 +- window_scene/session/host/src/session.cpp | 4 ++-- window_scene/session/host/src/sub_session.cpp | 2 +- .../src/scene_session_manager.cpp | 18 +++++++++--------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 7349fcdfa1..44e7311e22 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -284,7 +284,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; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 6b3fe3c492..c1b1995a35 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1681,10 +1681,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 { diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index 1495cf101a..78cab53c40 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -205,7 +205,7 @@ bool SubSession::IsModal() const bool SubSession::IsVisibleForeground() const { - auto mainSession = GetMainSession(); + const auto& mainSession = GetMainSession(); if (mainSession && WindowHelper::IsMainWindow(mainSession->GetWindowType())) { return mainSession->IsVisibleForeground() && Session::IsVisibleForeground(); } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3cce7733c9..dafbfca849 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4138,21 +4138,21 @@ 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()); + 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& parentState = 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()); + 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()); + LOGD(WmsLogTag::WMS_SUB, "Sub window is at background, id: %{public}d", session->GetPersistentId()); return false; } @@ -7498,8 +7498,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); } } From 94af0a92c4dd842cc20befadc036a1a370715674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Sat, 2 Nov 2024 10:10:59 +0000 Subject: [PATCH 074/132] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E7=AA=97?= =?UTF-8?q?=E9=80=80=E5=90=8E=E5=8F=B0=E6=97=B6=EF=BC=8C=E5=A4=9A=E7=BA=A7?= =?UTF-8?q?=E5=AD=90=E7=AA=97dump=20=E6=98=BE=E7=A4=BA=E5=9C=A8=E5=89=8D?= =?UTF-8?q?=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index dafbfca849..57453383ac 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4138,7 +4138,7 @@ bool SceneSessionManager::IsSessionVisible(const sptr& session) } const auto& state = session->GetSessionState(); if (WindowHelper::IsSubWindow(session->GetWindowType())) { - auto mainSession = session->GetMainSession(); + 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; From 1db22f4d4555a050268a9a683cfc975b584bff3b Mon Sep 17 00:00:00 2001 From: fukun <214202095@qq.com> Date: Sat, 2 Nov 2024 10:11:21 +0000 Subject: [PATCH 075/132] =?UTF-8?q?update=20window=5Fscene/session=5Fmanag?= =?UTF-8?q?er/src/scene=5Fsession=5Fmanager.cpp.=20=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=AE=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fukun <214202095@qq.com> --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 8706d3f7e9..2c60eb0a7e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3202,10 +3202,10 @@ WSError SceneSessionManager::ProcessBackEvent() WLOGFE("session is nullptr: %{public}d", focusedSessionId_); return WSError::WS_ERROR_INVALID_SESSION; } - WLOGFI("ProcessBackEvent session persistentId:%{public}d needBlock::%{public}d", + TLOGNI("ProcessBackEvent session persistentId:%{public}d needBlock::%{public}d", focusedSessionId_, needBlockNotifyFocusStatusUntilForeground_); if (needBlockNotifyFocusStatusUntilForeground_) { - WLOGFD("RequestSessionBack when start session"); + TLOGND("RequestSessionBack when start session"); if (session->GetSessionInfo().abilityInfo != nullptr && session->GetSessionInfo().abilityInfo->unclearableMission) { TLOGNI(WmsLogTag::WMS_MAIN, "backPress unclearableMission"); From 82823ae318420147ebde29ef8aa3a4b94171db98 Mon Sep 17 00:00:00 2001 From: fukun <214202095@qq.com> Date: Sat, 2 Nov 2024 10:14:40 +0000 Subject: [PATCH 076/132] =?UTF-8?q?update=20window=5Fscene/session=5Fmanag?= =?UTF-8?q?er/src/scene=5Fsession=5Fmanager.cpp.=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=AE=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fukun <214202095@qq.com> --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 2c60eb0a7e..87a938cc69 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3199,7 +3199,7 @@ WSError SceneSessionManager::ProcessBackEvent() auto task = [this]() { auto session = GetSceneSession(focusedSessionId_); if (!session) { - WLOGFE("session is nullptr: %{public}d", focusedSessionId_); + TLOGNE("session is nullptr: %{public}d", focusedSessionId_); return WSError::WS_ERROR_INVALID_SESSION; } TLOGNI("ProcessBackEvent session persistentId:%{public}d needBlock::%{public}d", From 03ec64061f464dea45f463b6f1c906018747a36f Mon Sep 17 00:00:00 2001 From: fukun <214202095@qq.com> Date: Sat, 2 Nov 2024 10:18:00 +0000 Subject: [PATCH 077/132] =?UTF-8?q?update=20window=5Fscene/session=5Fmanag?= =?UTF-8?q?er/src/scene=5Fsession=5Fmanager.cpp.=20=E4=BF=AE=E6=94=B9Proce?= =?UTF-8?q?ssBackEvent=E5=AD=97=E7=AC=A6=E4=B8=B2=E4=B8=BA=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fukun <214202095@qq.com> --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 87a938cc69..6aa63b33e7 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3222,7 +3222,7 @@ WSError SceneSessionManager::ProcessBackEvent() return WSError::WS_OK; }; - taskScheduler_->PostAsyncTask(task, "ProcessBackEvent"); + taskScheduler_->PostAsyncTask(task, __func__); return WSError::WS_OK; } From ff19b149281ba57c50db160d240781bbd08a476c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Sat, 2 Nov 2024 10:20:41 +0000 Subject: [PATCH 078/132] =?UTF-8?q?=E5=91=BD=E5=90=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 57453383ac..c89702ff8e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4143,9 +4143,9 @@ bool SceneSessionManager::IsSessionVisible(const sptr& session) TLOGE(WmsLogTag::WMS_SUB, "Can not find parent for this sub window, id: %{public}d", session->GetPersistentId()); return false; } - const auto& parentState = mainSession->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) { + 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; } From 59ade2f50551ae6e6bbae540467ee40e2843c2b4 Mon Sep 17 00:00:00 2001 From: fukun <214202095@qq.com> Date: Sat, 2 Nov 2024 10:22:19 +0000 Subject: [PATCH 079/132] =?UTF-8?q?update=20window=5Fscene/session=5Fmanag?= =?UTF-8?q?er/src/scene=5Fsession=5Fmanager.cpp.=20=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fukun <214202095@qq.com> --- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 6aa63b33e7..8a9ff46014 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3199,13 +3199,13 @@ WSError SceneSessionManager::ProcessBackEvent() auto task = [this]() { auto session = GetSceneSession(focusedSessionId_); if (!session) { - TLOGNE("session is nullptr: %{public}d", focusedSessionId_); + TLOGNE(WmsLogTag::WMS_MAIN, "session is nullptr: %{public}d", focusedSessionId_); return WSError::WS_ERROR_INVALID_SESSION; } - TLOGNI("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("RequestSessionBack when start session"); + TLOGND(WmsLogTag::WMS_MAIN, "RequestSessionBack when start session"); if (session->GetSessionInfo().abilityInfo != nullptr && session->GetSessionInfo().abilityInfo->unclearableMission) { TLOGNI(WmsLogTag::WMS_MAIN, "backPress unclearableMission"); From 974cba5b00b46b5223215b342bff0026975e44fd Mon Sep 17 00:00:00 2001 From: tanchenghao Date: Sat, 2 Nov 2024 17:48:51 +0800 Subject: [PATCH 080/132] =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanchenghao --- .../window_runtime/window_napi/js_window.cpp | 25 +++++++------------ wm/src/window_session_impl.cpp | 2 +- .../unittest/window_session_impl_test4.cpp | 5 ++-- 3 files changed, 12 insertions(+), 20 deletions(-) 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 6f0c56d6b7..60c5387a9d 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -837,7 +837,7 @@ napi_value JsWindow::SetWindowDecorVisible(napi_env env, napi_callback_info info napi_value JsWindow::SetWindowTitleMoveEnabled(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_LAYOUT, "[NAPI]"); + TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetWindowTitleMoveEnabled(env, info) : nullptr; } @@ -6161,29 +6161,22 @@ napi_value JsWindow::OnSetWindowDecorVisible(napi_env env, napi_callback_info in napi_value JsWindow::OnSetWindowTitleMoveEnabled(napi_env env, napi_callback_info info) { - size_t argc = 4; - napi_value argv[4] = {nullptr}; + 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); } - if (windowToken_ == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); - } - napi_value nativeVal = argv[0]; - if (nativeVal == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to visible"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); - } bool enable = true; - WmErrorCode errCode = WmErrorCode::WM_OK; - CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM, - napi_get_value_bool(env, nativeVal, &enable)); - if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { + 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"); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index ab55b07e79..8abc2af41b 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1928,7 +1928,7 @@ WMError WindowSessionImpl::SetWindowTitleMoveEnabled(bool enable) return WMError::WM_ERROR_NULLPTR; } uiContent->EnableContainerModalGesture(enable); - TLOGI(WmsLogTag::WMS_LAYOUT, "end"); + TLOGI(WmsLogTag::WMS_LAYOUT, "enable:%{public}d end", enable); return WMError::WM_OK; } diff --git a/wm/test/unittest/window_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index f15318836d..051b74eb52 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -274,7 +274,6 @@ HWTEST_F(WindowSessionImplTest4, SetWindowTitleMoveEnabled, Function | SmallTest ASSERT_NE(window, nullptr); WMError res = window->SetWindowTitleMoveEnabled(true); EXPECT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); - ASSERT_NE(window->property_, nullptr); window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = sptr::MakeSptr(sessionInfo); @@ -284,10 +283,10 @@ HWTEST_F(WindowSessionImplTest4, SetWindowTitleMoveEnabled, Function | SmallTest 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); + 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); + 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(); From a9fbe8ba9679c76cadd4dd624db79e3fea3e6e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Sat, 2 Nov 2024 11:49:53 +0000 Subject: [PATCH 081/132] =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c89702ff8e..971bd2ea6e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4152,7 +4152,7 @@ bool SceneSessionManager::IsSessionVisible(const sptr& session) TLOGD(WmsLogTag::WMS_SUB, "Sub window is at foreground, id: %{public}d", session->GetPersistentId()); return true; } - LOGD(WmsLogTag::WMS_SUB, "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; } From f2257a7a5b6671ce2f141558f3b8784182dfb1f1 Mon Sep 17 00:00:00 2001 From: Laiganlu Date: Mon, 4 Nov 2024 09:10:22 +0800 Subject: [PATCH 082/132] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Laiganlu --- window_scene/session_manager/src/scene_session_manager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 794b1f9c13..dd2a14a8a2 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -9596,10 +9596,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); From b1a3a334911adceb71e28597de06155606d776c2 Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Mon, 4 Nov 2024 10:01:04 +0800 Subject: [PATCH 083/132] add tdd Signed-off-by: ZihaoWU --- .../unittest/scene_session_manager_test6.cpp | 76 +++++++++++++++---- 1 file changed, 62 insertions(+), 14 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index c78a6dfea9..2708466957 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -1065,43 +1065,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); + 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_); + sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); + ASSERT_NE(nullptr, sceneSession); 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_); + 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); 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(1, infos.size()); + EXPECT_NE(1, infos[0]->displayId_); } /** From 8f1b9d277649d23230a143b9c47e80aef3854b1d Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Mon, 4 Nov 2024 10:39:50 +0800 Subject: [PATCH 084/132] add tdd Signed-off-by: ZihaoWU --- window_scene/test/unittest/scene_session_manager_test6.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index 2708466957..75d6329184 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -1100,7 +1100,7 @@ HWTEST_F(SceneSessionManagerTest6, FillWindowInfo02, Function | SmallTest | Leve sessionInfo.abilityName_ = "FillWindowInfo02"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(nullptr, sceneSession); - ret = ssm_->FillWindowInfo(infos, sceneSession); + auto ret = ssm_->FillWindowInfo(infos, sceneSession); EXPECT_EQ(false, ret); EXPECT_EQ(0, infos.size()); } @@ -1120,7 +1120,7 @@ HWTEST_F(SceneSessionManagerTest6, FillWindowInfo03, Function | SmallTest | Leve sessionInfo.isSystem_ = true; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(nullptr, sceneSession); - ret = ssm_->FillWindowInfo(infos, sceneSession); + auto ret = ssm_->FillWindowInfo(infos, sceneSession); EXPECT_EQ(true, ret); EXPECT_EQ(1, infos.size()); EXPECT_EQ(1, infos[0]->wid_); @@ -1141,7 +1141,7 @@ HWTEST_F(SceneSessionManagerTest6, FillWindowInfo04, Function | SmallTest | Leve sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(nullptr, sceneSession); sceneSession->property_->SetDisplayId(1); - ret = ssm_->FillWindowInfo(infos, sceneSession); + auto ret = ssm_->FillWindowInfo(infos, sceneSession); EXPECT_EQ(true, ret); EXPECT_EQ(1, infos.size()); EXPECT_EQ(1, infos[0]->displayId_); From 58ef91957ce9cc464d861f56ec5990e34b085cba Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Mon, 4 Nov 2024 11:08:17 +0800 Subject: [PATCH 085/132] add tdd Signed-off-by: ZihaoWU --- window_scene/test/unittest/scene_session_manager_test6.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index 75d6329184..0bb69a5182 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -1148,7 +1148,7 @@ HWTEST_F(SceneSessionManagerTest6, FillWindowInfo04, Function | SmallTest | Leve sceneSession->property_ = nullptr; ret = ssm_->FillWindowInfo(infos, sceneSession); EXPECT_EQ(true, ret); - EXPECT_EQ(1, infos.size()); + EXPECT_EQ(2, infos.size()); EXPECT_NE(1, infos[0]->displayId_); } From e49533ba50cafbaaaecc5bccfa8042ab501b7ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Mon, 4 Nov 2024 03:09:05 +0000 Subject: [PATCH 086/132] update wm/test/unittest/window_scene_session_impl_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- wm/test/unittest/window_scene_session_impl_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 1721054a6d..58e6bf0059 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1427,7 +1427,7 @@ HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn01, Function | SmallTest | L * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn02, Function | SmallTest | Level3) -{ +{ sptr option = new (std::nothrow) WindowOption(); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); window->property_->SetWindowName("SetKeepScreenOn"); From 399a737e28d5f584aacaa7f707a1a1c05c403ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Mon, 4 Nov 2024 03:12:44 +0000 Subject: [PATCH 087/132] update wm/test/unittest/window_scene_session_impl_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- .../unittest/window_scene_session_impl_test.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 58e6bf0059..89c9139b20 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1413,8 +1413,10 @@ HWTEST_F(WindowSceneSessionImplTest, SetBlur, 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)); @@ -1427,9 +1429,11 @@ HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn01, Function | SmallTest | L * @tc.type: FUNC */ HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn02, 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); window->property_->SetPersistentId(1); From cc97169dc38f70b3f71c3518ec660c8e71ff76b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Mon, 4 Nov 2024 03:16:36 +0000 Subject: [PATCH 088/132] update wm/test/unittest/window_scene_session_impl_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- wm/test/unittest/window_scene_session_impl_test.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 89c9139b20..91a54d3ace 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1414,9 +1414,7 @@ HWTEST_F(WindowSceneSessionImplTest, SetBlur, Function | SmallTest | Level3) HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn01, 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); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetKeepScreenOn(false)); @@ -1431,14 +1429,12 @@ HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn01, Function | SmallTest | L 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)); From 6d2fe868edc143066d0d3c9ac6e015aa3842e57f Mon Sep 17 00:00:00 2001 From: ZihaoWU Date: Mon, 4 Nov 2024 11:21:46 +0800 Subject: [PATCH 089/132] add tdd Signed-off-by: ZihaoWU --- window_scene/test/unittest/scene_session_manager_test6.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index 0bb69a5182..b4fa9dd054 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -1149,7 +1149,7 @@ HWTEST_F(SceneSessionManagerTest6, FillWindowInfo04, Function | SmallTest | Leve ret = ssm_->FillWindowInfo(infos, sceneSession); EXPECT_EQ(true, ret); EXPECT_EQ(2, infos.size()); - EXPECT_NE(1, infos[0]->displayId_); + EXPECT_NE(1, infos[1]->displayId_); } /** From d09acbbe8aaa690ffd3808e11a43897642469bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=AE=87=E8=B1=AA?= Date: Mon, 4 Nov 2024 03:31:28 +0000 Subject: [PATCH 090/132] update wm/test/unittest/window_scene_session_impl_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 卢宇豪 --- wm/test/unittest/window_scene_session_impl_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 91a54d3ace..0a25a57c96 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1414,7 +1414,9 @@ HWTEST_F(WindowSceneSessionImplTest, SetBlur, Function | SmallTest | Level3) HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn01, 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); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetKeepScreenOn(false)); @@ -1429,7 +1431,9 @@ HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn01, Function | SmallTest | L 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); From 03d8818b54d963c1efefc01429f45046fc278241 Mon Sep 17 00:00:00 2001 From: wyk99 Date: Mon, 4 Nov 2024 11:46:29 +0800 Subject: [PATCH 091/132] =?UTF-8?q?Description:=E4=BF=AE=E5=A4=8D=E7=AB=96?= =?UTF-8?q?=E5=B1=8F=E5=B1=95=E5=BC=80=E8=AF=AF=E6=97=8B=E8=BD=AC=E5=88=B0?= =?UTF-8?q?=E6=A8=AA=E5=B1=8F=20IssueNo:https://gitee.com/openharmony/driv?= =?UTF-8?q?ers=5Fhdf=5Fcore/issues/IB1WC1=20Feature=20or=20Bugfix:Bugfix?= =?UTF-8?q?=20Binary=20Source:No=20Signed-off-by:=20wyk99=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/screen_session_manager.cpp | 2 +- .../session/screen/include/screen_session.h | 2 ++ .../session/screen/src/screen_session.cpp | 9 ++++++++- .../test/dms_unittest/screen_session_test.cpp | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) 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 b12e86bf55..fe43fa7091 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -5379,7 +5379,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/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/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 From b5a232a97fd9a9eef98626545395fbeaed472539 Mon Sep 17 00:00:00 2001 From: huangji731 Date: Mon, 4 Nov 2024 14:12:10 +0800 Subject: [PATCH 092/132] https://gitee.com/openharmony/window_window_manager/issues/IB1V5C Signed-off-by: huangji731 --- interfaces/kits/napi/screenshot/native_screenshot_module.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); From 45c743f3151bf3df473da1176179b6de644d697d Mon Sep 17 00:00:00 2001 From: j30052480 Date: Mon, 4 Nov 2024 14:23:02 +0800 Subject: [PATCH 093/132] fix: fix notify displaymode change bug Signed-off-by: j30052480 --- .../src/fold_screen_controller/dual_display_fold_policy.cpp | 4 +--- .../src/fold_screen_controller/single_display_fold_policy.cpp | 2 +- .../single_display_pocket_fold_policy.cpp | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) 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/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, From 04d0442bbf4bd8d68914e055317e2aa006408c87 Mon Sep 17 00:00:00 2001 From: JJoel Date: Mon, 4 Nov 2024 14:52:32 +0800 Subject: [PATCH 094/132] tdd test cases supplement Signed-off-by: JJoel --- .../unittest/scene_session_manager_test2.cpp | 73 +++++++++++++++++++ .../unittest/scene_session_manager_test3.cpp | 25 +++++++ .../unittest/scene_session_manager_test5.cpp | 5 ++ .../unittest/scene_session_manager_test6.cpp | 41 +++++++++++ 4 files changed, 144 insertions(+) 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_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..affbc1e081 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -1716,6 +1716,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(result, WSError::WS_ERROR_INVALID_SESSION); + ssm_->sceneSessionMap_.clear(); +} + /** * @tc.name: RequestSceneSessionDestruction * @tc.desc: RequestSceneSessionDestruction @@ -1942,6 +1973,16 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession, Function | SmallTest | L ssm_->FlushUIParams(screenId, std::move(uiParams)); } +/** + * @tc.name: CheckIfReuseSession02 + * @tc.desc: CheckIfReuseSession02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession02, Function | SmallTest | Level3) +{ + +} + /** * @tc.name: UpdateAvoidArea * @tc.desc: UpdateAvoidArea From 269d7050019634d4d62d29d739d94bbd3a7d6644 Mon Sep 17 00:00:00 2001 From: baishimin <2258359443@qq.com> Date: Mon, 4 Nov 2024 14:54:50 +0800 Subject: [PATCH 095/132] =?UTF-8?q?ffrt=E6=8E=A5=E5=8F=A3=E9=80=82?= =?UTF-8?q?=E9=85=8D=E4=BB=A3=E7=A0=81=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: baishimin <2258359443@qq.com> --- .../session_manager/src/scene_session_manager.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 794b1f9c13..f3e5feebfb 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -165,16 +165,6 @@ 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()); @@ -279,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); From c9ad86765166fea9ed0dc773b087ab4964457fb0 Mon Sep 17 00:00:00 2001 From: Laiganlu Date: Mon, 4 Nov 2024 14:26:10 +0800 Subject: [PATCH 096/132] fix blank Signed-off-by: Laiganlu --- wm/include/window_session_impl.h | 2 +- wm/src/window_session_impl.cpp | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index cbf50d355c..fbac4e19f1 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -550,7 +550,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/window_session_impl.cpp b/wm/src/window_session_impl.cpp index c15e8b680f..e3394d7e25 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" @@ -838,8 +835,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()); @@ -849,7 +846,7 @@ void WindowSessionImpl::FlushLayoutSize(int32_t width, int32_t height) if (auto session = GetHostSession()) { session->NotifyFrameLayoutFinishFromApp(enableFrameLayoutFinishCb_, rect); } - windowSizeChanged_ = false; + layoutRect_ = rect; enableFrameLayoutFinishCb_ = false; } } From 5a47ca85b49a90b57b96dd7049ec260ee26f2a91 Mon Sep 17 00:00:00 2001 From: JJoel Date: Mon, 4 Nov 2024 15:06:37 +0800 Subject: [PATCH 097/132] TDD test cases window_adapter supplement Signed-off-by: JJoel --- wm/test/unittest/window_adapter_test.cpp | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/wm/test/unittest/window_adapter_test.cpp b/wm/test/unittest/window_adapter_test.cpp index 3140683361..b8b28e0aa3 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.windowMnagerServiceProxy_ = 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.windowMnagerServiceProxy_ = 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 From ebfb216c06e312b43267db29b963e33c01c7c16e Mon Sep 17 00:00:00 2001 From: JJoel Date: Mon, 4 Nov 2024 15:18:30 +0800 Subject: [PATCH 098/132] TDD test cases scene_session_manager supplement Signed-off-by: JJoel --- .../unittest/scene_session_manager_test6.cpp | 127 +++++++++++++++++- 1 file changed, 126 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index affbc1e081..e7145359ea 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -1975,12 +1975,137 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession, Function | SmallTest | L /** * @tc.name: CheckIfReuseSession02 - * @tc.desc: 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); } /** From e514f33d4b4976fc69e5b18e2390607a087f22f0 Mon Sep 17 00:00:00 2001 From: tyh Date: Mon, 4 Nov 2024 15:37:48 +0800 Subject: [PATCH 099/132] sync_tdd_master_1104 Signed-off-by: tyh Change-Id: I7fbc4a294fda00373dd9b33fb05a8155abf54c2f --- .../wms/window_multi_ability_test.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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()); From cba46fceb94eaf8ed07b1a2d583ff39063196b78 Mon Sep 17 00:00:00 2001 From: JJoel Date: Mon, 4 Nov 2024 15:47:47 +0800 Subject: [PATCH 100/132] TDD test cases Signed-off-by: JJoel --- .../unittest/scene_session_manager_test6.cpp | 18 +++++++++--------- wm/test/unittest/window_adapter_test.cpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index e7145359ea..3e51c9512e 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -1743,7 +1743,7 @@ HWTEST_F(SceneSessionManagerTest6, DestroyDialogWithMainWindow02, Function | Sma ssm_->sceneSessionMap_.insert({0, scnSession}); auto ret = ssm_->DestroyDialogWithMainWindow(scnSession); - ASSERT_EQ(result, WSError::WS_ERROR_INVALID_SESSION); + ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_SESSION); ssm_->sceneSessionMap_.clear(); } @@ -1988,12 +1988,12 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession02, Function | SmallTest | sessionInfo.moduleName_ = "SceneSessionManager"; sessionInfo.bundleName_ = "SceneSessionManagerTest6"; sessionInfo.abilityName_ = "CheckIfReuseSession02"; - sessionInfo.want = std::make_shared; + 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); @@ -2018,12 +2018,12 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession03, Function | SmallTest | sessionInfo.moduleName_ = "SceneSessionManager"; sessionInfo.bundleName_ = "SceneSessionManagerTest6"; sessionInfo.abilityName_ = "CheckIfReuseSession03"; - sessionInfo.want = std::make_shared; + 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); @@ -2049,12 +2049,12 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession04, Function | SmallTest | sessionInfo.moduleName_ = "SceneSessionManager"; sessionInfo.bundleName_ = "SceneSessionManagerTest6"; sessionInfo.abilityName_ = "CheckIfReuseSession04"; - sessionInfo.want = std::make_shared; + 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); @@ -2086,12 +2086,12 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession05, Function | SmallTest | sessionInfo.moduleName_ = "SceneSessionManager"; sessionInfo.bundleName_ = "SceneSessionManagerTest6"; sessionInfo.abilityName_ = "CheckIfReuseSession05"; - sessionInfo.want = std::make_shared; + 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); diff --git a/wm/test/unittest/window_adapter_test.cpp b/wm/test/unittest/window_adapter_test.cpp index b8b28e0aa3..f06228439c 100644 --- a/wm/test/unittest/window_adapter_test.cpp +++ b/wm/test/unittest/window_adapter_test.cpp @@ -485,7 +485,7 @@ HWTEST_F(WindowAdapterTest, RecoverAndConnectSpecificSession, Function | SmallTe iSessionStage, eventChannel, nullptr, nullptr, session, token); sptr remotObject = nullptr; - windowAdapter.windowMnagerServiceProxy_ = iface_cast(remotObject); + windowAdapter.windowManagerServiceProxy_ = iface_cast(remotObject); windowAdapter.RecoverAndConnectSpecificSession( iSessionStage, eventChannel, nullptr, nullptr, session, token); } @@ -512,7 +512,7 @@ HWTEST_F(WindowAdapterTest, RecoverAndReconnectSceneSession, Function | SmallTes ASSERT_EQ(ret2, WMError::WM_DO_NOTHING); sptr remotObject = nullptr; - windowAdapter.windowMnagerServiceProxy_ = iface_cast(remotObject); + windowAdapter.windowManagerServiceProxy_ = iface_cast(remotObject); auto ret3 = windowAdapter.RecoverAndReconnectSceneSession( iSessionStage, eventChannel, nullptr, session, nullptr, token); ASSERT_EQ(ret3, WMError::WM_DO_NOTHING); From d5663d5eb96a10d0ebf77c400bf0f35a01ceb66c Mon Sep 17 00:00:00 2001 From: jjxxx123 Date: Mon, 4 Nov 2024 16:19:28 +0800 Subject: [PATCH 101/132] =?UTF-8?q?ostringstream=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jjxxx123 --- window_scene/session_manager/src/scene_input_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 82332a15a7..6e34c9d251 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -164,12 +164,12 @@ std::string DumpDisplayInfo(const MMI::DisplayInfo& info) << "y: " << info.y << " width: " << info.width << "height: " << info.height - << " dpi: " << info.dp + << " dpi: " << info.dpi << " name:" << info.name << " uniq: " << info.uniq << " displayMode: " << static_cast(info.displayMode) << " direction: " << static_cast(info.direction) - << " transform: " << DumpTransformInDisplayInfo(info.transform) + << " transform: " << DumpTransformInDisplayInfo(info.transform); std::string infoStr = infoStream.str(); return infoStr; } From 4bbdf90febdaed81f07859883886d8229590fc4e Mon Sep 17 00:00:00 2001 From: c30063259 Date: Mon, 4 Nov 2024 16:45:09 +0800 Subject: [PATCH 102/132] add Signed-off-by: c30063259 --- .../test/unittest/scene_session_manager_test6.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index c78a6dfea9..e5106f7a7c 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(); @@ -1615,7 +1621,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); @@ -1789,7 +1795,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()); } From 54227ea808d89803f4dbdb9ec56f95df5dc3282d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=AD=9D=E5=9B=BD?= Date: Mon, 4 Nov 2024 09:02:41 +0000 Subject: [PATCH 103/132] =?UTF-8?q?=E6=84=8F=E8=A7=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 万孝国 --- window_scene/session/host/src/session.cpp | 2 +- .../session_manager/src/scene_session_manager.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index c1b1995a35..7efb70c550 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1684,7 +1684,7 @@ sptr Session::GetParentSession() const sptr Session::GetMainSession() const { if (SessionHelper::IsMainWindow(GetWindowType())) { - return const_cast(this); + return const_cast(this); } else if (parentSession_) { return parentSession_->GetMainSession(); } else { diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 971bd2ea6e..f252e679be 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4140,13 +4140,15 @@ bool SceneSessionManager::IsSessionVisible(const sptr& session) if (WindowHelper::IsSubWindow(session->GetWindowType())) { 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()); + TLOGE(WmsLogTag::WMS_SUB, "Can not find parent for this sub window, id: %{public}d", + session->GetPersistentId()); return false; } - const auto& mainState = mainSession->GetSessionState(); + const auto mainState = mainSession->GetSessionState(); if (session->IsVisible() || (state == SessionState::STATE_ACTIVE || state == SessionState::STATE_FOREGROUND)) { 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()); + TLOGD(WmsLogTag::WMS_SUB, "Parent of this sub window is at background, id: %{public}d", + session->GetPersistentId()); return false; } TLOGD(WmsLogTag::WMS_SUB, "Sub window is at foreground, id: %{public}d", session->GetPersistentId()); From 54e1c64877738147dc66003adcd843c6e5022574 Mon Sep 17 00:00:00 2001 From: JJoel Date: Mon, 4 Nov 2024 18:50:34 +0800 Subject: [PATCH 104/132] =?UTF-8?q?codecheck=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: JJoel --- window_scene/test/unittest/scene_session_manager_test6.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index 3e51c9512e..93120fe1dd 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -2000,7 +2000,7 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession02, Function | SmallTest | ssm_->abilityInfoMap_[list] = abilityInfo; auto ret1 = ssm_->CheckIfReuseSession(sessionInfo); ASSERT_EQ(ret1, BrokerStates::BROKER_UNKOWN); - ssm_->abilityInfoMap_.erase(list); + ssm_->abilityInfoMap_.erase(list); } /** @@ -2031,7 +2031,7 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession03, Function | SmallTest | ssm_->abilityInfoMap_[list] = abilityInfo; auto ret2 = ssm_->CheckIfReuseSession(sessionInfo); ASSERT_EQ(ret2, BrokerStates::BROKER_UNKOWN); - ssm_->abilityInfoMap_.erase(list); + ssm_->abilityInfoMap_.erase(list); } /** From 425b9bf367b7e3ecedfb624f6ed37707f80a3ada Mon Sep 17 00:00:00 2001 From: guofanfeng Date: Mon, 4 Nov 2024 19:22:28 +0800 Subject: [PATCH 105/132] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B8=90=E7=AF=B7?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B,=E9=87=8D=E5=A4=8D=E5=A4=9A?= =?UTF-8?q?=E6=AC=A1=E7=BB=99=E7=9B=B8=E6=9C=BA=E4=B8=8A=E6=8A=A5=E6=8A=98?= =?UTF-8?q?=E5=8F=A0=E7=8A=B6=E6=80=81=E9=97=AE=E9=A2=98=20Signed-off-by:?= =?UTF-8?q?=20guofanfeng=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7810ca3f612e289d45c26300b5b2c6e01c63f558 --- .../sensor_fold_state_manager/sensor_fold_state_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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_); From 1251c77178e370ca916cd6773e21cb12abf07f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E4=B9=A6=E5=8C=85=E6=8C=87=E6=8C=A5=E5=AE=98?= Date: Mon, 4 Nov 2024 17:05:35 +0800 Subject: [PATCH 106/132] fix codes for security reinforce MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 红书包指挥官 --- .../src/scene_session_dirty_manager.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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..aecc1be24b 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 updateSecSurfaceInfoFlag = false; + { + std::unique_lock lock(secSurfaceInfoMutex_); + if (secSurfaceInfoMap.size() != secSurfaceInfoMap_.size() || secSurfaceInfoMap_ != secSurfaceInfoMap) { + secSurfaceInfoMap_ = secSurfaceInfoMap; + updateSecSurfaceInfoFlag = true; + } + } + if (updateSecSurfaceInfoFlag) { 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 {}; From f4495b550b79be579c8e6e054ab0b3a72a6fc824 Mon Sep 17 00:00:00 2001 From: baishimin <2258359443@qq.com> Date: Mon, 4 Nov 2024 14:54:50 +0800 Subject: [PATCH 107/132] =?UTF-8?q?ffrt=E6=8E=A5=E5=8F=A3=E9=80=82?= =?UTF-8?q?=E9=85=8D=E4=BB=A3=E7=A0=81=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: baishimin <2258359443@qq.com> --- .../session_manager/src/scene_session_manager.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 794b1f9c13..f2e6a9a63a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -15,8 +15,6 @@ #include "session_manager/include/scene_session_manager.h" -#include - #include #include #include @@ -165,16 +163,6 @@ 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()); @@ -279,7 +267,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); From db68b92dff0dc7a9371610a890aca695c2c098fd Mon Sep 17 00:00:00 2001 From: jjxxx123 Date: Mon, 4 Nov 2024 21:08:35 +0800 Subject: [PATCH 108/132] =?UTF-8?q?ostringstream=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jjxxx123 --- .../src/scene_input_manager.cpp | 33 ++++++------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 6e34c9d251..51c7d52efa 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -159,18 +159,11 @@ std::string DumpTransformInDisplayInfo(const std::vector& transform) std::string DumpDisplayInfo(const MMI::DisplayInfo& info) { 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(); + 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 @@ -421,10 +414,8 @@ void SceneInputManager::PrintWindowInfo(const std::vector& wind if (e.defaultHotAreas.size() > 0) { auto iter = lastWindowDefaultHotArea.find(e.id); if (iter == lastWindowDefaultHotArea.end() || iter->second != e.defaultHotAreas[0]) { - idListStream << "|" << e.defaultHotAreas[0].x - << "|" << e.defaultHotAreas[0].y - << "|" << e.defaultHotAreas[0].width - << "|" << 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]}); } @@ -453,15 +444,11 @@ void SceneInputManager::PrintDisplayInfo(const std::vector& di std::ostringstream displayListStream; static std::string lastDisplayList = ""; for (auto& displayInfo : displayInfos) { - displayListStream << displayInfo.id << "|" - << displayInfo.x << "|" - << displayInfo.y << "|" - << displayInfo.width << "|" - << displayInfo.height << "|" + displayListStream << displayInfo.id << "|" << displayInfo.x << "|" << displayInfo.y << "|" + << displayInfo.width << "|" << displayInfo.height << "|" << static_cast(displayInfo.direction) << "|" << static_cast(displayInfo.displayDirection) << "|" - << static_cast(displayInfo.displayMode); - displayListStream << ","; + << static_cast(displayInfo.displayMode) << ","; } std::string displayList = displayListStream.str(); From 4b9f9a0619ad0793667b2e3f29259355062bea5a Mon Sep 17 00:00:00 2001 From: jjxxx123 Date: Mon, 4 Nov 2024 21:24:56 +0800 Subject: [PATCH 109/132] =?UTF-8?q?ostringstream=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jjxxx123 --- window_scene/session_manager/src/scene_input_manager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 51c7d52efa..1e26c2b495 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -161,8 +161,10 @@ std::string DumpDisplayInfo(const MMI::DisplayInfo& info) 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); + << " 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; } From c9efb74931d8e78c34a655a5e46c36f93759a23e Mon Sep 17 00:00:00 2001 From: wangziyi Date: Mon, 4 Nov 2024 21:40:46 +0800 Subject: [PATCH 110/132] layoutFullScreen fix Signed-off-by: wangziyi --- .../js_scene_session.cpp | 9 +++--- .../session/host/include/scene_session.h | 11 ++++++- .../session/host/src/scene_session.cpp | 21 +++++++++---- .../test/unittest/scene_session_test5.cpp | 30 ++++++++++++------- 4 files changed, 50 insertions(+), 21 deletions(-) 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 4df18952b2..0319b07f04 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 @@ -654,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"); @@ -667,6 +667,7 @@ void JsSceneSession::ProcessLayoutFullScreenChangeRegister() } jsSceneSession->OnLayoutFullScreenChange(isLayoutFullScreen); }; + session->RegisterLayoutFullScreenChangeCallback(layoutFullScreenChangeCallback); TLOGI(WmsLogTag::WMS_LAYOUT, "success"); } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 86a028c94b..04fe3511b8 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -128,7 +128,6 @@ public: NotifyRaiseAboveTargetFunc onRaiseAboveTarget_; NotifyTouchOutsideFunc OnTouchOutside_; NotifyLandscapeMultiWindowSessionFunc onSetLandscapeMultiWindowFunc_; - NotifyLayoutFullScreenChangeFunc onLayoutFullScreenChangeFunc_; NotifyDefaultDensityEnabledFunc onDefaultDensityEnabledFunc_; NotifyRestoreMainWindowFunc onRestoreMainWindowFunc_; NotifyTitleAndDockHoverShowChangeFunc onTitleAndDockHoverShowChangeFunc_; @@ -392,6 +391,11 @@ public: */ void RegisterIsCustomAnimationPlayingCallback(NotifyIsCustomAnimationPlayingCallback&& callback); + /** + * Window layoutFullScreen + */ + void RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreenChangeFunc&& callback); + /** * Window Visibility */ @@ -799,6 +803,11 @@ private: */ NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_; + /** + * Window LayoutFullscreen + */ + NotifyLayoutFullScreenChangeFunc onLayoutFullScreenChangeFunc_; + /** * Window Immersive */ diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ce35154f73..6051ff113d 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4730,10 +4730,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; }; @@ -5006,6 +5005,19 @@ void SceneSession::RegisterIsCustomAnimationPlayingCallback(NotifyIsCustomAnimat 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) { @@ -5322,7 +5334,6 @@ void SceneSession::UnregisterSessionChangeListeners() session->sessionChangeCallback_->onRaiseAboveTarget_ = nullptr; session->sessionChangeCallback_->OnTouchOutside_ = nullptr; session->sessionChangeCallback_->onSetLandscapeMultiWindowFunc_ = nullptr; - session->sessionChangeCallback_->onLayoutFullScreenChangeFunc_ = nullptr; session->sessionChangeCallback_->onRestoreMainWindowFunc_ = nullptr; } session->Session::UnregisterSessionChangeListeners(); diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 8eabcf3664..56c4866d5a 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -401,21 +401,29 @@ HWTEST_F(SceneSessionTest5, OnLayoutFullScreenChange, Function | SmallTest | Lev info.bundleName_ = "OnLayoutFullScreenChange"; sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - 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)); - - NotifyLayoutFullScreenChangeFunc func = [](bool isLayoutFullScreen) { - return; - }; + NotifyLayoutFullScreenChangeFunc func = [](bool isLayoutFullScreen) {}; sessionChangeCallback->onLayoutFullScreenChangeFunc_ = func; EXPECT_EQ(WSError::WS_OK, session->OnLayoutFullScreenChange(true)); } +/** + * @tc.name: RegisterLayoutFullScreenChangeCallback + * @tc.desc: test RegisterLayoutFullScreenChangeCallback + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest3, 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) {}; + + sceneSession->RegisterLayoutFullScreenChangeCallback(std::move(func)); + ASSERT_NE(sceneSession->onLayoutFullScreenChangeFunc_, nullptr); +} + /** * @tc.name: OnDefaultDensityEnabled * @tc.desc: OnDefaultDensityEnabled function From 71ccc7b3ae64996e95ce5f6075e68446e0a68f1b Mon Sep 17 00:00:00 2001 From: shiwz <1216470093@qq.com> Date: Mon, 4 Nov 2024 22:11:24 +0800 Subject: [PATCH 111/132] =?UTF-8?q?SetIsMidScene=E6=B7=BB=E5=8A=A0TDD?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib4883c77944be68ea1b3c954cbdbe3853a9f2c43 Signed-off-by: shiwz <1216470093@qq.com> --- .../test/unittest/scene_session_test3.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/window_scene/test/unittest/scene_session_test3.cpp b/window_scene/test/unittest/scene_session_test3.cpp index 6edc275fb3..3370a310e4 100644 --- a/window_scene/test/unittest/scene_session_test3.cpp +++ b/window_scene/test/unittest/scene_session_test3.cpp @@ -764,6 +764,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 From 187bc019954e264c69418887fbeeeb1134c2c351 Mon Sep 17 00:00:00 2001 From: c00680103 Date: Mon, 4 Nov 2024 22:15:29 +0800 Subject: [PATCH 112/132] =?UTF-8?q?tdd=E7=94=A8=E4=BE=8B=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: c00680103 --- wm/test/unittest/root_scene_test.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 From be93edb4b68950e45d7e4addb592ad5f7277e583 Mon Sep 17 00:00:00 2001 From: huangkai Date: Mon, 4 Nov 2024 23:19:45 +0800 Subject: [PATCH 113/132] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=87=8D=E5=90=AF=E5=90=8E=E9=80=9A=E7=9F=A5rs=E6=B7=B1?= =?UTF-8?q?=E8=89=B2=E6=A8=A1=E5=BC=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangkai --- window_scene/session_manager/BUILD.gn | 1 + .../include/scene_session_manager.h | 1 + .../src/scene_session_manager.cpp | 21 ++++++++++++++++++ window_scene/test/unittest/BUILD.gn | 1 + .../unittest/scene_session_manager_test4.cpp | 22 +++++++++++++++++++ 5 files changed, 46 insertions(+) diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index 67372de744..49c13da944 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -108,6 +108,7 @@ 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", diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index f3cbefc3ad..a03316f7df 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -631,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); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 794b1f9c13..4d678d9f2a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -308,6 +309,7 @@ void SceneSessionManager::Init() MultiInstanceManager::GetInstance().SetCurrentUserId(currentUserId_); } InitVsyncStation(); + UpdateDarkColorModeToRS(); } void SceneSessionManager::InitVsyncStation() @@ -8428,6 +8430,25 @@ WSError SceneSessionManager::UpdateSessionWindowVisibilityListener(int32_t persi return taskScheduler_->PostSyncTask(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; diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index b1495e0c5c..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", 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 From 8128e83c5ae15fc72c5d7d400a9b059395240e59 Mon Sep 17 00:00:00 2001 From: cxy20001123 Date: Mon, 4 Nov 2024 12:51:24 +0000 Subject: [PATCH 114/132] DTS2024061824214 Signed-off-by: cxy20001123 --- .../include/screen_session_dumper.h | 12 +++ .../src/screen_session_dumper.cpp | 91 ++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-) 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/src/screen_session_dumper.cpp b/window_scene/screen_session_manager/src/screen_session_dumper.cpp index 1b0d93b04d..c841c4aea0 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]); } } @@ -676,6 +708,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(','); From f6f6af182902448691bf79a2d91c510dd67e3c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E4=B9=A6=E5=8C=85=E6=8C=87=E6=8C=A5=E5=AE=98?= Date: Tue, 5 Nov 2024 10:33:56 +0800 Subject: [PATCH 115/132] change names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 红书包指挥官 --- .../session_manager/src/scene_session_dirty_manager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 aecc1be24b..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,15 +871,15 @@ void DumpSecSurfaceInfoMap(const std::map> void SceneSessionDirtyManager::UpdateSecSurfaceInfo(const std::map>& secSurfaceInfoMap) { - bool updateSecSurfaceInfoFlag = false; + bool updateSecSurfaceInfoNeeded = false; { std::unique_lock lock(secSurfaceInfoMutex_); - if (secSurfaceInfoMap.size() != secSurfaceInfoMap_.size() || secSurfaceInfoMap_ != secSurfaceInfoMap) { + if (secSurfaceInfoMap_ != secSurfaceInfoMap) { secSurfaceInfoMap_ = secSurfaceInfoMap; - updateSecSurfaceInfoFlag = true; + updateSecSurfaceInfoNeeded = true; } } - if (updateSecSurfaceInfoFlag) { + if (updateSecSurfaceInfoNeeded) { ResetFlushWindowInfoTask(); DumpSecSurfaceInfoMap(secSurfaceInfoMap); } From bd14411a616f482c0d225d2da1fc83064c45d032 Mon Sep 17 00:00:00 2001 From: marchosius Date: Tue, 5 Nov 2024 02:41:04 +0000 Subject: [PATCH 116/132] fix app cannot get aoid area height Signed-off-by: marchosius --- window_scene/session/host/src/scene_session.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 62b56dacec..5b74458d57 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1535,10 +1535,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) { From 8b236923bf2067fe726efae15d9ec509e770c3fb Mon Sep 17 00:00:00 2001 From: zhaoqi209 <18872749497@163.com> Date: Tue, 5 Nov 2024 10:17:26 +0800 Subject: [PATCH 117/132] =?UTF-8?q?PAD=E4=BA=A7=E5=93=81=E5=BA=94=E7=94=A8?= =?UTF-8?q?unspecified=E9=BB=98=E8=AE=A4=E8=A1=8C=E4=B8=BA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaoqi209 <18872749497@163.com> --- window_scene/interfaces/include/ws_common.h | 1 + .../napi/screen_session_manager/js_device_screen_config.cpp | 4 +++- .../screen_session_manager/src/screen_scene_config.cpp | 3 +++ .../screen_session_manager/src/screen_session_manager.cpp | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index 278e1a04cc..f26de070f5 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_ = ""; // default unspecified policy bool isRightPowerButton_ = true; }; 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/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_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 4eae711eed..6fa004b1bc 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); From f931e07fb2fa27dc7485fb17bd4384dcc7f0ca3a Mon Sep 17 00:00:00 2001 From: thks Date: Mon, 4 Nov 2024 20:03:40 +0800 Subject: [PATCH 118/132] =?UTF-8?q?systemSubWindow=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: thks --- .../session_manager/src/scene_session_manager.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 980dec377f..ddc13c9089 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2597,8 +2597,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."); From 127daf82979dd0137e0460ac5cb486b7ada1daad Mon Sep 17 00:00:00 2001 From: tanliang Date: Tue, 5 Nov 2024 11:44:11 +0800 Subject: [PATCH 119/132] =?UTF-8?q?int=E5=92=8Cunsigned=20int=E6=B7=B7?= =?UTF-8?q?=E7=94=A8=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanliang --- window_scene/session/host/src/session.cpp | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 960366c492..db1ac2a3eb 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -101,7 +101,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 }); } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 980dec377f..d37df68941 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1785,8 +1785,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_); @@ -2198,7 +2198,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); } From 80180790c5c678bc736dac38ecb76d8957329ee7 Mon Sep 17 00:00:00 2001 From: lpf Date: Tue, 5 Nov 2024 13:35:10 +0800 Subject: [PATCH 120/132] =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E6=8E=92=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- .../session_manager/src/zidl/scene_session_manager_stub.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; From bf5ba780a30256d98561603a8e7a0cebbe51bb2c Mon Sep 17 00:00:00 2001 From: lpf Date: Tue, 5 Nov 2024 14:00:48 +0800 Subject: [PATCH 121/132] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- interfaces/innerkits/wm/window.h | 2 +- previewer/include/window.h | 2 +- wm/src/window_impl.cpp | 2 +- wm/src/window_session_impl.cpp | 36 ++++++++----- wm/test/unittest/window_impl_test5.cpp | 6 +-- .../unittest/window_session_impl_test4.cpp | 51 ++++++++++--------- 6 files changed, 55 insertions(+), 44 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 1f45094e78..da7dce823a 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -2081,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. diff --git a/previewer/include/window.h b/previewer/include/window.h index 35894d9877..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; 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_session_impl.cpp b/wm/src/window_session_impl.cpp index d8fa5876de..03306533f7 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -702,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) { @@ -711,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(); @@ -735,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(); @@ -1057,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) 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_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index e723bd85a7..f2d6864c4f 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -1396,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 @@ -1643,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 From 1e13e165d33ba835ba3d2fe795eb5da161368409 Mon Sep 17 00:00:00 2001 From: lpf Date: Tue, 5 Nov 2024 14:14:49 +0800 Subject: [PATCH 122/132] =?UTF-8?q?=E8=93=9D=E9=BB=84=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lpf --- wm/include/window_session_impl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index ae9ae4eee0..86a0b70f48 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -418,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: From 003a98bab3a8bb6a2ede4d9a530a9757472940db Mon Sep 17 00:00:00 2001 From: zhaoqi209 <18872749497@163.com> Date: Tue, 5 Nov 2024 10:17:26 +0800 Subject: [PATCH 123/132] =?UTF-8?q?PAD=E4=BA=A7=E5=93=81=E5=BA=94=E7=94=A8?= =?UTF-8?q?unspecified=E9=BB=98=E8=AE=A4=E8=A1=8C=E4=B8=BA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaoqi209 <18872749497@163.com> --- window_scene/interfaces/include/ws_common.h | 1 + .../napi/screen_session_manager/js_device_screen_config.cpp | 4 +++- .../screen_session_manager/src/screen_scene_config.cpp | 3 +++ .../screen_session_manager/src/screen_session_manager.cpp | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index 278e1a04cc..f26de070f5 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_ = ""; // default unspecified policy bool isRightPowerButton_ = true; }; 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/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_manager.cpp b/window_scene/screen_session_manager/src/screen_session_manager.cpp index 4eae711eed..6fa004b1bc 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); From 02bbfef428eb73c3947c654df4d70e65dcba609b Mon Sep 17 00:00:00 2001 From: hsc Date: Tue, 5 Nov 2024 11:24:51 +0800 Subject: [PATCH 124/132] restore linker value Signed-off-by: hsc --- utils/include/vsync_station.h | 4 ++++ utils/src/vsync_station.cpp | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) 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/src/vsync_station.cpp b/utils/src/vsync_station.cpp index e815859b85..fdda900a9a 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_); } } } @@ -239,6 +244,8 @@ void VsyncStation::SetFrameRateLinkerEnable(bool enabled) range.preferred_, frameRateLinker->GetId()); frameRateLinker->UpdateFrameRateRange(range); frameRateLinker->UpdateFrameRateRangeImme(range); + } else if (lastFrameRateRange_) { + frameRateLinker->UpdateFrameRateRange(*lastFrameRateRange_, lastAnimatorExpectedFrameRate_); } frameRateLinker->SetEnable(enabled); } From 0f0dd9dc58dd3252d1e92b452446c3751d9058de Mon Sep 17 00:00:00 2001 From: jjxxx123 Date: Tue, 5 Nov 2024 15:59:09 +0800 Subject: [PATCH 125/132] =?UTF-8?q?ostringstream=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jjxxx123 --- window_scene/session_manager/src/scene_input_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 1e26c2b495..8a0ec790aa 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -161,7 +161,7 @@ std::string DumpDisplayInfo(const MMI::DisplayInfo& info) 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 + << " name: " << info.name << " uniq: " << info.uniq << " displayMode: " << static_cast(info.displayMode) << " direction: " << static_cast(info.direction) << " transform: " << DumpTransformInDisplayInfo(info.transform); From 029ab0db4ba908351487f60cee09202326128f8f Mon Sep 17 00:00:00 2001 From: hsc Date: Tue, 5 Nov 2024 16:46:22 +0800 Subject: [PATCH 126/132] add comment Signed-off-by: hsc --- utils/src/vsync_station.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/src/vsync_station.cpp b/utils/src/vsync_station.cpp index fdda900a9a..5348ba213d 100644 --- a/utils/src/vsync_station.cpp +++ b/utils/src/vsync_station.cpp @@ -239,12 +239,17 @@ 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); From 6fa6e1f0225d019ab52cb8b827b2badab5b2cd1f Mon Sep 17 00:00:00 2001 From: tyh Date: Tue, 5 Nov 2024 18:08:32 +0800 Subject: [PATCH 127/132] fix_tdd_1105 Signed-off-by: tyh Change-Id: I9df5d1f20d6ebbac50dd9f49999c18f9447a645f --- window_scene/test/unittest/session_test3.cpp | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index ba87624957..7e8888f35d 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -1193,17 +1193,17 @@ 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: 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 @@ -1306,7 +1306,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_); From 871f68449ef9dfd54d767c98134ace4798877478 Mon Sep 17 00:00:00 2001 From: tanyuhang Date: Tue, 5 Nov 2024 10:11:08 +0000 Subject: [PATCH 128/132] update window_scene/test/unittest/session_test3.cpp. Signed-off-by: tanyuhang --- window_scene/test/unittest/session_test3.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index 7e8888f35d..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 From 51437e6ba676940c46b5966d7b559de8f8e46d05 Mon Sep 17 00:00:00 2001 From: wangziyi Date: Tue, 5 Nov 2024 19:41:14 +0800 Subject: [PATCH 129/132] layoutfullscreen fix Signed-off-by: wangziyi --- .../kits/napi/scene_session_manager/js_scene_utils.cpp | 1 + window_scene/test/unittest/scene_session_test5.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 56c4866d5a..793cbb40fb 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -402,7 +402,7 @@ HWTEST_F(SceneSessionTest5, OnLayoutFullScreenChange, Function | SmallTest | Lev sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); NotifyLayoutFullScreenChangeFunc func = [](bool isLayoutFullScreen) {}; - sessionChangeCallback->onLayoutFullScreenChangeFunc_ = func; + session->onLayoutFullScreenChangeFunc_ = func; EXPECT_EQ(WSError::WS_OK, session->OnLayoutFullScreenChange(true)); } @@ -411,7 +411,7 @@ HWTEST_F(SceneSessionTest5, OnLayoutFullScreenChange, Function | SmallTest | Lev * @tc.desc: test RegisterLayoutFullScreenChangeCallback * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest3, RegisterLayoutFullScreenChangeCallback, Function | SmallTest | Level2) +HWTEST_F(SceneSessionTest5, RegisterLayoutFullScreenChangeCallback, Function | SmallTest | Level2) { SessionInfo info; info.abilityName_ = "RegisterLayoutFullScreenChangeCallback"; From 56cf81fac22c19c46cf6c715ec87099224da7cf7 Mon Sep 17 00:00:00 2001 From: "zhanghaozhi (A)" Date: Tue, 5 Nov 2024 21:41:05 +0800 Subject: [PATCH 130/132] SuperFoldStateManager and SuperFoldSensorManager-bugfix2 Signed-off-by: z00899566 --- .../super_fold_sensor_manager.h | 15 +---- .../super_fold_state_manager.h | 26 ++++---- .../super_fold_sensor_manager.cpp | 66 +++++++------------ .../super_fold_state_manager.cpp | 32 ++++----- 4 files changed, 56 insertions(+), 83 deletions(-) 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 5fb84e93d7..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" @@ -38,42 +39,41 @@ public: void AddStateManagerMap(SuperFoldStatus curState, SuperFoldStatusChangeEvents event, SuperFoldStatus nextState, - std::function action); + std::function action); void TransferState(SuperFoldStatus nextState); void HandleSuperFoldStatusChange(SuperFoldStatusChangeEvents events); SuperFoldStatus GetCurrentStatus(); - + + 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 DoFoldedToHalfFolded(); + static void DoFoldedToHalfFolded(SuperFoldStatusChangeEvents event); - static void DoExpandedToKeyboard(); + static void DoExpandedToKeyboard(SuperFoldStatusChangeEvents event); void SetCurrentStatus(SuperFoldStatus curState); - - FoldStatus MatchSuperFoldStatusToFoldStatus(SuperFoldStatus superFoldStatus); }; } // Rosen } // OHOS 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 ab6f790689..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,37 +24,37 @@ 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::DoFoldedToHalfFolded() +void SuperFoldStateManager::DoFoldedToHalfFolded(SuperFoldStatusChangeEvents event) { TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoFoldedToHalfFolded()"); } -void SuperFoldStateManager::DoExpandedToKeyboard() +void SuperFoldStateManager::DoExpandedToKeyboard(SuperFoldStatusChangeEvents event) { TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoExpandedToKeyboard()"); } @@ -102,15 +102,15 @@ SuperFoldStateManager::~SuperFoldStateManager() = default; 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) { - 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) @@ -131,10 +131,10 @@ FoldStatus SuperFoldStateManager::MatchSuperFoldStatusToFoldStatus(SuperFoldStat 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()) { @@ -144,7 +144,7 @@ void SuperFoldStateManager::HandleSuperFoldStatusChange(SuperFoldStatusChangeEve } if (isTransfer && action) { - action(); + action(event); TransferState(nextState); // notify auto screenSession = ScreenSessionManager::GetInstance().GetDefaultScreenSession(); @@ -155,18 +155,18 @@ void SuperFoldStateManager::HandleSuperFoldStatusChange(SuperFoldStatusChangeEve ScreenId screenId = screenSession->GetScreenId(); ScreenSessionManager::GetInstance().OnSuperFoldStatusChange(screenId, curState_); ScreenSessionManager::GetInstance().NotifyFoldStatusChanged( - MatchSuperFoldStatusToFoldStatus(nextState)); + MatchSuperFoldStatusToFoldStatus(curState_.load())); } } SuperFoldStatus SuperFoldStateManager::GetCurrentStatus() { - return curState_; + return curState_.load(); } void SuperFoldStateManager::SetCurrentStatus(SuperFoldStatus curState) { - curState_ = curState; + curState_.store(curState); } } // Rosen From aee75e915a99027ddf28afdc0b8ae1becd98f930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E4=BD=B3=E4=BC=9F?= Date: Tue, 5 Nov 2024 22:06:51 +0800 Subject: [PATCH 131/132] =?UTF-8?q?Description:=E8=A7=A3=E5=86=B3=E7=A9=BA?= =?UTF-8?q?=E6=8C=87=E9=92=88=E8=A7=A3=E5=BC=95=E7=94=A8=E5=92=8C=E5=85=B1?= =?UTF-8?q?=E4=BA=AB=E8=B5=84=E6=BA=90=E8=AE=BF=E9=97=AE=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20IssueNo:https:https://gitee.com/openharmony/window=5Fwindow?= =?UTF-8?q?=5Fmanager/issues/IB2AFT=20Binary=20Source:No=20Signed-off-by:?= =?UTF-8?q?=20songjiawei9=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dmserver/src/abstract_screen_controller.cpp | 4 ++++ .../screen_session_manager/src/screen_session_dumper.cpp | 4 ++++ 2 files changed, 8 insertions(+) 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/window_scene/screen_session_manager/src/screen_session_dumper.cpp b/window_scene/screen_session_manager/src/screen_session_dumper.cpp index c841c4aea0..bebaeb1d9e 100644 --- a/window_scene/screen_session_manager/src/screen_session_dumper.cpp +++ b/window_scene/screen_session_manager/src/screen_session_dumper.cpp @@ -695,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); From 43e93f59dc71a6db3cb2a6e1ecf7fdc00e54b38c Mon Sep 17 00:00:00 2001 From: liusensen Date: Wed, 6 Nov 2024 09:10:59 +0800 Subject: [PATCH 132/132] =?UTF-8?q?=E5=B9=B6=E5=8F=91=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E7=9A=84=E5=85=A8=E5=B1=80=E8=B5=84=E6=BA=90=E5=8A=A0=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- window_scene/session/host/src/session.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index db1ac2a3eb..1cb7c5438b 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -40,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; @@ -2881,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;