From cc943e046fa7b677965d58c19b5226998d63ad42 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 4 Jan 2025 16:04:52 +0800 Subject: [PATCH 01/36] =?UTF-8?q?=E7=BB=99=E7=8A=B6=E6=80=81=E6=A0=8F?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3=EF=BC=8C=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=A0=8F=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6=E4=BC=A0=E5=85=A5?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=A0=8F=E9=AB=98=E5=BA=A6=EF=BC=8C=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E7=94=A8=E6=AD=A4=E9=AB=98=E5=BA=A6=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=81=BF=E8=AE=A9=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangzilin --- .../js_scene_session_manager.cpp | 41 +++++++++++++++++++ .../js_scene_session_manager.h | 2 + .../session/host/include/scene_session.h | 2 + .../session/host/src/scene_session.cpp | 6 +++ .../include/scene_session_manager.h | 3 ++ .../src/scene_session_manager.cpp | 18 ++++++++ 6 files changed, 72 insertions(+) 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 19a6f88bd1..674f3c6897 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 @@ -238,6 +238,8 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::SetIsWindowRectAutoSave); BindNativeFunction(env, exportObj, "notifyAboveLockScreen", moduleName, JsSceneSessionManager::NotifyAboveLockScreen); + BindNativeFunction(env, exportObj, "setStatusBarDefaultHeightPerDisplay", moduleName, + JsSceneSessionManager::SetStatusBarDefaultHeightPerDisplay); return NapiGetUndefined(env); } @@ -1212,6 +1214,12 @@ napi_value JsSceneSessionManager::NotifyAboveLockScreen(napi_env env, napi_callb return me->OnNotifyAboveLockScreen(env, info); } +napi_value JsSceneSessionManager::SetStatusBarDefaultHeightPerDisplay(napi_env env, napi_callback_info info) +{ + JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetStatusBarDefaultHeightPerDisplay(env, info) : nullptr; +} + 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()); @@ -3979,4 +3987,37 @@ void JsSceneSessionManager::OnWatchFocusActiveChange(bool isActive) napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); }, __func__); } + +napi_value JsSceneSessionManager::OnSetStatusBarDefaultHeightPerDisplay(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_TWO) { + TLOGE(WmsLogTag::WMS_IMMS, "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); + } + int64_t displayId = -1; + if (!ConvertFromJsValue(env, argv[0], displayId)) { + TLOGE(WmsLogTag::WMS_IMMS, "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); + } + if (displayId < 0) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to displayId"); + return NapiGetUndefined(env); + } + uint32_t height = 0; + if (!ConvertFromJsValue(env, argv[1], height)) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to height"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + SceneSessionManager::GetInstance().SetStatusBarDefaultHeightPerDisplay(static_cast(displayId), height); + return NapiGetUndefined(env); +} } // namespace OHOS::Rosen 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 f81bfe9414..bd7469b646 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 @@ -125,6 +125,7 @@ public: 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); + static napi_value SetStatusBarDefaultHeightPerDisplay(napi_env env, napi_callback_info info); /* * Multi Instance @@ -205,6 +206,7 @@ private: 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); + napi_value OnSetStatusBarDefaultHeightPerDisplay(napi_env env, napi_callback_info info); /* * Multi Instance diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 6751adf26e..75ff2c4c6b 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -102,6 +102,7 @@ using UpdateAppUseControlFunc = std::function& avoidArea, AvoidAreaType type)>; using NotifySetSupportWindowModesFunc = std::function&& supportWindowModes)>; +using GetStatusBarDefaultHeightByDisplayIdFunc = std::function; struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; @@ -135,6 +136,7 @@ public: PiPStateChangeCallback onPiPStateChange_; UpdateGestureBackEnabledCallback onUpdateGestureBackEnabled_; NotifyAvoidAreaChangeCallback onNotifyAvoidAreaChange_; + GetStatusBarDefaultHeightByDisplayIdFunc onGetStatusBarDefaultHeightByDisplayId_; }; // func for change window scene pattern property diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 68cc15f04b..94dc716e19 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1860,6 +1860,12 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar not visible", GetPersistentId()); continue; } + if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarDefaultHeightByDisplay_) { + statusBarRect.height_ = specificCallback_->onGetStatusBarDefaultHeightByDisplay_( + GetSessionProperty()->GetDisplayId()); + TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d display %{public}d status bar default height %{public}d", + GetPersistentId(), GetSessionProperty()->GetDisplayId(), statusBarRect.height_); + } TLOGI(WmsLogTag::WMS_IMMS, "win %{public}s status bar %{public}s", rect.ToString().c_str(), statusBarRect.ToString().c_str()); CalculateAvoidAreaRect(rect, statusBarRect, avoidArea); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 9d0df69958..dc45c8c3b4 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -381,6 +381,8 @@ public: void SetIsRootSceneLastFrameLayoutFinishedFunc(IsRootSceneLastFrameLayoutFinishedFunc&& func); void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); + void SetStatusBarDefaultHeightPerDisplay(DisplayId displayId, bool visible); + bool GetStatusBarDefaultHeightByDisplayId(DisplayId displayId); WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; void DealwithVisibilityChange(const std::vector>& visibilityChangeInfos, @@ -1130,6 +1132,7 @@ private: std::unordered_map statusBarDefaultVisibilityPerDisplay_; std::set avoidAreaListenerSessionSet_; std::map> lastUpdatedAvoidArea_; + std::unordered_map statusBarDefaultHeightPerDisplay_; struct SessionInfoList { int32_t uid_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 0e598fd97f..80642dde83 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1458,6 +1458,9 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onUpdateGestureBackEnabled_ = [this](int32_t persistentId) { this->UpdateGestureBackEnabled(persistentId); }; + specificCb->onGetStatusBarDefaultHeightByDisplayId_ = [this](DisplayId displayId) { + return this->GetStatusBarDefaultHeightByDisplayId(displayId); + }; return specificCb; } @@ -12401,4 +12404,19 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent return WMError::WM_OK; }, __func__); } + +void SceneSessionManager::SetStatusBarDefaultHeightPerDisplay(DisplayId displayId, uint32_t height) +{ + taskScheduler_->PostAsyncTask([this, displayId, height] { + statusBarDefaultHeightPerDisplay_[displayId] = height; + TLOGNI(WmsLogTag::WMS_IMMS, "set status bar default height: %{public}u", height); + }, __func__); +} + +uint32_t SceneSessionManager::GetStatusBarDefaultHeightByDisplay(DisplayId displayId) +{ + return statusBarDefaultHeightPerDisplay_.count(displayId) != 0 ? + statusBarDefaultHeightPerDisplay_[displayId] : 0; +} + } // namespace OHOS::Rosen -- Gitee From b7d95fbe17c3b69596c0b98dbfbc141dcbc2b12e Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 4 Jan 2025 16:34:20 +0800 Subject: [PATCH 02/36] fix bug Signed-off-by: wangzilin --- window_scene/session/host/src/scene_session.cpp | 4 ++-- window_scene/session_manager/include/scene_session_manager.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 94dc716e19..c17d59228f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1860,8 +1860,8 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar not visible", GetPersistentId()); continue; } - if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarDefaultHeightByDisplay_) { - statusBarRect.height_ = specificCallback_->onGetStatusBarDefaultHeightByDisplay_( + if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarDefaultHeightByDisplayId_) { + statusBarRect.height_ = specificCallback_->onGetStatusBarDefaultHeightByDisplayId_( GetSessionProperty()->GetDisplayId()); TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d display %{public}d status bar default height %{public}d", GetPersistentId(), GetSessionProperty()->GetDisplayId(), statusBarRect.height_); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index dc45c8c3b4..09b0ad6fbd 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -382,7 +382,7 @@ public: void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); void SetStatusBarDefaultHeightPerDisplay(DisplayId displayId, bool visible); - bool GetStatusBarDefaultHeightByDisplayId(DisplayId displayId); + uint32_t GetStatusBarDefaultHeightByDisplayId(DisplayId displayId); WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; void DealwithVisibilityChange(const std::vector>& visibilityChangeInfos, -- Gitee From 92b7859b0f10365eb097b2c45919e2826b41251a Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 4 Jan 2025 16:39:14 +0800 Subject: [PATCH 03/36] fix bug Signed-off-by: wangzilin --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 80642dde83..0a0770d45e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12413,7 +12413,7 @@ void SceneSessionManager::SetStatusBarDefaultHeightPerDisplay(DisplayId displayI }, __func__); } -uint32_t SceneSessionManager::GetStatusBarDefaultHeightByDisplay(DisplayId displayId) +uint32_t SceneSessionManager::GetStatusBarDefaultHeightByDisplayId(DisplayId displayId) { return statusBarDefaultHeightPerDisplay_.count(displayId) != 0 ? statusBarDefaultHeightPerDisplay_[displayId] : 0; -- Gitee From 2b2fa67ed4d42bd83436e9f0f8179a7ea68d5454 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 4 Jan 2025 16:44:16 +0800 Subject: [PATCH 04/36] fix bug Signed-off-by: wangzilin --- window_scene/session_manager/include/scene_session_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 09b0ad6fbd..68bcf75a33 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -381,7 +381,7 @@ public: void SetIsRootSceneLastFrameLayoutFinishedFunc(IsRootSceneLastFrameLayoutFinishedFunc&& func); void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); - void SetStatusBarDefaultHeightPerDisplay(DisplayId displayId, bool visible); + void SetStatusBarDefaultHeightPerDisplay(DisplayId displayId, uint32_t height); uint32_t GetStatusBarDefaultHeightByDisplayId(DisplayId displayId); WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; -- Gitee From 0cca3da0d6415f7fec93ea99be917ac1e39b809b Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 4 Jan 2025 17:08:20 +0800 Subject: [PATCH 05/36] fix bug Signed-off-by: wangzilin --- window_scene/session/host/include/scene_session.h | 2 +- window_scene/session/host/src/scene_session.cpp | 6 +++--- .../session_manager/include/scene_session_manager.h | 2 +- .../session_manager/src/scene_session_manager.cpp | 9 ++++++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 75ff2c4c6b..3c927119fb 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -102,7 +102,7 @@ using UpdateAppUseControlFunc = std::function& avoidArea, AvoidAreaType type)>; using NotifySetSupportWindowModesFunc = std::function&& supportWindowModes)>; -using GetStatusBarDefaultHeightByDisplayIdFunc = std::function; +using GetStatusBarDefaultHeightByDisplayIdFunc = std::function; struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index c17d59228f..41da2f5590 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1861,9 +1861,9 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) continue; } if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarDefaultHeightByDisplayId_) { - statusBarRect.height_ = specificCallback_->onGetStatusBarDefaultHeightByDisplayId_( - GetSessionProperty()->GetDisplayId()); - TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d display %{public}d status bar default height %{public}d", + specificCallback_->onGetStatusBarDefaultHeightByDisplayId_( + GetSessionProperty()->GetDisplayId(), statusBarRect); + TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d display %{public}llu status bar height %{public}u", GetPersistentId(), GetSessionProperty()->GetDisplayId(), statusBarRect.height_); } TLOGI(WmsLogTag::WMS_IMMS, "win %{public}s status bar %{public}s", diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 68bcf75a33..89b5da27e4 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -382,7 +382,7 @@ public: void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); void SetStatusBarDefaultHeightPerDisplay(DisplayId displayId, uint32_t height); - uint32_t GetStatusBarDefaultHeightByDisplayId(DisplayId displayId); + void GetStatusBarDefaultHeightByDisplayId(DisplayId displayId, WSRect& barArea); WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; void DealwithVisibilityChange(const std::vector>& visibilityChangeInfos, diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 0a0770d45e..538d9f0e2a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12413,10 +12413,13 @@ void SceneSessionManager::SetStatusBarDefaultHeightPerDisplay(DisplayId displayI }, __func__); } -uint32_t SceneSessionManager::GetStatusBarDefaultHeightByDisplayId(DisplayId displayId) +void SceneSessionManager::GetStatusBarDefaultHeightByDisplayId(DisplayId displayId, WSRect& barArea) { - return statusBarDefaultHeightPerDisplay_.count(displayId) != 0 ? - statusBarDefaultHeightPerDisplay_[displayId] : 0; + if (!statusBarDefaultHeightPerDisplay_.count(displayId)) { + TLOGD(WmsLogTag::WMS_IMMS, "display %{public}llu failed", displayId); + } + barArea.height_ = statusBarDefaultHeightPerDisplay_.count(displayId) != 0 ? + statusBarDefaultHeightPerDisplay_[displayId] : barArea.height_; } } // namespace OHOS::Rosen -- Gitee From a0871894f2f19a9a4b02de9198adaa0634ad1f31 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 4 Jan 2025 19:02:31 +0800 Subject: [PATCH 06/36] fix bug Signed-off-by: wangzilin --- .../js_scene_session_manager.cpp | 17 +++-------------- .../session/host/include/scene_session.h | 2 +- window_scene/session/host/src/scene_session.cpp | 7 +++---- .../include/scene_session_manager.h | 6 +++--- .../src/scene_session_manager.cpp | 14 +++++--------- 5 files changed, 15 insertions(+), 31 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 674f3c6897..5605978553 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 @@ -3993,31 +3993,20 @@ napi_value JsSceneSessionManager::OnSetStatusBarDefaultHeightPerDisplay(napi_env size_t argc = ARGC_FOUR; napi_value argv[ARGC_FOUR] = { nullptr }; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc < ARGC_TWO) { + if (argc < ARGC_ONE) { TLOGE(WmsLogTag::WMS_IMMS, "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); } - int64_t displayId = -1; - if (!ConvertFromJsValue(env, argv[0], displayId)) { - TLOGE(WmsLogTag::WMS_IMMS, "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); - } - if (displayId < 0) { - TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to displayId"); - return NapiGetUndefined(env); - } uint32_t height = 0; - if (!ConvertFromJsValue(env, argv[1], height)) { + if (!ConvertFromJsValue(env, argv[0], height)) { TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to height"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - SceneSessionManager::GetInstance().SetStatusBarDefaultHeightPerDisplay(static_cast(displayId), height); + SceneSessionManager::GetInstance().SetStatusBarDefaultHeightPerDisplay(height); return NapiGetUndefined(env); } } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 3c927119fb..98650769bf 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -102,7 +102,7 @@ using UpdateAppUseControlFunc = std::function& avoidArea, AvoidAreaType type)>; using NotifySetSupportWindowModesFunc = std::function&& supportWindowModes)>; -using GetStatusBarDefaultHeightByDisplayIdFunc = std::function; +using GetStatusBarDefaultHeightByDisplayIdFunc = std::function; struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 41da2f5590..df366ea21d 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1861,10 +1861,9 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) continue; } if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarDefaultHeightByDisplayId_) { - specificCallback_->onGetStatusBarDefaultHeightByDisplayId_( - GetSessionProperty()->GetDisplayId(), statusBarRect); - TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d display %{public}llu status bar height %{public}u", - GetPersistentId(), GetSessionProperty()->GetDisplayId(), statusBarRect.height_); + specificCallback_->onGetStatusBarDefaultHeightByDisplayId_(statusBarRect); + TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar height %{public}u", + GetPersistentId(), statusBarRect.height_); } TLOGI(WmsLogTag::WMS_IMMS, "win %{public}s status bar %{public}s", rect.ToString().c_str(), statusBarRect.ToString().c_str()); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 89b5da27e4..0ab999792d 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -381,8 +381,8 @@ public: void SetIsRootSceneLastFrameLayoutFinishedFunc(IsRootSceneLastFrameLayoutFinishedFunc&& func); void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); - void SetStatusBarDefaultHeightPerDisplay(DisplayId displayId, uint32_t height); - void GetStatusBarDefaultHeightByDisplayId(DisplayId displayId, WSRect& barArea); + void SetStatusBarDefaultHeightPerDisplay(uint32_t height); + void GetStatusBarDefaultHeightByDisplayId(WSRect& barArea); WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; void DealwithVisibilityChange(const std::vector>& visibilityChangeInfos, @@ -1132,7 +1132,7 @@ private: std::unordered_map statusBarDefaultVisibilityPerDisplay_; std::set avoidAreaListenerSessionSet_; std::map> lastUpdatedAvoidArea_; - std::unordered_map statusBarDefaultHeightPerDisplay_; + uint32_t statusBarDefaultHeightPerDisplay_; struct SessionInfoList { int32_t uid_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 538d9f0e2a..a2e29e9935 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12405,21 +12405,17 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent }, __func__); } -void SceneSessionManager::SetStatusBarDefaultHeightPerDisplay(DisplayId displayId, uint32_t height) +void SceneSessionManager::SetStatusBarDefaultHeightPerDisplay(uint32_t height) { - taskScheduler_->PostAsyncTask([this, displayId, height] { - statusBarDefaultHeightPerDisplay_[displayId] = height; + taskScheduler_->PostAsyncTask([this, height] { + statusBarDefaultHeightPerDisplay_ = height; TLOGNI(WmsLogTag::WMS_IMMS, "set status bar default height: %{public}u", height); }, __func__); } -void SceneSessionManager::GetStatusBarDefaultHeightByDisplayId(DisplayId displayId, WSRect& barArea) +void SceneSessionManager::GetStatusBarDefaultHeightByDisplayId(WSRect& barArea) { - if (!statusBarDefaultHeightPerDisplay_.count(displayId)) { - TLOGD(WmsLogTag::WMS_IMMS, "display %{public}llu failed", displayId); - } - barArea.height_ = statusBarDefaultHeightPerDisplay_.count(displayId) != 0 ? - statusBarDefaultHeightPerDisplay_[displayId] : barArea.height_; + barArea.height_ = statusBarDefaultHeightPerDisplay_; } } // namespace OHOS::Rosen -- Gitee From edf3c491fe33e1029c459b37b4177f324061e164 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 4 Jan 2025 19:13:51 +0800 Subject: [PATCH 07/36] fix comments Signed-off-by: wangzilin --- .../js_scene_session_manager.cpp | 12 ++++++------ .../scene_session_manager/js_scene_session_manager.h | 4 ++-- window_scene/session/host/include/scene_session.h | 4 ++-- window_scene/session/host/src/scene_session.cpp | 4 ++-- .../session_manager/include/scene_session_manager.h | 6 +++--- .../session_manager/src/scene_session_manager.cpp | 12 +++++------- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 5605978553..39670a34b9 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 @@ -238,8 +238,8 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::SetIsWindowRectAutoSave); BindNativeFunction(env, exportObj, "notifyAboveLockScreen", moduleName, JsSceneSessionManager::NotifyAboveLockScreen); - BindNativeFunction(env, exportObj, "setStatusBarDefaultHeightPerDisplay", moduleName, - JsSceneSessionManager::SetStatusBarDefaultHeightPerDisplay); + BindNativeFunction(env, exportObj, "SetStatusBarAvoidHeight", moduleName, + JsSceneSessionManager::SetStatusBarAvoidHeight); return NapiGetUndefined(env); } @@ -1214,10 +1214,10 @@ napi_value JsSceneSessionManager::NotifyAboveLockScreen(napi_env env, napi_callb return me->OnNotifyAboveLockScreen(env, info); } -napi_value JsSceneSessionManager::SetStatusBarDefaultHeightPerDisplay(napi_env env, napi_callback_info info) +napi_value JsSceneSessionManager::SetStatusBarAvoidHeight(napi_env env, napi_callback_info info) { JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); - return (me != nullptr) ? me->OnSetStatusBarDefaultHeightPerDisplay(env, info) : nullptr; + return (me != nullptr) ? me->OnSetStatusBarAvoidHeight(env, info) : nullptr; } bool JsSceneSessionManager::IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject) @@ -3988,7 +3988,7 @@ void JsSceneSessionManager::OnWatchFocusActiveChange(bool isActive) }, __func__); } -napi_value JsSceneSessionManager::OnSetStatusBarDefaultHeightPerDisplay(napi_env env, napi_callback_info info) +napi_value JsSceneSessionManager::OnSetStatusBarAvoidHeight(napi_env env, napi_callback_info info) { size_t argc = ARGC_FOUR; napi_value argv[ARGC_FOUR] = { nullptr }; @@ -4006,7 +4006,7 @@ napi_value JsSceneSessionManager::OnSetStatusBarDefaultHeightPerDisplay(napi_env "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - SceneSessionManager::GetInstance().SetStatusBarDefaultHeightPerDisplay(height); + SceneSessionManager::GetInstance().SetStatusBarAvoidHeight(height); return NapiGetUndefined(env); } } // namespace OHOS::Rosen 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 bd7469b646..18f44ff5f0 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 @@ -125,7 +125,7 @@ public: 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); - static napi_value SetStatusBarDefaultHeightPerDisplay(napi_env env, napi_callback_info info); + static napi_value SetStatusBarAvoidHeight(napi_env env, napi_callback_info info); /* * Multi Instance @@ -206,7 +206,7 @@ private: 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); - napi_value OnSetStatusBarDefaultHeightPerDisplay(napi_env env, napi_callback_info info); + napi_value OnSetStatusBarAvoidHeight(napi_env env, napi_callback_info info); /* * Multi Instance diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 98650769bf..ba134000e2 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -102,7 +102,7 @@ using UpdateAppUseControlFunc = std::function& avoidArea, AvoidAreaType type)>; using NotifySetSupportWindowModesFunc = std::function&& supportWindowModes)>; -using GetStatusBarDefaultHeightByDisplayIdFunc = std::function; +using GetStatusBarAvoidHeightFunc = std::function; struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; @@ -136,7 +136,7 @@ public: PiPStateChangeCallback onPiPStateChange_; UpdateGestureBackEnabledCallback onUpdateGestureBackEnabled_; NotifyAvoidAreaChangeCallback onNotifyAvoidAreaChange_; - GetStatusBarDefaultHeightByDisplayIdFunc onGetStatusBarDefaultHeightByDisplayId_; + GetStatusBarAvoidHeightFunc onGetStatusBarAvoidHeight_; }; // func for change window scene pattern property diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index df366ea21d..1c4bc1ced6 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1860,8 +1860,8 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar not visible", GetPersistentId()); continue; } - if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarDefaultHeightByDisplayId_) { - specificCallback_->onGetStatusBarDefaultHeightByDisplayId_(statusBarRect); + if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarAvoidHeight_) { + specificCallback_->onGetStatusBarAvoidHeight_(statusBarRect); TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar height %{public}u", GetPersistentId(), statusBarRect.height_); } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 0ab999792d..ebcbdeec92 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -381,8 +381,8 @@ public: void SetIsRootSceneLastFrameLayoutFinishedFunc(IsRootSceneLastFrameLayoutFinishedFunc&& func); void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); - void SetStatusBarDefaultHeightPerDisplay(uint32_t height); - void GetStatusBarDefaultHeightByDisplayId(WSRect& barArea); + void SetStatusBarAvoidHeight(uint32_t height); + void GetStatusBarAvoidHeight(WSRect& barArea); WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; void DealwithVisibilityChange(const std::vector>& visibilityChangeInfos, @@ -1132,7 +1132,7 @@ private: std::unordered_map statusBarDefaultVisibilityPerDisplay_; std::set avoidAreaListenerSessionSet_; std::map> lastUpdatedAvoidArea_; - uint32_t statusBarDefaultHeightPerDisplay_; + uint32_t statusBarAvoidHeight_; struct SessionInfoList { int32_t uid_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index a2e29e9935..3f65613990 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12405,17 +12405,15 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent }, __func__); } -void SceneSessionManager::SetStatusBarDefaultHeightPerDisplay(uint32_t height) +void SceneSessionManager::SetStatusBarAvoidHeight(uint32_t height) { - taskScheduler_->PostAsyncTask([this, height] { - statusBarDefaultHeightPerDisplay_ = height; - TLOGNI(WmsLogTag::WMS_IMMS, "set status bar default height: %{public}u", height); - }, __func__); + statusBarAvoidHeight_ = height; + TLOGI(WmsLogTag::WMS_IMMS, "height: %{public}u", height); } -void SceneSessionManager::GetStatusBarDefaultHeightByDisplayId(WSRect& barArea) +void SceneSessionManager::GetStatusBarAvoidHeight(WSRect& barArea) { - barArea.height_ = statusBarDefaultHeightPerDisplay_; + barArea.height_ = statusBarAvoidHeight_; } } // namespace OHOS::Rosen -- Gitee From a38268b6af86e4df7a191bd4651267abe1d92110 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 6 Jan 2025 09:08:29 +0800 Subject: [PATCH 08/36] fix bug Signed-off-by: wangzilin --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3f65613990..90d73f3154 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1458,8 +1458,8 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onUpdateGestureBackEnabled_ = [this](int32_t persistentId) { this->UpdateGestureBackEnabled(persistentId); }; - specificCb->onGetStatusBarDefaultHeightByDisplayId_ = [this](DisplayId displayId) { - return this->GetStatusBarDefaultHeightByDisplayId(displayId); + specificCb->onGetStatusBarAvoidHeight_ = [this](WSRect& barArea) { + return this->GetStatusBarAvoidHeight(barArea); }; return specificCb; } -- Gitee From ffc936fd5c3e11abfc3b94883896bfb7d9256824 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 6 Jan 2025 09:24:47 +0800 Subject: [PATCH 09/36] fix bug Signed-off-by: wangzilin --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 90d73f3154..3ef2fbf639 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1459,7 +1459,7 @@ sptr SceneSessionManager::CreateSpecificS this->UpdateGestureBackEnabled(persistentId); }; specificCb->onGetStatusBarAvoidHeight_ = [this](WSRect& barArea) { - return this->GetStatusBarAvoidHeight(barArea); + this->GetStatusBarAvoidHeight(barArea); }; return specificCb; } -- Gitee From a26ed065724bd4a364877c8c5e821b5c6527dd23 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 6 Jan 2025 11:04:39 +0800 Subject: [PATCH 10/36] fix bug Signed-off-by: wangzilin --- window_scene/session/host/include/scene_session.h | 2 +- window_scene/session/host/src/scene_session.cpp | 2 +- .../session_manager/include/scene_session_manager.h | 2 +- .../session_manager/src/scene_session_manager.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index ba134000e2..962e6cf395 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -102,7 +102,7 @@ using UpdateAppUseControlFunc = std::function& avoidArea, AvoidAreaType type)>; using NotifySetSupportWindowModesFunc = std::function&& supportWindowModes)>; -using GetStatusBarAvoidHeightFunc = std::function; +using GetStatusBarAvoidHeightFunc = std::function; struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1c4bc1ced6..26066234eb 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1861,7 +1861,7 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) continue; } if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarAvoidHeight_) { - specificCallback_->onGetStatusBarAvoidHeight_(statusBarRect); + statusBarRect.height_ = specificCallback_->onGetStatusBarAvoidHeight_(); TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar height %{public}u", GetPersistentId(), statusBarRect.height_); } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index ebcbdeec92..dd7a7d97a3 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -382,7 +382,7 @@ public: void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); void SetStatusBarAvoidHeight(uint32_t height); - void GetStatusBarAvoidHeight(WSRect& barArea); + uint32_t GetStatusBarAvoidHeight(); WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; void DealwithVisibilityChange(const std::vector>& visibilityChangeInfos, diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3ef2fbf639..66663fbb61 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1458,8 +1458,8 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onUpdateGestureBackEnabled_ = [this](int32_t persistentId) { this->UpdateGestureBackEnabled(persistentId); }; - specificCb->onGetStatusBarAvoidHeight_ = [this](WSRect& barArea) { - this->GetStatusBarAvoidHeight(barArea); + specificCb->onGetStatusBarAvoidHeight_ = [this] { + return this->GetStatusBarAvoidHeight(); }; return specificCb; } @@ -12411,9 +12411,9 @@ void SceneSessionManager::SetStatusBarAvoidHeight(uint32_t height) TLOGI(WmsLogTag::WMS_IMMS, "height: %{public}u", height); } -void SceneSessionManager::GetStatusBarAvoidHeight(WSRect& barArea) +uint32_t SceneSessionManager::GetStatusBarAvoidHeight() { - barArea.height_ = statusBarAvoidHeight_; + return statusBarAvoidHeight_; } } // namespace OHOS::Rosen -- Gitee From f4c86e673c315d8027956ce0312782f2527f7a32 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 6 Jan 2025 14:53:13 +0800 Subject: [PATCH 11/36] fix comments Signed-off-by: wangzilin --- window_scene/session/host/include/scene_session.h | 1 + window_scene/session/host/src/scene_session.cpp | 4 +++- window_scene/session_manager/include/scene_session_manager.h | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 962e6cf395..5eac6c232f 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -977,6 +977,7 @@ private: std::atomic_bool isDisplayStatusBarTemporarily_ { false }; bool isStatusBarVisible_ = true; IsLastFrameLayoutFinishedFunc isLastFrameLayoutFinishedFunc_; + static constexpr uint32_t INVALID_STATUS_BAR_AVOID_HEIGHT = -1; /* * PC Window Layout diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 26066234eb..7b69010422 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1861,7 +1861,9 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) continue; } if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarAvoidHeight_) { - statusBarRect.height_ = specificCallback_->onGetStatusBarAvoidHeight_(); + statusBarRect.height_ = + specificCallback_->onGetStatusBarAvoidHeight_() == INVALID_STATUS_BAR_AVOID_HEIGHT ? + statusBarRect.height_ : specificCallback_->onGetStatusBarAvoidHeight_(); TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar height %{public}u", GetPersistentId(), statusBarRect.height_); } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index dd7a7d97a3..a34545d9b3 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -1132,7 +1132,7 @@ private: std::unordered_map statusBarDefaultVisibilityPerDisplay_; std::set avoidAreaListenerSessionSet_; std::map> lastUpdatedAvoidArea_; - uint32_t statusBarAvoidHeight_; + uint32_t statusBarAvoidHeight_ = INVALID_STATUS_BAR_AVOID_HEIGHT; struct SessionInfoList { int32_t uid_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 66663fbb61..5ca81ed6ff 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12408,7 +12408,7 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent void SceneSessionManager::SetStatusBarAvoidHeight(uint32_t height) { statusBarAvoidHeight_ = height; - TLOGI(WmsLogTag::WMS_IMMS, "height: %{public}u", height); + TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d height %{public}u", property->GetPersistentId(), height); } uint32_t SceneSessionManager::GetStatusBarAvoidHeight() -- Gitee From d1d189f8a78a9da157b98a7dc60db5979c679d91 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 6 Jan 2025 14:55:04 +0800 Subject: [PATCH 12/36] fix comments Signed-off-by: wangzilin --- .../napi/scene_session_manager/js_scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 39670a34b9..481a6c7827 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 @@ -238,7 +238,7 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::SetIsWindowRectAutoSave); BindNativeFunction(env, exportObj, "notifyAboveLockScreen", moduleName, JsSceneSessionManager::NotifyAboveLockScreen); - BindNativeFunction(env, exportObj, "SetStatusBarAvoidHeight", moduleName, + BindNativeFunction(env, exportObj, "setStatusBarAvoidHeight", moduleName, JsSceneSessionManager::SetStatusBarAvoidHeight); return NapiGetUndefined(env); } -- Gitee From 2be15cf0fe7687ca8431d5bf9c75ab86d1f7ea0b Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 6 Jan 2025 16:09:03 +0800 Subject: [PATCH 13/36] fix comments` Signed-off-by: wangzilin --- .../js_scene_session_manager.cpp | 2 +- .../session/host/include/scene_session.h | 3 +-- .../session/host/src/scene_session.cpp | 4 +--- .../include/scene_session_manager.h | 7 ++++--- .../src/scene_session_manager.cpp | 18 +++++++++++------- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 481a6c7827..3d2d5d898f 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 @@ -3999,7 +3999,7 @@ napi_value JsSceneSessionManager::OnSetStatusBarAvoidHeight(napi_env env, napi_c "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - uint32_t height = 0; + int32_t height = 0; if (!ConvertFromJsValue(env, argv[0], height)) { TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to height"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 5eac6c232f..9ac3a58e90 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -102,7 +102,7 @@ using UpdateAppUseControlFunc = std::function& avoidArea, AvoidAreaType type)>; using NotifySetSupportWindowModesFunc = std::function&& supportWindowModes)>; -using GetStatusBarAvoidHeightFunc = std::function; +using GetStatusBarAvoidHeightFunc = std::function; struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; @@ -977,7 +977,6 @@ private: std::atomic_bool isDisplayStatusBarTemporarily_ { false }; bool isStatusBarVisible_ = true; IsLastFrameLayoutFinishedFunc isLastFrameLayoutFinishedFunc_; - static constexpr uint32_t INVALID_STATUS_BAR_AVOID_HEIGHT = -1; /* * PC Window Layout diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 7b69010422..1c4bc1ced6 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1861,9 +1861,7 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) continue; } if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarAvoidHeight_) { - statusBarRect.height_ = - specificCallback_->onGetStatusBarAvoidHeight_() == INVALID_STATUS_BAR_AVOID_HEIGHT ? - statusBarRect.height_ : specificCallback_->onGetStatusBarAvoidHeight_(); + specificCallback_->onGetStatusBarAvoidHeight_(statusBarRect); TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar height %{public}u", GetPersistentId(), statusBarRect.height_); } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index a34545d9b3..0882011aba 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -381,8 +381,8 @@ public: void SetIsRootSceneLastFrameLayoutFinishedFunc(IsRootSceneLastFrameLayoutFinishedFunc&& func); void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); - void SetStatusBarAvoidHeight(uint32_t height); - uint32_t GetStatusBarAvoidHeight(); + void SetStatusBarAvoidHeight(int32_t height); + void GetStatusBarAvoidHeight(WSRect& barArea); WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; void DealwithVisibilityChange(const std::vector>& visibilityChangeInfos, @@ -1132,7 +1132,8 @@ private: std::unordered_map statusBarDefaultVisibilityPerDisplay_; std::set avoidAreaListenerSessionSet_; std::map> lastUpdatedAvoidArea_; - uint32_t statusBarAvoidHeight_ = INVALID_STATUS_BAR_AVOID_HEIGHT; + static constexpr int32_t INVALID_STATUS_BAR_AVOID_HEIGHT = -1; + int32_t statusBarAvoidHeight_ = INVALID_STATUS_BAR_AVOID_HEIGHT; struct SessionInfoList { int32_t uid_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5ca81ed6ff..3d8a1e8625 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1458,8 +1458,8 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onUpdateGestureBackEnabled_ = [this](int32_t persistentId) { this->UpdateGestureBackEnabled(persistentId); }; - specificCb->onGetStatusBarAvoidHeight_ = [this] { - return this->GetStatusBarAvoidHeight(); + specificCb->onGetStatusBarAvoidHeight_ = [this](WSRect& barArea) { + return this->GetStatusBarAvoidHeight(barArea); }; return specificCb; } @@ -12405,15 +12405,19 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent }, __func__); } -void SceneSessionManager::SetStatusBarAvoidHeight(uint32_t height) +void SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) { - statusBarAvoidHeight_ = height; - TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d height %{public}u", property->GetPersistentId(), height); + statusBarAvoidHeight_ = height >= 0 ? height : INVALID_STATUS_BAR_AVOID_HEIGHT; + if (statusBarAvoidHeight_ == INVALID_STATUS_BAR_AVOID_HEIGHT) { + TLOGI(WmsLogTag::WMS_IMMS, "cancelled, win %{public}d", property->GetPersistentId()); + } + TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d height %{public}d", property->GetPersistentId(), height); } -uint32_t SceneSessionManager::GetStatusBarAvoidHeight() +void SceneSessionManager::GetStatusBarAvoidHeight(WSRect& barArea) { - return statusBarAvoidHeight_; + barArea.height_ = statusBarAvoidHeight_ == INVALID_STATUS_BAR_AVOID_HEIGHT ? + barArea.height_ : statusBarAvoidHeight_; } } // namespace OHOS::Rosen -- Gitee From be1e9e6184b086f3892d195500495c6f2f746598 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 6 Jan 2025 16:28:10 +0800 Subject: [PATCH 14/36] fix bug Signed-off-by: wangzilin --- window_scene/session_manager/src/scene_session_manager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3d8a1e8625..e45bbc690b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12409,9 +12409,10 @@ void SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) { statusBarAvoidHeight_ = height >= 0 ? height : INVALID_STATUS_BAR_AVOID_HEIGHT; if (statusBarAvoidHeight_ == INVALID_STATUS_BAR_AVOID_HEIGHT) { - TLOGI(WmsLogTag::WMS_IMMS, "cancelled, win %{public}d", property->GetPersistentId()); + TLOGI(WmsLogTag::WMS_IMMS, "cancelled, win %{public}d", session->GetPersistentId()); + return; } - TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d height %{public}d", property->GetPersistentId(), height); + TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d height %{public}d", session->GetPersistentId(), height); } void SceneSessionManager::GetStatusBarAvoidHeight(WSRect& barArea) -- Gitee From af594f12d693eff55ba0e3122c128aa2788d5b7d Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 6 Jan 2025 16:56:31 +0800 Subject: [PATCH 15/36] fix comments Signed-off-by: wangzilin --- window_scene/session_manager/src/scene_session_manager.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index e45bbc690b..394eb338f5 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12408,11 +12408,6 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent void SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) { statusBarAvoidHeight_ = height >= 0 ? height : INVALID_STATUS_BAR_AVOID_HEIGHT; - if (statusBarAvoidHeight_ == INVALID_STATUS_BAR_AVOID_HEIGHT) { - TLOGI(WmsLogTag::WMS_IMMS, "cancelled, win %{public}d", session->GetPersistentId()); - return; - } - TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d height %{public}d", session->GetPersistentId(), height); } void SceneSessionManager::GetStatusBarAvoidHeight(WSRect& barArea) -- Gitee From d0f39887aa176d69cac79e6acee63f7aa7e69a5a Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 6 Jan 2025 21:59:07 +0800 Subject: [PATCH 16/36] fix bug Signed-off-by: wangzilin --- window_scene/session/host/src/scene_session.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1c4bc1ced6..ef102c49be 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1862,11 +1862,9 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) } if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarAvoidHeight_) { specificCallback_->onGetStatusBarAvoidHeight_(statusBarRect); - TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar height %{public}u", - GetPersistentId(), statusBarRect.height_); } - TLOGI(WmsLogTag::WMS_IMMS, "win %{public}s status bar %{public}s", - rect.ToString().c_str(), statusBarRect.ToString().c_str()); + TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d window rect %{public}s status bar %{public}s", + GetPersistentId(), rect.ToString().c_str(), statusBarRect.ToString().c_str()); CalculateAvoidAreaRect(rect, statusBarRect, avoidArea); } return; @@ -5620,11 +5618,11 @@ int32_t SceneSession::GetStatusBarHeight() std::vector> statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); for (auto& statusBar : statusBarVector) { - if (statusBar != nullptr && statusBar->GetSessionRect().height_ > height) { - height = statusBar->GetSessionRect().height_; + if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarAvoidHeight_) { + specificCallback_->onGetStatusBarAvoidHeight_(statusBarRect); } } - TLOGD(WmsLogTag::WMS_IMMS, "height %{public}d", height); + TLOGI(WmsLogTag::WMS_IMMS, "height %{public}d", height); return height; } -- Gitee From 92668209b968a17ccdc3d31545734f06b432e4cd Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 6 Jan 2025 22:41:15 +0800 Subject: [PATCH 17/36] fix bug Signed-off-by: wangzilin --- window_scene/session/host/src/scene_session.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ef102c49be..bd8af8cb20 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5618,9 +5618,11 @@ int32_t SceneSession::GetStatusBarHeight() std::vector> statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); for (auto& statusBar : statusBarVector) { + WSRect statusBarRect = statusBar->GetSessionRect(); if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarAvoidHeight_) { specificCallback_->onGetStatusBarAvoidHeight_(statusBarRect); } + height = statusBarRect.height_; } TLOGI(WmsLogTag::WMS_IMMS, "height %{public}d", height); return height; -- Gitee From 25de017c2d117c3348fcc8d86013a5d60bfbaa92 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Tue, 7 Jan 2025 14:32:59 +0800 Subject: [PATCH 18/36] fix comments Signed-off-by: wangzilin --- window_scene/session/host/include/scene_session.h | 2 +- window_scene/session/host/src/scene_session.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 9ac3a58e90..9d8890bae2 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -136,7 +136,6 @@ public: PiPStateChangeCallback onPiPStateChange_; UpdateGestureBackEnabledCallback onUpdateGestureBackEnabled_; NotifyAvoidAreaChangeCallback onNotifyAvoidAreaChange_; - GetStatusBarAvoidHeightFunc onGetStatusBarAvoidHeight_; }; // func for change window scene pattern property @@ -628,6 +627,7 @@ protected: bool PipelineNeedNotifyClientToUpdateAvoidArea(uint32_t dirty) const; NotifyNeedAvoidFunc onNeedAvoid_; NotifySystemBarPropertyChangeFunc onSystemBarPropertyChange_; + GetStatusBarAvoidHeightFunc onGetStatusBarAvoidHeight_; /* * Gesture Back diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index bd8af8cb20..b8883fa699 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1860,8 +1860,8 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar not visible", GetPersistentId()); continue; } - if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarAvoidHeight_) { - specificCallback_->onGetStatusBarAvoidHeight_(statusBarRect); + if (onGetStatusBarAvoidHeight_) { + onGetStatusBarAvoidHeight_(statusBarRect); } TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d window rect %{public}s status bar %{public}s", GetPersistentId(), rect.ToString().c_str(), statusBarRect.ToString().c_str()); @@ -5619,8 +5619,8 @@ int32_t SceneSession::GetStatusBarHeight() WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); for (auto& statusBar : statusBarVector) { WSRect statusBarRect = statusBar->GetSessionRect(); - if (specificCallback_ != nullptr && specificCallback_->onGetStatusBarAvoidHeight_) { - specificCallback_->onGetStatusBarAvoidHeight_(statusBarRect); + if (onGetStatusBarAvoidHeight_) { + onGetStatusBarAvoidHeight_(statusBarRect); } height = statusBarRect.height_; } -- Gitee From 90a9e93ecfef417f3fd17f432325ce02b1d6037c Mon Sep 17 00:00:00 2001 From: wangzilin Date: Tue, 7 Jan 2025 20:52:17 +0800 Subject: [PATCH 19/36] fix comments Signed-off-by: wangzilin --- window_scene/session/host/include/scene_session.h | 1 + window_scene/session/host/src/scene_session.cpp | 12 ++++++++++++ .../session_manager/src/scene_session_manager.cpp | 6 +++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 9d8890bae2..b501f30ab0 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -328,6 +328,7 @@ public: void RegisterSystemBarPropertyChangeCallback(NotifySystemBarPropertyChangeFunc&& callback); void MarkAvoidAreaAsDirty(); virtual void RecalculatePanelRectForAvoidArea(WSRect& panelRect) {} + void RegisterGetStatusBarAvoidHeightFunc(GetStatusBarAvoidHeightFunc&& func) void SetAbilitySessionInfo(std::shared_ptr abilityInfo); void SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index b8883fa699..474a69cfac 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5583,6 +5583,18 @@ void SceneSession::RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreen }, __func__); } +void SceneSession::RegisterGetStatusBarAvoidHeightFunc(NotifyLayoutFullScreenChangeFunc&& callback) +{ + PostTask([weakThis = wptr(this), callback = std::move(callback)] { + auto session = weakThis.promote(); + if (!session) { + TLOGNE(WmsLogTag::WMS_LAYOUT, "session is null"); + return; + } + session->onGetStatusBarAvoidHeight_ = std::move(callback); + }, __func__); +} + WMError SceneSession::GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) { if (forceSplitFunc_ == nullptr) { diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 394eb338f5..e7d3e4404e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1458,9 +1458,6 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onUpdateGestureBackEnabled_ = [this](int32_t persistentId) { this->UpdateGestureBackEnabled(persistentId); }; - specificCb->onGetStatusBarAvoidHeight_ = [this](WSRect& barArea) { - return this->GetStatusBarAvoidHeight(barArea); - }; return specificCb; } @@ -1808,6 +1805,9 @@ sptr SceneSessionManager::CreateSceneSession(const SessionInfo& se sceneSession->SetIsLastFrameLayoutFinishedFunc([this](bool& isLayoutFinished) { return this->IsLastFrameLayoutFinished(isLayoutFinished); }); + sceneSession->RegisterGetStatusBarAvoidHeightFunc([this](WSRect& barArea) { + return this->GetStatusBarAvoidHeight(barArea); + }); DragResizeType dragResizeType = DragResizeType::RESIZE_TYPE_UNDEFINED; GetAppDragResizeType(sessionInfo.bundleName_, dragResizeType); sceneSession->SetAppDragResizeType(dragResizeType); -- Gitee From b44382bdc734117ef65dcc3042b0273c419fafef Mon Sep 17 00:00:00 2001 From: wangzilin Date: Tue, 7 Jan 2025 22:30:45 +0800 Subject: [PATCH 20/36] fix bug Signed-off-by: wangzilin --- window_scene/session/host/include/scene_session.h | 2 +- window_scene/session/host/src/scene_session.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index b501f30ab0..e8e3c797cc 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -328,7 +328,7 @@ public: void RegisterSystemBarPropertyChangeCallback(NotifySystemBarPropertyChangeFunc&& callback); void MarkAvoidAreaAsDirty(); virtual void RecalculatePanelRectForAvoidArea(WSRect& panelRect) {} - void RegisterGetStatusBarAvoidHeightFunc(GetStatusBarAvoidHeightFunc&& func) + void RegisterGetStatusBarAvoidHeightFunc(GetStatusBarAvoidHeightFunc&& func); void SetAbilitySessionInfo(std::shared_ptr abilityInfo); void SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 474a69cfac..ec398d1a24 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5583,12 +5583,12 @@ void SceneSession::RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreen }, __func__); } -void SceneSession::RegisterGetStatusBarAvoidHeightFunc(NotifyLayoutFullScreenChangeFunc&& callback) +void SceneSession::RegisterGetStatusBarAvoidHeightFunc(GetStatusBarAvoidHeightFunc&& callback) { PostTask([weakThis = wptr(this), callback = std::move(callback)] { auto session = weakThis.promote(); if (!session) { - TLOGNE(WmsLogTag::WMS_LAYOUT, "session is null"); + TLOGNE(WmsLogTag::WMS_IMMS, "session is null"); return; } session->onGetStatusBarAvoidHeight_ = std::move(callback); -- Gitee From caa370eff649d5cddb817fc24546f9c4b1f2bc41 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Tue, 7 Jan 2025 22:35:09 +0800 Subject: [PATCH 21/36] fix comments Signed-off-by: wangzilin --- window_scene/session/host/src/scene_session.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ec398d1a24..94ae85ec73 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5585,14 +5585,7 @@ void SceneSession::RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreen void SceneSession::RegisterGetStatusBarAvoidHeightFunc(GetStatusBarAvoidHeightFunc&& callback) { - PostTask([weakThis = wptr(this), callback = std::move(callback)] { - auto session = weakThis.promote(); - if (!session) { - TLOGNE(WmsLogTag::WMS_IMMS, "session is null"); - return; - } - session->onGetStatusBarAvoidHeight_ = std::move(callback); - }, __func__); + session->onGetStatusBarAvoidHeight_ = std::move(callback); } WMError SceneSession::GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) -- Gitee From 1914d73dacdf461198283c1c8cc8388f74818130 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Wed, 8 Jan 2025 10:05:37 +0800 Subject: [PATCH 22/36] fix bug Signed-off-by: wangzilin --- window_scene/session/host/src/scene_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 94ae85ec73..0f69b9fcf2 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5585,7 +5585,7 @@ void SceneSession::RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreen void SceneSession::RegisterGetStatusBarAvoidHeightFunc(GetStatusBarAvoidHeightFunc&& callback) { - session->onGetStatusBarAvoidHeight_ = std::move(callback); + onGetStatusBarAvoidHeight_ = std::move(callback); } WMError SceneSession::GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) -- Gitee From 0c06136fa1d4bfacb86e88037ab0a8c4671bba06 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Wed, 8 Jan 2025 14:26:34 +0800 Subject: [PATCH 23/36] fix bug Signed-off-by: wangzilin --- .../js_scene_session_manager.h | 28 ++++++++++++------- .../session/host/src/root_scene_session.cpp | 3 ++ 2 files changed, 21 insertions(+), 10 deletions(-) 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 18f44ff5f0..37040199b6 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 @@ -98,9 +98,6 @@ public: static napi_value GetRssData(napi_env env, napi_callback_info info); static napi_value RegisterRssData(napi_env env, napi_callback_info info); static napi_value UnregisterRssData(napi_env env, napi_callback_info info); - static napi_value SetStatusBarDefaultVisibilityPerDisplay(napi_env env, napi_callback_info info); - static napi_value NotifyStatusBarShowStatus(napi_env env, napi_callback_info info); - static napi_value NotifyAINavigationBarShowStatus(napi_env env, napi_callback_info info); static napi_value NotifySessionRecoverStatus(napi_env env, napi_callback_info info); static napi_value UpdateSessionDisplayId(napi_env env, napi_callback_info info); static napi_value NotifyStackEmpty(napi_env env, napi_callback_info info); @@ -117,7 +114,6 @@ public: static napi_value SetAppForceLandscapeConfig(napi_env env, napi_callback_info info); static napi_value SwitchFreeMultiWindow(napi_env env, napi_callback_info info); static napi_value GetFreeMultiWindowConfig(napi_env env, napi_callback_info info); - static napi_value GetIsLayoutFullScreen(napi_env env, napi_callback_info info); static napi_value IsScbCoreEnabled(napi_env env, napi_callback_info info); static napi_value RefreshPcZOrder(napi_env env, napi_callback_info info); static napi_value GetWindowPid(napi_env env, napi_callback_info info); @@ -125,7 +121,6 @@ public: 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); - static napi_value SetStatusBarAvoidHeight(napi_env env, napi_callback_info info); /* * Multi Instance @@ -135,6 +130,15 @@ public: static napi_value GetLastInstanceKey(napi_env env, napi_callback_info info); static napi_value RefreshAppInfo(napi_env env, napi_callback_info info); + /* + * Window Immersive + */ + static napi_value NotifyAINavigationBarShowStatus(napi_env env, napi_callback_info info); + static napi_value GetIsLayoutFullScreen(napi_env env, napi_callback_info info); + static napi_value SetStatusBarDefaultVisibilityPerDisplay(napi_env env, napi_callback_info info); + static napi_value NotifyStatusBarShowStatus(napi_env env, napi_callback_info info); + static napi_value SetStatusBarAvoidHeight(napi_env env, napi_callback_info info); + private: napi_value OnRegisterCallback(napi_env env, napi_callback_info info); napi_value OnGetRootSceneSession(napi_env env, napi_callback_info info); @@ -182,9 +186,6 @@ private: napi_value OnUpdateSessionDisplayId(napi_env env, napi_callback_info info); napi_value OnNotifyStackEmpty(napi_env env, napi_callback_info info); napi_value OnNotifySwitchingUser(napi_env env, napi_callback_info info); - napi_value OnSetStatusBarDefaultVisibilityPerDisplay(napi_env env, napi_callback_info info); - napi_value OnNotifyStatusBarShowStatus(napi_env env, napi_callback_info info); - napi_value OnNotifyAINavigationBarShowStatus(napi_env env, napi_callback_info info); napi_value OnUpdateTitleInTargetPos(napi_env env, napi_callback_info info); napi_value OnSetSystemAnimatedScenes(napi_env env, napi_callback_info info); napi_value OnGetSessionSnapshotPixelMap(napi_env env, napi_callback_info info); @@ -193,7 +194,6 @@ private: napi_value OnGetCustomDecorHeight(napi_env env, napi_callback_info info); napi_value OnSwitchFreeMultiWindow(napi_env env, napi_callback_info info); napi_value OnGetFreeMultiWindowConfig(napi_env env, napi_callback_info info); - napi_value OnGetIsLayoutFullScreen(napi_env env, napi_callback_info info); napi_value OnNotifyEnterRecentTask(napi_env env, napi_callback_info info); napi_value OnUpdateDisplayHookInfo(napi_env env, napi_callback_info info); napi_value OnUpdateAppHookDisplayInfo(napi_env env, napi_callback_info info); @@ -206,7 +206,6 @@ private: 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); - napi_value OnSetStatusBarAvoidHeight(napi_env env, napi_callback_info info); /* * Multi Instance @@ -216,6 +215,15 @@ private: napi_value OnGetLastInstanceKey(napi_env env, napi_callback_info info); napi_value OnRefreshAppInfo(napi_env env, napi_callback_info info); + /* + * Window Immersive + */ + napi_value OnNotifyAINavigationBarShowStatus(napi_env env, napi_callback_info info); + napi_value OnGetIsLayoutFullScreen(napi_env env, napi_callback_info info); + napi_value OnSetStatusBarDefaultVisibilityPerDisplay(napi_env env, napi_callback_info info); + napi_value OnNotifyStatusBarShowStatus(napi_env env, napi_callback_info info); + napi_value OnSetStatusBarAvoidHeight(napi_env env, napi_callback_info info); + void OnRootSceneBackEvent(); void OnStatusBarEnabledUpdate(bool enable, const std::string& bundleName); void OnGestureNavigationEnabledUpdate(bool enable, const std::string& bundleName, GestureBackType type); diff --git a/window_scene/session/host/src/root_scene_session.cpp b/window_scene/session/host/src/root_scene_session.cpp index 0b06b17a34..c859b2fff0 100644 --- a/window_scene/session/host/src/root_scene_session.cpp +++ b/window_scene/session/host/src/root_scene_session.cpp @@ -43,6 +43,9 @@ void RootSceneSession::GetSystemAvoidAreaForRoot(const WSRect& rect, AvoidArea& continue; } WSRect statusBarRect = statusBar->GetSessionRect(); + if (onGetStatusBarAvoidHeight_) { + onGetStatusBarAvoidHeight_(statusBarRect); + } CalculateAvoidAreaRect(rect, statusBarRect, avoidArea); TLOGI(WmsLogTag::WMS_IMMS, "root scene %{public}s status bar %{public}s area %{public}s", rect.ToString().c_str(), statusBarRect.ToString().c_str(), avoidArea.ToString().c_str()); -- Gitee From 9f16776d75d4663cfc9f40a50a38b29a806be221 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Thu, 9 Jan 2025 22:18:46 +0800 Subject: [PATCH 24/36] fix comments Signed-off-by: wangzilin --- .../session_manager/src/scene_session_manager.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index e7d3e4404e..c394a2dfde 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12407,7 +12407,13 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent void SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) { - statusBarAvoidHeight_ = height >= 0 ? height : INVALID_STATUS_BAR_AVOID_HEIGHT; + const char* const where = __func__; + auto task = [this, where] { + statusBarAvoidHeight_ = height >= 0 ? height : INVALID_STATUS_BAR_AVOID_HEIGHT; + TLOGNI(WMS_IMMS, "%{public}s, height %{public}d", where, statusBarAvoidHeight_); + return WSError::WS_OK; + }; + return taskScheduler_->PostSyncTask(task, "SetStatusBarAvoidHeight"); } void SceneSessionManager::GetStatusBarAvoidHeight(WSRect& barArea) -- Gitee From ca434f8ed260b12bf699f4322bd35896359627dd Mon Sep 17 00:00:00 2001 From: wangzilin Date: Thu, 9 Jan 2025 22:34:58 +0800 Subject: [PATCH 25/36] fix bug Signed-off-by: wangzilin --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c394a2dfde..8e2a24b169 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12408,7 +12408,7 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent void SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) { const char* const where = __func__; - auto task = [this, where] { + auto task = [this, where, height] { statusBarAvoidHeight_ = height >= 0 ? height : INVALID_STATUS_BAR_AVOID_HEIGHT; TLOGNI(WMS_IMMS, "%{public}s, height %{public}d", where, statusBarAvoidHeight_); return WSError::WS_OK; -- Gitee From 764296edf2e0921ae617a5410ba685b3e237a0d0 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Thu, 9 Jan 2025 23:06:16 +0800 Subject: [PATCH 26/36] fix bug Signed-off-by: wangzilin --- window_scene/session_manager/include/scene_session_manager.h | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 0882011aba..3b440b4d1c 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -381,7 +381,7 @@ public: void SetIsRootSceneLastFrameLayoutFinishedFunc(IsRootSceneLastFrameLayoutFinishedFunc&& func); void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); - void SetStatusBarAvoidHeight(int32_t height); + WMError SetStatusBarAvoidHeight(int32_t height); void GetStatusBarAvoidHeight(WSRect& barArea); WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 8e2a24b169..2062007a1b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12405,12 +12405,12 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent }, __func__); } -void SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) +WMError SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) { const char* const where = __func__; auto task = [this, where, height] { statusBarAvoidHeight_ = height >= 0 ? height : INVALID_STATUS_BAR_AVOID_HEIGHT; - TLOGNI(WMS_IMMS, "%{public}s, height %{public}d", where, statusBarAvoidHeight_); + TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s, height %{public}d", where, statusBarAvoidHeight_); return WSError::WS_OK; }; return taskScheduler_->PostSyncTask(task, "SetStatusBarAvoidHeight"); -- Gitee From 13d0540eea6019ad84a85ce29346d74e9888c0e3 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Fri, 10 Jan 2025 09:41:31 +0800 Subject: [PATCH 27/36] fix bug Signed-off-by: wangzilin --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 2062007a1b..ab319ba14c 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12411,7 +12411,7 @@ WMError SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) auto task = [this, where, height] { statusBarAvoidHeight_ = height >= 0 ? height : INVALID_STATUS_BAR_AVOID_HEIGHT; TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s, height %{public}d", where, statusBarAvoidHeight_); - return WSError::WS_OK; + return WMError::WS_OK; }; return taskScheduler_->PostSyncTask(task, "SetStatusBarAvoidHeight"); } -- Gitee From f4950c4581d8e237505bb6d89f2f85c6e1f3b9c4 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Fri, 10 Jan 2025 09:42:41 +0800 Subject: [PATCH 28/36] fix bug Signed-off-by: wangzilin --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index ab319ba14c..d45ac8fa1f 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12411,7 +12411,7 @@ WMError SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) auto task = [this, where, height] { statusBarAvoidHeight_ = height >= 0 ? height : INVALID_STATUS_BAR_AVOID_HEIGHT; TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s, height %{public}d", where, statusBarAvoidHeight_); - return WMError::WS_OK; + return WMError::WM_OK; }; return taskScheduler_->PostSyncTask(task, "SetStatusBarAvoidHeight"); } -- Gitee From 36e7b283451953d4dbf4f2e855c6f9e52c72ee02 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 11 Jan 2025 12:01:42 +0800 Subject: [PATCH 29/36] fix bug Signed-off-by: wangzilin --- window_scene/session_manager/include/scene_session_manager.h | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 0146a23e46..c443bc71df 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -387,7 +387,7 @@ public: void SetIsRootSceneLastFrameLayoutFinishedFunc(IsRootSceneLastFrameLayoutFinishedFunc&& func); void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); - WMError SetStatusBarAvoidHeight(int32_t height); + void SetStatusBarAvoidHeight(int32_t height); void GetStatusBarAvoidHeight(WSRect& barArea); WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index e82b538999..90400fda49 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12330,7 +12330,7 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent }, __func__); } -WMError SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) +void SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) { const char* const where = __func__; auto task = [this, where, height] { @@ -12338,7 +12338,7 @@ WMError SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s, height %{public}d", where, statusBarAvoidHeight_); return WMError::WM_OK; }; - return taskScheduler_->PostSyncTask(task, "SetStatusBarAvoidHeight"); + taskScheduler_->PostSyncTask(task, "SetStatusBarAvoidHeight"); } void SceneSessionManager::GetStatusBarAvoidHeight(WSRect& barArea) -- Gitee From 21a010ec5108edc3d053e75ba6d866fea65b13bc Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 11 Jan 2025 15:02:14 +0800 Subject: [PATCH 30/36] fix comments Signed-off-by: wangzilin --- window_scene/session/host/include/scene_session.h | 3 ++- window_scene/session/host/src/scene_session.cpp | 6 +++--- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index a4c2edc487..381b604cfe 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -104,6 +104,7 @@ using NotifyAvoidAreaChangeCallback = std::function& using NotifySetSupportedWindowModesFunc = std::function&& supportedWindowModes)>; using GetStatusBarAvoidHeightFunc = std::function; + struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; uint32_t callingTokenId { 0 }; @@ -637,7 +638,7 @@ protected: bool PipelineNeedNotifyClientToUpdateAvoidArea(uint32_t dirty) const; NotifyNeedAvoidFunc onNeedAvoid_; NotifySystemBarPropertyChangeFunc onSystemBarPropertyChange_; - GetStatusBarAvoidHeightFunc onGetStatusBarAvoidHeight_; + GetStatusBarAvoidHeightFunc onGetStatusBarAvoidHeightFunc_; /* * Gesture Back diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index a6b07b099b..1305da58d4 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1869,7 +1869,7 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) if (onGetStatusBarAvoidHeight_) { onGetStatusBarAvoidHeight_(statusBarRect); } - TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d window rect %{public}s status bar %{public}s", + TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d rect %{public}s status bar %{public}s", GetPersistentId(), rect.ToString().c_str(), statusBarRect.ToString().c_str()); CalculateAvoidAreaRect(rect, statusBarRect, avoidArea); } @@ -5686,8 +5686,8 @@ int32_t SceneSession::GetStatusBarHeight() WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); for (auto& statusBar : statusBarVector) { WSRect statusBarRect = statusBar->GetSessionRect(); - if (onGetStatusBarAvoidHeight_) { - onGetStatusBarAvoidHeight_(statusBarRect); + if (onGetStatusBarAvoidHeightFunc_) { + onGetStatusBarAvoidHeightFunc_(statusBarRect); } height = statusBarRect.height_; } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 90400fda49..1cea53eaf7 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -12338,7 +12338,7 @@ void SceneSessionManager::SetStatusBarAvoidHeight(int32_t height) TLOGNI(WmsLogTag::WMS_IMMS, "%{public}s, height %{public}d", where, statusBarAvoidHeight_); return WMError::WM_OK; }; - taskScheduler_->PostSyncTask(task, "SetStatusBarAvoidHeight"); + taskScheduler_->PostSyncTask(task, where); } void SceneSessionManager::GetStatusBarAvoidHeight(WSRect& barArea) -- Gitee From ce5237e0c768feb854cb57d4811d927f64abb4fc Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 11 Jan 2025 15:37:45 +0800 Subject: [PATCH 31/36] fix bug Signed-off-by: wangzilin --- window_scene/session/host/src/root_scene_session.cpp | 4 ++-- window_scene/session/host/src/scene_session.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/session/host/src/root_scene_session.cpp b/window_scene/session/host/src/root_scene_session.cpp index 6d89a9ac5c..bd37759ea1 100644 --- a/window_scene/session/host/src/root_scene_session.cpp +++ b/window_scene/session/host/src/root_scene_session.cpp @@ -43,8 +43,8 @@ void RootSceneSession::GetSystemAvoidAreaForRoot(const WSRect& rect, AvoidArea& continue; } WSRect statusBarRect = statusBar->GetSessionRect(); - if (onGetStatusBarAvoidHeight_) { - onGetStatusBarAvoidHeight_(statusBarRect); + if (onGetStatusBarAvoidHeightFunc_) { + onGetStatusBarAvoidHeightFunc_(statusBarRect); } CalculateAvoidAreaRect(rect, statusBarRect, avoidArea); TLOGI(WmsLogTag::WMS_IMMS, "root scene %{public}s status bar %{public}s area %{public}s", diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1305da58d4..9113c9cba3 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1866,8 +1866,8 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d status bar not visible", GetPersistentId()); continue; } - if (onGetStatusBarAvoidHeight_) { - onGetStatusBarAvoidHeight_(statusBarRect); + if (onGetStatusBarAvoidHeightFunc_) { + onGetStatusBarAvoidHeightFunc_(statusBarRect); } TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d rect %{public}s status bar %{public}s", GetPersistentId(), rect.ToString().c_str(), statusBarRect.ToString().c_str()); -- Gitee From af117bf21c07a9ce35858d9fb050bb264b2ba14c Mon Sep 17 00:00:00 2001 From: wangzilin Date: Sat, 11 Jan 2025 15:49:06 +0800 Subject: [PATCH 32/36] fix bug Signed-off-by: wangzilin --- window_scene/session/host/src/scene_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 9113c9cba3..448a04e915 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5647,7 +5647,7 @@ void SceneSession::RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreen void SceneSession::RegisterGetStatusBarAvoidHeightFunc(GetStatusBarAvoidHeightFunc&& callback) { - onGetStatusBarAvoidHeight_ = std::move(callback); + onGetStatusBarAvoidHeightFunc_ = std::move(callback); } WMError SceneSession::GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) -- Gitee From de00529f7bec81eb5ab108603906835b6992047f Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 13 Jan 2025 16:33:17 +0800 Subject: [PATCH 33/36] fix comments Signed-off-by: wangzilin --- .../napi/scene_session_manager/js_scene_session_manager.cpp | 4 ++++ window_scene/session/host/src/scene_session.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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 0b0f3fd95e..febd09dcab 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 @@ -3997,6 +3997,10 @@ napi_value JsSceneSessionManager::OnSetStatusBarAvoidHeight(napi_env env, napi_c "Input parameter is missing or invalid")); return NapiGetUndefined(env); } + if ((systemConfig_.IsPcWindow() || systemConfig_.IsFreeMultiWindowMode())) { + TLOGE(WmsLogTag::WMS_IMMS, "device not support"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); + } int32_t height = 0; if (!ConvertFromJsValue(env, argv[0], height)) { TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to height"); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 9a7274f1d0..06a7fd644f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -5693,7 +5693,7 @@ int32_t SceneSession::GetStatusBarHeight() } height = statusBarRect.height_; } - TLOGI(WmsLogTag::WMS_IMMS, "height %{public}d", height); + TLOGI(WmsLogTag::WMS_IMMS, "win %{public}d height %{public}d", GetPersistentId(), height); return height; } -- Gitee From 6da627ac1aa1d1107879bc19f6010cc4a4266708 Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 13 Jan 2025 18:57:12 +0800 Subject: [PATCH 34/36] =?UTF-8?q?add=20=E5=88=A4=E7=A9=BA=E3=80=81PC?= =?UTF-8?q?=E9=9A=94=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangzilin --- .../napi/scene_session_manager/js_scene_session_manager.cpp | 3 ++- window_scene/session/host/src/scene_session.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 febd09dcab..d6310d0865 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 @@ -3997,7 +3997,8 @@ napi_value JsSceneSessionManager::OnSetStatusBarAvoidHeight(napi_env env, napi_c "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - if ((systemConfig_.IsPcWindow() || systemConfig_.IsFreeMultiWindowMode())) { + if (SceneSessionManager::GetInstance().GetSystemSessionConfig().IsPcWindow() || + SceneSessionManager::GetInstance().GetSystemSessionConfig().IsFreeMultiWindowMode()) { TLOGE(WmsLogTag::WMS_IMMS, "device not support"); return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); } diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 06a7fd644f..9f9da4edd0 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1859,6 +1859,9 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) WindowType::WINDOW_TYPE_STATUS_BAR, sessionProperty->GetDisplayId()); } for (auto& statusBar : statusBarVector) { + if (statusBar == nullptr) { + continue; + } WSRect statusBarRect = statusBar->GetSessionRect(); bool isStatusBarVisible = WindowHelper::IsMainWindow(Session::GetWindowType()) ? isStatusBarVisible_ : statusBar->isVisible_; @@ -5687,6 +5690,9 @@ int32_t SceneSession::GetStatusBarHeight() const auto& statusBarVector = specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_( WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); for (auto& statusBar : statusBarVector) { + if (statusBar == nullptr) { + continue; + } WSRect statusBarRect = statusBar->GetSessionRect(); if (onGetStatusBarAvoidHeightFunc_) { onGetStatusBarAvoidHeightFunc_(statusBarRect); -- Gitee From da52b3875288d3a4ea856e22351626dff6d7a92d Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 13 Jan 2025 20:26:30 +0800 Subject: [PATCH 35/36] fix bug Signed-off-by: wangzilin --- .../napi/scene_session_manager/js_scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d6310d0865..2d22a46a03 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 @@ -4000,7 +4000,7 @@ napi_value JsSceneSessionManager::OnSetStatusBarAvoidHeight(napi_env env, napi_c if (SceneSessionManager::GetInstance().GetSystemSessionConfig().IsPcWindow() || SceneSessionManager::GetInstance().GetSystemSessionConfig().IsFreeMultiWindowMode()) { TLOGE(WmsLogTag::WMS_IMMS, "device not support"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); + return NapiGetUndefined(env); } int32_t height = 0; if (!ConvertFromJsValue(env, argv[0], height)) { -- Gitee From f8347fcf63f0a1b7057956cec98c262d6fcd2b8a Mon Sep 17 00:00:00 2001 From: wangzilin Date: Mon, 13 Jan 2025 20:27:40 +0800 Subject: [PATCH 36/36] fix bug Signed-off-by: wangzilin --- .../napi/scene_session_manager/js_scene_session_manager.cpp | 2 ++ 1 file changed, 2 insertions(+) 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 2d22a46a03..ea8dd43b17 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 @@ -4000,6 +4000,8 @@ napi_value JsSceneSessionManager::OnSetStatusBarAvoidHeight(napi_env env, napi_c if (SceneSessionManager::GetInstance().GetSystemSessionConfig().IsPcWindow() || SceneSessionManager::GetInstance().GetSystemSessionConfig().IsFreeMultiWindowMode()) { TLOGE(WmsLogTag::WMS_IMMS, "device not support"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_DEVICE_NOT_SUPPORT), + "Device is not supported")); return NapiGetUndefined(env); } int32_t height = 0; -- Gitee