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 5a66b0d5b2db6d3517661a74fc2fae7cdade195d..cbbacbd780c98e6730c506b4b6234e11b1b13045 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 @@ -47,7 +47,7 @@ constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "JsScen constexpr int WAIT_FOR_SECONDS = 2; constexpr int MIN_ARG_COUNT = 3; constexpr int ARG_INDEX_1 = 1; -constexpr int ARG_INDEX_2 = 2; +constexpr int ARG_INDEX_TWO = 2; constexpr int ARG_INDEX_3 = 3; const std::string CREATE_SYSTEM_SESSION_CB = "createSpecificSession"; const std::string RECOVER_SCENE_SESSION_CB = "recoverSceneSession"; @@ -1800,7 +1800,7 @@ napi_value JsSceneSessionManager::OnRequestFocusStatus(napi_env env, napi_callba return NapiGetUndefined(env); } bool byForeground = false; - if (!ConvertFromJsValue(env, argv[ARG_INDEX_2], byForeground)) { + if (!ConvertFromJsValue(env, argv[ARG_INDEX_TWO], byForeground)) { WLOGFE("[NAPI]Failed to convert parameter to byForeground"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); @@ -1932,7 +1932,7 @@ napi_value JsSceneSessionManager::OnNotifyAINavigationBarShowStatus(napi_env env size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc < ARGC_TWO) { + if (argc < ARGC_THREE) { WLOGFE("[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")); @@ -1952,7 +1952,14 @@ napi_value JsSceneSessionManager::OnNotifyAINavigationBarShowStatus(napi_env env "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - SceneSessionManager::GetInstance().NotifyAINavigationBarShowStatus(isVisible, barArea); + int64_t displayId = -1; + if (!ConvertFromJsValue(env, argv[ARG_INDEX_TWO], displayId)) { + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to convert parameter to displayId"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + SceneSessionManager::GetInstance().NotifyAINavigationBarShowStatus(isVisible, barArea, displayId); return NapiGetUndefined(env); } @@ -2064,7 +2071,7 @@ napi_value JsSceneSessionManager::OnReportData(napi_env env, napi_callback_info } std::unordered_map mapPayload; - if (!ConvertStringMapFromJs(env, argv[ARG_INDEX_2], mapPayload)) { + if (!ConvertStringMapFromJs(env, argv[ARG_INDEX_TWO], mapPayload)) { WLOGFE("[NAPI]Failed to convert parameter to pauloadPid"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); diff --git a/window_scene/session/BUILD.gn b/window_scene/session/BUILD.gn index 1e6c60d2d2bc6845ac2427dcb81940283c761280..2d7db58257e675aba60f485b4aebddcba67e39c7 100755 --- a/window_scene/session/BUILD.gn +++ b/window_scene/session/BUILD.gn @@ -73,6 +73,8 @@ ohos_shared_library("scene_session") { "${window_base_path}/utils:libwmutil", "${window_base_path}/window_scene/common:window_scene_common", "${window_base_path}/window_scene/intention_event/service:intention_event_anr_manager", + "${window_base_path}/window_scene/screen_session_manager:screen_session_manager_client", + "${window_base_path}/window_scene/session:screen_session", ] public_deps = diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 31812366d2aba73fde1dce34b0d0219b8e8e8966..186eaba4385aecc6ccd275044f9fda76c4b72726 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -34,12 +34,13 @@ using SpecificSessionCreateCallback = std::function(const SessionInfo& info, sptr property)>; using SpecificSessionDestroyCallback = std::function; using CameraFloatSessionChangeCallback = std::function; -using GetSceneSessionVectorByTypeCallback = std::function>(WindowType type)>; +using GetSceneSessionVectorByTypeCallback = std::function>( + WindowType type, uint64_t displayId)>; using UpdateAvoidAreaCallback = std::function; using NotifyWindowInfoUpdateCallback = std::function; using NotifyWindowPidChangeCallback = std::function; using NotifySessionTouchOutsideCallback = std::function; -using GetAINavigationBarArea = std::function; +using GetAINavigationBarArea = std::function; using RecoveryCallback = std::function; using NotifyBindDialogSessionFunc = std::function& session)>; using NotifySessionRectChangeFunc = std::function; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1fd834691a18e9a20bdab157997e568fc35e5b26..461d4e5860d672ed86b487fde6a624727741ca8d 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -40,6 +40,7 @@ #include "wm_math.h" #include #include "singleton_container.h" +#include "screen_session_manager/include/screen_session_manager_client.h" namespace OHOS::Rosen { namespace { @@ -760,12 +761,15 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) if (GetSessionProperty()->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_NEED_AVOID)) { return; } + uint64_t displayId = GetSessionProperty()->GetDisplayId(); + auto screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(displayId); if ((Session::GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING || Session::GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || Session::GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) && WindowHelper::IsMainWindow(Session::GetWindowType()) && (system::GetParameter("const.product.devicetype", "unknown") == "phone" || - system::GetParameter("const.product.devicetype", "unknown") == "tablet")) { + system::GetParameter("const.product.devicetype", "unknown") == "tablet") && + (!screenSession || screenSession->GetName() != "HiCar")) { float miniScale = 0.316f; // Pressed mini floating Scale with 0.001 precision if (Session::GetFloatingScale() <= miniScale) { return; @@ -780,8 +784,11 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) avoidArea.topRect_.width_ = display->GetWidth(); return; } - std::vector> statusBarVector = - specificCallback_->onGetSceneSessionVectorByType_(WindowType::WINDOW_TYPE_STATUS_BAR); + std::vector> statusBarVector; + if (specificCallback_ != nullptr && specificCallback_->onGetSceneSessionVectorByType_) { + statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( + WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); + } for (auto& statusBar : statusBarVector) { if (!(statusBar->isVisible_)) { continue; @@ -803,8 +810,15 @@ void SceneSession::GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea) system::GetParameter("const.product.devicetype", "unknown") == "tablet")) { return; } - std::vector> inputMethodVector = - specificCallback_->onGetSceneSessionVectorByType_(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); + if (!GetSessionProperty()) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to get session property"); + return; + } + std::vector> inputMethodVector; + if (specificCallback_ != nullptr && specificCallback_->onGetSceneSessionVectorByType_) { + inputMethodVector = specificCallback_->onGetSceneSessionVectorByType_( + WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, GetSessionProperty()->GetDisplayId()); + } for (auto& inputMethod : inputMethodVector) { if (inputMethod->GetSessionState() != SessionState::STATE_FOREGROUND && inputMethod->GetSessionState() != SessionState::STATE_ACTIVE) { @@ -859,7 +873,14 @@ void SceneSession::GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea) Session::GetWindowMode() == WindowMode::WINDOW_MODE_PIP) { return; } - WSRect barArea = specificCallback_->onGetAINavigationBarArea_(); + if (!GetSessionProperty()) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to get session property"); + return; + } + WSRect barArea; + if (specificCallback_ != nullptr && specificCallback_->onGetAINavigationBarArea_) { + barArea = specificCallback_->onGetAINavigationBarArea_(GetSessionProperty()->GetDisplayId()); + } CalculateAvoidAreaRect(rect, barArea, avoidArea); } @@ -1359,9 +1380,16 @@ void SceneSession::UpdateWinRectForSystemBar(WSRect& rect) WLOGFE("specificCallback_ is null!"); return; } + if (!GetSessionProperty()) { + WLOGFE("get session property is null!"); + return; + } float tmpPosY = 0.0; - std::vector> statusBarVector = - specificCallback_->onGetSceneSessionVectorByType_(WindowType::WINDOW_TYPE_STATUS_BAR); + std::vector> statusBarVector; + if (specificCallback_->onGetSceneSessionVectorByType_) { + statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( + WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); + } for (auto& statusBar : statusBarVector) { if (!(statusBar->isVisible_)) { continue; diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index f56fcd843392f70fd921658f1d588c741827e138..9ad418d9dd2f251d556d67597fdd59c296dc5d70 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -262,8 +262,8 @@ public: WSError UpdateSessionDisplayId(int32_t persistentId, uint64_t screenId); void NotifySessionUpdate(const SessionInfo& sessionInfo, ActionType type, ScreenId fromScreenId = SCREEN_ID_INVALID); - WSError NotifyAINavigationBarShowStatus(bool isVisible, WSRect barArea); - WSRect GetAINavigationBarArea(); + WSError NotifyAINavigationBarShowStatus(bool isVisible, WSRect barArea, uint64_t displayId); + WSRect GetAINavigationBarArea(uint64_t displayId); bool UpdateImmersiveState(); WMError GetSurfaceNodeIdsFromMissionIds(std::vector& missionIds, std::vector& surfaceNodeIds); @@ -356,14 +356,14 @@ private: WSError UpdateParentSessionForDialog(const sptr& sceneSession, sptr property); void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); void UpdateFocusableProperty(int32_t persistentId); - std::vector> GetSceneSessionVectorByType(WindowType type); + std::vector> GetSceneSessionVectorByType(WindowType type, uint64_t displayId); bool UpdateSessionAvoidAreaIfNeed(const int32_t& persistentId, const sptr& sceneSession, const AvoidArea& avoidArea, AvoidAreaType avoidAreaType); void UpdateAvoidSessionAvoidArea(WindowType type, bool& needUpdate); void UpdateNormalSessionAvoidArea(const int32_t& persistentId, sptr& sceneSession, bool& needUpdate); void UpdateAvoidArea(const int32_t& persistentId); void NotifyMMIWindowPidChange(int32_t windowId, bool startMoving); - int32_t GetStatusBarHeight(); + int32_t GetStatusBarHeight(uint64_t displayId); sptr GetBundleManager(); std::shared_ptr GetResourceManager(const AppExecFwk::AbilityInfo& abilityInfo); @@ -430,6 +430,7 @@ private: WMError UpdatePropertyRaiseEnabled(const sptr& property, const sptr& sceneSession); void ClosePipWindowIfExist(WindowType type); + void NotifySessionAINavigationBarChange(int32_t persistentId); WSError DestroyAndDisconnectSpecificSessionInner(sptr sceneSession); sptr rootSceneSession_; @@ -488,7 +489,8 @@ private: sptr appAnrListener_; bool isAINavigationBarVisible_ = false; - WSRect currAINavigationBarArea_; + std::shared_mutex currAINavigationBarAreaMapMutex_; + std::map currAINavigationBarAreaMap_; std::shared_ptr eventLoop_; std::shared_ptr eventHandler_; diff --git a/window_scene/session_manager/include/screen_scene_config.h b/window_scene/session_manager/include/screen_scene_config.h index e8c19cf3d130a6498d1e49373c36ffce635badf3..17b37b60f7f2da69a01171da00922c7a701b6455 100644 --- a/window_scene/session_manager/include/screen_scene_config.h +++ b/window_scene/session_manager/include/screen_scene_config.h @@ -34,8 +34,8 @@ public: static const std::map>& GetIntNumbersConfig(); static const std::map& GetStringConfig(); static void DumpConfig(); - static std::vector GetCutoutBoundaryRect(); - static void SetCutoutSvgPath(const std::string& svgPath); + static std::vector GetCutoutBoundaryRect(uint64_t displayId); + static void SetCutoutSvgPath(uint64_t displayId, const std::string& svgPath); static bool IsWaterfallDisplay(); static void SetCurvedCompressionAreaInLandscape(); static std::vector GetCurvedScreenBoundaryConfig(); @@ -45,7 +45,7 @@ private: static std::map enableConfig_; static std::map> intNumbersConfig_; static std::map stringConfig_; - static std::vector cutoutBoundaryRect_; + static std::map> cutoutBoundaryRectMap_; static bool isWaterfallDisplay_; static bool isScreenCompressionEnableInLandscape_; static uint32_t curvedAreaInLandscape_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 738a05aa7ddce5ffa47df43ab2a2badd433599e0..2166c67bf2b33eb587968069805adf5ec0e75c45 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -859,13 +859,20 @@ sptr SceneSessionManager::GetSceneSessionByName(const std::string& return nullptr; } -std::vector> SceneSessionManager::GetSceneSessionVectorByType(WindowType type) +std::vector> SceneSessionManager::GetSceneSessionVectorByType( + WindowType type, uint64_t displayId) { + if (displayId == DISPLAY_ID_INVALID) { + TLOGE(WmsLogTag::WMS_LIFE, "displayId is invalid"); + return {}; + } std::vector> sceneSessionVector; std::shared_lock lock(sceneSessionMapMutex_); for (const auto &item : sceneSessionMap_) { auto sceneSession = item.second; - if (sceneSession->GetWindowType() == type) { + if (sceneSession->GetWindowType() == type && + sceneSession->GetSessionProperty() && + sceneSession->GetSessionProperty()->GetDisplayId() == displayId) { sceneSessionVector.emplace_back(sceneSession); } } @@ -914,7 +921,7 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onCameraFloatSessionChange_ = std::bind(&SceneSessionManager::UpdateCameraFloatWindowStatus, this, std::placeholders::_1, std::placeholders::_2); specificCb->onGetSceneSessionVectorByType_ = std::bind(&SceneSessionManager::GetSceneSessionVectorByType, - this, std::placeholders::_1); + this, std::placeholders::_1, std::placeholders::_2); specificCb->onUpdateAvoidArea_ = std::bind(&SceneSessionManager::UpdateAvoidArea, this, std::placeholders::_1); specificCb->onWindowInfoUpdate_ = std::bind(&SceneSessionManager::NotifyWindowInfoChange, this, std::placeholders::_1, std::placeholders::_2); @@ -922,7 +929,8 @@ sptr SceneSessionManager::CreateSpecificS this, std::placeholders::_1, std::placeholders::_2); specificCb->onSessionTouchOutside_ = std::bind(&SceneSessionManager::NotifySessionTouchOutside, this, std::placeholders::_1); - specificCb->onGetAINavigationBarArea_ = std::bind(&SceneSessionManager::GetAINavigationBarArea, this); + specificCb->onGetAINavigationBarArea_ = std::bind(&SceneSessionManager::GetAINavigationBarArea, + this, std::placeholders::_1); specificCb->onOutsideDownEvent_ = std::bind(&SceneSessionManager::OnOutsideDownEvent, this, std::placeholders::_1, std::placeholders::_2); specificCb->onHandleSecureSessionShouldHide_ = std::bind(&SceneSessionManager::HandleSecureSessionShouldHide, @@ -5237,11 +5245,12 @@ void SceneSessionManager::StartWindowInfoReportLoop() isReportTaskStart_ = true; } -int32_t SceneSessionManager::GetStatusBarHeight() +int32_t SceneSessionManager::GetStatusBarHeight(uint64_t displayId) { int32_t statusBarHeight = 0; int32_t height = 0; - std::vector> statusBarVector = GetSceneSessionVectorByType(WindowType::WINDOW_TYPE_STATUS_BAR); + std::vector> statusBarVector = GetSceneSessionVectorByType( + WindowType::WINDOW_TYPE_STATUS_BAR, displayId); for (auto& statusBar : statusBarVector) { if (statusBar == nullptr || !IsSessionVisible(statusBar)) { continue; @@ -5260,6 +5269,10 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( TLOGI(WmsLogTag::WMS_KEYBOARD, "calling session is nullptr"); return; } + if (!sceneSession->GetSessionProperty()) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "scene session property is nullptr"); + return; + } SessionGravity gravity; uint32_t percent = 0; sceneSession->GetSessionProperty()->GetSessionGravity(gravity, percent); @@ -5268,13 +5281,8 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( return; } - bool isCallingSessionFloating; - if (callingSession_->GetSessionProperty() && - callingSession_->GetSessionProperty()->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) { - isCallingSessionFloating = true; - } else { - isCallingSessionFloating = false; - } + bool isCallingSessionFloating = callingSession_->GetSessionProperty() && + callingSession_->GetSessionProperty()->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING; const WSRect& softInputSessionRect = sceneSession->GetSessionRect(); WSRect callingSessionRect; @@ -5291,7 +5299,7 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( } WSRect newRect = callingSessionRect; - int32_t statusHeight = GetStatusBarHeight(); + int32_t statusHeight = GetStatusBarHeight(sceneSession->GetSessionProperty()->GetDisplayId()); if (isCallingSessionFloating && callingSessionRect.posY_ > statusHeight) { // calculate new rect of calling window newRect.posY_ = softInputSessionRect.posY_ - static_cast(newRect.height_); @@ -6157,36 +6165,33 @@ void SceneSessionManager::UpdateAvoidArea(const int32_t& persistentId) return; } -WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSRect barArea) +WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSRect barArea, uint64_t displayId) { - WLOGFI("NotifyAINavigationBarShowStatus: isVisible: %{public}u, area{%{public}d,%{public}d,%{public}d,%{public}d}", - isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_); - auto task = [this, isVisible, barArea]() { - if (isAINavigationBarVisible_ != isVisible || currAINavigationBarArea_ != barArea) { - isAINavigationBarVisible_ = isVisible; - currAINavigationBarArea_ = barArea; - if (!isVisible && !barArea.IsEmpty()) { + WLOGFI("NotifyAINavigationBarShowStatus: isVisible: %{public}u, " \ + "area{%{public}d,%{public}d,%{public}d,%{public}d}, displayId: %{public}" PRIu64"", + isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_, displayId); + auto task = [this, isVisible, barArea, displayId]() { + bool isNeedUpdate = false; + { + std::unique_lock lock(currAINavigationBarAreaMapMutex_); + isNeedUpdate = isAINavigationBarVisible_ != isVisible || + currAINavigationBarAreaMap_.count(displayId) == 0 || + currAINavigationBarAreaMap_[displayId] != barArea; + if (isNeedUpdate) { + isAINavigationBarVisible_ = isVisible; + currAINavigationBarAreaMap_.clear(); + currAINavigationBarAreaMap_[displayId] = barArea; + } + if (isNeedUpdate && !isVisible && !barArea.IsEmpty()) { WLOGFD("NotifyAINavigationBarShowStatus: barArea should be empty if invisible"); - currAINavigationBarArea_ = WSRect(); + currAINavigationBarAreaMap_[displayId] = WSRect(); } + } + if (isNeedUpdate) { WLOGFI("NotifyAINavigationBarShowStatus: enter: %{public}u, {%{public}d,%{public}d,%{public}d,%{public}d}", isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_); for (auto persistentId : avoidAreaListenerSessionSet_) { - auto sceneSession = GetSceneSession(persistentId); - if (sceneSession == nullptr || !IsSessionVisible(sceneSession)) { - continue; - } - AvoidArea avoidArea = sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_NAVIGATION_INDICATOR); - if (!CheckAvoidAreaForAINavigationBar(isAINavigationBarVisible_, avoidArea, - sceneSession->GetSessionRect().posY_ + sceneSession->GetSessionRect().height_)) { - continue; - } - WLOGFI("NotifyAINavigationBarShowStatus: persistentId: %{public}d, " - "{%{public}d,%{public}d,%{public}d,%{public}d}", persistentId, - avoidArea.bottomRect_.posX_, avoidArea.bottomRect_.posY_, - avoidArea.bottomRect_.width_, avoidArea.bottomRect_.height_); - UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, - AvoidAreaType::TYPE_NAVIGATION_INDICATOR); + NotifySessionAINavigationBarChange(persistentId); } } }; @@ -6194,9 +6199,32 @@ WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSR return WSError::WS_OK; } -WSRect SceneSessionManager::GetAINavigationBarArea() +void SceneSessionManager::NotifySessionAINavigationBarChange(int32_t persistentId) +{ + auto sceneSession = GetSceneSession(persistentId); + if (sceneSession == nullptr || !IsSessionVisible(sceneSession)) { + return; + } + AvoidArea avoidArea = sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_NAVIGATION_INDICATOR); + if (!CheckAvoidAreaForAINavigationBar(isAINavigationBarVisible_, avoidArea, + sceneSession->GetSessionRect().posY_ + sceneSession->GetSessionRect().height_)) { + return; + } + WLOGFI("NotifyAINavigationBarShowStatus: persistentId: %{public}d, " + "{%{public}d,%{public}d,%{public}d,%{public}d}", persistentId, + avoidArea.bottomRect_.posX_, avoidArea.bottomRect_.posY_, + avoidArea.bottomRect_.width_, avoidArea.bottomRect_.height_); + UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, + AvoidAreaType::TYPE_NAVIGATION_INDICATOR); +} + +WSRect SceneSessionManager::GetAINavigationBarArea(uint64_t displayId) { - return currAINavigationBarArea_; + std::shared_lock lock(currAINavigationBarAreaMapMutex_); + if (currAINavigationBarAreaMap_.count(displayId) == 0) { + return {}; + } + return currAINavigationBarAreaMap_[displayId]; } WSError SceneSessionManager::UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener) diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index ca36ab836f8e8a9b650832f7e34dbb275a890328..01d9fcc876f69585c72bb3f3145f3a0980742d37 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -37,7 +37,7 @@ sptr ScreenCutoutController::GetScreenCutoutInfo(DisplayId displayId { WLOGFD("get screen cutout info."); std::vector boundaryRects; - if (!ScreenSceneConfig::GetCutoutBoundaryRect().empty()) { + if (!ScreenSceneConfig::GetCutoutBoundaryRect(displayId).empty()) { ConvertBoundaryRectsByRotation(boundaryRects, displayId); } @@ -62,7 +62,7 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& (ScreenSessionManager::GetInstance().GetFoldStatus() == FoldStatus::FOLDED)) { displayBoundaryRects = {{ 507, 18, 66, 66}}; // x:507, y:18, w:66, h:66 } else { - displayBoundaryRects = ScreenSceneConfig::GetCutoutBoundaryRect(); + displayBoundaryRects = ScreenSceneConfig::GetCutoutBoundaryRect(displayId); } CheckBoundaryRects(displayBoundaryRects, displayInfo); if (currentRotation == Rotation::ROTATION_0) { diff --git a/window_scene/session_manager/src/screen_scene_config.cpp b/window_scene/session_manager/src/screen_scene_config.cpp index 9d707dcd3844e5225f8bcf70f8b7087e34d491ca..47aa7455cdc5a993e3f5cf8b5941b1a7650e7da6 100644 --- a/window_scene/session_manager/src/screen_scene_config.cpp +++ b/window_scene/session_manager/src/screen_scene_config.cpp @@ -44,7 +44,7 @@ constexpr uint32_t NO_WATERFALL_DISPLAY_COMPRESSION_SIZE = 0; std::map ScreenSceneConfig::enableConfig_; std::map> ScreenSceneConfig::intNumbersConfig_; std::map ScreenSceneConfig::stringConfig_; -std::vector ScreenSceneConfig::cutoutBoundaryRect_; +std::map> ScreenSceneConfig::cutoutBoundaryRectMap_; bool ScreenSceneConfig::isWaterfallDisplay_ = false; bool ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false; uint32_t ScreenSceneConfig::curvedAreaInLandscape_ = 0; @@ -245,10 +245,10 @@ void ScreenSceneConfig::DumpConfig() } } -void ScreenSceneConfig::SetCutoutSvgPath(const std::string& svgPath) +void ScreenSceneConfig::SetCutoutSvgPath(uint64_t displayId, const std::string& svgPath) { - cutoutBoundaryRect_.clear(); - cutoutBoundaryRect_.emplace_back(CalcCutoutBoundaryRect(svgPath)); + cutoutBoundaryRectMap_.clear(); + cutoutBoundaryRectMap_[displayId].emplace_back(CalcCutoutBoundaryRect(svgPath)); } DMRect ScreenSceneConfig::CalcCutoutBoundaryRect(std::string svgPath) @@ -284,9 +284,12 @@ DMRect ScreenSceneConfig::CalcCutoutBoundaryRect(std::string svgPath) return cutoutMinOuterRect; } -std::vector ScreenSceneConfig::GetCutoutBoundaryRect() +std::vector ScreenSceneConfig::GetCutoutBoundaryRect(uint64_t displayId) { - return cutoutBoundaryRect_; + if (cutoutBoundaryRectMap_.count(displayId) == 0) { + return {}; + } + return cutoutBoundaryRectMap_[displayId]; } bool ScreenSceneConfig::IsWaterfallDisplay() diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 0fa1386bf63325dc14083a85e8244c49be9d5d88..1785df9be45b54527c438997b8a8bcf3aa527481 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -261,7 +261,7 @@ void ScreenSessionManager::ConfigureScreenScene() if (stringConfig.count("defaultDisplayCutoutPath") != 0) { std::string defaultDisplayCutoutPath = static_cast(stringConfig["defaultDisplayCutoutPath"]); WLOGFD("defaultDisplayCutoutPath = %{public}s.", defaultDisplayCutoutPath.c_str()); - ScreenSceneConfig::SetCutoutSvgPath(defaultDisplayCutoutPath); + ScreenSceneConfig::SetCutoutSvgPath(GetDefaultScreenId(), defaultDisplayCutoutPath); } ConfigureWaterfallDisplayCompressionParams(); diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 706aafd5a5d484179bf9ba35764f1fd31ff995ca..40cf58295fd2163d30cb4479fdf1ed58db3f85bf 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -1785,7 +1785,8 @@ HWTEST_F(SceneSessionManagerTest, GetSceneSessionByName, Function | SmallTest | HWTEST_F(SceneSessionManagerTest, GetSceneSessionVectorByType, Function | SmallTest | Level3) { int ret = 0; - ssm_->GetSceneSessionVectorByType(WindowType::APP_MAIN_WINDOW_BASE); + uint64_t displayId = 0; + ssm_->GetSceneSessionVectorByType(WindowType::APP_MAIN_WINDOW_BASE, displayId); ASSERT_EQ(ret, 0); } @@ -3005,7 +3006,8 @@ HWTEST_F(SceneSessionManagerTest, NotifyAINavigationBarShowStatus, Function | Sm { bool isVisible = false; WSRect barArea = { 0, 0, 320, 240}; // width: 320, height: 240 - WSError result = ssm_->NotifyAINavigationBarShowStatus(isVisible, barArea); + uint64_t displayId = 0; + WSError result = ssm_->NotifyAINavigationBarShowStatus(isVisible, barArea, displayId); ASSERT_EQ(result, WSError::WS_OK); } diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index e10a701f11ab61ee1f11326a25e3fcc30dab9582..2dc6dbe2fa3458efc190aefe8d9ea823f0952a53 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -755,7 +755,8 @@ HWTEST_F(SceneSessionTest, GetKeyboardAvoidArea, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - specificCallback_->onGetSceneSessionVectorByType_ = [](WindowType type) -> std::vector> { + specificCallback_->onGetSceneSessionVectorByType_ = [](WindowType type, + uint64_t displayId) -> std::vector> { std::vector> backgroundSession; return backgroundSession; }; @@ -892,7 +893,8 @@ HWTEST_F(SceneSessionTest, GetAvoidAreaByType, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - specificCallback_->onGetSceneSessionVectorByType_ = [](WindowType type)-> std::vector> + specificCallback_->onGetSceneSessionVectorByType_ = [](WindowType type, + uint64_t displayId)-> std::vector> { SessionInfo info_; info_.abilityName_ = "Background01"; diff --git a/window_scene/test/unittest/screen_scene_config_test.cpp b/window_scene/test/unittest/screen_scene_config_test.cpp index ff43835e83898555e827d5c2baa6e6fc6b881df4..e33697d4125a7f8d8059a578e2bfff3cafc538d1 100644 --- a/window_scene/test/unittest/screen_scene_config_test.cpp +++ b/window_scene/test/unittest/screen_scene_config_test.cpp @@ -310,7 +310,8 @@ HWTEST_F(ScreenSceneConfigTest, GetCurvedScreenBoundaryConfig, Function | SmallT */ HWTEST_F(ScreenSceneConfigTest, GetCutoutBoundaryRect, Function | SmallTest | Level3) { - auto result = ScreenSceneConfig::GetCutoutBoundaryRect(); + uint64_t displayId = -1; + auto result = ScreenSceneConfig::GetCutoutBoundaryRect(displayId); ASSERT_FALSE(result.size() > 0); } @@ -368,8 +369,9 @@ HWTEST_F(ScreenSceneConfigTest, CalcCutoutBoundaryRect, Function | SmallTest | L */ HWTEST_F(ScreenSceneConfigTest, SetCutoutSvgPath, Function | SmallTest | Level3) { - ScreenSceneConfig::SetCutoutSvgPath("oo"); - auto result_ = ScreenSceneConfig::GetCutoutBoundaryRect(); + uint64_t displayId = 0; + ScreenSceneConfig::SetCutoutSvgPath(displayId, "oo"); + auto result_ = ScreenSceneConfig::GetCutoutBoundaryRect(displayId); ASSERT_NE(0, result_.size()); }