diff --git a/bundle.json b/bundle.json index c0b519adb7..bc484ca32d 100755 --- a/bundle.json +++ b/bundle.json @@ -72,8 +72,7 @@ "libjpeg-turbo", "libxml2", "bounds_checking_function", - "device_status", - "ets_frontend" + "device_status" ], "third_party": [ ] diff --git a/dm/src/display_manager.cpp b/dm/src/display_manager.cpp index a437f5f7da..23e05ec22c 100644 --- a/dm/src/display_manager.cpp +++ b/dm/src/display_manager.cpp @@ -877,9 +877,9 @@ void DisplayManager::ShowDisplayIdList(bool isShowLog) oss << iter.second << ","; } if (isShowLog) { - WLOGFD("%{public}s]", oss.str().c_str()); - } else { WLOGFI("%{public}s]", oss.str().c_str()); + } else { + WLOGFD("%{public}s]", oss.str().c_str()); } } diff --git a/dmserver/include/display_manager_interface_code.h b/dmserver/include/display_manager_interface_code.h index 2c5dbdfac0..3f35890c06 100644 --- a/dmserver/include/display_manager_interface_code.h +++ b/dmserver/include/display_manager_interface_code.h @@ -104,6 +104,7 @@ enum class DisplayManagerMessage : unsigned int { TRANS_ID_SET_CLIENT = 2500, TRANS_ID_GET_SCREEN_PROPERTY, TRANS_ID_GET_DISPLAY_NODE, + TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO, TRANS_ID_UPDATE_SCREEN_ROTATION_PROPERTY, TRANS_ID_UPDATE_AVAILABLE_AREA, TRANS_ID_SET_SCREEN_OFF_DELAY_TIME, diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index 1a759ab178..1a6f2fb12b 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -466,6 +466,15 @@ struct ScrollableParam { std::string friction_; }; +/** + * @brief screen direction info + */ +struct ScreenDirectionInfo { + int32_t notifyRotation_; + int32_t screenRotation_; + int32_t rotation_; +}; + /** * @brief displayRect */ diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 06503d2ffc..fe18e3baf6 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1626,17 +1626,15 @@ public: /** * @brief Set requested mode support info. * - * @param modeSupportInfo Mode of window supported. + * @param windowModeSupportType Mode of window supported. */ - virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) {} - + virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) {} /** * @brief Get requested mode support info. * * @return Enumeration values under WindowModeSupport. */ - virtual uint32_t GetRequestModeSupportInfo() const { return 0; } - + virtual uint32_t GetRequestWindowModeSupportType() const { return 0; } /** * @brief Set touch hot areas. * diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index e9d8f5d1b9..51f9725f8b 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -713,6 +713,11 @@ struct Rect { return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0); } + bool IsUninitializedSize() const + { + return width_ == 0 && height_ == 0; + } + bool IsInsideOf(const Rect& a) const { return (posX_ >= a.posX_ && posY_ >= a.posY_ && diff --git a/interfaces/kits/napi/extension_window/BUILD.gn b/interfaces/kits/napi/extension_window/BUILD.gn index cb3a51d445..6c92ac75cf 100644 --- a/interfaces/kits/napi/extension_window/BUILD.gn +++ b/interfaces/kits/napi/extension_window/BUILD.gn @@ -90,6 +90,7 @@ ohos_shared_library("extensionwindow_napi") { ":extension_window_kit_config", "../../../../resources/config/build:coverage_flags", ] + public_configs = [ ":extension_window_kit_config" ] include_dirs = [ "extension_window" ] deps = [ diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp index 7ede0ce022..828183888a 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -28,6 +28,7 @@ namespace Rosen { using namespace AbilityRuntime; namespace { const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange"; +const std::string WINDOW_RECT_CHANGE_CB = "windowRectChange"; const std::string SYSTEM_AVOID_AREA_CHANGE_CB = "systemAvoidAreaChange"; const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange"; const std::string LIFECYCLE_EVENT_CB = "lifeCycleEvent"; @@ -70,7 +71,8 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r { TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]OnSizeChange, [%{public}u, %{public}u], reason=%{public}u", rect.width_, rect.height_, reason); - if (currentWidth_ == rect.width_ && currentHeight_ == rect.height_ && reason != WindowSizeChangeReason::DRAG_END) { + if (currRect_.width_ == rect.width_ && currRect_.height_ == rect.height_ && + reason != WindowSizeChangeReason::DRAG_END) { TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]no need to change size"); return; } @@ -111,8 +113,56 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r eventHandler_->PostTask(jsCallback, "wms:JsExtensionWindowListener::OnSizeChange", 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); } - currentWidth_ = rect.width_; - currentHeight_ = rect.height_; + currRect_ = rect; +} + +void JsExtensionWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason) +{ + if (currRect_ == rect && reason == WindowSizeChangeReason::UNDEFINED) { + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]Skip redundant rect update"); + return; + } + RectChangeReason rectChangeReason = RectChangeReason::UNDEFINED; + if (JS_SIZE_CHANGE_REASON.count(reason) != 0 && + !(reason == WindowSizeChangeReason::MAXIMIZE && rect.posX_ != 0)) { + rectChangeReason = JS_SIZE_CHANGE_REASON.at(reason); + } + if (currentRectChangeReason_ != RectChangeReason::DRAG && rectChangeReason == RectChangeReason::DRAG_END) { + rectChangeReason = RectChangeReason::MOVE; + } + // js callback should run in js thread + auto jsCallback = [self = weakRef_, rect, rectChangeReason, env = env_] { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsExtensionWindowListener::OnRectChange"); + auto thisListener = self.promote(); + if (thisListener == nullptr || env == nullptr) { + TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]This listener or env is nullptr"); + return; + } + HandleScope handleScope(env); + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to create js object"); + return; + } + napi_value rectObjValue = GetRectAndConvertToJsValue(env, rect); + if (rectObjValue == nullptr) { + TLOGNE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to create rect js object"); + return; + } + napi_set_named_property(env, objValue, "rect", rectObjValue); + napi_set_named_property(env, objValue, "reason", CreateJsValue(env, rectChangeReason)); + napi_value argv[] = { objValue }; + thisListener->CallJsMethod(WINDOW_RECT_CHANGE_CB.c_str(), argv, ArraySize(argv)); + }; + if (!eventHandler_) { + TLOGE(WmsLogTag::WMS_UIEXT, "Get main event handler failed!"); + return; + } + eventHandler_->PostTask(jsCallback, "wms:JsExtensionWindowListener::OnRectChange", 0, + AppExecFwk::EventQueue::Priority::IMMEDIATE); + currRect_ = rect; + currentRectChangeReason_ = rectChangeReason; } void JsExtensionWindowListener::OnModeChange(WindowMode mode, bool hasDeco) diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.h b/interfaces/kits/napi/extension_window/js_extension_window_listener.h index 101d8c91ce..757dae4c21 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.h +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.h @@ -27,10 +27,12 @@ #include "window_manager.h" #include "wm_common.h" #include "js_extension_window_utils.h" +#include "js_window_utils.h" namespace OHOS { namespace Rosen { class JsExtensionWindowListener : public IWindowChangeListener, + public IWindowRectChangeListener, public IAvoidAreaChangedListener, public IWindowLifeCycle, public IOccupiedAreaChangeListener { @@ -41,6 +43,7 @@ public: ~JsExtensionWindowListener(); void OnSizeChange(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; + void OnRectChange(Rect rect, WindowSizeChangeReason reason) override; void OnModeChange(WindowMode mode, bool hasDeco) override; void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override; void AfterForeground() override; @@ -56,8 +59,8 @@ public: void SetMainEventHandler(); private: - uint32_t currentWidth_ = 0; - uint32_t currentHeight_ = 0; + Rect currRect_; + RectChangeReason currentRectChangeReason_ = RectChangeReason::UNDEFINED; napi_env env_ = nullptr; WindowState state_ {WindowState::STATE_INITIAL}; std::shared_ptr jsCallBack_; diff --git a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp index e621542ca4..1d291354cd 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp @@ -22,6 +22,7 @@ namespace OHOS { namespace Rosen { namespace { const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange"; +const std::string WINDOW_RECT_CHANGE_CB = "windowRectChange"; const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange"; const std::string WINDOW_STAGE_EVENT_CB = "windowStageEvent"; const std::string WINDOW_EVENT_CB = "windowEvent"; @@ -32,6 +33,7 @@ JsExtensionWindowRegisterManager::JsExtensionWindowRegisterManager() // white register list for window listenerCodeMap_[CaseType::CASE_WINDOW] = { {WINDOW_SIZE_CHANGE_CB, ListenerType::WINDOW_SIZE_CHANGE_CB}, + {WINDOW_RECT_CHANGE_CB, ListenerType::WINDOW_RECT_CHANGE_CB}, {AVOID_AREA_CHANGE_CB, ListenerType::AVOID_AREA_CHANGE_CB}, {WINDOW_EVENT_CB, ListenerType::WINDOW_EVENT_CB}, }; @@ -62,6 +64,23 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowChangeRegister(sptr& listener, const sptr& window, bool isRegister) +{ + if (window == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window is nullptr"); + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + } + sptr thisListener(listener); + WmErrorCode ret = WmErrorCode::WM_OK; + if (isRegister) { + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterWindowRectChangeListener(thisListener)); + } else { + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterWindowRectChangeListener(thisListener)); + } + return ret; +} + WmErrorCode JsExtensionWindowRegisterManager::ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister) { @@ -209,6 +228,9 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessRegister(CaseType caseType, case ListenerType::WINDOW_SIZE_CHANGE_CB: ret = ProcessWindowChangeRegister(listener, window, isRegister); break; + case ListenerType::WINDOW_RECT_CHANGE_CB: + ret = ProcessWindowRectChangeRegister(listener, window, isRegister); + break; case ListenerType::AVOID_AREA_CHANGE_CB: ret = ProcessAvoidAreaChangeRegister(listener, window, isRegister); break; diff --git a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h index dde8170577..dfe442d1b3 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h +++ b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.h @@ -39,6 +39,7 @@ public: private: enum class ListenerType : uint32_t { WINDOW_SIZE_CHANGE_CB, + WINDOW_RECT_CHANGE_CB, AVOID_AREA_CHANGE_CB, WINDOW_EVENT_CB, WINDOW_STAGE_EVENT_CB, @@ -47,6 +48,8 @@ private: bool IsCallbackRegistered(napi_env env, std::string type, napi_value jsListenerObject); WmErrorCode ProcessWindowChangeRegister(sptr listener, sptr window, bool isRegister); + WmErrorCode ProcessWindowRectChangeRegister(const sptr& listener, + const sptr& window, bool isRegister); WmErrorCode ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister); WmErrorCode ProcessLifeCycleEventRegister(sptr listener, 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 2b8e9c1103..ede30da83e 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2643,33 +2643,37 @@ napi_value JsWindow::OnSetTitleAndDockHoverShown(napi_env env, napi_callback_inf if (argc > 1 && !ConvertFromJsValue(env, argv[INDEX_ONE], isDockHoverShown)) { TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert isDockHoverShown parameter"); } - const char* const funcName = __func__; - NapiAsyncTask::CompleteCallback complete = - [weakToken = wptr(windowToken_), isTitleHoverShown, isDockHoverShown, funcName](napi_env env, - NapiAsyncTask& task, int32_t status) { - auto window = weakToken.promote(); - if (window == nullptr) { - TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", funcName); - task.Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); - return; - } - WMError errCode = window->SetTitleAndDockHoverShown(isTitleHoverShown, isDockHoverShown); - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode); - if (ret != WmErrorCode::WM_OK) { - TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s set title and dock hover show failed!", funcName); - task.Reject(env, JsErrUtils::CreateJsError(env, - ret, "Window OnSetTitleAndDockHoverShown failed.")); - } else { - task.Resolve(env, NapiGetUndefined(env)); - } - TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s window [%{public}u, %{public}s] [%{public}d, %{public}d]", - funcName, window->GetWindowId(), window->GetWindowName().c_str(), - isTitleHoverShown, isDockHoverShown); - }; - napi_value lastParam = (argc <= 2) ? nullptr : (GetType(env, argv[2]) == napi_function ? argv[2] : nullptr); + // 2: params num; 2: index of callback + napi_value lastParam = (argc <= 2) ? nullptr : + (GetType(env, argv[INDEX_TWO]) == napi_function ? argv[INDEX_TWO] : nullptr); napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindow::OnSetTitleAndDockHoverShown", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); + const char* const where = __func__; + auto asyncTask = [weakToken = wptr(windowToken_), isTitleHoverShown, + isDockHoverShown, env, task = napiAsyncTask, where] { + auto window = weakToken.promote(); + if (window == nullptr) { + TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s window is nullptr", where); + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY)); + return; + } + WMError errCode = window->SetTitleAndDockHoverShown(isTitleHoverShown, isDockHoverShown); + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode); + if (ret != WmErrorCode::WM_OK) { + TLOGNE(WmsLogTag::WMS_IMMS, "%{public}s set title and dock hover show failed!", where); + task->Reject(env, JsErrUtils::CreateJsError(env, + ret, "Window OnSetTitleAndDockHoverShown failed.")); + return; + } + task->Resolve(env, NapiGetUndefined(env)); + TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s window [%{public}u, %{public}s] [%{public}d, %{public}d]", + where, window->GetWindowId(), window->GetWindowName().c_str(), + isTitleHoverShown, isDockHoverShown); + }; + if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { + napiAsyncTask->Reject(env, CreateJsError(env, + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + } return result; } @@ -3629,7 +3633,7 @@ napi_value JsWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info } else { task.Reject(env, JsErrUtils::CreateJsError(env, ret, "Window set brightness failed")); } - TLOGI(WmsLogTag::DEFAULT, "Window [%{public}u, %{public}s] set brightness end, state: %{public}d", + TLOGNI(WmsLogTag::DEFAULT, "Window [%{public}u, %{public}s] set brightness end, result: %{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; @@ -5895,51 +5899,50 @@ napi_value JsWindow::OnResetAspectRatio(napi_env env, napi_callback_info info) napi_value JsWindow::OnMinimize(napi_env env, napi_callback_info info) { - WmErrorCode errCode = WmErrorCode::WM_OK; - errCode = (windowToken_ == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : WmErrorCode::WM_OK; - 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) { - WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc); - errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; - } - - if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - if (errCode == WmErrorCode::WM_OK && WindowHelper::IsSubWindow(windowToken_->GetType())) { - WLOGFE("subWindow hide"); + + if (windowToken_ == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + if (WindowHelper::IsSubWindow(windowToken_->GetType())) { + TLOGI(WmsLogTag::WMS_LAYOUT, "subWindow use hide"); return HideWindowFunction(env, info, WmErrorCode::WM_OK); } - wptr weakToken(windowToken_); - NapiAsyncTask::CompleteCallback complete = - [weakToken, errCode](napi_env env, NapiAsyncTask& task, int32_t status) mutable { - auto weakWindow = weakToken.promote(); - errCode = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : errCode; - if (errCode != WmErrorCode::WM_OK) { - task.Reject(env, - JsErrUtils::CreateJsError(env, errCode, "OnMinimize failed.")); - WLOGFE("window is nullptr"); - return; - } - WMError ret = weakWindow->Minimize(); - if (ret == WMError::WM_OK) { - task.Resolve(env, NapiGetUndefined(env)); - } else { - WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); - task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Minimize failed.")); - } - WLOGI("[NAPI]Window [%{public}u, %{public}s] minimize end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); - }; - napi_value lastParam = (argc == 0) ? nullptr : - (GetType(env, argv[0]) == napi_function ? argv[0] : nullptr); + (GetType(env, argv[INDEX_ZERO]) == napi_function ? argv[INDEX_ZERO] : nullptr); napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindow::OnMinimize", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); + const char* const where = __func__; + auto asyncTask = [weakToken = wptr(windowToken_), env, task = napiAsyncTask, where] { + auto window = weakToken.promote(); + if (window == nullptr) { + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s window is nullptr", where); + task->Reject(env, + JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY, "window is nullptr")); + return; + } + WMError ret = window->Minimize(); + if (ret == WMError::WM_OK) { + task->Resolve(env, NapiGetUndefined(env)); + } else { + WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Minimize failed.")); + } + TLOGNI(WmsLogTag::WMS_LAYOUT, "%{public}s Window [%{public}u, %{public}s] minimize end, ret = %{public}d", + where, window->GetWindowId(), window->GetWindowName().c_str(), ret); + }; + if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) { + napiAsyncTask->Reject(env, CreateJsError(env, + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + } return result; } @@ -6313,8 +6316,8 @@ napi_value JsWindow::OnSetWindowTitleMoveEnabled(napi_env env, napi_callback_inf napi_value JsWindow::OnSetSubWindowModal(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 || argc > 2) { // 1: the minimum param num 2: the maximum param num TLOGE(WmsLogTag::WMS_SUB, "Argc is invalid: %{public}zu", argc); @@ -6342,39 +6345,41 @@ napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } } - + napi_value result = nullptr; + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); const char* const where = __func__; - NapiAsyncTask::CompleteCallback complete = - [where, window = windowToken_, isModal, modalityType](napi_env env, NapiAsyncTask& task, int32_t status) { + auto asyncTask = [where, weakToken = wptr(windowToken_), isModal, modalityType, env, task = napiAsyncTask] { + auto window = weakToken.promote(); if (window == nullptr) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s window is nullptr", where); WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR); - task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr.")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr.")); return; } if (!WindowHelper::IsSubWindow(window->GetType())) { TLOGNE(WmsLogTag::WMS_SUB, "%{public}s invalid call, type:%{public}d", where, window->GetType()); - task.Reject(env, JsErrUtils::CreateJsError(env, + task->Reject(env, JsErrUtils::CreateJsError(env, WmErrorCode::WM_ERROR_INVALID_CALLING, "invalid window type.")); return; } WMError ret = window->SetSubWindowModal(isModal, modalityType); if (ret == WMError::WM_OK) { - task.Resolve(env, NapiGetUndefined(env)); + task->Resolve(env, NapiGetUndefined(env)); } else { WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); TLOGNE(WmsLogTag::WMS_SUB, "%{public}s set failed, ret is %{public}d", where, wmErrorCode); - task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set subwindow modal failed")); + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Set subwindow modal failed")); + return; } TLOGNI(WmsLogTag::WMS_SUB, "%{public}s id:%{public}u, name:%{public}s, isModal:%{public}d, modalityType:%{public}hhu", where, window->GetWindowId(), window->GetWindowName().c_str(), isModal, modalityType); }; - napi_value lastParam = nullptr; - napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindow::SetSubWindowModal", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { + napiAsyncTask->Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + } return result; } @@ -6583,51 +6588,54 @@ napi_value JsWindow::OnSetWindowTitleButtonVisible(napi_env env, napi_callback_i napi_value JsWindow::OnSetWindowMask(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) { - WLOGFE("Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::DEFAULT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - if (!CheckWindowMaskParams(env, argv[0])) { + if (!CheckWindowMaskParams(env, argv[INDEX_ZERO])) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } std::vector> windowMask; - if (!GetWindowMaskFromJsValue(env, argv[0], windowMask)) { - WLOGFE("GetWindowMaskFromJsValue failed"); + if (!GetWindowMaskFromJsValue(env, argv[INDEX_ZERO], windowMask)) { + TLOGE(WmsLogTag::DEFAULT, "GetWindowMaskFromJsValue failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - wptr weakToken(windowToken_); - NapiAsyncTask::CompleteCallback complete = - [weakToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) { - auto weakWindow = weakToken.promote(); - if (weakWindow == nullptr) { - WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; - task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Invalidate params")); - return; - } - if (!WindowHelper::IsSubWindow(weakWindow->GetType()) && - !WindowHelper::IsAppFloatingWindow(weakWindow->GetType())) { - WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; - task.Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Invalidate window type")); - return; - } - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetWindowMask(windowMask)); - if (ret != WmErrorCode::WM_OK) { - task.Reject(env, JsErrUtils::CreateJsError(env, ret)); - WLOGFE("Window [%{public}u, %{public}s] set window mask failed", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); - return; - } - task.Resolve(env, NapiGetUndefined(env)); - WLOGI("Window [%{public}u, %{public}s] set window mask succeed", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); - }; - napi_value lastParam = nullptr; napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindow::OnSetWindowMask", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + std::shared_ptr napiAsyncTask = CreateEmptyAsyncTask(env, nullptr, &result); + const char* const where = __func__; + auto asyncTask = [weakToken = wptr(windowToken_), windowMask = std::move(windowMask), env, + task = napiAsyncTask, where] { + auto window = weakToken.promote(); + if (window == nullptr) { + TLOGNE(WmsLogTag::DEFAULT, "%{public}s window is nullptr", where); + WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "window is nullptr")); + return; + } + if (!WindowHelper::IsSubWindow(window->GetType()) && + !WindowHelper::IsAppFloatingWindow(window->GetType())) { + WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; + task->Reject(env, JsErrUtils::CreateJsError(env, wmErrorCode, "Invalidate window type")); + return; + } + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->SetWindowMask(windowMask)); + if (ret != WmErrorCode::WM_OK) { + task->Reject(env, JsErrUtils::CreateJsError(env, ret)); + TLOGNE(WmsLogTag::DEFAULT, "%{public}s Window [%{public}u, %{public}s] set window mask failed", + where, window->GetWindowId(), window->GetWindowName().c_str()); + return; + } + task->Resolve(env, NapiGetUndefined(env)); + TLOGNI(WmsLogTag::DEFAULT, "%{public}s Window [%{public}u, %{public}s] set window mask succeed", + where, window->GetWindowId(), window->GetWindowName().c_str()); + }; + if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { + napiAsyncTask->Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "send event failed")); + } return result; } 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 f3e538a7b2..5dd53afb74 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 @@ -73,18 +73,19 @@ napi_value JsWindowListener::CallJsMethod(const char* methodName, napi_value con void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction) { - WLOGI("[NAPI]OnSizeChange, wh[%{public}u, %{public}u], reason = %{public}u", rect.width_, rect.height_, reason); if (currRect_.width_ == rect.width_ && currRect_.height_ == rect.height_ && reason != WindowSizeChangeReason::DRAG_END) { - WLOGFD("[NAPI]no need to change size"); + TLOGD(WmsLogTag::WMS_LAYOUT, "no need to change size"); return; } + TLOGI(WmsLogTag::WMS_LAYOUT, "wh[%{public}u, %{public}u], reason = %{public}u", + rect.width_, rect.height_, reason); // js callback should run in js thread - auto jsCallback = [self = weakRef_, rect, eng = env_] () { + auto jsCallback = [self = weakRef_, rect, eng = env_, funcName = __func__] { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsWindowListener::OnSizeChange"); auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { - WLOGFE("[NAPI]this listener or eng is nullptr"); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: this listener or eng is nullptr", funcName); return; } napi_handle_scope scope = nullptr; @@ -92,7 +93,7 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason, napi_value objValue = nullptr; napi_create_object(eng, &objValue); if (objValue == nullptr) { - WLOGFE("Failed to convert rect to jsObject"); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Failed to convert rect to jsObject", funcName); napi_close_handle_scope(eng, scope); return; } @@ -106,7 +107,7 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason, jsCallback(); } else { if (!eventHandler_) { - WLOGFE("get main event handler failed!"); + TLOGE(WmsLogTag::WMS_LAYOUT, "get main event handler failed!"); return; } eventHandler_->PostTask(jsCallback, "wms:JsWindowListener::OnSizeChange", 0, @@ -524,11 +525,11 @@ void JsWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason) rectChangReason = RectChangeReason::MOVE; } // js callback should run in js thread - auto jsCallback = [self = weakRef_, rect, rectChangReason, env = env_] () { + auto jsCallback = [self = weakRef_, rect, rectChangReason, env = env_, funcName = __func__] () { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsWindowListener::OnRectChange"); auto thisListener = self.promote(); if (thisListener == nullptr || env == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "this listener or env is nullptr"); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: this listener or env is nullptr", funcName); return; } napi_handle_scope scope = nullptr; @@ -536,12 +537,12 @@ void JsWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason) napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to create js object"); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Failed to create js object", funcName); return; } napi_value rectObjValue = GetRectAndConvertToJsValue(env, rect); if (rectObjValue == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to create rect js object"); + TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: Failed to create rect js object", funcName); return; } napi_set_named_property(env, objValue, "rect", rectObjValue); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index e1bf00aa14..54801bf070 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -566,6 +566,7 @@ napi_value CreateJsWindowInfoObject(napi_env env, const sptrGetWindowId())); napi_set_named_property(env, objValue, "windowStatusType", CreateJsValue(env, static_cast(info->GetWindowStatus()))); + napi_set_named_property(env, objValue, "isFocused", CreateJsValue(env, info->IsFocused())); return objValue; } diff --git a/interfaces/kits/ndk/wm/oh_window_event_filter.h b/interfaces/kits/ndk/wm/oh_window_event_filter.h index 3fa4664c85..8fb154bb41 100644 --- a/interfaces/kits/ndk/wm/oh_window_event_filter.h +++ b/interfaces/kits/ndk/wm/oh_window_event_filter.h @@ -16,7 +16,7 @@ #ifndef OH_WINDOW_EVENT_FILTER_H #define OH_WINDOW_EVENT_FILTER_H -#include "foundation/multimodalinput/input/interfaces/kits/c/input/oh_input_manager.h" +#include "oh_input_manager.h" #include "key_event.h" #include "oh_window_comm.h" #include "stdint.h" diff --git a/previewer/include/window.h b/previewer/include/window.h index 564a2992ff..8bc6e1ee2f 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -262,8 +262,8 @@ public: virtual void OnNewWant(const AAFwk::Want& want) = 0; virtual void SetRequestedOrientation(Orientation) = 0; virtual Orientation GetRequestedOrientation() = 0; - virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) = 0; - virtual uint32_t GetRequestModeSupportInfo() const = 0; + virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) = 0; + virtual uint32_t GetRequestWindowModeSupportType() const = 0; virtual WMError SetTouchHotAreas(const std::vector& rects) = 0; virtual void GetRequestedTouchHotAreas(std::vector& rects) const = 0; virtual bool IsMainHandlerAvailable() const = 0; diff --git a/previewer/include/window_impl.h b/previewer/include/window_impl.h index 1ed3903f2d..792ebaaa61 100644 --- a/previewer/include/window_impl.h +++ b/previewer/include/window_impl.h @@ -74,7 +74,7 @@ public: virtual uint32_t GetWindowId() const override; uint64_t GetDisplayId() const override; virtual uint32_t GetWindowFlags() const override; - uint32_t GetRequestModeSupportInfo() const override; + uint32_t GetRequestWindowModeSupportType() const override; bool IsMainHandlerAvailable() const override; virtual SystemBarProperty GetSystemBarPropertyByType(WindowType type) const override; virtual bool IsFullScreen() const override; @@ -167,7 +167,7 @@ public: virtual void RegisterDialogDeathRecipientListener(const sptr& listener) override; virtual void UnregisterDialogDeathRecipientListener(const sptr& listener) override; virtual void SetAceAbilityHandler(const sptr& handler) override; - virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override; + virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) override; virtual void ConsumeKeyEvent(const std::shared_ptr& inputEvent) override; virtual void ConsumePointerEvent(const std::shared_ptr& inputEvent) override; virtual void RequestVsync(const std::shared_ptr& vsyncCallback) override; diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index 4f16c615eb..99b88a4cbe 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -511,6 +511,11 @@ struct Rect { { return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0); } + + bool IsUninitializedSize() const + { + return width_ == 0 && height_ == 0; + } }; /** diff --git a/previewer/src/window_impl.cpp b/previewer/src/window_impl.cpp index d52bc4ad5c..f984072447 100644 --- a/previewer/src/window_impl.cpp +++ b/previewer/src/window_impl.cpp @@ -196,7 +196,7 @@ uint32_t WindowImpl::GetWindowFlags() const return 0; } -uint32_t WindowImpl::GetRequestModeSupportInfo() const +uint32_t WindowImpl::GetRequestWindowModeSupportType() const { return 0; } @@ -786,7 +786,7 @@ void WindowImpl::SetAceAbilityHandler(const sptr& handler) return; } -void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo) +void WindowImpl::SetRequestWindowModeSupportType(uint32_t windowModeSupportType) { return; } diff --git a/test/common/mock/mock_IWindow.h b/test/common/mock/mock_IWindow.h index 52808d6e74..3ba4fdd44d 100644 --- a/test/common/mock/mock_IWindow.h +++ b/test/common/mock/mock_IWindow.h @@ -30,7 +30,7 @@ public: MOCK_METHOD4(UpdateWindowRect, WMError(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction)); MOCK_METHOD1(UpdateWindowMode, WMError(WindowMode mode)); - MOCK_METHOD1(UpdateWindowModeSupportInfo, WMError(uint32_t modeSupportInfo)); + MOCK_METHOD1(UpdateWindowModeSupportType, WMError(uint32_t windowModeSupportType)); MOCK_METHOD1(UpdateFocusStatus, WMError(bool focused)); MOCK_METHOD2(UpdateAvoidArea, WMError(const sptr& avoidArea, AvoidAreaType type)); MOCK_METHOD1(UpdateWindowState, WMError(WindowState state)); diff --git a/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp b/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp index 8aac189cea..47fff1afc8 100644 --- a/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp +++ b/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp @@ -461,9 +461,9 @@ void CheckWindowImplFunctionsPart3(sptr window, const uint8_t* data, startPos += GetObject(mode, data + startPos, size - startPos); window->UpdateMode(mode); - uint32_t modeSupportInfo; - startPos += GetObject(modeSupportInfo, data + startPos, size - startPos); - window->UpdateModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType; + startPos += GetObject(windowModeSupportType, data + startPos, size - startPos); + window->UpdateWindowModeSupportType(windowModeSupportType); WindowState windowState; startPos += GetObject(windowState, data + startPos, size - startPos); @@ -596,7 +596,7 @@ void CheckWindowImplFunctionsPart6(sptr window, const uint8_t* data, uint32_t uint32Val[2]; startPos += GetObject(uint32Val[0], data + startPos, size - startPos); startPos += GetObject(uint32Val[1], data + startPos, size - startPos); - window->SetModeSupportInfo(uint32Val[0]); + window->SetWindowModeSupportType(uint32Val[0]); float floatVal; startPos += GetObject(floatVal, data + startPos, size - startPos); @@ -660,9 +660,9 @@ void CheckWindowImplFunctionsPart7(sptr window, const uint8_t* data, window->UnregisterDialogDeathRecipientListener(dialogDeathRecipientListener); sptr aceAbilityHandler = new AceAbilityHandler(); window->SetAceAbilityHandler(aceAbilityHandler); - uint32_t modeSupportInfo; - startPos += GetObject(modeSupportInfo, data + startPos, size - startPos); - window->SetRequestModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType; + startPos += GetObject(windowModeSupportType, data + startPos, size - startPos); + window->SetRequestWindowModeSupportType(windowModeSupportType); float ratio; startPos += GetObject(ratio, data + startPos, size - startPos); window->SetAspectRatio(ratio); diff --git a/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp b/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp index f536e45d04..04d93c8ae3 100644 --- a/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp +++ b/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp @@ -61,9 +61,9 @@ void CheckWindowAgentFunctionsPart1(sptr agent, const uint8_t* data startPos += GetObject(mode, data + startPos, size - startPos); agent->UpdateWindowMode(mode); - uint32_t modeSupportInfo; - startPos += GetObject(modeSupportInfo, data + startPos, size - startPos); - agent->UpdateWindowModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType; + startPos += GetObject(windowModeSupportType, data + startPos, size - startPos); + agent->UpdateWindowModeSupportType(windowModeSupportType); agent->UpdateFocusStatus(boolVal); agent->NotifyForegroundInteractiveStatus(boolVal); diff --git a/test/systemtest/wms/window_display_zoom_test.cpp b/test/systemtest/wms/window_display_zoom_test.cpp index 6fc5cf4608..869cb13bbb 100644 --- a/test/systemtest/wms/window_display_zoom_test.cpp +++ b/test/systemtest/wms/window_display_zoom_test.cpp @@ -264,24 +264,6 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom05, Function | MediumTest | Level3) window->Destroy(); } -/** - * @tc.name: DisplayZoom06 - * @tc.desc: test speical window type - * @tc.type: FUNC - * @tc.require: issueI5NGWL - */ -HWTEST_F(WindowDisplayZoomTest, DisplayZoom06, Function | MediumTest | Level3) -{ - WindowAccessibilityController::GetInstance().SetAnchorAndScale(0, 0, 2); - sleep(1); - windowInfo_.name = "DisplayZoom06"; - windowInfo_.type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT; - sptr window = Utils::CreateTestWindow(windowInfo_); - ASSERT_NE(nullptr, window); - sleep(1); - WindowAccessibilityController::GetInstance().OffWindowZoom(); - window->Destroy(); -} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/wms/window_input_method_test.cpp b/test/systemtest/wms/window_input_method_test.cpp index 7273f979c9..53af68245a 100644 --- a/test/systemtest/wms/window_input_method_test.cpp +++ b/test/systemtest/wms/window_input_method_test.cpp @@ -63,55 +63,7 @@ void WindowInputMethodTest::TearDown() } namespace { -/** - * @tc.name: InputMethodWindow01 - * @tc.desc: One InputMethod Floating Window - * @tc.type: FUNC - */ -HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Level3) -{ - inputMethodWindowInfo_.name = "input_method.1"; - const sptr& window = Utils::CreateTestWindow(inputMethodWindowInfo_); - ASSERT_NE(window, nullptr); - ASSERT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, window->GetType()); - window->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_BOTTOM, 0); - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); - window->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_FLOAT, 0); - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); -} -/** - * @tc.name: InputMethodWindow02 - * @tc.desc: One InputMethod Floating Window & One KeyGuard Window - * @tc.type: FUNC - */ -HWTEST_F(WindowInputMethodTest, InputMethodWindow02, Function | MediumTest | Level3) -{ - inputMethodWindowInfo_.name = "input_method.2"; - const sptr& inputMethodWindow = Utils::CreateTestWindow(inputMethodWindowInfo_); - ASSERT_NE(inputMethodWindow, nullptr); - inputMethodWindow->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_BOTTOM, 0); - inputMethodWindow->Show(); - if (Utils::customAppRect_.width_ == inputMethodWindow->GetRect().width_) { - ASSERT_EQ(inputMethodWindow->GetRect().width_, Utils::customAppRect_.width_); - } - - if (inputMethodWindow->GetRect().height_ == Utils::customAppRect_.height_) { - ASSERT_EQ(inputMethodWindow->GetRect().height_, Utils::customAppRect_.height_); - } - - inputMethodWindow->Hide(); - inputMethodWindow->SetWindowGravity(WindowGravity::WINDOW_GRAVITY_FLOAT, 0); - inputMethodWindow->Show(); - - if (Utils::customAppRect_.width_ == inputMethodWindow->GetRect().width_) { - ASSERT_EQ(inputMethodWindow->GetRect().width_, Utils::customAppRect_.width_); - ASSERT_EQ(inputMethodWindow->GetRect().height_, Utils::customAppRect_.height_); - } - inputMethodWindow->Hide(); -} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/test/systemtest/wms/window_mode_support_info_test.cpp b/test/systemtest/wms/window_mode_support_info_test.cpp index 03dfee6484..aa4f7c8f01 100644 --- a/test/systemtest/wms/window_mode_support_info_test.cpp +++ b/test/systemtest/wms/window_mode_support_info_test.cpp @@ -25,7 +25,7 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { using Utils = WindowTestUtils; -class WindowModeSupportInfoTest : public testing::Test { +class WindowModeSupportTypeTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); @@ -37,7 +37,7 @@ private: static constexpr uint32_t WAIT_SYANC_US = 100000; }; -void WindowModeSupportInfoTest::SetUpTestCase() +void WindowModeSupportTypeTest::SetUpTestCase() { auto display = DisplayManager::GetInstance().GetDisplayById(0); ASSERT_TRUE((display != nullptr)); @@ -45,11 +45,11 @@ void WindowModeSupportInfoTest::SetUpTestCase() Utils::InitByDisplayRect(displayRect); } -void WindowModeSupportInfoTest::TearDownTestCase() +void WindowModeSupportTypeTest::TearDownTestCase() { } -void WindowModeSupportInfoTest::SetUp() +void WindowModeSupportTypeTest::SetUp() { fullAppInfo_1_ = { .name = "FullWindow", @@ -71,39 +71,39 @@ void WindowModeSupportInfoTest::SetUp() }; } -void WindowModeSupportInfoTest::TearDown() +void WindowModeSupportTypeTest::TearDown() { } namespace { /** - * @tc.name: WindowModeSupportInfo01 - * @tc.desc: SetRequestModeSupportInfo | GetRequestModeSupportInfo + * @tc.name: WindowModeSupportType01 + * @tc.desc: SetRequestWindowModeSupportType | GetRequestWindowModeSupportType * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType01, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { return; } - window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestModeSupportInfo()); + window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestWindowModeSupportType()); window->Destroy(); } /** - * @tc.name: WindowModeSupportInfo02 - * @tc.desc: modeSupportInfo test for single window, only support fullScreen mode + * @tc.name: WindowModeSupportType02 + * @tc.desc: windowModeSupportType test for single window, only support fullScreen mode * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType02, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { return; } - window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); @@ -121,17 +121,17 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo03 - * @tc.desc: modeSupportInfo test for single window, support both fullScreen and floating mode + * @tc.name: WindowModeSupportType03 + * @tc.desc: windowModeSupportType test for single window, support both fullScreen and floating mode * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType03, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { return; } - window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | + window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); ASSERT_EQ(WMError::WM_OK, window->Show()); ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode()); @@ -153,17 +153,17 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo04 - * @tc.desc: modeSupportInfo test for single window, window mode is not supported when show, show failed + * @tc.name: WindowModeSupportType04 + * @tc.desc: windowModeSupportType test for single window, window mode is not supported when show, show failed * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType04, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { return; } - window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | + window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); ASSERT_NE(WMError::WM_OK, window->Show()); @@ -172,20 +172,20 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo05 - * @tc.desc: modeSupportInfo test for layout cascade + * @tc.name: WindowModeSupportType05 + * @tc.desc: windowModeSupportType test for layout cascade * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType05, Function | MediumTest | Level3) { const sptr& window1 = Utils::CreateTestWindow(fullAppInfo_1_); if (window1 == nullptr) { return; } - window1->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + window1->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); const sptr& window2 = Utils::CreateTestWindow(fullAppInfo_2_); ASSERT_NE(nullptr, window2); - window2->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window2->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); ASSERT_EQ(WMError::WM_OK, window1->Show()); ASSERT_EQ(WMError::WM_OK, window2->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE); @@ -203,17 +203,17 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTe } /** - * @tc.name: WindowModeSupportInfo06 - * @tc.desc: modeSupportInfo test for layout tile + * @tc.name: WindowModeSupportType06 + * @tc.desc: windowModeSupportType test for layout tile * @tc.type: FUNC */ -HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3) +HWTEST_F(WindowModeSupportTypeTest, WindowModeSupportType06, Function | MediumTest | Level3) { const sptr& window = Utils::CreateTestWindow(fullAppInfo_1_); if (window == nullptr) { return; } - window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + window->SetRequestWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(WMError::WM_OK, window->Show()); WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE); usleep(WAIT_SYANC_US); diff --git a/utils/include/vsync_station.h b/utils/include/vsync_station.h index c1b570dda3..cd0ae63e09 100644 --- a/utils/include/vsync_station.h +++ b/utils/include/vsync_station.h @@ -58,6 +58,7 @@ private: std::shared_ptr GetOrCreateVsyncReceiver(); std::shared_ptr GetOrCreateVsyncReceiverLocked(); std::shared_ptr GetFrameRateLinker(); + std::shared_ptr GetFrameRateLinkerLocked(); void VsyncCallbackInner(int64_t nanoTimestamp, int64_t frameCount); void OnVsyncTimeOut(); @@ -65,9 +66,6 @@ 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; @@ -77,6 +75,8 @@ private: std::shared_ptr frameRateLinker_ = nullptr; using Callbacks = std::unordered_set>; Callbacks vsyncCallbacks_; + std::shared_ptr lastFrameRateRange_ = nullptr; + int32_t lastAnimatorExpectedFrameRate_ = 0; // Above guarded by mutex_ std::atomic requestVsyncTimes_ {0}; diff --git a/utils/include/window_helper.h b/utils/include/window_helper.h index ecc6dfa1b3..755fe776e4 100644 --- a/utils/include/window_helper.h +++ b/utils/include/window_helper.h @@ -208,19 +208,19 @@ public: static_cast(x_end - x_begin), static_cast(y_end - y_begin) }; } - static bool IsWindowModeSupported(uint32_t modeSupportInfo, WindowMode mode) + static bool IsWindowModeSupported(uint32_t windowModeSupportType, WindowMode mode) { switch (mode) { case WindowMode::WINDOW_MODE_FULLSCREEN: - return WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN & modeSupportInfo; + return WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN & windowModeSupportType; case WindowMode::WINDOW_MODE_FLOATING: - return WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING & modeSupportInfo; + return WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING & windowModeSupportType; case WindowMode::WINDOW_MODE_SPLIT_PRIMARY: - return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY & modeSupportInfo; + return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY & windowModeSupportType; case WindowMode::WINDOW_MODE_SPLIT_SECONDARY: - return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY & modeSupportInfo; + return WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY & windowModeSupportType; case WindowMode::WINDOW_MODE_PIP: - return WindowModeSupport::WINDOW_MODE_SUPPORT_PIP & modeSupportInfo; + return WindowModeSupport::WINDOW_MODE_SUPPORT_PIP & windowModeSupportType; case WindowMode::WINDOW_MODE_UNDEFINED: return false; default: @@ -228,10 +228,10 @@ public: } } - static WindowMode GetWindowModeFromModeSupportInfo(uint32_t modeSupportInfo) + static WindowMode GetWindowModeFromWindowModeSupportType(uint32_t windowModeSupportType) { // get the binary number consists of the last 1 and 0 behind it - uint32_t windowModeSupport = modeSupportInfo & (~modeSupportInfo + 1); + uint32_t windowModeSupport = windowModeSupportType & (~windowModeSupportType + 1); switch (windowModeSupport) { case WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN: @@ -249,20 +249,20 @@ public: } } - static uint32_t ConvertSupportModesToSupportInfo(const std::vector& supportModes) + static uint32_t ConvertSupportModesToSupportType(const std::vector& supportModes) { - uint32_t modeSupportInfo = 0; + uint32_t windowModeSupportType = 0; for (auto& mode : supportModes) { if (mode == AppExecFwk::SupportWindowMode::FULLSCREEN) { - modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN; + windowModeSupportType |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN; } else if (mode == AppExecFwk::SupportWindowMode::SPLIT) { - modeSupportInfo |= (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + windowModeSupportType |= (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); } else if (mode == AppExecFwk::SupportWindowMode::FLOATING) { - modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; + windowModeSupportType |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; } } - return modeSupportInfo; + return windowModeSupportType; } static bool IsPointInTargetRect(int32_t pointPosX, int32_t pointPosY, const Rect& targetRect) @@ -522,11 +522,11 @@ public: return false; } - static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t modeSupportInfo) + static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t windowModeSupportType) { - uint32_t splitModeInfo = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); - if (isShowWhenLocked && (splitModeInfo == modeSupportInfo)) { + uint32_t splitMode = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + if (isShowWhenLocked && (splitMode == windowModeSupportType)) { return true; } return false; @@ -541,15 +541,15 @@ public: return false; } - static bool CheckSupportWindowMode(WindowMode winMode, uint32_t modeSupportInfo, + static bool CheckSupportWindowMode(WindowMode winMode, uint32_t windowModeSupportType, const sptr& info) { if (!WindowHelper::IsMainWindow(info->GetWindowType())) { return true; } - if ((!IsWindowModeSupported(modeSupportInfo, winMode)) || - (IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), modeSupportInfo))) { + if (!IsWindowModeSupported(windowModeSupportType, winMode) || + IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), windowModeSupportType)) { return false; } return true; diff --git a/utils/include/window_property.h b/utils/include/window_property.h index 000090246e..103091dc82 100644 --- a/utils/include/window_property.h +++ b/utils/include/window_property.h @@ -70,8 +70,8 @@ public: void SetAnimationFlag(uint32_t animationFlag); void SetWindowSizeChangeReason(WindowSizeChangeReason reason); void SetTokenState(bool hasToken); - void SetModeSupportInfo(uint32_t modeSupportInfo); - void SetRequestModeSupportInfo(uint32_t requestModeSupportInfo); + void SetWindowModeSupportType(uint32_t windowModeSupportType); + void SetRequestWindowModeSupportType(uint32_t requestWindowModeSupportType); void SetDragType(DragType dragType); void SetStretchable(bool stretchable); void SetOriginRect(const Rect& rect); @@ -122,8 +122,8 @@ public: bool GetDecorEnable() const; const PointInfo& GetHitOffset() const; uint32_t GetAnimationFlag() const; - uint32_t GetModeSupportInfo() const; - uint32_t GetRequestModeSupportInfo() const; + uint32_t GetWindowModeSupportType() const; + uint32_t GetRequestWindowModeSupportType() const; DragType GetDragType() const; bool GetStretchable() const; const Rect& GetOriginRect() const; @@ -190,10 +190,10 @@ private: uint32_t parentId_ = INVALID_WINDOW_ID; PointInfo hitOffset_ { 0, 0 }; uint32_t animationFlag_ { static_cast(WindowAnimation::DEFAULT) }; - // modeSupportInfo_ means supported modes in runtime, which can be changed - uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; - // requestModeSupportInfo_ is configured in abilityInfo, usually can't be changed - uint32_t requestModeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; + // windowModeSupportType_ means supported modes in runtime, which can be changed + uint32_t windowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; + // requestWindowModeSupportType_ is configured in abilityInfo, usually can't be changed + uint32_t requestWindowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED; std::unordered_map sysBarPropMap_ { { WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() }, diff --git a/utils/include/window_visibility_info.h b/utils/include/window_visibility_info.h index 8154b7f928..71db8d98d2 100644 --- a/utils/include/window_visibility_info.h +++ b/utils/include/window_visibility_info.h @@ -72,9 +72,9 @@ public: WindowVisibilityInfo(uint32_t winId, int32_t pid, int32_t uid, WindowVisibilityState visibilityState, WindowType winType, WindowStatus windowStatus, const Rect& rect, const std::string& bundleName, - const std::string& abilityName) : windowId_(winId), pid_(pid), uid_(uid), visibilityState_(visibilityState), - windowType_(winType), windowStatus_(windowStatus), rect_(rect), bundleName_(bundleName), - abilityName_(abilityName) {} + const std::string& abilityName, bool isFocused) : windowId_(winId), pid_(pid), uid_(uid), + visibilityState_(visibilityState), windowType_(winType), windowStatus_(windowStatus), rect_(rect), + bundleName_(bundleName), abilityName_(abilityName), isFocused_(isFocused) {} /** * @brief Deconstruct of WindowVisibilityInfo. @@ -111,6 +111,8 @@ public: WindowVisibilityState GetWindowVisibilityState() const { return visibilityState_; } + bool IsFocused() const { return isFocused_; } + uint32_t windowId_ { INVALID_WINDOW_ID }; int32_t pid_ { 0 }; int32_t uid_ { 0 }; @@ -120,6 +122,7 @@ public: Rect rect_ = {0, 0, 0, 0}; std::string bundleName_; std::string abilityName_; + bool isFocused_ = false; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_VISIBILITY_INFO_H \ No newline at end of file diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index a87b664cfc..ba1f8b3ee0 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -99,7 +99,7 @@ struct ModeChangeHotZonesConfig { struct SystemConfig : public Parcelable { bool isSystemDecorEnable_ = true; - uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; bool isStretchable_ = false; WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; KeyboardAnimationCurve animationIn_; @@ -110,7 +110,7 @@ struct SystemConfig : public Parcelable { virtual bool Marshalling(Parcel& parcel) const override { if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) || - !parcel.WriteUint32(decorModeSupportInfo_)) { + !parcel.WriteUint32(decorWindowModeSupportType_)) { return false; } @@ -135,7 +135,7 @@ struct SystemConfig : public Parcelable { SystemConfig* config = new SystemConfig(); config->isSystemDecorEnable_ = parcel.ReadBool(); config->isStretchable_ = parcel.ReadBool(); - config->decorModeSupportInfo_ = parcel.ReadUint32(); + config->decorWindowModeSupportType_ = parcel.ReadUint32(); config->defaultWindowMode_ = static_cast(parcel.ReadUint32()); sptr animationIn = parcel.ReadParcelable(); if (animationIn == nullptr) { diff --git a/utils/src/vsync_station.cpp b/utils/src/vsync_station.cpp index 2e343bb5fe..eb88c189e9 100644 --- a/utils/src/vsync_station.cpp +++ b/utils/src/vsync_station.cpp @@ -151,7 +151,7 @@ __attribute__((no_sanitize("cfi"))) void VsyncStation::RequestVsync( } }; receiver->RequestNextVSync({ - .userData_ = nullptr, .callbackWithId_ = task, + .userData_ = nullptr, .callbackWithId_ = std::move(task), }); } @@ -204,6 +204,11 @@ void VsyncStation::OnVsyncTimeOut() std::shared_ptr VsyncStation::GetFrameRateLinker() { std::lock_guard lock(mutex_); + return GetFrameRateLinkerLocked(); +} + +std::shared_ptr VsyncStation::GetFrameRateLinkerLocked() +{ if (destroyed_) { TLOGW(WmsLogTag::WMS_MAIN, "VsyncStation has been destroyed"); return nullptr; @@ -221,7 +226,8 @@ FrameRateLinkerId VsyncStation::GetFrameRateLinkerId() void VsyncStation::FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRate, uint32_t rateType) { - if (auto frameRateLinker = GetFrameRateLinker()) { + std::lock_guard lock(mutex_); + if (auto frameRateLinker = GetFrameRateLinkerLocked()) { if (lastFrameRateRange_ == nullptr) { lastFrameRateRange_ = std::make_shared(0, RANGE_MAX_REFRESHRATE, rate, rateType); } else { @@ -237,7 +243,8 @@ void VsyncStation::FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRa void VsyncStation::SetFrameRateLinkerEnable(bool enabled) { - if (auto frameRateLinker = GetFrameRateLinker()) { + std::lock_guard lock(mutex_); + if (auto frameRateLinker = GetFrameRateLinkerLocked()) { if (!enabled) { // clear frameRate vote FrameRateRange range = {0, RANGE_MAX_REFRESHRATE, 0}; diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index 7dbaff1739..c7d3abd1ce 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -61,7 +61,7 @@ void WindowProperty::SetWindowType(WindowType type) void WindowProperty::SetWindowMode(WindowMode mode) { - if (!WindowHelper::IsValidWindowMode(mode) || !WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) { + if (!WindowHelper::IsValidWindowMode(mode) || !WindowHelper::IsWindowModeSupported(windowModeSupportType_, mode)) { return; } if (!WindowHelper::IsSplitWindowMode(mode_)) { @@ -72,7 +72,7 @@ void WindowProperty::SetWindowMode(WindowMode mode) void WindowProperty::SetLastWindowMode(WindowMode mode) { - if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) { + if (!WindowHelper::IsWindowModeSupported(windowModeSupportType_, mode)) { return; } lastMode_ = mode; @@ -331,8 +331,8 @@ WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const void WindowProperty::ResumeLastWindowMode() { // if lastMode isn't supported, get supported mode from supportModeInfo - if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, lastMode_)) { - auto mode = WindowHelper::GetWindowModeFromModeSupportInfo(modeSupportInfo_); + if (!WindowHelper::IsWindowModeSupported(windowModeSupportType_, lastMode_)) { + auto mode = WindowHelper::GetWindowModeFromWindowModeSupportType(windowModeSupportType_); if (!WindowHelper::IsSplitWindowMode(mode)) { mode_ = mode; } @@ -481,14 +481,14 @@ void WindowProperty::SetTokenState(bool hasToken) tokenState_ = hasToken; } -void WindowProperty::SetModeSupportInfo(uint32_t modeSupportInfo) +void WindowProperty::SetWindowModeSupportType(uint32_t windowModeSupportType) { - modeSupportInfo_ = modeSupportInfo; + windowModeSupportType_ = windowModeSupportType; } -void WindowProperty::SetRequestModeSupportInfo(uint32_t requestModeSupportInfo) +void WindowProperty::SetRequestWindowModeSupportType(uint32_t requestWindowModeSupportType) { - requestModeSupportInfo_ = requestModeSupportInfo; + requestWindowModeSupportType_ = requestWindowModeSupportType; } uint32_t WindowProperty::GetWindowId() const @@ -511,14 +511,14 @@ uint32_t WindowProperty::GetAnimationFlag() const return animationFlag_; } -uint32_t WindowProperty::GetModeSupportInfo() const +uint32_t WindowProperty::GetWindowModeSupportType() const { - return modeSupportInfo_; + return windowModeSupportType_; } -uint32_t WindowProperty::GetRequestModeSupportInfo() const +uint32_t WindowProperty::GetRequestWindowModeSupportType() const { - return requestModeSupportInfo_; + return requestWindowModeSupportType_; } bool WindowProperty::GetTokenState() const @@ -729,7 +729,7 @@ bool WindowProperty::Marshalling(Parcel& parcel) const parcel.WriteUint32(static_cast(windowSizeChangeReason_)) && parcel.WriteBool(tokenState_) && parcel.WriteUint32(callingWindow_) && parcel.WriteUint32(static_cast(requestedOrientation_)) && parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) && - parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(requestModeSupportInfo_) && + parcel.WriteUint32(windowModeSupportType_) && parcel.WriteUint32(requestWindowModeSupportType_) && parcel.WriteUint32(static_cast(dragType_)) && parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) && parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_) && @@ -777,8 +777,8 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel) property->SetRequestedOrientation(static_cast(parcel.ReadUint32())); property->SetTurnScreenOn(parcel.ReadBool()); property->SetKeepScreenOn(parcel.ReadBool()); - property->SetModeSupportInfo(parcel.ReadUint32()); - property->SetRequestModeSupportInfo(parcel.ReadUint32()); + property->SetWindowModeSupportType(parcel.ReadUint32()); + property->SetRequestWindowModeSupportType(parcel.ReadUint32()); property->SetDragType(static_cast(parcel.ReadUint32())); uint32_t w = parcel.ReadUint32(); uint32_t h = parcel.ReadUint32(); @@ -843,7 +843,7 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action) ret = ret && parcel.WriteFloat(brightness_); break; case PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: - ret = ret && parcel.WriteUint32(modeSupportInfo_); + ret = ret && parcel.WriteUint32(windowModeSupportType_); break; case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA: ret = ret && MarshallingTouchHotAreas(parcel); @@ -921,7 +921,7 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action) SetBrightness(parcel.ReadFloat()); break; case PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: - SetModeSupportInfo(parcel.ReadUint32()); + SetWindowModeSupportType(parcel.ReadUint32()); break; case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA: UnmarshallingTouchHotAreas(parcel, this); @@ -990,8 +990,8 @@ void WindowProperty::CopyFrom(const sptr& property) requestedOrientation_ = property->requestedOrientation_; turnScreenOn_ = property->turnScreenOn_; keepScreenOn_ = property->keepScreenOn_; - modeSupportInfo_ = property->modeSupportInfo_; - requestModeSupportInfo_ = property->requestModeSupportInfo_; + windowModeSupportType_ = property->windowModeSupportType_; + requestWindowModeSupportType_ = property->requestWindowModeSupportType_; dragType_ = property->dragType_; originRect_ = property->originRect_; isStretchable_ = property->isStretchable_; diff --git a/utils/src/window_visibility_info.cpp b/utils/src/window_visibility_info.cpp index 6fd09537c3..1461f7d1b3 100644 --- a/utils/src/window_visibility_info.cpp +++ b/utils/src/window_visibility_info.cpp @@ -28,7 +28,7 @@ bool WindowVisibilityInfo::Marshalling(Parcel& parcel) const parcel.WriteUint32(static_cast(windowType_)) && parcel.WriteUint32(static_cast(windowStatus_)) && parcel.WriteInt32(rect_.posX_) && parcel.WriteInt32(rect_.posY_) && parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) && - parcel.WriteString(bundleName_) && parcel.WriteString(abilityName_); + parcel.WriteString(bundleName_) && parcel.WriteString(abilityName_) && parcel.WriteBool(isFocused_); } WindowVisibilityInfo* WindowVisibilityInfo::Unmarshalling(Parcel& parcel) @@ -52,6 +52,7 @@ WindowVisibilityInfo* WindowVisibilityInfo::Unmarshalling(Parcel& parcel) windowVisibilityInfo->rect_ = { parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() }; windowVisibilityInfo->bundleName_ = parcel.ReadString(); windowVisibilityInfo->abilityName_ = parcel.ReadString(); + windowVisibilityInfo->isFocused_ = parcel.ReadBool(); return windowVisibilityInfo; } } // namespace OHOS::Rosen diff --git a/utils/test/unittest/window_property_test.cpp b/utils/test/unittest/window_property_test.cpp index f322667abf..2ad59afa7e 100644 --- a/utils/test/unittest/window_property_test.cpp +++ b/utils/test/unittest/window_property_test.cpp @@ -176,20 +176,20 @@ HWTEST_F(WindowPropertyTest, SetAbilityInfo, Function | SmallTest | Level2) HWTEST_F(WindowPropertyTest, ResumeLastWindowMode, Function | SmallTest | Level2) { WindowProperty winPropDst; - winPropDst.modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_PIP; - winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; + winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_PIP; + winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED; winPropDst.ResumeLastWindowMode(); ASSERT_EQ(WindowMode::WINDOW_MODE_PIP, winPropDst.mode_); - winPropDst.modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY; - winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; + winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY; + winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED; winPropDst.ResumeLastWindowMode(); ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, winPropDst.mode_); - winPropDst.modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; - winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; + winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; + winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP; winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED; winPropDst.ResumeLastWindowMode(); ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, winPropDst.mode_); @@ -453,31 +453,31 @@ HWTEST_F(WindowPropertyTest, GetAnimationFlag018, Function | SmallTest | Level2) } /** - * @tc.name: GetModeSupportInfo019 - * @tc.desc: GetModeSupportInfo test + * @tc.name: GetWindowModeSupportType019 + * @tc.desc: GetWindowModeSupportType test * @tc.type: FUNC */ -HWTEST_F(WindowPropertyTest, GetModeSupportInfo019, Function | SmallTest | Level2) +HWTEST_F(WindowPropertyTest, GetWindowModeSupportType019, Function | SmallTest | Level2) { WindowProperty winPropSrc; - uint32_t modeSupportInfo = 1; - winPropSrc.SetModeSupportInfo(modeSupportInfo); - uint32_t res = winPropSrc.GetModeSupportInfo(); - ASSERT_EQ(res, modeSupportInfo); + uint32_t windowModeSupportType = 1; + winPropSrc.SetWindowModeSupportType(windowModeSupportType); + uint32_t res = winPropSrc.GetWindowModeSupportType(); + ASSERT_EQ(res, windowModeSupportType); } /** - * @tc.name: GetRequestModeSupportInfo020 - * @tc.desc: GetRequestModeSupportInfo test + * @tc.name: GetRequestWindowModeSupportType020 + * @tc.desc: GetRequestWindowModeSupportType test * @tc.type: FUNC */ -HWTEST_F(WindowPropertyTest, GetRequestModeSupportInfo020, Function | SmallTest | Level2) +HWTEST_F(WindowPropertyTest, GetRequestWindowModeSupportType020, Function | SmallTest | Level2) { WindowProperty winPropSrc; - uint32_t requestModeSupportInfo = 1; - winPropSrc.SetRequestModeSupportInfo(requestModeSupportInfo); - uint32_t res = winPropSrc.GetRequestModeSupportInfo(); - ASSERT_EQ(res, requestModeSupportInfo); + uint32_t requestWindowModeSupportType = 1; + winPropSrc.SetRequestWindowModeSupportType(requestWindowModeSupportType); + uint32_t res = winPropSrc.GetRequestWindowModeSupportType(); + ASSERT_EQ(res, requestWindowModeSupportType); } /** diff --git a/window_scene/common/include/session_permission.h b/window_scene/common/include/session_permission.h index a2bc8b201b..ec7356301d 100644 --- a/window_scene/common/include/session_permission.h +++ b/window_scene/common/include/session_permission.h @@ -24,6 +24,7 @@ namespace PermissionConstants { constexpr const char* PERMISSION_MANAGE_MISSION = "ohos.permission.MANAGE_MISSIONS"; constexpr const char* PERMISSION_KILL_APP_PROCESS = "ohos.permission.KILL_APP_PROCESSES"; constexpr const char* PERMISSION_MAIN_WINDOW_TOPMOST = "ohos.permission.WINDOW_TOPMOST"; +constexpr const char* PERMISSION_CALLED_EXTENSION_ON_LOCK_SCREEN = "ohos.permission.CALLED_UIEXTENSION_ON_LOCK_SCREEN"; } class SessionPermission { public: diff --git a/window_scene/common/include/task_scheduler.h b/window_scene/common/include/task_scheduler.h index 50bb4cda80..8d185b4a36 100644 --- a/window_scene/common/include/task_scheduler.h +++ b/window_scene/common/include/task_scheduler.h @@ -22,7 +22,7 @@ namespace OHOS::Rosen { -void StartTraceForSyncTask(std::string name); +void StartTraceForSyncTask(const std::string& name); void FinishTraceForSyncTask(); class TaskScheduler { @@ -31,11 +31,12 @@ public: ~TaskScheduler() = default; std::shared_ptr GetEventHandler(); + using Task = std::function; - void PostAsyncTask(Task&& task, const std::string& name = "ssmTask", int64_t delayTime = 0); - void PostVoidSyncTask(Task&& task, const std::string& name = "ssmTask"); + void PostAsyncTask(Task&& task, const std::string& name, int64_t delayTime = 0); void PostTask(Task&& task, const std::string& name, int64_t delayTime = 0); void RemoveTask(const std::string& name); + void PostVoidSyncTask(Task&& task, const std::string& name = "ssmTask"); template> Return PostSyncTask(SyncTask&& task, const std::string& name = "ssmTask") { @@ -46,7 +47,7 @@ public: FinishTraceForSyncTask(); return ret; } - auto syncTask = [this, &ret, task = std::move(task), name] { + auto syncTask = [this, &ret, &task, &name] { StartTraceForSyncTask(name); ret = task(); FinishTraceForSyncTask(); diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 48b7a3dea1..5c54c1c08f 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -84,7 +84,7 @@ public: void SetMainWindowTopmost(bool isTopmost); bool IsMainWindowTopmost() const; void AddWindowFlag(WindowFlag flag); - void SetModeSupportInfo(uint32_t modeSupportInfo); + void SetWindowModeSupportType(uint32_t windowModeSupportType); void SetFloatingWindowAppType(bool isAppType); void SetTouchHotAreas(const std::vector& rects); void KeepKeyboardOnFocus(bool keepKeyboardFlag); @@ -137,7 +137,7 @@ public: WindowLimits GetUserWindowLimits() const; WindowLimits GetConfigWindowLimitsVP() const; float GetLastLimitsVpr() const; - uint32_t GetModeSupportInfo() const; + uint32_t GetWindowModeSupportType() const; std::unordered_map GetSystemBarProperty() const; bool IsDecorEnable(); uint32_t GetAnimationFlag() const; @@ -217,7 +217,7 @@ public: bool GetIsUIExtAnySubWindow() const; /** - * Multi instance + * Multi Instance */ void SetAppInstanceKey(const std::string& appInstanceKey); std::string GetAppInstanceKey() const; @@ -248,7 +248,7 @@ private: bool WriteActionUpdateWindowMask(Parcel& parcel); bool WriteActionUpdateTopmost(Parcel& parcel); bool WriteActionUpdateMainWindowTopmost(Parcel& parcel); - bool WriteActionUpdateModeSupportInfo(Parcel& parcel); + bool WriteActionUpdateWindowModeSupportType(Parcel& parcel); void ReadActionUpdateTurnScreenOn(Parcel& parcel); void ReadActionUpdateKeepScreenOn(Parcel& parcel); void ReadActionUpdateFocusable(Parcel& parcel); @@ -272,7 +272,7 @@ private: void ReadActionUpdateWindowMask(Parcel& parcel); void ReadActionUpdateTopmost(Parcel& parcel); void ReadActionUpdateMainWindowTopmost(Parcel& parcel); - void ReadActionUpdateModeSupportInfo(Parcel& parcel); + void ReadActionUpdateWindowModeSupportType(Parcel& parcel); std::string windowName_; SessionInfo sessionInfo_; Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size) @@ -311,7 +311,7 @@ private: float lastVpr_ = 0.0f; PiPTemplateInfo pipTemplateInfo_ = {0, 0, {}}; KeyboardLayoutParams keyboardLayoutParams_; - uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; + uint32_t windowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; std::unordered_map sysBarPropMap_ { { WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, @@ -368,21 +368,21 @@ private: WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; /** - * Multi instance + * Multi Instance */ std::string appInstanceKey_; }; struct FreeMultiWindowConfig : public Parcelable { bool isSystemDecorEnable_ = true; - uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; uint32_t maxMainFloatingWindowNumber_ = 0; virtual bool Marshalling(Parcel& parcel) const override { if (!parcel.WriteBool(isSystemDecorEnable_) || - !parcel.WriteUint32(decorModeSupportInfo_)) { + !parcel.WriteUint32(decorWindowModeSupportType_)) { return false; } @@ -400,7 +400,7 @@ struct FreeMultiWindowConfig : public Parcelable { return nullptr; } config->isSystemDecorEnable_ = parcel.ReadBool(); - config->decorModeSupportInfo_ = parcel.ReadUint32(); + config->decorWindowModeSupportType_ = parcel.ReadUint32(); config->defaultWindowMode_ = static_cast(parcel.ReadUint32()); config->maxMainFloatingWindowNumber_ = parcel.ReadUint32(); return config; @@ -437,7 +437,7 @@ struct AppForceLandscapeConfig : public Parcelable { struct SystemSessionConfig : public Parcelable { bool isSystemDecorEnable_ = true; - uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; bool isStretchable_ = false; WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; KeyboardAnimationCurve animationIn_; @@ -462,7 +462,7 @@ struct SystemSessionConfig : public Parcelable { virtual bool Marshalling(Parcel& parcel) const override { if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) || - !parcel.WriteUint32(decorModeSupportInfo_)) { + !parcel.WriteUint32(decorWindowModeSupportType_)) { return false; } @@ -508,7 +508,7 @@ struct SystemSessionConfig : public Parcelable { } config->isSystemDecorEnable_ = parcel.ReadBool(); config->isStretchable_ = parcel.ReadBool(); - config->decorModeSupportInfo_ = parcel.ReadUint32(); + config->decorWindowModeSupportType_ = parcel.ReadUint32(); config->defaultWindowMode_ = static_cast(parcel.ReadUint32()); sptr animationIn = parcel.ReadParcelable(); if (animationIn == nullptr) { diff --git a/window_scene/common/src/task_scheduler.cpp b/window_scene/common/src/task_scheduler.cpp index 65facb7848..051fce86a1 100644 --- a/window_scene/common/src/task_scheduler.cpp +++ b/window_scene/common/src/task_scheduler.cpp @@ -44,21 +44,6 @@ void TaskScheduler::PostAsyncTask(Task&& task, const std::string& name, int64_t handler_->PostTask(std::move(localTask), "wms:" + name, delayTime, AppExecFwk::EventQueue::Priority::IMMEDIATE); } -void TaskScheduler::PostVoidSyncTask(Task&& task, const std::string& name) -{ - if (handler_->GetEventRunner()->IsCurrentRunnerThread()) { - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str()); - task(); - return; - } - auto localTask = [this, task = std::move(task), name] { - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str()); - task(); - ExecuteExportTask(); - }; - handler_->PostSyncTask(std::move(localTask), "wms:" + name, AppExecFwk::EventQueue::Priority::IMMEDIATE); -} - void TaskScheduler::PostTask(Task&& task, const std::string& name, int64_t delayTime) { PostAsyncTask(std::move(task), name, delayTime); @@ -69,6 +54,26 @@ void TaskScheduler::RemoveTask(const std::string& name) handler_->RemoveTask("wms:" + name); } +void TaskScheduler::PostVoidSyncTask(Task&& task, const std::string& name) +{ + if (handler_->GetEventRunner()->IsCurrentRunnerThread()) { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str()); + task(); + return; + } + auto localTask = [this, &task, &name] { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str()); + task(); + ExecuteExportTask(); + }; + handler_->PostSyncTask(std::move(localTask), "wms:" + name, AppExecFwk::EventQueue::Priority::IMMEDIATE); +} + +void TaskScheduler::SetExportHandler(const std::shared_ptr& handler) +{ + exportHandler_ = handler; +} + void TaskScheduler::AddExportTask(std::string taskName, Task&& task) { if (handler_->GetEventRunner()->IsCurrentRunnerThread()) { @@ -78,17 +83,9 @@ void TaskScheduler::AddExportTask(std::string taskName, Task&& task) } } -void TaskScheduler::SetExportHandler(const std::shared_ptr& handler) -{ - exportHandler_ = handler; -} - void TaskScheduler::ExecuteExportTask() { - if (exportFuncMap_.empty()) { - return; - } - if (!exportHandler_) { + if (!exportHandler_ || exportFuncMap_.empty()) { return; } auto task = [funcMap = std::move(exportFuncMap_)] { @@ -98,10 +95,10 @@ void TaskScheduler::ExecuteExportTask() } }; exportFuncMap_.clear(); - exportHandler_->PostTask(task, "wms:exportTask"); + exportHandler_->PostTask(std::move(task), "wms:exportTask"); } -void StartTraceForSyncTask(std::string name) +void StartTraceForSyncTask(const std::string& name) { StartTraceArgs(HITRACE_TAG_WINDOW_MANAGER, "ssm:%s", name.c_str()); } diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 4291133eb7..1c0ab44a30 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -80,7 +80,7 @@ const std::map WindowSessionProperty::writeFun std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST), &WindowSessionProperty::WriteActionUpdateTopmost), std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO), - &WindowSessionProperty::WriteActionUpdateModeSupportInfo), + &WindowSessionProperty::WriteActionUpdateWindowModeSupportType), std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST), &WindowSessionProperty::WriteActionUpdateMainWindowTopmost), }; @@ -139,7 +139,7 @@ const std::map WindowSessionProperty::readFuncM std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST), &WindowSessionProperty::ReadActionUpdateTopmost), std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO), - &WindowSessionProperty::ReadActionUpdateModeSupportInfo), + &WindowSessionProperty::ReadActionUpdateWindowModeSupportType), std::make_pair(static_cast(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST), &WindowSessionProperty::ReadActionUpdateMainWindowTopmost), }; @@ -544,14 +544,14 @@ bool WindowSessionProperty::IsDecorEnable() return isDecorEnable_; } -void WindowSessionProperty::SetModeSupportInfo(uint32_t modeSupportInfo) +void WindowSessionProperty::SetWindowModeSupportType(uint32_t windowModeSupportType) { - modeSupportInfo_ = modeSupportInfo; + windowModeSupportType_ = windowModeSupportType; } -uint32_t WindowSessionProperty::GetModeSupportInfo() const +uint32_t WindowSessionProperty::GetWindowModeSupportType() const { - return modeSupportInfo_; + return windowModeSupportType_; } void WindowSessionProperty::SetAnimationFlag(uint32_t animationFlag) @@ -1169,6 +1169,7 @@ void WindowSessionProperty::CopyFrom(const sptr& property maximizeMode_ = property->maximizeMode_; windowMode_ = property->windowMode_; limits_ = property->limits_; + windowModeSupportType_ = property->windowModeSupportType_; sysBarPropMap_ = property->sysBarPropMap_; isDecorEnable_ = property->isDecorEnable_; animationFlag_ = property->animationFlag_; @@ -1313,9 +1314,9 @@ bool WindowSessionProperty::WriteActionUpdateMainWindowTopmost(Parcel& parcel) return MarshallingMainWindowTopmost(parcel); } -bool WindowSessionProperty::WriteActionUpdateModeSupportInfo(Parcel& parcel) +bool WindowSessionProperty::WriteActionUpdateWindowModeSupportType(Parcel& parcel) { - return parcel.WriteUint32(modeSupportInfo_); + return parcel.WriteUint32(windowModeSupportType_); } void WindowSessionProperty::Read(Parcel& parcel, WSPropertyChangeAction action) @@ -1449,9 +1450,9 @@ void WindowSessionProperty::ReadActionUpdateMainWindowTopmost(Parcel& parcel) UnmarshallingMainWindowTopmost(parcel, this); } -void WindowSessionProperty::ReadActionUpdateModeSupportInfo(Parcel& parcel) +void WindowSessionProperty::ReadActionUpdateWindowModeSupportType(Parcel& parcel) { - SetModeSupportInfo(parcel.ReadUint32()); + SetWindowModeSupportType(parcel.ReadUint32()); } void WindowSessionProperty::SetTransform(const Transform& trans) diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index a2afd8d50d..f6e4043d0c 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -32,12 +32,14 @@ class StartWindowOption; } namespace OHOS::AppExecFwk { struct AbilityInfo; +enum class SupportWindowMode; } namespace OHOS::Rosen { class RSTransaction; constexpr int32_t ROTATE_ANIMATION_DURATION = 400; constexpr int32_t INVALID_SESSION_ID = 0; +constexpr int32_t WINDOW_SUPPORT_MODE_MAX_SIZE = 4; enum class WSError : int32_t { WS_OK = 0, @@ -377,10 +379,16 @@ struct SessionInfo { SessionViewportConfig config_; /** - * Multi instance + * Multi Instance */ bool isNewAppInstance_ = false; std::string appInstanceKey_; + + /** + * PC Window + */ + std::vector supportWindowModes; + uint32_t windowModeSupportType = 0; }; enum class SessionFlag : uint32_t { diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp index 8dc19a7011..59e7b76f5d 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp @@ -118,10 +118,9 @@ napi_value JsRootSceneSession::OnRegisterCallback(napi_env env, napi_callback_in return NapiGetUndefined(env); } - NotifyPendingSessionActivationFunc func = [this](SessionInfo& info) { + rootSceneSession_->SetPendingSessionActivationEventListener([this](SessionInfo& info) { this->PendingSessionActivation(info); - }; - rootSceneSession_->SetPendingSessionActivationEventListener(func); + }); std::shared_ptr callbackRef; napi_ref result = nullptr; napi_create_reference(env, value, 1, &result); 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 855dc54a92..fb95137ec0 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 @@ -322,6 +322,8 @@ void JsSceneSession::BindNativeMethod(napi_env env, napi_value objValue, const c moduleName, JsSceneSession::SetSystemSceneOcclusionAlpha); BindNativeFunction(env, objValue, "setSystemSceneForceUIFirst", moduleName, JsSceneSession::SetSystemSceneForceUIFirst); + BindNativeFunction(env, objValue, "markSystemSceneUIFirst", + moduleName, JsSceneSession::MarkSystemSceneUIFirst); BindNativeFunction(env, objValue, "setFloatingScale", moduleName, JsSceneSession::SetFloatingScale); BindNativeFunction(env, objValue, "setIsMidScene", moduleName, JsSceneSession::SetIsMidScene); BindNativeFunction(env, objValue, "setScale", moduleName, JsSceneSession::SetScale); @@ -452,20 +454,20 @@ JsSceneSession::~JsSceneSession() void JsSceneSession::ProcessPendingSceneSessionActivationRegister() { - NotifyPendingSessionActivationFunc func = [weakThis = wptr(this)](SessionInfo& info) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessPendingSceneSessionActivationRegister jsSceneSession is null"); - return; - } - jsSceneSession->PendingSessionActivation(info); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetPendingSessionActivationEventListener(func); + const char* const where = __func__; + session->SetPendingSessionActivationEventListener([weakThis = wptr(this), where](SessionInfo& info) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->PendingSessionActivation(info); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } @@ -1190,125 +1192,124 @@ void JsSceneSession::ProcessSessionEventRegister() void JsSceneSession::ProcessTerminateSessionRegister() { TLOGD(WmsLogTag::WMS_LIFE, "in"); - NotifyTerminateSessionFunc func = [weakThis = wptr(this)](const SessionInfo& info) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessTerminateSessionRegister jsSceneSession is null"); - return; - } - jsSceneSession->TerminateSession(info); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetTerminateSessionListener(func); + const char* const where = __func__; + session->SetTerminateSessionListener([weakThis = wptr(this), where](const SessionInfo& info) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->TerminateSession(info); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } void JsSceneSession::ProcessTerminateSessionRegisterNew() { TLOGD(WmsLogTag::WMS_LIFE, "in"); - NotifyTerminateSessionFuncNew func = [weakThis = wptr(this)]( - const SessionInfo& info, bool needStartCaller, bool isFromBroker) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessTerminateSessionRegisterNew jsSceneSession is null"); - return; - } - jsSceneSession->TerminateSessionNew(info, needStartCaller, isFromBroker); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetTerminateSessionListenerNew(func); + const char* const where = __func__; + session->SetTerminateSessionListenerNew([weakThis = wptr(this), where]( + const SessionInfo& info, bool needStartCaller, bool isFromBroker) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->TerminateSessionNew(info, needStartCaller, isFromBroker); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } void JsSceneSession::ProcessTerminateSessionRegisterTotal() { TLOGD(WmsLogTag::WMS_LIFE, "in"); - NotifyTerminateSessionFuncTotal func = [weakThis = wptr(this)]( - const SessionInfo& info, TerminateType terminateType) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessTerminateSessionRegisterTotal jsSceneSession is null"); - return; - } - jsSceneSession->TerminateSessionTotal(info, terminateType); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetTerminateSessionListenerTotal(func); + const char* const where = __func__; + session->SetTerminateSessionListenerTotal([weakThis = wptr(this), where]( + const SessionInfo& info, TerminateType terminateType) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->TerminateSessionTotal(info, terminateType); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } void JsSceneSession::ProcessPendingSessionToForegroundRegister() { TLOGD(WmsLogTag::WMS_LIFE, "in"); - NotifyPendingSessionToForegroundFunc func = [weakThis = wptr(this)](const SessionInfo& info) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessPendingSessionToForegroundRegister jsSceneSession is null"); - return; - } - jsSceneSession->PendingSessionToForeground(info); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetPendingSessionToForegroundListener(func); + const char* const where = __func__; + session->SetPendingSessionToForegroundListener([weakThis = wptr(this), where](const SessionInfo& info) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->PendingSessionToForeground(info); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } void JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister() { TLOGD(WmsLogTag::WMS_LIFE, "in"); - NotifyPendingSessionToBackgroundForDelegatorFunc func = [weakThis = wptr(this)](const SessionInfo& info, - bool shouldBackToCaller) { - auto jsSceneSession = weakThis.promote(); - if (!jsSceneSession) { - TLOGNE(WmsLogTag::WMS_LIFE, "jsSceneSession is null"); - return; - } - jsSceneSession->PendingSessionToBackgroundForDelegator(info, shouldBackToCaller); - }; auto session = weakSession_.promote(); if (session == nullptr) { TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); return; } - session->SetPendingSessionToBackgroundForDelegatorListener(func); + const char* const where = __func__; + session->SetPendingSessionToBackgroundForDelegatorListener([weakThis = wptr(this), where]( + const SessionInfo& info, bool shouldBackToCaller) { + auto jsSceneSession = weakThis.promote(); + if (!jsSceneSession) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); + return; + } + jsSceneSession->PendingSessionToBackgroundForDelegator(info, shouldBackToCaller); + }); TLOGD(WmsLogTag::WMS_LIFE, "success"); } void JsSceneSession::ProcessSessionExceptionRegister() { - WLOGFD("in"); - NotifySessionExceptionFunc func = [weakThis = wptr(this)]( - const SessionInfo& info, bool needRemoveSession, bool startFail) { + TLOGD(WmsLogTag::WMS_LIFE, "in"); + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); + return; + } + const char* const where = __func__; + session->SetSessionExceptionListener([weakThis = wptr(this), where](const SessionInfo& info, + bool needRemoveSession, bool startFail) { auto jsSceneSession = weakThis.promote(); if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessSessionExceptionRegister jsSceneSession is null"); + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); return; } jsSceneSession->OnSessionException(info, needRemoveSession, startFail); - }; - auto session = weakSession_.promote(); - if (session == nullptr) { - WLOGFE("session is nullptr, id:%{public}d", persistentId_); - return; - } - session->SetSessionExceptionListener(func, true); - WLOGFD("success"); + }, true); } /** @note @window.hierarchy */ @@ -1497,20 +1498,20 @@ void JsSceneSession::OnSessionEvent(uint32_t eventId, const SessionEventParam& p void JsSceneSession::ProcessBackPressedRegister() { - NotifyBackPressedFunc func = [weakThis = wptr(this)](bool needMoveToBackground) { + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr, id:%{public}d", persistentId_); + return; + } + const char* const where = __func__; + session->SetBackPressedListenser([weakThis = wptr(this), where](bool needMoveToBackground) { auto jsSceneSession = weakThis.promote(); if (!jsSceneSession) { - TLOGE(WmsLogTag::WMS_LIFE, "ProcessBackPressedRegister jsSceneSession is null"); + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s jsSceneSession is null", where); return; } jsSceneSession->OnBackPressed(needMoveToBackground); - }; - auto session = weakSession_.promote(); - if (session == nullptr) { - WLOGFE("session is nullptr, id:%{public}d", persistentId_); - return; - } - session->SetBackPressedListenser(func); + }); } void JsSceneSession::ProcessSystemBarPropertyChangeRegister() @@ -1810,6 +1811,13 @@ napi_value JsSceneSession::SetSystemSceneForceUIFirst(napi_env env, napi_callbac return (me != nullptr) ? me->OnSetSystemSceneForceUIFirst(env, info) : nullptr; } +napi_value JsSceneSession::MarkSystemSceneUIFirst(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::DEFAULT, "[NAPI]"); + JsSceneSession* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnMarkSystemSceneUIFirst(env, info) : nullptr; +} + napi_value JsSceneSession::SetFocusable(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::WMS_FOCUS, "[NAPI]"); @@ -2482,6 +2490,40 @@ napi_value JsSceneSession::OnSetSystemSceneForceUIFirst(napi_env env, napi_callb return NapiGetUndefined(env); } +napi_value JsSceneSession::OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info) +{ + size_t argc = ARG_COUNT_4; + napi_value argv[ARG_COUNT_4] = { nullptr }; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < ARGC_TWO) { + TLOGE(WmsLogTag::DEFAULT, "[NAPI]Argc is invalid: %{public}zu", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + bool isForced = false; + if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], isForced)) { + TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isForced"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + bool isUIFirstEnabled = false; + if (!ConvertFromJsValue(env, argv[ARG_INDEX_1], isUIFirstEnabled)) { + TLOGE(WmsLogTag::DEFAULT, "[NAPI]Failed to convert parameter to isUIFirstEnabled"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::DEFAULT, "[NAPI]session is nullptr, id:%{public}d", persistentId_); + return NapiGetUndefined(env); + } + session->MarkSystemSceneUIFirst(isForced, isUIFirstEnabled); + return NapiGetUndefined(env); +} + napi_value JsSceneSession::OnSetFocusable(napi_env env, napi_callback_info info) { size_t argc = 4; 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 8e3722449b..e95da2bfb0 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 @@ -105,6 +105,7 @@ private: static napi_value SetIsMidScene(napi_env env, napi_callback_info info); static napi_value SetSystemSceneOcclusionAlpha(napi_env env, napi_callback_info info); static napi_value SetSystemSceneForceUIFirst(napi_env env, napi_callback_info info); + static napi_value MarkSystemSceneUIFirst(napi_env env, napi_callback_info info); static napi_value SetFocusable(napi_env env, napi_callback_info info); static napi_value SetFocusableOnShow(napi_env env, napi_callback_info info); static napi_value SetSystemFocusable(napi_env env, napi_callback_info info); @@ -169,6 +170,7 @@ private: napi_value OnSetIsMidScene(napi_env env, napi_callback_info info); napi_value OnSetSystemSceneOcclusionAlpha(napi_env env, napi_callback_info info); napi_value OnSetSystemSceneForceUIFirst(napi_env env, napi_callback_info info); + napi_value OnMarkSystemSceneUIFirst(napi_env env, napi_callback_info info); napi_value OnSetFocusable(napi_env env, napi_callback_info info); napi_value OnSetFocusableOnShow(napi_env env, napi_callback_info info); napi_value OnSetSystemFocusable(napi_env env, napi_callback_info info); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 49f7aab886..6936ac5513 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 @@ -224,6 +224,8 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::ResetPcFoldScreenArrangeRule); BindNativeFunction(env, exportObj, "setIsWindowRectAutoSave", moduleName, JsSceneSessionManager::SetIsWindowRectAutoSave); + BindNativeFunction(env, exportObj, "NotifyAboveLockScreen", moduleName, + JsSceneSessionManager::NotifyAboveLockScreen); return NapiGetUndefined(env); } @@ -1158,6 +1160,16 @@ napi_value JsSceneSessionManager::SetIsWindowRectAutoSave(napi_env env, napi_cal return (me != nullptr) ? me->OnSetIsWindowRectAutoSave(env, info) : nullptr; } +napi_value JsSceneSessionManager::NotifyAboveLockScreen(napi_env env, napi_callback_info info) +{ + JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); + if (me == nullptr) { + TLOGW(WmsLogTag::WMS_SCB, "me is null"); + return nullptr; + } + return me->OnNotifyAboveLockScreen(env, info); +} + bool JsSceneSessionManager::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsSceneSessionManager::IsCallbackRegistered[%s]", type.c_str()); @@ -1545,6 +1557,7 @@ napi_value JsSceneSessionManager::OnGetAbilityInfo(napi_env env, napi_callback_i if (ret != WSErrorCode::WS_OK) { napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_STATE_ABNORMALLY), "System is abnormal")); + return NapiGetUndefined(env); } return CreateSCBAbilityInfo(env, scbAbilityInfo); } @@ -2590,7 +2603,7 @@ napi_value JsSceneSessionManager::OnPreloadInLakeApp(napi_env env, napi_callback auto preloadTask = [bundleName = std::move(bundleName)] { SceneSessionManager::GetInstance().PreloadInLakeApp(bundleName); }; - localScheduler->PostAsyncTask(preloadTask); + localScheduler->PostAsyncTask(preloadTask, __func__); return NapiGetUndefined(env); } @@ -3407,6 +3420,41 @@ napi_value JsSceneSessionManager::OnIsScbCoreEnabled(napi_env env, napi_callback return result; } +napi_value JsSceneSessionManager::OnNotifyAboveLockScreen(napi_env env, napi_callback_info info) +{ + size_t argc = ARGC_FOUR; + napi_value argv[ARGC_FOUR] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc != ARGC_ONE) { + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Argc is invalid: %{public}zu", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + + std::vector windowIds; + if (!ConvertInt32ArrayFromJs(env, argv[0], windowIds)) { + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to convert windowIds"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + + std::string windowIdListStr = "none"; + if (!windowIds.empty()) { + windowIdListStr = std::accumulate(windowIds.begin() + 1, + windowIds.end(), + std::to_string(windowIds[0]), + [](const std::string &str, int32_t windowId) { return str + "," + std::to_string(windowId); }); + } + + TLOGI(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: OnNotifyAboveLockScreen, window list: %{public}s", + windowIdListStr.c_str()); + SceneSessionManager::GetInstance().OnNotifyAboveLockScreen(windowIds); + return NapiGetUndefined(env); +} + napi_value JsSceneSessionManager::OnRefreshPcZOrder(napi_env env, napi_callback_info info) { size_t argc = 4; @@ -3587,7 +3635,7 @@ napi_value JsSceneSessionManager::OnUpdatePcFoldScreenStatus(napi_env env, napi_ "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - ScreenFoldStatus status = static_cast(statusNum); + SuperFoldStatus status = static_cast(statusNum); WSRect defaultDisplayRect; if (argv[ARG_INDEX_TWO] == nullptr || !ConvertRectInfoFromJs(env, argv[ARG_INDEX_TWO], defaultDisplayRect)) { diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h index 9129086125..6f9b843d31 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h @@ -118,9 +118,10 @@ public: static napi_value UpdatePcFoldScreenStatus(napi_env env, napi_callback_info info); static napi_value ResetPcFoldScreenArrangeRule(napi_env env, napi_callback_info info); static napi_value SetIsWindowRectAutoSave(napi_env env, napi_callback_info info); + static napi_value NotifyAboveLockScreen(napi_env env, napi_callback_info info); /* - * Multi instance + * Multi Instance */ static napi_value GetMaxInstanceCount(napi_env env, napi_callback_info info); static napi_value GetInstanceCount(napi_env env, napi_callback_info info); @@ -194,9 +195,10 @@ private: napi_value OnUpdatePcFoldScreenStatus(napi_env env, napi_callback_info info); napi_value OnResetPcFoldScreenArrangeRule(napi_env env, napi_callback_info info); napi_value OnSetIsWindowRectAutoSave(napi_env env, napi_callback_info info); + napi_value OnNotifyAboveLockScreen(napi_env env, napi_callback_info info); /* - * multi instance + * Multi Instance */ napi_value OnGetMaxInstanceCount(napi_env env, napi_callback_info info); napi_value OnGetInstanceCount(napi_env env, napi_callback_info info); 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 3a488140cc..5a04291b35 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 @@ -894,6 +894,22 @@ JsSessionType GetApiType(WindowType type) } } +static napi_value CreateSupportWindowModes(napi_env env, + const std::vector& supportWindowModes) +{ + napi_value arrayValue = nullptr; + napi_create_array_with_length(env, supportWindowModes.size(), &arrayValue); + if (arrayValue == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "Failed to create napi array"); + return NapiGetUndefined(env); + } + int32_t index = 0; + for (const auto supportWindowMode : supportWindowModes) { + napi_set_element(env, arrayValue, index++, CreateJsValue(env, static_cast(supportWindowMode))); + } + return arrayValue; +} + napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) { napi_value objValue = nullptr; @@ -942,6 +958,8 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) CreateJsValue(env, sessionInfo.errorReason)); napi_set_named_property(env, objValue, "isFromIcon", CreateJsValue(env, sessionInfo.isFromIcon_)); SetJsSessionInfoByWant(env, sessionInfo, objValue); + napi_set_named_property(env, objValue, "supportWindowModes", + CreateSupportWindowModes(env, sessionInfo.supportWindowModes)); return objValue; } @@ -1569,20 +1587,14 @@ MainThreadScheduler::MainThreadScheduler(napi_env env) inline void MainThreadScheduler::GetMainEventHandler() { - if (handler_ != nullptr) { - return; - } auto runner = OHOS::AppExecFwk::EventRunner::GetMainEventRunner(); - if (runner == nullptr) { - return; - } handler_ = std::make_shared(runner); } void MainThreadScheduler::PostMainThreadTask(Task&& localTask, std::string traceInfo, int64_t delayTime) { - GetMainEventHandler(); - auto task = [env = env_, localTask, traceInfo, envChecker = std::weak_ptr(envChecker_)]() { + auto task = [env = env_, localTask = std::move(localTask), traceInfo, + envChecker = std::weak_ptr(envChecker_)] { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SCBCb:%s", traceInfo.c_str()); if (envChecker.expired()) { TLOGNE(WmsLogTag::WMS_MAIN, "post task expired because of invalid scheduler"); 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 bc66263aa1..25dfba113a 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn @@ -43,8 +43,10 @@ ohos_shared_library("screensessionmanager_napi") { ] external_deps = [ + "ability_runtime:ability_context_native", "ability_runtime:app_manager", "ability_runtime:runtime", + "ace_engine:ace_uicontent", "c_utils:utils", "eventhandler:libeventhandler", "graphic_2d:librender_service_base", diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp index 55318ccc89..5e6f064b54 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "interfaces/include/ws_common.h" #include "js_screen_utils.h" @@ -68,6 +69,8 @@ napi_value JsScreenSession::Create(napi_env env, const sptr& scre BindNativeFunction(env, objValue, "setTouchEnabled", moduleName, JsScreenSession::SetTouchEnabled); BindNativeFunction(env, objValue, "loadContent", moduleName, JsScreenSession::LoadContent); + BindNativeFunction(env, objValue, "getScreenUIContext", moduleName, + JsScreenSession::GetScreenUIContext); return objValue; } @@ -338,6 +341,45 @@ napi_value JsScreenSession::OnRegisterCallback(napi_env env, napi_callback_info return NapiGetUndefined(env); } +napi_value JsScreenSession::GetScreenUIContext(napi_env env, napi_callback_info info) +{ + JsScreenSession* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetScreenUIContext(env, info) : nullptr; +} + +napi_value JsScreenSession::OnGetScreenUIContext(napi_env env, napi_callback_info info) +{ + WLOGI("[NAPI]OnGetScreenUIContext"); + size_t argc = 1; + napi_value argv[1] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc > 0) { // 0: params num + WLOGFE("Argc is invalid: %{public}zu", argc); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM))); + return NapiGetUndefined(env); + } + + if (screenScene_ == nullptr) { + WLOGFE("screenScene_ is nullptr"); + napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); + return NapiGetUndefined(env); + } + const auto& uiContent = screenScene_->GetUIContent(); + if (uiContent == nullptr) { + WLOGFE("uiContent is nullptr"); + napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); + return NapiGetUndefined(env); + } + napi_value uiContext = uiContent->GetUINapiContext(); + if (uiContext == nullptr) { + WLOGFE("uiContext obtained from jsEngine is nullptr"); + napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); + return NapiGetUndefined(env); + } + WLOGI("success"); + return uiContext; +} + void JsScreenSession::CallJsCallback(const std::string& callbackType) { WLOGI("Call js callback: %{public}s.", callbackType.c_str()); diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h index 1ee32235e6..12d853565e 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session.h @@ -43,6 +43,8 @@ private: napi_value OnSetScreenRotationLocked(napi_env env, napi_callback_info info); static napi_value SetTouchEnabled(napi_env env, napi_callback_info info); napi_value OnSetTouchEnabled(napi_env env, napi_callback_info info); + static napi_value GetScreenUIContext(napi_env env, napi_callback_info info); + napi_value OnGetScreenUIContext(napi_env env, napi_callback_info info); void CallJsCallback(const std::string& callbackType); void RegisterScreenChangeListener(); void UnRegisterScreenChangeListener(); diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp index b37baee066..bb8844628e 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp @@ -439,11 +439,14 @@ napi_value JsScreenSessionManager::OnUpdateScreenRotationProperty(napi_env env, TLOGE(WmsLogTag::DMS, "[NAPI]Failed to get bounds from js object"); return NapiGetUndefined(env); } - int rotation; - if (!ConvertFromJsValue(env, argv[2], rotation)) { // 2: the 3rd argv - TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to rotation"); - napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), - "Input parameter is missing or invalid")); + ScreenDirectionInfo directionInfo; + napi_value nativeObject = argv[2]; + if (nativeObject == nullptr) { + TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to ScreenDirectionInfo,the param is null"); + return NapiGetUndefined(env); + } + if (!ConvertScreenDirectionInfoFromJs(env, nativeObject, directionInfo)) { + TLOGE(WmsLogTag::DMS, "[NAPI]Failed to convert parameter to ScreenDirectionInfo"); return NapiGetUndefined(env); } ScreenPropertyChangeType type = ScreenPropertyChangeType::UNSPECIFIED; @@ -456,7 +459,7 @@ napi_value JsScreenSessionManager::OnUpdateScreenRotationProperty(napi_env env, return NapiGetUndefined(env); } } - ScreenSessionManagerClient::GetInstance().UpdateScreenRotationProperty(screenId, bounds, rotation, + ScreenSessionManagerClient::GetInstance().UpdateScreenRotationProperty(screenId, bounds, directionInfo, type); return NapiGetUndefined(env); } diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp index a6b47ddef2..dc83cc8596 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.cpp @@ -242,6 +242,39 @@ bool ConvertRRectFromJs(napi_env env, napi_value jsObject, RRect& bound) return true; } +bool ConvertScreenDirectionInfoFromJs(napi_env env, napi_value jsObject, ScreenDirectionInfo& directionInfo) +{ + napi_value jsNotifyRotation = nullptr, jsScreenRotation = nullptr, jsRotation = nullptr; + napi_get_named_property(env, jsObject, "notifyRotation", &jsNotifyRotation); + napi_get_named_property(env, jsObject, "screenRotation", &jsScreenRotation); + napi_get_named_property(env, jsObject, "rotation", &jsRotation); + + if (GetType(env, jsNotifyRotation) != napi_undefined) { + int32_t notifyRotation; + if (!ConvertFromJsValue(env, jsNotifyRotation, notifyRotation)) { + WLOGFE("[NAPI]Failed to convert parameter to notifyRotation"); + return false; + } + directionInfo.notifyRotation_ = notifyRotation; + } + if (GetType(env, jsScreenRotation) != napi_undefined) { + int32_t screenRotation; + if (!ConvertFromJsValue(env, jsScreenRotation, screenRotation)) { + WLOGFE("[NAPI]Failed to convert parameter to screenRotation"); + return false; + } + directionInfo.screenRotation_ = screenRotation; + } + if (GetType(env, jsRotation) != napi_undefined) { + int32_t rotation; + if (!ConvertFromJsValue(env, jsRotation, rotation)) { + WLOGFE("[NAPI]Failed to convert parameter to rotation"); + return false; + } + directionInfo.rotation_ = rotation; + } + return true; +} bool ConvertDMRectFromJs(napi_env env, napi_value jsObject, DMRect& rect) { diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h index 08828e3620..8149e369e5 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_utils.h @@ -25,6 +25,7 @@ namespace OHOS::Rosen { bool ConvertRRectFromJs(napi_env env, napi_value jsObject, RRect& bound); bool ConvertDMRectFromJs(napi_env env, napi_value jsObject, DMRect& rect); +bool ConvertScreenDirectionInfoFromJs(napi_env env, napi_value jsObject, ScreenDirectionInfo& directionInfo); napi_value NapiGetUndefined(napi_env env); bool NapiIsCallable(napi_env env, napi_value value); class JsScreenUtils { diff --git a/window_scene/interfaces/kits/napi/transaction_manager/js_transaction_manager.cpp b/window_scene/interfaces/kits/napi/transaction_manager/js_transaction_manager.cpp index 02d4e5019e..4ca565a4b2 100644 --- a/window_scene/interfaces/kits/napi/transaction_manager/js_transaction_manager.cpp +++ b/window_scene/interfaces/kits/napi/transaction_manager/js_transaction_manager.cpp @@ -98,15 +98,13 @@ napi_value JsTransactionManager::OnOpenSyncTransaction(napi_env env, napi_callba napi_value JsTransactionManager::OnCloseSyncTransaction(napi_env env, napi_callback_info info) { - auto task = []() { - auto transactionController = RSSyncTransactionController::GetInstance(); - if (transactionController) { + auto task = [] { + if (auto transactionController = RSSyncTransactionController::GetInstance()) { transactionController->CloseSyncTransaction(); } }; - auto handler = SceneSessionManager::GetInstance().GetTaskScheduler(); - if (handler) { - handler->PostAsyncTask(task); + if (auto handler = SceneSessionManager::GetInstance().GetTaskScheduler()) { + handler->PostAsyncTask(task, __func__); } else { task(); } diff --git a/window_scene/screen_session_manager/BUILD.gn b/window_scene/screen_session_manager/BUILD.gn index 5645bc9c02..644bfe5f35 100644 --- a/window_scene/screen_session_manager/BUILD.gn +++ b/window_scene/screen_session_manager/BUILD.gn @@ -123,6 +123,9 @@ ohos_shared_library("screen_session_manager") { "ability_runtime:app_manager", "ability_runtime:dataobs_manager", "ability_runtime:extension_manager", + "access_token:libaccesstoken_sdk", + "access_token:libprivacy_sdk", + "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", "c_utils:utils", "common_event_service:cesfwk_innerkits", 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 b08181e37b..577c7b6ff3 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 @@ -26,11 +26,14 @@ #include "dm_common.h" #include "wm_single_instance.h" +#include "transaction/rs_interfaces.h" namespace OHOS { namespace Rosen { +class RSInterfaces; + class SuperFoldStateManager final { WM_DECLARE_SINGLE_INSTANCE_BASE(SuperFoldStateManager) public: @@ -47,7 +50,7 @@ public: void HandleSuperFoldStatusChange(SuperFoldStatusChangeEvents events); SuperFoldStatus GetCurrentStatus(); - + FoldStatus MatchSuperFoldStatusToFoldStatus(SuperFoldStatus superFoldStatus); private: std::atomic curState_ = SuperFoldStatus::HALF_FOLDED; 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 eeccc84580..0eab16b6bc 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager.h +++ b/window_scene/screen_session_manager/include/screen_session_manager.h @@ -273,6 +273,7 @@ public: std::shared_ptr GetDisplayNode(ScreenId screenId) override; void UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) override; + void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) override; uint32_t GetCurvedCompressionArea() override; ScreenProperty GetPhyScreenProperty(ScreenId screenId) override; void SetScreenPrivacyState(bool hasPrivate) override; @@ -393,6 +394,7 @@ private: DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, std::vector& windowIdList) override; void GetInternalAndExternalSession(sptr& internalSession, sptr& externalSession); + void AddPermissionUsedRecord(const std::string& permission, int32_t successCount, int32_t failCount); #ifdef DEVICE_STATUS_ENABLE void SetDragWindowScreenId(ScreenId screenId, ScreenId displayNodeScreenId); #endif // DEVICE_STATUS_ENABLE diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h index c40a98fd84..0d72b0a7be 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_interface.h @@ -164,6 +164,7 @@ public: virtual std::shared_ptr GetDisplayNode(ScreenId screenId) { return nullptr; } virtual void UpdateScreenRotationProperty(ScreenId screenId, const RRectT& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) {} + virtual void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) {} virtual void UpdateAvailableArea(ScreenId screenId, DMRect area) {} virtual int32_t SetScreenOffDelayTime(int32_t delay) { return 0; } virtual uint32_t GetCurvedCompressionArea() { return 0; } diff --git a/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h b/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h index 7244204048..26a0bcb2de 100644 --- a/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h +++ b/window_scene/screen_session_manager/include/zidl/screen_session_manager_proxy.h @@ -156,6 +156,7 @@ public: std::shared_ptr GetDisplayNode(ScreenId screenId) override; void UpdateScreenRotationProperty(ScreenId screenId, const RRectT& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) override; + void UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) override; void UpdateAvailableArea(ScreenId ScreenId, DMRect area) override; int32_t SetScreenOffDelayTime(int32_t delay) override; uint32_t GetCurvedCompressionArea() override; diff --git a/window_scene/screen_session_manager/src/connection/screen_session_ability_connection.cpp b/window_scene/screen_session_manager/src/connection/screen_session_ability_connection.cpp index b26a97c88d..30159a812f 100644 --- a/window_scene/screen_session_manager/src/connection/screen_session_ability_connection.cpp +++ b/window_scene/screen_session_manager/src/connection/screen_session_ability_connection.cpp @@ -121,7 +121,9 @@ bool ScreenSessionAbilityConnectionStub::IsAbilityConnected() bool ScreenSessionAbilityConnectionStub::IsAbilityConnectedSync() { std::unique_lock lock(connectedMutex_); - connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + if (!isConnected_) { + connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + } return IsAbilityConnected(); } @@ -129,7 +131,9 @@ int32_t ScreenSessionAbilityConnectionStub::SendMessageSync(int32_t transCode, MessageParcel &data, MessageParcel &reply) { std::unique_lock lock(connectedMutex_); - connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + if (!isConnected_) { + connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + } if (!IsAbilityConnected()) { TLOGE(WmsLogTag::DMS, "ability connection is not established"); lock.unlock(); @@ -154,7 +158,9 @@ int32_t ScreenSessionAbilityConnectionStub::SendMessageSyncBlock(int32_t transCo MessageParcel &data, MessageParcel &reply) { std::unique_lock lock(connectedMutex_); - connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + if (!isConnected_) { + connectedCv_.wait_for(lock, std::chrono::milliseconds(SEND_MESSAGE_SYNC_OUT_TIME)); + } if (!IsAbilityConnected()) { TLOGE(WmsLogTag::DMS, "ability connection is not established"); lock.unlock(); 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 51e0d10091..fe20acd7aa 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 @@ -236,6 +236,7 @@ void SingleDisplayFoldPolicy::ReportFoldStatusChangeBegin(int32_t offScreen, int void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToMain(sptr screenSession, DisplayModeChangeReason reason) { + RSInterfaces::GetInstance().SetScreenSwitching(true); if (onBootAnimation_) { ChangeScreenDisplayModeToMainOnBootAnimation(screenSession); return; @@ -288,6 +289,7 @@ void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToMain(sptr void SingleDisplayFoldPolicy::ChangeScreenDisplayModeToFull(sptr screenSession, DisplayModeChangeReason reason) { + RSInterfaces::GetInstance().SetScreenSwitching(true); if (onBootAnimation_) { ChangeScreenDisplayModeToFullOnBootAnimation(screenSession); return; 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 adebaf830d..333bec1f84 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 @@ -310,6 +310,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMainWhenFoldScreenO void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMain(sptr screenSession, DisplayModeChangeReason reason) { + RSInterfaces::GetInstance().SetScreenSwitching(true); SetdisplayModeChangeStatus(true); if (onBootAnimation_) { ChangeScreenDisplayModeToMainOnBootAnimation(screenSession); @@ -328,6 +329,7 @@ void SingleDisplayPocketFoldPolicy::ChangeScreenDisplayModeToMain(sptr screenSession, DisplayModeChangeReason reason) { + RSInterfaces::GetInstance().SetScreenSwitching(true); SetdisplayModeChangeStatus(true); if (onBootAnimation_) { ChangeScreenDisplayModeToFullOnBootAnimation(screenSession); 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 f452711c2b..97b96af9b2 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,6 +24,14 @@ namespace Rosen { WM_IMPLEMENT_SINGLE_INSTANCE(SuperFoldStateManager) +namespace { +#ifdef TP_FEATURE_ENABLE +const int32_t TP_TYPE = 12; +const char* KEYBOARD_ON_CONFIG = "version:3+main"; +const char* KEYBOARD_OFF_CONFIG = "version:3+whole"; +#endif +} + void SuperFoldStateManager::DoAngleChangeFolded(SuperFoldStatusChangeEvents event) { TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoAngleChangeFolded()"); @@ -41,14 +49,60 @@ void SuperFoldStateManager::DoAngleChangeExpanded(SuperFoldStatusChangeEvents ev void SuperFoldStateManager::DoKeyboardOn(SuperFoldStatusChangeEvents event) { + sptr meScreenSession = ScreenSessionManager::GetInstance(). + GetDefaultScreenSession(); + if (meScreenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screen session is null!"); + return; + } + auto screenProperty = meScreenSession->GetScreenProperty(); + auto screenWidth = screenProperty.GetFakeBounds().rect_.GetWidth(); + auto screenHeight = screenProperty.GetFakeBounds().rect_.GetHeight(); + + OHOS::Rect rectCur{ + .x = 0, + .y = 0, + .w = static_cast(screenWidth), + .h = static_cast(screenHeight), + }; + // SCREEN_ID_FULL = 0 + auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur); ScreenSessionManager::GetInstance().NotifyScreenMagneticStateChanged(true); - TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOn()"); +#ifdef TP_FEATURE_ENABLE + RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE, + KEYBOARD_ON_CONFIG, TpFeatureConfigType::AFT_TP_FEATURE); +#endif + TLOGI(WmsLogTag::DMS, "rect [%{public}f , %{public}f], rs response is %{public}ld", + screenWidth, screenHeight, static_cast(response)); } void SuperFoldStateManager::DoKeyboardOff(SuperFoldStatusChangeEvents event) { + sptr meScreenSession = ScreenSessionManager::GetInstance(). + GetDefaultScreenSession(); + if (meScreenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "screen session is null!"); + return; + } + auto screenProperty = meScreenSession->GetScreenProperty(); + auto screenWidth = screenProperty.GetBounds().rect_.GetWidth(); + auto screenHeight = screenProperty.GetBounds().rect_.GetHeight(); + + OHOS::Rect rectCur{ + .x = 0, + .y = 0, + .w = static_cast(screenWidth), + .h = static_cast(screenHeight), + }; + // SCREEN_ID_FULL = 0 + auto response = RSInterfaces::GetInstance().SetScreenActiveRect(0, rectCur); ScreenSessionManager::GetInstance().NotifyScreenMagneticStateChanged(false); - TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOff()"); +#ifdef TP_FEATURE_ENABLE + RSInterfaces::GetInstance().SetTpFeatureConfig(TP_TYPE, + KEYBOARD_OFF_CONFIG, TpFeatureConfigType::DEFAULT_TP_FEATURE); +#endif + TLOGI(WmsLogTag::DMS, "rect [%{public}f , %{public}f], rs response is %{public}ld", + screenWidth, screenHeight, static_cast(response)); } void SuperFoldStateManager::DoFoldedToHalfFolded(SuperFoldStatusChangeEvents event) 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 85cc379473..b31ca404c4 100644 --- a/window_scene/screen_session_manager/src/screen_session_dumper.cpp +++ b/window_scene/screen_session_manager/src/screen_session_dumper.cpp @@ -153,6 +153,17 @@ void ScreenSessionDumper::ExcuteDumpCmd() void ScreenSessionDumper::ExcuteInjectCmd() { + bool isDeveloperMode = system::GetBoolParameter("const.security.developermode.state", false); + if (isDeveloperMode) { + if (params_.size() == 1 && IsValidDisplayModeCommand(params_[0])) { + int errCode = SetFoldDisplayMode(); + if (errCode != 0) { + ShowIllegalArgsInfo(); + } + return; + } + } + bool isDebugMode = system::GetBoolParameter("dms.hidumper.supportdebug", false); if (!isDebugMode) { TLOGI(WmsLogTag::DMS, "Can't use DMS hidumper inject methods."); @@ -171,12 +182,6 @@ void ScreenSessionDumper::ExcuteInjectCmd() } 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(); @@ -746,12 +751,12 @@ void ScreenSessionDumper::SetHallAndPostureValue(std::string input) .angle = postureVal, }; SensorEvent hallEvent = { - .dataLen = sizeof(ExtHallData), .data = reinterpret_cast(&hallData), + .dataLen = sizeof(ExtHallData), }; SensorEvent postureEvent = { - .dataLen = sizeof(PostureData), .data = reinterpret_cast(&postureData), + .dataLen = sizeof(PostureData), }; OHOS::Rosen::FoldScreenSensorManager::GetInstance().HandleHallData(&hallEvent); OHOS::Rosen::FoldScreenSensorManager::GetInstance().HandlePostureData(&postureEvent); 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 5b2e26204c..c9d3d45194 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -2637,6 +2638,20 @@ void ScreenSessionManager::NotifyAndPublishEvent(sptr displayInfo, IPCSkeleton::SetCallingIdentity(identity); } +void ScreenSessionManager::UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, float rotation) +{ + sptr screenSession = GetScreenSession(screenId); + if (screenSession == nullptr) { + TLOGE(WmsLogTag::DMS, "fail, cannot find screen %{public}" PRIu64"", + screenId); + return; + } + screenSession->SetPhysicalRotation(rotation, GetFoldStatus()); + screenSession->SetScreenComponentRotation(screenComponentRotation); + TLOGI(WmsLogTag::DMS, "screenId: %{public}" PRIu64 ", rotation: %{public}f, screenComponentRotation: %{public}f", + screenId, rotation, screenComponentRotation); +} + void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) { @@ -2685,7 +2700,6 @@ void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const } { std::lock_guard lock_info(displayInfoMutex_); - screenSession->SetPhysicalRotation(rotation, GetFoldStatus()); screenSession->UpdatePropertyAfterRotation(bounds, rotation, GetFoldDisplayMode()); } sptr displayInfo = screenSession->ConvertToDisplayInfo(); @@ -4400,13 +4414,13 @@ std::shared_ptr ScreenSessionManager::GetDisplaySnapshotWithOpt HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetDisplaySnapshot(%" PRIu64")", option.displayId_); auto res = GetScreenSnapshot(option.displayId_); if (res != nullptr) { - NotifyScreenshot(option.displayId_); if (SessionPermission::IsBetaVersion()) { CheckAndSendHiSysEvent("GET_DISPLAY_SNAPSHOT", "hmos.screenshot"); } TLOGI(WmsLogTag::DMS, "isNeedNotify_:%{public}d", option.isNeedNotify_); if (option.isNeedNotify_) { isScreenShot_ = true; + NotifyScreenshot(option.displayId_); NotifyCaptureStatusChanged(); } } @@ -6118,7 +6132,6 @@ void ScreenSessionManager::InitFakeScreenSession(sptr screenSessi uint32_t screenHeight = screenProperty.GetBounds().rect_.GetHeight(); fakeScreenSession->UpdatePropertyByResolution(screenWidth, screenHeight / HALF_SCREEN_PARAM); screenSession->UpdatePropertyByFakeBounds(screenWidth, screenHeight / HALF_SCREEN_PARAM); - screenSession->UpdatePropertyByFakeInUse(true); screenSession->SetFakeScreenSession(fakeScreenSession); screenSession->SetIsFakeInUse(true); } @@ -6360,6 +6373,17 @@ void ScreenSessionManager::OnScreenCaptureNotify(ScreenId mainScreenId, int32_t clientProxy_->ScreenCaptureNotify(mainScreenId, uid, clientName); } +void ScreenSessionManager::AddPermissionUsedRecord(const std::string& permission, int32_t successCount, + int32_t failCount) +{ + int32_t ret = Security::AccessToken::PrivacyKit::AddPermissionUsedRecord(IPCSkeleton::GetCallingTokenID(), + permission, successCount, failCount); + if (ret != 0) { + TLOGW(WmsLogTag::DMS, "AddPermissionUsedRecord failed, permission:%{public}s, \ + successCount %{public}d, failedCount %{public}d", permission.c_str(), successCount, failCount); + } +} + std::shared_ptr ScreenSessionManager::GetScreenCapture(const CaptureOption& captureOption, DmErrorCode* errorCode) { @@ -6391,6 +6415,8 @@ std::shared_ptr ScreenSessionManager::GetScreenCapture(const Ca } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:GetScreenCapture(%" PRIu64")", captureOption.displayId_); auto res = GetScreenSnapshot(captureOption.displayId_); + AddPermissionUsedRecord(CUSTOM_SCREEN_CAPTURE_PERMISSION, + static_cast(res != nullptr), static_cast(res == nullptr)); if (res == nullptr) { TLOGE(WmsLogTag::DMS, "get capture null."); *errorCode = DmErrorCode::DM_ERROR_SYSTEM_INNORMAL; diff --git a/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp index ca8e3d2c14..00d924b254 100644 --- a/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/screen_session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -2493,6 +2493,41 @@ std::shared_ptr ScreenSessionManagerProxy::GetDisplayNode(ScreenI return displayNode; } +void ScreenSessionManagerProxy::UpdateScreenDirectionInfo(ScreenId screenId, float screenComponentRotation, + float rotation) +{ + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("UpdateScreenDirectionInfo: remote is null"); + return; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return; + } + if (!data.WriteUint64(screenId)) { + WLOGFE("Write screenId failed"); + return; + } + if (!data.WriteFloat(screenComponentRotation)) { + WLOGFE("Write screenComponentRotation failed"); + return; + } + if (!data.WriteFloat(rotation)) { + WLOGFE("Write rotation failed"); + return; + } + if (remote->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return; + } +} + void ScreenSessionManagerProxy::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, ScreenPropertyChangeType screenPropertyChangeType) { diff --git a/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp b/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp index 727b01ace5..f6aea297fa 100644 --- a/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp +++ b/window_scene/screen_session_manager/src/zidl/screen_session_manager_stub.cpp @@ -709,6 +709,13 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& } break; } + case DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO: { + auto screenId = static_cast(data.ReadUint64()); + auto screenComponentRotation = data.ReadFloat(); + auto rotation = data.ReadFloat(); + UpdateScreenDirectionInfo(screenId, screenComponentRotation, rotation); + break; + } case DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_ROTATION_PROPERTY: { auto screenId = static_cast(data.ReadUint64()); RRect bounds; diff --git a/window_scene/screen_session_manager_client/BUILD.gn b/window_scene/screen_session_manager_client/BUILD.gn index d8fdd143a7..ac96e0e445 100644 --- a/window_scene/screen_session_manager_client/BUILD.gn +++ b/window_scene/screen_session_manager_client/BUILD.gn @@ -52,6 +52,7 @@ ohos_shared_library("screen_session_manager_client") { external_deps = [ "c_utils:utils", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "hitrace:hitrace_meter", diff --git a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h index e8277fae61..1c28b7ce83 100644 --- a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h +++ b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h @@ -50,7 +50,7 @@ public: std::map GetAllScreensProperties() const; FoldDisplayMode GetFoldDisplayMode() const; - void UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, + void UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, ScreenDirectionInfo directionInfo, ScreenPropertyChangeType screenPropertyChangeType); uint32_t GetCurvedCompressionArea(); ScreenProperty GetPhyScreenProperty(ScreenId screenId); diff --git a/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp b/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp index 1dadeac1ba..c494efbccf 100644 --- a/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp +++ b/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp @@ -20,7 +20,7 @@ #include #include #include - +#include "dm_common.h" #include "pipeline/rs_node_map.h" #include "window_manager_hilog.h" @@ -301,14 +301,16 @@ FoldDisplayMode ScreenSessionManagerClient::GetFoldDisplayMode() const return displayMode_; } -void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation, - ScreenPropertyChangeType screenPropertyChangeType) +void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, + ScreenDirectionInfo directionInfo, ScreenPropertyChangeType screenPropertyChangeType) { if (!screenSessionManager_) { WLOGFE("screenSessionManager_ is null"); return; } - screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, rotation, screenPropertyChangeType); + screenSessionManager_->UpdateScreenDirectionInfo(screenId, directionInfo.screenRotation_, directionInfo.rotation_); + screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, directionInfo.notifyRotation_, + screenPropertyChangeType); // not need update property to input manager if (screenPropertyChangeType == ScreenPropertyChangeType::ROTATION_END || @@ -322,8 +324,9 @@ void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, } auto foldDisplayMode = screenSessionManager_->GetFoldDisplayMode(); auto foldStatus = screenSessionManager_->GetFoldStatus(); - screenSession->SetPhysicalRotation(rotation, foldStatus); - screenSession->UpdateToInputManager(bounds, rotation, foldDisplayMode); + screenSession->SetPhysicalRotation(directionInfo.rotation_, foldStatus); + screenSession->SetScreenComponentRotation(directionInfo.screenRotation_); + screenSession->UpdateToInputManager(bounds, directionInfo.notifyRotation_, foldDisplayMode); } void ScreenSessionManagerClient::SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId) diff --git a/window_scene/session/BUILD.gn b/window_scene/session/BUILD.gn index ab5fddc6d9..fc445e0ce3 100644 --- a/window_scene/session/BUILD.gn +++ b/window_scene/session/BUILD.gn @@ -79,6 +79,7 @@ ohos_shared_library("scene_session") { ] external_deps = [ + "ability_runtime:ability_manager", "ability_runtime:ability_start_setting", "ability_runtime:process_options", "ability_runtime:start_window_option", diff --git a/window_scene/session/host/include/extension_session.h b/window_scene/session/host/include/extension_session.h index 565a099e07..40dc677820 100644 --- a/window_scene/session/host/include/extension_session.h +++ b/window_scene/session/host/include/extension_session.h @@ -59,6 +59,7 @@ using NotifyAsyncOnFunc = std::function; using NotifyGetAvoidAreaByTypeFunc = std::function; using NotifyBindModalFunc = std::function; using NotifyExtensionEventFunc = std::function; +using GetStatusBarHeightFunc = std::function; class ExtensionSession : public Session { public: @@ -71,6 +72,7 @@ public: NotifyGetAvoidAreaByTypeFunc notifyGetAvoidAreaByTypeFunc_; NotifyBindModalFunc notifyBindModalFunc_; NotifyExtensionEventFunc notifyExtensionEventFunc_; + GetStatusBarHeightFunc getStatusBarHeightFunc_; }; explicit ExtensionSession(const SessionInfo& info); @@ -86,6 +88,7 @@ public: const std::string& identityToken = "") override; AvoidArea GetAvoidAreaByType(AvoidAreaType type) override; + int32_t GetStatusBarHeight() override; WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override; diff --git a/window_scene/session/host/include/pc_fold_screen_controller.h b/window_scene/session/host/include/pc_fold_screen_controller.h index 772931bcc9..d5efbd8ab9 100755 --- a/window_scene/session/host/include/pc_fold_screen_controller.h +++ b/window_scene/session/host/include/pc_fold_screen_controller.h @@ -34,14 +34,6 @@ class SceneSession; using RectRecordsVector = std::vector, WSRect>>; -enum class ScreenFoldStatus : uint8_t { - UNKNOWN = 0, - EXPANDED = 1, - FOLDED = 2, - HALF_FOLDED = 3, - HALF_FOLDED_KEYBOARD = 4, -}; - enum class ScreenSide : uint8_t { EXPAND = 0, FOLD_B = 1, @@ -51,7 +43,7 @@ enum class ScreenSide : uint8_t { class PcFoldScreenManager { WM_DECLARE_SINGLE_INSTANCE(PcFoldScreenManager); public: - void UpdateFoldScreenStatus(DisplayId displayId, ScreenFoldStatus status, + void UpdateFoldScreenStatus(DisplayId displayId, SuperFoldStatus status, const WSRect& defaultDisplayRect, const WSRect& virtualDisplayRect, const WSRect& foldCreaseRect); bool IsHalfFolded(DisplayId displayId); @@ -85,7 +77,7 @@ public: const WSRect& limitRect, int32_t titleHeight); private: - void SetDisplayInfo(DisplayId displayId, ScreenFoldStatus status); + void SetDisplayInfo(DisplayId displayId, SuperFoldStatus status); void SetDisplayRects( const WSRect& defaultDisplayRect, const WSRect& virtualDisplayRect, const WSRect& foldCreaseRect); float GetVpr(); @@ -97,7 +89,7 @@ private: std::shared_mutex displayInfoMutex_; // protect display infos DisplayId displayId_ { SCREEN_ID_INVALID }; float vpr_ { 1.5f }; // display vp ratio - ScreenFoldStatus screenFoldStatus_ { ScreenFoldStatus::UNKNOWN }; + SuperFoldStatus screenFoldStatus_ { SuperFoldStatus::UNKNOWN }; std::shared_mutex rectsMutex_; // protect rects WSRect defaultDisplayRect_; WSRect virtualDisplayRect_; @@ -117,6 +109,7 @@ class PcFoldScreenController : public RefBase { public: explicit PcFoldScreenController(wptr weakSession); bool IsHalfFolded(DisplayId displayId); + bool NeedFollowHandAnimation(); void RecordStartMoveRect(const WSRect& rect, bool isStartFullScreen); void RecordMoveRects(const WSRect& rect); bool ThrowSlip(DisplayId displayId, WSRect& rect, int32_t topAvoidHeight, int32_t botAvoidHeight); diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 771cccb80b..07b165d8e3 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -98,6 +98,12 @@ using NotifySetWindowRectAutoSaveFunc = std::function; class SceneSession : public Session { public: + struct UIExtensionTokenInfo { + bool canShowOnLockScreen{false}; + uint32_t callingTokenId{0}; + sptr abilityToken; + }; + friend class HidumpController; // callback for notify SceneSessionManager struct SpecificSessionCallback : public RefBase { @@ -126,7 +132,6 @@ public: NotifySessionTopmostChangeFunc onSessionTopmostChange_; NotifyRaiseToTopFunc onRaiseToTop_; NotifySessionEventFunc OnSessionEvent_; - NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_; NotifyRaiseAboveTargetFunc onRaiseAboveTarget_; NotifyLandscapeMultiWindowSessionFunc onSetLandscapeMultiWindowFunc_; }; @@ -211,6 +216,8 @@ public: WSError TransferPointerEvent(const std::shared_ptr& pointerEvent, bool needNotifyClient = true) override; + WSError TransferPointerEventInner(const std::shared_ptr& pointerEvent, + bool needNotifyClient = true); WSError RequestSessionBack(bool needMoveToBackground) override; WSError SetAspectRatio(float ratio) override; WSError SetGlobalMaximizeMode(MaximizeMode mode) override; @@ -260,6 +267,7 @@ public: void SetSnapshotSkip(bool isSkip); void SetSystemSceneOcclusionAlpha(double alpha); void SetSystemSceneForceUIFirst(bool forceUIFirst); + void MarkSystemSceneUIFirst(bool isForced, bool isUIFirstEnabled); void SetRequestedOrientation(Orientation orientation); WSError SetDefaultRequestedOrientation(Orientation orientation); void SetWindowAnimationFlag(bool needDefaultAnimationFlag); @@ -378,7 +386,6 @@ public: void NotifySessionForeground(uint32_t reason, bool withAnimation); void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits); void RegisterSessionChangeCallback(const sptr& sessionChangeCallback); - void RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimationFlagChangeFunc&& callback); void RegisterSystemBarPropertyChangeCallback(NotifySystemBarPropertyChangeFunc&& callback); void RegisterDefaultDensityEnabledCallback(NotifyDefaultDensityEnabledFunc&& callback); void RegisterForceSplitListener(const NotifyForceSplitFunc& func); @@ -404,11 +411,16 @@ public: * Window Animation */ void RegisterIsCustomAnimationPlayingCallback(NotifyIsCustomAnimationPlayingCallback&& callback); + void RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimationFlagChangeFunc&& callback); /** * Window Visibility */ void SetNotifyVisibleChangeFunc(const NotifyVisibleChangeFunc& func); + virtual WSError HideSync() + { + return WSError::WS_DO_NOTHING; + }; /** * Window Lifecycle @@ -460,6 +472,15 @@ public: WSPropertyChangeAction action) override; void SetSessionChangeByActionNotifyManagerListener(const SessionChangeByActionNotifyManagerFunc& func); + /** + * UIExtension + */ + bool IsShowOnLockScreen(uint32_t lockScreenZOrder); + void AddExtensionTokenInfo(const SceneSession::UIExtensionTokenInfo &tokenInfo); + void RemoveExtensionTokenInfo(sptr abilityToken); + void CheckExtensionOnLockScreenToClose(); + void CloseExtensionSync(const SceneSession::UIExtensionTokenInfo& tokenInfo); + void OnNotifyAboveLockScreen(); void AddModalUIExtension(const ExtensionWindowEventInfo& extensionInfo); void RemoveModalUIExtension(int32_t persistentId); bool HasModalUIExtension(); @@ -555,6 +576,7 @@ protected: bool PipelineNeedNotifyClientToUpdateRect() const; bool UpdateRectInner(const SessionUIParam& uiParam, SizeChangeReason reason); bool NotifyServerToUpdateRect(const SessionUIParam& uiParam, SizeChangeReason reason); + bool IsTransformNeedChange(float scaleX, float scaleY, float pivotX, float pivotY); bool UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY); bool UpdateZOrderInner(uint32_t zOrder); @@ -608,6 +630,7 @@ protected: * PC Fold Screen */ sptr pcFoldScreenController_ = nullptr; + std::atomic_bool throwSlipFullScreenFlag_ = false; /** * PC Window @@ -734,7 +757,7 @@ private: WSPropertyChangeAction action); WMError HandleActionUpdateMainWindowTopmost(const sptr& property, WSPropertyChangeAction action); - WMError HandleActionUpdateModeSupportInfo(const sptr& property, + WMError HandleActionUpdateWindowModeSupportType(const sptr& property, WSPropertyChangeAction action); WMError ProcessUpdatePropertyByAction(const sptr& property, WSPropertyChangeAction action); @@ -765,10 +788,16 @@ private: std::atomic_bool isStartMoving_ { false }; std::atomic_bool isVisibleForAccessibility_ { true }; bool isSystemSpecificSession_ { false }; + + /** + * UIExtension + */ std::atomic_bool shouldHideNonSecureWindows_ { false }; std::shared_mutex combinedExtWindowFlagsMutex_; ExtensionWindowFlags combinedExtWindowFlags_ { 0 }; std::map extWindowFlagsMap_; + mutable std::recursive_mutex extensionTokenInfosMutex_; + std::vector extensionTokenInfos_; /** * Window Decor @@ -841,6 +870,7 @@ private: * Window Animation */ NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_; + NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_; /** * Window Layout diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 36ddb3e81b..728b1a78aa 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -101,6 +101,7 @@ public: virtual void OnRemoveBlank() {} virtual void OnDrawingCompleted() {} virtual void OnExtensionDied() {} + virtual void OnExtensionDetachToDisplay() {} virtual void OnExtensionTimeout(int32_t errorCode) {} virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) {} @@ -133,6 +134,9 @@ public: void SetEventHandler(const std::shared_ptr& handler, const std::shared_ptr& exportHandler = nullptr); + /** + * Window LifeCycle + */ virtual WSError ConnectInner(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, SystemSessionConfig& systemConfig, sptr property = nullptr, sptr token = nullptr, @@ -149,9 +153,21 @@ public: WSError DrawingCompleted() override; void ResetSessionConnectState(); void ResetIsActive(); - + WSError PendingSessionToForeground(); + WSError PendingSessionToBackgroundForDelegator(bool shouldBackToCaller); bool RegisterLifecycleListener(const std::shared_ptr& listener); bool UnregisterLifecycleListener(const std::shared_ptr& listener); + void SetPendingSessionActivationEventListener(NotifyPendingSessionActivationFunc&& func); + void SetTerminateSessionListener(NotifyTerminateSessionFunc&& func); + void SetTerminateSessionListenerNew(NotifyTerminateSessionFuncNew&& func); + void SetSessionExceptionListener(NotifySessionExceptionFunc&& func, bool fromJsScene); + void SetTerminateSessionListenerTotal(NotifyTerminateSessionFuncTotal&& func); + void SetBackPressedListenser(NotifyBackPressedFunc&& func); + void SetPendingSessionToForegroundListener(NotifyPendingSessionToForegroundFunc&& func); + void SetPendingSessionToBackgroundForDelegatorListener(NotifyPendingSessionToBackgroundForDelegatorFunc&& func); + void SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func); + WSError TerminateSessionNew(const sptr info, bool needStartCaller, bool isFromBroker); + WSError TerminateSessionTotal(const sptr info, TerminateType terminateType); /** * Callbacks for ILifecycleListener @@ -167,6 +183,7 @@ public: void NotifyExtensionTimeout(int32_t errorCode) override; void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; + void NotifyExtensionDetachToDisplay() override; /** * Cross Display Move Drag @@ -255,16 +272,8 @@ public: virtual bool IsExitSplitOnBackground() const; virtual bool NeedStartingWindowExitAnimation() const { return true; } - void SetPendingSessionActivationEventListener(const NotifyPendingSessionActivationFunc& func); void SetChangeSessionVisibilityWithStatusBarEventListener( const NotifyChangeSessionVisibilityWithStatusBarFunc& func); - void SetTerminateSessionListener(const NotifyTerminateSessionFunc& func); - WSError TerminateSessionNew(const sptr info, bool needStartCaller, bool isFromBroker); - void SetTerminateSessionListenerNew(const NotifyTerminateSessionFuncNew& func); - void SetSessionExceptionListener(const NotifySessionExceptionFunc& func, bool fromJsScene); - void SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func); - WSError TerminateSessionTotal(const sptr info, TerminateType terminateType); - void SetTerminateSessionListenerTotal(const NotifyTerminateSessionFuncTotal& func); WSError Clear(bool needStartCaller = false); WSError SetSessionLabel(const std::string& label); void SetUpdateSessionLabelListener(const NofitySessionLabelUpdatedFunc& func); @@ -283,7 +292,6 @@ public: void SetSystemConfig(const SystemSessionConfig& systemConfig); void SetSnapshotScale(const float snapshotScale); - void SetBackPressedListenser(const NotifyBackPressedFunc& func); virtual WSError ProcessBackEvent(); // send back event to session_stage sptr GetScenePersistence() const; @@ -297,12 +305,6 @@ public: WSError NotifyDestroy(); WSError NotifyCloseExistPipWindow(); - void SetPendingSessionToForegroundListener(const NotifyPendingSessionToForegroundFunc& func); - WSError PendingSessionToForeground(); - void SetPendingSessionToBackgroundForDelegatorListener(const NotifyPendingSessionToBackgroundForDelegatorFunc& - func); - WSError PendingSessionToBackgroundForDelegator(bool shouldBackToCaller); - void SetSessionFocusableChangeListener(const NotifySessionFocusableChangeFunc& func); void SetSessionTouchableChangeListener(const NotifySessionTouchableChangeFunc& func); void SetClickListener(const NotifyClickFunc& func); @@ -537,6 +539,12 @@ public: void ProcessClickModalWindowOutside(int32_t posX, int32_t posY); void SetClickModalWindowOutsideListener(NotifyClickModalWindowOutsideFunc&& func); + /** + * Window Layout + */ + void SetClientDragEnable(bool dragEnable); + std::optional GetClientDragEnable() const; + protected: class SessionLifeCycleTask : public virtual RefBase { public: @@ -581,7 +589,7 @@ protected: FinishTraceForSyncTask(); return ret; } - auto syncTask = [&ret, &task, name]() { + auto syncTask = [&ret, &task, &name] { StartTraceForSyncTask(name); ret = task(); FinishTraceForSyncTask(); @@ -618,7 +626,6 @@ protected: SizeChangeReason reason_ = SizeChangeReason::UNDEFINED; NotifySessionRectChangeFunc sessionRectChangeFunc_; - NotifyPendingSessionActivationFunc pendingSessionActivationFunc_; NotifyChangeSessionVisibilityWithStatusBarFunc changeSessionVisibilityWithStatusBarFunc_; NotifySessionStateChangeFunc sessionStateChangeFunc_; NotifyBufferAvailableChangeFunc bufferAvailableChangeFunc_; @@ -629,20 +636,12 @@ protected: NotifyUIRequestFocusFunc requestFocusFunc_; NotifyUILostFocusFunc lostFocusFunc_; GetStateFromManagerFunc getStateFromManagerFunc_; - NotifyBackPressedFunc backPressedFunc_; NotifySessionFocusableChangeFunc sessionFocusableChangeFunc_; NotifySessionTouchableChangeFunc sessionTouchableChangeFunc_; NotifyClickFunc clickFunc_; - NotifyTerminateSessionFunc terminateSessionFunc_; - NotifyTerminateSessionFuncNew terminateSessionFuncNew_; - NotifyTerminateSessionFuncTotal terminateSessionFuncTotal_; NofitySessionLabelUpdatedFunc updateSessionLabelFunc_; NofitySessionIconUpdatedFunc updateSessionIconFunc_; - std::shared_ptr sessionExceptionFunc_; - std::shared_ptr jsSceneSessionExceptionFunc_; NotifySessionSnapshotFunc notifySessionSnapshotFunc_; - NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_; - NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_; NotifyRaiseToTopForPointDownFunc raiseToTopForPointDownFunc_; NotifySessionInfoLockedStateChangeFunc sessionInfoLockedStateChangeFunc_; NotifySystemSessionPointerEventFunc systemSessionPointerEventFunc_; @@ -651,6 +650,19 @@ protected: NotifyFrameLayoutFinishFunc frameLayoutFinishFunc_; VisibilityChangedDetectFunc visibilityChangedDetectFunc_; + /** + * Window LifeCycle + */ + NotifyPendingSessionActivationFunc pendingSessionActivationFunc_; + NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_; + NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_; + NotifyBackPressedFunc backPressedFunc_; + NotifyTerminateSessionFunc terminateSessionFunc_; + NotifyTerminateSessionFuncNew terminateSessionFuncNew_; + NotifyTerminateSessionFuncTotal terminateSessionFuncTotal_; + NotifySessionExceptionFunc sessionExceptionFunc_; + NotifySessionExceptionFunc jsSceneSessionExceptionFunc_; + /** * Window Rotate Animation */ @@ -663,6 +675,15 @@ protected: float snapshotScale_ = 0.5; sptr scenePersistence_ = nullptr; + /** + * Window Layout + */ + float clientScaleX_ = 1.0f; + float clientScaleY_ = 1.0f; + float clientPivotX_ = 0.0f; + float clientPivotY_ = 0.0f; + void SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY); + /** * Window ZOrder */ @@ -814,6 +835,11 @@ private: bool enableRemoveStartingWindow_ { false }; bool appBufferReady_ { false }; bool useStartingWindowAboveLocked_ { false }; + + /** + * Window Layout + */ + std::optional clientDragEnable_; }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/sub_session.h b/window_scene/session/host/include/sub_session.h index 387817034d..9362a1eee8 100644 --- a/window_scene/session/host/include/sub_session.h +++ b/window_scene/session/host/include/sub_session.h @@ -26,6 +26,8 @@ public: WSError Show(sptr property) override; WSError Hide() override; + WSError HideSync() override; + WSError Hide(bool needSyncHide); WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; int32_t GetMissionId() const override; WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index 529010c4a7..afe52e5164 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -273,7 +273,7 @@ public: virtual WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) { return WSError::WS_OK; } virtual int32_t GetStatusBarHeight() { return 0; } virtual WSError SetDialogSessionBackGestureEnabled(bool isEnabled) { return WSError::WS_OK; } - + virtual void NotifyExtensionDetachToDisplay() {} /** * @brief Request to get focus or lose focus. * 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 b5769c12ca..ab155e6dbf 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 @@ -86,6 +86,7 @@ enum class SessionInterfaceCode { TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION, TRANS_ID_NOTIFY_EXTENSION_TIMEOUT, TRANS_ID_NOTIFY_EXTENSION_EVENT_ASYNC, + TRANS_ID_NOTIFY_EXTENSION_DETACH_TO_DISPLAY, // PictureInPicture TRANS_ID_NOTIFY_PIP_WINDOW_PREPARE_CLOSE = 800, diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index 054c26e4af..88c1356b47 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -103,6 +103,7 @@ public: WMError SetSystemWindowEnableDrag(bool enableDrag) override; WSError RequestFocus(bool isFocused) override; void NotifyExtensionEventAsync(uint32_t notifyEvent) override; + void NotifyExtensionDetachToDisplay() override; WSError OnSessionModalTypeChange(SubWindowModalType subWindowModalType) override; WSError OnMainSessionModalTypeChange(bool isModal) override; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 614f5501d5..272873ba78 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -98,6 +98,7 @@ private: int HandleTriggerBindModalUIExtension(MessageParcel& data, MessageParcel& reply); int HandleTransferAccessibilityEvent(MessageParcel& data, MessageParcel& reply); int HandleNotifyExtensionEventAsync(MessageParcel& data, MessageParcel& reply); + int HandleNotifyExtensionDetachToDisplay(MessageParcel& data, MessageParcel& reply); // PictureInPicture int HandleNotifyPiPWindowPrepareClose(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index 63add20261..2a32bde39c 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -477,4 +477,13 @@ WSError ExtensionSession::NotifyDumpInfo(const std::vector& params, } return sessionStage_->NotifyDumpInfo(params, info); } + +int32_t ExtensionSession::GetStatusBarHeight() +{ + TLOGI(WmsLogTag::WMS_UIEXT, "persistenId=%{public}d", GetPersistentId()); + if (extSessionEventCallback_ != nullptr && extSessionEventCallback_->getStatusBarHeightFunc_ != nullptr) { + return extSessionEventCallback_->getStatusBarHeightFunc_(); + } + return 0; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/move_drag_controller.cpp b/window_scene/session/host/src/move_drag_controller.cpp index d849b91fad..695039aca8 100644 --- a/window_scene/session/host/src/move_drag_controller.cpp +++ b/window_scene/session/host/src/move_drag_controller.cpp @@ -823,7 +823,7 @@ void MoveDragController::InitDecorValue(const sptr proper bool isDialogWindow = WindowHelper::IsDialogWindow(windowType); isDecorEnable_ = (isMainWindow || ((isSubWindow || isDialogWindow) && property->IsDecorEnable())) && sysConfig.isSystemDecorEnable_ && - WindowHelper::IsWindowModeSupported(sysConfig.decorModeSupportInfo_, property->GetWindowMode()); + WindowHelper::IsWindowModeSupported(sysConfig.decorWindowModeSupportType_, property->GetWindowMode()); } void MoveDragController::ProcessSessionRectChange(SizeChangeReason reason) diff --git a/window_scene/session/host/src/pc_fold_screen_controller.cpp b/window_scene/session/host/src/pc_fold_screen_controller.cpp index 66c08cffb9..a61429b5b1 100755 --- a/window_scene/session/host/src/pc_fold_screen_controller.cpp +++ b/window_scene/session/host/src/pc_fold_screen_controller.cpp @@ -14,6 +14,7 @@ */ #include "session/host/include/pc_fold_screen_controller.h" +#include #include "display_manager.h" #include "session/host/include/scene_session.h" #include "window_manager_hilog.h" @@ -50,14 +51,14 @@ const WSRect RECT_ZERO = { 0, 0, 0, 0 }; WM_IMPLEMENT_SINGLE_INSTANCE(PcFoldScreenManager); -void PcFoldScreenManager::UpdateFoldScreenStatus(DisplayId displayId, ScreenFoldStatus status, +void PcFoldScreenManager::UpdateFoldScreenStatus(DisplayId displayId, SuperFoldStatus status, const WSRect& defaultDisplayRect, const WSRect& virtualDisplayRect, const WSRect& foldCreaseRect) { SetDisplayInfo(displayId, status); SetDisplayRects(defaultDisplayRect, virtualDisplayRect, foldCreaseRect); } -void PcFoldScreenManager::SetDisplayInfo(DisplayId displayId, ScreenFoldStatus status) +void PcFoldScreenManager::SetDisplayInfo(DisplayId displayId, SuperFoldStatus status) { std::unique_lock lock(displayInfoMutex_); if (displayId_ == displayId && screenFoldStatus_ == status) { @@ -89,7 +90,7 @@ void PcFoldScreenManager::SetDisplayRects( bool PcFoldScreenManager::IsHalfFolded(DisplayId displayId) { std::shared_lock lock(displayInfoMutex_); - return screenFoldStatus_ == ScreenFoldStatus::HALF_FOLDED && displayId_ == displayId; + return screenFoldStatus_ == SuperFoldStatus::HALF_FOLDED && displayId_ == displayId; } float PcFoldScreenManager::GetVpr() @@ -348,6 +349,13 @@ bool PcFoldScreenController::IsHalfFolded(DisplayId displayId) return PcFoldScreenManager::GetInstance().IsHalfFolded(displayId); } +bool PcFoldScreenController::NeedFollowHandAnimation() +{ + static bool needFollowHandAnimation = + system::GetParameter("persist.window.throw_slip_follow_animation.enabled", "0") == "1"; + return needFollowHandAnimation; +} + void PcFoldScreenController::RecordStartMoveRect(const WSRect& rect, bool isStartFullScreen) { TLOGI(WmsLogTag::WMS_LAYOUT, "rect: %{public}s, isStartFullScreen: %{public}d", diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 0111866cf2..b6d7096977 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -199,6 +199,127 @@ WSError SceneSession::ReconnectInner(sptr property) return ret; } +bool SceneSession::IsShowOnLockScreen(uint32_t lockScreenZorder) +{ + TLOGD(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: lockScreenZorder: %{public}d, zOrder_: %{public}d", + lockScreenZorder, + zOrder_); + + // must be default screen + ScreenId defaultScreenId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId(); + auto sessionProperty = GetSessionProperty(); + if (sessionProperty != nullptr && defaultScreenId != sessionProperty->GetDisplayId()) { + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not default display"); + return false; + } + + if (!GetStateFromManager(ManagerState::MANAGER_STATE_SCREEN_LOCKED)) { + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not in lock screen"); + return false; + } + + // current window on lock screen jurded by zorder + if (zOrder_ > lockScreenZorder) { + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: zOrder_ is bigger"); + return true; + } + + return false; +} + +void SceneSession::AddExtensionTokenInfo(const SceneSession::UIExtensionTokenInfo &tokenInfo) +{ + { + std::lock_guard lock(extensionTokenInfosMutex_); + extensionTokenInfos_.push_back(tokenInfo); + } + + TLOGI(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: canShowOnLockScreen: %{public}u, persistentId: %{public}u", + tokenInfo.canShowOnLockScreen, + GetPersistentId()); +} + +void SceneSession::RemoveExtensionTokenInfo(sptr abilityToken) +{ + std::lock_guard lock(extensionTokenInfosMutex_); + auto persistentId = GetPersistentId(); + auto itr = std::remove_if( + extensionTokenInfos_.begin(), extensionTokenInfos_.end(), [&abilityToken, persistentId](const auto &tokenInfo) { + TLOGI(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: need remove, calling token: %{public}u, persistentId: %{public}u", + tokenInfo.callingTokenId, + persistentId); + return tokenInfo.abilityToken == abilityToken; + }); + + extensionTokenInfos_.erase(itr, extensionTokenInfos_.end()); +} + +void SceneSession::OnNotifyAboveLockScreen() +{ + CheckExtensionOnLockScreenToClose(); +} + +void SceneSession::CheckExtensionOnLockScreenToClose() +{ + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: %{public}u", GetPersistentId()); + + // 1. check sub session + for (auto session : GetSubSession()) { + if (!session) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: session is null"); + continue; + } + session->CheckExtensionOnLockScreenToClose(); + } + + // 2. check self permission + std::vector tokenInfosToClose; + { + std::lock_guard lock(extensionTokenInfosMutex_); + for (auto &tokenInfo : extensionTokenInfos_) { + if (tokenInfo.canShowOnLockScreen) { + continue; + } + tokenInfosToClose.push_back(tokenInfo); + } + } + + // 3. close ui extension without lock screen permisson + std::for_each(tokenInfosToClose.rbegin(), + tokenInfosToClose.rend(), + [this](SceneSession::UIExtensionTokenInfo &tokenInfo) { CloseExtensionSync(tokenInfo); }); +} + +void SceneSession::CloseExtensionSync(const SceneSession::UIExtensionTokenInfo &tokenInfo) +{ + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock"); + + // hide sub window + auto subSceneSessions = GetSubSession(); + for (auto session : subSceneSessions) { + if (!session) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: session is null"); + continue; + } + // hide sub window of ui extension + if (session->GetAbilityToken() == tokenInfo.abilityToken) { + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: hide sub window %{public}u", session->GetWindowId()); + session->HideSync(); + } + } + + TLOGI(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: close ui extension, callerToken: %{public}u, persistent id %{public}u", + tokenInfo.callingTokenId, + GetPersistentId()); + + // kill ui extension ability + AAFwk::AbilityManagerClient::GetInstance()->CloseUIExtensionAbilityBySCB(tokenInfo.abilityToken); +} + WSError SceneSession::Foreground( sptr property, bool isFromClient, const std::string& identityToken) { @@ -724,16 +845,13 @@ void SceneSession::RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimat auto task = [weakThis = wptr(this), callback = std::move(callback)] { auto session = weakThis.promote(); if (!session) { - TLOGE(WmsLogTag::WMS_LIFE, "session is null"); - return WSError::WS_ERROR_DESTROYED_OBJECT; + TLOGNE(WmsLogTag::WMS_LIFE, "session is null"); + return; } - if (session->sessionChangeCallback_) { - session->sessionChangeCallback_->onWindowAnimationFlagChange_ = std::move(callback); - session->sessionChangeCallback_->onWindowAnimationFlagChange_(session->IsNeedDefaultAnimation()); - } - return WSError::WS_OK; + session->onWindowAnimationFlagChange_ = std::move(callback); + session->onWindowAnimationFlagChange_(session->IsNeedDefaultAnimation()); }; - PostTask(task, "RegisterDefaultAnimationFlagChangeCallback"); + PostTask(task, __func__); } void SceneSession::RegisterDefaultDensityEnabledCallback(NotifyDefaultDensityEnabledFunc&& callback) @@ -2127,6 +2245,20 @@ void SceneSession::NotifyOutsideDownEvent(const std::shared_ptr& pointerEvent, bool needNotifyClient) +{ + auto task = [weakThis = wptr(this), pointerEvent, needNotifyClient] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::DEFAULT, "session is null"); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + return session->TransferPointerEventInner(pointerEvent, needNotifyClient); + }; + return PostSyncTask(std::move(task), __func__); +} + +WSError SceneSession::TransferPointerEventInner(const std::shared_ptr& pointerEvent, + bool needNotifyClient) { WLOGFD("[WMSCom] TransferPointEvent, id: %{public}d, type: %{public}d, needNotifyClient: %{public}d", GetPersistentId(), GetWindowType(), needNotifyClient); @@ -2224,7 +2356,7 @@ bool SceneSession::IsFullScreenMovable() return false; } return property->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && - WindowHelper::IsWindowModeSupported(property->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING); + WindowHelper::IsWindowModeSupported(property->GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FLOATING); } bool SceneSession::IsMovable() @@ -2322,7 +2454,7 @@ bool SceneSession::IsDecorEnable() const bool isValidWindow = isMainWindow || ((isSubWindow || isDialogWindow) && property->IsDecorEnable()); bool isWindowModeSupported = WindowHelper::IsWindowModeSupported( - systemConfig_.decorModeSupportInfo_, property->GetWindowMode()); + systemConfig_.decorWindowModeSupportType_, property->GetWindowMode()); bool enable = isValidWindow && systemConfig_.isSystemDecorEnable_ && isWindowModeSupported; return enable; } @@ -2525,10 +2657,15 @@ void SceneSession::InitializeCrossMoveDrag() void SceneSession::HandleMoveDragSurfaceBounds(WSRect& rect, WSRect& globalRect, SizeChangeReason reason, bool isGlobal, bool needFlush) { + throwSlipFullScreenFlag_.store(false); if (pcFoldScreenController_ && pcFoldScreenController_->IsHalfFolded(GetScreenId())) { - auto movingPair = std::make_pair(pcFoldScreenController_->GetMovingTimingProtocol(), - pcFoldScreenController_->GetMovingTimingCurve()); - SetSurfaceBoundsWithAnimation(movingPair, globalRect, nullptr, isGlobal, needFlush); + if (pcFoldScreenController_->NeedFollowHandAnimation()) { + auto movingPair = std::make_pair(pcFoldScreenController_->GetMovingTimingProtocol(), + pcFoldScreenController_->GetMovingTimingCurve()); + SetSurfaceBoundsWithAnimation(movingPair, globalRect, nullptr, isGlobal, needFlush); + } else { + SetSurfaceBounds(globalRect, isGlobal, needFlush); + } if (reason == SizeChangeReason::MOVE) { pcFoldScreenController_->RecordMoveRects(rect); } @@ -2612,6 +2749,14 @@ bool SceneSession::MoveUnderInteriaAndNotifyRectChange(WSRect& rect, SizeChangeR TLOGNW(WmsLogTag::WMS_LAYOUT, "session is nullptr"); return; } + if (!session->IsVisibleForeground()) { + TLOGNW(WmsLogTag::WMS_LAYOUT, "session go background when throw"); + return; + } + if (!session->throwSlipFullScreenFlag_.load()) { + TLOGNW(WmsLogTag::WMS_LAYOUT, "session moved when throw"); + return; + } session->OnSessionEvent(SessionEvent::EVENT_MAXIMIZE_WITHOUT_ANIMATION, SessionEventParam {rect.posX_, rect.posY_, rect.width_, rect.height_}); }; @@ -3149,28 +3294,47 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst) } } +void SceneSession::MarkSystemSceneUIFirst(bool isForced, bool isUIFirstEnabled) +{ + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::MarkSystemSceneUIFirst"); + auto leashWinSurfaceNode = GetLeashWinSurfaceNode(); + if (leashWinSurfaceNode == nullptr && surfaceNode_ == nullptr) { + TLOGE(WmsLogTag::DEFAULT, "leashWindow and surfaceNode are nullptr"); + return; + } + if (leashWinSurfaceNode != nullptr) { + TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForced=%{public}d. isUIFirstEnabled=%{public}d", + leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId(), isForced, isUIFirstEnabled); + leashWinSurfaceNode->MarkUifirstNode(isForced, isUIFirstEnabled); + } else { + TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForced=%{public}d. isUIFirstEnabled=%{public}d", + surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), isForced, isUIFirstEnabled); + surfaceNode_->MarkUifirstNode(isForced, isUIFirstEnabled); + } +} + WSError SceneSession::UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) { - auto task = [weakThis = wptr(this), needDefaultAnimationFlag]() { + auto task = [weakThis = wptr(this), needDefaultAnimationFlag] { auto session = weakThis.promote(); if (!session) { - WLOGFE("session is null"); + TLOGNE(WmsLogTag::WMS_LIFE, "session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } session->needDefaultAnimationFlag_ = needDefaultAnimationFlag; - if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onWindowAnimationFlagChange_) { - session->sessionChangeCallback_->onWindowAnimationFlagChange_(needDefaultAnimationFlag); + if (session->onWindowAnimationFlagChange_) { + session->onWindowAnimationFlagChange_(needDefaultAnimationFlag); } return WSError::WS_OK; }; - return PostSyncTask(task, "UpdateWindowAnimationFlag"); + return PostSyncTask(task, __func__); } void SceneSession::SetWindowAnimationFlag(bool needDefaultAnimationFlag) { needDefaultAnimationFlag_ = needDefaultAnimationFlag; - if (sessionChangeCallback_ && sessionChangeCallback_->onWindowAnimationFlagChange_) { - sessionChangeCallback_->onWindowAnimationFlagChange_(needDefaultAnimationFlag); + if (onWindowAnimationFlagChange_) { + onWindowAnimationFlagChange_(needDefaultAnimationFlag); } return; } @@ -3610,6 +3774,9 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptrIsPcOrPadEnableActivation()) { info.startWindowOption = abilitySessionInfo->startWindowOption; + info.supportWindowModes.assign(abilitySessionInfo->supportWindowModes.begin(), + abilitySessionInfo->supportWindowModes.end()); + info.windowModeSupportType = WindowHelper::ConvertSupportModesToSupportType(info.supportWindowModes); } if (info.want != nullptr) { info.windowMode = info.want->GetIntParam(AAFwk::Want::PARAM_RESV_WINDOW_MODE, 0); @@ -3622,11 +3789,13 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptr(WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST): return HandleActionUpdateMainWindowTopmost(property, action); case static_cast(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO): - return HandleActionUpdateModeSupportInfo(property, action); + return HandleActionUpdateWindowModeSupportType(property, action); default: TLOGE(WmsLogTag::DEFAULT, "Failed to find func handler!"); return WMError::WM_DO_NOTHING; @@ -4335,12 +4504,10 @@ WSError SceneSession::NotifySessionExceptionInner(const sptr session->sessionInfo_.errorReason = abilitySessionInfo->errorReason; } if (session->sessionExceptionFunc_) { - auto exceptionFunc = *(session->sessionExceptionFunc_); - exceptionFunc(info, needRemoveSession, false); + session->sessionExceptionFunc_(info, needRemoveSession, false); } if (session->jsSceneSessionExceptionFunc_) { - auto exceptionFunc = *(session->jsSceneSessionExceptionFunc_); - exceptionFunc(info, needRemoveSession, startFail); + session->jsSceneSessionExceptionFunc_(info, needRemoveSession, startFail); } return WSError::WS_OK; }; @@ -5061,6 +5228,7 @@ WMError SceneSession::SetWindowEnableDragBySystem(bool enableDrag) TLOGNE(WmsLogTag::WMS_LAYOUT, "session is null"); return; } + session->SetClientDragEnable(enableDrag); TLOGNI(WmsLogTag::WMS_LAYOUT, "id: %{public}d, enableDrag: %{public}d", session->GetPersistentId(), enableDrag); auto sessionProperty = session->GetSessionProperty(); @@ -5077,17 +5245,17 @@ WMError SceneSession::SetWindowEnableDragBySystem(bool enableDrag) return WMError::WM_OK; } -WMError SceneSession::HandleActionUpdateModeSupportInfo(const sptr& property, +WMError SceneSession::HandleActionUpdateWindowModeSupportType(const sptr& property, WSPropertyChangeAction action) { if (!property->GetSystemCalling()) { - TLOGE(WmsLogTag::DEFAULT, "Update property modeSupportInfo permission denied!"); + TLOGE(WmsLogTag::DEFAULT, "permission denied!"); return WMError::WM_ERROR_NOT_SYSTEM_APP; } auto sessionProperty = GetSessionProperty(); if (sessionProperty != nullptr) { - sessionProperty->SetModeSupportInfo(property->GetModeSupportInfo()); + sessionProperty->SetWindowModeSupportType(property->GetWindowModeSupportType()); } return WMError::WM_OK; } @@ -5383,13 +5551,25 @@ void SceneSession::NotifyClientToUpdateAvoidArea() } } +bool SceneSession::IsTransformNeedChange(float scaleX, float scaleY, float pivotX, float pivotY) +{ + bool nearEqual = NearEqual(scaleX_, scaleX) && NearEqual(scaleY_, scaleY) && + NearEqual(pivotX_, pivotX) && NearEqual(pivotY_, pivotY) && + NearEqual(clientScaleX_, scaleX) && NearEqual(clientScaleY_, scaleY) && + NearEqual(clientPivotX_, pivotX) && NearEqual(clientPivotY_, pivotY); + return !nearEqual; +} + bool SceneSession::UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY) { - if (NearEqual(scaleX_, scaleX) && NearEqual(scaleY_, scaleY) && - NearEqual(pivotX_, pivotX) && NearEqual(pivotY_, pivotY)) { + if (!IsTransformNeedChange(scaleX, scaleY, pivotX, pivotY)) { return false; } Session::SetScale(scaleX, scaleY, pivotX, pivotY); + if (!IsSessionForeground()) { + TLOGD(WmsLogTag::WMS_LAYOUT, "id:%{public}d, session is not foreground!", GetPersistentId()); + return false; + } if (sessionStage_ != nullptr) { Transform transform; transform.scaleX_ = scaleX; @@ -5397,6 +5577,7 @@ bool SceneSession::UpdateScaleInner(float scaleX, float scaleY, float pivotX, fl transform.pivotX_ = pivotX; transform.pivotY_ = pivotY; sessionStage_->NotifyTransformChange(transform); + Session::SetClientScale(scaleX, scaleY, pivotX, pivotY); } else { WLOGFE("sessionStage is nullptr"); } @@ -5481,7 +5662,6 @@ void SceneSession::UnregisterSessionChangeListeners() session->sessionChangeCallback_->onSessionTopmostChange_ = nullptr; session->sessionChangeCallback_->onRaiseToTop_ = nullptr; session->sessionChangeCallback_->OnSessionEvent_ = nullptr; - session->sessionChangeCallback_->onWindowAnimationFlagChange_ = nullptr; session->sessionChangeCallback_->onRaiseAboveTarget_ = nullptr; session->sessionChangeCallback_->onSetLandscapeMultiWindowFunc_ = nullptr; } diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 51f7e97dd4..e9137f86a6 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -121,7 +121,7 @@ void Session::PostTask(Task&& task, const std::string& name, int64_t delayTime) HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str()); return task(); } - auto localTask = [task = std::move(task), name]() { + auto localTask = [task = std::move(task), name] { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str()); task(); }; @@ -134,7 +134,7 @@ void Session::PostExportTask(Task&& task, const std::string& name, int64_t delay HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str()); return task(); } - auto localTask = [task = std::move(task), name]() { + auto localTask = [task = std::move(task), name] { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "s:%s", name.c_str()); task(); }; @@ -471,6 +471,23 @@ void Session::NotifyTransferAccessibilityEvent(const Accessibility::Accessibilit } } +void Session::NotifyExtensionDetachToDisplay() +{ + if (!SessionPermission::IsSystemCalling()) { + TLOGE(WmsLogTag::WMS_UIEXT, "permission denied!"); + return; + } + + auto lifecycleListeners = GetListeners(); + for (auto &listener : lifecycleListeners) { + if (auto listenerPtr = listener.lock()) { + listenerPtr->OnExtensionDetachToDisplay(); + } + } + + TLOGI(WmsLogTag::WMS_UIEXT, "called"); +} + float Session::GetAspectRatio() const { return aspectRatio_; @@ -1071,6 +1088,7 @@ void Session::InitSessionPropertyWhenConnect(const sptr& property->SetWindowRect(rect); property->SetPersistentId(GetPersistentId()); property->SetFullScreenStart(GetSessionInfo().fullScreenStart_); + property->SetWindowModeSupportType(GetSessionInfo().windowModeSupportType); } if (sessionProperty && property) { property->SetRequestedOrientation(sessionProperty->GetRequestedOrientation()); @@ -1089,7 +1107,10 @@ void Session::InitSessionPropertyWhenConnect(const sptr& property->SetCompatibleWindowSizeInPc(sessionProperty->GetCompatibleInPcPortraitWidth(), sessionProperty->GetCompatibleInPcPortraitHeight(), sessionProperty->GetCompatibleInPcLandscapeWidth(), sessionProperty->GetCompatibleInPcLandscapeHeight()); - property->SetDragEnabled(sessionProperty->GetDragEnabled()); + std::optional clientDragEnable = GetClientDragEnable(); + if (clientDragEnable.has_value()) { + property->SetDragEnabled(clientDragEnable.value()); + } } if (sessionProperty && SessionHelper::IsMainWindow(GetWindowType())) { property->SetIsPcAppInPad(sessionProperty->GetIsPcAppInPad()); @@ -1368,6 +1389,16 @@ void Session::SetClickModalWindowOutsideListener(NotifyClickModalWindowOutsideFu PostTask(task, __func__); } +void Session::SetClientDragEnable(bool dragEnable) +{ + clientDragEnable_ = dragEnable; +} + +std::optional Session::GetClientDragEnable() const +{ + return clientDragEnable_; +} + void Session::NotifyForegroundInteractiveStatus(bool interactive) { SetForegroundInteractiveStatus(interactive); @@ -1469,19 +1500,46 @@ void Session::SetChangeSessionVisibilityWithStatusBarEventListener( changeSessionVisibilityWithStatusBarFunc_ = func; } -void Session::SetPendingSessionActivationEventListener(const NotifyPendingSessionActivationFunc& func) +void Session::SetPendingSessionActivationEventListener(NotifyPendingSessionActivationFunc&& func) { - pendingSessionActivationFunc_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->pendingSessionActivationFunc_ = std::move(func); + }; + PostTask(task, where); } -void Session::SetBackPressedListenser(const NotifyBackPressedFunc& func) +void Session::SetBackPressedListenser(NotifyBackPressedFunc&& func) { - backPressedFunc_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->backPressedFunc_ = std::move(func); + }; + PostTask(task, where); } -void Session::SetTerminateSessionListener(const NotifyTerminateSessionFunc& func) +void Session::SetTerminateSessionListener(NotifyTerminateSessionFunc&& func) { - terminateSessionFunc_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->terminateSessionFunc_ = std::move(func); + }; + PostTask(task, where); } void Session::RemoveLifeCycleTask(const LifeCycleTaskType& taskType) @@ -1585,9 +1643,18 @@ WSError Session::TerminateSessionNew( return WSError::WS_OK; } -void Session::SetTerminateSessionListenerNew(const NotifyTerminateSessionFuncNew& func) +void Session::SetTerminateSessionListenerNew(NotifyTerminateSessionFuncNew&& func) { - terminateSessionFuncNew_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->terminateSessionFuncNew_ = std::move(func); + }; + PostTask(task, where); } WSError Session::TerminateSessionTotal(const sptr abilitySessionInfo, TerminateType terminateType) @@ -1617,9 +1684,18 @@ WSError Session::TerminateSessionTotal(const sptr abilitySes return WSError::WS_OK; } -void Session::SetTerminateSessionListenerTotal(const NotifyTerminateSessionFuncTotal& func) +void Session::SetTerminateSessionListenerTotal(NotifyTerminateSessionFuncTotal&& func) { - terminateSessionFuncTotal_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->terminateSessionFuncTotal_ = std::move(func); + }; + PostTask(task, where); } WSError Session::SetSessionLabel(const std::string& label) @@ -1675,18 +1751,22 @@ WSError Session::Clear(bool needStartCaller) return WSError::WS_OK; } -void Session::SetSessionExceptionListener(const NotifySessionExceptionFunc& func, bool fromJsScene) +void Session::SetSessionExceptionListener(NotifySessionExceptionFunc&& func, bool fromJsScene) { - if (func == nullptr) { - WLOGFE("func is nullptr"); - return; - } - std::shared_ptr funcSptr = std::make_shared(func); - if (fromJsScene) { - jsSceneSessionExceptionFunc_ = funcSptr; - } else { - sessionExceptionFunc_ = funcSptr; - } + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where, fromJsScene] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + if (fromJsScene) { + session->jsSceneSessionExceptionFunc_ = std::move(func); + } else { + session->sessionExceptionFunc_ = std::move(func); + } + }; + PostTask(task, where); } void Session::SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func) @@ -1698,9 +1778,18 @@ void Session::SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func) notifySessionSnapshotFunc_ = func; } -void Session::SetPendingSessionToForegroundListener(const NotifyPendingSessionToForegroundFunc& func) +void Session::SetPendingSessionToForegroundListener(NotifyPendingSessionToForegroundFunc&& func) { - pendingSessionToForegroundFunc_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->pendingSessionToForegroundFunc_ = std::move(func); + }; + PostTask(task, where); } WSError Session::PendingSessionToForeground() @@ -1714,9 +1803,18 @@ WSError Session::PendingSessionToForeground() } void Session::SetPendingSessionToBackgroundForDelegatorListener( - const NotifyPendingSessionToBackgroundForDelegatorFunc& func) + NotifyPendingSessionToBackgroundForDelegatorFunc&& func) { - pendingSessionToBackgroundForDelegatorFunc_ = func; + const char* const where = __func__; + auto task = [weakThis = wptr(this), func = std::move(func), where] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LIFE, "%{public}s session is nullptr", where); + return; + } + session->pendingSessionToBackgroundForDelegatorFunc_ = std::move(func); + }; + PostTask(task, where); } WSError Session::PendingSessionToBackgroundForDelegator(bool shouldBackToCaller) @@ -3250,6 +3348,16 @@ void Session::SetScale(float scaleX, float scaleY, float pivotX, float pivotY) pivotY_ = pivotY; } +void Session::SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY) +{ + TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, preScaleX:%{public}f, preScaleY:%{public}f, " + "newScaleX:%{public}f, newScaleY:%{public}f", GetPersistentId(), clientScaleX_, clientScaleY_, scaleX, scaleY); + clientScaleX_ = scaleX; + clientScaleY_ = scaleY; + clientPivotX_ = pivotX; + clientPivotY_ = pivotY; +} + float Session::GetScaleX() const { return scaleX_; diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index 6b5b8e6b7e..73d8d98403 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -69,6 +69,16 @@ WSError SubSession::Show(sptr property) } WSError SubSession::Hide() +{ + return Hide(false); // async mode +} + +WSError SubSession::HideSync() +{ + return Hide(true); // sync mode +} + +WSError SubSession::Hide(bool needSyncHide) { if (!CheckPermissionWithPropertyAnimation(GetSessionProperty())) { return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -95,7 +105,12 @@ WSError SubSession::Hide() ret = session->SceneSession::Background(); return ret; }; - PostTask(task, "Hide"); + + if (needSyncHide) { + return PostSyncTask(task, "HideSync"); + } + + PostTask(task, "HideAsync"); return WSError::WS_OK; } diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 66676857ee..934c33b8f4 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -299,6 +299,7 @@ WSError SessionProxy::Connect(const sptr& sessionStage, const spt } property->SetCollaboratorType(reply.ReadInt32()); property->SetFullScreenStart(reply.ReadBool()); + property->SetWindowModeSupportType(reply.ReadUint32()); property->SetCompatibleModeInPc(reply.ReadBool()); property->SetCompatibleWindowSizeInPc(reply.ReadInt32(), reply.ReadInt32(), reply.ReadInt32(), reply.ReadInt32()); @@ -484,6 +485,21 @@ WSError SessionProxy::PendingSessionActivation(sptr abilityS return WSError::WS_ERROR_IPC_FAILED; } } + auto size = abilitySessionInfo->supportWindowModes.size(); + if (size > 0 && size <= WINDOW_SUPPORT_MODE_MAX_SIZE) { + if (!data.WriteUint32(static_cast(size))) { + return WSError::WS_ERROR_IPC_FAILED; + } + for (decltype(size) i = 0; i < size; i++) { + if (!data.WriteInt32(static_cast(abilitySessionInfo->supportWindowModes[i]))) { + return WSError::WS_ERROR_IPC_FAILED; + } + } + } else { + if (!data.WriteUint32(0)) { + return WSError::WS_ERROR_IPC_FAILED; + } + } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); @@ -1997,6 +2013,27 @@ void SessionProxy::NotifyExtensionEventAsync(uint32_t notifyEvent) } } +void SessionProxy::NotifyExtensionDetachToDisplay() +{ + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: UIExtcalled"); + + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: WriteInterfaceToken failed"); + return; + } + + sptr remote = Remote(); + auto ret = remote->SendRequest( + static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DETACH_TO_DISPLAY), data, reply, option); + if (ret != ERR_NONE) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: SendRequest failed"); + } +} + WMError SessionProxy::SetGestureBackEnabled(bool isEnabled) { MessageParcel data; diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index f76cd619a8..2f86a896e8 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -222,6 +222,8 @@ int SessionStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleMainSessionModalTypeChange(data, reply); case static_cast(SessionInterfaceCode::TRANS_ID_SET_WINDOW_RECT_AUTO_SAVE): return HandleSetWindowRectAutoSave(data, reply); + case static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DETACH_TO_DISPLAY): + return HandleNotifyExtensionDetachToDisplay(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -375,6 +377,7 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply) reply.WriteUint32(winRect.height_); reply.WriteInt32(property->GetCollaboratorType()); reply.WriteBool(property->GetFullScreenStart()); + reply.WriteUint32(property->GetWindowModeSupportType()); reply.WriteBool(property->GetCompatibleModeInPc()); reply.WriteInt32(property->GetCompatibleInPcPortraitWidth()); reply.WriteInt32(property->GetCompatibleInPcPortraitHeight()); @@ -654,6 +657,14 @@ int SessionStub::HandlePendingSessionActivation(MessageParcel& data, MessageParc auto startWindowOption = data.ReadParcelable(); abilitySessionInfo->startWindowOption.reset(startWindowOption); } + uint32_t size = data.ReadUint32(); + if (size > 0 && size <= WINDOW_SUPPORT_MODE_MAX_SIZE) { + abilitySessionInfo->supportWindowModes.reserve(size); + for (uint32_t i = 0; i < size; i++) { + abilitySessionInfo->supportWindowModes.push_back( + static_cast(data.ReadInt32())); + } + } WSError errCode = PendingSessionActivation(abilitySessionInfo); reply.WriteUint32(static_cast(errCode)); return ERR_NONE; @@ -1202,6 +1213,13 @@ int SessionStub::HandleSetDialogSessionBackGestureEnabled(MessageParcel& data, M return ERR_NONE; } +int SessionStub::HandleNotifyExtensionDetachToDisplay(MessageParcel &data, MessageParcel &reply) +{ + TLOGD(WmsLogTag::WMS_UIEXT, "in"); + NotifyExtensionDetachToDisplay(); + return ERR_NONE; +} + int SessionStub::HandleRequestFocus(MessageParcel& data, MessageParcel& reply) { TLOGD(WmsLogTag::WMS_FOCUS, "in"); diff --git a/window_scene/session/screen/include/screen_property.h b/window_scene/session/screen/include/screen_property.h index 4a3d816af9..776d7ca128 100644 --- a/window_scene/session/screen/include/screen_property.h +++ b/window_scene/session/screen/include/screen_property.h @@ -119,6 +119,9 @@ public: void SetPhysicalRotation(float rotation); float GetPhysicalRotation() const; + void SetScreenComponentRotation(float rotation); + float GetScreenComponentRotation() const; + float GetXDpi() const; float GetYDpi() const; @@ -160,6 +163,7 @@ private: } float rotation_ { 0.0f }; float physicalRotation_ { 0.0f }; + float screenComponentRotation_ { 0.0f }; RRect bounds_; RRect phyBounds_; RRect fakeBounds_; diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index f0ef4aef3b..d328106002 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -251,6 +251,7 @@ public: MirrorScreenType GetMirrorScreenType(); Rotation ConvertIntToRotation(int rotation); void SetPhysicalRotation(int rotation, FoldStatus foldStatus); + void SetScreenComponentRotation(int rotation); void SetStartPosition(uint32_t startX, uint32_t startY); void SetMirrorScreenRegion(ScreenId screenId, DMRect screenRegion); std::pair GetMirrorScreenRegion(); diff --git a/window_scene/session/screen/src/screen_property.cpp b/window_scene/session/screen/src/screen_property.cpp index 3b25626bc4..62e427efdf 100644 --- a/window_scene/session/screen/src/screen_property.cpp +++ b/window_scene/session/screen/src/screen_property.cpp @@ -47,6 +47,16 @@ float ScreenProperty::GetPhysicalRotation() const return physicalRotation_; } +void ScreenProperty::SetScreenComponentRotation(float rotation) +{ + screenComponentRotation_ = rotation; +} + +float ScreenProperty::GetScreenComponentRotation() const +{ + return screenComponentRotation_; +} + void ScreenProperty::SetBounds(const RRect& bounds) { bounds_ = bounds; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 54c91d4c66..7efb562700 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -688,6 +688,12 @@ void ScreenSession::SetPhysicalRotation(int rotation, FoldStatus foldStatus) property_.GetPhysicalRotation(), rotation, offsetRotation); } +void ScreenSession::SetScreenComponentRotation(int rotation) +{ + property_.SetScreenComponentRotation(static_cast(rotation)); + WLOGFI("screenComponentRotation :%{public}f ", property_.GetScreenComponentRotation()); +} + void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode) { Rotation targetRotation = ConvertIntToRotation(rotation); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 4c33a8a5d6..7f3087a407 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -174,7 +174,7 @@ public: sptr GetSceneSession(int32_t persistentId); sptr GetMainParentSceneSession(int32_t persistentId, const std::map>& sessionMap); - void PostFlushWindowInfoTask(FlushWindowInfoTask &&task, const std::string taskName, const int delayTime); + void PostFlushWindowInfoTask(FlushWindowInfoTask&& task, const std::string& taskName, const int delayTime); sptr GetSceneSessionByIdentityInfo(const SessionIdentityInfo& info); sptr GetSceneSessionByType(WindowType type); @@ -352,7 +352,6 @@ public: void UpdateRecoveredSessionInfo(const std::vector& recoveredPersistentIds); void SetAlivePersistentIds(const std::vector& alivePersistentIds); void NotifyRecoveringFinished(); - WMError CheckWindowId(int32_t windowId, int32_t& pid) override; void GetSceneSessionPrivacyModeBundles(DisplayId displayId, std::unordered_set& privacyBundles); BrokerStates CheckIfReuseSession(SessionInfo& sessionInfo); @@ -388,7 +387,6 @@ public: WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; void DealwithVisibilityChange(const std::vector>& visibilityChangeInfos, const std::vector>& currVisibleData); - void DealwithDrawingContentChange(const std::vector>& drawingChangeInfos); void NotifyUpdateRectAfterLayout(); void FlushUIParams(ScreenId screenId, std::unordered_map&& uiParams); WSError UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener) override; @@ -404,6 +402,16 @@ public: int32_t StartUIAbilityBySCB(sptr& abilitySessionInfo); int32_t StartUIAbilityBySCB(sptr& sceneSessions); int32_t ChangeUIAbilityVisibilityBySCB(sptr& sceneSessions, bool visibility); + + /* + * UIExtension + */ + uint32_t GetLockScreenZorder(); + WMError CheckUIExtensionCreation(int32_t windowId, + uint32_t tokenId, + const AppExecFwk::ElementName& element, + int32_t& pid); + void OnNotifyAboveLockScreen(const std::vector& windowIds); void AddExtensionWindowStageToSCB(const sptr& sessionStage, const sptr& token, uint64_t surfaceNodeId) override; void RemoveExtensionWindowStageFromSCB(const sptr& sessionStage, @@ -430,6 +438,12 @@ public: int32_t GetCustomDecorHeight(int32_t persistentId); + /** + * Window Property + */ + WMError ReleaseForegroundSessionScreenLock() override; + void DealwithDrawingContentChange(const std::vector>& drawingContentChangeInfo); + /** * Free Multi Window */ @@ -491,11 +505,6 @@ public: std::string GetLastInstanceKey(const std::string& bundleName); void RefreshAppInfo(const std::string& bundleName); - /** - * Window Property - */ - WMError ReleaseForegroundSessionScreenLock() override; - /** * PiP Window */ @@ -674,8 +683,6 @@ private: const sptr& sceneSession); std::vector> GetWindowVisibilityChangeInfo( std::vector>& currVisibleData); - std::vector> GetWindowDrawingContentChangeInfo( - std::vector> currDrawingContentData); void GetWindowLayerChangeInfo(std::shared_ptr occlusionData, std::vector>& currVisibleData, std::vector>& currDrawingContentData); @@ -686,6 +693,17 @@ private: void RegisterSessionSnapshotFunc(const sptr& sceneSession); void ResetWantInfo(const sptr& sceneSession); + /** + * Window Property + */ + std::vector> GetWindowDrawingContentChangeInfo( + const std::vector>& currDrawingContentData); + bool GetPreWindowDrawingState(uint64_t surfaceId, bool currentWindowDrawing, int32_t& pid); + bool GetProcessDrawingState(uint64_t surfaceId, int32_t pid); + void UpdateWindowDrawingData(uint64_t surfaceId, int32_t pid, int32_t uid); + bool GetSpecifiedDrawingData(uint64_t surfaceId, int32_t& pid, int32_t& uid); + void RemoveSpecifiedDrawingData(uint64_t surfaceId); + /** * Window Rotate Animation */ @@ -921,8 +939,6 @@ private: sptr property, const WindowType& type); sptr CreateSceneSession(const SessionInfo& sessionInfo, sptr property); void CreateKeyboardPanelSession(sptr keyboardSession); - bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState); - bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); void ClearSpecificSessionRemoteObjectMap(int32_t persistentId); WSError DestroyAndDisconnectSpecificSessionInner(const int32_t persistentId); WSError GetAppMainSceneSession(sptr& sceneSession, int32_t persistentId); @@ -979,7 +995,7 @@ private: std::unordered_set snapshotSkipPidSet_ GUARDED_BY(SCENE_GUARD); // ONLY Accessed on OS_sceneSession thread std::unordered_set snapshotSkipBundleNameSet_ GUARDED_BY(SCENE_GUARD); - int32_t sessionMapDirty_ { 0 }; + uint32_t sessionMapDirty_ { 0 }; std::condition_variable nextFlushCompletedCV_; std::mutex nextFlushCompletedMutex_; RootSceneProcessBackEventFunc rootSceneProcessBackEventFunc_ = nullptr; @@ -1039,6 +1055,15 @@ private: }; std::unordered_map, SessionHasher> abilityInfoMap_; + /** + * Window Property + */ + struct DrawingSessionInfo { + int32_t pid_ = 0; + int32_t uid_ = 0; + }; + std::unordered_map lastDrawingSessionInfoMap_; + /** * PC Window */ diff --git a/window_scene/session_manager/include/scene_session_manager_lite.h b/window_scene/session_manager/include/scene_session_manager_lite.h index 86595e1d51..ebf5fb2183 100644 --- a/window_scene/session_manager/include/scene_session_manager_lite.h +++ b/window_scene/session_manager/include/scene_session_manager_lite.h @@ -58,6 +58,8 @@ public: WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; WMError CheckWindowId(int32_t windowId, int32_t& pid) override; + WMError CheckUIExtensionCreation( + int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) override; WMError GetVisibilityWindowInfo(std::vector>& infos) override; WSError UpdateWindowMode(int32_t persistentId, int32_t windowMode); WMError GetWindowModeType(WindowModeType& windowModeType) override; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h index 8993e5054b..3da4176936 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h @@ -81,6 +81,7 @@ public: TRANS_ID_GET_CURRENT_PIP_WINDOW_INFO, TRANS_ID_GET_MAIN_WINDOW_STATES_BY_PID, TRANS_ID_GET_ROOT_MAIN_WINDOW_ID, + TRANS_ID_UI_EXTENSION_CREATION_CHECK, }; virtual WSError SetSessionLabel(const sptr& token, const std::string& label) = 0; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h index 0b911bffe2..7530c72496 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h @@ -69,6 +69,8 @@ public: WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; WMError CheckWindowId(int32_t windowId, int32_t& pid) override; + WMError CheckUIExtensionCreation( + int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) override; WMError GetVisibilityWindowInfo(std::vector>& infos) override; WMError GetWindowModeType(WindowModeType& windowModeType) override; WMError GetMainWindowInfos(int32_t topNum, std::vector& topNInfo) override; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h index f0227efa40..4c50c17ebf 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h @@ -59,6 +59,7 @@ private: int HandleRegisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply); int HandleUnregisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply); int HandleCheckWindowId(MessageParcel& data, MessageParcel& reply); + int HandleCheckUIExtensionCreation(MessageParcel& data, MessageParcel& reply); int HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply); int HandleGetWindowModeType(MessageParcel& data, MessageParcel& reply); int HandleGetMainWinodowInfo(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session_manager/src/hidump_controller.cpp b/window_scene/session_manager/src/hidump_controller.cpp index acc919686a..5aedb4bda2 100644 --- a/window_scene/session_manager/src/hidump_controller.cpp +++ b/window_scene/session_manager/src/hidump_controller.cpp @@ -101,7 +101,8 @@ void HidumpController::DumpSessionParamList(std::ostringstream& oss) << std::endl << "callingPid callingUid isSystem reuse lockedState time type isSystemCalling topmost" << std::endl - << "isPrivacyMode isSystemPrivacyMode parentId flag parentPersistentId mode state modeSupportInfo animationFlag" + << "isPrivacyMode isSystemPrivacyMode parentId flag parentPersistentId mode " + << "state windowModeSupportType animationFlag" << std::endl << "isFloatingAppType isNonSystemFloating forceHide isNeedUpdateMode " << "meedDefaultAnimationFlag shouldHideNonSecure forceHideState" @@ -130,7 +131,7 @@ void HidumpController::DumpSessionParam( << property->GetParentPersistentId() << "|" << static_cast(property->GetWindowMode()) << "|" << static_cast(property->GetWindowState()) << "|" - << property->GetModeSupportInfo() << "|" + << property->GetWindowModeSupportType() << "|" << property->GetAnimationFlag() << "|" << std::endl << property->IsFloatingWindowAppType() << "|" @@ -343,7 +344,7 @@ void HidumpController::DumpSysconfigParamList(std::ostringstream& oss) { oss << "Sysconfig:" << std::endl - << "isSystemDecorEnable decorModeSupportInfo isStretchable defaultWindowMode " + << "isSystemDecorEnable decorWindowModeSupportType isStretchable defaultWindowMode " << "keyboardAnimationConfig maxFloatingWindowSize windowUIType" << std::endl << "miniWidthOfMainWindow miniHeightOfMainWindow miniWidthOfSubWindow miniHeightOfSubWindow backgroundswitch " @@ -358,7 +359,7 @@ void HidumpController::DumpSysconfigParam(std::ostringstream& oss, sptr(systemConfig.defaultWindowMode_) << "|" << "[" << systemConfig.animationIn_.curveType_ << " " @@ -377,7 +378,7 @@ void HidumpController::DumpSysconfigParam(std::ostringstream& oss, sptr(freeMultiWindowConfig.defaultWindowMode_) << " " << freeMultiWindowConfig.maxMainFloatingWindowNumber_<< "]|" << std::endl; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 560655b29e..4fac373de4 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -183,6 +183,46 @@ bool GetEnableRemoveStartingWindowFromBMS(const std::shared_ptr> whitelist = { + std::make_tuple("com.huawei.hmos.settings", "AccessibilityReConfirmDialog", "phone_settings"), + std::make_tuple("com.huawei.hmos.settings", "AccessibilityShortKeyDialog", "phone_settings"), + std::make_tuple("com.huawei.hmos.settings", "DefaultIntentUiExtensionAbility", "phone_settings"), + std::make_tuple("com.ohos.sceneboard", "ScbIntentUIExtensionAbility", "phone_sceneboard"), + std::make_tuple("com.huawei.hmos.motiongesture", "IntentUIExtensionAbility", "entry"), + }; + + auto itr = std::find_if(whitelist.begin(), whitelist.end(), [element](const auto &item) { + auto [bundleName, abilityName, moduleName] = item; + if (element.GetBundleName() != bundleName) { + return false; + } + if (element.GetAbilityName() != abilityName) { + return false; + } + return true; + }); + + if (itr != whitelist.end()) { + return true; + } + + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not in white list"); + if (SessionPermission::VerifyPermissionByCallerToken( + callingTokenId, PermissionConstants::PERMISSION_CALLED_EXTENSION_ON_LOCK_SCREEN)) { + return true; + } + + return false; +} + class BundleStatusCallback : public IRemoteStub { public: BundleStatusCallback() = default; @@ -400,7 +440,7 @@ void SceneSessionManager::InitPrepareTerminateConfig() char value[PREPARE_TERMINATE_ENABLE_SIZE] = "false"; int32_t retSysParam = GetParameter(PREPARE_TERMINATE_ENABLE_PARAMETER, "false", value, PREPARE_TERMINATE_ENABLE_SIZE); - WLOGFI("InitPrepareTerminateConfig, %{public}s value is %{public}s.", PREPARE_TERMINATE_ENABLE_PARAMETER, value); + WLOGFI("%{public}s value is %{public}s.", PREPARE_TERMINATE_ENABLE_PARAMETER, value); if (retSysParam > 0 && !std::strcmp(value, "true")) { isPrepareTerminateEnable_ = true; } @@ -421,7 +461,7 @@ void SceneSessionManager::ConfigWindowSceneXml() item = config["backgroundswitch"]; int32_t param = -1; systemConfig_.backgroundswitch = GetSingleIntItem(item, param) && param == 1; - WLOGFD("Load ConfigWindowSceneXml backgroundswitch%{public}d", systemConfig_.backgroundswitch); + WLOGFD("Load backgroundswitch %{public}d", systemConfig_.backgroundswitch); item = config["defaultWindowMode"]; if (GetSingleIntItem(item, param) && (param == static_cast(WindowMode::WINDOW_MODE_FULLSCREEN) || @@ -557,7 +597,7 @@ void SceneSessionManager::LoadFreeMultiWindowConfig(bool enable) FreeMultiWindowConfig freeMultiWindowConfig = systemConfig_.freeMultiWindowConfig_; if (enable) { systemConfig_.defaultWindowMode_ = freeMultiWindowConfig.defaultWindowMode_; - systemConfig_.decorModeSupportInfo_ = freeMultiWindowConfig.decorModeSupportInfo_; + systemConfig_.decorWindowModeSupportType_ = freeMultiWindowConfig.decorWindowModeSupportType_; systemConfig_.isSystemDecorEnable_ = freeMultiWindowConfig.isSystemDecorEnable_; } else { const auto& config = WindowSceneConfig::GetConfig(); @@ -612,7 +652,7 @@ WSError SceneSessionManager::GetFreeMultiWindowEnableState(bool& enable) WSError SceneSessionManager::SetSessionContinueState(const sptr& token, const ContinueState& continueState) { - TLOGI(WmsLogTag::DEFAULT, "Enter"); + TLOGI(WmsLogTag::DEFAULT, "in"); int32_t callingUid = IPCSkeleton::GetCallingUid(); auto task = [this, token, continueState, callingUid]() { sptr sceneSession = FindSessionByToken(token); @@ -663,10 +703,10 @@ void SceneSessionManager::ConfigDecor(const WindowSceneConfig::ConfigItem& decor } } if (mainConfig && item.IsStrings()) { - systemConfig_.decorModeSupportInfo_ = support; + systemConfig_.decorWindowModeSupportType_ = support; } if (!mainConfig && item.IsStrings()) { - systemConfig_.freeMultiWindowConfig_.decorModeSupportInfo_ = support; + systemConfig_.freeMultiWindowConfig_.decorWindowModeSupportType_ = support; } } } @@ -724,7 +764,7 @@ void SceneSessionManager::ConfigWindowEffect(const WindowSceneConfig::ConfigItem AddAlphaToColor(appWindowSceneConfig_.focusedShadow_.alpha_, appWindowSceneConfig_.focusedShadow_.color_); AddAlphaToColor(appWindowSceneConfig_.unfocusedShadow_.alpha_, appWindowSceneConfig_.unfocusedShadow_.color_); - WLOGFI("Config window effect successfully"); + WLOGFI("successfully"); } bool SceneSessionManager::ConfigAppWindowCornerRadius(const WindowSceneConfig::ConfigItem& item, float& out) @@ -782,7 +822,7 @@ void SceneSessionManager::ClearUnrecoveredSessions(const std::vector& r void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector& recoveredPersistentIds) { - TLOGI(WmsLogTag::WMS_RECOVER, "Number of persistentIds recovered = %{public}zu. CurrentUserId = %{public}d", + TLOGI(WmsLogTag::WMS_RECOVER, "persistentIds recovered = %{public}zu. CurrentUserId = %{public}d", recoveredPersistentIds.size(), currentUserId_); auto task = [this, recoveredPersistentIds]() { @@ -828,7 +868,7 @@ void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector& } RemoveFailRecoveredSession(); }; - return taskScheduler_->PostAsyncTask(task, "UpdateSessionInfoBySCB"); + taskScheduler_->PostAsyncTask(task, __func__); } bool SceneSessionManager::ConfigAppWindowShadow(const WindowSceneConfig::ConfigItem& shadowConfig, @@ -1137,12 +1177,12 @@ void SceneSessionManager::ConfigSnapshotScale() void SceneSessionManager::ConfigSystemUIStatusBar(const WindowSceneConfig::ConfigItem& statusBarConfig) { - TLOGI(WmsLogTag::WMS_IMMS, "load ConfigSystemUIStatusBar"); + TLOGI(WmsLogTag::WMS_IMMS, "load"); WindowSceneConfig::ConfigItem item = statusBarConfig["showInLandscapeMode"]; if (item.IsInts() && item.intsValue_->size() == 1) { bool showInLandscapeMode = (*item.intsValue_)[0] > 0; appWindowSceneConfig_.systemUIStatusBarConfig_.showInLandscapeMode_ = showInLandscapeMode; - TLOGI(WmsLogTag::WMS_IMMS, "ConfigSystemUIStatusBar showInLandscapeMode:%{public}d", + TLOGI(WmsLogTag::WMS_IMMS, "showInLandscapeMode:%{public}d", appWindowSceneConfig_.systemUIStatusBarConfig_.showInLandscapeMode_); } @@ -1154,7 +1194,7 @@ void SceneSessionManager::ConfigSystemUIStatusBar(const WindowSceneConfig::Confi return; } appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarBgColor_ = color; - TLOGI(WmsLogTag::WMS_IMMS, "ConfigSystemUIStatusBar immersiveStatusBarBgColor:%{public}s", + TLOGI(WmsLogTag::WMS_IMMS, "immersiveStatusBarBgColor:%{public}s", appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarBgColor_.c_str()); } @@ -1166,7 +1206,7 @@ void SceneSessionManager::ConfigSystemUIStatusBar(const WindowSceneConfig::Confi return; } appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarContentColor_ = color; - TLOGI(WmsLogTag::WMS_IMMS, "ConfigSystemUIStatusBar immersiveStatusBarContentColor:%{public}s", + TLOGI(WmsLogTag::WMS_IMMS, "immersiveStatusBarContentColor:%{public}s", appWindowSceneConfig_.systemUIStatusBarConfig_.immersiveStatusBarContentColor_.c_str()); } } @@ -1201,11 +1241,10 @@ sptr SceneSessionManager::GetRootSceneSession() AvoidArea SceneSessionManager::GetRootSessionAvoidAreaByType(AvoidAreaType type) { - sptr rootSession = GetRootSceneSession(); - if (rootSession == nullptr) { - return {}; + if (auto rootSession = GetRootSceneSession()) { + return rootSession->GetAvoidAreaByType(type); } - return rootSession->GetAvoidAreaByType(type); + return {}; } sptr SceneSessionManager::GetSceneSession(int32_t persistentId) @@ -1213,7 +1252,7 @@ sptr SceneSessionManager::GetSceneSession(int32_t persistentId) std::shared_lock lock(sceneSessionMapMutex_); auto iter = sceneSessionMap_.find(persistentId); if (iter == sceneSessionMap_.end()) { - WLOGFD("Error found scene session with id: %{public}d", persistentId); + WLOGFD("Not found scene session with id: %{public}d", persistentId); return nullptr; } return iter->second; @@ -1222,8 +1261,7 @@ sptr SceneSessionManager::GetSceneSession(int32_t persistentId) sptr SceneSessionManager::GetSceneSessionByIdentityInfo(const SessionIdentityInfo& info) { std::shared_lock lock(sceneSessionMapMutex_); - for (const auto &item : sceneSessionMap_) { - auto sceneSession = item.second; + for (const auto& [_, sceneSession] : sceneSessionMap_) { if (!sceneSession) { return nullptr; } @@ -1267,8 +1305,7 @@ std::vector> SceneSessionManager::GetSceneSessionVectorByType } std::vector> sceneSessionVector; std::shared_lock lock(sceneSessionMapMutex_); - for (const auto &item : sceneSessionMap_) { - auto sceneSession = item.second; + for (const auto& [_, sceneSession] : sceneSessionMap_) { if (sceneSession->GetWindowType() == type && sceneSession->GetSessionProperty() && sceneSession->GetSessionProperty()->GetDisplayId() == displayId) { @@ -1404,7 +1441,7 @@ sptr SceneSessionManager::CreateKeyboa WMError SceneSessionManager::CheckWindowId(int32_t windowId, int32_t& pid) { if (!SessionPermission::IsSystemCalling()) { - TLOGE(WmsLogTag::WMS_EVENT, "CheckWindowId permission denied!"); + TLOGE(WmsLogTag::WMS_EVENT, "permission denied!"); return WMError::WM_ERROR_NOT_SYSTEM_APP; } @@ -1422,6 +1459,71 @@ WMError SceneSessionManager::CheckWindowId(int32_t windowId, int32_t& pid) return taskScheduler_->PostSyncTask(task, "CheckWindowId:" + std::to_string(windowId)); } +uint32_t SceneSessionManager::GetLockScreenZorder() +{ + std::shared_lock lock(sceneSessionMapMutex_); + for (auto &[sessionId, session] : sceneSessionMap_) { + if (session->GetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD) { + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: found window %{public}d: ", sessionId); + return session->GetZOrder(); + } + } + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not found"); + return 0; +} + +WMError SceneSessionManager::CheckUIExtensionCreation( + int32_t windowId, uint32_t callingTokenId, const AppExecFwk::ElementName &element, int32_t &pid) +{ + auto task = [this, windowId, &pid, &callingTokenId, element]() -> WMError { + pid = INVALID_PID; + auto sceneSession = GetSceneSession(windowId); + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: sceneSession(%{public}d) is nullptr", windowId); + return WMError::WM_ERROR_INVALID_WINDOW; + } + pid = sceneSession->GetCallingPid(); + + // 1. check window whether can show on main window + if (!sceneSession->IsShowOnLockScreen(GetLockScreenZorder())) { + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not called on lock screen"); + return WMError::WM_OK; + } + + // 2. check permission + if (!IsUIExtCanShowOnLockScreen(element, callingTokenId)) { + TLOGE(WmsLogTag::WMS_UIEXT, + "UIExtOnLock: no permisson, window id %{public}d, %{public}d", + windowId, + callingTokenId); + return WMError::WM_ERROR_INVALID_PERMISSION; + } + + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: IsShowOnLockScreen: The caller permission has granted"); + return WMError::WM_OK; + }; + + std::stringstream ss; + ss << "UIExtOnLockCheck" + << "_" << windowId << "_" << callingTokenId; + return taskScheduler_->PostSyncTask(task, ss.str()); +} + +// windowIds are all main window +void SceneSessionManager::OnNotifyAboveLockScreen(const std::vector &windowIds) +{ + // check every window + for (auto windowId : windowIds) { + auto sceneSession = GetSceneSession(windowId); + if (!sceneSession) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: sesssion is null for %{public}d", windowId); + continue; + } + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: check for %{public}d", windowId); + sceneSession->OnNotifyAboveLockScreen(); + } +} + void SceneSessionManager::CreateKeyboardPanelSession(sptr keyboardSession) { if (!isKeyboardPanelEnabled_) { @@ -1554,9 +1656,9 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s const char* const where = __func__; auto task = [this, sessionInfo, property, where] { - TLOGI(WmsLogTag::WMS_LIFE, "RequestSceneSession, appName: [%{public}s %{public}s %{public}s]" + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s: appName: [%{public}s %{public}s %{public}s] " "appIndex %{public}d, type %{public}u system %{public}u, isPersistentRecover %{public}u", - sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), + where, sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), sessionInfo.abilityName_.c_str(), sessionInfo.appIndex_, sessionInfo.windowType_, static_cast(sessionInfo.isSystem_), static_cast(sessionInfo.isPersistentRecover_)); sptr sceneSession = CreateSceneSession(sessionInfo, property); @@ -1598,8 +1700,9 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s } PerformRegisterInRequestSceneSession(sceneSession); NotifySessionUpdate(sessionInfo, ActionType::SINGLE_START); - TLOGI(WmsLogTag::WMS_LIFE, "RequestSceneSession id: %{public}d, type: %{public}d", - sceneSession->GetPersistentId(), sceneSession->GetWindowType()); + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s: id: %{public}d, type: %{public}d, instanceKey: %{public}s", + where, sceneSession->GetPersistentId(), sceneSession->GetWindowType(), + sceneSession->GetAppInstanceKey().c_str()); return sceneSession; }; return taskScheduler_->PostSyncTask(task, "RequestSceneSession:PID" + std::to_string(sessionInfo.persistentId_)); @@ -1698,7 +1801,7 @@ void SceneSessionManager::UpdateSceneSessionWant(const SessionInfo& sessionInfo) UpdateCollaboratorSessionWant(session, sessionInfo.persistentId_); } } else { - TLOGI(WmsLogTag::WMS_MAIN, "Got session fail(%{public}d), id:%{public}d", + TLOGI(WmsLogTag::WMS_MAIN, "Get session fail(%{public}d), id:%{public}d", session == nullptr, sessionInfo.persistentId_); } } else { @@ -1708,12 +1811,10 @@ void SceneSessionManager::UpdateSceneSessionWant(const SessionInfo& sessionInfo) void SceneSessionManager::UpdateCollaboratorSessionWant(sptr& session, int32_t persistentId) { - if (session != nullptr) { - if (session->GetSessionInfo().ancoSceneState < AncoSceneState::NOTIFY_CREATE) { - FillSessionInfo(session); - if (CheckCollaboratorType(session->GetCollaboratorType())) { - PreHandleCollaborator(session, persistentId); - } + if (session != nullptr && session->GetSessionInfo().ancoSceneState < AncoSceneState::NOTIFY_CREATE) { + FillSessionInfo(session); + if (CheckCollaboratorType(session->GetCollaboratorType())) { + PreHandleCollaborator(session, persistentId); } } } @@ -1791,7 +1892,7 @@ WSError SceneSessionManager::PrepareTerminate(int32_t persistentId, bool& isPrep } auto errorCode = AAFwk::AbilityManagerClient::GetInstance()-> PrepareTerminateAbilityBySCB(sceneSessionInfo, isPrepareTerminate); - TLOGI(WmsLogTag::WMS_MAIN, "PrepareTerminateAbilityBySCB Id:%{public}d isPrepareTerminate:%{public}d " + TLOGNI(WmsLogTag::WMS_MAIN, "PrepareTerminateAbilityBySCB Id:%{public}d isPrepareTerminate:%{public}d " "errorCode:%{public}d", persistentId, isPrepareTerminate, errorCode); return WSError::WS_OK; }; @@ -1805,7 +1906,7 @@ WSError SceneSessionManager::RequestSceneSessionActivation(const sptr sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { - TLOGE(WmsLogTag::WMS_MAIN, "Request active session is nullptr"); + TLOGNE(WmsLogTag::WMS_MAIN, "Request active session is nullptr"); return WSError::WS_ERROR_NULLPTR; } auto persistentId = sceneSession->GetPersistentId(); @@ -1813,7 +1914,7 @@ WSError SceneSessionManager::RequestSceneSessionActivation(const sptrSetForegroundInteractiveStatus(true); } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:RequestSceneSessionActivation(%d )", persistentId); - TLOGI(WmsLogTag::WMS_MAIN, "Request active id:%{public}d system:%{public}u isNewActive:%{public}d", + TLOGNI(WmsLogTag::WMS_MAIN, "Request active id:%{public}d system:%{public}u isNewActive:%{public}d", persistentId, static_cast(sceneSession->GetSessionInfo().isSystem_), isNewActive); if (!GetSceneSession(persistentId)) { TLOGE(WmsLogTag::WMS_MAIN, "Request active session invalid by %{public}d", persistentId); @@ -2018,11 +2119,11 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrGetPersistentId(); - TLOGI(WmsLogTag::WMS_MAIN, "Request background id:%{public}d isDelegator:%{public}d " + TLOGNI(WmsLogTag::WMS_MAIN, "Request background id:%{public}d isDelegator:%{public}d " "isToDesktop:%{public}d isSaveSnapshot:%{public}d", persistentId, isDelegator, isToDesktop, isSaveSnapshot); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:RequestSceneSessionBackground (%d )", persistentId); @@ -2037,7 +2138,7 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrBackgroundTask(isSaveSnapshot); if (!GetSceneSession(persistentId)) { - TLOGE(WmsLogTag::WMS_MAIN, "Request background session invalid by %{public}d", persistentId); + TLOGNE(WmsLogTag::WMS_MAIN, "Request background session invalid by %{public}d", persistentId); return WSError::WS_ERROR_INVALID_SESSION; } if (persistentId == brightnessSessionId_) { @@ -2045,14 +2146,14 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrNotifySessionBackground(1, true, true); } else { - TLOGI(WmsLogTag::WMS_MAIN, "begin MinimzeUIAbility: %{public}d system: %{public}u", + TLOGNI(WmsLogTag::WMS_MAIN, "begin MinimzeUIAbility: %{public}d system: %{public}u", persistentId, static_cast(sceneSession->GetSessionInfo().isSystem_)); if (!isDelegator) { AAFwk::AbilityManagerClient::GetInstance()->MinimizeUIAbilityBySCB(sceneSessionInfo); @@ -2075,15 +2176,14 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptr& sceneSession, bool interactive) { - wptr weakSceneSession(sceneSession); - auto task = [this, weakSceneSession, interactive]() { + auto task = [this, weakSceneSession = wptr(sceneSession), interactive]() { auto sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { WLOGFE("session is nullptr"); return; } auto persistentId = sceneSession->GetPersistentId(); - WLOGFI("NotifyForeInteractive id: %{public}d, status: %{public}d", persistentId, interactive); + WLOGI("NotifyForeInteractive id: %{public}d, status: %{public}d", persistentId, interactive); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:NotifyForegroundInteractiveStatus (%d )", persistentId); if (!GetSceneSession(persistentId)) { WLOGFE("session is invalid with %{public}d", persistentId); @@ -2210,14 +2310,13 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrGetPersistentId(); - TLOGI(WmsLogTag::WMS_MAIN, "Destruct session id:%{public}d unfocus", persistentId); + TLOGNI(WmsLogTag::WMS_MAIN, "Destruct session id:%{public}d remove:%{public}d isSaveSnapshot:%{public}d " + "isForceClean:%{public}d", persistentId, needRemoveSession, isSaveSnapshot, isForceClean); RequestSessionUnfocus(persistentId, FocusChangeReason::SCB_SESSION_REQUEST_UNFOCUS); lastUpdatedAvoidArea_.erase(persistentId); DestroyDialogWithMainWindow(sceneSession); DestroyToastSession(sceneSession); DestroySubSession(sceneSession); // destroy sub session by destruction - TLOGI(WmsLogTag::WMS_MAIN, "Destruct session id:%{public}d remove:%{public}d isSaveSnapshot:%{public}d" - " isForceClean:%{public}d", persistentId, needRemoveSession, isSaveSnapshot, isForceClean); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:RequestSceneSessionDestruction (%" PRIu32" )", persistentId); if (WindowHelper::IsMainWindow(sceneSession->GetWindowType())) { auto sessionInfo = sceneSession->GetSessionInfo(); @@ -2227,7 +2326,7 @@ WSError SceneSessionManager::RequestSceneSessionDestruction(const sptrGetSessionInfo(), ActionType::SINGLE_CLOSE); sceneSession->DisconnectTask(false, isSaveSnapshot); if (!GetSceneSession(persistentId)) { - TLOGE(WmsLogTag::WMS_MAIN, "Destruct session invalid by %{public}d", persistentId); + TLOGNE(WmsLogTag::WMS_MAIN, "Destruct session invalid by %{public}d", persistentId); return WSError::WS_ERROR_INVALID_SESSION; } auto sceneSessionInfo = SetAbilitySessionInfo(sceneSession); @@ -2319,7 +2418,7 @@ void SceneSessionManager::AddClientDeathRecipient(const sptr& ses TLOGE(WmsLogTag::WMS_LIFE, "failed to add death recipient"); return; } - WLOGFD("Id: %{public}d", sceneSession->GetPersistentId()); + TLOGD(WmsLogTag::WMS_LIFE, "Id: %{public}d", sceneSession->GetPersistentId()); } void SceneSessionManager::DestroySpecificSession(const sptr& remoteObject) @@ -2370,7 +2469,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW && property->GetIsUIExtFirstSubWindow()) { + if (property->GetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW) { WSError err = CheckSubSessionStartedByExtensionAndSetDisplayId(token, property, sessionStage); if (err != WSError::WS_OK) { return err; @@ -2424,7 +2523,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetPersistentId(), newSession->GetParentPersistentId(), type); return errCode; @@ -2438,26 +2537,52 @@ WSError SceneSessionManager::CheckSubSessionStartedByExtensionAndSetDisplayId(co { sptr extensionParentSession = GetSceneSession(property->GetParentPersistentId()); if (extensionParentSession == nullptr) { - WLOGFE("extensionParentSession is invalid with %{public}d", property->GetParentPersistentId()); + TLOGE(WmsLogTag::WMS_UIEXT, "extensionParentSession is invalid with %{public}d", + property->GetParentPersistentId()); return WSError::WS_ERROR_NULLPTR; } + auto pid = IPCSkeleton::GetCallingRealPid(); + auto parentPid = extensionParentSession->GetCallingPid(); + WSError result = WSError::WS_ERROR_INVALID_WINDOW; + if (pid == parentPid) { + TLOGI(WmsLogTag::WMS_UIEXT, "pid == parentPid"); + result = WSError::WS_OK; + } + AAFwk::UIExtensionSessionInfo info; + AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionSessionInfo(token, info); + if (info.persistentId != INVALID_SESSION_ID && info.hostWindowId != INVALID_SESSION_ID) { + int32_t parentId = static_cast(info.hostWindowId); + if (parentId == property->GetParentPersistentId()) { + TLOGI(WmsLogTag::WMS_UIEXT, "parentId == property->GetParentPersistentId(parentId:%{public}d)", parentId); + result = WSError::WS_OK; + } + } + if (SessionPermission::IsSystemCalling()) { + TLOGI(WmsLogTag::WMS_UIEXT, "is system app"); + result = WSError::WS_OK; + } if (property->GetIsUIExtensionAbilityProcess() && SessionPermission::IsStartedByUIExtension()) { SessionInfo sessionInfo = extensionParentSession->GetSessionInfo(); AAFwk::UIExtensionHostInfo hostInfo; AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionRootHostInfo(token, hostInfo); if (sessionInfo.bundleName_ != hostInfo.elementName_.GetBundleName()) { - WLOGE("The hostWindow is not this parentwindow ! parentwindow bundleName: %{public}s, " - "hostwindow bundleName: %{public}s", sessionInfo.bundleName_.c_str(), + TLOGE(WmsLogTag::WMS_UIEXT, "The hostWindow is not this parentwindow ! parentwindow bundleName: %{public}s," + " hostwindow bundleName: %{public}s", sessionInfo.bundleName_.c_str(), hostInfo.elementName_.GetBundleName().c_str()); return WSError::WS_ERROR_INVALID_WINDOW; } + result = WSError::WS_OK; } - sptr parentProperty = extensionParentSession->GetSessionProperty(); - if (sessionStage && parentProperty) { - sessionStage->UpdateDisplayId(parentProperty->GetDisplayId()); - property->SetDisplayId(parentProperty->GetDisplayId()); + if (result == WSError::WS_OK) { + sptr parentProperty = extensionParentSession->GetSessionProperty(); + if (sessionStage && parentProperty && property->GetIsUIExtFirstSubWindow()) { + sessionStage->UpdateDisplayId(parentProperty->GetDisplayId()); + property->SetDisplayId(parentProperty->GetDisplayId()); + } + } else { + TLOGE(WmsLogTag::WMS_UIEXT, "can't create sub window: persistentId %{public}d", property->GetPersistentId()); } - return WSError::WS_OK; + return result; } void SceneSessionManager::ClosePipWindowIfExist(WindowType type) @@ -2478,8 +2603,7 @@ void SceneSessionManager::ClosePipWindowIfExist(WindowType type) bool SceneSessionManager::CheckPiPPriority(const PiPTemplateInfo& pipTemplateInfo) { std::shared_lock lock(sceneSessionMapMutex_); - for (const auto& iter: sceneSessionMap_) { - auto& session = iter.second; + for (const auto& [_, session] : sceneSessionMap_) { if (session && session->GetWindowMode() == WindowMode::WINDOW_MODE_PIP && pipTemplateInfo.priority < session->GetPiPTemplateInfo().priority && session->IsSessionForeground()) { @@ -2588,7 +2712,7 @@ bool SceneSessionManager::CheckSystemWindowPermission(const sptr& alivePersistentIds) { - TLOGI(WmsLogTag::WMS_RECOVER, "Number of persistentIds need to be recovered = %{public}zu. CurrentUserId = " - "%{public}d", alivePersistentIds.size(), currentUserId_); + TLOGI(WmsLogTag::WMS_RECOVER, "PersistentIds need to be recovered=%{public}zu, CurrentUserId=%{public}d", + alivePersistentIds.size(), currentUserId_); alivePersistentIds_ = alivePersistentIds; } @@ -2678,7 +2802,7 @@ WSError SceneSessionManager::RecoverAndConnectSpecificSession(const sptrGetCallingSessionId()); + TLOGNI(WmsLogTag::WMS_RECOVER, "callingWindowId = %{public}" PRIu32, property->GetCallingSessionId()); ClosePipWindowIfExist(property->GetWindowType()); sptr sceneSession = RequestSceneSession(info, property); if (sceneSession == nullptr) { @@ -2715,10 +2839,10 @@ WSError SceneSessionManager::RecoverAndConnectSpecificSession(const sptrPostAsyncTask([this]() { - TLOGI(WmsLogTag::WMS_RECOVER, "RecoverFinished clear recoverSubSessionCacheMap"); - recoveringFinished_ = true; - recoverSubSessionCacheMap_.clear(); - }, "NotifyRecoveringFinished"); + TLOGNI(WmsLogTag::WMS_RECOVER, "RecoverFinished clear recoverSubSessionCacheMap"); + recoveringFinished_ = true; + recoverSubSessionCacheMap_.clear(); + }, "NotifyRecoveringFinished"); } void SceneSessionManager::CacheSubSessionForRecovering( @@ -2851,7 +2975,7 @@ void SceneSessionManager::SetStartPiPFailedListener(NotifyStartPiPFailedFunc&& f void SceneSessionManager::RegisterCreateSubSessionListener(int32_t persistentId, const NotifyCreateSubSessionFunc& func) { - TLOGI(WmsLogTag::WMS_SUB, "RegisterCreateSubSessionListener, id: %{public}d", persistentId); + TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", persistentId); auto task = [this, persistentId, func]() { createSubSessionFuncMap_[persistentId] = func; RecoverCachedSubSession(persistentId); @@ -2936,7 +3060,7 @@ void SceneSessionManager::NotifyCreateSubSession(int32_t persistentId, sptrsecond) { iter->second(session); } - TLOGD(WmsLogTag::WMS_LIFE, "NotifyCreateSubSession success, parentId: %{public}d, subId: %{public}d", + TLOGD(WmsLogTag::WMS_LIFE, "Notify success, parentId: %{public}d, subId: %{public}d", persistentId, session->GetPersistentId()); } @@ -2981,13 +3105,13 @@ void SceneSessionManager::NotifyCreateToastSession(int32_t persistentId, sptrAddToastSession(session); session->SetParentSession(parentSession); - TLOGD(WmsLogTag::WMS_LIFE, "NotifyCreateToastSession success, parentId: %{public}d, toastId: %{public}d", + TLOGD(WmsLogTag::WMS_LIFE, "Notify success, parentId: %{public}d, toastId: %{public}d", persistentId, session->GetPersistentId()); } void SceneSessionManager::UnregisterCreateSubSessionListener(int32_t persistentId) { - TLOGI(WmsLogTag::WMS_SUB, "UnregisterCreateSubSessionListener, id: %{public}d", persistentId); + TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", persistentId); auto task = [this, persistentId]() { auto iter = createSubSessionFuncMap_.find(persistentId); if (iter != createSubSessionFuncMap_.end()) { @@ -3002,7 +3126,7 @@ void SceneSessionManager::UnregisterCreateSubSessionListener(int32_t persistentI void SceneSessionManager::SetStatusBarEnabledChangeListener(const ProcessStatusBarEnabledChangeFunc& func) { - WLOGFD("SetStatusBarEnabledChangeListener"); + WLOGFD("in"); if (!func) { WLOGFD("set func is null"); } @@ -3012,7 +3136,7 @@ void SceneSessionManager::SetStatusBarEnabledChangeListener(const ProcessStatusB void SceneSessionManager::SetGestureNavigationEnabledChangeListener( const ProcessGestureNavigationEnabledChangeFunc& func) { - WLOGFD("SetGestureNavigationEnabledChangeListener"); + WLOGFD("in"); if (!func) { WLOGFD("set func is null"); } @@ -3038,14 +3162,13 @@ void SceneSessionManager::NotifySessionTouchOutside(int32_t persistentId) persistentId, callingSessionId); } std::shared_lock lock(sceneSessionMapMutex_); - for (const auto &item : sceneSessionMap_) { - sceneSession = item.second; + for (const auto& [_, sceneSession] : sceneSessionMap_) { if (sceneSession == nullptr) { continue; } if (!(sceneSession->IsVisible() || - sceneSession->GetSessionState() == SessionState::STATE_FOREGROUND || - sceneSession->GetSessionState() == SessionState::STATE_ACTIVE)) { + sceneSession->GetSessionState() == SessionState::STATE_FOREGROUND || + sceneSession->GetSessionState() == SessionState::STATE_ACTIVE)) { continue; } auto sessionId = sceneSession->GetPersistentId(); @@ -3068,7 +3191,7 @@ void SceneSessionManager::NotifySessionTouchOutside(int32_t persistentId) void SceneSessionManager::SetOutsideDownEventListener(const ProcessOutsideDownEventFunc& func) { - WLOGFD("SetOutsideDownEventListener"); + WLOGFD("in"); outsideDownEventFunc_ = func; } @@ -3190,7 +3313,7 @@ WSError SceneSessionManager::DestroyAndDisconnectSpecificSessionWithDetachCallba void SceneSessionManager::DestroyUIServiceExtensionSubWindow(const sptr& sceneSession) { if (!sceneSession) { - TLOGE(WmsLogTag::WMS_SUB,"sceneSession is null"); + TLOGE(WmsLogTag::WMS_SUB, "sceneSession is null"); return; } auto sessionProperty = sceneSession->GetSessionProperty(); @@ -3256,7 +3379,7 @@ WSError SceneSessionManager::InitUserInfo(int32_t userId, std::string& fileDir) TLOGE(WmsLogTag::WMS_MAIN, "params invalid"); return WSError::WS_DO_NOTHING; } - TLOGI(WmsLogTag::WMS_MAIN, "userId : %{public}d, path : %{public}s", userId, fileDir.c_str()); + TLOGI(WmsLogTag::WMS_MAIN, "userId: %{public}d, path: %{public}s", userId, fileDir.c_str()); auto task = [this, userId, &fileDir]() { if (!ScenePersistence::CreateSnapshotDir(fileDir)) { TLOGD(WmsLogTag::WMS_MAIN, "Create snapshot directory failed"); @@ -3535,8 +3658,7 @@ void SceneSessionManager::OnBundleUpdated(const std::string& bundleName, int use if (iter != startingWindowMap_.end()) { startingWindowMap_.erase(iter); } - }, - "OnBundleUpdated"); + }, "OnBundleUpdated"); } void SceneSessionManager::OnConfigurationUpdated(const std::shared_ptr& configuration) @@ -3544,8 +3666,7 @@ void SceneSessionManager::OnConfigurationUpdated(const std::shared_ptrPostAsyncTask([this]() { std::unique_lock lock(startingWindowMapMutex_); startingWindowMap_.clear(); - }, - "OnConfigurationUpdated"); + }, "OnConfigurationUpdated"); } void SceneSessionManager::FillSessionInfo(sptr& sceneSession) @@ -3864,7 +3985,7 @@ 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]", + 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"); @@ -3938,7 +4059,7 @@ void SceneSessionManager::PostBrightnessTask(float brightness) SetDisplayBrightness(brightness); } if (!postTaskRet) { - TLOGI(WmsLogTag::DEFAULT, "Report post listener callback task failed. the task name is SetBrightness"); + TLOGE(WmsLogTag::DEFAULT, "post task failed. task is SetBrightness"); } } @@ -4079,35 +4200,33 @@ static bool IsValidDigitString(const std::string& windowIdStr) void SceneSessionManager::RegisterSessionExceptionFunc(const sptr& sceneSession) { if (sceneSession == nullptr) { - WLOGFE("session is nullptr"); + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr"); return; } - NotifySessionExceptionFunc sessionExceptionFunc = [this]( + const char* const where = __func__; + sceneSession->SetSessionExceptionListener([this, where]( const SessionInfo& info, bool needRemoveSession, bool startFail) { - auto task = [this, info] { + auto task = [this, info, where] { auto session = GetSceneSession(info.persistentId_); if (session == nullptr) { - WLOGW("NotifySessionExceptionFunc, Not found session, id: %{public}d", - info.persistentId_); + TLOGNW(WmsLogTag::WMS_LIFE, "%{public}s Not found session, id:%{public}d", where, info.persistentId_); return; } if (session->GetSessionInfo().isSystem_) { - WLOGW("NotifySessionExceptionFunc, id: %{public}d is system", - session->GetPersistentId()); + TLOGNW(WmsLogTag::WMS_LIFE, "%{public}s id: %{public}d is system", where, session->GetPersistentId()); return; } - WLOGI("NotifySessionExceptionFunc, errorCode: %{public}d, id: %{public}d", - info.errorCode, info.persistentId_); + TLOGNI(WmsLogTag::WMS_LIFE, "%{public}s errorCode: %{public}d, id: %{public}d", + where, info.errorCode, info.persistentId_); if (info.errorCode == static_cast(AAFwk::ErrorLifecycleState::ABILITY_STATE_LOAD_TIMEOUT) || info.errorCode == static_cast(AAFwk::ErrorLifecycleState::ABILITY_STATE_FOREGROUND_TIMEOUT)) { - WLOGD("NotifySessionClosed when ability load timeout " + TLOGND(WmsLogTag::WMS_LIFE, "NotifySessionClosed when ability load timeout " "or foreground timeout, id: %{public}d", info.persistentId_); listenerController_->NotifySessionClosed(info.persistentId_); } }; taskScheduler_->PostVoidSyncTask(task, "sessionException"); - }; - sceneSession->SetSessionExceptionListener(sessionExceptionFunc, false); + }, false); TLOGD(WmsLogTag::WMS_LIFE, "success, id: %{public}d", sceneSession->GetPersistentId()); } @@ -4155,15 +4274,13 @@ void SceneSessionManager::RegisterVisibilityChangedDetectFunc(const sptr lock(sceneSessionMapMutex_); int32_t count = 0; - for (const auto& iter : sceneSessionMap_) { - auto& session = iter.second; + std::shared_lock lock(sceneSessionMapMutex_); + for (const auto& [_, session] : sceneSessionMap_) { if (session && session->GetCallingPid() == pid && session->IsVisible()) { count++; } } - if (count > 0) { visibleWindowCountMap_[pid] = count; } @@ -4260,7 +4377,7 @@ void SceneSessionManager::NotifySessionForCallback(const sptr& sce void SceneSessionManager::NotifyWindowInfoChangeFromSession(int32_t persistentId) { - WLOGFD("NotifyWindowInfoChange, persistentId = %{public}d", persistentId); + WLOGFD("persistentId = %{public}d", persistentId); sptr sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { WLOGFE("sceneSession nullptr"); @@ -4783,7 +4900,7 @@ void SceneSessionManager::RequestAllAppSessionUnfocus() */ WSError SceneSessionManager::RequestSessionFocusImmediately(int32_t persistentId) { - TLOGI(WmsLogTag::WMS_FOCUS, "RequestSessionFocusImmediately, id: %{public}d", persistentId); + TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); // base block WSError basicCheckRet = RequestFocusBasicCheck(persistentId); if (basicCheckRet != WSError::WS_OK) { @@ -4868,7 +4985,7 @@ WSError SceneSessionManager::RequestSessionFocus(int32_t persistentId, bool byFo WSError SceneSessionManager::RequestSessionUnfocus(int32_t persistentId, FocusChangeReason reason) { - TLOGD(WmsLogTag::WMS_FOCUS, "RequestSessionUnfocus, id: %{public}d", persistentId); + TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); if (persistentId == INVALID_SESSION_ID) { WLOGFE("id is invalid"); return WSError::WS_ERROR_INVALID_SESSION; @@ -4904,7 +5021,7 @@ WSError SceneSessionManager::RequestSessionUnfocus(int32_t persistentId, FocusCh WSError SceneSessionManager::RequestAllAppSessionUnfocusInner() { - TLOGI(WmsLogTag::WMS_FOCUS, "RequestAllAppSessionUnfocus"); + TLOGI(WmsLogTag::WMS_FOCUS, "in"); auto focusedSession = GetSceneSession(focusedSessionId_); if (!focusedSession) { TLOGE(WmsLogTag::WMS_FOCUS, "focused session is null"); @@ -5128,7 +5245,7 @@ void SceneSessionManager::DumpAllSessionFocusableInfo(int32_t persistentId) sptr SceneSessionManager::GetNextFocusableSession(int32_t persistentId) { - TLOGD(WmsLogTag::WMS_FOCUS, "GetNextFocusableSession, id: %{public}d", persistentId); + TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); bool previousFocusedSessionFound = false; sptr ret = nullptr; auto func = [this, persistentId, &previousFocusedSessionFound, &ret](sptr session) { @@ -5195,7 +5312,7 @@ sptr SceneSessionManager::GetTopNearestBlockingFocusSession(uint32 sptr SceneSessionManager::GetTopFocusableNonAppSession() { - TLOGD(WmsLogTag::WMS_FOCUS, "GetTopFocusableNonAppSession."); + TLOGD(WmsLogTag::WMS_FOCUS, "in."); sptr ret = nullptr; auto func = [this, &ret](sptr session) { if (session == nullptr) { @@ -5215,31 +5332,31 @@ sptr SceneSessionManager::GetTopFocusableNonAppSession() void SceneSessionManager::SetShiftFocusListener(const ProcessShiftFocusFunc& func) { - TLOGD(WmsLogTag::WMS_FOCUS, "SetShiftFocusListener"); + TLOGD(WmsLogTag::WMS_FOCUS, "in"); shiftFocusFunc_ = func; } void SceneSessionManager::SetSCBFocusedListener(const NotifySCBAfterUpdateFocusFunc& func) { - TLOGD(WmsLogTag::WMS_FOCUS, "SetSCBFocusedListener"); + TLOGD(WmsLogTag::WMS_FOCUS, "in"); notifySCBAfterFocusedFunc_ = func; } void SceneSessionManager::SetSCBUnfocusedListener(const NotifySCBAfterUpdateFocusFunc& func) { - TLOGD(WmsLogTag::WMS_FOCUS, "SetSCBUnfocusedListener"); + TLOGD(WmsLogTag::WMS_FOCUS, "in"); notifySCBAfterUnfocusedFunc_ = func; } void SceneSessionManager::SetCallingSessionIdSessionListenser(const ProcessCallingSessionIdChangeFunc& func) { - WLOGFD("SetCallingSessionIdSessionListenser"); + WLOGFD("in"); callingSessionIdChangeFunc_ = func; } void SceneSessionManager::SetStartUIAbilityErrorListener(const ProcessStartUIAbilityErrorFunc& func) { - WLOGFD("SetStartUIAbilityErrorListener"); + WLOGFD("in"); startUIAbilityErrorFunc_ = func; } @@ -5262,7 +5379,7 @@ WSError SceneSessionManager::ShiftFocus(sptr& nextSession, FocusCh int32_t nextId = INVALID_SESSION_ID; if (nextSession == nullptr) { std::string sessionLog(GetAllSessionFocusInfo()); - TLOGW(WmsLogTag::WMS_FOCUS, "ShiftFocus to nullptr! id: %{public}d, info: %{public}s", + TLOGW(WmsLogTag::WMS_FOCUS, "next session nullptr! id: %{public}d, info: %{public}s", focusedSessionId_, sessionLog.c_str()); } else { nextId = nextSession->GetPersistentId(); @@ -5294,7 +5411,7 @@ void SceneSessionManager::UpdateFocusStatus(sptr& sceneSession, bo } return; } - TLOGD(WmsLogTag::WMS_FOCUS, "UpdateFocusStatus, name: %{public}s, id: %{public}d, isFocused: %{public}d", + TLOGD(WmsLogTag::WMS_FOCUS, "name: %{public}s, id: %{public}d, isFocused: %{public}d", sceneSession->GetWindowNameAllType().c_str(), sceneSession->GetPersistentId(), isFocused); // set focused if (isFocused) { @@ -5377,8 +5494,7 @@ int32_t SceneSessionManager::NotifyRssThawApp(const int32_t uid, const std::stri payload.emplace("bundleName", bundleName); payload.emplace("reason", reason); nlohmann::json reply; - int32_t ret = ResourceSchedule::ResSchedClient::GetInstance().ReportSyncEvent(resType, 0, payload, reply); - return ret; + return ResourceSchedule::ResSchedClient::GetInstance().ReportSyncEvent(resType, 0, payload, reply); } void SceneSessionManager::NotifyFocusStatusByMission(sptr& prevSession, sptr& currSession) @@ -5421,7 +5537,7 @@ std::string SceneSessionManager::GetAllSessionFocusInfo() return false; } os << "WindowName: " << session->GetWindowName() << ", id: " << session->GetPersistentId() << - " ,focusable: "<< session->GetFocusable() << ";"; + ", focusable: " << session->GetFocusable() << ";"; return false; }; TraverseSessionTree(func, true); @@ -5437,7 +5553,7 @@ WSError SceneSessionManager::UpdateFocus(int32_t persistentId, bool isFocused) WLOGFE("UpdateFocus could not find window, persistentId:%{public}d", persistentId); return WSError::WS_ERROR_INVALID_WINDOW; } - WLOGFI("UpdateFocus, name: %{public}s, id: %{public}d, isFocused: %{public}u", + WLOGI("UpdateFocus, name: %{public}s, id: %{public}d, isFocused: %{public}u", sceneSession->GetWindowName().c_str(), persistentId, static_cast(isFocused)); // focusId change if (isFocused) { @@ -5809,7 +5925,7 @@ __attribute__((no_sanitize("cfi"))) void SceneSessionManager::OnSessionStateChan int32_t persistentId, const SessionState& state) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:OnSessionStateChange%d", persistentId); - WLOGFD("Session state change, id: %{public}d, state:%{public}u", persistentId, state); + WLOGFD("id: %{public}d, state:%{public}u", persistentId, state); auto sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { WLOGFD("session is nullptr"); @@ -6337,7 +6453,7 @@ WSError SceneSessionManager::SetSessionLabel(const sptr& token, c WSError SceneSessionManager::SetSessionIcon(const sptr& token, const std::shared_ptr& icon) { - WLOGFI("Enter"); + WLOGFI("in"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { WLOGFE("The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -6366,7 +6482,7 @@ WSError SceneSessionManager::SetSessionIcon(const sptr& token, WSError SceneSessionManager::IsValidSessionIds( const std::vector& sessionIds, std::vector& results) { - WLOGFI("Enter"); + WLOGFI("in"); std::shared_lock lock(sceneSessionMapMutex_); for (auto i = 0; i < static_cast(sessionIds.size()); ++i) { auto search = sceneSessionMap_.find(sessionIds.at(i)); @@ -6421,7 +6537,7 @@ WSError SceneSessionManager::UnRegisterSessionListener(const sptr& sessionInfos) { - WLOGFI("Enter num max %{public}d", numMax); + WLOGFI("num max %{public}d", numMax); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { WLOGFE("The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -6601,7 +6717,7 @@ WSError SceneSessionManager::GetSessionInfoByContinueSessionId(const std::string int SceneSessionManager::GetRemoteSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) { - WLOGFI("GetRemoteSessionInfoFromDms begin"); + WLOGFI("in"); std::vector sessionVector; int result = GetRemoteSessionInfos(deviceId, MAX_NUMBER_OF_DISTRIBUTED_SESSIONS, sessionVector); if (result != ERR_OK) { @@ -6620,19 +6736,19 @@ int SceneSessionManager::GetRemoteSessionInfo(const std::string& deviceId, bool SceneSessionManager::CheckIsRemote(const std::string& deviceId) { if (deviceId.empty()) { - WLOGFI("CheckIsRemote: deviceId is empty."); + WLOGFI("deviceId is empty."); return false; } std::string localDeviceId; if (!GetLocalDeviceId(localDeviceId)) { - WLOGFE("CheckIsRemote: get local deviceId failed"); + WLOGFE("get local deviceId failed"); return false; } if (localDeviceId == deviceId) { - WLOGFI("CheckIsRemote: deviceId is local."); + WLOGFI("deviceId is local."); return false; } - WLOGFD("CheckIsRemote, deviceId = %{public}s", AnonymizeDeviceId(deviceId).c_str()); + WLOGFD("Checked deviceId = %{public}s", AnonymizeDeviceId(deviceId).c_str()); return true; } @@ -6665,9 +6781,9 @@ std::string SceneSessionManager::AnonymizeDeviceId(const std::string& deviceId) WSError SceneSessionManager::DumpSessionAll(std::vector& infos) { - WLOGFI("Dump all session."); + WLOGFI("in."); if (!SessionPermission::IsSystemCalling()) { - WLOGFE("DumpSessionAll permission denied!"); + WLOGFE("permission denied!"); return WSError::WS_ERROR_NOT_SYSTEM_APP; } @@ -6689,9 +6805,9 @@ WSError SceneSessionManager::DumpSessionAll(std::vector& infos) WSError SceneSessionManager::DumpSessionWithId(int32_t persistentId, std::vector& infos) { - WLOGFI("Dump session with id %{public}d", persistentId); + WLOGFI("id %{public}d", persistentId); if (!SessionPermission::IsSystemCalling()) { - WLOGFE("DumpSessionWithId permission denied!"); + WLOGFE("permission denied!"); return WSError::WS_ERROR_NOT_SYSTEM_APP; } @@ -7058,8 +7174,7 @@ sptr SceneSessionManager::GetCollaboratorByT WSError SceneSessionManager::RequestSceneSessionByCall(const sptr& sceneSession) { - wptr weakSceneSession(sceneSession); - auto task = [this, weakSceneSession]() { + auto task = [this, weakSceneSession = wptr(sceneSession)] { auto sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { WLOGFE("session is nullptr"); @@ -7099,7 +7214,8 @@ WSError SceneSessionManager::RequestSceneSessionByCall(const sptr& void SceneSessionManager::StartAbilityBySpecified(const SessionInfo& sessionInfo) { auto task = [this, sessionInfo]() { - WLOGFI("StartAbilityBySpecified: bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s", + TLOGNI(WmsLogTag::WMS_LIFE, "StartAbilityBySpecified: bundleName: %{public}s, " + "moduleName: %{public}s, abilityName: %{public}s", sessionInfo.bundleName_.c_str(), sessionInfo.moduleName_.c_str(), sessionInfo.abilityName_.c_str()); AAFwk::Want want; want.SetElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); @@ -7176,7 +7292,7 @@ sptr SceneSessionManager::FindMainWindowWithToken(sptr targetToken) { if (!SessionPermission::IsSystemCalling()) { - TLOGE(WmsLogTag::WMS_DIALOG, "BindDialogSessionTarget permission denied!"); + TLOGE(WmsLogTag::WMS_DIALOG, "permission denied!"); return WSError::WS_ERROR_NOT_SYSTEM_APP; } if (targetToken == nullptr) { @@ -7294,7 +7410,7 @@ WMError SceneSessionManager::UnregisterWindowManagerAgent(WindowManagerAgentType type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED || type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG) { if (!SessionPermission::IsSystemCalling()) { - WLOGFE("UnregisterWindowManagerAgent permission denied!"); + WLOGFE("IsSystemCalling permission denied!"); return WMError::WM_ERROR_NOT_SYSTEM_APP; } } @@ -7304,7 +7420,7 @@ WMError SceneSessionManager::UnregisterWindowManagerAgent(WindowManagerAgentType type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS || type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE) { if (!SessionPermission::IsSACalling()) { - TLOGE(WmsLogTag::WMS_LIFE, "permission denied!"); + TLOGE(WmsLogTag::WMS_LIFE, "IsSACalling permission denied!"); return WMError::WM_ERROR_INVALID_PERMISSION; } } @@ -7367,7 +7483,7 @@ void SceneSessionManager::InitPersistentStorage() WMError SceneSessionManager::GetAccessibilityWindowInfo(std::vector>& infos) { - WLOGFD("Called."); + WLOGFD("in."); if (!SessionPermission::IsSystemServiceCalling()) { WLOGFE("Only support for system service."); return WMError::WM_ERROR_NOT_SYSTEM_APP; @@ -7436,7 +7552,7 @@ static void FillUnreliableWindowInfo(const sptr& sceneSession, WMError SceneSessionManager::GetUnreliableWindowInfo(int32_t windowId, std::vector>& infos) { - TLOGD(WmsLogTag::DEFAULT, "Called."); + TLOGD(WmsLogTag::DEFAULT, "in."); if (!SessionPermission::IsSystemServiceCalling()) { TLOGE(WmsLogTag::DEFAULT, "only support for system service."); return WMError::WM_ERROR_NOT_SYSTEM_APP; @@ -7509,7 +7625,7 @@ void SceneSessionManager::NotifyWindowInfoChange(int32_t persistentId, WindowUpd } SceneInputManager::GetInstance().NotifyWindowInfoChange(sceneSession, type); }; - taskScheduler_->PostAsyncTask(notifySceneInputTask); + taskScheduler_->PostAsyncTask(notifySceneInputTask, "notifySceneInputTask"); } bool SceneSessionManager::FillWindowInfo(std::vector>& infos, @@ -7775,7 +7891,9 @@ std::vector> SceneSessionManager::Get i = j = 0; for (; i < lastVisibleData_.size() && j < currVisibleData.size();) { if (lastVisibleData_[i].first < currVisibleData[j].first) { - visibilityChangeInfo.emplace_back(lastVisibleData_[i].first, WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION); + if (lastVisibleData_[i].second != WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { + visibilityChangeInfo.emplace_back(lastVisibleData_[i].first, WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION); + } i++; } else if (lastVisibleData_[i].first > currVisibleData[j].first) { if (currVisibleData[j].second != WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { @@ -7791,7 +7909,9 @@ std::vector> SceneSessionManager::Get } } for (; i < lastVisibleData_.size(); ++i) { - visibilityChangeInfo.emplace_back(lastVisibleData_[i].first, WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION); + if (lastVisibleData_[i].second != WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { + visibilityChangeInfo.emplace_back(lastVisibleData_[i].first, WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION); + } } for (; j < currVisibleData.size(); ++j) { if (currVisibleData[j].second != WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { @@ -7855,21 +7975,30 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vector> windowDrawingContenInfos; - for (const auto& elem : drawingContentChangeInfo) { - uint64_t surfaceId = elem.first; - bool drawingState = elem.second; + for (const auto& [surfaceId, drawingState] : drawingContentChangeInfo) { + int32_t windowId = 0; + int32_t pid = 0; + int32_t uid = 0; + WindowType type = WindowType::APP_WINDOW_BASE; sptr session = SelectSesssionFromMap(surfaceId); if (session == nullptr) { - continue; + if (!GetSpecifiedDrawingData(surfaceId, pid, uid)) { + continue; + } + RemoveSpecifiedDrawingData(surfaceId); + } else { + windowId = session->GetWindowId(); + pid = session->GetCallingPid(); + uid = session->GetCallingUid(); + type = session->GetWindowType(); } - windowDrawingContenInfos.emplace_back(new WindowDrawingContentInfo(session->GetWindowId(), - session->GetCallingPid(), session->GetCallingUid(), drawingState, session->GetWindowType())); + windowDrawingContenInfos.emplace_back(new WindowDrawingContentInfo(windowId, pid, uid, drawingState, type)); if (openDebugTrace_) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "Drawing status changed pid:(%d ) surfaceId:(%" PRIu64 ")" - "drawingState:(%d )", session->GetCallingPid(), surfaceId, drawingState); + "drawingState:(%d )", pid, surfaceId, drawingState); } WLOGFD("drawing status changed pid:%{public}d, " - "surfaceId:%{public}" PRIu64 ", drawingState:%{public}d", session->GetCallingPid(), surfaceId, drawingState); + "surfaceId:%{public}" PRIu64 ", drawingState:%{public}d", pid, surfaceId, drawingState); } if (windowDrawingContenInfos.size() != 0) { WLOGFD("Notify WindowDrawingContenInfo changed start"); @@ -7877,44 +8006,62 @@ void SceneSessionManager::DealwithDrawingContentChange(const std::vectorsecond.pid_; + uid = it->second.uid_; + return true; + } + return false; +} + +void SceneSessionManager::RemoveSpecifiedDrawingData(uint64_t surfaceId) +{ + auto it = lastDrawingSessionInfoMap_.find(surfaceId); + if (it != lastDrawingSessionInfoMap_.end()) { + lastDrawingSessionInfoMap_.erase(it); + } +} + std::vector> SceneSessionManager::GetWindowDrawingContentChangeInfo( - std::vector> currDrawingContentData) + const std::vector>& currDrawingContentData) { std::vector> processDrawingContentChangeInfo; - for (const auto& data : currDrawingContentData) { - uint64_t windowId = data.first; - bool currentDrawingContentState = data.second; + for (const auto& [surfaceId, isWindowDrawing] : currDrawingContentData) { int32_t pid = 0; - bool isChange = false; - if (GetPreWindowDrawingState(windowId, pid, currentDrawingContentState) == currentDrawingContentState) { - continue; - } else { - isChange = GetProcessDrawingState(windowId, pid, currentDrawingContentState); - } - - if (isChange) { - processDrawingContentChangeInfo.emplace_back(windowId, currentDrawingContentState); + sptr session = SelectSesssionFromMap(surfaceId); + bool isDrawingStateChanged = + session == nullptr || (GetPreWindowDrawingState(surfaceId, isWindowDrawing, pid) != isWindowDrawing && + GetProcessDrawingState(surfaceId, pid)); + if (isDrawingStateChanged) { + processDrawingContentChangeInfo.emplace_back(surfaceId, isWindowDrawing); } } return processDrawingContentChangeInfo; } -bool SceneSessionManager::GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState) +bool SceneSessionManager::GetPreWindowDrawingState(uint64_t surfaceId, bool currentWindowDrawing, int32_t& pid) { - bool preWindowDrawingState = true; - sptr session = SelectSesssionFromMap(windowId); + sptr session = SelectSesssionFromMap(surfaceId); if (session == nullptr) { return false; } pid = session->GetCallingPid(); - preWindowDrawingState = session->GetDrawingContentState(); - session->SetDrawingContentState(currentDrawingContentState); - return preWindowDrawingState; + bool preWindowDrawing = session->GetDrawingContentState(); + session->SetDrawingContentState(currentWindowDrawing); + UpdateWindowDrawingData(surfaceId, pid, session->GetCallingUid()); + return preWindowDrawing; } -bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState) +void SceneSessionManager::UpdateWindowDrawingData(uint64_t surfaceId, int32_t pid, int32_t uid) +{ + lastDrawingSessionInfoMap_[surfaceId] = { pid, uid }; +} + +bool SceneSessionManager::GetProcessDrawingState(uint64_t surfaceId, int32_t pid) { - bool isChange = true; std::shared_lock lock(sceneSessionMapMutex_); for (const auto& item : sceneSessionMap_) { auto sceneSession = item.second; @@ -7922,16 +8069,15 @@ bool SceneSessionManager::GetProcessDrawingState(uint64_t windowId, int32_t pid, continue; } if (sceneSession->GetCallingPid() == pid && sceneSession->GetSurfaceNode() != nullptr && - windowId != sceneSession->GetSurfaceNode()->GetId()) { - if (sceneSession->GetDrawingContentState()) { - return false; - } + surfaceId != sceneSession->GetSurfaceNode()->GetId()) { + if (sceneSession->GetDrawingContentState()) { + return false; } } - return isChange; + } + return true; } - void SceneSessionManager::InitWithRenderServiceAdded() { auto windowVisibilityChangeCb = [this](std::shared_ptr occlusiontionData) { @@ -8057,7 +8203,7 @@ sptr SceneSessionManager::FindSessionByAffinity(std::string affini void SceneSessionManager::PreloadInLakeApp(const std::string& bundleName) { - WLOGFD("Enter name %{public}s", bundleName.c_str()); + WLOGFD("name %{public}s", bundleName.c_str()); sptr collaborator = GetCollaboratorByType(CollaboratorType::RESERVE_TYPE); if (collaborator != nullptr) { WLOGFI("NotifyPreloadAbility: %{public}s", bundleName.c_str()); @@ -8067,7 +8213,7 @@ void SceneSessionManager::PreloadInLakeApp(const std::string& bundleName) WSError SceneSessionManager::PendingSessionToForeground(const sptr& token) { - TLOGI(WmsLogTag::DEFAULT, "Enter"); + TLOGI(WmsLogTag::DEFAULT, "in"); auto pid = IPCSkeleton::GetCallingRealPid(); if (!SessionPermission::IsSACalling() && !SessionPermission::CheckCallingIsUserTestMode(pid)) { TLOGE(WmsLogTag::DEFAULT, "Permission denied for going to foreground!"); @@ -8289,18 +8435,16 @@ void SceneSessionManager::NotifyMMIWindowPidChange(int32_t windowId, bool startM return; } - wptr weakSceneSession(sceneSession); - WLOGFI("SceneSessionManager NotifyMMIWindowPidChange to notify window: %{public}d, pid: %{public}d", windowId, pid); - auto task = [weakSceneSession, startMoving]() -> WSError { + WLOGFI("Notify window: %{public}d, pid: %{public}d", windowId, pid); + auto task = [weakSceneSession = wptr(sceneSession), startMoving] { auto sceneSession = weakSceneSession.promote(); if (sceneSession == nullptr) { WLOGFW("session is null"); - return WSError::WS_ERROR_NULLPTR; + return; } SceneInputManager::GetInstance().NotifyMMIWindowPidChange(sceneSession, startMoving); - return WSError::WS_OK; }; - return taskScheduler_->PostAsyncTask(task); + taskScheduler_->PostAsyncTask(task, __func__); } void SceneSessionManager::UpdateAvoidArea(int32_t persistentId) @@ -8449,7 +8593,7 @@ WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSR } } if (isNeedNotify) { - WLOGFI("NotifyAINavigationBar: enter: %{public}u, {%{public}d,%{public}d,%{public}d,%{public}d}", + WLOGFI("NotifyAINavigationBar inner: %{public}u, {%{public}d,%{public}d,%{public}d,%{public}d}", isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_); for (auto persistentId : avoidAreaListenerSessionSet_) { NotifySessionAINavigationBarChange(persistentId); @@ -8651,7 +8795,7 @@ void SceneSessionManager::ProcessDisplayScale(sptr& displayInfo) return; } - auto task = [displayInfo]() -> WSError { + auto task = [displayInfo] { ScreenSessionManagerClient::GetInstance().UpdateDisplayScale(displayInfo->GetScreenId(), displayInfo->GetScaleX(), displayInfo->GetScaleY(), @@ -8661,9 +8805,8 @@ void SceneSessionManager::ProcessDisplayScale(sptr& displayInfo) displayInfo->GetTranslateY()); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSessionManager::FlushWindowInfoToMMI"); SceneInputManager::GetInstance().FlushDisplayInfoToMMI(true); - return WSError::WS_OK; }; - return taskScheduler_->PostAsyncTask(task); + taskScheduler_->PostAsyncTask(task, __func__); } void DisplayChangeListener::OnDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, @@ -8734,7 +8877,7 @@ WSError SceneSessionManager::ClearSession(int32_t persistentId) WSError SceneSessionManager::ClearSession(sptr sceneSession) { - WLOGFD("Enter"); + WLOGFD("in"); if (sceneSession == nullptr) { WLOGFE("session is nullptr"); return WSError::WS_ERROR_INVALID_SESSION; @@ -8749,7 +8892,7 @@ WSError SceneSessionManager::ClearSession(sptr sceneSession) WSError SceneSessionManager::ClearAllSessions() { - WLOGFI("Enter"); + WLOGFD("in"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { WLOGFE("The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -8772,7 +8915,7 @@ WSError SceneSessionManager::ClearAllSessions() void SceneSessionManager::GetAllClearableSessions(std::vector>& sessionVector) { - WLOGFI("Enter"); + WLOGFD("in"); std::shared_lock lock(sceneSessionMapMutex_); for (const auto &item : sceneSessionMap_) { auto sceneSession = item.second; @@ -8830,7 +8973,7 @@ WSError SceneSessionManager::UnlockSession(int32_t sessionId) WSError SceneSessionManager::MoveSessionsToForeground(const std::vector& sessionIds, int32_t topSessionId) { - TLOGI(WmsLogTag::WMS_LIFE, "Enter"); + TLOGI(WmsLogTag::WMS_LIFE, "in"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { TLOGE(WmsLogTag::WMS_LIFE, "The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -8846,7 +8989,7 @@ WSError SceneSessionManager::MoveSessionsToForeground(const std::vector WSError SceneSessionManager::MoveSessionsToBackground(const std::vector& sessionIds, std::vector& result) { - TLOGI(WmsLogTag::WMS_LIFE, "Enter"); + TLOGI(WmsLogTag::WMS_LIFE, "in"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { TLOGE(WmsLogTag::WMS_LIFE, "The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -8871,7 +9014,7 @@ bool SceneSessionManager::IsSessionClearable(sptr sceneSession) WLOGFI("sceneSession abilityInfo is nullptr"); return false; } - if (sessionInfo.abilityInfo->excludeFromMissions) { + if (sessionInfo.abilityInfo->excludeFromMissions && !sceneSession->IsAnco()) { WLOGFI("persistentId %{public}d is excludeFromMissions", sceneSession->GetPersistentId()); return false; } @@ -9090,7 +9233,7 @@ void SceneSessionManager::NotifyLoadAbility(int32_t collaboratorType, void SceneSessionManager::NotifyUpdateSessionInfo(sptr sceneSession) { - WLOGFD("Enter"); + WLOGFD("in"); if (sceneSession == nullptr) { WLOGFE("sceneSession is nullptr"); return; @@ -9771,28 +9914,26 @@ const std::map> SceneSessionManager::GetSceneSession void SceneSessionManager::NotifyUpdateRectAfterLayout() { - auto transactionController = Rosen::RSSyncTransactionController::GetInstance(); std::shared_ptr rsTransaction = nullptr; - if (transactionController) { + if (auto transactionController = RSSyncTransactionController::GetInstance()) { rsTransaction = transactionController->GetRSTransaction(); } - auto task = [this, rsTransaction]() { + auto task = [this, rsTransaction] { std::shared_lock lock(sceneSessionMapMutex_); - for (const auto& iter: sceneSessionMap_) { - auto sceneSession = iter.second; + for (const auto& [_, sceneSession] : sceneSessionMap_) { if (sceneSession && sceneSession->IsDirtyWindow()) { sceneSession->NotifyClientToUpdateRect("AfterLayoutFromPersistentTask", rsTransaction); } } }; // need sync task since animation transcation need - return taskScheduler_->PostAsyncTask(task, "NotifyUpdateRectAfterLayout"); + taskScheduler_->PostAsyncTask(task, __func__); } WMError SceneSessionManager::GetVisibilityWindowInfo(std::vector>& infos) { if (!SessionPermission::IsSystemCalling()) { - WLOGFE("GetVisibilityWindowInfo permission denied!"); + WLOGFE("permission denied!"); return WMError::WM_ERROR_NOT_SYSTEM_APP; } auto task = [this, &infos]() { @@ -9808,7 +9949,8 @@ WMError SceneSessionManager::GetVisibilityWindowInfo(std::vectorGetSessionProperty()); infos.emplace_back(sptr::MakeSptr(session->GetWindowId(), session->GetCallingPid(), session->GetCallingUid(), session->GetVisibilityState(), session->GetWindowType(), windowStatus, rect, - session->GetSessionInfo().bundleName_, session->GetSessionInfo().abilityName_)); + session->GetSessionInfo().bundleName_, session->GetSessionInfo().abilityName_, + session->IsFocused())); } return WMError::WM_OK; }; @@ -9831,17 +9973,17 @@ void SceneSessionManager::FlushWindowInfoToMMI(const bool forceFlush) { auto task = [this, forceFlush] { if (isUserBackground_) { - TLOGD(WmsLogTag::WMS_MULTI_USER, "The user is in the background, no need to flush info to MMI"); + TLOGND(WmsLogTag::WMS_MULTI_USER, "The user is in the background, no need to flush info to MMI"); return; } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSessionManager::FlushWindowInfoToMMI"); SceneInputManager::GetInstance().FlushDisplayInfoToMMI(forceFlush); }; - taskScheduler_->PostAsyncTask(task); + taskScheduler_->PostAsyncTask(task, __func__); } -void SceneSessionManager::PostFlushWindowInfoTask(FlushWindowInfoTask &&task, - const std::string taskName, const int delayTime) +void SceneSessionManager::PostFlushWindowInfoTask(FlushWindowInfoTask&& task, + const std::string& taskName, const int delayTime) { taskScheduler_->PostAsyncTask(std::move(task), taskName, delayTime); } @@ -9869,7 +10011,9 @@ void SceneSessionManager::DestroyExtensionSession(const sptr& rem } int32_t persistentId = INVALID_SESSION_ID; int32_t parentId = INVALID_SESSION_ID; - if (!GetExtensionWindowIds(iter->second, persistentId, parentId)) { + + auto abilityToken = iter->second; + if (!GetExtensionWindowIds(abilityToken, persistentId, parentId)) { TLOGE(WmsLogTag::WMS_UIEXT, "Get UIExtension window ids by token failed"); return; } @@ -9891,6 +10035,7 @@ void SceneSessionManager::DestroyExtensionSession(const sptr& rem } sceneSession->RemoveModalUIExtension(persistentId); sceneSession->RemoveUIExtSurfaceNodeId(persistentId); + sceneSession->RemoveExtensionTokenInfo(abilityToken); } else { ExtensionWindowFlags actions; actions.SetAllActive(); @@ -9958,7 +10103,9 @@ void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr const sptr& token, uint64_t surfaceNodeId) { auto pid = IPCSkeleton::GetCallingRealPid(); - auto task = [this, sessionStage, token, surfaceNodeId, pid]() { + auto callingTokenId = IPCSkeleton::GetCallingTokenID(); + + auto task = [this, sessionStage, token, surfaceNodeId, pid, callingTokenId]() { if (sessionStage == nullptr || token == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "input is nullptr"); return; @@ -10005,6 +10152,12 @@ void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr }; parentSession->AddModalUIExtension(extensionInfo); } + + SceneSession::UIExtensionTokenInfo tokenInfo; + tokenInfo.abilityToken = token; + tokenInfo.callingTokenId = callingTokenId; + tokenInfo.canShowOnLockScreen = IsUIExtCanShowOnLockScreen(info.elementName, callingTokenId); + parentSession->AddExtensionTokenInfo(tokenInfo); }; taskScheduler_->PostAsyncTask(task, "AddExtensionWindowStageToSCB"); } @@ -10012,7 +10165,7 @@ void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr void SceneSessionManager::RemoveExtensionWindowStageFromSCB(const sptr& sessionStage, const sptr& token) { - TLOGI(WmsLogTag::WMS_UIEXT, "called"); + TLOGI(WmsLogTag::WMS_UIEXT, "in"); auto task = [this, sessionStage, token]() { if (sessionStage == nullptr || token == nullptr) { TLOGE(WmsLogTag::WMS_UIEXT, "input is nullptr"); @@ -11108,7 +11261,7 @@ WMError SceneSessionManager::TerminateSessionByPersistentId(int32_t persistentId void SceneSessionManager::SetRootSceneProcessBackEventFunc(const RootSceneProcessBackEventFunc& processBackEventFunc) { rootSceneProcessBackEventFunc_ = processBackEventFunc; - TLOGI(WmsLogTag::WMS_EVENT, "called"); + TLOGI(WmsLogTag::WMS_EVENT, "end"); } WMError SceneSessionManager::GetProcessSurfaceNodeIdByPersistentId(const int32_t pid, diff --git a/window_scene/session_manager/src/scene_session_manager_lite.cpp b/window_scene/session_manager/src/scene_session_manager_lite.cpp index ffe4df864c..1992e85bc2 100644 --- a/window_scene/session_manager/src/scene_session_manager_lite.cpp +++ b/window_scene/session_manager/src/scene_session_manager_lite.cpp @@ -190,6 +190,12 @@ WMError SceneSessionManagerLite::CheckWindowId(int32_t windowId, int32_t& pid) return SceneSessionManager::GetInstance().CheckWindowId(windowId, pid); } +WMError SceneSessionManagerLite::CheckUIExtensionCreation( + int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) +{ + return SceneSessionManager::GetInstance().CheckUIExtensionCreation(windowId, tokenId, element, pid); +} + WMError SceneSessionManagerLite::GetVisibilityWindowInfo(std::vector>& infos) { return SceneSessionManager::GetInstance().GetVisibilityWindowInfo(infos); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp index a311a5562d..27c1a76251 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp @@ -890,6 +890,59 @@ WMError SceneSessionManagerLiteProxy::CheckWindowId(int32_t windowId, int32_t& p return WMError::WM_OK; } +WMError SceneSessionManagerLiteProxy::CheckUIExtensionCreation( + int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write interfaceToken"); + return WMError::WM_ERROR_IPC_FAILED; + } + if (!data.WriteInt32(windowId)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write windowId"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!data.WriteUint32(tokenId)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write tokenId"); + return WMError::WM_ERROR_IPC_FAILED; + } + + data.WriteParcelable(&element); + + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write tokenId"); + return WMError::WM_ERROR_NULLPTR; + } + + int32_t ret = + remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UI_EXTENSION_CREATION_CHECK), + data, + reply, + option); + if (ret != ERR_NONE) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Send request failed, ret:%{public}d", ret); + return WMError::WM_ERROR_IPC_FAILED; + } + + int32_t errCode = 0; + if (!reply.ReadInt32(errCode)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to read errcode"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!reply.ReadInt32(pid)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to read pid"); + return WMError::WM_ERROR_IPC_FAILED; + } + + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: errcode %{public}u", errCode); + return static_cast(errCode); +} + WMError SceneSessionManagerLiteProxy::GetVisibilityWindowInfo(std::vector>& infos) { MessageParcel data; 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 c233ee9ff4..ecb26b1ff1 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 @@ -94,6 +94,8 @@ int SceneSessionManagerLiteStub::ProcessRemoteRequest(uint32_t code, MessageParc return HandleUnregisterWindowManagerAgent(data, reply); case static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CHECK_WINDOW_ID): return HandleCheckWindowId(data, reply); + case static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UI_EXTENSION_CREATION_CHECK): + return HandleCheckUIExtensionCreation(data, reply); case static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID): return HandleGetVisibilityWindowInfo(data, reply); case static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_WINDOW_MODE_TYPE): @@ -527,6 +529,44 @@ int SceneSessionManagerLiteStub::HandleCheckWindowId(MessageParcel& data, Messag return ERR_NONE; } +int SceneSessionManagerLiteStub::HandleCheckUIExtensionCreation(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: called"); + + int32_t windowId = INVALID_WINDOW_ID; + if (!data.ReadInt32(windowId)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get windowId"); + return ERR_INVALID_DATA; + } + + uint32_t token = -1; + if (!data.ReadUint32(token)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get token"); + return ERR_INVALID_DATA; + } + + sptr element = data.ReadParcelable(); + if (!element) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to get element"); + return ERR_INVALID_DATA; + } + + int32_t pid = INVALID_PID; + WMError errCode = CheckUIExtensionCreation(windowId, token, *element, pid); + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: ret %{public}u", errCode); + + if (!reply.WriteInt32(static_cast(errCode))) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write errcode"); + return ERR_INVALID_DATA; + } + + if (!reply.WriteInt32(pid)) { + TLOGE(WmsLogTag::WMS_UIEXT, "UIExtOnLock: Failed to write pid"); + return ERR_INVALID_DATA; + } + + return ERR_NONE; +} int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel& data, MessageParcel& reply) { @@ -537,7 +577,7 @@ int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel& return ERR_INVALID_DATA; } WindowManagerAgentType type = static_cast(typeId); - WLOGFI("run HandleRegisterWindowManagerAgent!, type=%{public}u", typeId); + TLOGI(WmsLogTag::DEFAULT, "type=%{public}u", typeId); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = iface_cast(windowManagerAgentObject); @@ -555,7 +595,7 @@ int SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent(MessageParce return ERR_INVALID_DATA; } WindowManagerAgentType type = static_cast(typeId); - WLOGFI("run HandleUnregisterWindowManagerAgent!, type=%{public}u", typeId); + TLOGI(WmsLogTag::DEFAULT, "type=%{public}u", typeId); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = iface_cast(windowManagerAgentObject); 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 693a5e0d39..2295036dcc 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 @@ -372,7 +372,7 @@ int SceneSessionManagerStub::HandleRegisterWindowManagerAgent(MessageParcel& dat return ERR_INVALID_DATA; } WindowManagerAgentType type = static_cast(typeId); - WLOGFI("run HandleRegisterWindowManagerAgent!, type=%{public}u", typeId); + TLOGI(WmsLogTag::DEFAULT, "type=%{public}u", typeId); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = iface_cast(windowManagerAgentObject); @@ -390,7 +390,7 @@ int SceneSessionManagerStub::HandleUnregisterWindowManagerAgent(MessageParcel& d return ERR_INVALID_DATA; } WindowManagerAgentType type = static_cast(typeId); - WLOGFI("run HandleUnregisterWindowManagerAgent!, type=%{public}u", typeId); + TLOGI(WmsLogTag::DEFAULT, "type=%{public}u", typeId); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = iface_cast(windowManagerAgentObject); diff --git a/window_scene/test/dms_unittest/screen_property_test.cpp b/window_scene/test/dms_unittest/screen_property_test.cpp index 74411efc18..773ad5d909 100644 --- a/window_scene/test/dms_unittest/screen_property_test.cpp +++ b/window_scene/test/dms_unittest/screen_property_test.cpp @@ -257,6 +257,72 @@ HWTEST_F(ScreenPropertyTest, GetRotation, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "ScreenPropertyTest: GetRotation end"; } +/** + * @tc.name: SetPhysicalRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, SetPhysicalRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPhysicalRotation start"; + ScreenProperty* property = new(std::nothrow) ScreenProperty(); + ASSERT_NE(property, nullptr); + float rotation = 2.0f; + property->SetPhysicalRotation(rotation); + ASSERT_EQ(property->physicalRotation_, rotation); + delete property; + GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPhysicalRotation end"; +} + +/** + * @tc.name: GetPhysicalRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, GetPhysicalRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhysicalRotation start"; + ScreenProperty* property = new(std::nothrow) ScreenProperty(); + ASSERT_NE(property, nullptr); + float rotation = property->GetPhysicalRotation(); + ASSERT_EQ(property->physicalRotation_, rotation); + delete property; + GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhysicalRotation end"; +} + +/** + * @tc.name: SetScreenComponentRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, SetScreenComponentRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenComponentRotation start"; + ScreenProperty* property = new(std::nothrow) ScreenProperty(); + ASSERT_NE(property, nullptr); + float rotation = 2.0f; + property->SetScreenComponentRotation(rotation); + ASSERT_EQ(property->screenComponentRotation_, rotation); + delete property; + GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenComponentRotation end"; +} + +/** + * @tc.name: GetScreenComponentRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, GetScreenComponentRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenPropertyTest: GetScreenComponentRotation start"; + ScreenProperty* property = new(std::nothrow) ScreenProperty(); + ASSERT_NE(property, nullptr); + float rotation = property->GetScreenComponentRotation(); + ASSERT_EQ(property->screenComponentRotation_, rotation); + delete property; + GTEST_LOG_(INFO) << "ScreenPropertyTest: GetScreenComponentRotation end"; +} + /** * @tc.name: GetBounds * @tc.desc: normal function diff --git a/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp index 4be3628f3a..8d6bcd340a 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_client_test.cpp @@ -415,11 +415,14 @@ HWTEST_F(ScreenSessionManagerClientTest, UpdateScreenRotationProperty, Function RRect bounds; bounds.rect_.width_ = 1344; bounds.rect_.height_ = 2772; - float rotation = 90; float scaleX = 1.0; float scaleY = 1.0; + ScreenDirectionInfo directionInfo; + directionInfo.notifyRotation_ = 90; + directionInfo.screenRotation_ = 90; + directionInfo.rotation_ = 90; ScreenPropertyChangeType screenPropertyChangeType = ScreenPropertyChangeType::ROTATION_BEGIN; - screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, rotation, + screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, directionInfo, screenPropertyChangeType); screenSessionManagerClient_->SetDisplayNodeScreenId(screenId, displayNodeScreenId); screenSessionManagerClient_->GetPhyScreenProperty(screenId); @@ -445,9 +448,12 @@ HWTEST_F(ScreenSessionManagerClientTest, GetScreenSnapshot, Function | SmallTest RRect bounds; bounds.rect_.width_ = 1344; bounds.rect_.height_ = 2772; - float rotation = 90; + ScreenDirectionInfo directionInfo; + directionInfo.notifyRotation_ = 90; + directionInfo.screenRotation_ = 90; + directionInfo.rotation_ = 90; ScreenPropertyChangeType screenPropertyChangeType = ScreenPropertyChangeType::ROTATION_BEGIN; - screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, rotation, + screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, directionInfo, screenPropertyChangeType); screenSessionManagerClient_->SetDisplayNodeScreenId(screenId, displayNodeScreenId); std::shared_ptr res = screenSessionManagerClient_->GetScreenSnapshot(screenId, scaleX, scaleY); @@ -1284,11 +1290,14 @@ HWTEST_F(ScreenSessionManagerClientTest, UpdateScreenRotationProperty02, Functio RRect bounds; bounds.rect_.width_ = 1344; bounds.rect_.height_ = 2772; - float rotation = 90; float scaleX = 1.0; float scaleY = 1.0; + ScreenDirectionInfo directionInfo; + directionInfo.notifyRotation_ = 90; + directionInfo.screenRotation_ = 90; + directionInfo.rotation_ = 90; ScreenPropertyChangeType screenPropertyChangeType = ScreenPropertyChangeType::ROTATION_BEGIN; - screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, rotation, + screenSessionManagerClient_->UpdateScreenRotationProperty(screenId, bounds, directionInfo, screenPropertyChangeType); screenSessionManagerClient_->SetDisplayNodeScreenId(screenId, displayNodeScreenId); screenSessionManagerClient_->GetPhyScreenProperty(screenId); diff --git a/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp b/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp index beb883f23b..f09760bb4a 100644 --- a/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_manager_stub_test.cpp @@ -2873,6 +2873,27 @@ HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest134, Function | SmallTest int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + +/** + * @tc.name: OnRemoteRequest135 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest135, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteUint64(0); + data.WriteFloat(0); + data.WriteFloat(0); + uint32_t code = static_cast( + DisplayManagerMessage::TRANS_ID_UPDATE_SCREEN_DIRECTION_INFO); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} } } } \ No newline at end of file diff --git a/window_scene/test/dms_unittest/screen_session_test.cpp b/window_scene/test/dms_unittest/screen_session_test.cpp index ed09d28949..e50443737f 100644 --- a/window_scene/test/dms_unittest/screen_session_test.cpp +++ b/window_scene/test/dms_unittest/screen_session_test.cpp @@ -383,6 +383,47 @@ HWTEST_F(ScreenSessionTest, GetVirtualScreenFlag, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "GetVirtualScreenFlag end"; } +/** + * @tc.name: SetPhysicalRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SetPhysicalRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "SetPhysicalRotation start"; + ScreenSessionConfig config = { + .screenId = 100, + .rsId = 101, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); + EXPECT_NE(nullptr, screenSession); + int rotation = 0; + FoldStatus foldStatus = FoldStatus::UNKNOWN; + screenSession->SetPhysicalRotation(rotation, foldStatus); + GTEST_LOG_(INFO) << "SetPhysicalRotation end"; +} + +/** + * @tc.name: SetScreenComponentRotation + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionTest, SetScreenComponentRotation, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "SetScreenComponentRotation start"; + ScreenSessionConfig config = { + .screenId = 100, + .rsId = 101, + .name = "OpenHarmony", + }; + sptr screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL); + EXPECT_NE(nullptr, screenSession); + int rotation = 0; + screenSession->SetScreenComponentRotation(rotation); + GTEST_LOG_(INFO) << "SetScreenComponentRotation end"; +} + /** * @tc.name: UpdateToInputManager * @tc.desc: normal function diff --git a/window_scene/test/mock/mock_ibundle_mgr.h b/window_scene/test/mock/mock_ibundle_mgr.h index f9a60e1d8b..2c27c891f7 100644 --- a/window_scene/test/mock/mock_ibundle_mgr.h +++ b/window_scene/test/mock/mock_ibundle_mgr.h @@ -23,6 +23,7 @@ namespace OHOS::AppExecFwk { class IBundleMgr; struct ApplicationInfo; enum ApplicationFlag; +struct BundleInfo; } // namespace OHOS::AppExecFwk namespace OHOS { @@ -36,6 +37,8 @@ public: const int32_t userId, std::vector& appInfos)); MOCK_METHOD4(GetApplicationInfo, bool(const std::string& appName, const AppExecFwk::ApplicationFlag flag, const int32_t userId, AppExecFwk::ApplicationInfo& appInfo)); + MOCK_METHOD4(GetBundleInfoV9, ErrCode(const std::string& bundleName, int32_t flags, + AppExecFwk::BundleInfo& bundleInfo, int32_t userId)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/extension_session_test.cpp b/window_scene/test/unittest/extension_session_test.cpp index dacc34ea36..ff6aa89d3a 100644 --- a/window_scene/test/unittest/extension_session_test.cpp +++ b/window_scene/test/unittest/extension_session_test.cpp @@ -900,6 +900,31 @@ HWTEST_F(ExtensionSessionTest, NotifyDumpInfo, Function | SmallTest | Level1) res = extensionSession_->NotifyDumpInfo(params, info); ASSERT_EQ(WSError::WS_ERROR_NULLPTR, res); } + +/** + * @tc.name: GetStatusBarHeight + * @tc.desc: test function : GetStatusBarHeight + * @tc.type: FUNC + */ +HWTEST_F(ExtensionSessionTest, GetStatusBarHeight, Function | SmallTest | Level1) +{ + ASSERT_NE(nullptr, extSessionEventCallback_); + MockFunction mockGetStatusBarHeightFunc; + extSessionEventCallback_->getStatusBarHeightFunc_ = mockGetStatusBarHeightFunc.AsStdFunction(); + extensionSession_->RegisterExtensionSessionEventCallback(extSessionEventCallback_); + EXPECT_CALL(mockGetStatusBarHeightFunc, Call()).Times(1); + extensionSession_->GetStatusBarHeight(); + + extSessionEventCallback_->getStatusBarHeightFunc_ = nullptr; + extensionSession_->RegisterExtensionSessionEventCallback(extSessionEventCallback_); + EXPECT_CALL(mockGetStatusBarHeightFunc, Call()).Times(0); + extensionSession_->GetStatusBarHeight(); + + extSessionEventCallback_ = nullptr; + extensionSession_->RegisterExtensionSessionEventCallback(extSessionEventCallback_); + EXPECT_CALL(mockGetStatusBarHeightFunc, Call()).Times(0); + extensionSession_->GetStatusBarHeight(); +} } } } \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_lifecycle_test.cpp b/window_scene/test/unittest/scene_session_lifecycle_test.cpp index 80d142232b..f4ba49a12f 100644 --- a/window_scene/test/unittest/scene_session_lifecycle_test.cpp +++ b/window_scene/test/unittest/scene_session_lifecycle_test.cpp @@ -1195,9 +1195,9 @@ HWTEST_F(SceneSessionLifecycleTest, NotifySessionExceptionInner, Function | Smal res = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, needRemoveSession, false); ASSERT_EQ(res, WSError::WS_OK); - sceneSession->sessionExceptionFunc_ = std::make_shared(); + sceneSession->sessionExceptionFunc_ = [](const SessionInfo& info, bool removeSession, bool startFail) {}; ASSERT_NE(nullptr, sceneSession->sessionExceptionFunc_); - sceneSession->jsSceneSessionExceptionFunc_ = std::make_shared(); + sceneSession->jsSceneSessionExceptionFunc_ = [](const SessionInfo& info, bool removeSession, bool startFail) {}; ASSERT_NE(nullptr, sceneSession->jsSceneSessionExceptionFunc_); res = sceneSession->NotifySessionExceptionInner(abilitySessionInfo, needRemoveSession, false); ASSERT_EQ(res, WSError::WS_OK); diff --git a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp index 990b7f7993..70b71b72f0 100644 --- a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp @@ -198,6 +198,11 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { { return nullptr; } + WMError CheckUIExtensionCreation(int32_t windowId, uint32_t tokenId, + const AppExecFwk::ElementName& element, int32_t& pid) override + { + return WMError::WM_OK; + } }; class SceneSessionManagerLiteStubTest : public testing::Test { diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index f510bf462a..ce399aaab5 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -504,10 +504,10 @@ HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions, Function | Small sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->SetCollaboratorType(CollaboratorType::DEFAULT_TYPE); - NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { + sceneSession->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { ssm_->sceneSessionMap_.erase(info.persistentId_); - }; - sceneSession->SetTerminateSessionListenerNew(callback); + }); + usleep(WAIT_SYNC_IN_NS); ssm_->sceneSessionMap_.insert({persistentId, sceneSession}); ssm_->ClearAllCollaboratorSessions(); ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], sceneSession); @@ -530,10 +530,10 @@ HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions02, Function | Sma sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->SetCollaboratorType(CollaboratorType::RESERVE_TYPE); - NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { + sceneSession->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { ssm_->sceneSessionMap_.erase(info.persistentId_); - }; - sceneSession->SetTerminateSessionListenerNew(callback); + }); + usleep(WAIT_SYNC_IN_NS); ssm_->sceneSessionMap_.insert({persistentId, sceneSession}); ssm_->ClearAllCollaboratorSessions(); ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], nullptr); @@ -556,10 +556,10 @@ HWTEST_F(SceneSessionManagerTest, ClearAllCollaboratorSessions03, Function | Sma sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); sceneSession->SetCollaboratorType(CollaboratorType::OTHERS_TYPE); - NotifyTerminateSessionFuncNew callback = [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { + sceneSession->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) { ssm_->sceneSessionMap_.erase(info.persistentId_); - }; - sceneSession->SetTerminateSessionListenerNew(callback); + }); + usleep(WAIT_SYNC_IN_NS); ssm_->sceneSessionMap_.insert({persistentId, sceneSession}); ssm_->ClearAllCollaboratorSessions(); ASSERT_EQ(ssm_->sceneSessionMap_[persistentId], nullptr); diff --git a/window_scene/test/unittest/scene_session_manager_test11.cpp b/window_scene/test/unittest/scene_session_manager_test11.cpp index 2abff7405f..eccc5113ea 100644 --- a/window_scene/test/unittest/scene_session_manager_test11.cpp +++ b/window_scene/test/unittest/scene_session_manager_test11.cpp @@ -285,6 +285,123 @@ HWTEST_F(SceneSessionManagerTest11, GetAllSessionDumpDetailInfo, Function | Smal std::string dumpInfo; ASSERT_EQ(ssm_->GetAllSessionDumpDetailInfo(dumpInfo), WSError::WS_OK); } + +/** + * @tc.name: GetAbilityInfo + * @tc.desc: SceneSesionManager test GetAbilityInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo, Function | SmallTest | Level1) +{ + ssm_->bundleMgr_ = nullptr; + std::string bundleName = "bundleName"; + std::string moduleName = "moduleName"; + std::string abilityName = "abilityName"; + int32_t userId = 100; + SCBAbilityInfo scbAbilityInfo; + WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo); + ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR); +} + +/** + * @tc.name: GetAbilityInfo02 + * @tc.desc: SceneSesionManager test GetAbilityInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo02, Function | SmallTest | Level1) +{ + sptr bundleMgrMocker = sptr::MakeSptr(); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce(Return(1)); + ssm_->bundleMgr_ = bundleMgrMocker; + std::string bundleName = "bundleName"; + std::string moduleName = "moduleName"; + std::string abilityName = "abilityName"; + int32_t userId = 100; + SCBAbilityInfo scbAbilityInfo; + WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo); + ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM); +} + +/** + * @tc.name: GetAbilityInfo03 + * @tc.desc: SceneSesionManager test GetAbilityInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo03, Function | SmallTest | Level1) +{ + sptr bundleMgrMocker = sptr::MakeSptr(); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([]( + const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { + bundleInfo.hapModuleInfos = {}; + return 0; + }); + ssm_->bundleMgr_ = bundleMgrMocker; + std::string bundleName = "bundleName"; + std::string moduleName = "moduleName"; + std::string abilityName = "abilityName"; + int32_t userId = 100; + SCBAbilityInfo scbAbilityInfo; + WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo); + ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM); +} + +/** + * @tc.name: GetAbilityInfo04 + * @tc.desc: SceneSesionManager test GetAbilityInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo04, Function | SmallTest | Level1) +{ + sptr bundleMgrMocker = sptr::MakeSptr(); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([]( + const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { + AppExecFwk::AbilityInfo abilityInfo; + abilityInfo.moduleName = "moduleName"; + abilityInfo.name = "abilityName"; + AppExecFwk::HapModuleInfo hapModuleInfo; + hapModuleInfo.abilityInfos = { abilityInfo }; + bundleInfo.hapModuleInfos = { hapModuleInfo }; + bundleInfo.applicationInfo.codePath = "testCodePath"; + return 0; + }); + ssm_->bundleMgr_ = bundleMgrMocker; + std::string bundleName = "bundleName"; + std::string moduleName = "moduleName"; + std::string abilityName = "abilityName"; + int32_t userId = 100; + SCBAbilityInfo scbAbilityInfo; + WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo); + ASSERT_EQ(ret, WSError::WS_OK); + ASSERT_EQ(scbAbilityInfo.codePath_, "testCodePath"); +} + +/** + * @tc.name: GetAbilityInfo05 + * @tc.desc: SceneSesionManager test GetAbilityInfo + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest11, GetAbilityInfo05, Function | SmallTest | Level1) +{ + sptr bundleMgrMocker = sptr::MakeSptr(); + EXPECT_CALL(*bundleMgrMocker, GetBundleInfoV9(_, _, _, _)).WillOnce([]( + const std::string& bundleName, int32_t flags, AppExecFwk::BundleInfo& bundleInfo, int32_t userId) { + AppExecFwk::AbilityInfo abilityInfo; + abilityInfo.moduleName = "moduleName2"; + abilityInfo.name = "abilityName2"; + AppExecFwk::HapModuleInfo hapModuleInfo; + hapModuleInfo.abilityInfos = { abilityInfo }; + bundleInfo.hapModuleInfos = { hapModuleInfo }; + return 0; + }); + ssm_->bundleMgr_ = bundleMgrMocker; + std::string bundleName = "bundleName"; + std::string moduleName = "moduleName"; + std::string abilityName = "abilityName"; + int32_t userId = 100; + SCBAbilityInfo scbAbilityInfo; + WSError ret = ssm_->GetAbilityInfo(bundleName, moduleName, abilityName, userId, scbAbilityInfo); + ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_PARAM); +} } // namespace } } \ No newline at end of file diff --git a/window_scene/test/unittest/scene_session_manager_test2.cpp b/window_scene/test/unittest/scene_session_manager_test2.cpp index a871bd021d..825f34a049 100644 --- a/window_scene/test/unittest/scene_session_manager_test2.cpp +++ b/window_scene/test/unittest/scene_session_manager_test2.cpp @@ -507,7 +507,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor01, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, static_cast(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN)); } @@ -525,7 +525,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor02, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); } @@ -544,7 +544,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor03, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); } @@ -563,7 +563,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor04, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_PIP); } @@ -582,7 +582,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor05, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); } @@ -602,7 +602,7 @@ HWTEST_F(SceneSessionManagerTest2, ConfigDecor06, Function | SmallTest | Level3) ""; WindowSceneConfig::config_ = ReadConfig(xmlStr); ssm_->ConfigWindowSceneXml(); - ASSERT_EQ(ssm_->systemConfig_.decorModeSupportInfo_, + ASSERT_EQ(ssm_->systemConfig_.decorWindowModeSupportType_, WINDOW_MODE_SUPPORT_ALL); } diff --git a/window_scene/test/unittest/scene_session_manager_test3.cpp b/window_scene/test/unittest/scene_session_manager_test3.cpp index e10dbbfcce..aa0eff850e 100644 --- a/window_scene/test/unittest/scene_session_manager_test3.cpp +++ b/window_scene/test/unittest/scene_session_manager_test3.cpp @@ -1369,7 +1369,7 @@ HWTEST_F(SceneSessionManagerTest3, HandleHideNonSystemFloatingWindows, Function property->SetFloatingWindowAppType(true); ssm_->UpdateForceHideState(sceneSession, property, true); ssm_->UpdateForceHideState(sceneSession, property, false); - uint32_t result = property->GetModeSupportInfo(); + uint32_t result = property->GetWindowModeSupportType(); ASSERT_EQ(result, WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); } diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index 9923523181..d81e30436e 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -772,7 +772,6 @@ HWTEST_F(SceneSessionManagerTest4, GetProcessDrawingState, Function | SmallTest ASSERT_NE(nullptr, ssm_); uint64_t windowId = 10; int32_t pid = 1; - bool currentDrawingContentState = true; SessionInfo info; info.abilityName_ = "SetBrightness"; sptr sceneSession01 = nullptr; @@ -793,7 +792,7 @@ HWTEST_F(SceneSessionManagerTest4, GetProcessDrawingState, Function | SmallTest sceneSession03->SetCallingPid(pid); sceneSession03->surfaceNode_ = nullptr; sceneSession04->SetCallingPid(6); - auto result = ssm_->GetProcessDrawingState(windowId, pid, currentDrawingContentState); + auto result = ssm_->GetProcessDrawingState(windowId, pid); EXPECT_EQ(result, true); } @@ -807,7 +806,7 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes ASSERT_NE(nullptr, ssm_); uint64_t surfaceId = 0; int32_t pid = 10; - bool result = ssm_->GetPreWindowDrawingState(surfaceId, pid, true); + bool result = ssm_->GetPreWindowDrawingState(surfaceId, true, pid); EXPECT_EQ(result, false); SessionInfo info; @@ -820,7 +819,7 @@ HWTEST_F(SceneSessionManagerTest4, GetPreWindowDrawingState, Function | SmallTes ASSERT_NE(sceneSession01->surfaceNode_, nullptr); sceneSession01->surfaceNode_->id_ = 10; surfaceId = 10; - result = ssm_->GetPreWindowDrawingState(surfaceId, pid, true); + result = ssm_->GetPreWindowDrawingState(surfaceId, true, pid); EXPECT_EQ(result, false); } @@ -858,6 +857,28 @@ HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo, Function | EXPECT_NE(result, currDrawingContentData); } +/** + * @tc.name: GetWindowDrawingContentChangeInfo02 + * @tc.desc: GetWindowDrawingContentChangeInfo02 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest4, GetWindowDrawingContentChangeInfo02, Function | SmallTest | Level3) +{ + ASSERT_NE(nullptr, ssm_); + SessionInfo info; + info.abilityName_ = "GetWindowDrawingContentChangeInfo02"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + ASSERT_NE(sceneSession, nullptr); + ssm_->sceneSessionMap_.insert(std::make_pair(0, nullptr)); + + std::vector> currDrawingContentData; + currDrawingContentData.push_back(std::make_pair(0, false)); + currDrawingContentData.push_back(std::make_pair(1, true)); + + auto result = ssm_->GetWindowDrawingContentChangeInfo(currDrawingContentData); + EXPECT_EQ(result, currDrawingContentData); +} + /** * @tc.name: DealwithDrawingContentChange * @tc.desc: DealwithDrawingContentChange diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index 643bad6b35..60fe330ad0 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -243,6 +243,29 @@ HWTEST_F(SceneSessionManagerTest6, GetWindowVisibilityChangeInfo03, Function | S ASSERT_EQ(visibilityChangeInfos[0].first, 2); } +/** + * @tc.name: GetWindowVisibilityChangeInfo04 + * @tc.desc: GetWindowVisibilityChangeInfo04 + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest6, GetWindowVisibilityChangeInfo04, Function | SmallTest | Level3) +{ + ASSERT_NE(nullptr, ssm_); + ssm_->lastVisibleData_.clear(); + std::vector> currVisibleData; + std::vector> visibilityChangeInfos; + ssm_->lastVisibleData_.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_NO_OCCLUSION)); + currVisibleData.push_back(std::make_pair(0, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION)); + currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION)); + visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData); + ASSERT_EQ(visibilityChangeInfos.size(), 1); + + currVisibleData.clear(); + currVisibleData.push_back(std::make_pair(1, WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION)); + visibilityChangeInfos = ssm_->GetWindowVisibilityChangeInfo(currVisibleData); + ASSERT_EQ(visibilityChangeInfos.size(), 0); +} + /** * @tc.name: DealwithVisibilityChange01 * @tc.desc: DealwithVisibilityChange01 diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index a2415eb254..9e3570f82f 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -1743,8 +1743,8 @@ HWTEST_F(SceneSessionTest2, OnMoveDragCallback02, Function | SmallTest | Level2) sceneSession->TerminateSession(abilitySessionInfo); bool needRemoveSession = true; - session.sessionExceptionFunc_ = std::make_shared(); - session.jsSceneSessionExceptionFunc_ = std::make_shared(); + session.sessionExceptionFunc_ = [](const SessionInfo& info, bool removeSession, bool startFail) {}; + session.jsSceneSessionExceptionFunc_ = [](const SessionInfo& info, bool removeSession, bool startFail) {}; sceneSession->NotifySessionException(abilitySessionInfo, needRemoveSession); sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); @@ -2030,10 +2030,7 @@ HWTEST_F(SceneSessionTest2, SetWindowAnimationFlag, Function | SmallTest | Level sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); EXPECT_NE(sceneSession, nullptr); - sceneSession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); - EXPECT_NE(sceneSession->sessionChangeCallback_, nullptr); - sceneSession->sessionChangeCallback_->onWindowAnimationFlagChange_ = []( - bool isNeedDefaultAnimationFlag) {}; + sceneSession->onWindowAnimationFlagChange_ = [](bool isNeedDefaultAnimationFlag) {}; sceneSession->SetWindowAnimationFlag(true); ASSERT_EQ(true, sceneSession->needDefaultAnimationFlag_); } diff --git a/window_scene/test/unittest/scene_session_test3.cpp b/window_scene/test/unittest/scene_session_test3.cpp index bab227a393..dccbfcee0d 100644 --- a/window_scene/test/unittest/scene_session_test3.cpp +++ b/window_scene/test/unittest/scene_session_test3.cpp @@ -457,19 +457,27 @@ HWTEST_F(SceneSessionTest3, UpdateScaleInner, Function | SmallTest | Level2) EXPECT_NE(nullptr, sceneSession); sceneSession->sessionStage_ = nullptr; + sceneSession->state_ = SessionState::STATE_FOREGROUND; bool res = sceneSession->UpdateScaleInner(10.0f, 10.0f, 10.0f, 10.0f); EXPECT_EQ(true, res); + res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 10.0f, 10.0f); res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 9.0f, 10.0f); res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 9.0f, 9.0f); EXPECT_EQ(true, res); + + sceneSession->state_ = SessionState::STATE_BACKGROUND; res = sceneSession->UpdateScaleInner(10.0f, 9.0f, 9.0f, 9.0f); EXPECT_EQ(false, res); + + sceneSession->state_ = SessionState::STATE_FOREGROUND; sptr mockSessionStage = sptr::MakeSptr(); ASSERT_NE(mockSessionStage, nullptr); sceneSession->sessionStage_ = mockSessionStage; res = sceneSession->UpdateScaleInner(1.0f, 2.0f, 3.0f, 4.0f); EXPECT_EQ(true, res); + res = sceneSession->UpdateScaleInner(1.0f, 2.0f, 3.0f, 4.0f); + EXPECT_EQ(false, res); } /** diff --git a/window_scene/test/unittest/scene_session_test4.cpp b/window_scene/test/unittest/scene_session_test4.cpp index 555dec323c..594b3b21e0 100644 --- a/window_scene/test/unittest/scene_session_test4.cpp +++ b/window_scene/test/unittest/scene_session_test4.cpp @@ -1148,10 +1148,7 @@ HWTEST_F(SceneSessionTest4, TerminateSession01, Function | SmallTest | Level2) ASSERT_EQ(WSError::WS_OK, sceneSession->TerminateSession(abilitySessionInfo)); sceneSession->isTerminating_ = false; - NotifyTerminateSessionFunc func = [sceneSession](const SessionInfo& info) { - return; - }; - sceneSession->SetTerminateSessionListener(func); + sceneSession->SetTerminateSessionListener([sceneSession](const SessionInfo& info) {}); ASSERT_EQ(WSError::WS_OK, sceneSession->TerminateSession(abilitySessionInfo)); } diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 327bddea8c..45aece8ee8 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -333,7 +333,7 @@ HWTEST_F(SceneSessionTest5, TransferPointerEvent01, Function | SmallTest | Level session->moveDragController_ = sptr::MakeSptr(2024, session->GetWindowType()); SystemSessionConfig systemConfig; systemConfig.isSystemDecorEnable_ = false; - systemConfig.decorModeSupportInfo_ = 2; + systemConfig.decorWindowModeSupportType_ = 2; session->SetSystemConfig(systemConfig); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, session->TransferPointerEvent(pointerEvent, false)); @@ -789,7 +789,7 @@ HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level SystemSessionConfig systemConfig; systemConfig.isSystemDecorEnable_ = true; - systemConfig.decorModeSupportInfo_ = 2; + systemConfig.decorWindowModeSupportType_ = 2; session->SetSystemConfig(systemConfig); EXPECT_EQ(true, session->FixRectByAspectRatio(rect)); @@ -1089,19 +1089,15 @@ HWTEST_F(SceneSessionTest5, UpdateWindowAnimationFlag, Function | SmallTest | Le sptr session = sptr::MakeSptr(info, nullptr); EXPECT_NE(session, nullptr); - sptr sessionChangeCallback = - sptr::MakeSptr(); - session->RegisterSessionChangeCallback(nullptr); EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true)); - sessionChangeCallback->onWindowAnimationFlagChange_ = nullptr; - session->RegisterSessionChangeCallback(sessionChangeCallback); + session->onWindowAnimationFlagChange_ = nullptr; EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true)); NotifyWindowAnimationFlagChangeFunc func = [](const bool flag) { return; }; - sessionChangeCallback->onWindowAnimationFlagChange_ = func; + session->onWindowAnimationFlagChange_ = func; EXPECT_EQ(WSError::WS_OK, session->UpdateWindowAnimationFlag(true)); } @@ -1305,27 +1301,27 @@ HWTEST_F(SceneSessionTest5, SetUniqueDensityDpi, Function | SmallTest | Level2) } /** - * @tc.name: HandleActionUpdateModeSupportInfo - * @tc.desc: HandleActionUpdateModeSupportInfo function01 + * @tc.name: HandleActionUpdateWindowModeSupportType + * @tc.desc: HandleActionUpdateWindowModeSupportType function01 * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest5, HandleActionUpdateModeSupportInfo, Function | SmallTest | Level2) +HWTEST_F(SceneSessionTest5, HandleActionUpdateWindowModeSupportType, Function | SmallTest | Level2) { SessionInfo info; - info.abilityName_ = "HandleActionUpdateModeSupportInfo"; - info.bundleName_ = "HandleActionUpdateModeSupportInfo"; + info.abilityName_ = "HandleActionUpdateWindowModeSupportType"; + info.bundleName_ = "HandleActionUpdateWindowModeSupportType"; sptr session = sptr::MakeSptr(info, nullptr); ASSERT_NE(session, nullptr); sptr property = sptr::MakeSptr(); property->isSystemCalling_ = true; ASSERT_NE(session, nullptr); session->SetSessionProperty(nullptr); - ASSERT_EQ(WMError::WM_OK, session->HandleActionUpdateModeSupportInfo(property, + ASSERT_EQ(WMError::WM_OK, session->HandleActionUpdateWindowModeSupportType(property, WSPropertyChangeAction::ACTION_UPDATE_RECT)); property->isSystemCalling_ = false; session->SetSessionProperty(property); - ASSERT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, session->HandleActionUpdateModeSupportInfo(property, + ASSERT_EQ(WMError::WM_ERROR_NOT_SYSTEM_APP, session->HandleActionUpdateWindowModeSupportType(property, WSPropertyChangeAction::ACTION_UPDATE_RECT)); } diff --git a/window_scene/test/unittest/session_lifecycle_test.cpp b/window_scene/test/unittest/session_lifecycle_test.cpp index a2cdc22d8f..41a9dc02de 100644 --- a/window_scene/test/unittest/session_lifecycle_test.cpp +++ b/window_scene/test/unittest/session_lifecycle_test.cpp @@ -361,15 +361,11 @@ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionNew01, Function | SmallTest */ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionNew02, Function | SmallTest | Level2) { - NotifyTerminateSessionFuncNew callback = - [](const SessionInfo& info, bool needStartCaller, bool isFromBroker) - { - }; - bool needStartCaller = true; bool isFromBroker = true; sptr info = new (std::nothrow)AAFwk::SessionInfo(); - session_->SetTerminateSessionListenerNew(callback); + session_->SetTerminateSessionListenerNew([](const SessionInfo& info, bool needStartCaller, bool isFromBroker) {}); + usleep(WAIT_SYNC_IN_NS); auto result = session_->TerminateSessionNew(info, needStartCaller, isFromBroker); EXPECT_EQ(result, WSError::WS_OK); } @@ -570,8 +566,7 @@ HWTEST_F(WindowSessionLifecycleTest, TerminateSessionTotal03, Function | SmallTe ASSERT_NE(session_, nullptr); sptr abilitySessionInfo = new AAFwk::SessionInfo(); session_->isTerminating_ = false; - NotifyTerminateSessionFuncTotal func = nullptr; - session_->SetTerminateSessionListenerTotal(func); + session_->SetTerminateSessionListenerTotal(nullptr); ASSERT_EQ(WSError::WS_OK, session_->TerminateSessionTotal(abilitySessionInfo, TerminateType::CLOSE_AND_KEEP_MULTITASK)); } diff --git a/window_scene/test/unittest/session_listener_controller_test.cpp b/window_scene/test/unittest/session_listener_controller_test.cpp index f165f1636b..860b4fefc1 100644 --- a/window_scene/test/unittest/session_listener_controller_test.cpp +++ b/window_scene/test/unittest/session_listener_controller_test.cpp @@ -368,6 +368,8 @@ HWTEST_F(SessionListenerControllerTest, OnListenerDied, Function | SmallTest | L */ HWTEST_F(SessionListenerControllerTest, NotifySessionIconChanged, Function | SmallTest | Level2) { +#ifndef SUPPORT_GRAPHICS +#define SUPPORT_GRAPHICS int32_t persistentId = -1; int32_t pixelMapWidth = 4; @@ -380,13 +382,20 @@ HWTEST_F(SessionListenerControllerTest, NotifySessionIconChanged, Function | Sma pixelMap->SetImageInfo(info); std::shared_ptr icon = std::move(pixelMap); slController->NotifySessionIconChanged(persistentId, icon); + sptr myListener = new MyMissionListener(); + EXPECT_NE(myListener, nullptr); + bool res = myListener->IsMissionIconUpdated(); + EXPECT_EQ(res, false); persistentId = 1; + sptr listener = new MyMissionListener(); + EXPECT_NE(listener, nullptr); + slController->sessionListeners_.push_back(listener); slController->NotifySessionIconChanged(persistentId, icon); - ASSERT_EQ(persistentId, 1); - - slController->NotifySessionIconChanged(persistentId, icon); - EXPECT_EQ(1, persistentId); + res = myListener->IsMissionIconUpdated(); + EXPECT_EQ(res, true); + slController->sessionListeners_.clear(); +#endif } /** diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index e946b40a68..c9f652dc9f 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -708,7 +708,7 @@ HWTEST_F(WindowSessionTest, ConsumeDragEvent02, Function | SmallTest | Level2) SystemSessionConfig sessionConfig; sessionConfig.isSystemDecorEnable_ = true; sessionConfig.backgroundswitch = true; - sessionConfig.decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + sessionConfig.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); ASSERT_TRUE(pointerEvent); pointerEvent->SetAgentWindowId(1); @@ -770,7 +770,7 @@ HWTEST_F(WindowSessionTest, ConsumeDragEvent03, Function | SmallTest | Level2) SystemSessionConfig sessionConfig; sessionConfig.isSystemDecorEnable_ = true; sessionConfig.backgroundswitch = true; - sessionConfig.decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + sessionConfig.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); ASSERT_TRUE(pointerEvent); pointerEvent->SetAgentWindowId(1); @@ -829,7 +829,7 @@ HWTEST_F(WindowSessionTest, ConsumeDragEvent04, Function | SmallTest | Level2) SystemSessionConfig sessionConfig; sessionConfig.isSystemDecorEnable_ = true; sessionConfig.backgroundswitch = true; - sessionConfig.decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + sessionConfig.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; std::shared_ptr pointerEvent = MMI::PointerEvent::Create(); ASSERT_TRUE(pointerEvent); pointerEvent->SetAgentWindowId(1); @@ -1209,8 +1209,7 @@ HWTEST_F(WindowSessionTest, SetTerminateSessionListener, Function | SmallTest | { ASSERT_NE(session_, nullptr); session_->state_ = SessionState::STATE_DISCONNECT; - NotifyTerminateSessionFunc func = nullptr; - session_->SetTerminateSessionListener(func); + session_->SetTerminateSessionListener(nullptr); ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false)); } @@ -1224,8 +1223,7 @@ HWTEST_F(WindowSessionTest, SetTerminateSessionListenerTotal, Function | SmallTe { ASSERT_NE(session_, nullptr); session_->state_ = SessionState::STATE_DISCONNECT; - NotifyTerminateSessionFuncTotal func = nullptr; - session_->SetTerminateSessionListenerTotal(func); + session_->SetTerminateSessionListenerTotal(nullptr); ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false)); } @@ -1268,8 +1266,7 @@ HWTEST_F(WindowSessionTest, SetPendingSessionToForegroundListener, Function | Sm { ASSERT_NE(session_, nullptr); session_->state_ = SessionState::STATE_DISCONNECT; - NotifyPendingSessionToForegroundFunc func = nullptr; - session_->SetPendingSessionToForegroundListener(func); + session_->SetPendingSessionToForegroundListener(nullptr); ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false)); } diff --git a/window_scene/test/unittest/session_test2.cpp b/window_scene/test/unittest/session_test2.cpp index 6227b57d11..ac1f38421d 100644 --- a/window_scene/test/unittest/session_test2.cpp +++ b/window_scene/test/unittest/session_test2.cpp @@ -2019,16 +2019,14 @@ HWTEST_F(WindowSessionTest2, UpdateSizeChangeReason, Function | SmallTest | Leve HWTEST_F(WindowSessionTest2, SetPendingSessionActivationEventListener, Function | SmallTest | Level2) { int resultValue = 0; - NotifyPendingSessionActivationFunc callback = [&resultValue](const SessionInfo& info) { + session_->SetPendingSessionActivationEventListener([&resultValue](const SessionInfo& info) { resultValue = 1; - }; - - sptr info = new (std::nothrow)AAFwk::SessionInfo(); - session_->SetPendingSessionActivationEventListener(callback); - NotifyTerminateSessionFunc callback1 = [&resultValue](const SessionInfo& info) { + }); + usleep(WAIT_SYNC_IN_NS); + session_->SetTerminateSessionListener([&resultValue](const SessionInfo& info) { resultValue = 2; - }; - session_->SetTerminateSessionListener(callback1); + }); + usleep(WAIT_SYNC_IN_NS); LifeCycleTaskType taskType = LifeCycleTaskType{0}; session_->RemoveLifeCycleTask(taskType); ASSERT_EQ(resultValue, 0); @@ -2070,10 +2068,8 @@ HWTEST_F(WindowSessionTest2, SetSessionIcon, Function | SmallTest | Level2) HWTEST_F(WindowSessionTest2, SetSessionExceptionListener, Function | SmallTest | Level2) { session_->SetSessionExceptionListener(nullptr, true); - - NotifySessionExceptionFunc func = [](const SessionInfo& info, bool needRemoveSession, bool startFail) {}; - session_->SetSessionExceptionListener(func, true); - + session_->SetSessionExceptionListener([](const SessionInfo& info, bool removeSession, bool startFail) {}, true); + usleep(WAIT_SYNC_IN_NS); ASSERT_NE(nullptr, session_->jsSceneSessionExceptionFunc_); } @@ -2198,11 +2194,13 @@ HWTEST_F(WindowSessionTest2, SetOffset, Function | SmallTest | Level2) HWTEST_F(WindowSessionTest2, SetBackPressedListenser, Function | SmallTest | Level2) { ASSERT_NE(session_, nullptr); - WLOGFI("SetBackPressedListenser begin!"); - - session_->SetBackPressedListenser(session_->backPressedFunc_); - - WLOGFI("SetBackPressedListenser end!"); + int32_t result = 0; + session_->SetBackPressedListenser([&result](const bool needMoveToBackground) { + result = 1; + }); + usleep(WAIT_SYNC_IN_NS); + session_->backPressedFunc_(true); + ASSERT_EQ(result, 1); } /** diff --git a/window_scene/test/unittest/task_scheduler_test.cpp b/window_scene/test/unittest/task_scheduler_test.cpp index 6d5c38b486..613a5e33d9 100644 --- a/window_scene/test/unittest/task_scheduler_test.cpp +++ b/window_scene/test/unittest/task_scheduler_test.cpp @@ -73,13 +73,12 @@ HWTEST_F(TaskSchedulerTest, PostTask, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "START_TASK"; resultValue = 1; }; - taskScheduler->PostAsyncTask(taskFunc); + taskScheduler->PostAsyncTask(taskFunc, "ssmTask"); EXPECT_NE(taskScheduler->handler_, nullptr); EXPECT_EQ(resultValue, 0); - std::string name = "ssmTask"; int64_t delayTime = 1; - taskScheduler->PostAsyncTask(taskFunc, name, delayTime); + taskScheduler->PostAsyncTask(taskFunc, "ssmTask", delayTime); EXPECT_EQ(resultValue, 0); } diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 3fd617e448..a47ce3380f 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -407,17 +407,17 @@ HWTEST_F(WindowSessionPropertyTest, IsDecorEnable, Function | SmallTest | Level2 } /** - * @tc.name: SetModeSupportInfo - * @tc.desc: SetModeSupportInfo test + * @tc.name: SetWindowModeSupportType + * @tc.desc: SetWindowModeSupportType test * @tc.type: FUNC */ -HWTEST_F(WindowSessionPropertyTest, SetModeSupportInfo, Function | SmallTest | Level2) +HWTEST_F(WindowSessionPropertyTest, SetWindowModeSupportType, Function | SmallTest | Level2) { - uint32_t modeSupportInfo = 1234567890; + uint32_t windowModeSupportType = 1234567890; WindowSessionProperty windowSessionProperty; - windowSessionProperty.SetModeSupportInfo(modeSupportInfo); + windowSessionProperty.SetWindowModeSupportType(windowModeSupportType); WindowSessionProperty *property = new WindowSessionProperty(); - ASSERT_NE(property->GetModeSupportInfo(), 0); + ASSERT_NE(property->GetWindowModeSupportType(), 0); } /** diff --git a/wm/include/screen_scene.h b/wm/include/screen_scene.h index ed76920c45..6e5b43650f 100644 --- a/wm/include/screen_scene.h +++ b/wm/include/screen_scene.h @@ -76,15 +76,11 @@ public: return 1; // 1 for root and screen } - Ace::UIContent* GetUIContent() const override - { - return uiContent_.get(); - } - + Ace::UIContent* GetUIContent() const override; WMError Destroy() override; private: - std::mutex mutex_; + mutable std::mutex mutex_; std::unique_ptr uiContent_; float density_ = 1.0f; int32_t orientation_; diff --git a/wm/include/window_agent.h b/wm/include/window_agent.h index e34e9848cc..eeb16092da 100644 --- a/wm/include/window_agent.h +++ b/wm/include/window_agent.h @@ -30,7 +30,7 @@ public: WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; WMError UpdateWindowMode(WindowMode mode) override; - WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override; + WMError UpdateWindowModeSupportType(uint32_t windowModeSupportType) override; WMError UpdateFocusStatus(bool focused) override; WMError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; WMError UpdateWindowState(WindowState state) override; diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index bceac35e9d..e0bda5fb94 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -133,7 +133,7 @@ public: virtual uint32_t GetWindowId() const override; uint64_t GetDisplayId() const override; virtual uint32_t GetWindowFlags() const override; - uint32_t GetRequestModeSupportInfo() const override; + uint32_t GetRequestWindowModeSupportType() const override; bool IsMainHandlerAvailable() const override; inline NotifyNativeWinDestroyFunc GetNativeDestroyCallback() { @@ -240,13 +240,13 @@ public: virtual void RegisterDialogDeathRecipientListener(const sptr& listener) override; virtual void UnregisterDialogDeathRecipientListener(const sptr& listener) override; virtual void SetAceAbilityHandler(const sptr& handler) override; - virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override; + virtual void SetRequestWindowModeSupportType(uint32_t windowModeSupportType) override; void UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr); void ScheduleUpdateRectTask(const Rect& rectToAce, const Rect& lastOriRect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction, const sptr& display); void UpdateMode(WindowMode mode); - void UpdateModeSupportInfo(uint32_t modeSupportInfo); + void UpdateWindowModeSupportType(uint32_t windowModeSupportType); virtual void ConsumeKeyEvent(std::shared_ptr& inputEvent) override; virtual void ConsumePointerEvent(const std::shared_ptr& inputEvent) override; virtual void RequestVsync(const std::shared_ptr& vsyncCallback) override; @@ -407,8 +407,8 @@ private: bool CheckCameraFloatingWindowMultiCreated(WindowType type); void GetConfigurationFromAbilityInfo(); void UpdateTitleButtonVisibility(); - void SetModeSupportInfo(uint32_t modeSupportInfo); - uint32_t GetModeSupportInfo() const; + void SetWindowModeSupportType(uint32_t windowModeSupportType); + uint32_t GetWindowModeSupportType() const; WMError PreProcessShow(uint32_t reason, bool withAnimation); bool NeedToStopShowing(); void CalculateStartRectExceptHotZone(float virtualPixelRatio); diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 5d5ba88904..57d9c05daf 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -169,7 +169,6 @@ public: void NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo) override; virtual WMError SetImmersiveModeEnabledState(bool enable) override; virtual bool GetImmersiveModeEnabledState() const override; - uint32_t GetStatusBarHeight() override; void NotifySessionFullScreen(bool fullScreen) override; WMError GetWindowStatus(WindowStatus& windowStatus) override; bool GetIsUIExtFirstSubWindow() const override; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index f90faf70d0..501df57319 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -426,6 +426,11 @@ protected: void UpdateVirtualPixelRatio(const sptr& display); WMError GetVirtualPixelRatio(float& vpr); + /* + * Window Immersive + */ + uint32_t GetStatusBarHeight() override; + private: //Trans between colorGamut and colorSpace static ColorSpace GetColorSpaceFromSurfaceGamut(GraphicColorGamut colorGamut); @@ -493,8 +498,6 @@ private: void NotifyRotationAnimationEnd(); void SubmitNoInteractionMonitorTask(int32_t eventId, const IWindowNoInteractionListenerSptr& listener); bool IsUserOrientation(Orientation orientation) const; - void GetTitleButtonVisible(bool isPC, bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, - bool& hideCloseButton); WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config); void SetForceSplitEnable(bool isForceSplit, const std::string& homePage = ""); void SetFrameLayoutCallbackEnable(bool enable); @@ -502,6 +505,12 @@ private: bool IsNotifyInteractiveDuplicative(bool interactive); void SetUniqueVirtualPixelRatioForSub(bool useUniqueDensity, float virtualPixelRatio); + /** + * PC Window + */ + void GetTitleButtonVisible(bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, + bool& hideCloseButton); + static std::recursive_mutex lifeCycleListenerMutex_; static std::recursive_mutex windowChangeListenerMutex_; static std::recursive_mutex avoidAreaChangeListenerMutex_; diff --git a/wm/include/zidl/window_interface.h b/wm/include/zidl/window_interface.h index 6719eb75ab..f6ef5a3824 100644 --- a/wm/include/zidl/window_interface.h +++ b/wm/include/zidl/window_interface.h @@ -58,7 +58,7 @@ public: virtual WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) = 0; virtual WMError UpdateWindowMode(WindowMode mode) = 0; - virtual WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) = 0; + virtual WMError UpdateWindowModeSupportType(uint32_t windowModeSupportType) = 0; virtual WMError UpdateFocusStatus(bool focused) = 0; virtual WMError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; virtual WMError UpdateWindowState(WindowState state) = 0; diff --git a/wm/include/zidl/window_proxy.h b/wm/include/zidl/window_proxy.h index b2b81aca06..682cad5b85 100644 --- a/wm/include/zidl/window_proxy.h +++ b/wm/include/zidl/window_proxy.h @@ -32,7 +32,7 @@ public: WMError UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr) override; WMError UpdateWindowMode(WindowMode mode) override; - WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override; + WMError UpdateWindowModeSupportType(uint32_t windowModeSupportType) override; WMError UpdateFocusStatus(bool focused) override; WMError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; WMError UpdateWindowState(WindowState state) override; diff --git a/wm/src/screen_scene.cpp b/wm/src/screen_scene.cpp index 81b8cfb948..3ce873606f 100644 --- a/wm/src/screen_scene.cpp +++ b/wm/src/screen_scene.cpp @@ -201,5 +201,16 @@ void ScreenScene::SetDisplayOrientation(int32_t orientation) } orientation_ = orientation; } + +Ace::UIContent* ScreenScene::GetUIContent() const +{ + std::lock_guard lock(mutex_); + if (uiContent_) { + return uiContent_.get(); + } else { + TLOGE(WmsLogTag::DMS, "uiContent_ is nullptr!"); + return nullptr; + } +} } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_agent.cpp b/wm/src/window_agent.cpp index 5f89988eed..cc78da80c0 100644 --- a/wm/src/window_agent.cpp +++ b/wm/src/window_agent.cpp @@ -49,13 +49,13 @@ WMError WindowAgent::UpdateWindowMode(WindowMode mode) return WMError::WM_OK; } -WMError WindowAgent::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) +WMError WindowAgent::UpdateWindowModeSupportType(uint32_t windowModeSupportType) { if (window_ == nullptr) { WLOGFE("window_ is nullptr"); return WMError::WM_ERROR_NULLPTR; } - window_->UpdateModeSupportInfo(modeSupportInfo); + window_->UpdateWindowModeSupportType(windowModeSupportType); return WMError::WM_OK; } diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index cbb4b03de2..220e3c0ed1 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -365,14 +365,14 @@ uint32_t WindowImpl::GetWindowFlags() const return property_->GetWindowFlags(); } -uint32_t WindowImpl::GetRequestModeSupportInfo() const +uint32_t WindowImpl::GetRequestWindowModeSupportType() const { - return property_->GetRequestModeSupportInfo(); + return property_->GetRequestWindowModeSupportType(); } -uint32_t WindowImpl::GetModeSupportInfo() const +uint32_t WindowImpl::GetWindowModeSupportType() const { - return property_->GetModeSupportInfo(); + return property_->GetWindowModeSupportType(); } bool WindowImpl::IsMainHandlerAvailable() const @@ -434,7 +434,7 @@ WMError WindowImpl::SetWindowMode(WindowMode mode) if (!IsWindowValid()) { return WMError::WM_ERROR_INVALID_WINDOW; } - if (!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), mode)) { + if (!WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), mode)) { WLOGE("window %{public}u do not support mode: %{public}u", property_->GetWindowId(), static_cast(mode)); return WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE; @@ -640,7 +640,7 @@ WMError WindowImpl::SetUIContentInner(const std::string& contentInfo, napi_env e break; case WindowSetUIContentType::BY_ABC: auto abcContent = GetAbcContent(contentInfo); - aceRet = uiContent->Initialize(this, abcContent, storage); + aceRet = uiContent->Initialize(this, abcContent, storage, contentInfo); break; } // make uiContent available after Initialize/Restore @@ -955,7 +955,7 @@ WMError WindowImpl::SetLayoutFullScreen(bool status) { WLOGI("Window %{public}u status: %{public}u", property_->GetWindowId(), status); if (!IsWindowValid() || - !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + !WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FULLSCREEN)) { WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -1002,7 +1002,7 @@ WMError WindowImpl::SetFullScreen(bool status) { WLOGI("Window %{public}u status: %{public}d", property_->GetWindowId(), status); if (!IsWindowValid() || - !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + !WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FULLSCREEN)) { WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -1023,7 +1023,7 @@ WMError WindowImpl::SetFloatingMaximize(bool isEnter) { WLOGFI("id:%{public}d SetFloatingMaximize status: %{public}d", property_->GetWindowId(), isEnter); if (!IsWindowValid() || - !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + !WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FULLSCREEN)) { WLOGFE("invalid window or maximize mode is not be supported, winId:%{public}u", property_->GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -1147,13 +1147,13 @@ void WindowImpl::GetConfigurationFromAbilityInfo() } // get support modes configuration - uint32_t modeSupportInfo = WindowHelper::ConvertSupportModesToSupportInfo(abilityInfo->windowModes); - if (modeSupportInfo == 0) { + uint32_t windowModeSupportType = WindowHelper::ConvertSupportModesToSupportType(abilityInfo->windowModes); + if (windowModeSupportType == 0) { WLOGFD("mode config param is 0, all modes is supported"); - modeSupportInfo = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + windowModeSupportType = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; } - WLOGFD("winId: %{public}u, modeSupportInfo: %{public}u", GetWindowId(), modeSupportInfo); - SetRequestModeSupportInfo(modeSupportInfo); + WLOGFD("winId: %{public}u, windowModeSupportType: %{public}u", GetWindowId(), windowModeSupportType); + SetRequestWindowModeSupportType(windowModeSupportType); // get window size limits configuration WindowLimits sizeLimits; @@ -1187,12 +1187,12 @@ void WindowImpl::UpdateTitleButtonVisibility() if (uiContent_ == nullptr || !IsDecorEnable()) { return; } - auto modeSupportInfo = GetModeSupportInfo(); - bool hideSplitButton = !(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + auto windowModeSupportType = GetWindowModeSupportType(); + bool hideSplitButton = !(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); // not support fullscreen in split and floating mode, or not support float in fullscreen mode - bool hideMaximizeButton = (!(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && + bool hideMaximizeButton = (!(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && (GetMode() == WindowMode::WINDOW_MODE_FLOATING || WindowHelper::IsSplitWindowMode(GetMode()))) || - (!(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) && + (!(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) && GetMode() == WindowMode::WINDOW_MODE_FULLSCREEN); WLOGD("[Client] [hideSplit, hideMaximize]: [%{public}d, %{public}d]", hideSplitButton, hideMaximizeButton); uiContent_->HideWindowTitleButton(hideSplitButton, hideMaximizeButton, false, false); @@ -1587,10 +1587,11 @@ bool WindowImpl::NeedToStopShowing() } // show failed when current mode is not support or window only supports split mode and can show when locked bool isShowWhenLocked = GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED); - if (!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), GetMode()) || - WindowHelper::IsOnlySupportSplitAndShowWhenLocked(isShowWhenLocked, GetModeSupportInfo())) { - WLOGFE("current mode is not supported, windowId: %{public}u, modeSupportInfo: %{public}u, winMode: %{public}u", - property_->GetWindowId(), GetModeSupportInfo(), GetMode()); + if (!WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), GetMode()) || + WindowHelper::IsOnlySupportSplitAndShowWhenLocked(isShowWhenLocked, GetWindowModeSupportType())) { + WLOGFE("current mode is not supported, windowId: %{public}u, " + "windowModeSupportType: %{public}u, winMode: %{public}u", + property_->GetWindowId(), GetWindowModeSupportType(), GetMode()); return true; } return false; @@ -1649,7 +1650,7 @@ WMError WindowImpl::PreProcessShow(uint32_t reason, bool withAnimation) return WMError::WM_ERROR_INVALID_OPERATION; } SetDefaultOption(); - SetModeSupportInfo(GetRequestModeSupportInfo()); + SetWindowModeSupportType(GetRequestWindowModeSupportType()); AdjustWindowAnimationFlag(withAnimation); if (NeedToStopShowing()) { // true means stop showing @@ -2187,7 +2188,7 @@ WMError WindowImpl::SetImmersiveModeEnabledState(bool enable) TLOGD(WmsLogTag::WMS_IMMS, "WindowImpl id: %{public}u SetImmersiveModeEnabledState: %{public}u", property_->GetWindowId(), static_cast(enable)); if (!IsWindowValid() || - !WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + !WindowHelper::IsWindowModeSupported(GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FULLSCREEN)) { TLOGE(WmsLogTag::WMS_IMMS, "invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; @@ -2683,15 +2684,15 @@ void WindowImpl::SetAceAbilityHandler(const sptr& handler) aceAbilityHandler_ = handler; } -void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo) +void WindowImpl::SetRequestWindowModeSupportType(uint32_t windowModeSupportType) { - property_->SetRequestModeSupportInfo(modeSupportInfo); - SetModeSupportInfo(modeSupportInfo); + property_->SetRequestWindowModeSupportType(windowModeSupportType); + SetWindowModeSupportType(windowModeSupportType); } -void WindowImpl::SetModeSupportInfo(uint32_t modeSupportInfo) +void WindowImpl::SetWindowModeSupportType(uint32_t windowModeSupportType) { - property_->SetModeSupportInfo(modeSupportInfo); + property_->SetWindowModeSupportType(windowModeSupportType); } void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason, @@ -2787,10 +2788,10 @@ void WindowImpl::UpdateMode(WindowMode mode) UpdateDecorEnable(true); } -void WindowImpl::UpdateModeSupportInfo(uint32_t modeSupportInfo) +void WindowImpl::UpdateWindowModeSupportType(uint32_t windowModeSupportType) { - WLOGFD("modeSupportInfo: %{public}u, winId: %{public}u", modeSupportInfo, GetWindowId()); - SetModeSupportInfo(modeSupportInfo); + WLOGFD("windowModeSupportType: %{public}u, winId: %{public}u", windowModeSupportType, GetWindowId()); + SetWindowModeSupportType(windowModeSupportType); UpdateTitleButtonVisibility(); } @@ -3449,7 +3450,7 @@ void WindowImpl::UpdateDecorEnable(bool needNotify) WLOGFD("Start"); if (WindowHelper::IsMainWindow(property_->GetWindowType())) { bool enable = windowSystemConfig_.isSystemDecorEnable_ && - WindowHelper::IsWindowModeSupported(windowSystemConfig_.decorModeSupportInfo_, GetMode()); + WindowHelper::IsWindowModeSupported(windowSystemConfig_.decorWindowModeSupportType_, GetMode()); WLOGFD("Decor enable: %{public}d", static_cast(enable)); property_->SetDecorEnable(enable); } else { diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 33dbd386fd..990fd69886 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -872,16 +872,21 @@ void WindowSceneSessionImpl::GetConfigurationFromAbilityInfo() UpdateWindowSizeLimits(); UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_LIMITS); // get support modes configuration - uint32_t modeSupportInfo = WindowHelper::ConvertSupportModesToSupportInfo(abilityInfo->windowModes); - if (modeSupportInfo == 0) { - WLOGFI("mode config param is 0, all modes is supported"); - modeSupportInfo = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + uint32_t windowModeSupportType = property_->GetWindowModeSupportType(); + if (windowModeSupportType == 0) { + TLOGI(WmsLogTag::WMS_LAYOUT, "startAbility support window mode param is 0, get modes from ability info"); + windowModeSupportType = WindowHelper::ConvertSupportModesToSupportType(abilityInfo->windowModes); + if (windowModeSupportType == 0) { + TLOGI(WmsLogTag::WMS_LAYOUT, "mode config param is 0, all modes is supported"); + windowModeSupportType = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + } } - WLOGFI("winId: %{public}u, modeSupportInfo: %{public}u", GetWindowId(), modeSupportInfo); - property_->SetModeSupportInfo(modeSupportInfo); - // update modeSupportInfo to server + TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}u, windowModeSupportType: %{public}u", + GetWindowId(), windowModeSupportType); + property_->SetWindowModeSupportType(windowModeSupportType); + // update windowModeSupportType to server UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO); - bool onlySupportFullScreen = (modeSupportInfo == WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && + bool onlySupportFullScreen = (windowModeSupportType == WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && ((!windowSystemConfig_.IsPhoneWindow() && !windowSystemConfig_.IsPadWindow()) || IsFreeMultiWindowMode()); if (onlySupportFullScreen || property_->GetFullScreenStart()) { TLOGI(WmsLogTag::WMS_LAYOUT, "onlySupportFullScreen:%{public}d fullScreenStart:%{public}d", @@ -1968,7 +1973,8 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) if (WindowHelper::IsMainWindow(GetType()) && !windowSystemConfig_.IsPhoneWindow() && !windowSystemConfig_.IsPadWindow()) { - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FULLSCREEN)) { TLOGE(WmsLogTag::WMS_IMMS, "fullscreen window mode is not supported"); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -2156,7 +2162,8 @@ WMError WindowSceneSessionImpl::SetFullScreen(bool status) if (WindowHelper::IsMainWindow(GetType()) && (IsFreeMultiWindowMode() || windowSystemConfig_.IsPcWindow())) { - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FULLSCREEN)) { TLOGE(WmsLogTag::WMS_IMMS, "fullscreen window mode is not supported"); return WMError::WM_ERROR_INVALID_WINDOW; } @@ -2199,7 +2206,7 @@ bool WindowSceneSessionImpl::IsDecorEnable() const bool isValidWindow = isMainWindow || ((isSubWindow || isDialogWindow) && property_->IsDecorEnable()); bool isWindowModeSupported = WindowHelper::IsWindowModeSupported( - windowSystemConfig_.decorModeSupportInfo_, GetMode()); + windowSystemConfig_.decorWindowModeSupportType_, GetMode()); if (windowSystemConfig_.freeMultiWindowSupport_) { return isValidWindow && windowSystemConfig_.isSystemDecorEnable_; } @@ -2256,7 +2263,8 @@ WMError WindowSceneSessionImpl::Maximize(MaximizePresentation presentation) TLOGE(WmsLogTag::WMS_LAYOUT, "maximize fail, not main window"); return WMError::WM_ERROR_INVALID_CALLING; } - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FULLSCREEN)) { return WMError::WM_ERROR_INVALID_WINDOW; } // The device is not supported @@ -2310,7 +2318,7 @@ WMError WindowSceneSessionImpl::MaximizeFloating() TLOGW(WmsLogTag::WMS_LAYOUT, "SetGlobalMaximizeMode fail, not main window"); return WMError::WM_ERROR_INVALID_WINDOW; } - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FULLSCREEN)) { return WMError::WM_ERROR_INVALID_WINDOW; } @@ -2338,7 +2346,7 @@ WMError WindowSceneSessionImpl::Recover() WLOGFE("session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; } - if (!(WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) || + if (!(WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FLOATING) || property_->GetCompatibleModeInPc())) { TLOGE(WmsLogTag::WMS_LAYOUT, "not support floating, can not Recover"); return WMError::WM_ERROR_INVALID_OPERATION; @@ -2403,7 +2411,8 @@ WMError WindowSceneSessionImpl::Recover(uint32_t reason) WLOGFE("The device is not supported"); return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } - if (!(WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) || + if (!(WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FLOATING) || property_->GetCompatibleModeInPc())) { TLOGE(WmsLogTag::WMS_LAYOUT, "not support floating, can not Recover"); return WMError::WM_ERROR_INVALID_OPERATION; @@ -2686,7 +2695,7 @@ WMError WindowSceneSessionImpl::SetWindowMode(WindowMode mode) } bool isCompatibleModeInPcSetFloatingWindowMode = property_->GetCompatibleModeInPc() && (mode == WindowMode::WINDOW_MODE_FLOATING); - if (!(WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), mode) || + if (!(WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), mode) || isCompatibleModeInPcSetFloatingWindowMode)) { TLOGE(WmsLogTag::DEFAULT, "window %{public}u do not support mode: %{public}u", GetWindowId(), static_cast(mode)); @@ -3534,7 +3543,7 @@ WSError WindowSceneSessionImpl::UpdateWindowMode(WindowMode mode) if (IsWindowSessionInvalid()) { return WSError::WS_ERROR_INVALID_WINDOW; } - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), mode)) { + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), mode)) { WLOGFE("%{public}u do not support mode: %{public}u", GetWindowId(), static_cast(mode)); return WSError::WS_ERROR_INVALID_WINDOW_MODE_OR_SIZE; @@ -3748,10 +3757,10 @@ void WindowSceneSessionImpl::UpdateNewSize() } bool needResize = false; Rect windowRect = GetRequestRect(); - if (windowRect.IsUninitializedRect()) { + if (windowRect.IsUninitializedSize()) { windowRect = GetRect(); - if (windowRect.IsUninitializedRect()) { - TLOGW(WmsLogTag::WMS_LAYOUT, "The requestRect and rect are uninitialized. winId: %{public}u", + if (windowRect.IsUninitializedSize()) { + TLOGW(WmsLogTag::WMS_LAYOUT, "The sizes of requestRect and rect are uninitialized. winId: %{public}u", GetWindowId()); return; } @@ -4198,7 +4207,8 @@ WMError WindowSceneSessionImpl::SetImmersiveModeEnabledState(bool enable) } auto hostSession = GetHostSession(); CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); - if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + if (!WindowHelper::IsWindowModeSupported(property_->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FULLSCREEN)) { return WMError::WM_ERROR_INVALID_WINDOW; } const WindowType curWindowType = GetType(); @@ -4225,16 +4235,6 @@ bool WindowSceneSessionImpl::GetImmersiveModeEnabledState() const return enableImmersiveMode_; } -uint32_t WindowSceneSessionImpl::GetStatusBarHeight() -{ - uint32_t height = 0; - auto hostSession = GetHostSession(); - CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, height); - height = static_cast(hostSession->GetStatusBarHeight()); - TLOGI(WmsLogTag::WMS_IMMS, "%{public}d", height); - return height; -} - template static V GetValueByKey(const std::unordered_map& map, K key) { diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 7ba1d6705b..5302cbb8b1 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -873,10 +873,11 @@ void WindowSessionImpl::FlushLayoutSize(int32_t width, int32_t height) } } -void WindowSessionImpl::GetTitleButtonVisible(bool isPC, bool& hideMaximizeButton, bool& hideMinimizeButton, +void WindowSessionImpl::GetTitleButtonVisible(bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, bool& hideCloseButton) { - if (!isPC) { + if (!IsPcOrPadFreeMultiWindowMode()) { + TLOGE(WmsLogTag::WMS_LAYOUT, "device not support"); return; } if (hideMaximizeButton > !windowTitleVisibleFlags_.isMaximizeVisible) { @@ -1206,7 +1207,6 @@ void WindowSessionImpl::UpdateTitleButtonVisibility() if (uiContent == nullptr || !IsDecorEnable()) { return; } - auto isPC = windowSystemConfig_.IsPcWindow(); WindowType windowType = GetType(); bool isSubWindow = WindowHelper::IsSubWindow(windowType); bool isDialogWindow = WindowHelper::IsDialogWindow(windowType); @@ -1215,16 +1215,16 @@ void WindowSessionImpl::UpdateTitleButtonVisibility() uiContent->HideWindowTitleButton(true, true, true, false); return; } - auto modeSupportInfo = property_->GetModeSupportInfo(); - bool hideSplitButton = !(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + auto windowModeSupportType = property_->GetWindowModeSupportType(); + bool hideSplitButton = !(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); // not support fullscreen in split and floating mode, or not support float in fullscreen mode - bool hideMaximizeButton = (!(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && + bool hideMaximizeButton = (!(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) && (GetMode() == WindowMode::WINDOW_MODE_FLOATING || WindowHelper::IsSplitWindowMode(GetMode()))) || - (!(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) && + (!(windowModeSupportType & WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) && GetMode() == WindowMode::WINDOW_MODE_FULLSCREEN); bool hideMinimizeButton = false; bool hideCloseButton = false; - GetTitleButtonVisible(isPC, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); TLOGI(WmsLogTag::WMS_LAYOUT, "[hideSplit, hideMaximize, hideMinimizeButton, hideCloseButton]:" "[%{public}d, %{public}d, %{public}d, %{public}d]", hideSplitButton, hideMaximizeButton, hideMinimizeButton, hideCloseButton); @@ -1302,7 +1302,7 @@ WMError WindowSessionImpl::InitUIContent(const std::string& contentInfo, napi_en break; case WindowSetUIContentType::BY_ABC: auto abcContent = GetAbcContent(contentInfo); - aceRet = uiContent->Initialize(this, abcContent, storage); + aceRet = uiContent->Initialize(this, abcContent, storage, contentInfo); break; } // make uiContent available after Initialize/Restore @@ -1625,6 +1625,24 @@ WMError WindowSessionImpl::SetResizeByDragEnabled(bool dragEnabled) WMError WindowSessionImpl::SetRaiseByClickEnabled(bool raiseEnabled) { WLOGFD("%{public}d", raiseEnabled); + auto parentId = GetParentId(); + if (parentId == INVALID_SESSION_ID) { + TLOGE(WmsLogTag::WMS_HIERARCHY, "Window id: %{public}d Parent id is invalid!", + GetPersistentId()); + return WMError::WM_ERROR_INVALID_PARENT; + } + + if (!WindowHelper::IsSubWindow(GetType())) { + TLOGE(WmsLogTag::WMS_HIERARCHY, "Window id: %{public}d Must be app sub window!", + GetPersistentId()); + return WMError::WM_ERROR_INVALID_CALLING; + } + + if (state_ != WindowState::STATE_SHOWN) { + TLOGE(WmsLogTag::WMS_HIERARCHY, "Window id: %{public}d The sub window must be shown!", + GetPersistentId()); + return WMError::WM_DO_NOTHING; + } if (IsWindowSessionInvalid()) { return WMError::WM_ERROR_INVALID_WINDOW; } @@ -3028,6 +3046,8 @@ void WindowSessionImpl::NotifySizeChange(Rect rect, WindowSizeChangeReason reaso { std::lock_guard lockListener(windowChangeListenerMutex_); auto windowChangeListeners = GetListeners(); + TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, sizeChange listenerSize:%{public}zu", + GetPersistentId(), windowChangeListeners.size()); for (auto& listener : windowChangeListeners) { if (listener != nullptr) { listener->OnSizeChange(rect, reason); @@ -3037,6 +3057,8 @@ void WindowSessionImpl::NotifySizeChange(Rect rect, WindowSizeChangeReason reaso { std::lock_guard lockRectListener(windowRectChangeListenerMutex_); auto windowRectChangeListeners = GetListeners(); + TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, rectChange listenerSize:%{public}zu", + GetPersistentId(), windowRectChangeListeners.size()); for (auto& listener : windowRectChangeListeners) { if (listener != nullptr) { listener->OnRectChange(rect, reason); @@ -3940,6 +3962,16 @@ WindowStatus WindowSessionImpl::GetWindowStatusInner(WindowMode mode) return windowStatus; } +uint32_t WindowSessionImpl::GetStatusBarHeight() +{ + uint32_t height = 0; + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, height); + height = static_cast(hostSession->GetStatusBarHeight()); + TLOGI(WmsLogTag::WMS_IMMS, "StatusBarVectorHeight is %{public}u", height); + return height; +} + /** @note @window.layout */ void WindowSessionImpl::NotifyWindowStatusChange(WindowMode mode) { diff --git a/wm/src/zidl/window_proxy.cpp b/wm/src/zidl/window_proxy.cpp index 343b559b55..0ac5fe14df 100644 --- a/wm/src/zidl/window_proxy.cpp +++ b/wm/src/zidl/window_proxy.cpp @@ -103,7 +103,7 @@ WMError WindowProxy::UpdateWindowMode(WindowMode mode) return WMError::WM_OK; } -WMError WindowProxy::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) +WMError WindowProxy::UpdateWindowModeSupportType(uint32_t windowModeSupportType) { MessageParcel data; MessageParcel reply; @@ -112,7 +112,7 @@ WMError WindowProxy::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) WLOGFE("WriteInterfaceToken failed"); return WMError::WM_ERROR_IPC_FAILED; } - if (!data.WriteUint32(modeSupportInfo)) { + if (!data.WriteUint32(windowModeSupportType)) { WLOGFE("Write WindowMode failed"); return WMError::WM_ERROR_IPC_FAILED; } diff --git a/wm/src/zidl/window_stub.cpp b/wm/src/zidl/window_stub.cpp index 93c359afe2..5e94e67fd8 100644 --- a/wm/src/zidl/window_stub.cpp +++ b/wm/src/zidl/window_stub.cpp @@ -99,12 +99,12 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParce break; } case WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO: { - uint32_t modeSupportInfo = 0; - if (!data.ReadUint32(modeSupportInfo)) { - TLOGE(WmsLogTag::WMS_LAYOUT, "read modeSupportInfo failed"); + uint32_t windowModeSupportType = 0; + if (!data.ReadUint32(windowModeSupportType)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "read windowModeSupportType failed"); return ERR_INVALID_DATA; } - UpdateWindowModeSupportInfo(modeSupportInfo); + UpdateWindowModeSupportType(windowModeSupportType); break; } case WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS: { diff --git a/wm/test/unittest/window_agent_test.cpp b/wm/test/unittest/window_agent_test.cpp index 94683746be..1069e96972 100644 --- a/wm/test/unittest/window_agent_test.cpp +++ b/wm/test/unittest/window_agent_test.cpp @@ -87,17 +87,17 @@ HWTEST_F(WindowAgentTest, UpdateWindowMode, Function | SmallTest | Level2) } /** - * @tc.name: UpdateWindowModeSupportInfo - * @tc.desc: UpdateWindowModeSupportInfo + * @tc.name: UpdateWindowModeSupportType + * @tc.desc: UpdateWindowModeSupportType * @tc.type: FUNC */ -HWTEST_F(WindowAgentTest, UpdateWindowModeSupportInfo, Function | SmallTest | Level2) +HWTEST_F(WindowAgentTest, UpdateWindowModeSupportType, Function | SmallTest | Level2) { - WMError err = windowAgent_->UpdateWindowModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + WMError err = windowAgent_->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(err, WMError::WM_OK); windowAgent_->window_ = nullptr; - err = windowAgent_->UpdateWindowModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + err = windowAgent_->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); ASSERT_EQ(err, WMError::WM_ERROR_NULLPTR); } diff --git a/wm/test/unittest/window_impl_test2.cpp b/wm/test/unittest/window_impl_test2.cpp index ed57cb35b9..63078293ae 100644 --- a/wm/test/unittest/window_impl_test2.cpp +++ b/wm/test/unittest/window_impl_test2.cpp @@ -799,10 +799,10 @@ HWTEST_F(WindowImplTest2, SetWindowMode, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); - window->UpdateModeSupportInfo(0); + window->UpdateWindowModeSupportType(0); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_DO_NOTHING)); ASSERT_EQ(WMError::WM_DO_NOTHING, window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); window->SetWindowState(WindowState::STATE_FROZEN); @@ -967,9 +967,9 @@ HWTEST_F(WindowImplTest2, SetLayoutFullScreen, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), GetSystemConfig(_)).WillOnce(Return(WMError::WM_OK)); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Create(INVALID_WINDOW_ID)); - window->UpdateModeSupportInfo(0); + window->UpdateWindowModeSupportType(0); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(true)); - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -1025,9 +1025,9 @@ HWTEST_F(WindowImplTest2, SetImmersiveModeEnabledState, Function | SmallTest | L EXPECT_CALL(m->Mock(), GetSystemConfig(_)).WillOnce(Return(WMError::WM_OK)); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Create(INVALID_WINDOW_ID)); - window->UpdateModeSupportInfo(0); + window->UpdateWindowModeSupportType(0); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetImmersiveModeEnabledState(true)); - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -1086,9 +1086,9 @@ HWTEST_F(WindowImplTest2, SetFullScreen, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Create(INVALID_WINDOW_ID)); - window->UpdateModeSupportInfo(0); + window->UpdateWindowModeSupportType(0); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(true)); - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Show()); diff --git a/wm/test/unittest/window_impl_test3.cpp b/wm/test/unittest/window_impl_test3.cpp index 722b9c851e..df2b33ed42 100644 --- a/wm/test/unittest/window_impl_test3.cpp +++ b/wm/test/unittest/window_impl_test3.cpp @@ -771,7 +771,7 @@ HWTEST_F(WindowImplTest3, UpdateDecorEnable, Function | SmallTest | Level3) window->property_->mode_ = WindowMode::WINDOW_MODE_FULLSCREEN; window->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; window->windowSystemConfig_.isSystemDecorEnable_ = true; - window->windowSystemConfig_.decorModeSupportInfo_ = WINDOW_MODE_SUPPORT_FLOATING; + window->windowSystemConfig_.decorWindowModeSupportType_ = WINDOW_MODE_SUPPORT_FLOATING; window->uiContent_ = std::make_unique(); Ace::UIContentMocker* content = reinterpret_cast(window->uiContent_.get()); sptr listener = new MockWindowChangeListener; @@ -782,7 +782,7 @@ HWTEST_F(WindowImplTest3, UpdateDecorEnable, Function | SmallTest | Level3) window->UpdateDecorEnable(true); ASSERT_TRUE(window->IsDecorEnable()); ASSERT_FALSE(window->property_->GetDecorEnable()); - window->windowSystemConfig_.decorModeSupportInfo_ = WINDOW_MODE_SUPPORT_ALL; + window->windowSystemConfig_.decorWindowModeSupportType_ = WINDOW_MODE_SUPPORT_ALL; window->UpdateDecorEnable(); ASSERT_TRUE(window->IsDecorEnable()); ASSERT_TRUE(window->property_->GetDecorEnable()); @@ -1255,7 +1255,7 @@ HWTEST_F(WindowImplTest3, SetFloatingMaximize, Function | SmallTest | Level3) EXPECT_CALL(m->Mock(), GetSystemConfig(_)).WillOnce(Return(WMError::WM_OK)); EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, window->Create(INVALID_WINDOW_ID)); - window->UpdateModeSupportInfo(0); + window->UpdateWindowModeSupportType(0); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFloatingMaximize(true)); ASSERT_EQ(WMError::WM_OK, window->Destroy()); } diff --git a/wm/test/unittest/window_impl_test5.cpp b/wm/test/unittest/window_impl_test5.cpp index f5918a9d99..0835c2eeba 100644 --- a/wm/test/unittest/window_impl_test5.cpp +++ b/wm/test/unittest/window_impl_test5.cpp @@ -990,7 +990,7 @@ HWTEST_F(WindowImplTest5, SetImmersiveModeEnabledState02, Function | SmallTest | EXPECT_EQ(window->SetImmersiveModeEnabledState(true), WMError::WM_ERROR_INVALID_WINDOW); window->state_ = WindowState::STATE_CREATED; - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL); window->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); EXPECT_EQ(window->SetImmersiveModeEnabledState(true), WMError::WM_ERROR_INVALID_WINDOW); @@ -1174,7 +1174,7 @@ HWTEST_F(WindowImplTest5, NeedToStopShowing, Function | SmallTest | Level1) window->property_->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); EXPECT_EQ(window->NeedToStopShowing(), true); - window->UpdateModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + window->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); window->property_->SetWindowFlags(1 << 2); EXPECT_EQ(window->NeedToStopShowing(), false); diff --git a/wm/test/unittest/window_manager_test.cpp b/wm/test/unittest/window_manager_test.cpp index 28edb0db93..632727c38e 100644 --- a/wm/test/unittest/window_manager_test.cpp +++ b/wm/test/unittest/window_manager_test.cpp @@ -222,7 +222,7 @@ HWTEST_F(WindowManagerTest, GetSnapshotByWindowId01, Function | SmallTest | Leve WMError ret = windowManager.GetSnapshotByWindowId(windowId, pixelMap); if (SceneBoardJudgement::IsSceneBoardEnabled()) { ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, ret); - }else { + } else { ASSERT_EQ(WMError::WM_ERROR_NULLPTR, ret); } } diff --git a/wm/test/unittest/window_proxy_test.cpp b/wm/test/unittest/window_proxy_test.cpp index d264d93cf6..624d482024 100644 --- a/wm/test/unittest/window_proxy_test.cpp +++ b/wm/test/unittest/window_proxy_test.cpp @@ -76,13 +76,13 @@ HWTEST_F(WindowProxyTest, UpdateWindowMode01, Function | SmallTest | Level2) } /** - * @tc.name: UpdateWindowModeSupportInfo01 + * @tc.name: UpdateWindowModeSupportType01 * @tc.desc: normal function * @tc.type: FUNC */ -HWTEST_F(WindowProxyTest, UpdateWindowModeSupportInfo01, Function | SmallTest | Level2) +HWTEST_F(WindowProxyTest, UpdateWindowModeSupportType01, Function | SmallTest | Level2) { - WMError err = windowProxy_->UpdateWindowModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + WMError err = windowProxy_->UpdateWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); ASSERT_EQ(err, WMError::WM_OK); } diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index bc29e80b99..830a37eac7 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1776,20 +1776,6 @@ HWTEST_F(WindowSceneSessionImplTest, SetShadowOffsetY, Function | SmallTest | Le ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetShadowOffsetY(1.0)); } -/** - * @tc.name: GetStatusBarHeight - * @tc.desc: GetStatusBarHeight test - * @tc.type: FUNC - */ -HWTEST_F(WindowSceneSessionImplTest, GetStatusBarHeight, Function | SmallTest | Level3) -{ - sptr option = new (std::nothrow) WindowOption(); - option->SetWindowName("GetStatusBarHeight"); - sptr window = new (std::nothrow) WindowSceneSessionImpl(option); - ASSERT_NE(window, nullptr); - ASSERT_EQ(0, window->GetStatusBarHeight()); -} - /** * @tc.name: SetGestureBackEnabled * @tc.desc: SetGestureBackEnabled test diff --git a/wm/test/unittest/window_scene_session_impl_test2.cpp b/wm/test/unittest/window_scene_session_impl_test2.cpp index 37c6770a37..2e31dcb146 100644 --- a/wm/test/unittest/window_scene_session_impl_test2.cpp +++ b/wm/test/unittest/window_scene_session_impl_test2.cpp @@ -1481,7 +1481,7 @@ HWTEST_F(WindowSceneSessionImplTest2, Maximize02, Function | SmallTest | Level2) // window not support fullscreen window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - window->property_->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_PIP); + window->property_->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_PIP); ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Maximize(presentation)); } @@ -1659,8 +1659,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible01, Function | SmallT option->SetWindowName("GetTitleButtonVisible01"); sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); - uint32_t modeSupportInfo = 1 | (1 << 1) | (1 << 2); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1) | (1 << 2); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { false, false, false, false}; @@ -1668,7 +1668,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible01, Function | SmallT bool hideMinimizeButton = false; bool hideSplitButton = false; bool hideCloseButton = false; - window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, true); ASSERT_EQ(hideMinimizeButton, true); ASSERT_EQ(hideSplitButton, true); @@ -1687,8 +1688,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible02, Function | SmallT sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); // only not support WINDOW_MODE_SUPPORT_SPLIT - uint32_t modeSupportInfo = 1 | (1 << 1); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { true, true, true, true}; @@ -1696,7 +1697,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible02, Function | SmallT bool hideMinimizeButton = false; bool hideSplitButton = false; bool hideCloseButton = false; - window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, false); ASSERT_EQ(hideMinimizeButton, false); ASSERT_EQ(hideSplitButton, false); @@ -1715,8 +1717,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible03, Function | SmallT sptr window = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, window); // only not support WINDOW_MODE_SUPPORT_SPLIT - uint32_t modeSupportInfo = 1 | (1 << 1) | (1 << 2); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1) | (1 << 2); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { false, false, false, false}; @@ -1724,7 +1726,8 @@ HWTEST_F(WindowSceneSessionImplTest2, GetTitleButtonVisible03, Function | SmallT bool hideMinimizeButton = true; bool hideSplitButton = true; bool hideCloseButton = true; - window->GetTitleButtonVisible(false, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, true); ASSERT_EQ(hideMinimizeButton, true); ASSERT_EQ(hideSplitButton, true); diff --git a/wm/test/unittest/window_scene_session_impl_test3.cpp b/wm/test/unittest/window_scene_session_impl_test3.cpp index d387d1ed7f..30bb46296c 100644 --- a/wm/test/unittest/window_scene_session_impl_test3.cpp +++ b/wm/test/unittest/window_scene_session_impl_test3.cpp @@ -174,6 +174,8 @@ HWTEST_F(WindowSceneSessionImplTest3, UpdateTitleInTargetPos, Function | SmallTe ASSERT_NE(nullptr, session); windowSceneSessionImpl->hostSession_ = session; windowSceneSessionImpl->state_ = WindowState::STATE_SHOWN; + windowSceneSessionImpl->windowSessionMap_.insert(std::make_pair(windowSceneSessionImpl->GetWindowName(), + std::make_pair(windowSceneSessionImpl->GetWindowId(), windowSceneSessionImpl))); ret = windowSceneSessionImpl->SwitchFreeMultiWindow(true); EXPECT_EQ(WSError::WS_OK, ret); ret = windowSceneSessionImpl->SwitchFreeMultiWindow(false); @@ -191,6 +193,7 @@ HWTEST_F(WindowSceneSessionImplTest3, UpdateTitleInTargetPos, Function | SmallTe EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); ret = windowSceneSessionImpl->UpdateTitleInTargetPos(false, 0); EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, ret); + windowSceneSessionImpl->windowSessionMap_.erase(windowSceneSessionImpl->GetWindowName()); } /** @@ -1167,7 +1170,7 @@ HWTEST_F(WindowSceneSessionImplTest3, MaximizeFloating, Function | SmallTest | L ret = windowSceneSessionImpl->MaximizeFloating(); EXPECT_EQ(WMError::WM_OK, ret); ASSERT_NE(nullptr, windowSceneSessionImpl->property_); - windowSceneSessionImpl->property_->SetModeSupportInfo(WINDOW_MODE_SUPPORT_FLOATING); + windowSceneSessionImpl->property_->SetWindowModeSupportType(WINDOW_MODE_SUPPORT_FLOATING); ret = windowSceneSessionImpl->MaximizeFloating(); EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret); ret1 = windowSceneSessionImpl->GetGlobalMaximizeMode(); diff --git a/wm/test/unittest/window_scene_session_impl_test4.cpp b/wm/test/unittest/window_scene_session_impl_test4.cpp index be3e3abdf0..d81d31bbd3 100644 --- a/wm/test/unittest/window_scene_session_impl_test4.cpp +++ b/wm/test/unittest/window_scene_session_impl_test4.cpp @@ -1323,7 +1323,7 @@ HWTEST_F(WindowSceneSessionImplTest4, SetWindowMode01, Function | SmallTest | Le sptr subSession = new (std::nothrow) SessionMocker(subSessionInfo); ASSERT_NE(nullptr, subSession); subWindow->hostSession_ = subSession; - subWindow->property_->SetModeSupportInfo(0); + subWindow->property_->SetWindowModeSupportType(0); auto ret = subWindow->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED); EXPECT_EQ(WMError::WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE, ret); } @@ -1344,7 +1344,7 @@ HWTEST_F(WindowSceneSessionImplTest4, SetWindowMode02, Function | SmallTest | Le SessionInfo subSessionInfo = {"CreateSubTestBundle", "CreateSubTestModule", "CreateSubTestAbility"}; sptr subSession = sptr::MakeSptr(subSessionInfo); subWindow->hostSession_ = subSession; - subWindow->property_->SetModeSupportInfo(1); + subWindow->property_->SetWindowModeSupportType(1); auto ret = subWindow->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); EXPECT_EQ(WMError::WM_OK, ret); } diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index dc15c356ca..b25bc31df4 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -1878,18 +1878,39 @@ HWTEST_F(WindowSessionImplTest, SetRaiseByClickEnabled01, Function | SmallTest | { sptr option = new WindowOption(); option->SetWindowName("SetRaiseByClickEnabled01"); + option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); sptr window = new(std::nothrow) WindowSessionImpl(option); ASSERT_NE(nullptr, window); + WMError retCode = window->SetRaiseByClickEnabled(true); + ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_PARENT); + + option->SetWindowName("SetRaiseByClickForFloatWindow"); + option->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + sptr floatWindow = new(std::nothrow) WindowSessionImpl(option); + floatWindow->property_->SetParentPersistentId(1); + ASSERT_NE(nullptr, floatWindow); + + retCode = floatWindow->SetRaiseByClickEnabled(true); + ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_CALLING); + + option->SetWindowName("SetRaiseByClickForSubWindow"); + option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + sptr subWindow = new(std::nothrow) WindowSessionImpl(option); + ASSERT_NE(nullptr, subWindow); + + subWindow->property_->SetParentPersistentId(1); + subWindow->Hide(); + retCode = subWindow->SetRaiseByClickEnabled(true); + ASSERT_EQ(retCode, WMError::WM_DO_NOTHING); + + subWindow->state_ = WindowState::STATE_SHOWN; + retCode = subWindow->SetRaiseByClickEnabled(true); ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_WINDOW); - window->property_->SetPersistentId(1); - SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; - sptr session = new(std::nothrow) SessionMocker(sessionInfo); - ASSERT_NE(nullptr, session); - window->hostSession_ = session; - window->state_ = WindowState::STATE_CREATED; - window->SetRaiseByClickEnabled(true); - ASSERT_NE(nullptr, session); + + subWindow->property_->SetParentPersistentId(2); + subWindow->SetRaiseByClickEnabled(true); + ASSERT_EQ(subWindow->property_->GetRaiseEnabled(), true); } /** @@ -2136,6 +2157,20 @@ HWTEST_F(WindowSessionImplTest, NotifySetUIContentComplete, Function | SmallTest window->NotifySetUIContentComplete(); EXPECT_EQ(window->setUIContentCompleted_.load(), false); } + +/** + * @tc.name: GetStatusBarHeight + * @tc.desc: GetStatusBarHeight test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, GetStatusBarHeight, Function | SmallTest | Level3) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("GetStatusBarHeight"); + sptr window = sptr::MakeSptr(option); + ASSERT_NE(window, nullptr); + ASSERT_EQ(0, window->GetStatusBarHeight()); +} } } // namespace Rosen } // namespace OHOS diff --git a/wm/test/unittest/window_session_impl_test2.cpp b/wm/test/unittest/window_session_impl_test2.cpp index 9a651dcdb7..a6135cb2df 100644 --- a/wm/test/unittest/window_session_impl_test2.cpp +++ b/wm/test/unittest/window_session_impl_test2.cpp @@ -107,20 +107,20 @@ HWTEST_F(WindowSessionImplTest2, GetTitleButtonVisible, Function | SmallTest | L { auto window = GetTestWindowImpl("GetTitleButtonVisible"); ASSERT_NE(window, nullptr); - bool isPC = false; + window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; bool isMaximizeVisible = false; bool isMinimizeVisible = false; bool isSplitVisible = false; bool isCloseVisible = false; - window->GetTitleButtonVisible(isPC, isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); + window->GetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); ASSERT_FALSE(isSplitVisible); - isPC = true; + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; window->windowTitleVisibleFlags_.isSplitVisible = false; window->windowTitleVisibleFlags_.isMaximizeVisible = false; window->windowTitleVisibleFlags_.isMinimizeVisible = false; window->windowTitleVisibleFlags_.isCloseVisible = false; - window->GetTitleButtonVisible(isPC, isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); + window->GetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); ASSERT_TRUE(isSplitVisible); ASSERT_TRUE(isMaximizeVisible); ASSERT_TRUE(isMinimizeVisible); @@ -130,7 +130,7 @@ HWTEST_F(WindowSessionImplTest2, GetTitleButtonVisible, Function | SmallTest | L window->windowTitleVisibleFlags_.isMaximizeVisible = true; window->windowTitleVisibleFlags_.isMinimizeVisible = true; window->windowTitleVisibleFlags_.isCloseVisible = true; - window->GetTitleButtonVisible(isPC, isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); + window->GetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isSplitVisible, isCloseVisible); ASSERT_TRUE(isSplitVisible); ASSERT_TRUE(isMaximizeVisible); ASSERT_TRUE(isMinimizeVisible); diff --git a/wm/test/unittest/window_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index 11be0d1ceb..f1c2240783 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -902,7 +902,8 @@ HWTEST_F(WindowSessionImplTest4, SetTitleButtonVisible, Function | SmallTest | L bool &hideMinimizeButton = isMinimizeVisible; bool &hideSplitButton = isSplitVisible; bool &hideCloseButton = isCloseVisible; - window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); } @@ -1212,8 +1213,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible01, Function | SmallTest | sptr window = new (std::nothrow) WindowSessionImpl(option); ASSERT_NE(window, nullptr); ASSERT_NE(window->property_, nullptr); - uint32_t modeSupportInfo = 1 | (1 << 1) | (1 << 2); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1) | (1 << 2); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { false, false, false, false }; @@ -1221,7 +1222,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible01, Function | SmallTest | bool hideMinimizeButton = false; bool hideSplitButton = false; bool hideCloseButton = false; - window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton, + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, true); ASSERT_EQ(hideMinimizeButton, true); @@ -1281,8 +1283,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible02, Function | SmallTest | ASSERT_NE(window, nullptr); ASSERT_NE(window->property_, nullptr); // only not support WINDOW_MODE_SUPPORT_SPLIT - uint32_t modeSupportInfo = 1 | (1 << 1); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { true, true, true, true }; @@ -1290,7 +1292,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible02, Function | SmallTest | bool hideMinimizeButton = false; bool hideSplitButton = false; bool hideCloseButton = false; - window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, false); ASSERT_EQ(hideMinimizeButton, false); ASSERT_EQ(hideSplitButton, false); @@ -1313,8 +1316,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible03, Function | SmallTest | ASSERT_NE(window->property_, nullptr); ASSERT_EQ(1, window->GetDisplayId()); // only not support WINDOW_MODE_SUPPORT_SPLIT - uint32_t modeSupportInfo = 1 | (1 << 1) | (1 << 2); - window->property_->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = 1 | (1 << 1) | (1 << 2); + window->property_->SetWindowModeSupportType(windowModeSupportType); window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { false, false, false, false }; @@ -1322,7 +1325,8 @@ HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible03, Function | SmallTest | bool hideMinimizeButton = true; bool hideSplitButton = true; bool hideCloseButton = true; - window->GetTitleButtonVisible(false, hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); + window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton); ASSERT_EQ(hideMaximizeButton, true); ASSERT_EQ(hideMinimizeButton, true); ASSERT_EQ(hideSplitButton, true); diff --git a/wm/test/unittest/window_stub_test.cpp b/wm/test/unittest/window_stub_test.cpp index 3867972dbc..86ffdba79d 100644 --- a/wm/test/unittest/window_stub_test.cpp +++ b/wm/test/unittest/window_stub_test.cpp @@ -455,10 +455,11 @@ HWTEST_F(WindowStubTest, OnRemoteRequest18, Function | SmallTest | Level2) MessageOption option(MessageOption::TF_ASYNC); data.WriteInterfaceToken(WindowStub::GetDescriptor()); + data.WriteUint32(1); uint32_t code = static_cast(IWindow::WindowMessage::TRANS_ID_UPDATE_WINDOW_STATE); int res = windowStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(res, static_cast(ERR_NONE)); + EXPECT_EQ(res, static_cast(ERR_INVALID_DATA)); } /** diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 8446328973..e5fc3747f3 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -1577,30 +1577,30 @@ HWTEST_F(WindowTest, GetRequestedOrientation, Function | SmallTest | Level2) } /** - * @tc.name: SetRequestModeSupportInfo + * @tc.name: SetRequestWindowModeSupportType * @tc.desc: get * @tc.type: FUNC */ -HWTEST_F(WindowTest, SetRequestModeSupportInfo, Function | SmallTest | Level2) +HWTEST_F(WindowTest, SetRequestWindowModeSupportType, Function | SmallTest | Level2) { sptr window = new Window(); ASSERT_NE(nullptr, window); - uint32_t modeSupportInfo = 0; - window->SetRequestModeSupportInfo(modeSupportInfo); - ASSERT_EQ(static_cast(Orientation::UNSPECIFIED), modeSupportInfo); + uint32_t windowModeSupportType = 0; + window->SetRequestWindowModeSupportType(windowModeSupportType); + ASSERT_EQ(static_cast(Orientation::UNSPECIFIED), windowModeSupportType); ASSERT_EQ(WMError::WM_OK, window->Destroy()); } /** - * @tc.name: GetRequestModeSupportInfo + * @tc.name: GetRequestWindowModeSupportType * @tc.desc: get * @tc.type: FUNC */ -HWTEST_F(WindowTest, GetRequestModeSupportInfo, Function | SmallTest | Level2) +HWTEST_F(WindowTest, GetRequestWindowModeSupportType, Function | SmallTest | Level2) { sptr window = new Window(); ASSERT_NE(nullptr, window); - uint32_t ret = window->GetRequestModeSupportInfo(); + uint32_t ret = window->GetRequestWindowModeSupportType(); ASSERT_EQ(true, ret == 0); ASSERT_EQ(WMError::WM_OK, window->Destroy()); } diff --git a/wmserver/include/window_node.h b/wmserver/include/window_node.h index 2630f71353..cac2ba0b66 100644 --- a/wmserver/include/window_node.h +++ b/wmserver/include/window_node.h @@ -81,7 +81,7 @@ public: void SetWindowSizeChangeReason(WindowSizeChangeReason reason); void SetRequestedOrientation(Orientation orientation); void SetShowingDisplays(const std::vector& displayIdVec); - void SetModeSupportInfo(uint32_t modeSupportInfo); + void SetWindowModeSupportType(uint32_t windowModeSupportType); void SetDragType(DragType dragType); void SetOriginRect(const Rect& rect); void SetTouchHotAreas(const std::vector& rects); @@ -123,7 +123,7 @@ public: WindowSizeChangeReason GetWindowSizeChangeReason() const; Orientation GetRequestedOrientation() const; std::vector GetShowingDisplays() const; - uint32_t GetModeSupportInfo() const; + uint32_t GetWindowModeSupportType() const; DragType GetDragType() const; bool GetStretchable() const; const Rect& GetOriginRect() const; diff --git a/wmserver/include/window_node_container.h b/wmserver/include/window_node_container.h index b93ee0d3cc..7cdf01fff2 100644 --- a/wmserver/include/window_node_container.h +++ b/wmserver/include/window_node_container.h @@ -171,7 +171,7 @@ private: void UpdateRSTreeWhenShowingDisplaysChange(sptr& node, const std::vector& lastShowingDisplays); bool CheckWindowNodeWhetherInWindowTree(const sptr& node) const; - void UpdateModeSupportInfoWhenKeyguardChange(const sptr& node, bool up); + void UpdateWindowModeSupportTypeWhenKeyguardChange(const sptr& node, bool up); void RemoveFromRsTreeWhenRemoveWindowNode(sptr& node, bool fromAnimation); void UpdateSizeChangeReason(sptr& node, WindowMode srcMode, WindowMode dstMode); void UpdatePrivateWindowCount(); diff --git a/wmserver/include/zidl/window_manager_lite_interface.h b/wmserver/include/zidl/window_manager_lite_interface.h index 57b5c221a5..f6ddbe0ce8 100644 --- a/wmserver/include/zidl/window_manager_lite_interface.h +++ b/wmserver/include/zidl/window_manager_lite_interface.h @@ -40,6 +40,8 @@ public: virtual WMError GetVisibilityWindowInfo(std::vector>& infos) { return WMError::WM_OK; }; virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo) = 0; virtual WMError CheckWindowId(int32_t windowId, int32_t& pid) = 0; + virtual WMError CheckUIExtensionCreation( + int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName &element, int32_t &pid) = 0; virtual WMError GetWindowModeType(WindowModeType& windowModeType) { return WMError::WM_OK; } virtual WMError GetMainWindowInfos(int32_t topNum, std::vector& topNInfo) = 0; virtual WMError GetAllMainWindowInfos(std::vector& infos) = 0; diff --git a/wmserver/src/remote_animation.cpp b/wmserver/src/remote_animation.cpp index b045a0a761..67d18b2e37 100644 --- a/wmserver/src/remote_animation.cpp +++ b/wmserver/src/remote_animation.cpp @@ -155,10 +155,10 @@ bool RemoteAnimation::CheckTransition(sptr srcInfo, const // check support window mode when one app starts another app if ((dstNode != nullptr && dstInfo != nullptr) && - !WindowHelper::CheckSupportWindowMode(dstNode->GetWindowMode(), dstNode->GetModeSupportInfo(), dstInfo)) { + !WindowHelper::CheckSupportWindowMode(dstNode->GetWindowMode(), dstNode->GetWindowModeSupportType(), dstInfo)) { WLOGFE("RSWindowAnimation: the mode of dstNode isn't supported, winId: %{public}u, mode: %{public}u, " - "modeSupportInfo: %{public}u", dstNode->GetWindowId(), dstNode->GetWindowMode(), - dstNode->GetModeSupportInfo()); + "windowModeSupportType: %{public}u", dstNode->GetWindowId(), dstNode->GetWindowMode(), + dstNode->GetWindowModeSupportType()); return false; } diff --git a/wmserver/src/starting_window.cpp b/wmserver/src/starting_window.cpp index 0950254bd9..044d08ff8e 100644 --- a/wmserver/src/starting_window.cpp +++ b/wmserver/src/starting_window.cpp @@ -77,8 +77,8 @@ sptr StartingWindow::CreateWindowNode(const sptrabilityInfo_.missionId_ = info->GetMissionId(); node->abilityInfo_.bundleName_ = info->GetBundleName(); node->abilityInfo_.abilityName_ = info->GetAbilityName(); - uint32_t modeSupportInfo = WindowHelper::ConvertSupportModesToSupportInfo(info->GetWindowSupportModes()); - node->SetModeSupportInfo(modeSupportInfo); + uint32_t windowModeSupportType = WindowHelper::ConvertSupportModesToSupportType(info->GetWindowSupportModes()); + node->SetWindowModeSupportType(windowModeSupportType); if (CreateLeashAndStartingSurfaceNode(node) != WMError::WM_OK) { return nullptr; diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 71b42829db..0b284b17c6 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -96,7 +96,7 @@ void WindowController::StartingWindow(sptr info, std::shar } } - if (!WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), node->GetModeSupportInfo(), info)) { + if (!WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), node->GetWindowModeSupportType(), info)) { WLOGFE("need to cancel starting window"); return; } @@ -1519,7 +1519,7 @@ WMError WindowController::UpdateProperty(sptr& property, Propert break; } case PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: { - node->SetModeSupportInfo(property->GetModeSupportInfo()); + node->SetWindowModeSupportType(property->GetWindowModeSupportType()); break; } case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA: { diff --git a/wmserver/src/window_layout_policy_cascade.cpp b/wmserver/src/window_layout_policy_cascade.cpp index 6daa7ef4ba..8f18280fea 100644 --- a/wmserver/src/window_layout_policy_cascade.cpp +++ b/wmserver/src/window_layout_policy_cascade.cpp @@ -66,7 +66,8 @@ void WindowLayoutPolicyCascade::Reorder() continue; } // if window don't support floating mode, or default rect of cascade is not satisfied with limits - if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) || + if (!WindowHelper::IsWindowModeSupported(node->GetWindowModeSupportType(), + WindowMode::WINDOW_MODE_FLOATING) || !WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowUpdatedSizeLimits())) { MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_CASCADE); continue; diff --git a/wmserver/src/window_layout_policy_tile.cpp b/wmserver/src/window_layout_policy_tile.cpp index 591f641785..0eb8576e31 100644 --- a/wmserver/src/window_layout_policy_tile.cpp +++ b/wmserver/src/window_layout_policy_tile.cpp @@ -218,9 +218,9 @@ void WindowLayoutPolicyTile::PushBackNodeInTileQueue(const sptr& nod return; } - if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) { + if (!WindowHelper::IsWindowModeSupported(node->GetWindowModeSupportType(), WindowMode::WINDOW_MODE_FLOATING)) { WLOGFD("Window don't support floating mode that should be minimized, winId: %{public}u, " - "modeSupportInfo: %{public}u", node->GetWindowId(), node->GetModeSupportInfo()); + "windowModeSupportType: %{public}u", node->GetWindowId(), node->GetWindowModeSupportType()); MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::INVALID_MODE_OR_SIZE_IN_TILE); return; } diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 4d128c33cd..5edb991bc3 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -466,22 +466,22 @@ void WindowManagerService::ConfigDecor(const WindowManagerConfig::ConfigItem& de std::vector supportedModes; item = decorConfig["supportedMode"]; if (item.IsStrings()) { - systemConfig_.decorModeSupportInfo_ = 0; + systemConfig_.decorWindowModeSupportType_ = 0; supportedModes = *item.stringsValue_; } for (auto mode : supportedModes) { if (mode == "fullscreen") { - systemConfig_.decorModeSupportInfo_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN; + systemConfig_.decorWindowModeSupportType_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN; } else if (mode == "floating") { - systemConfig_.decorModeSupportInfo_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; + systemConfig_.decorWindowModeSupportType_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING; } else if (mode == "pip") { - systemConfig_.decorModeSupportInfo_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_PIP; + systemConfig_.decorWindowModeSupportType_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_PIP; } else if (mode == "split") { - systemConfig_.decorModeSupportInfo_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + systemConfig_.decorWindowModeSupportType_ |= WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY; } else { WLOGFW("Invalid supporedMode"); - systemConfig_.decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + systemConfig_.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; break; } } diff --git a/wmserver/src/window_node.cpp b/wmserver/src/window_node.cpp index b6e80b1b96..0e552dd1d7 100644 --- a/wmserver/src/window_node.cpp +++ b/wmserver/src/window_node.cpp @@ -129,9 +129,9 @@ void WindowNode::SetShowingDisplays(const std::vector& displayIdVec) showingDisplays_.assign(displayIdVec.begin(), displayIdVec.end()); } -void WindowNode::SetModeSupportInfo(uint32_t modeSupportInfo) +void WindowNode::SetWindowModeSupportType(uint32_t windowModeSupportType) { - property_->SetModeSupportInfo(modeSupportInfo); + property_->SetWindowModeSupportType(windowModeSupportType); } void WindowNode::ResetWindowSizeChangeReason() @@ -372,9 +372,9 @@ std::vector WindowNode::GetShowingDisplays() const return showingDisplays_; } -uint32_t WindowNode::GetModeSupportInfo() const +uint32_t WindowNode::GetWindowModeSupportType() const { - return property_->GetModeSupportInfo(); + return property_->GetWindowModeSupportType(); } void WindowNode::GetTouchHotAreas(std::vector& rects) const diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index 607464acb9..c8ff5cbac0 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -2213,22 +2213,23 @@ WMError WindowNodeContainer::SwitchLayoutPolicy(WindowLayoutMode dstMode, Displa return WMError::WM_OK; } -void WindowNodeContainer::UpdateModeSupportInfoWhenKeyguardChange(const sptr& node, bool up) +void WindowNodeContainer::UpdateWindowModeSupportTypeWhenKeyguardChange(const sptr& node, bool up) { - if (!WindowHelper::IsWindowModeSupported(node->GetWindowProperty()->GetRequestModeSupportInfo(), + if (!WindowHelper::IsWindowModeSupported(node->GetWindowProperty()->GetRequestWindowModeSupportType(), WindowMode::WINDOW_MODE_SPLIT_PRIMARY)) { WLOGFD("window doesn't support split mode, winId: %{public}d", node->GetWindowId()); return; } - uint32_t modeSupportInfo; + uint32_t windowModeSupportType; if (up) { - modeSupportInfo = node->GetModeSupportInfo() & (~WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); + windowModeSupportType = node->GetWindowModeSupportType() & + (~WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY); } else { - modeSupportInfo = node->GetModeSupportInfo() | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY; + windowModeSupportType = node->GetWindowModeSupportType() | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY; } - node->SetModeSupportInfo(modeSupportInfo); + node->SetWindowModeSupportType(windowModeSupportType); if (node->GetWindowToken() != nullptr) { - node->GetWindowToken()->UpdateWindowModeSupportInfo(modeSupportInfo); + node->GetWindowToken()->UpdateWindowModeSupportType(windowModeSupportType); } } @@ -2300,7 +2301,7 @@ void WindowNodeContainer::ReZOrderShowWhenLockedWindows(bool up) } } - UpdateModeSupportInfoWhenKeyguardChange(needReZOrderNode, up); + UpdateWindowModeSupportTypeWhenKeyguardChange(needReZOrderNode, up); parentNode->children_.insert(position, needReZOrderNode); if (up && WindowHelper::IsSplitWindowMode(needReZOrderNode->GetWindowMode())) { diff --git a/wmserver/src/window_pair.cpp b/wmserver/src/window_pair.cpp index 2a0460ad43..4e49dfc41f 100644 --- a/wmserver/src/window_pair.cpp +++ b/wmserver/src/window_pair.cpp @@ -195,11 +195,11 @@ void WindowPair::Clear() { WLOGI("Clear window pair."); DumpPairInfo(); - auto splitModeInfo = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + auto splitMode = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); if (primary_ != nullptr && primary_->GetWindowProperty() != nullptr && primary_->GetWindowToken() != nullptr) { - if (primary_->GetModeSupportInfo() == splitModeInfo) { + if (primary_->GetWindowModeSupportType() == splitMode) { MinimizeApp::AddNeedMinimizeApp(primary_, MinimizeReason::SPLIT_QUIT); MinimizeApp::ExecuteMinimizeTargetReasons(MinimizeReason::SPLIT_QUIT); } else { @@ -216,7 +216,7 @@ void WindowPair::Clear() } if (secondary_ != nullptr && secondary_->GetWindowProperty() != nullptr && secondary_->GetWindowToken() != nullptr) { - if (secondary_->GetModeSupportInfo() == splitModeInfo) { + if (secondary_->GetWindowModeSupportType() == splitMode) { MinimizeApp::AddNeedMinimizeApp(secondary_, MinimizeReason::SPLIT_QUIT); MinimizeApp::ExecuteMinimizeTargetReasons(MinimizeReason::SPLIT_QUIT); } else { diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index f811e7ddb9..901d32655b 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -678,7 +678,8 @@ bool WindowRoot::CheckAddingModeAndSize(sptr& node, const sptrGetModeSupportInfo(), container->GetCurrentLayoutMode())) { + if (WindowHelper::IsInvalidWindowInTileLayoutMode(node->GetWindowModeSupportType(), + container->GetCurrentLayoutMode())) { WLOGFE("window doesn't support floating mode in tile, windowId: %{public}u", node->GetWindowId()); return false; } diff --git a/wmserver/src/zidl/window_manager_stub.cpp b/wmserver/src/zidl/window_manager_stub.cpp index 9673900624..3b318faffc 100644 --- a/wmserver/src/zidl/window_manager_stub.cpp +++ b/wmserver/src/zidl/window_manager_stub.cpp @@ -370,7 +370,7 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& data, M case WindowManagerMessage::TRANS_ID_BIND_DIALOG_TARGET: { uint32_t windowId = 0; if (!data.ReadUint32(windowId)) { - TLOGE(WmsLogTag::DEFAULT, "Failed to readInt32 windowId"); + TLOGE(WmsLogTag::DEFAULT, "Failed to read windowId"); return ERR_INVALID_DATA; } sptr targetToken = data.ReadRemoteObject(); diff --git a/wmserver/test/unittest/avoid_area_controller_test.cpp b/wmserver/test/unittest/avoid_area_controller_test.cpp index 38010fcb13..cad3428c7b 100644 --- a/wmserver/test/unittest/avoid_area_controller_test.cpp +++ b/wmserver/test/unittest/avoid_area_controller_test.cpp @@ -80,7 +80,7 @@ public: } return WMError::WM_OK; } - WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override + WMError UpdateWindowModeSupportType(uint32_t windowModeSupportType) override { return WMError::WM_OK; } diff --git a/wmserver/test/unittest/remote_animation_test.cpp b/wmserver/test/unittest/remote_animation_test.cpp index b35657476f..b02f096443 100644 --- a/wmserver/test/unittest/remote_animation_test.cpp +++ b/wmserver/test/unittest/remote_animation_test.cpp @@ -245,9 +245,9 @@ HWTEST_F(RemoteAnimationTest, CheckTransition02, Function | SmallTest | Level2) sptr dstNode = StartingWindow::CreateWindowNode(transitionInfo_, 1); ASSERT_NE(nullptr, dstNode); dstNode->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - dstNode->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); + dstNode->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); ASSERT_EQ(false, WindowHelper::CheckSupportWindowMode(dstNode->GetWindowMode(), - dstNode->GetModeSupportInfo(), transitionInfo_)); + dstNode->GetWindowModeSupportType(), transitionInfo_)); EXPECT_EQ(false, RemoteAnimation::CheckTransition(transitionInfo_, srcNode, transitionInfo_, dstNode)); } diff --git a/wmserver/test/unittest/starting_window_test.cpp b/wmserver/test/unittest/starting_window_test.cpp index 37a5886ebb..c30e416dfa 100644 --- a/wmserver/test/unittest/starting_window_test.cpp +++ b/wmserver/test/unittest/starting_window_test.cpp @@ -118,7 +118,7 @@ HWTEST_F(StartingWindowTest, NeedToStopStartingWindow01, Function | SmallTest | transitionInfo_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); sptr node = new WindowNode(CreateWindowProperty()); ASSERT_EQ(true, WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), - node->GetModeSupportInfo(), transitionInfo_)); + node->GetWindowModeSupportType(), transitionInfo_)); } /** @@ -130,9 +130,9 @@ HWTEST_F(StartingWindowTest, NeedToStopStartingWindow02, Function | SmallTest | { sptr node = new WindowNode(CreateWindowProperty()); node->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - node->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); + node->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); ASSERT_EQ(false, WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), - node->GetModeSupportInfo(), transitionInfo_)); + node->GetWindowModeSupportType(), transitionInfo_)); } /** @@ -144,7 +144,7 @@ HWTEST_F(StartingWindowTest, NeedToStopStartingWindow03, Function | SmallTest | { sptr node = new WindowNode(CreateWindowProperty()); ASSERT_EQ(false, WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), - node->GetModeSupportInfo(), transitionInfo_)); + node->GetWindowModeSupportType(), transitionInfo_)); } /** @@ -156,10 +156,10 @@ HWTEST_F(StartingWindowTest, NeedToStopStartingWindow04, Function | SmallTest | { sptr node = new WindowNode(CreateWindowProperty()); transitionInfo_->SetShowFlagWhenLocked(true); - node->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); + node->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY); ASSERT_EQ(false, WindowHelper::CheckSupportWindowMode(node->GetWindowMode(), - node->GetModeSupportInfo(), transitionInfo_)); + node->GetWindowModeSupportType(), transitionInfo_)); } /** diff --git a/wmserver/test/unittest/window_controller_test.cpp b/wmserver/test/unittest/window_controller_test.cpp index 319fd64da6..4c3147d9b9 100644 --- a/wmserver/test/unittest/window_controller_test.cpp +++ b/wmserver/test/unittest/window_controller_test.cpp @@ -128,7 +128,7 @@ HWTEST_F(WindowControllerTest, StartingWindow, Function | SmallTest | Level3) transitionInfo_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); windowController_->StartingWindow(transitionInfo_, nullptr, 0, false); transitionInfo_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); - node_->property_->modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + node_->property_->windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; windowController_->StartingWindow(transitionInfo_, nullptr, 0, false); ASSERT_EQ(1, windowRoot_->windowNodeMap_.size()); @@ -159,13 +159,13 @@ HWTEST_F(WindowControllerTest, NotifyWindowTransition, Function | SmallTest | Le sptr srcAbilityTokenMocker = new IRemoteObjectMocker(); srcInfo->SetAbilityToken(srcAbilityTokenMocker); sptr srcNode = StartingWindow::CreateWindowNode(srcInfo, 102); // 102 is windowId - srcNode->property_->modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + srcNode->property_->windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; dstInfo = new WindowTransitionInfo(); sptr dstAbilityTokenMocker = new IRemoteObjectMocker(); dstInfo->SetAbilityToken(dstAbilityTokenMocker); sptr dstNode = StartingWindow::CreateWindowNode(dstInfo, 103); // 103 is windowId - dstNode->property_->modeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; + dstNode->property_->windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; windowRoot_->windowNodeMap_.clear(); windowRoot_->windowNodeMap_.insert(std::make_pair(srcNode->GetWindowId(), srcNode)); diff --git a/wmserver/test/unittest/window_manager_config_test.cpp b/wmserver/test/unittest/window_manager_config_test.cpp index f901a1ef9c..f1c229b102 100644 --- a/wmserver/test/unittest/window_manager_config_test.cpp +++ b/wmserver/test/unittest/window_manager_config_test.cpp @@ -254,7 +254,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig01, Function | SmallTest | Level2) WindowManagerConfig::config_ = ReadConfig(xmlStr); WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, WindowManagerService::GetInstance().systemConfig_.isSystemDecorEnable_); - ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorModeSupportInfo_); + ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorWindowModeSupportType_); xmlStr = "" "" @@ -263,7 +263,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig01, Function | SmallTest | Level2) WindowManagerConfig::config_ = ReadConfig(xmlStr); WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(false, WindowManagerService::GetInstance().systemConfig_.isSystemDecorEnable_); - ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorModeSupportInfo_); + ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorWindowModeSupportType_); } /** @@ -284,7 +284,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig02, Function | SmallTest | Level2) WindowManagerConfig::config_ = ReadConfig(xmlStr); WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, sysConfig.isSystemDecorEnable_); - ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN == sysConfig.decorModeSupportInfo_); + ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN == sysConfig.decorWindowModeSupportType_); } /** @@ -305,7 +305,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig03, Function | SmallTest | Level2) WindowManagerConfig::config_ = ReadConfig(xmlStr); WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, sysConfig.isSystemDecorEnable_); - ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING == sysConfig.decorModeSupportInfo_); + ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING == sysConfig.decorWindowModeSupportType_); } /** @@ -327,7 +327,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig04, Function | SmallTest | Level2) WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, sysConfig.isSystemDecorEnable_); ASSERT_TRUE((WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN | - WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) == sysConfig.decorModeSupportInfo_); + WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) == sysConfig.decorWindowModeSupportType_); } /** @@ -349,7 +349,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig05, Function | SmallTest | Level2) WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, sysConfig.isSystemDecorEnable_); ASSERT_TRUE((WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY | - WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY) == sysConfig.decorModeSupportInfo_); + WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY) == sysConfig.decorWindowModeSupportType_); } /** @@ -370,7 +370,7 @@ HWTEST_F(WindowManagerConfigTest, DecorConfig06, Function | SmallTest | Level2) WindowManagerConfig::config_ = ReadConfig(xmlStr); WindowManagerService::GetInstance().ConfigureWindowManagerService(); ASSERT_EQ(true, sysConfig.isSystemDecorEnable_); - ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorModeSupportInfo_); + ASSERT_TRUE(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL == sysConfig.decorWindowModeSupportType_); } } // namespace } // namespace Rosen diff --git a/wmserver/test/unittest/window_manager_stub_test.cpp b/wmserver/test/unittest/window_manager_stub_test.cpp index f62e4835a7..c1ad6699a1 100644 --- a/wmserver/test/unittest/window_manager_stub_test.cpp +++ b/wmserver/test/unittest/window_manager_stub_test.cpp @@ -315,7 +315,7 @@ HWTEST_F(WindowManagerStubTest, OnRemoteRequest13, Function | SmallTest | Level2 uint32_t code = static_cast(IWindowManager::WindowManagerMessage::TRANS_ID_UPDATE_PROPERTY); int res = stub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(res, static_cast(ERR_INVALID_DATA)); + EXPECT_EQ(res, static_cast(ERR_NONE)); } /** @@ -552,6 +552,26 @@ HWTEST_F(WindowManagerStubTest, OnRemoteRequest23, Function | SmallTest | Level2 int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + +/** + * @tc.name: OnRemoteRequest24 + * @tc.desc: test TRANS_ID_GET_SNAPSHOT success + * @tc.type: FUNC + */ +HWTEST_F(WindowManagerStubTest, OnRemoteRequest24, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(WindowManagerStub::GetDescriptor()); + uint32_t writeValue = 0; + data.WriteInt32(writeValue); + uint32_t code = static_cast( + IWindowManager::WindowManagerMessage::TRANS_ID_GET_SNAPSHOT); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, static_cast(ERR_NONE)); +} } } } diff --git a/wmserver/test/unittest/window_node_test.cpp b/wmserver/test/unittest/window_node_test.cpp index 556247c5c6..044ec685eb 100644 --- a/wmserver/test/unittest/window_node_test.cpp +++ b/wmserver/test/unittest/window_node_test.cpp @@ -61,7 +61,7 @@ public: { return WMError::WM_OK; }; - virtual WMError UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override + virtual WMError UpdateWindowModeSupportType(uint32_t windowModeSupportType) override { return WMError::WM_OK; }; @@ -647,11 +647,11 @@ HWTEST_F(WindowNodeTest, SetShowingDisplays01, Function | SmallTest | Level1) } /** - * @tc.name: SetModeSupportInfo01 - * @tc.desc: SetModeSupportInfo & GetModeSupportInfo + * @tc.name: SetWindowModeSupportType01 + * @tc.desc: SetWindowModeSupportType & GetWindowModeSupportType * @tc.type: FUNC */ -HWTEST_F(WindowNodeTest, SetModeSupportInfo01, Function | SmallTest | Level1) +HWTEST_F(WindowNodeTest, SetWindowModeSupportType01, Function | SmallTest | Level1) { std::string windowName = "WindowNode22"; auto property = CreateWindowProperty(22, windowName); @@ -659,9 +659,9 @@ HWTEST_F(WindowNodeTest, SetModeSupportInfo01, Function | SmallTest | Level1) sptr windowNode = new WindowNode(property); ASSERT_NE(nullptr, windowNode); windowNode->SetWindowProperty(property); - ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, windowNode->GetModeSupportInfo()); - windowNode->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); - ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, windowNode->GetModeSupportInfo()); + ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL, windowNode->GetWindowModeSupportType()); + windowNode->SetWindowModeSupportType(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN); + ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, windowNode->GetWindowModeSupportType()); } /** diff --git a/wmserver/test/unittest/window_root_test.cpp b/wmserver/test/unittest/window_root_test.cpp index 04b3e84e55..ec00e36151 100644 --- a/wmserver/test/unittest/window_root_test.cpp +++ b/wmserver/test/unittest/window_root_test.cpp @@ -1167,7 +1167,7 @@ HWTEST_F(WindowRootTest, CheckAddingModeAndSize02, Function | SmallTest | Level2 sptr container = new WindowNodeContainer( defaultDisplay_->GetDisplayInfo(), defaultDisplay_->GetScreenId()); container->layoutMode_ = WindowLayoutMode::TILE; - node->property_->SetModeSupportInfo(0); + node->property_->SetWindowModeSupportType(0); ASSERT_TRUE((windowRoot_ != nullptr)); windowRoot_->CheckAddingModeAndSize(node, container); } @@ -1859,7 +1859,7 @@ HWTEST_F(WindowRootTest, AddWindowNode05, Function | SmallTest | Level2) WMError ret; sptr node = new WindowNode(); node->property_->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); - node->property_->SetModeSupportInfo(0); + node->property_->SetWindowModeSupportType(0); ret = windowRoot_->AddWindowNode(INVALID_WINDOW_ID, node, false); ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_DISPLAY); diff --git a/wmserver/test/unittest/window_snapshot_test.cpp b/wmserver/test/unittest/window_snapshot_test.cpp index 13a4c984f4..ad575f26c6 100644 --- a/wmserver/test/unittest/window_snapshot_test.cpp +++ b/wmserver/test/unittest/window_snapshot_test.cpp @@ -117,14 +117,14 @@ HWTEST_F(WindowSnapshotTest, GetSnapshot04, Function | SmallTest | Level3) sptr iRemoteObjectMocker = new IRemoteObjectMocker(); node->abilityToken_ = iRemoteObjectMocker; - sptr snapshotController_ = new SnapshotController(root, handler); - AAFwk::Snapshot snapshot_; + sptr snapshotController = new SnapshotController(root, handler); + AAFwk::Snapshot snapshot; ASSERT_EQ(static_cast(WMError::WM_ERROR_NULLPTR), - snapshotController_->GetSnapshot(iRemoteObjectMocker, snapshot_)); + snapshotController->GetSnapshot(iRemoteObjectMocker, snapshot)); sptr iRemoteObjectMockerInvalid = new IRemoteObjectMocker(); ASSERT_EQ(static_cast(WMError::WM_ERROR_NULLPTR), - snapshotController_->GetSnapshot(iRemoteObjectMockerInvalid, snapshot_)); + snapshotController->GetSnapshot(iRemoteObjectMockerInvalid, snapshot)); } } } // namespace Rosen