From 10b02d76b69abdab6722c8b2ab5a426d873784ec Mon Sep 17 00:00:00 2001 From: chenhao Date: Wed, 31 Jan 2024 11:03:05 +0800 Subject: [PATCH 001/385] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E5=B1=8F?= =?UTF-8?q?=E5=90=8C=E6=98=BE=E5=92=8C=E5=A4=9A=E5=B1=8F=E5=BC=82=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic6a397c1c6deffffacd8e54a6a907e5ba780ac2a Signed-off-by: chenhao --- .../include/abstract_display_controller.h | 2 +- dmserver/include/abstract_screen.h | 4 +- dmserver/src/abstract_display_controller.cpp | 54 ++++++++++++++---- dmserver/src/abstract_screen.cpp | 44 +++++++++------ dmserver/src/abstract_screen_controller.cpp | 55 ++++++++++++++++++- wmserver/include/window_layout_policy.h | 4 +- wmserver/src/display_group_controller.cpp | 6 ++ wmserver/src/window_layout_policy.cpp | 4 +- 8 files changed, 137 insertions(+), 36 deletions(-) diff --git a/dmserver/include/abstract_display_controller.h b/dmserver/include/abstract_display_controller.h index 51102b0be..351d9eb1b 100644 --- a/dmserver/include/abstract_display_controller.h +++ b/dmserver/include/abstract_display_controller.h @@ -65,7 +65,7 @@ private: sptr absScreen, sptr screenGroup, sptr& absDisplay); DisplayId ProcessExpandScreenDisconnected( sptr absScreen, sptr screenGroup, sptr& absDisplay); - bool UpdateDisplaySize(sptr absDisplay, sptr info); + bool UpdateDisplaySize(sptr absDisplay, sptr info, Point offset); void SetDisplayStateChangeListener(sptr abstractDisplay, DisplayStateChangeType type); DisplayId GetDefaultDisplayId(); diff --git a/dmserver/include/abstract_screen.h b/dmserver/include/abstract_screen.h index f82d87ed2..a9e2ddf1a 100644 --- a/dmserver/include/abstract_screen.h +++ b/dmserver/include/abstract_screen.h @@ -56,6 +56,7 @@ public: void UpdateDisplayGroupRSTree(std::shared_ptr& surfaceNode, NodeId parentNodeId, bool isAdd); void InitRSDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); void InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, const Point& startPoint); + void UpdateRSDisplayNode(Point startPoint); ScreenId GetScreenGroupId() const; // colorspace, gamut @@ -76,6 +77,7 @@ public: bool isScreenGroup_ { false }; std::shared_ptr rsDisplayNode_; RSDisplayNodeConfig rSDisplayNodeConfig_; + Point startPoint_{}; ScreenId groupDmsId_ { SCREEN_ID_INVALID }; ScreenId lastGroupDmsId_ { SCREEN_ID_INVALID }; ScreenType type_ { ScreenType::REAL }; @@ -130,7 +132,7 @@ public: private: bool GetRSDisplayNodeConfig(sptr& dmsScreen, struct RSDisplayNodeConfig& config); - std::map, Point>> abstractScreenMap_; + std::map> screenMap_; }; } // namespace OHOS::Rosen #endif // FOUNDATION_DMSERVER_ABSTRACT_SCREEN_H \ No newline at end of file diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index 123595a7b..0a80fc3bd 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -450,7 +450,7 @@ void AbstractDisplayController::ProcessDisplaySizeChange(sptr ab if (absDisplay == nullptr || absDisplay->GetAbstractScreenId() != absScreen->dmsId_) { continue; } - if (UpdateDisplaySize(absDisplay, info)) { + if (UpdateDisplaySize(absDisplay, info, absScreen->startPoint_)) { matchedDisplays.insert(std::make_pair(iter->first, iter->second)); } } @@ -466,22 +466,52 @@ void AbstractDisplayController::ProcessDisplaySizeChange(sptr ab } } -bool AbstractDisplayController::UpdateDisplaySize(sptr absDisplay, sptr info) +bool AbstractDisplayController::UpdateDisplaySize(sptr absDisplay, sptr info, Point offset) { - if (absDisplay == nullptr || info == nullptr) { + if (absDisplay == nullptr) { WLOGFE("invalid params."); return false; } - if (info->height_ == static_cast(absDisplay->GetHeight()) && - info->width_ == static_cast(absDisplay->GetWidth())) { - WLOGFI("keep display size. display:%{public}" PRIu64"", absDisplay->GetId()); - return false; + + bool changed = false; + if (info) { + auto rotation = absDisplay->GetRotation(); + int32_t width = 0; + int32_t height = 0; + if (rotation == Rotation::ROTATION_90 || rotation == Rotation::ROTATION_270) { + width = absDisplay->GetHeight(); + height = absDisplay->GetWidth(); + } else { + width = absDisplay->GetWidth(); + height = absDisplay->GetHeight(); + } + + if (info->width_ == static_cast(width) && + info->height_ == static_cast(height)) { + WLOGFD("keep display size. display:%{public}" PRIu64"", absDisplay->GetId()); + } else { + WLOGFD("Reset H&W. id %{public}" PRIu64", size: %{public}d %{public}d", + absDisplay->GetId(), info->width_, info->height_); + absDisplay->SetWidth(info->width_); + absDisplay->SetHeight(info->height_); + changed = true; + } + } else { + WLOGFE("mode info is null"); } - absDisplay->SetHeight(info->height_); - absDisplay->SetWidth(info->width_); - WLOGFI("Reset H&W. id %{public}" PRIu64", size: %{public}d %{public}d", - absDisplay->GetId(), absDisplay->GetWidth(), absDisplay->GetHeight()); - return true; + + if (offset.posX_ == absDisplay->GetOffsetX() && + offset.posY_ == absDisplay->GetOffsetY()) { + WLOGFD("keep display offset. display:%{public}" PRIu64"", absDisplay->GetId()); + } else { + WLOGFD("Reset offset. id %{public}" PRIu64", size: %{public}d %{public}d", + absDisplay->GetId(), offset.posX_, offset.posY_); + absDisplay->SetOffsetX(offset.posX_); + absDisplay->SetOffsetY(offset.posY_); + changed = true; + } + + return changed; } void AbstractDisplayController::ProcessVirtualPixelRatioChange(sptr absScreen) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index 5ea59e951..e16c27545 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -173,6 +173,7 @@ void AbstractScreen::SetPropertyForDisplayNode(const std::shared_ptrSetDisplayOffset(startPoint.posX_, startPoint.posY_); uint32_t width = 0; @@ -249,6 +250,14 @@ void AbstractScreen::InitRSDefaultDisplayNode(const RSDisplayNodeConfig& config, WLOGFD("InitRSDefaultDisplayNode success"); } +void AbstractScreen::UpdateRSDisplayNode(Point startPoint) +{ + WLOGD("update display offset from [%{public}d %{public}d] to [%{public}d %{public}d]", + startPoint_.posX_, startPoint_.posY_, startPoint.posX_, startPoint.posY_); + startPoint_ = startPoint; + rsDisplayNode_->SetDisplayOffset(startPoint.posX_, startPoint.posY_); +} + ScreenId AbstractScreen::GetScreenGroupId() const { return groupDmsId_; @@ -486,7 +495,6 @@ AbstractScreenGroup::AbstractScreenGroup(sptr screenCo AbstractScreenGroup::~AbstractScreenGroup() { rsDisplayNode_ = nullptr; - abstractScreenMap_.clear(); } sptr AbstractScreenGroup::ConvertToScreenGroupInfo() const @@ -497,11 +505,10 @@ sptr AbstractScreenGroup::ConvertToScreenGroupInfo() const } FillScreenInfo(screenGroupInfo); screenGroupInfo->combination_ = combination_; - for (auto iter = abstractScreenMap_.begin(); iter != abstractScreenMap_.end(); iter++) { + for (auto iter = screenMap_.begin(); iter != screenMap_.end(); iter++) { screenGroupInfo->children_.push_back(iter->first); + screenGroupInfo->position_.push_back(iter->second->startPoint_); } - auto positions = GetChildrenPosition(); - screenGroupInfo->position_.insert(screenGroupInfo->position_.end(), positions.begin(), positions.end()); return screenGroupInfo; } @@ -556,13 +563,13 @@ bool AbstractScreenGroup::AddChild(sptr& dmsScreen, Point& start } ScreenId screenId = dmsScreen->dmsId_; WLOGFD("AbstractScreenGroup AddChild dmsScreenId: %{public}" PRIu64"", screenId); - auto iter = abstractScreenMap_.find(screenId); - if (iter != abstractScreenMap_.end()) { + auto iter = screenMap_.find(screenId); + if (iter != screenMap_.end()) { if (dmsScreen->rsDisplayNode_ != nullptr && dmsScreen->type_ == ScreenType::REAL && defaultScreenId_ == screenId) { WLOGFD("Add default screen, id: %{public}" PRIu64"", screenId); } else { - WLOGE("AddChild, abstractScreenMap_ has dmsScreen:%{public}" PRIu64"", screenId); + WLOGE("AddChild, screenMap_ has dmsScreen:%{public}" PRIu64"", screenId); return false; } } @@ -578,7 +585,7 @@ bool AbstractScreenGroup::AddChild(sptr& dmsScreen, Point& start dmsScreen->InitRSDisplayNode(config, startPoint); dmsScreen->lastGroupDmsId_ = dmsScreen->groupDmsId_; dmsScreen->groupDmsId_ = dmsId_; - abstractScreenMap_.insert(std::make_pair(screenId, std::make_pair(dmsScreen, startPoint))); + screenMap_.insert(std::make_pair(screenId, dmsScreen)); } return true; } @@ -606,6 +613,7 @@ bool AbstractScreenGroup::RemoveChild(sptr& dmsScreen) ScreenId screenId = dmsScreen->dmsId_; dmsScreen->lastGroupDmsId_ = dmsScreen->groupDmsId_; dmsScreen->groupDmsId_ = SCREEN_ID_INVALID; + dmsScreen->startPoint_ = Point(); if (dmsScreen->rsDisplayNode_ != nullptr) { dmsScreen->rsDisplayNode_->SetDisplayOffset(0, 0); dmsScreen->rsDisplayNode_->RemoveFromTree(); @@ -617,7 +625,7 @@ bool AbstractScreenGroup::RemoveChild(sptr& dmsScreen) } WLOGFD("groupDmsId:%{public}" PRIu64", screenId:%{public}" PRIu64"", dmsScreen->groupDmsId_, screenId); - return abstractScreenMap_.erase(screenId); + return screenMap_.erase(screenId); } bool AbstractScreenGroup::RemoveDefaultScreen(const sptr& dmsScreen) @@ -644,14 +652,14 @@ bool AbstractScreenGroup::RemoveDefaultScreen(const sptr& dmsScr bool AbstractScreenGroup::HasChild(ScreenId childScreen) const { - return abstractScreenMap_.find(childScreen) != abstractScreenMap_.end(); + return screenMap_.find(childScreen) != screenMap_.end(); } std::vector> AbstractScreenGroup::GetChildren() const { std::vector> res; - for (auto iter = abstractScreenMap_.begin(); iter != abstractScreenMap_.end(); iter++) { - res.push_back(iter->second.first); + for (auto iter = screenMap_.begin(); iter != screenMap_.end(); iter++) { + res.push_back(iter->second); } return res; } @@ -659,8 +667,8 @@ std::vector> AbstractScreenGroup::GetChildren() const std::vector AbstractScreenGroup::GetChildrenPosition() const { std::vector res; - for (auto iter = abstractScreenMap_.begin(); iter != abstractScreenMap_.end(); iter++) { - res.push_back(iter->second.second); + for (auto iter = screenMap_.begin(); iter != screenMap_.end(); iter++) { + res.push_back(iter->second->startPoint_); } return res; } @@ -668,16 +676,16 @@ std::vector AbstractScreenGroup::GetChildrenPosition() const Point AbstractScreenGroup::GetChildPosition(ScreenId screenId) const { Point point; - auto iter = abstractScreenMap_.find(screenId); - if (iter != abstractScreenMap_.end()) { - point = iter->second.second; + auto iter = screenMap_.find(screenId); + if (iter != screenMap_.end()) { + point = iter->second->startPoint_; } return point; } size_t AbstractScreenGroup::GetChildCount() const { - return abstractScreenMap_.size(); + return screenMap_.size(); } ScreenCombination AbstractScreenGroup::GetScreenCombination() const diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index bc134c8d2..23705d86c 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -588,7 +588,15 @@ sptr AbstractScreenController::AddAsSuccedentScreenLocked(s auto screenGroup = screenGroupIter->second; Point point; if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) { - point = {screen->GetActiveScreenMode()->width_, 0}; + for (auto& child : screenGroup->GetChildren()) { + WLOGD("AddAsSuccedentScreenLocked. defaultScreen rotation:%d", child->rotation_); + if (child->rotation_ == Rotation::ROTATION_90 || child->rotation_ == Rotation::ROTATION_270) { + point.posX_ += child->GetActiveScreenMode()->height_; + } else { + point.posX_ += child->GetActiveScreenMode()->width_; + } + } + WLOGD("AddAsSuccedentScreenLocked. point:[%d %d]", point.posX_, point.posY_); } screenGroup->AddChild(newScreen, point); return screenGroup; @@ -762,6 +770,51 @@ DMError AbstractScreenController::SetOrientation(ScreenId screenId, Orientation abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::UPDATE_ORIENTATION); } } + + auto screenGroup = screen->GetGroup(); + if (!screenGroup) { + WLOGE("no screen group"); + return DMError::DM_ERROR_NULLPTR; + } + + if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) { + // update display start point + auto screens = screenGroup->GetChildren(); + if (screens.size() > 1) { + // from left to right + std::sort(screens.begin(), screens.end(), [](const auto &a, const auto &b) { + return a->startPoint_.posX_ < b->startPoint_.posX_; + }); + + Point point; + int width = 0; + for (auto& screen : screens) { + WLOGD("screen: %{public}llu", screen->dmsId_); + auto mode = screen->GetActiveScreenMode(); + if (!mode) { + WLOGE("no active screen mode"); + continue; + } + + if (screen->startPoint_.posX_ != point.posX_) { + screen->UpdateRSDisplayNode(point); + if (abstractScreenCallback_ != nullptr) { + abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); + } + } + + if (screen->rotation_ == Rotation::ROTATION_90 || + screen->rotation_ == Rotation::ROTATION_270) { + width = mode->height_; + } else { + width = mode->width_; + } + + point.posX_ += width; + } + } + } + return DMError::DM_OK; } diff --git a/wmserver/include/window_layout_policy.h b/wmserver/include/window_layout_policy.h index 8a549503d..12da59bc2 100644 --- a/wmserver/include/window_layout_policy.h +++ b/wmserver/include/window_layout_policy.h @@ -111,8 +111,8 @@ protected: void GetStoragedAspectRatio(const sptr& node); bool IsNeedAnimationSync(WindowType type); - Rect displayGroupRect_; - Rect displayGroupLimitRect_; + Rect displayGroupRect_{}; + Rect displayGroupLimitRect_{}; bool isMultiDisplay_ = false; mutable std::map limitRectMap_; DisplayGroupWindowTree& displayGroupWindowTree_; diff --git a/wmserver/src/display_group_controller.cpp b/wmserver/src/display_group_controller.cpp index b356c5110..d641fe0df 100644 --- a/wmserver/src/display_group_controller.cpp +++ b/wmserver/src/display_group_controller.cpp @@ -228,6 +228,12 @@ void DisplayGroupController::UpdateWindowDisplayIdIfNeeded(const sptr& node, DisplayId displayId) { + auto displays = node->GetShowingDisplays(); + if (std::find(displays.begin(), displays.end(), displayId) != displays.end()) { + WLOGFD("Alreedy show in display %{public}" PRIu64 "", displayId); + return; + } + Rect requestRect = node->GetRequestRect(); const Rect& displayRect = DisplayGroupInfo::GetInstance().GetDisplayRect(displayId); requestRect.posX_ += displayRect.posX_; diff --git a/wmserver/src/window_layout_policy.cpp b/wmserver/src/window_layout_policy.cpp index 38ce238ab..4aca5d323 100644 --- a/wmserver/src/window_layout_policy.cpp +++ b/wmserver/src/window_layout_policy.cpp @@ -87,7 +87,9 @@ void WindowLayoutPolicy::UpdateDisplayGroupRect() for (auto& elem : DisplayGroupInfo::GetInstance().GetAllDisplayRects()) { newDisplayGroupRect.posX_ = std::min(displayGroupRect_.posX_, elem.second.posX_); newDisplayGroupRect.posY_ = std::min(displayGroupRect_.posY_, elem.second.posY_); - newDisplayGroupRect.width_ += elem.second.width_; + int32_t right = std::max(newDisplayGroupRect.posX_ + static_cast(newDisplayGroupRect.width_), + elem.second.posX_+ static_cast(elem.second.width_)); + newDisplayGroupRect.width_ = right - newDisplayGroupRect.posX_; int32_t maxHeight = std::max(newDisplayGroupRect.posY_ + static_cast(newDisplayGroupRect.height_), elem.second.posY_+ static_cast(elem.second.height_)); newDisplayGroupRect.height_ = maxHeight - newDisplayGroupRect.posY_; -- Gitee From ce4d9cbf9156c1927d08607fd5442175d972d8de Mon Sep 17 00:00:00 2001 From: chenhao Date: Thu, 1 Feb 2024 19:57:39 +0800 Subject: [PATCH 002/385] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=A3=80=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6f05ee163f52b55231a98872e257d12627375eb8 Signed-off-by: chenhao --- dmserver/include/abstract_screen_controller.h | 1 + dmserver/src/abstract_display_controller.cpp | 3 +- dmserver/src/abstract_screen_controller.cpp | 73 ++++++++++--------- wmserver/src/window_layout_policy.cpp | 2 +- 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/dmserver/include/abstract_screen_controller.h b/dmserver/include/abstract_screen_controller.h index 274252bd7..347dcfb5e 100644 --- a/dmserver/include/abstract_screen_controller.h +++ b/dmserver/include/abstract_screen_controller.h @@ -120,6 +120,7 @@ private: void NotifyScreenGroupChanged(const std::vector>& screenInfo, ScreenGroupChangeEvent event) const; void OpenRotationSyncTransaction(); void CloseRotationSyncTransaction(); + void UpdateScreenGroupLayout(sptr screenGroup); class ScreenIdManager { public: diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index 0a80fc3bd..9b8371c6f 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -466,7 +466,8 @@ void AbstractDisplayController::ProcessDisplaySizeChange(sptr ab } } -bool AbstractDisplayController::UpdateDisplaySize(sptr absDisplay, sptr info, Point offset) +bool AbstractDisplayController::UpdateDisplaySize(sptr absDisplay, sptr info, + Point offset) { if (absDisplay == nullptr) { WLOGFE("invalid params."); diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index 23705d86c..ce2e0923e 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -772,50 +772,53 @@ DMError AbstractScreenController::SetOrientation(ScreenId screenId, Orientation } auto screenGroup = screen->GetGroup(); - if (!screenGroup) { - WLOGE("no screen group"); - return DMError::DM_ERROR_NULLPTR; + if (screenGroup) { + UpdateScreenGroupLayout(screenGroup); } - if (screenGroup->combination_ == ScreenCombination::SCREEN_EXPAND) { - // update display start point - auto screens = screenGroup->GetChildren(); - if (screens.size() > 1) { - // from left to right - std::sort(screens.begin(), screens.end(), [](const auto &a, const auto &b) { - return a->startPoint_.posX_ < b->startPoint_.posX_; - }); - - Point point; - int width = 0; - for (auto& screen : screens) { - WLOGD("screen: %{public}llu", screen->dmsId_); - auto mode = screen->GetActiveScreenMode(); - if (!mode) { - WLOGE("no active screen mode"); - continue; - } + return DMError::DM_OK; +} - if (screen->startPoint_.posX_ != point.posX_) { - screen->UpdateRSDisplayNode(point); - if (abstractScreenCallback_ != nullptr) { - abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); - } - } +void AbstractScreenController::UpdateScreenGroupLayout(sptr screenGroup) +{ + if (screenGroup->combination_ != ScreenCombination::SCREEN_EXPAND) { + return; + } - if (screen->rotation_ == Rotation::ROTATION_90 || - screen->rotation_ == Rotation::ROTATION_270) { - width = mode->height_; - } else { - width = mode->width_; + // update display start point + auto screens = screenGroup->GetChildren(); + if (screens.size() > 1) { + // from left to right + std::sort(screens.begin(), screens.end(), [](const auto &a, const auto &b) { + return a->startPoint_.posX_ < b->startPoint_.posX_; + }); + + Point point; + int width = 0; + for (auto& screen : screens) { + auto mode = screen->GetActiveScreenMode(); + if (!mode) { + WLOGE("no active screen mode"); + continue; + } + + if (screen->startPoint_.posX_ != point.posX_) { + screen->UpdateRSDisplayNode(point); + if (abstractScreenCallback_ != nullptr) { + abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); } + } - point.posX_ += width; + if (screen->rotation_ == Rotation::ROTATION_90 || + screen->rotation_ == Rotation::ROTATION_270) { + width = mode->height_; + } else { + width = mode->width_; } + + point.posX_ += width; } } - - return DMError::DM_OK; } void AbstractScreenController::SetScreenRotateAnimation( diff --git a/wmserver/src/window_layout_policy.cpp b/wmserver/src/window_layout_policy.cpp index 4aca5d323..c6a0fa1f3 100644 --- a/wmserver/src/window_layout_policy.cpp +++ b/wmserver/src/window_layout_policy.cpp @@ -88,7 +88,7 @@ void WindowLayoutPolicy::UpdateDisplayGroupRect() newDisplayGroupRect.posX_ = std::min(displayGroupRect_.posX_, elem.second.posX_); newDisplayGroupRect.posY_ = std::min(displayGroupRect_.posY_, elem.second.posY_); int32_t right = std::max(newDisplayGroupRect.posX_ + static_cast(newDisplayGroupRect.width_), - elem.second.posX_+ static_cast(elem.second.width_)); + elem.second.posX_+ static_cast(elem.second.width_)); newDisplayGroupRect.width_ = right - newDisplayGroupRect.posX_; int32_t maxHeight = std::max(newDisplayGroupRect.posY_ + static_cast(newDisplayGroupRect.height_), elem.second.posY_+ static_cast(elem.second.height_)); -- Gitee From e6914f7b8ea0ec8395b8cdb81964f32b389ae03b Mon Sep 17 00:00:00 2001 From: chenhao Date: Thu, 1 Feb 2024 21:33:46 +0800 Subject: [PATCH 003/385] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=A3=80=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenhao Change-Id: Iec10cf620afbcdc08f63ba737662c9391c0016c4 --- dmserver/src/abstract_screen_controller.cpp | 55 +++++++++++---------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index ce2e0923e..d58eb4d4b 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -785,39 +785,40 @@ void AbstractScreenController::UpdateScreenGroupLayout(sptr return; } - // update display start point auto screens = screenGroup->GetChildren(); - if (screens.size() > 1) { - // from left to right - std::sort(screens.begin(), screens.end(), [](const auto &a, const auto &b) { - return a->startPoint_.posX_ < b->startPoint_.posX_; - }); - - Point point; - int width = 0; - for (auto& screen : screens) { - auto mode = screen->GetActiveScreenMode(); - if (!mode) { - WLOGE("no active screen mode"); - continue; - } + if (screens.size() <= 1) { + return; + } - if (screen->startPoint_.posX_ != point.posX_) { - screen->UpdateRSDisplayNode(point); - if (abstractScreenCallback_ != nullptr) { - abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); - } - } + // update display node's start point from left to right. + std::sort(screens.begin(), screens.end(), [](const auto &a, const auto &b) { + return a->startPoint_.posX_ < b->startPoint_.posX_; + }); + + Point point; + int width = 0; + for (auto& screen : screens) { + auto mode = screen->GetActiveScreenMode(); + if (!mode) { + WLOGE("no active screen mode"); + continue; + } - if (screen->rotation_ == Rotation::ROTATION_90 || - screen->rotation_ == Rotation::ROTATION_270) { - width = mode->height_; - } else { - width = mode->width_; + if (screen->startPoint_.posX_ != point.posX_) { + screen->UpdateRSDisplayNode(point); + if (abstractScreenCallback_ != nullptr) { + abstractScreenCallback_->onChange_(screen, DisplayChangeEvent::DISPLAY_SIZE_CHANGED); } + } - point.posX_ += width; + if (screen->rotation_ == Rotation::ROTATION_90 || + screen->rotation_ == Rotation::ROTATION_270) { + width = mode->height_; + } else { + width = mode->width_; } + + point.posX_ += width; } } -- Gitee From 35c927d6ca8a51afe7c563788c5e98a1b044d313 Mon Sep 17 00:00:00 2001 From: chenhao Date: Thu, 1 Feb 2024 22:17:26 +0800 Subject: [PATCH 004/385] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenhao Change-Id: I6d6fe17cd46ebcdfa40c1f45c76a8874c32921db --- .../include/abstract_display_controller.h | 2 +- .../abstract_display_controller_test.cpp | 4 +-- .../abstract_screen_controller_test.cpp | 14 ++++------ .../test/unittest/abstract_screen_test.cpp | 28 +++++++++---------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/dmserver/include/abstract_display_controller.h b/dmserver/include/abstract_display_controller.h index 351d9eb1b..67a6eb956 100644 --- a/dmserver/include/abstract_display_controller.h +++ b/dmserver/include/abstract_display_controller.h @@ -65,7 +65,7 @@ private: sptr absScreen, sptr screenGroup, sptr& absDisplay); DisplayId ProcessExpandScreenDisconnected( sptr absScreen, sptr screenGroup, sptr& absDisplay); - bool UpdateDisplaySize(sptr absDisplay, sptr info, Point offset); + bool UpdateDisplaySize(sptr absDisplay, sptr info, Point offset = Point(0, 0)); void SetDisplayStateChangeListener(sptr abstractDisplay, DisplayStateChangeType type); DisplayId GetDefaultDisplayId(); diff --git a/dmserver/test/unittest/abstract_display_controller_test.cpp b/dmserver/test/unittest/abstract_display_controller_test.cpp index e48c879a4..1f85c8686 100644 --- a/dmserver/test/unittest/abstract_display_controller_test.cpp +++ b/dmserver/test/unittest/abstract_display_controller_test.cpp @@ -121,7 +121,7 @@ HWTEST_F(AbstractDisplayControllerTest, OnAbstractScreenConnectAndDisConnect02, { auto group = absScreen_->GetGroup(); EXPECT_NE(nullptr, group); - group->abstractScreenMap_.insert(std::make_pair(100, std::make_pair(absScreen_, Point(0, 0)))); // 100 is test data + group->screenMap_.insert(std::make_pair(100, absScreen_)); // 100 is test data group->combination_ = ScreenCombination::SCREEN_MIRROR; absDisplayController_->OnAbstractScreenConnect(absScreen_); absDisplayController_->OnAbstractScreenDisconnect(absScreen_); @@ -136,7 +136,7 @@ HWTEST_F(AbstractDisplayControllerTest, OnAbstractScreenConnectAndDisConnect03, { auto group = absScreen_->GetGroup(); EXPECT_NE(nullptr, group); - group->abstractScreenMap_.insert(std::make_pair(100, std::make_pair(absScreen_, Point(0, 0)))); // 100 is test data + group->screenMap_.insert(std::make_pair(100, absScreen_)); // 100 is test data group->combination_ = ScreenCombination::SCREEN_EXPAND; absDisplayController_->OnAbstractScreenConnect(absScreen_); absDisplayController_->OnAbstractScreenDisconnect(absScreen_); diff --git a/dmserver/test/unittest/abstract_screen_controller_test.cpp b/dmserver/test/unittest/abstract_screen_controller_test.cpp index dceb59e4a..35cb1046f 100644 --- a/dmserver/test/unittest/abstract_screen_controller_test.cpp +++ b/dmserver/test/unittest/abstract_screen_controller_test.cpp @@ -423,10 +423,8 @@ HWTEST_F(AbstractScreenControllerTest, RemoveChildFromGroup01, Function | SmallT { sptr screen = screenVec[0]; ScreenId dmsId = screen->dmsId_; - Point point; - auto p = std::make_pair(screen, point); sptr screenGroup = absController_->dmsScreenGroupMap_[0]; - screenGroup->abstractScreenMap_.insert(std::make_pair(dmsId, p)); + screenGroup->screenMap_.insert(std::make_pair(dmsId, screen)); ASSERT_EQ(true, absController_->RemoveChildFromGroup(screen, screenGroup)); } /** @@ -652,9 +650,8 @@ HWTEST_F(AbstractScreenControllerTest, ChangeScreenGroup01, Function | SmallTest { sptr group = screenGroupVec[0]; Point point; - auto abs2pointPair = std::make_pair(screenVec[0], point); - group->abstractScreenMap_.insert(std::make_pair(0, abs2pointPair)); - group->abstractScreenMap_.insert(std::make_pair(1, abs2pointPair)); + group->screenMap_.insert(std::make_pair(0, screenVec[0])); + group->screenMap_.insert(std::make_pair(1, screenVec[0])); std::vector startPoints; std::vector screens; for (ScreenId i = 0; i < 7; ++i) { @@ -676,9 +673,8 @@ HWTEST_F(AbstractScreenControllerTest, ChangeScreenGroup02, Function | SmallTest { sptr group = screenGroupVec[0]; Point point; - auto abs2pointPair = std::make_pair(screenVec[0], point); - group->abstractScreenMap_.insert(std::make_pair(0, abs2pointPair)); - group->abstractScreenMap_.insert(std::make_pair(1, abs2pointPair)); + group->screenMap_.insert(std::make_pair(0, screenVec[0])); + group->screenMap_.insert(std::make_pair(1, screenVec[0])); std::vector startPoints; std::vector screens; for (ScreenId i = 0; i < 7; ++i) { diff --git a/dmserver/test/unittest/abstract_screen_test.cpp b/dmserver/test/unittest/abstract_screen_test.cpp index aa41be2eb..c37ce01f3 100644 --- a/dmserver/test/unittest/abstract_screen_test.cpp +++ b/dmserver/test/unittest/abstract_screen_test.cpp @@ -273,8 +273,8 @@ HWTEST_F(AbstractScreenTest, GetSourceMode, Function | SmallTest | Level3) HWTEST_F(AbstractScreenTest, ConvertToScreenGroupInfo, Function | SmallTest | Level3) { Point point_(159, 357); - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({10086, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({10086, absScreen_}); sptr result = absScreenGroup_->ConvertToScreenGroupInfo(); EXPECT_EQ(result->children_[0], 10086); } @@ -300,8 +300,8 @@ HWTEST_F(AbstractScreenTest, GetRSDisplayNodeConfig, Function | SmallTest | Leve result = absScreenGroup_->GetRSDisplayNodeConfig(absTest, config_); EXPECT_FALSE(result); Point point_(159, 357); - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({10086, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({10086, absScreen_}); absScreenGroup_->mirrorScreenId_ = 10086; EXPECT_FALSE(result); } @@ -313,7 +313,7 @@ HWTEST_F(AbstractScreenTest, GetRSDisplayNodeConfig, Function | SmallTest | Leve */ HWTEST_F(AbstractScreenTest, AddChild01, Function | SmallTest | Level3) { - absScreenGroup_->abstractScreenMap_.clear(); + absScreenGroup_->screenMap_.clear(); sptr absTest = nullptr; Point point_(159, 357); bool result = absScreenGroup_->AddChild(absTest, point_); @@ -343,12 +343,12 @@ HWTEST_F(AbstractScreenTest, AddChild01, Function | SmallTest | Level3) */ HWTEST_F(AbstractScreenTest, AddChild02, Function | SmallTest | Level3) { - absScreenGroup_->abstractScreenMap_.clear(); + absScreenGroup_->screenMap_.clear(); Point point_(159, 357); absScreenGroup_->mirrorScreenId_ = 10086; absScreenGroup_->combination_ = ScreenCombination::SCREEN_MIRROR; - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({0, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({0, absScreen_}); absScreen_->rsDisplayNode_ = nullptr; bool result = absScreenGroup_->AddChild(absScreen_, point_); EXPECT_FALSE(result); @@ -406,8 +406,8 @@ HWTEST_F(AbstractScreenTest, RemoveChild02, Function | SmallTest | Level3) Point point_(159, 357); struct RSDisplayNodeConfig config; absScreen_->rsDisplayNode_ = std::make_shared(config); - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({0, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({0, absScreen_}); bool result = absScreenGroup_->RemoveChild(absScreen_); ASSERT_TRUE(result); } @@ -441,8 +441,8 @@ HWTEST_F(AbstractScreenTest, RemoveDefaultScreen, Function | SmallTest | Level3) HWTEST_F(AbstractScreenTest, GetChildren, Function | SmallTest | Level3) { Point point_(159, 357); - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({10086, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({10086, absScreen_}); std::vector> result = absScreenGroup_->GetChildren(); ASSERT_EQ(result[0], absScreen_); } @@ -455,8 +455,8 @@ HWTEST_F(AbstractScreenTest, GetChildren, Function | SmallTest | Level3) HWTEST_F(AbstractScreenTest, GetChildrenPosition, Function | SmallTest | Level3) { Point point_(159, 357); - std::pair, Point> pair_ = std::make_pair(absScreen_, point_); - (absScreenGroup_->abstractScreenMap_).insert({10086, pair_}); + absScreen_->startPoint_ = point_; + (absScreenGroup_->screenMap_).insert({10086, absScreen_}); std::vector result = absScreenGroup_->GetChildrenPosition(); EXPECT_EQ(result[0].posX_, 159); EXPECT_EQ(result[0].posY_, 357); -- Gitee From b783e428e1178a6d55066676076d5cf6345b44eb Mon Sep 17 00:00:00 2001 From: chenhao Date: Thu, 1 Feb 2024 22:30:31 +0800 Subject: [PATCH 005/385] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=A3=80=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenhao Change-Id: I2e1a7069d06ecb4b6e129dc8b854ef701aeb8dc9 --- dmserver/include/abstract_display_controller.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dmserver/include/abstract_display_controller.h b/dmserver/include/abstract_display_controller.h index 67a6eb956..33ff7eea8 100644 --- a/dmserver/include/abstract_display_controller.h +++ b/dmserver/include/abstract_display_controller.h @@ -65,7 +65,8 @@ private: sptr absScreen, sptr screenGroup, sptr& absDisplay); DisplayId ProcessExpandScreenDisconnected( sptr absScreen, sptr screenGroup, sptr& absDisplay); - bool UpdateDisplaySize(sptr absDisplay, sptr info, Point offset = Point(0, 0)); + bool UpdateDisplaySize(sptr absDisplay, sptr info, + Point offset = Point(0, 0)); void SetDisplayStateChangeListener(sptr abstractDisplay, DisplayStateChangeType type); DisplayId GetDefaultDisplayId(); -- Gitee From 615002c26e67744f5d214306e3c4bc314bddb39b Mon Sep 17 00:00:00 2001 From: ludao Date: Tue, 6 Feb 2024 16:26:48 +0800 Subject: [PATCH 006/385] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ludao Change-Id: I5912ed6ae9866a4f15cf36a0295ef8fa8263ab72 --- dmserver/src/abstract_screen.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dmserver/src/abstract_screen.cpp b/dmserver/src/abstract_screen.cpp index e16c27545..472a86bda 100644 --- a/dmserver/src/abstract_screen.cpp +++ b/dmserver/src/abstract_screen.cpp @@ -254,6 +254,11 @@ void AbstractScreen::UpdateRSDisplayNode(Point startPoint) { WLOGD("update display offset from [%{public}d %{public}d] to [%{public}d %{public}d]", startPoint_.posX_, startPoint_.posY_, startPoint.posX_, startPoint.posY_); + if (rsDisplayNode_ == nullptr) { + WLOGFD("rsDisplayNode_ is nullptr"); + return; + } + startPoint_ = startPoint; rsDisplayNode_->SetDisplayOffset(startPoint.posX_, startPoint.posY_); } -- Gitee From eba697ea79fcf1f9f6f787be2fa3c78002f90220 Mon Sep 17 00:00:00 2001 From: ludao Date: Wed, 7 Feb 2024 14:34:36 +0800 Subject: [PATCH 007/385] =?UTF-8?q?=E9=80=82=E9=85=8D=E5=A4=9A=E6=A8=A1?= =?UTF-8?q?=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ludao Change-Id: I8d9e38cbe0bba88ec93a91a8efa33401f73e55ee --- wmserver/src/input_window_monitor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wmserver/src/input_window_monitor.cpp b/wmserver/src/input_window_monitor.cpp index fe20f4569..dca2e3d58 100644 --- a/wmserver/src/input_window_monitor.cpp +++ b/wmserver/src/input_window_monitor.cpp @@ -124,9 +124,10 @@ void InputWindowMonitor::UpdateDisplayInfo(const std::vector>& .width = static_cast(displayWidth), .height = static_cast(displayHeight), .dpi = displayInfo->GetDpi(), - .name = (std::stringstream("display ")<GetDisplayId()).str(), + .name = "display " + std::to_string(displayInfo->GetDisplayId()), .uniq = "default" + std::to_string(displayInfo->GetDisplayId()), .direction = GetDisplayDirectionForMmi(displayInfo->GetRotation()), + .displayDirection = GetDisplayDirectionForMmi(displayInfo->GetRotation()), }; auto displayIter = std::find_if(displayInfoVector.begin(), displayInfoVector.end(), [&display](MMI::DisplayInfo& displayInfoTmp) { -- Gitee From 17009262f3bdfb347182bdbbe20e22da8ea1b69e Mon Sep 17 00:00:00 2001 From: xiongyonglong Date: Sun, 18 Feb 2024 12:02:31 +0800 Subject: [PATCH 008/385] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=B3=95=E6=81=A2=E5=A4=8D=E6=96=B9=E6=A1=88=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E5=85=A8=E6=90=9C=E3=80=81=E5=A4=87=E5=BF=98?= =?UTF-8?q?=E5=BD=95=E3=80=81=E6=97=A5=E5=8E=86=E7=AD=89=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E8=BE=93=E5=85=A5=E6=B3=95=E9=83=BD=E8=83=BD?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiongyonglong --- .../include/scene_session_manager.h | 1 - .../src/scene_session_manager.cpp | 37 +++---------------- wm/src/window_scene_session_impl.cpp | 8 ++++ 3 files changed, 13 insertions(+), 33 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 8beef9645..cf912caeb 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -507,7 +507,6 @@ private: sptr windowDeath_ = new AgentDeathRecipient( std::bind(&SceneSessionManager::DestroySpecificSession, this, std::placeholders::_1)); sptr callingSession_ = nullptr; - uint32_t callingWindowId_ = 0; WSError ClearSession(sptr sceneSession); bool IsSessionClearable(sptr scnSession); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index cd8317103..413dc59f1 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1770,7 +1770,7 @@ WSError SceneSessionManager::RecoverAndConnectSpecificSession(const sptr sceneSession, const sptr& property) +void SceneSessionManager::RecoverWindowSessionProperty(int32_t persistentId) { - if (sceneSession == nullptr || property == nullptr) { - WLOGFE("[WMSRecover] sceneSession or property is nullptr"); - return; - } - - auto windowType = property->GetWindowType(); - if (windowType == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { - RelayoutKeyBoard(sceneSession); - callingWindowId_ = property->GetCallingWindow(); - const auto& callingSession = GetSceneSession(static_cast(callingWindowId_)); - if (callingSession != nullptr) { - WLOGFI("[WMSRecover] NotifyOccupiedAreaChangeInfo after inputMethod session recovered," - "persistentId = %{public}" PRId32, callingSession->GetPersistentId()); - sptr info = new OccupiedAreaChangeInfo(); - callingSession->NotifyOccupiedAreaChangeInfo(info); - } - } else { - auto persistentId = sceneSession->GetPersistentId(); - if (persistentId == static_cast(callingWindowId_)) { - WLOGFI("[WMSRecover] NotifyOccupiedAreaChangeInfo after calling session recovered," - "persistentId = %{public}" PRId32, persistentId); - sptr info = new OccupiedAreaChangeInfo(); - sceneSession->NotifyOccupiedAreaChangeInfo(info); - } - } - if (listenerController_ != nullptr) { - WLOGFI("[WMSRecover] NotifySessionUnfocused"); - listenerController_->NotifySessionUnfocused(sceneSession->GetPersistentId()); + WLOGFI("[WMSRecover] NotifySessionUnfocused persistentId = %{public}" PRId32, persistentId); + listenerController_->NotifySessionUnfocused(persistentId); } } @@ -1919,7 +1892,7 @@ WSError SceneSessionManager::RecoverAndReconnectSceneSession(const sptrGetPersistentId()); session = sceneSession; return WSError::WS_OK; } diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 20aa54b48..485bacac0 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -239,6 +239,9 @@ WMError WindowSceneSessionImpl::RecoverAndConnectSpecificSession() WMError WindowSceneSessionImpl::RecoverAndReconnectSceneSession() { + if (isFocused_) { + UpdateFocus(false); + } SessionInfo info; auto abilityContext = AbilityRuntime::Context::ConvertTo(context_); if (property_ && context_ && context_->GetHapModuleInfo() && abilityContext && abilityContext->GetAbilityInfo()) { @@ -467,6 +470,11 @@ void WindowSceneSessionImpl::RegisterSessionRecoverListener(bool isSpecificSessi { WLOGFD("[WMSRecover] persistentId = %{public}d, isSpecificSession = %{public}s", GetPersistentId(), isSpecificSession ? "true" : "false"); + + if (GetType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { + WLOGFI("[WMSRecover] input method window does not need to recover"); + return; + } wptr weakThis = this; auto callbackFunc = [weakThis, isSpecificSession] { -- Gitee From c5edb8edc412c46ea51435bcb07a871f2f05fe2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E6=B0=B8=E9=BE=99?= Date: Thu, 7 Mar 2024 03:59:57 +0000 Subject: [PATCH 009/385] update window_scene/session_manager/include/scene_session_manager.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 熊永龙 --- 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 cf912caeb..da7ef1e05 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -540,7 +540,7 @@ private: void NotifyCreateSubSession(int32_t persistentId, sptr session); void CacheSubSessionForRecovering(sptr sceneSession, const sptr& property); void RecoverCachedSubSession(int32_t persistentId); - void RecoverWindowSessionProperty(sptr sceneSession, const sptr& property); + void RecoverWindowSessionProperty(int32_t persistentId); void NotifyCreateSpecificSession(sptr session, sptr property, const WindowType& type); sptr CreateSceneSession(const SessionInfo& sessionInfo, sptr property); -- Gitee From 936bbdaae3217c02b97b694018d8f9d53ba5d3a6 Mon Sep 17 00:00:00 2001 From: yangningning Date: Thu, 7 Mar 2024 09:59:49 +0800 Subject: [PATCH 010/385] scene_session_test Signed-off-by: yangningning Change-Id: Id9dd10261f1184ccc0ffa5aa6763e02c060d3c70 --- .../test/unittest/scene_session_test.cpp | 412 ++++++++++++++++++ 1 file changed, 412 insertions(+) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 80e9aba31..2fa27faa2 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -2442,6 +2442,418 @@ HWTEST_F(SceneSessionTest, RequestHideKeyboard, Function | SmallTest | Level2) scensession->RequestHideKeyboard(); ASSERT_EQ(0, resultValue); } + +/** + * @tc.name: UpdateAvoidArea + * @tc.desc: * @tc.name: UpdateAvoidArea + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, UpdateAvoidArea, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "UpdateAvoidArea"; + info.bundleName_ = "UpdateAvoidArea"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + scensession->sessionStage_ = nullptr; + WSError result = scensession->UpdateAvoidArea(nullptr, AvoidAreaType::TYPE_SYSTEM); + EXPECT_EQ(WSError::WS_ERROR_NULLPTR, result); + + scensession->sessionStage_ = new SessionStageMocker(); + EXPECT_NE(nullptr, scensession->sessionStage_); + result = scensession->UpdateAvoidArea(nullptr, AvoidAreaType::TYPE_SYSTEM); + EXPECT_EQ(WSError::WS_OK, result); +} + +/** + * @tc.name: SaveUpdatedIcon + * @tc.desc: * @tc.name: SaveUpdatedIcon + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, SaveUpdatedIcon, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "SaveUpdatedIcon"; + info.bundleName_ = "SaveUpdatedIcon"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + + scensession->scenePersistence_ = new ScenePersistence("OpenHarmony", 1); + EXPECT_NE(nullptr, scensession->scenePersistence_); + scensession->SaveUpdatedIcon(nullptr); +} + +/** + * @tc.name: NotifyTouchOutside + * @tc.desc: * @tc.name: NotifyTouchOutside + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, NotifyTouchOutside, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "NotifyTouchOutside"; + info.bundleName_ = "NotifyTouchOutside"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + + scensession->sessionStage_ = new SessionStageMocker(); + EXPECT_NE(nullptr, scensession->sessionStage_); + scensession->NotifyTouchOutside(); + + scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); + EXPECT_NE(nullptr, scensession->sessionChangeCallback_); + auto func = [scensession]() { + scensession->SaveUpdatedIcon(nullptr); + }; + scensession->sessionChangeCallback_->OnTouchOutside_ = func; + EXPECT_NE(nullptr, &func); + scensession->sessionStage_ = nullptr; + scensession->NotifyTouchOutside(); +} + +/** + * @tc.name: CheckOutTouchOutsideRegister + * @tc.desc: * @tc.name: CheckOutTouchOutsideRegister + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, CheckOutTouchOutsideRegister, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "CheckOutTouchOutsideRegister"; + info.bundleName_ = "CheckOutTouchOutsideRegister"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + + scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); + EXPECT_NE(nullptr, scensession->sessionChangeCallback_); + auto func = [scensession]() { + scensession->NotifyWindowVisibility(); + }; + scensession->sessionChangeCallback_->OnTouchOutside_ = func; + bool result = scensession->CheckOutTouchOutsideRegister(); + EXPECT_EQ(true, result); + + scensession->sessionChangeCallback_ = nullptr; + result = scensession->CheckOutTouchOutsideRegister(); + EXPECT_EQ(false, result); +} + +/** + * @tc.name: UpdateRotationAvoidArea + * @tc.desc: * @tc.name: UpdateRotationAvoidArea + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, UpdateRotationAvoidArea, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "UpdateRotationAvoidArea"; + info.bundleName_ = "UpdateRotationAvoidArea"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + scensession->specificCallback_ = new SceneSession::SpecificSessionCallback(); + EXPECT_NE(nullptr, scensession->specificCallback_); + auto func = [scensession](const int32_t& persistentId) { + scensession->SetParentPersistentId(persistentId); + scensession->GetParentPersistentId(); + }; + scensession->specificCallback_->onUpdateAvoidArea_ = func; + sptr session; + session = new (std::nothrow) Session(info); + int result = session->GetPersistentId(); + EXPECT_EQ(0, result); + scensession->UpdateRotationAvoidArea(); +} + +/** + * @tc.name: NotifyForceHideChange + * @tc.desc: * @tc.name: NotifyForceHideChange + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, NotifyForceHideChange, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "NotifyForceHideChange"; + info.bundleName_ = "NotifyForceHideChange"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + scensession->NotifyForceHideChange(true); + + sptr session; + session = new (std::nothrow) Session(info); + scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); + auto func = [scensession](bool hide) { + scensession->SetPrivacyMode(hide); + }; + scensession->sessionChangeCallback_->OnForceHideChange_ = func; + EXPECT_NE(nullptr, &func); + scensession->NotifyForceHideChange(true); +} + +/** + * @tc.name: RegisterSessionChangeCallback + * @tc.desc: * @tc.name: RegisterSessionChangeCallback + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, RegisterSessionChangeCallback, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "RegisterSessionChangeCallback"; + info.bundleName_ = "RegisterSessionChangeCallback"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + sptr callback = new SceneSession::SessionChangeCallback(); + EXPECT_NE(nullptr, callback); + scensession->RegisterSessionChangeCallback(callback); +} + +/** + * @tc.name: ClearSpecificSessionCbMap + * @tc.desc: * @tc.name: ClearSpecificSessionCbMap + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, ClearSpecificSessionCbMap, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "ClearSpecificSessionCbMap"; + info.bundleName_ = "ClearSpecificSessionCbMap"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(nullptr, scensession); + scensession->ClearSpecificSessionCbMap(); +} + +/** + * @tc.name: SendPointerEventToUI + * @tc.desc: * @tc.name: SendPointerEventToUI + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, SendPointerEventToUI, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "SendPointerEventToUI"; + info.bundleName_ = "SendPointerEventToUI"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(nullptr, scensession); + auto pointerEventFunc = [scensession](std::shared_ptr pointerEvent) { + scensession->NotifyOutsideDownEvent(pointerEvent); + }; + scensession->systemSessionPointerEventFunc_ = pointerEventFunc; + std::shared_ptr pointerEvent = + MMI::PointerEvent::Create(); + scensession->SendPointerEventToUI(pointerEvent); + EXPECT_NE(nullptr, pointerEvent); +} + +/** + * @tc.name: SetFloatingScale + * @tc.desc: * @tc.name: SetFloatingScale + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, SetFloatingScale, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "SetFloatingScale"; + info.bundleName_ = "SetFloatingScale"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + scensession->specificCallback_ = new SceneSession::SpecificSessionCallback(); + auto windowInfoUpdateFun = [scensession](int32_t persistentId, WindowUpdateType type) { + if (WindowUpdateType::WINDOW_UPDATE_PROPERTY == type) { + scensession->SetCollaboratorType(persistentId); + return; + } else { + persistentId++; + scensession->SetParentPersistentId(persistentId); + return; + } + }; + auto updateAvoidAreaFun = [scensession](const int32_t& persistentId) { + bool result = scensession->RemoveSubSession(persistentId); + scensession->SetWindowAnimationFlag(result); + }; + scensession->specificCallback_->onWindowInfoUpdate_ = windowInfoUpdateFun; + scensession->specificCallback_->onUpdateAvoidArea_ = updateAvoidAreaFun; + EXPECT_NE(3.1415928, scensession->floatingScale_); +} + +/** + * @tc.name: ProcessPointDownSession + * @tc.desc: * @tc.name: ProcessPointDownSession + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, ProcessPointDownSession, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "ProcessPointDownSession"; + info.bundleName_ = "ProcessPointDownSession"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + scensession->specificCallback_ = new SceneSession::SpecificSessionCallback(); + EXPECT_NE(nullptr, scensession->specificCallback_); + auto sessionTouchOutsideFun = [scensession](int32_t persistentId) { + scensession->SetCollaboratorType(persistentId); + }; + auto outsideDownEventFun = [scensession](int32_t x, int32_t y) { + int z = x + y; + scensession->SetCollaboratorType(z); + }; + scensession->specificCallback_->onSessionTouchOutside_ = sessionTouchOutsideFun; + scensession->specificCallback_->onOutsideDownEvent_ = outsideDownEventFun; + EXPECT_EQ(WSError::WS_OK, scensession->ProcessPointDownSession(3, 4)); +} + +/** + * @tc.name: SetSelfToken + * @tc.desc: * @tc.name: SetSelfToken + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, SetSelfToken, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "SetSelfToken"; + info.bundleName_ = "SetSelfToken"; + sptr scensession; + sptr specificSession = + new SceneSession::SpecificSessionCallback(); + scensession = new (std::nothrow) SceneSession(info, specificSession); + EXPECT_NE(nullptr, scensession); + sptr selftoken = scensession; + scensession->SetSelfToken(selftoken); + EXPECT_EQ(selftoken, scensession->GetSelfToken()); + scensession->SetSessionState(SessionState::STATE_DISCONNECT); + scensession->UpdateSessionState(SessionState::STATE_CONNECT); + scensession->isVisible_ = true; + EXPECT_EQ(true, scensession->IsVisibleForAccessibility()); + scensession->SetSystemTouchable(false); + EXPECT_EQ(false, scensession->IsVisibleForAccessibility()); + scensession->SetForegroundInteractiveStatus(true); + scensession->NotifyAccessibilityVisibilityChange(); + auto windowInfoUpdateFun = [scensession](int32_t persistentId, WindowUpdateType type) { + if (WindowUpdateType::WINDOW_UPDATE_PROPERTY == type) { + scensession->SetCollaboratorType(persistentId); + return; + } else { + persistentId++; + scensession->SetParentPersistentId(persistentId); + return; + } + }; + scensession->specificCallback_->onWindowInfoUpdate_ = windowInfoUpdateFun; + scensession->NotifyAccessibilityVisibilityChange(); + EXPECT_NE(nullptr, scensession->specificCallback_); +} + +/** + * @tc.name: SetLastSafeRect + * @tc.desc: * @tc.name: SetLastSafeRect + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, SetLastSafeRect, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "SetLastSafeRect"; + info.bundleName_ = "SetLastSafeRect"; + sptr scensession; + sptr specificSession = + new SceneSession::SpecificSessionCallback(); + scensession = new (std::nothrow) SceneSession(info, specificSession); + WSRect rect = {3, 4, 5, 6}; + scensession->SetLastSafeRect(rect); + WSRect result = scensession->GetLastSafeRect(); + EXPECT_EQ(3, result.posX_); + EXPECT_EQ(4, result.posY_); + EXPECT_EQ(5, result.width_); + EXPECT_EQ(6, result.height_); +} + +/** + * @tc.name: RecoveryPullPiPMainWindow + * @tc.desc: * @tc.name: RecoveryPullPiPMainWindow + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, RecoveryPullPiPMainWindow, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "SetLastSafeRect"; + info.bundleName_ = "SetLastSafeRect"; + sptr scensession; + sptr specificSession = + new SceneSession::SpecificSessionCallback(); + scensession = new (std::nothrow) SceneSession(info, specificSession); + Rect rec = {3, 4, 5, 6}; + scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); + auto prepareClosePiPSessionFunc = [scensession]() { + scensession->NotifyUILostFocus(); + }; + scensession->sessionChangeCallback_->onPrepareClosePiPSession_ = prepareClosePiPSessionFunc; + auto recoveryPullPiPMainWindowFunc = [scensession](int32_t persistentId, Rect rect) { + rect.posX_ = persistentId; + rect.posY_ = persistentId; + rect.width_ = persistentId; + rect.height_ = persistentId; + }; + scensession->specificCallback_->onRecoveryPullPiPMainWindow_ = recoveryPullPiPMainWindowFunc; + scensession->NotifyPiPWindowPrepareClose(); + EXPECT_EQ(WSError::WS_OK, scensession->RecoveryPullPiPMainWindow(5, rec)); +} + +/** + * @tc.name: GetSessionTargetRect + * @tc.desc: * @tc.name: GetSessionTargetRect + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, GetSessionTargetRect, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "GetSubSession"; + info.bundleName_ = "GetSessionTargetRect"; + sptr scensession; + sptr specificSession = + new SceneSession::SpecificSessionCallback(); + scensession = new (std::nothrow) SceneSession(info, specificSession); + bool res = scensession->AddSubSession(scensession); + EXPECT_EQ(true, res); + EXPECT_EQ(scensession, (scensession->GetSubSession())[0]); + scensession->moveDragController_ = new MoveDragController(1024); + WSRect rectResult = scensession->GetSessionTargetRect(); + EXPECT_EQ(0, rectResult.posX_); + EXPECT_EQ(0, rectResult.width_); + auto dragHotAreaFunc = [scensession](int32_t type, const SizeChangeReason& reason) { + if (SizeChangeReason::END == reason) { + GTEST_LOG_(INFO) << "type = " << type; + } + return; + }; + scensession->SetWindowDragHotAreaListener(dragHotAreaFunc); + EXPECT_NE(nullptr, scensession->moveDragController_); +} + +/** + * @tc.name: OnPiPMoveCallback + * @tc.desc: * @tc.name: OnPiPMoveCallback + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, OnPiPMoveCallback, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "OnPiPMoveCallback"; + info.bundleName_ = "SetTextFieldAvoidInfo"; + sptr scensession; + sptr specificSession = + new SceneSession::SpecificSessionCallback(); + scensession = new (std::nothrow) SceneSession(info, specificSession); + WSError res = scensession->SetTextFieldAvoidInfo(3.1415927, 2.718); + EXPECT_EQ(WSError::WS_OK, res); + sptr session = new (std::nothrow) Session(info); + EXPECT_NE(nullptr, session->property_); + sptr property = new WindowSessionProperty(); + property->SetWindowType(WindowType::WINDOW_TYPE_PIP); + WSRect rect = {5, 6, 7, 8}; + scensession->OnPiPMoveCallback(rect, SizeChangeReason::MOVE); + scensession->OnPiPMoveCallback(rect, SizeChangeReason::DRAG_END); + EXPECT_EQ(WindowType::WINDOW_TYPE_PIP, property->GetWindowType()); +} } } } \ No newline at end of file -- Gitee From 473f260b8655063d5914dcf4204824159259ef28 Mon Sep 17 00:00:00 2001 From: ywx1282843 Date: Thu, 7 Mar 2024 10:04:36 +0000 Subject: [PATCH 011/385] update window_scene/test/unittest/scene_session_test.cpp. Signed-off-by: ywx1282843 --- window_scene/test/unittest/scene_session_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 2fa27faa2..d35c21e06 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -2674,7 +2674,8 @@ HWTEST_F(SceneSessionTest, SetFloatingScale, Function | SmallTest | Level2) }; scensession->specificCallback_->onWindowInfoUpdate_ = windowInfoUpdateFun; scensession->specificCallback_->onUpdateAvoidArea_ = updateAvoidAreaFun; - EXPECT_NE(3.1415928, scensession->floatingScale_); + scensession->SetFloatingScale(3.14f); + EXPECT_NE(3.14f, scensession->floatingScale_); } /** -- Gitee From f4a4371470b6d2ccaf09bd05ab3d9fe1240b4f32 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Thu, 7 Mar 2024 22:00:40 +0800 Subject: [PATCH 012/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- interfaces/innerkits/wm/wm_common.h | 14 ++++++ .../js_pip_window_manager.cpp | 50 +++++++++++++++++-- wm/src/picture_in_picture_controller.cpp | 1 + wm/src/window_scene_session_impl.cpp | 18 +++++++ 4 files changed, 80 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 800dbc8e2..19275a0cb 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -636,6 +636,20 @@ enum class PipTemplateType : uint32_t { END, }; +/** + * @brief Enumerates picture in picture control group. + */ +enum class PipControlGroup : uint32_t { + START = 0, + VIDEO_PREVIOUS_NEXT = 1, + FAST_FORWARD_BACKWARD = 2, + MICROPHONE_SWITCH = 3, + HANG_UP_BUTTON = 4, + CAMERA_SWITCH = 5, + MUTE_SWITCH = 6, + END, +}; + /** * @brief Enumerates picture in picture state. */ diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 4fc05e688..4ae634a5f 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -28,10 +28,54 @@ using namespace AbilityRuntime; using namespace Ace; namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipWindowManager"}; + constexpr std::set VIDEO_PLAY_CONTROLS { + PipControlGroup::VIDEO_PREVIOUS_NEXT,PipControlGroup::FAST_FORWARD_BACKWARD + }; + constexpr std::set VIDEO_CALL_CONTROLS { + PipControlGroup::MICROPHONE_SWITCH,PipControlGroup::HANG_UP_BUTTON, + PipControlGroup::CAMERA_SWITCH + }; + constexpr std::set VIDEO_MEETING_CONTROLS { + PipControlGroup::MUTE_SWITCH,PipControlGroup::HANG_UP_BUTTON, + PipControlGroup::CAMERA_SWITCH + }; + constexpr std::map> TEMPLATE_CONTROL_MAP { + {PipTemplateType::VIDEO_PLAY, VIDEO_PLAY_CONTROLS}, + {PipTemplateType::VIDEO_CALL, VIDEO_CALL_CONTROLS}, + {PipTemplateType::VIDEO_MEETING, VIDEO_MEETING_CONTROLS}, + {PipTemplateType::VIDEO_LIVE, {}} + }; } std::mutex JsPipWindowManager::mutex_; +static bool checkOptionParams(PipOption& option) +{ + if (option.GetContext() == nullptr) { + WLOGE("check pipoption param error, context is nullptr."); + return false; + } + if (option.GetXComponentController() == nullptr) { + WLOGE("check pipoption param error, XComponentController is nullptr."); + return false; + } + uint32_t pipTemplateType = option.GetPipTemplate(); + if (TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)) + == TEMPLATE_CONTROL_MAP.end()) { + WLOGE("check pipoption param error, pipTemplateType is not exist."); + return false; + } + auto iter = TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)); + auto controls = iter->second; + for (auto control : option.GetControlGroup()) { + if (controls.find(static_cast(control)) == controls.end()) { + WLOGE("check pipoption param error, controlGroup not matches."); + return false; + } + } + return true; +} + static bool GetControlGroupFromJs(napi_env env, napi_value controlGroup, std::vector &controls) { if (controlGroup == nullptr) { @@ -63,7 +107,7 @@ static int32_t GetPictureInPictureOptionFromJs(napi_env env, napi_value optionOb napi_value controlGroup = nullptr; void* contextPtr = nullptr; std::string navigationId = ""; - uint32_t templateType = 0; + uint32_t templateType = static_cast(PipTemplateType::VIDEO_PLAY); uint32_t width = 0; uint32_t height = 0; std::vector controls; @@ -89,7 +133,7 @@ static int32_t GetPictureInPictureOptionFromJs(napi_env env, napi_value optionOb option.SetContentSize(width, height); option.SetControlGroup(controls); option.SetXComponentController(xComponentControllerResult); - return 0; + return checkOptionParams(option); } JsPipWindowManager::JsPipWindowManager() @@ -159,7 +203,7 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback WMError::WM_ERROR_PIP_INTERNAL_ERROR), "Invalid context")); return; } - sptr mainWindow = Window::GetTopWindowWithContext(context->lock()); + sptr mainWindow = Window::GetMainWindowWithContext(context->lock()); sptr pipController = new PictureInPictureController(pipOptionPtr, mainWindow, mainWindow->GetWindowId(), env); task.Resolve(env, CreateJsPipControllerObject(env, pipController)); diff --git a/wm/src/picture_in_picture_controller.cpp b/wm/src/picture_in_picture_controller.cpp index 9cc6ae69f..80c11d9e2 100644 --- a/wm/src/picture_in_picture_controller.cpp +++ b/wm/src/picture_in_picture_controller.cpp @@ -94,6 +94,7 @@ WMError PictureInPictureController::CreatePictureInPictureWindow() windowOption->SetWindowType(WindowType::WINDOW_TYPE_PIP); windowOption->SetWindowMode(WindowMode::WINDOW_MODE_PIP); windowOption->SetWindowRect(windowRect_); + windowOption->SetKeepScreenOn(true); WMError errCode; PiPTemplateInfo pipTemplateInfo; pipTemplateInfo.pipTemplateType = pipOption_->GetPipTemplate(); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index b53d5eed2..d649adbde 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1960,6 +1960,24 @@ sptr WindowSceneSessionImpl::GetTopWindowWithId(uint32_t mainWinId) return FindWindowById(topWinId); } +sptr WindowSceneSessionImpl::GetMainWindowWithId(const std::shared_ptr& context) +{ + std::unique_lock lock(windowSessionMutex_); + if (windowSessionMap_.empty()) { + WLOGFE("Please create mainWindow First!"); + return nullptr; + } + for (const auto& winPair : windowSessionMap_) { + auto win = winPair.second.second; + if (win && WindowHelper::IsMainWindow(win->GetType()) && context.get() == win->GetContext().get()) { + WLOGI("GetTopWindow Find MainWinId:%{public}u.", mainWinId); + return win; + } + } + WLOGFE("Cannot find Window!"); + return nullptr; +} + sptr WindowSceneSessionImpl::GetMainWindowWithId(uint32_t mainWinId) { std::unique_lock lock(windowSessionMutex_); -- Gitee From 166d8a9fd7dbf367fb8f7bc4139d73acdccf1d03 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Fri, 8 Mar 2024 18:11:41 +0800 Subject: [PATCH 013/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../picture_in_picture_napi/js_pip_utils.cpp | 15 +++++++ .../js_pip_window_manager.cpp | 39 ++++++++++--------- wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 4 +- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp index 8ecc1d324..d8cc99e38 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp @@ -87,11 +87,26 @@ static napi_value ExportPictureInPictureState(napi_env env) return result; } +static napi_value ExportPictureInPictureControlGroup(napi_env env) +{ + napi_value result = nullptr; + napi_create_object(env, &result); + (void)SetNamedProperty(env, result, "VIDEO_PREVIOUS_NEXT", static_cast(PipControlGroup::VIDEO_PREVIOUS_NEXT)); + (void)SetNamedProperty(env, result, "FAST_FORWARD_BACKWARD", static_cast(PipControlGroup::FAST_FORWARD_BACKWARD)); + (void)SetNamedProperty(env, result, "MICROPHONE_SWITCH", static_cast(PipControlGroup::MICROPHONE_SWITCH)); + (void)SetNamedProperty(env, result, "HANG_UP_BUTTON", static_cast(PipControlGroup::HANG_UP_BUTTON)); + (void)SetNamedProperty(env, result, "CAMERA_SWITCH", static_cast(PipControlGroup::CAMERA_SWITCH)); + (void)SetNamedProperty(env, result, "MUTE_SWITCH", static_cast(PipControlGroup::MUTE_SWITCH)); + napi_object_freeze(env, result); + return result; +} + napi_status InitEnums(napi_env env, napi_value exports) { const napi_property_descriptor properties[] = { DECLARE_NAPI_PROPERTY("PiPTemplateType", ExportPictureInPictureTemplateType(env)), DECLARE_NAPI_PROPERTY("PiPState", ExportPictureInPictureState(env)), + DECLARE_NAPI_PROPERTY("PipControlGroup", ExportPictureInPictureControlGroup(env)), }; size_t count = sizeof(properties) / sizeof(napi_property_descriptor); return napi_define_properties(env, exports, count, properties); diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 4ae634a5f..77a1c40a5 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -20,6 +20,7 @@ #include "js_runtime_utils.h" #include "window_manager_hilog.h" #include "window.h" +#include "window_scene_session_impl.h" #include "xcomponent_controller.h" namespace OHOS { @@ -28,25 +29,25 @@ using namespace AbilityRuntime; using namespace Ace; namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipWindowManager"}; - constexpr std::set VIDEO_PLAY_CONTROLS { - PipControlGroup::VIDEO_PREVIOUS_NEXT,PipControlGroup::FAST_FORWARD_BACKWARD - }; - constexpr std::set VIDEO_CALL_CONTROLS { - PipControlGroup::MICROPHONE_SWITCH,PipControlGroup::HANG_UP_BUTTON, - PipControlGroup::CAMERA_SWITCH - }; - constexpr std::set VIDEO_MEETING_CONTROLS { - PipControlGroup::MUTE_SWITCH,PipControlGroup::HANG_UP_BUTTON, - PipControlGroup::CAMERA_SWITCH - }; - constexpr std::map> TEMPLATE_CONTROL_MAP { - {PipTemplateType::VIDEO_PLAY, VIDEO_PLAY_CONTROLS}, - {PipTemplateType::VIDEO_CALL, VIDEO_CALL_CONTROLS}, - {PipTemplateType::VIDEO_MEETING, VIDEO_MEETING_CONTROLS}, - {PipTemplateType::VIDEO_LIVE, {}} - }; } +const std::set VIDEO_PLAY_CONTROLS { + PipControlGroup::VIDEO_PREVIOUS_NEXT,PipControlGroup::FAST_FORWARD_BACKWARD +}; +const std::set VIDEO_CALL_CONTROLS { + PipControlGroup::MICROPHONE_SWITCH,PipControlGroup::HANG_UP_BUTTON, + PipControlGroup::CAMERA_SWITCH +}; +const std::set VIDEO_MEETING_CONTROLS { + PipControlGroup::MUTE_SWITCH,PipControlGroup::HANG_UP_BUTTON, + PipControlGroup::CAMERA_SWITCH +}; +const std::map> TEMPLATE_CONTROL_MAP { + {PipTemplateType::VIDEO_PLAY, VIDEO_PLAY_CONTROLS}, + {PipTemplateType::VIDEO_CALL, VIDEO_CALL_CONTROLS}, + {PipTemplateType::VIDEO_MEETING, VIDEO_MEETING_CONTROLS}, + {PipTemplateType::VIDEO_LIVE, {}} +}; std::mutex JsPipWindowManager::mutex_; static bool checkOptionParams(PipOption& option) @@ -62,14 +63,14 @@ static bool checkOptionParams(PipOption& option) uint32_t pipTemplateType = option.GetPipTemplate(); if (TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)) == TEMPLATE_CONTROL_MAP.end()) { - WLOGE("check pipoption param error, pipTemplateType is not exist."); + WLOGE("check pipoption param error, pipTemplateType not exists."); return false; } auto iter = TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)); auto controls = iter->second; for (auto control : option.GetControlGroup()) { if (controls.find(static_cast(control)) == controls.end()) { - WLOGE("check pipoption param error, controlGroup not matches."); + WLOGE("check pipoption param error, controlGroup not matches, controlGroup: %{public}u", control); return false; } } diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 628307c02..76523aa4e 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -82,6 +82,7 @@ public: static void UpdateConfigurationForAll(const std::shared_ptr& configuration); static sptr GetTopWindowWithContext(const std::shared_ptr& context = nullptr); static sptr GetTopWindowWithId(uint32_t mainWinId); + static sptr GetMainWindowWithContext(const std::shared_ptr& context = nullptr); static sptr GetMainWindowWithId(uint32_t mainWinId); virtual void UpdateConfiguration(const std::shared_ptr& configuration) override; WMError NotifyMemoryLevel(int32_t level) override; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index d649adbde..c45719b75 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1960,16 +1960,18 @@ sptr WindowSceneSessionImpl::GetTopWindowWithId(uint32_t mainWinId) return FindWindowById(topWinId); } -sptr WindowSceneSessionImpl::GetMainWindowWithId(const std::shared_ptr& context) +sptr WindowSceneSessionImpl::GetMainWindowWithContext(const std::shared_ptr& context) { std::unique_lock lock(windowSessionMutex_); if (windowSessionMap_.empty()) { WLOGFE("Please create mainWindow First!"); return nullptr; } + uint32_t mainWinId = INVALID_WINDOW_ID; for (const auto& winPair : windowSessionMap_) { auto win = winPair.second.second; if (win && WindowHelper::IsMainWindow(win->GetType()) && context.get() == win->GetContext().get()) { + mainWinId = win->GetWindowId(); WLOGI("GetTopWindow Find MainWinId:%{public}u.", mainWinId); return win; } -- Gitee From 533e21afbf3468c1ebaa50bbaefe11fdc05bc2c7 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Sat, 9 Mar 2024 11:07:24 +0800 Subject: [PATCH 014/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- interfaces/innerkits/wm/wm_common.h | 8 +-- .../js_pip_controller.cpp | 14 ++--- .../js_pip_controller.h | 2 +- .../picture_in_picture_napi/js_pip_utils.cpp | 34 +++++------ .../js_pip_window_manager.cpp | 56 +++++++++---------- .../test/unittest/scene_session_test.cpp | 4 +- .../unittest/window_session_property_test.cpp | 4 +- wm/include/picture_in_picture_controller.h | 4 +- wm/src/picture_in_picture_controller.cpp | 46 +++++++-------- wm/src/picture_in_picture_manager.cpp | 2 +- wm/src/window_scene_session_impl.cpp | 6 +- .../picture_in_picture_controller_test.cpp | 8 +-- .../picture_in_picture_manager_test.cpp | 2 +- 13 files changed, 95 insertions(+), 95 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 19275a0cb..9c6c3896e 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -617,7 +617,7 @@ enum class WindowUpdateType : int32_t { /** * @brief Enumerates picture in picture window state. */ -enum class PipWindowState : uint32_t { +enum class PiPWindowState : uint32_t { STATE_UNDEFINED = 0, STATE_STARTING = 1, STATE_STARTED = 2, @@ -628,7 +628,7 @@ enum class PipWindowState : uint32_t { /** * @brief Enumerates picture in picture template type. */ -enum class PipTemplateType : uint32_t { +enum class PiPTemplateType : uint32_t { VIDEO_PLAY = 0, VIDEO_CALL = 1, VIDEO_MEETING = 2, @@ -639,7 +639,7 @@ enum class PipTemplateType : uint32_t { /** * @brief Enumerates picture in picture control group. */ -enum class PipControlGroup : uint32_t { +enum class PiPControlGroup : uint32_t { START = 0, VIDEO_PREVIOUS_NEXT = 1, FAST_FORWARD_BACKWARD = 2, @@ -653,7 +653,7 @@ enum class PipControlGroup : uint32_t { /** * @brief Enumerates picture in picture state. */ -enum class PipState : int32_t { +enum class PiPState : int32_t { ABOUT_TO_START = 1, STARTED = 2, ABOUT_TO_STOP = 3, diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp index 8d1843107..669a32f8e 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp @@ -399,40 +399,40 @@ void CallJsMethod(napi_env env, napi_value method, napi_value const* argv, size_ void JsPipController::PiPLifeCycleImpl::OnPreparePictureInPictureStart() { WLOGI("OnPreparePictureInPictureStart"); - OnPipListenerCallback(PipState::ABOUT_TO_START, 0); + OnPipListenerCallback(PiPState::ABOUT_TO_START, 0); } void JsPipController::PiPLifeCycleImpl::OnPictureInPictureStart() { WLOGI("OnPictureInPictureStart"); - OnPipListenerCallback(PipState::STARTED, 0); + OnPipListenerCallback(PiPState::STARTED, 0); } void JsPipController::PiPLifeCycleImpl::OnPreparePictureInPictureStop() { WLOGI("OnPreparePictureInPictureStop"); - OnPipListenerCallback(PipState::ABOUT_TO_STOP, 0); + OnPipListenerCallback(PiPState::ABOUT_TO_STOP, 0); } void JsPipController::PiPLifeCycleImpl::OnPictureInPictureStop() { WLOGI("OnPictureInPictureStop"); - OnPipListenerCallback(PipState::STOPPED, 0); + OnPipListenerCallback(PiPState::STOPPED, 0); } void JsPipController::PiPLifeCycleImpl::OnRestoreUserInterface() { WLOGI("OnRestoreUserInterface"); - OnPipListenerCallback(PipState::ABOUT_TO_RESTORE, 0); + OnPipListenerCallback(PiPState::ABOUT_TO_RESTORE, 0); } void JsPipController::PiPLifeCycleImpl::OnPictureInPictureOperationError(int32_t errorCode) { WLOGI("OnPictureInPictureOperationError"); - OnPipListenerCallback(PipState::ERROR, errorCode); + OnPipListenerCallback(PiPState::ERROR, errorCode); } -void JsPipController::PiPLifeCycleImpl::OnPipListenerCallback(PipState state, int32_t errorCode) +void JsPipController::PiPLifeCycleImpl::OnPipListenerCallback(PiPState state, int32_t errorCode) { std::lock_guard lock(mtx_); WLOGI("OnPipListenerCallback is called, state: %{public}d", static_cast(state)); diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.h b/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.h index c23747980..3d1d324c0 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.h +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.h @@ -76,7 +76,7 @@ public: void OnRestoreUserInterface() override; private: - void OnPipListenerCallback(PipState state, int32_t errorCode); + void OnPipListenerCallback(PiPState state, int32_t errorCode); napi_env engine_ = nullptr; std::shared_ptr jsCallBack_ = nullptr; std::mutex mtx_; diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp index d8cc99e38..ce8e0d06a 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp @@ -65,10 +65,10 @@ static napi_value ExportPictureInPictureTemplateType(napi_env env) { napi_value result = nullptr; napi_create_object(env, &result); - (void)SetNamedProperty(env, result, "VIDEO_PLAY", static_cast(PipTemplateType::VIDEO_PLAY)); - (void)SetNamedProperty(env, result, "VIDEO_CALL", static_cast(PipTemplateType::VIDEO_CALL)); - (void)SetNamedProperty(env, result, "VIDEO_MEETING", static_cast(PipTemplateType::VIDEO_MEETING)); - (void)SetNamedProperty(env, result, "VIDEO_LIVE", static_cast(PipTemplateType::VIDEO_LIVE)); + (void)SetNamedProperty(env, result, "VIDEO_PLAY", static_cast(PiPTemplateType::VIDEO_PLAY)); + (void)SetNamedProperty(env, result, "VIDEO_CALL", static_cast(PiPTemplateType::VIDEO_CALL)); + (void)SetNamedProperty(env, result, "VIDEO_MEETING", static_cast(PiPTemplateType::VIDEO_MEETING)); + (void)SetNamedProperty(env, result, "VIDEO_LIVE", static_cast(PiPTemplateType::VIDEO_LIVE)); napi_object_freeze(env, result); return result; } @@ -77,12 +77,12 @@ static napi_value ExportPictureInPictureState(napi_env env) { napi_value result = nullptr; napi_create_object(env, &result); - (void)SetNamedProperty(env, result, "ABOUT_TO_START", static_cast(PipState::ABOUT_TO_START)); - (void)SetNamedProperty(env, result, "STARTED", static_cast(PipState::STARTED)); - (void)SetNamedProperty(env, result, "ABOUT_TO_STOP", static_cast(PipState::ABOUT_TO_STOP)); - (void)SetNamedProperty(env, result, "STOPPED", static_cast(PipState::STOPPED)); - (void)SetNamedProperty(env, result, "ABOUT_TO_RESTORE", static_cast(PipState::ABOUT_TO_RESTORE)); - (void)SetNamedProperty(env, result, "ERROR", static_cast(PipState::ERROR)); + (void)SetNamedProperty(env, result, "ABOUT_TO_START", static_cast(PiPState::ABOUT_TO_START)); + (void)SetNamedProperty(env, result, "STARTED", static_cast(PiPState::STARTED)); + (void)SetNamedProperty(env, result, "ABOUT_TO_STOP", static_cast(PiPState::ABOUT_TO_STOP)); + (void)SetNamedProperty(env, result, "STOPPED", static_cast(PiPState::STOPPED)); + (void)SetNamedProperty(env, result, "ABOUT_TO_RESTORE", static_cast(PiPState::ABOUT_TO_RESTORE)); + (void)SetNamedProperty(env, result, "ERROR", static_cast(PiPState::ERROR)); napi_object_freeze(env, result); return result; } @@ -91,12 +91,12 @@ static napi_value ExportPictureInPictureControlGroup(napi_env env) { napi_value result = nullptr; napi_create_object(env, &result); - (void)SetNamedProperty(env, result, "VIDEO_PREVIOUS_NEXT", static_cast(PipControlGroup::VIDEO_PREVIOUS_NEXT)); - (void)SetNamedProperty(env, result, "FAST_FORWARD_BACKWARD", static_cast(PipControlGroup::FAST_FORWARD_BACKWARD)); - (void)SetNamedProperty(env, result, "MICROPHONE_SWITCH", static_cast(PipControlGroup::MICROPHONE_SWITCH)); - (void)SetNamedProperty(env, result, "HANG_UP_BUTTON", static_cast(PipControlGroup::HANG_UP_BUTTON)); - (void)SetNamedProperty(env, result, "CAMERA_SWITCH", static_cast(PipControlGroup::CAMERA_SWITCH)); - (void)SetNamedProperty(env, result, "MUTE_SWITCH", static_cast(PipControlGroup::MUTE_SWITCH)); + (void)SetNamedProperty(env, result, "VIDEO_PREVIOUS_NEXT", static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT)); + (void)SetNamedProperty(env, result, "FAST_FORWARD_BACKWARD", static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); + (void)SetNamedProperty(env, result, "MICROPHONE_SWITCH", static_cast(PiPControlGroup::MICROPHONE_SWITCH)); + (void)SetNamedProperty(env, result, "HANG_UP_BUTTON", static_cast(PiPControlGroup::HANG_UP_BUTTON)); + (void)SetNamedProperty(env, result, "CAMERA_SWITCH", static_cast(PiPControlGroup::CAMERA_SWITCH)); + (void)SetNamedProperty(env, result, "MUTE_SWITCH", static_cast(PiPControlGroup::MUTE_SWITCH)); napi_object_freeze(env, result); return result; } @@ -106,7 +106,7 @@ napi_status InitEnums(napi_env env, napi_value exports) const napi_property_descriptor properties[] = { DECLARE_NAPI_PROPERTY("PiPTemplateType", ExportPictureInPictureTemplateType(env)), DECLARE_NAPI_PROPERTY("PiPState", ExportPictureInPictureState(env)), - DECLARE_NAPI_PROPERTY("PipControlGroup", ExportPictureInPictureControlGroup(env)), + DECLARE_NAPI_PROPERTY("PiPControlGroup", ExportPictureInPictureControlGroup(env)), }; size_t count = sizeof(properties) / sizeof(napi_property_descriptor); return napi_define_properties(env, exports, count, properties); diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 77a1c40a5..cf50a895f 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -29,52 +29,52 @@ using namespace AbilityRuntime; using namespace Ace; namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipWindowManager"}; + const std::set VIDEO_PLAY_CONTROLS { + PiPControlGroup::VIDEO_PREVIOUS_NEXT,PiPControlGroup::FAST_FORWARD_BACKWARD + }; + const std::set VIDEO_CALL_CONTROLS { + PiPControlGroup::MICROPHONE_SWITCH,PiPControlGroup::HANG_UP_BUTTON, + PiPControlGroup::CAMERA_SWITCH, + }; + const std::set VIDEO_MEETING_CONTROLS { + PiPControlGroup::MUTE_SWITCH,PiPControlGroup::HANG_UP_BUTTON, + PiPControlGroup::CAMERA_SWITCH, + }; + const std::map> TEMPLATE_CONTROL_MAP { + {PiPTemplateType::VIDEO_PLAY, VIDEO_PLAY_CONTROLS}, + {PiPTemplateType::VIDEO_CALL, VIDEO_CALL_CONTROLS}, + {PiPTemplateType::VIDEO_MEETING, VIDEO_MEETING_CONTROLS}, + {PiPTemplateType::VIDEO_LIVE, {}}, + }; } -const std::set VIDEO_PLAY_CONTROLS { - PipControlGroup::VIDEO_PREVIOUS_NEXT,PipControlGroup::FAST_FORWARD_BACKWARD -}; -const std::set VIDEO_CALL_CONTROLS { - PipControlGroup::MICROPHONE_SWITCH,PipControlGroup::HANG_UP_BUTTON, - PipControlGroup::CAMERA_SWITCH -}; -const std::set VIDEO_MEETING_CONTROLS { - PipControlGroup::MUTE_SWITCH,PipControlGroup::HANG_UP_BUTTON, - PipControlGroup::CAMERA_SWITCH -}; -const std::map> TEMPLATE_CONTROL_MAP { - {PipTemplateType::VIDEO_PLAY, VIDEO_PLAY_CONTROLS}, - {PipTemplateType::VIDEO_CALL, VIDEO_CALL_CONTROLS}, - {PipTemplateType::VIDEO_MEETING, VIDEO_MEETING_CONTROLS}, - {PipTemplateType::VIDEO_LIVE, {}} -}; std::mutex JsPipWindowManager::mutex_; -static bool checkOptionParams(PipOption& option) +static int32_t checkOptionParams(PipOption& option) { if (option.GetContext() == nullptr) { WLOGE("check pipoption param error, context is nullptr."); - return false; + return -1; } if (option.GetXComponentController() == nullptr) { WLOGE("check pipoption param error, XComponentController is nullptr."); - return false; + return -1; } uint32_t pipTemplateType = option.GetPipTemplate(); - if (TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)) + if (TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)) == TEMPLATE_CONTROL_MAP.end()) { WLOGE("check pipoption param error, pipTemplateType not exists."); - return false; + return -1; } - auto iter = TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)); + auto iter = TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)); auto controls = iter->second; for (auto control : option.GetControlGroup()) { - if (controls.find(static_cast(control)) == controls.end()) { + if (controls.find(static_cast(control)) == controls.end()) { WLOGE("check pipoption param error, controlGroup not matches, controlGroup: %{public}u", control); - return false; + return -1; } } - return true; + return 0; } static bool GetControlGroupFromJs(napi_env env, napi_value controlGroup, std::vector &controls) @@ -108,7 +108,7 @@ static int32_t GetPictureInPictureOptionFromJs(napi_env env, napi_value optionOb napi_value controlGroup = nullptr; void* contextPtr = nullptr; std::string navigationId = ""; - uint32_t templateType = static_cast(PipTemplateType::VIDEO_PLAY); + uint32_t templateType = static_cast(PiPTemplateType::VIDEO_PLAY); uint32_t width = 0; uint32_t height = 0; std::vector controls; @@ -204,7 +204,7 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback WMError::WM_ERROR_PIP_INTERNAL_ERROR), "Invalid context")); return; } - sptr mainWindow = Window::GetMainWindowWithContext(context->lock()); + sptr mainWindow = WindowSceneSessionImpl::GetMainWindowWithContext(context->lock()); sptr pipController = new PictureInPictureController(pipOptionPtr, mainWindow, mainWindow->GetWindowId(), env); task.Resolve(env, CreateJsPipControllerObject(env, pipController)); diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 80e9aba31..f10ba3b8e 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -195,10 +195,10 @@ HWTEST_F(SceneSessionTest, SetAndGetPipTemplateInfo, Function | SmallTest | Leve EXPECT_NE(scensession, nullptr); scensession->isActive_ = true; PiPTemplateInfo pipTemplateInfo; - pipTemplateInfo.pipTemplateType = static_cast(PipTemplateType::VIDEO_CALL); + pipTemplateInfo.pipTemplateType = static_cast(PiPTemplateType::VIDEO_CALL); scensession->SetPiPTemplateInfo(pipTemplateInfo); ASSERT_EQ(scensession->GetPiPTemplateInfo().pipTemplateType, - static_cast(PipTemplateType::VIDEO_CALL)); + static_cast(PiPTemplateType::VIDEO_CALL)); } /** diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 0bd5d2f77..628f911a1 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -169,10 +169,10 @@ HWTEST_F(WindowSessionPropertyTest, SetAndGetPipTemplateInfo, Function | SmallTe { WindowSessionProperty *property = new WindowSessionProperty(); PiPTemplateInfo pipTemplateInfo; - pipTemplateInfo.pipTemplateType = static_cast(PipTemplateType::VIDEO_CALL); + pipTemplateInfo.pipTemplateType = static_cast(PiPTemplateType::VIDEO_CALL); property->SetPiPTemplateInfo(pipTemplateInfo); ASSERT_EQ(property->GetPiPTemplateInfo().pipTemplateType, - static_cast(PipTemplateType::VIDEO_CALL)); + static_cast(PiPTemplateType::VIDEO_CALL)); } /** diff --git a/wm/include/picture_in_picture_controller.h b/wm/include/picture_in_picture_controller.h index 14fc2f4ee..f9b20a28a 100644 --- a/wm/include/picture_in_picture_controller.h +++ b/wm/include/picture_in_picture_controller.h @@ -71,7 +71,7 @@ public: sptr GetPictureInPictureLifecycle() const; sptr GetPictureInPictureActionObserver() const; WMError SetXComponentController(std::shared_ptr xComponentController); - PipWindowState GetControllerState(); + PiPWindowState GetControllerState(); std::string GetPiPNavigationId(); class PipMainWindowLifeCycleImpl : public Rosen::IWindowLifeCycle { @@ -119,7 +119,7 @@ private: uint32_t mainWindowId_; Rect windowRect_ = {0, 0, 0, 0}; bool isAutoStartEnabled_ = false; - PipWindowState curState_ = PipWindowState::STATE_UNDEFINED; + PiPWindowState curState_ = PiPWindowState::STATE_UNDEFINED; std::shared_ptr handler_ = nullptr; std::shared_ptr pipXComponentController_; std::shared_ptr mainWindowXComponentController_; diff --git a/wm/src/picture_in_picture_controller.cpp b/wm/src/picture_in_picture_controller.cpp index 80c11d9e2..eacdf7088 100644 --- a/wm/src/picture_in_picture_controller.cpp +++ b/wm/src/picture_in_picture_controller.cpp @@ -42,12 +42,12 @@ namespace { } static uint32_t GetPipPriority(uint32_t pipTemplateType) { - if (pipTemplateType < 0 || pipTemplateType >= static_cast(PipTemplateType::END)) { + if (pipTemplateType < 0 || pipTemplateType >= static_cast(PiPTemplateType::END)) { WLOGFE("param invalid, pipTemplateType is %{public}d", pipTemplateType); return PIP_LOW_PRIORITY; } - if (pipTemplateType == static_cast(PipTemplateType::VIDEO_PLAY) || - pipTemplateType == static_cast(PipTemplateType::VIDEO_LIVE)) { + if (pipTemplateType == static_cast(PiPTemplateType::VIDEO_PLAY) || + pipTemplateType == static_cast(PiPTemplateType::VIDEO_LIVE)) { return PIP_LOW_PRIORITY; } else { return PIP_HIGH_PRIORITY; @@ -59,7 +59,7 @@ PictureInPictureController::PictureInPictureController(sptr pipOption : weakRef_(this), pipOption_(pipOption), mainWindow_(mainWindow), mainWindowId_(windowId), env_(env) { this->handler_ = std::make_shared(AppExecFwk::EventRunner::GetMainEventRunner()); - curState_ = PipWindowState::STATE_UNDEFINED; + curState_ = PiPWindowState::STATE_UNDEFINED; pipDisplayListener_ = new PictureInPictureController::PipDisplayListener(weakRef_); } @@ -126,21 +126,21 @@ WMError PictureInPictureController::ShowPictureInPictureWindow(StartPipType star WLOGFE("Get PictureInPicture option failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } - auto pipTemplateType = static_cast(pipOption_->GetPipTemplate()); + auto pipTemplateType = static_cast(pipOption_->GetPipTemplate()); WLOGFI("mainWindow: %{public}u, pipWindow: %{public}u, template:%{public}u", mainWindowId_, window_->GetWindowId(), pipTemplateType); switch (pipTemplateType) { default: - case PipTemplateType::VIDEO_PLAY: + case PiPTemplateType::VIDEO_PLAY: window_->SetUIContentByAbc(VIDEO_PAGE_PATH, env_, nullptr, nullptr); break; - case PipTemplateType::VIDEO_CALL: + case PiPTemplateType::VIDEO_CALL: window_->SetUIContentByAbc(CALL_PAGE_PATH, env_, nullptr, nullptr); break; - case PipTemplateType::VIDEO_MEETING: + case PiPTemplateType::VIDEO_MEETING: window_->SetUIContentByAbc(MEETING_PAGE_PATH, env_, nullptr, nullptr); break; - case PipTemplateType::VIDEO_LIVE: + case PiPTemplateType::VIDEO_LIVE: window_->SetUIContentByAbc(LIVE_PAGE_PATH, env_, nullptr, nullptr); break; } @@ -165,7 +165,7 @@ WMError PictureInPictureController::StartPictureInPicture(StartPipType startType { WLOGI("StartPictureInPicture called"); std::lock_guard lock(mutex_); - if (curState_ == PipWindowState::STATE_STARTING || curState_ == PipWindowState::STATE_STARTED) { + if (curState_ == PiPWindowState::STATE_STARTING || curState_ == PiPWindowState::STATE_STARTED) { WLOGFW("pip window is starting, state: %{public}u, pipWindow: %{public}u, mainWindow: %{public}u", curState_, window_->GetWindowId(), mainWindowId_); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), @@ -185,7 +185,7 @@ WMError PictureInPictureController::StartPictureInPicture(StartPipType startType return WMError::WM_ERROR_PIP_CREATE_FAILED; } Rosen::DisplayManager::GetInstance().RegisterDisplayListener(pipDisplayListener_); - curState_ = PipWindowState::STATE_STARTING; + curState_ = PiPWindowState::STATE_STARTING; if (PictureInPictureManager::HasActiveController() && !PictureInPictureManager::IsActiveController(weakRef_)) { // if current controller is not the active one, but belongs to the same mainWindow, reserve pipWindow if (PictureInPictureManager::IsAttachedToSameWindow(mainWindowId_)) { @@ -199,9 +199,9 @@ WMError PictureInPictureController::StartPictureInPicture(StartPipType startType PictureInPictureManager::PutPipControllerInfo(window_->GetWindowId(), this); WMError err = ShowPictureInPictureWindow(startType); if (err != WMError::WM_OK) { - curState_ = PipWindowState::STATE_UNDEFINED; + curState_ = PiPWindowState::STATE_UNDEFINED; } else { - curState_ = PipWindowState::STATE_STARTED; + curState_ = PiPWindowState::STATE_STARTED; } return err; } @@ -215,7 +215,7 @@ WMError PictureInPictureController::StartPictureInPictureInner(StartPipType star { WMError errCode = CreatePictureInPictureWindow(); if (errCode != WMError::WM_OK) { - curState_ = PipWindowState::STATE_UNDEFINED; + curState_ = PiPWindowState::STATE_UNDEFINED; WLOGFE("Create pip window failed, err: %{public}u", errCode); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), pipOption_->GetPipTemplate(), FAILED, "Create pip window failed"); @@ -223,13 +223,13 @@ WMError PictureInPictureController::StartPictureInPictureInner(StartPipType star } errCode = ShowPictureInPictureWindow(startType); if (errCode != WMError::WM_OK) { - curState_ = PipWindowState::STATE_UNDEFINED; + curState_ = PiPWindowState::STATE_UNDEFINED; WLOGFE("Show pip window failed, err: %{public}u", errCode); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), pipOption_->GetPipTemplate(), FAILED, "Show pip window failed"); return errCode; } - curState_ = PipWindowState::STATE_STARTED; + curState_ = PiPWindowState::STATE_STARTED; SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), pipOption_->GetPipTemplate(), SUCCESS, "start pip success"); return WMError::WM_OK; @@ -239,7 +239,7 @@ WMError PictureInPictureController::StopPictureInPicture(bool destroyWindow, boo { WLOGI("StopPictureInPicture is called, destroyWindow: %{public}u, needAnim: %{public}u", destroyWindow, needAnim); std::lock_guard lock(mutex_); - if (curState_ == PipWindowState::STATE_STOPPING || curState_ == PipWindowState::STATE_STOPPED) { + if (curState_ == PiPWindowState::STATE_STOPPING || curState_ == PiPWindowState::STATE_STOPPED) { WLOGFE("Repeat stop request, curState: %{public}u", curState_); SingletonContainer::Get().ReportPiPStopWindow(static_cast(stopPipType), pipOption_->GetPipTemplate(), FAILED, "Repeat stop request"); @@ -251,14 +251,14 @@ WMError PictureInPictureController::StopPictureInPicture(bool destroyWindow, boo pipOption_->GetPipTemplate(), FAILED, "window_ is nullptr"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; } - curState_ = PipWindowState::STATE_STOPPING; + curState_ = PiPWindowState::STATE_STOPPING; if (pipLifeCycleListener_ != nullptr) { pipLifeCycleListener_->OnPreparePictureInPictureStop(); } (void)Rosen::DisplayManager::GetInstance().UnregisterDisplayListener(pipDisplayListener_); if (!destroyWindow) { ResetExtController(); - curState_ = PipWindowState::STATE_STOPPED; + curState_ = PiPWindowState::STATE_STOPPED; if (pipLifeCycleListener_) { pipLifeCycleListener_->OnPictureInPictureStop(); } @@ -283,7 +283,7 @@ WMError PictureInPictureController::StopPictureInPictureInner(bool needAnim, Sto session->ResetExtController(); WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(session->window_->Destroy()); if (ret != WmErrorCode::WM_OK) { - session->curState_ = PipWindowState::STATE_UNDEFINED; + session->curState_ = PiPWindowState::STATE_UNDEFINED; WLOGFE("Window destroy failed"); int32_t err = static_cast(ret); if (session->pipLifeCycleListener_ != nullptr) { @@ -299,7 +299,7 @@ WMError PictureInPictureController::StopPictureInPictureInner(bool needAnim, Sto PictureInPictureManager::RemoveActiveController(session); PictureInPictureManager::RemovePipControllerInfo(session->window_->GetWindowId()); session->window_ = nullptr; - session->curState_ = PipWindowState::STATE_STOPPED; + session->curState_ = PiPWindowState::STATE_STOPPED; std::string navId = session->pipOption_->GetNavigationId(); if (navId != "" && session->mainWindow_) { auto navController = NavigationController::GetNavigationController( @@ -360,7 +360,7 @@ void PictureInPictureController::IsAutoStartEnabled(bool& enable) const enable = isAutoStartEnabled_; } -PipWindowState PictureInPictureController::GetControllerState() +PiPWindowState PictureInPictureController::GetControllerState() { return curState_; } @@ -371,7 +371,7 @@ void PictureInPictureController::UpdateContentSize(int32_t width, int32_t height WLOGFE("invalid size"); return; } - if (curState_ != PipWindowState::STATE_STARTED) { + if (curState_ != PiPWindowState::STATE_STARTED) { WLOGFD("UpdateContentSize is disabled when state: %{public}u", curState_); return; } diff --git a/wm/src/picture_in_picture_manager.cpp b/wm/src/picture_in_picture_manager.cpp index a07840ce1..fe92ab606 100644 --- a/wm/src/picture_in_picture_manager.cpp +++ b/wm/src/picture_in_picture_manager.cpp @@ -44,7 +44,7 @@ PictureInPictureManager::~PictureInPictureManager() bool PictureInPictureManager::ShouldAbortPipStart() { - return activeController_ != nullptr && activeController_->GetControllerState() == PipWindowState::STATE_STARTING; + return activeController_ != nullptr && activeController_->GetControllerState() == PiPWindowState::STATE_STARTING; } void PictureInPictureManager::PutPipControllerInfo(int32_t windowId, sptr pipController) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index c45719b75..618d24c30 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1964,7 +1964,7 @@ sptr WindowSceneSessionImpl::GetMainWindowWithContext(const std::shared_ { std::unique_lock lock(windowSessionMutex_); if (windowSessionMap_.empty()) { - WLOGFE("Please create mainWindow First!"); + WLOGFE("[GetMainWin] Please create mainWindow First!"); return nullptr; } uint32_t mainWinId = INVALID_WINDOW_ID; @@ -1972,11 +1972,11 @@ sptr WindowSceneSessionImpl::GetMainWindowWithContext(const std::shared_ auto win = winPair.second.second; if (win && WindowHelper::IsMainWindow(win->GetType()) && context.get() == win->GetContext().get()) { mainWinId = win->GetWindowId(); - WLOGI("GetTopWindow Find MainWinId:%{public}u.", mainWinId); + WLOGI("[GetMainWin] Find MainWinId:%{public}u.", mainWinId); return win; } } - WLOGFE("Cannot find Window!"); + WLOGFE("[GetMainWin] Cannot find Window!"); return nullptr; } diff --git a/wm/test/unittest/picture_in_picture_controller_test.cpp b/wm/test/unittest/picture_in_picture_controller_test.cpp index cf18aeb6b..1793db064 100644 --- a/wm/test/unittest/picture_in_picture_controller_test.cpp +++ b/wm/test/unittest/picture_in_picture_controller_test.cpp @@ -84,17 +84,17 @@ HWTEST_F(PictureInPictureControllerTest, StopPictureInPicture01, Function | Smal ASSERT_NE(nullptr, mw); sptr option = new PipOption(); sptr pipControl = new PictureInPictureController(option, mw, 100, nullptr); - ASSERT_EQ(PipWindowState::STATE_UNDEFINED, pipControl->GetControllerState()); + ASSERT_EQ(PiPWindowState::STATE_UNDEFINED, pipControl->GetControllerState()); ASSERT_EQ(WMError::WM_ERROR_PIP_STATE_ABNORMALLY, pipControl->StopPictureInPicture(true, false, StopPipType::NULL_STOP)); pipControl->window_ = mw; EXPECT_CALL(*(mw), Destroy()).Times(1).WillOnce(Return(WMError::WM_DO_NOTHING)); ASSERT_EQ(WMError::WM_ERROR_PIP_DESTROY_FAILED, pipControl->StopPictureInPicture(true, false, StopPipType::NULL_STOP)); - ASSERT_EQ(PipWindowState::STATE_UNDEFINED, pipControl->GetControllerState()); + ASSERT_EQ(PiPWindowState::STATE_UNDEFINED, pipControl->GetControllerState()); EXPECT_CALL(*(mw), Destroy()).Times(1).WillOnce(Return(WMError::WM_OK)); ASSERT_EQ(WMError::WM_OK, pipControl->StopPictureInPicture(true, false, StopPipType::NULL_STOP)); - ASSERT_EQ(PipWindowState::STATE_STOPPED, pipControl->GetControllerState()); + ASSERT_EQ(PiPWindowState::STATE_STOPPED, pipControl->GetControllerState()); } /** @@ -200,7 +200,7 @@ HWTEST_F(PictureInPictureControllerTest, IsAutoStartEnabled, Function | SmallTes pipControl->IsAutoStartEnabled(enable); auto ret = pipControl->GetControllerState(); - ASSERT_EQ(PipWindowState::STATE_UNDEFINED, ret); + ASSERT_EQ(PiPWindowState::STATE_UNDEFINED, ret); } /** diff --git a/wm/test/unittest/picture_in_picture_manager_test.cpp b/wm/test/unittest/picture_in_picture_manager_test.cpp index 09658de63..90a4e7d1d 100644 --- a/wm/test/unittest/picture_in_picture_manager_test.cpp +++ b/wm/test/unittest/picture_in_picture_manager_test.cpp @@ -48,7 +48,7 @@ void PictureInPictureManagerTest::TearDown() namespace { /** - * @tc.name: PipWindowState + * @tc.name: PiPWindowState * @tc.desc: PutPipControllerInfo/RemovePipControllerInfo * @tc.type: FUNC */ -- Gitee From e618f456f7845300b337f5967401589cb4a654a9 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Sat, 9 Mar 2024 11:18:41 +0800 Subject: [PATCH 015/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../napi/picture_in_picture_napi/js_pip_utils.cpp | 12 ++++++------ .../js_pip_window_manager.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp index ce8e0d06a..ad26d4a8d 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp @@ -91,12 +91,12 @@ static napi_value ExportPictureInPictureControlGroup(napi_env env) { napi_value result = nullptr; napi_create_object(env, &result); - (void)SetNamedProperty(env, result, "VIDEO_PREVIOUS_NEXT", static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT)); - (void)SetNamedProperty(env, result, "FAST_FORWARD_BACKWARD", static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); - (void)SetNamedProperty(env, result, "MICROPHONE_SWITCH", static_cast(PiPControlGroup::MICROPHONE_SWITCH)); - (void)SetNamedProperty(env, result, "HANG_UP_BUTTON", static_cast(PiPControlGroup::HANG_UP_BUTTON)); - (void)SetNamedProperty(env, result, "CAMERA_SWITCH", static_cast(PiPControlGroup::CAMERA_SWITCH)); - (void)SetNamedProperty(env, result, "MUTE_SWITCH", static_cast(PiPControlGroup::MUTE_SWITCH)); + (void)SetNamedProperty(env, result, "VIDEO_PREVIOUS_NEXT", static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT)); + (void)SetNamedProperty(env, result, "FAST_FORWARD_BACKWARD", static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); + (void)SetNamedProperty(env, result, "MICROPHONE_SWITCH", static_cast(PiPControlGroup::MICROPHONE_SWITCH)); + (void)SetNamedProperty(env, result, "HANG_UP_BUTTON", static_cast(PiPControlGroup::HANG_UP_BUTTON)); + (void)SetNamedProperty(env, result, "CAMERA_SWITCH", static_cast(PiPControlGroup::CAMERA_SWITCH)); + (void)SetNamedProperty(env, result, "MUTE_SWITCH", static_cast(PiPControlGroup::MUTE_SWITCH)); napi_object_freeze(env, result); return result; } diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index cf50a895f..e960d7d92 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -30,14 +30,17 @@ using namespace Ace; namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipWindowManager"}; const std::set VIDEO_PLAY_CONTROLS { - PiPControlGroup::VIDEO_PREVIOUS_NEXT,PiPControlGroup::FAST_FORWARD_BACKWARD + PiPControlGroup::VIDEO_PREVIOUS_NEXT, + PiPControlGroup::FAST_FORWARD_BACKWARD }; const std::set VIDEO_CALL_CONTROLS { - PiPControlGroup::MICROPHONE_SWITCH,PiPControlGroup::HANG_UP_BUTTON, + PiPControlGroup::MICROPHONE_SWITCH, + PiPControlGroup::HANG_UP_BUTTON, PiPControlGroup::CAMERA_SWITCH, }; const std::set VIDEO_MEETING_CONTROLS { - PiPControlGroup::MUTE_SWITCH,PiPControlGroup::HANG_UP_BUTTON, + PiPControlGroup::MUTE_SWITCH, + PiPControlGroup::HANG_UP_BUTTON, PiPControlGroup::CAMERA_SWITCH, }; const std::map> TEMPLATE_CONTROL_MAP { -- Gitee From 8840183c7d1fe076653a38c999be4366734243b9 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Sat, 9 Mar 2024 14:49:14 +0800 Subject: [PATCH 016/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E7=BB=84?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../js_pip_window_manager.cpp | 6 ++--- .../window_scene_session_impl_test.cpp | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index e960d7d92..cd0b6a0ea 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -31,7 +31,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipWindowManager"}; const std::set VIDEO_PLAY_CONTROLS { PiPControlGroup::VIDEO_PREVIOUS_NEXT, - PiPControlGroup::FAST_FORWARD_BACKWARD + PiPControlGroup::FAST_FORWARD_BACKWARD, }; const std::set VIDEO_CALL_CONTROLS { PiPControlGroup::MICROPHONE_SWITCH, @@ -64,8 +64,8 @@ static int32_t checkOptionParams(PipOption& option) return -1; } uint32_t pipTemplateType = option.GetPipTemplate(); - if (TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)) - == TEMPLATE_CONTROL_MAP.end()) { + if (TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)) == + TEMPLATE_CONTROL_MAP.end()) { WLOGE("check pipoption param error, pipTemplateType not exists."); return -1; } diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 382c8b1bc..d005264c5 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -1619,6 +1619,29 @@ HWTEST_F(WindowSceneSessionImplTest, GetTopWindowWithContext01, Function | Small ASSERT_NE(nullptr, windowscenesession->GetTopWindowWithContext(context)); } +/** + * @tc.name: GetMainWindowWithContext01 + * @tc.desc: GetMainWindowWithContext + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, GetMainWindowWithContext01, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("GetMainWindowWithContext"); + option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); + std::shared_ptr context; + sptr windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, windowscenesession); + if (windowscenesession->GetMainWindowWithContext(context) == nullptr) { + ASSERT_EQ(nullptr, windowscenesession->GetMainWindowWithContext(context)); + } + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(nullptr, session); + ASSERT_EQ(WMError::WM_OK, windowscenesession->Create(abilityContext_, session)); + ASSERT_NE(nullptr, windowscenesession->GetMainWindowWithContext(context)); +} + /** * @tc.name: NotifyMemoryLevel01 * @tc.desc: NotifyMemoryLevel -- Gitee From 859cdba501dc48ac235e1b50c944369a8caf6c67 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Sat, 9 Mar 2024 15:14:03 +0800 Subject: [PATCH 017/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../kits/napi/picture_in_picture_napi/js_pip_utils.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp index ad26d4a8d..0366d8a62 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp @@ -91,8 +91,10 @@ static napi_value ExportPictureInPictureControlGroup(napi_env env) { napi_value result = nullptr; napi_create_object(env, &result); - (void)SetNamedProperty(env, result, "VIDEO_PREVIOUS_NEXT", static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT)); - (void)SetNamedProperty(env, result, "FAST_FORWARD_BACKWARD", static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); + (void)SetNamedProperty(env, result, "VIDEO_PREVIOUS_NEXT", + static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT)); + (void)SetNamedProperty(env, result, "FAST_FORWARD_BACKWARD", + static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); (void)SetNamedProperty(env, result, "MICROPHONE_SWITCH", static_cast(PiPControlGroup::MICROPHONE_SWITCH)); (void)SetNamedProperty(env, result, "HANG_UP_BUTTON", static_cast(PiPControlGroup::HANG_UP_BUTTON)); (void)SetNamedProperty(env, result, "CAMERA_SWITCH", static_cast(PiPControlGroup::CAMERA_SWITCH)); -- Gitee From 500b06c4afb329fb984f23bb61e53cb05886a86c Mon Sep 17 00:00:00 2001 From: xu-jingyi12 Date: Sat, 9 Mar 2024 16:09:17 +0800 Subject: [PATCH 018/385] add tdd test Signed-off-by: xu-jingyi12 Change-Id: Ie8e6719345ff09310ef86591d429e2e72f32a46a --- wm/test/unittest/BUILD.gn | 11 ++ wm/test/unittest/window_adapter_test.cpp | 211 +++++++++++++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 wm/test/unittest/window_adapter_test.cpp diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index 87f6d5947..453b9ed75 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -42,6 +42,7 @@ group("unittest") { ":wm_window_session_impl_test", ":wm_window_stub_test", ":wm_window_test", + ":wm_window_adapter_test", ] if (!scene_board_enabled) { deps += [ ":wm_window_proxy_test" ] @@ -389,6 +390,16 @@ ohos_unittest("wm_window_manager_agent_proxy_test") { external_deps = [ "c_utils:utils" ] } +ohos_unittest("wm_window_adapter_test") { + module_out_path = module_out_path + + sources = [ "window_adapter_test.cpp" ] + + deps = [ ":wm_unittest_common" ] + + external_deps = [ "c_utils:utils" ] +} + ## Build wm_unittest_common.a {{{ config("wm_unittest_common_public_config") { include_dirs = [ diff --git a/wm/test/unittest/window_adapter_test.cpp b/wm/test/unittest/window_adapter_test.cpp new file mode 100644 index 000000000..183c078f8 --- /dev/null +++ b/wm/test/unittest/window_adapter_test.cpp @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "mock_RSIWindowAnimationController.h" + +#include "remote_animation.h" +#include "starting_window.h" +#include "window_transition_info.h" +#include "window_property.h" +#include "window_agent.h" +#include "window_adapter.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class WindowAdapterTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void WindowAdapterTest::SetUpTestCase() +{ +} + +void WindowAdapterTest::TearDownTestCase() +{ +} + +void WindowAdapterTest::SetUp() +{ +} + +void WindowAdapterTest::TearDown() +{ +} + +namespace { +/** + * @tc.name: AddWindow + * @tc.desc: WindowAdapter/AddWindow + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, AddWindow, Function | SmallTest | Level2) +{ + sptr windowProperty = nullptr; + WindowAdapter windowAdapter; + + windowAdapter.AddWindow(windowProperty); + auto ret = windowAdapter.InitWMSProxy(); + ASSERT_EQ(true, ret); +} + +/** + * @tc.name: RemoveWindow + * @tc.desc: WindowAdapter/RemoveWindow + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, RemoveWindow, Function | SmallTest | Level2) +{ + uint32_t windowId = 0; + bool isFromInnerkits = false; + WindowAdapter windowAdapter; + + windowAdapter.RemoveWindow(windowId, isFromInnerkits); + auto ret = windowAdapter.InitWMSProxy(); + ASSERT_EQ(true, ret); +} + +/** + * @tc.name: RequestFocus + * @tc.desc: WindowAdapter/RequestFocus + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, RequestFocus, Function | SmallTest | Level2) +{ + uint32_t windowId = 0; + WindowAdapter windowAdapter; + + windowAdapter.RequestFocus(windowId); + auto ret = windowAdapter.InitWMSProxy(); + ASSERT_EQ(true, ret); +} + +/** + * @tc.name: CheckWindowId + * @tc.desc: WindowAdapter/CheckWindowId + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, CheckWindowId, Function | SmallTest | Level2) +{ + int32_t windowId = 0; + int32_t pid = 0; + WindowAdapter windowAdapter; + + windowAdapter.CheckWindowId(windowId, pid); + auto ret = windowAdapter.InitWMSProxy(); + ASSERT_EQ(true, ret); +} + +/** + * @tc.name: SetWindowAnimationController + * @tc.desc: WindowAdapter/SetWindowAnimationController + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, SetWindowAnimationController, Function | SmallTest | Level2) +{ + sptr controller = nullptr; + WindowAdapter windowAdapter; + + windowAdapter.SetWindowAnimationController(controller); + auto ret = windowAdapter.InitWMSProxy(); + ASSERT_EQ(true, ret); +} + +/** + * @tc.name: GetAvoidAreaByType + * @tc.desc: WindowAdapter/GetAvoidAreaByType + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, GetAvoidAreaByType, Function | SmallTest | Level2) +{ + uint32_t windowId = 0; + AvoidAreaType type = AvoidAreaType::TYPE_CUTOUT; + AvoidArea avoidArea; + WindowAdapter windowAdapter; + + windowAdapter.GetAvoidAreaByType(windowId, type, avoidArea); + auto ret = windowAdapter.InitWMSProxy(); + ASSERT_EQ(true, ret); +} + +/** + * @tc.name: NotifyServerReadyToMoveOrDrag + * @tc.desc: WindowAdapter/NotifyServerReadyToMoveOrDrag + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, NotifyServerReadyToMoveOrDrag, Function | SmallTest | Level2) +{ + uint32_t windowId = 0; + sptr windowProperty = nullptr; + sptr moveDragProperty = nullptr; + WindowAdapter windowAdapter; + + windowAdapter.NotifyServerReadyToMoveOrDrag(windowId, windowProperty, moveDragProperty); + auto ret = windowAdapter.InitWMSProxy(); + ASSERT_EQ(true, ret); +} + +/** + * @tc.name: ProcessPointDown + * @tc.desc: WindowAdapter/ProcessPointDown + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, ProcessPointDown, Function | SmallTest | Level2) +{ + uint32_t windowId = 0; + bool isPointDown = false; + WindowAdapter windowAdapter; + + windowAdapter.ProcessPointDown(windowId, isPointDown); + windowAdapter.ProcessPointUp(windowId); + auto ret = windowAdapter.InitWMSProxy(); + ASSERT_EQ(true, ret); +} + +/** + * @tc.name: ToggleShownStateForAllAppWindows + * @tc.desc: WindowAdapter/ToggleShownStateForAllAppWindows + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, ToggleShownStateForAllAppWindows, Function | SmallTest | Level2) +{ + WindowAdapter windowAdapter; + + windowAdapter.ToggleShownStateForAllAppWindows(); + auto ret = windowAdapter.InitWMSProxy(); + ASSERT_EQ(true, ret); +} + +/** + * @tc.name: InitWMSProxy + * @tc.desc: WindowAdapter/InitWMSProxy + * @tc.type: FUNC + */ +HWTEST_F(WindowAdapterTest, InitWMSProxy, Function | SmallTest | Level2) +{ + WindowAdapter windowAdapter; + auto ret = windowAdapter.InitWMSProxy(); + ASSERT_EQ(true, ret); +} +} +} +} \ No newline at end of file -- Gitee From d7717210239b33f5c001492bef1d88287cf3009d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E9=9D=99=E6=80=A1?= Date: Sat, 9 Mar 2024 08:59:09 +0000 Subject: [PATCH 019/385] update wm/test/unittest/BUILD.gn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许静怡 --- wm/test/unittest/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index 453b9ed75..9db705038 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -25,6 +25,7 @@ group("unittest") { ":wm_picture_in_picture_manager_test", ":wm_picture_in_picture_option_test", ":wm_root_scene_test", + ":wm_window_adapter_test", ":wm_window_agent_test", ":wm_window_effect_test", ":wm_window_extension_session_impl_test", @@ -42,7 +43,6 @@ group("unittest") { ":wm_window_session_impl_test", ":wm_window_stub_test", ":wm_window_test", - ":wm_window_adapter_test", ] if (!scene_board_enabled) { deps += [ ":wm_window_proxy_test" ] @@ -392,7 +392,7 @@ ohos_unittest("wm_window_manager_agent_proxy_test") { ohos_unittest("wm_window_adapter_test") { module_out_path = module_out_path - + sources = [ "window_adapter_test.cpp" ] deps = [ ":wm_unittest_common" ] -- Gitee From ce2a9caeeaa182f8025177e8a29d902a1b9294ac Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 11 Mar 2024 16:58:39 +0800 Subject: [PATCH 020/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- interfaces/innerkits/wm/wm_common.h | 23 +++++++---- .../picture_in_picture_napi/js_pip_utils.cpp | 38 ++++++++++++++++--- .../js_pip_window_manager.cpp | 12 +++--- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 9c6c3896e..6df7b2668 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -640,13 +640,22 @@ enum class PiPTemplateType : uint32_t { * @brief Enumerates picture in picture control group. */ enum class PiPControlGroup : uint32_t { - START = 0, - VIDEO_PREVIOUS_NEXT = 1, - FAST_FORWARD_BACKWARD = 2, - MICROPHONE_SWITCH = 3, - HANG_UP_BUTTON = 4, - CAMERA_SWITCH = 5, - MUTE_SWITCH = 6, + VIDEO_PLAY_START = 100, + VIDEO_PREVIOUS_NEXT = 101, + FAST_FORWARD_BACKWARD = 102, + VIDEO_PLAY_END, + + VIDEO_CALL_START = 200, + VIDEO_CALL_MICROPHONE_SWITCH = 201, + VIDEO_CALL_HANG_UP_BUTTON = 202, + VIDEO_CALL_CAMERA_SWITCH = 203, + VIDEO_CALL_END, + + VIDEO_MEETING_START = 300, + VIDEO_MEETING_HANG_UP_BUTTON = 301, + VIDEO_MEETING_CAMERA_SWITCH = 302, + VIDEO_MEETING_MUTE_SWITCH = 303, + VIDEO_MEETING_END, END, }; diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp index 0366d8a62..c1a79b5cc 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_utils.cpp @@ -87,7 +87,7 @@ static napi_value ExportPictureInPictureState(napi_env env) return result; } -static napi_value ExportPictureInPictureControlGroup(napi_env env) +static napi_value ExportVideoPlayControlGroup(napi_env env) { napi_value result = nullptr; napi_create_object(env, &result); @@ -95,10 +95,34 @@ static napi_value ExportPictureInPictureControlGroup(napi_env env) static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT)); (void)SetNamedProperty(env, result, "FAST_FORWARD_BACKWARD", static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); - (void)SetNamedProperty(env, result, "MICROPHONE_SWITCH", static_cast(PiPControlGroup::MICROPHONE_SWITCH)); - (void)SetNamedProperty(env, result, "HANG_UP_BUTTON", static_cast(PiPControlGroup::HANG_UP_BUTTON)); - (void)SetNamedProperty(env, result, "CAMERA_SWITCH", static_cast(PiPControlGroup::CAMERA_SWITCH)); - (void)SetNamedProperty(env, result, "MUTE_SWITCH", static_cast(PiPControlGroup::MUTE_SWITCH)); + napi_object_freeze(env, result); + return result; +} + +static napi_value ExportVideoCallControlGroup(napi_env env) +{ + napi_value result = nullptr; + napi_create_object(env, &result); + (void)SetNamedProperty(env, result, "MICROPHONE_SWITCH", + static_cast(PiPControlGroup::VIDEO_CALL_MICROPHONE_SWITCH)); + (void)SetNamedProperty(env, result, "HANG_UP_BUTTON", + static_cast(PiPControlGroup::VIDEO_CALL_HANG_UP_BUTTON)); + (void)SetNamedProperty(env, result, "CAMERA_SWITCH", + static_cast(PiPControlGroup::VIDEO_CALL_CAMERA_SWITCH)); + napi_object_freeze(env, result); + return result; +} + +static napi_value ExportVideoMeetingControlGroup(napi_env env) +{ + napi_value result = nullptr; + napi_create_object(env, &result); + (void)SetNamedProperty(env, result, "HANG_UP_BUTTON", + static_cast(PiPControlGroup::VIDEO_MEETING_HANG_UP_BUTTON)); + (void)SetNamedProperty(env, result, "CAMERA_SWITCH", + static_cast(PiPControlGroup::VIDEO_MEETING_CAMERA_SWITCH)); + (void)SetNamedProperty(env, result, "MUTE_SWITCH", + static_cast(PiPControlGroup::VIDEO_MEETING_MUTE_SWITCH)); napi_object_freeze(env, result); return result; } @@ -108,7 +132,9 @@ napi_status InitEnums(napi_env env, napi_value exports) const napi_property_descriptor properties[] = { DECLARE_NAPI_PROPERTY("PiPTemplateType", ExportPictureInPictureTemplateType(env)), DECLARE_NAPI_PROPERTY("PiPState", ExportPictureInPictureState(env)), - DECLARE_NAPI_PROPERTY("PiPControlGroup", ExportPictureInPictureControlGroup(env)), + DECLARE_NAPI_PROPERTY("VideoPlayControlGroup", ExportVideoPlayControlGroup(env)), + DECLARE_NAPI_PROPERTY("VideoCallControlGroup", ExportVideoCallControlGroup(env)), + DECLARE_NAPI_PROPERTY("VideoMeetingControlGroup", ExportVideoMeetingControlGroup(env)), }; size_t count = sizeof(properties) / sizeof(napi_property_descriptor); return napi_define_properties(env, exports, count, properties); diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index cd0b6a0ea..223eb1877 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -34,14 +34,14 @@ namespace { PiPControlGroup::FAST_FORWARD_BACKWARD, }; const std::set VIDEO_CALL_CONTROLS { - PiPControlGroup::MICROPHONE_SWITCH, - PiPControlGroup::HANG_UP_BUTTON, - PiPControlGroup::CAMERA_SWITCH, + PiPControlGroup::VIDEO_CALL_MICROPHONE_SWITCH, + PiPControlGroup::VIDEO_CALL_HANG_UP_BUTTON, + PiPControlGroup::VIDEO_CALL_CAMERA_SWITCH, }; const std::set VIDEO_MEETING_CONTROLS { - PiPControlGroup::MUTE_SWITCH, - PiPControlGroup::HANG_UP_BUTTON, - PiPControlGroup::CAMERA_SWITCH, + PiPControlGroup::VIDEO_MEETING_HANG_UP_BUTTON, + PiPControlGroup::VIDEO_MEETING_CAMERA_SWITCH, + PiPControlGroup::VIDEO_MEETING_MUTE_SWITCH, }; const std::map> TEMPLATE_CONTROL_MAP { {PiPTemplateType::VIDEO_PLAY, VIDEO_PLAY_CONTROLS}, -- Gitee From 7d8b5b23944d0715072316518511d6e25c9d97fa Mon Sep 17 00:00:00 2001 From: chuchengcheng Date: Tue, 27 Feb 2024 10:19:24 +0800 Subject: [PATCH 021/385] =?UTF-8?q?=E7=BB=84=E4=BB=B6=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chuchengcheng Change-Id: I6df9c66c94c63e76a49875eea8564828318e5747 --- previewer/include/window.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/previewer/include/window.h b/previewer/include/window.h index 5d861addb..f919bd091 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -57,7 +57,7 @@ namespace Rosen { class RSSurfaceNode; class RSTransaction; using NotifyNativeWinDestroyFunc = std::function; -using SendRenderDataCallback = bool (*)(const void*, const size_t, const int32_t, const int32_t); +using SendRenderDataCallback = bool (*)(const void*, const size_t, const int32_t, const int32_t, const uint64_t); using ContentInfoCallback = std::function; class IWindowLifeCycle : virtual public RefBase { -- Gitee From 7f8bbfa4be43a3f4dde03a4febbe0064d4882528 Mon Sep 17 00:00:00 2001 From: cloud_nine Date: Tue, 12 Mar 2024 20:42:13 +0800 Subject: [PATCH 022/385] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=99=9A=E6=8B=9F?= =?UTF-8?q?=E5=B1=8Fdisplaynode=E4=B8=8Ers=E4=BE=A7node=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenyunjiu --- window_scene/session/screen/src/screen_session.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 96e39d1ba..419653f2f 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -72,10 +72,11 @@ ScreenSession::ScreenSession(const std::string& name, ScreenId smsId, ScreenId r : name_(name), screenId_(smsId), rsId_(rsId), defaultScreenId_(defaultScreenId) { (void)rsId_; - Rosen::RSDisplayNodeConfig config = { .screenId = screenId_ }; + // 虚拟屏的screen id和rs id不一致,displayNode的创建应使用rs id + Rosen::RSDisplayNodeConfig config = { .screenId = rsId_ }; displayNode_ = Rosen::RSDisplayNode::Create(config); if (displayNode_) { - WLOGI("Success to create displayNode in constructor_3, screenid is %{public}" PRIu64"", screenId_); + WLOGI("Success to create displayNode in constructor_3, rs id is %{public}" PRIu64"", rsId_); displayNode_->SetFrame(property_.GetBounds().rect_.left_, property_.GetBounds().rect_.top_, property_.GetBounds().rect_.width_, property_.GetBounds().rect_.height_); displayNode_->SetBounds(property_.GetBounds().rect_.left_, property_.GetBounds().rect_.top_, -- Gitee From 1333da1dff2716d5fde38d2104a509caa187d4fa Mon Sep 17 00:00:00 2001 From: w00574628 Date: Tue, 12 Mar 2024 20:55:14 +0800 Subject: [PATCH 023/385] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E5=90=8E=E6=8B=89=E8=B5=B7=E6=82=AC=E6=B5=AE=E6=80=81=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=B3=95=E7=AA=97=E5=8F=A3=E5=AD=98=E5=9C=A8=E5=8A=A8?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: w00574628 --- .../session_manager/src/scene_session_manager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c07bd4135..8b5c753e7 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -5294,6 +5294,7 @@ void SceneSessionManager::RestoreCallingSessionSizeIfNeed() WSError SceneSessionManager::SetSessionGravity(int32_t persistentId, SessionGravity gravity, uint32_t percent) { auto task = [this, persistentId, gravity, percent]() -> WSError { + bool isKeyboardForeground = true; auto sceneSession = GetSceneSession(persistentId); if (!sceneSession) { WLOGFE("scene session is nullptr"); @@ -5309,17 +5310,21 @@ WSError SceneSessionManager::SetSessionGravity(int32_t persistentId, SessionGrav RelayoutKeyBoard(sceneSession); if (sceneSession->GetSessionState() != SessionState::STATE_FOREGROUND && sceneSession->GetSessionState() != SessionState::STATE_ACTIVE) { + isKeyboardForeground = false; TLOGI(WmsLogTag::WMS_KEYBOARD, "Keyboard is not foreground, not need to adjust or restore callingWindow"); - return WSError::WS_OK; } if (gravity == SessionGravity::SESSION_GRAVITY_FLOAT) { TLOGD(WmsLogTag::WMS_KEYBOARD, "input method is float mode"); sceneSession->SetWindowAnimationFlag(false); - RestoreCallingSessionSizeIfNeed(); + if (isKeyboardForeground) { + RestoreCallingSessionSizeIfNeed(); + } } else { TLOGD(WmsLogTag::WMS_KEYBOARD, "input method is bottom mode"); sceneSession->SetWindowAnimationFlag(true); - ResizeSoftInputCallingSessionIfNeed(sceneSession); + if (isKeyboardForeground) { + ResizeSoftInputCallingSessionIfNeed(sceneSession); + } } return WSError::WS_OK; }; -- Gitee From 557765634c57a3737122def2bc26f081fd9cbc9d Mon Sep 17 00:00:00 2001 From: liuyufeng Date: Wed, 13 Mar 2024 09:58:39 +0800 Subject: [PATCH 024/385] =?UTF-8?q?=E6=96=B0=E5=A2=9Etdd=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuyufeng --- .../test/unittest/timer_manager_test.cpp | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/window_scene/test/unittest/timer_manager_test.cpp b/window_scene/test/unittest/timer_manager_test.cpp index 995b9d646..a31e699e2 100644 --- a/window_scene/test/unittest/timer_manager_test.cpp +++ b/window_scene/test/unittest/timer_manager_test.cpp @@ -16,6 +16,7 @@ #include #include "intention_event/service/timer_manager/include/timer_manager.h" #include "intention_event/service/anr_manager/include/anr_manager.h" +#include "intention_event/framework/anr_handler/include/anr_handler.h" #include #include #include "window_manager_hilog.h" @@ -347,6 +348,105 @@ HWTEST_F(TimerManagerTest, AddTimerInternal004, Function | SmallTest | Level2) delete(timermanager); GTEST_LOG_(INFO) << "AddTimerInternal004::ProcessTimersInternal start"; } + +/** + * @tc.name: ANRHandler.HandleEventConsumed + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(TimerManagerTest, HandleEventConsumed01, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ANRHandler::HandleEventConsumed01 start"; + int32_t evenid = -1; + int64_t actionTime = 10; + ANRHandler* ANRHandler = new (class ANRHandler)(); + ANRHandler->HandleEventConsumed(evenid, actionTime); + ASSERT_EQ(evenid, -1); + delete ANRHandler; + GTEST_LOG_(INFO) << "ANRHandler::HandleEventConsumed01 end"; +} + +/** + * @tc.name: ANRHandler.HandleEventConsumed + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(TimerManagerTest, HandleEventConsumed02, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ANRHandler::HandleEventConsumed02 start"; + int32_t evenid = 0; + int64_t actionTime = 10; + ANRHandler* ANRHandler = new (class ANRHandler)(); + ANRHandler->HandleEventConsumed(evenid, actionTime); + ASSERT_EQ(evenid, 0); + delete ANRHandler; + GTEST_LOG_(INFO) << "ANRHandler::HandleEventConsumed02 end"; +} + +/** + * @tc.name: ANRHandler.HandleEventConsumed + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(TimerManagerTest, HandleEventConsumed03, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ANRHandler::HandleEventConsumed03 start"; + int32_t evenid = 1; + int64_t actionTime = 10; + ANRHandler* ANRHandler = new (class ANRHandler)(); + ANRHandler->HandleEventConsumed(evenid, actionTime); + ASSERT_EQ(evenid, 1); + delete ANRHandler; + GTEST_LOG_(INFO) << "ANRHandler::HandleEventConsumed03 end"; +} + +/** + * @tc.name: ANRHandler.OnWindowDestroyed + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(TimerManagerTest, OnWindowDestroyed01, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ANRHandler::OnWindowDestroyed01 start"; + int32_t persistentId = 1; + ANRHandler* ANRHandler = new (class ANRHandler)(); + ANRHandler->OnWindowDestroyed(persistentId); + ASSERT_EQ(persistentId, 1); + delete ANRHandler; + GTEST_LOG_(INFO) << "ANRHandler::OnWindowDestroyed01 end"; +} + +/** + * @tc.name: ANRHandler.OnWindowDestroyed + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(TimerManagerTest, OnWindowDestroyed02, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ANRHandler::OnWindowDestroyed02 start"; + int32_t persistentId = -1; + ANRHandler* ANRHandler = new (class ANRHandler)(); + ANRHandler->OnWindowDestroyed(persistentId); + ASSERT_EQ(persistentId, -1); + delete ANRHandler; + GTEST_LOG_(INFO) << "ANRHandler::OnWindowDestroyed02 end"; +} + +/** + * @tc.name: ANRHandler.UpdateLatestEventId + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(TimerManagerTest, UpdateLatestEventId, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ANRHandler::UpdateLatestEventId start"; + int32_t eventId = -1; + ANRHandler* ANRHandler = new (class ANRHandler)(); + ANRHandler->UpdateLatestEventId(eventId); + ASSERT_EQ(eventId, -1); + delete ANRHandler; + GTEST_LOG_(INFO) << "ANRHandler::UpdateLatestEventId end"; +} } } } -- Gitee From 7df3b4314d20141202a2af053263c053f028248f Mon Sep 17 00:00:00 2001 From: liwei l30031422 Date: Tue, 5 Mar 2024 20:35:23 +0800 Subject: [PATCH 025/385] Add_Embeddable_Window_Stage Signed-off-by: liwei l30031422 Change-Id: I0c6c4440670d94119196635e0507e54f7af2187d --- bundle.json | 11 + interfaces/kits/napi/BUILD.gn | 1 + .../napi/embeddable_window_stage/BUILD.gn | 105 +++++++++ .../embeddable_window_stage.js | 54 +++++ .../embeddable_window_stage_module.cpp | 55 +++++ .../js_embeddable_window_stage.cpp | 51 +++++ .../js_embeddable_window_stage.h | 4 + .../kits/napi/extension_window/BUILD.gn | 2 - .../napi/extension_window/extension_window.js | 15 -- .../extension_window/js_extension_window.cpp | 208 ++++++++++++++++-- .../extension_window/js_extension_window.h | 16 ++ .../js_extension_window_utils.cpp | 39 ++++ .../js_extension_window_utils.h | 1 + wm/include/window_session_impl.h | 6 +- wm/src/window_extension_session_impl.cpp | 5 + wm/src/window_session_impl.cpp | 28 ++- 16 files changed, 551 insertions(+), 50 deletions(-) create mode 100644 interfaces/kits/napi/embeddable_window_stage/BUILD.gn create mode 100644 interfaces/kits/napi/embeddable_window_stage/embeddable_window_stage.js create mode 100644 interfaces/kits/napi/embeddable_window_stage/embeddable_window_stage_module.cpp rename interfaces/kits/napi/{extension_window => embeddable_window_stage}/js_embeddable_window_stage.cpp (84%) rename interfaces/kits/napi/{extension_window => embeddable_window_stage}/js_embeddable_window_stage.h (89%) diff --git a/bundle.json b/bundle.json index 9b5013a47..4a89667dc 100755 --- a/bundle.json +++ b/bundle.json @@ -83,6 +83,7 @@ "base_group": [ "//foundation/window/window_manager/snapshot:snapshot_display", "//foundation/window/window_manager/setresolution:setresolution_screen", + "//foundation/window/window_manager/interfaces/kits/napi/embeddable_window_stage:embeddablewindowstage", "//foundation/window/window_manager/interfaces/kits/napi/extension_window:extensionwindow", "//foundation/window/window_manager/interfaces/kits/napi/window_runtime/window_stage_napi:windowstage", "//foundation/window/window_manager/interfaces/kits/napi:napi_packages", @@ -306,6 +307,16 @@ "header_base": "//foundation/window/window_manager/previewer/include" } }, + { + "type": "so", + "name": "//foundation/window/window_manager/interfaces/kits/napi/embeddable_window_stage:embeddablewindowstage_kit", + "header": { + "header_files": [ + "js_embeddable_window_stage.h" + ], + "header_base": "//foundation/window/window_manager/interfaces/kits/napi/embeddable_window_stage" + } + }, { "type": "so", "name": "//foundation/window/window_manager/interfaces/kits/napi/extension_window:extensionwindow_napi", diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index fa4bf36d2..4f7bd247e 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -16,6 +16,7 @@ import("//build/ohos.gni") group("napi_packages") { deps = [ "display_runtime:display_napi", + "embeddable_window_stage:embeddablewindowstage_kit", "extension_window:extensionwindow_napi", "picture_in_picture_napi:pipwindow_napi", "picture_in_picture_napi/inner:pip_napi", diff --git a/interfaces/kits/napi/embeddable_window_stage/BUILD.gn b/interfaces/kits/napi/embeddable_window_stage/BUILD.gn new file mode 100644 index 000000000..1d04f470a --- /dev/null +++ b/interfaces/kits/napi/embeddable_window_stage/BUILD.gn @@ -0,0 +1,105 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") +import("//build/ohos.gni") + +es2abc_gen_abc("gen_embeddable_window_stage_abc") { + src_js = rebase_path("embeddable_window_stage.js") + dst_file = rebase_path(target_out_dir + "/embeddable_window_stage.abc") + in_puts = [ "embeddable_window_stage.js" ] + out_puts = [ target_out_dir + "/embeddable_window_stage.abc" ] + extra_args = [ "--module" ] +} + +gen_js_obj("embeddable_window_stage_js") { + input = "embeddable_window_stage.js" + output = target_out_dir + "/embeddable_window_stage.o" +} + +gen_js_obj("embeddable_window_stage_abc") { + input = get_label_info(":gen_embeddable_window_stage_abc", "target_out_dir") + + "/embeddable_window_stage.abc" + output = target_out_dir + "/embeddable_window_stage_abc.o" + dep = ":gen_embeddable_window_stage_abc" +} + +ohos_shared_library("embeddablewindowstage") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + sources = [ "embeddable_window_stage_module.cpp" ] + + configs = [ "../../../../resources/config/build:coverage_flags" ] + + deps = [ + ":embeddable_window_stage_abc", + ":embeddable_window_stage_js", + ] + + external_deps = [ "napi:ace_napi" ] + + relative_install_dir = "module/application" + part_name = "window_manager" + subsystem_name = "window" +} + +config("embeddable_window_stage_kit_config") { + visibility = [ ":*" ] + + include_dirs = [ + "../extension_window", + "../window_runtime/window_napi", + "../../../innerkits/wm", + "../../../../utils/include", + "../../../../wm/include", + "../../../../wmserver/include", + ] +} + +ohos_shared_library("embeddablewindowstage_kit") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + sources = [ "js_embeddable_window_stage.cpp" ] + + configs = [ + ":embeddable_window_stage_kit_config", + "../../../../resources/config/build:coverage_flags", + ] + + include_dirs = [ "embeddable_window_stage" ] + deps = [ + "../../../../utils:libwmutil", + "../../../../wm:libwm", + "../extension_window:extensionwindow_napi", + ] + + external_deps = [ + "ability_runtime:runtime", + "ace_engine:ace_uicontent", + "c_utils:utils", + "hilog:libhilog", + "napi:ace_napi", + ] + + innerapi_tags = [ "platformsdk" ] + part_name = "window_manager" + subsystem_name = "window" +} diff --git a/interfaces/kits/napi/embeddable_window_stage/embeddable_window_stage.js b/interfaces/kits/napi/embeddable_window_stage/embeddable_window_stage.js new file mode 100644 index 000000000..bec6a6072 --- /dev/null +++ b/interfaces/kits/napi/embeddable_window_stage/embeddable_window_stage.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class EmbeddableWindowStage { + constructor(obj) { + this.__embeddable_window_stage__ = obj; + } + + on(type, callback) { + return this.__embeddable_window_stage__.on(type, callback); + } + + off(type, callback) { + return this.__embeddable_window_stage__.off(type, callback); + } + + loadContent(url, storage, asyncCallback) { + return this.__embeddable_window_stage__.loadContent(url, storage, asyncCallback); + } + + loadContentByName(name, storage, asyncCallback) { + return this.__embeddable_window_stage__.loadContentByName(name, storage, asyncCallback); + } + + getMainWindow(asyncCallback) { + return this.__embeddable_window_stage__.getMainWindow(asyncCallback); + } + + getMainWindowSync() { + return this.__embeddable_window_stage__.getMainWindowSync(); + } + + createSubWindow(windowName, asyncCallback) { + return this.__embeddable_window_stage__.createSubWindow(windowName, asyncCallback); + } + + getSubWindow(asyncCallback) { + return this.__embeddable_window_stage__.getSubWindow(asyncCallback); + } +} + +export default EmbeddableWindowStage; diff --git a/interfaces/kits/napi/embeddable_window_stage/embeddable_window_stage_module.cpp b/interfaces/kits/napi/embeddable_window_stage/embeddable_window_stage_module.cpp new file mode 100644 index 000000000..21945718b --- /dev/null +++ b/interfaces/kits/napi/embeddable_window_stage/embeddable_window_stage_module.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "native_engine/native_engine.h" + +extern const char _binary_embeddable_window_stage_js_start[]; +extern const char _binary_embeddable_window_stage_js_end[]; +extern const char _binary_embeddable_window_stage_abc_start[]; +extern const char _binary_embeddable_window_stage_abc_end[]; + +static napi_module g_embeddablewindowstageModule = { + .nm_filename = "application/libembeddablewindowstage.so/embeddable_window_stage.js", + .nm_modname = "application.embeddablewindowstage", +}; + +extern "C" __attribute__((constructor)) void NAPI_application_embeddablewindowstage_AutoRegister() +{ + napi_module_register(&g_embeddablewindowstageModule); +} + +extern "C" __attribute__((visibility("default"))) +void NAPI_application_embeddablewindowstage_GetJSCode(const char **buf, int *bufLen) +{ + if (buf != nullptr) { + *buf = _binary_embeddable_window_stage_js_start; + } + + if (bufLen != nullptr) { + *bufLen = _binary_embeddable_window_stage_js_end - _binary_embeddable_window_stage_js_start; + } +} + +// embeddable_window_stage JS register +extern "C" __attribute__((visibility("default"))) +void NAPI_application_embeddablewindowstage_GetABCCode(const char **buf, int *buflen) +{ + if (buf != nullptr) { + *buf = _binary_embeddable_window_stage_abc_start; + } + if (buflen != nullptr) { + *buflen = _binary_embeddable_window_stage_abc_end - _binary_embeddable_window_stage_abc_start; + } +} \ No newline at end of file diff --git a/interfaces/kits/napi/extension_window/js_embeddable_window_stage.cpp b/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp similarity index 84% rename from interfaces/kits/napi/extension_window/js_embeddable_window_stage.cpp rename to interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp index 10ce2c042..fa2c5ec64 100644 --- a/interfaces/kits/napi/extension_window/js_embeddable_window_stage.cpp +++ b/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp @@ -86,6 +86,55 @@ napi_value JsEmbeddableWindowStage::LoadContentByName(napi_env env, napi_callbac return (me != nullptr) ? me->OnLoadContent(env, info, true) : nullptr; } +napi_value JsEmbeddableWindowStage::CreateSubWindow(napi_env env, napi_callback_info info) +{ + WLOGFD("[NAPI]CreateSubWindow"); + JsEmbeddableWindowStage* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnCreateSubWindow(env, info) : nullptr; +} + +napi_value JsEmbeddableWindowStage::GetSubWindow(napi_env env, napi_callback_info info) +{ + WLOGFD("[NAPI]GetSubWindow"); + JsEmbeddableWindowStage* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetSubWindow(env, info) : nullptr; +} + +napi_value JsEmbeddableWindowStage::OnGetSubWindow(napi_env env, napi_callback_info info) +{ + NapiAsyncTask::CompleteCallback complete = + [](napi_env env, NapiAsyncTask& task, int32_t status) { + task.Reject(env, CreateJsError(env, + static_cast(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT))); + }; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + napi_value callback = (argv[0] != nullptr && GetType(env, argv[0]) == napi_function) ? argv[0] : nullptr; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsEmbeddableWindowStage::OnGetSubWindow", + env, CreateAsyncTaskWithLastParam(env, callback, nullptr, std::move(complete), &result)); + return result; +} + +napi_value JsEmbeddableWindowStage::OnCreateSubWindow(napi_env env, napi_callback_info info) +{ + std::string windowName; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + NapiAsyncTask::CompleteCallback complete = + [](napi_env env, NapiAsyncTask& task, int32_t status) { + task.Reject(env, CreateJsError(env, + static_cast(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT))); + }; + napi_value callback = (argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsEmbeddableWindowStage::OnCreateSubWindow", + env, CreateAsyncTaskWithLastParam(env, callback, nullptr, std::move(complete), &result)); + return result; +} + napi_value JsEmbeddableWindowStage::OnGetMainWindow(napi_env env, napi_callback_info info) { NapiAsyncTask::CompleteCallback complete = @@ -309,6 +358,8 @@ napi_value JsEmbeddableWindowStage::CreateJsEmbeddableWindowStage(napi_env env, objValue, "getMainWindowSync", moduleName, JsEmbeddableWindowStage::GetMainWindowSync); BindNativeFunction(env, objValue, "on", moduleName, JsEmbeddableWindowStage::On); BindNativeFunction(env, objValue, "off", moduleName, JsEmbeddableWindowStage::Off); + BindNativeFunction(env, objValue, "createSubWindow", moduleName, JsEmbeddableWindowStage::CreateSubWindow); + BindNativeFunction(env, objValue, "getSubWindow", moduleName, JsEmbeddableWindowStage::GetSubWindow); return objValue; } diff --git a/interfaces/kits/napi/extension_window/js_embeddable_window_stage.h b/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.h similarity index 89% rename from interfaces/kits/napi/extension_window/js_embeddable_window_stage.h rename to interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.h index 1bd47499b..45aaf2640 100644 --- a/interfaces/kits/napi/extension_window/js_embeddable_window_stage.h +++ b/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.h @@ -38,6 +38,8 @@ public: static napi_value Off(napi_env env, napi_callback_info info); static napi_value LoadContent(napi_env env, napi_callback_info info); static napi_value LoadContentByName(napi_env env, napi_callback_info info); + static napi_value CreateSubWindow(napi_env env, napi_callback_info info); + static napi_value GetSubWindow(napi_env env, napi_callback_info info); private: napi_value OnGetMainWindow(napi_env env, napi_callback_info info); @@ -45,6 +47,8 @@ private: napi_value OnEvent(napi_env env, napi_callback_info info); napi_value OffEvent(napi_env env, napi_callback_info info); napi_value OnLoadContent(napi_env env, napi_callback_info info, bool isLoadedByName); + napi_value OnCreateSubWindow(napi_env env, napi_callback_info info); + napi_value OnGetSubWindow(napi_env env, napi_callback_info info); sptr windowExtensionSessionImpl_; sptr sessionInfo_ = nullptr; diff --git a/interfaces/kits/napi/extension_window/BUILD.gn b/interfaces/kits/napi/extension_window/BUILD.gn index df084049a..268a5b9d2 100644 --- a/interfaces/kits/napi/extension_window/BUILD.gn +++ b/interfaces/kits/napi/extension_window/BUILD.gn @@ -61,7 +61,6 @@ config("extension_window_kit_config") { visibility = [ ":*" ] include_dirs = [ - "../extension_window", "../window_runtime/window_napi", "../../../innerkits/wm", "../../../../utils/include", @@ -78,7 +77,6 @@ ohos_shared_library("extensionwindow_napi") { debug = false } sources = [ - "js_embeddable_window_stage.cpp", "js_extension_window.cpp", "js_extension_window_listener.cpp", "js_extension_window_register_manager.cpp", diff --git a/interfaces/kits/napi/extension_window/extension_window.js b/interfaces/kits/napi/extension_window/extension_window.js index 3be609398..f135f5998 100644 --- a/interfaces/kits/napi/extension_window/extension_window.js +++ b/interfaces/kits/napi/extension_window/extension_window.js @@ -41,21 +41,6 @@ class ExtensionWindow { return this.__extension_window__.hideNonSecureWindows(type, callback); } - loadContent(url, storage, asyncCallback) { - return this.__extension_window__.loadContent(url, storage, asyncCallback); - } - - loadContentByName(name, storage, asyncCallback) { - return this.__extension_window__.loadContentByName(name, storage, asyncCallback); - } - - getMainWindow(asyncCallback) { - return this.__extension_window__.getMainWindow(asyncCallback); - } - - getMainWindowSync() { - return this.__extension_window__.getMainWindowSync(); - } } export default ExtensionWindow; diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index 1e8211b71..3d3ddb70a 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -93,14 +93,25 @@ napi_value JsExtensionWindow::CreateJsExtensionWindowObject(napi_env env, sptrOnSetWindowBackgroundColorSync(env, info) : nullptr; } +napi_value JsExtensionWindow::GetWindowPropertiesSync(napi_env env, napi_callback_info info) +{ + WLOGD("GetProperties is called"); + JsExtensionWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetWindowPropertiesSync(env, info) : nullptr; +} + +napi_value JsExtensionWindow::MoveWindowTo(napi_env env, napi_callback_info info) +{ + WLOGD("MoveTo"); + JsExtensionWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnMoveWindowTo(env, info) : nullptr; +} + +napi_value JsExtensionWindow::ResizeWindow(napi_env env, napi_callback_info info) +{ + WLOGI("Resize"); + JsExtensionWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnResizeWindow(env, info) : nullptr; +} + +napi_value JsExtensionWindow::SetSpecificSystemBarEnabled(napi_env env, napi_callback_info info) +{ + WLOGI("SetSystemBarEnable"); + JsExtensionWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetSpecificSystemBarEnabled(env, info) : nullptr; +} + +napi_value JsExtensionWindow::SetPreferredOrientation(napi_env env, napi_callback_info info) +{ + WLOGD("SetPreferredOrientation"); + JsExtensionWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetPreferredOrientation(env, info) : nullptr; +} + +napi_value JsExtensionWindow::GetUIContext(napi_env env, napi_callback_info info) +{ + WLOGD("GetUIContext"); + JsExtensionWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetUIContext(env, info) : nullptr; +} + +napi_value JsExtensionWindow::SetWindowBrightness(napi_env env, napi_callback_info info) +{ + WLOGI("SetBrightness"); + JsExtensionWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetWindowBrightness(env, info) : nullptr; +} + +napi_value JsExtensionWindow::SetWindowKeepScreenOn(napi_env env, napi_callback_info info) +{ + WLOGI("SetKeepScreenOn"); + JsExtensionWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetWindowKeepScreenOn(env, info) : nullptr; +} + napi_valuetype GetType(napi_env env, napi_value value) { napi_valuetype res = napi_undefined; @@ -217,39 +284,140 @@ static void LoadContentTask(std::shared_ptr contentStorage, std return; } -napi_value JsExtensionWindow::OnSetWindowBackgroundColorSync(napi_env env, napi_callback_info info) +napi_value JsExtensionWindow::OnSetWindowKeepScreenOn(napi_env env, napi_callback_info info) { - WmErrorCode errCode = WmErrorCode::WM_OK; size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc < 1) { // 1: params num - WLOGFE("Argc is invalid: %{public}zu", argc); - errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; - } - std::string color; - if (errCode == WmErrorCode::WM_OK && !ConvertFromJsValue(env, argv[0], color)) { - WLOGFE("Failed to convert parameter to background color"); - errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; - } - if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); - } + NapiAsyncTask::CompleteCallback complete = + [](napi_env env, NapiAsyncTask& task, int32_t status) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT))); + }; + napi_value LastParam = (argc <= 1) ? nullptr : + ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsExtensionWindow::OnSetWindowKeepScreenOn", + env, CreateAsyncTaskWithLastParam(env, LastParam, nullptr, std::move(complete), &result)); + return result; +} + +napi_value JsExtensionWindow::OnSetWindowBrightness(napi_env env, napi_callback_info info) +{ + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + NapiAsyncTask::CompleteCallback complete = + [](napi_env env, NapiAsyncTask& task, int32_t status) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT))); + }; + + napi_value lastParam = (argc <= 1) ? nullptr : + ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsExtensionWindow::OnSetWindowBrightness", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} + +napi_value JsExtensionWindow::OnGetUIContext(napi_env env, napi_callback_info info) +{ + return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); +} + +napi_value JsExtensionWindow::OnSetPreferredOrientation(napi_env env, napi_callback_info info) +{ + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + NapiAsyncTask::CompleteCallback complete = + [](napi_env env, NapiAsyncTask& task, int32_t status) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT))); + }; + + napi_value lastParam = (argc <= 1) ? nullptr : + ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsExtensionWindow::OnSetPreferredOrientation", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} +napi_value JsExtensionWindow::OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_info info) +{ + NapiAsyncTask::CompleteCallback complete = + [](napi_env env, NapiAsyncTask& task, int32_t status) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT))); + }; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsExtensionWindow::OnSetSpecificSystemBarEnabled", + env, CreateAsyncTaskWithLastParam(env, nullptr, nullptr, std::move(complete), &result)); + return result; +} + +napi_value JsExtensionWindow::OnResizeWindow(napi_env env, napi_callback_info info) +{ + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + NapiAsyncTask::CompleteCallback complete = + [](napi_env env, NapiAsyncTask& task, int32_t status) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT))); + }; + // 2: params num; 2: index of callback + napi_value lastParam = (argc <= 2) ? nullptr : + ((argv[2] != nullptr && GetType(env, argv[2]) == napi_function) ? argv[2] : nullptr); + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsExtensionWindow::OnResizeWindow", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} + +napi_value JsExtensionWindow::OnMoveWindowTo(napi_env env, napi_callback_info info) +{ + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + NapiAsyncTask::CompleteCallback complete = + [](napi_env env, NapiAsyncTask& task, int32_t status) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT))); + }; + // 2: params num; 2: index of callback + napi_value lastParam = (argc <= 2) ? nullptr : + ((argv[2] != nullptr && GetType(env, argv[2]) == napi_function) ? argv[2] : nullptr); + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsExtensionWindow::OnMoveWindowTo", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} + +napi_value JsExtensionWindow::OnGetWindowPropertiesSync(napi_env env, napi_callback_info info) +{ sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { + WLOGFW("window is nullptr or get invalid param"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowImpl->SetBackgroundColor(color)); - if (ret == WmErrorCode::WM_OK) { - WLOGI("Window [%{public}u, %{public}s] set background color end", - windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str()); - return NapiGetUndefined(env); + auto objValue = CreateJsExtensionWindowProperties(env, windowImpl); + WLOGI("Window [%{public}u, %{public}s] get properties end", + windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str()); + if (objValue != nullptr) { + return objValue; } else { - return NapiThrowError(env, ret); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } } +napi_value JsExtensionWindow::OnSetWindowBackgroundColorSync(napi_env env, napi_callback_info info) +{ + return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); +} + napi_value JsExtensionWindow::OnDestroyWindow(napi_env env, napi_callback_info info) { NapiAsyncTask::CompleteCallback complete = diff --git a/interfaces/kits/napi/extension_window/js_extension_window.h b/interfaces/kits/napi/extension_window/js_extension_window.h index 9de6aa6e0..0e67c9f95 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.h +++ b/interfaces/kits/napi/extension_window/js_extension_window.h @@ -48,6 +48,14 @@ public: static napi_value SetUIContent(napi_env env, napi_callback_info info); static napi_value DestroyWindow(napi_env env, napi_callback_info info); static napi_value SetWindowBackgroundColorSync(napi_env env, napi_callback_info info); + static napi_value GetWindowPropertiesSync(napi_env env, napi_callback_info info); + static napi_value MoveWindowTo(napi_env env, napi_callback_info info); + static napi_value ResizeWindow(napi_env env, napi_callback_info info); + static napi_value SetSpecificSystemBarEnabled(napi_env env, napi_callback_info info); + static napi_value SetPreferredOrientation(napi_env env, napi_callback_info info); + static napi_value GetUIContext(napi_env env, napi_callback_info info); + static napi_value SetWindowBrightness(napi_env env, napi_callback_info info); + static napi_value SetWindowKeepScreenOn(napi_env env, napi_callback_info info); private: napi_value OnGetWindowAvoidArea(napi_env env, napi_callback_info info); napi_value OnRegisterExtensionWindowCallback(napi_env env, napi_callback_info info); @@ -59,6 +67,14 @@ private: napi_value OnSetUIContent(napi_env env, napi_callback_info info); napi_value OnDestroyWindow(napi_env env, napi_callback_info info); napi_value OnSetWindowBackgroundColorSync(napi_env env, napi_callback_info info); + napi_value OnGetWindowPropertiesSync(napi_env env, napi_callback_info info); + napi_value OnMoveWindowTo(napi_env env, napi_callback_info info); + napi_value OnResizeWindow(napi_env env, napi_callback_info info); + napi_value OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_info info); + napi_value OnSetPreferredOrientation(napi_env env, napi_callback_info info); + napi_value OnGetUIContext(napi_env env, napi_callback_info info); + napi_value OnSetWindowBrightness(napi_env env, napi_callback_info info); + napi_value OnSetWindowKeepScreenOn(napi_env env, napi_callback_info info); static napi_value GetProperties(napi_env env, napi_callback_info info); diff --git a/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp b/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp index 588695aa2..d9f1cc191 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp @@ -15,6 +15,7 @@ #include "js_extension_window_utils.h" +#include "js_window_utils.h" #include "js_extension_window.h" #include "window_manager_hilog.h" @@ -76,6 +77,44 @@ napi_value CreateJsExtensionWindowPropertiesObject(napi_env env, sptr& w return objValue; } +napi_value CreateJsExtensionWindowProperties(napi_env env, sptr& window) +{ + WLOGI("CreateJsWindowPropertiesObject is called"); + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + WLOGFE("Failed to convert windowProperties to jsObject"); + return nullptr; + } + + Rect windowRect = window->GetRect(); + napi_value windowRectObj = GetRectAndConvertToJsValue(env, windowRect); + if (windowRectObj == nullptr) { + WLOGFE("GetWindowRect failed!"); + } + napi_set_named_property(env, objValue, "windowRect", windowRectObj); + + WindowType type = window->GetType(); + if (NATIVE_JS_TO_WINDOW_TYPE_MAP.count(type) != 0) { + napi_set_named_property(env, objValue, "type", CreateJsValue(env, NATIVE_JS_TO_WINDOW_TYPE_MAP.at(type))); + } else { + napi_set_named_property(env, objValue, "type", CreateJsValue(env, type)); + } + napi_set_named_property(env, objValue, "isLayoutFullScreen", CreateJsValue(env, window->IsLayoutFullScreen())); + napi_set_named_property(env, objValue, "isFullScreen", CreateJsValue(env, window->IsFullScreen())); + napi_set_named_property(env, objValue, "touchable", CreateJsValue(env, window->GetTouchable())); + napi_set_named_property(env, objValue, "focusable", CreateJsValue(env, window->GetFocusable())); + napi_set_named_property(env, objValue, "name", CreateJsValue(env, window->GetWindowName())); + napi_set_named_property(env, objValue, "isPrivacyMode", CreateJsValue(env, window->IsPrivacyMode())); + napi_set_named_property(env, objValue, "isKeepScreenOn", CreateJsValue(env, window->IsKeepScreenOn())); + napi_set_named_property(env, objValue, "brightness", CreateJsValue(env, window->GetBrightness())); + napi_set_named_property(env, objValue, "isTransparent", CreateJsValue(env, window->IsTransparent())); + napi_set_named_property(env, objValue, "isRoundCorner", CreateJsValue(env, false)); // empty method + napi_set_named_property(env, objValue, "dimBehindValue", CreateJsValue(env, 0)); + napi_set_named_property(env, objValue, "id", CreateJsValue(env, window->GetWindowId())); + return objValue; +} + bool NapiIsCallable(napi_env env, napi_value value) { bool result = false; diff --git a/interfaces/kits/napi/extension_window/js_extension_window_utils.h b/interfaces/kits/napi/extension_window/js_extension_window_utils.h index 754f765d9..ba7439079 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_utils.h +++ b/interfaces/kits/napi/extension_window/js_extension_window_utils.h @@ -35,6 +35,7 @@ namespace Rosen { napi_value GetRectAndConvertToJsValue(napi_env env, const Rect& rect); napi_value ConvertAvoidAreaToJsValue(napi_env env, const AvoidArea& avoidArea, AvoidAreaType type); napi_value CreateJsExtensionWindowPropertiesObject(napi_env env, sptr& window); + napi_value CreateJsExtensionWindowProperties(napi_env env, sptr& window); bool NapiIsCallable(napi_env env, napi_value value); napi_value NapiGetUndefined(napi_env env); napi_value NapiThrowError(napi_env env, WmErrorCode errCode); diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index ec7db9123..cecc03839 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -197,8 +197,8 @@ public: protected: WMError Connect(); bool IsWindowSessionInvalid() const; - void NotifyAfterUnfocused(bool needNotifyUiContent = true); - void NotifyAfterFocused(); + void NotifyWindowAfterUnfocused(); + void NotifyWindowAfterFocused(); void NotifyAfterActive(); void NotifyAfterInactive(); void NotifyBeforeDestroy(std::string windowName); @@ -282,6 +282,8 @@ private: EnableIfSame>> GetListeners(); void NotifyUIContentFocusStatus(); + void NotifyAfterUnfocused(bool needNotifyUiContent = true); + void NotifyAfterFocused(); void NotifyAfterResumed(); void NotifyAfterPaused(); diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 00197293d..181c684e6 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -221,6 +221,11 @@ void WindowExtensionSessionImpl::NotifyFocusStateEvent(bool focusState) if (uiContent_) { focusState ? uiContent_->Focus() : uiContent_->UnFocus(); } + if (focusState) { + NotifyWindowAfterFocused(); + } else { + NotifyWindowAfterUnfocused(); + } focusState_ = focusState; } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 4681a2c7c..d113202f3 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1526,11 +1526,7 @@ void WindowSessionImpl::NotifyUIContentFocusStatus() void WindowSessionImpl::NotifyAfterFocused() { - { - std::lock_guard lockListener(lifeCycleListenerMutex_); - auto lifecycleListeners = GetListeners(); - CALL_LIFECYCLE_LISTENER(AfterFocused, lifecycleListeners); - } + NotifyWindowAfterFocused(); if (uiContent_ != nullptr) { NotifyUIContentFocusStatus(); } else { @@ -1540,12 +1536,7 @@ void WindowSessionImpl::NotifyAfterFocused() void WindowSessionImpl::NotifyAfterUnfocused(bool needNotifyUiContent) { - { - std::lock_guard lockListener(lifeCycleListenerMutex_); - auto lifecycleListeners = GetListeners(); - // use needNotifyUinContent to separate ui content callbacks - CALL_LIFECYCLE_LISTENER(AfterUnfocused, lifecycleListeners); - } + NotifyWindowAfterUnfocused(); if (needNotifyUiContent) { if (uiContent_ == nullptr) { shouldReNotifyFocus_ = true; @@ -1554,6 +1545,21 @@ void WindowSessionImpl::NotifyAfterUnfocused(bool needNotifyUiContent) } } +void WindowSessionImpl::NotifyWindowAfterFocused() +{ + std::lock_guard lockListener(lifeCycleListenerMutex_); + auto lifecycleListeners = GetListeners(); + CALL_LIFECYCLE_LISTENER(AfterFocused, lifecycleListeners); +} + +void WindowSessionImpl::NotifyWindowAfterUnfocused() +{ + std::lock_guard lockListener(lifeCycleListenerMutex_); + auto lifecycleListeners = GetListeners(); + // use needNotifyUinContent to separate ui content callbacks + CALL_LIFECYCLE_LISTENER(AfterUnfocused, lifecycleListeners); +} + void WindowSessionImpl::NotifyBeforeDestroy(std::string windowName) { std::lock_guard lock(mutex_); -- Gitee From 940d8f94ad7f6a0c4254cb3e97f90eec45b2d8e6 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Wed, 13 Mar 2024 17:59:34 +0800 Subject: [PATCH 026/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 223eb1877..caacd34df 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -122,7 +122,7 @@ static int32_t GetPictureInPictureOptionFromJs(napi_env env, napi_value optionOb napi_get_named_property(env, optionObject, "contentWidth", &widthValue); napi_get_named_property(env, optionObject, "contentHeight", &heightValue); napi_get_named_property(env, optionObject, "componentController", &xComponentControllerValue); - napi_get_named_property(env, optionObject, "controlGroup", &controlGroup); + napi_get_named_property(env, optionObject, "controlGroups", &controlGroup); napi_unwrap(env, contextPtrValue, &contextPtr); ConvertFromJsValue(env, navigationIdValue, navigationId); ConvertFromJsValue(env, templateTypeValue, templateType); -- Gitee From 34daf067a0d452ecee465b1a1111f547f1d68a69 Mon Sep 17 00:00:00 2001 From: zhangyao Date: Wed, 13 Mar 2024 12:38:27 +0000 Subject: [PATCH 027/385] =?UTF-8?q?Description:=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF=20IssueNo:=20https://gitee?= =?UTF-8?q?.com/openharmony/window=5Fwindow=5Fmanager/issues/I98B3G=20Feat?= =?UTF-8?q?ure=20or=20Bugfix:=20Feature=20Binary=20Source:No=20Signed-off-?= =?UTF-8?q?by:=20zhangyao=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/innerkits/dm/dm_common.h | 6 +++--- previewer/include/dm_common.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index f841d3bb2..921e529af 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -63,9 +63,9 @@ enum class PowerStateChangeReason : uint32_t { STATE_CHANGE_REASON_COLLABORATION = 24, STATE_CHANGE_REASON_SWITCH = 25, STATE_CHANGE_REASON_PRE_BRIGHT = 26, - STATE_CHANGE_REASON_PRE_BRIGHT_ATUH_SUCCESS = 27, - STATE_CHANGE_REASON_PRE_BRIGHT_ATUH_FAIL_SCREEN_ON = 28, - STATE_CHANGE_REASON_PRE_BRIGHT_ATUH_FAIL_SCREEN_OFF = 29, + STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_SUCCESS = 27, + STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_ON = 28, + STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF = 29, STATE_CHANGE_REASON_REMOTE = 100, STATE_CHANGE_REASON_UNKNOWN = 1000, }; diff --git a/previewer/include/dm_common.h b/previewer/include/dm_common.h index ec069f418..9a958ff41 100644 --- a/previewer/include/dm_common.h +++ b/previewer/include/dm_common.h @@ -68,9 +68,9 @@ enum class PowerStateChangeReason : uint32_t { STATE_CHANGE_REASON_DOUBLE_CLICK = 23, STATE_CHANGE_REASON_SWITCH = 25, STATE_CHANGE_REASON_PRE_BRIGHT = 26, - STATE_CHANGE_REASON_PRE_BRIGHT_ATUH_SUCCESS = 27, - STATE_CHANGE_REASON_PRE_BRIGHT_ATUH_FAIL_SCREEN_ON = 28, - STATE_CHANGE_REASON_PRE_BRIGHT_ATUH_FAIL_SCREEN_OFF = 29, + STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_SUCCESS = 27, + STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_ON = 28, + STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF = 29, STATE_CHANGE_REASON_REMOTE = 100, STATE_CHANGE_REASON_UNKNOWN = 1000, }; -- Gitee From 69436b8721b58ebda10375ddf0f731752db54824 Mon Sep 17 00:00:00 2001 From: yiicen Date: Thu, 14 Mar 2024 09:45:37 +0800 Subject: [PATCH 028/385] =?UTF-8?q?window=20config=E5=92=8Cdayu=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E8=A7=A3=E8=80=A6=EF=BC=8C=E5=9B=A0BundleCheck?= =?UTF-8?q?=E9=81=97=E7=95=99window=5Fmanager=5Fdayu210=5Fresource=5Fconfi?= =?UTF-8?q?g=20Signed-off-by:=20yiicen=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/config/BUILD.gn | 20 --- .../config/rk3568/display_manager_config.xml | 57 -------- .../config/rk3568/window_manager_config.xml | 121 ----------------- .../config/rk3588/display_manager_config.xml | 57 -------- .../config/rk3588/window_manager_config.xml | 123 ------------------ 5 files changed, 378 deletions(-) delete mode 100644 resources/config/rk3568/display_manager_config.xml delete mode 100644 resources/config/rk3568/window_manager_config.xml delete mode 100644 resources/config/rk3588/display_manager_config.xml delete mode 100644 resources/config/rk3588/window_manager_config.xml diff --git a/resources/config/BUILD.gn b/resources/config/BUILD.gn index 8cdbc5169..1ae5c655b 100755 --- a/resources/config/BUILD.gn +++ b/resources/config/BUILD.gn @@ -12,24 +12,10 @@ # limitations under the License. import("//build/ohos.gni") -declare_args() { - window_manager_dayu200_resource_config = true -} - -declare_args() { - window_manager_dayu210_resource_config = true -} - ohos_prebuilt_etc("window_manager_config") { if (is_emulator) { source = "./other/window_manager_config.xml" install_enable = false - } else if (window_manager_dayu200_resource_config) { - source = "./rk3568/window_manager_config.xml" - install_enable = true - } else if (window_manager_dayu210_resource_config) { - source = "./rk3588/window_manager_config.xml" - install_enable = true } else { source = "./other/window_manager_config.xml" install_enable = false @@ -43,12 +29,6 @@ ohos_prebuilt_etc("display_manager_config") { if (is_emulator) { source = "./other/display_manager_config.xml" install_enable = false - } else if (window_manager_dayu200_resource_config) { - source = "./rk3568/display_manager_config.xml" - install_enable = true - } else if (window_manager_dayu210_resource_config) { - source = "./rk3588/display_manager_config.xml" - install_enable = true } else { source = "./other/display_manager_config.xml" install_enable = false diff --git a/resources/config/rk3568/display_manager_config.xml b/resources/config/rk3568/display_manager_config.xml deleted file mode 100644 index 024dce91a..000000000 --- a/resources/config/rk3568/display_manager_config.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - 240 - - - 0 - - - - - - - - - - 0 0 0 0 - - - - - - - - - - - - - - - - - - - 0 - - - - - - 0 - diff --git a/resources/config/rk3568/window_manager_config.xml b/resources/config/rk3568/window_manager_config.xml deleted file mode 100644 index be58d44ed..000000000 --- a/resources/config/rk3568/window_manager_config.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - floating fullscreen - - - 100 - - - - 50 50 50 - - - - 0.1 0.9 - - 0.5 0.33 0.67 - - 1 - - - - - 350 - - - - - 0.7 0.7 - - 0 0 1 0 - - 0 0 - - 0 - - - - - - - - 150 - - 0.2 0.0 0.2 1.0 - - - - - - - 150 - - 0.2 0.0 0.2 1.0 - - - - - - - - 200 - - - - - 1 - - 0 - - - - - - - - - - off - off - off - - - - 0 - #000000 - 0 - 0 - 0 - - - 0 - #000000 - 0 - 0 - 0 - - - - - diff --git a/resources/config/rk3588/display_manager_config.xml b/resources/config/rk3588/display_manager_config.xml deleted file mode 100644 index 024dce91a..000000000 --- a/resources/config/rk3588/display_manager_config.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - 240 - - - 0 - - - - - - - - - - 0 0 0 0 - - - - - - - - - - - - - - - - - - - 0 - - - - - - 0 - diff --git a/resources/config/rk3588/window_manager_config.xml b/resources/config/rk3588/window_manager_config.xml deleted file mode 100644 index 11710080c..000000000 --- a/resources/config/rk3588/window_manager_config.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - floating fullscreen - - - 100 - - - - 50 50 50 - - - - 0.1 0.9 - - 0.5 0.33 0.67 - - 1 - - - - - 350 - - - - - 0.7 0.7 - - 0 0 1 0 - - 0 0 - - 0 - - - - - - - - 500 - - 0.2 0.0 0.2 1.0 - - - - - - - 300 - - 0.2 0.0 0.2 1.0 - - - - - - - - 200 - - - - - 1 - - 0 - - - - - - - - - - off - off - off - - - - 0 - #000000 - 0 - 0 - 0 - 0 - - - 0 - #000000 - 0 - 0 - 0 - 0 - - - - - -- Gitee From 5f1b548d4b6229cc96200ea91d78c48b6c1ac239 Mon Sep 17 00:00:00 2001 From: shark_00783 Date: Wed, 13 Mar 2024 11:12:40 +0800 Subject: [PATCH 029/385] =?UTF-8?q?UIExtension=E5=88=9B=E5=BB=BA=E5=AD=90?= =?UTF-8?q?=E7=AA=97=E5=9C=BA=E6=99=AF=E9=98=B2=E5=B5=8C=E5=A5=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shark_00783 --- test/common/mock/mock_uicontent.h | 4 ++++ wm/include/window_session_impl.h | 1 + wm/src/window_extension_session_impl.cpp | 1 + wm/src/window_session_impl.cpp | 5 +++++ 4 files changed, 11 insertions(+) diff --git a/test/common/mock/mock_uicontent.h b/test/common/mock/mock_uicontent.h index 23e93230e..02ccda95b 100644 --- a/test/common/mock/mock_uicontent.h +++ b/test/common/mock/mock_uicontent.h @@ -100,6 +100,10 @@ public: MOCK_METHOD1(SubscribeContainerModalButtonsRectChange, void(std::function&& callback)); MOCK_METHOD1(UpdateTransform, void(const OHOS::Rosen::Transform& transform)); + MOCK_METHOD1(SetUIExtensionSubWindow, void(bool isUIExtensionSubWindow)); + MOCK_METHOD1(SetUIExtensionAbilityProcess, void(bool isUIExtensionAbilityProcess)); + MOCK_METHOD0(GetUIExtensionSubWindow, bool()); + MOCK_METHOD0(GetUIExtensionAbilityProcess, bool()); }; } // namespace Ace } // namespace OHOS diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index ec7db9123..cbf601261 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -248,6 +248,7 @@ protected: bool needRemoveWindowInputChannel_ = false; float virtualPixelRatio_ { 1.0f }; bool escKeyEventTriggered_ = false; + static bool isUIExtensionAbility_; private: //Trans between colorGamut and colorSpace diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index a0b38d462..77fb2cd36 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -61,6 +61,7 @@ WMError WindowExtensionSessionImpl::Create(const std::shared_ptr>> WindowSession std::shared_mutex WindowSessionImpl::windowSessionMutex_; std::map>> WindowSessionImpl::subWindowSessionMap_; std::map>> WindowSessionImpl::windowStatusChangeListeners_; +bool WindowSessionImpl::isUIExtensionAbility_ = false; #define CALL_LIFECYCLE_LISTENER(windowLifecycleCb, listeners) \ do { \ @@ -706,6 +707,10 @@ WMError WindowSessionImpl::SetUIContentInner(const std::string& contentInfo, nap default: case WindowSetUIContentType::DEFAULT: aceRet = uiContent->Initialize(this, contentInfo, storage); + if (isUIExtensionAbility_ && WindowHelper::IsExtensionSubWindow(GetType())) { + uiContent->SetUIExtensionSubWindow(true); + uiContent->SetUIExtensionAbilityProcess(true); + } break; case WindowSetUIContentType::DISTRIBUTE: aceRet = uiContent->Restore(this, contentInfo, storage); -- Gitee From e5547128b710cae9581f2209b943a76ddd067d98 Mon Sep 17 00:00:00 2001 From: shark_00783 Date: Fri, 15 Mar 2024 09:22:55 +0800 Subject: [PATCH 030/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=AD=90=E7=AA=97=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shark_00783 --- wm/src/window_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 9fde7c989..2d54d13ad 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -707,7 +707,7 @@ WMError WindowSessionImpl::SetUIContentInner(const std::string& contentInfo, nap default: case WindowSetUIContentType::DEFAULT: aceRet = uiContent->Initialize(this, contentInfo, storage); - if (isUIExtensionAbility_ && WindowHelper::IsExtensionSubWindow(GetType())) { + if (isUIExtensionAbility_ && property_->GetExtensionFlag() == true) { uiContent->SetUIExtensionSubWindow(true); uiContent->SetUIExtensionAbilityProcess(true); } -- Gitee From c4890c4d9d00485bd044a7b4914903ebaff43568 Mon Sep 17 00:00:00 2001 From: cloud_nine Date: Wed, 13 Mar 2024 10:50:56 +0800 Subject: [PATCH 031/385] =?UTF-8?q?=E6=94=AF=E6=8C=81DUMP=E8=BE=93?= =?UTF-8?q?=E5=87=BAScreen=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenyunjiu --- window_scene/session_manager/BUILD.gn | 1 + .../include/screen_session_dumper.h | 53 +++++ .../src/screen_session_dumper.cpp | 195 ++++++++++++++++++ .../src/screen_session_manager.cpp | 15 +- window_scene/test/unittest/BUILD.gn | 13 ++ .../unittest/screen_session_dumper_test.cpp | 123 +++++++++++ 6 files changed, 391 insertions(+), 9 deletions(-) create mode 100644 window_scene/session_manager/include/screen_session_dumper.h create mode 100644 window_scene/session_manager/src/screen_session_dumper.cpp create mode 100644 window_scene/test/unittest/screen_session_dumper_test.cpp diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index d453bf7aa..349858a50 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -202,6 +202,7 @@ ohos_shared_library("screen_session_manager") { "src/screen_rotation_property.cpp", "src/screen_scene_config.cpp", "src/screen_sensor_connector.cpp", + "src/screen_session_dumper.cpp", "src/screen_session_manager.cpp", "src/screen_setting_helper.cpp", "src/session_display_power_controller.cpp", diff --git a/window_scene/session_manager/include/screen_session_dumper.h b/window_scene/session_manager/include/screen_session_dumper.h new file mode 100644 index 000000000..c60ac784e --- /dev/null +++ b/window_scene/session_manager/include/screen_session_dumper.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ROSEN_SCREEN_SESSION_DUMPER_H +#define OHOS_ROSEN_SCREEN_SESSION_DUMPER_H + +#include +#include +#include +#include +#include + +#include "dm_common.h" +#include "window_manager_hilog.h" +#include "screen_session_manager.h" + +namespace OHOS { +namespace Rosen { + +class ScreenSessionDumper : public RefBase { +public: + ScreenSessionDumper(int fd, const std::vector& args); + ~ScreenSessionDumper() = default; + + void ExcuteDumpCmd(); + +private: + void ShowHelpInfo(); + void ShowAllScreenInfo(); + void OutputDumpInfo(); + void DumpScreenInfoById(ScreenId id); + void DumpScreenPropertyById(ScreenId id); + +private: + int fd_; + std::vector params_; + std::string dumpInfo_; +}; +} // Rosen +} // OHOS +#endif // OHOS_ROSEN_SCREEN_SESSION_DUMPER_H \ No newline at end of file diff --git a/window_scene/session_manager/src/screen_session_dumper.cpp b/window_scene/session_manager/src/screen_session_dumper.cpp new file mode 100644 index 000000000..bbe208691 --- /dev/null +++ b/window_scene/session_manager/src/screen_session_dumper.cpp @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "screen_session_dumper.h" + +#include + +#include "unique_fd.h" +#include "session_permission.h" + +namespace OHOS { +namespace Rosen { +namespace { +constexpr int LINE_WIDTH = 25; +constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenSessionDumper" }; +} + +ScreenSessionDumper::ScreenSessionDumper(int fd, const std::vector& args) + : fd_(fd) +{ + std::wstring_convert, char16_t> cv; + std::string info; + for (auto& u16str: args) { + std::string arg = cv.to_bytes(u16str); + params_.emplace_back(arg); + info += arg; + } + WLOGFI("input args: [%{public}s]", info.c_str()); +} + +void ScreenSessionDumper::OutputDumpInfo() +{ + if (fd_ < 0) { + WLOGFE("invalid fd: %{public}d", fd_); + return; + } + + static_cast(signal(SIGPIPE, SIG_IGN)); // ignore SIGPIPE crash + UniqueFd ufd = UniqueFd(fd_); // auto free + int ret = dprintf(ufd.Get(), "%s\n", dumpInfo_.c_str()); + if (ret < 0) { + WLOGFE("dprintf error. ret: %{public}d", ret); + return; + } + dumpInfo_.clear(); +} + + +void ScreenSessionDumper::ExcuteDumpCmd() +{ + const std::string ARG_DUMP_HELP = "-h"; + const std::string ARG_DUMP_ALL = "-a"; + if (params_.empty() || params_[0] == ARG_DUMP_HELP) { //help command + ShowHelpInfo(); + } + + if (!(SessionPermission::IsSACalling() || SessionPermission::IsStartByHdcd())) { + WLOGFE("dump permission denied!"); + return; + } + if (params_[0] == ARG_DUMP_ALL) { // dump all info command + ShowAllScreenInfo(); + } + OutputDumpInfo(); +} + +void ScreenSessionDumper::ShowHelpInfo() +{ + dumpInfo_.append("Usage:\n") + .append(" -h ") + .append("|help text for the tool\n") + .append(" -a ") + .append("|dump all screen information in the system\n"); +} + +void ScreenSessionDumper::ShowAllScreenInfo() +{ + std::vector screenIds = ScreenSessionManager::GetInstance().GetAllScreenIds(); + for (auto screenId : screenIds) { + std::ostringstream oss; + oss << "---------------- Screen ID: " << screenId << " ----------------" << std::endl; + dumpInfo_.append(oss.str()); + DumpScreenInfoById(screenId); + DumpScreenPropertyById(screenId); + } +} + +void ScreenSessionDumper::DumpScreenInfoById(ScreenId id) +{ + std::ostringstream oss; + oss << "[SCREEN INFO]" << std::endl; + auto screenInfo = ScreenSessionManager::GetInstance().GetScreenInfoById(id); + if (screenInfo == nullptr) { + WLOGFE("screenInfo nullptr. screen id: %{public}" PRIu64"", id); + return; + } + auto modes = screenInfo->GetModes(); + auto modeId = screenInfo->GetModeId(); + oss << std::left << std::setw(LINE_WIDTH) << "Name: " + << screenInfo->GetName() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "VirtualWidth: " + << screenInfo->GetVirtualWidth() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "VirtualHeight: " + << screenInfo->GetVirtualHeight() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "LastParentId: " + << screenInfo->GetLastParentId() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "ParentId: " + << screenInfo->GetParentId() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "IsScreenGroup: " + << screenInfo->GetIsScreenGroup() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "VirtualPixelRatio: " + << screenInfo->GetVirtualPixelRatio() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "Rotation: " + << static_cast(screenInfo->GetRotation()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "Orientation: " + << static_cast(screenInfo->GetOrientation()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "SourceMode: " + << static_cast(screenInfo->GetSourceMode()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "ScreenType: " + << static_cast(screenInfo->GetType()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "ModeId: " << modeId << std::endl; + if (modes.size() > modeId) { + oss << std::left << std::setw(LINE_WIDTH) << "modes: " + << modes[modeId]->id_ << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "modes: " + << modes[modeId]->width_ << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "modes: " + << modes[modeId]->height_ << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "modes: " + << modes[modeId]->refreshRate_ << std::endl; + } else { + WLOGFW("invalid modes size: %{public}u ", static_cast(modes.size())); + } + dumpInfo_.append(oss.str()); +} + +void ScreenSessionDumper::DumpScreenPropertyById(ScreenId id) +{ + std::ostringstream oss; + oss << "[SCREEN PROPERTY]" << std::endl; + ScreenProperty screenProperty = ScreenSessionManager::GetInstance().GetScreenProperty(id); + + oss << std::left << std::setw(LINE_WIDTH) << "Rotation: " << screenProperty.GetRotation() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "Density: " << screenProperty.GetDensity() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "DensityInCurResolution: " + << screenProperty.GetDensityInCurResolution() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "PhyWidth: " << screenProperty.GetPhyWidth() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "PhyHeight: " << screenProperty.GetPhyHeight() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "RefreshRate: " << screenProperty.GetRefreshRate() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "VirtualPixelRatio: " + << screenProperty.GetVirtualPixelRatio() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "ScreenRotation: " + << static_cast(screenProperty.GetRotation()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "Orientation: " + << static_cast(screenProperty.GetOrientation()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "DisplayOrientation: " + << static_cast(screenProperty.GetDisplayOrientation()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "GetScreenType: " + << static_cast(screenProperty.GetScreenType()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "ReqOrientation: " + << static_cast(screenProperty.GetScreenRequestedOrientation()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "DPI: " << screenProperty.GetXDpi() + << ", " << screenProperty.GetYDpi() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "Offset: " << screenProperty.GetOffsetX() + << ", " << screenProperty.GetOffsetY() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "Bounds: " + << screenProperty.GetBounds().rect_.GetLeft() << ", " + << screenProperty.GetBounds().rect_.GetTop() << ", " + << screenProperty.GetBounds().rect_.GetWidth() << ", " + << screenProperty.GetBounds().rect_.GetHeight() << ", " << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "PhyBounds: " + << screenProperty.GetPhyBounds().rect_.GetLeft() << ", " + << screenProperty.GetPhyBounds().rect_.GetTop() << ", " + << screenProperty.GetPhyBounds().rect_.GetWidth() << ", " + << screenProperty.GetPhyBounds().rect_.GetHeight() << ", " << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "AvailableArea " + << screenProperty.GetAvailableArea().posX_ << ", " + << screenProperty.GetAvailableArea().posY_ << ", " + << screenProperty.GetAvailableArea().width_ << ", " + << screenProperty.GetAvailableArea().height_ << ", " << std::endl; + dumpInfo_.append(oss.str()); +} +} // Rosen +} // OHOS \ No newline at end of file diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index b92bff948..d5769088f 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -42,6 +42,7 @@ #include "screen_rotation_property.h" #include "screen_sensor_connector.h" #include "screen_setting_helper.h" +#include "screen_session_dumper.h" #include "mock_session_manager_service.h" namespace OHOS::Rosen { @@ -3289,12 +3290,13 @@ static std::string Str16ToStr8(const std::u16string& str) int ScreenSessionManager::Dump(int fd, const std::vector& args) { WLOGFI("Dump begin"); - if (fd < 0) { + sptr dumper = new ScreenSessionDumper(fd, args); + if (dumper == nullptr) { + WLOGFE("dumper is nullptr"); return -1; } - (void) signal(SIGPIPE, SIG_IGN); // ignore SIGPIPE crash - UniqueFd ufd = UniqueFd(fd); // auto close - fd = ufd.Get(); + dumper->ExcuteDumpCmd(); + std::vector params; for (auto& arg : args) { params.emplace_back(Str16ToStr8(arg)); @@ -3325,11 +3327,6 @@ int ScreenSessionManager::Dump(int fd, const std::vector& args) ShowIllegalArgsInfo(dumpInfo); } } - int ret = dprintf(fd, "%s\n", dumpInfo.c_str()); - if (ret < 0) { - WLOGFE("dprintf error"); - return -1; // WMError::WM_ERROR_INVALID_OPERATION; - } WLOGI("dump end"); return 0; } diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index 326a754ec..e5864917e 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -500,6 +500,19 @@ ohos_unittest("ws_screen_rotation_property_test") { } } +ohos_unittest("ws_screen_session_dumper_test") { + module_out_path = module_out_path + + sources = [ "ws_screen_session_dumper_test.cpp" ] + + deps = [ ":ws_unittest_common" ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + ] +} + ohos_unittest("ws_move_drag_controller_test") { module_out_path = module_out_path diff --git a/window_scene/test/unittest/screen_session_dumper_test.cpp b/window_scene/test/unittest/screen_session_dumper_test.cpp new file mode 100644 index 000000000..c6daf4c2d --- /dev/null +++ b/window_scene/test/unittest/screen_session_dumper_test.cpp @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "screen_session_dumper.h" +#include "screen_session_manager.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +class ScreenSessionDumperTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void ScreenSessionDumperTest::SetUpTestCase() +{ +} + +void ScreenSessionDumperTest::TearDownTestCase() +{ +} + +void ScreenSessionDumperTest::SetUp() +{ +} + +void ScreenSessionDumperTest::TearDown() +{ +} + +namespace { +/** + * @tc.name: Dump01 + * @tc.desc: Dump + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionDumperTest, Dump01, Function | SmallTest | Level1) +{ + int fd = 1; + std::vector args; + sptr dumper = new ScreenSessionDumper(fd, args); + ASSERT_NE(nullptr, dumper); +} + +/** + * @tc.name: Dump02 + * @tc.desc: Dump input for -h + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionDumperTest, Dump02, Function | SmallTest | Level1) +{ + int fd = 1; + std::vector args = {u"-h"}; + sptr dumper = new ScreenSessionDumper(fd, args); + dumper->ExcuteDumpCmd(); + ASSERT_TRUE(true); +} + +/** + * @tc.name: Dump03 + * @tc.desc: Dump input for -a + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionDumperTest, Dump03, Function | SmallTest | Level1) +{ + int fd = 1; + std::vector args = {u"-a"}; + sptr dumper = new ScreenSessionDumper(fd, args); + dumper->ExcuteDumpCmd(); + ASSERT_TRUE(true); +} + +/** + * @tc.name: Dump04 + * @tc.desc: Dump input for abnormal + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionDumperTest, Dump04, Function | SmallTest | Level1) +{ + int fd = 1; + std::vector args = {u"-abnormal"}; + sptr dumper = new ScreenSessionDumper(fd, args); + dumper->ExcuteDumpCmd(); + ASSERT_TRUE(true); +} + +/** + * @tc.name: Dump05 + * @tc.desc: Dump fd less 0 + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionDumperTest, Dump05, Function | SmallTest | Level1) +{ + int fd = -1; + std::vector args = {u"-h"}; + sptr dumper = new ScreenSessionDumper(fd, args); + dumper->ExcuteDumpCmd(); + ASSERT_TRUE(true); +} + +} + +} +} \ No newline at end of file -- Gitee From dc7c50b9b07031a53a4669282aa34b4546d155d5 Mon Sep 17 00:00:00 2001 From: xuyangyang Date: Fri, 15 Mar 2024 11:55:08 +0800 Subject: [PATCH 032/385] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=9B=B8=E5=85=B3=E7=BB=B4=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuyangyang Change-Id: I9a58d073dde2a77334cb75648a31e64574110edc --- wm/src/window_impl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index e5851bcbc..f5ce90fc4 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -946,6 +946,7 @@ void WindowImpl::MapFloatingWindowToAppIfNeeded() return; } + WLOGFI("MapFloatingWindowToAppIfNeeded: enter this"); for (const auto& winPair : windowMap_) { auto win = winPair.second.second; if (win->GetType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && @@ -1301,6 +1302,7 @@ void WindowImpl::DestroyDialogWindow() void WindowImpl::DestroyFloatingWindow() { // remove from appFloatingWindowMap_ + WLOGFI("DestroyFloatingWindow:remove from appFloatingWindowMap_"); for (auto& floatingWindows: appFloatingWindowMap_) { for (auto iter = floatingWindows.second.begin(); iter != floatingWindows.second.end(); ++iter) { if ((*iter) == nullptr) { @@ -1314,6 +1316,7 @@ void WindowImpl::DestroyFloatingWindow() } // Destroy app floating window if exist + WLOGFI("DestroyFloatingWindow:Destroy app floating window if exist"); if (appFloatingWindowMap_.count(GetWindowId()) > 0) { auto& floatingWindows = appFloatingWindowMap_.at(GetWindowId()); for (auto iter = floatingWindows.begin(); iter != floatingWindows.end(); iter = floatingWindows.begin()) { -- Gitee From df57faac84942a0ad8f3124c5e48e21d02d9dabf Mon Sep 17 00:00:00 2001 From: chengz12138 Date: Fri, 15 Mar 2024 11:57:37 +0800 Subject: [PATCH 033/385] systenwindoe support subwindow and subwindow create subwindow Signed-off-by: chengz12138 --- .../scene_session_manager/js_scene_utils.h | 6 ++ .../src/scene_session_manager.cpp | 6 +- wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 55 ++++++++++++++----- 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h index 6846c1fb2..94e2eb701 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h @@ -59,6 +59,8 @@ enum class JsSessionType : uint32_t { TYPE_PIP, TYPE_THEME_EDITOR, TYPE_NAVIGATION_INDICATOR, + TYPE_SEARCHING_BAR, + TYPE_SYSTEM_SUB_WINDOW, }; // should same with bundlemanager ability info @@ -109,6 +111,8 @@ const std::map WINDOW_TO_JS_SESSION_TYPE_MAP { { WindowType::WINDOW_TYPE_PIP, JsSessionType::TYPE_PIP }, { WindowType::WINDOW_TYPE_THEME_EDITOR, JsSessionType::TYPE_THEME_EDITOR }, { WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, JsSessionType::TYPE_NAVIGATION_INDICATOR }, + { WindowType::WINDOW_TYPE_SEARCHING_BAR, JsSessionType::TYPE_SEARCHING_BAR }, + { WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW, JsSessionType::TYPE_SYSTEM_SUB_WINDOW }, }; const std::map JS_SESSION_TO_WINDOW_TYPE_MAP { @@ -142,6 +146,8 @@ const std::map JS_SESSION_TO_WINDOW_TYPE_MAP { { JsSessionType::TYPE_PIP, WindowType::WINDOW_TYPE_PIP, }, { JsSessionType::TYPE_THEME_EDITOR, WindowType::WINDOW_TYPE_THEME_EDITOR }, { JsSessionType::TYPE_NAVIGATION_INDICATOR, WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR }, + { JsSessionType::TYPE_SEARCHING_BAR, WindowType::WINDOW_TYPE_SEARCHING_BAR }, + { JsSessionType::TYPE_SYSTEM_SUB_WINDOW, WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW }, }; const std::map WINDOW_ORIENTATION_TO_JS_SESSION_MAP { diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 4ffe264ad..31c05b276 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2059,7 +2059,11 @@ void SceneSessionManager::NotifyCreateSpecificSession(sptr newSess } } if (createSystemSessionFunc_ && type != WindowType::WINDOW_TYPE_DIALOG) { - createSystemSessionFunc_(newSession); + if (WindowHelper::IsSystemSubWindow(type)) { + NotifyCreateSubSession(property->GetParentPersistentId(), newSession); + } else { + createSystemSessionFunc_(newSession); + } TLOGD(WmsLogTag::WMS_LIFE, "Create system session, id:%{public}d, type: %{public}d", newSession->GetPersistentId(), type); } else { diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index ea551b549..00ff27518 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -145,6 +145,7 @@ protected: WMError RecoverAndConnectSpecificSession(); WMError RecoverAndReconnectSceneSession(); sptr FindParentSessionByParentId(uint32_t parentId); + bool isSessionMainWindow(uint32_t parentId); sptr FindMainWindowWithContext(); void UpdateSubWindowStateAndNotify(int32_t parentPersistentId, const WindowState& newState); void LimitCameraFloatWindowMininumSize(uint32_t& width, uint32_t& height); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 659a8c492..d50250cb4 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -91,7 +91,8 @@ bool WindowSceneSessionImpl::IsValidSystemWindowType(const WindowType& type) type == WindowType::WINDOW_TYPE_SEARCHING_BAR || type == WindowType::WINDOW_TYPE_PANEL || type == WindowType::WINDOW_TYPE_VOLUME_OVERLAY || type == WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR || type == WindowType::WINDOW_TYPE_SYSTEM_TOAST || type == WindowType::WINDOW_TYPE_SYSTEM_FLOAT || - type == WindowType::WINDOW_TYPE_PIP || type == WindowType::WINDOW_TYPE_GLOBAL_SEARCH)) { + type == WindowType::WINDOW_TYPE_PIP || type == WindowType::WINDOW_TYPE_GLOBAL_SEARCH || + type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW)) { TLOGI(WmsLogTag::WMS_SYSTEM, "Invalid type: %{public}u", type); return false; } @@ -101,20 +102,39 @@ bool WindowSceneSessionImpl::IsValidSystemWindowType(const WindowType& type) sptr WindowSceneSessionImpl::FindParentSessionByParentId(uint32_t parentId) { - std::unique_lock lock(windowSessionMutex_); + std::shared_lock lock(windowSessionMutex_); for (const auto& item : windowSessionMap_) { if (item.second.second && item.second.second->GetProperty() && - item.second.second->GetWindowId() == parentId && - WindowHelper::IsMainWindow(item.second.second->GetType())) { - WLOGFD("Find parent, [parentName: %{public}s, parentId:%{public}u, selfPersistentId: %{public}d]", - item.second.second->GetProperty()->GetWindowName().c_str(), parentId, GetProperty()->GetPersistentId()); - return item.second.second; + item.second.second->GetWindowId() == parentId) { + if (WindowHelper::IsMainWindow(item.second.second->GetType()) || + WindowHelper::IsSystemWindow(item.second.second->GetType())) { + WLOGFD("Find parent, [parentName: %{public}s, parentId:%{public}u, selfPersistentId: %{public}d]", + item.second.second->GetProperty()->GetWindowName().c_str(), parentId, GetProperty()->GetPersistentId()); + return item.second.second; + } else if (WindowHelper::IsSubWindow(item.second.second->GetType()) { + auto granParendId = item.second.second->GetParendId(); + if (isSessionMainWindow(granParendId)) { + return item.second.second; + } + } } } WLOGFD("[WMSCom] Can not find parent window, id: %{public}d", parentId); return nullptr; } +bool WindowSceneSessionImpl::isSessionMainWindow(uint32_t parentId) { + std::shared_lock lock(windowSessionMutex_); + for (const auto& item : windowSessionMap_) { + if (item.second.second && item.second.second->GetProperty() && + item.second.second->GetWindowId() == parentId && + WindowHelper::IsMainWindow(item.second.second->GetType())) { + return true; + } + } + return false; +} + sptr WindowSceneSessionImpl::FindMainWindowWithContext() { std::unique_lock lock(windowSessionMutex_); @@ -178,6 +198,20 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() property_->SetParentPersistentId(mainWindow->GetPersistentId()); TLOGI(WmsLogTag::WMS_DIALOG, "Set parentId, parentId:%{public}d", mainWindow->GetPersistentId()); } + } else if (WindowHelper::IsSystemSubWindow(type)) { + auto parentSession = FindParentSessionByParentId(property_->GetParentId()); + if (parentSession == nullptr || parentSession->GetHostSession() == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "parent of system sub window, name: %{public}s, type: %{public}d", + property_->GetWindowName().c_str(), type); + return WMError::WM_ERROR_NULLPTR; + } + if (WindowHelper::IsSystemSubWindow(parentSession->GetType())) { + TLOGE(WmsLogTag::WMS_LIFE, "parent of system sub window is system sub window, name: %{public}s, type: %{public}d", + property_->GetWindowName().c_str(), type); + return WMError::WM_ERROR_INVALID_TYPE; + } + // set parent persistentId + property_->SetParentPersistentId(parentSession->GetPersistentId()); } PreProcessCreate(); SingletonContainer::Get().CreateAndConnectSpecificSession(iSessionStage, eventChannel, @@ -350,11 +384,6 @@ WMError WindowSceneSessionImpl::Create(const std::shared_ptrOnSessionEvent(SessionEvent::EVENT_CLOSE); return WMError::WM_OK; } - } else if (WindowHelper::IsSubWindow(GetType())) { + } else if (WindowHelper::IsSubWindow(GetType()) || WindowHelper::IsSystemSubWindow(GetType()) { WLOGFI("WindowSceneSessionImpl::Close subwindow"); return Destroy(true); } -- Gitee From 0eec5fc6558b164d90ec5c332301c9ee4200238f Mon Sep 17 00:00:00 2001 From: shark_00783 Date: Fri, 15 Mar 2024 11:58:05 +0800 Subject: [PATCH 034/385] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shark_00783 --- wm/src/window_session_impl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 2d54d13ad..be778ad26 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -730,6 +730,9 @@ WMError WindowSessionImpl::SetUIContentInner(const std::string& contentInfo, nap uiContent_ = std::move(uiContent); } + WLOGFI("UIContent Initialize, isUIExtensionSubWindow:%{public}u, isUIExtensionAbilityProcess:%{public}u", + static_cast(uiContent_->GetUIExtensionSubWindow()), static_cast(uiContent_->GetUIExtensionAbilityProcess())); + if (WindowHelper::IsSubWindow(GetType()) && IsDecorEnable()) { SetAPPWindowLabel(subWindowTitle_); } -- Gitee From 8036f0c844ea179c0c2f96f04ab1bacd6f72bf54 Mon Sep 17 00:00:00 2001 From: shark_00783 Date: Fri, 15 Mar 2024 14:21:14 +0800 Subject: [PATCH 035/385] =?UTF-8?q?=E4=BF=AE=E8=AF=A5=E8=B5=8B=E5=80=BC?= =?UTF-8?q?=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shark_00783 --- wm/src/window_session_impl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index be778ad26..a11f96a82 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -705,12 +705,12 @@ WMError WindowSessionImpl::SetUIContentInner(const std::string& contentInfo, nap OHOS::Ace::UIContentErrorCode aceRet = OHOS::Ace::UIContentErrorCode::NO_ERRORS; switch (type) { default: - case WindowSetUIContentType::DEFAULT: - aceRet = uiContent->Initialize(this, contentInfo, storage); + case WindowSetUIContentType::DEFAULT: if (isUIExtensionAbility_ && property_->GetExtensionFlag() == true) { uiContent->SetUIExtensionSubWindow(true); uiContent->SetUIExtensionAbilityProcess(true); } + aceRet = uiContent->Initialize(this, contentInfo, storage); break; case WindowSetUIContentType::DISTRIBUTE: aceRet = uiContent->Restore(this, contentInfo, storage); @@ -730,8 +730,8 @@ WMError WindowSessionImpl::SetUIContentInner(const std::string& contentInfo, nap uiContent_ = std::move(uiContent); } - WLOGFI("UIContent Initialize, isUIExtensionSubWindow:%{public}u, isUIExtensionAbilityProcess:%{public}u", - static_cast(uiContent_->GetUIExtensionSubWindow()), static_cast(uiContent_->GetUIExtensionAbilityProcess())); + WLOGFI("UIContent Initialize, isUIExtensionSubWindow:%{public}d, isUIExtensionAbilityProcess:%{public}d", + uiContent_->IsUIExtensionSubWindow(), uiContent_->IsUIExtensionAbilityProcess()); if (WindowHelper::IsSubWindow(GetType()) && IsDecorEnable()) { SetAPPWindowLabel(subWindowTitle_); -- Gitee From d84f97b320c13e693eb73e67eca0979becec53e6 Mon Sep 17 00:00:00 2001 From: x00838529 Date: Fri, 15 Mar 2024 15:10:58 +0800 Subject: [PATCH 036/385] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dscb=E4=B8=8E=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=90=8C=E6=97=B6=E6=AD=BB=E4=BA=A1=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=87=BA=E7=8E=B0sys=5FFREEZE=EF=BC=8C=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=8B=89=E8=B5=B7=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: x00838529 --- .../src/scene_session_manager.cpp | 52 +++++++++++++------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 4ffe264ad..ed0007cf9 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -487,27 +487,45 @@ void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector& WLOGFI("[WMSRecover] Number of persistentIds recovered = %{public}zu. CurrentUserId = " "%{public}d", recoveredPersistentIds.size(), currentUserId_); - std::vector abilitySessionInfos; - for (auto i = 0; i < static_cast(recoveredPersistentIds.size()); i++) { - std::shared_lock lock(sceneSessionMapMutex_); - auto search = sceneSessionMap_.find(recoveredPersistentIds.at(i)); - if (search == sceneSessionMap_.end() || search->second == nullptr) { - continue; + auto task = [this, recoveredPersistentIds]() { + std::list abilitySessionInfos; + { + std::shared_lock lock(sceneSessionMapMutex_); + for (auto i = 0; i < static_cast(recoveredPersistentIds.size()); i++) { + auto search = sceneSessionMap_.find(recoveredPersistentIds.at(i)); + if (search == sceneSessionMap_.end() || search->second == nullptr) { + continue; + } + WLOGFD("[WMSRecover] recovered persistentId = %{public}d", search->first); + auto sceneSession = search->second; + const auto& abilitySessionInfo = SetAbilitySessionInfo(sceneSession); + if (!abilitySessionInfo) { + WLOGFW("[WMSRecover] abilitySessionInfo is null"); + return; + } + abilitySessionInfos.emplace_back(*abilitySessionInfo); + } } - WLOGFD("[WMSRecover] recovered persistentId = %{public}d", search->first); - auto sceneSession = search->second; - const auto& abilitySessionInfo = SetAbilitySessionInfo(sceneSession); - if (!abilitySessionInfo) { - WLOGFW("[WMSRecover] abilitySessionInfo is null"); - return; + std::vector unrecoverableSessionIds; + AAFwk::AbilityManagerClient::GetInstance()->UpdateSessionInfoBySCB( + abilitySessionInfos, currentUserId_, unrecoverableSessionIds); + WLOGFI("[WMSRecover] Number of unrecoverableSessionIds = %{public}zu", unrecoverableSessionIds.size()); + { + std::shared_lock lock(sceneSessionMapMutex_); + for (auto i = 0; i < static_cast(unrecoverableSessionIds.size()); i++) { + auto search = sceneSessionMap_.find(unrecoverableSessionIds.at(i)); + if (search == sceneSessionMap_.end() || search->second == nullptr) { + WLOGFW("[WMSRecover]There is no session corresponding to sessionId=%{public}d ", search->first); + continue; + } + WLOGFI("[WMSRecover] unrecoverable sessionId=%{public}d", search->first); + auto sceneSession = search->second; + const auto& scnSessionInfo = SetAbilitySessionInfo(sceneSession); + sceneSession->NotifySessionException(scnSessionInfo, false); + } } - abilitySessionInfos.emplace_back(*abilitySessionInfo); } - auto task = [abilitySessionInfos]() { - AAFwk::AbilityManagerClient::GetInstance()->UpdateSessionInfoBySCB( - abilitySessionInfos, SceneSessionManager::GetInstance().GetCurrentUserId()); - }; return taskScheduler_->PostAsyncTask(task, "UpdateSessionInfoBySCB"); } -- Gitee From fa7edb63e1e7d962cfa0b170987793cea5bc3372 Mon Sep 17 00:00:00 2001 From: shark_00783 Date: Fri, 15 Mar 2024 15:20:03 +0800 Subject: [PATCH 037/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9mock=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shark_00783 --- test/common/mock/mock_uicontent.h | 4 ++-- wm/src/window_session_impl.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/common/mock/mock_uicontent.h b/test/common/mock/mock_uicontent.h index 02ccda95b..d307ebd1b 100644 --- a/test/common/mock/mock_uicontent.h +++ b/test/common/mock/mock_uicontent.h @@ -102,8 +102,8 @@ public: MOCK_METHOD1(UpdateTransform, void(const OHOS::Rosen::Transform& transform)); MOCK_METHOD1(SetUIExtensionSubWindow, void(bool isUIExtensionSubWindow)); MOCK_METHOD1(SetUIExtensionAbilityProcess, void(bool isUIExtensionAbilityProcess)); - MOCK_METHOD0(GetUIExtensionSubWindow, bool()); - MOCK_METHOD0(GetUIExtensionAbilityProcess, bool()); + MOCK_METHOD0(IsUIExtensionSubWindow, bool()); + MOCK_METHOD0(IsUIExtensionAbilityProcess, bool()); }; } // namespace Ace } // namespace OHOS diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index a11f96a82..a442d00fa 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -705,7 +705,7 @@ WMError WindowSessionImpl::SetUIContentInner(const std::string& contentInfo, nap OHOS::Ace::UIContentErrorCode aceRet = OHOS::Ace::UIContentErrorCode::NO_ERRORS; switch (type) { default: - case WindowSetUIContentType::DEFAULT: + case WindowSetUIContentType::DEFAULT: if (isUIExtensionAbility_ && property_->GetExtensionFlag() == true) { uiContent->SetUIExtensionSubWindow(true); uiContent->SetUIExtensionAbilityProcess(true); -- Gitee From 2b1c8c4f00b7337d0c1da49bfcd546a2402abc22 Mon Sep 17 00:00:00 2001 From: x00838529 Date: Fri, 15 Mar 2024 15:52:47 +0800 Subject: [PATCH 038/385] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dscb=E4=B8=8E=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=90=8C=E6=97=B6=E6=AD=BB=E4=BA=A1=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=87=BA=E7=8E=B0sys=5FFREEZE=EF=BC=8C=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=8B=89=E8=B5=B7=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: x00838529 --- .../src/scene_session_manager.cpp | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index ed0007cf9..99d15fc22 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -490,40 +490,36 @@ void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector& auto task = [this, recoveredPersistentIds]() { std::list abilitySessionInfos; - { - std::shared_lock lock(sceneSessionMapMutex_); - for (auto i = 0; i < static_cast(recoveredPersistentIds.size()); i++) { - auto search = sceneSessionMap_.find(recoveredPersistentIds.at(i)); - if (search == sceneSessionMap_.end() || search->second == nullptr) { - continue; - } - WLOGFD("[WMSRecover] recovered persistentId = %{public}d", search->first); - auto sceneSession = search->second; - const auto& abilitySessionInfo = SetAbilitySessionInfo(sceneSession); - if (!abilitySessionInfo) { - WLOGFW("[WMSRecover] abilitySessionInfo is null"); - return; - } - abilitySessionInfos.emplace_back(*abilitySessionInfo); + for (const auto& persistentId : recoveredPersistentIds) { + auto sceneSession = GetSceneSession(persistentId); + if (sceneSession == nullptr) { + continue; + } + WLOGFD("[WMSRecover] recovered persistentId = %{public}d", persistentId); + const auto& abilitySessionInfo = SetAbilitySessionInfo(sceneSession); + if (!abilitySessionInfo) { + WLOGFW("[WMSRecover] abilitySessionInfo is null"); + continue; } + abilitySessionInfos.emplace_back(*abilitySessionInfo); } std::vector unrecoverableSessionIds; AAFwk::AbilityManagerClient::GetInstance()->UpdateSessionInfoBySCB( abilitySessionInfos, currentUserId_, unrecoverableSessionIds); WLOGFI("[WMSRecover] Number of unrecoverableSessionIds = %{public}zu", unrecoverableSessionIds.size()); - { - std::shared_lock lock(sceneSessionMapMutex_); - for (auto i = 0; i < static_cast(unrecoverableSessionIds.size()); i++) { - auto search = sceneSessionMap_.find(unrecoverableSessionIds.at(i)); - if (search == sceneSessionMap_.end() || search->second == nullptr) { - WLOGFW("[WMSRecover]There is no session corresponding to sessionId=%{public}d ", search->first); - continue; - } - WLOGFI("[WMSRecover] unrecoverable sessionId=%{public}d", search->first); - auto sceneSession = search->second; - const auto& scnSessionInfo = SetAbilitySessionInfo(sceneSession); - sceneSession->NotifySessionException(scnSessionInfo, false); + for (const auto& sessionId : unrecoverableSessionIds) { + auto sceneSession = GetSceneSession(sessionId); + if (sceneSession == nullptr) { + WLOGFW("[WMSRecover]There is no session corresponding to sessionId = %{public}d ", sessionId); + continue; + } + WLOGFI("[WMSRecover] unrecoverable sessionId = %{public}d", sessionId); + const auto& scnSessionInfo = SetAbilitySessionInfo(sceneSession); + if (!scnSessionInfo) { + WLOGFW("[WMSRecover] scnSessionInfo is null"); + continue; } + sceneSession->NotifySessionException(scnSessionInfo, false); } } return taskScheduler_->PostAsyncTask(task, "UpdateSessionInfoBySCB"); -- Gitee From a602cceb3db21a29852302359a7fdc69c8920281 Mon Sep 17 00:00:00 2001 From: x00838529 Date: Fri, 15 Mar 2024 16:17:21 +0800 Subject: [PATCH 039/385] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dscb=E4=B8=8E=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=90=8C=E6=97=B6=E6=AD=BB=E4=BA=A1=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=87=BA=E7=8E=B0sys=5FFREEZE=EF=BC=8C=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=8B=89=E8=B5=B7=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: x00838529 --- 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 99d15fc22..c5f5d38dd 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -505,7 +505,7 @@ void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector& } std::vector unrecoverableSessionIds; AAFwk::AbilityManagerClient::GetInstance()->UpdateSessionInfoBySCB( - abilitySessionInfos, currentUserId_, unrecoverableSessionIds); + abilitySessionInfos, currentUserId_, unrecoverableSessionIds); WLOGFI("[WMSRecover] Number of unrecoverableSessionIds = %{public}zu", unrecoverableSessionIds.size()); for (const auto& sessionId : unrecoverableSessionIds) { auto sceneSession = GetSceneSession(sessionId); -- Gitee From 35b0ef819b44f944793ad6d13c956fdb31a1bcdf Mon Sep 17 00:00:00 2001 From: Gazizova Sofia Date: Fri, 15 Mar 2024 11:25:34 +0300 Subject: [PATCH 040/385] fixed large functions Signed-off-by: Gazizova Sofia Change-Id: I3eaea09fd6cfe27435ec85052b521f8c4e7ec70e --- .../include/screen_cutout_controller.h | 1 + .../src/scene_session_manager.cpp | 56 ++++++--------- .../src/screen_cutout_controller.cpp | 72 +++++++++++++------ 3 files changed, 74 insertions(+), 55 deletions(-) diff --git a/window_scene/session_manager/include/screen_cutout_controller.h b/window_scene/session_manager/include/screen_cutout_controller.h index f92bd1162..730aa7ea3 100644 --- a/window_scene/session_manager/include/screen_cutout_controller.h +++ b/window_scene/session_manager/include/screen_cutout_controller.h @@ -42,6 +42,7 @@ private: void CalcWaterfallRectsByRotation(Rotation rotation, uint32_t displayHeight, uint32_t displayWidth, std::vector realNumVec); void CheckBoundaryRects(std::vector& boundaryRects, sptr displayInfo); + std::vector GetBoundaryRects(sptr displayInfo); void ConvertBoundaryRectsByRotation(std::vector& boundaryRects, DisplayId displayId); bool IsDisplayRotationHorizontal(Rotation rotation); DMRect CreateWaterfallRect(uint32_t left, uint32_t top, uint32_t width, uint32_t height); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 2e1b3da6b..656f1c0b9 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -160,6 +160,16 @@ int Comp(const std::pair &a, const std::pairsize() == 1) { + const auto& numbers = *item.intsValue_; + value = numbers[0]; + return true; + } + return false; +} } // namespace SceneSessionManager& SceneSessionManager::GetInstance() @@ -292,64 +302,44 @@ void SceneSessionManager::ConfigWindowSceneXml() if (item.IsMap()) { ConfigWindowEffect(item); } - item = config["decor"]; if (item.IsMap()) { ConfigDecor(item); } - item = config["backgroundswitch"]; - if (item.IsInts()) { - auto numbers = *item.intsValue_; - if (numbers.size() == 1 && numbers[0] == 1) { - systemConfig_.backgroundswitch = true; - } + int32_t param = -1; + if (GetSingleIntItem(item, param) && param == 1) { + systemConfig_.backgroundswitch = true; } WLOGFD("Load ConfigWindowSceneXml backgroundswitch%{public}d", systemConfig_.backgroundswitch); - item = config["defaultWindowMode"]; - if (item.IsInts()) { - auto numbers = *item.intsValue_; - if (numbers.size() == 1 && - (numbers[0] == static_cast(WindowMode::WINDOW_MODE_FULLSCREEN) || - numbers[0] == static_cast(WindowMode::WINDOW_MODE_FLOATING))) { - systemConfig_.defaultWindowMode_ = static_cast(static_cast(numbers[0])); - } + if (GetSingleIntItem(item, param) && + (param == static_cast(WindowMode::WINDOW_MODE_FULLSCREEN) || + param == static_cast(WindowMode::WINDOW_MODE_FLOATING))) { + systemConfig_.defaultWindowMode_ = static_cast(static_cast(param)); } - item = config["defaultMaximizeMode"]; - if (item.IsInts()) { - auto numbers = *item.intsValue_; - if (numbers.size() == 1 && - (numbers[0] == static_cast(MaximizeMode::MODE_AVOID_SYSTEM_BAR) || - numbers[0] == static_cast(MaximizeMode::MODE_FULL_FILL))) { - SceneSession::maximizeMode_ = static_cast(numbers[0]); - } + if (GetSingleIntItem(item, param) && + (param == static_cast(MaximizeMode::MODE_AVOID_SYSTEM_BAR) || + param == static_cast(MaximizeMode::MODE_FULL_FILL))) { + SceneSession::maximizeMode_ = static_cast(param); } - item = config["keyboardAnimation"]; if (item.IsMap()) { ConfigKeyboardAnimation(item); } - item = config["maxFloatingWindowSize"]; - if (item.IsInts()) { - auto numbers = *item.intsValue_; - if (numbers.size() == 1) { - systemConfig_.maxFloatingWindowSize_ = static_cast(numbers[0]); - } + if (GetSingleIntItem(item, param)) { + systemConfig_.maxFloatingWindowSize_ = static_cast(param); } - item = config["windowAnimation"]; if (item.IsMap()) { ConfigWindowAnimation(item); } - item = config["startWindowTransitionAnimation"]; if (item.IsMap()) { ConfigStartingWindowAnimation(item); } - ConfigWindowSizeLimits(); ConfigSnapshotScale(); } diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index ca36ab836..75c15ba99 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -28,6 +28,33 @@ constexpr std::vector::size_type BOTTOM = 3; constexpr uint8_t HALF_SCREEN = 2; constexpr uint8_t QUARTER_SCREEN = 4; constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "ScreenCutoutController" }; + +template +DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect); + +template<> +DMRect GetRotatedRect<90>(uint32_t width, uint32_t height, const DMRect& rect) +{ + return DMRect { .posX_ = width - rect.posY_ - rect.height_, + .posY_ = rect.posX_, + .width_ = rect.height_, + .height_ = rect.width_ }; +} + +template<> +DMRect GetRotatedRect<180>(uint32_t width, uint32_t height, const DMRect& rect) +{ + return DMRect { width - rect.posX_ - rect.width_, + height - rect.posY_ - rect.height_, rect.width_, rect.height_ }; +} + +template<> +DMRect GetRotatedRect<270>(uint32_t width, uint32_t height, const DMRect& rect) +{ + return DMRect { rect.posY_, height - rect.posX_ - rect.width_, + rect.height_, rect.width_ }; +} + } uint32_t ScreenCutoutController::defaultDeviceRotation_ = 0; @@ -46,6 +73,20 @@ sptr ScreenCutoutController::GetScreenCutoutInfo(DisplayId displayId return cutoutInfo; } +std::vector ScreenCutoutController::GetBoundaryRects(sptr displayInfo) +{ + std::vector displayBoundaryRects; + if (ScreenSessionManager::GetInstance().IsFoldable() && + (ScreenSessionManager::GetInstance().GetFoldStatus() == FoldStatus::FOLDED)) { + displayBoundaryRects = {{ 507, 18, 66, 66}}; // x:507, y:18, w:66, h:66 + } else { + displayBoundaryRects = ScreenSceneConfig::GetCutoutBoundaryRect(); + } + CheckBoundaryRects(displayBoundaryRects, displayInfo); + + return displayBoundaryRects; +} + void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& boundaryRects, DisplayId displayId) { std::vector finalVector; @@ -57,16 +98,9 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& } Rotation currentRotation = displayInfo->GetRotation(); - std::vector displayBoundaryRects; - if (ScreenSessionManager::GetInstance().IsFoldable() && - (ScreenSessionManager::GetInstance().GetFoldStatus() == FoldStatus::FOLDED)) { - displayBoundaryRects = {{ 507, 18, 66, 66}}; // x:507, y:18, w:66, h:66 - } else { - displayBoundaryRects = ScreenSceneConfig::GetCutoutBoundaryRect(); - } - CheckBoundaryRects(displayBoundaryRects, displayInfo); + std::vector displayBoundaryRects = GetBoundaryRects(displayInfo); if (currentRotation == Rotation::ROTATION_0) { - boundaryRects = displayBoundaryRects; + boundaryRects = std::move(displayBoundaryRects); return; } @@ -74,33 +108,27 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& uint32_t displayHeight = static_cast(displayInfo->GetHeight()); switch (currentRotation) { case Rotation::ROTATION_90: { - for (DMRect rect : displayBoundaryRects) { - finalVector.emplace_back(DMRect { - .posX_ = displayWidth - rect.posY_ - rect.height_, - .posY_ = rect.posX_, - .width_ = rect.height_, - .height_ = rect.width_ }); + for (const DMRect& rect : displayBoundaryRects) { + finalVector.emplace_back(GetRotatedRect<90>(displayWidth, displayHeight, rect)); } break; } case Rotation::ROTATION_180: { - for (DMRect rect : displayBoundaryRects) { - finalVector.emplace_back(DMRect { displayWidth - rect.posX_ - rect.width_, - displayHeight - rect.posY_ - rect.height_, rect.width_, rect.height_ }); + for (const DMRect& rect : displayBoundaryRects) { + finalVector.emplace_back(GetRotatedRect<180>(displayWidth, displayHeight, rect)); } break; } case Rotation::ROTATION_270: { - for (DMRect rect : displayBoundaryRects) { - finalVector.emplace_back( - DMRect { rect.posY_, displayHeight - rect.posX_ - rect.width_, rect.height_, rect.width_ }); + for (const DMRect& rect : displayBoundaryRects) { + finalVector.emplace_back(GetRotatedRect<270>(displayWidth, displayHeight, rect)); } break; } default: break; } - boundaryRects = finalVector; + boundaryRects = std::move(finalVector); } void ScreenCutoutController::CheckBoundaryRects(std::vector& boundaryRects, sptr displayInfo) -- Gitee From 6c5a1e562d91faf2d47c9504ef7f852e9bded68a Mon Sep 17 00:00:00 2001 From: wanganjie Date: Fri, 15 Mar 2024 16:40:24 +0800 Subject: [PATCH 041/385] =?UTF-8?q?AddExtensionWindowStageToSCB=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E5=88=B0=E9=98=9F=E5=88=97=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wanganjie --- .../src/scene_session_manager.cpp | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 4ffe264ad..d147189a7 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7093,24 +7093,27 @@ void SceneSessionManager::PostFlushWindowInfoTask(FlushWindowInfoTask &&task, void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr& sessionStage, int32_t persistentId, int32_t parentId) { - if (sessionStage == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "sessionStage is nullptr"); - return; - } + auto task = [this, sessionStage, persistentId, parentId]() { + if (sessionStage == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "sessionStage is nullptr"); + return; + } - auto remoteExtSession = sessionStage->AsObject(); - remoteExtSessionMap_.insert(std::make_pair(remoteExtSession, std::make_pair(persistentId, parentId))); + auto remoteExtSession = sessionStage->AsObject(); + remoteExtSessionMap_.insert(std::make_pair(remoteExtSession, std::make_pair(persistentId, parentId))); - if (extensionDeath_ == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "failed to create death recipient"); - return; - } - if (!remoteExtSession->AddDeathRecipient(extensionDeath_)) { - TLOGE(WmsLogTag::WMS_UIEXT, "failed to add death recipient"); - return; - } - TLOGD(WmsLogTag::WMS_UIEXT, "add extension window stage Id: %{public}d, parent Id: %{public}d", - persistentId, parentId); + if (extensionDeath_ == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "failed to create death recipient"); + return; + } + if (!remoteExtSession->AddDeathRecipient(extensionDeath_)) { + TLOGE(WmsLogTag::WMS_UIEXT, "failed to add death recipient"); + return; + } + TLOGD(WmsLogTag::WMS_UIEXT, "add extension window stage Id: %{public}d, parent Id: %{public}d", + persistentId, parentId); + }; + taskScheduler_->PostAsyncTask(task, "AddExtensionWindowStageToSCB"); } WSError SceneSessionManager::HandleSecureSessionShouldHide(const sptr& sceneSession) -- Gitee From eabe4ddb0ab9d9ef9ee4dd98f6adecc464b716ef Mon Sep 17 00:00:00 2001 From: x00838529 Date: Fri, 15 Mar 2024 16:52:42 +0800 Subject: [PATCH 042/385] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dscb=E4=B8=8E=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=90=8C=E6=97=B6=E6=AD=BB=E4=BA=A1=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=87=BA=E7=8E=B0sys=5FFREEZE=EF=BC=8C=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=8B=89=E8=B5=B7=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: x00838529 --- 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 c5f5d38dd..2e1d2b9da 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -521,7 +521,7 @@ void SceneSessionManager::UpdateRecoveredSessionInfo(const std::vector& } sceneSession->NotifySessionException(scnSessionInfo, false); } - } + }; return taskScheduler_->PostAsyncTask(task, "UpdateSessionInfoBySCB"); } -- Gitee From 1299003a724219e2a8f1d84825df5970a36ed195 Mon Sep 17 00:00:00 2001 From: yu Date: Fri, 15 Mar 2024 09:33:49 +0000 Subject: [PATCH 043/385] change wmsfocus log I to D Signed-off-by: yu Change-Id: Id69f7aa35d195525448df8fb947d3353974ca392 --- .../kits/napi/scene_session_manager/js_scene_session.cpp | 2 +- window_scene/session/host/src/session.cpp | 4 ++-- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- wm/src/window_manager.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 5a7c939e7..2a9713261 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -1479,7 +1479,7 @@ void JsSceneSession::OnRaiseAboveTarget(int32_t subWindowId) void JsSceneSession::OnSessionFocusableChange(bool isFocusable) { - TLOGI(WmsLogTag::WMS_FOCUS, "[NAPI]OnSessionFocusableChange, state: %{public}u", isFocusable); + TLOGD(WmsLogTag::WMS_FOCUS, "[NAPI]OnSessionFocusableChange, state: %{public}u", isFocusable); std::shared_ptr jsCallBack = nullptr; { std::shared_lock lock(jsCbMapMutex_); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 037513d16..d8f5bf525 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1883,7 +1883,7 @@ void Session::NotifySessionStateChange(const SessionState& state) void Session::SetSessionFocusableChangeListener(const NotifySessionFocusableChangeFunc& func) { sessionFocusableChangeFunc_ = func; - sessionFocusableChangeFunc_(GetFocusable()); + NotifySessionFocusableChange(GetFocusable()); } void Session::SetSessionTouchableChangeListener(const NotifySessionTouchableChangeFunc& func) @@ -1899,7 +1899,7 @@ void Session::SetClickListener(const NotifyClickFunc& func) void Session::NotifySessionFocusableChange(bool isFocusable) { - WLOGFI("Notify session focusable change, id: %{public}d, focusable: %{public}u", GetPersistentId(), isFocusable); + TLOGI(WmsLogTag::WMS_FOCUS, "id: %{public}d, focusable: %{public}u", GetPersistentId(), isFocusable); if (sessionFocusableChangeFunc_) { sessionFocusableChangeFunc_(isFocusable); } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 2378f0a48..e1674b75a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3608,7 +3608,7 @@ WSError SceneSessionManager::RequestSessionFocusImmediately(int32_t persistentId WSError SceneSessionManager::RequestSessionFocus(int32_t persistentId, bool byForeground) { - TLOGI(WmsLogTag::WMS_FOCUS, "RequestSessionFocus, id: %{public}d, by foreground: %{public}d", + TLOGD(WmsLogTag::WMS_FOCUS, "RequestSessionFocus, id: %{public}d, by foreground: %{public}d", persistentId, byForeground); WSError basicCheckRet = RequestFocusBasicCheck(persistentId); if (basicCheckRet != WSError::WS_OK) { @@ -3646,7 +3646,7 @@ WSError SceneSessionManager::RequestSessionFocus(int32_t persistentId, bool byFo WSError SceneSessionManager::RequestSessionUnfocus(int32_t persistentId) { - TLOGI(WmsLogTag::WMS_FOCUS, "RequestSessionUnfocus, id: %{public}d", persistentId); + TLOGD(WmsLogTag::WMS_FOCUS, "RequestSessionUnfocus, id: %{public}d", persistentId); if (persistentId == INVALID_SESSION_ID) { WLOGFE("id is invalid"); return WSError::WS_ERROR_INVALID_SESSION; diff --git a/wm/src/window_manager.cpp b/wm/src/window_manager.cpp index 55a2dc724..072ed46a9 100644 --- a/wm/src/window_manager.cpp +++ b/wm/src/window_manager.cpp @@ -743,7 +743,7 @@ void WindowManager::UpdateFocusChangeInfo(const sptr& focusChan WLOGFE("focusChangeInfo is nullptr."); return; } - TLOGI(WmsLogTag::WMS_FOCUS, "window focus change: %{public}d, id: %{public}u", focused, focusChangeInfo->windowId_); + TLOGD(WmsLogTag::WMS_FOCUS, "window focus change: %{public}d, id: %{public}u", focused, focusChangeInfo->windowId_); if (focused) { pImpl_->NotifyFocused(focusChangeInfo); } else { -- Gitee From 6405ef2fa82932d71734937e216cf84906e0f503 Mon Sep 17 00:00:00 2001 From: jiyujia926 Date: Fri, 15 Mar 2024 16:43:03 +0800 Subject: [PATCH 044/385] fix the scenario when the keyboard height change Signed-off-by: jiyujia926 --- utils/include/wm_common_inner.h | 1 + utils/src/window_property.cpp | 7 +++++++ window_scene/interfaces/include/ws_common_inner.h | 1 + .../session_manager/src/scene_session_manager.cpp | 4 ++++ wm/include/window_scene_session_impl.h | 1 + wm/src/window_impl.cpp | 1 + wm/src/window_scene_session_impl.cpp | 8 ++++++++ wmserver/src/window_controller.cpp | 5 +++++ 8 files changed, 28 insertions(+) diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index 5fba547f9..e84d779eb 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -86,6 +86,7 @@ enum class PropertyChangeAction : uint32_t { ACTION_UPDATE_MAXIMIZE_STATE = 1 << 17, ACTION_UPDATE_SYSTEM_PRIVACY_MODE = 1 << 18, ACTION_UPDATE_SNAPSHOT_SKIP = 1 << 19, + ACTION_UPDATE_TEXTFIELD_AVOID_INFO = 1 << 20, }; struct ModeChangeHotZonesConfig { diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index b16d956e8..a9f63791d 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -869,6 +869,9 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action) case PropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE: ret = ret && parcel.WriteUint32(static_cast(maximizeMode_)); break; + case PropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO: + ret = ret && parcel.WriteDouble(textFieldPositionY_) && parcel.WriteDouble(textFieldHeight_); + break; default: break; } @@ -948,6 +951,10 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action) case PropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE: SetMaximizeMode(static_cast(parcel.ReadUint32())); break; + case PropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO: + SetTextFieldPositionY(parcel.ReadDouble()); + SetTextFieldHeight(parcel.ReadDouble()); + break; default: break; } diff --git a/window_scene/interfaces/include/ws_common_inner.h b/window_scene/interfaces/include/ws_common_inner.h index 8e4e277d2..40be64502 100644 --- a/window_scene/interfaces/include/ws_common_inner.h +++ b/window_scene/interfaces/include/ws_common_inner.h @@ -51,6 +51,7 @@ enum class WSPropertyChangeAction : uint32_t { ACTION_UPDATE_STATUS_PROPS = 1 << 24, ACTION_UPDATE_NAVIGATION_PROPS = 1 << 25, ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS = 1 << 26, + ACTION_UPDATE_TEXTFIELD_AVOID_INFO = 1 << 27, }; enum class AreaType : uint32_t { diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 2378f0a48..35eddbf03 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2772,6 +2772,10 @@ WMError SceneSessionManager::HandleUpdateProperty(const sptrSetTextFieldAvoidInfo(property->GetTextFieldPositionY(), property->GetTextFieldHeight()); + break; + } default: break; } diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index ea551b549..3338c1179 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -48,6 +48,7 @@ public: WMError Show(uint32_t reason = 0, bool withAnimation = false) override; WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WMError Destroy(bool needNotifyServer, bool needClearListener = true) override; + WMError SetTextFieldAvoidInfo(double textFieldPositionY, double textFieldHeight) override; void PreProcessCreate(); void SetDefaultProperty(); WSError SetActive(bool active) override; diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index e5851bcbc..49dfd2662 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -3803,6 +3803,7 @@ WMError WindowImpl::SetTextFieldAvoidInfo(double textFieldPositionY, double text { property_->SetTextFieldPositionY(textFieldPositionY); property_->SetTextFieldHeight(textFieldHeight); + UpdateProperty(PropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO); return WMError::WM_OK; } } // namespace Rosen diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 659a8c492..a4ea0a805 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2759,5 +2759,13 @@ WMError WindowSceneSessionImpl::HideNonSecureWindows(bool shouldHide) { return SingletonContainer::Get().AddOrRemoveSecureSession(property_->GetPersistentId(), shouldHide); } + +WMError WindowSceneSessionImpl::SetTextFieldAvoidInfo(double textFieldPositionY, double textFieldHeight) +{ + property_->SetTextFieldPositionY(textFieldPositionY); + property_->SetTextFieldHeight(textFieldHeight); + UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO); + return WMError::WM_OK; +} } // namespace Rosen } // namespace OHOS diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 06ef92d15..ab075b02f 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -1583,6 +1583,11 @@ WMError WindowController::UpdateProperty(sptr& property, Propert ret = ResizeRectAndFlush(windowId, newRect, WindowSizeChangeReason::MAXIMIZE); break; } + case PropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO: { + node->GetWindowProperty()->SetTextFieldPositionY(property->GetTextFieldPositionY()); + node->GetWindowProperty()->SetTextFieldHeight(property->GetTextFieldHeight()); + break; + } default: break; } -- Gitee From 15137c9fc56c75bbf51f3075ef8bd3203a07e5e9 Mon Sep 17 00:00:00 2001 From: Gazizova Sofia Date: Fri, 15 Mar 2024 13:08:07 +0300 Subject: [PATCH 045/385] fixed code check issues Signed-off-by: Gazizova Sofia Change-Id: I05dcc976cfea1fe6217115b02d6dadbb6eb96f2c --- .../session_manager/src/scene_session_manager.cpp | 6 +++--- .../session_manager/src/screen_cutout_controller.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 656f1c0b9..c4c5eff51 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -306,16 +306,16 @@ void SceneSessionManager::ConfigWindowSceneXml() if (item.IsMap()) { ConfigDecor(item); } + item = config["backgroundswitch"]; - int32_t param = -1; + int32_t param = -1; if (GetSingleIntItem(item, param) && param == 1) { systemConfig_.backgroundswitch = true; } WLOGFD("Load ConfigWindowSceneXml backgroundswitch%{public}d", systemConfig_.backgroundswitch); item = config["defaultWindowMode"]; if (GetSingleIntItem(item, param) && - (param == static_cast(WindowMode::WINDOW_MODE_FULLSCREEN) || - param == static_cast(WindowMode::WINDOW_MODE_FLOATING))) { + (param == static_cast(WindowMode::WINDOW_MODE_FULLSCREEN) || param == static_cast(WindowMode::WINDOW_MODE_FLOATING))) { systemConfig_.defaultWindowMode_ = static_cast(static_cast(param)); } item = config["defaultMaximizeMode"]; diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index 75c15ba99..03d09ec25 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -28,6 +28,9 @@ constexpr std::vector::size_type BOTTOM = 3; constexpr uint8_t HALF_SCREEN = 2; constexpr uint8_t QUARTER_SCREEN = 4; constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "ScreenCutoutController" }; +constexpr int32_t Rotate90 = 90; +constexpr int32_t Rotate180 = 180; +constexpr int32_t Rotate270 = 270; template DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect); @@ -109,19 +112,19 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& switch (currentRotation) { case Rotation::ROTATION_90: { for (const DMRect& rect : displayBoundaryRects) { - finalVector.emplace_back(GetRotatedRect<90>(displayWidth, displayHeight, rect)); + finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); } break; } case Rotation::ROTATION_180: { for (const DMRect& rect : displayBoundaryRects) { - finalVector.emplace_back(GetRotatedRect<180>(displayWidth, displayHeight, rect)); + finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); } break; } case Rotation::ROTATION_270: { for (const DMRect& rect : displayBoundaryRects) { - finalVector.emplace_back(GetRotatedRect<270>(displayWidth, displayHeight, rect)); + finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); } break; } -- Gitee From ad176279b3dd0d65c46efe48961b22704034fa17 Mon Sep 17 00:00:00 2001 From: Gazizova Sofia Date: Fri, 15 Mar 2024 14:40:20 +0300 Subject: [PATCH 046/385] fixed large functions Signed-off-by: Gazizova Sofia Change-Id: Ia97364a077f5c91732c4f1fe067b491af071a4d1 --- 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 c4c5eff51..0339e2bd7 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -315,11 +315,12 @@ void SceneSessionManager::ConfigWindowSceneXml() WLOGFD("Load ConfigWindowSceneXml backgroundswitch%{public}d", systemConfig_.backgroundswitch); item = config["defaultWindowMode"]; if (GetSingleIntItem(item, param) && - (param == static_cast(WindowMode::WINDOW_MODE_FULLSCREEN) || param == static_cast(WindowMode::WINDOW_MODE_FLOATING))) { + (param == static_cast(WindowMode::WINDOW_MODE_FULLSCREEN) || + param == static_cast(WindowMode::WINDOW_MODE_FLOATING))) { systemConfig_.defaultWindowMode_ = static_cast(static_cast(param)); } item = config["defaultMaximizeMode"]; - if (GetSingleIntItem(item, param) && + if (GetSingleIntItem(item, param) && (param == static_cast(MaximizeMode::MODE_AVOID_SYSTEM_BAR) || param == static_cast(MaximizeMode::MODE_FULL_FILL))) { SceneSession::maximizeMode_ = static_cast(param); -- Gitee From 38741518e447712f3c66a1824105d752f63468e5 Mon Sep 17 00:00:00 2001 From: Gazizova Sofia Date: Fri, 15 Mar 2024 15:14:12 +0300 Subject: [PATCH 047/385] fixed large functions Signed-off-by: Gazizova Sofia Change-Id: I7436284c624d11b59fa359fddb68abfca44284a3 --- 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 0339e2bd7..47dc505f0 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -314,7 +314,7 @@ void SceneSessionManager::ConfigWindowSceneXml() } WLOGFD("Load ConfigWindowSceneXml backgroundswitch%{public}d", systemConfig_.backgroundswitch); item = config["defaultWindowMode"]; - if (GetSingleIntItem(item, param) && + if (GetSingleIntItem(item, param) && (param == static_cast(WindowMode::WINDOW_MODE_FULLSCREEN) || param == static_cast(WindowMode::WINDOW_MODE_FLOATING))) { systemConfig_.defaultWindowMode_ = static_cast(static_cast(param)); -- Gitee From 3382b878de414d78a6afb99958168b667f4e1e40 Mon Sep 17 00:00:00 2001 From: chengzhen Date: Sat, 16 Mar 2024 02:23:30 +0000 Subject: [PATCH 048/385] update wm/src/window_scene_session_impl.cpp. Signed-off-by: chengzhen --- wm/src/window_scene_session_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index d50250cb4..79f52c13a 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -111,7 +111,7 @@ sptr WindowSceneSessionImpl::FindParentSessionByParentId(uint WLOGFD("Find parent, [parentName: %{public}s, parentId:%{public}u, selfPersistentId: %{public}d]", item.second.second->GetProperty()->GetWindowName().c_str(), parentId, GetProperty()->GetPersistentId()); return item.second.second; - } else if (WindowHelper::IsSubWindow(item.second.second->GetType()) { + } else if (WindowHelper::IsSubWindow(item.second.second->GetType())) { auto granParendId = item.second.second->GetParendId(); if (isSessionMainWindow(granParendId)) { return item.second.second; @@ -1713,7 +1713,7 @@ WMError WindowSceneSessionImpl::Close() hostSession_->OnSessionEvent(SessionEvent::EVENT_CLOSE); return WMError::WM_OK; } - } else if (WindowHelper::IsSubWindow(GetType()) || WindowHelper::IsSystemSubWindow(GetType()) { + } else if (WindowHelper::IsSubWindow(GetType()) || WindowHelper::IsSystemSubWindow(GetType())) { WLOGFI("WindowSceneSessionImpl::Close subwindow"); return Destroy(true); } -- Gitee From 41d38dc9f5ad09169fcf22279add2ba20169a5f0 Mon Sep 17 00:00:00 2001 From: chengzhen Date: Sat, 16 Mar 2024 02:29:08 +0000 Subject: [PATCH 049/385] update wm/src/window_scene_session_impl.cpp. Signed-off-by: chengzhen --- wm/src/window_scene_session_impl.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 79f52c13a..bf44e7f33 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -109,7 +109,8 @@ sptr WindowSceneSessionImpl::FindParentSessionByParentId(uint if (WindowHelper::IsMainWindow(item.second.second->GetType()) || WindowHelper::IsSystemWindow(item.second.second->GetType())) { WLOGFD("Find parent, [parentName: %{public}s, parentId:%{public}u, selfPersistentId: %{public}d]", - item.second.second->GetProperty()->GetWindowName().c_str(), parentId, GetProperty()->GetPersistentId()); + item.second.second->GetProperty()->GetWindowName().c_str(), + parentId, GetProperty()->GetPersistentId()); return item.second.second; } else if (WindowHelper::IsSubWindow(item.second.second->GetType())) { auto granParendId = item.second.second->GetParendId(); @@ -123,7 +124,8 @@ sptr WindowSceneSessionImpl::FindParentSessionByParentId(uint return nullptr; } -bool WindowSceneSessionImpl::isSessionMainWindow(uint32_t parentId) { +bool WindowSceneSessionImpl::isSessionMainWindow(uint32_t parentId) +{ std::shared_lock lock(windowSessionMutex_); for (const auto& item : windowSessionMap_) { if (item.second.second && item.second.second->GetProperty() && @@ -206,8 +208,8 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() return WMError::WM_ERROR_NULLPTR; } if (WindowHelper::IsSystemSubWindow(parentSession->GetType())) { - TLOGE(WmsLogTag::WMS_LIFE, "parent of system sub window is system sub window, name: %{public}s, type: %{public}d", - property_->GetWindowName().c_str(), type); + TLOGE(WmsLogTag::WMS_LIFE, "parent of system sub window is system sub window, name: %{public}s, + type: %{public}d", property_->GetWindowName().c_str(), type); return WMError::WM_ERROR_INVALID_TYPE; } // set parent persistentId -- Gitee From b4912f60f152eacd81071bcabb845f7a2f5788fc Mon Sep 17 00:00:00 2001 From: chengzhen Date: Sat, 16 Mar 2024 02:42:12 +0000 Subject: [PATCH 050/385] update wm/src/window_scene_session_impl.cpp. Signed-off-by: chengzhen --- wm/src/window_scene_session_impl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index bf44e7f33..790b9938d 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -109,8 +109,8 @@ sptr WindowSceneSessionImpl::FindParentSessionByParentId(uint if (WindowHelper::IsMainWindow(item.second.second->GetType()) || WindowHelper::IsSystemWindow(item.second.second->GetType())) { WLOGFD("Find parent, [parentName: %{public}s, parentId:%{public}u, selfPersistentId: %{public}d]", - item.second.second->GetProperty()->GetWindowName().c_str(), - parentId, GetProperty()->GetPersistentId()); + item.second.second->GetProperty()->GetWindowName().c_str(), parentId, + GetProperty()->GetPersistentId()); return item.second.second; } else if (WindowHelper::IsSubWindow(item.second.second->GetType())) { auto granParendId = item.second.second->GetParendId(); @@ -124,7 +124,7 @@ sptr WindowSceneSessionImpl::FindParentSessionByParentId(uint return nullptr; } -bool WindowSceneSessionImpl::isSessionMainWindow(uint32_t parentId) +bool WindowSceneSessionImpl::isSessionMainWindow(uint32_t parentId) { std::shared_lock lock(windowSessionMutex_); for (const auto& item : windowSessionMap_) { @@ -208,7 +208,7 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() return WMError::WM_ERROR_NULLPTR; } if (WindowHelper::IsSystemSubWindow(parentSession->GetType())) { - TLOGE(WmsLogTag::WMS_LIFE, "parent of system sub window is system sub window, name: %{public}s, + TLOGE(WmsLogTag::WMS_LIFE, "parent of system sub window is system sub window, name: %{public}s, type: %{public}d", property_->GetWindowName().c_str(), type); return WMError::WM_ERROR_INVALID_TYPE; } -- Gitee From 9872bd021c34295dd300eeb449e906cace717784 Mon Sep 17 00:00:00 2001 From: yusong Date: Sat, 16 Mar 2024 10:54:26 +0800 Subject: [PATCH 051/385] add uiextension water mark Signed-off-by: yusong --- interfaces/innerkits/wm/extension_window.h | 2 + interfaces/innerkits/wm/wm_common.h | 8 ++ .../napi/extension_window/extension_window.js | 4 + .../extension_window/js_extension_window.cpp | 42 +++++++++ .../extension_window/js_extension_window.h | 2 + .../include/scene_session_manager.h | 4 + .../zidl/scene_session_manager_interface.h | 5 ++ .../zidl/scene_session_manager_proxy.h | 1 + .../include/zidl/scene_session_manager_stub.h | 1 + .../src/scene_session_manager.cpp | 59 +++++++++++++ .../src/zidl/scene_session_manager_proxy.cpp | 31 +++++++ .../src/zidl/scene_session_manager_stub.cpp | 13 +++ wm/include/extension_window_impl.h | 1 + wm/include/window_adapter.h | 1 + wm/include/window_extension_session_impl.h | 8 ++ wm/src/extension_window_impl.cpp | 10 +++ wm/src/window_adapter.cpp | 6 ++ wm/src/window_extension_session_impl.cpp | 85 +++++++++++++++++++ .../include/zidl/window_manager_interface.h | 5 ++ 19 files changed, 288 insertions(+) diff --git a/interfaces/innerkits/wm/extension_window.h b/interfaces/innerkits/wm/extension_window.h index 803edcf20..31e9df126 100644 --- a/interfaces/innerkits/wm/extension_window.h +++ b/interfaces/innerkits/wm/extension_window.h @@ -33,6 +33,8 @@ public: virtual sptr GetWindow() = 0; virtual WMError HideNonSecureWindows(bool shouldHide) = 0; + + virtual WMError SetWaterMarkFlag(bool isEnable) = 0; }; } // namespace Rosen } // namespace OHOS diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 3541cb340..ca73ac5a4 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -265,6 +265,14 @@ enum class WindowFlag : uint32_t { WINDOW_FLAG_END = 1 << 5, }; +/** + * @brief Enumerates flag of uiextension window. + */ +enum class ExtensionWindowFlag : uint32_t { + EXTENSION_WINDOW_FLAG_WATER_MARK = 1, + EXTENSION_WINDOW_FLAG_END = 1 << 1, +}; + /** * @brief Enumerates window size change reason. */ diff --git a/interfaces/kits/napi/extension_window/extension_window.js b/interfaces/kits/napi/extension_window/extension_window.js index b08042849..a3eaf08a4 100644 --- a/interfaces/kits/napi/extension_window/extension_window.js +++ b/interfaces/kits/napi/extension_window/extension_window.js @@ -60,6 +60,10 @@ class ExtensionWindow { createSubWindowWithOptions(type, callback) { return this.__extension_window__.createSubWindowWithOptions(type, callback); } + + setWaterMarkFlag(type, callback) { + return this.__extension_window__.setWaterMarkFlag(type, callback); + } } export default ExtensionWindow; diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index df391d667..94a87817a 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -75,6 +75,7 @@ napi_value JsExtensionWindow::CreateJsExtensionWindow(napi_env env, sptrOnCreateSubWindowWithOptions(env, info) : nullptr; } +napi_value JsExtensionWindow::SetWaterMarkFlag(napi_env env, napi_callback_info info) +{ + WLOGI("SetWaterMark is called"); + JsExtensionWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetWaterMarkFlag(env, info) : nullptr; +} + napi_value JsExtensionWindow::LoadContent(napi_env env, napi_callback_info info) { WLOGI("LoadContent is called"); @@ -783,6 +791,40 @@ napi_value JsExtensionWindow::OnHideNonSecureWindows(napi_env env, napi_callback return NapiGetUndefined(env); } +napi_value JsExtensionWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info) +{ + if (extensionWindow_ == nullptr) { + WLOGFE("extensionWindow_ is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + sptr windowImpl = extensionWindow_->GetWindow(); + if (windowImpl == nullptr) { + WLOGFE("windowImpl is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < 1) { + WLOGFE("Argc is invalid: %{public}zu", argc); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + bool isEnable = false; + if (!ConvertFromJsValue(env, argv[0], isEnable)) { + WLOGFE("Failed to convert parameter to bool"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + + WmErrorCode ret = WmErrorCode::WM_OK; + ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->SetWaterMarkFlag(isEnable)); + if (ret != WmErrorCode::WM_OK) { + return NapiThrowError(env, ret); + } + WLOGI("OnSetWaterMark end, window [%{public}u, %{public}s], isEnable:%{public}u.", + windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), isEnable); + return NapiGetUndefined(env); +} + napi_value JsExtensionWindow::GetProperties(napi_env env, napi_callback_info info) { WLOGI("GetProperties is called"); diff --git a/interfaces/kits/napi/extension_window/js_extension_window.h b/interfaces/kits/napi/extension_window/js_extension_window.h index 90ecb7f2f..b404e2d19 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.h +++ b/interfaces/kits/napi/extension_window/js_extension_window.h @@ -57,6 +57,7 @@ public: static napi_value SetWindowBrightness(napi_env env, napi_callback_info info); static napi_value SetWindowKeepScreenOn(napi_env env, napi_callback_info info); static napi_value CreateSubWindowWithOptions(napi_env env, napi_callback_info info); + static napi_value SetWaterMarkFlag(napi_env env, napi_callback_info info); private: napi_value OnGetWindowAvoidArea(napi_env env, napi_callback_info info); napi_value OnRegisterExtensionWindowCallback(napi_env env, napi_callback_info info); @@ -77,6 +78,7 @@ private: napi_value OnSetWindowBrightness(napi_env env, napi_callback_info info); napi_value OnSetWindowKeepScreenOn(napi_env env, napi_callback_info info); napi_value OnCreateSubWindowWithOptions(napi_env env, napi_callback_info info); + napi_value OnSetWaterMarkFlag(napi_env env, napi_callback_info info); static napi_value GetProperties(napi_env env, napi_callback_info info); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 58283377f..fccfd32b2 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -294,6 +294,7 @@ public: int32_t StartUIAbilityBySCB(sptr& abilitySessionInfo); int32_t StartUIAbilityBySCB(sptr& sceneSessions); int32_t ChangeUIAbilityVisibilityBySCB(sptr& sceneSessions, bool visibility); + WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) override; public: std::shared_ptr GetTaskScheduler() {return taskScheduler_;}; @@ -433,6 +434,7 @@ private: const sptr& sceneSession); void ClosePipWindowIfExist(WindowType type); WSError DestroyAndDisconnectSpecificSessionInner(sptr sceneSession); + int64_t ConvertParentIdAndPersistentIdToExtId(int32_t parentId, int32_t persistentId); sptr rootSceneSession_; std::weak_ptr rootSceneContextWeak_; @@ -449,6 +451,8 @@ private: std::set windowVisibilityListenerSessionSet_; std::set secureSessionSet_; std::map> lastUpdatedAvoidArea_; + std::shared_mutex extensionWindowFlagsMapMutex_; + std::map extensionWindowFlagsMap_; NotifyCreateSystemSessionFunc createSystemSessionFunc_; std::map createSubSessionFuncMap_; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h index 6296d2da0..6dfda7020 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h @@ -99,6 +99,7 @@ public: TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB, TRANS_ID_ADD_OR_REMOVE_SECURE_SESSION, TRANS_ID_ADD_OR_REMOVE_SECURE_EXT_SESSION, + TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS, }; virtual WSError SetSessionLabel(const sptr &token, const std::string &label) = 0; @@ -214,6 +215,10 @@ public: { return WSError::WS_OK; } + WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) override + { + return WSError::WS_OK; + } }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_INTERFACE_H diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h index 21993c993..98ec59107 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h @@ -96,6 +96,7 @@ public: int32_t parentId) override; WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) override; WSError AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide) override; + WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) override; private: template diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_stub.h b/window_scene/session_manager/include/zidl/scene_session_manager_stub.h index 2ae8547b5..b0bda9491 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_stub.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_stub.h @@ -89,6 +89,7 @@ private: int HandleAddExtensionWindowStageToSCB(MessageParcel& data, MessageParcel& reply); int HandleAddOrRemoveSecureSession(MessageParcel& data, MessageParcel& reply); int HandleAddOrRemoveSecureExtSession(MessageParcel& data, MessageParcel& reply); + int HandleUpdateExtWindowFlags(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_STUB_H \ No newline at end of file diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index ba71fc7c9..a071da935 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -148,6 +148,7 @@ const std::string ARG_DUMP_WINDOW = "-w"; const std::string ARG_DUMP_SCREEN = "-s"; const std::string ARG_DUMP_DISPLAY = "-d"; constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns +const int32_t LOGICAL_DISPLACEMENT_32 = 32; std::string GetCurrentTime() { struct timespec tn; @@ -1663,6 +1664,10 @@ void SceneSessionManager::DestroyExtensionSession(const sptr& rem TLOGD(WmsLogTag::WMS_UIEXT, "Remote died, id: %{public}d", persistentId); AddOrRemoveSecureExtSession(persistentId, parentId, false); remoteExtSessionMap_.erase(iter); + std::shared_lock lock(extensionWindowFlagsMapMutex_); + int64_t extId = ConvertParentIdAndPersistentIdToExtId(parentId, persistentId); + extensionWindowFlagsMap_.erase(extId); + CheckAndNotifyWaterMarkChangedResult(); }; taskScheduler_->PostAsyncTask(task, "DestroyExtensionSession"); } @@ -4368,6 +4373,17 @@ void SceneSessionManager::CheckAndNotifyWaterMarkChangedResult() break; } } + std::shared_lock extLock(extensionWindowFlagsMapMutex_); + for (const auto& iter: extensionWindowFlagsMap_) { + auto& extWindowFlags = iter.second; + if (!extWindowFlags) { + continue; + } + if (extWindowFlags & static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)) { + currentWaterMarkShowState = true; + break; + } + } } if (lastWaterMarkShowState_ != currentWaterMarkShowState) { lastWaterMarkShowState_ = currentWaterMarkShowState; @@ -7205,4 +7221,47 @@ WSError SceneSessionManager::AddOrRemoveSecureExtSession(int32_t persistentId, i taskScheduler_->PostAsyncTask(task, "AddOrRemoveSecureExtSession"); return WSError::WS_OK; } + +WSError SceneSessionManager::UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) +{ + TLOGI(WmsLogTag::WMS_LIFE, "UpdateExtWindowFlags, parentId:%{public}d, persistentId:%{public}d, \ + extWindowFlags:%{public}d", parentId, persistentId, extWindowFlags); + if (!SessionPermission::IsSystemCalling()) { + TLOGE(WmsLogTag::WMS_LIFE, "UpdateExtWindowFlags permission denied!"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + auto task = [this, parentId, persistentId, extWindowFlags]() { + std::shared_lock lock(extensionWindowFlagsMapMutex_); + int64_t extId = ConvertParentIdAndPersistentIdToExtId(parentId, persistentId); + auto iter = extensionWindowFlagsMap_.find(extId); + bool waterMarkChanged = false; + if (iter == extensionWindowFlagsMap_.end()) { + extensionWindowFlagsMap_.insert({ extId, extWindowFlags}); + waterMarkChanged = true; + } else { + auto oriFlags = iter->second; + TLOGI(WmsLogTag::WMS_LIFE, "UpdateExtWindowFlags, oriFlags:%{public}d", oriFlags); + auto oldWaterMarkFlag = oriFlags & + (static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)); + auto newWaterMarkFlag = extWindowFlags & + (static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)); + if (oldWaterMarkFlag != newWaterMarkFlag) { + waterMarkChanged = true; + } + extensionWindowFlagsMap_[iter->first] = extWindowFlags; + } + if (waterMarkChanged) { + CheckAndNotifyWaterMarkChangedResult(); + } + return WSError::WS_OK; + }; + return taskScheduler_->PostSyncTask(task); +} + +int64_t SceneSessionManager::ConvertParentIdAndPersistentIdToExtId(int32_t parentId, int32_t persistentId) +{ + int64_t result = parentId; + result = (result << LOGICAL_DISPLACEMENT_32) | persistentId; + return result; +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index 39590bbea..e342dd628 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -1552,4 +1552,35 @@ WSError SceneSessionManagerProxy::AddOrRemoveSecureExtSession(int32_t persistent } return static_cast(reply.ReadInt32()); } + +WSError SceneSessionManagerProxy::UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) +{ + WLOGFD("run SceneSessionManagerProxy::UpdateExtWindowFlags"); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("Write interface token failed."); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteInt32(parentId)) { + WLOGFE("Write parentId failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteInt32(persistentId)) { + WLOGFE("Write persistentId failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteUint32(extWindowFlags)) { + WLOGFE("Write persistentId failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (Remote()->SendRequest( + static_cast(SceneSessionManagerMessage::TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest AddExtensionSessionInfo failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + return static_cast(reply.ReadInt32()); +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index a0efda446..f8b8c63ee 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -138,6 +138,8 @@ const std::map SceneSessionManagerStub::s &SceneSessionManagerStub::HandleAddOrRemoveSecureSession), std::make_pair(static_cast(SceneSessionManagerMessage::TRANS_ID_ADD_OR_REMOVE_SECURE_EXT_SESSION), &SceneSessionManagerStub::HandleAddOrRemoveSecureExtSession), + std::make_pair(static_cast(SceneSessionManagerMessage::TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS), + &SceneSessionManagerStub::HandleUpdateExtWindowFlags), }; int SceneSessionManagerStub::OnRemoteRequest(uint32_t code, @@ -833,4 +835,15 @@ int SceneSessionManagerStub::HandleAddOrRemoveSecureExtSession(MessageParcel &da reply.WriteInt32(static_cast(ret)); return ERR_NONE; } + +int SceneSessionManagerStub::HandleUpdateExtWindowFlags(MessageParcel &data, MessageParcel &reply) +{ + WLOGFI("run HandleRemoveExtensionSessionInfo!"); + int32_t parentId = data.ReadInt32(); + int32_t persistentId = data.ReadInt32(); + uint32_t extWindowFlags = data.ReadUint32(); + WSError ret = UpdateExtWindowFlags(parentId, persistentId, extWindowFlags); + reply.WriteInt32(static_cast(ret)); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/wm/include/extension_window_impl.h b/wm/include/extension_window_impl.h index f3941eba2..004139293 100644 --- a/wm/include/extension_window_impl.h +++ b/wm/include/extension_window_impl.h @@ -31,6 +31,7 @@ public: WMError GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea) override; sptr GetWindow() override; WMError HideNonSecureWindows(bool shouldHide) override; + WMError SetWaterMarkFlag(bool isEnable) override; private: sptr windowExtensionSessionImpl_; }; diff --git a/wm/include/window_adapter.h b/wm/include/window_adapter.h index 61c54a7fe..18b03a950 100644 --- a/wm/include/window_adapter.h +++ b/wm/include/window_adapter.h @@ -118,6 +118,7 @@ public: int32_t parentId); virtual WMError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide); virtual WMError AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide); + virtual WMError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags); private: static inline SingletonDelegator delegator; bool InitWMSProxy(); diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index f1343d00c..79cbd9c72 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -80,6 +80,8 @@ public: WMError Show(uint32_t reason = 0, bool withAnimation = false) override; WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WMError HideNonSecureWindows(bool shouldHide) override; + WMError AddWindowFlag(WindowFlag flag) override; + WMError RemoveWindowFlag(WindowFlag flag) override; protected: NotifyTransferComponentDataFunc notifyTransferComponentDataFunc_; @@ -92,6 +94,10 @@ private: void InputMethodKeyEventResultCallback(const std::shared_ptr& keyEvent, bool consumed, std::shared_ptr> isConsumedPromise, std::shared_ptr isTimeout); + void CheckAndAddExtWindowFlags(); + void CheckAndRemoveExtWindowFlags(); + WMError SetExtWindowFlags(uint32_t flags); + WMError UpdateExtWindowFlags(); sptr occupiedAreaChangeListener_; std::optional> focusState_ = std::nullopt; @@ -99,6 +105,8 @@ private: static std::shared_mutex windowExtensionSessionMutex_; int16_t rotationAnimationCount_ { 0 }; bool shouldHideNonSecureWindows_ = false; + bool isWaterMarkEnable_ = false; + uint32_t extensionWindowFlags_ = 0; }; } // namespace Rosen } // namespace OHOS diff --git a/wm/src/extension_window_impl.cpp b/wm/src/extension_window_impl.cpp index 20a657c8b..dab08b453 100644 --- a/wm/src/extension_window_impl.cpp +++ b/wm/src/extension_window_impl.cpp @@ -45,5 +45,15 @@ WMError ExtensionWindowImpl::HideNonSecureWindows(bool shouldHide) WLOGI("HideNonSecureWindows is called"); return windowExtensionSessionImpl_->HideNonSecureWindows(shouldHide); } + +WMError ExtensionWindowImpl::SetWaterMarkFlag(bool isEnable) +{ + WLOGI("SetWaterMarkFlag is called"); + if (isEnable) { + return windowExtensionSessionImpl_->AddWindowFlag(WindowFlag::WINDOW_FLAG_WATER_MARK); + } else { + return windowExtensionSessionImpl_->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_WATER_MARK); + } +} } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index 13d665aae..b48e9e0f4 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -600,5 +600,11 @@ WMError WindowAdapter::AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, shouldHide)); } +WMError WindowAdapter::UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) +{ + INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING); + return static_cast(windowManagerServiceProxy_->UpdateExtWindowFlags(parentId, persistentId, + extWindowFlags)); +} } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index c07923080..a811a0370 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -23,6 +23,8 @@ #include "window_manager_hilog.h" #include "parameters.h" #include "anr_handler.h" +#include "session_permission.h" +#include "singleton_container.h" #include "window_adapter.h" namespace OHOS { @@ -99,6 +101,7 @@ WMError WindowExtensionSessionImpl::Destroy(bool needNotifyServer, bool needClea TLOGE(WmsLogTag::WMS_LIFE, "session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; } + CheckAndRemoveExtWindowFlags(); if (hostSession_ != nullptr) { hostSession_->Disconnect(); } @@ -581,6 +584,7 @@ WMError WindowExtensionSessionImpl::Show(uint32_t reason, bool withAnimation) SingletonContainer::Get().AddOrRemoveSecureExtSession(property_->GetPersistentId(), property_->GetParentId(), true); } + CheckAndAddExtWindowFlags(); return this->WindowSessionImpl::Show(reason, withAnimation); } @@ -592,6 +596,7 @@ WMError WindowExtensionSessionImpl::Hide(uint32_t reason, bool withAnimation, bo WLOGFE("session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; } + CheckAndRemoveExtWindowFlags(); if (state_ == WindowState::STATE_HIDDEN || state_ == WindowState::STATE_CREATED) { TLOGD(WmsLogTag::WMS_LIFE, "window extension session is already hidden \ [name:%{public}s,id:%{public}d,type: %{public}u]", @@ -625,5 +630,85 @@ WMError WindowExtensionSessionImpl::HideNonSecureWindows(bool shouldHide) return SingletonContainer::Get().AddOrRemoveSecureExtSession(property_->GetPersistentId(), property_->GetParentId(), shouldHide); } + +WMError WindowExtensionSessionImpl::AddWindowFlag(WindowFlag flag) +{ + TLOGI(WmsLogTag::WMS_LIFE, "AddWindowFlag flags:%{public}u", (static_cast(flag))); + uint32_t updateFlags = extensionWindowFlags_; + switch (flag) { + case WindowFlag::WINDOW_FLAG_WATER_MARK: { + isWaterMarkEnable_ = true; + if (state_ == WindowState::STATE_SHOWN) { + updateFlags |= (static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)); + } + break; + } + default: + break; + } + return SetExtWindowFlags(updateFlags); +} + +WMError WindowExtensionSessionImpl::RemoveWindowFlag(WindowFlag flag) +{ + TLOGI(WmsLogTag::WMS_LIFE, "RemoveWindowFlag flags:%{public}u", (static_cast(flag))); + uint32_t updateFlags = extensionWindowFlags_; + switch (flag) { + case WindowFlag::WINDOW_FLAG_WATER_MARK: { + isWaterMarkEnable_ = true; + if (state_ == WindowState::STATE_SHOWN) { + updateFlags &= (~(static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK))); + } + break; + } + default: + break; + } + return SetExtWindowFlags(updateFlags); +} + +void WindowExtensionSessionImpl::CheckAndAddExtWindowFlags() +{ + uint32_t updateFlags = extensionWindowFlags_; + if (isWaterMarkEnable_) { + updateFlags |= (static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)); + } + SetExtWindowFlags(updateFlags); +} + +void WindowExtensionSessionImpl::CheckAndRemoveExtWindowFlags() +{ + uint32_t updateFlags = extensionWindowFlags_; + if (isWaterMarkEnable_) { + updateFlags &= (~(static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK))); + } + SetExtWindowFlags(updateFlags); +} + +WMError WindowExtensionSessionImpl::SetExtWindowFlags(uint32_t flags) +{ + TLOGI(WmsLogTag::WMS_LIFE, "SetExtWindowFlags extensionWindowFlags_:%{public}u, flags:%{public}u", + extensionWindowFlags_, flags); + if (IsWindowSessionInvalid()) { + WLOGFE("session is invalid"); + return WMError::WM_ERROR_INVALID_WINDOW; + } + if (extensionWindowFlags_ == flags) { + return WMError::WM_OK; + } + auto oriFlags = extensionWindowFlags_; + extensionWindowFlags_ = flags; + WMError ret = UpdateExtWindowFlags(); + if (ret != WMError::WM_OK) { + extensionWindowFlags_ = oriFlags; + } + return ret; +} + +WMError WindowExtensionSessionImpl::UpdateExtWindowFlags() +{ + return SingletonContainer::Get().UpdateExtWindowFlags(property_->GetParentId(), GetPersistentId(), + extensionWindowFlags_); +} } // namespace Rosen } // namespace OHOS diff --git a/wmserver/include/zidl/window_manager_interface.h b/wmserver/include/zidl/window_manager_interface.h index 5db551bbd..6385e087e 100644 --- a/wmserver/include/zidl/window_manager_interface.h +++ b/wmserver/include/zidl/window_manager_interface.h @@ -83,6 +83,7 @@ public: TRANS_ID_SET_MAXIMIZE_MODE, TRANS_ID_GET_MAXIMIZE_MODE, TRANS_ID_GET_FOCUS_WINDOW_INFO, + TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS, }; virtual WMError CreateWindow(sptr& window, sptr& property, const std::shared_ptr& surfaceNode, @@ -196,6 +197,10 @@ public: { return WSError::WS_OK; } + virtual WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) + { + return WSError::WS_OK; + } }; } } -- Gitee From 901a530faba2c43700868d2d4efb76671974324d Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Sat, 16 Mar 2024 11:08:41 +0800 Subject: [PATCH 052/385] add hostSession_ NULL Signed-off-by: redking-zhong --- wm/src/window_scene_session_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 659a8c492..3f3af95e2 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -750,8 +750,8 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation) WMError WindowSceneSessionImpl::Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits) { - if (property_ == nullptr) { - TLOGE(WmsLogTag::WMS_LIFE, "Window hide failed, property is nullptr"); + if (property_ == nullptr || hostSession_ == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "Window hide failed, because of nullptr"); return WMError::WM_ERROR_NULLPTR; } -- Gitee From c6a36ba50a85ff6ac813df8d1dc9b26eb62db034 Mon Sep 17 00:00:00 2001 From: chengzhen Date: Sat, 16 Mar 2024 03:19:28 +0000 Subject: [PATCH 053/385] update wm/src/window_scene_session_impl.cpp. Signed-off-by: chengzhen --- wm/src/window_scene_session_impl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 790b9938d..6a286ae6d 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -113,7 +113,7 @@ sptr WindowSceneSessionImpl::FindParentSessionByParentId(uint GetProperty()->GetPersistentId()); return item.second.second; } else if (WindowHelper::IsSubWindow(item.second.second->GetType())) { - auto granParendId = item.second.second->GetParendId(); + auto granParendId = item.second.second->GetParentId(); if (isSessionMainWindow(granParendId)) { return item.second.second; } @@ -208,8 +208,8 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() return WMError::WM_ERROR_NULLPTR; } if (WindowHelper::IsSystemSubWindow(parentSession->GetType())) { - TLOGE(WmsLogTag::WMS_LIFE, "parent of system sub window is system sub window, name: %{public}s, - type: %{public}d", property_->GetWindowName().c_str(), type); + TLOGE(WmsLogTag::WMS_LIFE, "parent is system sub window, name: %{public}s, type: %{public}d", + property_->GetWindowName().c_str(), type); return WMError::WM_ERROR_INVALID_TYPE; } // set parent persistentId -- Gitee From bce1d38b10b715f8a04e190c2e295defb6e2e771 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Sat, 16 Mar 2024 15:07:16 +0800 Subject: [PATCH 054/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/picture_in_picture_controller.cpp | 2 +- wm/test/unittest/window_test.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wm/src/picture_in_picture_controller.cpp b/wm/src/picture_in_picture_controller.cpp index a7b5c6eca..cf7730d66 100644 --- a/wm/src/picture_in_picture_controller.cpp +++ b/wm/src/picture_in_picture_controller.cpp @@ -232,7 +232,7 @@ WMError PictureInPictureController::StopPictureInPictureFromClient() pipOption_->GetPipTemplate(), FAILED, "window is null"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; } - if (curState_ == PipWindowState::STATE_STOPPING || curState_ == PipWindowState::STATE_STOPPED) { + if (curState_ == PiPWindowState::STATE_STOPPING || curState_ == PiPWindowState::STATE_STOPPED) { WLOGFE("Repeat stop request, curState: %{public}u", curState_); SingletonContainer::Get().ReportPiPStopWindow(static_cast(StopPipType::USER_STOP), pipOption_->GetPipTemplate(), FAILED, "Repeat stop request"); diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 8968c66a5..1820f3be4 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -121,7 +121,11 @@ HWTEST_F(WindowTest, CreatePiP, Function | SmallTest | Level2) sptr option = nullptr; PiPTemplateInfo pipTemplateInfo; ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); - option = new WindowOption(); + windowOption = new WindowOption(); + ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + windowOption->SetWindowName("pip_window"); + windowOption->SetWindowType(WindowType::WINDOW_TYPE_PIP); + windowOption->SetWindowMode(WindowMode::WINDOW_MODE_PIP); ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); } -- Gitee From 154cccbd5a1a047291ddb6d97b15c1739f9b7976 Mon Sep 17 00:00:00 2001 From: chehang Date: Sat, 16 Mar 2024 15:45:11 +0800 Subject: [PATCH 055/385] feat: send hover event to extension Signed-off-by: chehang Change-Id: Id522003cea67c85d537a72f3414172e357e243c3 --- .../include/zidl/session_stage_interface.h | 73 +++++++++++-------- .../zidl/window_event_channel_interface.h | 2 + .../include/zidl/window_event_channel_proxy.h | 2 + .../include/zidl/window_event_channel_stub.h | 1 + .../zidl/window_event_ipc_interface_code.h | 3 +- .../container/src/window_event_channel.cpp | 10 +++ .../src/zidl/window_event_channel_proxy.cpp | 28 +++++++ .../src/zidl/window_event_channel_stub.cpp | 18 +++++ window_scene/session/host/include/session.h | 7 +- window_scene/session/host/src/session.cpp | 10 +++ wm/include/window_extension_session_impl.h | 2 + wm/src/window_extension_session_impl.cpp | 11 +++ 12 files changed, 132 insertions(+), 35 deletions(-) diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index 09fe74d23..a0baed2b7 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -39,6 +39,45 @@ class ISessionStage : public IRemoteBroker { public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISessionStage"); + // IPC interface + virtual WSError SetActive(bool active) = 0; + virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, + const std::shared_ptr& rsTransaction = nullptr) = 0; + virtual void UpdateDensity() = 0; + virtual WSError HandleBackEvent() = 0; + virtual WSError MarkProcessed(int32_t eventId) = 0; + virtual WSError UpdateFocus(bool isFocused) = 0; + virtual WSError NotifyDestroy() = 0; + virtual WSError NotifyCloseExistPipWindow() = 0; + virtual WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) + { + return WSError::WS_OK; + } + virtual WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, + AAFwk::WantParams& reWantParams) + { + return WSErrorCode::WS_OK; + } + virtual void NotifyOccupiedAreaChangeInfo(sptr info) = 0; + virtual WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; + virtual void NotifyScreenshot() = 0; + virtual void DumpSessionElementInfo(const std::vector& params) = 0; + virtual WSError NotifyTouchOutside() = 0; + virtual WSError NotifyWindowVisibility(bool isVisible) = 0; + virtual WSError UpdateWindowMode(WindowMode mode) = 0; + virtual void NotifyForegroundInteractiveStatus(bool interactive) = 0; + virtual WSError UpdateMaximizeMode(MaximizeMode mode) = 0; + virtual void NotifySessionForeground(uint32_t reason, bool withAnimation) = 0; + virtual void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) = 0; + virtual WSError UpdateTitleInTargetPos(bool isShow, int32_t height) = 0; + virtual void NotifyTransformChange(const Transform& transform) = 0; + virtual WSError NotifyDialogStateChange(bool isForeground) + { + return WSError::WS_OK; + } + + + // **Non** IPC interface virtual void NotifyBackpressedEvent(bool& isConsumed) {} virtual void NotifyPointerEvent(const std::shared_ptr& pointerEvent) {} virtual void NotifyKeyEvent(const std::shared_ptr& keyEvent, bool& isConsumed, @@ -49,10 +88,6 @@ public: { return -1; } - virtual WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) - { - return WSError::WS_OK; - } virtual WSError NotifySearchElementInfoByAccessibilityId(int64_t elementId, int32_t mode, int64_t baseParent, std::list& infos) { @@ -78,37 +113,11 @@ public: { return WSError::WS_OK; } - virtual WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, - AAFwk::WantParams& reWantParams) - { - return WSErrorCode::WS_OK; - } - virtual WSError NotifyDialogStateChange(bool isForeground) + virtual WSError NotifyAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) { return WSError::WS_OK; } - virtual WSError SetActive(bool active) = 0; - virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, - const std::shared_ptr& rsTransaction = nullptr) = 0; - virtual void UpdateDensity() = 0; - virtual WSError HandleBackEvent() = 0; - virtual WSError MarkProcessed(int32_t eventId) = 0; - virtual WSError UpdateFocus(bool isFocused) = 0; - virtual WSError NotifyDestroy() = 0; - virtual WSError NotifyCloseExistPipWindow() = 0; - virtual void NotifyOccupiedAreaChangeInfo(sptr info) = 0; - virtual WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; - virtual void NotifyScreenshot() = 0; - virtual void DumpSessionElementInfo(const std::vector& params) = 0; - virtual WSError NotifyTouchOutside() = 0; - virtual WSError NotifyWindowVisibility(bool isVisible) = 0; - virtual WSError UpdateWindowMode(WindowMode mode) = 0; - virtual void NotifyForegroundInteractiveStatus(bool interactive) = 0; - virtual WSError UpdateMaximizeMode(MaximizeMode mode) = 0; - virtual void NotifySessionForeground(uint32_t reason, bool withAnimation) = 0; - virtual void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) = 0; - virtual WSError UpdateTitleInTargetPos(bool isShow, int32_t height) = 0; - virtual void NotifyTransformChange(const Transform& transform) = 0; }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/window_event_channel_interface.h b/window_scene/session/container/include/zidl/window_event_channel_interface.h index 10628a317..84aaafb5e 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_interface.h +++ b/window_scene/session/container/include/zidl/window_event_channel_interface.h @@ -53,6 +53,8 @@ public: Accessibility::AccessibilityElementInfo& info) = 0; virtual WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, int32_t action, int64_t baseParent) = 0; + virtual WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) = 0; }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_WINDOW_EVENT_CHANNEL_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/window_event_channel_proxy.h b/window_scene/session/container/include/zidl/window_event_channel_proxy.h index 538fbe2b8..0ff4edbb6 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_proxy.h +++ b/window_scene/session/container/include/zidl/window_event_channel_proxy.h @@ -47,6 +47,8 @@ public: Accessibility::AccessibilityElementInfo& info) override; WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, int32_t action, int64_t baseParent) override; + WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) override; private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/session/container/include/zidl/window_event_channel_stub.h b/window_scene/session/container/include/zidl/window_event_channel_stub.h index eb5cb45cd..ec3217352 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_stub.h +++ b/window_scene/session/container/include/zidl/window_event_channel_stub.h @@ -46,6 +46,7 @@ private: int HandleTransferFindFocusedElementInfo(MessageParcel& data, MessageParcel& reply); int HandleTransferFocusMoveSearch(MessageParcel& data, MessageParcel& reply); int HandleTransferExecuteAction(MessageParcel& data, MessageParcel& reply); + int HandleTransferAccessibilityHoverEvent(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_WINDOW_EVENT_CHANNEL_STUB_H diff --git a/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h b/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h index f5b4ebdac..ca3528838 100644 --- a/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h @@ -32,8 +32,9 @@ enum class WindowEventInterfaceCode { TRANS_ID_TRANSFER_FOCUS_MOVE_SEARCH, TRANS_ID_TRANSFER_EXECUTE_ACTION, TRANS_ID_TRANSFER_CLEAR_FOCUS, + TRANS_ID_TRANSFER_ACCESSIBILITY_HOVER_EVENT, }; } // namespace Rosen } // namespace OHOS -#endif // WINDOW_EVENT_IPC_INTERFACE_CODE_H \ No newline at end of file +#endif // WINDOW_EVENT_IPC_INTERFACE_CODE_H diff --git a/window_scene/session/container/src/window_event_channel.cpp b/window_scene/session/container/src/window_event_channel.cpp index b96bde5bf..326948fcb 100644 --- a/window_scene/session/container/src/window_event_channel.cpp +++ b/window_scene/session/container/src/window_event_channel.cpp @@ -262,4 +262,14 @@ WSError WindowEventChannel::TransferExecuteAction(int64_t elementId, } return sessionStage_->NotifyExecuteAction(elementId, actionArguments, action, baseParent); } + +WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) +{ + if (!sessionStage_) { + WLOGFE("session stage is null!"); + return WSError::WS_ERROR_NULLPTR; + } + return sessionStage_->NotifyAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp b/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp index 4593dbcf5..441ab22f4 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp @@ -374,4 +374,32 @@ WSError WindowEventChannelProxy::TransferExecuteAction(int64_t elementId, int32_t ret = reply.ReadInt32(); return static_cast(ret); } + +WSError WindowEventChannelProxy::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, + int32_t eventType, int64_t timeMs) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteFloat(pointX) || + !data.WriteFloat(pointY) || + !data.WriteInt32(sourceType) || + !data.WriteInt32(eventType) || + !data.WriteInt64(timeMs)) { + WLOGFE("Write TransferAccessibilityHoverEvent data failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (Remote()->SendRequest( + static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_ACCESSIBILITY_HOVER_EVENT), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + int32_t ret = reply.ReadInt32(); + return static_cast(ret); +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp index d18ddc173..cd42a0d4f 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp @@ -317,4 +317,22 @@ int WindowEventChannelStub::HandleTransferExecuteAction(MessageParcel& data, Mes reply.WriteUint32(static_cast(errCode)); return ERR_NONE; } + +int WindowEventChannelStub::HandleTransferAccessibilityHoverEvent(MessageParcel& data, MessageParcel& reply) +{ + float pointX, pointY; + int32_t sourceType, eventType; + int64_t timeMs; + if (!data.ReadFloat(pointX) || + !data.ReadFloat(pointY) || + !data.ReadInt32(sourceType) || + !data.ReadInt32(eventType) || + !data.ReadInt64(timeMs)) { + WLOGFE("Read HandleTransferAccessibilityHoverEvent data failed!"); + return ERR_INVALID_DATA; + }; + WSError errCode = TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); + reply.WriteUint32(static_cast(errCode)); + return ERR_NONE; +} } diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 48fbd5275..34d4bc762 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -141,13 +141,16 @@ public: Accessibility::AccessibilityElementInfo& info); virtual WSError TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent, Accessibility::AccessibilityElementInfo& info); + virtual WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, + int32_t action, int64_t baseParent); + WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs); + virtual WSError NotifyClientToUpdateRect(std::shared_ptr rsTransaction) { return WSError::WS_OK; } WSError TransferBackPressedEventForConsumed(bool& isConsumed); WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed); WSError TransferFocusActiveEvent(bool isFocusActive); WSError TransferFocusStateEvent(bool focusState); - virtual WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, - int32_t action, int64_t baseParent); virtual WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) { return WSError::WS_OK; } int32_t GetPersistentId() const; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 2fef2b7f4..d2a868e35 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -2418,6 +2418,16 @@ WSError Session::TransferExecuteAction(int64_t elementId, const std::mapTransferExecuteAction(elementId, actionArguments, action, baseParent); } +WSError Session::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) +{ + if (!windowEventChannel_) { + WLOGFE("windowEventChannel_ is null"); + return WSError::WS_ERROR_NULLPTR; + } + return windowEventChannel_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); +} + void Session::SetSessionInfoLockedStateChangeListener(const NotifySessionInfoLockedStateChangeFunc& func) { sessionInfoLockedStateChangeFunc_ = func; diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index 8598df255..77b6cc28f 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -58,6 +58,8 @@ public: Accessibility::AccessibilityElementInfo& info) override; WSError NotifyExecuteAction(int64_t elementId, const std::map& actionAguments, int32_t action, int64_t baseParent) override; + WSError NotifyAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) override; WMError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; WMError Destroy(bool needNotifyServer, bool needClearListener = true) override; diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index a0b38d462..53b15417e 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -490,6 +490,17 @@ WSError WindowExtensionSessionImpl::NotifyExecuteAction(int64_t elementId, return WSError::WS_OK; } +WSError WindowExtensionSessionImpl::NotifyAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, + int32_t eventType, int64_t timeMs) +{ + if (uiContent_ == nullptr) { + WLOGFE("NotifyExecuteAction error, no uiContent_"); + return WSError::WS_ERROR_NO_UI_CONTENT_ERROR; + } + uiContent_->HandleAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); + return WSError::WS_OK; +} + WMError WindowExtensionSessionImpl::TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) { -- Gitee From 49ffc486d6e0094d99bb6d697e7b0192af685869 Mon Sep 17 00:00:00 2001 From: yusong Date: Sat, 16 Mar 2024 18:09:29 +0800 Subject: [PATCH 056/385] add uiextension water mark Signed-off-by: yusong --- interfaces/innerkits/wm/window.h | 14 ++++ .../extension_window/js_extension_window.cpp | 12 ++-- .../session/host/include/scene_session.h | 7 ++ .../session/host/src/scene_session.cpp | 40 +++++++++++ .../include/scene_session_manager.h | 3 - .../src/scene_session_manager.cpp | 68 +++++++------------ .../src/zidl/scene_session_manager_proxy.cpp | 12 ++-- .../src/zidl/scene_session_manager_stub.cpp | 2 +- wm/include/window_extension_session_impl.h | 4 +- wm/src/extension_window_impl.cpp | 8 ++- wm/src/window_extension_session_impl.cpp | 36 ++-------- 11 files changed, 111 insertions(+), 95 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 6e01b4bc8..8f1fec828 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -643,6 +643,20 @@ public: * @return WM_OK means remove success, others means failed. */ virtual WMError RemoveWindowFlag(WindowFlag flag) { return WMError::WM_OK; } + /** + * @brief Add uiextension window flag. + * + * @param flag Flag of uiextension window. + * @return WM_OK means add success, others means failed. + */ + virtual WMError AddExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Remove uiextension window flag. + * + * @param flag Flag of uiextension window + * @return WM_OK means remove success, others means failed. + */ + virtual WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } /** * @brief Set window flag. * diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index 94a87817a..e6ac27f11 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -166,7 +166,7 @@ napi_value JsExtensionWindow::CreateSubWindowWithOptions(napi_env env, napi_call napi_value JsExtensionWindow::SetWaterMarkFlag(napi_env env, napi_callback_info info) { - WLOGI("SetWaterMark is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "SetWaterMark is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetWaterMarkFlag(env, info) : nullptr; } @@ -794,24 +794,24 @@ napi_value JsExtensionWindow::OnHideNonSecureWindows(napi_env env, napi_callback napi_value JsExtensionWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info) { if (extensionWindow_ == nullptr) { - WLOGFE("extensionWindow_ is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { - WLOGFE("windowImpl is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "windowImpl is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - WLOGFE("Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_UIEXT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } bool isEnable = false; if (!ConvertFromJsValue(env, argv[0], isEnable)) { - WLOGFE("Failed to convert parameter to bool"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to bool"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } @@ -820,7 +820,7 @@ napi_value JsExtensionWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_inf if (ret != WmErrorCode::WM_OK) { return NapiThrowError(env, ret); } - WLOGI("OnSetWaterMark end, window [%{public}u, %{public}s], isEnable:%{public}u.", + TLOGI(WmsLogTag::WMS_UIEXT, "OnSetWaterMark end, window [%{public}u, %{public}s], isEnable:%{public}u.", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), isEnable); return NapiGetUndefined(env); } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index f8a3e5326..dad9ad913 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -223,6 +223,10 @@ public: void SetShouldHideNonSecureWindows(bool shouldHide); WSError AddOrRemoveSecureExtSession(int32_t persistentId, bool shouldHide); WSError SetPipActionEvent(const std::string& action, int32_t status); + void UpdateExtWindowFlags(int32_t extPersistentId, uint32_t flags); + bool IsExtWindowHasWaterMarkFlag(); + void RomoveExtWindowFlags(int32_t extPersistentId); + void ClearExtWindowFlags(); void SetSessionState(SessionState state) override; void UpdateSessionState(SessionState state) override; @@ -295,6 +299,9 @@ private: std::atomic_bool isVisibleForAccessibility_ { true }; std::atomic_bool shouldHideNonSecureWindows_ { false }; std::set secureExtSessionSet_; + std::shared_mutex extWindowFlagsMapMutex_; + std::map extWindowFlagsMap_; + }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H \ No newline at end of file diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 7d8c68d96..ac4b81a8c 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2512,4 +2512,44 @@ WSError SceneSession::AddOrRemoveSecureExtSession(int32_t persistentId, bool sho return PostSyncTask(task, "AddOrRemoveSecureExtSession"); } + +void SceneSession::UpdateExtWindowFlags(int32_t extPersistentId, uint32_t flags) +{ + std::shared_lock lock(extWindowFlagsMapMutex_); + auto iter = extWindowFlagsMap_.find(extPersistentId); + if (iter == extWindowFlagsMap_.end()) { + extWindowFlagsMap_.insert({ extPersistentId, extWindowFlags }); + } else { + extWindowFlagsMap_[iter->first] = extWindowFlags; + } +} +bool SceneSession::IsExtWindowHasWaterMarkFlag() +{ + bool isExtWindowHasWaterMarkFlag = false; + std::shared_lock lock(extWindowFlagsMapMutex_); + for (const auto& iter: extWindowFlagsMap_) { + auto& extWindowFlags = iter.second; + if (!extWindowFlags) { + continue; + } + if (extWindowFlags & static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)) { + isExtWindowHasWaterMarkFlag = true; + break; + } + } + return isExtWindowHasWaterMarkFlag; +} +void SceneSession::RomoveExtWindowFlags(int32_t extPersistentId) +{ + std::shared_lock lock(extWindowFlagsMapMutex_); + auto iter = extWindowFlagsMap_.find(extPersistentId); + if (iter != extWindowFlagsMap_.end()) { + extWindowFlagsMap_.erase(iter); + } +} +void SceneSession::ClearExtWindowFlags() +{ + std::shared_lock lock(extWindowFlagsMapMutex_); + extWindowFlagsMap_.clear(); +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index fccfd32b2..39c8016b0 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -434,7 +434,6 @@ private: const sptr& sceneSession); void ClosePipWindowIfExist(WindowType type); WSError DestroyAndDisconnectSpecificSessionInner(sptr sceneSession); - int64_t ConvertParentIdAndPersistentIdToExtId(int32_t parentId, int32_t persistentId); sptr rootSceneSession_; std::weak_ptr rootSceneContextWeak_; @@ -451,8 +450,6 @@ private: std::set windowVisibilityListenerSessionSet_; std::set secureSessionSet_; std::map> lastUpdatedAvoidArea_; - std::shared_mutex extensionWindowFlagsMapMutex_; - std::map extensionWindowFlagsMap_; NotifyCreateSystemSessionFunc createSystemSessionFunc_; std::map createSubSessionFuncMap_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index a071da935..0c0e6c632 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1662,12 +1662,16 @@ void SceneSessionManager::DestroyExtensionSession(const sptr& rem auto persistentId = iter->second.first; auto parentId = iter->second.second; TLOGD(WmsLogTag::WMS_UIEXT, "Remote died, id: %{public}d", persistentId); + auto sceneSession = GetSceneSession(parentId); + if (sceneSession != nullptr) { + auto oldWaterMark = sceneSession->IsExtWindowHasWaterMarkFlag(); + sceneSession->RemoveExtensionWindowFlag(persistentId); + if (oldWaterMark) { + CheckAndNotifyWaterMarkChangedResult(); + } + } AddOrRemoveSecureExtSession(persistentId, parentId, false); remoteExtSessionMap_.erase(iter); - std::shared_lock lock(extensionWindowFlagsMapMutex_); - int64_t extId = ConvertParentIdAndPersistentIdToExtId(parentId, persistentId); - extensionWindowFlagsMap_.erase(extId); - CheckAndNotifyWaterMarkChangedResult(); }; taskScheduler_->PostAsyncTask(task, "DestroyExtensionSession"); } @@ -4368,18 +4372,8 @@ void SceneSessionManager::CheckAndNotifyWaterMarkChangedResult() } bool hasWaterMark = session->GetSessionProperty()->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_WATER_MARK); - if (hasWaterMark && session->GetVisible()) { - currentWaterMarkShowState = true; - break; - } - } - std::shared_lock extLock(extensionWindowFlagsMapMutex_); - for (const auto& iter: extensionWindowFlagsMap_) { - auto& extWindowFlags = iter.second; - if (!extWindowFlags) { - continue; - } - if (extWindowFlags & static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)) { + bool isExtWindowHasWaterMarkFlag = session->IsExtWindowHasWaterMarkFlag() + if ((hasWaterMark && session->GetVisible()) || isExtWindowHasWaterMarkFlag) { currentWaterMarkShowState = true; break; } @@ -5836,6 +5830,7 @@ void SceneSessionManager::WindowDestroyNotifyVisibility(const sptr #endif sceneSession->SetVisible(false); sceneSession->SetVisibilityState(WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION); + sceneSession->ClearExtWindowFlags(); windowVisibilityInfos.emplace_back(new WindowVisibilityInfo(sceneSession->GetWindowId(), sceneSession->GetCallingPid(), sceneSession->GetCallingUid(), WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION, sceneSession->GetWindowType())); @@ -7224,44 +7219,27 @@ WSError SceneSessionManager::AddOrRemoveSecureExtSession(int32_t persistentId, i WSError SceneSessionManager::UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) { - TLOGI(WmsLogTag::WMS_LIFE, "UpdateExtWindowFlags, parentId:%{public}d, persistentId:%{public}d, \ + TLOGI(WmsLogTag::WMS_UIEXT, "UpdateExtWindowFlags, parentId:%{public}d, persistentId:%{public}d, \ extWindowFlags:%{public}d", parentId, persistentId, extWindowFlags); if (!SessionPermission::IsSystemCalling()) { - TLOGE(WmsLogTag::WMS_LIFE, "UpdateExtWindowFlags permission denied!"); + TLOGE(WmsLogTag::WMS_UIEXT, "UpdateExtWindowFlags permission denied!"); return WSError::WS_ERROR_NOT_SYSTEM_APP; } auto task = [this, parentId, persistentId, extWindowFlags]() { - std::shared_lock lock(extensionWindowFlagsMapMutex_); - int64_t extId = ConvertParentIdAndPersistentIdToExtId(parentId, persistentId); - auto iter = extensionWindowFlagsMap_.find(extId); - bool waterMarkChanged = false; - if (iter == extensionWindowFlagsMap_.end()) { - extensionWindowFlagsMap_.insert({ extId, extWindowFlags}); - waterMarkChanged = true; - } else { - auto oriFlags = iter->second; - TLOGI(WmsLogTag::WMS_LIFE, "UpdateExtWindowFlags, oriFlags:%{public}d", oriFlags); - auto oldWaterMarkFlag = oriFlags & - (static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)); - auto newWaterMarkFlag = extWindowFlags & - (static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)); - if (oldWaterMarkFlag != newWaterMarkFlag) { - waterMarkChanged = true; - } - extensionWindowFlagsMap_[iter->first] = extWindowFlags; + auto sceneSession = GetSceneSession(parentId); + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "Session with persistentId %{public}d not found", parentId); + return WSError::WS_ERROR_INVALID_SESSION; } - if (waterMarkChanged) { + auto oldWaterMark = sceneSession->IsExtWindowHasWaterMarkFlag(); + sceneSession->UpdateExtWindowFlags(persistentId, extWindowFlags); + auto newWaterMark = sceneSession->IsExtWindowHasWaterMarkFlag(); + if (oldWaterMark != newWaterMark) { CheckAndNotifyWaterMarkChangedResult(); } return WSError::WS_OK; }; - return taskScheduler_->PostSyncTask(task); -} - -int64_t SceneSessionManager::ConvertParentIdAndPersistentIdToExtId(int32_t parentId, int32_t persistentId) -{ - int64_t result = parentId; - result = (result << LOGICAL_DISPLACEMENT_32) | persistentId; - return result; + taskScheduler_->PostAsyncTask(task, "UpdateExtWindowFlags") + return WSError::WS_OK; } } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index e342dd628..3cf269cbf 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -1555,30 +1555,30 @@ WSError SceneSessionManagerProxy::AddOrRemoveSecureExtSession(int32_t persistent WSError SceneSessionManagerProxy::UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) { - WLOGFD("run SceneSessionManagerProxy::UpdateExtWindowFlags"); + TLOGD(WmsLogTag::WMS_UIEXT, "run SceneSessionManagerProxy::UpdateExtWindowFlags"); MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("Write interface token failed."); + TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed."); return WSError::WS_ERROR_IPC_FAILED; } if (!data.WriteInt32(parentId)) { - WLOGFE("Write parentId failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "Write parentId failed"); return WSError::WS_ERROR_IPC_FAILED; } if (!data.WriteInt32(persistentId)) { - WLOGFE("Write persistentId failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "Write persistentId failed"); return WSError::WS_ERROR_IPC_FAILED; } if (!data.WriteUint32(extWindowFlags)) { - WLOGFE("Write persistentId failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "Write persistentId failed"); return WSError::WS_ERROR_IPC_FAILED; } if (Remote()->SendRequest( static_cast(SceneSessionManagerMessage::TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS), data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest AddExtensionSessionInfo failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest AddExtensionSessionInfo failed"); return WSError::WS_ERROR_IPC_FAILED; } return static_cast(reply.ReadInt32()); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index f8b8c63ee..eed6a1049 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -838,7 +838,7 @@ int SceneSessionManagerStub::HandleAddOrRemoveSecureExtSession(MessageParcel &da int SceneSessionManagerStub::HandleUpdateExtWindowFlags(MessageParcel &data, MessageParcel &reply) { - WLOGFI("run HandleRemoveExtensionSessionInfo!"); + TLOGI(WmsLogTag::WMS_UIEXT, "run HandleRemoveExtensionSessionInfo!"); int32_t parentId = data.ReadInt32(); int32_t persistentId = data.ReadInt32(); uint32_t extWindowFlags = data.ReadUint32(); diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index 79cbd9c72..9b8307077 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -80,8 +80,8 @@ public: WMError Show(uint32_t reason = 0, bool withAnimation = false) override; WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WMError HideNonSecureWindows(bool shouldHide) override; - WMError AddWindowFlag(WindowFlag flag) override; - WMError RemoveWindowFlag(WindowFlag flag) override; + WMError AddExtensionWindowFlag(ExtensionWindowFlag flag) override; + WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) override; protected: NotifyTransferComponentDataFunc notifyTransferComponentDataFunc_; diff --git a/wm/src/extension_window_impl.cpp b/wm/src/extension_window_impl.cpp index dab08b453..19c805a49 100644 --- a/wm/src/extension_window_impl.cpp +++ b/wm/src/extension_window_impl.cpp @@ -48,11 +48,13 @@ WMError ExtensionWindowImpl::HideNonSecureWindows(bool shouldHide) WMError ExtensionWindowImpl::SetWaterMarkFlag(bool isEnable) { - WLOGI("SetWaterMarkFlag is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "SetWaterMarkFlag is called"); if (isEnable) { - return windowExtensionSessionImpl_->AddWindowFlag(WindowFlag::WINDOW_FLAG_WATER_MARK); + return windowExtensionSessionImpl_->AddExtensionWindowFlag( + ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK); } else { - return windowExtensionSessionImpl_->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_WATER_MARK); + return windowExtensionSessionImpl_->RemoveExtensionWindowFlag( + ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK); } } } // namespace Rosen diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index a811a0370..4c44112ba 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -631,39 +631,17 @@ WMError WindowExtensionSessionImpl::HideNonSecureWindows(bool shouldHide) property_->GetParentId(), shouldHide); } -WMError WindowExtensionSessionImpl::AddWindowFlag(WindowFlag flag) +WMError WindowExtensionSessionImpl::AddExtensionWindowFlag(ExtensionWindowFlag flag) { - TLOGI(WmsLogTag::WMS_LIFE, "AddWindowFlag flags:%{public}u", (static_cast(flag))); - uint32_t updateFlags = extensionWindowFlags_; - switch (flag) { - case WindowFlag::WINDOW_FLAG_WATER_MARK: { - isWaterMarkEnable_ = true; - if (state_ == WindowState::STATE_SHOWN) { - updateFlags |= (static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK)); - } - break; - } - default: - break; - } + TLOGI(WmsLogTag::WMS_UIEXT, "AddWindowFlag flags:%{public}u", (static_cast(flag))); + uint32_t updateFlags = property_->GetWindowFlags() | (static_cast(flag)); return SetExtWindowFlags(updateFlags); } WMError WindowExtensionSessionImpl::RemoveWindowFlag(WindowFlag flag) { - TLOGI(WmsLogTag::WMS_LIFE, "RemoveWindowFlag flags:%{public}u", (static_cast(flag))); - uint32_t updateFlags = extensionWindowFlags_; - switch (flag) { - case WindowFlag::WINDOW_FLAG_WATER_MARK: { - isWaterMarkEnable_ = true; - if (state_ == WindowState::STATE_SHOWN) { - updateFlags &= (~(static_cast(ExtensionWindowFlag::EXTENSION_WINDOW_FLAG_WATER_MARK))); - } - break; - } - default: - break; - } + TLOGI(WmsLogTag::WMS_UIEXT, "RemoveWindowFlag flags:%{public}u", (static_cast(flag))); + uint32_t updateFlags = property_->GetWindowFlags() & (~(static_cast(flag))); return SetExtWindowFlags(updateFlags); } @@ -687,10 +665,10 @@ void WindowExtensionSessionImpl::CheckAndRemoveExtWindowFlags() WMError WindowExtensionSessionImpl::SetExtWindowFlags(uint32_t flags) { - TLOGI(WmsLogTag::WMS_LIFE, "SetExtWindowFlags extensionWindowFlags_:%{public}u, flags:%{public}u", + TLOGI(WmsLogTag::WMS_UIEXT, "SetExtWindowFlags extensionWindowFlags_:%{public}u, flags:%{public}u", extensionWindowFlags_, flags); if (IsWindowSessionInvalid()) { - WLOGFE("session is invalid"); + TLOGI(WmsLogTag::WMS_UIEXT, "session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; } if (extensionWindowFlags_ == flags) { -- Gitee From 04bc826eeeb80271852fc9266bcdfea3438d62db Mon Sep 17 00:00:00 2001 From: yusong Date: Sat, 16 Mar 2024 18:39:55 +0800 Subject: [PATCH 057/385] add uiextension water mark Signed-off-by: yusong --- window_scene/session/host/include/scene_session.h | 2 +- window_scene/session/host/src/scene_session.cpp | 2 +- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++--- wm/src/window_extension_session_impl.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index dad9ad913..ec4dda36b 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -223,7 +223,7 @@ public: void SetShouldHideNonSecureWindows(bool shouldHide); WSError AddOrRemoveSecureExtSession(int32_t persistentId, bool shouldHide); WSError SetPipActionEvent(const std::string& action, int32_t status); - void UpdateExtWindowFlags(int32_t extPersistentId, uint32_t flags); + void UpdateExtWindowFlags(int32_t extPersistentId, uint32_t extWindowFlags); bool IsExtWindowHasWaterMarkFlag(); void RomoveExtWindowFlags(int32_t extPersistentId); void ClearExtWindowFlags(); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ac4b81a8c..5db7c0fb9 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2513,7 +2513,7 @@ WSError SceneSession::AddOrRemoveSecureExtSession(int32_t persistentId, bool sho return PostSyncTask(task, "AddOrRemoveSecureExtSession"); } -void SceneSession::UpdateExtWindowFlags(int32_t extPersistentId, uint32_t flags) +void SceneSession::UpdateExtWindowFlags(int32_t extPersistentId, uint32_t extWindowFlags) { std::shared_lock lock(extWindowFlagsMapMutex_); auto iter = extWindowFlagsMap_.find(extPersistentId); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 0c0e6c632..85b577e9a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1665,7 +1665,7 @@ void SceneSessionManager::DestroyExtensionSession(const sptr& rem auto sceneSession = GetSceneSession(parentId); if (sceneSession != nullptr) { auto oldWaterMark = sceneSession->IsExtWindowHasWaterMarkFlag(); - sceneSession->RemoveExtensionWindowFlag(persistentId); + sceneSession->RomoveExtWindowFlags(persistentId); if (oldWaterMark) { CheckAndNotifyWaterMarkChangedResult(); } @@ -4372,7 +4372,7 @@ void SceneSessionManager::CheckAndNotifyWaterMarkChangedResult() } bool hasWaterMark = session->GetSessionProperty()->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_WATER_MARK); - bool isExtWindowHasWaterMarkFlag = session->IsExtWindowHasWaterMarkFlag() + bool isExtWindowHasWaterMarkFlag = session->IsExtWindowHasWaterMarkFlag(); if ((hasWaterMark && session->GetVisible()) || isExtWindowHasWaterMarkFlag) { currentWaterMarkShowState = true; break; @@ -7239,7 +7239,7 @@ WSError SceneSessionManager::UpdateExtWindowFlags(int32_t parentId, int32_t pers } return WSError::WS_OK; }; - taskScheduler_->PostAsyncTask(task, "UpdateExtWindowFlags") + taskScheduler_->PostAsyncTask(task, "UpdateExtWindowFlags"); return WSError::WS_OK; } } // namespace OHOS::Rosen diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 4c44112ba..86a45baf0 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -638,7 +638,7 @@ WMError WindowExtensionSessionImpl::AddExtensionWindowFlag(ExtensionWindowFlag f return SetExtWindowFlags(updateFlags); } -WMError WindowExtensionSessionImpl::RemoveWindowFlag(WindowFlag flag) +WMError WindowExtensionSessionImpl::RemoveExtensionWindowFlag(ExtensionWindowFlag flag) { TLOGI(WmsLogTag::WMS_UIEXT, "RemoveWindowFlag flags:%{public}u", (static_cast(flag))); uint32_t updateFlags = property_->GetWindowFlags() & (~(static_cast(flag))); -- Gitee From a50578682ebbcf2c0afe3e5cb685297e8511e1d5 Mon Sep 17 00:00:00 2001 From: w00845693 Date: Sat, 16 Mar 2024 18:50:03 +0800 Subject: [PATCH 058/385] =?UTF-8?q?Description:=E4=BF=AE=E5=A4=8D=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E6=80=81=E5=BC=80=E6=9C=BA=E9=87=8D=E5=90=AF=E5=90=8E?= =?UTF-8?q?=E5=B1=8F=E5=B9=95=E6=96=B9=E5=90=91=E6=97=A0=E6=B3=95=E6=97=8B?= =?UTF-8?q?=E8=BD=AC=E5=88=B0sensor=E8=A7=92=E5=BA=A6=20IssueNo:https://gi?= =?UTF-8?q?tee.com/openharmony/window=5Fwindow=5Fmanager/issues/I993OI=20F?= =?UTF-8?q?eature=20or=20Bugfix:Bugfix=20Binary=20Source:No=20Signed-off-b?= =?UTF-8?q?y:=20wyk99=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/session/screen/include/screen_session.h | 2 ++ window_scene/session/screen/src/screen_session.cpp | 10 ++++++++++ .../session_manager/src/screen_session_manager.cpp | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index 2f523ff5d..de41fb8ac 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -164,6 +164,7 @@ public: void SetAvailableArea(DMRect area); bool UpdateAvailableArea(DMRect area); void SetFoldScreen(bool isFold); + void UpdateRotationAfterBoot(bool foldToExpand); std::shared_ptr GetScreenSnapshot(float scaleX, float scaleY); private: @@ -177,6 +178,7 @@ private: std::recursive_mutex mutex_; std::function updateToInputManagerCallback_ = nullptr; bool isFold_ = false; + float currentSensorRotation_ { 0.0f }; std::vector hdrFormats_; std::vector colorSpaces_; }; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 419653f2f..ca758ccac 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -308,6 +308,7 @@ void ScreenSession::SensorRotationChange(Rotation sensorRotation) void ScreenSession::SensorRotationChange(float sensorRotation) { + currentSensorRotation_ = sensorRotation; for (auto& listener : screenChangeListenerList_) { listener->OnSensorRotationChange(sensorRotation, screenId_); } @@ -400,6 +401,15 @@ void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation, Fold rotation, displayOrientation); } +void ScreenSession::UpdateRotationAfterBoot(bool foldToExpand) +{ + if (foldToExpand) { + if (property_.GetRotation() != currentSensorRotation_) { + SensorRotationChange(currentSensorRotation_); + } + } +} + sptr ScreenSession::GetActiveScreenMode() const { if (activeIdx_ < 0 || activeIdx_ >= static_cast(modes_.size())) { diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index a13ea4ffa..ce3ba8f54 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -3422,6 +3422,12 @@ void ScreenSessionManager::NotifyFoldToExpandCompletion(bool foldToExpand) { WLOGFI("NotifyFoldToExpandCompletion ENTER"); SetDisplayNodeScreenId(SCREEN_ID_FULL, foldToExpand ? SCREEN_ID_FULL : SCREEN_ID_MAIN); + sptr screenSession = GetDefaultScreenSession(); + if (screenSession == nullptr) { + WLOGFE("fail to get default screenSession"); + return; + } + screenSession->UpdateRotationAfterBoot(foldToExpand); } void ScreenSessionManager::CheckAndSendHiSysEvent(const std::string& eventName, const std::string& bundleName) const -- Gitee From a3c112df393f0d4f09eb7c31f8f17918c069e7b9 Mon Sep 17 00:00:00 2001 From: cloud_nine Date: Sun, 17 Mar 2024 14:50:12 +0800 Subject: [PATCH 059/385] =?UTF-8?q?=E6=94=AF=E6=8C=81dump=E8=BE=93?= =?UTF-8?q?=E5=87=BAscreensession=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenyunjiu --- .../include/screen_session_dumper.h | 4 + .../src/screen_session_dumper.cpp | 169 ++++++++++++++++-- 2 files changed, 155 insertions(+), 18 deletions(-) diff --git a/window_scene/session_manager/include/screen_session_dumper.h b/window_scene/session_manager/include/screen_session_dumper.h index c60ac784e..2c0e9696d 100644 --- a/window_scene/session_manager/include/screen_session_dumper.h +++ b/window_scene/session_manager/include/screen_session_dumper.h @@ -40,6 +40,10 @@ private: void ShowHelpInfo(); void ShowAllScreenInfo(); void OutputDumpInfo(); + void DumpScreenSessionById(ScreenId id); + void DumpRsInfoById(ScreenId id); + void DumpRsInfoById01(sptr screenSession); + void DumpCutoutInfoById(ScreenId id); void DumpScreenInfoById(ScreenId id); void DumpScreenPropertyById(ScreenId id); diff --git a/window_scene/session_manager/src/screen_session_dumper.cpp b/window_scene/session_manager/src/screen_session_dumper.cpp index bbe208691..641a98594 100644 --- a/window_scene/session_manager/src/screen_session_dumper.cpp +++ b/window_scene/session_manager/src/screen_session_dumper.cpp @@ -22,7 +22,7 @@ namespace OHOS { namespace Rosen { namespace { -constexpr int LINE_WIDTH = 25; +constexpr int LINE_WIDTH = 30; constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenSessionDumper" }; } @@ -91,11 +91,161 @@ void ScreenSessionDumper::ShowAllScreenInfo() std::ostringstream oss; oss << "---------------- Screen ID: " << screenId << " ----------------" << std::endl; dumpInfo_.append(oss.str()); + DumpScreenSessionById(screenId); + DumpRsInfoById(screenId); + DumpCutoutInfoById(screenId); DumpScreenInfoById(screenId); DumpScreenPropertyById(screenId); } } +void ScreenSessionDumper::DumpScreenSessionById(ScreenId id) +{ + std::ostringstream oss; + oss << "[SCREEN SESSION]" << std::endl; + auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(id); + if (screenSession == nullptr) { + WLOGFE("screenSession nullptr. screen id: %{public}" PRIu64"", id); + return; + } + oss << std::left << std::setw(LINE_WIDTH) << "Name: " + << screenSession->GetName() << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "RSScreenId: " + << screenSession->GetRSScreenId() << std::endl; + sptr activeModes = screenSession->GetActiveScreenMode(); + if (activeModes != nullptr) { + oss << std::left << std::setw(LINE_WIDTH) << "activeModes: " + << activeModes->id_ << ", " << activeModes->width_ << ", " + << activeModes->height_ << ", " << activeModes->refreshRate_ << std::endl; + } + oss << std::left << std::setw(LINE_WIDTH) << "SourceMode: " + << static_cast(screenSession->GetSourceMode()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "ScreenCombination: " + << static_cast(screenSession->GetScreenCombination()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "Orientation: " + << static_cast(screenSession->GetOrientation()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "Rotation: " + << static_cast(screenSession->GetRotation()) << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "ScreenRequestedOrientation: " + << static_cast(screenSession->GetScreenRequestedOrientation()) << std::endl; + dumpInfo_.append(oss.str()); +} + +void ScreenSessionDumper::DumpRsInfoById(ScreenId id) +{ + std::ostringstream oss; + oss << "[RS INFO]" << std::endl; + auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(id); + if (screenSession == nullptr) { + WLOGFE("screenSession nullptr. screen id: %{public}" PRIu64"", id); + return; + } + std::vector colorGamuts; + DMError ret = screenSession->GetScreenSupportedColorGamuts(colorGamuts); + if (ret == DMError::DM_OK) { + oss << std::left << std::setw(LINE_WIDTH) << "SupportedColorGamuts: "; + for (uint32_t i = 0; i < colorGamuts.size() -1 ; i++) { + oss << static_cast(colorGamuts[i]) << ", "; + } + oss << static_cast(colorGamuts[colorGamuts.size() -1]) << std::endl; + } + ScreenColorGamut colorGamut; + ret = screenSession->GetScreenColorGamut(colorGamut); + if (ret == DMError::DM_OK) { + oss << std::left << std::setw(LINE_WIDTH) << "ScreenColorGamut: " + << static_cast(colorGamut) << std::endl; + } + ScreenGamutMap gamutMap; + ret = screenSession->GetScreenGamutMap(gamutMap); + if (ret == DMError::DM_OK) { + oss << std::left << std::setw(LINE_WIDTH) << "ScreenGamutMap: " + << static_cast(gamutMap) << std::endl; + } + GraphicPixelFormat pixelFormat; + ret = screenSession->GetPixelFormat(pixelFormat); + if (ret == DMError::DM_OK) { + oss << std::left << std::setw(LINE_WIDTH) << "GraphicPixelFormat: " + << static_cast(pixelFormat) << std::endl; + } + dumpInfo_.append(oss.str()); + DumpRsInfoById01(screenSession); // 拆分函数,避免函数过长 +} + +void ScreenSessionDumper::DumpRsInfoById01(sptr screenSession) +{ + std::ostringstream oss; + std::vector hdrFormats; + DMError ret = screenSession->GetSupportedHDRFormats(hdrFormats); + if (ret == DMError::DM_OK) { + oss << std::left << std::setw(LINE_WIDTH) << "SupportedScreenHDRFormat: "; + for (uint32_t i = 0; i < hdrFormats.size() -1 ; i++) { + oss << static_cast(hdrFormats[i]) << ", "; + } + oss << static_cast(hdrFormats[hdrFormats.size() -1]) << std::endl; + } + ScreenHDRFormat hdrFormat; + ret = screenSession->GetScreenHDRFormat(hdrFormat); + if (ret == DMError::DM_OK) { + oss << std::left << std::setw(LINE_WIDTH) << "ScreenHDRFormat: " + << static_cast(hdrFormat) << std::endl; + } + std::vector colorSpaces; + ret = screenSession->GetSupportedColorSpaces(colorSpaces); + if (ret == DMError::DM_OK) { + oss << std::left << std::setw(LINE_WIDTH) << "SupportedColorSpaces: "; + for (uint32_t i = 0; i < colorSpaces.size() -1 ; i++) { + oss << static_cast(colorSpaces[i]) << ", "; + } + oss << static_cast(colorSpaces[colorSpaces.size() -1]) << std::endl; + } + GraphicCM_ColorSpaceType colorSpace; + ret = screenSession->GetScreenColorSpace(colorSpace); + if (ret == DMError::DM_OK) { + oss << std::left << std::setw(LINE_WIDTH) << "ScreenColorSpace: " + << static_cast(colorSpace) << std::endl; + } + dumpInfo_.append(oss.str()); +} + +void ScreenSessionDumper::DumpCutoutInfoById(ScreenId id) +{ + std::ostringstream oss; + oss << "[CUTOUT INFO]" << std::endl; + sptr cutoutInfo = ScreenSessionManager::GetInstance().GetCutoutInfo(id); + if (cutoutInfo == nullptr) { + WLOGFE("cutoutInfo nullptr. screen id: %{public}" PRIu64"", id); + return; + } + oss << std::left << std::setw(LINE_WIDTH) << "WaterFall_L: " + << cutoutInfo->GetWaterfallDisplayAreaRects().left.posX_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().left.posY_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().left.width_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().left.height_ << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "WaterFall_T: " + << cutoutInfo->GetWaterfallDisplayAreaRects().top.posX_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().top.posY_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().top.width_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().top.height_ << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "WaterFall_R: " + << cutoutInfo->GetWaterfallDisplayAreaRects().right.posX_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().right.posY_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().right.width_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().right.height_ << std::endl; + oss << std::left << std::setw(LINE_WIDTH) << "WaterFall_B: " + << cutoutInfo->GetWaterfallDisplayAreaRects().bottom.posX_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().bottom.posY_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().bottom.width_ << ", " + << cutoutInfo->GetWaterfallDisplayAreaRects().bottom.height_ << std::endl; + + std::vector boundingRects = cutoutInfo->GetBoundingRects(); + oss << std::left << std::setw(LINE_WIDTH) << "BoundingRects: "; + for (auto rect : boundingRects) { + oss << "[" << rect.posX_ << ", " << rect.posY_ << ", " << rect.width_ << ", " << rect.height_ << "] "; + } + oss << std::endl; + dumpInfo_.append(oss.str()); +} + void ScreenSessionDumper::DumpScreenInfoById(ScreenId id) { std::ostringstream oss; @@ -105,10 +255,6 @@ void ScreenSessionDumper::DumpScreenInfoById(ScreenId id) WLOGFE("screenInfo nullptr. screen id: %{public}" PRIu64"", id); return; } - auto modes = screenInfo->GetModes(); - auto modeId = screenInfo->GetModeId(); - oss << std::left << std::setw(LINE_WIDTH) << "Name: " - << screenInfo->GetName() << std::endl; oss << std::left << std::setw(LINE_WIDTH) << "VirtualWidth: " << screenInfo->GetVirtualWidth() << std::endl; oss << std::left << std::setw(LINE_WIDTH) << "VirtualHeight: " @@ -129,19 +275,6 @@ void ScreenSessionDumper::DumpScreenInfoById(ScreenId id) << static_cast(screenInfo->GetSourceMode()) << std::endl; oss << std::left << std::setw(LINE_WIDTH) << "ScreenType: " << static_cast(screenInfo->GetType()) << std::endl; - oss << std::left << std::setw(LINE_WIDTH) << "ModeId: " << modeId << std::endl; - if (modes.size() > modeId) { - oss << std::left << std::setw(LINE_WIDTH) << "modes: " - << modes[modeId]->id_ << std::endl; - oss << std::left << std::setw(LINE_WIDTH) << "modes: " - << modes[modeId]->width_ << std::endl; - oss << std::left << std::setw(LINE_WIDTH) << "modes: " - << modes[modeId]->height_ << std::endl; - oss << std::left << std::setw(LINE_WIDTH) << "modes: " - << modes[modeId]->refreshRate_ << std::endl; - } else { - WLOGFW("invalid modes size: %{public}u ", static_cast(modes.size())); - } dumpInfo_.append(oss.str()); } -- Gitee From 549716274d5513429d603809de9627a5ecfd4e9d Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 18 Mar 2024 09:27:51 +0800 Subject: [PATCH 060/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/test/unittest/window_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 1820f3be4..58bcfc24a 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -118,7 +118,7 @@ HWTEST_F(WindowTest, Create04, Function | SmallTest | Level2) */ HWTEST_F(WindowTest, CreatePiP, Function | SmallTest | Level2) { - sptr option = nullptr; + sptr windowOption = nullptr; PiPTemplateInfo pipTemplateInfo; ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); windowOption = new WindowOption(); -- Gitee From 61d174a40541b85c36fea33f1395f4e11a8b9ecd Mon Sep 17 00:00:00 2001 From: chengzhen Date: Mon, 18 Mar 2024 02:47:37 +0000 Subject: [PATCH 061/385] update wm/src/window_scene_session_impl.cpp. Signed-off-by: chengzhen --- wm/src/window_scene_session_impl.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 6a286ae6d..49d518c71 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -112,11 +112,10 @@ sptr WindowSceneSessionImpl::FindParentSessionByParentId(uint item.second.second->GetProperty()->GetWindowName().c_str(), parentId, GetProperty()->GetPersistentId()); return item.second.second; - } else if (WindowHelper::IsSubWindow(item.second.second->GetType())) { - auto granParendId = item.second.second->GetParentId(); - if (isSessionMainWindow(granParendId)) { - return item.second.second; - } + } else if (WindowHelper::IsSubWindow(item.second.second->GetType()) && + isSessionMainWindow(item.second.second->GetParentId())) { + // subwindow grandparent is mainwindow + return item.second.second; } } } -- Gitee From 29474fbf013f081dcfc5db75da49f093a85c5c29 Mon Sep 17 00:00:00 2001 From: chyyy0213 Date: Fri, 15 Mar 2024 16:15:14 +0800 Subject: [PATCH 062/385] =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=8E=87=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chyyy0213 Change-Id: Icda5a3933ee550cf08103cf4f5f7ee43c2db35bc Signed-off-by: chyyy0213 --- window_scene/session/host/src/scene_session.cpp | 2 +- wm/src/window_session_impl.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 06650f245..d9a20fdeb 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -419,7 +419,7 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason, return WSError::WS_ERROR_DESTROYED_OBJECT; } if (session->winRect_ == rect) { - TLOGI(WmsLogTag::WMS_LAYOUT, "skip same rect update id:%{public}d rect:%{public}s!", + TLOGD(WmsLogTag::WMS_LAYOUT, "skip same rect update id:%{public}d rect:%{public}s!", session->GetPersistentId(), rect.ToString().c_str()); return WSError::WS_OK; } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 6f59268fc..265b0ad44 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -608,9 +608,15 @@ void WindowSessionImpl::UpdateViewportConfig(const Rect& rect, WindowSizeChangeR config.SetDensity(density); config.SetOrientation(orientation); uiContent_->UpdateViewportConfig(config, reason, rsTransaction); - TLOGI(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, reason:%{public}d, windowRect:[%{public}d, %{public}d, \ - %{public}u, %{public}u], orientation: %{public}d", GetPersistentId(), reason, rect.posX_, rect.posY_, - rect.width_, rect.height_, orientation); + if (WindowHelper::IsUIExtensionWindow(GetType())) { + TLOGD(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, reason:%{public}d, windowRect:[%{public}d, %{public}d, \ + %{public}u, %{public}u], orientation: %{public}d", GetPersistentId(), reason, rect.posX_, rect.posY_, + rect.width_, rect.height_, orientation); + } else { + TLOGI(WmsLogTag::WMS_LAYOUT, "Id:%{public}d, reason:%{public}d, windowRect:[%{public}d, %{public}d, \ + %{public}u, %{public}u], orientation: %{public}d", GetPersistentId(), reason, rect.posX_, rect.posY_, + rect.width_, rect.height_, orientation); + } } int32_t WindowSessionImpl::GetFloatingWindowParentId() -- Gitee From aa60368a5adb2473054d1f2721d33b2a91b62bef Mon Sep 17 00:00:00 2001 From: db Date: Wed, 13 Mar 2024 11:21:04 +0800 Subject: [PATCH 063/385] update log format Signed-off-by: db --- .../js_scene_session.cpp | 15 +++--- .../js_scene_session_manager.cpp | 38 +++++++-------- .../src/scene_session_manager.cpp | 46 ++++++++++--------- 3 files changed, 51 insertions(+), 48 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 5a7c939e7..aa60a86f4 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -547,7 +547,7 @@ void JsSceneSession::ProcessTerminateSessionRegister() }; auto session = weakSession_.promote(); if (session == nullptr) { - WLOGFE("session is nullptr"); + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr"); return; } session->SetTerminateSessionListener(func); @@ -563,7 +563,7 @@ void JsSceneSession::ProcessTerminateSessionRegisterNew() }; auto session = weakSession_.promote(); if (session == nullptr) { - WLOGFE("session is nullptr"); + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr"); return; } session->SetTerminateSessionListenerNew(func); @@ -579,7 +579,7 @@ void JsSceneSession::ProcessTerminateSessionRegisterTotal() }; auto session = weakSession_.promote(); if (session == nullptr) { - WLOGFE("session is nullptr"); + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr"); return; } session->SetTerminateSessionListenerTotal(func); @@ -595,7 +595,7 @@ void JsSceneSession::ProcessPendingSessionToForegroundRegister() }; auto session = weakSession_.promote(); if (session == nullptr) { - WLOGFE("session is nullptr"); + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr"); return; } session->SetPendingSessionToForegroundListener(func); @@ -612,7 +612,7 @@ void JsSceneSession::ProcessPendingSessionToBackgroundForDelegatorRegister() }; auto session = weakSession_.promote(); if (session == nullptr) { - WLOGFE("session is nullptr"); + TLOGE(WmsLogTag::WMS_LIFE, "session is nullptr"); return; } session->SetPendingSessionToBackgroundForDelegatorListener(func); @@ -1319,7 +1319,7 @@ void JsSceneSession::OnSessionStateChange(const SessionState& state) { auto session = weakSession_.promote(); if (session == nullptr) { - WLOGFW("[WMSLife] session is nullptr"); + TLOGW(WmsLogTag::WMS_LIFE, "session is nullptr"); return; } @@ -1328,7 +1328,8 @@ void JsSceneSession::OnSessionStateChange(const SessionState& state) std::shared_lock lock(jsCbMapMutex_); auto iter = jsCbMap_.find(SESSION_STATE_CHANGE_CB); if (iter == jsCbMap_.end()) { - WLOGFW("[WMSLife] Not find sessionStateChangeCallback, id: %{public}d", session->GetPersistentId()); + TLOGW(WmsLogTag::WMS_LIFE, "Not find sessionStateChangeCallback, id: %{public}d", + session->GetPersistentId()); return; } jsCallBack = iter->second; 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 e718371b0..2b555b743 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 @@ -513,21 +513,21 @@ napi_value JsSceneSessionManager::UpdateSceneSessionWant(napi_env env, napi_call napi_value JsSceneSessionManager::RequestSceneSessionActivation(napi_env env, napi_callback_info info) { - WLOGD("[NAPI]RequestSceneSessionActivation"); + TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]"); JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnRequestSceneSessionActivation(env, info) : nullptr; } napi_value JsSceneSessionManager::RequestSceneSessionBackground(napi_env env, napi_callback_info info) { - WLOGI("[NAPI]RequestSceneSessionBackground"); + TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]"); JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnRequestSceneSessionBackground(env, info) : nullptr; } napi_value JsSceneSessionManager::RequestSceneSessionDestruction(napi_env env, napi_callback_info info) { - WLOGI("[NAPI]RequestSceneSessionDestruction"); + TLOGD(WmsLogTag::WMS_LIFE, "[NAPI]"); JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnRequestSceneSessionDestruction(env, info) : nullptr; } @@ -1130,18 +1130,18 @@ napi_value JsSceneSessionManager::OnUpdateSceneSessionWant(napi_env env, napi_ca napi_value JsSceneSessionManager::OnRequestSceneSessionActivation(napi_env env, napi_callback_info info) { - WLOGD("[NAPI]OnRequestSceneSessionActivation"); + TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < ARGC_TWO) { // 2: params num - WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Argc is invalid: %{public}zu", argc); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "InputInvalid")); return NapiGetUndefined(env); } napi_value jsSceneSessionObj = argv[0]; if (jsSceneSessionObj == nullptr) { - WLOGFE("[NAPI]Failed to get js scene session object"); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to get js scene session object"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "InputInvalid")); return NapiGetUndefined(env); } @@ -1149,13 +1149,13 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionActivation(napi_env env, napi_unwrap(env, jsSceneSessionObj, &pointerResult); auto jsSceneSession = static_cast(pointerResult); if (jsSceneSession == nullptr) { - WLOGFE("[NAPI]Failed to get scene session from js object"); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to get scene session from js object"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "InputInvalid")); return NapiGetUndefined(env); } sptr sceneSession = jsSceneSession->GetNativeSession(); if (sceneSession == nullptr) { - WLOGFE("[NAPI]sceneSession is nullptr"); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]sceneSession is nullptr"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_SYSTEM_ABNORMALLY), "sceneSession is nullptr")); return NapiGetUndefined(env); @@ -1176,13 +1176,13 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionActivation(napi_env env, napi_value JsSceneSessionManager::OnRequestSceneSessionBackground(napi_env env, napi_callback_info info) { - WLOGI("[NAPI]OnRequestSceneSessionBackground"); + TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]"); WSErrorCode errCode = WSErrorCode::WS_OK; size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < ARGC_ONE) { // 1: params num - WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Argc is invalid: %{public}zu", argc); errCode = WSErrorCode::WS_ERROR_INVALID_PARAM; } @@ -1190,14 +1190,14 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionBackground(napi_env env, if (errCode == WSErrorCode::WS_OK) { napi_value jsSceneSessionObj = argv[0]; if (jsSceneSessionObj == nullptr) { - WLOGFE("[NAPI]Failed to get js scene session object"); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to get js scene session object"); errCode = WSErrorCode::WS_ERROR_INVALID_PARAM; } else { void* pointerResult = nullptr; napi_unwrap(env, jsSceneSessionObj, &pointerResult); auto jsSceneSession = static_cast(pointerResult); if (jsSceneSession == nullptr) { - WLOGFE("[NAPI]Failed to get scene session from js object"); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to get scene session from js object"); errCode = WSErrorCode::WS_ERROR_INVALID_PARAM; } else { sceneSession = jsSceneSession->GetNativeSession(); @@ -1205,7 +1205,7 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionBackground(napi_env env, } } if (sceneSession == nullptr) { - WLOGFE("[NAPI]sceneSession is nullptr"); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]sceneSession is nullptr"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_SYSTEM_ABNORMALLY), "sceneSession is nullptr")); return NapiGetUndefined(env); @@ -1235,20 +1235,20 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionBackground(napi_env env, napi_value JsSceneSessionManager::OnRequestSceneSessionDestruction(napi_env env, napi_callback_info info) { - WLOGI("[NAPI]OnRequestSceneSessionDestruction"); + TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]"); WSErrorCode errCode = WSErrorCode::WS_OK; size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < ARGC_ONE) { - WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Argc is invalid: %{public}zu", argc); errCode = WSErrorCode::WS_ERROR_INVALID_PARAM; } bool needRemoveSession = false; if (argc == ARGC_TWO && GetType(env, argv[1]) == napi_boolean) { ConvertFromJsValue(env, argv[1], needRemoveSession); - WLOGFD("[NAPI]needRemoveSession: %{public}u", needRemoveSession); + TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]needRemoveSession: %{public}u", needRemoveSession); } sptr sceneSession = nullptr; @@ -1256,14 +1256,14 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionDestruction(napi_env env, if (errCode == WSErrorCode::WS_OK) { napi_value jsSceneSessionObj = argv[0]; if (jsSceneSessionObj == nullptr) { - WLOGFE("[NAPI]Failed to get js scene session object"); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to get js scene session object"); errCode = WSErrorCode::WS_ERROR_INVALID_PARAM; } else { void* pointerResult = nullptr; napi_unwrap(env, jsSceneSessionObj, &pointerResult); jsSceneSession = static_cast(pointerResult); if (jsSceneSession == nullptr) { - WLOGFE("[NAPI]Failed to get scene session from js object"); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to get scene session from js object"); errCode = WSErrorCode::WS_ERROR_INVALID_PARAM; } else { sceneSession = jsSceneSession->GetNativeSession(); @@ -1272,7 +1272,7 @@ napi_value JsSceneSessionManager::OnRequestSceneSessionDestruction(napi_env env, } } if (sceneSession == nullptr) { - WLOGFE("[NAPI]sceneSession is nullptr"); + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]sceneSession is nullptr"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_SYSTEM_ABNORMALLY), "sceneSession is nullptr")); return NapiGetUndefined(env); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 2e1b3da6b..035508bb8 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1249,8 +1249,8 @@ std::future SceneSessionManager::RequestSceneSessionActivation( auto persistentId = scnSession->GetPersistentId(); scnSession->NotifyForegroundInteractiveStatus(true); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:RequestSceneSessionActivation(%d )", persistentId); - TLOGI(WmsLogTag::WMS_MAIN, "active persistentId: %{public}d isSystem_:%{public}u", - persistentId, static_cast(scnSession->GetSessionInfo().isSystem_)); + TLOGI(WmsLogTag::WMS_MAIN, "active persistentId: %{public}d isSystem_:%{public}u, isNewActive:%{public}d", + persistentId, static_cast(scnSession->GetSessionInfo().isSystem_), isNewActive); if (!GetSceneSession(persistentId)) { TLOGE(WmsLogTag::WMS_MAIN, "session is invalid with %{public}d", persistentId); promise->set_value(static_cast(WSError::WS_ERROR_INVALID_SESSION)); @@ -2044,16 +2044,16 @@ void SceneSessionManager::NotifyCreateSpecificSession(sptr newSess TLOGD(WmsLogTag::WMS_LIFE, "Create system session, id:%{public}d, type: %{public}d", newSession->GetPersistentId(), type); } else { - WLOGFW("[WMSLife] Didn't create jsSceneSession for this system type, id:%{public}d, " - "type: %{public}d", newSession->GetPersistentId(), type); + TLOGW(WmsLogTag::WMS_LIFE, "Didn't create jsSceneSession for this system type, id:%{public}d, " + "type:%{public}d", newSession->GetPersistentId(), type); return; } } else if (SessionHelper::IsSubWindow(type)) { NotifyCreateSubSession(property->GetParentPersistentId(), newSession); - TLOGD(WmsLogTag::WMS_LIFE, "Notify sub jsSceneSession, id:%{public}d, parentId: %{public}d, type: %{public}d", + TLOGD(WmsLogTag::WMS_LIFE, "Notify sub jsSceneSession, id:%{public}d, parentId:%{public}d, type:%{public}d", newSession->GetPersistentId(), property->GetParentPersistentId(), type); } else { - WLOGFW("[WMSLife] Invalid session type, id:%{public}d, type: %{public}d", + TLOGW(WmsLogTag::WMS_LIFE, "Invalid session type, id:%{public}d, type:%{public}d", newSession->GetPersistentId(), type); } } @@ -2066,7 +2066,7 @@ void SceneSessionManager::NotifyCreateSubSession(int32_t persistentId, sptr& auto task = [this, info]() { auto scnSession = GetSceneSession(info.persistentId_); if (scnSession == nullptr) { - WLOGFW("[WMSLife]NotifySessionExceptionFunc, Not found session, id: %{public}d", info.persistentId_); + TLOGW(WmsLogTag::WMS_LIFE, "NotifySessionExceptionFunc, Not found session, id: %{public}d", + info.persistentId_); return; } if (listenerController_ == nullptr) { - WLOGFW("[WMSLife]NotifySessionExceptionFunc, listenerController_ is nullptr"); + TLOGW(WmsLogTag::WMS_LIFE, "NotifySessionExceptionFunc, listenerController_ is nullptr"); return; } if (scnSession->GetSessionInfo().isSystem_) { - WLOGFW("[WMSLife]NotifySessionExceptionFunc, id: %{public}d is system", scnSession->GetPersistentId()); + TLOGW(WmsLogTag::WMS_LIFE, "NotifySessionExceptionFunc, id: %{public}d is system", + scnSession->GetPersistentId()); return; } TLOGI(WmsLogTag::WMS_LIFE, "NotifySessionExceptionFunc, errorCode: %{public}d, id: %{public}d", @@ -4839,15 +4841,15 @@ WSError SceneSessionManager::GetAbilityInfosFromBundleInfo(std::vector info, bool needStartCaller) { if (info == nullptr) { - WLOGFI("sessionInfo is nullptr."); + TLOGI(WmsLogTag::WMS_LIFE, "sessionInfo is nullptr."); return WSError::WS_ERROR_INVALID_PARAM; } - WLOGFI("run TerminateSessionNew, bundleName=%{public}s, needStartCaller=%{public}d", + TLOGI(WmsLogTag::WMS_LIFE, "bundleName=%{public}s, needStartCaller=%{public}d", info->want.GetElement().GetBundleName().c_str(), needStartCaller); auto task = [this, info, needStartCaller]() { sptr sceneSession = FindSessionByToken(info->sessionToken); if (sceneSession == nullptr) { - WLOGFE("fail to find session by token."); + TLOGE(WmsLogTag::WMS_LIFE, "TerminateSessionNew:fail to find session by token."); return WSError::WS_ERROR_INVALID_PARAM; } const WSError& errCode = sceneSession->TerminateSessionNew(info, needStartCaller); @@ -5870,13 +5872,13 @@ void SceneSessionManager::PreloadInLakeApp(const std::string& bundleName) WSError SceneSessionManager::PendingSessionToForeground(const sptr &token) { - WLOGFI("run PendingSessionToForeground"); + TLOGI(WmsLogTag::WMS_LIFE, "run PendingSessionToForeground"); auto task = [this, &token]() { auto session = FindSessionByToken(token); if (session != nullptr) { return session->PendingSessionToForeground(); } - WLOGFE("fail to find token"); + TLOGE(WmsLogTag::WMS_LIFE, "PendingSessionToForeground:fail to find token"); return WSError::WS_ERROR_INVALID_PARAM; }; return taskScheduler_->PostSyncTask(task, "PendingSessionToForeground"); @@ -5889,7 +5891,7 @@ WSError SceneSessionManager::PendingSessionToBackgroundForDelegator(const sptrPendingSessionToBackgroundForDelegator(); } - WLOGFE("fail to find token"); + TLOGE(WmsLogTag::WMS_LIFE, "PendingSessionToBackgroundForDelegator:fail to find token"); return WSError::WS_ERROR_INVALID_PARAM; }; return taskScheduler_->PostSyncTask(task, "PendingSessionToBackgroundForDelegator"); @@ -6400,13 +6402,13 @@ WSError SceneSessionManager::UnlockSession(int32_t sessionId) WSError SceneSessionManager::MoveSessionsToForeground(const std::vector& sessionIds, int32_t topSessionId) { - WLOGFI("run MoveSessionsToForeground"); + TLOGI(WmsLogTag::WMS_LIFE, "run"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { - WLOGFE("The caller is not system-app, can not use system-api"); + TLOGE(WmsLogTag::WMS_LIFE, "The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; } if (!SessionPermission::VerifySessionPermission()) { - WLOGFE("The caller has not permission granted"); + TLOGE(WmsLogTag::WMS_LIFE, "The caller has not permission granted"); return WSError::WS_ERROR_INVALID_PERMISSION; } @@ -6416,13 +6418,13 @@ WSError SceneSessionManager::MoveSessionsToForeground(const std::vector WSError SceneSessionManager::MoveSessionsToBackground(const std::vector& sessionIds, std::vector& result) { - WLOGFI("run MoveSessionsToBackground"); + TLOGI(WmsLogTag::WMS_LIFE, "run"); if (!SessionPermission::JudgeCallerIsAllowedToUseSystemAPI()) { - WLOGFE("The caller is not system-app, can not use system-api"); + TLOGE(WmsLogTag::WMS_LIFE, "The caller is not system-app, can not use system-api"); return WSError::WS_ERROR_NOT_SYSTEM_APP; } if (!SessionPermission::VerifySessionPermission()) { - WLOGFE("The caller has not permission granted"); + TLOGE(WmsLogTag::WMS_LIFE, "The caller has not permission granted"); return WSError::WS_ERROR_INVALID_PERMISSION; } -- Gitee From 9f44e90a57ad60d82dd367f305cfd99320bbb132 Mon Sep 17 00:00:00 2001 From: yusong Date: Mon, 18 Mar 2024 06:08:46 +0000 Subject: [PATCH 064/385] add uiextension water mark Signed-off-by: yusong --- interfaces/innerkits/wm/window.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 8f1fec828..d0808ba89 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -643,20 +643,6 @@ public: * @return WM_OK means remove success, others means failed. */ virtual WMError RemoveWindowFlag(WindowFlag flag) { return WMError::WM_OK; } - /** - * @brief Add uiextension window flag. - * - * @param flag Flag of uiextension window. - * @return WM_OK means add success, others means failed. - */ - virtual WMError AddExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } - /** - * @brief Remove uiextension window flag. - * - * @param flag Flag of uiextension window - * @return WM_OK means remove success, others means failed. - */ - virtual WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } /** * @brief Set window flag. * @@ -1686,6 +1672,22 @@ public: * @return WMError */ virtual WMError Recover(uint32_t reason) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + + /** + * @brief Add uiextension window flag. + * + * @param flag Flag of uiextension window. + * @return WM_OK means add success, others means failed. + */ + virtual WMError AddExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + + /** + * @brief Remove uiextension window flag. + * + * @param flag Flag of uiextension window + * @return WM_OK means remove success, others means failed. + */ + virtual WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } }; } } -- Gitee From 6dccfad5819ec69a96d624f742103299ae198495 Mon Sep 17 00:00:00 2001 From: chengzhen Date: Mon, 18 Mar 2024 06:49:31 +0000 Subject: [PATCH 065/385] update wm/include/window_scene_session_impl.h. Signed-off-by: chengzhen --- wm/include/window_scene_session_impl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 00ff27518..d9bfd25e5 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -142,6 +142,7 @@ public: protected: void DestroySubWindow(); WMError CreateAndConnectSpecificSession(); + WMError CreateSystemWindow(WindowType type); WMError RecoverAndConnectSpecificSession(); WMError RecoverAndReconnectSceneSession(); sptr FindParentSessionByParentId(uint32_t parentId); -- Gitee From 45fc1b0ba47623b7ea7334272ff7586a1c87569f Mon Sep 17 00:00:00 2001 From: chengzhen Date: Mon, 18 Mar 2024 07:00:26 +0000 Subject: [PATCH 066/385] update wm/src/window_scene_session_impl.cpp. Signed-off-by: chengzhen --- wm/src/window_scene_session_impl.cpp | 63 ++++++++++++++++------------ 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 49d518c71..792ac18e8 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -186,33 +186,9 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() SingletonContainer::Get().CreateAndConnectSpecificSession(iSessionStage, eventChannel, surfaceNode_, property_, persistentId, session, windowSystemConfig_, token); } else { // system window - if (WindowHelper::IsAppFloatingWindow(type) || WindowHelper::IsPipWindow(type) || - (type == WindowType::WINDOW_TYPE_TOAST)) { - property_->SetParentPersistentId(GetFloatingWindowParentId()); - TLOGI(WmsLogTag::WMS_SYSTEM, "set parentId: %{public}d, type: %{public}d", - property_->GetParentPersistentId(), type); - auto mainWindow = FindMainWindowWithContext(); - property_->SetFloatingWindowAppType(mainWindow != nullptr ? true : false); - } else if (type == WindowType::WINDOW_TYPE_DIALOG) { - auto mainWindow = FindMainWindowWithContext(); - if (mainWindow != nullptr) { - property_->SetParentPersistentId(mainWindow->GetPersistentId()); - TLOGI(WmsLogTag::WMS_DIALOG, "Set parentId, parentId:%{public}d", mainWindow->GetPersistentId()); - } - } else if (WindowHelper::IsSystemSubWindow(type)) { - auto parentSession = FindParentSessionByParentId(property_->GetParentId()); - if (parentSession == nullptr || parentSession->GetHostSession() == nullptr) { - TLOGE(WmsLogTag::WMS_LIFE, "parent of system sub window, name: %{public}s, type: %{public}d", - property_->GetWindowName().c_str(), type); - return WMError::WM_ERROR_NULLPTR; - } - if (WindowHelper::IsSystemSubWindow(parentSession->GetType())) { - TLOGE(WmsLogTag::WMS_LIFE, "parent is system sub window, name: %{public}s, type: %{public}d", - property_->GetWindowName().c_str(), type); - return WMError::WM_ERROR_INVALID_TYPE; - } - // set parent persistentId - property_->SetParentPersistentId(parentSession->GetPersistentId()); + WMError createSystemWindowRet = CreateSystemWindow(type); + if(createSystemWindowRet != WMError::WM_OK) { + return createSystemWindowRet; } PreProcessCreate(); SingletonContainer::Get().CreateAndConnectSpecificSession(iSessionStage, eventChannel, @@ -234,6 +210,39 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() return WMError::WM_OK; } +WMError WindowSceneSessionImpl::CreateSystemWindow(WindowType type) +{ + if (WindowHelper::IsAppFloatingWindow(type) || WindowHelper::IsPipWindow(type) || + (type == WindowType::WINDOW_TYPE_TOAST)) { + property_->SetParentPersistentId(GetFloatingWindowParentId()); + TLOGI(WmsLogTag::WMS_SYSTEM, "set parentId: %{public}d, type: %{public}d", + property_->GetParentPersistentId(), type); + auto mainWindow = FindMainWindowWithContext(); + property_->SetFloatingWindowAppType(mainWindow != nullptr ? true : false); + } else if (type == WindowType::WINDOW_TYPE_DIALOG) { + auto mainWindow = FindMainWindowWithContext(); + if (mainWindow != nullptr) { + property_->SetParentPersistentId(mainWindow->GetPersistentId()); + TLOGI(WmsLogTag::WMS_DIALOG, "Set parentId, parentId:%{public}d", mainWindow->GetPersistentId()); + } + } else if (WindowHelper::IsSystemSubWindow(type)) { + auto parentSession = FindParentSessionByParentId(property_->GetParentId()); + if (parentSession == nullptr || parentSession->GetHostSession() == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "parent of system sub window, name: %{public}s, type: %{public}d", + property_->GetWindowName().c_str(), type); + return WMError::WM_ERROR_NULLPTR; + } + if (WindowHelper::IsSystemSubWindow(parentSession->GetType())) { + TLOGE(WmsLogTag::WMS_LIFE, "parent is system sub window, name: %{public}s, type: %{public}d", + property_->GetWindowName().c_str(), type); + return WMError::WM_ERROR_INVALID_TYPE; + } + // set parent persistentId + property_->SetParentPersistentId(parentSession->GetPersistentId()); + } + return WMError::WM_OK; +} + WMError WindowSceneSessionImpl::RecoverAndConnectSpecificSession() { if (property_ == nullptr) { -- Gitee From ae8bf370164bb9c6583b6c356a8550daba054838 Mon Sep 17 00:00:00 2001 From: lijie176 Date: Mon, 18 Mar 2024 15:04:45 +0800 Subject: [PATCH 067/385] =?UTF-8?q?=E5=A2=9E=E5=8A=A0uiextension=E7=9A=84?= =?UTF-8?q?=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F=E8=B6=85=E6=97=B6=E9=80=9A?= =?UTF-8?q?=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijie176 --- .../sessioninterface_fuzzer.cpp | 2 ++ window_scene/session/host/include/session.h | 2 ++ .../host/include/zidl/session_interface.h | 1 + .../include/zidl/session_ipc_interface_code.h | 1 + .../session/host/include/zidl/session_proxy.h | 1 + .../session/host/include/zidl/session_stub.h | 1 + window_scene/session/host/src/session.cpp | 11 +++++++++++ .../session/host/src/zidl/session_proxy.cpp | 19 +++++++++++++++++++ .../session/host/src/zidl/session_stub.cpp | 14 ++++++++++++++ window_scene/test/mock/mock_session_stub.h | 1 + .../test/unittest/session_proxy_test.cpp | 15 +++++++++++++++ .../test/unittest/session_stub_test.cpp | 2 ++ window_scene/test/unittest/session_test.cpp | 14 ++++++++++++++ 13 files changed, 84 insertions(+) diff --git a/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp b/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp index 4ed425e2f..90441c6c8 100644 --- a/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp +++ b/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp @@ -271,6 +271,8 @@ void ProxyInterfaceFuzzTestPart3(const uint8_t* data, size_t size) proxy->TransferExtensionData(*wantParams); proxy->NotifyRemoteReady(); proxy->NotifyExtensionDied(); + int32_t errorCode = 1; + proxy->NotifyExtensionTimeOut(errorCode); } void ProxyInterfaceFuzzTest(const uint8_t* data, size_t size) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 48fbd5275..b335a448e 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -86,6 +86,7 @@ public: virtual void OnBackground() = 0; virtual void OnDisconnect() = 0; virtual void OnExtensionDied() = 0; + virtual void OnExtensionTimeOut(int32_t errorCode) {}; virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) = 0; }; @@ -126,6 +127,7 @@ public: void NotifyBackground(); void NotifyDisconnect(); void NotifyExtensionDied() override; + void NotifyExtensionTimeOut(int32_t errorCode) override; void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index 30179961f..e3778acf1 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -78,6 +78,7 @@ public: } virtual void NotifyRemoteReady() {} virtual void NotifyExtensionDied() {} + virtual void NotifyExtensionTimeOut(int32_t errorCode) {} virtual void TriggerBindModalUIExtension() {} virtual void NotifySyncOn() {} virtual void NotifyAsyncOn() {} diff --git a/window_scene/session/host/include/zidl/session_ipc_interface_code.h b/window_scene/session/host/include/zidl/session_ipc_interface_code.h index f5cc8d8f0..69ff541a5 100644 --- a/window_scene/session/host/include/zidl/session_ipc_interface_code.h +++ b/window_scene/session/host/include/zidl/session_ipc_interface_code.h @@ -60,6 +60,7 @@ enum class SessionInterfaceCode { TRANS_ID_NOTIFY_SYNC_ON, TRANS_ID_NOTIFY_REPORT_ACCESSIBILITY_EVENT, TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION, + TRANS_ID_NOTIFY_EXTENSION_TIMEOUT, //PictureInPicture TRANS_ID_NOTIFY_PIP_WINDOW_PREPARE_CLOSE = 800, diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index 63800c72f..771e6c60d 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -67,6 +67,7 @@ public: void NotifySyncOn() override; void NotifyAsyncOn() override; void NotifyExtensionDied() override; + void NotifyExtensionTimeOut(int32_t errorCode) override; void TriggerBindModalUIExtension() override; void NotifyPiPWindowPrepareClose() override; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 21c84ef29..1698b438e 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -72,6 +72,7 @@ private: int HandleNotifySyncOn(MessageParcel& data, MessageParcel& reply); int HandleNotifyAsyncOn(MessageParcel& data, MessageParcel& reply); int HandleNotifyExtensionDied(MessageParcel& data, MessageParcel& reply); + int HandleNotifyExtensionTimeOut(MessageParcel& data, MessageParcel& reply); int HandleTriggerBindModalUIExtension(MessageParcel& data, MessageParcel& reply); int HandleTransferAccessibilityEvent(MessageParcel& data, MessageParcel& reply); static const std::map stubFuncMap_; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 037513d16..9b562b216 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -339,6 +339,17 @@ void Session::NotifyExtensionDied() } } +void Session::NotifyExtensionTimeOut(int32_t errorCode) +{ + auto lifecycleListeners = GetListeners(); + std::lock_guard lock(lifecycleListenersMutex_); + for (auto& listener : lifecycleListeners) { + if (!listener.expired()) { + listener.lock()->OnExtensionTimeOut(errorCode); + } + } +} + void Session::NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) { diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 2555b4e82..6f21b8597 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -865,6 +865,25 @@ void SessionProxy::NotifyExtensionDied() } } +void SessionProxy::NotifyExtensionTimeOut(int32_t errorCode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return; + } + if (!data.WriteInt32(static_cast(errorCode))) { + WLOGFE("errorCode write failed."); + return; + } + if (Remote()->SendRequest(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_TIMEOUT), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + } +} + void SessionProxy::TriggerBindModalUIExtension() { MessageParcel data; diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 6c03add94..557a603ef 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -106,6 +106,8 @@ const std::map SessionStub::stubFuncMap_ { &SessionStub::HandleNotifySyncOn), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DIED), &SessionStub::HandleNotifyExtensionDied), + std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_TIMEOUT), + &SessionStub::HandleNotifyExtensionTimeOut), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION), &SessionStub::HandleTriggerBindModalUIExtension), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_REPORT_ACCESSIBILITY_EVENT), @@ -527,6 +529,18 @@ int SessionStub::HandleNotifyExtensionDied(MessageParcel& data, MessageParcel& r return ERR_NONE; } +int SessionStub::HandleNotifyExtensionTimeOut(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("HandleNotifyExtensionTimeOut called"); + int32_t errorCode = 0; + if (!data.ReadInt32(errorCode)) { + WLOGFE("Read eventId from parcel failed!"); + return ERR_INVALID_DATA; + } + NotifyExtensionTimeOut(errorCode); + return ERR_NONE; +} + int SessionStub::HandleTriggerBindModalUIExtension(MessageParcel& data, MessageParcel& reply) { WLOGFD("called"); diff --git a/window_scene/test/mock/mock_session_stub.h b/window_scene/test/mock/mock_session_stub.h index 3c44015a8..2c7e12be6 100644 --- a/window_scene/test/mock/mock_session_stub.h +++ b/window_scene/test/mock/mock_session_stub.h @@ -69,6 +69,7 @@ public: MOCK_METHOD2(HandleTransferExtensionData, int(MessageParcel &data, MessageParcel &reply)); MOCK_METHOD2(HandleNotifyRemoteReady, int(MessageParcel &data, MessageParcel &reply)); MOCK_METHOD2(HandleNotifyExtensionDied, int(MessageParcel &data, MessageParcel &reply)); + MOCK_METHOD2(HandleNotifyExtensionTimeOut, int(MessageParcel &data, MessageParcel &reply)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_proxy_test.cpp b/window_scene/test/unittest/session_proxy_test.cpp index 705a717ee..0d432247e 100644 --- a/window_scene/test/unittest/session_proxy_test.cpp +++ b/window_scene/test/unittest/session_proxy_test.cpp @@ -430,6 +430,21 @@ HWTEST_F(SessionProxyTest, NotifyExtensionDied, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionDied end"; } +/** + * @tc.name: NotifyExtensionTimeOut + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(SessionProxyTest, NotifyExtensionTimeOut, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeOut start"; + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); + sProxy->NotifyExtensionTimeOut(2); + + GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeOut end"; +} + /** * @tc.name: UpdateWindowAnimationFlag * @tc.desc: normal function diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index ba623d1e1..a067d26b7 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -172,6 +172,8 @@ HWTEST_F(SessionStubTest, sessionStubTest02, Function | SmallTest | Level2) ASSERT_EQ(0, res); res = session_->HandleNotifyExtensionDied(data, reply); ASSERT_EQ(0, res); + res = session_->HandleNotifyExtensionTimeOut(data, reply); + ASSERT_EQ(0, res); } /** diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index c937029e8..76204005d 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -1257,6 +1257,20 @@ HWTEST_F(WindowSessionTest, NotifyExtensionDied, Function | SmallTest | Level2) ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false)); } +/** + * @tc.name: NotifyExtensionTimeOut + * @tc.desc: NotifyExtensionTimeOut Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest, NotifyExtensionTimeOut, Function | SmallTest | Level2) +{ + ASSERT_NE(session_, nullptr); + session_->state_ = SessionState::STATE_DISCONNECT; + session_->NotifyExtensionTimeOut(3); + + ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->SetFocusable(false)); +} + /** * @tc.name: SetAspectRatio * @tc.desc: SetAspectRatio Test -- Gitee From 966ef5222734e1c24b8abb513c58deaa843dc6a6 Mon Sep 17 00:00:00 2001 From: chengzhen Date: Mon, 18 Mar 2024 07:22:07 +0000 Subject: [PATCH 068/385] update wm/src/window_scene_session_impl.cpp. Signed-off-by: chengzhen --- wm/src/window_scene_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 792ac18e8..bd24b6038 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -187,7 +187,7 @@ WMError WindowSceneSessionImpl::CreateAndConnectSpecificSession() surfaceNode_, property_, persistentId, session, windowSystemConfig_, token); } else { // system window WMError createSystemWindowRet = CreateSystemWindow(type); - if(createSystemWindowRet != WMError::WM_OK) { + if (createSystemWindowRet != WMError::WM_OK) { return createSystemWindowRet; } PreProcessCreate(); -- Gitee From 60f6ce473c1ca2e7193a777936178aa07d937b7f Mon Sep 17 00:00:00 2001 From: chehang Date: Mon, 18 Mar 2024 20:03:58 +0800 Subject: [PATCH 069/385] patch 1 Signed-off-by: chehang Change-Id: I1ae28501bf2702940a819993ac9cabb8d8634c6c --- window_scene/session/container/include/window_event_channel.h | 2 ++ window_scene/session/container/src/window_event_channel.cpp | 4 ++-- .../session/container/src/zidl/window_event_channel_stub.cpp | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/window_scene/session/container/include/window_event_channel.h b/window_scene/session/container/include/window_event_channel.h index 45cf4a526..5e24e860b 100644 --- a/window_scene/session/container/include/window_event_channel.h +++ b/window_scene/session/container/include/window_event_channel.h @@ -52,6 +52,8 @@ public: Accessibility::AccessibilityElementInfo& info) override; WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, int32_t action, int64_t baseParent) override; + WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, + int32_t eventType, int64_t timeMs) override; private: void PrintKeyEvent(const std::shared_ptr& event); diff --git a/window_scene/session/container/src/window_event_channel.cpp b/window_scene/session/container/src/window_event_channel.cpp index 326948fcb..2312ec142 100644 --- a/window_scene/session/container/src/window_event_channel.cpp +++ b/window_scene/session/container/src/window_event_channel.cpp @@ -263,8 +263,8 @@ WSError WindowEventChannel::TransferExecuteAction(int64_t elementId, return sessionStage_->NotifyExecuteAction(elementId, actionArguments, action, baseParent); } -WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, - int64_t timeMs) +WSError WindowEventChannel::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, + int32_t eventType, int64_t timeMs) { if (!sessionStage_) { WLOGFE("session stage is null!"); diff --git a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp index cd42a0d4f..631c7ae4b 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp @@ -52,6 +52,8 @@ const std::map WindowEventChannelStub::stu &WindowEventChannelStub::HandleTransferFocusMoveSearch), std::make_pair(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_EXECUTE_ACTION), &WindowEventChannelStub::HandleTransferExecuteAction), + std::make_pair(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_ACCESSIBILITY_HOVER_EVENT), + &WindowEventChannelStub::HandleTransferAccessibilityHoverEvent), }; int WindowEventChannelStub::OnRemoteRequest(uint32_t code, MessageParcel &data, -- Gitee From 4de48dec9abff26f79d8b29821609ddec487c7a5 Mon Sep 17 00:00:00 2001 From: ZhengJiangliang Date: Mon, 18 Mar 2024 22:03:56 +0800 Subject: [PATCH 070/385] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=B2=89=E6=B5=B8?= =?UTF-8?q?=E5=BC=8F=E6=97=A5=E5=BF=97=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ZhengJiangliang --- .../window_runtime/window_napi/js_window.cpp | 18 +++++++++--------- .../scene_session_manager/js_scene_session.cpp | 4 ++-- .../session/host/src/scene_session.cpp | 6 ++++-- wm/src/window_scene_session_impl.cpp | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 3c72ef10b..7bab46ae6 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -268,35 +268,35 @@ napi_value JsWindow::SetUIContent(napi_env env, napi_callback_info info) napi_value JsWindow::SetFullScreen(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_IMMS, "SetFullScreen"); + TLOGD(WmsLogTag::WMS_IMMS, "SetFullScreen"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetFullScreen(env, info) : nullptr; } napi_value JsWindow::SetLayoutFullScreen(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_IMMS, "SetLayoutFullScreen"); + TLOGD(WmsLogTag::WMS_IMMS, "SetLayoutFullScreen"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetLayoutFullScreen(env, info) : nullptr; } napi_value JsWindow::SetWindowLayoutFullScreen(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_IMMS, "SetWindowLayoutFullScreen"); + TLOGD(WmsLogTag::WMS_IMMS, "SetWindowLayoutFullScreen"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetWindowLayoutFullScreen(env, info) : nullptr; } napi_value JsWindow::SetSystemBarEnable(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_IMMS, "SetSystemBarEnable"); + TLOGD(WmsLogTag::WMS_IMMS, "SetSystemBarEnable"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetSystemBarEnable(env, info) : nullptr; } napi_value JsWindow::SetWindowSystemBarEnable(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_IMMS, "SetSystemBarEnable"); + TLOGD(WmsLogTag::WMS_IMMS, "SetSystemBarEnable"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetWindowSystemBarEnable(env, info) : nullptr; } @@ -310,28 +310,28 @@ napi_value JsWindow::SetSpecificSystemBarEnabled(napi_env env, napi_callback_inf napi_value JsWindow::SetSystemBarProperties(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_IMMS, "SetSystemBarProperties"); + TLOGD(WmsLogTag::WMS_IMMS, "SetSystemBarProperties"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetSystemBarProperties(env, info) : nullptr; } napi_value JsWindow::SetWindowSystemBarProperties(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_IMMS, "SetWindowSystemBarProperties"); + TLOGD(WmsLogTag::WMS_IMMS, "SetWindowSystemBarProperties"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetWindowSystemBarProperties(env, info) : nullptr; } napi_value JsWindow::GetAvoidArea(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_IMMS, "GetAvoidArea"); + TLOGD(WmsLogTag::WMS_IMMS, "GetAvoidArea"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetAvoidArea(env, info) : nullptr; } napi_value JsWindow::GetWindowAvoidAreaSync(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_IMMS, "GetWindowAvoidAreaSync"); + TLOGD(WmsLogTag::WMS_IMMS, "GetWindowAvoidAreaSync"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetWindowAvoidAreaSync(env, info) : nullptr; } diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index bb45243b5..e0ee4449f 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -1886,7 +1886,7 @@ void JsSceneSession::PendingSessionToBackgroundForDelegator(const SessionInfo& i void JsSceneSession::OnSystemBarPropertyChange(const std::unordered_map& propertyMap) { - TLOGI(WmsLogTag::WMS_IMMS, "[NAPI]OnSystemBarPropertyChange"); + TLOGD(WmsLogTag::WMS_IMMS, "[NAPI]OnSystemBarPropertyChange"); std::shared_ptr jsCallBack = nullptr; { std::shared_lock lock(jsCbMapMutex_); @@ -1910,7 +1910,7 @@ void JsSceneSession::OnSystemBarPropertyChange(const std::unordered_map jsCallBack = nullptr; { std::shared_lock lock(jsCbMapMutex_); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 72e3a4619..b9fcb9320 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -701,7 +701,8 @@ WSError SceneSession::OnNeedAvoid(bool status) TLOGE(WmsLogTag::WMS_IMMS, "session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } - TLOGI(WmsLogTag::WMS_IMMS, "SceneSession OnNeedAvoid status:%{public}d", static_cast(status)); + TLOGI(WmsLogTag::WMS_IMMS, "SceneSession OnNeedAvoid status:%{public}d, id:%{public}d", + static_cast(status), session->GetPersistentId()); if (session->sessionChangeCallback_ && session->sessionChangeCallback_->OnNeedAvoid_) { session->sessionChangeCallback_->OnNeedAvoid_(status); } @@ -894,7 +895,8 @@ AvoidArea SceneSession::GetAvoidAreaByType(AvoidAreaType type) return avoidArea; } default: { - TLOGI(WmsLogTag::WMS_IMMS, "cannot find avoidAreaType: %{public}u", type); + TLOGI(WmsLogTag::WMS_IMMS, "cannot find avoidAreaType:%{public}u, id:%{public}d", + type, session->GetPersistentId()); return avoidArea; } } diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index bc95f5473..bbf97e57b 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1403,10 +1403,10 @@ WMError WindowSceneSessionImpl::SetSystemBarProperty(WindowType type, const Syst GetWindowId(), static_cast(type), property.enable_, property.backgroundColor_, property.contentColor_); if (!((state_ > WindowState::STATE_INITIAL) && (state_ < WindowState::STATE_BOTTOM))) { - TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty window state is invalid"); + TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty windowId:%{public}u state is invalid", GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } else if (GetSystemBarPropertyByType(type) == property) { - TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty property is same"); + TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty windowId:%{public}u property is same", GetWindowId()); return WMError::WM_OK; } -- Gitee From e628a3d50f6845a06baa4ad521a4e917085f1ff1 Mon Sep 17 00:00:00 2001 From: cloud_nine Date: Tue, 19 Mar 2024 09:59:57 +0800 Subject: [PATCH 071/385] =?UTF-8?q?screen=20connection=20=E7=BB=B4?= =?UTF-8?q?=E6=B5=8B=E6=97=A5=E5=BF=97=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenyunjiu --- .../screen_session_manager/js_screen_session_manager.cpp | 1 + .../src/screen_session_manager_client.cpp | 1 + window_scene/session/screen/src/screen_session.cpp | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp index 06251d914..ce0dff323 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp @@ -168,6 +168,7 @@ napi_value JsScreenSessionManager::GetScreenSnapshot(napi_env env, napi_callback void JsScreenSessionManager::OnScreenConnected(const sptr& screenSession) { if (screenConnectionCallback_ == nullptr) { + WLOGE("[NAPI]screenConnectionCallback is nullptr"); return; } diff --git a/window_scene/screen_session_manager/src/screen_session_manager_client.cpp b/window_scene/screen_session_manager/src/screen_session_manager_client.cpp index e0f3c35e3..c811a0685 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager_client.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager_client.cpp @@ -69,6 +69,7 @@ void ScreenSessionManagerClient::RegisterScreenConnectionListener(IScreenConnect screenConnectionListener_ = listener; ConnectToServer(); + WLOGFI("Success to register screen connection listener"); } bool ScreenSessionManagerClient::CheckIfNeedConnectScreen(ScreenId screenId, ScreenId rsId, const std::string& name) diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 419653f2f..93f5311ae 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -30,7 +30,9 @@ constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_DMS_SCREEN_SESS ScreenSession::ScreenSession(ScreenId screenId, ScreenId rsId, const std::string& name, const ScreenProperty& property, const std::shared_ptr& displayNode) : name_(name), screenId_(screenId), rsId_(rsId), property_(property), displayNode_(displayNode) -{} +{ + WLOGFI("Success to create screenSession in constructor_0, screenid is %{public}" PRIu64"", screenId_); +} ScreenSession::ScreenSession(ScreenId screenId, const ScreenProperty& property, ScreenId defaultScreenId) : screenId_(screenId), defaultScreenId_(defaultScreenId), property_(property) @@ -112,6 +114,7 @@ void ScreenSession::RegisterScreenChangeListener(IScreenChangeListener* screenCh if (screenState_ == ScreenState::CONNECTION) { screenChangeListener->OnConnect(screenId_); } + WLOGFI("Success to register screen change listener."); } void ScreenSession::UnregisterScreenChangeListener(IScreenChangeListener* screenChangeListener) @@ -238,6 +241,10 @@ void ScreenSession::ReleaseDisplayNode() void ScreenSession::Connect() { screenState_ = ScreenState::CONNECTION; + if (screenChangeListenerList_.empty()) { + WLOGFE("screenChangeListenerList is empty."); + return; + } for (auto& listener : screenChangeListenerList_) { listener->OnConnect(screenId_); } -- Gitee From 4aca5bdd18d5129427d52980ff7df114852f4817 Mon Sep 17 00:00:00 2001 From: chehang Date: Tue, 19 Mar 2024 10:02:20 +0800 Subject: [PATCH 072/385] patch 2 Signed-off-by: chehang Change-Id: I1703387f458de1aff727027ca3511e9519bfd3ce --- .../include/zidl/session_stage_interface.h | 15 +++------------ window_scene/test/mock/mock_session_stage.h | 3 +++ window_scene/test/unittest/session_test.cpp | 10 +++++++++- wm/include/window_session_impl.h | 4 ++++ wm/src/window_session_impl.cpp | 16 ++++++++++++++++ 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index a0baed2b7..1fe748501 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -49,15 +49,9 @@ public: virtual WSError UpdateFocus(bool isFocused) = 0; virtual WSError NotifyDestroy() = 0; virtual WSError NotifyCloseExistPipWindow() = 0; - virtual WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) - { - return WSError::WS_OK; - } + virtual WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) = 0; virtual WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, - AAFwk::WantParams& reWantParams) - { - return WSErrorCode::WS_OK; - } + AAFwk::WantParams& reWantParams) = 0; virtual void NotifyOccupiedAreaChangeInfo(sptr info) = 0; virtual WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; virtual void NotifyScreenshot() = 0; @@ -71,10 +65,7 @@ public: virtual void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) = 0; virtual WSError UpdateTitleInTargetPos(bool isShow, int32_t height) = 0; virtual void NotifyTransformChange(const Transform& transform) = 0; - virtual WSError NotifyDialogStateChange(bool isForeground) - { - return WSError::WS_OK; - } + virtual WSError NotifyDialogStateChange(bool isForeground) = 0; // **Non** IPC interface diff --git a/window_scene/test/mock/mock_session_stage.h b/window_scene/test/mock/mock_session_stage.h index 33a5dd49c..67761eed6 100644 --- a/window_scene/test/mock/mock_session_stage.h +++ b/window_scene/test/mock/mock_session_stage.h @@ -34,6 +34,8 @@ public: MOCK_METHOD0(NotifyDestroy, WSError(void)); MOCK_METHOD1(UpdateFocus, WSError(bool isFocused)); MOCK_METHOD1(NotifyTransferComponentData, WSError(const AAFwk::WantParams& wantParams)); + MOCK_METHOD2(NotifyTransferComponentDataSync, WSErrorCode(const AAFwk::WantParams& wantParams, + AAFwk::WantParams& reWantParams)); MOCK_METHOD1(MarkProcessed, WSError(int32_t eventId)); MOCK_METHOD1(NotifyOccupiedAreaChangeInfo, void(sptr info)); MOCK_METHOD2(UpdateAvoidArea, WSError(const sptr& avoidArea, AvoidAreaType type)); @@ -50,6 +52,7 @@ public: MOCK_METHOD1(UpdateWindowDrawingContentInfo, void(const WindowDrawingContentInfo& info)); MOCK_METHOD1(NotifyWindowVisibility, WSError(bool isVisible)); MOCK_METHOD1(NotifyTransformChange, void(const Transform& transform)); + MOCK_METHOD1(NotifyDialogStateChange, WSError(bool isForeground)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index c937029e8..41c801b8b 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -56,6 +56,8 @@ public: Accessibility::AccessibilityElementInfo& info) override; WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, int32_t action, int64_t baseParent) override; + WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) override; sptr AsObject() override { @@ -124,6 +126,12 @@ WSError TestWindowEventChannel::TransferExecuteAction(int64_t elementId, return WSError::WS_OK; } +WSError TestWindowEventChannel::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, + int32_t eventType, int64_t timeMs) +{ + return WSError::WS_OK; +} + class WindowSessionTest : public testing::Test { public: static void SetUpTestCase(); @@ -2883,4 +2891,4 @@ HWTEST_F(WindowSessionTest, IsTerminated49, Function | SmallTest | Level2) } } // namespace Rosen -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index ec7db9123..8fdf97fc8 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -156,6 +156,9 @@ public: void UpdateTitleButtonVisibility(); WSError NotifyDestroy() override; WSError NotifyCloseExistPipWindow() override; + WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) override; + WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, + AAFwk::WantParams& reWantParams) override; void NotifyAvoidAreaChange(const sptr& avoidArea, AvoidAreaType type); WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; void NotifyTouchDialogTarget(int32_t posX = 0, int32_t posY = 0) override; @@ -175,6 +178,7 @@ public: void NotifySessionForeground(uint32_t reason, bool withAnimation) override; void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WSError UpdateTitleInTargetPos(bool isShow, int32_t height) override; + WSError NotifyDialogStateChange(bool isForeground) override; bool IsMainHandlerAvailable() const override; void UpdatePiPRect(const uint32_t width, const uint32_t height, PiPRectUpdateReason reason) override; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 6858f1045..511e4689e 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1861,6 +1861,17 @@ void WindowSessionImpl::NotifyAvoidAreaChange(const sptr& avoidArea, } } +WSError WindowSessionImpl::NotifyTransferComponentData(const AAFwk::WantParams& wantParams) +{ + return WSError::WS_OK; +} + +WSErrorCode WindowSessionImpl::NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, + AAFwk::WantParams& reWantParams) +{ + return WSErrorCode::WS_OK; +} + WSError WindowSessionImpl::UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) { TLOGI(WmsLogTag::WMS_IMMS, @@ -2382,6 +2393,11 @@ WSError WindowSessionImpl::UpdateTitleInTargetPos(bool isShow, int32_t height) return WSError::WS_OK; } +WSError WindowSessionImpl::NotifyDialogStateChange(bool isForeground) +{ + return WSError::WS_OK; +} + void WindowSessionImpl::UpdatePiPRect(const uint32_t width, const uint32_t height, PiPRectUpdateReason reason) { if (IsWindowSessionInvalid()) { -- Gitee From 5f74b845f89b0a8384d8363cbd05921a1fe2a0cb Mon Sep 17 00:00:00 2001 From: chehang Date: Tue, 19 Mar 2024 02:37:55 +0000 Subject: [PATCH 073/385] patch code check Signed-off-by: chehang --- .../container/src/zidl/window_event_channel_stub.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp index 631c7ae4b..0583d3a70 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp @@ -322,9 +322,11 @@ int WindowEventChannelStub::HandleTransferExecuteAction(MessageParcel& data, Mes int WindowEventChannelStub::HandleTransferAccessibilityHoverEvent(MessageParcel& data, MessageParcel& reply) { - float pointX, pointY; - int32_t sourceType, eventType; - int64_t timeMs; + float pointX = 0; + float pointY = 0; + int32_t sourceType = 0; + int32_t eventType = 0; + int64_t timeMs = 0; if (!data.ReadFloat(pointX) || !data.ReadFloat(pointY) || !data.ReadInt32(sourceType) || -- Gitee From 2d5f87110a9c29bcf510015d3ccaa79a3a7a04d0 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 19 Mar 2024 15:04:01 +0800 Subject: [PATCH 074/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../js_pip_window_manager.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index caacd34df..4976f74c3 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -69,14 +69,37 @@ static int32_t checkOptionParams(PipOption& option) WLOGE("check pipoption param error, pipTemplateType not exists."); return -1; } + return checkControlsRules(pipTemplateType, option.GetControlGroup()); +} + +static int32_t checkControlsRules(uint32_t pipTemplateType, std::vector controlGroups) +{ auto iter = TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)); auto controls = iter->second; - for (auto control : option.GetControlGroup()) { + for (auto control : controlGroups) { if (controls.find(static_cast(control)) == controls.end()) { WLOGE("check pipoption param error, controlGroup not matches, controlGroup: %{public}u", control); return -1; } } + if (pipTemplateType == static_cast(PiPTemplateType::VIDEO_PLAY)) { + if(controlGroups.find(static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT) != controls.end() && + controlGroups.find(static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD) != controls.end()) { + return -1; + } + } + if (pipTemplateType == static_cast(PiPTemplateType::VIDEO_CALL)) { + if (controlGroups.size != 0 && + controlGroups.find(static_cast(PiPControlGroup::VIDEO_CALL_HANG_UP_BUTTON) == controls.end()) { + return -1; + } + } + if (pipTemplateType == static_cast(PiPTemplateType::VIDEO_MEETING)) { + if (controlGroups.size != 0 && + controlGroups.find(static_cast(PiPControlGroup::VIDEO_MEETING_HANG_UP_BUTTON) == controls.end()) { + return -1; + } + } return 0; } -- Gitee From d889f518b7f93b2eecd677efb30e6a3b40bf98e8 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 19 Mar 2024 15:48:34 +0800 Subject: [PATCH 075/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../js_pip_window_manager.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 4976f74c3..ba184077c 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -83,20 +83,28 @@ static int32_t checkControlsRules(uint32_t pipTemplateType, std::vector(PiPTemplateType::VIDEO_PLAY)) { - if(controlGroups.find(static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT) != controls.end() && - controlGroups.find(static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD) != controls.end()) { + auto iter = std::find(controls.begin(), controls.end(), + static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT)); + if (iter == controls.end()) { + return -1; + } + iter = std::find(controls.begin(), controls.end(), + static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); + if (iter == controls.end()) { return -1; } } if (pipTemplateType == static_cast(PiPTemplateType::VIDEO_CALL)) { - if (controlGroups.size != 0 && - controlGroups.find(static_cast(PiPControlGroup::VIDEO_CALL_HANG_UP_BUTTON) == controls.end()) { + auto iter = std::find(controls.begin(), controls.end(), + static_cast(PiPControlGroup::VIDEO_CALL_HANG_UP_BUTTON)); + if (controlGroups.size != 0 && iter == controls.end()) { return -1; } } if (pipTemplateType == static_cast(PiPTemplateType::VIDEO_MEETING)) { - if (controlGroups.size != 0 && - controlGroups.find(static_cast(PiPControlGroup::VIDEO_MEETING_HANG_UP_BUTTON) == controls.end()) { + auto iter = std::find(controls.begin(), controls.end(), + static_cast(PiPControlGroup::VIDEO_MEETING_HANG_UP_BUTTON)); + if (controlGroups.size != 0 && iter == controls.end()) { return -1; } } -- Gitee From e35be5cd06f143ac59f1d77099411bace7693db6 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 19 Mar 2024 16:45:39 +0800 Subject: [PATCH 076/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../js_pip_window_manager.cpp | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index ba184077c..ad95274cb 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -53,64 +53,66 @@ namespace { std::mutex JsPipWindowManager::mutex_; -static int32_t checkOptionParams(PipOption& option) -{ - if (option.GetContext() == nullptr) { - WLOGE("check pipoption param error, context is nullptr."); - return -1; - } - if (option.GetXComponentController() == nullptr) { - WLOGE("check pipoption param error, XComponentController is nullptr."); - return -1; - } - uint32_t pipTemplateType = option.GetPipTemplate(); - if (TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)) == - TEMPLATE_CONTROL_MAP.end()) { - WLOGE("check pipoption param error, pipTemplateType not exists."); - return -1; - } - return checkControlsRules(pipTemplateType, option.GetControlGroup()); -} - static int32_t checkControlsRules(uint32_t pipTemplateType, std::vector controlGroups) { auto iter = TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)); auto controls = iter->second; for (auto control : controlGroups) { if (controls.find(static_cast(control)) == controls.end()) { - WLOGE("check pipoption param error, controlGroup not matches, controlGroup: %{public}u", control); + WLOGE("pipoption param error, controlGroup not matches, controlGroup: %{public}u", control); return -1; } } if (pipTemplateType == static_cast(PiPTemplateType::VIDEO_PLAY)) { - auto iter = std::find(controls.begin(), controls.end(), + auto iterFirst = std::find(controlGroups.begin(), controlGroups.end(), static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT)); - if (iter == controls.end()) { - return -1; - } - iter = std::find(controls.begin(), controls.end(), + iterSecond = std::find(controlGroups.begin(), controlGroups.end(), static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); - if (iter == controls.end()) { + if (iterFirst != controlGroups.end() && iterSecond != controlGroups.end()) { + WLOGE("pipoption param error, %{public}u conflicts with %{public}u in controlGroups", + static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT), + static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); return -1; } } if (pipTemplateType == static_cast(PiPTemplateType::VIDEO_CALL)) { - auto iter = std::find(controls.begin(), controls.end(), + auto iterator = std::find(controlGroups.begin(), controlGroups.end(), static_cast(PiPControlGroup::VIDEO_CALL_HANG_UP_BUTTON)); - if (controlGroups.size != 0 && iter == controls.end()) { + if (controlGroups.size() != 0 && iterator == controlGroups.end()) { + WLOGE("pipoption param error, requires HANG_UP_BUTTON when using controlGroups in VIDEO_CALL."); return -1; } } if (pipTemplateType == static_cast(PiPTemplateType::VIDEO_MEETING)) { - auto iter = std::find(controls.begin(), controls.end(), + auto iterator = std::find(controlGroups.begin(), controlGroups.end(), static_cast(PiPControlGroup::VIDEO_MEETING_HANG_UP_BUTTON)); - if (controlGroups.size != 0 && iter == controls.end()) { + if (controlGroups.size() != 0 && iterator == controlGroups.end()) { + WLOGE("pipoption param error, requires HANG_UP_BUTTON when using controlGroups in VIDEO_MEETING."); return -1; } } return 0; } +static int32_t checkOptionParams(PipOption& option) +{ + if (option.GetContext() == nullptr) { + WLOGE("pipoption param error, context is nullptr."); + return -1; + } + if (option.GetXComponentController() == nullptr) { + WLOGE("pipoption param error, XComponentController is nullptr."); + return -1; + } + uint32_t pipTemplateType = option.GetPipTemplate(); + if (TEMPLATE_CONTROL_MAP.find(static_cast(pipTemplateType)) == + TEMPLATE_CONTROL_MAP.end()) { + WLOGE("pipoption param error, pipTemplateType not exists."); + return -1; + } + return checkControlsRules(pipTemplateType, option.GetControlGroup()); +} + static bool GetControlGroupFromJs(napi_env env, napi_value controlGroup, std::vector &controls) { if (controlGroup == nullptr) { -- Gitee From ff0a2bbc86fd32d0e4791011f072782513d2a722 Mon Sep 17 00:00:00 2001 From: shark_00783 Date: Tue, 19 Mar 2024 17:04:51 +0800 Subject: [PATCH 077/385] =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=A0=8F=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shark_00783 --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index f8d2f58d7..9308662ea 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -45,7 +45,7 @@ using namespace AbilityRuntime; namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsWindow"}; constexpr Rect g_emptyRect = {0, 0, 0, 0}; - constexpr int32_t MIN_DECOR_HEIGHT = 48; + constexpr int32_t MIN_DECOR_HEIGHT = 37; constexpr int32_t MAX_DECOR_HEIGHT = 112; } @@ -5058,7 +5058,7 @@ napi_value JsWindow::OnSetWindowDecorHeight(napi_env env, napi_callback_info inf int32_t height = 0; napi_get_value_int32(env, nativeVal, &height); if (height < MIN_DECOR_HEIGHT || height > MAX_DECOR_HEIGHT) { - WLOGFE("height should greater than 48 or smaller than 112"); + WLOGFE("height should greater than 37 or smaller than 112"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } -- Gitee From 0e196eeb7e36d2893ac1cd3b38efe40e0b748ef3 Mon Sep 17 00:00:00 2001 From: chehang Date: Tue, 19 Mar 2024 13:40:13 +0000 Subject: [PATCH 078/385] update code check Signed-off-by: chehang --- .../session/container/include/zidl/session_stage_interface.h | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index 785b684fb..b4950fa46 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -69,7 +69,6 @@ public: virtual WSError SetPipActionEvent(const std::string& action, int32_t status) = 0; virtual WSError UpdateDisplayId(uint64_t displayId) = 0; - // **Non** IPC interface virtual void NotifyBackpressedEvent(bool& isConsumed) {} virtual void NotifyPointerEvent(const std::shared_ptr& pointerEvent) {} -- Gitee From 92cf9e37a2162fa28c3caacac2f0380c05f96aa2 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 19 Mar 2024 22:00:44 +0800 Subject: [PATCH 079/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=87=AA=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index ad95274cb..170ba48fa 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -66,7 +66,7 @@ static int32_t checkControlsRules(uint32_t pipTemplateType, std::vector(PiPTemplateType::VIDEO_PLAY)) { auto iterFirst = std::find(controlGroups.begin(), controlGroups.end(), static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT)); - iterSecond = std::find(controlGroups.begin(), controlGroups.end(), + auto iterSecond = std::find(controlGroups.begin(), controlGroups.end(), static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); if (iterFirst != controlGroups.end() && iterSecond != controlGroups.end()) { WLOGE("pipoption param error, %{public}u conflicts with %{public}u in controlGroups", -- Gitee From cf9b24930ee51ea7b734e1a7370b5e8f778e7ab2 Mon Sep 17 00:00:00 2001 From: zhangzhi Date: Tue, 19 Mar 2024 22:26:11 +0800 Subject: [PATCH 080/385] fix some problem and add tdd Signed-off-by: zhangzhi --- .../session/host/src/scene_session.cpp | 8 +---- .../unittest/scene_session_manager_test.cpp | 32 +++++++++++++++++++ .../test/unittest/scene_session_test.cpp | 28 ++++++++++++++++ window_scene/test/unittest/session_test.cpp | 28 ++++++++++++++++ 4 files changed, 89 insertions(+), 7 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 7d52b24f9..a602ad693 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1944,13 +1944,7 @@ WSError SceneSession::ChangeSessionVisibilityWithStatusBar( if (session->changeSessionVisibilityWithStatusBarFunc_) { session->changeSessionVisibilityWithStatusBarFunc_(info, visible); } - SessionState oldState = session->GetSessionState(); - SessionState newState = visible == false ? SessionState::STATE_BACKGROUND : SessionState::STATE_FOREGROUND; - if (oldState != newState) { - session->SetSessionState(newState); - session->NotifySessionStateChange(newState); - } - + return WSError::WS_OK; }; PostTask(task, "ChangeSessionVisibilityWithStatusBar"); diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 7157473dd..811f4b768 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -1789,6 +1789,38 @@ HWTEST_F(SceneSessionManagerTest, GetSceneSessionVectorByType, Function | SmallT ASSERT_EQ(ret, 0); } +/** + * @tc.name: StartUIAbilityBySCB + * @tc.desc: StartUIAbilityBySCB + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, StartUIAbilityBySCB, Function | SmallTest | Level3) +{ + SessionInfo info; + info.abilityName_ = "StartUIAbilityBySCB"; + info.bundleName_ = "StartUIAbilityBySCB"; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sceneSession->SetSessionState(SessionState::STATE_ACTIVE); + int32_t ret = ssm->StartUIAbilityBySCB(sceneSession); + EXPECT_EQ(ret, 2097202); +} + +/** + * @tc.name: ChangeUIAbilityVisibilityBySCB + * @tc.desc: ChangeUIAbilityVisibilityBySCB + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, ChangeUIAbilityVisibilityBySCB, Function | SmallTest | Level3) +{ + SessionInfo info; + info.abilityName_ = "ChangeUIAbilityVisibilityBySCB"; + info.bundleName_ = "ChangeUIAbilityVisibilityBySCB"; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sceneSession->SetSessionState(SessionState::STATE_ACTIVE); + int32_t ret = ssm->ChangeUIAbilityVisibilityBySCB(sceneSession, true); + EXPECT_EQ(ret, 2097202); +} + /** * @tc.name: RegisterInputMethodShownFunc * @tc.desc: SceneSesionManager register input method show func diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 919917304..d6e9b2d04 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -2537,6 +2537,34 @@ HWTEST_F(SceneSessionTest, AddOrRemoveSecureExtSession, Function | SmallTest | L sceneSession->AddOrRemoveSecureExtSession(12345, false); EXPECT_TRUE(sceneSession->secureExtSessionSet_.empty()); } + +/** + * @tc.name: ChangeSessionVisibilityWithStatusBar + * @tc.desc: * @tc.name: ChangeSessionVisibilityWithStatusBar + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, ChangeSessionVisibilityWithStatusBar, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "ChangeSessionVisibilityWithStatusBar"; + info.bundleName_ = "ChangeSessionVisibilityWithStatusBar"; + + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->isActive_ = true; + + sptr info1 = nullptr; + WSError result = sceneSession->ChangeSessionVisibilityWithStatusBar(info1, false); + ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); + + sptr abilitySessionInfo = new AAFwk::SessionInfo(); + result = sceneSession->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, false); + ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); + delete sceneSession; +} + + + } } } \ No newline at end of file diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index c937029e8..76bf79ed2 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -2881,6 +2881,34 @@ HWTEST_F(WindowSessionTest, IsTerminated49, Function | SmallTest | Level2) ASSERT_EQ(false, res); } +/** + * @tc.name: SetSystemActive48 + * @tc.desc: SetSystemActive + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest, SetChangeSessionVisibilityWithStatusBarEventListener, Function | SmallTest | Level2) +{ + int resultValue = 0; + NotifyChangeSessionVisibilityWithStatusBarFunc func1 = [&resultValue](SessionInfo& info, consst bool visible) { + resultValue = 1; + }; + NotifyChangeSessionVisibilityWithStatusBarFunc func2 = [&resultValue](SessionInfo& info, consst bool visible) { + resultValue = 2; + }; + + session_->SetChangeSessionVisibilityWithStatusBarEventListener(func1); + ASSERT_NE(session_->changeSessionVisibilityWithStatusBarFunc_, nullptr); + + SessionInfo info; + session_->changeSessionVisibilityWithStatusBarFunc_(info, true); + ASSERT_EQ(resultValue, 1); + + session_->SetChangeSessionVisibilityWithStatusBarEventListener(func2); + ASSERT_NE(session_->changeSessionVisibilityWithStatusBarFunc_, nullptr); + session_->changeSessionVisibilityWithStatusBarFunc_(info, true); + ASSERT_EQ(resultValue, 2); +} + } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From 0dad04ae0309b7d40282562b251c8ac081b5938c Mon Sep 17 00:00:00 2001 From: zhangzhi Date: Tue, 19 Mar 2024 22:26:11 +0800 Subject: [PATCH 081/385] fix some problem and add tdd Signed-off-by: zhangzhi --- window_scene/test/unittest/scene_session_manager_test.cpp | 4 ++-- window_scene/test/unittest/scene_session_test.cpp | 4 ++-- window_scene/test/unittest/session_test.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 811f4b768..706aafd5a 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -1801,7 +1801,7 @@ HWTEST_F(SceneSessionManagerTest, StartUIAbilityBySCB, Function | SmallTest | Le info.bundleName_ = "StartUIAbilityBySCB"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession->SetSessionState(SessionState::STATE_ACTIVE); - int32_t ret = ssm->StartUIAbilityBySCB(sceneSession); + int32_t ret = ssm_->StartUIAbilityBySCB(sceneSession); EXPECT_EQ(ret, 2097202); } @@ -1817,7 +1817,7 @@ HWTEST_F(SceneSessionManagerTest, ChangeUIAbilityVisibilityBySCB, Function | Sma info.bundleName_ = "ChangeUIAbilityVisibilityBySCB"; sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); sceneSession->SetSessionState(SessionState::STATE_ACTIVE); - int32_t ret = ssm->ChangeUIAbilityVisibilityBySCB(sceneSession, true); + int32_t ret = ssm_->ChangeUIAbilityVisibilityBySCB(sceneSession, true); EXPECT_EQ(ret, 2097202); } diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index d6e9b2d04..ea821b7da 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -2553,11 +2553,11 @@ HWTEST_F(SceneSessionTest, ChangeSessionVisibilityWithStatusBar, Function | Smal EXPECT_NE(sceneSession, nullptr); sceneSession->isActive_ = true; - sptr info1 = nullptr; + sptr info1 = nullptr; WSError result = sceneSession->ChangeSessionVisibilityWithStatusBar(info1, false); ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); - sptr abilitySessionInfo = new AAFwk::SessionInfo(); + sptr abilitySessionInfo = new AAFwk::SessionInfo(); result = sceneSession->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, false); ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); delete sceneSession; diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 76bf79ed2..2e6fe1a4e 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -2889,10 +2889,10 @@ HWTEST_F(WindowSessionTest, IsTerminated49, Function | SmallTest | Level2) HWTEST_F(WindowSessionTest, SetChangeSessionVisibilityWithStatusBarEventListener, Function | SmallTest | Level2) { int resultValue = 0; - NotifyChangeSessionVisibilityWithStatusBarFunc func1 = [&resultValue](SessionInfo& info, consst bool visible) { + NotifyChangeSessionVisibilityWithStatusBarFunc func1 = [&resultValue](SessionInfo& info, const bool visible) { resultValue = 1; }; - NotifyChangeSessionVisibilityWithStatusBarFunc func2 = [&resultValue](SessionInfo& info, consst bool visible) { + NotifyChangeSessionVisibilityWithStatusBarFunc func2 = [&resultValue](SessionInfo& info, const bool visible) { resultValue = 2; }; -- Gitee From 11e42837c8288926963b506af294962767b7f41a Mon Sep 17 00:00:00 2001 From: zhangzhi Date: Tue, 19 Mar 2024 22:26:11 +0800 Subject: [PATCH 082/385] fix some problem and add tdd Signed-off-by: zhangzhi --- window_scene/test/unittest/scene_session_test.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index ea821b7da..21cf28de2 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -2563,8 +2563,6 @@ HWTEST_F(SceneSessionTest, ChangeSessionVisibilityWithStatusBar, Function | Smal delete sceneSession; } - - } } } \ No newline at end of file -- Gitee From 22ee96db16b71ed99c3ea5578d642bd319078f11 Mon Sep 17 00:00:00 2001 From: ywx1282843 Date: Wed, 20 Mar 2024 03:14:15 +0000 Subject: [PATCH 083/385] update window_scene/test/unittest/scene_session_test.cpp. Signed-off-by: ywx1282843 --- window_scene/test/unittest/scene_session_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 067151b87..63c7783f8 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -2853,6 +2853,8 @@ HWTEST_F(SceneSessionTest, OnPiPMoveCallback, Function | SmallTest | Level2) scensession->OnPiPMoveCallback(rect, SizeChangeReason::MOVE); scensession->OnPiPMoveCallback(rect, SizeChangeReason::DRAG_END); EXPECT_EQ(WindowType::WINDOW_TYPE_PIP, property->GetWindowType()); +} + * @tc.name: SetPipActionEvent * @tc.desc: * @tc.name: SetPipActionEvent * @tc.type: FUNC -- Gitee From 67c8089ff55ad04c0c060eed60827eafa6cf6c2d Mon Sep 17 00:00:00 2001 From: db Date: Sun, 17 Mar 2024 17:02:28 +0800 Subject: [PATCH 084/385] add getSystemBarProperties Signed-off-by: db --- .../window_runtime/window_napi/js_window.cpp | 30 +++++++++++++++++++ .../window_runtime/window_napi/js_window.h | 2 ++ .../window_napi/js_window_utils.cpp | 22 ++++++++++++++ .../window_napi/js_window_utils.h | 1 + 4 files changed, 55 insertions(+) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 4ce10616b..2e1b6ccc2 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -315,6 +315,14 @@ napi_value JsWindow::SetSystemBarProperties(napi_env env, napi_callback_info inf return (me != nullptr) ? me->OnSetSystemBarProperties(env, info) : nullptr; } +napi_value JsWindow::GetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info) +{ + TLOGI(WmsLogTag::WMS_IMMS, "GetWindowSystemBarPropertiesSync"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetWindowSystemBarPropertiesSync(env, info) : nullptr; +} + + napi_value JsWindow::SetWindowSystemBarProperties(napi_env env, napi_callback_info info) { TLOGI(WmsLogTag::WMS_IMMS, "SetWindowSystemBarProperties"); @@ -2240,6 +2248,26 @@ napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info i return result; } +napi_value JsWindow::OnGetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info) +{ + wptr weakToken(windowToken_); + auto weakWindow = weakToken.promote(); + if (weakWindow == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "window is null"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + if (!WindowHelper::IsMainWindow(weakWindow->GetType())) { + TLOGE(WmsLogTag::WMS_IMMS, "only main window has right to call"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + } + auto objValue = CreateJsSystemBarPropertiesObject(env, weakWindow); + if (objValue == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "get properties failed"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY); + } + return objValue; +} + napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_info info) { WmErrorCode errCode = WmErrorCode::WM_OK; @@ -5143,6 +5171,8 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setSystemBarEnable", moduleName, JsWindow::SetSystemBarEnable); BindNativeFunction(env, object, "setWindowSystemBarEnable", moduleName, JsWindow::SetWindowSystemBarEnable); BindNativeFunction(env, object, "setSystemBarProperties", moduleName, JsWindow::SetSystemBarProperties); + BindNativeFunction(env, object, "getWindowSystemBarProperties", + moduleName, JsWindow::GetWindowSystemBarPropertiesSync); BindNativeFunction(env, object, "setWindowSystemBarProperties", moduleName, JsWindow::SetWindowSystemBarProperties); BindNativeFunction(env, object, "getAvoidArea", moduleName, JsWindow::GetAvoidArea); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 87e18073b..536868632 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -72,6 +72,7 @@ public: static napi_value SetSystemBarEnable(napi_env env, napi_callback_info info); static napi_value SetWindowSystemBarEnable(napi_env env, napi_callback_info info); static napi_value SetSystemBarProperties(napi_env env, napi_callback_info info); + static napi_value GetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info); static napi_value SetWindowSystemBarProperties(napi_env env, napi_callback_info info); static napi_value GetAvoidArea(napi_env env, napi_callback_info info); static napi_value GetWindowAvoidAreaSync(napi_env env, napi_callback_info info); @@ -175,6 +176,7 @@ private: napi_value OnSetSystemBarEnable(napi_env env, napi_callback_info info); napi_value OnSetWindowSystemBarEnable(napi_env env, napi_callback_info info); napi_value OnSetSystemBarProperties(napi_env env, napi_callback_info info); + napi_value OnGetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info); napi_value OnSetWindowSystemBarProperties(napi_env env, napi_callback_info info); napi_value OnLoadContent(napi_env env, napi_callback_info info, bool isLoadedByName); napi_value OnGetUIContext(napi_env env, napi_callback_info info); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 15a194e75..5d3a3dbfa 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -495,6 +495,28 @@ napi_value CreateJsWindowPropertiesObject(napi_env env, sptr& window, co napi_set_named_property(env, objValue, "id", CreateJsValue(env, window->GetWindowId())); return objValue; } + +napi_value CreateJsSystemBarPropertiesObject(napi_env env, sptr& window) +{ + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert SystemBarProperties to jsObject"); + return nullptr; + } + SystemBarProperty status = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); + SystemBarProperty navi = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_BAR); + napi_set_named_property(env, objValue, "statusBarColor", CreateJsValue(env, status.backgroundColor_)); + napi_set_named_property(env, objValue, "statusBarContentColor", CreateJsValue(env, status.contentColor_)); + napi_set_named_property(env, objValue, "isStatusBarLightIcon", + CreateJsValue(env, status.contentColor_ == SYSTEM_COLOR_WHITE)); + napi_set_named_property(env, objValue, "navigationBarColor", CreateJsValue(env, navi.backgroundColor_)); + napi_set_named_property(env, objValue, "navigationBarContentColor", CreateJsValue(env, navi.contentColor_)); + napi_set_named_property(env, objValue, "isNavigationBarLightIcon", + CreateJsValue(env, status.contentColor_ == SYSTEM_COLOR_WHITE)); + return objValue; +} + static std::string GetHexColor(uint32_t color) { std::stringstream ioss; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 6bbe76922..5f683bbb5 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -191,6 +191,7 @@ struct SystemBarPropertyFlag { napi_value GetRectAndConvertToJsValue(napi_env env, const Rect& rect); napi_value CreateJsWindowPropertiesObject(napi_env env, sptr& window, const Rect& drawableRect); + napi_value CreateJsSystemBarPropertiesObject(napi_env env, sptr& window); bool SetSystemBarPropertiesFromJs(napi_env env, napi_value jsObject, std::map& properties, std::map& propertyFlags, sptr& window); -- Gitee From 46c9bedaf7052a6a7e402a9cc116e766c6160def Mon Sep 17 00:00:00 2001 From: l30030525 Date: Wed, 20 Mar 2024 12:23:00 +0800 Subject: [PATCH 085/385] =?UTF-8?q?=E6=96=B0=E5=A2=9EUIExtensiong=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=87=AA=E5=88=9B=E9=89=B4=E6=9D=83=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- .../session_manager/src/scene_session_manager.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 8ff21eb15..0d2282618 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1705,6 +1705,19 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetExtensionFlag() == true) { + auto extensionParentSession = GetSceneSession(property->GetParentPersistentId()); + SessionInfo sessionInfo = extensionParentSession->GetSessionInfo(); + AAFwk::UIExtensionHostInfo hostInfo; + AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionRootHostInfo(token, hostInfo); + if (sessionInfo.bundleName_ != hostInfo.elementName_.GetBundleName()) { + WLOGE("The hostWindow is not thie parentwindow ! parentwindow bundleName: %{public}s, " + "hostwindow bundleName: %{public}s", sessionInfo.bundleName_.c_str(), + hostInfo.elementName_.GetBundleName().c_str()); + return SError::WS_ERROR_INVALID_WINDOW; + } + } + // WINDOW_TYPE_SYSTEM_ALARM_WINDOW has been deprecated, will be deleted after 5 versions. if (property->GetWindowType() == WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW) { WLOGFE("The alarm window has been deprecated!"); -- Gitee From 4c8e009f55f2df3c4c5ba891c97199050498d9dd Mon Sep 17 00:00:00 2001 From: l30030525 Date: Wed, 20 Mar 2024 12:27:40 +0800 Subject: [PATCH 086/385] =?UTF-8?q?=E6=96=B0=E5=A2=9EUIExtensiong=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=87=AA=E5=88=9B=E9=89=B4=E6=9D=83=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- .../window_scene_session_impl_test.cpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 382c8b1bc..dc7aecd2b 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -165,6 +165,36 @@ HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession02, Function } } +/** + * @tc.name: CreateAndConnectSpecificSession03 + * @tc.desc: CreateAndConnectSpecificSession + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession03, Function | SmallTest | Level2) +{ + sptr option_ = new (std::nothrow) WindowOption(); + option_->SetWindowTag(WindowTag::SUB_WINDOW); + option_->SetWindowName("ChildWindow0003"); + option_->SetExtensionTag(true); + sptr parentscenesession_ = new (std::nothrow) WindowSceneSessionImpl(option_); + ASSERT_NE(nullptr, parentscenesession_); + + SessionInfo sessionInfo_ = { "CreateTestBundle0", "CreateTestModule0", "CreateTestAbility0" }; + sptr session_ = new (std::nothrow) SessionMocker(sessionInfo_); + ASSERT_NE(nullptr, session_); + ASSERT_EQ(WMError::WM_OK, parentscenesession_->Create(abilityContext_, session_)); + + parentscenesession_->property_->SetParentPersistentId(102); + parentscenesession_->property_->SetParentId(102); + parentscenesession_->property_->type_ = WindowType::APP_MAIN_WINDOW_BASE; + parentscenesession_->hostSession_ = session_; + + parentscenesession_->property_->type_ = WindowType::APP_SUB_WINDOW_BASE; + if (parentscenesession_->CreateAndConnectSpecificSession() == WMError::WM_OK) { + ASSERT_EQ(WMError::WM_OK, parentscenesession_->CreateAndConnectSpecificSession()); + } +} + /** * @tc.name: RecoverAndReconnectSceneSession * @tc.desc: RecoverAndReconnectSceneSession -- Gitee From 4e6f7b5e4245ad4b42bd83cbff744b457e965007 Mon Sep 17 00:00:00 2001 From: w00574628 Date: Wed, 20 Mar 2024 11:35:52 +0800 Subject: [PATCH 087/385] Fix the issue of not notifying arkui of keyboard area changes when callingWindowRestoringRect_ is empty, resulting in a white screen problem. Signed-off-by: wulehui --- window_scene/session_manager/src/scene_session_manager.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 8ff21eb15..2725a57a0 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -5318,8 +5318,7 @@ void SceneSessionManager::NotifyOccupiedAreaChangeInfo(const sptr sptr info = new OccupiedAreaChangeInfo(OccupiedAreaType::TYPE_INPUT, SessionHelper::TransferToRect(safeRect), safeRect.height_, sceneSession->textFieldPositionY_, sceneSession->textFieldHeight_); - TLOGD(WmsLogTag::WMS_KEYBOARD, "OccupiedAreaChangeInfo rect: %{public}u %{public}u %{public}u %{public}u", - occupiedArea.posX_, occupiedArea.posY_, occupiedArea.width_, occupiedArea.height_); + TLOGI(WmsLogTag::WMS_KEYBOARD, "OccupiedAreaChangeInfo rect: %{public}s", occupiedArea.ToString().c_str()); callingSession_->NotifyOccupiedAreaChangeInfo(info); } @@ -5331,9 +5330,9 @@ void SceneSessionManager::RestoreCallingSessionSizeIfNeed() return; } + WSRect overlapRect = { 0, 0, 0, 0 }; + NotifyOccupiedAreaChangeInfo(callingSession_, callingWindowRestoringRect_, overlapRect); if (!SessionHelper::IsEmptyRect(callingWindowRestoringRect_)) { - WSRect overlapRect = { 0, 0, 0, 0 }; - NotifyOccupiedAreaChangeInfo(callingSession_, callingWindowRestoringRect_, overlapRect); if (needUpdateSessionRect_ && callingSession_->GetSessionProperty() && callingSession_->GetSessionProperty()->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING && callingSession_->GetSessionRect() == callingWindowNewRect_) { -- Gitee From cfc3872f3c5de2b911e0b98042edab64365997e5 Mon Sep 17 00:00:00 2001 From: ywx1282843 Date: Wed, 20 Mar 2024 06:13:11 +0000 Subject: [PATCH 088/385] update window_scene/test/unittest/scene_session_test.cpp. Signed-off-by: ywx1282843 --- window_scene/test/unittest/scene_session_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 63c7783f8..4fef236f5 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -2855,6 +2855,7 @@ HWTEST_F(SceneSessionTest, OnPiPMoveCallback, Function | SmallTest | Level2) EXPECT_EQ(WindowType::WINDOW_TYPE_PIP, property->GetWindowType()); } +/* * @tc.name: SetPipActionEvent * @tc.desc: * @tc.name: SetPipActionEvent * @tc.type: FUNC -- Gitee From 61c223f09b82c320c2f3a7fade86843cf7363621 Mon Sep 17 00:00:00 2001 From: l30030525 Date: Wed, 20 Mar 2024 14:43:57 +0800 Subject: [PATCH 089/385] =?UTF-8?q?=E6=96=B0=E5=A2=9EUIExtensiong=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=87=AA=E5=88=9B=E9=89=B4=E6=9D=83=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- 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 0d2282618..4bb8d35d0 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1714,7 +1714,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptr Date: Wed, 20 Mar 2024 15:43:38 +0800 Subject: [PATCH 090/385] Fix the issue that keyboard could not be closed by the third-party input method app. Signed-off-by: wulehui --- window_scene/session/host/src/scene_session.cpp | 8 -------- window_scene/session/host/src/system_session.cpp | 7 ++++++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index e58448e20..5216f7e57 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -157,14 +157,6 @@ WSError SceneSession::Foreground(sptr property) WSError SceneSession::Background() { - auto type = GetWindowType(); - if (WindowHelper::IsSystemWindow(type) && Session::NeedSystemPermission(type)) { - if (!SessionPermission::IsSystemCalling()) { - TLOGE(WmsLogTag::WMS_LIFE, "Background permission denied id: %{public}d type:%{public}u", - GetPersistentId(), type); - return WSError::WS_ERROR_INVALID_PERMISSION; - } - } auto task = [weakThis = wptr(this)]() { auto session = weakThis.promote(); if (!session) { diff --git a/window_scene/session/host/src/system_session.cpp b/window_scene/session/host/src/system_session.cpp index 20d7d2081..6b6a5a22e 100644 --- a/window_scene/session/host/src/system_session.cpp +++ b/window_scene/session/host/src/system_session.cpp @@ -84,7 +84,12 @@ WSError SystemSession::Hide() { auto type = GetWindowType(); if (WindowHelper::IsSystemWindow(type) && Session::NeedSystemPermission(type)) { - if (!SessionPermission::IsSystemCalling()) { + if (type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { + if (!SessionPermission::IsStartedByInputMethod()) { + TLOGE(WmsLogTag::WMS_LIFE, "Hide permission denied, keyboard is not hidden by current input method"); + return WSError::WS_ERROR_INVALID_PERMISSION; + } + } else if (!SessionPermission::IsSystemCalling()) { TLOGE(WmsLogTag::WMS_LIFE, "Hide permission denied id: %{public}d type:%{public}u", GetPersistentId(), type); return WSError::WS_ERROR_INVALID_PERMISSION; -- Gitee From 4a4469ba9b8a1fe680b446df9127a1ee789091a0 Mon Sep 17 00:00:00 2001 From: xuhaodong Date: Wed, 20 Mar 2024 18:59:29 +0800 Subject: [PATCH 091/385] =?UTF-8?q?wms=E5=8A=A0=E5=85=A5=E5=88=B0=E5=BC=80?= =?UTF-8?q?=E6=9C=BAevent=E6=8A=95=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuhaodong --- etc/wms.para | 3 ++- etc/wms.para.dac | 3 ++- wmserver/BUILD.gn | 2 +- wmserver/src/mock_session_manager_service.cpp | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/etc/wms.para b/etc/wms.para index 10cefe49e..eecfd0787 100644 --- a/etc/wms.para +++ b/etc/wms.para @@ -11,4 +11,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -bootevent.wms.fullscreen.ready=false \ No newline at end of file +bootevent.wms.fullscreen.ready=false +bootevent.wms.ready=false \ No newline at end of file diff --git a/etc/wms.para.dac b/etc/wms.para.dac index cdccccffe..2c8f6c551 100644 --- a/etc/wms.para.dac +++ b/etc/wms.para.dac @@ -11,4 +11,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -bootevent.wms.fullscreen.ready = foundation:foundation:0775 \ No newline at end of file +bootevent.wms.fullscreen.ready = foundation:foundation:0775 +bootevent.wms.ready = foundation:foundation:0775 \ No newline at end of file diff --git a/wmserver/BUILD.gn b/wmserver/BUILD.gn index 0bec4801e..a832510fd 100644 --- a/wmserver/BUILD.gn +++ b/wmserver/BUILD.gn @@ -133,7 +133,7 @@ ohos_shared_library("sms") { if (scene_board_enabled) { group("libwms") { - deps = [] + deps = [ "../etc:wms_etc" ] } } else { ohos_shared_library("libwms") { diff --git a/wmserver/src/mock_session_manager_service.cpp b/wmserver/src/mock_session_manager_service.cpp index 044664c73..bd0755dc3 100644 --- a/wmserver/src/mock_session_manager_service.cpp +++ b/wmserver/src/mock_session_manager_service.cpp @@ -57,6 +57,7 @@ const std::string ARG_DUMP_WINDOW = "-w"; const std::string KEY_SCENE_BOARD_TEST_ENABLE = "persist.scb.testmode.enable"; const std::string SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard"; const std::string TEST_MODULE_NAME_SUFFIX = "_test"; +const std::string BOOTEVENT_WMS_READY = "bootevent.wms.ready"; } // namespace class ClientListenerDeathRecipient : public IRemoteObject::DeathRecipient { @@ -187,7 +188,7 @@ bool MockSessionManagerService::SetSessionManagerService(const sptr Date: Mon, 11 Mar 2024 16:34:44 +0800 Subject: [PATCH 092/385] setRectInConnect Signed-off-by: zhangkai Change-Id: Iaef105ef44d812425540c33b99c94cf2e1961c33 --- window_scene/session/host/src/session.cpp | 7 +++++++ window_scene/session/host/src/zidl/session_proxy.cpp | 2 ++ window_scene/session/host/src/zidl/session_stub.cpp | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 80daf2620..0ad115275 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -781,6 +781,13 @@ WSError Session::Connect(const sptr& sessionStage, const sptrSetDisplayId(GetSessionInfo().screenId_); } + Rect rect = { + winRect_.posX_, + winRect_.posY_, + static_cast(winRect_.width_), + static_cast(winRect_.height_) + }; + property->SetWindowRect(rect); SetSessionProperty(property); if (property) { property->SetPersistentId(GetPersistentId()); diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 9253a116b..854b3f58c 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -212,6 +212,8 @@ WSError SessionProxy::Connect(const sptr& sessionStage, const spt if (needUpdate) { property->SetWindowMode(static_cast(reply.ReadUint32())); } + Rect rect = { reply.ReadInt32(), reply.ReadInt32(), reply.ReadUint32(), reply.ReadUint32() }; + property->SetWindowRect(rect); } int32_t ret = reply.ReadInt32(); return static_cast(ret); diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 4287301b7..15edad33f 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -234,6 +234,12 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply) reply.WriteUint32(static_cast(property->GetWindowMode())); } property->SetIsNeedUpdateWindowMode(false); + + Rect winRect = property->GetWindowRect(); + reply.WriteInt32(winRect.posX_); + reply.WriteInt32(winRect.posY_); + reply.WriteUint32(winRect.width_); + reply.WriteUint32(winRect.height_); } reply.WriteUint32(static_cast(errCode)); return ERR_NONE; -- Gitee From 068f72efd986ba4dcef9251d8ab688b7bfacff0f Mon Sep 17 00:00:00 2001 From: zhangkai Date: Mon, 26 Feb 2024 14:26:43 +0800 Subject: [PATCH 093/385] check WindowMode In windowSceneSessionImpl Signed-off-by: zhangkai Change-Id: I61087dbfb953f58bbf61ac00d4f8b7f37afbe6d8 --- wm/src/window_scene_session_impl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index b53d5eed2..0170bf6f3 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1114,6 +1114,12 @@ WMError WindowSceneSessionImpl::Resize(uint32_t width, uint32_t height) WLOGFW("[WMSLayout] Unsupported operation for pip window"); return WMError::WM_ERROR_INVALID_OPERATION; } + + if (GetMode() != WindowMode::WINDOW_MODE_FLOATING) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Unsupport operation for full screen window. WindowId: %{public}d", + GetWindowId()); + return WMError::WM_ERROR_INVALID_OPERATION; + } // Float camera window has special limits LimitCameraFloatWindowMininumSize(width, height); -- Gitee From 3dd8b4ac336e3a18dd34d682e27f75fa7c2b365b Mon Sep 17 00:00:00 2001 From: z00514981 Date: Wed, 20 Mar 2024 22:08:48 +0800 Subject: [PATCH 094/385] =?UTF-8?q?=E6=A8=A1=E6=80=81=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=AA=97=E5=8F=A3=E5=A4=A7=E5=B0=8F=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: z00514981 Change-Id: I5f92113f5d67c6ee38b7c0472e44e958be6bf9c5 --- wm/src/window_scene_session_impl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 786bcada4..a46980a4b 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1119,7 +1119,8 @@ void WindowSceneSessionImpl::UpdateFloatingWindowSizeBySizeLimits(uint32_t& widt // get new limit config with the settings of system and app const auto& sizeLimits = property_->GetWindowLimits(); // limit minimum size of floating (not system type) window - if (!WindowHelper::IsSystemWindow(property_->GetWindowType())) { + if ((!WindowHelper::IsSystemWindow(property_->GetWindowType())) || + (property_->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG)) { width = std::max(sizeLimits.minWidth_, width); height = std::max(sizeLimits.minHeight_, height); } -- Gitee From bd3be0dc027a12501d85ea1121a0bce8d17e6333 Mon Sep 17 00:00:00 2001 From: xuzirong Date: Thu, 21 Mar 2024 09:39:17 +0800 Subject: [PATCH 095/385] Pass caller abilityName and bundleName from ams to ts in sceneboard Signed-off-by: xuzirong --- window_scene/interfaces/include/ws_common.h | 2 ++ .../kits/napi/scene_session_manager/js_scene_utils.cpp | 2 ++ window_scene/session/host/src/scene_session.cpp | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index c0babfd60..7b7f3e082 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -181,6 +181,8 @@ struct SessionInfo { std::string errorReason; int32_t persistentId_ = INVALID_SESSION_ID; int32_t callerPersistentId_ = INVALID_SESSION_ID; + std::string callerBundleName_ = ""; + std::string callerAbilityName_ = ""; uint32_t callState_ = 0; uint32_t callingTokenId_ = 0; bool reuse = false; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp index 7767e40fb..6e97e306f 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp @@ -649,6 +649,8 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) CreateJsValue(env, static_cast(sessionInfo.persistentId_))); napi_set_named_property(env, objValue, "callerPersistentId", CreateJsValue(env, static_cast(sessionInfo.callerPersistentId_))); + napi_set_named_property(env, objValue, "callerBundleName", CreateJsValue(env, sessionInfo.callerBundleName_)); + napi_set_named_property(env, objValue, "callerAbilityName", CreateJsValue(env, sessionInfo.callerAbilityName_)); napi_set_named_property(env, objValue, "callState", CreateJsValue(env, static_cast(sessionInfo.callState_))); napi_set_named_property(env, objValue, "windowMode", diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index e58448e20..82b975be7 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -1933,6 +1933,8 @@ WSError SceneSession::ChangeSessionVisibilityWithStatusBar( info.appIndex_ = abilitySessionInfo->want.GetIntParam(DLP_INDEX, 0); info.persistentId_ = abilitySessionInfo->persistentId; info.callerPersistentId_ = session->GetPersistentId(); + info.callerBundleName_ = abilitySessionInfo->want.GetStringParam(AAFwk::Want::PARAM_RESV_CALLER_BUNDLE_NAME); + info.callerAbilityName_ = abilitySessionInfo->want.GetStringParam(AAFwk::Want::PARAM_RESV_CALLER_ABILITY_NAME); info.callState_ = static_cast(abilitySessionInfo->state); info.uiAbilityId_ = abilitySessionInfo->uiAbilityId; info.want = std::make_shared(abilitySessionInfo->want); @@ -1984,6 +1986,8 @@ WSError SceneSession::PendingSessionActivation(const sptr ab info.appIndex_ = abilitySessionInfo->want.GetIntParam(DLP_INDEX, 0); info.persistentId_ = abilitySessionInfo->persistentId; info.callerPersistentId_ = session->GetPersistentId(); + info.callerBundleName_ = abilitySessionInfo->want.GetStringParam(AAFwk::Want::PARAM_RESV_CALLER_BUNDLE_NAME); + info.callerAbilityName_ = abilitySessionInfo->want.GetStringParam(AAFwk::Want::PARAM_RESV_CALLER_ABILITY_NAME); info.callState_ = static_cast(abilitySessionInfo->state); info.uiAbilityId_ = abilitySessionInfo->uiAbilityId; info.want = std::make_shared(abilitySessionInfo->want); -- Gitee From 08a90ddf474b055e6b1eb289529672f70e8e41d7 Mon Sep 17 00:00:00 2001 From: w00845693 Date: Wed, 20 Mar 2024 18:09:51 +0800 Subject: [PATCH 096/385] =?UTF-8?q?Description:=E4=BF=AE=E5=A4=8Dscreen=5F?= =?UTF-8?q?pattern=E5=88=B7=E6=96=B0=E5=B1=8F=E5=B9=95=E8=A7=92=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9=20IssueNo:https://gitee.com/openharmony/wind?= =?UTF-8?q?ow=5Fwindow=5Fmanager/issues/I9A65F=20Feature=20or=20Bugfix:Bug?= =?UTF-8?q?fix=20Binary=20Source:No=20Signed-off-by:=20wyk99=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/session/screen/src/screen_session.cpp | 9 +++------ wm/include/root_scene.h | 3 +++ wm/src/root_scene.cpp | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 847fc48a9..a5bc78c47 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -533,14 +533,11 @@ Rotation ScreenSession::CalcRotation(Orientation orientation, FoldDisplayMode fo DisplayOrientation ScreenSession::CalcDisplayOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const { - sptr info = GetActiveScreenMode(); - if (info == nullptr) { - return DisplayOrientation::UNKNOWN; - } // vertical: phone(Plugin screen); horizontal: pad & external screen - bool isVerticalScreen = info->width_ < info->height_; + bool isVerticalScreen = property_.GetPhyWidth() < property_.GetPhyHeight(); if (foldDisplayMode != FoldDisplayMode::UNKNOWN) { - isVerticalScreen = info->width_ > info->height_; + WLOGD("foldDisplay is verticalScreen when width is greater than height"); + isVerticalScreen = property_.GetPhyWidth() > property_.GetPhyHeight(); } switch (rotation) { case Rotation::ROTATION_0: { diff --git a/wm/include/root_scene.h b/wm/include/root_scene.h index 91473995e..54e6d42fa 100644 --- a/wm/include/root_scene.h +++ b/wm/include/root_scene.h @@ -55,6 +55,8 @@ public: density_ = density; } + void SetDisplayOrientation(int32_t orientation); + float GetDisplayDensity() { return density_; @@ -94,6 +96,7 @@ private: std::shared_ptr eventHandler_; sptr launcherService_; float density_ = 1.0f; + int32_t orientation_; WindowType type_ = WindowType::WINDOW_TYPE_SCENE_BOARD; std::string name_ = "EntryView"; std::function frameLayoutFinishCb_ = nullptr; diff --git a/wm/src/root_scene.cpp b/wm/src/root_scene.cpp index 2d1398c4f..05de1cfbb 100644 --- a/wm/src/root_scene.cpp +++ b/wm/src/root_scene.cpp @@ -121,6 +121,11 @@ void RootScene::LoadContent(const std::string& contentUrl, napi_env env, napi_va }); } +void RootScene::SetDisplayOrientation(int32_t orientation) +{ + orientation_ = orientation; +} + void RootScene::UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason reason) { if (uiContent_ == nullptr) { @@ -131,6 +136,7 @@ void RootScene::UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason re config.SetSize(rect.width_, rect.height_); config.SetPosition(rect.posX_, rect.posY_); config.SetDensity(density_); + config.SetOrientation(orientation_); uiContent_->UpdateViewportConfig(config, reason); } -- Gitee From aa2f05e291defd43ac7ecdd5555dd9037f1370d3 Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Thu, 21 Mar 2024 11:16:32 +0800 Subject: [PATCH 097/385] add handwrite window type and flag Signed-off-by: chengyiyi --- interfaces/innerkits/wm/wm_common.h | 4 +- .../window_runtime/window_napi/js_window.cpp | 59 +++++++++++++++++++ .../window_runtime/window_napi/js_window.h | 2 + .../window_napi/js_window_utils.cpp | 2 + .../window_napi/js_window_utils.h | 3 + previewer/include/wm_common.h | 3 +- .../scene_session_manager/js_scene_utils.cpp | 1 + .../scene_session_manager/js_scene_utils.h | 3 + wm/src/window_scene_session_impl.cpp | 6 +- wmserver/src/input_window_monitor.cpp | 3 + 10 files changed, 83 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index ca73ac5a4..b80def5bf 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -78,6 +78,7 @@ enum class WindowType : uint32_t { WINDOW_TYPE_PIP, WINDOW_TYPE_THEME_EDITOR, WINDOW_TYPE_NAVIGATION_INDICATOR, + WINDOW_TYPE_HANDWRITE, ABOVE_APP_SYSTEM_WINDOW_END, SYSTEM_SUB_WINDOW_BASE = 2500, @@ -262,7 +263,8 @@ enum class WindowFlag : uint32_t { WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2, WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3, WINDOW_FLAG_WATER_MARK = 1 << 4, - WINDOW_FLAG_END = 1 << 5, + WINDOW_FLAG_HANDWRITING = 1 << 5, + WINDOW_FLAG_END = 1 << 6, }; /** diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index f8d2f58d7..4076bef57 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -658,6 +658,13 @@ napi_value JsWindow::SetWaterMarkFlag(napi_env env, napi_callback_info info) return (me != nullptr) ? me->OnSetWaterMarkFlag(env, info) : nullptr; } +napi_value JsWindow::SetHandwritingFlag(napi_env env, napi_callback_info info) +{ + WLOGI("SetHandwritingFlag"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetHandwritingFlag(env, info) : nullptr; +} + napi_value JsWindow::SetAspectRatio(napi_env env, napi_callback_info info) { WLOGI("[NAPI]SetAspectRatio"); @@ -4644,6 +4651,57 @@ napi_value JsWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info) return result; } +napi_value JsWindow::OnSetHandwritingFlag(napi_env env, napi_callback_info info) +{ + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < 1) { + WLOGFE("Argc is invalid: %{public}zu", argc); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + + napi_value nativeBool = argv[0]; + if (nativeBool == nullptr) { + WLOGFE("SetHandwritingFlag Invalid window flag"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + + bool isAddFlag = false; + napi_get_value_bool(env, nativeBool, &isAddFlag); + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [weakToken, isAddFlag](napi_env env, NapiAsyncTask& task, int32_t status) { + auto window = weakToken.promote(); + if (window == nullptr) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "OnSetHandwritingFlag failed.")); + return; + } + WMError ret = WMError::WM_OK; + if (isAddFlag) { + ret = window->AddWindowFlag(WindowFlag::WINDOW_FLAG_HANDWRITING); + } else { + ret = window->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_HANDWRITING); + } + if (ret == WMError::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, CreateJsError(env, + static_cast(WM_JS_TO_ERROR_CODE_MAP.at(ret)), "SetHandwritingFlag failed.")); + } + WLOGI("[NAPI]Window [%{public}u, %{public}s] set handwriting flag end, ret = %{public}d", + window->GetWindowId(), window->GetWindowName().c_str(), ret); + }; + + napi_value lastParam = (argc == 1) ? nullptr : + (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnSetHandwritingFlag", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) { @@ -5192,6 +5250,7 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setAspectRatio", moduleName, JsWindow::SetAspectRatio); BindNativeFunction(env, object, "resetAspectRatio", moduleName, JsWindow::ResetAspectRatio); BindNativeFunction(env, object, "setWaterMarkFlag", moduleName, JsWindow::SetWaterMarkFlag); + BindNativeFunction(env, object, "setHandwritingFlag", moduleName, JsWindow::SetHandwritingFlag); BindNativeFunction(env, object, "minimize", moduleName, JsWindow::Minimize); BindNativeFunction(env, object, "maximize", moduleName, JsWindow::Maximize); BindNativeFunction(env, object, "setResizeByDragEnabled", moduleName, JsWindow::SetResizeByDragEnabled); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 87e18073b..6ae018016 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -137,6 +137,7 @@ public: static napi_value SetBackdropBlur(napi_env env, napi_callback_info info); static napi_value SetBackdropBlurStyle(napi_env env, napi_callback_info info); static napi_value SetWaterMarkFlag(napi_env env, napi_callback_info info); + static napi_value SetHandwritingFlag(napi_env env, napi_callback_info info); static napi_value SetWindowDecorVisible(napi_env env, napi_callback_info info); static napi_value SetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetWindowDecorHeight(napi_env env, napi_callback_info info); @@ -248,6 +249,7 @@ private: napi_value OnSetBackdropBlur(napi_env env, napi_callback_info info); napi_value OnSetBackdropBlurStyle(napi_env env, napi_callback_info info); napi_value OnSetWaterMarkFlag(napi_env env, napi_callback_info info); + napi_value OnSetHandwritingFlag(napi_env env, napi_callback_info info); sptr windowToken_ = nullptr; std::unique_ptr registerManager_ = nullptr; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 15a194e75..070460bc3 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -85,6 +85,8 @@ napi_value WindowTypeInit(napi_env env) static_cast(ApiWindowType::TYPE_SYSTEM_TOAST))); napi_set_named_property(env, objValue, "TYPE_GLOBAL_SEARCH", CreateJsValue(env, static_cast(ApiWindowType::TYPE_GLOBAL_SEARCH))); + napi_set_named_property(env, objValue, "TYPE_HANDWRITE", CreateJsValue(env, + static_cast(ApiWindowType::TYPE_HANDWRITE))); return objValue; } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 6bbe76922..17676d73b 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -66,6 +66,7 @@ enum class ApiWindowType : uint32_t { TYPE_SYSTEM_TOAST, TYPE_DIVIDER, TYPE_GLOBAL_SEARCH, + TYPE_HANDWRITE, TYPE_END }; @@ -101,6 +102,7 @@ const std::map NATIVE_JS_TO_WINDOW_TYPE_MAP { { WindowType::WINDOW_TYPE_SYSTEM_TOAST, ApiWindowType::TYPE_SYSTEM_TOAST }, { WindowType::WINDOW_TYPE_DOCK_SLICE, ApiWindowType::TYPE_DIVIDER }, { WindowType::WINDOW_TYPE_GLOBAL_SEARCH, ApiWindowType::TYPE_GLOBAL_SEARCH }, + { WindowType::WINDOW_TYPE_HANDWRITE, ApiWindowType::TYPE_HANDWRITE }, }; const std::map JS_TO_NATIVE_WINDOW_TYPE_MAP { @@ -125,6 +127,7 @@ const std::map JS_TO_NATIVE_WINDOW_TYPE_MAP { { ApiWindowType::TYPE_SYSTEM_TOAST, WindowType::WINDOW_TYPE_SYSTEM_TOAST }, { ApiWindowType::TYPE_DIVIDER, WindowType::WINDOW_TYPE_DOCK_SLICE }, { ApiWindowType::TYPE_GLOBAL_SEARCH, WindowType::WINDOW_TYPE_GLOBAL_SEARCH }, + { ApiWindowType::TYPE_HANDWRITE, WindowType::WINDOW_TYPE_HANDWRITE }, }; enum class ApiWindowMode : uint32_t { diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index e859e6cb1..a75dda5b6 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -242,7 +242,8 @@ enum class WindowFlag : uint32_t { WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2, WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3, WINDOW_FLAG_WATER_MARK = 1 << 4, - WINDOW_FLAG_END = 1 << 5, + WINDOW_FLAG_HANDWRITING = 1 << 5, + WINDOW_FLAG_END = 1 << 6, }; /** diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp index 7767e40fb..244d57023 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp @@ -956,6 +956,7 @@ napi_value SessionTypeInit(napi_env env) SetTypeProperty(objValue, env, "TYPE_PIP", JsSessionType::TYPE_PIP); SetTypeProperty(objValue, env, "TYPE_THEME_EDITOR", JsSessionType::TYPE_THEME_EDITOR); SetTypeProperty(objValue, env, "TYPE_NAVIGATION_INDICATOR", JsSessionType::TYPE_NAVIGATION_INDICATOR); + SetTypeProperty(objValue, env, "TYPE_HANDWRITE", JsSessionType::TYPE_HANDWRITE); return objValue; } diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h index 94e2eb701..9fb8748dc 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h @@ -61,6 +61,7 @@ enum class JsSessionType : uint32_t { TYPE_NAVIGATION_INDICATOR, TYPE_SEARCHING_BAR, TYPE_SYSTEM_SUB_WINDOW, + TYPE_HANDWRITE, }; // should same with bundlemanager ability info @@ -113,6 +114,7 @@ const std::map WINDOW_TO_JS_SESSION_TYPE_MAP { { WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, JsSessionType::TYPE_NAVIGATION_INDICATOR }, { WindowType::WINDOW_TYPE_SEARCHING_BAR, JsSessionType::TYPE_SEARCHING_BAR }, { WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW, JsSessionType::TYPE_SYSTEM_SUB_WINDOW }, + { WindowType::WINDOW_TYPE_HANDWRITE, JsSessionType::TYPE_HANDWRITE }, }; const std::map JS_SESSION_TO_WINDOW_TYPE_MAP { @@ -148,6 +150,7 @@ const std::map JS_SESSION_TO_WINDOW_TYPE_MAP { { JsSessionType::TYPE_NAVIGATION_INDICATOR, WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR }, { JsSessionType::TYPE_SEARCHING_BAR, WindowType::WINDOW_TYPE_SEARCHING_BAR }, { JsSessionType::TYPE_SYSTEM_SUB_WINDOW, WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW }, + { JsSessionType::TYPE_HANDWRITE, WindowType::WINDOW_TYPE_HANDWRITE }, }; const std::map WINDOW_ORIENTATION_TO_JS_SESSION_MAP { diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 786bcada4..ef4026e11 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -92,7 +92,7 @@ bool WindowSceneSessionImpl::IsValidSystemWindowType(const WindowType& type) type == WindowType::WINDOW_TYPE_VOLUME_OVERLAY || type == WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR || type == WindowType::WINDOW_TYPE_SYSTEM_TOAST || type == WindowType::WINDOW_TYPE_SYSTEM_FLOAT || type == WindowType::WINDOW_TYPE_PIP || type == WindowType::WINDOW_TYPE_GLOBAL_SEARCH || - type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW)) { + type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW || type == WindowType::WINDOW_TYPE_HANDWRITE)){ TLOGI(WmsLogTag::WMS_SYSTEM, "Invalid type: %{public}u", type); return false; } @@ -1910,6 +1910,10 @@ WMError WindowSceneSessionImpl::AddWindowFlag(WindowFlag flag) WLOGI("Can not add window flag WINDOW_FLAG_SHOW_WHEN_LOCKED"); return WMError::WM_ERROR_INVALID_PERMISSION; } + if (flag == WindowFlag::WINDOW_FLAG_HANDWRITING && !SessionPermission::IsSystemCalling()) { + WLOGI("Can not add window flag WINDOW_FLAG_HANDWRITING"); + return WMError::WM_ERROR_INVALID_PERMISSION; + } uint32_t updateFlags = property_->GetWindowFlags() | (static_cast(flag)); return SetWindowFlags(updateFlags); } diff --git a/wmserver/src/input_window_monitor.cpp b/wmserver/src/input_window_monitor.cpp index fe20f4569..31a7a8ad2 100644 --- a/wmserver/src/input_window_monitor.cpp +++ b/wmserver/src/input_window_monitor.cpp @@ -210,6 +210,9 @@ void InputWindowMonitor::TraverseWindowNodes(const std::vector> WLOGFD("window is not touchable: %{public}u", windowNode->GetWindowId()); windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_UNTOUCHABLE; } + if (!windowNode->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING)) { + windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_UNTOUCHABLE; + } windowsInfo.emplace_back(windowInfo); } } -- Gitee From 5cc8fdc711de3d64dbd9b7044cdb496c8ee7e392 Mon Sep 17 00:00:00 2001 From: cloud_nine Date: Thu, 21 Mar 2024 11:27:35 +0800 Subject: [PATCH 098/385] =?UTF-8?q?=E9=81=BF=E5=85=8D=E7=81=AD=E5=B1=8F?= =?UTF-8?q?=E5=90=8E=E6=9C=AA=E5=8F=96=E6=B6=88=E4=BC=A0=E6=84=9F=E5=99=A8?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E5=BD=B1=E5=93=8D=E5=8A=9F=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wulehui --- window_scene/session_manager/src/screen_session_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index ce3ba8f54..0fa1386bf 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -1045,6 +1045,7 @@ bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateCh if (foldScreenController_ != nullptr) { rsInterface_.SetScreenPowerStatus(foldScreenController_->GetCurrentScreenId(), status); + HandlerSensor(status); } else { for (auto screenId : screenIds) { rsInterface_.SetScreenPowerStatus(screenId, status); -- Gitee From 7d26c3270c6640cee89148395bab574fc7bec377 Mon Sep 17 00:00:00 2001 From: lijie176 Date: Thu, 21 Mar 2024 10:55:13 +0800 Subject: [PATCH 099/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9TimeOut=E4=B8=BATimeo?= =?UTF-8?q?ut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijie176 --- .../sessioninterface_fuzzer.cpp | 2 +- window_scene/session/host/include/session.h | 4 ++-- .../session/host/include/zidl/session_interface.h | 2 +- window_scene/session/host/include/zidl/session_proxy.h | 2 +- window_scene/session/host/include/zidl/session_stub.h | 2 +- window_scene/session/host/src/session.cpp | 6 ++++-- window_scene/session/host/src/zidl/session_proxy.cpp | 2 +- window_scene/session/host/src/zidl/session_stub.cpp | 8 ++++---- window_scene/test/mock/mock_session_stub.h | 2 +- window_scene/test/unittest/session_proxy_test.cpp | 10 +++++----- window_scene/test/unittest/session_stub_test.cpp | 2 +- window_scene/test/unittest/session_test.cpp | 10 +++++----- 12 files changed, 27 insertions(+), 25 deletions(-) diff --git a/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp b/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp index 90441c6c8..e47b3bf6a 100644 --- a/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp +++ b/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp @@ -272,7 +272,7 @@ void ProxyInterfaceFuzzTestPart3(const uint8_t* data, size_t size) proxy->NotifyRemoteReady(); proxy->NotifyExtensionDied(); int32_t errorCode = 1; - proxy->NotifyExtensionTimeOut(errorCode); + proxy->NotifyExtensionTimeout(errorCode); } void ProxyInterfaceFuzzTest(const uint8_t* data, size_t size) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index b335a448e..9843d8baf 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -86,7 +86,7 @@ public: virtual void OnBackground() = 0; virtual void OnDisconnect() = 0; virtual void OnExtensionDied() = 0; - virtual void OnExtensionTimeOut(int32_t errorCode) {}; + virtual void OnExtensionTimeout(int32_t errorCode) {}; virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) = 0; }; @@ -127,7 +127,7 @@ public: void NotifyBackground(); void NotifyDisconnect(); void NotifyExtensionDied() override; - void NotifyExtensionTimeOut(int32_t errorCode) override; + void NotifyExtensionTimeout(int32_t errorCode) override; void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index e3778acf1..df386237a 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -78,7 +78,7 @@ public: } virtual void NotifyRemoteReady() {} virtual void NotifyExtensionDied() {} - virtual void NotifyExtensionTimeOut(int32_t errorCode) {} + virtual void NotifyExtensionTimeout(int32_t errorCode) {} virtual void TriggerBindModalUIExtension() {} virtual void NotifySyncOn() {} virtual void NotifyAsyncOn() {} diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index 771e6c60d..fc8fb780f 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -67,7 +67,7 @@ public: void NotifySyncOn() override; void NotifyAsyncOn() override; void NotifyExtensionDied() override; - void NotifyExtensionTimeOut(int32_t errorCode) override; + void NotifyExtensionTimeout(int32_t errorCode) override; void TriggerBindModalUIExtension() override; void NotifyPiPWindowPrepareClose() override; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 1698b438e..8c5d9b87e 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -72,7 +72,7 @@ private: int HandleNotifySyncOn(MessageParcel& data, MessageParcel& reply); int HandleNotifyAsyncOn(MessageParcel& data, MessageParcel& reply); int HandleNotifyExtensionDied(MessageParcel& data, MessageParcel& reply); - int HandleNotifyExtensionTimeOut(MessageParcel& data, MessageParcel& reply); + int HandleNotifyExtensionTimeout(MessageParcel& data, MessageParcel& reply); int HandleTriggerBindModalUIExtension(MessageParcel& data, MessageParcel& reply); int HandleTransferAccessibilityEvent(MessageParcel& data, MessageParcel& reply); static const std::map stubFuncMap_; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 9b562b216..494d92549 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -330,6 +330,7 @@ void Session::NotifyDisconnect() void Session::NotifyExtensionDied() { + TLOGD(WmsLogTag::WMS_UIEXT, "NotifyExtensionDied called in session."); auto lifecycleListeners = GetListeners(); std::lock_guard lock(lifecycleListenersMutex_); for (auto& listener : lifecycleListeners) { @@ -339,13 +340,14 @@ void Session::NotifyExtensionDied() } } -void Session::NotifyExtensionTimeOut(int32_t errorCode) +void Session::NotifyExtensionTimeout(int32_t errorCode) { + TLOGD(WmsLogTag::WMS_UIEXT, "NotifyExtensionTimeout(errorCode:%{public}d) called in session.", errorCode); auto lifecycleListeners = GetListeners(); std::lock_guard lock(lifecycleListenersMutex_); for (auto& listener : lifecycleListeners) { if (!listener.expired()) { - listener.lock()->OnExtensionTimeOut(errorCode); + listener.lock()->OnExtensionTimeout(errorCode); } } } diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 6f21b8597..0c808ccfe 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -865,7 +865,7 @@ void SessionProxy::NotifyExtensionDied() } } -void SessionProxy::NotifyExtensionTimeOut(int32_t errorCode) +void SessionProxy::NotifyExtensionTimeout(int32_t errorCode) { MessageParcel data; MessageParcel reply; diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 557a603ef..f8bb355be 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -107,7 +107,7 @@ const std::map SessionStub::stubFuncMap_ { std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DIED), &SessionStub::HandleNotifyExtensionDied), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_TIMEOUT), - &SessionStub::HandleNotifyExtensionTimeOut), + &SessionStub::HandleNotifyExtensionTimeout), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION), &SessionStub::HandleTriggerBindModalUIExtension), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_REPORT_ACCESSIBILITY_EVENT), @@ -529,15 +529,15 @@ int SessionStub::HandleNotifyExtensionDied(MessageParcel& data, MessageParcel& r return ERR_NONE; } -int SessionStub::HandleNotifyExtensionTimeOut(MessageParcel& data, MessageParcel& reply) +int SessionStub::HandleNotifyExtensionTimeout(MessageParcel& data, MessageParcel& reply) { - WLOGFD("HandleNotifyExtensionTimeOut called"); + WLOGFD("HandleNotifyExtensionTimeout called"); int32_t errorCode = 0; if (!data.ReadInt32(errorCode)) { WLOGFE("Read eventId from parcel failed!"); return ERR_INVALID_DATA; } - NotifyExtensionTimeOut(errorCode); + NotifyExtensionTimeout(errorCode); return ERR_NONE; } diff --git a/window_scene/test/mock/mock_session_stub.h b/window_scene/test/mock/mock_session_stub.h index 2c7e12be6..460178658 100644 --- a/window_scene/test/mock/mock_session_stub.h +++ b/window_scene/test/mock/mock_session_stub.h @@ -69,7 +69,7 @@ public: MOCK_METHOD2(HandleTransferExtensionData, int(MessageParcel &data, MessageParcel &reply)); MOCK_METHOD2(HandleNotifyRemoteReady, int(MessageParcel &data, MessageParcel &reply)); MOCK_METHOD2(HandleNotifyExtensionDied, int(MessageParcel &data, MessageParcel &reply)); - MOCK_METHOD2(HandleNotifyExtensionTimeOut, int(MessageParcel &data, MessageParcel &reply)); + MOCK_METHOD2(HandleNotifyExtensionTimeout, int(MessageParcel &data, MessageParcel &reply)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_proxy_test.cpp b/window_scene/test/unittest/session_proxy_test.cpp index 0d432247e..16a623cae 100644 --- a/window_scene/test/unittest/session_proxy_test.cpp +++ b/window_scene/test/unittest/session_proxy_test.cpp @@ -431,18 +431,18 @@ HWTEST_F(SessionProxyTest, NotifyExtensionDied, Function | SmallTest | Level2) } /** - * @tc.name: NotifyExtensionTimeOut + * @tc.name: NotifyExtensionTimeout * @tc.desc: normal function * @tc.type: FUNC */ -HWTEST_F(SessionProxyTest, NotifyExtensionTimeOut, Function | SmallTest | Level2) +HWTEST_F(SessionProxyTest, NotifyExtensionTimeout, Function | SmallTest | Level2) { - GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeOut start"; + GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeout start"; sptr iRemoteObjectMocker = new IRemoteObjectMocker(); SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); - sProxy->NotifyExtensionTimeOut(2); + sProxy->NotifyExtensionTimeout(2); - GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeOut end"; + GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeout end"; } /** diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index a067d26b7..d8ba772ac 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -172,7 +172,7 @@ HWTEST_F(SessionStubTest, sessionStubTest02, Function | SmallTest | Level2) ASSERT_EQ(0, res); res = session_->HandleNotifyExtensionDied(data, reply); ASSERT_EQ(0, res); - res = session_->HandleNotifyExtensionTimeOut(data, reply); + res = session_->HandleNotifyExtensionTimeout(data, reply); ASSERT_EQ(0, res); } diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 76204005d..309af2b7a 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -1258,17 +1258,17 @@ HWTEST_F(WindowSessionTest, NotifyExtensionDied, Function | SmallTest | Level2) } /** - * @tc.name: NotifyExtensionTimeOut - * @tc.desc: NotifyExtensionTimeOut Test + * @tc.name: NotifyExtensionTimeout + * @tc.desc: NotifyExtensionTimeout Test * @tc.type: FUNC */ -HWTEST_F(WindowSessionTest, NotifyExtensionTimeOut, Function | SmallTest | Level2) +HWTEST_F(WindowSessionTest, NotifyExtensionTimeout, Function | SmallTest | Level2) { ASSERT_NE(session_, nullptr); session_->state_ = SessionState::STATE_DISCONNECT; - session_->NotifyExtensionTimeOut(3); + session_->NotifyExtensionTimeout(3); - ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->SetFocusable(false)); + ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false)); } /** -- Gitee From 72112b277bc1f01b2c3cc476a672fadfe09a7332 Mon Sep 17 00:00:00 2001 From: gonghongyu Date: Thu, 21 Mar 2024 17:09:06 +0800 Subject: [PATCH 100/385] delete SetActive method in WindowSceneSessionImpl Signed-off-by: gonghongyu --- wm/include/window_scene_session_impl.h | 1 - wm/src/window_scene_session_impl.cpp | 21 ------------------- .../window_scene_session_impl_test.cpp | 1 + 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 67b746887..fc7303f9b 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -51,7 +51,6 @@ public: WMError SetTextFieldAvoidInfo(double textFieldPositionY, double textFieldHeight) override; void PreProcessCreate(); void SetDefaultProperty(); - WSError SetActive(bool active) override; WMError DisableAppWindowDecor() override; bool IsDecorEnable() const override; WMError Minimize() override; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 786bcada4..e824e3b25 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -904,27 +904,6 @@ void WindowSceneSessionImpl::SetDefaultProperty() } } -WSError WindowSceneSessionImpl::SetActive(bool active) -{ - WLOGFI("[WMSCom] active status: %{public}d", active); - if (!WindowHelper::IsMainWindow(GetType())) { - if (hostSession_ == nullptr) { - WLOGFD("hostSession_ nullptr"); - return WSError::WS_ERROR_INVALID_WINDOW; - } - WSError ret = hostSession_->UpdateActiveStatus(active); - if (ret != WSError::WS_OK) { - return ret; - } - } - if (active) { - NotifyAfterActive(); - } else { - NotifyAfterInactive(); - } - return WSError::WS_OK; -} - void WindowSceneSessionImpl::DestroySubWindow() { const int32_t& parentPersistentId = property_->GetParentPersistentId(); diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 382c8b1bc..393363e84 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -527,6 +527,7 @@ HWTEST_F(WindowSceneSessionImplTest, SetActive01, Function | SmallTest | Level2) windowscenesession->hostSession_ = session; ASSERT_EQ(WSError::WS_OK, windowscenesession->SetActive(false)); + ASSERT_EQ(WSError::WS_OK, windowscenesession->SetActive(true)); } /** -- Gitee From 597b72a137f475f460552c230d57e6b4d64273bf Mon Sep 17 00:00:00 2001 From: l30030525 Date: Thu, 21 Mar 2024 17:37:04 +0800 Subject: [PATCH 101/385] =?UTF-8?q?=E6=96=B0=E5=A2=9EUIExtensiong=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=87=AA=E5=88=9B=E9=89=B4=E6=9D=83=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- .../common/include/session_permission.h | 1 + .../common/src/session_permission.cpp | 33 +++++++++++++++++++ .../src/scene_session_manager.cpp | 3 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/window_scene/common/include/session_permission.h b/window_scene/common/include/session_permission.h index 7236b2118..822483e6e 100644 --- a/window_scene/common/include/session_permission.h +++ b/window_scene/common/include/session_permission.h @@ -35,6 +35,7 @@ public: static bool IsSACalling(); static bool VerifyCallingPermission(const std::string& permissionName); static bool IsSameBundleNameAsCalling(const std::string& bundleName); + static bool IsStartedByUIExtension(); }; } // Rosen } // OHOS diff --git a/window_scene/common/src/session_permission.cpp b/window_scene/common/src/session_permission.cpp index 54ab04f44..67bb8aaa4 100644 --- a/window_scene/common/src/session_permission.cpp +++ b/window_scene/common/src/session_permission.cpp @@ -234,5 +234,38 @@ bool SessionPermission::IsSameBundleNameAsCalling(const std::string& bundleName) return false; } } + +bool SessionPermission::IsStartedByUIExtension() +{ + auto bundleManagerServiceProxy_ = GetBundleManagerProxy(); + if (!bundleManagerServiceProxy_) { + WLOGFE("failed to get BundleManagerServiceProxy"); + return false; + } + + int uid = IPCSkeleton::GetCallingUid(); + // reset ipc identity + std::string identity = IPCSkeleton::ResetCallingIdentity(); + std::string bundleName; + bundleManagerServiceProxy_->GetNameForUid(uid, bundleName); + AppExecFwk::BundleInfo bundleInfo; + // 200000 use uid to caculate userId + int userId = uid / 200000; + bool result = bundleManagerServiceProxy_->GetBundleInfo(bundleName, + AppExecFwk::BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO, bundleInfo, userId); + // set ipc identity to raw + IPCSkeleton::SetCallingIdentity(identity); + if (!result) { + WLOGFE("failed to query extension ability info, bundleName:%{public}s, userId:%{public}d", + bundleName.c_str(), userId); + return false; + } + + auto extensionInfo = std::find_if(bundleInfo.extensionInfos.begin(), bundleInfo.extensionInfos.end(), + [](AppExecFwk::ExtensionAbilityInfo extensionInfo) { + return (extensionInfo.type == AppExecFwk::ExtensionAbilityType::SYS_COMMON_UI); + }); + return extensionInfo != bundleInfo.extensionInfos.end(); +} } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 4bb8d35d0..f2823f823 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1705,7 +1705,8 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetExtensionFlag() == true) { + if (SessionPermission::IsStartedByUIExtension() && + property->GetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW) { auto extensionParentSession = GetSceneSession(property->GetParentPersistentId()); SessionInfo sessionInfo = extensionParentSession->GetSessionInfo(); AAFwk::UIExtensionHostInfo hostInfo; -- Gitee From 165903dbda3f25c0514714b3eab88af9debe0eed Mon Sep 17 00:00:00 2001 From: xuhaodong Date: Wed, 20 Mar 2024 18:59:29 +0800 Subject: [PATCH 102/385] =?UTF-8?q?wms=E5=8A=A0=E5=85=A5=E5=88=B0=E5=BC=80?= =?UTF-8?q?=E6=9C=BAevent=E6=8A=95=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuhaodong --- etc/wms.para | 3 ++- etc/wms.para.dac | 3 ++- wmserver/BUILD.gn | 2 +- wmserver/src/mock_session_manager_service.cpp | 3 ++- wmserver/src/window_manager_service.cpp | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/etc/wms.para b/etc/wms.para index 10cefe49e..eecfd0787 100644 --- a/etc/wms.para +++ b/etc/wms.para @@ -11,4 +11,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -bootevent.wms.fullscreen.ready=false \ No newline at end of file +bootevent.wms.fullscreen.ready=false +bootevent.wms.ready=false \ No newline at end of file diff --git a/etc/wms.para.dac b/etc/wms.para.dac index cdccccffe..2c8f6c551 100644 --- a/etc/wms.para.dac +++ b/etc/wms.para.dac @@ -11,4 +11,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -bootevent.wms.fullscreen.ready = foundation:foundation:0775 \ No newline at end of file +bootevent.wms.fullscreen.ready = foundation:foundation:0775 +bootevent.wms.ready = foundation:foundation:0775 \ No newline at end of file diff --git a/wmserver/BUILD.gn b/wmserver/BUILD.gn index 0bec4801e..a832510fd 100644 --- a/wmserver/BUILD.gn +++ b/wmserver/BUILD.gn @@ -133,7 +133,7 @@ ohos_shared_library("sms") { if (scene_board_enabled) { group("libwms") { - deps = [] + deps = [ "../etc:wms_etc" ] } } else { ohos_shared_library("libwms") { diff --git a/wmserver/src/mock_session_manager_service.cpp b/wmserver/src/mock_session_manager_service.cpp index 044664c73..bd0755dc3 100644 --- a/wmserver/src/mock_session_manager_service.cpp +++ b/wmserver/src/mock_session_manager_service.cpp @@ -57,6 +57,7 @@ const std::string ARG_DUMP_WINDOW = "-w"; const std::string KEY_SCENE_BOARD_TEST_ENABLE = "persist.scb.testmode.enable"; const std::string SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard"; const std::string TEST_MODULE_NAME_SUFFIX = "_test"; +const std::string BOOTEVENT_WMS_READY = "bootevent.wms.ready"; } // namespace class ClientListenerDeathRecipient : public IRemoteObject::DeathRecipient { @@ -187,7 +188,7 @@ bool MockSessionManagerService::SetSessionManagerService(const sptr()); +const std::string BOOTEVENT_WMS_READY = "bootevent.wms.ready"; WindowManagerService::WindowManagerService() : SystemAbility(WINDOW_MANAGER_SERVICE_ID, true), rsInterface_(RSInterfaces::GetInstance()), @@ -108,7 +109,7 @@ void WindowManagerService::OnStart() sptr windowInfoQueriedListener = new WindowInfoQueriedListener(); DisplayManagerServiceInner::GetInstance().RegisterWindowInfoQueriedListener(windowInfoQueriedListener); - + system::SetParameter(BOOTEVENT_WMS_READY.c_str(), "true"); AddSystemAbilityListener(RENDER_SERVICE); AddSystemAbilityListener(ABILITY_MGR_SERVICE_ID); AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); -- Gitee From 8b57f29341bc5f7f0df3daf195ac91af4448398c Mon Sep 17 00:00:00 2001 From: xiazhiqi Date: Thu, 21 Mar 2024 11:23:29 +0000 Subject: [PATCH 103/385] fix KeepScreenOn,GetTopWindow Async Problem Signed-off-by: xiazhiqi Change-Id: I9a6b7a222e013089fd3931b8ee9f8f6f5899854f --- .../window_manager_napi/js_window_manager.cpp | 115 +++++++++--------- .../window_runtime/window_napi/js_window.cpp | 33 +++-- 2 files changed, 79 insertions(+), 69 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index c495d6b7d..604724d9f 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -757,49 +757,70 @@ napi_value JsWindowManager::OnUnregisterWindowManagerCallback(napi_env env, napi return NapiGetUndefined(env); } -static void GetTopWindowTask(void* contextPtr, napi_env env, NapiAsyncTask& task, bool newApi) -{ - std::string windowName; +struct TopWindowInfoList { sptr window = nullptr; AppExecFwk::Ability* ability = nullptr; - bool isOldApi = GetAPI7Ability(env, ability); - int32_t error; - if (isOldApi) { - if (ability->GetWindow() == nullptr) { - error = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : + int32_t errorCode = 0; + std::string errMsg = ""; +}; +static napi_value GetTopWindowTask(void* contextPtr, napi_env env, napi_value callback, bool newApi) +{ + std::shared_ptr lists = std::make_shared(); + bool isOldApi = GetAPI7Ability(env, lists->ability); + NapiAsyncTask::ExecuteCallback execute = [lists, isOldApi, newApi, contextPtr]() { + if (lists == nullptr) { + return; + } + if (isOldApi) { + if (lists->ability->GetWindow() == nullptr) { + lists->errorCode = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : + static_cast(WMError::WM_ERROR_NULLPTR); + lists->errMsg = "FA mode can not get ability window"; + return; + } + lists->window = Window::GetTopWindowWithId(lists->ability->GetWindow()->GetWindowId()); + } else { + auto context = static_cast*>(contextPtr); + if (contextPtr == nullptr || context == nullptr) { + lists->errorCode = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : + static_cast(WMError::WM_ERROR_NULLPTR); + lists->errMsg = "Stage mode without context"; + return; + } + lists->window = Window::GetTopWindowWithContext(context->lock()); + } + }; + NapiAsyncTask::CompleteCallback complete = [lists, newApi](napi_env env, NapiAsyncTask& task, int32_t status) { + if (lists == nullptr) { + int32_t error = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : static_cast(WMError::WM_ERROR_NULLPTR); - task.Reject(env, CreateJsError(env, error, "FA mode can not get ability window")); - WLOGE("FA mode can not get ability window"); + task.Reject(env, CreateJsError(env, error, "napi abnormal")); return; } - window = Window::GetTopWindowWithId(ability->GetWindow()->GetWindowId()); - } else { - auto context = static_cast*>(contextPtr); - if (contextPtr == nullptr || context == nullptr) { - error = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : + if (lists->errorCode != 0) { + task.Reject(env, CreateJsError(env, lists->errorCode, lists->errMsg)); + WLOGFE("%{public}s", lists->errMsg.c_str()); + return; + } + if (lists->window == nullptr) { + auto error = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : static_cast(WMError::WM_ERROR_NULLPTR); - task.Reject(env, CreateJsError(env, error, "Stage mode without context")); - WLOGFE("Stage mode without context"); + task.Reject(env, CreateJsError(env, error, "Get top window failed")); return; } - window = Window::GetTopWindowWithContext(context->lock()); - } - if (window == nullptr) { - error = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : - static_cast(WMError::WM_ERROR_NULLPTR); - task.Reject(env, CreateJsError(env, error, "Get top window failed")); - WLOGFE("Get top window failed"); - return; - } - windowName = window->GetWindowName(); - std::shared_ptr jsWindowObj = FindJsWindowObject(windowName); - if (jsWindowObj != nullptr && jsWindowObj->GetNapiValue() != nullptr) { - task.Resolve(env, jsWindowObj->GetNapiValue()); - } else { - task.Resolve(env, CreateJsWindowObject(env, window)); - } - WLOGD("Get top window %{public}s success", windowName.c_str()); - return; + std::string windowName = lists->window->GetWindowName(); + std::shared_ptr jsWindowObj = FindJsWindowObject(windowName); + if (jsWindowObj != nullptr && jsWindowObj->GetNapiValue() != nullptr) { + task.Resolve(env, jsWindowObj->GetNapiValue()); + } else { + task.Resolve(env, CreateJsWindowObject(env, lists->window)); + } + WLOGD("Get top window %{public}s success", windowName.c_str()); + }; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindowManager::OnGetTopWindow", + env, CreateAsyncTaskWithLastParam(env, callback, std::move(execute), std::move(complete), &result)); + return result; } napi_value JsWindowManager::OnGetTopWindow(napi_env env, napi_callback_info info) @@ -826,20 +847,7 @@ napi_value JsWindowManager::OnGetTopWindow(napi_env env, napi_callback_info info } GetNativeContext(env, nativeContext, contextPtr, errCode); } - - WLOGI("err %{public}u", errCode); - NapiAsyncTask::CompleteCallback complete = - [=](napi_env env, NapiAsyncTask& task, int32_t status) { - if (errCode != WMError::WM_OK) { - task.Reject(env, CreateJsError(env, static_cast(errCode), "Invalidate params")); - return; - } - return GetTopWindowTask(contextPtr, env, task, false); - }; - napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindowManager::OnGetTopWindow", - env, CreateAsyncTaskWithLastParam(env, nativeCallback, nullptr, std::move(complete), &result)); - return result; + return GetTopWindowTask(contextPtr, env, nativeCallback, false); } napi_value JsWindowManager::OnGetLastWindow(napi_env env, napi_callback_info info) @@ -866,14 +874,7 @@ napi_value JsWindowManager::OnGetLastWindow(napi_env env, napi_callback_info inf return NapiGetUndefined(env); } - NapiAsyncTask::CompleteCallback complete = - [=](napi_env env, NapiAsyncTask& task, int32_t status) { - return GetTopWindowTask(contextPtr, env, task, true); - }; - napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindowManager::OnGetTopWindow", - env, CreateAsyncTaskWithLastParam(env, nativeCallback, nullptr, std::move(complete), &result)); - return result; + return GetTopWindowTask(contextPtr, env, nativeCallback, true); } napi_value JsWindowManager::OnSetWindowLayoutMode(napi_env env, napi_callback_info info) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index dcc8d855f..ecd8a6dd1 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -3004,31 +3004,40 @@ napi_value JsWindow::OnSetWindowKeepScreenOn(napi_env env, napi_callback_info in } wptr weakToken(windowToken_); + std::shared_ptr errCodeExe = std::make_shared(WmErrorCode::WM_OK); + NapiAsyncTask::ExecuteCallback execute = [weakToken, keepScreenOn, errCodeExe] () { + if (errCodeExe == nullptr) { + return; + } + auto weakWindow = weakToken.promote(); + if (weakWindow == nullptr) { + *errCodeExe = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + return; + } + *errCodeExe = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetKeepScreenOn(keepScreenOn)); + WLOGI("Window [%{public}u, %{public}s] set keep screen on end", + weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); + }; NapiAsyncTask::CompleteCallback complete = - [weakToken, keepScreenOn](napi_env env, NapiAsyncTask& task, int32_t status) { - auto weakWindow = weakToken.promote(); - if (weakWindow == nullptr) { - task.Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "Invalidate params.")); + [weakToken, keepScreenOn, errCodeExe](napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCodeExe == nullptr) { + task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "System abnormal.")); return; } - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetKeepScreenOn(keepScreenOn)); - if (ret == WmErrorCode::WM_OK) { + if (*errCodeExe == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, CreateJsError(env, static_cast(ret), + task.Reject(env, CreateJsError(env, static_cast(*errCodeExe), "Window set keep screen on failed")); } - WLOGI("Window [%{public}u, %{public}s] set keep screen on end", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); }; napi_value lastParam = (argc <= 1) ? nullptr : ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); napi_value result = nullptr; NapiAsyncTask::Schedule("JsWindow::OnSetWindowKeepScreenOn", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result)); return result; } -- Gitee From 73dde18af854ab732dea0b8d47005321488c1dfe Mon Sep 17 00:00:00 2001 From: Deltsov Andrey Date: Thu, 21 Mar 2024 12:51:49 +0000 Subject: [PATCH 104/385] Update window_scene/session_manager/src/scene_session_manager.cpp --- 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 47dc505f0..af097b42e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -161,7 +161,7 @@ int Comp(const std::pair &a, const std::pairsize() == 1) { const auto& numbers = *item.intsValue_; -- Gitee From f7fa734e607623fb0ca7d05ea816bc957b3150f8 Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Thu, 21 Mar 2024 13:18:48 +0000 Subject: [PATCH 105/385] update wmserver/src/input_window_monitor.cpp. Signed-off-by: chengyiyi --- wmserver/src/input_window_monitor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wmserver/src/input_window_monitor.cpp b/wmserver/src/input_window_monitor.cpp index 31a7a8ad2..deca58b6f 100644 --- a/wmserver/src/input_window_monitor.cpp +++ b/wmserver/src/input_window_monitor.cpp @@ -210,8 +210,8 @@ void InputWindowMonitor::TraverseWindowNodes(const std::vector> WLOGFD("window is not touchable: %{public}u", windowNode->GetWindowId()); windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_UNTOUCHABLE; } - if (!windowNode->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING)) { - windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_UNTOUCHABLE; + if (windowNode->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING)) { + windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_HANDWRITING; } windowsInfo.emplace_back(windowInfo); } -- Gitee From 0fa7e0f32b7b5d5da5969b8e1a127a239d5ab8cc Mon Sep 17 00:00:00 2001 From: zhangkai Date: Thu, 21 Mar 2024 22:11:48 +0800 Subject: [PATCH 106/385] can double regist Signed-off-by: zhangkai Change-Id: Ib0dfde416180bb70a4dd3c6998ac2ade306015c2 --- .../window_runtime/window_napi/js_window_register_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp index d02b20ad3..4e494362b 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp @@ -314,7 +314,7 @@ WmErrorCode JsWindowRegisterManager::RegisterListener(sptr window, std:: { std::lock_guard lock(mtx_); if (IsCallbackRegistered(env, type, value)) { - return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + return WmErrorCode::WM_OK; } if (listenerProcess_[caseType].count(type) == 0) { WLOGFE("[NAPI]Type %{public}s is not supported", type.c_str()); @@ -346,7 +346,7 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr window, std std::lock_guard lock(mtx_); if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) { WLOGFE("[NAPI]Type %{public}s was not registerted", type.c_str()); - return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + return WmErrorCode::WM_OK; } if (listenerProcess_[caseType].count(type) == 0) { WLOGFE("[NAPI]Type %{public}s is not supported", type.c_str()); -- Gitee From 38e89e03970ec273d6c7ddcf15479e5cf3ed7c87 Mon Sep 17 00:00:00 2001 From: Deltsov Andrey Date: Thu, 21 Mar 2024 14:35:43 +0000 Subject: [PATCH 107/385] Update window_scene/session_manager/src/scene_session_manager.cpp --- 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 af097b42e..0e842303c 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -165,7 +165,7 @@ bool GetSingleIntItem(const WindowSceneConfig::ConfigItem& item, int32_t& value) { if (item.IsInts() && item.intsValue_ && item.intsValue_->size() == 1) { const auto& numbers = *item.intsValue_; - value = numbers[0]; + value = item.intsValue_->numbers[0]; return true; } return false; -- Gitee From 425fe9e9745699c8bb467b64ca334c98b955ca1e Mon Sep 17 00:00:00 2001 From: Deltsov Andrey Date: Thu, 21 Mar 2024 14:36:07 +0000 Subject: [PATCH 108/385] Update window_scene/session_manager/src/scene_session_manager.cpp --- 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 0e842303c..874fee9f2 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -310,7 +310,7 @@ void SceneSessionManager::ConfigWindowSceneXml() item = config["backgroundswitch"]; int32_t param = -1; if (GetSingleIntItem(item, param) && param == 1) { - systemConfig_.backgroundswitch = true; + systemConfig_.backgroundswitch = GetSingleIntItem(item, param) && param == 1; } WLOGFD("Load ConfigWindowSceneXml backgroundswitch%{public}d", systemConfig_.backgroundswitch); item = config["defaultWindowMode"]; -- Gitee From 1968e88f119be35579131d4633cb0b47d8be12fe Mon Sep 17 00:00:00 2001 From: Deltsov Andrey Date: Thu, 21 Mar 2024 14:36:34 +0000 Subject: [PATCH 109/385] Update window_scene/session_manager/src/scene_session_manager.cpp --- window_scene/session_manager/src/scene_session_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 874fee9f2..63eaba005 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -168,6 +168,7 @@ bool GetSingleIntItem(const WindowSceneConfig::ConfigItem& item, int32_t& value) value = item.intsValue_->numbers[0]; return true; } + value = -1; return false; } } // namespace -- Gitee From c0071ec09a4c0a6abd02eb2bad18ebcba7406427 Mon Sep 17 00:00:00 2001 From: lijie176 Date: Thu, 21 Mar 2024 23:00:33 +0800 Subject: [PATCH 110/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijie176 --- window_scene/session/host/src/session.cpp | 5 +++-- window_scene/session/host/src/zidl/session_proxy.cpp | 6 +++--- window_scene/session/host/src/zidl/session_stub.cpp | 3 +-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 494d92549..fbb54fc9d 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -330,7 +330,7 @@ void Session::NotifyDisconnect() void Session::NotifyExtensionDied() { - TLOGD(WmsLogTag::WMS_UIEXT, "NotifyExtensionDied called in session."); + TLOGI(WmsLogTag::WMS_UIEXT, "NotifyExtensionDied called in session(persistentId:%{public}d).", persistentId_); auto lifecycleListeners = GetListeners(); std::lock_guard lock(lifecycleListenersMutex_); for (auto& listener : lifecycleListeners) { @@ -342,7 +342,8 @@ void Session::NotifyExtensionDied() void Session::NotifyExtensionTimeout(int32_t errorCode) { - TLOGD(WmsLogTag::WMS_UIEXT, "NotifyExtensionTimeout(errorCode:%{public}d) called in session.", errorCode); + TLOGI(WmsLogTag::WMS_UIEXT, "NotifyExtensionTimeout(errorCode:%{public}d) in session(persistentId:%{public}d).", + errorCode, persistentId_); auto lifecycleListeners = GetListeners(); std::lock_guard lock(lifecycleListenersMutex_); for (auto& listener : lifecycleListeners) { diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 0c808ccfe..7c51088f0 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -871,16 +871,16 @@ void SessionProxy::NotifyExtensionTimeout(int32_t errorCode) MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed"); return; } if (!data.WriteInt32(static_cast(errorCode))) { - WLOGFE("errorCode write failed."); + TLOGE(WmsLogTag::WMS_UIEXT, "errorCode write failed."); return; } if (Remote()->SendRequest(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_TIMEOUT), data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed"); } } diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index f8bb355be..e67a6c27f 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -531,10 +531,9 @@ int SessionStub::HandleNotifyExtensionDied(MessageParcel& data, MessageParcel& r int SessionStub::HandleNotifyExtensionTimeout(MessageParcel& data, MessageParcel& reply) { - WLOGFD("HandleNotifyExtensionTimeout called"); int32_t errorCode = 0; if (!data.ReadInt32(errorCode)) { - WLOGFE("Read eventId from parcel failed!"); + TLOGE(WmsLogTag::WMS_UIEXT, "Read eventId from parcel failed!"); return ERR_INVALID_DATA; } NotifyExtensionTimeout(errorCode); -- Gitee From 5b4e91b66f6b8a10359ff29225cdc240c0156d76 Mon Sep 17 00:00:00 2001 From: gazizova sofia Date: Thu, 21 Mar 2024 20:17:49 +0300 Subject: [PATCH 111/385] address review comments Signed-off-by: gazizova sofia Change-Id: Ic153d5fda66b62599ea8e402ed37b66406f9c3d0 --- .../session_manager/src/scene_session_manager.cpp | 8 ++------ .../src/screen_cutout_controller.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 63eaba005..d03edc04a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -164,11 +164,9 @@ int Comp(const std::pair &a, const std::pairsize() == 1) { - const auto& numbers = *item.intsValue_; - value = item.intsValue_->numbers[0]; + value = (*item.intsValue_)[0]; return true; } - value = -1; return false; } } // namespace @@ -310,9 +308,7 @@ void SceneSessionManager::ConfigWindowSceneXml() item = config["backgroundswitch"]; int32_t param = -1; - if (GetSingleIntItem(item, param) && param == 1) { - systemConfig_.backgroundswitch = GetSingleIntItem(item, param) && param == 1; - } + systemConfig_.backgroundswitch = GetSingleIntItem(item, param) && param == 1; WLOGFD("Load ConfigWindowSceneXml backgroundswitch%{public}d", systemConfig_.backgroundswitch); item = config["defaultWindowMode"]; if (GetSingleIntItem(item, param) && diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index 03d09ec25..5eff5e219 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -32,11 +32,11 @@ constexpr int32_t Rotate90 = 90; constexpr int32_t Rotate180 = 180; constexpr int32_t Rotate270 = 270; -template +template DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect); template<> -DMRect GetRotatedRect<90>(uint32_t width, uint32_t height, const DMRect& rect) +DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect) { return DMRect { .posX_ = width - rect.posY_ - rect.height_, .posY_ = rect.posX_, @@ -45,14 +45,14 @@ DMRect GetRotatedRect<90>(uint32_t width, uint32_t height, const DMRect& rect) } template<> -DMRect GetRotatedRect<180>(uint32_t width, uint32_t height, const DMRect& rect) +DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect) { return DMRect { width - rect.posX_ - rect.width_, height - rect.posY_ - rect.height_, rect.width_, rect.height_ }; } template<> -DMRect GetRotatedRect<270>(uint32_t width, uint32_t height, const DMRect& rect) +DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect) { return DMRect { rect.posY_, height - rect.posX_ - rect.width_, rect.height_, rect.width_ }; @@ -112,19 +112,19 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& switch (currentRotation) { case Rotation::ROTATION_90: { for (const DMRect& rect : displayBoundaryRects) { - finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); + finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); } break; } case Rotation::ROTATION_180: { for (const DMRect& rect : displayBoundaryRects) { - finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); + finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); } break; } case Rotation::ROTATION_270: { for (const DMRect& rect : displayBoundaryRects) { - finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); + finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); } break; } -- Gitee From f92ec28ec5119913890024ba2cf8a29dd91bbbe2 Mon Sep 17 00:00:00 2001 From: lijie176 Date: Fri, 22 Mar 2024 09:42:25 +0800 Subject: [PATCH 112/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=BA=E7=BA=AF=E8=99=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijie176 --- window_scene/session/host/include/session.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 9843d8baf..fb8020257 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -86,7 +86,7 @@ public: virtual void OnBackground() = 0; virtual void OnDisconnect() = 0; virtual void OnExtensionDied() = 0; - virtual void OnExtensionTimeout(int32_t errorCode) {}; + virtual void OnExtensionTimeout(int32_t errorCode) = 0; virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) = 0; }; -- Gitee From d4d87af50beb697e878deb492a1ea1199f569473 Mon Sep 17 00:00:00 2001 From: shark_00783 Date: Fri, 22 Mar 2024 10:06:10 +0800 Subject: [PATCH 113/385] =?UTF-8?q?=E6=96=B0=E5=A2=9EUIExtension=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=AD=90=E7=AA=97=E5=9C=BA=E6=99=AFtdd=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shark_00783 --- wm/test/unittest/window_session_impl_test.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index cabf86841..6f636a21c 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -1698,6 +1698,26 @@ HWTEST_F(WindowSessionImplTest, SetPipActionEvent, Function | SmallTest | Level2 ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "WindowSessionImplTest: SetPipActionEvent end"; } + +/** + * @tc.name: SetUIContentInner + * @tc.desc: SetUIContentInner Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, SetUIContentInner, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetUIContentInner start"; + sptr option = new WindowOption(); + ASSERT_NE(option, nullptr); + option->SetWindowName("SetUIContentInner"); + option->SetExtensionFlag(true); + sptr window = new (std::nothrow) WindowSessionImpl(option); + ASSERT_NE(window, nullptr); + string url = ""; + WMError res = window->SetUIContentInner(url, nullptr, nullptr, WindowSetUIContentType::DEFAULT, nullptr); + ASSERT_EQ(res, WMError::WM_ERROR_INVALID_PARAM); + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetUIContentInner end"; +} } } // namespace Rosen } // namespace OHOS -- Gitee From 33147b04c550c9f62a2eebb11bb71ae890e248ac Mon Sep 17 00:00:00 2001 From: Ning Yuanfeng Date: Fri, 22 Mar 2024 10:27:02 +0800 Subject: [PATCH 114/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ning Yuanfeng --- interfaces/innerkits/wm/window.h | 8 - interfaces/innerkits/wm/wm_common.h | 30 ---- .../inner/js_pip_manager.cpp | 19 +- .../js_pip_controller.cpp | 79 ++++---- .../js_pip_window_manager.cpp | 21 +-- utils/BUILD.gn | 2 - utils/include/pip_util.h | 37 ---- utils/include/window_manager_hilog.h | 2 + utils/src/pip_report.cpp | 33 ++-- utils/src/pip_util.cpp | 148 --------------- utils/test/unittest/BUILD.gn | 14 -- utils/test/unittest/pip_util_test.cpp | 146 --------------- .../js_scene_session.cpp | 20 +-- .../js_scene_session_manager.cpp | 27 --- .../js_scene_session_manager.h | 2 - .../container/src/zidl/session_stage_stub.cpp | 6 +- .../host/include/scene_persistent_storage.h | 13 -- .../session/host/include/scene_session.h | 9 - .../host/include/zidl/session_interface.h | 1 - .../include/zidl/session_ipc_interface_code.h | 1 - .../session/host/include/zidl/session_proxy.h | 1 - .../session/host/include/zidl/session_stub.h | 1 - .../host/src/scene_persistent_storage.cpp | 1 - .../session/host/src/scene_session.cpp | 170 +----------------- .../session/host/src/zidl/session_proxy.cpp | 37 ---- .../session/host/src/zidl/session_stub.cpp | 20 +-- .../include/scene_session_manager.h | 4 - .../src/scene_session_manager.cpp | 36 +--- .../test/unittest/scene_session_test.cpp | 57 ------ .../test/unittest/session_stub_test.cpp | 16 -- wm/include/picture_in_picture_controller.h | 2 - wm/include/picture_in_picture_manager.h | 2 - wm/include/window_scene_session_impl.h | 1 - wm/src/picture_in_picture_controller.cpp | 164 +++++++---------- wm/src/picture_in_picture_manager.cpp | 57 ++---- wm/src/window.cpp | 8 +- wm/src/window_scene_session_impl.cpp | 13 +- wm/src/window_session_impl.cpp | 4 +- .../picture_in_picture_controller_test.cpp | 3 - 39 files changed, 180 insertions(+), 1035 deletions(-) delete mode 100644 utils/include/pip_util.h delete mode 100644 utils/src/pip_util.cpp delete mode 100644 utils/test/unittest/pip_util_test.cpp diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index d0808ba89..2b956c29a 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1501,14 +1501,6 @@ public: */ virtual void UpdatePiPRect(const Rect& rect, WindowSizeChangeReason reason) {} - /** - * @brief Recovery pip main window. - * - * @param Rect of window. - * @return Errorcode of window. - */ - virtual WMError RecoveryPullPiPMainWindow(const Rect& rect) { return WMError::WM_OK; } - /** * @brief When get focused, keep the keyboard created by other windows, support system window and app subwindow. * diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index ca73ac5a4..103f540eb 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -659,36 +659,6 @@ enum class PipState : int32_t { ERROR = 6, }; -/** - * @brief Enumerates picture in picture scale level. - */ -enum class PiPScaleLevel : int32_t { - PIP_SCALE_LEVEL_SMALLEST = 0, - PIP_SCALE_LEVEL_BIGGEST = 1, - COUNT = 2, -}; - -/** - * @brief Enumerates picture in picture scale pivot. - */ -enum class PiPScalePivot : int32_t { - UNDEFINED = 0, - START, - MIDDLE, - END, -}; - -/** - * @brief Structure of picture in picture rect info. - */ -struct PiPRectInfo { - PiPScalePivot xPivot_; - PiPScalePivot yPivot_; - uint32_t originWidth_; - uint32_t originHeight_; - PiPScaleLevel level_; -}; - struct PiPTemplateInfo { uint32_t pipTemplateType; uint32_t priority; diff --git a/interfaces/kits/napi/picture_in_picture_napi/inner/js_pip_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/inner/js_pip_manager.cpp index be04fddae..ceea6bc8e 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/inner/js_pip_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/inner/js_pip_manager.cpp @@ -23,7 +23,6 @@ namespace Rosen { using namespace AbilityRuntime; using namespace Ace; namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipManager"}; constexpr int32_t NUMBER_ONE = 1; } @@ -50,7 +49,7 @@ JsPipManager::~JsPipManager() void JsPipManager::Finalizer(napi_env env, void* data, void* hint) { - WLOGFD("[NAPI]JsPipManager::Finalizer"); + TLOGD(WmsLogTag::WMS_PIP, "[NAPI]JsPipManager::Finalizer"); std::unique_ptr(static_cast(data)); } @@ -62,12 +61,12 @@ napi_value JsPipManager::InitXComponentController(napi_env env, napi_callback_in napi_value JsPipManager::OnInitXComponentController(napi_env env, napi_callback_info info) { - WLOGFD("[NAPI]JsPipManager::OnInitXComponentController"); + TLOGD(WmsLogTag::WMS_PIP, "[NAPI]JsPipManager::OnInitXComponentController"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < NUMBER_ONE) { - WLOGFE("[NAPI]Argc count is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Argc count is invalid: %{public}zu", argc); return NapiThrowInvalidParam(env); } napi_value xComponentController = argv[0]; @@ -75,28 +74,28 @@ napi_value JsPipManager::OnInitXComponentController(napi_env env, napi_callback_ XComponentController::GetXComponentControllerFromNapiValue(xComponentController); sptr pipWindow = Window::Find(PIP_WINDOW_NAME); if (!pipWindow) { - WLOGFE("[NAPI]Failed to find pip window"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to find pip window"); return NapiGetUndefined(env); } int32_t windowId = static_cast(pipWindow->GetWindowId()); sptr pipController = PictureInPictureManager::GetPipControllerInfo(windowId); if (pipController == nullptr) { - WLOGFE("[NAPI]Failed to get pictureInPictureController"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to get pictureInPictureController"); return NapiGetUndefined(env); } - WLOGFI("[NAPI]set xComponentController to window: %{public}u", windowId); + TLOGI(WmsLogTag::WMS_PIP, "[NAPI]set xComponentController to window: %{public}u", windowId); WMError errCode = pipController->SetXComponentController(xComponentControllerResult); if (errCode != WMError::WM_OK) { - WLOGFE("[NAPI]Failed to set xComponentController"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to set xComponentController"); } return NapiGetUndefined(env); } napi_value JsPipManagerInit(napi_env env, napi_value exportObj) { - WLOGFD("[NAPI]JsPipManager::JsPipManagerInit"); + TLOGD(WmsLogTag::WMS_PIP, "[NAPI]JsPipManager::JsPipManagerInit"); if (env == nullptr || exportObj == nullptr) { - WLOGFE("JsPipManagerInit failed, env or exportObj is null"); + TLOGE(WmsLogTag::WMS_PIP, "JsPipManagerInit failed, env or exportObj is null"); return nullptr; } std::unique_ptr jsPipManager = std::make_unique(); diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp index 961a481dd..ff928b6ac 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp @@ -28,7 +28,6 @@ namespace OHOS { namespace Rosen { using namespace AbilityRuntime; namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipController"}; constexpr int32_t NUMBER_TWO = 2; const std::string STATE_CHANGE_CB = "stateChange"; const std::string CONTROL_PANEL_ACTION_EVENT_CB = "controlPanelActionEvent"; @@ -51,7 +50,7 @@ napi_value CreateJsPipControllerObject(napi_env env, sptr jsPipController = std::make_unique(pipController, env); napi_wrap(env, objValue, jsPipController.release(), JsPipController::Finalizer, nullptr, nullptr); @@ -78,7 +77,7 @@ JsPipController::~JsPipController() void JsPipController::Finalizer(napi_env env, void* data, void* hint) { - WLOGFD("Finalizer is called"); + TLOGD(WmsLogTag::WMS_PIP, "Finalizer is called"); std::unique_ptr(static_cast(data)); } @@ -90,10 +89,10 @@ napi_value JsPipController::StartPictureInPicture(napi_env env, napi_callback_in napi_value JsPipController::OnStartPictureInPicture(napi_env env, napi_callback_info info) { - WLOGI("OnStartPictureInPicture is called"); + TLOGI(WmsLogTag::WMS_PIP, "OnStartPictureInPicture is called"); std::lock_guard lock(pipMutex_); if (PictureInPictureManager::ShouldAbortPipStart()) { - WLOGFI("OnStartPictureInPicture abort"); + TLOGI(WmsLogTag::WMS_PIP, "OnStartPictureInPicture abort"); return NapiGetUndefined(env); } size_t argc = 4; @@ -133,7 +132,7 @@ napi_value JsPipController::StopPictureInPicture(napi_env env, napi_callback_inf napi_value JsPipController::OnStopPictureInPicture(napi_env env, napi_callback_info info) { - WLOGI("OnStopPictureInPicture is called"); + TLOGI(WmsLogTag::WMS_PIP, "OnStopPictureInPicture is called"); std::lock_guard lock(pipMutex_); size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -172,21 +171,21 @@ napi_value JsPipController::SetAutoStartEnabled(napi_env env, napi_callback_info napi_value JsPipController::OnSetAutoStartEnabled(napi_env env, napi_callback_info info) { - WLOGI("OnSetAutoStartEnabled is called"); + TLOGI(WmsLogTag::WMS_PIP, "OnSetAutoStartEnabled is called"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != 1) { - WLOGFE("Argc count is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "Argc count is invalid: %{public}zu", argc); return NapiThrowInvalidParam(env); } bool enable = false; if (!ConvertFromJsValue(env, argv[0], enable)) { - WLOGFE("[NAPI]Failed to convert parameter to bool"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to convert parameter to bool"); return NapiGetUndefined(env); } if (pipController_ == nullptr) { - WLOGFE("[NAPI]OnSetAutoStartEnabled error, controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]OnSetAutoStartEnabled error, controller is nullptr"); return NapiGetUndefined(env); } pipController_->SetAutoStartEnabled(enable); @@ -201,26 +200,26 @@ napi_value JsPipController::UpdateContentSize(napi_env env, napi_callback_info i napi_value JsPipController::OnUpdateContentSize(napi_env env, napi_callback_info info) { - WLOGI("OnUpdateContentSize is called"); + TLOGI(WmsLogTag::WMS_PIP, "OnUpdateContentSize is called"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != NUMBER_TWO) { - WLOGFE("Argc count is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "Argc count is invalid: %{public}zu", argc); return NapiThrowInvalidParam(env); } int32_t width = 0; if (!ConvertFromJsValue(env, argv[0], width) || width <= 0) { - WLOGFE("Failed to convert parameter to uint32_t or parameter is invalid"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to uint32_t or parameter is invalid"); return NapiThrowInvalidParam(env); } int32_t height = 0; if (!ConvertFromJsValue(env, argv[1], height) || height <= 0) { - WLOGFE("Failed to convert parameter to uint32_t or parameter is invalid"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to uint32_t or parameter is invalid"); return NapiThrowInvalidParam(env); } if (pipController_ == nullptr) { - WLOGFE("OnUpdateContentSize error, controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "OnUpdateContentSize error, controller is nullptr"); return NapiThrowInvalidParam(env); } pipController_->UpdateContentSize(width, height); @@ -235,28 +234,28 @@ napi_value JsPipController::RegisterCallback(napi_env env, napi_callback_info in napi_value JsPipController::OnRegisterCallback(napi_env env, napi_callback_info info) { - WLOGI("OnRegisterCallback is called"); + TLOGI(WmsLogTag::WMS_PIP, "OnRegisterCallback is called"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < NUMBER_TWO) { - WLOGFE("JsPipController Params not match: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "JsPipController Params not match: %{public}zu", argc); return NapiThrowInvalidParam(env); } std::string cbType; if (!ConvertFromJsValue(env, argv[0], cbType)) { - WLOGFE("Failed to convert parameter to callbackType"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to callbackType"); return NapiThrowInvalidParam(env); } napi_value value = argv[1]; if (value == nullptr || !NapiIsCallable(env, value)) { - WLOGFE("Callback is nullptr or not callable"); + TLOGE(WmsLogTag::WMS_PIP, "Callback is nullptr or not callable"); return NapiThrowInvalidParam(env); } std::lock_guard lock(mtx_); WmErrorCode ret = RegisterListenerWithType(env, cbType, value); if (ret != WmErrorCode::WM_OK) { - WLOGFE("OnRegisterCallback failed"); + TLOGE(WmsLogTag::WMS_PIP, "OnRegisterCallback failed"); return NapiThrowInvalidParam(env); } return NapiGetUndefined(env); @@ -265,7 +264,7 @@ napi_value JsPipController::OnRegisterCallback(napi_env env, napi_callback_info WmErrorCode JsPipController::RegisterListenerWithType(napi_env env, const std::string& type, napi_value value) { if (IfCallbackRegistered(env, type, value)) { - WLOGFE("Callback already registered!"); + TLOGE(WmsLogTag::WMS_PIP, "Callback already registered!"); return WmErrorCode::WM_ERROR_INVALID_CALLING; } std::shared_ptr callbackRef; @@ -280,7 +279,7 @@ WmErrorCode JsPipController::RegisterListenerWithType(napi_env env, const std::s bool JsPipController::IfCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject) { if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) { - WLOGFI("methodName %{public}s not registered!", type.c_str()); + TLOGI(WmsLogTag::WMS_PIP, "methodName %{public}s not registered!", type.c_str()); return false; } @@ -288,7 +287,7 @@ bool JsPipController::IfCallbackRegistered(napi_env env, const std::string& type bool isEquals = false; napi_strict_equals(env, jsListenerObject, iter->second->GetNapiValue(), &isEquals); if (isEquals) { - WLOGFE("Callback already registered!"); + TLOGE(WmsLogTag::WMS_PIP, "Callback already registered!"); return true; } } @@ -298,11 +297,11 @@ bool JsPipController::IfCallbackRegistered(napi_env env, const std::string& type void JsPipController::ProcessStateChangeRegister() { if (jsCbMap_.empty() || jsCbMap_.find(STATE_CHANGE_CB) == jsCbMap_.end()) { - WLOGFE("Register state change error"); + TLOGE(WmsLogTag::WMS_PIP, "Register state change error"); return; } if (pipController_ == nullptr) { - WLOGFE("controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr"); return; } sptr lifeCycle = new JsPipController::PiPLifeCycleImpl(env_, jsCbMap_[STATE_CHANGE_CB]); @@ -312,11 +311,11 @@ void JsPipController::ProcessStateChangeRegister() void JsPipController::ProcessActionEventRegister() { if (jsCbMap_.empty() || jsCbMap_.find(CONTROL_PANEL_ACTION_EVENT_CB) == jsCbMap_.end()) { - WLOGFE("Register action event error"); + TLOGE(WmsLogTag::WMS_PIP, "Register action event error"); return; } if (pipController_ == nullptr) { - WLOGFE("controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr"); return; } sptr actionObserver = @@ -327,7 +326,7 @@ void JsPipController::ProcessActionEventRegister() void JsPipController::ProcessStateChangeUnRegister() { if (pipController_ == nullptr) { - WLOGFE("controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr"); return; } pipController_->SetPictureInPictureLifecycle(nullptr); @@ -336,7 +335,7 @@ void JsPipController::ProcessStateChangeUnRegister() void JsPipController::ProcessActionEventUnRegister() { if (pipController_ == nullptr) { - WLOGFE("controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr"); return; } pipController_->SetPictureInPictureActionObserver(nullptr); @@ -350,23 +349,22 @@ napi_value JsPipController::UnregisterCallback(napi_env env, napi_callback_info napi_value JsPipController::OnUnregisterCallback(napi_env env, napi_callback_info info) { - WLOGI("OnUnregisterCallback is called"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != 1) { - WLOGFE("JsPipController Params not match: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "JsPipController Params not match: %{public}zu", argc); return NapiThrowInvalidParam(env); } std::string cbType; if (!ConvertFromJsValue(env, argv[0], cbType)) { - WLOGFE("Failed to convert parameter to string"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to string"); return NapiThrowInvalidParam(env); } std::lock_guard lock(mtx_); WmErrorCode ret = UnRegisterListenerWithType(env, cbType); if (ret != WmErrorCode::WM_OK) { - WLOGFE("OnUnregisterCallback failed"); + TLOGE(WmsLogTag::WMS_PIP, "OnUnregisterCallback failed"); napi_throw(env, CreateJsError(env, static_cast(ret))); } return NapiGetUndefined(env); @@ -375,7 +373,7 @@ napi_value JsPipController::OnUnregisterCallback(napi_env env, napi_callback_inf WmErrorCode JsPipController::UnRegisterListenerWithType(napi_env env, const std::string& type) { if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) { - WLOGFI("methodName %{public}s not registered!", type.c_str()); + TLOGI(WmsLogTag::WMS_PIP, "methodName %{public}s not registered!", type.c_str()); return WmErrorCode::WM_ERROR_INVALID_CALLING; } jsCbMap_.erase(type); @@ -386,11 +384,10 @@ WmErrorCode JsPipController::UnRegisterListenerWithType(napi_env env, const std: void CallJsMethod(napi_env env, napi_value method, napi_value const* argv, size_t argc) { if (method == nullptr) { - WLOGFE("empty method, call method failed"); + TLOGE(WmsLogTag::WMS_PIP, "empty method, call method failed"); return; } if (env == nullptr) { - WLOGFE("env_ nullptr"); return; } napi_call_function(env, NapiGetUndefined(env), method, argc, argv, nullptr); @@ -398,44 +395,38 @@ void CallJsMethod(napi_env env, napi_value method, napi_value const* argv, size_ void JsPipController::PiPLifeCycleImpl::OnPreparePictureInPictureStart() { - WLOGI("OnPreparePictureInPictureStart"); OnPipListenerCallback(PipState::ABOUT_TO_START, 0); } void JsPipController::PiPLifeCycleImpl::OnPictureInPictureStart() { - WLOGI("OnPictureInPictureStart"); OnPipListenerCallback(PipState::STARTED, 0); } void JsPipController::PiPLifeCycleImpl::OnPreparePictureInPictureStop() { - WLOGI("OnPreparePictureInPictureStop"); OnPipListenerCallback(PipState::ABOUT_TO_STOP, 0); } void JsPipController::PiPLifeCycleImpl::OnPictureInPictureStop() { - WLOGI("OnPictureInPictureStop"); OnPipListenerCallback(PipState::STOPPED, 0); } void JsPipController::PiPLifeCycleImpl::OnRestoreUserInterface() { - WLOGI("OnRestoreUserInterface"); OnPipListenerCallback(PipState::ABOUT_TO_RESTORE, 0); } void JsPipController::PiPLifeCycleImpl::OnPictureInPictureOperationError(int32_t errorCode) { - WLOGI("OnPictureInPictureOperationError"); OnPipListenerCallback(PipState::ERROR, errorCode); } void JsPipController::PiPLifeCycleImpl::OnPipListenerCallback(PipState state, int32_t errorCode) { std::lock_guard lock(mtx_); - WLOGI("OnPipListenerCallback is called, state: %{public}d", static_cast(state)); + TLOGI(WmsLogTag::WMS_PIP, "OnPipListenerCallback is called, state: %{public}d", static_cast(state)); auto jsCallback = jsCallBack_; std::string error = std::to_string(errorCode); std::unique_ptr complete = std::make_unique ( @@ -454,7 +445,7 @@ void JsPipController::PiPLifeCycleImpl::OnPipListenerCallback(PipState state, in void JsPipController::PiPActionObserverImpl::OnActionEvent(const std::string& actionEvent, int32_t statusCode) { std::lock_guard lock(mtx_); - WLOGI("OnActionEvent is called, actionEvent: %{public}s", actionEvent.c_str()); + TLOGI(WmsLogTag::WMS_PIP, "OnActionEvent is called, actionEvent: %{public}s", actionEvent.c_str()); auto jsCallback = jsCallBack_; std::unique_ptr complete = std::make_unique ( [jsCallback, actionEvent, statusCode] (napi_env env, NapiAsyncTask &task, int32_t status) { diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 4fc05e688..d04a26ff6 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -26,9 +26,6 @@ namespace OHOS { namespace Rosen { using namespace AbilityRuntime; using namespace Ace; -namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipWindowManager"}; -} std::mutex JsPipWindowManager::mutex_; @@ -44,7 +41,7 @@ static bool GetControlGroupFromJs(napi_env env, napi_value controlGroup, std::ve napi_value getElementValue = nullptr; napi_get_element(env, controlGroup, i, &getElementValue); if (!ConvertFromJsValue(env, getElementValue, controlType)) { - WLOGE("Failed to convert parameter to controlType"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to controlType"); return false; } controls.push_back(controlType); @@ -102,7 +99,7 @@ JsPipWindowManager::~JsPipWindowManager() void JsPipWindowManager::Finalizer(napi_env env, void* data, void* hint) { - WLOGFD("Finalizer"); + TLOGD(WmsLogTag::WMS_PIP, "Finalizer"); std::unique_ptr(static_cast(data)); } @@ -114,7 +111,7 @@ napi_value JsPipWindowManager::IsPipEnabled(napi_env env, napi_callback_info inf napi_value JsPipWindowManager::OnIsPipEnabled(napi_env env, napi_callback_info info) { - WLOGFD("OnIsPipEnabled called"); + TLOGD(WmsLogTag::WMS_PIP, "OnIsPipEnabled called"); return CreateJsValue(env, true); } @@ -126,24 +123,24 @@ napi_value JsPipWindowManager::CreatePipController(napi_env env, napi_callback_i napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback_info info) { - WLOGI("OnCreatePipController called"); + TLOGI(WmsLogTag::WMS_PIP, "OnCreatePipController called"); std::lock_guard lock(mutex_); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - WLOGFE("Missing args when creating pipController"); + TLOGE(WmsLogTag::WMS_PIP, "Missing args when creating pipController"); return NapiThrowInvalidParam(env); } napi_value config = argv[0]; if (config == nullptr) { - WLOGFE("Failed to convert object to pip Configuration"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert object to pip Configuration"); return NapiThrowInvalidParam(env); } PipOption pipOption; int32_t errCode = GetPictureInPictureOptionFromJs(env, config, pipOption); if (errCode == -1) { - WLOGFE("Configuration is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "Configuration is invalid: %{public}zu", argc); return NapiThrowInvalidParam(env); } napi_value callback = nullptr; @@ -172,9 +169,9 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback napi_value JsPipWindowManagerInit(napi_env env, napi_value exportObj) { - WLOGFD("JsPipWindowManagerInit"); + TLOGD(WmsLogTag::WMS_PIP, "JsPipWindowManagerInit"); if (env == nullptr || exportObj == nullptr) { - WLOGFE("JsPipWindowManagerInit env or exportObj is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "JsPipWindowManagerInit env or exportObj is nullptr"); return nullptr; } std::unique_ptr jsPipManager = std::make_unique(); diff --git a/utils/BUILD.gn b/utils/BUILD.gn index dab8d34a7..ffe298da4 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -48,7 +48,6 @@ ohos_static_library("libwmutil_static") { "src/permission.cpp", "src/persistent_storage.cpp", "src/pip_report.cpp", - "src/pip_util.cpp", "src/screen_group_info.cpp", "src/screen_info.cpp", "src/screenshot_info.cpp", @@ -149,7 +148,6 @@ ohos_shared_library("libwmutil") { "src/permission.cpp", "src/persistent_storage.cpp", "src/pip_report.cpp", - "src/pip_util.cpp", "src/screen_group_info.cpp", "src/screen_info.cpp", "src/surface_draw.cpp", diff --git a/utils/include/pip_util.h b/utils/include/pip_util.h deleted file mode 100644 index f371de373..000000000 --- a/utils/include/pip_util.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ROSEN_WINDOW_PIP_UTIL_H -#define OHOS_ROSEN_WINDOW_PIP_UTIL_H - -#include "wm_common.h" - -namespace OHOS::Rosen { -class PiPUtil { -public: - static void SetDisplayVpr(const float displayVpr); - static void UpdateRectPivot(const int32_t start, const uint32_t len, const uint32_t totalLen, - PiPScalePivot& pivot); - static void GetRectByPivot(int32_t& start, const uint32_t oldLen, const uint32_t len, const uint32_t totalLen, - const PiPScalePivot& pivot); - static void GetRectByScale(const uint32_t width, const uint32_t height, const PiPScaleLevel& scaleLevel, - Rect& rect, bool isLandscape); - static bool GetValidRect(const int32_t width, const int32_t height, Rect& rect); - static constexpr int32_t SAFE_PADDING_HORIZONTAL_VP = 12; - static constexpr int32_t SAFE_PADDING_VERTICAL_TOP = 150; - static constexpr int32_t SAFE_PADDING_VERTICAL_BOTTOM = 150; -}; -} // namespace OHOS::Rosen -#endif // OHOS_ROSEN_WINDOW_PIP_UTIL_H \ No newline at end of file diff --git a/utils/include/window_manager_hilog.h b/utils/include/window_manager_hilog.h index c68605736..d7d27596b 100644 --- a/utils/include/window_manager_hilog.h +++ b/utils/include/window_manager_hilog.h @@ -62,6 +62,7 @@ enum class WmsLogTag : uint8_t { WMS_KEYBOARD, // C0420B WMS_EVENT, // C0420C WMS_UIEXT, // C0420D + WMS_PIP, // C0420E END = 256, // Last one, do not use }; @@ -81,6 +82,7 @@ const std::unordered_map DOMAIN_CONTENTS_MAP = { { WmsLogTag::WMS_KEYBOARD, "WMSKeyboard" }, { WmsLogTag::WMS_EVENT, "WMSEvent" }, { WmsLogTag::WMS_UIEXT, "WMSUiext" }, + { WmsLogTag::WMS_PIP, "WMSPiP" }, }; #define WMS_FILE_NAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) diff --git a/utils/src/pip_report.cpp b/utils/src/pip_report.cpp index 07ff346b3..3feea653e 100644 --- a/utils/src/pip_report.cpp +++ b/utils/src/pip_report.cpp @@ -21,7 +21,6 @@ namespace OHOS { namespace Rosen { namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "PictureInPictureReport"}; const std::string PNAMEID = "windowManager"; const std::string PVERSION = "1.0"; } @@ -58,9 +57,9 @@ void PiPReporter::SetCurrentPackageName(const std::string &packageName) void PiPReporter::ReportPiPStartWindow(int32_t source, int32_t templateType, int32_t isSuccess, const std::string& errorReason) { - WLOGI("Report start pip widow"); + TLOGI(WmsLogTag::WMS_PIP, "Report start pip widow"); if (source == 0) { - WLOGI("need not report start pip widow"); + TLOGI(WmsLogTag::WMS_PIP, "need not report start pip widow"); return; } std::string eventName = "START_PIP"; @@ -75,16 +74,16 @@ void PiPReporter::ReportPiPStartWindow(int32_t source, int32_t templateType, EVENT_KEY_OPERATION_CODE, isSuccess, EVENT_KEY_OPERATION_ERROR_REASON, errorReason); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPStopWindow(int32_t source, int32_t templateType, int32_t isSuccess, const std::string& errorReason) { - WLOGI("Report stop pip widow"); + TLOGI(WmsLogTag::WMS_PIP, "Report stop pip widow"); if (source == 0) { - WLOGI("need not report stop pip widow"); + TLOGI(WmsLogTag::WMS_PIP, "need not report stop pip widow"); return; } std::string eventName = "STOP_PIP"; @@ -99,13 +98,13 @@ void PiPReporter::ReportPiPStopWindow(int32_t source, int32_t templateType, EVENT_KEY_OPERATION_CODE, isSuccess, EVENT_KEY_OPERATION_ERROR_REASON, errorReason); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPActionEvent(int32_t templateType, const std::string &actionEvent) { - WLOGI("Report pip widow action event"); + TLOGI(WmsLogTag::WMS_PIP, "Report pip widow action event"); std::string eventName = "CONTROL_PANNEL_ACTION_EVENT"; int32_t currentAction = CONTROL_ACTION_MAP[actionEvent]; int32_t ret = HiSysEventWrite( @@ -117,13 +116,13 @@ void PiPReporter::ReportPiPActionEvent(int32_t templateType, const std::string & EVENT_KEY_ACTION_EVENT, currentAction, EVENT_KEY_OPERATION_PACKAGE_NAME, packageName_); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPResize(int32_t scaleLevel, int32_t windowWidth, int32_t windowHeight) { - WLOGI("Report pip widow resize"); + TLOGI(WmsLogTag::WMS_PIP, "Report pip widow resize"); std::string eventName = "RESIZE_PIP_SIZE"; int32_t currentScaleLevel = scaleLevel + 1; int32_t ret = HiSysEventWrite( @@ -136,13 +135,13 @@ void PiPReporter::ReportPiPResize(int32_t scaleLevel, int32_t windowWidth, int32 EVENT_KEY_WINDOW_HEIGHT, windowHeight, EVENT_KEY_OPERATION_PACKAGE_NAME, packageName_); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPRatio(int32_t windowWidth, int32_t windowHeight) { - WLOGI("Report pip widow ratio"); + TLOGI(WmsLogTag::WMS_PIP, "Report pip widow ratio"); std::string eventName = "UPDATE_PIP_RATIO"; int32_t ret = HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, eventName, @@ -153,13 +152,13 @@ void PiPReporter::ReportPiPRatio(int32_t windowWidth, int32_t windowHeight) EVENT_KEY_WINDOW_HEIGHT, windowHeight, EVENT_KEY_OPERATION_PACKAGE_NAME, packageName_); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPRestore() { - WLOGI("Report pip widow restore"); + TLOGI(WmsLogTag::WMS_PIP, "Report pip widow restore"); std::string eventName = "RESOTRE_PIP"; int32_t ret = HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, eventName, @@ -168,13 +167,13 @@ void PiPReporter::ReportPiPRestore() EVENT_KEY_PVERSION, PVERSION, EVENT_KEY_OPERATION_PACKAGE_NAME, packageName_); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPMove() { - WLOGI("Report pip widow move"); + TLOGI(WmsLogTag::WMS_PIP, "Report pip widow move"); std::string eventName = "MOVE_PIP"; int32_t ret = HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, eventName, @@ -183,7 +182,7 @@ void PiPReporter::ReportPiPMove() EVENT_KEY_PVERSION, PVERSION, EVENT_KEY_OPERATION_PACKAGE_NAME, packageName_); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } } // namespace Rosen diff --git a/utils/src/pip_util.cpp b/utils/src/pip_util.cpp deleted file mode 100644 index 40c94a0e0..000000000 --- a/utils/src/pip_util.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "pip_util.h" - -namespace OHOS { -namespace Rosen { -namespace { - constexpr float DEFAULT_PROPORTION = 0.3; - constexpr int32_t NUMBER_TWO = 2; - constexpr int32_t NUMBER_THREE = 3; - constexpr int32_t NUMBER_FOUR = 4; - constexpr int32_t NUMBER_SEVEN = 7; - float g_vpr = 1.0f; -} - -void PiPUtil::SetDisplayVpr(const float displayVpr) -{ - g_vpr = displayVpr; -} - -void PiPUtil::UpdateRectPivot(const int32_t start, const uint32_t len, const uint32_t totalLen, PiPScalePivot& pivot) -{ - int32_t end = static_cast(totalLen) - start - static_cast(len); - if (start > end) { - pivot = PiPScalePivot::END; - } else if (start < end) { - pivot = PiPScalePivot::START; - } else { - pivot = PiPScalePivot::MIDDLE; - } -} - -void PiPUtil::GetRectByPivot(int32_t& start, const uint32_t oldLen, const uint32_t len, const uint32_t totalLen, - const PiPScalePivot& pivot) -{ - switch (pivot) { - default: - case PiPScalePivot::START: - break; - case PiPScalePivot::MIDDLE: - start = (static_cast(totalLen) - static_cast(len)) / NUMBER_TWO; - break; - case PiPScalePivot::END: - start = start - static_cast(len) + static_cast(oldLen); - break; - } -} - -void CalcWinRectLand(const uint32_t width, const uint32_t height, const uint32_t winWidth, - const uint32_t winHeight, Rect& rect) -{ - if (winWidth == 0 || winHeight == 0) { - return; - } - int32_t heightTmp = - static_cast(height) - PiPUtil::SAFE_PADDING_VERTICAL_TOP - PiPUtil::SAFE_PADDING_VERTICAL_BOTTOM; - int32_t safePaddingHorizontal = static_cast(PiPUtil::SAFE_PADDING_HORIZONTAL_VP * g_vpr); - if (winWidth <= winHeight) { - int32_t widthTmp = (NUMBER_THREE * static_cast(width) - - NUMBER_SEVEN * safePaddingHorizontal) / NUMBER_FOUR; - rect.width_ = static_cast(widthTmp); - rect.height_ = rect.width_ * winHeight / winWidth; - if (rect.height_ > static_cast(heightTmp)) { - rect.height_ = static_cast(heightTmp); - rect.width_ = rect.height_ * winWidth / winHeight; - } - } else { - rect.height_ = static_cast(heightTmp); - rect.width_ = rect.height_ * winWidth / winHeight; - } -} - -void PiPUtil::GetRectByScale(const uint32_t width, const uint32_t height, const PiPScaleLevel& scaleLevel, - Rect& rect, bool isLandscape) -{ - uint32_t winWidth = rect.width_; - uint32_t winHeight = rect.height_; - if (winWidth == 0 || winHeight == 0) { - return; - } - int32_t safePaddingHorizontal = static_cast(SAFE_PADDING_HORIZONTAL_VP * g_vpr); - switch (scaleLevel) { - default: - case PiPScaleLevel::PIP_SCALE_LEVEL_SMALLEST: { - float shortBorder = static_cast(width < height ? width : height) * DEFAULT_PROPORTION; - if (winWidth < winHeight) { - rect.width_ = static_cast(shortBorder); - rect.height_ = rect.width_ * winHeight / winWidth; - } else { - rect.height_ = static_cast(shortBorder); - rect.width_ = rect.height_ * winWidth / winHeight; - } - break; - } - case PiPScaleLevel::PIP_SCALE_LEVEL_BIGGEST: { - if (isLandscape) { - CalcWinRectLand(width, height, winWidth, winHeight, rect); - } else { - int32_t widthTmp = 0; - if (winWidth < winHeight) { - widthTmp = (NUMBER_THREE * static_cast(width) - - NUMBER_SEVEN * safePaddingHorizontal) / NUMBER_FOUR; - } else { - widthTmp = static_cast(width) - NUMBER_TWO * safePaddingHorizontal; - } - rect.width_ = static_cast(widthTmp); - rect.height_ = rect.width_ * winHeight / winWidth; - } - break; - } - } -} - -bool PiPUtil::GetValidRect(const int32_t width, const int32_t height, Rect& rect) -{ - int32_t safePaddingHorizontal = static_cast(SAFE_PADDING_HORIZONTAL_VP * g_vpr); - bool hasChanged = false; - if (rect.posX_ < safePaddingHorizontal) { - rect.posX_ = safePaddingHorizontal; - hasChanged = true; - } else if ((rect.posX_ + static_cast(rect.width_)) > (width - safePaddingHorizontal)) { - rect.posX_ = width - safePaddingHorizontal - static_cast(rect.width_); - hasChanged = true; - } - if (rect.posY_ < SAFE_PADDING_VERTICAL_TOP) { - rect.posY_ = SAFE_PADDING_VERTICAL_TOP; - hasChanged = true; - } else if ((rect.posY_ + static_cast(rect.height_)) > (height - SAFE_PADDING_VERTICAL_BOTTOM)) { - rect.posY_ = height - SAFE_PADDING_VERTICAL_BOTTOM - static_cast(rect.height_); - hasChanged = true; - } - return hasChanged; -} -} // namespace Rosen -} // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/BUILD.gn b/utils/test/unittest/BUILD.gn index deafdfc71..ef9c1d43e 100644 --- a/utils/test/unittest/BUILD.gn +++ b/utils/test/unittest/BUILD.gn @@ -23,7 +23,6 @@ group("unittest") { ":utils_cutout_info_test", ":utils_display_info_test", ":utils_perform_reporter_test", - ":utils_pip_util_test", ":utils_screen_group_info_test", ":utils_screen_info_test", ":utils_string_test", @@ -236,19 +235,6 @@ ohos_unittest("utils_window_transition_info_test") { ] } -ohos_unittest("utils_pip_util_test") { - module_out_path = module_out_path - - sources = [ "pip_util_test.cpp" ] - - deps = [ ":utils_unittest_common" ] - - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - ] -} - ## Build dm_unittest_common.a {{{ config("utils_unittest_common_public_config") { include_dirs = [ diff --git a/utils/test/unittest/pip_util_test.cpp b/utils/test/unittest/pip_util_test.cpp deleted file mode 100644 index 0a1ee9ba1..000000000 --- a/utils/test/unittest/pip_util_test.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "pip_util.h" - -using namespace testing; -using namespace testing::ext; - -namespace OHOS { -namespace Rosen { -class PiPUtilTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp() override; - void TearDown() override; -}; - -void PiPUtilTest::SetUpTestCase() -{ -} - -void PiPUtilTest::TearDownTestCase() -{ -} - -void PiPUtilTest::SetUp() -{ -} - -void PiPUtilTest::TearDown() -{ -} - -namespace { -/** - * @tc.name: UpdateRectPivot - * @tc.desc: UpdateRectPivot test - * @tc.type: FUNC - */ -HWTEST_F(PiPUtilTest, UpdateRectPivot, Function | SmallTest | Level2) -{ - auto pivot1 = PiPScalePivot::UNDEFINED; - PiPUtil::UpdateRectPivot(10, 20, 100, pivot1); - ASSERT_EQ(PiPScalePivot::START, pivot1); - - auto pivot2 = PiPScalePivot::UNDEFINED; - PiPUtil::UpdateRectPivot(40, 20, 100, pivot2); - ASSERT_EQ(PiPScalePivot::MIDDLE, pivot2); - - auto pivot3 = PiPScalePivot::UNDEFINED; - PiPUtil::UpdateRectPivot(70, 20, 100, pivot3); - ASSERT_EQ(PiPScalePivot::END, pivot3); -} - -/** - * @tc.name: GetRectByPivot - * @tc.desc: GetRectByPivot test - * @tc.type: FUNC - */ -HWTEST_F(PiPUtilTest, GetRectByPivot, Function | SmallTest | Level2) -{ - auto pivot1 = PiPScalePivot::UNDEFINED; - int32_t start1 = 100; - PiPUtil::GetRectByPivot(start1, 100, 200, 300, pivot1); - ASSERT_EQ(100, start1); - - auto pivot2 = PiPScalePivot::UNDEFINED; - int32_t start2 = 100; - PiPUtil::GetRectByPivot(start2, 100, 200, 300, pivot2); - ASSERT_EQ(100, start2); - - auto pivot3 = PiPScalePivot::UNDEFINED; - int32_t start3 = 100; - PiPUtil::GetRectByPivot(start3, 100, 200, 300, pivot3); - ASSERT_EQ(100, start3); -} - -/** - * @tc.name: GetRectByScale - * @tc.desc: GetRectByScale test - * @tc.type: FUNC - */ -HWTEST_F(PiPUtilTest, GetRectByScale, Function | SmallTest | Level2) -{ - Rect rect1 = {0, 0, 100, 100}; - auto level1 = PiPScaleLevel::PIP_SCALE_LEVEL_SMALLEST; - PiPUtil::GetRectByScale(200, 200, level1, rect1, false); - ASSERT_EQ(60, rect1.width_); - ASSERT_EQ(60, rect1.height_); - - Rect rect2 = {0, 0, 100, 100}; - auto level2 = PiPScaleLevel::PIP_SCALE_LEVEL_SMALLEST; - PiPUtil::GetRectByScale(200, 200, level2, rect2, false); - ASSERT_EQ(60, rect2.width_); - ASSERT_EQ(60, rect2.height_); -} - -/** - * @tc.name: GetValidRect - * @tc.desc: GetValidRect test - * @tc.type: FUNC - */ -HWTEST_F(PiPUtilTest, GetValidRect, Function | SmallTest | Level2) -{ - Rect rect1 = {0, PiPUtil::SAFE_PADDING_VERTICAL_TOP, 100, 100}; - ASSERT_EQ(true, PiPUtil::GetValidRect(1000, 1000, rect1)); - ASSERT_EQ(PiPUtil::SAFE_PADDING_HORIZONTAL_VP, rect1.posX_); - ASSERT_EQ(PiPUtil::SAFE_PADDING_VERTICAL_TOP, rect1.posY_); - - Rect rect2 = {1000, PiPUtil::SAFE_PADDING_VERTICAL_TOP, 100, 100}; - ASSERT_EQ(true, PiPUtil::GetValidRect(1000, 1000, rect2)); - ASSERT_EQ(1000 - rect2.width_ - PiPUtil::SAFE_PADDING_HORIZONTAL_VP, rect2.posX_); - ASSERT_EQ(PiPUtil::SAFE_PADDING_VERTICAL_TOP, rect2.posY_); - - Rect rect3 = {PiPUtil::SAFE_PADDING_HORIZONTAL_VP, 0, 100, 100}; - ASSERT_EQ(true, PiPUtil::GetValidRect(1000, 1000, rect3)); - ASSERT_EQ(PiPUtil::SAFE_PADDING_HORIZONTAL_VP, rect3.posX_); - ASSERT_EQ(PiPUtil::SAFE_PADDING_VERTICAL_TOP, rect3.posY_); - - Rect rect4 = {PiPUtil::SAFE_PADDING_HORIZONTAL_VP, 1000, 100, 100}; - ASSERT_EQ(true, PiPUtil::GetValidRect(1000, 1000, rect4)); - ASSERT_EQ(PiPUtil::SAFE_PADDING_HORIZONTAL_VP, rect4.posX_); - ASSERT_EQ(1000 - 100 - PiPUtil::SAFE_PADDING_VERTICAL_BOTTOM, rect4.posY_); - - Rect rect5 = {PiPUtil::SAFE_PADDING_HORIZONTAL_VP, PiPUtil::SAFE_PADDING_VERTICAL_TOP, 100, 100}; - ASSERT_EQ(false, PiPUtil::GetValidRect(1000, 1000, rect5)); - ASSERT_EQ(PiPUtil::SAFE_PADDING_HORIZONTAL_VP, rect5.posX_); - ASSERT_EQ(PiPUtil::SAFE_PADDING_VERTICAL_TOP, rect5.posY_); -} -} -} // namespace Rosen -} // namespace OHOS \ No newline at end of file diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index d5211a1a1..cc296fc0d 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -970,7 +970,7 @@ napi_value JsSceneSession::SetOffset(napi_env env, napi_callback_info info) { napi_value JsSceneSession::SetPipActionEvent(napi_env env, napi_callback_info info) { - WLOGI("[NAPI]SetPipActionEvent"); + TLOGI(WmsLogTag::WMS_PIP, "[NAPI]SetPipActionEvent"); JsSceneSession *me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetPipActionEvent(env, info) : nullptr; } @@ -2312,19 +2312,19 @@ void JsSceneSession::ProcessPrepareClosePiPSessionRegister() { auto sessionchangeCallback = sessionchangeCallback_.promote(); if (sessionchangeCallback == nullptr) { - WLOGFE("sessionchangeCallback is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "sessionchangeCallback is nullptr"); return; } sessionchangeCallback->onPrepareClosePiPSession_ = [weak = weak_from_this()]() { auto weakJsSceneSession = weak.lock(); if (weakJsSceneSession) weakJsSceneSession->OnPrepareClosePiPSession(); }; - WLOGFD("ProcessPrepareClosePiPSessionRegister success"); + TLOGD(WmsLogTag::WMS_PIP, "ProcessPrepareClosePiPSessionRegister success"); } void JsSceneSession::OnPrepareClosePiPSession() { - WLOGFI("[NAPI]OnPrepareClosePiPSession"); + TLOGI(WmsLogTag::WMS_PIP, "[NAPI]OnPrepareClosePiPSession"); std::shared_ptr jsCallBack = nullptr; { std::shared_lock lock(jsCbMapMutex_); @@ -2336,7 +2336,7 @@ void JsSceneSession::OnPrepareClosePiPSession() } auto task = [jsCallBack, env = env_]() { if (!jsCallBack) { - WLOGFE("[NAPI]jsCallBack is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]jsCallBack is nullptr"); return; } napi_value argv[] = {}; @@ -2430,14 +2430,14 @@ napi_value JsSceneSession::OnSetPipActionEvent(napi_env env, napi_callback_info napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - WLOGFE("[NAPI]Argc count is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Argc count is invalid: %{public}zu", argc); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } std::string action; if (!ConvertFromJsValue(env, argv[0], action)) { - WLOGFE("[NAPI]Failed to convert parameter to string"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to convert parameter to string"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); @@ -2445,7 +2445,7 @@ napi_value JsSceneSession::OnSetPipActionEvent(napi_env env, napi_callback_info int32_t status = -1; if (argc > 1) { if (!ConvertFromJsValue(env, argv[1], status)) { - WLOGFE("[NAPI]Failed to convert parameter to int"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to convert parameter to int"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); @@ -2454,9 +2454,7 @@ napi_value JsSceneSession::OnSetPipActionEvent(napi_env env, napi_callback_info auto session = weakSession_.promote(); if (session == nullptr) { - WLOGFE("[NAPI]Session is nullptr"); - napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), - "Session is nullptr")); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Session is nullptr"); return NapiGetUndefined(env); } session->SetPipActionEvent(action, status); 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 2b555b743..5a66b0d5b 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 @@ -57,7 +57,6 @@ const std::string OUTSIDE_DOWN_EVENT_CB = "outsideDownEvent"; const std::string START_UI_ABILITY_ERROR = "startUIAbilityError"; const std::string ARG_DUMP_HELP = "-h"; const std::string SHIFT_FOCUS_CB = "shiftFocus"; -const std::string SHOW_PIP_MAIN_WINDOW_CB = "showPiPMainWindow"; const std::string CALLING_WINDOW_ID_CHANGE_CB = "callingWindowIdChange"; } // namespace @@ -146,7 +145,6 @@ JsSceneSessionManager::JsSceneSessionManager(napi_env env) : env_(env) { STATUS_BAR_ENABLED_CHANGE_CB, &JsSceneSessionManager::ProcessStatusBarEnabledChangeListener}, { OUTSIDE_DOWN_EVENT_CB, &JsSceneSessionManager::ProcessOutsideDownEvent }, { SHIFT_FOCUS_CB, &JsSceneSessionManager::ProcessShiftFocus }, - { SHOW_PIP_MAIN_WINDOW_CB, &JsSceneSessionManager::ProcessShowPiPMainWindow }, { START_UI_ABILITY_ERROR, &JsSceneSessionManager::ProcessStartUIAbilityErrorRegister}, { GESTURE_NAVIGATION_ENABLED_CHANGE_CB, &JsSceneSessionManager::ProcessGestureNavigationEnabledChangeListener }, @@ -324,22 +322,6 @@ void JsSceneSessionManager::OnShiftFocus(int32_t persistentId) taskScheduler_->PostMainThreadTask(task, "OnShiftFocus, PID:" + std::to_string(persistentId)); } -void JsSceneSessionManager::OnShowPiPMainWindow(int32_t persistentId) -{ - WLOGFI("[NAPI]OnShowPiPMainWindow"); - auto iter = jsCbMap_.find(SHOW_PIP_MAIN_WINDOW_CB); - if (iter == jsCbMap_.end()) { - return; - } - - auto jsCallBack = iter->second; - auto task = [this, persistentId, jsCallBack, env = env_]() { - napi_value argv[] = {CreateJsValue(env, persistentId)}; - napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); - }; - taskScheduler_->PostMainThreadTask(task, "OnShowPiPMainWindow, persistentId:" + std::to_string(persistentId)); -} - void JsSceneSessionManager::OnCallingWindowIdChange(const uint32_t windowId) { TLOGD(WmsLogTag::WMS_KEYBOARD, "[NAPI]OnCallingWindowIdChange"); @@ -438,15 +420,6 @@ void JsSceneSessionManager::ProcessShiftFocus() SceneSessionManager::GetInstance().SetSCBUnfocusedListener(unfocusedCallback); } -void JsSceneSessionManager::ProcessShowPiPMainWindow() -{ - ProcessShowPiPMainWindowFunc func = [this](int32_t persistentId) { - WLOGFD("ProcessShowPiPMainWindow called, persistentId: %{public}d", persistentId); - this->OnShowPiPMainWindow(persistentId); - }; - SceneSessionManager::GetInstance().SetShowPiPMainWindowListener(func); -} - void JsSceneSessionManager::ProcessCallingWindowIdChangeRegister() { ProcessCallingWindowIdChangeFunc func = [this](uint32_t callingWindowId) { 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 717073c4b..0409c14b4 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 @@ -123,7 +123,6 @@ private: void OnOutsideDownEvent(int32_t x, int32_t y); void OnStartUIAbilityError(const uint32_t errorCode); void OnShiftFocus(int32_t persistentId); - void OnShowPiPMainWindow(int32_t persistentId); void OnCallingWindowIdChange(const uint32_t callingWindowId); void ProcessCreateSystemSessionRegister(); void ProcessRecoverSceneSessionRegister(); @@ -132,7 +131,6 @@ private: void ProcessStartUIAbilityErrorRegister(); void ProcessOutsideDownEvent(); void ProcessShiftFocus(); - void ProcessShowPiPMainWindow(); void ProcessCallingWindowIdChangeRegister(); bool IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject); void RegisterDumpRootSceneElementInfoListener(); diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index fd0f51c0e..540687e0e 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -151,7 +151,7 @@ int SessionStageStub::HandleNotifyDestroy(MessageParcel& data, MessageParcel& re int SessionStageStub::HandleNotifyCloseExistPipWindow(MessageParcel& data, MessageParcel& reply) { - WLOGFD("Notify Pip AlreadyExists"); + TLOGD(WmsLogTag::WMS_PIP, "Notify Pip AlreadyExists"); WSError errCode = NotifyCloseExistPipWindow(); reply.WriteUint32(static_cast(errCode)); return ERR_NONE; @@ -334,10 +334,10 @@ int SessionStageStub::HandleNotifyDialogStateChange(MessageParcel& data, Message int SessionStageStub::HandleSetPipActionEvent(MessageParcel& data, MessageParcel& reply) { - WLOGD("HandleSetPipActionEvent"); + TLOGD(WmsLogTag::WMS_PIP, "HandleSetPipActionEvent"); std::string action = data.ReadString(); if (action.empty()) { - WLOGFE("SessionStageStub pip action event is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "SessionStageStub pip action event is nullptr"); return ERR_INVALID_VALUE; } int32_t status; diff --git a/window_scene/session/host/include/scene_persistent_storage.h b/window_scene/session/host/include/scene_persistent_storage.h index 785a8e7ed..ae844605c 100644 --- a/window_scene/session/host/include/scene_persistent_storage.h +++ b/window_scene/session/host/include/scene_persistent_storage.h @@ -29,7 +29,6 @@ enum class ScenePersistentStorageType : uint32_t { UKNOWN = 0, ASPECT_RATIO, MAXIMIZE_STATE, - PIP_INFO, }; class ScenePersistentStorage { @@ -60,12 +59,6 @@ public: key.c_str(), static_cast(value)); break; } - case ScenePersistentStorageType::PIP_INFO: { - pref->PutInt(key, value); - WLOGD("[ScenePersistentStorage] Insert PicutreInPicture info, key %{public}s, value %{public}d", - key.c_str(), static_cast(value)); - break; - } default: WLOGW("[ScenePersistentStorage] Unknown storage type!"); } @@ -93,12 +86,6 @@ public: key.c_str(), static_cast(value)); break; } - case ScenePersistentStorageType::PIP_INFO: { - value = pref->GetInt(key); - WLOGD("[ScenePersistentStorage] Get PicutreInPicture info, key: %{public}s, value:%{public}d", - key.c_str(), static_cast(value)); - break; - } default: WLOGW("[ScenePersistentStorage] Unknown storage type!"); } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index ec4dda36b..a7b1c4675 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -73,7 +73,6 @@ public: NotifyWindowPidChangeCallback onWindowInputPidChangeCallback_; NotifySessionTouchOutsideCallback onSessionTouchOutside_; GetAINavigationBarArea onGetAINavigationBarArea_; - RecoveryCallback onRecoveryPullPiPMainWindow_; OnOutsideDownEvent onOutsideDownEvent_; NotifyAddOrRemoveSecureSessionFunc onHandleSecureSessionShouldHide_; }; @@ -146,7 +145,6 @@ public: WSError SetTextFieldAvoidInfo(double textFieldPositionY, double textFieldHeight) override; WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) override; void NotifyPiPWindowPrepareClose() override; - WSError RecoveryPullPiPMainWindow(int32_t persistentId, const Rect& rect) override; void SetScale(float scaleX, float scaleY, float pivotX, float pivotY) override; void RequestHideKeyboard(bool isAppColdStart = false); WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; @@ -277,12 +275,6 @@ private: void SetSurfaceBounds(const WSRect &rect); void UpdateWinRectForSystemBar(WSRect& rect); bool UpdateInputMethodSessionRect(const WSRect& rect, WSRect& newWinRect, WSRect& newRequestRect); - void OnPiPMoveCallback(const WSRect& rect, const SizeChangeReason& reason); - bool InitPiPRectInfo(); - void ClearPiPRectPivotInfo(); - void SavePiPRectInfo(); - void GetNewPiPRect(const uint32_t displayWidth, const uint32_t displayHeight, Rect& rect); - void ProcessUpdatePiPRect(SizeChangeReason reason); NotifySessionRectChangeFunc sessionRectChangeFunc_; static wptr enterSession_; @@ -293,7 +285,6 @@ private: WSRect lastSafeRect = { 0, 0, 0, 0 }; std::vector> subSession_; bool needDefaultAnimationFlag_ = true; - PiPRectInfo pipRectInfo_; PiPTemplateInfo pipTemplateInfo_; std::atomic_bool isStartMoving_ { false }; std::atomic_bool isVisibleForAccessibility_ { true }; diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index 30179961f..42f583740 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -88,7 +88,6 @@ public: virtual void NotifyPiPWindowPrepareClose() {} virtual WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) { return WSError::WS_OK; } - virtual WSError RecoveryPullPiPMainWindow(int32_t persistentId, const Rect& rect) { return WSError::WS_OK; } virtual WSError ProcessPointDownSession(int32_t posX, int32_t posY) { return WSError::WS_OK; } virtual WSError SendPointEventForMoveDrag(const std::shared_ptr& pointerEvent) { diff --git a/window_scene/session/host/include/zidl/session_ipc_interface_code.h b/window_scene/session/host/include/zidl/session_ipc_interface_code.h index f5cc8d8f0..4a9301785 100644 --- a/window_scene/session/host/include/zidl/session_ipc_interface_code.h +++ b/window_scene/session/host/include/zidl/session_ipc_interface_code.h @@ -64,7 +64,6 @@ enum class SessionInterfaceCode { //PictureInPicture TRANS_ID_NOTIFY_PIP_WINDOW_PREPARE_CLOSE = 800, TRANS_ID_UPDATE_PIP_RECT, - TRANS_ID_RECOVERY_PULL_PIP_MAIN_WINDOW, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index 63800c72f..02dbce4c0 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -71,7 +71,6 @@ public: void NotifyPiPWindowPrepareClose() override; WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) override; - WSError RecoveryPullPiPMainWindow(int32_t persistentId, const Rect& rect) override; WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; WSError SendPointEventForMoveDrag(const std::shared_ptr& pointerEvent) override; private: diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 21c84ef29..51f452cf4 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -79,7 +79,6 @@ private: // PictureInPicture int HandleNotifyPiPWindowPrepareClose(MessageParcel& data, MessageParcel& reply); int HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply); - int HandleRecoveryPullPiPMainWindow(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/scene_persistent_storage.cpp b/window_scene/session/host/src/scene_persistent_storage.cpp index 70dad6e16..759ec3786 100644 --- a/window_scene/session/host/src/scene_persistent_storage.cpp +++ b/window_scene/session/host/src/scene_persistent_storage.cpp @@ -74,7 +74,6 @@ void ScenePersistentStorage::InitDir(std::string dir) storagePath_ = { { ScenePersistentStorageType::ASPECT_RATIO, saveDir_ + "/session_window_aspect_ratio" }, { ScenePersistentStorageType::MAXIMIZE_STATE, saveDir_ + "/session_window_maximize_state" }, - { ScenePersistentStorageType::PIP_INFO, saveDir_ + "/session_pip_window_location_info" }, }; } diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index cace6982a..89caf90fc 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -31,7 +31,6 @@ #include "common/include/session_permission.h" #include "interfaces/include/ws_common.h" #include "pixel_map.h" -#include "pip_util.h" #include "session/host/include/scene_persistent_storage.h" #include "session/host/include/session_utils.h" #include "display_manager.h" @@ -41,7 +40,6 @@ #include "wm_math.h" #include #include "singleton_container.h" -#include "pip_report.h" namespace OHOS::Rosen { namespace { @@ -231,10 +229,6 @@ WSError SceneSession::Disconnect(bool isFromClient) session->snapshot_.reset(); } } - if (WindowHelper::IsPipWindow(session->GetWindowType()) && - session->GetWindowMode() == WindowMode::WINDOW_MODE_PIP) { - session->SavePiPRectInfo(); - } session->Session::Disconnect(isFromClient); session->isTerminating = false; if (session->specificCallback_ != nullptr) { @@ -917,7 +911,7 @@ WSError SceneSession::UpdateAvoidArea(const sptr& avoidArea, AvoidAre WSError SceneSession::SetPipActionEvent(const std::string& action, int32_t status) { - WLOGFI("action: %{public}s, status: %{public}d", action.c_str(), status); + TLOGI(WmsLogTag::WMS_PIP, "action: %{public}s, status: %{public}d", action.c_str(), status); if (GetWindowType() != WindowType::WINDOW_TYPE_PIP || GetWindowMode() != WindowMode::WINDOW_MODE_PIP) { return WSError::WS_ERROR_INVALID_TYPE; } @@ -1137,18 +1131,6 @@ WSError SceneSession::TransferPointerEvent(const std::shared_ptrGetWindowMode() == WindowMode::WINDOW_MODE_PIP && - WindowHelper::IsPipWindow(property->GetWindowType())) { - if (!moveDragController_) { - WLOGFE("moveDragController is null"); - return Session::TransferPointerEvent(pointerEvent, needNotifyClient); - } - if (moveDragController_->ConsumeMoveEvent(pointerEvent, winRect_)) { - pointerEvent->MarkProcessed(); - return WSError::WS_OK; - } - } - bool raiseEnabled = property->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG && property->GetRaiseEnabled() && (action == MMI::PointerEvent::POINTER_ACTION_DOWN || action == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN); if (raiseEnabled) { @@ -1358,7 +1340,6 @@ void SceneSession::OnMoveDragCallback(const SizeChangeReason& reason) HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::OnMoveDragCallback [%d, %d, %u, %u]", rect.posX_, rect.posY_, rect.width_, rect.height_); SetSurfaceBounds(rect); - OnPiPMoveCallback(rect, reason); if (reason != SizeChangeReason::MOVE) { UpdateSizeChangeReason(reason); UpdateRect(rect, reason); @@ -1409,7 +1390,7 @@ void SceneSession::SetSurfaceBounds(const WSRect& rect) surfaceNode_->SetBounds(0, 0, rect.width_, rect.height_); surfaceNode_->SetFrame(0, 0, rect.width_, rect.height_); } else if (WindowHelper::IsPipWindow(GetWindowType()) && surfaceNode_) { - WLOGFD("PipWindow setSurfaceBounds"); + TLOGD(WmsLogTag::WMS_PIP, "PipWindow setSurfaceBounds"); surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_); surfaceNode_->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_); } else if (WindowHelper::IsSubWindow(GetWindowType()) && surfaceNode_) { @@ -2145,40 +2126,22 @@ bool SceneSession::RemoveSubSession(int32_t persistentId) void SceneSession::NotifyPiPWindowPrepareClose() { - WLOGFD("NotifyPiPWindowPrepareClose"); + TLOGD(WmsLogTag::WMS_PIP, "NotifyPiPWindowPrepareClose"); auto task = [weakThis = wptr(this)]() { auto session = weakThis.promote(); if (!session) { - WLOGFE("session is null"); + TLOGE(WmsLogTag::WMS_PIP, "session is null"); return; } if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onPrepareClosePiPSession_) { session->sessionChangeCallback_->onPrepareClosePiPSession_(); } - WLOGFD("NotifyPiPWindowPrepareClose, id: %{public}d", session->GetPersistentId()); + TLOGD(WmsLogTag::WMS_PIP, "NotifyPiPWindowPrepareClose, id: %{public}d", session->GetPersistentId()); return; }; PostTask(task, "NotifyPiPWindowPrepareClose"); } -WSError SceneSession::RecoveryPullPiPMainWindow(int32_t persistentId, const Rect& rect) -{ - WLOGFD("NotifyRecoveryPullPiPMainWindow"); - auto task = [weakThis = wptr(this), persistentId, rect]() { - auto session = weakThis.promote(); - if (!session) { - WLOGFE("session is null"); - return WSError::WS_ERROR_DESTROYED_OBJECT; - } - if (session->specificCallback_ != nullptr) { - session->specificCallback_->onRecoveryPullPiPMainWindow_(persistentId, rect); - } - return WSError::WS_OK; - }; - PostTask(task, "RecoveryPullPiPMainWindow"); - return WSError::WS_OK; -} - std::vector> SceneSession::GetSubSession() const { return subSession_; @@ -2225,127 +2188,6 @@ WSError SceneSession::SetTextFieldAvoidInfo(double textFieldPositionY, double te return WSError::WS_OK; } -void SceneSession::OnPiPMoveCallback(const WSRect& rect, const SizeChangeReason& reason) -{ - if (!WindowHelper::IsPipWindow(GetWindowType())) { - return; - } - if (reason == SizeChangeReason::MOVE) { - NotifySessionRectChange(rect, reason); - } - if (reason == SizeChangeReason::DRAG_END) { - ClearPiPRectPivotInfo(); - ScenePersistentStorage::Insert("pip_window_pos_x", rect.posX_, ScenePersistentStorageType::PIP_INFO); - ScenePersistentStorage::Insert("pip_window_pos_y", rect.posY_, ScenePersistentStorageType::PIP_INFO); - } -} - -bool SceneSession::InitPiPRectInfo() -{ - auto requestRect = GetSessionRequestRect(); - if (requestRect.width_ == 0 || requestRect.height_ == 0) { - return false; - } - ClearPiPRectPivotInfo(); - pipRectInfo_.originWidth_ = requestRect.width_; - pipRectInfo_.originHeight_ = requestRect.height_; - int32_t level = 0; - ScenePersistentStorage::Get("pip_window_level", level, ScenePersistentStorageType::PIP_INFO); - pipRectInfo_.level_ = static_cast(level); - return true; -} - -void SceneSession::ClearPiPRectPivotInfo() -{ - pipRectInfo_.xPivot_ = PiPScalePivot::UNDEFINED; - pipRectInfo_.yPivot_ = PiPScalePivot::UNDEFINED; -} - -void SceneSession::SavePiPRectInfo() -{ - ScenePersistentStorage::Insert("pip_window_level", static_cast(pipRectInfo_.level_), - ScenePersistentStorageType::PIP_INFO); -} - -void SceneSession::GetNewPiPRect(const uint32_t displayWidth, const uint32_t displayHeight, Rect& rect) -{ - auto display = DisplayManager::GetInstance().GetDefaultDisplay(); - if (!display) { - WLOGFE("cannot find display"); - return; - } - Rotation rotation = display->GetRotation(); - bool isLandscape = rotation == Rotation::ROTATION_90 || rotation == Rotation::ROTATION_270; - PiPUtil::GetRectByScale(displayWidth, displayHeight, pipRectInfo_.level_, rect, isLandscape); - WLOGFD("scale rect = (%{public}d, %{public}d, %{public}d, %{public}d)", - rect.posX_, rect.posY_, rect.width_, rect.height_); - auto sessionRect = GetSessionRect(); - WLOGFD("session rect = (%{public}d, %{public}d, %{public}d, %{public}d)", - sessionRect.posX_, sessionRect.posY_, sessionRect.width_, sessionRect.height_); - bool isMoveOrDrag = moveDragController_ && - (moveDragController_->GetStartDragFlag() || moveDragController_->GetStartMoveFlag()); - if (sessionRect.width_ != 0 && sessionRect.height_ != 0 && !isMoveOrDrag) { - if (pipRectInfo_.xPivot_ == PiPScalePivot::UNDEFINED || pipRectInfo_.yPivot_ == PiPScalePivot::UNDEFINED) { - // If no anchor, create anchor - PiPUtil::UpdateRectPivot(sessionRect.posX_, sessionRect.width_, displayWidth, pipRectInfo_.xPivot_); - PiPUtil::UpdateRectPivot(sessionRect.posY_, sessionRect.height_, displayHeight, pipRectInfo_.yPivot_); - } - PiPUtil::GetRectByPivot(rect.posX_, sessionRect.width_, rect.width_, displayWidth, pipRectInfo_.xPivot_); - PiPUtil::GetRectByPivot(rect.posY_, sessionRect.height_, rect.height_, displayHeight, pipRectInfo_.yPivot_); - WLOGFD("pivot rect = (%{public}d, %{public}d, %{public}d, %{public}d)", - rect.posX_, rect.posY_, rect.width_, rect.height_); - } - PiPUtil::GetValidRect(displayWidth, displayHeight, rect); - WLOGFD("valid rect = (%{public}d, %{public}d, %{public}d, %{public}d)", - rect.posX_, rect.posY_, rect.width_, rect.height_); -} - -void SceneSession::ProcessUpdatePiPRect(SizeChangeReason reason) -{ - if (!WindowHelper::IsPipWindow(GetWindowType())) { - WLOGFW("Session is not PiP type!"); - return; - } - auto display = DisplayManager::GetInstance().GetDefaultDisplay(); - if (!display) { - WLOGFE("can't find display info"); - return; - } - uint32_t displayWidth = static_cast(display->GetWidth()); - uint32_t displayHeight = static_cast(display->GetHeight()); - float displayVpr = display->GetVirtualPixelRatio(); - if (displayVpr < 0.0f) { - displayVpr = 1.5f; - } - PiPUtil::SetDisplayVpr(displayVpr); - - // default pos of phone is the right top - Rect rect = { 0, 0, pipRectInfo_.originWidth_, pipRectInfo_.originHeight_ }; - if (reason != SizeChangeReason::ROTATION) { - ScenePersistentStorage::Get("pip_window_pos_x", rect.posX_, ScenePersistentStorageType::PIP_INFO); - ScenePersistentStorage::Get("pip_window_pos_y", rect.posY_, ScenePersistentStorageType::PIP_INFO); - } - if (rect.posX_ == 0) { - rect.posX_ = displayWidth; - } - WLOGFD("window rect: (%{public}d, %{public}d, %{public}u, %{public}u)", - rect.posX_, rect.posY_, rect.width_, rect.height_); - - GetNewPiPRect(displayWidth, displayHeight, rect); - WLOGFD("window new rect: (%{public}d, %{public}d, %{public}u, %{public}u)", - rect.posX_, rect.posY_, rect.width_, rect.height_); - ScenePersistentStorage::Insert("pip_window_pos_x", rect.posX_, ScenePersistentStorageType::PIP_INFO); - ScenePersistentStorage::Insert("pip_window_pos_y", rect.posY_, ScenePersistentStorageType::PIP_INFO); - - WSRect newRect = SessionHelper::TransferToWSRect(rect); - SetSessionRect(newRect); - SetSessionRequestRect(newRect); - Session::UpdateRect(newRect, reason); - NotifySessionRectChange(newRect, reason); - SingletonContainer::Get() - .ReportPiPResize(static_cast(pipRectInfo_.level_), newRect.width_, newRect.height_); -} - WSError SceneSession::UpdatePiPRect(const Rect& rect, SizeChangeReason reason) { if (!WindowHelper::IsPipWindow(GetWindowType())) { @@ -2354,7 +2196,7 @@ WSError SceneSession::UpdatePiPRect(const Rect& rect, SizeChangeReason reason) auto task = [weakThis = wptr(this), rect, reason]() { auto session = weakThis.promote(); if (!session || session->isTerminating) { - WLOGE("SceneSession::UpdatePiPRect session is null or is terminating"); + TLOGE(WmsLogTag::WMS_PIP, "SceneSession::UpdatePiPRect session is null or is terminating"); return WSError::WS_ERROR_INVALID_OPERATION; } WSRect wsRect = SessionHelper::TransferToWSRect(rect); diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 450b6e83a..7bc404d0d 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -986,43 +986,6 @@ WSError SessionProxy::UpdatePiPRect(const Rect& rect, SizeChangeReason reason) return static_cast(ret); } -WSError SessionProxy::RecoveryPullPiPMainWindow(int32_t persistentId, const Rect& rect) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("writeInterfaceToken failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (!data.WriteInt32(persistentId)) { - WLOGFE("WriteInterfaceToken failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (!data.WriteInt32(rect.posX_)) { - WLOGFE("Write posX_ failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (!data.WriteInt32(rect.posY_)) { - WLOGFE("Write posY_ failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (!data.WriteUint32(rect.width_)) { - WLOGFE("Write width_ failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (!data.WriteUint32(rect.height_)) { - WLOGFE("Write height_ failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (Remote()->SendRequest(static_cast(SessionInterfaceCode::TRANS_ID_RECOVERY_PULL_PIP_MAIN_WINDOW), - data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - return WSError::WS_OK; -} - WSError SessionProxy::ProcessPointDownSession(int32_t posX, int32_t posY) { MessageParcel data; diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index e907b5653..23d443218 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -114,8 +114,6 @@ const std::map SessionStub::stubFuncMap_ { &SessionStub::HandleNotifyPiPWindowPrepareClose), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_PIP_RECT), &SessionStub::HandleUpdatePiPRect), - std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_RECOVERY_PULL_PIP_MAIN_WINDOW), - &SessionStub::HandleRecoveryPullPiPMainWindow) }; int SessionStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) @@ -555,14 +553,14 @@ int SessionStub::HandleTransferAccessibilityEvent(MessageParcel& data, MessagePa int SessionStub::HandleNotifyPiPWindowPrepareClose(MessageParcel& data, MessageParcel& reply) { - WLOGFD("HandleNotifyPiPWindowPrepareClose"); + TLOGD(WmsLogTag::WMS_PIP, "HandleNotifyPiPWindowPrepareClose"); NotifyPiPWindowPrepareClose(); return ERR_NONE; } int SessionStub::HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply) { - WLOGFD("HandleUpdatePiPRect!"); + TLOGD(WmsLogTag::WMS_PIP, "HandleUpdatePiPRect!"); Rect rect = {data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32()}; auto reason = static_cast(data.ReadInt32()); WSError errCode = UpdatePiPRect(rect, reason); @@ -570,20 +568,6 @@ int SessionStub::HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply) return ERR_NONE; } -int SessionStub::HandleRecoveryPullPiPMainWindow(MessageParcel& data, MessageParcel& reply) -{ - WLOGFD("HandleNotifyRecoveryPullPiPMainWindow"); - int32_t persistentId = 0; - if (!data.ReadInt32(persistentId)) { - WLOGFE("Read eventId from parcel failed!"); - return ERR_INVALID_DATA; - } - Rect rect = {data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32()}; - WSError errCode = RecoveryPullPiPMainWindow(persistentId, rect); - reply.WriteUint32(static_cast(errCode)); - return ERR_NONE; -} - int SessionStub::HandleProcessPointDownSession(MessageParcel& data, MessageParcel& reply) { WLOGFD("HandleProcessPointDownSession!"); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 39c8016b0..f56fcd843 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -77,7 +77,6 @@ using WindowChangedFunc = std::function& session)>; using CmpFunc = std::function>& lhs, std::pair>& rhs)>; -using ProcessShowPiPMainWindowFunc = std::function; using ProcessStartUIAbilityErrorFunc = std::function; using NotifySCBAfterUpdateFocusFunc = std::function; using ProcessCallingWindowIdChangeFunc = std::function; @@ -149,7 +148,6 @@ public: void SetShiftFocusListener(const ProcessShiftFocusFunc& func); void SetSCBFocusedListener(const NotifySCBAfterUpdateFocusFunc& func); void SetSCBUnfocusedListener(const NotifySCBAfterUpdateFocusFunc& func); - void SetShowPiPMainWindowListener(const ProcessShowPiPMainWindowFunc& func); void SetCallingWindowIdChangeListenser(const ProcessCallingWindowIdChangeFunc& func); const AppWindowSceneConfig& GetWindowSceneConfig() const; WSError ProcessBackEvent(); @@ -246,7 +244,6 @@ public: WSError RegisterIAbilityManagerCollaborator(int32_t type, const sptr &impl) override; WSError UnregisterIAbilityManagerCollaborator(int32_t type) override; - WSError RecoveryPullPiPMainWindow(const int32_t& persistentId, const Rect& rect); bool IsInputEventEnabled(); void SetEnableInputEvent(bool enabled); @@ -463,7 +460,6 @@ private: ProcessShiftFocusFunc shiftFocusFunc_; NotifySCBAfterUpdateFocusFunc notifySCBAfterFocusedFunc_; NotifySCBAfterUpdateFocusFunc notifySCBAfterUnfocusedFunc_; - ProcessShowPiPMainWindowFunc showPiPMainWindowFunc_; ProcessCallingWindowIdChangeFunc callingWindowIdChangeFunc_; ProcessStartUIAbilityErrorFunc startUIAbilityErrorFunc_; ProcessVirtualPixelRatioChangeFunc processVirtualPixelRatioChangeFunc_ = nullptr; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3eb4e8829..4c0c3dd34 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -88,7 +88,6 @@ #include "softbus_bus_center.h" #include "window_manager.h" #include "perform_reporter.h" -#include "pip_util.h" #include "focus_change_info.h" #include "anr_manager.h" @@ -924,8 +923,6 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onSessionTouchOutside_ = std::bind(&SceneSessionManager::NotifySessionTouchOutside, this, std::placeholders::_1); specificCb->onGetAINavigationBarArea_ = std::bind(&SceneSessionManager::GetAINavigationBarArea, this); - specificCb->onRecoveryPullPiPMainWindow_ = std::bind(&SceneSessionManager::RecoveryPullPiPMainWindow, - this, std::placeholders::_1, std::placeholders::_2); specificCb->onOutsideDownEvent_ = std::bind(&SceneSessionManager::OnOutsideDownEvent, this, std::placeholders::_1, std::placeholders::_2); specificCb->onHandleSecureSessionShouldHide_ = std::bind(&SceneSessionManager::HandleSecureSessionShouldHide, @@ -1791,7 +1788,7 @@ bool SceneSessionManager::CheckPiPPriority(const PiPTemplateInfo& pipTemplateInf if (session && session->GetWindowMode() == WindowMode::WINDOW_MODE_PIP && pipTemplateInfo.priority < session->GetPiPTemplateInfo().priority && IsSessionVisible(session)) { - WLOGFE("create pip window failed, reason: low priority."); + TLOGE(WmsLogTag::WMS_PIP, "create pip window failed, reason: low priority."); return false; } } @@ -3850,12 +3847,6 @@ void SceneSessionManager::SetSCBUnfocusedListener(const NotifySCBAfterUpdateFocu notifySCBAfterUnfocusedFunc_ = func; } -void SceneSessionManager::SetShowPiPMainWindowListener(const ProcessShowPiPMainWindowFunc& func) -{ - WLOGFD("SetShowPiPMainWindowListener"); - showPiPMainWindowFunc_ = func; -} - void SceneSessionManager::SetCallingWindowIdChangeListenser(const ProcessCallingWindowIdChangeFunc& func) { WLOGFD("SetCallingWindowIdChangeListenser"); @@ -6577,31 +6568,6 @@ WSError SceneSessionManager::UnregisterIAbilityManagerCollaborator(int32_t type) return WSError::WS_OK; } -WSError SceneSessionManager::RecoveryPullPiPMainWindow(const int32_t& persistentId, const Rect& rect) -{ - auto scnSession = GetSceneSession(persistentId); - if (scnSession == nullptr) { - WLOGFE("scnSession is nullptr, persistentId: %{public}d", persistentId); - return WSError::WS_ERROR_NULLPTR; - } - if (!WindowHelper::IsPipWindow(scnSession->GetWindowType())) { - WLOGFE("not pip window"); - return WSError::WS_DO_NOTHING; - } - auto task = [this, scnSession, rect, persistentId]() { - if (!showPiPMainWindowFunc_) { - WLOGFE("showPiPMainWindowFunc_ init error, persistentId: %{public}d", persistentId); - return WSError::WS_DO_NOTHING; - } - showPiPMainWindowFunc_(scnSession->GetParentPersistentId()); - WSRect rectPos = SessionHelper::TransferToWSRect(rect); - scnSession->UpdateSessionRect(rectPos, SizeChangeReason::RECOVER); - return WSError::WS_OK; - }; - taskScheduler_->PostAsyncTask(task, "RecoveryPullPiPMainWindow"); - return WSError::WS_OK; -} - bool SceneSessionManager::CheckCollaboratorType(int32_t type) { if (type != CollaboratorType::RESERVE_TYPE && type != CollaboratorType::OTHERS_TYPE) { diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 7bfeaca4f..e10a701f1 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -2767,37 +2767,6 @@ HWTEST_F(SceneSessionTest, SetLastSafeRect, Function | SmallTest | Level2) EXPECT_EQ(6, result.height_); } -/** - * @tc.name: RecoveryPullPiPMainWindow - * @tc.desc: * @tc.name: RecoveryPullPiPMainWindow - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionTest, RecoveryPullPiPMainWindow, Function | SmallTest | Level2) -{ - SessionInfo info; - info.abilityName_ = "SetLastSafeRect"; - info.bundleName_ = "SetLastSafeRect"; - sptr scensession; - sptr specificSession = - new SceneSession::SpecificSessionCallback(); - scensession = new (std::nothrow) SceneSession(info, specificSession); - Rect rec = {3, 4, 5, 6}; - scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); - auto prepareClosePiPSessionFunc = [scensession]() { - scensession->NotifyUILostFocus(); - }; - scensession->sessionChangeCallback_->onPrepareClosePiPSession_ = prepareClosePiPSessionFunc; - auto recoveryPullPiPMainWindowFunc = [scensession](int32_t persistentId, Rect rect) { - rect.posX_ = persistentId; - rect.posY_ = persistentId; - rect.width_ = persistentId; - rect.height_ = persistentId; - }; - scensession->specificCallback_->onRecoveryPullPiPMainWindow_ = recoveryPullPiPMainWindowFunc; - scensession->NotifyPiPWindowPrepareClose(); - EXPECT_EQ(WSError::WS_OK, scensession->RecoveryPullPiPMainWindow(5, rec)); -} - /** * @tc.name: GetSessionTargetRect * @tc.desc: * @tc.name: GetSessionTargetRect @@ -2829,32 +2798,6 @@ HWTEST_F(SceneSessionTest, GetSessionTargetRect, Function | SmallTest | Level2) EXPECT_NE(nullptr, scensession->moveDragController_); } -/** - * @tc.name: OnPiPMoveCallback - * @tc.desc: * @tc.name: OnPiPMoveCallback - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionTest, OnPiPMoveCallback, Function | SmallTest | Level2) -{ - SessionInfo info; - info.abilityName_ = "OnPiPMoveCallback"; - info.bundleName_ = "SetTextFieldAvoidInfo"; - sptr scensession; - sptr specificSession = - new SceneSession::SpecificSessionCallback(); - scensession = new (std::nothrow) SceneSession(info, specificSession); - WSError res = scensession->SetTextFieldAvoidInfo(3.1415927, 2.718); - EXPECT_EQ(WSError::WS_OK, res); - sptr session = new (std::nothrow) Session(info); - EXPECT_NE(nullptr, session->property_); - sptr property = new WindowSessionProperty(); - property->SetWindowType(WindowType::WINDOW_TYPE_PIP); - WSRect rect = {5, 6, 7, 8}; - scensession->OnPiPMoveCallback(rect, SizeChangeReason::MOVE); - scensession->OnPiPMoveCallback(rect, SizeChangeReason::DRAG_END); - EXPECT_EQ(WindowType::WINDOW_TYPE_PIP, property->GetWindowType()); -} - /* * @tc.name: SetPipActionEvent * @tc.desc: * @tc.name: SetPipActionEvent diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index ba623d1e1..bca58db99 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -238,22 +238,6 @@ HWTEST_F(SessionStubTest, HandleUpdatePiPRect004, Function | SmallTest | Level2) ASSERT_EQ(0, res); } -/** - * @tc.name: HandleRecoveryPullPiPMainWindow005 - * @tc.desc: sessionStub sessionStubTest - * @tc.type: FUNC - * @tc.require: #I6JLSI - */ -HWTEST_F(SessionStubTest, HandleRecoveryPullPiPMainWindow005, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - data.WriteBool(true); - sptr iRemoteObjectMocker = new IRemoteObjectMocker(); - auto res = session_->HandleRecoveryPullPiPMainWindow(data, reply); - ASSERT_EQ(0, res); -} - /** * @tc.name: HandleProcessPointDownSession006 * @tc.desc: sessionStub sessionStubTest diff --git a/wm/include/picture_in_picture_controller.h b/wm/include/picture_in_picture_controller.h index 6cc496df6..273120bef 100644 --- a/wm/include/picture_in_picture_controller.h +++ b/wm/include/picture_in_picture_controller.h @@ -62,8 +62,6 @@ public: void SetAutoStartEnabled(bool enable); void IsAutoStartEnabled(bool& enable) const; void UpdateContentSize(int32_t width, int32_t height); - void StartMove(); - void DoScale(); void DoActionEvent(const std::string& actionName, int32_t status); void RestorePictureInPictureWindow(); void SetPictureInPictureLifecycle(sptr listener); diff --git a/wm/include/picture_in_picture_manager.h b/wm/include/picture_in_picture_manager.h index 748439435..f571d0090 100644 --- a/wm/include/picture_in_picture_manager.h +++ b/wm/include/picture_in_picture_manager.h @@ -45,8 +45,6 @@ public: static void DoRestore(); static void DoClose(bool destroyWindow, bool needAnim); - static void DoStartMove(); - static void DoScale(); static void DoActionEvent(const std::string& actionName, int32_t status); static void AutoStartPipWindow(std::string navigationId); private: diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 67b746887..ee56b1d37 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -133,7 +133,6 @@ public: void NotifySessionForeground(uint32_t reason, bool withAnimation) override; void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WMError NotifyPrepareClosePiPWindow() override; - WMError RecoveryPullPiPMainWindow(const Rect& rect) override; void UpdateSubWindowState(const WindowType& type); WMError SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) override; void ConsumePointerEvent(const std::shared_ptr& pointerEvent) override; diff --git a/wm/src/picture_in_picture_controller.cpp b/wm/src/picture_in_picture_controller.cpp index ef7704a06..6c172b9a1 100644 --- a/wm/src/picture_in_picture_controller.cpp +++ b/wm/src/picture_in_picture_controller.cpp @@ -29,8 +29,6 @@ namespace OHOS { namespace Rosen { namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "PictureInPictureController"}; - constexpr int32_t DELAY_ANIM = 500; constexpr int32_t SUCCESS = 1; constexpr int32_t FAILED = 0; constexpr uint32_t PIP_LOW_PRIORITY = 0; @@ -40,7 +38,7 @@ namespace { static uint32_t GetPipPriority(uint32_t pipTemplateType) { if (pipTemplateType < 0 || pipTemplateType >= static_cast(PipTemplateType::END)) { - WLOGFE("param invalid, pipTemplateType is %{public}d", pipTemplateType); + TLOGE(WmsLogTag::WMS_PIP, "param invalid, pipTemplateType is %{public}d", pipTemplateType); return PIP_LOW_PRIORITY; } if (pipTemplateType == static_cast(PipTemplateType::VIDEO_PLAY) || @@ -66,10 +64,10 @@ PictureInPictureController::~PictureInPictureController() WMError PictureInPictureController::CreatePictureInPictureWindow() { - WLOGI("CreatePictureInPictureWindow is called, mainWindow:%{public}u", mainWindowId_); + TLOGI(WmsLogTag::WMS_PIP, "CreatePictureInPictureWindow is called, mainWindow:%{public}u", mainWindowId_); sptr thisController = this; if (pipOption_ == nullptr || pipOption_->GetContext() == nullptr) { - WLOGFE("Get PictureInPictureOption failed"); + TLOGE(WmsLogTag::WMS_PIP, "Create pip failed, invalid pipOption"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } auto context = static_cast*>(pipOption_->GetContext()); @@ -77,12 +75,11 @@ WMError PictureInPictureController::CreatePictureInPictureWindow() SingletonContainer::Get().SetCurrentPackageName(abilityContext->GetApplicationInfo()->name); sptr windowOption = new(std::nothrow) WindowOption(); if (windowOption == nullptr) { - WLOGFE("Get WindowOption failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } mainWindowXComponentController_ = pipOption_->GetXComponentController(); if (mainWindowXComponentController_ == nullptr || mainWindow_ == nullptr) { - WLOGFE("mainWindowXComponentController or main window is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "mainWindowXComponentController or mainWindow is nullptr"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } UpdateXComponentPositionAndSize(); @@ -98,7 +95,7 @@ WMError PictureInPictureController::CreatePictureInPictureWindow() pipTemplateInfo.priority = GetPipPriority(pipOption_->GetPipTemplate()); sptr window = Window::CreatePiP(windowOption, pipTemplateInfo, context->lock(), errCode); if (window == nullptr || errCode != WMError::WM_OK) { - WLOGFE("Window create failed, reason: %{public}d", errCode); + TLOGE(WmsLogTag::WMS_PIP, "Window create failed, reason: %{public}d", errCode); return WMError::WM_ERROR_PIP_CREATE_FAILED; } window_ = window; @@ -109,30 +106,30 @@ WMError PictureInPictureController::CreatePictureInPictureWindow() WMError PictureInPictureController::ShowPictureInPictureWindow(StartPipType startType) { - WLOGD("ShowPictureInPictureWindow is called"); + TLOGD(WmsLogTag::WMS_PIP, "ShowPictureInPictureWindow is called"); if (window_ == nullptr) { - WLOGFD("window_ is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "window is null when show pip"); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), - pipOption_->GetPipTemplate(), FAILED, "window_ is nullptr"); + pipOption_->GetPipTemplate(), FAILED, "window is nullptr"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; } if (pipLifeCycleListener_ != nullptr) { pipLifeCycleListener_->OnPreparePictureInPictureStart(); } if (pipOption_ == nullptr) { - WLOGFE("Get PictureInPicture option failed"); + TLOGE(WmsLogTag::WMS_PIP, "Get PictureInPicture option failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } window_->SetUIContentByAbc(PIP_CONTENT_PATH, env_, nullptr, nullptr); WMError errCode = window_->Show(0, false); if (errCode != WMError::WM_OK) { - WLOGFD("window_ show failed, err: %{public}u", errCode); + TLOGE(WmsLogTag::WMS_PIP, "window show failed, err: %{public}u", errCode); int32_t err = static_cast(errCode); if (pipLifeCycleListener_ != nullptr) { pipLifeCycleListener_->OnPictureInPictureOperationError(err); } SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), - pipOption_->GetPipTemplate(), FAILED, "window_ show failed"); + pipOption_->GetPipTemplate(), FAILED, "window show failed"); return WMError::WM_ERROR_PIP_INTERNAL_ERROR; } uint32_t requestWidth = 0; @@ -152,25 +149,25 @@ WMError PictureInPictureController::ShowPictureInPictureWindow(StartPipType star WMError PictureInPictureController::StartPictureInPicture(StartPipType startType) { - WLOGI("StartPictureInPicture called"); + TLOGI(WmsLogTag::WMS_PIP, "StartPictureInPicture called"); std::lock_guard lock(mutex_); if (curState_ == PipWindowState::STATE_STARTING || curState_ == PipWindowState::STATE_STARTED) { - WLOGFW("pip window is starting, state: %{public}u, pipWindow: %{public}u, mainWindow: %{public}u", + TLOGW(WmsLogTag::WMS_PIP, "pipWindow is starting, state: %{public}u, id: %{public}u, mainWindow: %{public}u", curState_, window_->GetWindowId(), mainWindowId_); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), pipOption_->GetPipTemplate(), FAILED, "Pip window is starting"); return WMError::WM_ERROR_PIP_REPEAT_OPERATION; } if (pipOption_ == nullptr || pipOption_->GetContext() == nullptr) { - WLOGFE("Get PictureInPictureOption failed"); + TLOGE(WmsLogTag::WMS_PIP, "Get PictureInPictureOption failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } if (mainWindow_ == nullptr) { - WLOGFE("Init main window failed"); + TLOGE(WmsLogTag::WMS_PIP, "Init main window failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } if (!IsPullPiPAndHandleNavigation()) { - WLOGFE("Navigation operate failed"); + TLOGE(WmsLogTag::WMS_PIP, "Navigation operate failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } curState_ = PipWindowState::STATE_STARTING; @@ -178,7 +175,7 @@ WMError PictureInPictureController::StartPictureInPicture(StartPipType startType // if current controller is not the active one, but belongs to the same mainWindow, reserve pipWindow if (PictureInPictureManager::IsAttachedToSameWindow(mainWindowId_)) { window_ = PictureInPictureManager::GetCurrentWindow(); - WLOGFD("Reuse pipWindow: %{public}u as attached to the same mainWindow: %{public}u", + TLOGE(WmsLogTag::WMS_PIP, "Reuse pipWindow: %{public}u as attached to the same mainWindow: %{public}u", window_->GetWindowId(), mainWindowId_); PictureInPictureManager::DoClose(false, false); mainWindowXComponentController_ = pipOption_->GetXComponentController(); @@ -204,7 +201,7 @@ WMError PictureInPictureController::StartPictureInPictureInner(StartPipType star WMError errCode = CreatePictureInPictureWindow(); if (errCode != WMError::WM_OK) { curState_ = PipWindowState::STATE_UNDEFINED; - WLOGFE("Create pip window failed, err: %{public}u", errCode); + TLOGE(WmsLogTag::WMS_PIP, "Create pip window failed, err: %{public}u", errCode); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), pipOption_->GetPipTemplate(), FAILED, "Create pip window failed"); return errCode; @@ -212,7 +209,7 @@ WMError PictureInPictureController::StartPictureInPictureInner(StartPipType star errCode = ShowPictureInPictureWindow(startType); if (errCode != WMError::WM_OK) { curState_ = PipWindowState::STATE_UNDEFINED; - WLOGFE("Show pip window failed, err: %{public}u", errCode); + TLOGE(WmsLogTag::WMS_PIP, "Show pip window failed, err: %{public}u", errCode); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), pipOption_->GetPipTemplate(), FAILED, "Show pip window failed"); return errCode; @@ -226,13 +223,13 @@ WMError PictureInPictureController::StartPictureInPictureInner(StartPipType star WMError PictureInPictureController::StopPictureInPictureFromClient() { if (!window_) { - WLOGFE("window is null"); + TLOGE(WmsLogTag::WMS_PIP, "window is null"); SingletonContainer::Get().ReportPiPStopWindow(static_cast(StopPipType::USER_STOP), pipOption_->GetPipTemplate(), FAILED, "window is null"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; } if (curState_ == PipWindowState::STATE_STOPPING || curState_ == PipWindowState::STATE_STOPPED) { - WLOGFE("Repeat stop request, curState: %{public}u", curState_); + TLOGE(WmsLogTag::WMS_PIP, "Repeat stop request, curState: %{public}u", curState_); SingletonContainer::Get().ReportPiPStopWindow(static_cast(StopPipType::USER_STOP), pipOption_->GetPipTemplate(), FAILED, "Repeat stop request"); return WMError::WM_ERROR_PIP_REPEAT_OPERATION; @@ -248,16 +245,16 @@ WMError PictureInPictureController::StopPictureInPictureFromClient() WMError PictureInPictureController::StopPictureInPicture(bool destroyWindow, StopPipType stopPipType) { - WLOGI("StopPictureInPicture is called, destroyWindow: %{public}u", destroyWindow); + TLOGD(WmsLogTag::WMS_PIP, "StopPictureInPicture is called, destroyWindow: %{public}u", destroyWindow); std::lock_guard lock(mutex_); if (curState_ == PipWindowState::STATE_STOPPING || curState_ == PipWindowState::STATE_STOPPED) { - WLOGFE("Repeat stop request, curState: %{public}u", curState_); + TLOGE(WmsLogTag::WMS_PIP, "Repeat stop request, curState: %{public}u", curState_); SingletonContainer::Get().ReportPiPStopWindow(static_cast(stopPipType), pipOption_->GetPipTemplate(), FAILED, "Repeat stop request"); return WMError::WM_ERROR_PIP_REPEAT_OPERATION; } if (window_ == nullptr) { - WLOGFE("window_ is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "window is nullptr when stop pip"); SingletonContainer::Get().ReportPiPStopWindow(static_cast(stopPipType), pipOption_->GetPipTemplate(), FAILED, "window_ is nullptr"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; @@ -284,16 +281,16 @@ WMError PictureInPictureController::StopPictureInPictureInner(StopPipType stopTy auto task = [weakThis = wptr(this), currentStopType = stopType, currentPipOption = pipOption_]() { auto session = weakThis.promote(); if (!session || !session->window_) { - WLOGFE("session is null"); + TLOGE(WmsLogTag::WMS_PIP, "pipController is null in stopping task"); SingletonContainer::Get().ReportPiPStopWindow(static_cast(currentStopType), - currentPipOption->GetPipTemplate(), FAILED, "session is null"); + currentPipOption->GetPipTemplate(), FAILED, "pipController is null"); return WMError::WM_ERROR_PIP_INTERNAL_ERROR; } session->ResetExtController(); WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(session->window_->Destroy()); if (ret != WmErrorCode::WM_OK) { session->curState_ = PipWindowState::STATE_UNDEFINED; - WLOGFE("Window destroy failed"); + TLOGE(WmsLogTag::WMS_PIP, "Window destroy failed, err:%{public}u", ret); int32_t err = static_cast(ret); if (session->pipLifeCycleListener_ != nullptr) { session->pipLifeCycleListener_->OnPictureInPictureOperationError(err); @@ -315,7 +312,7 @@ WMError PictureInPictureController::StopPictureInPictureInner(StopPipType stopTy session->mainWindow_->GetUIContent(), navId); if (navController) { navController->DeletePIPMode(session->handleId_); - WLOGFI("Delete pip mode id: %{public}d", session->handleId_); + TLOGI(WmsLogTag::WMS_PIP, "Delete pip mode id: %{public}d", session->handleId_); } } SingletonContainer::Get().ReportPiPStopWindow(static_cast(currentStopType), @@ -347,12 +344,13 @@ void PictureInPictureController::SetPipWindow(sptr window) void PictureInPictureController::SetAutoStartEnabled(bool enable) { - WLOGI("SetAutoStartEnabled called, enable: %{public}u, mainWindow: %{public}u", enable, mainWindowId_); + TLOGI(WmsLogTag::WMS_PIP, + "SetAutoStartEnabled called, enable: %{public}u, mainWindow: %{public}u", enable, mainWindowId_); isAutoStartEnabled_ = enable; if (isAutoStartEnabled_) { // cache navigation here as we cannot get containerId while BG if (!IsPullPiPAndHandleNavigation()) { - WLOGFE("Navigation operate failed"); + TLOGE(WmsLogTag::WMS_PIP, "Navigation operate failed"); return; } PictureInPictureManager::AttachAutoStartController(handleId_, weakRef_); @@ -366,7 +364,7 @@ void PictureInPictureController::SetAutoStartEnabled(bool enable) auto navController = NavigationController::GetNavigationController(mainWindow_->GetUIContent(), navId); if (navController) { navController->DeletePIPMode(handleId_); - WLOGFI("Delete pip mode id: %{public}d", handleId_); + TLOGI(WmsLogTag::WMS_PIP, "Delete pip mode id: %{public}d", handleId_); } } } @@ -385,48 +383,27 @@ PipWindowState PictureInPictureController::GetControllerState() void PictureInPictureController::UpdateContentSize(int32_t width, int32_t height) { if (width <= 0 || height <= 0) { - WLOGFE("invalid size"); + TLOGE(WmsLogTag::WMS_PIP, "invalid size"); return; } if (curState_ != PipWindowState::STATE_STARTED) { - WLOGFD("UpdateContentSize is disabled when state: %{public}u", curState_); + TLOGD(WmsLogTag::WMS_PIP, "UpdateContentSize is disabled when state: %{public}u", curState_); return; } if (window_ == nullptr) { - WLOGFE("pipWindow not exist"); + TLOGE(WmsLogTag::WMS_PIP, "pipWindow not exist"); return; } - WLOGI("UpdateContentSize window: %{public}u width:%{public}u height:%{public}u", + TLOGI(WmsLogTag::WMS_PIP, "UpdateContentSize window: %{public}u width:%{public}u height:%{public}u", window_->GetWindowId(), width, height); Rect rect = {0, 0, width, height}; window_->UpdatePiPRect(rect, WindowSizeChangeReason::PIP_RATIO_CHANGE); } -void PictureInPictureController::StartMove() -{ - if (window_ == nullptr) { - WLOGFE("pipWindow not exist"); - return; - } - WLOGI("StartMove is called, window: %{public}u", window_->GetWindowId()); - SingletonContainer::Get().ReportPiPMove(); - window_->StartMove(); -} - -void PictureInPictureController::DoScale() -{ - if (window_ == nullptr) { - WLOGFE("PiPWindow is not exist"); - return; - } - WLOGI("DoScale is called, window: %{public}u", window_->GetWindowId()); -} - void PictureInPictureController::PipMainWindowLifeCycleImpl::AfterBackground() { - WLOGI("PipMainWindowLifeCycleImpl AfterBackground is called"); if (!PowerMgr::PowerMgrClient::GetInstance().IsScreenOn()) { - WLOGFI("disable auto start as screen is off"); + TLOGI(WmsLogTag::WMS_PIP, "disable auto start as screen is off"); return; } PictureInPictureManager::AutoStartPipWindow(navigationId_); @@ -434,14 +411,14 @@ void PictureInPictureController::PipMainWindowLifeCycleImpl::AfterBackground() void PictureInPictureController::PipMainWindowLifeCycleImpl::BackgroundFailed(int32_t type) { - WLOGI("PipMainWindowLifeCycleImpl BackgroundFailed"); + TLOGD(WmsLogTag::WMS_PIP, "PipMainWindowLifeCycleImpl BackgroundFailed"); } void PictureInPictureController::DoActionEvent(const std::string& actionName, int32_t status) { - WLOGFD("actionName: %{public}s", actionName.c_str()); + TLOGD(WmsLogTag::WMS_PIP, "actionName: %{public}s", actionName.c_str()); if (pipActionObserver_ == nullptr) { - WLOGFE("pipActionObserver is not registered"); + TLOGE(WmsLogTag::WMS_PIP, "pipActionObserver is not registered"); return; } SingletonContainer::Get().ReportPiPActionEvent(pipOption_->GetPipTemplate(), actionName); @@ -450,41 +427,26 @@ void PictureInPictureController::DoActionEvent(const std::string& actionName, in void PictureInPictureController::RestorePictureInPictureWindow() { - if (window_ == nullptr || mainWindow_ == nullptr) { - WLOGFE("window or main window is nullptr"); - return; - } - WLOGFI("restore pipWindow %{public}u to [%{public}u, %{public}u, %{public}u, %{public}u]", window_->GetWindowId(), - windowRect_.posX_, windowRect_.posY_, windowRect_.width_, windowRect_.height_); if (pipLifeCycleListener_) { pipLifeCycleListener_->OnRestoreUserInterface(); } - window_->RecoveryPullPiPMainWindow(windowRect_); + if (mainWindow_ == nullptr) { + TLOGI(WmsLogTag::WMS_PIP, "main window is nullptr"); + return; + } std::string navId = pipOption_->GetNavigationId(); if (navId != "") { auto navController = NavigationController::GetNavigationController(mainWindow_->GetUIContent(), navId); if (navController) { navController->PushInPIP(handleId_); - WLOGFI("Push in pip handleId: %{public}d", handleId_); + TLOGI(WmsLogTag::WMS_PIP, "Push in pip handleId: %{public}d", handleId_); } else { - WLOGFE("navController is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "navController is nullptr"); } } - auto stopPipTask = [weakThis = wptr(this)]() { - auto session = weakThis.promote(); - if (!session) { - WLOGFE("session is null"); - return; - } - session->StopPictureInPicture(true, StopPipType::NULL_STOP); - }; - if (handler_ == nullptr) { - WLOGFE("handler is nullptr"); - return; - } - handler_->PostTask(stopPipTask, "wms:RestorePictureInPictureWindow", DELAY_ANIM); + StopPictureInPicture(true, StopPipType::NULL_STOP); SingletonContainer::Get().ReportPiPRestore(); - WLOGFI("restore pip main window finished"); + TLOGI(WmsLogTag::WMS_PIP, "restore pip main window finished"); } void PictureInPictureController::UpdateXComponentPositionAndSize() @@ -499,40 +461,40 @@ void PictureInPictureController::UpdateXComponentPositionAndSize() windowRect_.height_ = static_cast(height); windowRect_.posX_ = static_cast(posX); windowRect_.posY_ = static_cast(posY); - WLOGFD("position width: %{public}u, height: %{public}u, posX: %{public}d, posY: %{public}d", + TLOGD(WmsLogTag::WMS_PIP, "position width: %{public}u, height: %{public}u, posX: %{public}d, posY: %{public}d", windowRect_.width_, windowRect_.height_, windowRect_.posX_, windowRect_.posY_); } void PictureInPictureController::ResetExtController() { - WLOGI("ResetExtController is called"); + TLOGI(WmsLogTag::WMS_PIP, "ResetExtController is called"); if (mainWindowXComponentController_ == nullptr || pipXComponentController_ == nullptr) { - WLOGFE("error when reset XComponentController"); + TLOGE(WmsLogTag::WMS_PIP, "error when resetExtController, one of the xComponentController is null"); return; } XComponentControllerErrorCode errorCode = mainWindowXComponentController_->ResetExtController(pipXComponentController_); if (errorCode != XComponentControllerErrorCode::XCOMPONENT_CONTROLLER_NO_ERROR) { - WLOGFE("swap xComponent failed, errorCode: %{public}u", errorCode); + TLOGE(WmsLogTag::WMS_PIP, "swap xComponent failed, errorCode: %{public}u", errorCode); } } WMError PictureInPictureController::SetXComponentController(std::shared_ptr xComponentController) { - WLOGI("SetXComponentController is called"); + TLOGD(WmsLogTag::WMS_PIP, "SetXComponentController is called"); pipXComponentController_ = xComponentController; if (window_ == nullptr) { - WLOGFE("window_ is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "window is nullptr when set XComponentController"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; } if (mainWindowXComponentController_ == nullptr || pipXComponentController_ == nullptr) { - WLOGFE("window_ is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "error when setXController, one of the xComponentController is null"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; } XComponentControllerErrorCode errorCode = mainWindowXComponentController_->SetExtController(pipXComponentController_); if (errorCode != XComponentControllerErrorCode::XCOMPONENT_CONTROLLER_NO_ERROR) { - WLOGFE("swap xComponent failed, errorCode: %{public}u", errorCode); + TLOGE(WmsLogTag::WMS_PIP, "swap xComponent failed, errorCode: %{public}u", errorCode); return WMError::WM_ERROR_PIP_INTERNAL_ERROR; } if (pipLifeCycleListener_ != nullptr) { @@ -543,13 +505,11 @@ WMError PictureInPictureController::SetXComponentController(std::shared_ptr listener) { - WLOGFD("SetPictureInPictureLifecycle is called"); pipLifeCycleListener_ = listener; } void PictureInPictureController::SetPictureInPictureActionObserver(sptr listener) { - WLOGFD("SetPictureInPictureActionObserver is called"); pipActionObserver_ = listener; } @@ -566,11 +526,11 @@ sptr PictureInPictureController::GetPictureInPictureActionOb bool PictureInPictureController::IsPullPiPAndHandleNavigation() { if (pipOption_->GetNavigationId() == "") { - WLOGFI("App not use navigation"); + TLOGI(WmsLogTag::WMS_PIP, "App not use navigation"); return true; } if (mainWindow_ == nullptr) { - WLOGFE("Main window init error"); + TLOGE(WmsLogTag::WMS_PIP, "Main window init error"); return false; } std::string navId = pipOption_->GetNavigationId(); @@ -579,19 +539,19 @@ bool PictureInPictureController::IsPullPiPAndHandleNavigation() if (navController->IsNavDestinationInTopStack()) { handleId_ = navController->GetTopHandle(); if (handleId_ != -1) { - WLOGFD("Top handle id : %{public}d", handleId_); + TLOGD(WmsLogTag::WMS_PIP, "Top handle id : %{public}d", handleId_); navController->SetInPIPMode(handleId_); return true; } else { - WLOGFE("Get top handle error"); + TLOGE(WmsLogTag::WMS_PIP, "Get top handle error"); return false; } } else { - WLOGFE("Top is not navDestination"); + TLOGE(WmsLogTag::WMS_PIP, "Top is not navDestination"); return false; } } else { - WLOGFE("Get navController error"); + TLOGE(WmsLogTag::WMS_PIP, "Get navController error"); } return false; } diff --git a/wm/src/picture_in_picture_manager.cpp b/wm/src/picture_in_picture_manager.cpp index 5d9dbcfb7..dd92cd636 100644 --- a/wm/src/picture_in_picture_manager.cpp +++ b/wm/src/picture_in_picture_manager.cpp @@ -25,7 +25,6 @@ namespace OHOS { namespace Rosen { namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "PictureInPictureManager"}; const std::string ACTION_CLOSE = "close"; const std::string ACTION_RESTORE = "restore"; } @@ -51,20 +50,20 @@ bool PictureInPictureManager::ShouldAbortPipStart() void PictureInPictureManager::PutPipControllerInfo(int32_t windowId, sptr pipController) { - WLOGD("PutPipControllerInfo called, windowId %{public}u", windowId); + TLOGD(WmsLogTag::WMS_PIP, "PutPipControllerInfo called, windowId %{public}u", windowId); windowToControllerMap_.insert(std::make_pair(windowId, pipController)); } void PictureInPictureManager::RemovePipControllerInfo(int32_t windowId) { - WLOGD("RemovePipControllerInfo called, windowId %{public}u", windowId); + TLOGD(WmsLogTag::WMS_PIP, "RemovePipControllerInfo called, windowId %{public}u", windowId); windowToControllerMap_.erase(windowId); } sptr PictureInPictureManager::GetPipControllerInfo(int32_t windowId) { if (windowToControllerMap_.empty() || windowToControllerMap_.find(windowId) == windowToControllerMap_.end()) { - WLOGE("GetPipControllerInfo error, %{public}d not registered!", windowId); + TLOGE(WmsLogTag::WMS_PIP, "GetPipControllerInfo error, %{public}d not registered!", windowId); return nullptr; } return windowToControllerMap_[windowId]; @@ -81,19 +80,19 @@ bool PictureInPictureManager::IsActiveController(wptr pipController) { - WLOGD("SetActiveController called"); + TLOGD(WmsLogTag::WMS_PIP, "SetActiveController called"); activeController_ = pipController; } void PictureInPictureManager::RemoveActiveController(wptr pipController) { - WLOGD("RemoveActiveController called"); + TLOGD(WmsLogTag::WMS_PIP, "RemoveActiveController called"); if (!IsActiveController(pipController)) { return; } @@ -103,7 +102,7 @@ void PictureInPictureManager::RemoveActiveController(wptr pipController) { - WLOGD("AttachAutoStartController, %{public}u", handleId); + TLOGD(WmsLogTag::WMS_PIP, "AttachAutoStartController, %{public}u", handleId); if (pipController == nullptr) { return; } @@ -128,14 +127,14 @@ void PictureInPictureManager::AttachAutoStartController(int32_t handleId, void PictureInPictureManager::DetachAutoStartController(int32_t handleId, wptr pipController) { - WLOGD("Detach active pipController, %{public}u", handleId); + TLOGD(WmsLogTag::WMS_PIP, "Detach active pipController, %{public}u", handleId); autoStartControllerMap_.erase(handleId); if (autoStartController_ == nullptr) { return; } if (pipController != nullptr && pipController.GetRefPtr() != autoStartController_.GetRefPtr()) { - WLOGFE("not same pip controller or no active pip controller"); + TLOGE(WmsLogTag::WMS_PIP, "not same pip controller or no active pip controller"); return; } sptr mainWindow = WindowSceneSessionImpl::GetMainWindowWithId( @@ -148,7 +147,7 @@ void PictureInPictureManager::DetachAutoStartController(int32_t handleId, bool PictureInPictureManager::IsAttachedToSameWindow(uint32_t windowId) { - WLOGD("IsAttachedToSameWindow called %{public}u", windowId); + TLOGD(WmsLogTag::WMS_PIP, "IsAttachedToSameWindow called %{public}u", windowId); if (!HasActiveController()) { return false; } @@ -165,7 +164,7 @@ sptr PictureInPictureManager::GetCurrentWindow() void PictureInPictureManager::DoRestore() { - WLOGD("DoRestore is called"); + TLOGD(WmsLogTag::WMS_PIP, "DoRestore is called"); if (!HasActiveController()) { return; } @@ -174,7 +173,7 @@ void PictureInPictureManager::DoRestore() void PictureInPictureManager::DoClose(bool destroyWindow, bool byPriority) { - WLOGD("DoClose is called"); + TLOGD(WmsLogTag::WMS_PIP, "DoClose is called"); if (!HasActiveController()) { return; } @@ -187,27 +186,9 @@ void PictureInPictureManager::DoClose(bool destroyWindow, bool byPriority) activeController_->StopPictureInPicture(destroyWindow, currentStopType); } -void PictureInPictureManager::DoStartMove() -{ - WLOGD("DoStartMove is called"); - if (!HasActiveController()) { - return; - } - activeController_->StartMove(); -} - -void PictureInPictureManager::DoScale() -{ - WLOGD("DoScale is called"); - if (!HasActiveController()) { - return; - } - activeController_->DoScale(); -} - void PictureInPictureManager::DoActionEvent(const std::string& actionName, int32_t status) { - WLOGD("DoActionEvent is called"); + TLOGD(WmsLogTag::WMS_PIP, "DoActionEvent is called"); if (!HasActiveController()) { return; } @@ -222,13 +203,13 @@ void PictureInPictureManager::DoActionEvent(const std::string& actionName, int32 void PictureInPictureManager::AutoStartPipWindow(std::string navigationId) { - WLOGD("AutoStartPipWindow is called, navId: %{public}s", navigationId.c_str()); + TLOGD(WmsLogTag::WMS_PIP, "AutoStartPipWindow is called, navId: %{public}s", navigationId.c_str()); if (autoStartController_ == nullptr) { - WLOGFE("autoStartController_ is null"); + TLOGE(WmsLogTag::WMS_PIP, "autoStartController_ is null"); return; } if (navigationId == "") { - WLOGFI("No use navigationId for auto start"); + TLOGI(WmsLogTag::WMS_PIP, "No use navigationId for auto start"); autoStartController_->StartPictureInPicture(StartPipType::AUTO_START); return; } @@ -237,20 +218,20 @@ void PictureInPictureManager::AutoStartPipWindow(std::string navigationId) if (mainWindow) { auto navController = NavigationController::GetNavigationController(mainWindow->GetUIContent(), navigationId); if (!navController) { - WLOGFE("navController is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "navController is nullptr"); return; } if (navController->IsNavDestinationInTopStack()) { int handleId = navController->GetTopHandle(); if (autoStartControllerMap_.empty() || autoStartControllerMap_.find(handleId) == autoStartControllerMap_.end()) { - WLOGFE("GetNAvController info error, %{public}d not registered", handleId); + TLOGE(WmsLogTag::WMS_PIP, "GetNAvController info error, %{public}d not registered", handleId); return; } auto pipController = autoStartControllerMap_[handleId]; pipController->StartPictureInPicture(StartPipType::AUTO_START); } else { - WLOGFE("Top is not navDestination"); + TLOGE(WmsLogTag::WMS_PIP, "Top is not navDestination"); } } } diff --git a/wm/src/window.cpp b/wm/src/window.cpp index 4e8b89861..5e5bb53c6 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -146,17 +146,17 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo return nullptr; } if (!option || option->GetWindowName().empty()) { - WLOGE("host window session is nullptr:%{public}u or option is null: %{public}u", + TLOGE(WmsLogTag::WMS_PIP, "host window session is nullptr:%{public}u or option is null: %{public}u", option->GetWindowName().empty(), option == nullptr); return nullptr; } if (!WindowHelper::IsPipWindow(option->GetWindowType())) { - WLOGE("window type is not pip window."); + TLOGE(WmsLogTag::WMS_PIP, "window type is not pip window."); return nullptr; } sptr windowSessionImpl = new(std::nothrow) WindowSceneSessionImpl(option); if (windowSessionImpl == nullptr) { - WLOGFE("malloc windowSessionImpl failed."); + TLOGE(WmsLogTag::WMS_PIP, "malloc windowSessionImpl failed."); return nullptr; } if (windowSessionImpl->GetProperty() != nullptr) { @@ -165,7 +165,7 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo WMError error = windowSessionImpl->Create(context, nullptr); if (error != WMError::WM_OK) { errCode = error; - WLOGFD("Create pip window with session, error: %{public}u", static_cast(errCode)); + TLOGD(WmsLogTag::WMS_PIP, "Create pip window with session, error: %{public}u", static_cast(errCode)); return nullptr; } return windowSessionImpl; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 4ac071907..d0dc9c605 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2557,17 +2557,6 @@ WSError WindowSceneSessionImpl::UpdateWindowMode(WindowMode mode) return static_cast(ret); } -WMError WindowSceneSessionImpl::RecoveryPullPiPMainWindow(const Rect& rect) -{ - WLOGFI("RecoveryPullPiPMainWindow"); - if (hostSession_ && property_->GetWindowType() == WindowType::WINDOW_TYPE_PIP) { - hostSession_->RecoveryPullPiPMainWindow(GetPersistentId(), rect); - return WMError::WM_OK; - } - WLOGFW("not pip window, nothing to do"); - return WMError::WM_DO_NOTHING; -} - WMError WindowSceneSessionImpl::UpdateWindowModeImmediately(WindowMode mode) { if (state_ == WindowState::STATE_CREATED || state_ == WindowState::STATE_HIDDEN) { @@ -2633,7 +2622,7 @@ WSError WindowSceneSessionImpl::UpdateTitleInTargetPos(bool isShow, int32_t heig WMError WindowSceneSessionImpl::NotifyPrepareClosePiPWindow() { - WLOGFD("NotifyPrepareClosePiPWindow type: %{public}u", GetType()); + TLOGD(WmsLogTag::WMS_PIP, "NotifyPrepareClosePiPWindow type: %{public}u", GetType()); if (!WindowHelper::IsPipWindow(GetType())) { return WMError::WM_DO_NOTHING; } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index a6683215e..abf508e54 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1755,7 +1755,7 @@ WSError WindowSessionImpl::NotifyDestroy() WSError WindowSessionImpl::NotifyCloseExistPipWindow() { - WLOGFD("WindowSessionImpl::NotifyCloseExistPipWindow"); + TLOGD(WmsLogTag::WMS_PIP, "WindowSessionImpl::NotifyCloseExistPipWindow"); PictureInPictureManager::DoClose(true, true); return WSError::WS_OK; } @@ -1902,7 +1902,7 @@ WSError WindowSessionImpl::UpdateAvoidArea(const sptr& avoidArea, Avo WSError WindowSessionImpl::SetPipActionEvent(const std::string& action, int32_t status) { - WLOGFI("action: %{public}s, status: %{public}d", action.c_str(), status); + TLOGI(WmsLogTag::WMS_PIP, "action: %{public}s, status: %{public}d", action.c_str(), status); PictureInPictureManager::DoActionEvent(action, status); return WSError::WS_OK; } diff --git a/wm/test/unittest/picture_in_picture_controller_test.cpp b/wm/test/unittest/picture_in_picture_controller_test.cpp index 77d62efd7..c8a12d905 100644 --- a/wm/test/unittest/picture_in_picture_controller_test.cpp +++ b/wm/test/unittest/picture_in_picture_controller_test.cpp @@ -234,9 +234,6 @@ HWTEST_F(PictureInPictureControllerTest, StartMove, Function | SmallTest | Level sptr pipControl = new PictureInPictureController(option, mw, 100, nullptr); GTEST_LOG_(INFO) << "TearDownCasecccccc"; - pipControl->StartMove(); - pipControl->DoScale(); - sptr pipMainWindowLifeCycleImpl = new PictureInPictureController::PipMainWindowLifeCycleImpl(navigationId); GTEST_LOG_(INFO) << "TearDownCasecccccc3"; -- Gitee From cbbaba6356f119a92046f4f6567d1eaf742333cd Mon Sep 17 00:00:00 2001 From: wang-song-12 Date: Thu, 21 Mar 2024 08:04:14 +0000 Subject: [PATCH 115/385] modify register listener code Signed-off-by: wang-song-12 Change-Id: I55b9576e85cf3267dddb70fb85dd8866cd19a00b --- utils/include/client_agent_container.h | 17 ++++++++++------- wm/src/window_manager.cpp | 16 ++++++++-------- .../src/window_manager_agent_controller.cpp | 7 ++++--- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/utils/include/client_agent_container.h b/utils/include/client_agent_container.h index 16e7192e4..1a765f9f1 100644 --- a/utils/include/client_agent_container.h +++ b/utils/include/client_agent_container.h @@ -64,9 +64,8 @@ template bool ClientAgentContainer::RegisterAgent(const sptr& agent, T2 type) { std::lock_guard lock(mutex_); - auto iter = std::find_if(agentMap_[type].begin(), agentMap_[type].end(), finder_t(agent->AsObject())); - if (iter != agentMap_[type].end()) { - WLOGFW("failed to register agent"); + if (agent == nullptr) { + WLOGFE("agent is invalid"); return false; } agentMap_[type].insert(agent); @@ -80,14 +79,18 @@ template bool ClientAgentContainer::UnregisterAgent(const sptr& agent, T2 type) { std::lock_guard lock(mutex_); - if (agent == nullptr || agentMap_.count(type) == 0) { - WLOGFE("agent or type is invalid"); + if (agent == nullptr) { + WLOGFE("agent is invalid"); return false; } + if (agentMap_.count(type) == 0) { + WLOGFD("repeat unregister agent"); + return true; + } auto& agents = agentMap_.at(type); - bool ret = UnregisterAgentLocked(agents, agent->AsObject()); + UnregisterAgentLocked(agents, agent->AsObject()); agent->AsObject()->RemoveDeathRecipient(deathRecipient_); - return ret; + return true; } template diff --git a/wm/src/window_manager.cpp b/wm/src/window_manager.cpp index 55a2dc724..e37169dfe 100644 --- a/wm/src/window_manager.cpp +++ b/wm/src/window_manager.cpp @@ -315,7 +315,7 @@ WMError WindowManager::RegisterFocusChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS, pImpl_->focusChangedListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->focusChangedListenerAgent_ = nullptr; } else { @@ -368,7 +368,7 @@ WMError WindowManager::RegisterSystemBarChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR, pImpl_->systemBarChangedListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->systemBarChangedListenerAgent_ = nullptr; } else { @@ -444,7 +444,7 @@ WMError WindowManager::RegisterWindowUpdateListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE, pImpl_->windowUpdateListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->windowUpdateListenerAgent_ = nullptr; } else { @@ -496,7 +496,7 @@ WMError WindowManager::RegisterVisibilityChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY, pImpl_->windowVisibilityListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->windowVisibilityListenerAgent_ = nullptr; } else { @@ -550,7 +550,7 @@ WMError WindowManager::RegisterCameraFloatWindowChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT, pImpl_->cameraFloatWindowChangedListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->cameraFloatWindowChangedListenerAgent_ = nullptr; } else { @@ -609,7 +609,7 @@ WMError WindowManager::RegisterWaterMarkFlagChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG, pImpl_->waterMarkFlagChangeAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->waterMarkFlagChangeAgent_ = nullptr; } else { @@ -675,7 +675,7 @@ WMError WindowManager::RegisterGestureNavigationEnabledChangedListener( WLOGFE("Create windowManagerAgent object failed!"); ret = WMError::WM_ERROR_NULLPTR; } - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFE("RegisterWindowManagerAgent failed!"); pImpl_->gestureNavigationEnabledAgent_ = nullptr; } else { @@ -867,7 +867,7 @@ WMError WindowManager::RegisterDrawingContentChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE, pImpl_->windowDrawingContentListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->windowDrawingContentListenerAgent_ = nullptr; } else { diff --git a/wmserver/src/window_manager_agent_controller.cpp b/wmserver/src/window_manager_agent_controller.cpp index 374e39891..7d7165acd 100644 --- a/wmserver/src/window_manager_agent_controller.cpp +++ b/wmserver/src/window_manager_agent_controller.cpp @@ -27,14 +27,15 @@ WM_IMPLEMENT_SINGLE_INSTANCE(WindowManagerAgentController) WMError WindowManagerAgentController::RegisterWindowManagerAgent(const sptr& windowManagerAgent, WindowManagerAgentType type) { - return wmAgentContainer_.RegisterAgent(windowManagerAgent, type) ? WMError::WM_OK : - WMError::WM_ERROR_REPEAT_OPERATION; + return wmAgentContainer_.RegisterAgent( + windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR; } WMError WindowManagerAgentController::UnregisterWindowManagerAgent(const sptr& windowManagerAgent, WindowManagerAgentType type) { - return wmAgentContainer_.UnregisterAgent(windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR; + return wmAgentContainer_.UnregisterAgent( + windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR; } void WindowManagerAgentController::UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) -- Gitee From 1190ee513a9cbe0b0bcb280478941b51e1bd739c Mon Sep 17 00:00:00 2001 From: qintongtong Date: Thu, 21 Mar 2024 14:34:56 +0800 Subject: [PATCH 116/385] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=97=A9=E4=BA=8E?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E5=BA=94=E7=94=A8=E6=83=B3ArkUI?= =?UTF-8?q?=E6=B4=BE=E5=8F=91=E4=B8=80=E6=AC=A1key=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qintongtong Change-Id: I9f7c5043e7f7d1542db9351bf60bfcf63bd49809 --- interfaces/innerkits/wm/window.h | 6 ++++++ test/common/mock/mock_uicontent.h | 2 +- .../src/intention_event_manager.cpp | 2 ++ .../container/include/window_event_channel.h | 3 ++- .../include/zidl/session_stage_interface.h | 1 + .../zidl/window_event_channel_interface.h | 3 ++- .../include/zidl/window_event_channel_proxy.h | 3 ++- .../container/src/window_event_channel.cpp | 8 +++++++- .../src/zidl/window_event_channel_proxy.cpp | 13 ++++++++++--- .../src/zidl/window_event_channel_stub.cpp | 3 ++- .../session/host/include/scene_session.h | 2 +- window_scene/session/host/include/session.h | 6 ++++-- window_scene/session/host/src/scene_session.cpp | 5 +++-- window_scene/session/host/src/session.cpp | 5 +++-- window_scene/test/unittest/session_test.cpp | 5 +++-- wm/include/window_impl.h | 2 +- wm/include/window_session_impl.h | 2 ++ wm/src/window_impl.cpp | 8 ++++++++ wm/src/window_input_channel.cpp | 3 ++- wm/src/window_session_impl.cpp | 13 +++++++++++++ wm/test/unittest/window_impl_test.cpp | 2 +- wm/test/unittest/window_test.cpp | 16 ++++++++++++++++ 22 files changed, 92 insertions(+), 21 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 6e01b4bc8..a897fd572 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -926,6 +926,12 @@ public: * @param inputEvent Keyboard input event. */ virtual void ConsumeKeyEvent(std::shared_ptr& inputEvent) {} + /** + * @brief Notify KeyEvent to arkui. + * + * @param inputEvent Keyboard input event + */ + virtual bool PreNotifyKeyEvent(const std::shared_ptr& keyEvent) {return false;} /** * @brief Consume PointerEvent from MMI. * diff --git a/test/common/mock/mock_uicontent.h b/test/common/mock/mock_uicontent.h index d307ebd1b..b4f9ff1a1 100644 --- a/test/common/mock/mock_uicontent.h +++ b/test/common/mock/mock_uicontent.h @@ -45,7 +45,7 @@ public: MOCK_METHOD0(DestroyUIDirector, void()); MOCK_METHOD0(ProcessBackPressed, bool()); MOCK_METHOD1(ProcessPointerEvent, bool(const std::shared_ptr& pointerEvent)); - MOCK_METHOD1(ProcessKeyEvent, bool(const std::shared_ptr& keyEvent)); + MOCK_METHOD2(ProcessKeyEvent, bool(const std::shared_ptr& keyEvent, bool isPreIme)); MOCK_METHOD1(ProcessAxisEvent, bool(const std::shared_ptr& axisEvent)); MOCK_METHOD1(ProcessVsyncEvent, bool(uint64_t timeStampNanos)); MOCK_METHOD1(UpdateConfiguration, void(const std::shared_ptr& config)); diff --git a/window_scene/intention_event/src/intention_event_manager.cpp b/window_scene/intention_event/src/intention_event_manager.cpp index cd3a07875..4db2ef127 100644 --- a/window_scene/intention_event/src/intention_event_manager.cpp +++ b/window_scene/intention_event/src/intention_event_manager.cpp @@ -285,6 +285,8 @@ void IntentionEventManager::InputEventListener::OnInputEvent(std::shared_ptrSendKeyEventToUI(keyEvent, true); + TLOGI(WmsLogTag::WMS_EVENT, "SendKeyEventToUI isConsumed = %{public}d", static_cast(isConsumed)); #ifdef IMF_ENABLE bool isKeyboardEvent = IsKeyboardEvent(keyEvent); if (isKeyboardEvent) { diff --git a/window_scene/session/container/include/window_event_channel.h b/window_scene/session/container/include/window_event_channel.h index 45cf4a526..9bef295f0 100644 --- a/window_scene/session/container/include/window_event_channel.h +++ b/window_scene/session/container/include/window_event_channel.h @@ -39,7 +39,8 @@ public: WSError TransferBackpressedEventForConsumed(bool& isConsumed) override; WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; WSError TransferPointerEvent(const std::shared_ptr& pointerEvent) override; - WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) override; + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent = false) override; WSError TransferFocusActiveEvent(bool isFocusActive) override; WSError TransferFocusState(bool focusState) override; WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index 4a306f283..6db89ac6b 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -45,6 +45,7 @@ public: bool notifyInputMethod = true) {} virtual void NotifyFocusActiveEvent(bool isFocusActive) {} virtual void NotifyFocusStateEvent(bool focusState) {} + virtual bool NotifyOnKeyPreImeEvent(const std::shared_ptr& keyEvent) {return false;} virtual int32_t GetPersistentId() const { return -1; diff --git a/window_scene/session/container/include/zidl/window_event_channel_interface.h b/window_scene/session/container/include/zidl/window_event_channel_interface.h index 10628a317..1b7644d6e 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_interface.h +++ b/window_scene/session/container/include/zidl/window_event_channel_interface.h @@ -40,7 +40,8 @@ public: // transfer sync key event for weather consumed virtual WSError TransferBackpressedEventForConsumed(bool& isConsumed) = 0; - virtual WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) = 0; + virtual WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent = false) = 0; virtual WSError TransferFocusActiveEvent(bool isFocusActive) = 0; virtual WSError TransferFocusState(bool focusState) = 0; virtual WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, diff --git a/window_scene/session/container/include/zidl/window_event_channel_proxy.h b/window_scene/session/container/include/zidl/window_event_channel_proxy.h index 538fbe2b8..f8a442d78 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_proxy.h +++ b/window_scene/session/container/include/zidl/window_event_channel_proxy.h @@ -34,7 +34,8 @@ public: WSError TransferBackpressedEventForConsumed(bool& isConsumed) override; WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; WSError TransferPointerEvent(const std::shared_ptr& pointerEvent) override; - WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) override; + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent = false) override; WSError TransferFocusActiveEvent(bool isFocusActive) override; WSError TransferFocusState(bool focusState) override; WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, diff --git a/window_scene/session/container/src/window_event_channel.cpp b/window_scene/session/container/src/window_event_channel.cpp index b96bde5bf..cfc73d201 100644 --- a/window_scene/session/container/src/window_event_channel.cpp +++ b/window_scene/session/container/src/window_event_channel.cpp @@ -79,7 +79,7 @@ WSError WindowEventChannel::TransferBackpressedEventForConsumed(bool& isConsumed } WSError WindowEventChannel::TransferKeyEventForConsumed( - const std::shared_ptr& keyEvent, bool& isConsumed) + const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent) { WLOGFD("WindowEventChannel receive key event"); if (!sessionStage_) { @@ -90,6 +90,12 @@ WSError WindowEventChannel::TransferKeyEventForConsumed( WLOGFE("keyEvent is nullptr"); return WSError::WS_ERROR_NULLPTR; } + if (isPreImeEvent) { + isConsumed = sessionStage_->NotifyOnKeyPreImeEvent(keyEvent); + TLOGI(WmsLogTag::WMS_EVENT, "TransferKeyEventForConsumed isConsumed = %{public}d", + static_cast(isConsumed)); + return WSError::WS_OK; + } DelayedSingleton::GetInstance()->SetSessionStage(keyEvent->GetId(), sessionStage_); sessionStage_->NotifyKeyEvent(keyEvent, isConsumed); keyEvent->MarkProcessed(); diff --git a/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp b/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp index 4593dbcf5..cc217b21f 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp @@ -47,7 +47,11 @@ WSError WindowEventChannelProxy::TransferKeyEvent(const std::shared_ptrSendRequest(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_KEY_EVENT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -103,7 +107,7 @@ WSError WindowEventChannelProxy::TransferBackpressedEventForConsumed(bool& isCon } WSError WindowEventChannelProxy::TransferKeyEventForConsumed( - const std::shared_ptr& keyEvent, bool& isConsumed) + const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent) { MessageParcel data; MessageParcel reply; @@ -117,7 +121,10 @@ WSError WindowEventChannelProxy::TransferKeyEventForConsumed( WLOGFE("Failed to write key event"); return WSError::WS_ERROR_IPC_FAILED; } - + if (!data.WriteBool(isPreImeEvent)) { + WLOGFE("Write bool failed"); + return WSError::WS_ERROR_IPC_FAILED; + } if (Remote()->SendRequest(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_KEY_EVENT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); diff --git a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp index d18ddc173..c5c337bbe 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp @@ -95,8 +95,9 @@ int WindowEventChannelStub::HandleTransferKeyEvent(MessageParcel& data, MessageP WLOGFE("Read Key Event failed"); return ERR_INVALID_DATA; } + bool isPreImeEvent = data.ReadBool(); bool isConsumed = false; - WSError errCode = TransferKeyEventForConsumed(keyEvent, isConsumed); + WSError errCode = TransferKeyEventForConsumed(keyEvent, isConsumed, isPreImeEvent); reply.WriteBool(isConsumed); reply.WriteUint32(static_cast(errCode)); diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index f8a3e5326..0d412026a 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -216,7 +216,7 @@ public: void RegisterSessionChangeCallback(const sptr& sessionChangeCallback); void ClearSpecificSessionCbMap(); void SendPointerEventToUI(std::shared_ptr pointerEvent); - void SendKeyEventToUI(std::shared_ptr keyEvent); + bool SendKeyEventToUI(std::shared_ptr keyEvent, bool isPreImeEvent = false); bool IsStartMoving() const; void SetIsStartMoving(const bool startMoving); bool ShouldHideNonSecureWindows() const; diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 48fbd5275..42b5d490c 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -76,7 +76,8 @@ using GetStateFromManagerFunc = std::function; using NotifySessionInfoLockedStateChangeFunc = std::function; using NotifySystemSessionPointerEventFunc = std::function pointerEvent)>; using NotifySessionInfoChangeNotifyManagerFunc = std::function; -using NotifySystemSessionKeyEventFunc = std::function keyEvent)>; +using NotifySystemSessionKeyEventFunc = std::function keyEvent, + bool isPreImeEvent)>; class ILifecycleListener { public: @@ -143,7 +144,8 @@ public: Accessibility::AccessibilityElementInfo& info); virtual WSError NotifyClientToUpdateRect(std::shared_ptr rsTransaction) { return WSError::WS_OK; } WSError TransferBackPressedEventForConsumed(bool& isConsumed); - WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed); + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent = false); WSError TransferFocusActiveEvent(bool isFocusActive); WSError TransferFocusStateEvent(bool focusState); virtual WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 7d8c68d96..1c1aa35b6 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2388,12 +2388,13 @@ void SceneSession::SendPointerEventToUI(std::shared_ptr point } } -void SceneSession::SendKeyEventToUI(std::shared_ptr keyEvent) +bool SceneSession::SendKeyEventToUI(std::shared_ptr keyEvent, bool isPreImeEvent) { std::lock_guard lock(keyEventMutex_); if (systemSessionKeyEventFunc_ != nullptr) { - systemSessionKeyEventFunc_(keyEvent); + return systemSessionKeyEventFunc_(keyEvent, isPreImeEvent); } + return false; } WSError SceneSession::UpdateSizeChangeReason(SizeChangeReason reason) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 037513d16..ae4f6c89e 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1722,7 +1722,8 @@ WSError Session::TransferBackPressedEventForConsumed(bool& isConsumed) return windowEventChannel_->TransferBackpressedEventForConsumed(isConsumed); } -WSError Session::TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) +WSError Session::TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent) { if (!windowEventChannel_) { WLOGFE("windowEventChannel_ is null"); @@ -1732,7 +1733,7 @@ WSError Session::TransferKeyEventForConsumed(const std::shared_ptrTransferKeyEventForConsumed(keyEvent, isConsumed); + return windowEventChannel_->TransferKeyEventForConsumed(keyEvent, isConsumed, isPreImeEvent); } WSError Session::TransferFocusActiveEvent(bool isFocusActive) diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index c937029e8..e2987cf8e 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -43,7 +43,8 @@ public: WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; WSError TransferPointerEvent(const std::shared_ptr& pointerEvent) override; WSError TransferFocusActiveEvent(bool isFocusActive) override; - WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) override; + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent = false) override; WSError TransferFocusState(bool focusState) override; WSError TransferBackpressedEventForConsumed(bool& isConsumed) override; WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, @@ -79,7 +80,7 @@ WSError TestWindowEventChannel::TransferFocusActiveEvent(bool isFocusActive) } WSError TestWindowEventChannel::TransferKeyEventForConsumed( - const std::shared_ptr& keyEvent, bool& isConsumed) + const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent) { return WSError::WS_OK; } diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index 9ff6ff259..d3beb2472 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -262,7 +262,7 @@ public: void UpdateZoomTransform(const Transform& trans, bool isDisplayZoomOn); void PerformBack() override; void NotifyForegroundInteractiveStatus(bool interactive); - + virtual bool PreNotifyKeyEvent(const std::shared_ptr& keyEvent) override; virtual WMError NapiSetUIContent(const std::string& contentInfo, napi_env env, napi_value storage, bool isdistributed, sptr token, AppExecFwk::Ability* ability) override; virtual WMError SetUIContentByName(const std::string& contentInfo, napi_env env, napi_value storage, diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 8029fd563..65c051ad1 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -49,6 +49,8 @@ public: ~WindowSessionImpl(); void ConsumePointerEvent(const std::shared_ptr& pointerEvent) override; void ConsumeKeyEvent(std::shared_ptr& inputEvent) override; + bool PreNotifyKeyEvent(const std::shared_ptr& keyEvent) override; + virtual bool NotifyOnKeyPreImeEvent(const std::shared_ptr& keyEvent) override; static sptr Find(const std::string& name); static std::vector> GetSubWindow(int parentId); // inherits from window diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index e5851bcbc..5bda012c7 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -1230,6 +1230,14 @@ WMError WindowImpl::Create(uint32_t parentId, const std::shared_ptr& keyEvent) +{ + if (uiContent_ != nullptr) { + return uiContent_->ProcessKeyEvent(keyEvent, true); + } + return false; +} + void WindowImpl::InitAbilityInfo() { AbilityInfo info; diff --git a/wm/src/window_input_channel.cpp b/wm/src/window_input_channel.cpp index 42ed2a16e..7846de8ad 100644 --- a/wm/src/window_input_channel.cpp +++ b/wm/src/window_input_channel.cpp @@ -73,7 +73,8 @@ void WindowInputChannel::HandleKeyEvent(std::shared_ptr& keyEvent return; } } - + bool isConsumed = window_->PreNotifyKeyEvent(keyEvent); + TLOGI(WmsLogTag::WMS_EVENT, "PreNotifyKeyEvent isConsumed = %{public}d", static_cast(isConsumed)); #ifdef IMF_ENABLE bool isKeyboardEvent = IsKeyboardEvent(keyEvent); if (isKeyboardEvent) { diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index adcbe0ccc..ffab2cd47 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -350,6 +350,19 @@ void WindowSessionImpl::ConsumeKeyEvent(std::shared_ptr& keyEvent NotifyKeyEvent(keyEvent, isConsumed, false); } +bool WindowSessionImpl::PreNotifyKeyEvent(const std::shared_ptr& keyEvent) +{ + if (uiContent_ != nullptr) { + return uiContent_->ProcessKeyEvent(keyEvent, true); + } + return false; +} + +bool WindowSessionImpl::NotifyOnKeyPreImeEvent(const std::shared_ptr& keyEvent) +{ + return PreNotifyKeyEvent(keyEvent); +} + WMError WindowSessionImpl::Show(uint32_t reason, bool withAnimation) { TLOGI(WmsLogTag::WMS_LIFE, "Window Show [name:%{public}s, id:%{public}d, type:%{public}u], reason:%{public}u \ diff --git a/wm/test/unittest/window_impl_test.cpp b/wm/test/unittest/window_impl_test.cpp index 027a5f9ce..64dd41ed0 100644 --- a/wm/test/unittest/window_impl_test.cpp +++ b/wm/test/unittest/window_impl_test.cpp @@ -2855,7 +2855,7 @@ HWTEST_F(WindowImplTest, ConsumeKeyEvent, Function | SmallTest | Level3) window->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; window->uiContent_ = std::make_unique(); Ace::UIContentMocker* content = reinterpret_cast(window->uiContent_.get()); - EXPECT_CALL(*content, ProcessKeyEvent(_)); + EXPECT_CALL(*content, ProcessKeyEvent(_, _)); window->ConsumeKeyEvent(keyEvent); window->inputEventConsumer_.reset(new MockInputEventConsumer); diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 8968c66a5..cff76a9ab 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -911,6 +911,22 @@ HWTEST_F(WindowTest, ConsumeKeyEvent, Function | SmallTest | Level2) ASSERT_EQ(WMError::WM_OK, window->Destroy()); } +/** + * @tc.name: PreNotifyKeyEvent + * @tc.desc: get + * @tc.type: FUNC + */ +HWTEST_F(WindowTest, PreNotifyKeyEvent, Function | SmallTest | Level2) +{ + sptr window = new Window(); + ASSERT_NE(nullptr, window); + auto ret = WMError::WM_OK; + std::shared_ptr inputEvent = nullptr; + window->PreNotifyKeyEvent(inputEvent); + ASSERT_EQ(WMError::WM_OK, ret); + ASSERT_EQ(WMError::WM_OK, window->Destroy()); +} + /** * @tc.name: ConsumePointerEvent * @tc.desc: get -- Gitee From ae91ca78de5a1993f3c77859f85606ab9a6eebe2 Mon Sep 17 00:00:00 2001 From: shark_00783 Date: Fri, 22 Mar 2024 11:00:04 +0800 Subject: [PATCH 117/385] =?UTF-8?q?=E6=96=B0=E5=A2=9EUIExtension=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=AD=90=E7=AA=97=E5=9C=BA=E6=99=AFtdd=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shark_00783 --- wm/test/unittest/window_session_impl_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 6f636a21c..834fa4f6a 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -1710,7 +1710,7 @@ HWTEST_F(WindowSessionImplTest, SetUIContentInner, Function | SmallTest | Level2 sptr option = new WindowOption(); ASSERT_NE(option, nullptr); option->SetWindowName("SetUIContentInner"); - option->SetExtensionFlag(true); + option->SetExtensionTag(true); sptr window = new (std::nothrow) WindowSessionImpl(option); ASSERT_NE(window, nullptr); string url = ""; -- Gitee From d9031ca61b2da9b1d2b35dfcf6d8347025efd0dd Mon Sep 17 00:00:00 2001 From: ywx1281675 Date: Fri, 22 Mar 2024 14:38:42 +0800 Subject: [PATCH 118/385] modify the window log Signed-off-by: ywx1281675 --- .../napi/scene_session_manager/js_root_scene_session.cpp | 6 ++++-- window_scene/session/host/src/session.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp index 222970ef7..163683720 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp @@ -230,7 +230,8 @@ void JsRootSceneSession::PendingSessionActivationInner(std::shared_ptrpersistentId_); napi_call_function(env_ref, NapiGetUndefined(env_ref), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); }; @@ -250,7 +251,8 @@ void JsRootSceneSession::PendingSessionActivation(SessionInfo& info) if (info.want != nullptr) { bool isNeedBackToOther = info.want->GetBoolParam(AAFwk::Want::PARAM_BACK_TO_OTHER_MISSION_STACK, false); - TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]isNeedBackToOther: %{public}d", isNeedBackToOther); + TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]session: %{public}d isNeedBackToOther: %{public}d", + sceneSession->GetPersistentId(), isNeedBackToOther); if (isNeedBackToOther) { int32_t realCallerSessionId = SceneSessionManager::GetInstance().GetFocusedSession(); if (realCallerSessionId == sceneSession->GetPersistentId()) { diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 08ba7255a..caf0dcccf 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -959,7 +959,8 @@ WSError Session::Background() isActive_ = false; } if (state != SessionState::STATE_INACTIVE) { - TLOGW(WmsLogTag::WMS_LIFE, "Background state invalid! state:%{public}u", state); + TLOGW(WmsLogTag::WMS_LIFE, "Background state invalid! id: %{public}d, state: %{public}u", + GetPersistentId(), state); return WSError::WS_ERROR_INVALID_SESSION; } UpdateSessionState(SessionState::STATE_BACKGROUND); -- Gitee From ed607796465e2bba6b415c59c9072f6fd5540548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=8F=99?= <1352288123@qq.com> Date: Fri, 15 Mar 2024 16:35:24 +0800 Subject: [PATCH 119/385] =?UTF-8?q?extension=E5=88=9B=E5=BB=BA=E5=B8=A6?= =?UTF-8?q?=E6=A8=A1=E6=80=81=E5=B1=9E=E6=80=A7=E7=9A=84=E5=AD=90=E7=AA=97?= =?UTF-8?q?=EF=BC=8C=E5=8A=A8=E6=80=81=E4=BF=AE=E6=94=B9=E5=AD=90=E7=AA=97?= =?UTF-8?q?=E6=A8=A1=E6=80=81=E5=B1=9E=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴叙 <1352288123@qq.com> --- interfaces/innerkits/wm/window.h | 11 ++++ interfaces/innerkits/wm/wm_common.h | 3 +- .../extension_window/js_extension_window.cpp | 36 +++++++---- .../extension_window/js_extension_window.h | 2 +- .../window_runtime/window_napi/js_window.cpp | 63 +++++++++++++++++++ .../window_runtime/window_napi/js_window.h | 2 + .../window_stage_napi/js_window_stage.cpp | 8 +++ previewer/include/window.h | 10 +++ previewer/include/wm_common.h | 3 +- .../src/scene_session_dirty_manager.cpp | 12 +++- wm/include/window_session_impl.h | 1 + wm/src/window_input_channel.cpp | 31 ++++++++- wm/src/window_session_impl.cpp | 6 ++ wm/test/unittest/window_session_impl_test.cpp | 19 ++++++ 14 files changed, 189 insertions(+), 18 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 6e01b4bc8..3eeea6a75 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1665,6 +1665,17 @@ public: return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Set the modality of window. + * + * @param isModal bool. + * @return WMError + */ + virtual WMError SetSubWindowModal(bool isModal) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + /** * @brief recovery the main window by function overloading. It is called by JsWindow. * diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 3541cb340..4ef127f63 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -262,7 +262,8 @@ enum class WindowFlag : uint32_t { WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2, WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3, WINDOW_FLAG_WATER_MARK = 1 << 4, - WINDOW_FLAG_END = 1 << 5, + WINDOW_FLAG_IS_MODAL = 1 << 5, + WINDOW_FLAG_END = 1 << 6, }; /** diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index 2ad962124..23408e904 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -643,17 +643,11 @@ napi_value JsExtensionWindow::OnCreateSubWindowWithOptions(napi_env env, napi_ca return NapiGetUndefined(env); } WindowOption option; - std::string title; - if (!ParseJsValue(argv[1], env, "title", title)) { - napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); - return NapiGetUndefined(env); - } - bool decorEnabled; - if (!ParseJsValue(argv[1], env, "decorEnabled", decorEnabled)) { + if (!ParseSubWindowOptions(env, argv[1], option)) { + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Get invalid options param"); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); return NapiGetUndefined(env); } - option = SetOption(option, title, decorEnabled); NapiAsyncTask::CompleteCallback complete = [weak = extensionWindow_, windowName, option](napi_env env, NapiAsyncTask& task, int32_t status) { if (weak == nullptr) { @@ -691,13 +685,33 @@ void JsExtensionWindow::SetWindowOption(sptr windowOption) windowOption->SetExtensionTag(true); } -WindowOption JsExtensionWindow::SetOption(WindowOption option, std::string title, - bool decorEnabled) +bool JsExtensionWindow::ParseSubWindowOptions(napi_env env, napi_value jsObject, WindowOption& option) { + if (jsObject == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "jsObject is null"); + return false; + } + std::string title; + if (!ParseJsValue(jsObject, env, "title", title)) { + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to title"); + return false; + } + bool decorEnabled; + if (!ParseJsValue(jsObject, env, "decorEnabled", decorEnabled)) { + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to decorEnabled"); + return false; + } + bool isModal = false; + if (ParseJsValue(jsObject, env, "isModal", isModal)) { + TLOGI(WmsLogTag::WMS_UIEXT, "isModal:%{public}d", isModal); + if (isModal) { + option.AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_MODAL); + } + } option.SetSubWindowTitle(title); option.SetSubWindowDecorEnable(decorEnabled); option.SetParentId(hostWindowId_); - return option; + return true; } } // namespace Rosen } // namespace OHOS diff --git a/interfaces/kits/napi/extension_window/js_extension_window.h b/interfaces/kits/napi/extension_window/js_extension_window.h index 5cb9b7bad..f4e12ceea 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.h +++ b/interfaces/kits/napi/extension_window/js_extension_window.h @@ -69,7 +69,7 @@ private: sptr sessionInfo_ = nullptr; std::unique_ptr extensionRegisterManager_ = nullptr; static void SetWindowOption(sptr windowOption); - WindowOption SetOption(WindowOption option, std::string title, bool decorEnabled); + bool ParseSubWindowOptions(napi_env env, napi_value jsObject, WindowOption& option); }; } // namespace Rosen } // namespace OHOS diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 3c72ef10b..1f73912ae 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -714,6 +714,13 @@ napi_value JsWindow::SetWindowDecorVisible(napi_env env, napi_callback_info info return (me != nullptr) ? me->OnSetWindowDecorVisible(env, info) : nullptr; } +napi_value JsWindow::SetSubWindowModal(napi_env env, napi_callback_info info) +{ + TLOGI(WmsLogTag::WMS_DIALOG, "[NAPI]SetSubWindowModal"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetSubWindowModal(env, info) : nullptr; +} + napi_value JsWindow::SetWindowDecorHeight(napi_env env, napi_callback_info info) { WLOGI("[NAPI]SetWindowDecorHeight"); @@ -4974,6 +4981,61 @@ napi_value JsWindow::OnSetWindowDecorVisible(napi_env env, napi_callback_info in return NapiGetUndefined(env); } +napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) +{ + WmErrorCode errCode = WmErrorCode::WM_OK; + bool isModal = false; + size_t argc = 4; + napi_value argv[4] = { nullptr }; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc != 1 || argv[0] == nullptr) { // 1: the param num + errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; + } else { + CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM, napi_get_value_bool(env, argv[0], &isModal)); + } + + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [weakToken, isModal, errCode](napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCode != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_DIALOG, "invalid parameter"); + task.Reject(env, CreateJsError(env, static_cast(errCode), "invalid parameter.")); + return; + } + + WmErrorCode wmErrorCode; + auto window = weakToken.promote(); + if (window == nullptr) { + TLOGE(WmsLogTag::WMS_DIALOG, "window is nullptr"); + wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR); + task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "window is nullptr.")); + return; + } + + if (!WindowHelper::IsSubWindow(window->GetType())) { + TLOGE(WmsLogTag::WMS_DIALOG, "called by invalid window type, type:%{public}d", window->GetType()); + wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; + task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "invalid window type.")); + return; + } + WMError ret = window->SetSubWindowModal(isModal); + if (ret == WMError::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); + TLOGE(WmsLogTag::WMS_DIALOG, "Set subwindow modal failed, ret is %{public}d", wmErrorCode); + task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "Set subwindow modal failed")); + } + TLOGI(WmsLogTag::WMS_DIALOG, "id:%{public}u, name:%{public}s, isModal:%{public}d", + window->GetWindowId(), window->GetWindowName().c_str(), isModal); + }; + napi_value lastParam = nullptr; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::SetSubWindowModal", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} + napi_value JsWindow::OnSetWindowDecorHeight(napi_env env, napi_callback_info info) { size_t argc = 4; @@ -5142,6 +5204,7 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setSingleFrameComposerEnabled", moduleName, JsWindow::SetSingleFrameComposerEnabled); BindNativeFunction(env, object, "setWindowDecorVisible", moduleName, JsWindow::SetWindowDecorVisible); + BindNativeFunction(env, object, "setSubWindowModal", moduleName, JsWindow::SetSubWindowModal); BindNativeFunction(env, object, "setWindowDecorHeight", moduleName, JsWindow::SetWindowDecorHeight); BindNativeFunction(env, object, "getWindowDecorHeight", moduleName, JsWindow::GetWindowDecorHeight); BindNativeFunction(env, object, "getTitleButtonRect", moduleName, JsWindow::GetTitleButtonRect); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 2e1296997..bb520b466 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -137,6 +137,7 @@ public: static napi_value SetBackdropBlurStyle(napi_env env, napi_callback_info info); static napi_value SetWaterMarkFlag(napi_env env, napi_callback_info info); static napi_value SetWindowDecorVisible(napi_env env, napi_callback_info info); + static napi_value SetSubWindowModal(napi_env env, napi_callback_info info); static napi_value SetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetTitleButtonRect(napi_env env, napi_callback_info info); @@ -193,6 +194,7 @@ private: napi_value OnGetWindowLimits(napi_env env, napi_callback_info info); napi_value OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_info info); napi_value OnSetWindowDecorVisible(napi_env env, napi_callback_info info); + napi_value OnSetSubWindowModal(napi_env env, napi_callback_info info); napi_value OnSetWindowDecorHeight(napi_env env, napi_callback_info info); napi_value OnGetWindowDecorHeight(napi_env env, napi_callback_info info); napi_value OnGetTitleButtonRect(napi_env env, napi_callback_info info); diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index ea8694568..768348f91 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -652,6 +652,14 @@ bool JsWindowStage::ParseSubWindowOptions(napi_env env, napi_value jsObject, Win return false; } + bool isModal = false; + if (ParseJsValue(jsObject, env, "isModal", isModal)) { + TLOGI(WmsLogTag::WMS_DIALOG, "isModal:%{public}d", isModal); + if (isModal) { + option.AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_MODAL); + } + } + return true; } diff --git a/previewer/include/window.h b/previewer/include/window.h index 5d861addb..adbecb36d 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -288,6 +288,16 @@ public: { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Set the modality of window. + * + * @param isModal bool. + * @return WMError + */ + virtual WMError SetSubWindowModal(bool isModal) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } virtual WMError Recover(uint32_t reason = 0) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }; }; } diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index e859e6cb1..65650391a 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -242,7 +242,8 @@ enum class WindowFlag : uint32_t { WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2, WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3, WINDOW_FLAG_WATER_MARK = 1 << 4, - WINDOW_FLAG_END = 1 << 5, + WINDOW_FLAG_IS_MODAL = 1 << 5, + WINDOW_FLAG_END = 1 << 6, }; /** diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 47120de5b..fa60d45f6 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -244,7 +244,17 @@ std::map> SceneSessionDirtyManager::GetDialogSession for (const auto& elem: sessionMap) { const auto& session = elem.second; - if (session != nullptr && session->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) { + if (session == nullptr) { + continue; + } + bool isModalSubWindow = false; + auto property = session->GetSessionProperty(); + if (property != nullptr) { + bool isSubWindow = WindowHelper::IsSubWindow(property->GetWindowType()); + bool isModal = property->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_IS_MODAL); + isModalSubWindow = isSubWindow && isModal; + } + if (isModalSubWindow || session->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) { const auto& parentSession = session->GetParentSession(); if (parentSession == nullptr) { continue; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index d908dc70e..93b65cd97 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -184,6 +184,7 @@ public: WMError RegisterWindowStatusChangeListener(const sptr& listener) override; WMError UnregisterWindowStatusChangeListener(const sptr& listener) override; WMError SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) override; + virtual WMError SetSubWindowModal(bool isModal) override; virtual WMError SetDecorVisible(bool isVisible) override; virtual WMError SetDecorHeight(int32_t decorHeight) override; virtual WMError GetDecorHeight(int32_t& height) override; diff --git a/wm/src/window_input_channel.cpp b/wm/src/window_input_channel.cpp index 42ed2a16e..a447d519c 100644 --- a/wm/src/window_input_channel.cpp +++ b/wm/src/window_input_channel.cpp @@ -18,6 +18,7 @@ #include #endif // IMF_ENABLE #include "window_manager_hilog.h" +#include "window_helper.h" namespace OHOS { namespace Rosen { @@ -102,10 +103,14 @@ void WindowInputChannel::HandleKeyEvent(std::shared_ptr& keyEvent void WindowInputChannel::HandlePointerEvent(std::shared_ptr& pointerEvent) { if (pointerEvent == nullptr) { - WLOGFE("pointerEvent is nullptr"); + TLOGE(WmsLogTag::WMS_EVENT, "pointerEvent is nullptr"); return; } - WLOGFD("Receive pointer event, Id: %{public}u, action: %{public}d", + if (window_ == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "window_ is nullptr"); + return; + } + TLOGD(WmsLogTag::WMS_EVENT, "Receive pointer event, Id: %{public}u, action: %{public}d", window_->GetWindowId(), pointerEvent->GetPointerAction()); if ((window_->GetType() == WindowType::WINDOW_TYPE_DIALOG) && (pointerEvent->GetAgentWindowId() != pointerEvent->GetTargetWindowId())) { @@ -119,7 +124,27 @@ void WindowInputChannel::HandlePointerEvent(std::shared_ptr& pointerEvent->MarkProcessed(); return; } - WLOGFD("Dispatch move event, windowId: %{public}u, action: %{public}d", + + bool isModal = window_->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_IS_MODAL); + bool isSubWindow = WindowHelper::IsSubWindow(window_->GetType()); + if (isModal && isSubWindow) { + MMI::PointerEvent::PointerItem pointerItem; + bool validPointItem = pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); + bool outsideWindow = !WindowHelper::IsPointInTargetRectWithBound(pointerItem.GetDisplayX(), + pointerItem.GetDisplayY(), window_->GetRect()); + auto action = pointerEvent->GetPointerAction(); + bool isTargetAction = (action == MMI::PointerEvent::POINTER_ACTION_DOWN || + action == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN); + bool isInterceptAction = isTargetAction || action == MMI::PointerEvent::POINTER_ACTION_MOVE; + if (validPointItem && outsideWindow && isInterceptAction) { + if (isTargetAction) { + window_->NotifyTouchDialogTarget(pointerItem.GetDisplayX(), pointerItem.GetDisplayY()); + } + pointerEvent->MarkProcessed(); + return; + } + } + TLOGD(WmsLogTag::WMS_EVENT, "Dispatch move event, windowId: %{public}u, action: %{public}d", window_->GetWindowId(), pointerEvent->GetPointerAction()); window_->ConsumePointerEvent(pointerEvent); } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 63a454c81..4362a0c84 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1160,6 +1160,12 @@ WMError WindowSessionImpl::SetDecorVisible(bool isVisible) return WMError::WM_OK; } +WMError WindowSessionImpl::SetSubWindowModal(bool isModal) +{ + return isModal ? AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_MODAL) : + RemoveWindowFlag(WindowFlag::WINDOW_FLAG_IS_MODAL); +} + WMError WindowSessionImpl::SetDecorHeight(int32_t decorHeight) { if (uiContent_ == nullptr) { diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index cabf86841..31bc3c2c3 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -1586,6 +1586,25 @@ HWTEST_F(WindowSessionImplTest, SetDecorVisible, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "WindowSessionImplTest: SetDecorVisibletest01 end"; } +/** + * @tc.name: SetSubWindowModal + * @tc.desc: SetSubWindowModal and check the retCode + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, SetSubWindowModal, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetSubWindowModaltest01 start"; + sptr option = new WindowOption(); + ASSERT_NE(option, nullptr); + option->SetWindowName("SetSubWindowModal"); + sptr window = new (std::nothrow) WindowSessionImpl(option); + ASSERT_NE(window, nullptr); + bool isModal = true; + WMError res = window->SetSubWindowModal(isModal); + ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetSubWindowModaltest01 end"; +} + /** * @tc.name: SetDecorHeight * @tc.desc: SetDecorHeight and check the retCode -- Gitee From fcb8ca5fe5903c679e8441d238962aee9a1400d1 Mon Sep 17 00:00:00 2001 From: gazizova sofia Date: Fri, 22 Mar 2024 11:49:39 +0300 Subject: [PATCH 120/385] address review comment Signed-off-by: gazizova sofia Change-Id: Ie8cd32355070a1da3ff2dae80f1b208ca35b6381 --- window_scene/session_manager/src/screen_cutout_controller.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index 5eff5e219..ea059f1dd 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -28,9 +28,6 @@ constexpr std::vector::size_type BOTTOM = 3; constexpr uint8_t HALF_SCREEN = 2; constexpr uint8_t QUARTER_SCREEN = 4; constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "ScreenCutoutController" }; -constexpr int32_t Rotate90 = 90; -constexpr int32_t Rotate180 = 180; -constexpr int32_t Rotate270 = 270; template DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect); -- Gitee From f458d6af6b0b188cdfbdee8b089c7d51e0f46158 Mon Sep 17 00:00:00 2001 From: chehang Date: Fri, 22 Mar 2024 08:52:07 +0000 Subject: [PATCH 121/385] update errcode type Signed-off-by: chehang --- .../src/zidl/window_event_channel_stub.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp index 0583d3a70..c831ab354 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp @@ -81,7 +81,7 @@ int WindowEventChannelStub::HandleTransferBackpressedEvent(MessageParcel& data, WSError errCode = TransferBackpressedEventForConsumed(isConsumed); reply.WriteBool(isConsumed); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -101,7 +101,7 @@ int WindowEventChannelStub::HandleTransferKeyEvent(MessageParcel& data, MessageP WSError errCode = TransferKeyEventForConsumed(keyEvent, isConsumed); reply.WriteBool(isConsumed); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -118,7 +118,7 @@ int WindowEventChannelStub::HandleTransferPointerEvent(MessageParcel& data, Mess return ERR_INVALID_DATA; } WSError errCode = TransferPointerEvent(pointerEvent); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -126,7 +126,7 @@ int WindowEventChannelStub::HandleTransferFocusActiveEvent(MessageParcel& data, { bool isFocusActive = data.ReadBool(); WSError errCode = TransferFocusActiveEvent(isFocusActive); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -134,7 +134,7 @@ int WindowEventChannelStub::HandleTransferFocusStateEvent(MessageParcel& data, M { bool focusState = data.ReadBool(); WSError errCode = TransferFocusState(focusState); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -158,8 +158,8 @@ int WindowEventChannelStub::HandleTransferSearchElementInfo(MessageParcel& data, std::list infos; WSError errCode = TransferSearchElementInfo(elementId, mode, baseParent, infos); if (errCode != WSError::WS_OK) { - WLOGFE("Failed to TransferSearchElementInfo:%{public}d", static_cast(errCode)); - return static_cast(errCode); + WLOGFE("Failed to TransferSearchElementInfo:%{public}d", static_cast(errCode)); + return static_cast(errCode); } int64_t count = static_cast(infos.size()); if (!reply.WriteInt64(count)) { @@ -196,8 +196,8 @@ int WindowEventChannelStub::HandleTransferSearchElementInfosByText(MessageParcel std::list infos; WSError errCode = TransferSearchElementInfosByText(elementId, text, baseParent, infos); if (errCode != WSError::WS_OK) { - WLOGFE("Failed to HandleTransferSearchElementInfosByText:%{public}d", static_cast(errCode)); - return static_cast(errCode); + WLOGFE("Failed to HandleTransferSearchElementInfosByText:%{public}d", static_cast(errCode)); + return static_cast(errCode); } int64_t count = static_cast(infos.size()); if (!reply.WriteInt64(count)) { @@ -234,8 +234,8 @@ int WindowEventChannelStub::HandleTransferFindFocusedElementInfo(MessageParcel& Accessibility::AccessibilityElementInfo info; WSError errCode = TransferFindFocusedElementInfo(elementId, focusType, baseParent, info); if (errCode != WSError::WS_OK) { - WLOGFE("Failed to TransferFindFocusedElementInfo:%{public}d", static_cast(errCode)); - return static_cast(errCode); + WLOGFE("Failed to TransferFindFocusedElementInfo:%{public}d", static_cast(errCode)); + return static_cast(errCode); } Accessibility::AccessibilityElementInfoParcel infoParcel(info); if (!reply.WriteParcelable(&infoParcel)) { @@ -265,8 +265,8 @@ int WindowEventChannelStub::HandleTransferFocusMoveSearch(MessageParcel& data, M Accessibility::AccessibilityElementInfo info; WSError errCode = TransferFocusMoveSearch(elementId, direction, baseParent, info); if (errCode != WSError::WS_OK) { - WLOGFE("Failed to TransferFocusMoveSearch:%{public}d", static_cast(errCode)); - return static_cast(errCode); + WLOGFE("Failed to TransferFocusMoveSearch:%{public}d", static_cast(errCode)); + return static_cast(errCode); } Accessibility::AccessibilityElementInfoParcel infoParcel(info); if (!reply.WriteParcelable(&infoParcel)) { @@ -316,7 +316,7 @@ int WindowEventChannelStub::HandleTransferExecuteAction(MessageParcel& data, Mes return ERR_INVALID_DATA; } WSError errCode = TransferExecuteAction(elementId, actionArguments, action, baseParent); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -336,7 +336,7 @@ int WindowEventChannelStub::HandleTransferAccessibilityHoverEvent(MessageParcel& return ERR_INVALID_DATA; }; WSError errCode = TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } } -- Gitee From 9436016bebfc4b5dcedb6a3169e8c5fffcfc2d8e Mon Sep 17 00:00:00 2001 From: zhangzhicong Date: Fri, 22 Mar 2024 17:22:31 +0800 Subject: [PATCH 122/385] add getPreferredOrientation Signed-off-by: zhangzhicong --- .../extension_window/js_extension_window.cpp | 10 ++++++- .../extension_window/js_extension_window.h | 1 + .../window_runtime/window_napi/js_window.cpp | 29 +++++++++++++++++++ .../window_runtime/window_napi/js_window.h | 1 + .../window_napi/js_window_utils.h | 15 ++++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index e6ac27f11..03ec97c3a 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -119,7 +119,8 @@ napi_value JsExtensionWindow::CreateJsExtensionWindowObject(napi_env env, sptrOnSetPreferredOrientation(env, info) : nullptr; } +napi_value JsExtensionWindow::GetPreferredOrientation(napi_env env, napi_callback_info info) +{ + WLOGD("GetPreferredOrientation"); + JsExtensionWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetPreferredOrientation(env, info) : nullptr; +} + napi_value JsExtensionWindow::GetUIContext(napi_env env, napi_callback_info info) { WLOGD("GetUIContext"); diff --git a/interfaces/kits/napi/extension_window/js_extension_window.h b/interfaces/kits/napi/extension_window/js_extension_window.h index b404e2d19..91af0d8d6 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.h +++ b/interfaces/kits/napi/extension_window/js_extension_window.h @@ -53,6 +53,7 @@ public: static napi_value ResizeWindow(napi_env env, napi_callback_info info); static napi_value SetSpecificSystemBarEnabled(napi_env env, napi_callback_info info); static napi_value SetPreferredOrientation(napi_env env, napi_callback_info info); + static napi_value GetPreferredOrientation(napi_env env, napi_callback_info info); static napi_value GetUIContext(napi_env env, napi_callback_info info); static napi_value SetWindowBrightness(napi_env env, napi_callback_info info); static napi_value SetWindowKeepScreenOn(napi_env env, napi_callback_info info); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index e8f2ce549..345085135 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -519,6 +519,13 @@ napi_value JsWindow::SetPreferredOrientation(napi_env env, napi_callback_info in return (me != nullptr) ? me->OnSetPreferredOrientation(env, info) : nullptr; } +napi_value JsWindow::GetPreferredOrientation(napi_env env, napi_callback_info info) +{ + WLOGD("GetPreferredOrientation"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetPreferredOrientation(env, info) : nullptr; +} + napi_value JsWindow::SetSnapshotSkip(napi_env env, napi_callback_info info) { WLOGI("SetSnapshotSkip"); @@ -2554,6 +2561,27 @@ napi_value JsWindow::OnSetPreferredOrientation(napi_env env, napi_callback_info return result; } +napi_value JsWindow::OnGetPreferredOrientation(napi_env env, napi_callback_info info) +{ + WmErrorCode errCode = WmErrorCode::WM_OK; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc >= 1) { + WLOGFE("Argc is invalid: %{public}zu, expect zero params", argc); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + wptr weakToken(windowToken_); + auto window = weakToken.promote(); + if (window == nullptr) { + WLOGFE("window is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + Orientation requestedOrientation = weakWindow->GetRequestedOrientation(); + napi_value result = nullptr; + return result; +} + napi_value JsWindow::OnIsSupportWideGamut(napi_env env, napi_callback_info info) { WMError errCode = WMError::WM_OK; @@ -5208,6 +5236,7 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "dump", moduleName, JsWindow::Dump); BindNativeFunction(env, object, "setForbidSplitMove", moduleName, JsWindow::SetForbidSplitMove); BindNativeFunction(env, object, "setPreferredOrientation", moduleName, JsWindow::SetPreferredOrientation); + BindNativeFunction(env, object, "getPreferredOrientation", moduleName, JsWindow::GetPreferredOrientation); BindNativeFunction(env, object, "opacity", moduleName, JsWindow::Opacity); BindNativeFunction(env, object, "scale", moduleName, JsWindow::Scale); BindNativeFunction(env, object, "rotate", moduleName, JsWindow::Rotate); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 536868632..90bde9376 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -99,6 +99,7 @@ public: static napi_value SetTransparent(napi_env env, napi_callback_info info); static napi_value SetCallingWindow(napi_env env, napi_callback_info info); static napi_value SetPreferredOrientation(napi_env env, napi_callback_info info); + static napi_value GetPreferredOrientation(napi_env env, napi_callback_info info); static napi_value DisableWindowDecor(napi_env env, napi_callback_info info); static napi_value SetSnapshotSkip(napi_env env, napi_callback_info info); static napi_value RaiseToAppTop(napi_env env, napi_callback_info info); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 5f683bbb5..6953b3a5b 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -182,6 +182,21 @@ const std::map JS_TO_NATIVE_ORIENTATION_MAP { {ApiOrientation::LOCKED, Orientation::LOCKED }, }; +const std::map NATIVE_TO_JS_ORIENTATION_MAP { + {Orientation::UNSPECIFIED, ApiOrientation::UNSPECIFIED }, + {Orientation::VERTICAL, ApiOrientation::PORTRAIT }, + {Orientation::HORIZONTAL, ApiOrientation::LANDSCAPE }, + {Orientation::REVERSE_VERTICAL, ApiOrientation::PORTRAIT_INVERTED }, + {Orientation::REVERSE_HORIZONTAL, ApiOrientation::LANDSCAPE_INVERTED }, + {Orientation::SENSOR, ApiOrientation::AUTO_ROTATION }, + {Orientation::SENSOR_VERTICAL, ApiOrientation::AUTO_ROTATION_PORTRAIT }, + {Orientation::SENSOR_HORIZONTAL, ApiOrientation::AUTO_ROTATION_LANDSCAPE }, + {Orientation::AUTO_ROTATION_RESTRICTED, ApiOrientation::AUTO_ROTATION_RESTRICTED }, + {Orientation::AUTO_ROTATION_PORTRAIT_RESTRICTED, ApiOrientation::AUTO_ROTATION_PORTRAIT_RESTRICTED }, + {Orientation::AUTO_ROTATION_LANDSCAPE_RESTRICTED, ApiOrientation::AUTO_ROTATION_LANDSCAPE_RESTRICTED }, + {Orientation::LOCKED, ApiOrientation::LOCKED }, +}; + struct SystemBarPropertyFlag { bool enableFlag; bool backgroundColorFlag; -- Gitee From 7fc96263652867d6d50d34aac985dcc155c1a97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 11:30:17 +0000 Subject: [PATCH 123/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../js_scene_session_manager.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 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 5a66b0d5b..e9f55c886 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 @@ -1932,7 +1932,7 @@ napi_value JsSceneSessionManager::OnNotifyAINavigationBarShowStatus(napi_env env size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc < ARGC_TWO) { + if (argc < ARGC_THREE) { WLOGFE("[NAPI]Argc is invalid: %{public}zu", argc); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); @@ -1952,7 +1952,14 @@ napi_value JsSceneSessionManager::OnNotifyAINavigationBarShowStatus(napi_env env "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - SceneSessionManager::GetInstance().NotifyAINavigationBarShowStatus(isVisible, barArea); + int32_t displayId = -1; + if (!ConvertFromJsValue(env, argv[2], displayId)) { + WLOGFE("[NAPI]Failed to convert parameter to displayId"); + napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), + "Input parameter is missing or invalid")); + return NapiGetUndefined(env); + } + SceneSessionManager::GetInstance().NotifyAINavigationBarShowStatus(isVisible, barArea, displayId); return NapiGetUndefined(env); } -- Gitee From b22a34ecbecac48c1385f2b8205790ab729587aa Mon Sep 17 00:00:00 2001 From: w00574628 Date: Fri, 22 Mar 2024 15:02:32 +0800 Subject: [PATCH 124/385] add update calling window id and position when calling window id changed Signed-off-by: wulehui --- .../session/host/include/scene_session.h | 4 ++ .../include/scene_session_manager.h | 5 +- .../src/scene_session_manager.cpp | 65 ++++++++++++++----- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index ec4dda36b..4df98a975 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -240,6 +240,10 @@ public: static MaximizeMode maximizeMode_; static std::map windowDragHotAreaMap_; + WSRect callingWindowRestoringRect_ = {0, 0, 0, 0}; + WSRect callingWindowNewRect_ = {0, 0, 0, 0}; + bool needUpdateSessionRect_ = false; + protected: void NotifyIsCustomAnimationPlaying(bool isPlaying); void SetMoveDragCallback(); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 39c8016b0..177e0358d 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -349,6 +349,8 @@ private: void RegisterRequestFocusStatusNotifyManagerFunc(sptr& sceneSession); void RegisterGetStateFromManagerFunc(sptr& sceneSession); + void UpdateCallingWindowIdAndPosition(const sptr& property, + const sptr& sceneSession); void RelayoutKeyBoard(sptr sceneSession); void RestoreCallingSessionSizeIfNeed(); void ResizeSoftInputCallingSessionIfNeed(const sptr& sceneSession, bool isInputUpdated = false); @@ -478,9 +480,6 @@ private: bool needBlockNotifyUnfocusStatus_ {false}; bool isScreenLocked_ {false}; bool isPrepareTerminateEnable_ {false}; - WSRect callingWindowRestoringRect_ = {0, 0, 0, 0}; - WSRect callingWindowNewRect_ = {0, 0, 0, 0}; - bool needUpdateSessionRect_ = false; bool openDebugTrace {false}; int32_t currentUserId_; std::atomic enableInputEvent_ = true; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c33e948d1..c7d0c702e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2779,12 +2779,7 @@ WMError SceneSessionManager::HandleUpdateProperty(const sptrGetSessionProperty() != nullptr) { - sceneSession->GetSessionProperty()->SetCallingWindow(property->GetCallingWindow()); - } - if (callingWindowIdChangeFunc_ != nullptr) { - callingWindowIdChangeFunc_(property->GetCallingWindow()); - } + UpdateCallingWindowIdAndPosition(property, sceneSession); break; } case WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE: { @@ -5288,7 +5283,7 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( const WSRect& softInputSessionRect = sceneSession->GetSessionRect(); WSRect callingSessionRect; if (isInputUpdated && isCallingSessionFloating) { - callingSessionRect = callingWindowRestoringRect_; + callingSessionRect = callingSession_->callingWindowRestoringRect_; } else { callingSessionRect = callingSession_->GetSessionRect(); } @@ -5308,13 +5303,13 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( } if (!isInputUpdated) { - callingWindowRestoringRect_ = callingSessionRect; + callingSession_->callingWindowRestoringRect_ = callingSessionRect; } NotifyOccupiedAreaChangeInfo(sceneSession, newRect, softInputSessionRect); if (isCallingSessionFloating && callingSessionRect.posY_ > statusHeight) { - needUpdateSessionRect_ = true; + callingSession_->needUpdateSessionRect_ = true; callingSession_->UpdateSessionRect(newRect, SizeChangeReason::UNDEFINED); - callingWindowNewRect_ = callingSession_->GetSessionRect(); + callingSession_->callingWindowNewRect_ = callingSession_->GetSessionRect(); } } @@ -5345,16 +5340,18 @@ void SceneSessionManager::RestoreCallingSessionSizeIfNeed() } WSRect overlapRect = { 0, 0, 0, 0 }; - NotifyOccupiedAreaChangeInfo(callingSession_, callingWindowRestoringRect_, overlapRect); - if (!SessionHelper::IsEmptyRect(callingWindowRestoringRect_)) { - if (needUpdateSessionRect_ && callingSession_->GetSessionProperty() && + NotifyOccupiedAreaChangeInfo(callingSession_, callingSession_->callingWindowRestoringRect_, overlapRect); + if (!SessionHelper::IsEmptyRect(callingSession_->callingWindowRestoringRect_)) { + if (callingSession_->needUpdateSessionRect_ && callingSession_->GetSessionProperty() && callingSession_->GetSessionProperty()->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING && - callingSession_->GetSessionRect() == callingWindowNewRect_) { - callingSession_->UpdateSessionRect(callingWindowRestoringRect_, SizeChangeReason::UNDEFINED); + callingSession_->GetSessionRect() == callingSession_->callingWindowNewRect_) { + callingSession_->UpdateSessionRect(callingSession_->callingWindowRestoringRect_, + SizeChangeReason::UNDEFINED); } } - needUpdateSessionRect_ = false; - callingWindowRestoringRect_ = { 0, 0, 0, 0 }; + callingSession_->needUpdateSessionRect_ = false; + callingSession_->callingWindowRestoringRect_ = { 0, 0, 0, 0 }; + callingSession_->callingWindowNewRect_ = {0, 0, 0, 0}; } WSError SceneSessionManager::SetSessionGravity(int32_t persistentId, SessionGravity gravity, uint32_t percent) @@ -5435,6 +5432,40 @@ void SceneSessionManager::RelayoutKeyBoard(sptr sceneSession) sceneSession->UpdateSessionRect(SessionHelper::TransferToWSRect(requestRect), SizeChangeReason::UNDEFINED); } +void SceneSessionManager::UpdateCallingWindowIdAndPosition(const sptr& property, + const sptr& sceneSession) +{ + if (sceneSession->GetSessionProperty() == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Failed to update calling window id: %{public}d", property->GetCallingWindow()); + return; + } + uint32_t curWindowId = sceneSession->GetSessionProperty()->GetCallingWindow(); + uint32_t newWindowId = property->GetCallingWindow(); + TLOGI(WmsLogTag::WMS_KEYBOARD, "CallingWindow curId: %{public}d, newId: %{public}d", curWindowId, newWindowId); + // When calling window id changes, restore the old calling window, raise the new calling window. + if (curWindowId != INVALID_WINDOW_ID && newWindowId != curWindowId && callingSession_ != nullptr) { + RestoreCallingSessionSizeIfNeed(); + + callingSession_ = GetSceneSession(newWindowId); + if (callingSession_ == nullptr) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "Using focusedSession id: %{public}d", focusedSessionId_); + callingSession_ = GetSceneSession(focusedSessionId_); + if (callingSession_ == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Calling window id invalid,Calling session is null"); + return; + } else { + newWindowId = focusedSessionId_; + } + } + ResizeSoftInputCallingSessionIfNeed(sceneSession); + } + sceneSession->GetSessionProperty()->SetCallingWindow(newWindowId); + + if (callingWindowIdChangeFunc_ != nullptr) { + callingWindowIdChangeFunc_(newWindowId); + } +} + void SceneSessionManager::InitPersistentStorage() { if (ScenePersistentStorage::HasKey("maximize_state", ScenePersistentStorageType::MAXIMIZE_STATE)) { -- Gitee From b91eb8ed96d7f3b466700843d68cf31cce80dbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 11:34:52 +0000 Subject: [PATCH 125/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session/host/include/scene_session.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 31812366d..186eaba43 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -34,12 +34,13 @@ using SpecificSessionCreateCallback = std::function(const SessionInfo& info, sptr property)>; using SpecificSessionDestroyCallback = std::function; using CameraFloatSessionChangeCallback = std::function; -using GetSceneSessionVectorByTypeCallback = std::function>(WindowType type)>; +using GetSceneSessionVectorByTypeCallback = std::function>( + WindowType type, uint64_t displayId)>; using UpdateAvoidAreaCallback = std::function; using NotifyWindowInfoUpdateCallback = std::function; using NotifyWindowPidChangeCallback = std::function; using NotifySessionTouchOutsideCallback = std::function; -using GetAINavigationBarArea = std::function; +using GetAINavigationBarArea = std::function; using RecoveryCallback = std::function; using NotifyBindDialogSessionFunc = std::function& session)>; using NotifySessionRectChangeFunc = std::function; -- Gitee From c5b98ce3199c5976f296002de893217b4c9f8a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 11:50:12 +0000 Subject: [PATCH 126/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../session/host/src/scene_session.cpp | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1fd834691..2d24f6b77 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -40,6 +40,7 @@ #include "wm_math.h" #include #include "singleton_container.h" +#include "screen_session_manager/include/screen_session_manager_client.h" namespace OHOS::Rosen { namespace { @@ -760,12 +761,15 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) if (GetSessionProperty()->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_NEED_AVOID)) { return; } + uint64_t displayId = GetSessionProperty()->GetDisplayId(); + auto screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession(displayId); if ((Session::GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING || Session::GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || Session::GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) && WindowHelper::IsMainWindow(Session::GetWindowType()) && (system::GetParameter("const.product.devicetype", "unknown") == "phone" || - system::GetParameter("const.product.devicetype", "unknown") == "tablet")) { + system::GetParameter("const.product.devicetype", "unknown") == "tablet") && + (!screenSession || screenSession->GetName() != "HiCar")) { float miniScale = 0.316f; // Pressed mini floating Scale with 0.001 precision if (Session::GetFloatingScale() <= miniScale) { return; @@ -780,8 +784,8 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) avoidArea.topRect_.width_ = display->GetWidth(); return; } - std::vector> statusBarVector = - specificCallback_->onGetSceneSessionVectorByType_(WindowType::WINDOW_TYPE_STATUS_BAR); + std::vector> statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( + WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); for (auto& statusBar : statusBarVector) { if (!(statusBar->isVisible_)) { continue; @@ -803,8 +807,12 @@ void SceneSession::GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea) system::GetParameter("const.product.devicetype", "unknown") == "tablet")) { return; } - std::vector> inputMethodVector = - specificCallback_->onGetSceneSessionVectorByType_(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); + if (!GetSessionProperty()) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to get session property"); + return; + } + std::vector> inputMethodVector = specificCallback_->onGetSceneSessionVectorByType_( + WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, GetSessionProperty()->GetDisplayId()); for (auto& inputMethod : inputMethodVector) { if (inputMethod->GetSessionState() != SessionState::STATE_FOREGROUND && inputMethod->GetSessionState() != SessionState::STATE_ACTIVE) { @@ -859,7 +867,11 @@ void SceneSession::GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea) Session::GetWindowMode() == WindowMode::WINDOW_MODE_PIP) { return; } - WSRect barArea = specificCallback_->onGetAINavigationBarArea_(); + if (!GetSessionProperty()) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to get session property"); + return; + } + WSRect barArea = specificCallback_->onGetAINavigationBarArea_(GetSessionProperty()->GetDisplayId()); CalculateAvoidAreaRect(rect, barArea, avoidArea); } @@ -1359,9 +1371,13 @@ void SceneSession::UpdateWinRectForSystemBar(WSRect& rect) WLOGFE("specificCallback_ is null!"); return; } + if (!GetSessionProperty()) { + WLOGFE("get session property is null!"); + return; + } float tmpPosY = 0.0; - std::vector> statusBarVector = - specificCallback_->onGetSceneSessionVectorByType_(WindowType::WINDOW_TYPE_STATUS_BAR); + std::vector> statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( + WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); for (auto& statusBar : statusBarVector) { if (!(statusBar->isVisible_)) { continue; -- Gitee From c63558a5cdabe5b9b9438c4c96253f0bf712478e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 11:55:18 +0000 Subject: [PATCH 127/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../session_manager/include/scene_session_manager.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index f56fcd843..cfe731a5f 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -262,8 +262,8 @@ public: WSError UpdateSessionDisplayId(int32_t persistentId, uint64_t screenId); void NotifySessionUpdate(const SessionInfo& sessionInfo, ActionType type, ScreenId fromScreenId = SCREEN_ID_INVALID); - WSError NotifyAINavigationBarShowStatus(bool isVisible, WSRect barArea); - WSRect GetAINavigationBarArea(); + WSError NotifyAINavigationBarShowStatus(bool isVisible, WSRect barArea, uint64_t displayId); + WSRect GetAINavigationBarArea(uint64_t displayId); bool UpdateImmersiveState(); WMError GetSurfaceNodeIdsFromMissionIds(std::vector& missionIds, std::vector& surfaceNodeIds); @@ -356,14 +356,14 @@ private: WSError UpdateParentSessionForDialog(const sptr& sceneSession, sptr property); void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); void UpdateFocusableProperty(int32_t persistentId); - std::vector> GetSceneSessionVectorByType(WindowType type); + std::vector> GetSceneSessionVectorByType(WindowType type, uint64_t displayId); bool UpdateSessionAvoidAreaIfNeed(const int32_t& persistentId, const sptr& sceneSession, const AvoidArea& avoidArea, AvoidAreaType avoidAreaType); void UpdateAvoidSessionAvoidArea(WindowType type, bool& needUpdate); void UpdateNormalSessionAvoidArea(const int32_t& persistentId, sptr& sceneSession, bool& needUpdate); void UpdateAvoidArea(const int32_t& persistentId); void NotifyMMIWindowPidChange(int32_t windowId, bool startMoving); - int32_t GetStatusBarHeight(); + int32_t GetStatusBarHeight(uint64_t displayId); sptr GetBundleManager(); std::shared_ptr GetResourceManager(const AppExecFwk::AbilityInfo& abilityInfo); @@ -488,7 +488,7 @@ private: sptr appAnrListener_; bool isAINavigationBarVisible_ = false; - WSRect currAINavigationBarArea_; + std::map currAINavigationBarAreaMap_; std::shared_ptr eventLoop_; std::shared_ptr eventHandler_; -- Gitee From 0a07c30edcc2364933a8726fd67e812af1044aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 11:59:03 +0000 Subject: [PATCH 128/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session_manager/include/screen_scene_config.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/include/screen_scene_config.h b/window_scene/session_manager/include/screen_scene_config.h index e8c19cf3d..17b37b60f 100644 --- a/window_scene/session_manager/include/screen_scene_config.h +++ b/window_scene/session_manager/include/screen_scene_config.h @@ -34,8 +34,8 @@ public: static const std::map>& GetIntNumbersConfig(); static const std::map& GetStringConfig(); static void DumpConfig(); - static std::vector GetCutoutBoundaryRect(); - static void SetCutoutSvgPath(const std::string& svgPath); + static std::vector GetCutoutBoundaryRect(uint64_t displayId); + static void SetCutoutSvgPath(uint64_t displayId, const std::string& svgPath); static bool IsWaterfallDisplay(); static void SetCurvedCompressionAreaInLandscape(); static std::vector GetCurvedScreenBoundaryConfig(); @@ -45,7 +45,7 @@ private: static std::map enableConfig_; static std::map> intNumbersConfig_; static std::map stringConfig_; - static std::vector cutoutBoundaryRect_; + static std::map> cutoutBoundaryRectMap_; static bool isWaterfallDisplay_; static bool isScreenCompressionEnableInLandscape_; static uint32_t curvedAreaInLandscape_; -- Gitee From c0435f5c4d2645613dfe21e11a8c74f3adaf7faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 12:15:57 +0000 Subject: [PATCH 129/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../src/scene_session_manager.cpp | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 738a05aa7..eefe03a76 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -859,13 +859,16 @@ sptr SceneSessionManager::GetSceneSessionByName(const std::string& return nullptr; } -std::vector> SceneSessionManager::GetSceneSessionVectorByType(WindowType type) +std::vector> SceneSessionManager::GetSceneSessionVectorByType( + WindowType type, uint64_t displayId) { std::vector> sceneSessionVector; std::shared_lock lock(sceneSessionMapMutex_); for (const auto &item : sceneSessionMap_) { auto sceneSession = item.second; - if (sceneSession->GetWindowType() == type) { + if (sceneSession->GetWindowType() == type && + sceneSession->GetSessionProperty() && + sceneSession->GetSessionProperty()->GetDisplayId == displayId) { sceneSessionVector.emplace_back(sceneSession); } } @@ -914,7 +917,7 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onCameraFloatSessionChange_ = std::bind(&SceneSessionManager::UpdateCameraFloatWindowStatus, this, std::placeholders::_1, std::placeholders::_2); specificCb->onGetSceneSessionVectorByType_ = std::bind(&SceneSessionManager::GetSceneSessionVectorByType, - this, std::placeholders::_1); + this, std::placeholders::_1, std::placeholders::_2); specificCb->onUpdateAvoidArea_ = std::bind(&SceneSessionManager::UpdateAvoidArea, this, std::placeholders::_1); specificCb->onWindowInfoUpdate_ = std::bind(&SceneSessionManager::NotifyWindowInfoChange, this, std::placeholders::_1, std::placeholders::_2); @@ -922,7 +925,8 @@ sptr SceneSessionManager::CreateSpecificS this, std::placeholders::_1, std::placeholders::_2); specificCb->onSessionTouchOutside_ = std::bind(&SceneSessionManager::NotifySessionTouchOutside, this, std::placeholders::_1); - specificCb->onGetAINavigationBarArea_ = std::bind(&SceneSessionManager::GetAINavigationBarArea, this); + specificCb->onGetAINavigationBarArea_ = std::bind(&SceneSessionManager::GetAINavigationBarArea, + this, std::placeholders::_1); specificCb->onOutsideDownEvent_ = std::bind(&SceneSessionManager::OnOutsideDownEvent, this, std::placeholders::_1, std::placeholders::_2); specificCb->onHandleSecureSessionShouldHide_ = std::bind(&SceneSessionManager::HandleSecureSessionShouldHide, @@ -5237,11 +5241,12 @@ void SceneSessionManager::StartWindowInfoReportLoop() isReportTaskStart_ = true; } -int32_t SceneSessionManager::GetStatusBarHeight() +int32_t SceneSessionManager::GetStatusBarHeight(uint64_t displayId) { int32_t statusBarHeight = 0; int32_t height = 0; - std::vector> statusBarVector = GetSceneSessionVectorByType(WindowType::WINDOW_TYPE_STATUS_BAR); + std::vector> statusBarVector = GetSceneSessionVectorByType( + WindowType::WINDOW_TYPE_STATUS_BAR, displayId); for (auto& statusBar : statusBarVector) { if (statusBar == nullptr || !IsSessionVisible(statusBar)) { continue; @@ -5260,6 +5265,10 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( TLOGI(WmsLogTag::WMS_KEYBOARD, "calling session is nullptr"); return; } + if (!sceneSession->GetSessionProperty()) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "scene session property is nullptr"); + return; + } SessionGravity gravity; uint32_t percent = 0; sceneSession->GetSessionProperty()->GetSessionGravity(gravity, percent); @@ -5291,7 +5300,7 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( } WSRect newRect = callingSessionRect; - int32_t statusHeight = GetStatusBarHeight(); + int32_t statusHeight = GetStatusBarHeight(sceneSession->GetSessionProperty()->GetDisplayId()); if (isCallingSessionFloating && callingSessionRect.posY_ > statusHeight) { // calculate new rect of calling window newRect.posY_ = softInputSessionRect.posY_ - static_cast(newRect.height_); @@ -6157,17 +6166,19 @@ void SceneSessionManager::UpdateAvoidArea(const int32_t& persistentId) return; } -WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSRect barArea) +WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSRect barArea, uint64_t displayId) { - WLOGFI("NotifyAINavigationBarShowStatus: isVisible: %{public}u, area{%{public}d,%{public}d,%{public}d,%{public}d}", - isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_); - auto task = [this, isVisible, barArea]() { - if (isAINavigationBarVisible_ != isVisible || currAINavigationBarArea_ != barArea) { + WLOGFI("NotifyAINavigationBarShowStatus: isVisible: %{public}u, " \ + "area{%{public}d,%{public}d,%{public}d,%{public}d}, displayId: %{public}" PRIu64"", + isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_, displayId); + auto task = [this, isVisible, barArea, displayId]() { + if (isAINavigationBarVisible_ != isVisible || currAINavigationBarAreaMap_[displayId] != barArea) { isAINavigationBarVisible_ = isVisible; - currAINavigationBarArea_ = barArea; + currAINavigationBarAreaMap_.clear(); + currAINavigationBarAreaMap_[displayId] = barArea; if (!isVisible && !barArea.IsEmpty()) { WLOGFD("NotifyAINavigationBarShowStatus: barArea should be empty if invisible"); - currAINavigationBarArea_ = WSRect(); + currAINavigationBarAreaMap_[displayId] = WSRect(); } WLOGFI("NotifyAINavigationBarShowStatus: enter: %{public}u, {%{public}d,%{public}d,%{public}d,%{public}d}", isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_); @@ -6194,9 +6205,12 @@ WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSR return WSError::WS_OK; } -WSRect SceneSessionManager::GetAINavigationBarArea() +WSRect SceneSessionManager::GetAINavigationBarArea(uint64_t displayId) { - return currAINavigationBarArea_; + if (currAINavigationBarAreaMap_.count(displayId) < 1) { + return {}; + } + return currAINavigationBarAreaMap_[displayId]; } WSError SceneSessionManager::UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener) -- Gitee From 51626a3573e37acf41ab61100cbdf5dec2f47df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 12:17:15 +0000 Subject: [PATCH 130/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session_manager/src/screen_cutout_controller.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index ca36ab836..01d9fcc87 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -37,7 +37,7 @@ sptr ScreenCutoutController::GetScreenCutoutInfo(DisplayId displayId { WLOGFD("get screen cutout info."); std::vector boundaryRects; - if (!ScreenSceneConfig::GetCutoutBoundaryRect().empty()) { + if (!ScreenSceneConfig::GetCutoutBoundaryRect(displayId).empty()) { ConvertBoundaryRectsByRotation(boundaryRects, displayId); } @@ -62,7 +62,7 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& (ScreenSessionManager::GetInstance().GetFoldStatus() == FoldStatus::FOLDED)) { displayBoundaryRects = {{ 507, 18, 66, 66}}; // x:507, y:18, w:66, h:66 } else { - displayBoundaryRects = ScreenSceneConfig::GetCutoutBoundaryRect(); + displayBoundaryRects = ScreenSceneConfig::GetCutoutBoundaryRect(displayId); } CheckBoundaryRects(displayBoundaryRects, displayInfo); if (currentRotation == Rotation::ROTATION_0) { -- Gitee From cc4fa36becbea8ca2cae3597458d1c95034122d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 12:22:04 +0000 Subject: [PATCH 131/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../session_manager/src/screen_scene_config.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/screen_scene_config.cpp b/window_scene/session_manager/src/screen_scene_config.cpp index 9d707dcd3..1d96aca67 100644 --- a/window_scene/session_manager/src/screen_scene_config.cpp +++ b/window_scene/session_manager/src/screen_scene_config.cpp @@ -44,7 +44,7 @@ constexpr uint32_t NO_WATERFALL_DISPLAY_COMPRESSION_SIZE = 0; std::map ScreenSceneConfig::enableConfig_; std::map> ScreenSceneConfig::intNumbersConfig_; std::map ScreenSceneConfig::stringConfig_; -std::vector ScreenSceneConfig::cutoutBoundaryRect_; +std::vector ScreenSceneConfig::cutoutBoundaryRectMap_; bool ScreenSceneConfig::isWaterfallDisplay_ = false; bool ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false; uint32_t ScreenSceneConfig::curvedAreaInLandscape_ = 0; @@ -245,10 +245,10 @@ void ScreenSceneConfig::DumpConfig() } } -void ScreenSceneConfig::SetCutoutSvgPath(const std::string& svgPath) +void ScreenSceneConfig::SetCutoutSvgPath(uint64_t displayId, const std::string& svgPath) { - cutoutBoundaryRect_.clear(); - cutoutBoundaryRect_.emplace_back(CalcCutoutBoundaryRect(svgPath)); + cutoutBoundaryRectMap_.clear(); + cutoutBoundaryRectMap_[displayId].emplace_back(CalcCutoutBoundaryRect(svgPath)); } DMRect ScreenSceneConfig::CalcCutoutBoundaryRect(std::string svgPath) @@ -284,9 +284,12 @@ DMRect ScreenSceneConfig::CalcCutoutBoundaryRect(std::string svgPath) return cutoutMinOuterRect; } -std::vector ScreenSceneConfig::GetCutoutBoundaryRect() +std::vector ScreenSceneConfig::GetCutoutBoundaryRect(uint64_t displayId) { - return cutoutBoundaryRect_; + if (cutoutBoundaryRectMap_.count(displayId) < 1) { + return {}; + } + return cutoutBoundaryRectMap_[displayId]; } bool ScreenSceneConfig::IsWaterfallDisplay() -- Gitee From 7e93cfe2ee03f4c8df891246d1a06b1c8330fd6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 12:23:15 +0000 Subject: [PATCH 132/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session_manager/src/screen_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 0fa1386bf..1785df9be 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -261,7 +261,7 @@ void ScreenSessionManager::ConfigureScreenScene() if (stringConfig.count("defaultDisplayCutoutPath") != 0) { std::string defaultDisplayCutoutPath = static_cast(stringConfig["defaultDisplayCutoutPath"]); WLOGFD("defaultDisplayCutoutPath = %{public}s.", defaultDisplayCutoutPath.c_str()); - ScreenSceneConfig::SetCutoutSvgPath(defaultDisplayCutoutPath); + ScreenSceneConfig::SetCutoutSvgPath(GetDefaultScreenId(), defaultDisplayCutoutPath); } ConfigureWaterfallDisplayCompressionParams(); -- Gitee From ab66e90ff9059586754adf948a040ebb0c81af86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 12:24:48 +0000 Subject: [PATCH 133/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/test/unittest/scene_session_manager_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 706aafd5a..5325fb413 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -1785,7 +1785,8 @@ HWTEST_F(SceneSessionManagerTest, GetSceneSessionByName, Function | SmallTest | HWTEST_F(SceneSessionManagerTest, GetSceneSessionVectorByType, Function | SmallTest | Level3) { int ret = 0; - ssm_->GetSceneSessionVectorByType(WindowType::APP_MAIN_WINDOW_BASE); + uint64_t displayId = 0; + ssm_->GetSceneSessionVectorByType(WindowType::APP_MAIN_WINDOW_BASE, displayId); ASSERT_EQ(ret, 0); } -- Gitee From 844c76068734fc0aa6cf8497b4fdc531c9160f9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 12:26:18 +0000 Subject: [PATCH 134/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/test/unittest/scene_session_test.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index e10a701f1..2dc6dbe2f 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -755,7 +755,8 @@ HWTEST_F(SceneSessionTest, GetKeyboardAvoidArea, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - specificCallback_->onGetSceneSessionVectorByType_ = [](WindowType type) -> std::vector> { + specificCallback_->onGetSceneSessionVectorByType_ = [](WindowType type, + uint64_t displayId) -> std::vector> { std::vector> backgroundSession; return backgroundSession; }; @@ -892,7 +893,8 @@ HWTEST_F(SceneSessionTest, GetAvoidAreaByType, Function | SmallTest | Level2) sptr specificCallback_ = new (std::nothrow) SceneSession::SpecificSessionCallback(); EXPECT_NE(specificCallback_, nullptr); - specificCallback_->onGetSceneSessionVectorByType_ = [](WindowType type)-> std::vector> + specificCallback_->onGetSceneSessionVectorByType_ = [](WindowType type, + uint64_t displayId)-> std::vector> { SessionInfo info_; info_.abilityName_ = "Background01"; -- Gitee From b750929d6ae89e9802f3df1da35373f971d919d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Fri, 22 Mar 2024 12:28:31 +0000 Subject: [PATCH 135/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/test/unittest/screen_scene_config_test.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/window_scene/test/unittest/screen_scene_config_test.cpp b/window_scene/test/unittest/screen_scene_config_test.cpp index ff43835e8..e33697d41 100644 --- a/window_scene/test/unittest/screen_scene_config_test.cpp +++ b/window_scene/test/unittest/screen_scene_config_test.cpp @@ -310,7 +310,8 @@ HWTEST_F(ScreenSceneConfigTest, GetCurvedScreenBoundaryConfig, Function | SmallT */ HWTEST_F(ScreenSceneConfigTest, GetCutoutBoundaryRect, Function | SmallTest | Level3) { - auto result = ScreenSceneConfig::GetCutoutBoundaryRect(); + uint64_t displayId = -1; + auto result = ScreenSceneConfig::GetCutoutBoundaryRect(displayId); ASSERT_FALSE(result.size() > 0); } @@ -368,8 +369,9 @@ HWTEST_F(ScreenSceneConfigTest, CalcCutoutBoundaryRect, Function | SmallTest | L */ HWTEST_F(ScreenSceneConfigTest, SetCutoutSvgPath, Function | SmallTest | Level3) { - ScreenSceneConfig::SetCutoutSvgPath("oo"); - auto result_ = ScreenSceneConfig::GetCutoutBoundaryRect(); + uint64_t displayId = 0; + ScreenSceneConfig::SetCutoutSvgPath(displayId, "oo"); + auto result_ = ScreenSceneConfig::GetCutoutBoundaryRect(displayId); ASSERT_NE(0, result_.size()); } -- Gitee From 92b10cde227f903958cc4b8d5f1622c112d8be96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 02:42:42 +0000 Subject: [PATCH 136/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session/host/src/scene_session.cpp | 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 2d24f6b77..f9ce176a7 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -785,7 +785,7 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) return; } std::vector> statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( - WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); + WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); for (auto& statusBar : statusBarVector) { if (!(statusBar->isVisible_)) { continue; -- Gitee From 39d205f9cce08844961c0b97315e742761bc8c24 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Sat, 23 Mar 2024 10:47:52 +0800 Subject: [PATCH 137/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../unittest/picture_in_picture_option_test.cpp | 15 +++++++++++++++ wm/test/unittest/window_test.cpp | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/wm/test/unittest/picture_in_picture_option_test.cpp b/wm/test/unittest/picture_in_picture_option_test.cpp index 11be87f99..bf617462f 100644 --- a/wm/test/unittest/picture_in_picture_option_test.cpp +++ b/wm/test/unittest/picture_in_picture_option_test.cpp @@ -84,6 +84,21 @@ HWTEST_F(PictureInPictureOptionTest, NavigationId, Function | SmallTest | Level2 ASSERT_EQ(navigationId, option->GetNavigationId()); } +/** + * @tc.name: NavigationId + * @tc.desc: SetNavigationId/GetNavigationId + * @tc.type: FUNC + */ +HWTEST_F(PictureInPictureOptionTest, SetGetPiPTemplateInfoTest, Function | SmallTest | Level2) +{ + sptr option = new PipOption(); + PiPTemplateInfo pipTemplateInfo; + pipTemplateInfo.pipTemplateType = static_cast(PiPTemplateType::VIDEO_CALL); + option->SetPiPTemplateInfo(pipTemplateInfo); + ASSERT_EQ(option->GetPiPTemplateInfo().pipTemplateType, + static_cast(PiPTemplateType::VIDEO_CALL)); +} + /** * @tc.name: ContentSize * @tc.desc: SetContentSize/GetContentSize diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 58bcfc24a..18dcf7257 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -126,7 +126,11 @@ HWTEST_F(WindowTest, CreatePiP, Function | SmallTest | Level2) windowOption->SetWindowName("pip_window"); windowOption->SetWindowType(WindowType::WINDOW_TYPE_PIP); windowOption->SetWindowMode(WindowMode::WINDOW_MODE_PIP); - ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + } else { + ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + } } /** -- Gitee From 47789d57cc39b57c2171f6c37f4119217f72469c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 02:52:19 +0000 Subject: [PATCH 138/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session_manager/src/screen_scene_config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/screen_scene_config.cpp b/window_scene/session_manager/src/screen_scene_config.cpp index 1d96aca67..0184347bd 100644 --- a/window_scene/session_manager/src/screen_scene_config.cpp +++ b/window_scene/session_manager/src/screen_scene_config.cpp @@ -44,7 +44,7 @@ constexpr uint32_t NO_WATERFALL_DISPLAY_COMPRESSION_SIZE = 0; std::map ScreenSceneConfig::enableConfig_; std::map> ScreenSceneConfig::intNumbersConfig_; std::map ScreenSceneConfig::stringConfig_; -std::vector ScreenSceneConfig::cutoutBoundaryRectMap_; +std::map> ScreenSceneConfig::cutoutBoundaryRectMap_; bool ScreenSceneConfig::isWaterfallDisplay_ = false; bool ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false; uint32_t ScreenSceneConfig::curvedAreaInLandscape_ = 0; -- Gitee From f64d8f1f938bee5b73e841839934d4b6bf1a51ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 02:56:40 +0000 Subject: [PATCH 139/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/test/unittest/scene_session_manager_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 5325fb413..40cf58295 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -3006,7 +3006,8 @@ HWTEST_F(SceneSessionManagerTest, NotifyAINavigationBarShowStatus, Function | Sm { bool isVisible = false; WSRect barArea = { 0, 0, 320, 240}; // width: 320, height: 240 - WSError result = ssm_->NotifyAINavigationBarShowStatus(isVisible, barArea); + uint64_t displayId = 0; + WSError result = ssm_->NotifyAINavigationBarShowStatus(isVisible, barArea, displayId); ASSERT_EQ(result, WSError::WS_OK); } -- Gitee From a9a63d6d30f4a6f232af222aa43ec6682b687c12 Mon Sep 17 00:00:00 2001 From: cloud_nine Date: Sat, 23 Mar 2024 11:00:48 +0800 Subject: [PATCH 140/385] =?UTF-8?q?tablet=E4=B8=8D=E8=83=BD=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E4=BC=A0=E6=84=9F=E5=99=A8=E8=AE=A2=E9=98=85=E5=BD=B1?= =?UTF-8?q?=E5=93=8D=E5=8A=9F=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenyunjiu --- window_scene/session_manager/src/screen_session_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 0fa1386bf..ca23ad5bc 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -1045,13 +1045,12 @@ bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateCh if (foldScreenController_ != nullptr) { rsInterface_.SetScreenPowerStatus(foldScreenController_->GetCurrentScreenId(), status); - HandlerSensor(status); } else { for (auto screenId : screenIds) { rsInterface_.SetScreenPowerStatus(screenId, status); - HandlerSensor(status); } } + HandlerSensor(status); if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_COLLABORATION) { return true; } @@ -1067,7 +1066,8 @@ void ScreenSessionManager::SetKeyguardDrawnDoneFlag(bool flag) void ScreenSessionManager::HandlerSensor(ScreenPowerStatus status) { auto isPhone = system::GetParameter("const.product.devicetype", "unknown") == "phone"; - if (isPhone) { + auto isTablet = system::GetParameter("const.product.devicetype", "unknown") == "tablet"; + if (isPhone || isTablet) { if (status == ScreenPowerStatus::POWER_STATUS_ON) { WLOGFI("subscribe rotation sensor when phone turn on"); ScreenSensorConnector::SubscribeRotationSensor(); -- Gitee From 87d6e86dce86911b109b68f07048147a1eb4b34b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 03:11:22 +0000 Subject: [PATCH 141/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session/BUILD.gn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window_scene/session/BUILD.gn b/window_scene/session/BUILD.gn index 1e6c60d2d..2d7db5825 100755 --- a/window_scene/session/BUILD.gn +++ b/window_scene/session/BUILD.gn @@ -73,6 +73,8 @@ ohos_shared_library("scene_session") { "${window_base_path}/utils:libwmutil", "${window_base_path}/window_scene/common:window_scene_common", "${window_base_path}/window_scene/intention_event/service:intention_event_anr_manager", + "${window_base_path}/window_scene/screen_session_manager:screen_session_manager_client", + "${window_base_path}/window_scene/session:screen_session", ] public_deps = -- Gitee From 1a3d247e6089574693b7da445169bcf04de1d36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 03:48:41 +0000 Subject: [PATCH 142/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index eefe03a76..fd0bcc5f0 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -868,7 +868,7 @@ std::vector> SceneSessionManager::GetSceneSessionVectorByType auto sceneSession = item.second; if (sceneSession->GetWindowType() == type && sceneSession->GetSessionProperty() && - sceneSession->GetSessionProperty()->GetDisplayId == displayId) { + sceneSession->GetSessionProperty()->GetDisplayId() == displayId) { sceneSessionVector.emplace_back(sceneSession); } } -- Gitee From 2c31e67303280a52dabe0a229400ea4f73496046 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Sat, 23 Mar 2024 15:02:21 +0800 Subject: [PATCH 143/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../js_pip_window_manager.cpp | 17 ++++++++++------- wm/src/window_scene_session_impl.cpp | 3 +-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 50b1f2ab4..aea85c9cc 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -59,7 +59,8 @@ static int32_t checkControlsRules(uint32_t pipTemplateType, std::vectorsecond; for (auto control : controlGroups) { if (controls.find(static_cast(control)) == controls.end()) { - WLOGE("pipoption param error, controlGroup not matches, controlGroup: %{public}u", control); + TLOGE(WmsLogTag::WMS_PIP, "pipoption param error, controlGroup not matches, controlGroup: %{public}u", + control); return -1; } } @@ -69,7 +70,7 @@ static int32_t checkControlsRules(uint32_t pipTemplateType, std::vector(PiPControlGroup::FAST_FORWARD_BACKWARD)); if (iterFirst != controlGroups.end() && iterSecond != controlGroups.end()) { - WLOGE("pipoption param error, %{public}u conflicts with %{public}u in controlGroups", + TLOGE(WmsLogTag::WMS_PIP, "pipoption param error, %{public}u conflicts with %{public}u in controlGroups", static_cast(PiPControlGroup::VIDEO_PREVIOUS_NEXT), static_cast(PiPControlGroup::FAST_FORWARD_BACKWARD)); return -1; @@ -79,7 +80,8 @@ static int32_t checkControlsRules(uint32_t pipTemplateType, std::vector(PiPControlGroup::VIDEO_CALL_HANG_UP_BUTTON)); if (controlGroups.size() != 0 && iterator == controlGroups.end()) { - WLOGE("pipoption param error, requires HANG_UP_BUTTON when using controlGroups in VIDEO_CALL."); + TLOGE(WmsLogTag::WMS_PIP, "pipoption param error, requires HANG_UP_BUTTON " + "when using controlGroups in VIDEO_CALL."); return -1; } } @@ -87,7 +89,8 @@ static int32_t checkControlsRules(uint32_t pipTemplateType, std::vector(PiPControlGroup::VIDEO_MEETING_HANG_UP_BUTTON)); if (controlGroups.size() != 0 && iterator == controlGroups.end()) { - WLOGE("pipoption param error, requires HANG_UP_BUTTON when using controlGroups in VIDEO_MEETING."); + TLOGE(WmsLogTag::WMS_PIP, "pipoption param error, requires HANG_UP_BUTTON " + "when using controlGroups in VIDEO_MEETING."); return -1; } } @@ -97,17 +100,17 @@ static int32_t checkControlsRules(uint32_t pipTemplateType, std::vector(pipTemplateType)) == TEMPLATE_CONTROL_MAP.end()) { - WLOGE("pipoption param error, pipTemplateType not exists."); + TLOGE(WmsLogTag::WMS_PIP, "pipoption param error, pipTemplateType not exists."); return -1; } return checkControlsRules(pipTemplateType, option.GetControlGroup()); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 0fd441ebd..7cd268134 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2008,8 +2008,7 @@ sptr WindowSceneSessionImpl::GetMainWindowWithContext(const std::shared_ for (const auto& winPair : windowSessionMap_) { auto win = winPair.second.second; if (win && WindowHelper::IsMainWindow(win->GetType()) && context.get() == win->GetContext().get()) { - mainWinId = win->GetWindowId(); - WLOGI("[GetMainWin] Find MainWinId:%{public}u.", mainWinId); + WLOGI("[GetMainWin] Find MainWinId:%{public}u.", win->GetWindowId()); return win; } } -- Gitee From d8bac267a8192578b509c338e9f0a4057883063e Mon Sep 17 00:00:00 2001 From: dengbing Date: Sat, 23 Mar 2024 07:05:34 +0000 Subject: [PATCH 144/385] =?UTF-8?q?update=20window=5Fscene/session=5Fmanag?= =?UTF-8?q?er/src/scene=5Fsession=5Fmanager.cpp.=20=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=A8=A1=E6=80=81=E7=AA=97=E6=97=B6=E6=9C=AA=E8=B0=83bindDialo?= =?UTF-8?q?gTarget=E6=9C=AA=E4=BC=A0=E5=9B=9EparentId=E3=80=82=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=9A=E5=9C=A8BindDialogSessionTarget=E4=B8=8B?= =?UTF-8?q?=E4=B8=80=E7=BA=A7=E5=87=BD=E6=95=B0=E7=BB=9F=E4=B8=80=E8=AE=BE?= =?UTF-8?q?=E7=BD=AEparentId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dengbing --- 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 683b7af7c..e4997ba3a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -855,6 +855,7 @@ WSError SceneSessionManager::UpdateParentSessionForDialog(const sptrGetParentPersistentId(); + sceneSession->SetParentPersistentId(parentPersistentId); if (property->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG && parentPersistentId != INVALID_SESSION_ID) { auto parentSession = GetSceneSession(parentPersistentId); if (parentSession == nullptr) { @@ -4904,7 +4905,6 @@ WSError SceneSessionManager::BindDialogSessionTarget(uint64_t persistentId, sptr return WSError::WS_ERROR_INVALID_PARAM; } scnSession->SetParentSession(parentSession); - scnSession->SetParentPersistentId(parentSession->GetPersistentId()); UpdateParentSessionForDialog(scnSession, scnSession->GetSessionProperty()); WLOGFI("[WMSDialog] Bind dialog success, dialog id %{public}" PRIu64 ", parentId %{public}d", persistentId, parentSession->GetPersistentId()); -- Gitee From 5bdc332fad0841a87a4aebeeb33474b064cf9fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 07:09:39 +0000 Subject: [PATCH 145/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../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 e9f55c886..53aa0a7c9 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 @@ -1953,7 +1953,7 @@ napi_value JsSceneSessionManager::OnNotifyAINavigationBarShowStatus(napi_env env return NapiGetUndefined(env); } int32_t displayId = -1; - if (!ConvertFromJsValue(env, argv[2], displayId)) { + if (!ConvertFromJsValue(env, argv[ARG_INDEX_2], displayId)) { WLOGFE("[NAPI]Failed to convert parameter to displayId"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); -- Gitee From 069da842d5a2e88065c3c8ef63612552ab19dd90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 07:15:34 +0000 Subject: [PATCH 146/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../session_manager/src/scene_session_manager.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index fd0bcc5f0..faddfc412 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -5277,13 +5277,8 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( return; } - bool isCallingSessionFloating; - if (callingSession_->GetSessionProperty() && - callingSession_->GetSessionProperty()->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) { - isCallingSessionFloating = true; - } else { - isCallingSessionFloating = false; - } + bool isCallingSessionFloating = callingSession_->GetSessionProperty() && + callingSession_->GetSessionProperty()->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING; const WSRect& softInputSessionRect = sceneSession->GetSessionRect(); WSRect callingSessionRect; -- Gitee From ffd6c12fe6c3038ec666d5c53ebdb468120da754 Mon Sep 17 00:00:00 2001 From: cuifeihe Date: Fri, 22 Mar 2024 20:52:48 +0800 Subject: [PATCH 147/385] =?UTF-8?q?Description:=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=80=A5=E9=80=9F=E6=8C=87=E7=BA=B9=E8=A7=A3=E9=94=81=20IssueN?= =?UTF-8?q?o:=20https://gitee.com/openharmony/window=5Fwindow=5Fmanager/is?= =?UTF-8?q?sues/I99KCK=20Signed-off-by:=20cuifeihe=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/screen_session_manager.h | 8 ++ .../src/screen_session_manager.cpp | 94 ++++++++++++++++++- .../src/session_display_power_controller.cpp | 10 +- 3 files changed, 102 insertions(+), 10 deletions(-) diff --git a/window_scene/session_manager/include/screen_session_manager.h b/window_scene/session_manager/include/screen_session_manager.h index 307aa65a7..6d2edae56 100644 --- a/window_scene/session_manager/include/screen_session_manager.h +++ b/window_scene/session_manager/include/screen_session_manager.h @@ -76,6 +76,7 @@ public: virtual DMError UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) override; + bool IsFastFingerprintReason(PowerStateChangeReason reason); bool WakeUpBegin(PowerStateChangeReason reason) override; bool WakeUpEnd() override; bool SuspendBegin(PowerStateChangeReason reason) override; @@ -177,6 +178,7 @@ public: void SetDisplayBoundary(const sptr screenSession); void BlockScreenOnByCV(void); + bool BlockSetDisplayState(); //Fold Screen void SetFoldDisplayMode(const FoldDisplayMode displayMode) override; @@ -330,6 +332,12 @@ private: std::mutex screenOnMutex_; std::condition_variable screenOnCV_; + + std::atomic prePowerStateChangeReason = PowerStateChangeReason::STATE_CHANGE_REASON_UNKNOWN; + std::atomic lastWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_INIT; + std::atomic currentWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_INIT; + std::atomic buttonBlock_ = false; + //Fold Screen std::map phyScreenPropMap_; mutable std::recursive_mutex phyScreenPropMapMutex_; diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 0fa1386bf..1bfe816c8 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -52,7 +52,8 @@ const std::string SCREEN_SESSION_MANAGER_THREAD = "OS_ScreenSessionManager"; const std::string SCREEN_SESSION_MANAGER_SCREEN_POWER_THREAD = "OS_ScreenSessionManager_ScreenPower"; const std::string SCREEN_CAPTURE_PERMISSION = "ohos.permission.CAPTURE_SCREEN"; const std::string BOOTEVENT_BOOT_COMPLETED = "bootevent.boot.completed"; -const int CV_WAIT_MS = 300; +const int32_t SLEEP_10_MS = 10 * 1000; // 10ms +const int32_t CV_WAIT_MS = 300; const std::u16string DEFAULT_USTRING = u"error"; const std::string DEFAULT_STRING = "error"; const std::string ARG_DUMP_HELP = "-h"; @@ -888,19 +889,31 @@ ScreenId ScreenSessionManager::GetDefaultScreenId() bool ScreenSessionManager::WakeUpBegin(PowerStateChangeReason reason) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:WakeUpBegin(%u)", reason); - WLOGFI("[UL_POWER]WakeUpBegin remove suspend begin task"); + currentWakeUpReason_ = reason; + WLOGFI("[UL_POWER]WakeUpBegin remove suspend begin task, reason: %{public}u", static_cast(reason)); + blockScreenPowerChange_ = false; taskScheduler_->RemoveTask("suspendBeginTask"); if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_COLLABORATION) { isMultiScreenCollaboration_ = true; return true; } + // Handling Power Button Conflicts + if (IsFastFingerprintReason(lastWakeUpReason_) && reason == PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY) { + WLOGFI("[UL_POWER]WakeUpBegin buttonBlock_ is true"); + buttonBlock_ = true; + screenOnCV_.notify_all(); + usleep(SLEEP_10_MS); + } + lastWakeUpReason_ = reason; + return NotifyDisplayPowerEvent(DisplayPowerEvent::WAKE_UP, EventStatus::BEGIN, reason); } bool ScreenSessionManager::WakeUpEnd() { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:WakeUpEnd"); + WLOGFI("[UL_POWER]WakeUpEnd enter"); if (isMultiScreenCollaboration_) { isMultiScreenCollaboration_ = false; return true; @@ -912,8 +925,15 @@ bool ScreenSessionManager::WakeUpEnd() bool ScreenSessionManager::SuspendBegin(PowerStateChangeReason reason) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:SuspendBegin(%u)", reason); - WLOGFI("[UL_POWER]SuspendBegin block screen power change is true"); + WLOGFI("[UL_POWER]SuspendBegin block screen power change is true, reason: %{public}u", + static_cast(reason)); + lastWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_INIT; blockScreenPowerChange_ = true; + if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF) { + sessionDisplayPowerController_->SuspendBegin(reason); + lastWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF; + return NotifyDisplayPowerEvent(DisplayPowerEvent::SLEEP, EventStatus::BEGIN, reason); + } auto suspendBeginTask = [this]() { WLOGFI("[UL_POWER]SuspendBegin delay task start"); blockScreenPowerChange_ = false; @@ -941,14 +961,46 @@ bool ScreenSessionManager::SuspendEnd() PowerStateChangeReason::STATE_CHANGE_REASON_INIT); } +bool ScreenSessionManager::BlockSetDisplayState() +{ + return prePowerStateChangeReason == PowerStateChangeReason::POWER_BUTTON; +} + bool ScreenSessionManager::SetDisplayState(DisplayState state) { WLOGFI("[UL_POWER]SetDisplayState enter"); return sessionDisplayPowerController_->SetDisplayState(state); } +bool ScreenSessionManager::IsFastFingerprintReason(PowerStateChangeReason reason) +{ + switch (reason) { + case PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT : { + [[fallthrough]]; + } + case PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_SUCCESS : { + [[fallthrough]]; + } + case PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_ON : { + [[fallthrough]]; + } + case PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF : { + return true; + } + default: { + return false; + } + } +} + void ScreenSessionManager::BlockScreenOnByCV(void) { + // Handling Power Button Conflicts + if (buttonBlock_ && currentWakeUpReason_ != PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY) { + WLOGFI("[UL_POWER]BlockScreenOnByCV exit because buttonBlock_"); + return; + } + if (keyguardDrawnDone_ == false) { WLOGFI("[UL_POWER]screenOnCV_ set"); needScreenOnWhenKeyguardNotify_ = true; @@ -1004,22 +1056,44 @@ bool ScreenSessionManager::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowe bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) { + WLOGFI("[UL_POWER]state: %{public}u, reason: %{public}u", + static_cast(state), static_cast(reason)); ScreenPowerStatus status; if (blockScreenPowerChange_) { WLOGFI("[UL_POWER]SetScreenPowerForAll block screen power change"); return true; } + // Handling Power Button Conflicts + if (buttonBlock_ && reason != PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY && + state == ScreenPowerState::POWER_ON) { + WLOGFI("[UL_POWER]SetScreenPowerForAll exit because buttonBlock_"); + buttonBlock_ = false; + return true; + } + switch (state) { case ScreenPowerState::POWER_ON: { + if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT) { + status = ScreenPowerStatus::POWER_STATUS_ON_ADVANCED; + WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON_ADVANCED"); + } else { + status = ScreenPowerStatus::POWER_STATUS_ON; + WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON"); + } keyguardDrawnDone_ = false; WLOGFI("[UL_POWER]SetScreenPowerForAll keyguardDrawnDone_ is false"); - status = ScreenPowerStatus::POWER_STATUS_ON; break; } case ScreenPowerState::POWER_OFF: { + if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF) { + status = ScreenPowerStatus::POWER_STATUS_OFF_ADVANCED; + WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_OFF_ADVANCED"); + } else { + status = ScreenPowerStatus::POWER_STATUS_OFF; + WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_OFF"); + } keyguardDrawnDone_ = false; WLOGFI("[UL_POWER]SetScreenPowerForAll keyguardDrawnDone_ is false"); - status = ScreenPowerStatus::POWER_STATUS_OFF; break; } default: { @@ -1027,6 +1101,7 @@ bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerSta return false; } } + prePowerStateChangeReason = reason; return SetScreenPower(status, reason); } @@ -1043,6 +1118,14 @@ bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateCh taskScheduler_->RemoveTask("screenOnTask"); } + // Handling Power Button Conflicts + if (buttonBlock_ && reason != PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY && + status != ScreenPowerStatus::POWER_STATUS_OFF) { + WLOGFI("[UL_POWER]SetScreenPower exit because buttonBlock_"); + buttonBlock_ = false; + return true; + } + if (foldScreenController_ != nullptr) { rsInterface_.SetScreenPowerStatus(foldScreenController_->GetCurrentScreenId(), status); HandlerSensor(status); @@ -1055,6 +1138,7 @@ bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateCh if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_COLLABORATION) { return true; } + buttonBlock_ = false; return NotifyDisplayPowerEvent(status == ScreenPowerStatus::POWER_STATUS_ON ? DisplayPowerEvent::DISPLAY_ON : DisplayPowerEvent::DISPLAY_OFF, EventStatus::END, reason); } diff --git a/window_scene/session_manager/src/session_display_power_controller.cpp b/window_scene/session_manager/src/session_display_power_controller.cpp index 6bb75bf52..5f7da18e3 100644 --- a/window_scene/session_manager/src/session_display_power_controller.cpp +++ b/window_scene/session_manager/src/session_display_power_controller.cpp @@ -34,11 +34,11 @@ bool SessionDisplayPowerController::SuspendBegin(PowerStateChangeReason reason) bool SessionDisplayPowerController::SetDisplayState(DisplayState state) { - WLOGFI("state:%{public}u", state); + WLOGFI("[UL_POWER]state:%{public}u", state); { std::lock_guard lock(mutex_); - if (displayState_ == state) { - WLOGFE("state is already set"); + if (displayState_ == state && ScreenSessionManager::GetInstance().BlockSetDisplayState()) { + WLOGFE("[UL_POWER]state is already set"); return false; } } @@ -67,7 +67,7 @@ bool SessionDisplayPowerController::SetDisplayState(DisplayState state) break; } default: { - WLOGFW("unknown DisplayState!"); + WLOGFW("[UL_POWER]unknown DisplayState!"); return false; } } @@ -83,7 +83,7 @@ DisplayState SessionDisplayPowerController::GetDisplayState(DisplayId displayId) void SessionDisplayPowerController::NotifyDisplayEvent(DisplayEvent event) { - WLOGFI("DisplayEvent:%{public}u", event); + WLOGFI("[UL_POWER]DisplayEvent:%{public}u", event); if (event == DisplayEvent::UNLOCK) { std::map> emptyMap; displayStateChangeListener_(DISPLAY_ID_INVALID, nullptr, emptyMap, DisplayStateChangeType::BEFORE_UNLOCK); -- Gitee From aed9d5404406092e18c49c16f4e06e0b7ba9d3a0 Mon Sep 17 00:00:00 2001 From: z00514981 Date: Sat, 23 Mar 2024 15:39:21 +0800 Subject: [PATCH 148/385] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: z00514981 Change-Id: I8d473d239272b2e41401792cf579bd916b93ca8c --- wm/src/window_scene_session_impl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 192701328..ec248f0c6 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -605,6 +605,9 @@ WindowLimits WindowSceneSessionImpl::GetSystemSizeLimits(uint32_t displayWidth, MIN_FLOATING_WIDTH, vpr); systemLimits.minHeight_ = UpdateConfigVal(0, displayHeight, windowSystemConfig_.miniHeightOfSubWindow_, MIN_FLOATING_HEIGHT, vpr); + } else if (WindowHelper::IsSystemWindow(GetType()) && GetType() != WindowType::WINDOW_TYPE_DIALOG) { + systemLimits.minWidth_ = 0; + systemLimits.minHeight_ = 0; } else { systemLimits.minWidth_ = static_cast(MIN_FLOATING_WIDTH * vpr); systemLimits.minHeight_ = static_cast(MIN_FLOATING_HEIGHT * vpr); -- Gitee From 838a6000c3018337b3795e4d553dab7245c7aec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 07:49:30 +0000 Subject: [PATCH 149/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../src/scene_session_manager.cpp | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index faddfc412..d9951556e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6178,21 +6178,7 @@ WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSR WLOGFI("NotifyAINavigationBarShowStatus: enter: %{public}u, {%{public}d,%{public}d,%{public}d,%{public}d}", isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_); for (auto persistentId : avoidAreaListenerSessionSet_) { - auto sceneSession = GetSceneSession(persistentId); - if (sceneSession == nullptr || !IsSessionVisible(sceneSession)) { - continue; - } - AvoidArea avoidArea = sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_NAVIGATION_INDICATOR); - if (!CheckAvoidAreaForAINavigationBar(isAINavigationBarVisible_, avoidArea, - sceneSession->GetSessionRect().posY_ + sceneSession->GetSessionRect().height_)) { - continue; - } - WLOGFI("NotifyAINavigationBarShowStatus: persistentId: %{public}d, " - "{%{public}d,%{public}d,%{public}d,%{public}d}", persistentId, - avoidArea.bottomRect_.posX_, avoidArea.bottomRect_.posY_, - avoidArea.bottomRect_.width_, avoidArea.bottomRect_.height_); - UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, - AvoidAreaType::TYPE_NAVIGATION_INDICATOR); + NotifySessionAINavigationBarChange(persistentId); } } }; @@ -6200,6 +6186,25 @@ WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSR return WSError::WS_OK; } +void SceneSessionManager::NotifySessionAINavigationBarChange(int32_t persistentId) +{ + auto sceneSession = GetSceneSession(persistentId); + if (sceneSession == nullptr || !IsSessionVisible(sceneSession)) { + return; + } + AvoidArea avoidArea = sceneSession->GetAvoidAreaByType(AvoidAreaType::TYPE_NAVIGATION_INDICATOR); + if (!CheckAvoidAreaForAINavigationBar(isAINavigationBarVisible_, avoidArea, + sceneSession->GetSessionRect().posY_ + sceneSession->GetSessionRect().height_)) { + return; + } + WLOGFI("NotifyAINavigationBarShowStatus: persistentId: %{public}d, " + "{%{public}d,%{public}d,%{public}d,%{public}d}", persistentId, + avoidArea.bottomRect_.posX_, avoidArea.bottomRect_.posY_, + avoidArea.bottomRect_.width_, avoidArea.bottomRect_.height_); + UpdateSessionAvoidAreaIfNeed(persistentId, sceneSession, avoidArea, + AvoidAreaType::TYPE_NAVIGATION_INDICATOR); +} + WSRect SceneSessionManager::GetAINavigationBarArea(uint64_t displayId) { if (currAINavigationBarAreaMap_.count(displayId) < 1) { -- Gitee From 1a6490693872c9be12a3e5e1df80465522b52f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 07:50:32 +0000 Subject: [PATCH 150/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session_manager/include/scene_session_manager.h | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index cfe731a5f..f40e1ce94 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -430,6 +430,7 @@ private: WMError UpdatePropertyRaiseEnabled(const sptr& property, const sptr& sceneSession); void ClosePipWindowIfExist(WindowType type); + void SceneSessionManager::NotifySessionAINavigationBarChange(int32_t persistentId) WSError DestroyAndDisconnectSpecificSessionInner(sptr sceneSession); sptr rootSceneSession_; -- Gitee From 63361e4775f413381cf8a9189faec23f423bed6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 08:13:30 +0000 Subject: [PATCH 151/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- 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 f40e1ce94..9726937df 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -430,7 +430,7 @@ private: WMError UpdatePropertyRaiseEnabled(const sptr& property, const sptr& sceneSession); void ClosePipWindowIfExist(WindowType type); - void SceneSessionManager::NotifySessionAINavigationBarChange(int32_t persistentId) + void SceneSessionManager::NotifySessionAINavigationBarChange(int32_t persistentId); WSError DestroyAndDisconnectSpecificSessionInner(sptr sceneSession); sptr rootSceneSession_; -- Gitee From 4d26862391dc2821beaaf85aa5d720af945fa37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Sat, 23 Mar 2024 08:38:40 +0000 Subject: [PATCH 152/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- 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 9726937df..ad7231cfd 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -430,7 +430,7 @@ private: WMError UpdatePropertyRaiseEnabled(const sptr& property, const sptr& sceneSession); void ClosePipWindowIfExist(WindowType type); - void SceneSessionManager::NotifySessionAINavigationBarChange(int32_t persistentId); + void NotifySessionAINavigationBarChange(int32_t persistentId); WSError DestroyAndDisconnectSpecificSessionInner(sptr sceneSession); sptr rootSceneSession_; -- Gitee From 9e21a2bcb3e246cabf8607d59a719c334d129521 Mon Sep 17 00:00:00 2001 From: "yangfei110@huawei.com" Date: Thu, 21 Mar 2024 17:21:38 +0800 Subject: [PATCH 153/385] add display move listener Signed-off-by: yangfei110@huawei.com Change-Id: Ief61a3a6afe41b63d9f572c9cce96194da95e756 --- .../include/zidl/session_stage_interface.h | 1 + .../zidl/session_stage_ipc_interface_code.h | 1 + .../include/zidl/session_stage_proxy.h | 1 + .../include/zidl/session_stage_stub.h | 1 + .../src/zidl/session_stage_proxy.cpp | 27 ++++++++++++ .../container/src/zidl/session_stage_stub.cpp | 11 +++++ .../session/host/include/scene_session.h | 1 + .../session/host/src/scene_session.cpp | 8 ++++ .../src/scene_session_manager.cpp | 6 +++ window_scene/test/mock/mock_session_stage.h | 1 + wm/include/window_session_impl.h | 6 +++ wm/src/window_session_impl.cpp | 41 +++++++++++++++++++ wm/test/unittest/window_session_impl_test.cpp | 33 +++++++++++++++ 13 files changed, 138 insertions(+) diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index 2aba4fb34..7256b924b 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -68,6 +68,7 @@ public: virtual WSError NotifyDialogStateChange(bool isForeground) = 0; virtual WSError SetPipActionEvent(const std::string& action, int32_t status) = 0; virtual WSError UpdateDisplayId(uint64_t displayId) = 0; + virtual void NotifyDisplayMove(DisplayId from, DisplayId to) = 0; // **Non** IPC interface virtual void NotifyBackpressedEvent(bool& isConsumed) {} diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 5bf2f7271..c0dcf88ca 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -47,6 +47,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_NOTIFY_DIALOG_STATE_CHANGE, TRANS_ID_SET_PIP_ACTION_EVENT, TRANS_ID_NOTIFY_DISPLAYID_CHANGE, + TRANS_ID_NOTIFY_DISPLAY_MOVE, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index 3efe0d072..ac2cb8c6f 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -57,6 +57,7 @@ public: WSError NotifyDialogStateChange(bool isForeground) override; WSError SetPipActionEvent(const std::string& action, int32_t status) override; WSError UpdateDisplayId(uint64_t displayId) override; + void NotifyDisplayMove(DisplayId from, DisplayId to) override; private: static inline BrokerDelegator delegator_; diff --git a/window_scene/session/container/include/zidl/session_stage_stub.h b/window_scene/session/container/include/zidl/session_stage_stub.h index 75a51ac92..6638c0270 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -62,6 +62,7 @@ private: int HandleNotifyDialogStateChange(MessageParcel& data, MessageParcel& reply); int HandleSetPipActionEvent(MessageParcel& data, MessageParcel& reply); int HandleUpdateDisplayId(MessageParcel& data, MessageParcel& reply); + int HandleNotifyDisplayMove(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index 0dbeffa26..e8fa024da 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -631,4 +631,31 @@ WSError SessionStageProxy::SetPipActionEvent(const std::string& action, int32_t } return WSError::WS_OK; } + +void SessionStageProxy::NotifyDisplayMove(DisplayId from, DisplayId to) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return; + } + + if (!data.WriteUint64(from)) { + WLOGFE("Write from id failed"); + return; + } + + if (!data.WriteUint64(to)) { + WLOGFE("Write to id failed"); + return; + } + + if (Remote()->SendRequest(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAY_MOVE), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest notify display move failed"); + return; + } +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index 540687e0e..619aa6122 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -77,6 +77,8 @@ const std::map SessionStageStub::stubFuncMap_{ &SessionStageStub::HandleSetPipActionEvent), std::make_pair(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAYID_CHANGE), &SessionStageStub::HandleUpdateDisplayId), + std::make_pair(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAY_MOVE), + &SessionStageStub::HandleNotifyDisplayMove), }; int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) @@ -356,4 +358,13 @@ int SessionStageStub::HandleUpdateDisplayId(MessageParcel& data, MessageParcel& reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } + +int SessionStageStub::HandleNotifyDisplayMove(MessageParcel& data, MessageParcel& reply) +{ + WLOGD("HandleNotifyDisplayMove!"); + DisplayId from = static_cast(data.ReadUint64()); + DisplayId to = static_cast(data.ReadUint64()); + NotifyDisplayMove(from, to); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 53908688c..9b3f4a602 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -225,6 +225,7 @@ public: bool IsExtWindowHasWaterMarkFlag(); void RomoveExtWindowFlags(int32_t extPersistentId); void ClearExtWindowFlags(); + void NotifyDisplayMove(DisplayId from, DisplayId to); void SetSessionState(SessionState state) override; void UpdateSessionState(SessionState state) override; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1fd834691..58995f731 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2370,6 +2370,14 @@ bool SceneSession::IsExtWindowHasWaterMarkFlag() } return isExtWindowHasWaterMarkFlag; } + +void SceneSession::NotifyDisplayMove(DisplayId from, DisplayId to) +{ + if (sessionStage_) { + sessionStage_->NotifyDisplayMove(from, to); + } +} + void SceneSession::RomoveExtWindowFlags(int32_t extPersistentId) { std::shared_lock lock(extWindowFlagsMapMutex_); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index d0ba599a0..b8443cc67 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1208,6 +1208,10 @@ sptr SceneSessionManager::SetAbilitySessionInfo(const sptruserId = currentUserId_; abilitySessionInfo->isClearSession = sessionInfo.isClearSession; abilitySessionInfo->processOptions = sessionInfo.processOptions; + if (scnSession->GetSessionProperty()) { + abilitySessionInfo->want.SetParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, + static_cast(scnSession->GetSessionProperty()->GetDisplayId())); + } if (sessionInfo.want != nullptr) { abilitySessionInfo->want = *sessionInfo.want; } else { @@ -6847,6 +6851,8 @@ WSError SceneSessionManager::UpdateSessionDisplayId(int32_t persistentId, uint64 scnSession->GetSessionProperty()->SetDisplayId(screenId); WLOGFD("Session move display %{public}" PRIu64" from %{public}" PRIu64"", screenId, fromScreenId); NotifySessionUpdate(scnSession->GetSessionInfo(), ActionType::MOVE_DISPLAY, fromScreenId); + scnSession->NotifyDisplayMove(fromScreenId, screenId); + scnSession->UpdateDensity(); return WSError::WS_OK; } diff --git a/window_scene/test/mock/mock_session_stage.h b/window_scene/test/mock/mock_session_stage.h index f782bf6d7..28d3d5a29 100644 --- a/window_scene/test/mock/mock_session_stage.h +++ b/window_scene/test/mock/mock_session_stage.h @@ -55,6 +55,7 @@ public: MOCK_METHOD1(NotifyDialogStateChange, WSError(bool isForeground)); MOCK_METHOD2(SetPipActionEvent, WSError(const std::string& action, int32_t status)); MOCK_METHOD1(UpdateDisplayId, WSError(uint64_t displayId)); + MOCK_METHOD2(NotifyDisplayMove, void(DisplayId from, DisplayId to)); }; } // namespace Rosen } // namespace OHOS diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 3a4977448..e4ce3cd67 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -118,9 +118,12 @@ public: bool notifyInputMethod = true) override; void NotifyOccupiedAreaChangeInfo(sptr info) override; void NotifyForegroundInteractiveStatus(bool interactive) override; + void NotifyDisplayMove(DisplayId from, DisplayId to) override; WMError RegisterLifeCycleListener(const sptr& listener) override; WMError UnregisterLifeCycleListener(const sptr& listener) override; + WMError RegisterDisplayMoveListener(sptr& listener) override; + WMError UnregisterDisplayMoveListener(sptr& listener) override; WMError RegisterWindowChangeListener(const sptr& listener) override; WMError UnregisterWindowChangeListener(const sptr& listener) override; WMError RegisterAvoidAreaChangeListener(sptr& listener) override; @@ -265,6 +268,7 @@ private: template WMError RegisterListener(std::vector>& holder, const sptr& listener); template WMError UnregisterListener(std::vector>& holder, const sptr& listener); template EnableIfSame>> GetListeners(); + template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template @@ -314,7 +318,9 @@ private: static std::recursive_mutex windowVisibilityChangeListenerMutex_; static std::recursive_mutex windowStatusChangeListenerMutex_; static std::recursive_mutex windowTitleButtonRectChangeListenerMutex_; + static std::recursive_mutex displayMoveListenerMutex_; static std::map>> lifecycleListeners_; + static std::map>> displayMoveListeners_; static std::map>> windowChangeListeners_; static std::map>> avoidAreaChangeListeners_; static std::map>> dialogDeathRecipientListeners_; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 542e2474c..69c3f528f 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -62,6 +62,7 @@ constexpr int32_t ANIMATION_TIME = 400; } std::map>> WindowSessionImpl::lifecycleListeners_; +std::map>> WindowSessionImpl::displayMoveListeners_; std::map>> WindowSessionImpl::windowChangeListeners_; std::map>> WindowSessionImpl::avoidAreaChangeListeners_; std::map>> WindowSessionImpl::dialogDeathRecipientListeners_; @@ -83,6 +84,7 @@ std::recursive_mutex WindowSessionImpl::touchOutsideListenerMutex_; std::recursive_mutex WindowSessionImpl::windowVisibilityChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::windowStatusChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::windowTitleButtonRectChangeListenerMutex_; +std::recursive_mutex WindowSessionImpl::displayMoveListenerMutex_; std::map>> WindowSessionImpl::windowSessionMap_; std::shared_mutex WindowSessionImpl::windowSessionMutex_; std::map>> WindowSessionImpl::subWindowSessionMap_; @@ -1127,6 +1129,20 @@ WMError WindowSessionImpl::RegisterLifeCycleListener(const sptr& listener) +{ + WLOGFD("RegisterDisplayMoveListener"); + std::lock_guard lockListener(displayMoveListenerMutex_); + return RegisterListener(displayMoveListeners_[GetPersistentId()], listener); +} + +WMError WindowSessionImpl::UnregisterDisplayMoveListener(sptr& listener) +{ + WLOGFD("UnregisterDisplayMoveListener"); + std::lock_guard lockListener(displayMoveListenerMutex_); + return UnregisterListener(displayMoveListeners_[GetPersistentId()], listener); +} + WMError WindowSessionImpl::RegisterOccupiedAreaChangeListener(const sptr& listener) { WLOGFD("Start register"); @@ -1440,6 +1456,10 @@ EnableIfSame lockListener(displayMoveListenerMutex_); + ClearUselessListeners(displayMoveListeners_, persistentId); + } { std::lock_guard lockListener(lifeCycleListenerMutex_); ClearUselessListeners(lifecycleListeners_, persistentId); @@ -1766,6 +1786,27 @@ WSError WindowSessionImpl::NotifyDestroy() return WSError::WS_OK; } +template +EnableIfSame>> WindowSessionImpl::GetListeners() +{ + std::vector> displayMoveListeners; + for (auto& listener : displayMoveListeners_[GetPersistentId()]) { + displayMoveListeners.push_back(listener); + } + return displayMoveListeners; +} + +void WindowSessionImpl::NotifyDisplayMove(DisplayId from, DisplayId to) +{ + std::lock_guard lockListener(displayMoveListenerMutex_); + auto displayMoveListeners = GetListeners(); + for (auto& listener : displayMoveListeners) { + if (listener != nullptr) { + listener->OnDisplayMove(from, to); + } + } +} + WSError WindowSessionImpl::NotifyCloseExistPipWindow() { TLOGD(WmsLogTag::WMS_PIP, "WindowSessionImpl::NotifyCloseExistPipWindow"); diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 834fa4f6a..b105caa27 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -863,6 +863,12 @@ HWTEST_F(WindowSessionImplTest, RegisterListener01, Function | SmallTest | Level res = window->UnregisterWindowStatusChangeListener(listener5); ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); + sptr listener6 = nullptr; + res = window->RegisterDisplayMoveListener(listener6); + ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); + res = window->UnregisterDisplayMoveListener(listener6); + ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); + GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener01 end"; } @@ -917,6 +923,33 @@ HWTEST_F(WindowSessionImplTest, RegisterListener02, Function | SmallTest | Level GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener02 end"; } +/** + * @tc.name: NotifyDisplayMove + * @tc.desc: NotifyDisplayMove + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, NotifyDisplayMove, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyDisplayMove start"; + sptr option = new WindowOption(); + option->SetWindowName("NotifyDisplayMove"); + sptr window = new WindowSessionImpl(option); + + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", + "CreateTestAbility"}; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(nullptr, session); + ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session)); + + int res = 0; + DisplayId from = 0; + DisplayId to = 2; + window->NotifyDisplayMove(from, to); + ASSERT_EQ(res, 0); + + GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyDisplayMove end"; +} + /** * @tc.name: NotifyAfterForeground * @tc.desc: NotifyAfterForeground -- Gitee From f67c8349b9d1edd342fef9d4d55314a5ad9fc8e0 Mon Sep 17 00:00:00 2001 From: huangji731 Date: Sat, 23 Mar 2024 20:45:21 +0800 Subject: [PATCH 154/385] https://gitee.com/openharmony/window_window_manager/issues/I9B0GE Signed-off-by: huangji731 --- dm/include/display_manager_adapter.h | 3 + dm/src/display_manager_adapter.cpp | 24 ++++ dm/src/screen_manager.cpp | 10 ++ dm/test/unittest/screen_manager_test.cpp | 32 +++++ dmserver/include/display_manager_interface.h | 11 ++ interfaces/innerkits/dm/dm_common.h | 2 + interfaces/innerkits/dm/screen.h | 6 + interfaces/innerkits/dm/screen_manager.h | 17 +++ window_scene/interfaces/include/ws_common.h | 1 + .../scene_session_manager/js_scene_utils.cpp | 1 + .../include/screen_session_manager_client.h | 1 + .../src/screen_session_manager_client.cpp | 9 ++ window_scene/session/BUILD.gn | 2 + .../session/host/include/scene_session.h | 1 + .../session/host/src/scene_session.cpp | 31 +++++ .../session/screen/include/screen_session.h | 4 + .../session/screen/src/screen_session.cpp | 13 ++ .../include/scene_session_manager.h | 1 + .../include/screen_session_manager.h | 5 +- .../zidl/screen_session_manager_proxy.h | 2 + .../src/scene_session_manager.cpp | 23 ++++ .../src/screen_session_manager.cpp | 124 +++++++++++++++++- .../src/zidl/screen_session_manager_proxy.cpp | 51 +++++++ .../src/zidl/screen_session_manager_stub.cpp | 13 ++ 24 files changed, 379 insertions(+), 8 deletions(-) diff --git a/dm/include/display_manager_adapter.h b/dm/include/display_manager_adapter.h index 7deabacb2..5f0c05573 100644 --- a/dm/include/display_manager_adapter.h +++ b/dm/include/display_manager_adapter.h @@ -142,6 +142,9 @@ public: // unique screen virtual DMError MakeUniqueScreen(const std::vector& screenIds); + + virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId); + virtual DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag); private: static inline SingletonDelegator delegator; }; diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index ac049c993..ad52a141e 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -661,4 +661,28 @@ DMError DisplayManagerAdapter::GetAvailableArea(DisplayId displayId, DMRect& are return displayManagerServiceProxy_->GetAvailableArea(displayId, area); } + +VirtualScreenFlag ScreenManagerAdapter::GetVirtualScreenFlag(ScreenId screenId) +{ + INIT_PROXY_CHECK_RETURN(VirtualScreenFlag::DEFAULT); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("screenId id is invalid"); + return VirtualScreenFlag::DEFAULT; + } + + return displayManagerServiceProxy_->GetVirtualScreenFlag(screenId); +} + +DMError ScreenManagerAdapter::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("displayId id is invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) { + return DMError::DM_ERROR_INVALID_PARAM; + } + return displayManagerServiceProxy_->SetVirtualScreenFlag(screenId, screenFlag); +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/dm/src/screen_manager.cpp b/dm/src/screen_manager.cpp index a5e394d1a..e4cc2d970 100644 --- a/dm/src/screen_manager.cpp +++ b/dm/src/screen_manager.cpp @@ -563,6 +563,16 @@ DMError ScreenManager::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, b return SingletonContainer::Get().SetVirtualMirrorScreenCanvasRotation(screenId, rotation); } +VirtualScreenFlag ScreenManager::GetVirtualScreenFlag(ScreenId screenId) +{ + return SingletonContainer::Get().GetVirtualScreenFlag(screenId); +} + +DMError ScreenManager::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) +{ + return SingletonContainer::Get().SetVirtualScreenFlag(screenId, screenFlag); +} + bool ScreenManager::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) { WLOGFI("screenId:%{public}" PRIu64 ", state:%{public}u, reason:%{public}u", screenId, state, reason); diff --git a/dm/test/unittest/screen_manager_test.cpp b/dm/test/unittest/screen_manager_test.cpp index 3fbe78434..c1cc5d355 100644 --- a/dm/test/unittest/screen_manager_test.cpp +++ b/dm/test/unittest/screen_manager_test.cpp @@ -509,6 +509,38 @@ HWTEST_F(ScreenManagerTest, RegisterVirtualScreenGroupListener02, Function | Sma result = ScreenManager::GetInstance().RegisterVirtualScreenGroupListener(listener); ASSERT_EQ(DMError::DM_OK, result); } + +/** + * @tc.name: SetVirtualScreenFlag01 + * @tc.desc: SetVirtualScreenFlag01 fun + * @tc.type: FUNC + */ +HWTEST_F(ScreenManagerTest, SetVirtualScreenFlag01, Function | SmallTest | Level1) +{ + VirtualScreenOption defaultOption = {defaultName_, defaultWidth_, defaultHeight_, + defaultDensity_, nullptr, defaultFlags_}; + ScreenId screenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); + DMError ret = ScreenManager::GetInstance().SetVirtualScreenFlag(screenId, VirtualScreenFlag::CAST); + ASSERT_EQ(DMError::DM_OK, ret); + ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId); + ASSERT_EQ(DMError::DM_OK, ret); +} + +/** + * @tc.name: SetVirtualScreenFlag02 + * @tc.desc: SetVirtualScreenFlag02 fun + * @tc.type: FUNC + */ +HWTEST_F(ScreenManagerTest, SetVirtualScreenFlag02, Function | SmallTest | Level1) +{ + VirtualScreenOption defaultOption = {defaultName_, defaultWidth_, defaultHeight_, + defaultDensity_, nullptr, defaultFlags_}; + ScreenId screenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); + DMError ret = ScreenManager::GetInstance().SetVirtualScreenFlag(screenId, VirtualScreenFlag::MAX); + ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, ret); + ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId); + ASSERT_EQ(DMError::DM_OK, ret); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/dmserver/include/display_manager_interface.h b/dmserver/include/display_manager_interface.h index a7e4e6eec..4ce610ae4 100644 --- a/dmserver/include/display_manager_interface.h +++ b/dmserver/include/display_manager_interface.h @@ -119,6 +119,8 @@ public: TRANS_ID_GET_AVAILABLE_AREA, TRANS_ID_NOTIFY_FOLD_TO_EXPAND_COMPLETION, TRANS_ID_CONVERT_SCREENID_TO_RSSCREENID, + TRANS_ID_GET_VIRTUAL_SCREEN_FLAG, + TRANS_ID_SET_VIRTUAL_SCREEN_FLAG, }; virtual sptr GetDefaultDisplayInfo() = 0; @@ -235,6 +237,15 @@ public: // unique screen virtual DMError MakeUniqueScreen(const std::vector& screenIds) { return DMError::DM_OK; } + + virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) + { + return VirtualScreenFlag::DEFAULT; + } + virtual DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } }; } // namespace OHOS::Rosen diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index 921e529af..5121eb6f3 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -204,6 +204,7 @@ enum class ScreenChangeEvent : uint32_t { UPDATE_ROTATION, CHANGE_MODE, VIRTUAL_PIXEL_RATIO_CHANGED, + SCREEN_SWITCH_CHANGE, }; /** @@ -316,6 +317,7 @@ enum class ScreenSourceMode: uint32_t { SCREEN_MIRROR = 1, SCREEN_EXTEND = 2, SCREEN_ALONE = 3, + SCREEN_UNIQUE = 4, }; /** diff --git a/interfaces/innerkits/dm/screen.h b/interfaces/innerkits/dm/screen.h index 5d44ebf71..f246b084f 100644 --- a/interfaces/innerkits/dm/screen.h +++ b/interfaces/innerkits/dm/screen.h @@ -39,6 +39,12 @@ struct VirtualScreenOption { std::vector missionIds_ {}; }; +enum class VirtualScreenFlag : uint32_t { + DEFAULT = 0, + CAST = 1, + MAX = 2, +}; + class Screen : public RefBase { friend class ScreenManager; public: diff --git a/interfaces/innerkits/dm/screen_manager.h b/interfaces/innerkits/dm/screen_manager.h index 6acf7a1f4..eb7149e01 100644 --- a/interfaces/innerkits/dm/screen_manager.h +++ b/interfaces/innerkits/dm/screen_manager.h @@ -295,6 +295,23 @@ public: * @return DM_OK means unregister success, others means unregister failed. */ DMError UnregisterVirtualScreenGroupListener(sptr listener); + + /** + * @brief Get virtual screen flag. + * + * @param screenId virtual screen id. + * @return virtual screen flag + */ + VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId); + + /** + * @brief Set virtual screen flag. + * + * @param screenId virtual screen id. + * @param screenFlag virtual screen flag. + * @return DM_OK means set success, others means failed. + */ + DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag); private: ScreenManager(); ~ScreenManager(); diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index c0babfd60..4eeabc6f7 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -200,6 +200,7 @@ struct SessionInfo { bool isSystemInput_ = false; bool isAsyncModalBinding_ = false; bool isSetPointerAreas_ = false; + bool isCastSession_ = false; }; enum class SessionFlag : uint32_t { diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp index 7767e40fb..60ea82cba 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp @@ -645,6 +645,7 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) napi_set_named_property(env, objValue, "abilityName", CreateJsValue(env, sessionInfo.abilityName_)); napi_set_named_property(env, objValue, "appIndex", CreateJsValue(env, sessionInfo.appIndex_)); napi_set_named_property(env, objValue, "isSystem", CreateJsValue(env, sessionInfo.isSystem_)); + napi_set_named_property(env, objValue, "isCastSession", CreateJsValue(env, sessionInfo.isCastSession_)); napi_set_named_property(env, objValue, "persistentId", CreateJsValue(env, static_cast(sessionInfo.persistentId_))); napi_set_named_property(env, objValue, "callerPersistentId", diff --git a/window_scene/screen_session_manager/include/screen_session_manager_client.h b/window_scene/screen_session_manager/include/screen_session_manager_client.h index 8a3f944e0..63f52c6b6 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager_client.h +++ b/window_scene/screen_session_manager/include/screen_session_manager_client.h @@ -66,6 +66,7 @@ public: FoldStatus GetFoldStatus(); std::shared_ptr GetScreenSnapshot(ScreenId screenId, float scaleX, float scaleY); sptr GetScreenSessionById(const ScreenId id); + ScreenId GetDefaultScreenId(); protected: ScreenSessionManagerClient() = default; diff --git a/window_scene/screen_session_manager/src/screen_session_manager_client.cpp b/window_scene/screen_session_manager/src/screen_session_manager_client.cpp index c811a0685..4cdc49f86 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager_client.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager_client.cpp @@ -361,4 +361,13 @@ sptr ScreenSessionManagerClient::GetScreenSessionById(const Scree } return iter->second; } + +ScreenId ScreenSessionManagerClient::GetDefaultScreenId() +{ + auto iter = screenSessionMap_.begin(); + if (iter != screenSessionMap_.end()) { + return iter->first; + } + return SCREEN_ID_INVALID; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/BUILD.gn b/window_scene/session/BUILD.gn index 1e6c60d2d..2d7db5825 100755 --- a/window_scene/session/BUILD.gn +++ b/window_scene/session/BUILD.gn @@ -73,6 +73,8 @@ ohos_shared_library("scene_session") { "${window_base_path}/utils:libwmutil", "${window_base_path}/window_scene/common:window_scene_common", "${window_base_path}/window_scene/intention_event/service:intention_event_anr_manager", + "${window_base_path}/window_scene/screen_session_manager:screen_session_manager_client", + "${window_base_path}/window_scene/session:screen_session", ] public_deps = diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 53908688c..df9403b2e 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -279,6 +279,7 @@ private: void SetSurfaceBounds(const WSRect &rect); void UpdateWinRectForSystemBar(WSRect& rect); bool UpdateInputMethodSessionRect(const WSRect& rect, WSRect& newWinRect, WSRect& newRequestRect); + void HandleCastScreenConnection(SessionInfo& info, sptr session); NotifySessionRectChangeFunc sessionRectChangeFunc_; static wptr enterSession_; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1fd834691..b31f80b52 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -31,6 +31,8 @@ #include "common/include/session_permission.h" #include "interfaces/include/ws_common.h" #include "pixel_map.h" +#include "session/screen/include/screen_session.h" +#include "screen_session_manager/include/screen_session_manager_client.h" #include "session/host/include/scene_persistent_storage.h" #include "session/host/include/session_utils.h" #include "display_manager.h" @@ -39,6 +41,8 @@ #include "window_manager_hilog.h" #include "wm_math.h" #include +#include "screen_manager.h" +#include "screen.h" #include "singleton_container.h" namespace OHOS::Rosen { @@ -1977,6 +1981,7 @@ WSError SceneSession::PendingSessionActivation(const sptr ab ", windowMode: %{public}d, caller persistentId: %{public}d", info.callState_, info.persistentId_, info.callingTokenId_, info.uiAbilityId_, info.windowMode, info.callerPersistentId_); + session->HandleCastScreenConnection(info, session); if (session->pendingSessionActivationFunc_) { session->pendingSessionActivationFunc_(info); } @@ -1986,6 +1991,32 @@ WSError SceneSession::PendingSessionActivation(const sptr ab return WSError::WS_OK; } +void SceneSession::HandleCastScreenConnection(SessionInfo& info, sptr session) +{ + ScreenId defScreenId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId(); + if (defScreenId == info.screenId_) { + return; + } + auto flag = Rosen::ScreenManager::GetInstance().GetVirtualScreenFlag(info.screenId_); + if (flag != VirtualScreenFlag::CAST) { + return; + } + TLOGI(WmsLogTag::WMS_LIFE, "Get exist session state :%{public}d persistentId:%{public}d", + session->GetSessionState(), info.callerPersistentId_); + if (session->GetSessionState() != SessionState::STATE_FOREGROUND && + session->GetSessionState() != SessionState::STATE_ACTIVE) { + TLOGI(WmsLogTag::WMS_LIFE, "Get exist session state is not foreground"); + return; + } + info.isCastSession_ = true; + std::vector mirrorIds { info.screenId_ }; + Rosen::DMError ret = Rosen::ScreenManager::GetInstance().MakeUniqueScreen(mirrorIds); + if (ret != Rosen::DMError::DM_OK) { + TLOGE(WmsLogTag::WMS_LIFE, "MakeUniqueScreen failed,ret: %{public}d", ret); + return; + } +} + WSError SceneSession::TerminateSession(const sptr abilitySessionInfo) { auto task = [weakThis = wptr(this), abilitySessionInfo]() { diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index de41fb8ac..3ae3ac97b 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -136,6 +136,9 @@ public: void SetHdrFormats(std::vector&& hdrFormats); void SetColorSpaces(std::vector&& colorSpaces); + VirtualScreenFlag GetVirtualScreenFlag(); + void SetVirtualScreenFlag(VirtualScreenFlag screenFlag); + std::string name_ { "UNKNOW" }; ScreenId screenId_ {}; ScreenId rsId_ {}; @@ -174,6 +177,7 @@ private: ScreenState screenState_ { ScreenState::INIT }; std::vector screenChangeListenerList_; ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE }; + VirtualScreenFlag screenFlag_ { VirtualScreenFlag::DEFAULT }; bool hasPrivateWindowForeground_ = false; std::recursive_mutex mutex_; std::function updateToInputManagerCallback_ = nullptr; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index a5bc78c47..7e9deab40 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -360,6 +360,16 @@ void ScreenSession::SetUpdateToInputManagerCallback(std::function u updateToInputManagerCallback_ = updateToInputManagerCallback; } +VirtualScreenFlag ScreenSession::GetVirtualScreenFlag() +{ + return screenFlag_; +} + +void ScreenSession::SetVirtualScreenFlag(VirtualScreenFlag screenFlag) +{ + screenFlag_ = screenFlag; +} + void ScreenSession::UpdateToInputManager(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode) { bool needUpdateToInputManager = false; @@ -575,6 +585,9 @@ ScreenSourceMode ScreenSession::GetSourceMode() const case ScreenCombination::SCREEN_ALONE: { return ScreenSourceMode::SCREEN_ALONE; } + case ScreenCombination::SCREEN_UNIQUE: { + return ScreenSourceMode::SCREEN_UNIQUE; + } default: { return ScreenSourceMode::SCREEN_ALONE; } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 8f04a4bac..1c631a9e5 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -557,6 +557,7 @@ private: bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); WSError GetAppMainSceneSession(sptr& sceneSession, int32_t persistentId); WSError HandleSecureSessionShouldHide(const sptr& sceneSession); + void HandleCastScreenDisConnection(const sptr sceneSession); }; } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/include/screen_session_manager.h b/window_scene/session_manager/include/screen_session_manager.h index 6d2edae56..3e04b1d6e 100644 --- a/window_scene/session_manager/include/screen_session_manager.h +++ b/window_scene/session_manager/include/screen_session_manager.h @@ -228,6 +228,8 @@ public: void NotifyAvailableAreaChanged(DMRect area); void NotifyFoldToExpandCompletion(bool foldToExpand) override; + VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) override; + DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) override; protected: ScreenSessionManager(); virtual ~ScreenSessionManager() = default; @@ -246,7 +248,8 @@ private: void CreateScreenProperty(ScreenId screenId, ScreenProperty& property); sptr GetScreenSessionInner(ScreenId screenId, ScreenProperty property); void FreeDisplayMirrorNodeInner(const sptr mirrorSession); - + DMError MirrorUniqueSwitch(const std::vector& screenIds); + void MirrorSwitchNotify(ScreenId screenId); ScreenId GetDefaultScreenId(); void NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, diff --git a/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h b/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h index c9ec95e5d..9e427d878 100644 --- a/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h @@ -142,6 +142,8 @@ public: virtual DMError GetAvailableArea(DisplayId displayId, DMRect& area) override; void NotifyFoldToExpandCompletion(bool foldToExpand) override; + VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) override; + DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) override; private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 3aca8bab2..5aff2319e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -44,6 +44,8 @@ #include #include #include "transaction/rs_sync_transaction_controller.h" +#include "screen_manager.h" +#include "screen.h" #ifdef POWERMGR_DISPLAY_MANAGER_ENABLE #include @@ -1559,6 +1561,7 @@ WSError SceneSessionManager::RequestSceneSessionDestruction( TLOGE(WmsLogTag::WMS_MAIN, "session is nullptr"); return WSError::WS_ERROR_NULLPTR; } + HandleCastScreenDisConnection(scnSession); auto persistentId = scnSession->GetPersistentId(); RequestSessionUnfocus(persistentId); lastUpdatedAvoidArea_.erase(persistentId); @@ -1596,6 +1599,26 @@ WSError SceneSessionManager::RequestSceneSessionDestruction( return WSError::WS_OK; } +void SceneSessionManager::HandleCastScreenDisConnection(const sptr sceneSession) +{ + auto sessionInfo = sceneSession->GetSessionInfo(); + ScreenId defScreenId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId(); + if (defScreenId == sessionInfo.screenId_) { + return; + } + auto flag = Rosen::ScreenManager::GetInstance().GetVirtualScreenFlag(sessionInfo.screenId_); + if (flag != VirtualScreenFlag::CAST) { + return; + } + std::vector mirrorIds { sessionInfo.screenId_ }; + ScreenId groupId; + Rosen::DMError ret = Rosen::ScreenManager::GetInstance().MakeMirror(0, mirrorIds, groupId); + if (ret != Rosen::DMError::DM_OK) { + TLOGI(WmsLogTag::WMS_LIFE, "MakeMirror failed,ret: %{public}d", ret); + return; + } +} + WSError SceneSessionManager::RequestSceneSessionDestructionInner( sptr &scnSession, sptr scnSessionInfo, const bool needRemoveSession) { diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 1bfe816c8..dd5cc2074 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -296,11 +296,10 @@ void ScreenSessionManager::RegisterScreenChangeListener() void ScreenSessionManager::RegisterRefreshRateModeChangeListener() { - WLOGFI("Register refreshrate mode change listener."); auto res = rsInterface_.RegisterHgmRefreshRateModeChangeCallback( [this](int32_t refreshRateMode) { OnHgmRefreshRateModeChange(refreshRateMode); }); if (res != StatusCode::SUCCESS) { - WLOGFE("Register refreshrate mode change listener failed, retry after 50 ms."); + WLOGFE("Register refresh rate mode change listener failed, retry after 50 ms."); auto task = [this]() { RegisterRefreshRateModeChangeListener(); }; taskScheduler_->PostAsyncTask(task, "RegisterRefreshRateModeChangeListener", 50); // Retry after 50 ms. } @@ -375,9 +374,15 @@ void ScreenSessionManager::OnScreenChange(ScreenId screenId, ScreenEvent screenE clientProxy_->OnScreenConnectionChanged(screenId, ScreenEvent::CONNECTED, screenSession->GetRSScreenId(), screenSession->GetName()); } + if (screenSession->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) { + NotifyScreenConnected(screenSession->ConvertToScreenInfo()); + } return; } if (screenEvent == ScreenEvent::DISCONNECTED) { + if (screenSession->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) { + NotifyScreenDisconnected(screenSession->GetScreenId()); + } if (phyMirrorEnable) { FreeDisplayMirrorNodeInner(screenSession); } @@ -770,6 +775,10 @@ sptr ScreenSessionManager::GetScreenSessionInner(ScreenId screenI } WLOGFI("GetScreenSessionInner: nodeId:%{public}" PRIu64 "", nodeId); session = new ScreenSession(screenId, property, nodeId, defScreenId); + session->SetVirtualScreenFlag(VirtualScreenFlag::CAST); + session->SetName("CastEngine"); + session->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); + NotifyScreenChanged(session->ConvertToScreenInfo(), ScreenChangeEvent::SCREEN_SWITCH_CHANGE); } else { session = new ScreenSession(screenId, property, defScreenId); } @@ -1764,10 +1773,8 @@ DMError ScreenSessionManager::DestroyVirtualScreen(ScreenId screenId) } // virtual screen destroy callback to notify scb - WLOGFI("destroy callback virtual screen"); + WLOGFI("destroy virtual screen"); OnVirtualScreenChange(screenId, ScreenEvent::DISCONNECTED); - - WLOGI("DestroyVirtualScreen Enter"); std::lock_guard lock(screenSessionMapMutex_); ScreenId rsScreenId = SCREEN_ID_INVALID; screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId); @@ -1838,6 +1845,15 @@ DMError ScreenSessionManager::DisableMirror(bool disableOrNot) return DMError::DM_OK; } +void ScreenSessionManager::MirrorSwitchNotify(ScreenId screenId) +{ + auto mirrorScreen = GetScreenSession(screenId); + if (mirrorScreen != nullptr && mirrorScreen->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) { + mirrorScreen->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); + NotifyScreenChanged(mirrorScreen->ConvertToScreenInfo(), ScreenChangeEvent::SCREEN_SWITCH_CHANGE); + } +} + DMError ScreenSessionManager::MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId) { @@ -1850,12 +1866,20 @@ DMError ScreenSessionManager::MakeMirror(ScreenId mainScreenId, std::vectorGetVirtualScreenFlag() != VirtualScreenFlag::CAST) { + continue; + } + OnVirtualScreenChange(screenId, ScreenEvent::DISCONNECTED); + } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:MakeMirror"); auto mainScreen = GetScreenSession(mainScreenId); if (mainScreen == nullptr || allMirrorScreenIds.empty()) { @@ -1873,6 +1897,9 @@ DMError ScreenSessionManager::MakeMirror(ScreenId mainScreenId, std::vectorgroupSmsId_; + for (ScreenId screenId : allMirrorScreenIds) { + MirrorSwitchNotify(screenId); + } return DMError::DM_OK; } @@ -1928,6 +1955,85 @@ DMError ScreenSessionManager::StopScreens(const std::vector& screenIds return DMError::DM_OK; } +VirtualScreenFlag ScreenSessionManager::GetVirtualScreenFlag(ScreenId screenId) +{ + if (!SessionPermission::IsSystemCalling()) { + WLOGFE("permission denied!"); + return VirtualScreenFlag::DEFAULT; + } + auto screen = GetScreenSession(screenId); + if (screen == nullptr) { + WLOGFE("get virtual screen flag screen session null"); + return VirtualScreenFlag::DEFAULT; + } + return screen->GetVirtualScreenFlag(); +} + +DMError ScreenSessionManager::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) +{ + if (!SessionPermission::IsSystemCalling()) { + WLOGFE("permission denied!"); + return DMError::DM_ERROR_NOT_SYSTEM_APP; + } + if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) { + WLOGFE("set virtual screen flag range error"); + return DMError::DM_ERROR_INVALID_PARAM; + } + auto screen = GetScreenSession(screenId); + if (screen == nullptr) { + WLOGFE("set virtual screen flag screen session null"); + return DMError::DM_ERROR_INVALID_PARAM; + } + screen->SetVirtualScreenFlag(screenFlag); + return DMError::DM_OK; +} + +DMError ScreenSessionManager::MirrorUniqueSwitch(const std::vector& screenIds) +{ + WLOGFI("MirrorUniqueSwitch enter"); + auto defaultScreen = GetDefaultScreenSession(); + if (!defaultScreen) { + WLOGFE("Default screen is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + defaultScreen->groupSmsId_ = 1; + std::lock_guard lock(screenSessionMapMutex_); + auto iter = smsScreenGroupMap_.find(defaultScreen->groupSmsId_); + if (iter != smsScreenGroupMap_.end()) { + smsScreenGroupMap_.erase(iter); + } + for (ScreenId screenId : screenIds) { + auto screen = GetScreenSession(screenId); + if (screen == nullptr || screen->GetVirtualScreenFlag() != VirtualScreenFlag::CAST) { + continue; + } + OnVirtualScreenChange(screenId, ScreenEvent::DISCONNECTED); + } + ScreenId uniqueScreenId = screenIds[0]; + WLOGFI("disconnect virtual screen end make unique screenId %{public}" PRIu64".", uniqueScreenId); + auto group = GetAbstractScreenGroup(defaultScreen->groupSmsId_); + if (group == nullptr) { + group = AddToGroupLocked(defaultScreen); + if (group == nullptr) { + WLOGFE("group is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + NotifyScreenGroupChanged(defaultScreen->ConvertToScreenInfo(), ScreenGroupChangeEvent::ADD_TO_GROUP); + } + Point point; + std::vector startPoints; + startPoints.insert(startPoints.begin(), screenIds.size(), point); + ChangeScreenGroup(group, screenIds, startPoints, true, ScreenCombination::SCREEN_UNIQUE); + auto uniqueScreen = GetScreenSession(uniqueScreenId); + if (uniqueScreen != nullptr && uniqueScreen->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) { + uniqueScreen->SetScreenCombination(ScreenCombination::SCREEN_UNIQUE); + NotifyScreenChanged(uniqueScreen->ConvertToScreenInfo(), ScreenChangeEvent::SCREEN_SWITCH_CHANGE); + } + // virtual screen create callback to notify scb + OnVirtualScreenChange(uniqueScreenId, ScreenEvent::CONNECTED); + return DMError::DM_OK; +} + DMError ScreenSessionManager::MakeUniqueScreen(const std::vector& screenIds) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { @@ -1939,12 +2045,17 @@ DMError ScreenSessionManager::MakeUniqueScreen(const std::vector& scre WLOGFE("MakeUniqueScreen screen is empty"); return DMError::DM_ERROR_INVALID_PARAM; } + ScreenId uniqueScreenId = screenIds[0]; + auto uniqueScreen = GetScreenSession(uniqueScreenId); + if (uniqueScreen != nullptr && uniqueScreen->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) { + return MirrorUniqueSwitch(screenIds); + } for (auto screenId : screenIds) { ScreenId rsScreenId = SCREEN_ID_INVALID; bool res = ConvertScreenIdToRsScreenId(screenId, rsScreenId); WLOGFI("unique screenId: %{public}" PRIu64" rsScreenId: %{public}" PRIu64"", screenId, rsScreenId); if (!res) { - WLOGFE("convert screenid to rsScreenId failed"); + WLOGFE("convert screenId to rsScreenId failed"); continue; } auto screenSession = GetScreenSession(screenId); @@ -1964,7 +2075,6 @@ DMError ScreenSessionManager::MakeUniqueScreen(const std::vector& scre return DMError::DM_OK; } - DMError ScreenSessionManager::MakeExpand(std::vector screenId, std::vector startPoint, ScreenId& screenGroupId) diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp index 83a748ad1..225b53527 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -2166,4 +2166,55 @@ void ScreenSessionManagerProxy::NotifyFoldToExpandCompletion(bool foldToExpand) return; } } + +VirtualScreenFlag ScreenSessionManagerProxy::GetVirtualScreenFlag(ScreenId screenId) +{ + if (screenId == SCREEN_ID_INVALID) { + return VirtualScreenFlag::DEFAULT; + } + MessageOption option(MessageOption::TF_SYNC); + MessageParcel reply; + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return VirtualScreenFlag::DEFAULT; + } + if (!data.WriteUint64(screenId)) { + WLOGFE("Write screenId failed"); + return VirtualScreenFlag::DEFAULT; + } + if (Remote()->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_VIRTUAL_SCREEN_FLAG), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return VirtualScreenFlag::DEFAULT; + } + return static_cast(reply.ReadUint32()); +} + +DMError ScreenSessionManagerProxy::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) +{ + if (screenId == SCREEN_ID_INVALID) { + return DMError::DM_ERROR_INVALID_PARAM; + } + if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) { + return DMError::DM_ERROR_INVALID_PARAM; + } + MessageOption option(MessageOption::TF_ASYNC); + MessageParcel reply; + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(screenId) || !data.WriteUint32(static_cast(screenFlag))) { + WLOGFE("Write screenId or screenFlag failed"); + return DMError::DM_ERROR_WRITE_DATA_FAILED; + } + if (Remote()->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_FLAG), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + return static_cast(reply.ReadInt32()); +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp index 54c3f10f9..1059d599e 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp @@ -652,6 +652,19 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& NotifyFoldToExpandCompletion(foldToExpand); break; } + case DisplayManagerMessage::TRANS_ID_GET_VIRTUAL_SCREEN_FLAG: { + ScreenId screenId = static_cast(data.ReadUint64()); + VirtualScreenFlag screenFlag = GetVirtualScreenFlag(screenId); + reply.WriteUint32(static_cast(screenFlag)); + break; + } + case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_FLAG: { + ScreenId screenId = static_cast(data.ReadUint64()); + VirtualScreenFlag screenFlag = static_cast(data.ReadUint32()); + DMError setRet = SetVirtualScreenFlag(screenId, screenFlag); + reply.WriteInt32(static_cast(setRet)); + break; + } default: WLOGFW("unknown transaction code"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); -- Gitee From e110bdb842ba33f791bcef3e36b80a9419afcf99 Mon Sep 17 00:00:00 2001 From: gazizova sofia Date: Sat, 23 Mar 2024 17:34:57 +0300 Subject: [PATCH 155/385] address review comment Signed-off-by: gazizova sofia Change-Id: Ic8680222dcb2e14f65a270a7c415eb6302fecf49 --- .../src/screen_cutout_controller.cpp | 69 ++++++++++--------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index ea059f1dd..550ef058f 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -19,6 +19,8 @@ #include "screen_session_manager.h" #include "window_manager_hilog.h" +#include + namespace OHOS::Rosen { namespace { constexpr std::vector::size_type LEFT = 0; @@ -29,11 +31,7 @@ constexpr uint8_t HALF_SCREEN = 2; constexpr uint8_t QUARTER_SCREEN = 4; constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "ScreenCutoutController" }; -template -DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect); - -template<> -DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect) +DMRect TransferRectByRotation90(const DMRect& rect, uint32_t width, uint32_t height) { return DMRect { .posX_ = width - rect.posY_ - rect.height_, .posY_ = rect.posX_, @@ -41,20 +39,40 @@ DMRect GetRotatedRect(uint32_t width, uint32_t height, co .height_ = rect.width_ }; } -template<> -DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect) +DMRect TransferRectByRotation180(const DMRect& rect, uint32_t width, uint32_t height) { return DMRect { width - rect.posX_ - rect.width_, height - rect.posY_ - rect.height_, rect.width_, rect.height_ }; } -template<> -DMRect GetRotatedRect(uint32_t width, uint32_t height, const DMRect& rect) +DMRect TransferRectByRotation270(const DMRect& rect, uint32_t width, uint32_t height) { return DMRect { rect.posY_, height - rect.posX_ - rect.width_, rect.height_, rect.width_ }; } +using TransferRectByRotationFunc = std::function; +TransferRectByRotationFunc SelectTransferRectByRotationFunc(Rotation currentRotation) { + TransferRectByRotationFunc func; + switch (currentRotation) { + case Rotation::ROTATION_90: { + func = &TransferRectByRotation90; + break; + } + case Rotation::ROTATION_180: { + func = &TransferRectByRotation180; + break; + } + case Rotation::ROTATION_270: { + func = &TransferRectByRotation270; + break; + } + default: { + } + } + return func; +} + } uint32_t ScreenCutoutController::defaultDeviceRotation_ = 0; @@ -89,11 +107,10 @@ std::vector ScreenCutoutController::GetBoundaryRects(sptr d void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& boundaryRects, DisplayId displayId) { - std::vector finalVector; + boundaryRects.clear(); sptr displayInfo = ScreenSessionManager::GetInstance().GetDisplayInfoById(displayId); if (!displayInfo) { WLOGFE("displayInfo invalid"); - boundaryRects = finalVector; return; } @@ -106,29 +123,15 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& uint32_t displayWidth = static_cast(displayInfo->GetWidth()); uint32_t displayHeight = static_cast(displayInfo->GetHeight()); - switch (currentRotation) { - case Rotation::ROTATION_90: { - for (const DMRect& rect : displayBoundaryRects) { - finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); - } - break; - } - case Rotation::ROTATION_180: { - for (const DMRect& rect : displayBoundaryRects) { - finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); - } - break; - } - case Rotation::ROTATION_270: { - for (const DMRect& rect : displayBoundaryRects) { - finalVector.emplace_back(GetRotatedRect(displayWidth, displayHeight, rect)); - } - break; - } - default: - break; + TransferRectByRotationFunc transferFunc = SelectTransferRectByRotationFunc(currentRotation); + if (!transferFunc) { + return; + } + + + for (const DMRect& rect : displayBoundaryRects) { + boundaryRects.emplace_back(transferFunc(rect, displayHeight, displayWidth)); } - boundaryRects = std::move(finalVector); } void ScreenCutoutController::CheckBoundaryRects(std::vector& boundaryRects, sptr displayInfo) -- Gitee From 5420f55a172922bd16eee4f9513d6a484f8ce52b Mon Sep 17 00:00:00 2001 From: gazizova sofia Date: Sat, 23 Mar 2024 17:55:13 +0300 Subject: [PATCH 156/385] fixed code check errors Signed-off-by: gazizova sofia Change-Id: If7db96ee32d697cd500160e55717275a598b3dae --- .../session_manager/src/screen_cutout_controller.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index 550ef058f..730be494c 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -51,8 +51,9 @@ DMRect TransferRectByRotation270(const DMRect& rect, uint32_t width, uint32_t he rect.height_, rect.width_ }; } -using TransferRectByRotationFunc = std::function; -TransferRectByRotationFunc SelectTransferRectByRotationFunc(Rotation currentRotation) { +using TransferRectByRotationFunc = std::function; +TransferRectByRotationFunc SelectTransferRectByRotationFunc(Rotation currentRotation) +{ TransferRectByRotationFunc func; switch (currentRotation) { case Rotation::ROTATION_90: { @@ -128,7 +129,6 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& return; } - for (const DMRect& rect : displayBoundaryRects) { boundaryRects.emplace_back(transferFunc(rect, displayHeight, displayWidth)); } -- Gitee From 8dadddeafd64f20ffd91fe334559d1ccbaf2f5b5 Mon Sep 17 00:00:00 2001 From: q00510303 Date: Fri, 15 Mar 2024 11:16:03 +0800 Subject: [PATCH 157/385] =?UTF-8?q?=E5=85=81=E8=AE=B8APP=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E7=9B=91=E5=90=AC=EF=BC=9A=E9=95=BF=E6=97=B6=E9=97=B4=E6=97=A0?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=EF=BC=8C=E9=80=9A=E8=BF=87=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E9=80=9A=E7=9F=A5APP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 祁生德 --- interfaces/innerkits/wm/window.h | 35 ++++++++ .../window_runtime/window_napi/js_window.cpp | 20 +++-- .../window_napi/js_window_listener.cpp | 19 +++++ .../window_napi/js_window_listener.h | 5 +- .../js_window_register_manager.cpp | 61 +++++++++----- .../window_napi/js_window_register_manager.h | 44 ++++++---- previewer/include/window.h | 13 +++ previewer/mock/js_window_register_manager.cpp | 2 +- previewer/mock/js_window_register_manager.h | 2 +- .../wms/window_fuzzer/window_fuzzer.cpp | 7 ++ wm/include/window_scene_session_impl.h | 1 + wm/include/window_session_impl.h | 13 +++ wm/src/window_scene_session_impl.cpp | 10 +++ wm/src/window_session_impl.cpp | 80 +++++++++++++++++++ 14 files changed, 268 insertions(+), 44 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index d0808ba89..ae3248686 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -386,6 +386,17 @@ public: }; using IWindowVisibilityListenerSptr = sptr; +/** + * @class IWindowNoInteractionListenerSptr + * + * @brief Listener to observe no interaction event for a long time of window. +*/ +class IWindowNoInteractionListener : virtual public RefBase { +public: + virtual void OnWindowNoInteractionCallback() {}; +}; +using IWindowNoInteractionListenerSptr = sptr; + /** * @class IWindowTitleButtonRectChangedListener * @@ -1555,6 +1566,30 @@ public: return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Register listener, if timeout(seconds) pass with no interaction, the listener will be executed. + * + * @param listener IWindowNoInteractionListenerSptr. + * @param timeout uint32_t if timeout(seconds) pass with no interaction, the listener will be executed. + * @return WM_OK means unregister success, others means unregister failed. + */ + virtual WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, + uint32_t timeout) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + + /** + * @brief Unregister window no interaction listener. + * + * @param listener IWindowNoInteractionListenerSptr. + * @return WM_OK means unregister success, others means unregister failed. + */ + virtual WMError UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + /** * @brief Register window status change listener. * diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index dcc8d855f..619a30980 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -1547,10 +1547,12 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i WLOGFE("Window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } + constexpr size_t ARGC_MIN = 2; + constexpr size_t ARGC_MAX = 3; size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc < 2) { // 2: params num + if (argc < ARGC_MIN || argc > ARGC_MAX) { WLOGFE("Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } @@ -1559,12 +1561,20 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i WLOGFE("Failed to convert parameter to callbackType"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - napi_value value = argv[1]; - if (!NapiIsCallable(env, value)) { - WLOGI("Callback(info->argv[1]) is not callable"); + size_t cbIndex = argc - 1; + napi_value callback = argv[cbIndex]; + if (!NapiIsCallable(env, callback)) { + WLOGI("Callback(info->argv[%{public}zu]) is not callable", cbIndex); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - WmErrorCode ret = registerManager_->RegisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, env, value); + + napi_value parameter = nullptr; + if (argc > ARGC_MIN) { + parameter = argv[cbIndex - 1]; + } + + WmErrorCode ret = registerManager_->RegisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, + env, callback, parameter); if (ret != WmErrorCode::WM_OK) { return NapiThrowError(env, ret); } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index a2fba0b27..1c5cf44c9 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -395,6 +395,25 @@ void JsWindowListener::OnWaterMarkFlagUpdate(bool showWaterMark) env_, std::make_unique(callback, std::move(execute), std::move(complete))); } +void JsWindowListener::OnWindowNoInteractionCallback() +{ + std::unique_ptr complete = std::make_unique ( + [self = weakRef_] (napi_env env, NapiAsyncTask &task, int32_t status) { + auto thisListener = self.promote(); + if (thisListener == nullptr) { + WLOGFE("[NAPI]this listener is nullptr"); + return; + } + thisListener->CallJsMethod(WINDOW_NO_INTERACTION_DETECT_CB.c_str(), nullptr, 0); + } + ); + + napi_ref callback = nullptr; + std::unique_ptr execute = nullptr; + NapiAsyncTask::Schedule("JsWindowListener::OnWindowNoInteractionCallback", env_, + std::make_unique(callback, std::move(execute), std::move(complete))); +} + void JsWindowListener::OnWindowStatusChange(WindowStatus windowstatus) { WLOGFD("[NAPI]OnWindowStatusChange"); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h index 45e60936c..017bc52dd 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h @@ -47,6 +47,7 @@ const std::string WATER_MARK_FLAG_CHANGE_CB = "waterMarkFlagChange"; const std::string WINDOW_STATUS_CHANGE_CB = "windowStatusChange"; const std::string WINDOW_VISIBILITY_CHANGE_CB = "windowVisibilityChange"; const std::string WINDOW_TITLE_BUTTON_RECT_CHANGE_CB = "windowTitleButtonRectChange"; +const std::string WINDOW_NO_INTERACTION_DETECT_CB = "noInteractionDetect"; class JsWindowListener : public IWindowChangeListener, public ISystemBarChangedListener, @@ -61,7 +62,8 @@ class JsWindowListener : public IWindowChangeListener, public IGestureNavigationEnabledChangedListener, public IWindowVisibilityChangedListener, public IWindowTitleButtonRectChangedListener, - public IWindowStatusChangeListener { + public IWindowStatusChangeListener, + public IWindowNoInteractionListener { public: JsWindowListener(napi_env env, std::shared_ptr callback) : env_(env), jsCallBack_(callback), weakRef_(wptr (this)) {} @@ -90,6 +92,7 @@ public: void SetMainEventHandler(); void OnWindowStatusChange(WindowStatus windowstatus) override; void OnWindowVisibilityChangedCallback(const bool isVisible) override; + void OnWindowNoInteractionCallback() override; void OnWindowTitleButtonRectChanged(const TitleButtonRect& titleButtonRect) override; private: uint32_t currentWidth_ = 0; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp index d02b20ad3..5bddf9b2a 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp @@ -16,8 +16,10 @@ #include "singleton_container.h" #include "window_manager.h" #include "window_manager_hilog.h" +#include "js_runtime_utils.h" namespace OHOS { namespace Rosen { +using namespace AbilityRuntime; namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsRegisterManager"}; } @@ -45,6 +47,7 @@ JsWindowRegisterManager::JsWindowRegisterManager() { WINDOW_STATUS_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowStatusChangeRegister }, { WINDOW_TITLE_BUTTON_RECT_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowTitleButtonRectChangeRegister}, { WINDOW_VISIBILITY_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowVisibilityChangeRegister }, + { WINDOW_NO_INTERACTION_DETECT_CB, &JsWindowRegisterManager::ProcessWindowNoInteractionRegister }, }; // white register list for window stage listenerProcess_[CaseType::CASE_STAGE] = { @@ -57,7 +60,7 @@ JsWindowRegisterManager::~JsWindowRegisterManager() } WmErrorCode JsWindowRegisterManager::ProcessWindowChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { WLOGFE("[NAPI]Window is nullptr"); @@ -74,7 +77,7 @@ WmErrorCode JsWindowRegisterManager::ProcessWindowChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "[NAPI]Window is nullptr"); @@ -96,7 +99,7 @@ WmErrorCode JsWindowRegisterManager::ProcessSystemAvoidAreaChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { WLOGFE("[NAPI]Window is nullptr"); @@ -113,7 +116,7 @@ WmErrorCode JsWindowRegisterManager::ProcessAvoidAreaChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { WLOGFE("[NAPI]Window is nullptr"); @@ -130,7 +133,7 @@ WmErrorCode JsWindowRegisterManager::ProcessLifeCycleEventRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { WLOGFE("[NAPI]Window is nullptr"); @@ -147,7 +150,7 @@ WmErrorCode JsWindowRegisterManager::ProcessOccupiedAreaChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { sptr thisListener(listener); WmErrorCode ret = WmErrorCode::WM_OK; @@ -162,7 +165,7 @@ WmErrorCode JsWindowRegisterManager::ProcessSystemBarChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { sptr thisListener(listener); WmErrorCode ret; @@ -177,7 +180,7 @@ WmErrorCode JsWindowRegisterManager::ProcessGestureNavigationEnabledChangeRegist } WmErrorCode JsWindowRegisterManager::ProcessWaterMarkFlagChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { sptr thisListener(listener); WmErrorCode ret; @@ -191,7 +194,7 @@ WmErrorCode JsWindowRegisterManager::ProcessWaterMarkFlagChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { WLOGI("called"); if (window == nullptr) { @@ -208,7 +211,7 @@ WmErrorCode JsWindowRegisterManager::ProcessTouchOutsideRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { WLOGD("called"); if (window == nullptr) { @@ -224,8 +227,28 @@ WmErrorCode JsWindowRegisterManager::ProcessWindowVisibilityChangeRegister(sptr< return ret; } +WmErrorCode JsWindowRegisterManager::ProcessWindowNoInteractionRegister(sptr listener, + sptr window, bool isRegister, napi_env env, napi_value parameter) +{ + if (window == nullptr) { + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + } + sptr thisListener(listener); + + if (!isRegister) { + return WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterWindowNoInteractionListener(thisListener)); + } + + uint32_t timeout = 0; + if (parameter == nullptr || !ConvertFromJsNumber(env, parameter, timeout)) { + WLOGFE("Failed to convert parameter to timeout"); + return WmErrorCode::WM_ERROR_INVALID_PARAM; + } + return WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterWindowNoInteractionListener(thisListener, timeout)); +} + WmErrorCode JsWindowRegisterManager::ProcessScreenshotRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { WLOGI("called"); if (window == nullptr) { @@ -243,7 +266,7 @@ WmErrorCode JsWindowRegisterManager::ProcessScreenshotRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; @@ -259,7 +282,7 @@ WmErrorCode JsWindowRegisterManager::ProcessDialogTargetTouchRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; @@ -274,7 +297,7 @@ WmErrorCode JsWindowRegisterManager::ProcessDialogDeathRecipientRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { WLOGD("called"); if (window == nullptr) { @@ -310,7 +333,7 @@ bool JsWindowRegisterManager::IsCallbackRegistered(napi_env env, std::string typ } WmErrorCode JsWindowRegisterManager::RegisterListener(sptr window, std::string type, - CaseType caseType, napi_env env, napi_value value) + CaseType caseType, napi_env env, napi_value value, napi_value parameter) { std::lock_guard lock(mtx_); if (IsCallbackRegistered(env, type, value)) { @@ -329,7 +352,7 @@ WmErrorCode JsWindowRegisterManager::RegisterListener(sptr window, std:: return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } windowManagerListener->SetMainEventHandler(); - WmErrorCode ret = (this->*listenerProcess_[caseType][type])(windowManagerListener, window, true); + WmErrorCode ret = (this->*listenerProcess_[caseType][type])(windowManagerListener, window, true, env, parameter); if (ret != WmErrorCode::WM_OK) { WLOGFE("[NAPI]Register type %{public}s failed", type.c_str()); return ret; @@ -354,7 +377,7 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr window, std } if (value == nullptr) { for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) { - WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false); + WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false, env, nullptr); if (ret != WmErrorCode::WM_OK) { WLOGFE("[NAPI]Unregister type %{public}s failed, no value", type.c_str()); return ret; @@ -370,7 +393,7 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr window, std continue; } findFlag = true; - WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false); + WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false, env, nullptr); if (ret != WmErrorCode::WM_OK) { WLOGFE("[NAPI]Unregister type %{public}s failed", type.c_str()); return ret; @@ -393,7 +416,7 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr window, std } WmErrorCode JsWindowRegisterManager::ProcessWindowStatusChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { WLOGFE("[NAPI]Window is nullptr"); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h index 6503a2b2d..587c30957 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h @@ -29,35 +29,45 @@ public: JsWindowRegisterManager(); ~JsWindowRegisterManager(); WmErrorCode RegisterListener(sptr window, std::string type, - CaseType caseType, napi_env env, napi_value value); + CaseType caseType, napi_env env, napi_value callback, napi_value parameter = nullptr); WmErrorCode UnregisterListener(sptr window, std::string type, CaseType caseType, napi_env env, napi_value value); private: bool IsCallbackRegistered(napi_env env, std::string type, napi_value jsListenerObject); - WmErrorCode ProcessWindowChangeRegister(sptr listener, sptr window, bool isRegister); + WmErrorCode ProcessWindowChangeRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessSystemAvoidAreaChangeRegister(sptr listener, sptr window, - bool isRegister); - WmErrorCode ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister); - WmErrorCode ProcessLifeCycleEventRegister(sptr listener, sptr window, bool isRegister); + bool isRegister, napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessLifeCycleEventRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessOccupiedAreaChangeRegister(sptr listener, sptr window, - bool isRegister); - WmErrorCode ProcessSystemBarChangeRegister(sptr listener, sptr window, bool isRegister); - WmErrorCode ProcessTouchOutsideRegister(sptr listener, sptr window, bool isRegister); - WmErrorCode ProcessScreenshotRegister(sptr listener, sptr window, bool isRegister); - WmErrorCode ProcessDialogTargetTouchRegister(sptr listener, sptr window, bool isRegister); + bool isRegister, napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessSystemBarChangeRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessTouchOutsideRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessScreenshotRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessDialogTargetTouchRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessDialogDeathRecipientRegister(sptr listener, sptr window, - bool isRegister); + bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessGestureNavigationEnabledChangeRegister(sptr listener, - sptr window, bool isRegister); + sptr window, bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessWaterMarkFlagChangeRegister(sptr listener, - sptr window, bool isRegister); + sptr window, bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessWindowVisibilityChangeRegister(sptr listener, sptr window, - bool isRegister); + bool isRegister, napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessWindowNoInteractionRegister(sptr listener, sptr window, + bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessWindowStatusChangeRegister(sptr listener, sptr window, - bool isRegister); + bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessWindowTitleButtonRectChangeRegister(sptr listener, sptr window, - bool isRegister); - using Func = WmErrorCode(JsWindowRegisterManager::*)(sptr, sptr window, bool); + bool isRegister, napi_env env, napi_value parameter = nullptr); + using Func = WmErrorCode(JsWindowRegisterManager::*)(sptr, sptr window, bool, + napi_env env, napi_value parameter); std::map, sptr>> jsCbMap_; std::mutex mtx_; std::map> listenerProcess_; diff --git a/previewer/include/window.h b/previewer/include/window.h index 5d861addb..69b0401ef 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -102,6 +102,10 @@ class IWindowVisibilityChangedListener : virtual public RefBase { }; using WindowVisibilityListenerSptr = sptr; +class IWindowNoInteractionListener : virtual public RefBase { +}; +using IWindowNoInteractionListenerSptr = sptr; + static WMError DefaultCreateErrCode = WMError::WM_OK; class WINDOW_EXPORT Window : public RefBase { public: @@ -270,6 +274,15 @@ public: virtual WMError GetWindowLimits(WindowLimits& windowLimits) { return WMError::WM_OK; }; virtual WMError RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0; virtual WMError UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0; + virtual WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, + uint32_t timeout) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual WMError UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } virtual WMError SetSingleFrameComposerEnabled(bool enable) = 0; virtual WMError SetDecorVisible(bool isVisible) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual WMError SetDecorHeight(int32_t decorHeight) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } diff --git a/previewer/mock/js_window_register_manager.cpp b/previewer/mock/js_window_register_manager.cpp index 8fbcd9924..f67e9541c 100644 --- a/previewer/mock/js_window_register_manager.cpp +++ b/previewer/mock/js_window_register_manager.cpp @@ -24,7 +24,7 @@ JsWindowRegisterManager::~JsWindowRegisterManager() } WmErrorCode JsWindowRegisterManager::RegisterListener(sptr window, std::string type, - CaseType caseType, napi_env env, napi_value value) + CaseType caseType, napi_env env, napi_value value, napi_value parameter) { return WmErrorCode::WM_OK; } diff --git a/previewer/mock/js_window_register_manager.h b/previewer/mock/js_window_register_manager.h index 4b49110c5..aaeadcf37 100644 --- a/previewer/mock/js_window_register_manager.h +++ b/previewer/mock/js_window_register_manager.h @@ -33,7 +33,7 @@ public: JsWindowRegisterManager(); ~JsWindowRegisterManager(); WmErrorCode RegisterListener(sptr window, std::string type, - CaseType caseType, napi_env env, napi_value value); + CaseType caseType, napi_env env, napi_value value, napi_value parameter = nullptr); WmErrorCode UnregisterListener(sptr window, std::string type, CaseType caseType, napi_env env, napi_value value); }; diff --git a/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp b/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp index 9bbd08087..6fefa0040 100644 --- a/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp +++ b/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp @@ -111,6 +111,13 @@ public: } }; +class WindowNoInteractionListener : public IWindowNoInteractionListener { +public: + void OnWindowNoInteractionCallback() override + { + } +}; + class AnimationTransitionController : public IAnimationTransitionController { public: void AnimationForShown() override diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 67b746887..93aefb0db 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -137,6 +137,7 @@ public: void UpdateSubWindowState(const WindowType& type); WMError SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) override; void ConsumePointerEvent(const std::shared_ptr& pointerEvent) override; + void ConsumeKeyEvent(std::shared_ptr& keyEvent) override; WSError NotifyDialogStateChange(bool isForeground) override; WMError HideNonSecureWindows(bool shouldHide) override; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 8029fd563..54d485606 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -133,6 +133,9 @@ public: WMError UnregisterTouchOutsideListener(const sptr& listener) override; WMError RegisterWindowVisibilityChangeListener(const IWindowVisibilityListenerSptr& listener) override; WMError UnregisterWindowVisibilityChangeListener(const IWindowVisibilityListenerSptr& listener) override; + WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, + uint32_t timeout) override; + WMError UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) override; void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) override; WMError RegisterScreenshotListener(const sptr& listener) override; WMError UnregisterScreenshotListener(const sptr& listener) override; @@ -168,6 +171,7 @@ public: virtual ColorSpace GetColorSpace() override; WSError NotifyTouchOutside() override; WSError NotifyWindowVisibility(bool isVisible) override; + WSError NotifyNoInteractionTimeout(); WMError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; WindowState state_ { WindowState::STATE_INITIAL }; @@ -225,6 +229,8 @@ protected: WMError RegisterExtensionAvoidAreaChangeListener(sptr& listener); WMError UnregisterExtensionAvoidAreaChangeListener(sptr& listener); + void RefreshNoInteractionTimeoutMonitor(int32_t eventId); + sptr hostSession_; std::unique_ptr uiContent_; std::shared_ptr context_; @@ -276,6 +282,8 @@ private: template EnableIfSame> GetListeners(); template + EnableIfSame> GetListeners(); + template EnableIfSame>> GetListeners(); template void ClearUselessListeners(std::map& listeners, int32_t persistentId); @@ -306,6 +314,7 @@ private: static std::recursive_mutex screenshotListenerMutex_; static std::recursive_mutex touchOutsideListenerMutex_; static std::recursive_mutex windowVisibilityChangeListenerMutex_; + static std::recursive_mutex windowNoInteractionListenerMutex_; static std::recursive_mutex windowStatusChangeListenerMutex_; static std::recursive_mutex windowTitleButtonRectChangeListenerMutex_; static std::map>> lifecycleListeners_; @@ -317,6 +326,7 @@ private: static std::map>> screenshotListeners_; static std::map>> touchOutsideListeners_; static std::map> windowVisibilityChangeListeners_; + static std::map> windowNoInteractionListeners_; static std::map>> windowStatusChangeListeners_; static std::map>> windowTitleButtonRectChangeListeners_; @@ -324,6 +334,9 @@ private: // FA only sptr aceAbilityHandler_; + std::atomic lastInteractionEventId_ { -1 }; + std::atomic noInteractionTimeout_ { 0 }; // ms + WindowSizeChangeReason lastSizeChangeReason_ = WindowSizeChangeReason::END; bool postTaskDone_ = false; int16_t rotationAnimationCount_ { 0 }; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 786bcada4..ade504025 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -467,6 +467,7 @@ void WindowSceneSessionImpl::ConsumePointerEventInner(const std::shared_ptrGetId()); } bool isPointUp = (action == MMI::PointerEvent::POINTER_ACTION_UP || @@ -511,6 +512,13 @@ void WindowSceneSessionImpl::ConsumePointerEvent(const std::shared_ptr& keyEvent) +{ + bool isConsumed = false; + NotifyKeyEvent(keyEvent, isConsumed, false); + RefreshNoInteractionTimeoutMonitor(keyEvent->GetId()); +} + void WindowSceneSessionImpl::RegisterSessionRecoverListener(bool isSpecificSession) { WLOGFD("[WMSRecover] persistentId = %{public}d, isSpecificSession = %{public}s", @@ -739,6 +747,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation) hostSession_->RaiseAppMainWindowToTop(); } NotifyAfterForeground(true, false); + RefreshNoInteractionTimeoutMonitor(-1); return WMError::WM_OK; } @@ -778,6 +787,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation) state_ = WindowState::STATE_SHOWN; requestState_ = WindowState::STATE_SHOWN; NotifyAfterForeground(); + RefreshNoInteractionTimeoutMonitor(-1); } else { NotifyForegroundFailed(ret); } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index a6683215e..6c73221b6 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -70,6 +70,7 @@ std::map>> WindowSessionI std::map>> WindowSessionImpl::screenshotListeners_; std::map>> WindowSessionImpl::touchOutsideListeners_; std::map> WindowSessionImpl::windowVisibilityChangeListeners_; +std::map> WindowSessionImpl::windowNoInteractionListeners_; std::map>> WindowSessionImpl::windowTitleButtonRectChangeListeners_; std::recursive_mutex WindowSessionImpl::lifeCycleListenerMutex_; @@ -81,6 +82,7 @@ std::recursive_mutex WindowSessionImpl::occupiedAreaChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::screenshotListenerMutex_; std::recursive_mutex WindowSessionImpl::touchOutsideListenerMutex_; std::recursive_mutex WindowSessionImpl::windowVisibilityChangeListenerMutex_; +std::recursive_mutex WindowSessionImpl::windowNoInteractionListenerMutex_; std::recursive_mutex WindowSessionImpl::windowStatusChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::windowTitleButtonRectChangeListenerMutex_; std::map>> WindowSessionImpl::windowSessionMap_; @@ -2025,6 +2027,28 @@ WMError WindowSessionImpl::UnregisterWindowVisibilityChangeListener(const IWindo return ret; } +WMError WindowSessionImpl::RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, + uint32_t timeout) +{ + constexpr uint32_t S_TO_MS_RATIO = 1000; + noInteractionTimeout_.store(timeout * S_TO_MS_RATIO); // s -> ms. + WLOGFD("Start to register window no interaction listener."); + std::lock_guard lockListener(windowNoInteractionListenerMutex_); + return RegisterListener(windowNoInteractionListeners_[GetPersistentId()], listener); +} + +WMError WindowSessionImpl::UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) +{ + WLOGFD("Start to unregister window no interaction listener."); + std::lock_guard lockListener(windowNoInteractionListenerMutex_); + WMError ret = UnregisterListener(windowNoInteractionListeners_[GetPersistentId()], listener); + if (windowNoInteractionListeners_[GetPersistentId()].empty()) { + noInteractionTimeout_.store(0); + lastInteractionEventId_.store(-1); + } + return ret; +} + template EnableIfSame> WindowSessionImpl::GetListeners() { @@ -2035,6 +2059,16 @@ EnableIfSame +EnableIfSame> WindowSessionImpl::GetListeners() +{ + std::vector noInteractionListeners; + for (auto& listener : windowNoInteractionListeners_[GetPersistentId()]) { + noInteractionListeners.push_back(listener); + } + return noInteractionListeners; +} + WSError WindowSessionImpl::NotifyWindowVisibility(bool isVisible) { WLOGFD("Notify window visibility Change, window: name=%{public}s, id=%{public}u, isVisible:%{public}d", @@ -2049,6 +2083,20 @@ WSError WindowSessionImpl::NotifyWindowVisibility(bool isVisible) return WSError::WS_OK; } +WSError WindowSessionImpl::NotifyNoInteractionTimeout() +{ + WLOGFD("Notify window no interaction timeout, window: name=%{public}s, id=%{public}u", + GetWindowName().c_str(), GetPersistentId()); + std::lock_guard lockListener(windowNoInteractionListenerMutex_); + auto noInteractionListeners = GetListeners(); + for (auto& listener : noInteractionListeners) { + if (listener != nullptr) { + listener->OnWindowNoInteractionCallback(); + } + } + return WSError::WS_OK; +} + void WindowSessionImpl::NotifyPointerEvent(const std::shared_ptr& pointerEvent) { if (!pointerEvent) { @@ -2462,5 +2510,37 @@ void WindowSessionImpl::NotifyTransformChange(const Transform& transform) } } +void WindowSessionImpl::RefreshNoInteractionTimeoutMonitor(int32_t eventId) +{ + { + std::lock_guard lockListener(windowNoInteractionListenerMutex_); + if (windowNoInteractionListeners_[GetPersistentId()].empty()) { + return; + } + } + + this->lastInteractionEventId_.store(eventId); + auto task = [sessionWptr = wptr(this), eventId]() { + auto session = sessionWptr.promote(); + if (session == nullptr) { + WLOGFE("windowInteractionMonitor task running failed, window session is null"); + return; + } + if (eventId != session->lastInteractionEventId_.load()) { + WLOGFD("event id of windowInteractionMonitor has been changed, need not notify!"); + return; + } + if (session->state_ != WindowState::STATE_SHOWN) { + WLOGFD("window state is not show, need not notify!"); + return; + } + + session->NotifyNoInteractionTimeout(); + return; + }; + + handler_->PostTask(task, noInteractionTimeout_.load()); +} + } // namespace Rosen } // namespace OHOS -- Gitee From 698d1f3dfb81ae112c11c0c637234aff2671a528 Mon Sep 17 00:00:00 2001 From: zhangyao Date: Sun, 24 Mar 2024 07:42:09 +0000 Subject: [PATCH 158/385] =?UTF-8?q?Description:=20=E9=A2=84=E4=BA=AE?= =?UTF-8?q?=E5=B1=8Foff=E9=80=82=E9=85=8D=20IssueNo:=20https://gitee.com/o?= =?UTF-8?q?penharmony/window=5Fwindow=5Fmanager/issues/I9B3AV=20Feature=20?= =?UTF-8?q?or=20Bugfix:=20Feature=20Binary=20Source:No=20Signed-off-by:=20?= =?UTF-8?q?zhangyao=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/session_manager/src/screen_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index dd5cc2074..d8ed18eb1 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -937,12 +937,12 @@ bool ScreenSessionManager::SuspendBegin(PowerStateChangeReason reason) WLOGFI("[UL_POWER]SuspendBegin block screen power change is true, reason: %{public}u", static_cast(reason)); lastWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_INIT; - blockScreenPowerChange_ = true; if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF) { sessionDisplayPowerController_->SuspendBegin(reason); lastWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF; return NotifyDisplayPowerEvent(DisplayPowerEvent::SLEEP, EventStatus::BEGIN, reason); } + blockScreenPowerChange_ = true; auto suspendBeginTask = [this]() { WLOGFI("[UL_POWER]SuspendBegin delay task start"); blockScreenPowerChange_ = false; -- Gitee From 24eca9ebb58fbcfefd0a2d3722cc2dd11868fd93 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 25 Mar 2024 09:17:10 +0800 Subject: [PATCH 159/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/window_scene_session_impl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 7cd268134..a1e77369d 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2004,7 +2004,6 @@ sptr WindowSceneSessionImpl::GetMainWindowWithContext(const std::shared_ WLOGFE("[GetMainWin] Please create mainWindow First!"); return nullptr; } - uint32_t mainWinId = INVALID_WINDOW_ID; for (const auto& winPair : windowSessionMap_) { auto win = winPair.second.second; if (win && WindowHelper::IsMainWindow(win->GetType()) && context.get() == win->GetContext().get()) { -- Gitee From 8273bfd354463efbeaf894e3e067c5be44c8df0f Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 25 Mar 2024 10:28:23 +0800 Subject: [PATCH 160/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/window.cpp | 9 ++++++--- .../unittest/picture_in_picture_option_test.cpp | 15 ++++++++------- wm/test/unittest/window_test.cpp | 8 ++++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/wm/src/window.cpp b/wm/src/window.cpp index 5e5bb53c6..f0deefb39 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -145,9 +145,12 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo if (!SceneBoardJudgement::IsSceneBoardEnabled()) { return nullptr; } - if (!option || option->GetWindowName().empty()) { - TLOGE(WmsLogTag::WMS_PIP, "host window session is nullptr:%{public}u or option is null: %{public}u", - option->GetWindowName().empty(), option == nullptr); + if (!option) { + TLOGE(WmsLogTag::WMS_PIP, "option is null."); + return nullptr; + } + if (option->GetWindowName().empty()) { + TLOGE(WmsLogTag::WMS_PIP, "window option name is empty:%{public}u", option == nullptr); return nullptr; } if (!WindowHelper::IsPipWindow(option->GetWindowType())) { diff --git a/wm/test/unittest/picture_in_picture_option_test.cpp b/wm/test/unittest/picture_in_picture_option_test.cpp index bf617462f..159bcf76d 100644 --- a/wm/test/unittest/picture_in_picture_option_test.cpp +++ b/wm/test/unittest/picture_in_picture_option_test.cpp @@ -15,7 +15,7 @@ #include #include "picture_in_picture_option.h" - +#include "wm_common.h" using namespace testing; using namespace testing::ext; @@ -89,14 +89,15 @@ HWTEST_F(PictureInPictureOptionTest, NavigationId, Function | SmallTest | Level2 * @tc.desc: SetNavigationId/GetNavigationId * @tc.type: FUNC */ -HWTEST_F(PictureInPictureOptionTest, SetGetPiPTemplateInfoTest, Function | SmallTest | Level2) +HWTEST_F(PictureInPictureOptionTest, SetGetControlGroupTest, Function | SmallTest | Level2) { sptr option = new PipOption(); - PiPTemplateInfo pipTemplateInfo; - pipTemplateInfo.pipTemplateType = static_cast(PiPTemplateType::VIDEO_CALL); - option->SetPiPTemplateInfo(pipTemplateInfo); - ASSERT_EQ(option->GetPiPTemplateInfo().pipTemplateType, - static_cast(PiPTemplateType::VIDEO_CALL)); + std::vector controlGroup; + controlGroup.push_back(static_cast(PiPControlGroup::VIDEO_CALL_MICROPHONE_SWITCH)); + controlGroup.push_back(static_cast(PiPControlGroup::VIDEO_CALL_HANG_UP_BUTTON)); + controlGroup.push_back(static_cast(PiPControlGroup::VIDEO_CALL_CAMERA_SWITCH)); + option->SetControlGroup(controlGroup); + ASSERT_NE(option->GetControlGroup().size(), 0); } /** diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index d82a2001b..26478e9c8 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -120,16 +120,16 @@ HWTEST_F(WindowTest, CreatePiP, Function | SmallTest | Level2) { sptr windowOption = nullptr; PiPTemplateInfo pipTemplateInfo; - ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + ASSERT_EQ(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); windowOption = new WindowOption(); - ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + ASSERT_EQ(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); windowOption->SetWindowName("pip_window"); windowOption->SetWindowType(WindowType::WINDOW_TYPE_PIP); windowOption->SetWindowMode(WindowMode::WINDOW_MODE_PIP); if (SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + ASSERT_NE(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); } else { - ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + ASSERT_EQ(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); } } -- Gitee From 974a9ce4ee094bc83081163e70d4ae7788ff1cdf Mon Sep 17 00:00:00 2001 From: xiazhiqi Date: Mon, 25 Mar 2024 02:56:38 +0000 Subject: [PATCH 161/385] fix comments Signed-off-by: xiazhiqi Change-Id: I3b6128135530d08c69af8bcf27ff039a925b37fa --- .../window_manager_napi/js_window_manager.cpp | 20 +++---- .../window_runtime/window_napi/js_window.cpp | 60 +++++++++++++++---- 2 files changed, 57 insertions(+), 23 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index 604724d9f..ff1904f05 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -757,14 +757,14 @@ napi_value JsWindowManager::OnUnregisterWindowManagerCallback(napi_env env, napi return NapiGetUndefined(env); } -struct TopWindowInfoList { - sptr window = nullptr; - AppExecFwk::Ability* ability = nullptr; - int32_t errorCode = 0; - std::string errMsg = ""; -}; static napi_value GetTopWindowTask(void* contextPtr, napi_env env, napi_value callback, bool newApi) { + struct TopWindowInfoList { + sptr window = nullptr; + AppExecFwk::Ability* ability = nullptr; + int32_t errorCode = 0; + std::string errMsg = ""; + }; std::shared_ptr lists = std::make_shared(); bool isOldApi = GetAPI7Ability(env, lists->ability); NapiAsyncTask::ExecuteCallback execute = [lists, isOldApi, newApi, contextPtr]() { @@ -808,13 +808,7 @@ static napi_value GetTopWindowTask(void* contextPtr, napi_env env, napi_value ca task.Reject(env, CreateJsError(env, error, "Get top window failed")); return; } - std::string windowName = lists->window->GetWindowName(); - std::shared_ptr jsWindowObj = FindJsWindowObject(windowName); - if (jsWindowObj != nullptr && jsWindowObj->GetNapiValue() != nullptr) { - task.Resolve(env, jsWindowObj->GetNapiValue()); - } else { - task.Resolve(env, CreateJsWindowObject(env, lists->window)); - } + task.Resolve(env, CreateJsWindowObject(env, lists->window)); WLOGD("Get top window %{public}s success", windowName.c_str()); }; napi_value result = nullptr; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index ecd8a6dd1..b9f9c5be3 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -3002,33 +3002,73 @@ napi_value JsWindow::OnSetWindowKeepScreenOn(napi_env env, napi_callback_info in if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + int x = 10; + x = x + 1; wptr weakToken(windowToken_); - std::shared_ptr errCodeExe = std::make_shared(WmErrorCode::WM_OK); - NapiAsyncTask::ExecuteCallback execute = [weakToken, keepScreenOn, errCodeExe] () { - if (errCodeExe == nullptr) { + std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); + NapiAsyncTask::ExecuteCallback execute = [weakToken, keepScreenOn, errCodePtr] () { + if (errCodePtr == nullptr) { return; } auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - *errCodeExe = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + *errCodePtr = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; return; } - *errCodeExe = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetKeepScreenOn(keepScreenOn)); + *errCodePtr = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetKeepScreenOn(keepScreenOn)); WLOGI("Window [%{public}u, %{public}s] set keep screen on end", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); }; NapiAsyncTask::CompleteCallback complete = - [weakToken, keepScreenOn, errCodeExe](napi_env env, NapiAsyncTask& task, int32_t status) { - if (errCodeExe == nullptr) { + [weakToken, keepScreenOn, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCodePtr == nullptr) { task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "System abnormal.")); return; } - if (*errCodeExe == WmErrorCode::WM_OK) { + if (*errCodePtr == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, CreateJsError(env, static_cast(*errCodeExe), + task.Reject(env, CreateJsError(env, static_cast(*errCodePtr), "Window set keep screen on failed")); } }; -- Gitee From a3600b6cc673030d06a57cba08c5c43106d8a368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AE=A1=E4=BC=9F=E7=BF=94?= Date: Mon, 18 Mar 2024 20:21:57 +0800 Subject: [PATCH 162/385] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E7=AB=AF=E4=B8=89=E6=96=B9=E5=BA=94=E7=94=A8=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=82=AC=E6=B5=AE=E7=AA=97=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: guanweixiang --- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++++- 1 file changed, 5 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 3aca8bab2..5f98b8cd9 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1816,8 +1816,12 @@ bool SceneSessionManager::CheckSystemWindowPermission(const sptr Date: Sat, 23 Mar 2024 20:21:28 +0800 Subject: [PATCH 163/385] add enableLandScapeMultiWindow/disableLandScapeMultiWindow for C++ Signed-off-by: qiwenchao --- interfaces/innerkits/wm/window.h | 13 ++- .../window_runtime/window_napi/js_window.cpp | 79 ++++++++++++++++++- .../window_runtime/window_napi/js_window.h | 4 + previewer/include/window.h | 1 + previewer/include/window_impl.h | 2 + previewer/src/window_impl.cpp | 5 ++ .../js_scene_session.cpp | 36 +++++++++ .../scene_session_manager/js_scene_session.h | 2 + .../js_scene_session_manager.cpp | 2 + .../session/host/include/scene_session.h | 5 +- .../host/include/zidl/session_interface.h | 1 + .../include/zidl/session_ipc_interface_code.h | 1 + .../session/host/include/zidl/session_proxy.h | 1 + .../session/host/include/zidl/session_stub.h | 1 + .../session/host/src/scene_session.cpp | 28 ++++++- .../session/host/src/zidl/session_proxy.cpp | 22 ++++++ .../session/host/src/zidl/session_stub.cpp | 11 +++ wm/include/window_session_impl.h | 1 + wm/src/window_session_impl.cpp | 10 +++ 19 files changed, 221 insertions(+), 4 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index b4e2f3b38..c53ce350e 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1678,7 +1678,7 @@ public: * @return WM_OK means add success, others means failed. */ virtual WMError AddExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } - + /** * @brief Remove uiextension window flag. * @@ -1686,6 +1686,17 @@ public: * @return WM_OK means remove success, others means failed. */ virtual WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + + /** + * @brief Make multi-window become landscape or not. + * + * @param isLandscapeMultiWindow means whether multi-window's scale is landscape. + * @return WMError WM_OK means set success, others means failed. + */ + virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) + { + return WMError::WM_OK; + } }; } } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index dcc8d855f..a94e2c102 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -308,6 +308,20 @@ napi_value JsWindow::SetSpecificSystemBarEnabled(napi_env env, napi_callback_inf return (me != nullptr) ? me->OnSetSpecificSystemBarEnabled(env, info) : nullptr; } +napi_value JsWindow::EnableLandscapeMultiWindow(napi_env env, napi_callback_info info) +{ + WLOGI("EnableLandscapeMultiWindow"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnEnableLandscapeMultiWindow(env, info) : nullptr; +} + +napi_value JsWindow::DisableLandscapeMultiWindow(napi_env env, napi_callback_info info) +{ + WLOGI("DisableLandscapeMultiWindow"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnDisableLandscapeMultiWindow(env, info) : nullptr; +} + napi_value JsWindow::SetSystemBarProperties(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::WMS_IMMS, "SetSystemBarProperties"); @@ -2193,6 +2207,67 @@ napi_value JsWindow::OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_i return result; } +napi_value JsWindow::OnEnableLandscapeMultiWindow(napi_env env, napi_callback_info info) +{ + WLOGI("OnEnableLandscapeMultiWindow"); + WmErrorCode err = (windowToken_ == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : WmErrorCode::WM_OK; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [weakToken, err](napi_env env, NapiAsyncTask& task, int32_t status) mutable { + auto weakWindow = weakToken.promote(); + err = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : err; + if (err != WmErrorCode::WM_OK) { + task.Reject(env, CreateJsError(env, static_cast(err))); + return; + } + WMError ret = weakWindow->SetLandscapeMultiWindow(true); + if (ret == WMError::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY), + "JsWindow::OnEnableLandscapeMultiWindow failed")); + } + }; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnEnableLandscapeMultiWindow", + env, CreateAsyncTaskWithLastParam(env, nullptr, nullptr, std::move(complete), &result)); + return result; +} + +napi_value JsWindow::OnDisableLandscapeMultiWindow(napi_env env, napi_callback_info info) +{ + WmErrorCode err = (windowToken_ == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : WmErrorCode::WM_OK; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [weakToken, err](napi_env env, NapiAsyncTask &task, int32_t status) mutable { + auto weakWindow = weakToken.promote(); + err = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : err; + if (err != WmErrorCode::WM_OK) { + task.Reject(env, CreateJsError(env, static_cast(err))); + return; + } + WMError ret = weakWindow->SetLandscapeMultiWindow(false); + if (ret == WMError::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY), + "JsWindow::OnDisableLandscapeMultiWindow failed")); + } + }; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnDisableLandscapeMultiWindow", + env, CreateAsyncTaskWithLastParam(env, nullptr, nullptr, std::move(complete), &result)); + return result; +} + napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info info) { WMError errCode = WMError::WM_OK; @@ -4844,7 +4919,7 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) WLOGFE("[NAPI] maximize interface only support main Window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); } - + NapiAsyncTask::CompleteCallback complete = [weakToken](napi_env env, NapiAsyncTask& task, int32_t status) mutable { auto weakWindow = weakToken.promote(); @@ -5235,6 +5310,8 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setSpecificSystemBarEnabled", moduleName, JsWindow::SetSpecificSystemBarEnabled); BindNativeFunction(env, object, "setSingleFrameComposerEnabled", moduleName, JsWindow::SetSingleFrameComposerEnabled); + BindNativeFunction(env, object, "enableLandscapeMultiWindow", moduleName, JsWindow::EnableLandscapeMultiWindow); + BindNativeFunction(env, object, "disableLandscapeMultiWindow", moduleName, JsWindow::DisableLandscapeMultiWindow); BindNativeFunction(env, object, "setWindowDecorVisible", moduleName, JsWindow::SetWindowDecorVisible); BindNativeFunction(env, object, "setWindowDecorHeight", moduleName, JsWindow::SetWindowDecorHeight); BindNativeFunction(env, object, "getWindowDecorHeight", moduleName, JsWindow::GetWindowDecorHeight); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 536868632..7b7e3d588 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -112,6 +112,8 @@ public: static napi_value SetWindowLimits(napi_env env, napi_callback_info info); static napi_value SetSpecificSystemBarEnabled(napi_env env, napi_callback_info info); static napi_value SetSingleFrameComposerEnabled(napi_env env, napi_callback_info info); + static napi_value EnableLandscapeMultiWindow(napi_env env, napi_callback_info info); + static napi_value DisableLandscapeMultiWindow(napi_env env, napi_callback_info info); // colorspace, gamut static napi_value IsSupportWideGamut(napi_env env, napi_callback_info info); @@ -234,6 +236,8 @@ private: napi_value OnSnapshot(napi_env env, napi_callback_info info); napi_value OnSetSnapshotSkip(napi_env env, napi_callback_info info); napi_value OnSetSingleFrameComposerEnabled(napi_env env, napi_callback_info info); + napi_value OnEnableLandscapeMultiWindow(napi_env env, napi_callback_info info); + napi_value OnDisableLandscapeMultiWindow(napi_env env, napi_callback_info info); // animation Config napi_value OnOpacity(napi_env env, napi_callback_info info); diff --git a/previewer/include/window.h b/previewer/include/window.h index f919bd091..86ba766a1 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -271,6 +271,7 @@ public: virtual WMError RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0; virtual WMError UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0; virtual WMError SetSingleFrameComposerEnabled(bool enable) = 0; + virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) = 0; virtual WMError SetDecorVisible(bool isVisible) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual WMError SetDecorHeight(int32_t decorHeight) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual WMError GetDecorHeight(int32_t& height) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } diff --git a/previewer/include/window_impl.h b/previewer/include/window_impl.h index ee5b02ddb..4b82edb4f 100644 --- a/previewer/include/window_impl.h +++ b/previewer/include/window_impl.h @@ -215,6 +215,8 @@ public: virtual WMError UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) override; virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag) override; virtual WMError SetSingleFrameComposerEnabled(bool enable) override; + virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; + private: static std::map>> windowMap_; static std::map>> subWindowMap_; diff --git a/previewer/src/window_impl.cpp b/previewer/src/window_impl.cpp index cc935c052..b9ec3b913 100644 --- a/previewer/src/window_impl.cpp +++ b/previewer/src/window_impl.cpp @@ -889,5 +889,10 @@ WMError WindowImpl::SetSingleFrameComposerEnabled(bool enable) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + +WMError WindowImpl::SetLandscapeMultiWindow(bool isLandscapeMultiWindow) +{ + return WMError::WM_OK; +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 9a6b654f5..eccb0204f 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -58,6 +58,7 @@ const std::string TOUCH_OUTSIDE_CB = "touchOutside"; const std::string WINDOW_DRAG_HOT_AREA_CB = "windowDragHotArea"; const std::string SESSIONINFO_LOCKEDSTATE_CHANGE_CB = "sessionInfoLockedStateChange"; const std::string PREPARE_CLOSE_PIP_SESSION = "prepareClosePiPSession"; +const std::string LANDSCAPE_MULTI_WINDOW_CB = "landscapeMultiWindow"; constexpr int SCALE_ARG_COUNT = 4; constexpr int ARG_INDEX_0 = 0; constexpr int ARG_INDEX_1 = 1; @@ -209,6 +210,7 @@ void JsSceneSession::InitListenerFuncs() { WINDOW_DRAG_HOT_AREA_CB, &JsSceneSession::ProcessWindowDragHotAreaRegister }, { SESSIONINFO_LOCKEDSTATE_CHANGE_CB, &JsSceneSession::ProcessSessionInfoLockedStateChangeRegister }, { PREPARE_CLOSE_PIP_SESSION, &JsSceneSession::ProcessPrepareClosePiPSessionRegister}, + { LANDSCAPE_MULTI_WINDOW_CB, &JsSceneSession::ProcessLandscapeMultiWindowRegister }, }; } @@ -287,6 +289,40 @@ void JsSceneSession::ProcessSessionInfoLockedStateChangeRegister() WLOGFD("ProcessSessionInfoLockedStateChangeRegister success"); } +void JsSceneSession::ProcessLandscapeMultiWindowRegister() +{ + WLOGFD("ProcessLandscapeMultiWindowRegister"); + auto sessionchangeCallback = sessionchangeCallback_.promote(); + if (sessionchangeCallback == nullptr) { + WLOGFE("sessionchangeCallback is nullptr"); + return; + } + sessionchangeCallback->onSetLandscapeMultiWindowFunc_ = std::bind(&JsSceneSession::SetLandscapeMultiWindow, + this, std::placeholders::_1); + WLOGFD("ProcessLandscapeMultiWindowRegister success"); +} + +void JsSceneSession::SetLandscapeMultiWindow(bool isLandscapeMultiWindow) +{ + WLOGFI("[NAPI]SetLandScapeMultiWindow, isLandscapeMultiWindow: %{public}u", isLandscapeMultiWindow); + auto iter = jsCbMap_.find(LANDSCAPE_MULTI_WINDOW_CB); + if (iter == jsCbMap_.end()) { + return; + } + auto jsCallBack = iter->second; + auto task = [isLandscapeMultiWindow, jsCallBack, env = env_]() { + if (!jsCallBack) { + WLOGFE("[NAPI]jsCallBack is nullptr"); + return; + } + napi_value jsSessionLandscapeMultiWindowObj = CreateJsValue(env, isLandscapeMultiWindow); + napi_value argv[] = {jsSessionLandscapeMultiWindowObj}; + napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); + }; + taskScheduler_->PostMainThreadTask(task, + "SetLandscapeMultiWindow, isLandscapeMultiWindow:" + std::to_string(isLandscapeMultiWindow)); +} + void JsSceneSession::OnSessionInfoLockedStateChange(bool lockedState) { WLOGFI("[NAPI]OnSessionInfoLockedStateChange, state: %{public}u", lockedState); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h index 1851e8732..9bd81ef71 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h @@ -116,6 +116,7 @@ private: void ProcessWindowDragHotAreaRegister(); void ProcessSessionInfoLockedStateChangeRegister(); void ProcessPrepareClosePiPSessionRegister(); + void ProcessLandscapeMultiWindowRegister(); void ChangeSessionVisibilityWithStatusBar(SessionInfo& info, bool visible); void ChangeSessionVisibilityWithStatusBarInner(std::shared_ptr sessionInfo, bool visible); @@ -153,6 +154,7 @@ private: void OnWindowDragHotArea(int32_t type, const SizeChangeReason& reason); void OnSessionInfoLockedStateChange(bool lockedState); void OnPrepareClosePiPSession(); + void SetLandscapeMultiWindow(bool isLandscapeMultiWindow); napi_env env_; wptr weakSession_ = nullptr; 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 5a66b0d5b..81b6a010e 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 @@ -874,6 +874,8 @@ napi_value JsSceneSessionManager::CreateAbilityItemInfo(napi_env env, const AppE napi_set_named_property(env, objValue, "continuable", CreateJsValue(env, abilityInfo.continuable)); napi_set_named_property(env, objValue, "removeSessionAfterTerminate", CreateJsValue(env, abilityInfo.removeMissionAfterTerminate)); + napi_set_named_property(env, objValue, "preferMultiWindowOrientation", + CreateJsValue(env, abilityInfo.preferMultiWindowOrientation)); return objValue; } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 53908688c..b8f1a1ed7 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -60,6 +60,7 @@ using ClearCallbackMapFunc = std::function; using OnOutsideDownEvent = std::function; using NotifyAddOrRemoveSecureSessionFunc = std::function& sceneSession)>; +using NotifyLandscapeMultiWindowSessionFunc = std::function; class SceneSession : public Session { public: // callback for notify SceneSessionManager @@ -94,6 +95,7 @@ public: NotifyTouchOutsideFunc OnTouchOutside_; ClearCallbackMapFunc clearCallbackFunc_; NotifyPrepareClosePiPSessionFunc onPrepareClosePiPSession_; + NotifyLandscapeMultiWindowSessionFunc onSetLandscapeMultiWindowFunc_; }; // func for change window scene pattern property @@ -151,6 +153,7 @@ public: WSError SendPointEventForMoveDrag(const std::shared_ptr& pointerEvent) override; void NotifyOutsideDownEvent(const std::shared_ptr& pointerEvent); void SetForegroundInteractiveStatus(bool interactive) override; + WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; WSError SetKeepScreenOn(bool keepScreenOn); void SetParentPersistentId(int32_t parentId); @@ -296,7 +299,7 @@ private: std::set secureExtSessionSet_; std::shared_mutex extWindowFlagsMapMutex_; std::map extWindowFlagsMap_; - + }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H \ No newline at end of file diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index 42f583740..97ac887c7 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -62,6 +62,7 @@ public: virtual WSError PendingSessionActivation(const sptr abilitySessionInfo) { return WSError::WS_OK; } virtual WSError TerminateSession(const sptr abilitySessionInfo) { return WSError::WS_OK; } + virtual WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) { return WSError::WS_OK; } virtual WSError ChangeSessionVisibilityWithStatusBar(const sptr abilitySessionInfo, bool isShow) { return WSError::WS_OK; } virtual WSError NotifySessionException( diff --git a/window_scene/session/host/include/zidl/session_ipc_interface_code.h b/window_scene/session/host/include/zidl/session_ipc_interface_code.h index 4a9301785..1491fcc59 100644 --- a/window_scene/session/host/include/zidl/session_ipc_interface_code.h +++ b/window_scene/session/host/include/zidl/session_ipc_interface_code.h @@ -50,6 +50,7 @@ enum class SessionInterfaceCode { TRANS_ID_RAISE_APP_MAIN_WINDOW, TRANS_ID_PROCESS_POINT_DOWN_SESSION, TRANS_ID_SEND_POINTEREVENT_FOR_MOVE_DRAG, + TRANS_ID_SET_LANDSCAPE_MULTI_WINDOW, // Extension TRANS_ID_TRANSFER_ABILITY_RESULT = 500, diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index 02dbce4c0..a7436ea84 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -55,6 +55,7 @@ public: WSError SetSessionProperty(const sptr& property) override; WSError SetAspectRatio(float ratio) override; WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) override; + WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override; WSError RaiseAboveTarget(int32_t subWindowId) override; WSError RaiseAppMainWindowToTop() override; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 51f452cf4..cafdfc451 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -64,6 +64,7 @@ private: int HandleSessionException(MessageParcel& data, MessageParcel& reply); int HandleProcessPointDownSession(MessageParcel& data, MessageParcel& reply); int HandleSendPointerEvenForMoveDrag(MessageParcel& data, MessageParcel& reply); + int HandleSetLandscapeMultiWindow(MessageParcel& data, MessageParcel& reply); // extension extension int HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1fd834691..278e341e8 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -770,6 +770,10 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) if (Session::GetFloatingScale() <= miniScale) { return; } + if (Session::GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING && + rect.height_ < rect.width_) { + return; + } float vpr = 3.5f; // 3.5f: default pixel ratio auto display = DisplayManager::GetInstance().GetDefaultDisplay(); if (display) { @@ -1919,7 +1923,7 @@ WSError SceneSession::ChangeSessionVisibilityWithStatusBar( if (session->changeSessionVisibilityWithStatusBarFunc_) { session->changeSessionVisibilityWithStatusBarFunc_(info, visible); } - + return WSError::WS_OK; }; PostTask(task, "ChangeSessionVisibilityWithStatusBar"); @@ -2142,6 +2146,28 @@ void SceneSession::NotifyPiPWindowPrepareClose() PostTask(task, "NotifyPiPWindowPrepareClose"); } +WSError SceneSession::SetLandscapeMultiWindow(bool isLandscapeMultiWindow) +{ + WLOGFD("NotifySetLandscapeMultiWindow"); + auto task = [weakThis = wptr(this), isLandscapeMultiWindow]() { + auto session = weakThis.promote(); + if (!session) { + WLOGFE("session is null"); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + if (session->sessionChangeCallback_ && + session->sessionChangeCallback_->onSetLandscapeMultiWindowFunc_) { + session->sessionChangeCallback_->onSetLandscapeMultiWindowFunc_( + isLandscapeMultiWindow); + } + WLOGFD("NotifySetLandscapeMultiWindow, id: %{public}d, isLandscapeMultiWindow: %{public}u", + session->GetPersistentId(), isLandscapeMultiWindow); + return WSError::WS_OK; + }; + PostTask(task, "NotifySetLandscapeMultiWindow"); + return WSError::WS_OK; +} + std::vector> SceneSession::GetSubSession() const { return subSession_; diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 7bc404d0d..dad1edeb9 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -755,6 +755,28 @@ WSError SessionProxy::UpdateWindowSceneAfterCustomAnimation(bool isAdd) return static_cast(ret); } +WSError SessionProxy::SetLandscapeMultiWindow(bool isLandscapeMultiWindow) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteBool(isLandscapeMultiWindow)) { + WLOGFE("Write isLandscapeMultiWindow failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (Remote()->SendRequest(static_cast(SessionInterfaceCode::TRANS_ID_SET_LANDSCAPE_MULTI_WINDOW), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + int32_t ret = reply.ReadInt32(); + return static_cast(ret); +} + WSError SessionProxy::TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) { MessageParcel data; diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 23d443218..73f04dc94 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -77,6 +77,8 @@ const std::map SessionStub::stubFuncMap_ { &SessionStub::HandleSetWindowAnimationFlag), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_CUSTOM_ANIMATION), &SessionStub::HandleUpdateWindowSceneAfterCustomAnimation), + std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_SET_LANDSCAPE_MULTI_WINDOW), + &SessionStub::HandleSetLandscapeMultiWindow), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_RAISE_ABOVE_TARGET), &SessionStub::HandleRaiseAboveTarget), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_RAISE_APP_MAIN_WINDOW), @@ -478,6 +480,15 @@ int SessionStub::HandleUpdateWindowSceneAfterCustomAnimation(MessageParcel& data return ERR_NONE; } +int SessionStub::HandleSetLandscapeMultiWindow(MessageParcel& data, MessageParcel& reply) +{ + WLOGD("HandleSetLandscapeMultiWindow!"); + bool isLandscapeMultiWindow = data.ReadBool(); + const WSError errCode = SetLandscapeMultiWindow(isLandscapeMultiWindow); + reply.WriteUint32(static_cast(errCode)); + return ERR_NONE; +} + int SessionStub::HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply) { WLOGFD("HandleTransferAbilityResult!"); diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 3a4977448..25295fb84 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -172,6 +172,7 @@ public: virtual void SetColorSpace(ColorSpace colorSpace) override; virtual ColorSpace GetColorSpace() override; WSError NotifyTouchOutside() override; + WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; WSError NotifyWindowVisibility(bool isVisible) override; WMError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 542e2474c..094b7a6f2 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -981,6 +981,16 @@ WMError WindowSessionImpl::HideNonSystemFloatingWindows(bool shouldHide) return UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS); } +WMError WindowSessionImpl::SetLandscapeMultiWindow(bool isLandscapeMultiWindow) +{ + WLOGI("SetLandscapeMultiWindow"); + if (IsWindowSessionInvalid()) { + return WMError::WM_ERROR_INVALID_WINDOW; + } + hostSession_->SetLandscapeMultiWindow(isLandscapeMultiWindow); + return WMError::WM_OK; +} + WMError WindowSessionImpl::SetSingleFrameComposerEnabled(bool enable) { WLOGFD("Set the enable flag of single frame composer."); -- Gitee From cf9436e7c95355c13d48a747af368ab0de14a42d Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 25 Mar 2024 11:23:34 +0800 Subject: [PATCH 164/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index aea85c9cc..441084a19 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -28,7 +28,6 @@ namespace Rosen { using namespace AbilityRuntime; using namespace Ace; namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipWindowManager"}; const std::set VIDEO_PLAY_CONTROLS { PiPControlGroup::VIDEO_PREVIOUS_NEXT, PiPControlGroup::FAST_FORWARD_BACKWARD, -- Gitee From 133339f8c7dfac2c3f5ca75fb18821a79d1c4fe1 Mon Sep 17 00:00:00 2001 From: xiazhiqi Date: Mon, 25 Mar 2024 02:57:08 +0000 Subject: [PATCH 165/385] fix comments2 Signed-off-by: xiazhiqi Change-Id: I538dbc510e186879ec7cbcebbfe18c029e9eff63 --- .../window_manager_napi/js_window_manager.cpp | 2 +- .../window_runtime/window_napi/js_window.cpp | 41 ------------------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index ff1904f05..29c479182 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -809,7 +809,7 @@ static napi_value GetTopWindowTask(void* contextPtr, napi_env env, napi_value ca return; } task.Resolve(env, CreateJsWindowObject(env, lists->window)); - WLOGD("Get top window %{public}s success", windowName.c_str()); + WLOGD("Get top window success"); }; napi_value result = nullptr; NapiAsyncTask::Schedule("JsWindowManager::OnGetTopWindow", diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index b9f9c5be3..4e50d5a75 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -3002,47 +3002,6 @@ napi_value JsWindow::OnSetWindowKeepScreenOn(napi_env env, napi_callback_info in if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - int x = 10; - x = x + 1; wptr weakToken(windowToken_); std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); NapiAsyncTask::ExecuteCallback execute = [weakToken, keepScreenOn, errCodePtr] () { -- Gitee From b1ed42baee355bf2a06a1e700e25ed958e165f8c Mon Sep 17 00:00:00 2001 From: z00514981 Date: Mon, 25 Mar 2024 14:37:14 +0800 Subject: [PATCH 166/385] =?UTF-8?q?=E6=B2=89=E6=B5=B8=E5=BC=8F=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: z00514981 Change-Id: I2c14232af8a364bb948d81100c9989809ae2895c --- .../window_runtime/window_napi/js_window.cpp | 155 ++++++++++-------- .../js_scene_session.cpp | 1 + .../session/host/src/scene_session.cpp | 26 +-- .../src/scene_session_manager.cpp | 4 +- wm/src/window_scene_session_impl.cpp | 66 +++----- 5 files changed, 125 insertions(+), 127 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index dcc8d855f..e994096db 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -317,12 +317,11 @@ napi_value JsWindow::SetSystemBarProperties(napi_env env, napi_callback_info inf napi_value JsWindow::GetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_IMMS, "GetWindowSystemBarPropertiesSync"); + TLOGD(WmsLogTag::WMS_IMMS, "GetWindowSystemBarPropertiesSync"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetWindowSystemBarPropertiesSync(env, info) : nullptr; } - napi_value JsWindow::SetWindowSystemBarProperties(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::WMS_IMMS, "SetWindowSystemBarProperties"); @@ -1923,10 +1922,9 @@ napi_value JsWindow::OnSetFullScreen(napi_env env, napi_callback_info info) if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { + TLOGE(WmsLogTag::WMS_IMMS, "SetFullScreen failed, ret = %{public}d", ret); task.Reject(env, CreateJsError(env, static_cast(ret), "Window SetFullScreen failed.")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set full screen end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; napi_value lastParam = (argc <= 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); @@ -1973,11 +1971,10 @@ napi_value JsWindow::OnSetLayoutFullScreen(napi_env env, napi_callback_info info if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { + TLOGE(WmsLogTag::WMS_IMMS, "SetLayoutFullScreen failed, ret = %{public}d", ret); task.Reject(env, CreateJsError(env, static_cast(ret), "Window OnSetLayoutFullScreen failed.")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set layout full screen end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; napi_value lastParam = (argc <= 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); napi_value result = nullptr; @@ -2015,8 +2012,8 @@ napi_value JsWindow::OnSetWindowLayoutFullScreen(napi_env env, napi_callback_inf [weakToken, isLayoutFullScreen](napi_env env, NapiAsyncTask& task, int32_t status) { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - task.Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); + task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "Invalidate params.")); return; } @@ -2024,11 +2021,10 @@ napi_value JsWindow::OnSetWindowLayoutFullScreen(napi_env env, napi_callback_inf if (ret == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { + TLOGE(WmsLogTag::WMS_IMMS, "SetWindowLayoutFullScreen failed, ret = %{public}d", ret); task.Reject(env, CreateJsError(env, static_cast(ret), "Window OnSetLayoutFullScreen failed.")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set window layout full screen end, " - "ret = %{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; napi_value lastParam = (argc <= 1) ? nullptr : @@ -2039,6 +2035,28 @@ napi_value JsWindow::OnSetWindowLayoutFullScreen(napi_env env, napi_callback_inf return result; } +static WMError SetSystemBarPropertiesByFlags(std::map& systemBarPropertyFlags, + std::map& systemBarProperties, wptr weakToken) +{ + auto weakWindow = weakToken.promote(); + WMError ret = WMError::WM_OK; + WMError err = WMError::WM_OK; + + for (auto it : systemBarPropertyFlags) { + WindowType type = it.first; + SystemBarPropertyFlag flag = it.second; + if (flag.enableFlag || flag.backgroundColorFlag || flag.contentColorFlag) { + err = weakWindow->SetSystemBarProperty(type, systemBarProperties.at(type)); + if (err != WMError::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty failed, ret = %{public}d", err); + ret = err; + } + } + } + + return ret; +} + napi_value JsWindow::OnSetSystemBarEnable(napi_env env, napi_callback_info info) { WMError errCode = WMError::WM_OK; @@ -2054,6 +2072,7 @@ napi_value JsWindow::OnSetSystemBarEnable(napi_env env, napi_callback_info info) std::map systemBarPropertyFlags; if (errCode == WMError::WM_OK && !GetSystemBarStatus(systemBarProperties, systemBarPropertyFlags, env, info, windowToken_)) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to systemBarProperties"); errCode = WMError::WM_ERROR_INVALID_PARAM; } wptr weakToken(windowToken_); @@ -2061,6 +2080,7 @@ napi_value JsWindow::OnSetSystemBarEnable(napi_env env, napi_callback_info info) (napi_env env, NapiAsyncTask& task, int32_t status) mutable { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); errCode = WMError::WM_ERROR_NULLPTR; } if (errCode != WMError::WM_OK) { @@ -2068,18 +2088,14 @@ napi_value JsWindow::OnSetSystemBarEnable(napi_env env, napi_callback_info info) return; } UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, weakToken); - WMError ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR)); - ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR)); + WMError ret = SetSystemBarPropertiesByFlags( + systemBarPropertyFlags, systemBarProperties, weakToken); if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { task.Reject(env, CreateJsError(env, static_cast(ret), "JsWindow::OnSetSystemBarEnable failed")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set system bar enable end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; napi_value lastParam = nullptr; if (argc > 0 && GetType(env, argv[0]) == napi_function) { @@ -2104,6 +2120,7 @@ napi_value JsWindow::OnSetWindowSystemBarEnable(napi_env env, napi_callback_info napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (errCode == WmErrorCode::WM_OK && (argc < 1 || // 1: params num !GetSystemBarStatus(systemBarProperties, systemBarPropertyFlags, env, info, windowToken_))) { + TLOGE(WmsLogTag::WMS_IMMS, "invalid param or argc:%{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } wptr weakToken(windowToken_); @@ -2112,18 +2129,13 @@ napi_value JsWindow::OnSetWindowSystemBarEnable(napi_env env, napi_callback_info auto weakWindow = weakToken.promote(); errCode = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : errCode; if (errCode != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); task.Reject(env, CreateJsError(env, static_cast(errCode))); return; } UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, weakToken); - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetSystemBarProperty( - WindowType::WINDOW_TYPE_STATUS_BAR, systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR))); - if (ret != WmErrorCode::WM_OK) { - task.Reject(env, CreateJsError(env, - static_cast(ret), "JsWindow::OnSetWindowSystemBarEnable failed")); - } - ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR))); + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at( + SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, weakToken)); if (ret == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { @@ -2146,26 +2158,27 @@ napi_value JsWindow::OnSetWindowSystemBarEnable(napi_env env, napi_callback_info napi_value JsWindow::OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_info info) { std::map systemBarProperties; - std::map systemBarPropertyFlags; WmErrorCode err = (windowToken_ == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : WmErrorCode::WM_OK; size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); std::string name; if (!ConvertFromJsValue(env, argv[0], name)) { - WLOGFE("Failed to convert parameter to SystemBarName"); + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to SystemBarName"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } if (err == WmErrorCode::WM_OK && (argc < 1 || // 1: params num !GetSpecificBarStatus(systemBarProperties, env, info, windowToken_))) { + TLOGE(WmsLogTag::WMS_IMMS, "invalid param or argc:%{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } wptr weakToken(windowToken_); - NapiAsyncTask::CompleteCallback complete = [weakToken, systemBarProperties, systemBarPropertyFlags, name, err] + NapiAsyncTask::CompleteCallback complete = [weakToken, systemBarProperties, name, err] (napi_env env, NapiAsyncTask& task, int32_t status) mutable { auto weakWindow = weakToken.promote(); err = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : err; if (err != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); task.Reject(env, CreateJsError(env, static_cast(err))); return; } @@ -2183,6 +2196,7 @@ napi_value JsWindow::OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_i if (err == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { + TLOGE(WmsLogTag::WMS_IMMS, "SetSpecificSystemBarEnabled failed, ret = %{public}d", err); task.Reject(env, CreateJsError(env, static_cast(err), "JsWindow::OnSetSpecificSystemBarEnabled failed")); } @@ -2197,6 +2211,7 @@ napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info i { WMError errCode = WMError::WM_OK; if (windowToken_ == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "windowToken_ is nullptr"); errCode = WMError::WM_ERROR_NULLPTR; } size_t argc = 4; @@ -2212,6 +2227,7 @@ napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info i napi_value nativeObj = argv[0]; if (nativeObj == nullptr || !SetSystemBarPropertiesFromJs(env, nativeObj, systemBarProperties, systemBarPropertyFlags, windowToken_)) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to systemBarProperties"); errCode = WMError::WM_ERROR_INVALID_PARAM; } } @@ -2220,6 +2236,7 @@ napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info i (napi_env env, NapiAsyncTask& task, int32_t status) mutable { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "windowToken is nullptr"); errCode = WMError::WM_ERROR_NULLPTR; } if (errCode != WMError::WM_OK) { @@ -2227,18 +2244,14 @@ napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info i return; } UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, weakToken); - WMError ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR)); - ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR)); + WMError ret = SetSystemBarPropertiesByFlags( + systemBarPropertyFlags, systemBarProperties, weakToken); if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { task.Reject(env, CreateJsError(env, static_cast(WMError::WM_ERROR_NULLPTR), "JsWindow::OnSetSystemBarProperties failed")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set prop end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; napi_value lastParam = (argc <= 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); @@ -2248,26 +2261,6 @@ napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info i return result; } -napi_value JsWindow::OnGetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info) -{ - wptr weakToken(windowToken_); - auto weakWindow = weakToken.promote(); - if (weakWindow == nullptr) { - TLOGE(WmsLogTag::WMS_IMMS, "window is null"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); - } - if (!WindowHelper::IsMainWindow(weakWindow->GetType())) { - TLOGE(WmsLogTag::WMS_IMMS, "only main window has right to call"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); - } - auto objValue = CreateJsSystemBarPropertiesObject(env, weakWindow); - if (objValue == nullptr) { - TLOGE(WmsLogTag::WMS_IMMS, "get properties failed"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY); - } - return objValue; -} - napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_info info) { WmErrorCode errCode = WmErrorCode::WM_OK; @@ -2276,6 +2269,7 @@ napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_ napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { // 2: maximum params num + TLOGE(WmsLogTag::WMS_IMMS, "Argc is invalid: %{public}zu", argc); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } std::map systemBarProperties; @@ -2284,6 +2278,7 @@ napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_ napi_value nativeObj = argv[0]; if (nativeObj == nullptr || !SetSystemBarPropertiesFromJs(env, nativeObj, systemBarProperties, systemBarPropertyFlags, windowToken_)) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to systemBarProperties"); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } } @@ -2297,22 +2292,19 @@ napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_ auto weakWindow = weakToken.promote(); errCode = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : errCode; if (errCode != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); task.Reject(env, CreateJsError(env, static_cast(errCode))); return; } UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, weakToken); - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetSystemBarProperty( - WindowType::WINDOW_TYPE_STATUS_BAR, systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR))); - if (ret != WmErrorCode::WM_OK) { - task.Reject(env, CreateJsError(env, static_cast(ret))); - } - ret = WM_JS_TO_ERROR_CODE_MAP.at( - weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR))); - if (ret != WmErrorCode::WM_OK) { - task.Reject(env, CreateJsError(env, static_cast(ret))); + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at( + SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, weakToken)); + if (ret == WmErrorCode::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, CreateJsError(env, + static_cast(ret), "JsWindow::OnSetWindowSystemBarProperties failed")); } - task.Resolve(env, NapiGetUndefined(env)); }; napi_value lastParam = (argc <= 1) ? nullptr : @@ -2323,6 +2315,26 @@ napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_ return result; } +napi_value JsWindow::OnGetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info) +{ + wptr weakToken(windowToken_); + auto weakWindow = weakToken.promote(); + if (weakWindow == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "window is null"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + if (!WindowHelper::IsMainWindow(weakWindow->GetType())) { + TLOGE(WmsLogTag::WMS_IMMS, "only main window has right to call"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + } + auto objValue = CreateJsSystemBarPropertiesObject(env, weakWindow); + if (objValue == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "get properties failed"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY); + } + return objValue; +} + static void ParseAvoidAreaParam(napi_env env, napi_callback_info info, WMError& errCode, AvoidAreaType& avoidAreaType) { size_t argc = 4; @@ -2370,6 +2382,7 @@ napi_value JsWindow::OnGetAvoidArea(napi_env env, napi_callback_info info) AvoidArea avoidArea; WMError ret = weakWindow->GetAvoidAreaByType(avoidAreaType, avoidArea); if (ret != WMError::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "GetAvoidArea failed, ret = %{public}d", ret); avoidArea.topRect_ = g_emptyRect; avoidArea.leftRect_ = g_emptyRect; avoidArea.rightRect_ = g_emptyRect; @@ -2379,11 +2392,10 @@ napi_value JsWindow::OnGetAvoidArea(napi_env env, napi_callback_info info) if (avoidAreaObj != nullptr) { task.Resolve(env, avoidAreaObj); } else { + TLOGE(WmsLogTag::WMS_IMMS, "ConvertAvoidAreaToJsValue failed"); task.Reject(env, CreateJsError(env, static_cast(WMError::WM_ERROR_NULLPTR), "JsWindow::OnGetAvoidArea failed")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] get avoid area end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -2403,6 +2415,7 @@ napi_value JsWindow::OnGetWindowAvoidAreaSync(napi_env env, napi_callback_info i napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { // 1: params num + TLOGE(WmsLogTag::WMS_IMMS, "invalid argc:%{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } AvoidAreaType avoidAreaType = AvoidAreaType::TYPE_SYSTEM; @@ -2418,33 +2431,31 @@ napi_value JsWindow::OnGetWindowAvoidAreaSync(napi_env env, napi_callback_info i WmErrorCode::WM_ERROR_INVALID_PARAM : WmErrorCode::WM_OK; } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { + TLOGE(WmsLogTag::WMS_IMMS, "invalid param"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } wptr weakToken(windowToken_); auto window = weakToken.promote(); if (window == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } // getAvoidRect by avoidAreaType AvoidArea avoidArea; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->GetAvoidAreaByType(avoidAreaType, avoidArea)); if (ret != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "GetWindowAvoidAreaSync failed, ret = %{public}d", ret); avoidArea.topRect_ = g_emptyRect; avoidArea.leftRect_ = g_emptyRect; avoidArea.rightRect_ = g_emptyRect; avoidArea.bottomRect_ = g_emptyRect; } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] get avoid area type %{public}d end, ret %{public}d " - "top{%{public}d,%{public}d,%{public}d,%{public}d}, down{%{public}d,%{public}d,%{public}d,%{public}d}", - window->GetWindowId(), window->GetWindowName().c_str(), avoidAreaType, ret, - avoidArea.topRect_.posX_, avoidArea.topRect_.posY_, avoidArea.topRect_.width_, avoidArea.topRect_.height_, - avoidArea.bottomRect_.posX_, avoidArea.bottomRect_.posY_, avoidArea.bottomRect_.width_, - avoidArea.bottomRect_.height_); napi_value avoidAreaObj = ConvertAvoidAreaToJsValue(env, avoidArea, avoidAreaType); if (avoidAreaObj != nullptr) { return avoidAreaObj; } else { + TLOGE(WmsLogTag::WMS_IMMS, "ConvertAvoidAreaToJsValue failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } } diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 9a6b654f5..07b4046d6 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -1997,6 +1997,7 @@ void JsSceneSession::OnSystemBarPropertyChange(const std::unordered_map lock(jsCbMapMutex_); auto iter = jsCbMap_.find(SYSTEMBAR_PROPERTY_CHANGE_CB); if (iter == jsCbMap_.end()) { + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]fail to find systemBar property change callback"); return; } jsCallBack = iter->second; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1fd834691..cc5f1bfe4 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -646,15 +646,16 @@ WSError SceneSession::BindDialogSessionTarget(const sptr& sceneSes WSError SceneSession::SetSystemBarProperty(WindowType type, SystemBarProperty systemBarProperty) { + TLOGD(WmsLogTag::WMS_IMMS, "persistentId():%{public}u type:%{public}u" + "enable:%{public}u bgColor:%{public}x Color:%{public}x", + GetPersistentId(), static_cast(type), + systemBarProperty.enable_, systemBarProperty.backgroundColor_, systemBarProperty.contentColor_); auto property = GetSessionProperty(); if (property == nullptr) { + TLOGE(WmsLogTag::WMS_DIALOG, "property is null"); return WSError::WS_ERROR_NULLPTR; } property->SetSystemBarProperty(type, systemBarProperty); - TLOGI(WmsLogTag::WMS_IMMS, "SceneSession SetSystemBarProperty persistentId():%{public}u type:%{public}u" - "enable:%{public}u bgColor:%{public}x Color:%{public}x", - GetPersistentId(), static_cast(type), - systemBarProperty.enable_, systemBarProperty.backgroundColor_, systemBarProperty.contentColor_); if (sessionChangeCallback_ != nullptr && sessionChangeCallback_->OnSystemBarPropertyChange_) { sessionChangeCallback_->OnSystemBarPropertyChange_(property->GetSystemBarProperty()); } @@ -832,12 +833,12 @@ void SceneSession::GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea) } sptr cutoutInfo = display->GetCutoutInfo(); if (cutoutInfo == nullptr) { - TLOGI(WmsLogTag::WMS_IMMS, "GetCutoutAvoidArea There is no CutoutInfo"); + TLOGI(WmsLogTag::WMS_IMMS, "There is no CutoutInfo"); return; } std::vector cutoutAreas = cutoutInfo->GetBoundingRects(); if (cutoutAreas.empty()) { - TLOGI(WmsLogTag::WMS_IMMS, "GetCutoutAvoidArea There is no cutoutAreas"); + TLOGI(WmsLogTag::WMS_IMMS, "There is no cutoutAreas"); return; } for (auto& cutoutArea : cutoutAreas) { @@ -879,20 +880,23 @@ AvoidArea SceneSession::GetAvoidAreaByType(AvoidAreaType type) session->GetSystemAvoidArea(rect, avoidArea); return avoidArea; } - case AvoidAreaType::TYPE_KEYBOARD: { - session->GetKeyboardAvoidArea(rect, avoidArea); - return avoidArea; - } case AvoidAreaType::TYPE_CUTOUT: { session->GetCutoutAvoidArea(rect, avoidArea); return avoidArea; } + case AvoidAreaType::TYPE_SYSTEM_GESTURE: { + return avoidArea; + } + case AvoidAreaType::TYPE_KEYBOARD: { + session->GetKeyboardAvoidArea(rect, avoidArea); + return avoidArea; + } case AvoidAreaType::TYPE_NAVIGATION_INDICATOR: { session->GetAINavigationBarArea(rect, avoidArea); return avoidArea; } default: { - TLOGI(WmsLogTag::WMS_IMMS, "cannot find avoidAreaType:%{public}u, id:%{public}d", + TLOGE(WmsLogTag::WMS_IMMS, "cannot find avoidAreaType:%{public}u, id:%{public}d", type, session->GetPersistentId()); return avoidArea; } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 738a05aa7..6ecdb8c21 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2667,8 +2667,8 @@ void SceneSessionManager::HandleSpecificSystemBarProperty(WindowType type, const for (auto iter : systemBarProperties) { if (iter.first == type) { sceneSession->SetSystemBarProperty(iter.first, iter.second); - WLOGFD("SetSystemBarProperty: %{public}d, enable: %{public}d", - static_cast(iter.first), iter.second.enable_); + TLOGD(WmsLogTag::WMS_IMMS, "SetSystemBarProperty: %{public}d, enable: %{public}d", + static_cast(iter.first), iter.second.enable_); } } NotifyWindowInfoChange(property->GetPersistentId(), WindowUpdateType::WINDOW_UPDATE_PROPERTY); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 192701328..0df14763a 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1262,8 +1262,6 @@ WmErrorCode WindowSceneSessionImpl::RaiseAboveTarget(int32_t subWindowId) WMError WindowSceneSessionImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea) { uint32_t windowId = GetWindowId(); - TLOGI(WmsLogTag::WMS_IMMS, - "GetAvoidAreaByType windowId:%{public}u type:%{public}u", windowId, static_cast(type)); WindowMode mode = GetMode(); if (type != AvoidAreaType::TYPE_KEYBOARD && mode != WindowMode::WINDOW_MODE_FULLSCREEN && @@ -1278,9 +1276,16 @@ WMError WindowSceneSessionImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea return WMError::WM_OK; } if (hostSession_ == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "hostSession_ is null"); return WMError::WM_ERROR_NULLPTR; } avoidArea = hostSession_->GetAvoidAreaByType(type); + TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] type %{public}d " + "top{%{public}d, %{public}d, %{public}d, %{public}d}, down{%{public}d, %{public}d, %{public}d, %{public}d}", + windowId, GetWindowName().c_str(), type, + avoidArea.topRect_.posX_, avoidArea.topRect_.posY_, avoidArea.topRect_.width_, avoidArea.topRect_.height_, + avoidArea.bottomRect_.posX_, avoidArea.bottomRect_.posY_, avoidArea.bottomRect_.width_, + avoidArea.bottomRect_.height_); return WMError::WM_OK; } @@ -1350,8 +1355,8 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreenByApiVersion(bool status) WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) { - TLOGI(WmsLogTag::WMS_IMMS, - "winId:%{public}u status:%{public}d", GetWindowId(), static_cast(status)); + TLOGI(WmsLogTag::WMS_IMMS, "winId:%{public}u %{public}s status:%{public}d", + GetWindowId(), GetWindowName().c_str(), static_cast(status)); if (hostSession_ == nullptr) { return WMError::WM_ERROR_NULLPTR; } @@ -1399,7 +1404,7 @@ SystemBarProperty WindowSceneSessionImpl::GetSystemBarPropertyByType(WindowType WMError WindowSceneSessionImpl::NotifyWindowSessionProperty() { - TLOGD(WmsLogTag::WMS_IMMS, "NotifyWindowSessionProperty called windowId:%{public}u", GetWindowId()); + TLOGD(WmsLogTag::WMS_IMMS, "windowId:%{public}u", GetWindowId()); if (IsWindowSessionInvalid()) { TLOGE(WmsLogTag::WMS_IMMS, "session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; @@ -1410,16 +1415,11 @@ WMError WindowSceneSessionImpl::NotifyWindowSessionProperty() WMError WindowSceneSessionImpl::NotifySpecificWindowSessionProperty(WindowType type, const SystemBarProperty& property) { - WLOGFD("NotifySpecificWindowSessionProperty called windowId:%{public}u", GetWindowId()); + TLOGD(WmsLogTag::WMS_IMMS, "windowId:%{public}u", GetWindowId()); if (IsWindowSessionInvalid()) { - WLOGFE("session is invalid"); + TLOGE(WmsLogTag::WMS_IMMS, "session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; } - if ((state_ == WindowState::STATE_CREATED && - property_->GetModeSupportInfo() != WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) || - state_ == WindowState::STATE_HIDDEN) { - return WMError::WM_OK; - } if (type == WindowType::WINDOW_TYPE_STATUS_BAR) { UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS); } else if (type == WindowType::WINDOW_TYPE_NAVIGATION_BAR) { @@ -1430,62 +1430,44 @@ WMError WindowSceneSessionImpl::NotifySpecificWindowSessionProperty(WindowType t return WMError::WM_OK; } -WMError WindowSceneSessionImpl::SetSystemBarProperty(WindowType type, const SystemBarProperty& property) +WMError WindowSceneSessionImpl::SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) { - TLOGI(WmsLogTag::WMS_IMMS, "SetSystemBarProperty windowId:%{public}u type:%{public}u" + TLOGI(WmsLogTag::WMS_IMMS, "windowId:%{public}u %{public}s type:%{public}u" "enable:%{public}u bgColor:%{public}x Color:%{public}x", - GetWindowId(), static_cast(type), + GetWindowId(), GetWindowName().c_str(), static_cast(type), property.enable_, property.backgroundColor_, property.contentColor_); if (!((state_ > WindowState::STATE_INITIAL) && (state_ < WindowState::STATE_BOTTOM))) { - TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty windowId:%{public}u state is invalid", GetWindowId()); + TLOGE(WmsLogTag::WMS_IMMS, "windowId:%{public}u state is invalid", GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } else if (GetSystemBarPropertyByType(type) == property) { - TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty windowId:%{public}u property is same", GetWindowId()); + TLOGI(WmsLogTag::WMS_IMMS, "windowId:%{public}u property is same", GetWindowId()); return WMError::WM_OK; } if (property_ == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "property_ is null"); return WMError::WM_ERROR_NULLPTR; } isSystembarPropertiesSet_ = true; property_->SetSystemBarProperty(type, property); - WMError ret = NotifyWindowSessionProperty(); + WMError ret = NotifySpecificWindowSessionProperty(type, property); if (ret != WMError::WM_OK) { - TLOGE(WmsLogTag::WMS_IMMS, "NotifyWindowSessionProperty winId:%{public}u errCode:%{public}d", + TLOGE(WmsLogTag::WMS_IMMS, "winId:%{public}u errCode:%{public}d", GetWindowId(), static_cast(ret)); } return ret; } -WMError WindowSceneSessionImpl::SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) +WMError WindowSceneSessionImpl::SetSystemBarProperty(WindowType type, const SystemBarProperty& property) { - WLOGFI("SetSystemBarProperty windowId:%{public}u type:%{public}u" - "enable:%{public}u bgColor:%{public}x Color:%{public}x", - GetWindowId(), static_cast(type), - property.enable_, property.backgroundColor_, property.contentColor_); - if (!((state_ > WindowState::STATE_INITIAL) && (state_ < WindowState::STATE_BOTTOM))) { - return WMError::WM_ERROR_INVALID_WINDOW; - } else if (GetSystemBarPropertyByType(type) == property) { - return WMError::WM_OK; - } - - if (property_ == nullptr) { - return WMError::WM_ERROR_NULLPTR; - } - isSystembarPropertiesSet_ = true; - property_->SetSystemBarProperty(type, property); - WMError ret = NotifySpecificWindowSessionProperty(type, property); - if (ret != WMError::WM_OK) { - WLOGFE("NotifySpecificWindowSessionProperty winId:%{public}u errCode:%{public}d", - GetWindowId(), static_cast(ret)); - } - return ret; + return SetSpecificBarProperty(type, property); } WMError WindowSceneSessionImpl::SetFullScreen(bool status) { TLOGI(WmsLogTag::WMS_IMMS, - "winId:%{public}u status:%{public}d", GetWindowId(), static_cast(status)); + "winId:%{public}u %{public}s status:%{public}d", + GetWindowId(), GetWindowName().c_str(), static_cast(status)); if (hostSession_ == nullptr) { return WMError::WM_ERROR_NULLPTR; } -- Gitee From 6d8eb12ab6595d8a1ba7d599ca305c8119d551f6 Mon Sep 17 00:00:00 2001 From: yxn Date: Fri, 22 Mar 2024 16:47:11 +0800 Subject: [PATCH 167/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=93=9D=E5=8C=BASet?= =?UTF-8?q?WindowBrightness=E4=BC=A0=E5=8F=82-1=E8=BF=94=E5=9B=9E=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=A0=81401=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yxn --- wm/src/window_impl.cpp | 4 +++- wmserver/src/window_root.cpp | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index a880189b3..0010b38fa 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -1780,7 +1780,9 @@ WMError WindowImpl::SetBrightness(float brightness) if (!IsWindowValid()) { return WMError::WM_ERROR_INVALID_WINDOW; } - if (brightness < MINIMUM_BRIGHTNESS || brightness > MAXIMUM_BRIGHTNESS) { + if ((brightness < MINIMUM_BRIGHTNESS && + std::fabs(brightness - UNDEFINED_BRIGHTNESS) >= std::numeric_limits::min()) || + brightness > MAXIMUM_BRIGHTNESS) { WLOGFE("invalid brightness value: %{public}f", brightness); return WMError::WM_ERROR_INVALID_PARAM; } diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index 68d91217f..f020945b0 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -904,8 +904,20 @@ void WindowRoot::SetBrightness(uint32_t windowId, float brightness) WLOGW("Only app window support set brightness"); return; } - if (windowId == container->GetActiveWindow()) { - if (container->GetDisplayBrightness() != brightness) { + if (windowId != container->GetActiveWindow()) { + WLOGE("Window is not active with windowId:%{public}d", windowId); + return; + } + if (std::fabs(brightness - UNDEFINED_BRIGHTNESS) <= std::numeric_limits::min()) { + if (std::fabs(container->GetDisplayBrightness() - brightness) > std::numeric_limits::min()) { + WLOGFI("value: %{public}f to restore brightness", brightness); +#ifdef POWERMGR_DISPLAY_MANAGER_ENABLE + DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().RestoreBrightness(); +#endif + container->SetDisplayBrightness(brightness); + } + } else { + if (std::fabs(container->GetDisplayBrightness() - brightness) > std::numeric_limits::min()) { WLOGFI("value: %{public}u", container->ToOverrideBrightness(brightness)); #ifdef POWERMGR_DISPLAY_MANAGER_ENABLE DisplayPowerMgr::DisplayPowerMgrClient::GetInstance().OverrideBrightness( @@ -913,8 +925,8 @@ void WindowRoot::SetBrightness(uint32_t windowId, float brightness) #endif container->SetDisplayBrightness(brightness); } - container->SetBrightnessWindow(windowId); } + container->SetBrightnessWindow(windowId); } void WindowRoot::HandleKeepScreenOn(uint32_t windowId, bool requireLock) -- Gitee From 05f0ac6a4cc79257ad05026c5b833cf0584cf66b Mon Sep 17 00:00:00 2001 From: zhangzhicong Date: Mon, 25 Mar 2024 15:09:42 +0800 Subject: [PATCH 168/385] add getPreferredOrientation Signed-off-by: zhangzhicong --- .../napi/window_runtime/window_napi/js_window.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 345085135..1eb2c6a15 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2578,8 +2578,16 @@ napi_value JsWindow::OnGetPreferredOrientation(napi_env env, napi_callback_info return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } Orientation requestedOrientation = weakWindow->GetRequestedOrientation(); - napi_value result = nullptr; - return result; + ApiOrientation apiOrientation = ApiOrientation::UNSPECIFIED; + if (requestedOrientation >= ApiOrientation::UNSPECIFIED && requestedOrientation <= ApiOrientation::LOCKED) { + apiOrientation = NATIVE_TO_JS_ORIENTATION_MAP.at(requestedOrientation); + } else { + WLOGFE("OnGetPreferredOrientation Orientation %{public}u invalid!", + static_cast(requestedOrientation)); + } + WLOGI("Window [%{public}u, %{public}s] OnGetPreferredOrientation end, Orientation = %{public}u", + window->GetWindowId(), window->GetWindowName().c_str(), static_cast(apiOrientation)); + return CreateJsValue(env, static_cast(apiOrientation)); } napi_value JsWindow::OnIsSupportWideGamut(napi_env env, napi_callback_info info) -- Gitee From bc8325b77174521126524a4154c478d7ec7721e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Mon, 25 Mar 2024 15:26:15 +0800 Subject: [PATCH 169/385] add setWindowMask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- interfaces/innerkits/wm/window.h | 11 ++++ .../window_runtime/window_napi/js_window.cpp | 53 +++++++++++++++++++ .../window_runtime/window_napi/js_window.h | 2 + .../window_napi/js_window_utils.cpp | 19 +++++++ .../window_napi/js_window_utils.h | 1 + window_scene/common/BUILD.gn | 1 + .../common/include/window_session_property.h | 10 ++++ .../common/src/window_session_property.cpp | 48 ++++++++++++++++- .../interfaces/include/ws_common_inner.h | 1 + .../src/scene_session_dirty_manager.cpp | 4 +- wm/include/window_scene_session_impl.h | 2 + wm/src/window_scene_session_impl.cpp | 52 ++++++++++++++++++ 12 files changed, 202 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 7685a3140..ebb130a5c 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1721,6 +1721,17 @@ public: * @return WM_OK means remove success, others means failed. */ virtual WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + + /** + * @brief Set Shaped Window Mask. + * + * @param windowMask Mask of the shaped window. + * @return WM_OK means set success, others means failed. + */ + virtual WMError SetWindowMask(const std::vector>& windowMask) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } }; } } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 619a30980..76c1e4c92 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -750,6 +750,13 @@ napi_value JsWindow::GetTitleButtonRect(napi_env env, napi_callback_info info) return (me != nullptr) ? me->OnGetTitleButtonRect(env, info) : nullptr; } +napi_value JsWindow::SetWindowMask(napi_env env, napi_callback_info info) +{ + WLOGI("[NAPI]SetWindowMask"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetWindowMask(env, info) : nullptr; +} + static void UpdateSystemBarProperties(std::map& systemBarProperties, const std::map& systemBarPropertyFlags, wptr weakToken) { @@ -5150,6 +5157,51 @@ napi_value JsWindow::OnGetTitleButtonRect(napi_env env, napi_callback_info info) return TitleButtonAreaObj; } +napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) +{ + WmErrorCode errCode = WmErrorCode::WM_OK; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < 1) { + WLOGFE("Argc is invalid: %{piblic}zu", argc); + errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; + } + std::vector> windowMask; + if (errCode == WmErrorCode::WM_OK) { + if (!GetWindowMaskFromJsValue(env, argv[0], windowMask)) { + WLOGFE("GetWindowMaskFromJsValue failed"); + errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; + } + } + if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [waekToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) { + auto waekWindow = waekToken.promote(); + if (waekWindow == nullptr) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "Invalidate params")); + return; + } + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetWindowMask(windowMask)); + if (ret != WmErrorCode::WM_OK) { + task.Reject(env, CreateJsError(env, static_cast(ret))); + WLOGI("Window [%{public}u, %{public}s] set window mask failed", + waekWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); + return; + } + task.Resolve(env, NapiGetUndefined(env)); + WLOGI("Window [%{public}u, %{public}s] set window mask succeed", + waekWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); + }; + napi_value lastParam = (argc <= 1) ? nullptr : + ((argv[1] != nullptr && GetType)) +} + void BindFunctions(napi_env env, napi_value object, const char *moduleName) { BindNativeFunction(env, object, "show", moduleName, JsWindow::Show); @@ -5249,6 +5301,7 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setWindowDecorHeight", moduleName, JsWindow::SetWindowDecorHeight); BindNativeFunction(env, object, "getWindowDecorHeight", moduleName, JsWindow::GetWindowDecorHeight); BindNativeFunction(env, object, "getTitleButtonRect", moduleName, JsWindow::GetTitleButtonRect); + BindNativeFunction(env, object, "setWindowMask", moduleName, JsWindow::SetWindowMask); } } // namespace Rosen } // namespace OHOS diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 536868632..41da93523 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -142,6 +142,7 @@ public: static napi_value SetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetTitleButtonRect(napi_env env, napi_callback_info info); + static napi_value SetWindowMask(napi_env env, napi_callback_info info); private: std::string GetWindowName(); static bool ParseScaleOption(napi_env env, napi_value jsObject, Transform& trans); @@ -250,6 +251,7 @@ private: napi_value OnSetBackdropBlur(napi_env env, napi_callback_info info); napi_value OnSetBackdropBlurStyle(napi_env env, napi_callback_info info); napi_value OnSetWaterMarkFlag(napi_env env, napi_callback_info info); + napi_value OnSetWindowMask(napi_env env, napi_callback_info info); sptr windowToken_ = nullptr; std::unique_ptr registerManager_ = nullptr; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 5d3a3dbfa..18a67f7eb 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -836,5 +836,24 @@ bool GetAPI7Ability(napi_env env, AppExecFwk::Ability* &ability) } return true; } +bool GetWindowMaskFromJsValue(napi_env env, napi_value jsObject, std::vector>& windowMask) +{ + if (jsObject == nullptr) { + WLOGFE("Failed to convert parameter to window mask"); + return false; + } + uint32_t size = 0; + for (uint32_t i = 0; i < size; i++) { + std::vector elementArray; + napi_value getElementValue = nullptr; + napi_get_element(env, jsObject, i, &getElementValue); + if (!ConvertNativeValueToVector(env, getElementValue, elementArray)) { + WLOGFE("Failed to convert parameter to window mask"); + return false; + } + windowMask.emplace_back(elementArray); + } + return true; +} } // namespace Rosen } // namespace OHOS diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 5f683bbb5..c4ffd28de 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -219,6 +219,7 @@ struct SystemBarPropertyFlag { napi_value GetWindowLimitsAndConvertToJsValue(napi_env env, const WindowLimits& windowLimits); napi_value ConvertTitleButtonAreaToJsValue(napi_env env, const TitleButtonRect& titleButtonRect); bool GetAPI7Ability(napi_env env, AppExecFwk::Ability* &ability); + bool GetWindowMaskFromJsValue(napi_env env, napi_value jsObject, std::vector>& windowMask); template bool ParseJsValue(napi_value jsObject, napi_env env, const std::string& name, T& data) { diff --git a/window_scene/common/BUILD.gn b/window_scene/common/BUILD.gn index e9cee0156..a035e8dd7 100644 --- a/window_scene/common/BUILD.gn +++ b/window_scene/common/BUILD.gn @@ -55,6 +55,7 @@ ohos_shared_library("window_scene_common") { "input:libmmi-client", "ipc:ipc_single", "samgr:samgr_proxy", + "image_framework:image_native", ] innerapi_tags = [ "platformsdk_indirect" ] diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index d05f39aa5..f6b5a8143 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -25,6 +25,7 @@ #include "wm_common.h" #include "dm_common.h" #include +#include "pixel_map.h" namespace OHOS { namespace Rosen { @@ -77,6 +78,8 @@ public: void SetCallingWindow(uint32_t windowId); void SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo); void SetExtensionFlag(bool isExtensionFlag); + void SetWindowMask(const sptr& windowMask); + void SetIsShaped(bool isShaped); bool GetIsNeedUpdateWindowMode() const; const std::string& GetWindowName() const; @@ -119,6 +122,8 @@ public: uint32_t GetCallingWindow() const; PiPTemplateInfo GetPiPTemplateInfo() const; bool GetExtensionFlag() const; + sptr GetWindowMask() const; + bool GetIsShaped() const; bool MarshallingWindowLimits(Parcel& parcel) const; static void UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property); @@ -128,6 +133,8 @@ public: static void UnmarshallingPiPTemplateInfo(Parcel& parcel, WindowSessionProperty* property); bool Marshalling(Parcel& parcel) const override; static WindowSessionProperty* Unmarshalling(Parcel& parcel); + bool MarshallingWindowMask(Parcel& parcel) const; + static void UnmarshallingWindowMask(Parcel& parcel, WindowSessionProperty* property); void SetTextFieldPositionY(double textFieldPositionY); void SetTextFieldHeight(double textFieldHeight); @@ -198,6 +205,9 @@ private: std::function touchHotAreasChangeCallback_; bool isLayoutFullScreen_ = false; bool isExtensionFlag_ = false; + + bool isShaped_ = false; + sptr windowMask_ = nullptr; }; struct SystemSessionConfig : public Parcelable { diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 0271cbd22..3d20a86cb 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -567,6 +567,28 @@ void WindowSessionProperty::UnmarshallingPiPTemplateInfo(Parcel& parcel, WindowS property->SetPiPTemplateInfo(pipTemplateInfo); } +bool WindowSessionProperty::MarshallingWindowMask(Parcel& parcel) const +{ + if (!parcel.WriteBool(isShaped_)) { + return false; + } + if (isShaped_) { + if (!parcel.WriteParcelable(windowMask_)) { + return false; + } + } + return true; +} + +void WindowSessionProperty::UnmarshallingWindowMask(Parcel& parcel, WindowSessionProperty* property) +{ + bool isShaped_ = parcel.ReadBool(); + property->SetIsShaped(isShaped); + if (isShaped) { + property->SetWindowMask(parcel.ReadParcelable()); + } +} + bool WindowSessionProperty::Marshalling(Parcel& parcel) const { return parcel.WriteString(windowName_) && parcel.WriteInt32(windowRect_.posX_) && @@ -598,7 +620,8 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const parcel.WriteUint32(static_cast(windowState_)) && parcel.WriteBool(isNeedUpdateWindowMode_) && parcel.WriteUint32(callingWindowId_) && parcel.WriteBool(isLayoutFullScreen_) && - parcel.WriteBool(isExtensionFlag_); + parcel.WriteBool(isExtensionFlag_) && + MarshallingWindowMask(parcel); } WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) @@ -651,6 +674,7 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) property->SetCallingWindow(parcel.ReadUint32()); property->SetIsLayoutFullScreen(parcel.ReadBool()); property->SetExtensionFlag(parcel.ReadBool()); + UnmarshallingWindowMask(parcel, property); return property; } @@ -693,6 +717,8 @@ void WindowSessionProperty::CopyFrom(const sptr& property textFieldHeight_ = property->textFieldHeight_; isNeedUpdateWindowMode_ = property->isNeedUpdateWindowMode_; isLayoutFullScreen_ = property->isLayoutFullScreen_; + windowMask_ = property->windowMask_; + isShaped_ = property->isShaped_; } void WindowSessionProperty::SetTransform(const Transform& trans) @@ -749,5 +775,25 @@ bool WindowSessionProperty::GetExtensionFlag() const { return isExtensionFlag_; } + +void WindowSessionProperty::SetWindowMask(const sptr& windowMask) +{ + windowMask_ = windowMask; +} + +sptr WindowSessionProperty::GetWindowMask() const +{ + return windowMask_; +} + +void WindowSessionProperty::SetIsShaped(bool isShaped) const +{ + isShaped_ = isShaped; +} + +bool WindowSessionProperty::GetIsShaped() const +{ + return isShaped_; +} } // namespace Rosen } // namespace OHOS diff --git a/window_scene/interfaces/include/ws_common_inner.h b/window_scene/interfaces/include/ws_common_inner.h index 40be64502..f2904fcea 100644 --- a/window_scene/interfaces/include/ws_common_inner.h +++ b/window_scene/interfaces/include/ws_common_inner.h @@ -52,6 +52,7 @@ enum class WSPropertyChangeAction : uint32_t { ACTION_UPDATE_NAVIGATION_PROPS = 1 << 25, ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS = 1 << 26, ACTION_UPDATE_TEXTFIELD_AVOID_INFO = 1 << 27, + ACTION_UPDATE_WINDOW_MASK = 1 << 28, }; enum class AreaType : uint32_t { diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 47120de5b..793539ab2 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -413,6 +413,7 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr std::vector touchHotAreas; std::vector pointerHotAreas; UpdateHotAreas(sceneSession, touchHotAreas, pointerHotAreas); + auto windowMask = sceneSession->GetSessionProperty()->GetWindowMask(); MMI::WindowInfo windowInfo = { .id = windowId, .pid = sceneSession->IsStartMoving() ? static_cast(getpid()) : pid, @@ -426,7 +427,8 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr .action = static_cast(action), .pointerChangeAreas = pointerChangeAreas, .zOrder = zOrder, - .transform = transformData + .transform = transformData, + .windowMask = windowMask }; return windowInfo; } diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 5c6d26b58..4bc076279 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -138,6 +138,7 @@ public: void ConsumeKeyEvent(std::shared_ptr& keyEvent) override; WSError NotifyDialogStateChange(bool isForeground) override; WMError HideNonSecureWindows(bool shouldHide) override; + WMError SetWindowMask(const std::vector>& windowMsak) const; protected: void DestroySubWindow(); @@ -177,6 +178,7 @@ private: const MMI::PointerEvent::PointerItem& pointerItem); bool HandlePointDownEvent(const std::shared_ptr& pointerEvent, const MMI::PointerEvent::PointerItem& pointerItem, int32_t sourceType, float vpr, const WSRect& rect); + std::unique_ptr HandleWindowMask(const std::vector& windowMask); bool enableDefaultAnimation_ = true; sptr animationTransitionController_; }; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 2b546da70..dad004354 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2794,5 +2794,57 @@ WMError WindowSceneSessionImpl::SetTextFieldAvoidInfo(double textFieldPositionY, UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_TEXTFIELD_AVOID_INFO); return WMError::WM_OK; } + +std::unique_ptr WindowSceneSessionImpl::HandleWindowMask( + const std::vector>& windowMask) +{ + const Rect& windowRect = GetRect(); + uint32_t maskHeight = windowMask.size(); + uint32_t maskeWidth = windowMask[0].size(); + if (windowRect.height_ != maskHeight || windowRect.width_ != maskWidth) { + WLOGFE("WindowMask is invalid"); + return nullptr; + } + Media::InitializationOptions opts; + opts.size.width = maskWidth; + opts.size.height = maskHeight; + opts.pixelFormat = Media::PixelFormat::RGBA_8888; + opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE; + opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE; + uint32_t length = maskeWidth * maskHeight; + uint32_t data = new (std::nothrow) uint32_t[length]; + for (uint32_t i = 0; i < maskHeight; i++) { + for (uint32_t j = 0; j < maskWidth; j++) { + uint32_t idx = i * maskWidth + j; + data[idx] = windowMask[i][j]; + } + } + std::unique_ptr mask = Media::PixelMap::Create(data, length, opts); + delete[] data; + return mask; +} + +WMError WindowSceneSessionImpl::SetWindowMask(const std::vector>& windowMask) +{ + WLOGFI("SetWindowMask, WindowId : %{public}u", GetWindowId()); + if (IsWindowSessionInvalid()) { + WLOGFE("session is invalid"); + return WMError::WM_ERROR_INVALID_WINDOW; + } + + sptr mask = sptr(HandleWindowMask(windowMask).release()); + if (mask == nullptr) { + WLOGFE("Failed to create pixelMap of window mask"); + return WMError::WM_ERROR_INVALID_WINDOW; + } + + surfaceNode_->SetCornerRadius(0.0f); + surfaceNode_->SetShadowRadius(0.0f); + RSTransaction::FlushImplicitTransaction(); + + property_->SetWindowMask(mask); + property_->SetIsShaped(true); + return UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK); +} } // namespace Rosen } // namespace OHOS -- Gitee From a73e381a3a81b048cd913e6a3d3ee2bc70601d52 Mon Sep 17 00:00:00 2001 From: zhangzhicong Date: Mon, 25 Mar 2024 15:47:55 +0800 Subject: [PATCH 170/385] fix screen rotate Signed-off-by: zhangzhicong --- .../napi/extension_window/js_extension_window.cpp | 12 ++++++++++++ .../kits/napi/extension_window/js_extension_window.h | 1 + .../napi/window_runtime/window_napi/js_window.cpp | 1 - .../kits/napi/window_runtime/window_napi/js_window.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index 03ec97c3a..748e49386 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -374,6 +374,18 @@ napi_value JsExtensionWindow::OnSetPreferredOrientation(napi_env env, napi_callb return result; } +napi_value JsExtensionWindow::OnGetPreferredOrientation(napi_env env, napi_callback_info info) +{ + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc >= 1) { + WLOGFE("Argc is invalid: %{public}zu, expect zero params", argc); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); +} + napi_value JsExtensionWindow::OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_info info) { NapiAsyncTask::CompleteCallback complete = diff --git a/interfaces/kits/napi/extension_window/js_extension_window.h b/interfaces/kits/napi/extension_window/js_extension_window.h index 91af0d8d6..0679154ab 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.h +++ b/interfaces/kits/napi/extension_window/js_extension_window.h @@ -75,6 +75,7 @@ private: napi_value OnResizeWindow(napi_env env, napi_callback_info info); napi_value OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_info info); napi_value OnSetPreferredOrientation(napi_env env, napi_callback_info info); + napi_value OnGetPreferredOrientation(napi_env env, napi_callback_info info); napi_value OnGetUIContext(napi_env env, napi_callback_info info); napi_value OnSetWindowBrightness(napi_env env, napi_callback_info info); napi_value OnSetWindowKeepScreenOn(napi_env env, napi_callback_info info); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 1eb2c6a15..7bbbab197 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2563,7 +2563,6 @@ napi_value JsWindow::OnSetPreferredOrientation(napi_env env, napi_callback_info napi_value JsWindow::OnGetPreferredOrientation(napi_env env, napi_callback_info info) { - WmErrorCode errCode = WmErrorCode::WM_OK; size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 90bde9376..a5649b5bc 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -187,6 +187,7 @@ private: napi_value OnIsShowing(napi_env env, napi_callback_info info); napi_value OnIsWindowShowingSync(napi_env env, napi_callback_info info); napi_value OnSetPreferredOrientation(napi_env env, napi_callback_info info); + napi_value OnGetPreferredOrientation(napi_env env, napi_callback_info info); napi_value OnRaiseToAppTop(napi_env env, napi_callback_info info); napi_value OnSetAspectRatio(napi_env env, napi_callback_info info); napi_value OnResetAspectRatio(napi_env env, napi_callback_info info); -- Gitee From b13a156d4d8048dadbc607274cdbd5653b436e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Mon, 25 Mar 2024 15:52:50 +0800 Subject: [PATCH 171/385] update setWindowMask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 76c1e4c92..abfd2c338 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5198,8 +5198,11 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) WLOGI("Window [%{public}u, %{public}s] set window mask succeed", waekWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); }; - napi_value lastParam = (argc <= 1) ? nullptr : - ((argv[1] != nullptr && GetType)) + napi_value lastParam = nullptr; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::SetWindowMask", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; } void BindFunctions(napi_env env, napi_value object, const char *moduleName) -- Gitee From e1bf87fca8ebb2e22c5853b794a0fbf78ef79316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Mon, 25 Mar 2024 15:57:11 +0800 Subject: [PATCH 172/385] update setWindowMask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../session_manager/src/scene_session_manager.cpp | 12 ++++++++++++ wm/src/window_scene_session_impl.cpp | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5aff2319e..315671852 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2630,6 +2630,11 @@ WMError SceneSessionManager::UpdateSessionProperty(const sptrSetSystemCalling(isSystemCalling); @@ -2833,6 +2838,13 @@ WMError SceneSessionManager::HandleUpdateProperty(const sptrSetTextFieldAvoidInfo(property->GetTextFieldPositionY(), property->GetTextFieldHeight()); break; } + case WSPropertyChangeAction::ACTION_UPDATE_WINDOW_MASK: { + if (sceneSession->GetSessionProperty() != nullptr) { + sceneSession->GetSessionProperty()->SetWindowMask(property->GetWindowMask()); + sceneSession->GetSessionProperty()->SetIsShaped(property->GetIsShaped()); + } + FlushWindowInfoToMMI(); + } default: break; } diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index dad004354..3e1932cbe 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2813,6 +2813,10 @@ std::unique_ptr WindowSceneSessionImpl::HandleWindowMask( opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE; uint32_t length = maskeWidth * maskHeight; uint32_t data = new (std::nothrow) uint32_t[length]; + if (data == nullptr) { + WLOGFE("data is nullptr"); + return nullptr; + } for (uint32_t i = 0; i < maskHeight; i++) { for (uint32_t j = 0; j < maskWidth; j++) { uint32_t idx = i * maskWidth + j; -- Gitee From 9285b95f9a9728d16a93c769f5fd243cc6bfcd0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Mon, 25 Mar 2024 16:09:44 +0800 Subject: [PATCH 173/385] update setWindowMask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 6 +++--- .../napi/window_runtime/window_napi/js_window_utils.cpp | 1 + wm/src/window_scene_session_impl.cpp | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index abfd2c338..8fc3070cb 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5180,7 +5180,7 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) wptr weakToken(windowToken_); NapiAsyncTask::CompleteCallback complete = [waekToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) { - auto waekWindow = waekToken.promote(); + auto weakWindow = weakToken.promote(); if (waekWindow == nullptr) { task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), @@ -5191,12 +5191,12 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) if (ret != WmErrorCode::WM_OK) { task.Reject(env, CreateJsError(env, static_cast(ret))); WLOGI("Window [%{public}u, %{public}s] set window mask failed", - waekWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); + weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); return; } task.Resolve(env, NapiGetUndefined(env)); WLOGI("Window [%{public}u, %{public}s] set window mask succeed", - waekWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); + weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); }; napi_value lastParam = nullptr; napi_value result = nullptr; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 18a67f7eb..b31f29ad3 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -843,6 +843,7 @@ bool GetWindowMaskFromJsValue(napi_env env, napi_value jsObject, std::vector elementArray; napi_value getElementValue = nullptr; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 3e1932cbe..807665a23 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2844,6 +2844,7 @@ WMError WindowSceneSessionImpl::SetWindowMask(const std::vectorSetCornerRadius(0.0f); surfaceNode_->SetShadowRadius(0.0f); + surfaceNode_->SetMask(mask);//RS interface to set mask RSTransaction::FlushImplicitTransaction(); property_->SetWindowMask(mask); -- Gitee From 84f167be9328295d84af55cdd9a3d36d99ad4b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Mon, 25 Mar 2024 16:11:41 +0800 Subject: [PATCH 174/385] update setWindowMask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 8fc3070cb..78dd98410 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5179,9 +5179,9 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) } wptr weakToken(windowToken_); NapiAsyncTask::CompleteCallback complete = - [waekToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) { + [weakToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) { auto weakWindow = weakToken.promote(); - if (waekWindow == nullptr) { + if (weakWindow == nullptr) { task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "Invalidate params")); -- Gitee From 2a8740509201fe3c1b17915e1a8435d0b2ec2901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Mon, 25 Mar 2024 16:13:37 +0800 Subject: [PATCH 175/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 78dd98410..d0653b8c7 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5200,7 +5200,7 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) }; napi_value lastParam = nullptr; napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindow::SetWindowMask", + NapiAsyncTask::Schedule("JsWindow::OnSetWindowMask", env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); return result; } -- Gitee From 9f5950505acd1141ce943f5c77943e4ec180546c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Mon, 25 Mar 2024 16:43:07 +0800 Subject: [PATCH 176/385] delete permission MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- 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 315671852..d06730e22 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2630,11 +2630,6 @@ WMError SceneSessionManager::UpdateSessionProperty(const sptrSetSystemCalling(isSystemCalling); -- Gitee From 1e6a64a37b067eb4c0c0bb6fd39216522c974b38 Mon Sep 17 00:00:00 2001 From: wanganjie Date: Mon, 25 Mar 2024 16:59:59 +0800 Subject: [PATCH 177/385] =?UTF-8?q?UIExtension=E9=9A=90=E8=97=8F=E9=9D=9E?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E7=AA=97=E5=8F=A3=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wanganjie --- .../include/scene_session_manager.h | 5 + .../src/scene_session_manager.cpp | 87 ++++++++++----- .../src/zidl/scene_session_manager_stub.cpp | 3 - .../unittest/scene_session_manager_test.cpp | 101 ++++++++++++++++++ .../window_extension_session_impl_test.cpp | 15 +++ .../window_scene_session_impl_test.cpp | 16 +++ 6 files changed, 197 insertions(+), 30 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 1c631a9e5..c3a8c44f2 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -556,7 +556,12 @@ private: bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState); bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); WSError GetAppMainSceneSession(sptr& sceneSession, int32_t persistentId); + void AddSecureSession(int32_t persistentId, bool shouldHide, size_t& sizeBefore, size_t& sizeAfter); + void HideNonSecureFloatingWindows(size_t sizeBefore, size_t sizeAfter, bool shouldHide); + void HideNonSecureSubWindows(const sptr& sceneSession, size_t sizeBefore, size_t sizeAfter, + bool shouldHide); WSError HandleSecureSessionShouldHide(const sptr& sceneSession); + WSError HandleSecureExtSessionShouldHide(int32_t persistentId, bool shouldHide); void HandleCastScreenDisConnection(const sptr sceneSession); }; } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 0482ed36c..30d4bbe31 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7198,51 +7198,83 @@ void SceneSessionManager::AddExtensionWindowStageToSCB(const sptr taskScheduler_->PostAsyncTask(task, "AddExtensionWindowStageToSCB"); } -WSError SceneSessionManager::HandleSecureSessionShouldHide(const sptr& sceneSession) +void SceneSessionManager::AddSecureSession(int32_t persistentId, bool shouldHide, + size_t& sizeBefore, size_t& sizeAfter) { - if (sceneSession == nullptr) { - TLOGE(WmsLogTag::WMS_UIEXT, "sceneSession is nullptr"); - return WSError::WS_ERROR_INVALID_SESSION; - } - - auto persistentId = sceneSession->GetPersistentId(); - auto shouldHide = sceneSession->ShouldHideNonSecureWindows(); - auto sizeBefore = secureSessionSet_.size(); + sizeBefore = secureSessionSet_.size(); if (shouldHide) { secureSessionSet_.insert(persistentId); } else { secureSessionSet_.erase(persistentId); } + sizeAfter = secureSessionSet_.size(); +} - auto sizeAfter = secureSessionSet_.size(); - if (sizeBefore == sizeAfter) { - return WSError::WS_OK; +void SceneSessionManager::HideNonSecureFloatingWindows(size_t sizeBefore, size_t sizeAfter, bool shouldHide) +{ + auto stateShouldChange = (sizeBefore == 0 && sizeAfter > 0) || (sizeBefore > 0 && sizeAfter == 0); + if (!stateShouldChange) { + return; } - auto stateShouldChange = (sizeBefore == 0 && sizeAfter > 0) || (sizeBefore > 0 && sizeAfter == 0); - if (stateShouldChange) { - for (const auto& item: nonSystemFloatSceneSessionMap_) { - auto session = item.second; - if (session && session->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT) { - session->NotifyForceHideChange(shouldHide); - TLOGD(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows name=%{public}s, persistendId=%{public}d", - session->GetWindowName().c_str(), item.first); - } + for (const auto& item: nonSystemFloatSceneSessionMap_) { + auto session = item.second; + if (session && session->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT) { + session->NotifyForceHideChange(shouldHide); + TLOGD(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows name=%{public}s, persistendId=%{public}d, " + "shouldHide=%{public}u", session->GetWindowName().c_str(), item.first, shouldHide); } } +} + +void SceneSessionManager::HideNonSecureSubWindows(const sptr& sceneSession, + size_t sizeBefore, size_t sizeAfter, bool shouldHide) +{ + if (!sceneSession->IsSessionForeground() || sizeBefore == sizeAfter) { + return; + } auto subSessions = sceneSession->GetSubSession(); for (const auto& subSession: subSessions) { subSession->NotifyForceHideChange(shouldHide); - TLOGD(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows name=%{public}s, persistendId=%{public}d", - subSession->GetWindowName().c_str(), subSession->GetPersistentId()); + TLOGD(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows name=%{public}s, persistendId=%{public}d, " + "shouldHide=%{public}u", subSession->GetWindowName().c_str(), subSession->GetPersistentId(), + shouldHide); } +} + +WSError SceneSessionManager::HandleSecureSessionShouldHide(const sptr& sceneSession) +{ + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "sceneSession is nullptr"); + return WSError::WS_ERROR_INVALID_SESSION; + } + + auto persistentId = sceneSession->GetPersistentId(); + auto shouldHide = sceneSession->ShouldHideNonSecureWindows(); + size_t sizeBefore = 0; + size_t sizeAfter = 0; + AddSecureSession(persistentId, shouldHide, sizeBefore, sizeAfter); + HideNonSecureFloatingWindows(sizeBefore, sizeAfter, shouldHide); + HideNonSecureSubWindows(sceneSession, sizeBefore, sizeAfter, shouldHide); + + return WSError::WS_OK; +} + +WSError SceneSessionManager::HandleSecureExtSessionShouldHide(int32_t persistentId, bool shouldHide) +{ + size_t sizeBefore = 0; + size_t sizeAfter = 0; + AddSecureSession(persistentId, shouldHide, sizeBefore, sizeAfter); + HideNonSecureFloatingWindows(sizeBefore, sizeAfter, shouldHide); + return WSError::WS_OK; } WSError SceneSessionManager::AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) { - TLOGD(WmsLogTag::WMS_UIEXT, "AddOrRemoveSecureSession, shouldHide %{public}u", shouldHide); + TLOGD(WmsLogTag::WMS_UIEXT, "AddOrRemoveSecureSession, persistentId=%{public}d, shouldHide=%{public}u", + persistentId, shouldHide); auto task = [this, persistentId, shouldHide]() { std::shared_lock lock(sceneSessionMapMutex_); auto iter = sceneSessionMap_.find(persistentId); @@ -7262,7 +7294,8 @@ WSError SceneSessionManager::AddOrRemoveSecureSession(int32_t persistentId, bool WSError SceneSessionManager::AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide) { - TLOGD(WmsLogTag::WMS_UIEXT, "AddOrRemoveSecureExtSession, shouldHide %{public}u", shouldHide); + TLOGD(WmsLogTag::WMS_UIEXT, "AddOrRemoveSecureExtSession, persistentId=%{public}d, parentId=%{public}d, " + "shouldHide=%{public}u", persistentId, parentId, shouldHide); if (!SessionPermission::IsSystemCalling()) { TLOGE(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows permission denied!"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -7272,8 +7305,8 @@ WSError SceneSessionManager::AddOrRemoveSecureExtSession(int32_t persistentId, i std::shared_lock lock(sceneSessionMapMutex_); auto iter = sceneSessionMap_.find(parentId); if (iter == sceneSessionMap_.end()) { - TLOGE(WmsLogTag::WMS_UIEXT, "Session with persistentId %{public}d not found", parentId); - return WSError::WS_ERROR_INVALID_SESSION; + TLOGD(WmsLogTag::WMS_UIEXT, "Parent session with persistentId %{public}d not found", parentId); + return HandleSecureExtSessionShouldHide(persistentId, shouldHide); } auto sceneSession = iter->second; diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index eed6a1049..bcd564580 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -806,7 +806,6 @@ int SceneSessionManagerStub::HandleGetVisibilityWindowInfo(MessageParcel& data, int SceneSessionManagerStub::HandleAddExtensionWindowStageToSCB(MessageParcel &data, MessageParcel &reply) { - TLOGI(WmsLogTag::WMS_UIEXT, "run HandleAddExtensionWindowStageToSCB!"); sptr sessionStageObject = data.ReadRemoteObject(); sptr sessionStage = iface_cast(sessionStageObject); int32_t persistentId = data.ReadInt32(); @@ -817,7 +816,6 @@ int SceneSessionManagerStub::HandleAddExtensionWindowStageToSCB(MessageParcel &d int SceneSessionManagerStub::HandleAddOrRemoveSecureSession(MessageParcel &data, MessageParcel &reply) { - TLOGI(WmsLogTag::WMS_UIEXT, "run HandleAddOrRemoveSecureSession!"); int32_t persistentId = data.ReadInt32(); bool shouldHide = data.ReadBool(); WSError ret = AddOrRemoveSecureSession(persistentId, shouldHide); @@ -827,7 +825,6 @@ int SceneSessionManagerStub::HandleAddOrRemoveSecureSession(MessageParcel &data, int SceneSessionManagerStub::HandleAddOrRemoveSecureExtSession(MessageParcel &data, MessageParcel &reply) { - TLOGI(WmsLogTag::WMS_UIEXT, "run HandleAddOrRemoveSecureExtSession!"); int32_t persistentId = data.ReadInt32(); int32_t parentId = data.ReadInt32(); bool shouldHide = data.ReadBool(); diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 706aafd5a..94fe48ad0 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -3094,6 +3094,83 @@ HWTEST_F(SceneSessionManagerTest, GetSessionSnapshotPixelMap, Function | SmallTe EXPECT_EQ(pixelMap, nullptr); } +/** + * @tc.name: AddSecureSession + * @tc.desc: SceneSesionManager add secure session + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, AddSecureSession, Function | SmallTest | Level3) +{ + int32_t persistentId = 12345; + size_t sizeBefore = 0; + size_t sizeAfter = 0; + ssm_->AddSecureSession(persistentId, true, sizeBefore, sizeAfter); + EXPECT_EQ(sizeBefore, 0); + EXPECT_EQ(sizeAfter, 1); + EXPECT_EQ(*ssm_->secureSessionSet_.begin(), persistentId); + ssm_->AddSecureSession(persistentId, false, sizeBefore, sizeAfter); + EXPECT_EQ(sizeBefore, 1); + EXPECT_EQ(sizeAfter, 0); + ssm_->secureSessionSet_.clear(); +} + +/** + * @tc.name: HideNonSecureFloatingWindows + * @tc.desc: SceneSesionManager hide non-secure floating windows + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, HideNonSecureFloatingWindows, Function | SmallTest | Level3) +{ + SessionInfo info; + info.abilityName_ = "HideNonSecureFloatingWindows"; + info.bundleName_ = "HideNonSecureFloatingWindows"; + + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_FLOAT); + + ssm_->nonSystemFloatSceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession)); + EXPECT_FALSE(sceneSession->GetSessionProperty()->GetForceHide()); + ssm_->HideNonSecureFloatingWindows(0, 0, true); + EXPECT_FALSE(sceneSession->GetSessionProperty()->GetForceHide()); + ssm_->HideNonSecureFloatingWindows(0, 1, true); + EXPECT_TRUE(sceneSession->GetSessionProperty()->GetForceHide()); + ssm_->HideNonSecureFloatingWindows(1, 0, false); + EXPECT_FALSE(sceneSession->GetSessionProperty()->GetForceHide()); + ssm_->nonSystemFloatSceneSessionMap_.clear(); +} + +/** + * @tc.name: HideNonSecureSubWindows + * @tc.desc: SceneSesionManager hide non-secure sub windows + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, HideNonSecureSubWindows, Function | SmallTest | Level3) +{ + SessionInfo info; + info.abilityName_ = "HideNonSecureSubWindows"; + info.bundleName_ = "HideNonSecureSubWindows"; + + sptr sceneSession; + sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->state_ = SessionState::STATE_FOREGROUND; + + sptr subSession; + subSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(subSession, nullptr); + + sceneSession->AddSubSession(subSession); + EXPECT_FALSE(subSession->GetSessionProperty()->GetForceHide()); + ssm_->HideNonSecureSubWindows(sceneSession, 0, 0, true); + EXPECT_FALSE(subSession->GetSessionProperty()->GetForceHide()); + ssm_->HideNonSecureSubWindows(sceneSession, 0, 1, true); + EXPECT_TRUE(subSession->GetSessionProperty()->GetForceHide()); + ssm_->HideNonSecureSubWindows(sceneSession, 1, 0, false); + EXPECT_FALSE(subSession->GetSessionProperty()->GetForceHide()); +} + /** * @tc.name: HandleSecureSessionShouldHide * @tc.desc: SceneSesionManager handle secure session should hide @@ -3116,6 +3193,30 @@ HWTEST_F(SceneSessionManagerTest, HandleSecureSessionShouldHide, Function | Smal EXPECT_EQ(ret, WSError::WS_OK); EXPECT_EQ(ssm_->secureSessionSet_.size(), 1); EXPECT_EQ(*ssm_->secureSessionSet_.begin(), sceneSession->persistentId_); + sceneSession->SetShouldHideNonSecureWindows(false); + ret = ssm_->HandleSecureSessionShouldHide(sceneSession); + EXPECT_EQ(ret, WSError::WS_OK); + EXPECT_TRUE(ssm_->secureSessionSet_.empty()); + ssm_->secureSessionSet_.clear(); +} + +/** + * @tc.name: HandleSecureExtSessionShouldHide + * @tc.desc: SceneSesionManager handle secure extension session should hide + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, HandleSecureExtSessionShouldHide, Function | SmallTest | Level3) +{ + int32_t persistentId = 12345; + EXPECT_TRUE(ssm_->secureSessionSet_.empty()); + auto ret = ssm_->HandleSecureExtSessionShouldHide(persistentId, true); + EXPECT_EQ(ret, WSError::WS_OK); + EXPECT_EQ(ssm_->secureSessionSet_.size(), 1); + EXPECT_EQ(*ssm_->secureSessionSet_.begin(), persistentId); + ret = ssm_->HandleSecureExtSessionShouldHide(persistentId, false); + EXPECT_EQ(ret, WSError::WS_OK); + EXPECT_TRUE(ssm_->secureSessionSet_.empty()); + ssm_->secureSessionSet_.clear(); } /** diff --git a/wm/test/unittest/window_extension_session_impl_test.cpp b/wm/test/unittest/window_extension_session_impl_test.cpp index 62c1df96b..e63235995 100644 --- a/wm/test/unittest/window_extension_session_impl_test.cpp +++ b/wm/test/unittest/window_extension_session_impl_test.cpp @@ -411,6 +411,21 @@ HWTEST_F(WindowExtensionSessionImplTest, UnregisterAvoidAreaChangeListener, Func ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowExtensionSessionImpl.UnregisterAvoidAreaChangeListener(listener)); } +/** + * @tc.name: HideNonSecureWindows + * @tc.desc: HideNonSecureWindows Test + * @tc.type: FUNC + */ +HWTEST_F(WindowExtensionSessionImplTest, HideNonSecureWindows, Function | SmallTest | Level3) +{ + sptr option = new WindowOption(); + WindowExtensionSessionImpl windowExtensionSessionImpl(option); + windowExtensionSessionImpl.state_ = WindowState::STATE_HIDDEN; + ASSERT_EQ(WMError::WM_OK, windowExtensionSessionImpl.HideNonSecureWindows(true)); + windowExtensionSessionImpl.state_ = WindowState::STATE_SHOWN; + ASSERT_EQ(WMError::WM_OK, windowExtensionSessionImpl.HideNonSecureWindows(true)); +} + /** * @tc.name: UpdateConfiguration * @tc.desc: UpdateConfiguration Test diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 83f546611..07a82bde8 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -2046,6 +2046,22 @@ HWTEST_F(WindowSceneSessionImplTest, SetWindowLimits01, Function | SmallTest | L ASSERT_EQ(windowSizeLimits.minWidth_, 1000); ASSERT_EQ(windowSizeLimits.minHeight_, 1000); } + +/** + * @tc.name: HideNonSecureWindows01 + * @tc.desc: HideNonSecureWindows + * @tc.type: FUNC +*/ +HWTEST_F(WindowSceneSessionImplTest, HideNonSecureWindows01, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("HideNonSecureWindows01"); + + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + ASSERT_EQ(WMError::WM_OK, window->HideNonSecureWindows(true)); +} } } // namespace Rosen } // namespace OHOS -- Gitee From 43597e87f9dd6d164ac9c8140f686898bde79b39 Mon Sep 17 00:00:00 2001 From: zhouchengchao Date: Mon, 25 Mar 2024 17:34:20 +0800 Subject: [PATCH 178/385] maximize add tdd and option Signed-off-by: zhouchengchao --- interfaces/innerkits/wm/window.h | 9 +++ interfaces/innerkits/wm/wm_common.h | 14 ++++ .../window_runtime/window_napi/js_window.cpp | 13 +--- previewer/include/window.h | 2 + previewer/include/wm_common.h | 15 ++++ wm/include/window_scene_session_impl.h | 1 + wm/src/window_scene_session_impl.cpp | 17 +++++ .../window_scene_session_impl_test.cpp | 70 +++++++++++++++++++ wm/test/unittest/window_test.cpp | 13 ++++ 9 files changed, 144 insertions(+), 10 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index b4e2f3b38..54dcd9fb9 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1291,6 +1291,15 @@ public: * @return WMError */ virtual WMError Maximize() { return WMError::WM_OK; } + + /** + * @brief maximize window with layoutOption. + * + * @param option UI layout param. + * @return WM_OK means maximize window ok, others means failed. + */ + virtual WMError Maximize(MaximizeLayoutOption option) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** * @brief maximize the main window according to MaximizeMode. called by ACE when maximize button is clicked. * diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 103f540eb..5a1ac4bfe 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -788,6 +788,20 @@ enum class CaseType { CASE_STAGE }; +/** + * maximize layout show type + */ +enum ShowType : int32_t { + SHOW, // normally show + HIDE, // show when hover, but hide normally + FORBIDDEN // hide always +}; + +struct MaximizeLayoutOption { + ShowType decor = ShowType::HIDE; + ShowType dock = ShowType::HIDE; +}; + } } #endif // OHOS_ROSEN_WM_COMMON_H diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index dcc8d855f..87c6cd6fd 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -4844,9 +4844,9 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) WLOGFE("[NAPI] maximize interface only support main Window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); } - + MaximizeLayoutOption option; NapiAsyncTask::CompleteCallback complete = - [weakToken](napi_env env, NapiAsyncTask& task, int32_t status) mutable { + [weakToken, option](napi_env env, NapiAsyncTask& task, int32_t status) mutable { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { task.Reject(env, @@ -4854,14 +4854,7 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) "OnMaximize failed.")); return; } - WMError ret = weakWindow->Maximize(); - auto uicontent = weakWindow->GetUIContent(); - if (uicontent == nullptr) { - WLOGFE("uicontent is nullptr"); - ret = WMError::WM_ERROR_NULLPTR; - } else { - uicontent->UpdateDecorVisible(false); - } + WMError ret = weakWindow->Maximize(option); if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { diff --git a/previewer/include/window.h b/previewer/include/window.h index f919bd091..1ac352b4c 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -289,6 +289,8 @@ public: return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual WMError Recover(uint32_t reason = 0) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }; + + virtual WMError Maximize(MaximizeLayoutOption option) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } }; } } diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index e859e6cb1..a6b3d0e39 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -703,6 +703,21 @@ public: return config; } }; + +/** + * maximize layout show type + */ +enum ShowType : int32_t { + SHOW, // normally show + HIDE, // show when hover, but hide normally + FORBIDDEN // hide always +}; + +struct MaximizeLayoutOption { + ShowType decor = ShowType::HIDE; + ShowType dock = ShowType::HIDE; +}; + } } #endif // OHOS_ROSEN_WM_COMMON_H diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 3a3f15603..9231239f7 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -56,6 +56,7 @@ public: WMError Minimize() override; WMError MaximizeFloating() override; WMError Maximize() override; + WMError Maximize(MaximizeLayoutOption option) override; WMError Recover() override; WMError Recover(uint32_t reason) override; void StartMove() override; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 192701328..a491edd51 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1570,6 +1570,23 @@ WMError WindowSceneSessionImpl::Maximize() return WMError::WM_OK; } +WMError WindowSceneSessionImpl::Maximize(MaximizeLayoutOption option) +{ + if (option.dock != ShowType::HIDE || option.decor == ShowType::FORBIDDEN) { + WLOGE("[WMLayout] dock cannot be hide always! dock is not hide: %{public}d", option.dock != ShowType::HIDE); + return WMError::WM_ERROR_INVALID_PARAM; + } + if (!WindowHelper::IsMainWindow(GetType())) { + WLOGFE("maximize fail, not main window"); + return WMError::WM_ERROR_INVALID_CALLING; + } + if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + return WMError::WM_ERROR_INVALID_WINDOW; + } + property_->SetIsLayoutFullScreen(option.decor == ShowType::HIDE); + return SetFullScreen(true); +} + WMError WindowSceneSessionImpl::MaximizeFloating() { WLOGFI("WindowSceneSessionImpl::MaximizeFloating id: %{public}d", GetPersistentId()); diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 83f546611..0b9082e91 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -2046,6 +2046,76 @@ HWTEST_F(WindowSceneSessionImplTest, SetWindowLimits01, Function | SmallTest | L ASSERT_EQ(windowSizeLimits.minWidth_, 1000); ASSERT_EQ(windowSizeLimits.minHeight_, 1000); } + +/** + * @tc.name: Maximize01 + * @tc.desc: test errorCode + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, Maximize02, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("Maximize02"); + option->SetDisplayId(0); + + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + window->property_->SetWindowName("Maximize02"); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + window->property_->SetPersistentId(2); + + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(nullptr, session); + window->hostSession_ = session; + + MaximizeLayoutOption layoutOption; + // not support subWinodw call + ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, window->Maximize(layoutOption)); + + // window not support fullscreen + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Maximize(layoutOption)); +} + +/** + * @tc.name: Maximize02 + * @tc.desc: test maximizeLayoutOption + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, Maximize03, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("Maximize03"); + option->SetDisplayId(0); + + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + window->property_->SetWindowName("Maximize03"); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + window->property_->SetPersistentId(2); + + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(nullptr, session); + window->hostSession_ = session; + + ASSERT_NE(nullptr, window); + MaximizeLayoutOption layoutOption; + // dock can not be hide from maximize interface! + layoutOption.dock = ShowType::FORBIDDEN; + auto ret = window->Maximize(layoutOption); + ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, ret); + layoutOption.dock = ShowType::HIDE; + layoutOption.decor = ShowType::HIDE; + ASSERT_NE(WMError::WM_ERROR_INVALID_PARAM, window->Maximize(layoutOption)); + layoutOption.dock = ShowType::HIDE; + layoutOption.decor = ShowType::SHOW; + ASSERT_NE(WMError::WM_ERROR_INVALID_PARAM, window->Maximize(layoutOption)); +} } } // namespace Rosen } // namespace OHOS diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index cff76a9ab..525b25112 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -2283,6 +2283,19 @@ HWTEST_F(WindowTest, FlushFrameRate, Function | SmallTest | Level2) window->FlushFrameRate(rate); ASSERT_EQ(WMError::WM_OK, window->Destroy()); } + +/** + * @tc.name: Maximize01 + * @tc.desc: maximize interface Test + * @tc.type: FUNC + */ +HWTEST_F(WindowTest, Maximize01, Function | SmallTest | Level2) +{ + sptr window = new Window(); + ASSERT_NE(nullptr, window); + MaximizeLayoutOption option; + ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->Maximize(option)); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From 3d7245a227208ebd2cdb26ea477d4e2b962516a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Mon, 25 Mar 2024 10:14:55 +0000 Subject: [PATCH 179/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session_manager/src/scene_session_manager.cpp | 3 ++- 1 file changed, 2 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 d9951556e..9c4e940d8 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6167,7 +6167,8 @@ WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSR "area{%{public}d,%{public}d,%{public}d,%{public}d}, displayId: %{public}" PRIu64"", isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_, displayId); auto task = [this, isVisible, barArea, displayId]() { - if (isAINavigationBarVisible_ != isVisible || currAINavigationBarAreaMap_[displayId] != barArea) { + if (isAINavigationBarVisible_ != isVisible || currAINavigationBarAreaMap_.count(displayId) < 1 || + currAINavigationBarAreaMap_[displayId] != barArea) { isAINavigationBarVisible_ = isVisible; currAINavigationBarAreaMap_.clear(); currAINavigationBarAreaMap_[displayId] = barArea; -- Gitee From 33642da54cd0c4e1d6a9e1575569df7aeddb1f6e Mon Sep 17 00:00:00 2001 From: wanganjie Date: Mon, 25 Mar 2024 20:09:51 +0800 Subject: [PATCH 180/385] add comments Signed-off-by: wanganjie --- window_scene/session_manager/src/scene_session_manager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 30d4bbe31..bf67f7350 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7230,6 +7230,7 @@ void SceneSessionManager::HideNonSecureFloatingWindows(size_t sizeBefore, size_t void SceneSessionManager::HideNonSecureSubWindows(const sptr& sceneSession, size_t sizeBefore, size_t sizeAfter, bool shouldHide) { + // don't let sub-window show when switching secure host window to background if (!sceneSession->IsSessionForeground() || sizeBefore == sizeAfter) { return; } @@ -7306,6 +7307,7 @@ WSError SceneSessionManager::AddOrRemoveSecureExtSession(int32_t persistentId, i auto iter = sceneSessionMap_.find(parentId); if (iter == sceneSessionMap_.end()) { TLOGD(WmsLogTag::WMS_UIEXT, "Parent session with persistentId %{public}d not found", parentId); + // process UIExtension that created by SceneBoard return HandleSecureExtSessionShouldHide(persistentId, shouldHide); } -- Gitee From 2359b8139b60abfafa48acf2c3054e8c610e9340 Mon Sep 17 00:00:00 2001 From: huangji731 Date: Mon, 25 Mar 2024 14:35:04 +0800 Subject: [PATCH 181/385] https://gitee.com/openharmony/window_window_manager/issues/I9BBZ8 Signed-off-by: huangji731 --- dm/include/display_manager_adapter.h | 1 + dm/src/display_manager_adapter.cpp | 7 ++++ dm/src/screen_manager.cpp | 5 +++ dm/test/unittest/screen_manager_test.cpp | 34 +++++++++++++++++++ dmserver/include/display_manager_interface.h | 5 +++ interfaces/innerkits/dm/screen_manager.h | 9 +++++ .../src/screen_session_manager_client.cpp | 4 +-- .../include/screen_session_manager.h | 1 + .../zidl/screen_session_manager_proxy.h | 2 ++ .../src/screen_session_manager.cpp | 19 +++++++++++ .../src/zidl/screen_session_manager_proxy.cpp | 25 ++++++++++++++ .../src/zidl/screen_session_manager_stub.cpp | 7 ++++ 12 files changed, 117 insertions(+), 2 deletions(-) diff --git a/dm/include/display_manager_adapter.h b/dm/include/display_manager_adapter.h index 5f0c05573..bf83296bf 100644 --- a/dm/include/display_manager_adapter.h +++ b/dm/include/display_manager_adapter.h @@ -100,6 +100,7 @@ public: virtual DMError DestroyVirtualScreen(ScreenId screenId); virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr surface); virtual DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool canvasRotation); + virtual DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode); virtual bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason); virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason); virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId); diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index ad52a141e..3f00521cb 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -225,6 +225,13 @@ DMError ScreenManagerAdapter::SetVirtualMirrorScreenCanvasRotation(ScreenId scre return displayManagerServiceProxy_->SetVirtualMirrorScreenCanvasRotation(screenId, canvasRotation); } +DMError ScreenManagerAdapter::SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + WLOGFI("DisplayManagerAdapter::SetVirtualMirrorScreenScaleMode"); + return displayManagerServiceProxy_->SetVirtualMirrorScreenScaleMode(screenId, scaleMode); +} + DMError ScreenManagerAdapter::SetScreenRotationLocked(bool isLocked) { INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); diff --git a/dm/src/screen_manager.cpp b/dm/src/screen_manager.cpp index e4cc2d970..d3a3aae5d 100644 --- a/dm/src/screen_manager.cpp +++ b/dm/src/screen_manager.cpp @@ -563,6 +563,11 @@ DMError ScreenManager::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, b return SingletonContainer::Get().SetVirtualMirrorScreenCanvasRotation(screenId, rotation); } +DMError ScreenManager::SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) +{ + return SingletonContainer::Get().SetVirtualMirrorScreenScaleMode(screenId, scaleMode); +} + VirtualScreenFlag ScreenManager::GetVirtualScreenFlag(ScreenId screenId) { return SingletonContainer::Get().GetVirtualScreenFlag(screenId); diff --git a/dm/test/unittest/screen_manager_test.cpp b/dm/test/unittest/screen_manager_test.cpp index c1cc5d355..6d59bdcbb 100644 --- a/dm/test/unittest/screen_manager_test.cpp +++ b/dm/test/unittest/screen_manager_test.cpp @@ -541,6 +541,40 @@ HWTEST_F(ScreenManagerTest, SetVirtualScreenFlag02, Function | SmallTest | Level ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId); ASSERT_EQ(DMError::DM_OK, ret); } + +/** + * @tc.name: SetVirtualMirrorScreenScaleMode01 + * @tc.desc: SetVirtualMirrorScreenScaleMode01 fun + * @tc.type: FUNC + */ +HWTEST_F(ScreenManagerTest, SetVirtualMirrorScreenScaleMode01, Function | SmallTest | Level1) +{ + VirtualScreenOption defaultOption = {defaultName_, defaultWidth_, defaultHeight_, + defaultDensity_, nullptr, defaultFlags_}; + ScreenId screenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); + DMError ret = ScreenManager::GetInstance().SetVirtualMirrorScreenScaleMode(screenId, + ScreenScaleMode::FILL_MODE); + ASSERT_EQ(DMError::DM_OK, ret); + ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId); + ASSERT_EQ(DMError::DM_OK, ret); +} + +/** + * @tc.name: SetVirtualMirrorScreenScaleMode02 + * @tc.desc: SetVirtualMirrorScreenScaleMode02 fun + * @tc.type: FUNC + */ +HWTEST_F(ScreenManagerTest, SetVirtualMirrorScreenScaleMode02, Function | SmallTest | Level1) +{ + VirtualScreenOption defaultOption = {defaultName_, defaultWidth_, defaultHeight_, + defaultDensity_, nullptr, defaultFlags_}; + ScreenId screenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); + DMError ret = ScreenManager::GetInstance().SetVirtualMirrorScreenScaleMode(screenId, + ScreenScaleMode::UNISCALE_MODE); + ASSERT_EQ(DMError::DM_OK, ret); + ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId); + ASSERT_EQ(DMError::DM_OK, ret); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/dmserver/include/display_manager_interface.h b/dmserver/include/display_manager_interface.h index 4ce610ae4..dbb791b8d 100644 --- a/dmserver/include/display_manager_interface.h +++ b/dmserver/include/display_manager_interface.h @@ -121,6 +121,7 @@ public: TRANS_ID_CONVERT_SCREENID_TO_RSSCREENID, TRANS_ID_GET_VIRTUAL_SCREEN_FLAG, TRANS_ID_SET_VIRTUAL_SCREEN_FLAG, + TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE, }; virtual sptr GetDefaultDisplayInfo() = 0; @@ -134,6 +135,10 @@ public: virtual DMError DestroyVirtualScreen(ScreenId screenId) = 0; virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr surface) = 0; virtual DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool rotate) { return DMError::DM_OK; } + virtual DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } virtual DMError SetOrientation(ScreenId screenId, Orientation orientation) = 0; virtual std::shared_ptr GetDisplaySnapshot(DisplayId displayId, DmErrorCode* errorCode = nullptr) = 0; diff --git a/interfaces/innerkits/dm/screen_manager.h b/interfaces/innerkits/dm/screen_manager.h index eb7149e01..8347a6162 100644 --- a/interfaces/innerkits/dm/screen_manager.h +++ b/interfaces/innerkits/dm/screen_manager.h @@ -205,6 +205,15 @@ public: */ DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool canvasRotation); + /** + * @brief Set virtual screen scale mode + * + * @param screenId Screen id. + * @param scaleMode scale mode + * @return DM_OK means set success, others means set failed. + */ + DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode); + /** * @brief Set the screen power state on the specified screen. * diff --git a/window_scene/screen_session_manager/src/screen_session_manager_client.cpp b/window_scene/screen_session_manager/src/screen_session_manager_client.cpp index 4cdc49f86..11ea16b1c 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager_client.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager_client.cpp @@ -79,8 +79,8 @@ bool ScreenSessionManagerClient::CheckIfNeedConnectScreen(ScreenId screenId, Scr return false; } if (screenSessionManager_->GetScreenProperty(screenId).GetScreenType() == ScreenType::VIRTUAL) { - if (name == "HiCar" || name == "SuperLauncher") { - WLOGFI("HiCar or SuperLauncher, need to connect the screen"); + if (name == "HiCar" || name == "SuperLauncher" || name == "CastEngine") { + WLOGFI("HiCar or SuperLauncher or CastEngine, need to connect the screen"); return true; } else { WLOGFE("ScreenType is virtual, no need to connect the screen"); diff --git a/window_scene/session_manager/include/screen_session_manager.h b/window_scene/session_manager/include/screen_session_manager.h index 3e04b1d6e..993efb424 100644 --- a/window_scene/session_manager/include/screen_session_manager.h +++ b/window_scene/session_manager/include/screen_session_manager.h @@ -96,6 +96,7 @@ public: const sptr& displayManagerAgent) override; virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr surface) override; virtual DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool autoRotate) override; + virtual DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) override; virtual DMError DestroyVirtualScreen(ScreenId screenId) override; DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) override; virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, diff --git a/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h b/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h index 9e427d878..83c16c186 100644 --- a/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h @@ -77,6 +77,8 @@ public: virtual DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool autoRotate) override; + virtual DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) override; + virtual DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId) override; virtual DMError StopMirror(const std::vector& mirrorScreenIds) override; diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 3b6d4bfca..186658e61 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -1717,6 +1717,25 @@ DMError ScreenSessionManager::SetVirtualScreenSurface(ScreenId screenId, sptr(reply.ReadInt32()); } +DMError ScreenSessionManagerProxy::SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode) +{ + if (screenId == SCREEN_ID_INVALID) { + return DMError::DM_ERROR_INVALID_PARAM; + } + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + bool res = data.WriteUint64(static_cast(screenId)) && data.WriteUint32(static_cast(scaleMode)); + if (!res) { + WLOGFE("Write screenId/scaleMode failed"); + return DMError::DM_ERROR_WRITE_DATA_FAILED; + } + if (Remote()->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE), + data, reply, option) != ERR_NONE) { + WLOGFW("SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + return static_cast(reply.ReadInt32()); +} + DMError ScreenSessionManagerProxy::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) { WLOGFI("ScreenSessionManagerProxy::ResizeVirtualScreen: ENTER"); diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp index 1059d599e..0bea9607a 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp @@ -210,6 +210,13 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& reply.WriteInt32(static_cast(result)); break; } + case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE: { + ScreenId screenId = static_cast(data.ReadUint64()); + ScreenScaleMode scaleMode = static_cast(data.ReadUint32()); + DMError result = SetVirtualMirrorScreenScaleMode(screenId, scaleMode); + reply.WriteInt32(static_cast(result)); + break; + } case DisplayManagerMessage::TRANS_ID_DESTROY_VIRTUAL_SCREEN: { ScreenId screenId = static_cast(data.ReadUint64()); DMError result = DestroyVirtualScreen(screenId); -- Gitee From 7227b8f09f67e4451cc89d189602d40fa60d0c01 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 26 Mar 2024 10:18:22 +0800 Subject: [PATCH 182/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/window.cpp | 9 +++++++++ wm/src/window_scene_session_impl.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/wm/src/window.cpp b/wm/src/window.cpp index f0deefb39..1e56ee3c9 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -201,6 +201,15 @@ sptr Window::GetTopWindowWithId(uint32_t mainWinId) } } +sptr Window::GetMainWindowWithContext(const std::shared_ptr& context) +{ + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + return WindowSceneSessionImpl::GetMainWindowWithContext(context); + } else { + return WindowImpl::GetTopWindowWithContext(context); + } +} + std::vector> Window::GetSubWindow(uint32_t parentId) { if (SceneBoardJudgement::IsSceneBoardEnabled()) { diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index a1e77369d..df9cb7c63 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1999,19 +1999,19 @@ sptr WindowSceneSessionImpl::GetTopWindowWithId(uint32_t mainWinId) sptr WindowSceneSessionImpl::GetMainWindowWithContext(const std::shared_ptr& context) { - std::unique_lock lock(windowSessionMutex_); + std::shared_lock lock(windowSessionMutex_); if (windowSessionMap_.empty()) { - WLOGFE("[GetMainWin] Please create mainWindow First!"); + TLOGE(WmsLogTag::WMS_MAIN, "Please create mainWindow First!"); return nullptr; } for (const auto& winPair : windowSessionMap_) { auto win = winPair.second.second; if (win && WindowHelper::IsMainWindow(win->GetType()) && context.get() == win->GetContext().get()) { - WLOGI("[GetMainWin] Find MainWinId:%{public}u.", win->GetWindowId()); + TLOGI(WmsLogTag::WMS_MAIN, "Find MainWinId:%{public}u.", win->GetWindowId()); return win; } } - WLOGFE("[GetMainWin] Cannot find Window!"); + TLOGE(WmsLogTag::WMS_MAIN, "Cannot find Window!"); return nullptr; } -- Gitee From 62cd8e650128fafccabe8f3a24cdcfe5cad87ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Tue, 26 Mar 2024 10:20:24 +0800 Subject: [PATCH 183/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- interfaces/innerkits/wm/window.h | 2 +- .../napi/window_runtime/window_napi/js_window.cpp | 11 +++++++++-- wm/src/window_scene_session_impl.cpp | 6 +++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index ebb130a5c..a7715bb06 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1724,7 +1724,7 @@ public: /** * @brief Set Shaped Window Mask. - * + * * @param windowMask Mask of the shaped window. * @return WM_OK means set success, others means failed. */ diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index d0653b8c7..12458e0dc 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5157,7 +5157,7 @@ napi_value JsWindow::OnGetTitleButtonRect(napi_env env, napi_callback_info info) return TitleButtonAreaObj; } -napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) +napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) { WmErrorCode errCode = WmErrorCode::WM_OK; size_t argc = 4; @@ -5178,7 +5178,7 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } wptr weakToken(windowToken_); - NapiAsyncTask::CompleteCallback complete = + NapiAsyncTask::CompleteCallback complete = [weakToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { @@ -5187,6 +5187,13 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) "Invalidate params")); return; } + if (!WindowHelper::IsSubWindow(weakWindow->GetType()) && + !WindowHelper::IsAppFloatingWindow(weakWindow->GetType())) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_CALLING), + "Invalidate window type")); + return; + } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetWindowMask(windowMask)); if (ret != WmErrorCode::WM_OK) { task.Reject(env, CreateJsError(env, static_cast(ret))); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 807665a23..8b1c9728f 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2800,6 +2800,10 @@ std::unique_ptr WindowSceneSessionImpl::HandleWindowMask( { const Rect& windowRect = GetRect(); uint32_t maskHeight = windowMask.size(); + if (maskHeight <= 0) { + WLOGFE("WindowMask is invalid"); + return nullptr; + } uint32_t maskeWidth = windowMask[0].size(); if (windowRect.height_ != maskHeight || windowRect.width_ != maskWidth) { WLOGFE("WindowMask is invalid"); @@ -2844,7 +2848,7 @@ WMError WindowSceneSessionImpl::SetWindowMask(const std::vectorSetCornerRadius(0.0f); surfaceNode_->SetShadowRadius(0.0f); - surfaceNode_->SetMask(mask);//RS interface to set mask + surfaceNode_->SetMask(mask);// RS interface to set mask RSTransaction::FlushImplicitTransaction(); property_->SetWindowMask(mask); -- Gitee From fc6bd154b1dea384d4ae9981115b7789639edfe4 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 26 Mar 2024 10:27:56 +0800 Subject: [PATCH 184/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/window.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/wm/src/window.cpp b/wm/src/window.cpp index 1e56ee3c9..f0deefb39 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -201,15 +201,6 @@ sptr Window::GetTopWindowWithId(uint32_t mainWinId) } } -sptr Window::GetMainWindowWithContext(const std::shared_ptr& context) -{ - if (SceneBoardJudgement::IsSceneBoardEnabled()) { - return WindowSceneSessionImpl::GetMainWindowWithContext(context); - } else { - return WindowImpl::GetTopWindowWithContext(context); - } -} - std::vector> Window::GetSubWindow(uint32_t parentId) { if (SceneBoardJudgement::IsSceneBoardEnabled()) { -- Gitee From 587f930e807727a9961d91d1f2676d80d19e53d5 Mon Sep 17 00:00:00 2001 From: zhangzhicong Date: Tue, 26 Mar 2024 10:43:46 +0800 Subject: [PATCH 185/385] fix GetPreferredOrientation Signed-off-by: zhangzhicong --- .../kits/napi/extension_window/js_extension_window.cpp | 7 ------- .../kits/napi/window_runtime/window_napi/js_window.cpp | 4 ++-- .../kits/napi/window_runtime/window_napi/js_window_utils.h | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index 748e49386..d31122ab0 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -376,13 +376,6 @@ napi_value JsExtensionWindow::OnSetPreferredOrientation(napi_env env, napi_callb napi_value JsExtensionWindow::OnGetPreferredOrientation(napi_env env, napi_callback_info info) { - size_t argc = 4; - napi_value argv[4] = {nullptr}; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc >= 1) { - WLOGFE("Argc is invalid: %{public}zu, expect zero params", argc); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); - } return NapiThrowError(env, WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT); } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 7bbbab197..dbc3b38a7 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -2576,9 +2576,9 @@ napi_value JsWindow::OnGetPreferredOrientation(napi_env env, napi_callback_info WLOGFE("window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } - Orientation requestedOrientation = weakWindow->GetRequestedOrientation(); + Orientation requestedOrientation = window->GetRequestedOrientation(); ApiOrientation apiOrientation = ApiOrientation::UNSPECIFIED; - if (requestedOrientation >= ApiOrientation::UNSPECIFIED && requestedOrientation <= ApiOrientation::LOCKED) { + if (requestedOrientation >= Orientation::UNSPECIFIED && requestedOrientation <= Orientation::LOCKED) { apiOrientation = NATIVE_TO_JS_ORIENTATION_MAP.at(requestedOrientation); } else { WLOGFE("OnGetPreferredOrientation Orientation %{public}u invalid!", diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 6953b3a5b..7fb9e9678 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -182,7 +182,7 @@ const std::map JS_TO_NATIVE_ORIENTATION_MAP { {ApiOrientation::LOCKED, Orientation::LOCKED }, }; -const std::map NATIVE_TO_JS_ORIENTATION_MAP { +const std::map NATIVE_TO_JS_ORIENTATION_MAP { {Orientation::UNSPECIFIED, ApiOrientation::UNSPECIFIED }, {Orientation::VERTICAL, ApiOrientation::PORTRAIT }, {Orientation::HORIZONTAL, ApiOrientation::LANDSCAPE }, -- Gitee From f330e2dcee2e2a0481532593f2c11208d9bc9078 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 26 Mar 2024 15:09:22 +0800 Subject: [PATCH 186/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- interfaces/innerkits/wm/window.h | 7 +++++++ .../picture_in_picture_napi/js_pip_window_manager.cpp | 3 +-- wm/src/window.cpp | 9 +++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index b4e2f3b38..f3da194f1 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -460,6 +460,13 @@ public: * @return sptr */ static sptr GetTopWindowWithId(uint32_t mainWinId); + /** + * @brief Get the main window by context. + * + * @param context Indicates the context on which the window depends + * @return sptr + */ + static sptr GetMainWindowWithContext(const std::shared_ptr& context = nullptr); /** * @brief Get the all sub windows by parent * diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 441084a19..04305336e 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -20,7 +20,6 @@ #include "js_runtime_utils.h" #include "window_manager_hilog.h" #include "window.h" -#include "window_scene_session_impl.h" #include "xcomponent_controller.h" namespace OHOS { @@ -242,7 +241,7 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback WMError::WM_ERROR_PIP_INTERNAL_ERROR), "Invalid context")); return; } - sptr mainWindow = WindowSceneSessionImpl::GetMainWindowWithContext(context->lock()); + sptr mainWindow = Window::GetMainWindowWithContext(context->lock()); sptr pipController = new PictureInPictureController(pipOptionPtr, mainWindow, mainWindow->GetWindowId(), env); task.Resolve(env, CreateJsPipControllerObject(env, pipController)); diff --git a/wm/src/window.cpp b/wm/src/window.cpp index f0deefb39..01eab19ea 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -201,6 +201,15 @@ sptr Window::GetTopWindowWithId(uint32_t mainWinId) } } +sptr Window::GetMainWindowWithContext(const std::shared_ptr& context) +{ + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + return WindowSceneSessionImpl::GetMainWindowWithContext(context); + } else { + return nullptr; + } +} + std::vector> Window::GetSubWindow(uint32_t parentId) { if (SceneBoardJudgement::IsSceneBoardEnabled()) { -- Gitee From 35004e789e7f3c130c223669bd7e8df84da147c7 Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Tue, 26 Mar 2024 07:13:33 +0000 Subject: [PATCH 187/385] update wm/src/window_scene_session_impl.cpp. Signed-off-by: chengyiyi --- wm/src/window_scene_session_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 60daebc81..605c6fa94 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -92,7 +92,7 @@ bool WindowSceneSessionImpl::IsValidSystemWindowType(const WindowType& type) type == WindowType::WINDOW_TYPE_VOLUME_OVERLAY || type == WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR || type == WindowType::WINDOW_TYPE_SYSTEM_TOAST || type == WindowType::WINDOW_TYPE_SYSTEM_FLOAT || type == WindowType::WINDOW_TYPE_PIP || type == WindowType::WINDOW_TYPE_GLOBAL_SEARCH || - type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW || type == WindowType::WINDOW_TYPE_HANDWRITE)){ + type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW || type == WindowType::WINDOW_TYPE_HANDWRITE)) { TLOGI(WmsLogTag::WMS_SYSTEM, "Invalid type: %{public}u", type); return false; } @@ -1910,7 +1910,7 @@ WMError WindowSceneSessionImpl::AddWindowFlag(WindowFlag flag) } if (flag == WindowFlag::WINDOW_FLAG_HANDWRITING && !SessionPermission::IsSystemCalling()) { WLOGI("Can not add window flag WINDOW_FLAG_HANDWRITING"); - return WMError::WM_ERROR_INVALID_PERMISSION; + return WMError::WM_ERROR_NOT_SYSTEM_APP; } uint32_t updateFlags = property_->GetWindowFlags() | (static_cast(flag)); return SetWindowFlags(updateFlags); -- Gitee From 5fa5c50bc01f2a7959a11b8f94097df6d05286f9 Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Tue, 26 Mar 2024 07:16:39 +0000 Subject: [PATCH 188/385] update wmserver/src/input_window_monitor.cpp. Signed-off-by: chengyiyi --- wmserver/src/input_window_monitor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wmserver/src/input_window_monitor.cpp b/wmserver/src/input_window_monitor.cpp index deca58b6f..e5b1a80e6 100644 --- a/wmserver/src/input_window_monitor.cpp +++ b/wmserver/src/input_window_monitor.cpp @@ -211,6 +211,7 @@ void InputWindowMonitor::TraverseWindowNodes(const std::vector> windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_UNTOUCHABLE; } if (windowNode->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING)) { + WLOGFD("add handwriting flag to window: %{public}u", windowNode->GetWindowId()); windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_HANDWRITING; } windowsInfo.emplace_back(windowInfo); -- Gitee From f7e43c95d648afcc21004c7c914ec7a21df749dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Tue, 26 Mar 2024 15:29:34 +0800 Subject: [PATCH 189/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../napi/window_runtime/window_napi/js_window.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 0e319d318..27f62bc72 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5319,7 +5319,6 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) std::vector> windowMask; if (errCode == WmErrorCode::WM_OK) { if (!GetWindowMaskFromJsValue(env, argv[0], windowMask)) { - WLOGFE("GetWindowMaskFromJsValue failed"); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } } @@ -5328,19 +5327,17 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) } wptr weakToken(windowToken_); NapiAsyncTask::CompleteCallback complete = - [weakToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) { + [weakToken, windowMask, errCode](napi_env env, NapiAsyncTask& task, int32_t status) { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - task.Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "Invalidate params")); + errorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + task.Reject(env, CreateJsError(env, static_cast(errorCode), "Invalidate params")); return; } if (!WindowHelper::IsSubWindow(weakWindow->GetType()) && !WindowHelper::IsAppFloatingWindow(weakWindow->GetType())) { - task.Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_CALLING), - "Invalidate window type")); + errorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; + task.Reject(env, CreateJsError(env, static_cast(errorCode), "Invalidate window type")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetWindowMask(windowMask)); -- Gitee From c19f3fe0c717092f4898ea0ac3e045ada82fdd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Tue, 26 Mar 2024 15:32:45 +0800 Subject: [PATCH 190/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- wm/src/window_scene_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index b1ee9ae75..fe09ec7fd 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2847,7 +2847,7 @@ WMError WindowSceneSessionImpl::SetWindowMask(const std::vectorSetCornerRadius(0.0f); surfaceNode_->SetShadowRadius(0.0f); - surfaceNode_->SetMask(mask);// RS interface to set mask + surfaceNode_->SetMask(mask); // RS interface to set mask RSTransaction::FlushImplicitTransaction(); property_->SetWindowMask(mask); -- Gitee From 0d556006a12abd6f2933aec3c2f4d2a372d788cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Tue, 26 Mar 2024 15:44:27 +0800 Subject: [PATCH 191/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- window_scene/common/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/common/BUILD.gn b/window_scene/common/BUILD.gn index a035e8dd7..53142271f 100644 --- a/window_scene/common/BUILD.gn +++ b/window_scene/common/BUILD.gn @@ -51,11 +51,11 @@ ohos_shared_library("window_scene_common") { "eventhandler:libeventhandler", "hilog:libhilog", "hitrace:hitrace_meter", + "image_framework:image_native", "imf:inputmethod_client", "input:libmmi-client", "ipc:ipc_single", "samgr:samgr_proxy", - "image_framework:image_native", ] innerapi_tags = [ "platformsdk_indirect" ] -- Gitee From 77dc99e9192231368aae3c88df83a9ac2a91229e Mon Sep 17 00:00:00 2001 From: yangningning Date: Tue, 26 Mar 2024 10:34:50 +0800 Subject: [PATCH 192/385] setting_observer_test Signed-off-by: yangningning Change-Id: Ib79889d4760bff62352630e7107e974198b03bea --- window_scene/test/unittest/BUILD.gn | 16 +++ .../test/unittest/setting_observer_test.cpp | 103 ++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 window_scene/test/unittest/setting_observer_test.cpp diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index e5864917e..efc0166a3 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -55,6 +55,7 @@ group("unittest") { ":ws_session_stub_mock_test", ":ws_session_stub_test", ":ws_session_test", + ":ws_setting_observer_test", ":ws_system_session_test", ":ws_task_scheduler_test", ":ws_timer_manager_test", @@ -768,6 +769,21 @@ ohos_unittest("ws_distributed_client_test") { ] } +ohos_unittest("ws_setting_observer_test") { + module_out_path = module_out_path + + sources = [ "setting_observer_test.cpp" ] + + deps = [ ":ws_unittest_common" ] + + external_deps = [ + "ability_runtime:ability_manager", + "ability_runtime:dataobs_manager", + "c_utils:utils", + "hilog:libhilog", + ] +} + ## Build ws_unittest_common.a {{{ config("ws_unittest_common_public_config") { include_dirs = [ diff --git a/window_scene/test/unittest/setting_observer_test.cpp b/window_scene/test/unittest/setting_observer_test.cpp new file mode 100644 index 000000000..f0dcaac16 --- /dev/null +++ b/window_scene/test/unittest/setting_observer_test.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "setting_observer.h" + +using namespace testing; +using namespace testing::ext; + +using UpdateFunc = std::function; + +namespace OHOS { +namespace Rosen { +class SettingObserverTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + sptr settingObserver_ = nullptr; + +}; + +void SettingObserverTest::SetUpTestCase() +{ +} + +void SettingObserverTest::TearDownTestCase() +{ +} + +void SettingObserverTest::SetUp() +{ + settingObserver_ = new SettingObserver(); +} + +void SettingObserverTest::TearDown() +{ + settingObserver_ = nullptr; +} + +namespace { +/** + * @tc.name: SetUpdateFunc + * @tc.desc: test function : SetUpdateFunc + * @tc.type: FUNC + */ +HWTEST_F(SettingObserverTest, SetUpdateFunc, Function | SmallTest | Level1) +{ + UpdateFunc func = [this](const std::string& key) { + settingObserver_->SetKey(key); + }; + EXPECT_EQ(nullptr, settingObserver_->update_); + settingObserver_->SetUpdateFunc(func); + EXPECT_NE(nullptr, settingObserver_->update_); +} + +/** + * @tc.name: SetKey + * @tc.desc: test function : SetKey + * @tc.type: FUNC + */ +HWTEST_F(SettingObserverTest, SetKey, Function | SmallTest | Level1) +{ + const char* s = ""; + EXPECT_EQ(settingObserver_->key_, s); + settingObserver_->SetKey("SetKey"); + std::string res = settingObserver_->GetKey(); + EXPECT_EQ(res, settingObserver_->key_); +} + +/** + * @tc.name: OnChange + * @tc.desc: test function : OnChange + * @tc.type: FUNC + */ +HWTEST_F(SettingObserverTest, OnChange, Function | SmallTest | Level1) +{ + UpdateFunc func = [this](const std::string& key) { + settingObserver_->SetKey(key); + }; + settingObserver_->SetUpdateFunc(func); + EXPECT_NE(nullptr, settingObserver_->update_); + settingObserver_->SetKey("OnChange"); + settingObserver_->OnChange(); + EXPECT_EQ("OnChange", settingObserver_->key_); +} +} +} +} \ No newline at end of file -- Gitee From e5e3641146e0d054b17928474964b1521fd4f08b Mon Sep 17 00:00:00 2001 From: ywx1282843 Date: Tue, 26 Mar 2024 07:49:12 +0000 Subject: [PATCH 193/385] update window_scene/test/unittest/setting_observer_test.cpp. Signed-off-by: ywx1282843 --- window_scene/test/unittest/setting_observer_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/window_scene/test/unittest/setting_observer_test.cpp b/window_scene/test/unittest/setting_observer_test.cpp index f0dcaac16..db2428cd1 100644 --- a/window_scene/test/unittest/setting_observer_test.cpp +++ b/window_scene/test/unittest/setting_observer_test.cpp @@ -31,7 +31,6 @@ public: void SetUp() override; void TearDown() override; sptr settingObserver_ = nullptr; - }; void SettingObserverTest::SetUpTestCase() -- Gitee From 2ed7c91b00cb21e4d211b11897e6310a472aa574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Tue, 26 Mar 2024 15:54:26 +0800 Subject: [PATCH 194/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- window_scene/common/include/window_session_property.h | 2 +- window_scene/common/src/window_session_property.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index f6b5a8143..73f127776 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -207,7 +207,7 @@ private: bool isExtensionFlag_ = false; bool isShaped_ = false; - sptr windowMask_ = nullptr; + sptr windowMask_ = nullptr; }; struct SystemSessionConfig : public Parcelable { diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 3d20a86cb..50c56ecec 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -582,7 +582,7 @@ bool WindowSessionProperty::MarshallingWindowMask(Parcel& parcel) const void WindowSessionProperty::UnmarshallingWindowMask(Parcel& parcel, WindowSessionProperty* property) { - bool isShaped_ = parcel.ReadBool(); + bool isShaped = parcel.ReadBool(); property->SetIsShaped(isShaped); if (isShaped) { property->SetWindowMask(parcel.ReadParcelable()); @@ -786,7 +786,7 @@ sptr WindowSessionProperty::GetWindowMask() const return windowMask_; } -void WindowSessionProperty::SetIsShaped(bool isShaped) const +void WindowSessionProperty::SetIsShaped(bool isShaped) { isShaped_ = isShaped; } -- Gitee From d97f9bec52ae054cb6e92a63459ba74a055ff152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Tue, 26 Mar 2024 16:16:06 +0800 Subject: [PATCH 195/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 27f62bc72..14b6ec62b 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5330,14 +5330,14 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) [weakToken, windowMask, errCode](napi_env env, NapiAsyncTask& task, int32_t status) { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - errorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; - task.Reject(env, CreateJsError(env, static_cast(errorCode), "Invalidate params")); + errCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + task.Reject(env, CreateJsError(env, static_cast(errCode), "Invalidate params")); return; } if (!WindowHelper::IsSubWindow(weakWindow->GetType()) && !WindowHelper::IsAppFloatingWindow(weakWindow->GetType())) { - errorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; - task.Reject(env, CreateJsError(env, static_cast(errorCode), "Invalidate window type")); + errCode = WmErrorCode::WM_ERROR_INVALID_CALLING; + task.Reject(env, CreateJsError(env, static_cast(errCode), "Invalidate window type")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetWindowMask(windowMask)); -- Gitee From 528806a732a81a02074e92d1fee1ca8074f119f8 Mon Sep 17 00:00:00 2001 From: lijie176 Date: Tue, 26 Mar 2024 16:20:20 +0800 Subject: [PATCH 196/385] =?UTF-8?q?=E5=A2=9E=E5=8A=A0UIExtension=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=88=86=E5=8F=91=E8=B6=85=E6=97=B6=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E5=92=8C=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijie176 --- .../container/include/window_event_channel.h | 2 + .../zidl/window_event_channel_interface.h | 12 ++ .../include/zidl/window_event_channel_proxy.h | 2 + .../include/zidl/window_event_channel_stub.h | 1 + .../zidl/window_event_ipc_interface_code.h | 1 + .../container/src/window_event_channel.cpp | 54 +++++++++ .../src/zidl/window_event_channel_proxy.cpp | 35 ++++++ .../src/zidl/window_event_channel_stub.cpp | 22 ++++ .../session/host/include/extension_session.h | 3 + window_scene/session/host/include/session.h | 2 +- .../session/host/src/extension_session.cpp | 112 ++++++++++++++++++ .../session/host/src/zidl/session_proxy.cpp | 6 +- window_scene/test/unittest/session_test.cpp | 8 ++ 13 files changed, 257 insertions(+), 3 deletions(-) diff --git a/window_scene/session/container/include/window_event_channel.h b/window_scene/session/container/include/window_event_channel.h index 0bb450f02..7e817be3a 100644 --- a/window_scene/session/container/include/window_event_channel.h +++ b/window_scene/session/container/include/window_event_channel.h @@ -41,6 +41,8 @@ public: WSError TransferPointerEvent(const std::shared_ptr& pointerEvent) override; WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent = false) override; + WSError TransferKeyEventForConsumedAsync(const std::shared_ptr& keyEvent, bool isPreImeEvent, + const sptr& listener) override; WSError TransferFocusActiveEvent(bool isFocusActive) override; WSError TransferFocusState(bool focusState) override; WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, diff --git a/window_scene/session/container/include/zidl/window_event_channel_interface.h b/window_scene/session/container/include/zidl/window_event_channel_interface.h index 46f9c8f0e..f37aa4ef5 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_interface.h +++ b/window_scene/session/container/include/zidl/window_event_channel_interface.h @@ -31,6 +31,16 @@ namespace OHOS::Accessibility { class AccessibilityElementInfo; } namespace OHOS::Rosen { +class IWindowEventChannelListener : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowEventChannelListener"); + enum class WindowEventChannelListenerMessage : int32_t { + TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC, + }; + + virtual void OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) = 0; +}; + class IWindowEventChannel : public IRemoteBroker { public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowEventChannel"); @@ -42,6 +52,8 @@ public: virtual WSError TransferBackpressedEventForConsumed(bool& isConsumed) = 0; virtual WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent = false) = 0; + virtual WSError TransferKeyEventForConsumedAsync(const std::shared_ptr& keyEvent, bool isPreImeEvent, + const sptr& listener) = 0; virtual WSError TransferFocusActiveEvent(bool isFocusActive) = 0; virtual WSError TransferFocusState(bool focusState) = 0; virtual WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, diff --git a/window_scene/session/container/include/zidl/window_event_channel_proxy.h b/window_scene/session/container/include/zidl/window_event_channel_proxy.h index f81bd1dc6..7c57f1144 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_proxy.h +++ b/window_scene/session/container/include/zidl/window_event_channel_proxy.h @@ -36,6 +36,8 @@ public: WSError TransferPointerEvent(const std::shared_ptr& pointerEvent) override; WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent = false) override; + WSError TransferKeyEventForConsumedAsync(const std::shared_ptr& keyEvent, bool isPreImeEvent, + const sptr& listener) override; WSError TransferFocusActiveEvent(bool isFocusActive) override; WSError TransferFocusState(bool focusState) override; WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, diff --git a/window_scene/session/container/include/zidl/window_event_channel_stub.h b/window_scene/session/container/include/zidl/window_event_channel_stub.h index ec3217352..67315b830 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_stub.h +++ b/window_scene/session/container/include/zidl/window_event_channel_stub.h @@ -37,6 +37,7 @@ private: int HandleTransferBackpressedEvent(MessageParcel& data, MessageParcel& reply); int HandleTransferKeyEvent(MessageParcel& data, MessageParcel& reply); + int HandleTransferKeyEventAsync(MessageParcel& data, MessageParcel& reply); int HandleTransferPointerEvent(MessageParcel& data, MessageParcel& reply); int HandleGetApplicationPid(MessageParcel& data, MessageParcel& reply); int HandleTransferFocusActiveEvent(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h b/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h index ca3528838..d7e1bffb5 100644 --- a/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h @@ -33,6 +33,7 @@ enum class WindowEventInterfaceCode { TRANS_ID_TRANSFER_EXECUTE_ACTION, TRANS_ID_TRANSFER_CLEAR_FOCUS, TRANS_ID_TRANSFER_ACCESSIBILITY_HOVER_EVENT, + TRANS_ID_TRANSFER_KEY_EVENT_ASYNC, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/src/window_event_channel.cpp b/window_scene/session/container/src/window_event_channel.cpp index c92806613..beadb8d03 100644 --- a/window_scene/session/container/src/window_event_channel.cpp +++ b/window_scene/session/container/src/window_event_channel.cpp @@ -22,6 +22,7 @@ #include #include +#include "iremote_proxy.h" #include "anr_handler.h" #include "window_manager_hilog.h" @@ -30,6 +31,43 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowEventChannel" }; } +class WindowEventChannelListenerProxy : public IRemoteProxy { +public: + explicit WindowEventChannelListenerProxy(const sptr& impl) + : IRemoteProxy(impl) {} + virtual ~WindowEventChannelListenerProxy() = default; + + void OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) override + { + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_EVENT, "WriteInterfaceToken failed"); + return; + } + + if (!data.WriteBool(isConsumed)) { + TLOGE(WmsLogTag::WMS_EVENT, "isConsumed write failed."); + return; + } + + if (!data.WriteInt32(static_cast(retCode))) { + TLOGE(WmsLogTag::WMS_EVENT, "retCode write failed."); + return; + } + + if (Remote()->SendRequest(static_cast( + WindowEventChannelListenerMessage::TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed"); + return; + } + } +private: + static inline BrokerDelegator delegator_; +}; + WSError WindowEventChannel::TransferKeyEvent(const std::shared_ptr& keyEvent) { WLOGFD("WindowEventChannel receive key event"); @@ -102,6 +140,22 @@ WSError WindowEventChannel::TransferKeyEventForConsumed( return WSError::WS_OK; } +WSError WindowEventChannel::TransferKeyEventForConsumedAsync( + const std::shared_ptr& keyEvent, bool isPreImeEvent, const sptr& listener) +{ + bool isConsumed = false; + auto ret = TransferKeyEventForConsumed(keyEvent, isConsumed); + auto wecListener = iface_cast(listener); + if (wecListener == nullptr) { + TLOGD(WmsLogTag::WMS_EVENT, "listener is null."); + return ret; + } + + WLOGFD("TransferKeyEventForConsumedAsync finished with isConsumed:%{public}d ret:%{public}d", isConsumed, ret); + wecListener->OnTransferKeyEventForConsumed(isConsumed, ret); + return ret; +} + WSError WindowEventChannel::TransferFocusActiveEvent(bool isFocusActive) { WLOGFD("WindowEventChannel receive focus active event"); diff --git a/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp b/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp index aba341e1c..4a7deffe1 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp @@ -135,6 +135,41 @@ WSError WindowEventChannelProxy::TransferKeyEventForConsumed( return static_cast(ret); } +WSError WindowEventChannelProxy::TransferKeyEventForConsumedAsync( + const std::shared_ptr& keyEvent, bool isPreImeEvent, const sptr& listener) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_EVENT, "WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + + if (!keyEvent->WriteToParcel(data)) { + TLOGE(WmsLogTag::WMS_EVENT, "Failed to write key event"); + return WSError::WS_ERROR_IPC_FAILED; + } + + if (!data.WriteBool(isPreImeEvent)) { + TLOGE(WmsLogTag::WMS_EVENT, "Write isPreImeEvent failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + + if (!data.WriteRemoteObject(listener)) { + TLOGE(WmsLogTag::WMS_EVENT, "WriteRemoteObject listener failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + + if (Remote()->SendRequest(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_KEY_EVENT_ASYNC), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + int32_t ret = reply.ReadInt32(); + return static_cast(ret); +} + WSError WindowEventChannelProxy::TransferFocusActiveEvent(bool isFocusActive) { MessageParcel data; diff --git a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp index 6294195a2..037f016c5 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp @@ -34,6 +34,8 @@ constexpr int32_t MAX_ARGUMENTS_KEY_SIZE = 1000; const std::map WindowEventChannelStub::stubFuncMap_{ std::make_pair(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_KEY_EVENT), &WindowEventChannelStub::HandleTransferKeyEvent), + std::make_pair(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_KEY_EVENT_ASYNC), + &WindowEventChannelStub::HandleTransferKeyEventAsync), std::make_pair(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_POINTER_EVENT), &WindowEventChannelStub::HandleTransferPointerEvent), std::make_pair(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_FOCUS_ACTIVE_EVENT), @@ -106,6 +108,26 @@ int WindowEventChannelStub::HandleTransferKeyEvent(MessageParcel& data, MessageP return ERR_NONE; } +int WindowEventChannelStub::HandleTransferKeyEventAsync(MessageParcel& data, MessageParcel& reply) +{ + WLOGFD("TransferKeyEvent!"); + auto keyEvent = MMI::KeyEvent::Create(); + if (keyEvent == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "Failed to create key event!"); + return ERR_INVALID_DATA; + } + if (!keyEvent->ReadFromParcel(data)) { + TLOGE(WmsLogTag::WMS_EVENT, "Read Key Event failed"); + return ERR_INVALID_DATA; + } + bool isPreImeEvent = data.ReadBool(); + sptr listener = data.ReadRemoteObject(); + WSError errCode = TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, listener); + + reply.WriteUint32(static_cast(errCode)); + return ERR_NONE; +} + int WindowEventChannelStub::HandleTransferPointerEvent(MessageParcel& data, MessageParcel& reply) { WLOGFD("TransferPointerEvent!"); diff --git a/window_scene/session/host/include/extension_session.h b/window_scene/session/host/include/extension_session.h index 3b410062d..e6869fdab 100644 --- a/window_scene/session/host/include/extension_session.h +++ b/window_scene/session/host/include/extension_session.h @@ -62,6 +62,9 @@ public: void NotifyAsyncOn() override; void TriggerBindModalUIExtension() override; void RegisterExtensionSessionEventCallback(const sptr& extSessionEventCallback); + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed); + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool& isTimeOut, bool isPreImeEvent = false); sptr GetExtensionSessionEventCallback(); WSError Background() override; diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 799a7bacb..40e9f7fb9 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -499,6 +499,7 @@ protected: mutable std::mutex dialogVecMutex_; std::vector> dialogVec_; sptr parentSession_; + sptr windowEventChannel_; mutable std::mutex pointerEventMutex_; mutable std::mutex keyEventMutex_; @@ -532,7 +533,6 @@ private: std::recursive_mutex lifecycleListenersMutex_; std::vector> lifecycleListeners_; - sptr windowEventChannel_; std::shared_ptr handler_; std::shared_ptr mainHandler_; std::shared_ptr exportHandler_; diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index a90be5b7a..2c3801075 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -13,6 +13,9 @@ * limitations under the License. */ +#include + +#include "key_event.h" #include "session/host/include/extension_session.h" #include "ipc_skeleton.h" @@ -25,6 +28,64 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "ExtensionSession" }; } // namespace +class WindowEventChannelListener : public IRemoteStub { +public: + explicit WindowEventChannelListener() = default; + + void SetTransferKeyEventForConsumedParams(std::shared_ptr>& isConsumedPromise, + std::shared_ptr& retCode) + { + std::lock_guard lock(transferKeyEventForConsumedMutex_); + isConsumedPromise_ = isConsumedPromise; + retCode_ = retCode; + } + + void ReSetTransferKeyEventForConsumedParams() + { + std::lock_guard lock(transferKeyEventForConsumedMutex_); + isConsumedPromise_ = nullptr; + retCode_ = nullptr; + } + + void OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) override + { + std::lock_guard lock(transferKeyEventForConsumedMutex_); + if (isConsumedPromise_ == nullptr || retCode_ == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "Promise or ret is null in WindowEventChannelListener."); + return; + } + isConsumedPromise_->set_value(isConsumed); + *retCode_ = retCode; + } + + int32_t OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override + { + if (data.ReadInterfaceToken() != GetDescriptor()) { + TLOGE(WmsLogTag::WMS_EVENT, "InterfaceToken check failed"); + return -1; + } + + auto msgId = static_cast(code); + switch (msgId) { + case WindowEventChannelListenerMessage::TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC: { + bool isConsumed = data.ReadBool(); + WSError retCode = static_cast(data.ReadInt32()); + OnTransferKeyEventForConsumed(isConsumed, retCode); + break; + } + default: + TLOGE(WmsLogTag::WMS_EVENT, "unknown transaction code %{public}d", code); + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return 0; + } +private: + std::mutex transferKeyEventForConsumedMutex_; + std::shared_ptr> isConsumedPromise_; + std::shared_ptr retCode_; +}; + ExtensionSession::ExtensionSession(const SessionInfo& info) : Session(info) { WLOGFD("Create extension session, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.", @@ -128,6 +189,57 @@ void ExtensionSession::RegisterExtensionSessionEventCallback( extSessionEventCallback_ = extSessionEventCallback; } +WSError ExtensionSession::TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) +{ + bool isTimeout = false; + bool isPreImeEvent = false; + return TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); +} + +WSError ExtensionSession::TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool& isTimeout, bool isPreImeEvent) +{ + TLOGD(WmsLogTag::WMS_EVENT, "TransferKeyEventForConsumed in , id:%{public}d", keyEvent->GetId()); + if (!windowEventChannel_) { + TLOGE(WmsLogTag::WMS_EVENT, "windowEventChannel_ is null"); + return WSError::WS_ERROR_NULLPTR; + } + if (keyEvent == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "KeyEvent is nullptr"); + return WSError::WS_ERROR_NULLPTR; + } + + sptr listener = new WindowEventChannelListener(); + if (listener == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "Created WindowEventChannelListener is nullptr."); + return WSError::WS_ERROR_NULLPTR; + } + + auto isConsumedPromise = std::make_shared>(); + std::shared_ptr retCode = std::make_shared(WSError::WS_OK); + listener->SetTransferKeyEventForConsumedParams(isConsumedPromise, retCode); + auto ret = windowEventChannel_->TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, listener); + + constexpr int64_t TRANSFER_KEY_EVENT_TIMEOUT_TIME_MS = 1000; + auto isConsumedFuture = isConsumedPromise->get_future().share(); + if (isConsumedFuture.wait_for(std::chrono::milliseconds(TRANSFER_KEY_EVENT_TIMEOUT_TIME_MS)) == + std::future_status::timeout) { + // Prevent external variables from being used after the lifecycle ends. + listener->ReSetTransferKeyEventForConsumedParams(); + isTimeout = true; + keyEvent->MarkProcessed(); + } else { + isTimeout = false; + isConsumed = isConsumedFuture.get(); + if (retCode != nullptr) { + ret = *retCode; + } + } + TLOGD(WmsLogTag::WMS_EVENT, "isConsumed is %{public}d, Timeout is %{public}d, ret is %{public}d in id:%{public}d.", + isConsumed, isTimeout, ret, keyEvent->GetId()); + return ret; +} + sptr ExtensionSession::GetExtensionSessionEventCallback() { if (extSessionEventCallback_ == nullptr) { diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 45414c74a..153342d40 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -875,22 +875,24 @@ void SessionProxy::NotifyAsyncOn() void SessionProxy::NotifyExtensionDied() { + TLOGI(WmsLogTag::WMS_UIEXT, "NotifyExtensionDied called."); MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("WriteInterfaceToken failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed"); return; } if (Remote()->SendRequest(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DIED), data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed"); return; } } void SessionProxy::NotifyExtensionTimeout(int32_t errorCode) { + TLOGI(WmsLogTag::WMS_UIEXT, "NotifyExtensionTimeout(errorCode:%{public}d) called.", errorCode); MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index d14df4192..f89552862 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -45,6 +45,8 @@ public: WSError TransferFocusActiveEvent(bool isFocusActive) override; WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent = false) override; + WSError TransferKeyEventForConsumedAsync(const std::shared_ptr& keyEvent, bool isPreImeEvent, + const sptr& listener) override; WSError TransferFocusState(bool focusState) override; WSError TransferBackpressedEventForConsumed(bool& isConsumed) override; WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, @@ -87,6 +89,12 @@ WSError TestWindowEventChannel::TransferKeyEventForConsumed( return WSError::WS_OK; } +WSError TestWindowEventChannel::TransferKeyEventForConsumedAsync(const std::shared_ptr& keyEvent, + bool isPreImeEvent, const sptr& listener) +{ + return WSError::WS_OK; +} + WSError TestWindowEventChannel::TransferFocusState(bool foucsState) { return WSError::WS_OK; -- Gitee From a7c539f32f7264b1d8dcd9c7a10293af021c5729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Tue, 26 Mar 2024 17:17:48 +0800 Subject: [PATCH 197/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../napi/window_runtime/window_napi/js_window.cpp | 12 ++++++------ wm/include/window_scene_session_impl.h | 4 ++-- wm/src/window_scene_session_impl.cpp | 9 +++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 14b6ec62b..9a491604a 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5313,7 +5313,6 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - WLOGFE("Argc is invalid: %{piblic}zu", argc); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } std::vector> windowMask; @@ -5327,17 +5326,18 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) } wptr weakToken(windowToken_); NapiAsyncTask::CompleteCallback complete = - [weakToken, windowMask, errCode](napi_env env, NapiAsyncTask& task, int32_t status) { + [weakToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) { + WmErrorCode wmErrorCode; auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - errCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; - task.Reject(env, CreateJsError(env, static_cast(errCode), "Invalidate params")); + wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "Invalidate params")); return; } if (!WindowHelper::IsSubWindow(weakWindow->GetType()) && !WindowHelper::IsAppFloatingWindow(weakWindow->GetType())) { - errCode = WmErrorCode::WM_ERROR_INVALID_CALLING; - task.Reject(env, CreateJsError(env, static_cast(errCode), "Invalidate window type")); + wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; + task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "Invalidate window type")); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetWindowMask(windowMask)); diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 135374bef..37f857393 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -139,7 +139,7 @@ public: void ConsumeKeyEvent(std::shared_ptr& keyEvent) override; WSError NotifyDialogStateChange(bool isForeground) override; WMError HideNonSecureWindows(bool shouldHide) override; - WMError SetWindowMask(const std::vector>& windowMsak) const; + WMError SetWindowMask(const std::vector>& windowMsak) override; protected: void DestroySubWindow(); @@ -179,7 +179,7 @@ private: const MMI::PointerEvent::PointerItem& pointerItem); bool HandlePointDownEvent(const std::shared_ptr& pointerEvent, const MMI::PointerEvent::PointerItem& pointerItem, int32_t sourceType, float vpr, const WSRect& rect); - std::unique_ptr HandleWindowMask(const std::vector& windowMask); + std::unique_ptr HandleWindowMask(const std::vector>& windowMask); bool enableDefaultAnimation_ = true; sptr animationTransitionController_; }; diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index fe09ec7fd..8b1f0de70 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2803,7 +2803,7 @@ std::unique_ptr WindowSceneSessionImpl::HandleWindowMask( WLOGFE("WindowMask is invalid"); return nullptr; } - uint32_t maskeWidth = windowMask[0].size(); + uint32_t maskWidth = windowMask[0].size(); if (windowRect.height_ != maskHeight || windowRect.width_ != maskWidth) { WLOGFE("WindowMask is invalid"); return nullptr; @@ -2814,8 +2814,8 @@ std::unique_ptr WindowSceneSessionImpl::HandleWindowMask( opts.pixelFormat = Media::PixelFormat::RGBA_8888; opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE; opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE; - uint32_t length = maskeWidth * maskHeight; - uint32_t data = new (std::nothrow) uint32_t[length]; + uint32_t length = maskWidth * maskHeight; + uint32_t *data = new (std::nothrow) uint32_t[length]; if (data == nullptr) { WLOGFE("data is nullptr"); return nullptr; @@ -2845,9 +2845,10 @@ WMError WindowSceneSessionImpl::SetWindowMask(const std::vector(*mask)); surfaceNode_->SetCornerRadius(0.0f); surfaceNode_->SetShadowRadius(0.0f); - surfaceNode_->SetMask(mask); // RS interface to set mask + surfaceNode_->SetMask(RSMask); // RS interface to set mask RSTransaction::FlushImplicitTransaction(); property_->SetWindowMask(mask); -- Gitee From ea5c5591ffad04f4feb4f5de40db9891e8a657e0 Mon Sep 17 00:00:00 2001 From: xuyangyang Date: Tue, 26 Mar 2024 18:53:31 +0800 Subject: [PATCH 198/385] add TDD ut case Signed-off-by: xuyangyang Change-Id: I60b663321128a3aeed158f6ef44a27fd69b75fe8 --- .../unittest/display_manager_proxy_test.cpp | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) diff --git a/dmserver/test/unittest/display_manager_proxy_test.cpp b/dmserver/test/unittest/display_manager_proxy_test.cpp index a35978a01..02f10490c 100644 --- a/dmserver/test/unittest/display_manager_proxy_test.cpp +++ b/dmserver/test/unittest/display_manager_proxy_test.cpp @@ -706,6 +706,207 @@ HWTEST_F(DisplayManagerProxyTest, SetFreeze, Function | SmallTest | Level1) auto result = proxy.SetFreeze(displayIds, true); ASSERT_TRUE(result); } + +/** + * @tc.name: StopMirror + * @tc.desc: test DisplayManagerProxy::StopMirror + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, StopMirror, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + DisplayEvent event = DisplayEvent{0}; + proxy.NotifyDisplayEvent(event); + + std::vector mirrorScreenIds; + auto result = proxy.StopMirror(mirrorScreenIds); + EXPECT_EQ(DMError::DM_OK, result); +} + +/** + * @tc.name: GetScreenInfoById + * @tc.desc: test DisplayManagerProxy::GetScreenInfoById + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, GetScreenInfoById, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + DisplayEvent event = DisplayEvent{0}; + proxy.NotifyDisplayEvent(event); + + auto result = proxy.GetScreenInfoById(0); + EXPECT_EQ(nullptr, result); +} + +/** + * @tc.name: GetScreenGroupInfoById + * @tc.desc: test DisplayManagerProxy::GetScreenGroupInfoById + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, GetScreenGroupInfoById, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + DisplayEvent event = DisplayEvent{0}; + proxy.NotifyDisplayEvent(event); + + auto result = proxy.GetScreenGroupInfoById(0); + EXPECT_EQ(nullptr, result); +} + +/** + * @tc.name: GetAllScreenInfos + * @tc.desc: test DisplayManagerProxy::GetAllScreenInfos + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, GetAllScreenInfos, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); + std::vector> screenInfos; + auto result = proxy.GetAllScreenInfos(screenInfos); + EXPECT_EQ(DMError::DM_OK, result); +} + +/** + * @tc.name: MakeExpand + * @tc.desc: test DisplayManagerProxy::MakeExpand + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, MakeExpand, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); + std::vector screenId; + std::vector startPoint; + ScreenId screenGroupId; + auto result = proxy.MakeExpand(screenId, startPoint, screenGroupId); + EXPECT_EQ(DMError::DM_OK, result); +} + +/** + * @tc.name: StopExpand + * @tc.desc: test DisplayManagerProxy::StopExpand + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, StopExpand, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); + std::vector expandScreenIds; + auto result = proxy.StopExpand(expandScreenIds); + EXPECT_EQ(DMError::DM_OK, result); +} + +/** + * @tc.name: SetScreenActiveMode + * @tc.desc: test DisplayManagerProxy::SetScreenActiveMode + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, SetScreenActiveMode, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); + ScreenId screenId = 0; + auto result = proxy.SetScreenActiveMode(screenId, 0); + EXPECT_EQ(DMError::DM_OK, result); +} + +/** + * @tc.name: SetVirtualPixelRatio + * @tc.desc: test DisplayManagerProxy::SetVirtualPixelRatio + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, SetVirtualPixelRatio, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); + ScreenId screenId = 0; + auto result = proxy.SetVirtualPixelRatio(screenId, 1.0); + EXPECT_EQ(DMError::DM_OK, result); +} + +/** + * @tc.name: SetResolution + * @tc.desc: test DisplayManagerProxy::SetResolution + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, SetResolution, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); + ScreenId screenId = 0; + auto result = proxy.SetResolution(screenId, 50, 100, 1.00); + EXPECT_EQ(DMError::DM_OK, result); +} + +/** + * @tc.name: IsScreenRotationLocked + * @tc.desc: test DisplayManagerProxy::IsScreenRotationLocked + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, IsScreenRotationLocked, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); + bool isLocked = true; + auto result = proxy.IsScreenRotationLocked(isLocked); + EXPECT_EQ(DMError::DM_OK, result); +} + +/** + * @tc.name: SetScreenRotationLocked + * @tc.desc: test DisplayManagerProxy::SetScreenRotationLocked + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, SetScreenRotationLocked, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); + bool isLocked = true; + auto result = proxy.SetScreenRotationLocked(isLocked); + EXPECT_EQ(DMError::DM_OK, result); +} + +/** + * @tc.name: ResizeVirtualScreen + * @tc.desc: test DisplayManagerProxy::ResizeVirtualScreen + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, ResizeVirtualScreen, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); + ScreenId screenId = 0; + auto result = proxy.ResizeVirtualScreen(screenId, 50, 100); + EXPECT_EQ(DMError::DM_OK, result); +} + +/** + * @tc.name: MakeUniqueScreen + * @tc.desc: test DisplayManagerProxy::MakeUniqueScreen + * @tc.type: FUNC + */ +HWTEST_F(DisplayManagerProxyTest, MakeUniqueScreen, Function | SmallTest | Level1) +{ + sptr remoteMocker = new RemoteMocker(); + DisplayManagerProxy proxy(remoteMocker); + EXPECT_EQ(static_cast>(remoteMocker), proxy.remoteObject_); + std::vector screenIds; + auto result = proxy.MakeUniqueScreen(screenIds); + EXPECT_EQ(DMError::DM_OK, result); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From df08d454584748eaa9c0b7be44cf070a0c46f071 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 26 Mar 2024 20:01:27 +0800 Subject: [PATCH 199/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/window.cpp | 11 ++++------- wm/test/unittest/window_test.cpp | 14 +++----------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/wm/src/window.cpp b/wm/src/window.cpp index 01eab19ea..f6a5f1fcc 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -145,12 +145,9 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo if (!SceneBoardJudgement::IsSceneBoardEnabled()) { return nullptr; } - if (!option) { - TLOGE(WmsLogTag::WMS_PIP, "option is null."); - return nullptr; - } - if (option->GetWindowName().empty()) { - TLOGE(WmsLogTag::WMS_PIP, "window option name is empty:%{public}u", option == nullptr); + if (!option || option->GetWindowName().empty()) { + WLOGE("host window session is nullptr:%{public}u or option is null: %{public}u", + option->GetWindowName().empty(), option == nullptr); return nullptr; } if (!WindowHelper::IsPipWindow(option->GetWindowType())) { @@ -206,7 +203,7 @@ sptr Window::GetMainWindowWithContext(const std::shared_ptr windowOption = nullptr; + sptr option = nullptr; PiPTemplateInfo pipTemplateInfo; ASSERT_EQ(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); - windowOption = new WindowOption(); - ASSERT_EQ(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); - windowOption->SetWindowName("pip_window"); - windowOption->SetWindowType(WindowType::WINDOW_TYPE_PIP); - windowOption->SetWindowMode(WindowMode::WINDOW_MODE_PIP); - if (SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_NE(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); - } else { - ASSERT_EQ(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); - } + option = new WindowOption(); + ASSERT_NE(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); } /** -- Gitee From 4addb8a079e63b16a05d9f7900dcc035fd837059 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 26 Mar 2024 20:03:23 +0800 Subject: [PATCH 200/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window.cpp b/wm/src/window.cpp index f6a5f1fcc..f693151f9 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -146,7 +146,7 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo return nullptr; } if (!option || option->GetWindowName().empty()) { - WLOGE("host window session is nullptr:%{public}u or option is null: %{public}u", + TLOGE(WmsLogTag::WMS_PIP, "host window session is nullptr:%{public}u or option is null: %{public}u", option->GetWindowName().empty(), option == nullptr); return nullptr; } -- Gitee From ed5be1f5db4ba87131421b6879db600a1c860298 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 26 Mar 2024 20:04:17 +0800 Subject: [PATCH 201/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/test/unittest/window_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index f0dfb88fa..cff76a9ab 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -120,9 +120,9 @@ HWTEST_F(WindowTest, CreatePiP, Function | SmallTest | Level2) { sptr option = nullptr; PiPTemplateInfo pipTemplateInfo; - ASSERT_EQ(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); + ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); option = new WindowOption(); - ASSERT_NE(nullptr, Window::CreatePiP(windowOption, pipTemplateInfo, abilityContext_)); + ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); } /** -- Gitee From bd64228d46fa41a196932691bd8ba03c6987d92c Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 26 Mar 2024 20:23:58 +0800 Subject: [PATCH 202/385] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E6=B5=81=E7=A8=8B=E7=A9=BA=E6=8C=87?= =?UTF-8?q?=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/window.cpp | 9 ++++++--- wm/test/unittest/window_test.cpp | 11 ++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/wm/src/window.cpp b/wm/src/window.cpp index 5e5bb53c6..3d890da76 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -145,9 +145,12 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo if (!SceneBoardJudgement::IsSceneBoardEnabled()) { return nullptr; } - if (!option || option->GetWindowName().empty()) { - TLOGE(WmsLogTag::WMS_PIP, "host window session is nullptr:%{public}u or option is null: %{public}u", - option->GetWindowName().empty(), option == nullptr); + if (!option) { + TLOGE(WmsLogTag::WMS_PIP, "option is null."); + return nullptr; + } + if (option->GetWindowName().empty()) { + TLOGE(WmsLogTag::WMS_PIP, "the window name of option is empty."); return nullptr; } if (!WindowHelper::IsPipWindow(option->GetWindowType())) { diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 525b25112..2d5b18b8e 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -122,7 +122,16 @@ HWTEST_F(WindowTest, CreatePiP, Function | SmallTest | Level2) PiPTemplateInfo pipTemplateInfo; ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); option = new WindowOption(); - ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + option->SetWindowName("pip_window"); + ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + option->SetWindowType(WindowType::WINDOW_TYPE_PIP); + option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + } else { + ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + } } /** -- Gitee From 5c4a3d44dfb13e07523a2946389022b33974dc9a Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Thu, 21 Mar 2024 11:16:32 +0800 Subject: [PATCH 203/385] add handwrite window type and flag Signed-off-by: chengyiyi --- interfaces/innerkits/wm/wm_common.h | 4 +- .../window_runtime/window_napi/js_window.cpp | 59 +++++++++++++++++++ .../window_runtime/window_napi/js_window.h | 2 + .../window_napi/js_window_utils.cpp | 2 + .../window_napi/js_window_utils.h | 3 + previewer/include/wm_common.h | 3 +- .../scene_session_manager/js_scene_utils.cpp | 1 + .../scene_session_manager/js_scene_utils.h | 3 + .../src/scene_session_dirty_manager.cpp | 5 ++ wm/src/window_scene_session_impl.cpp | 6 +- 10 files changed, 85 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index ca73ac5a4..b80def5bf 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -78,6 +78,7 @@ enum class WindowType : uint32_t { WINDOW_TYPE_PIP, WINDOW_TYPE_THEME_EDITOR, WINDOW_TYPE_NAVIGATION_INDICATOR, + WINDOW_TYPE_HANDWRITE, ABOVE_APP_SYSTEM_WINDOW_END, SYSTEM_SUB_WINDOW_BASE = 2500, @@ -262,7 +263,8 @@ enum class WindowFlag : uint32_t { WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2, WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3, WINDOW_FLAG_WATER_MARK = 1 << 4, - WINDOW_FLAG_END = 1 << 5, + WINDOW_FLAG_HANDWRITING = 1 << 5, + WINDOW_FLAG_END = 1 << 6, }; /** diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index f8d2f58d7..4076bef57 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -658,6 +658,13 @@ napi_value JsWindow::SetWaterMarkFlag(napi_env env, napi_callback_info info) return (me != nullptr) ? me->OnSetWaterMarkFlag(env, info) : nullptr; } +napi_value JsWindow::SetHandwritingFlag(napi_env env, napi_callback_info info) +{ + WLOGI("SetHandwritingFlag"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetHandwritingFlag(env, info) : nullptr; +} + napi_value JsWindow::SetAspectRatio(napi_env env, napi_callback_info info) { WLOGI("[NAPI]SetAspectRatio"); @@ -4644,6 +4651,57 @@ napi_value JsWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info) return result; } +napi_value JsWindow::OnSetHandwritingFlag(napi_env env, napi_callback_info info) +{ + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < 1) { + WLOGFE("Argc is invalid: %{public}zu", argc); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + + napi_value nativeBool = argv[0]; + if (nativeBool == nullptr) { + WLOGFE("SetHandwritingFlag Invalid window flag"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + + bool isAddFlag = false; + napi_get_value_bool(env, nativeBool, &isAddFlag); + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [weakToken, isAddFlag](napi_env env, NapiAsyncTask& task, int32_t status) { + auto window = weakToken.promote(); + if (window == nullptr) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "OnSetHandwritingFlag failed.")); + return; + } + WMError ret = WMError::WM_OK; + if (isAddFlag) { + ret = window->AddWindowFlag(WindowFlag::WINDOW_FLAG_HANDWRITING); + } else { + ret = window->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_HANDWRITING); + } + if (ret == WMError::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, CreateJsError(env, + static_cast(WM_JS_TO_ERROR_CODE_MAP.at(ret)), "SetHandwritingFlag failed.")); + } + WLOGI("[NAPI]Window [%{public}u, %{public}s] set handwriting flag end, ret = %{public}d", + window->GetWindowId(), window->GetWindowName().c_str(), ret); + }; + + napi_value lastParam = (argc == 1) ? nullptr : + (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnSetHandwritingFlag", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) { @@ -5192,6 +5250,7 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setAspectRatio", moduleName, JsWindow::SetAspectRatio); BindNativeFunction(env, object, "resetAspectRatio", moduleName, JsWindow::ResetAspectRatio); BindNativeFunction(env, object, "setWaterMarkFlag", moduleName, JsWindow::SetWaterMarkFlag); + BindNativeFunction(env, object, "setHandwritingFlag", moduleName, JsWindow::SetHandwritingFlag); BindNativeFunction(env, object, "minimize", moduleName, JsWindow::Minimize); BindNativeFunction(env, object, "maximize", moduleName, JsWindow::Maximize); BindNativeFunction(env, object, "setResizeByDragEnabled", moduleName, JsWindow::SetResizeByDragEnabled); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 87e18073b..6ae018016 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -137,6 +137,7 @@ public: static napi_value SetBackdropBlur(napi_env env, napi_callback_info info); static napi_value SetBackdropBlurStyle(napi_env env, napi_callback_info info); static napi_value SetWaterMarkFlag(napi_env env, napi_callback_info info); + static napi_value SetHandwritingFlag(napi_env env, napi_callback_info info); static napi_value SetWindowDecorVisible(napi_env env, napi_callback_info info); static napi_value SetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetWindowDecorHeight(napi_env env, napi_callback_info info); @@ -248,6 +249,7 @@ private: napi_value OnSetBackdropBlur(napi_env env, napi_callback_info info); napi_value OnSetBackdropBlurStyle(napi_env env, napi_callback_info info); napi_value OnSetWaterMarkFlag(napi_env env, napi_callback_info info); + napi_value OnSetHandwritingFlag(napi_env env, napi_callback_info info); sptr windowToken_ = nullptr; std::unique_ptr registerManager_ = nullptr; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 15a194e75..070460bc3 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -85,6 +85,8 @@ napi_value WindowTypeInit(napi_env env) static_cast(ApiWindowType::TYPE_SYSTEM_TOAST))); napi_set_named_property(env, objValue, "TYPE_GLOBAL_SEARCH", CreateJsValue(env, static_cast(ApiWindowType::TYPE_GLOBAL_SEARCH))); + napi_set_named_property(env, objValue, "TYPE_HANDWRITE", CreateJsValue(env, + static_cast(ApiWindowType::TYPE_HANDWRITE))); return objValue; } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 6bbe76922..17676d73b 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -66,6 +66,7 @@ enum class ApiWindowType : uint32_t { TYPE_SYSTEM_TOAST, TYPE_DIVIDER, TYPE_GLOBAL_SEARCH, + TYPE_HANDWRITE, TYPE_END }; @@ -101,6 +102,7 @@ const std::map NATIVE_JS_TO_WINDOW_TYPE_MAP { { WindowType::WINDOW_TYPE_SYSTEM_TOAST, ApiWindowType::TYPE_SYSTEM_TOAST }, { WindowType::WINDOW_TYPE_DOCK_SLICE, ApiWindowType::TYPE_DIVIDER }, { WindowType::WINDOW_TYPE_GLOBAL_SEARCH, ApiWindowType::TYPE_GLOBAL_SEARCH }, + { WindowType::WINDOW_TYPE_HANDWRITE, ApiWindowType::TYPE_HANDWRITE }, }; const std::map JS_TO_NATIVE_WINDOW_TYPE_MAP { @@ -125,6 +127,7 @@ const std::map JS_TO_NATIVE_WINDOW_TYPE_MAP { { ApiWindowType::TYPE_SYSTEM_TOAST, WindowType::WINDOW_TYPE_SYSTEM_TOAST }, { ApiWindowType::TYPE_DIVIDER, WindowType::WINDOW_TYPE_DOCK_SLICE }, { ApiWindowType::TYPE_GLOBAL_SEARCH, WindowType::WINDOW_TYPE_GLOBAL_SEARCH }, + { ApiWindowType::TYPE_HANDWRITE, WindowType::WINDOW_TYPE_HANDWRITE }, }; enum class ApiWindowMode : uint32_t { diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index e859e6cb1..a75dda5b6 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -242,7 +242,8 @@ enum class WindowFlag : uint32_t { WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2, WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3, WINDOW_FLAG_WATER_MARK = 1 << 4, - WINDOW_FLAG_END = 1 << 5, + WINDOW_FLAG_HANDWRITING = 1 << 5, + WINDOW_FLAG_END = 1 << 6, }; /** diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp index 7767e40fb..244d57023 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp @@ -956,6 +956,7 @@ napi_value SessionTypeInit(napi_env env) SetTypeProperty(objValue, env, "TYPE_PIP", JsSessionType::TYPE_PIP); SetTypeProperty(objValue, env, "TYPE_THEME_EDITOR", JsSessionType::TYPE_THEME_EDITOR); SetTypeProperty(objValue, env, "TYPE_NAVIGATION_INDICATOR", JsSessionType::TYPE_NAVIGATION_INDICATOR); + SetTypeProperty(objValue, env, "TYPE_HANDWRITE", JsSessionType::TYPE_HANDWRITE); return objValue; } diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h index 94e2eb701..9fb8748dc 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h @@ -61,6 +61,7 @@ enum class JsSessionType : uint32_t { TYPE_NAVIGATION_INDICATOR, TYPE_SEARCHING_BAR, TYPE_SYSTEM_SUB_WINDOW, + TYPE_HANDWRITE, }; // should same with bundlemanager ability info @@ -113,6 +114,7 @@ const std::map WINDOW_TO_JS_SESSION_TYPE_MAP { { WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, JsSessionType::TYPE_NAVIGATION_INDICATOR }, { WindowType::WINDOW_TYPE_SEARCHING_BAR, JsSessionType::TYPE_SEARCHING_BAR }, { WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW, JsSessionType::TYPE_SYSTEM_SUB_WINDOW }, + { WindowType::WINDOW_TYPE_HANDWRITE, JsSessionType::TYPE_HANDWRITE }, }; const std::map JS_SESSION_TO_WINDOW_TYPE_MAP { @@ -148,6 +150,7 @@ const std::map JS_SESSION_TO_WINDOW_TYPE_MAP { { JsSessionType::TYPE_NAVIGATION_INDICATOR, WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR }, { JsSessionType::TYPE_SEARCHING_BAR, WindowType::WINDOW_TYPE_SEARCHING_BAR }, { JsSessionType::TYPE_SYSTEM_SUB_WINDOW, WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW }, + { JsSessionType::TYPE_HANDWRITE, WindowType::WINDOW_TYPE_HANDWRITE }, }; const std::map WINDOW_ORIENTATION_TO_JS_SESSION_MAP { diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 47120de5b..876efee58 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -428,6 +428,11 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr .zOrder = zOrder, .transform = transformData }; + if (sceneSession->GetSessionProperty()->GetWindowFlags() & + static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING)) { + WLOGFI("Add handwrite flag for session, id: %{public}d", windowId); + windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_HANDWRITE; + } return windowInfo; } diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 786bcada4..ef4026e11 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -92,7 +92,7 @@ bool WindowSceneSessionImpl::IsValidSystemWindowType(const WindowType& type) type == WindowType::WINDOW_TYPE_VOLUME_OVERLAY || type == WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR || type == WindowType::WINDOW_TYPE_SYSTEM_TOAST || type == WindowType::WINDOW_TYPE_SYSTEM_FLOAT || type == WindowType::WINDOW_TYPE_PIP || type == WindowType::WINDOW_TYPE_GLOBAL_SEARCH || - type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW)) { + type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW || type == WindowType::WINDOW_TYPE_HANDWRITE)){ TLOGI(WmsLogTag::WMS_SYSTEM, "Invalid type: %{public}u", type); return false; } @@ -1910,6 +1910,10 @@ WMError WindowSceneSessionImpl::AddWindowFlag(WindowFlag flag) WLOGI("Can not add window flag WINDOW_FLAG_SHOW_WHEN_LOCKED"); return WMError::WM_ERROR_INVALID_PERMISSION; } + if (flag == WindowFlag::WINDOW_FLAG_HANDWRITING && !SessionPermission::IsSystemCalling()) { + WLOGI("Can not add window flag WINDOW_FLAG_HANDWRITING"); + return WMError::WM_ERROR_INVALID_PERMISSION; + } uint32_t updateFlags = property_->GetWindowFlags() | (static_cast(flag)); return SetWindowFlags(updateFlags); } -- Gitee From dea8f1ed11f939f62cf898a3b38b9c69869059ea Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Thu, 21 Mar 2024 11:16:32 +0800 Subject: [PATCH 204/385] add handwrite window type and flag Signed-off-by: chengyiyi --- dm/include/display_manager_adapter.h | 3 + dm/src/display_manager_adapter.cpp | 24 + dm/src/screen_manager.cpp | 10 + dm/test/unittest/screen_manager_test.cpp | 32 ++ dmserver/include/display_manager_interface.h | 11 + etc/wms.para | 3 +- etc/wms.para.dac | 3 +- interfaces/innerkits/dm/dm_common.h | 2 + interfaces/innerkits/dm/screen.h | 6 + interfaces/innerkits/dm/screen_manager.h | 17 + interfaces/innerkits/wm/window.h | 82 +++- interfaces/innerkits/wm/wm_common.h | 49 +-- .../extension_window/js_extension_window.cpp | 36 +- .../extension_window/js_extension_window.h | 2 +- .../inner/js_pip_manager.cpp | 19 +- .../js_pip_controller.cpp | 79 ++-- .../js_pip_window_manager.cpp | 21 +- .../window_manager_napi/js_window_manager.cpp | 111 +++-- .../window_runtime/window_napi/js_window.cpp | 411 ++++++++++++++---- .../window_runtime/window_napi/js_window.h | 10 + .../window_napi/js_window_listener.cpp | 19 + .../window_napi/js_window_listener.h | 5 +- .../js_window_register_manager.cpp | 61 ++- .../window_napi/js_window_register_manager.h | 44 +- .../window_napi/js_window_utils.cpp | 24 + .../window_napi/js_window_utils.h | 4 + .../window_stage_napi/js_window_stage.cpp | 8 + previewer/include/window.h | 28 +- previewer/include/window_impl.h | 2 + previewer/include/wm_common.h | 19 +- previewer/mock/js_window_register_manager.cpp | 2 +- previewer/mock/js_window_register_manager.h | 2 +- previewer/src/window_impl.cpp | 5 + test/common/mock/mock_uicontent.h | 2 +- .../sessioninterface_fuzzer.cpp | 2 + .../wms/window_fuzzer/window_fuzzer.cpp | 7 + utils/BUILD.gn | 2 - utils/include/client_agent_container.h | 17 +- utils/include/pip_util.h | 37 -- utils/include/window_manager_hilog.h | 2 + utils/src/pip_report.cpp | 33 +- utils/src/pip_util.cpp | 148 ------- utils/test/unittest/BUILD.gn | 14 - utils/test/unittest/pip_util_test.cpp | 146 ------- .../common/include/session_permission.h | 1 + .../common/src/session_permission.cpp | 33 ++ .../src/intention_event_manager.cpp | 2 + window_scene/interfaces/include/ws_common.h | 1 + .../js_root_scene_session.cpp | 6 +- .../js_scene_session.cpp | 59 ++- .../scene_session_manager/js_scene_session.h | 2 + .../js_scene_session_manager.cpp | 29 +- .../js_scene_session_manager.h | 2 - .../scene_session_manager/js_scene_utils.cpp | 2 + .../scene_session_manager/js_scene_utils.h | 3 + .../include/screen_session_manager_client.h | 1 + .../src/screen_session_manager_client.cpp | 9 + window_scene/session/BUILD.gn | 2 + .../container/include/window_event_channel.h | 5 +- .../include/zidl/session_stage_interface.h | 69 +-- .../zidl/session_stage_ipc_interface_code.h | 1 + .../include/zidl/session_stage_proxy.h | 1 + .../include/zidl/session_stage_stub.h | 1 + .../zidl/window_event_channel_interface.h | 5 +- .../include/zidl/window_event_channel_proxy.h | 5 +- .../include/zidl/window_event_channel_stub.h | 1 + .../zidl/window_event_ipc_interface_code.h | 3 +- .../container/src/window_event_channel.cpp | 18 +- .../src/zidl/session_stage_proxy.cpp | 27 ++ .../container/src/zidl/session_stage_stub.cpp | 17 +- .../src/zidl/window_event_channel_proxy.cpp | 41 +- .../src/zidl/window_event_channel_stub.cpp | 53 ++- .../host/include/scene_persistent_storage.h | 13 - .../session/host/include/scene_session.h | 22 +- window_scene/session/host/include/session.h | 15 +- .../host/include/zidl/session_interface.h | 3 +- .../include/zidl/session_ipc_interface_code.h | 3 +- .../session/host/include/zidl/session_proxy.h | 3 +- .../session/host/include/zidl/session_stub.h | 3 +- .../host/src/scene_persistent_storage.cpp | 1 - .../session/host/src/scene_session.cpp | 248 ++++------- window_scene/session/host/src/session.cpp | 43 +- .../session/host/src/zidl/session_proxy.cpp | 80 ++-- .../session/host/src/zidl/session_stub.cpp | 50 ++- .../session/screen/include/screen_session.h | 4 + .../session/screen/src/screen_session.cpp | 22 +- .../include/scene_session_manager.h | 10 +- .../include/screen_session_manager.h | 13 +- .../zidl/screen_session_manager_proxy.h | 2 + .../src/scene_session_dirty_manager.cpp | 17 +- .../src/scene_session_manager.cpp | 160 ++++--- .../src/screen_session_manager.cpp | 223 +++++++++- .../src/session_display_power_controller.cpp | 10 +- .../src/zidl/screen_session_manager_proxy.cpp | 51 +++ .../src/zidl/screen_session_manager_stub.cpp | 13 + window_scene/test/mock/mock_session_stage.h | 4 + window_scene/test/mock/mock_session_stub.h | 1 + .../unittest/scene_session_manager_test.cpp | 32 ++ .../test/unittest/scene_session_test.cpp | 83 ++-- .../test/unittest/session_proxy_test.cpp | 15 + .../test/unittest/session_stub_test.cpp | 18 +- window_scene/test/unittest/session_test.cpp | 57 ++- wm/include/picture_in_picture_controller.h | 2 - wm/include/picture_in_picture_manager.h | 2 - wm/include/root_scene.h | 3 + wm/include/window_extension_session_impl.h | 2 + wm/include/window_impl.h | 2 +- wm/include/window_scene_session_impl.h | 4 +- wm/include/window_session_impl.h | 27 ++ wm/src/picture_in_picture_controller.cpp | 164 +++---- wm/src/picture_in_picture_manager.cpp | 57 +-- wm/src/root_scene.cpp | 6 + wm/src/window.cpp | 8 +- wm/src/window_extension_session_impl.cpp | 11 + wm/src/window_impl.cpp | 8 + wm/src/window_input_channel.cpp | 34 +- wm/src/window_manager.cpp | 18 +- wm/src/window_scene_session_impl.cpp | 145 +++--- wm/src/window_session_impl.cpp | 170 +++++++- .../picture_in_picture_controller_test.cpp | 3 - wm/test/unittest/window_impl_test.cpp | 2 +- .../window_scene_session_impl_test.cpp | 101 +++++ wm/test/unittest/window_session_impl_test.cpp | 72 +++ wm/test/unittest/window_test.cpp | 29 ++ wmserver/BUILD.gn | 2 +- wmserver/src/mock_session_manager_service.cpp | 3 +- .../src/window_manager_agent_controller.cpp | 7 +- wmserver/src/window_manager_service.cpp | 3 +- 128 files changed, 2608 insertions(+), 1459 deletions(-) delete mode 100644 utils/include/pip_util.h delete mode 100644 utils/src/pip_util.cpp delete mode 100644 utils/test/unittest/pip_util_test.cpp diff --git a/dm/include/display_manager_adapter.h b/dm/include/display_manager_adapter.h index 7deabacb2..5f0c05573 100644 --- a/dm/include/display_manager_adapter.h +++ b/dm/include/display_manager_adapter.h @@ -142,6 +142,9 @@ public: // unique screen virtual DMError MakeUniqueScreen(const std::vector& screenIds); + + virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId); + virtual DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag); private: static inline SingletonDelegator delegator; }; diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index ac049c993..ad52a141e 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -661,4 +661,28 @@ DMError DisplayManagerAdapter::GetAvailableArea(DisplayId displayId, DMRect& are return displayManagerServiceProxy_->GetAvailableArea(displayId, area); } + +VirtualScreenFlag ScreenManagerAdapter::GetVirtualScreenFlag(ScreenId screenId) +{ + INIT_PROXY_CHECK_RETURN(VirtualScreenFlag::DEFAULT); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("screenId id is invalid"); + return VirtualScreenFlag::DEFAULT; + } + + return displayManagerServiceProxy_->GetVirtualScreenFlag(screenId); +} + +DMError ScreenManagerAdapter::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) +{ + INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED); + if (screenId == SCREEN_ID_INVALID) { + WLOGFE("displayId id is invalid"); + return DMError::DM_ERROR_INVALID_PARAM; + } + if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) { + return DMError::DM_ERROR_INVALID_PARAM; + } + return displayManagerServiceProxy_->SetVirtualScreenFlag(screenId, screenFlag); +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/dm/src/screen_manager.cpp b/dm/src/screen_manager.cpp index a5e394d1a..e4cc2d970 100644 --- a/dm/src/screen_manager.cpp +++ b/dm/src/screen_manager.cpp @@ -563,6 +563,16 @@ DMError ScreenManager::SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, b return SingletonContainer::Get().SetVirtualMirrorScreenCanvasRotation(screenId, rotation); } +VirtualScreenFlag ScreenManager::GetVirtualScreenFlag(ScreenId screenId) +{ + return SingletonContainer::Get().GetVirtualScreenFlag(screenId); +} + +DMError ScreenManager::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) +{ + return SingletonContainer::Get().SetVirtualScreenFlag(screenId, screenFlag); +} + bool ScreenManager::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) { WLOGFI("screenId:%{public}" PRIu64 ", state:%{public}u, reason:%{public}u", screenId, state, reason); diff --git a/dm/test/unittest/screen_manager_test.cpp b/dm/test/unittest/screen_manager_test.cpp index 3fbe78434..c1cc5d355 100644 --- a/dm/test/unittest/screen_manager_test.cpp +++ b/dm/test/unittest/screen_manager_test.cpp @@ -509,6 +509,38 @@ HWTEST_F(ScreenManagerTest, RegisterVirtualScreenGroupListener02, Function | Sma result = ScreenManager::GetInstance().RegisterVirtualScreenGroupListener(listener); ASSERT_EQ(DMError::DM_OK, result); } + +/** + * @tc.name: SetVirtualScreenFlag01 + * @tc.desc: SetVirtualScreenFlag01 fun + * @tc.type: FUNC + */ +HWTEST_F(ScreenManagerTest, SetVirtualScreenFlag01, Function | SmallTest | Level1) +{ + VirtualScreenOption defaultOption = {defaultName_, defaultWidth_, defaultHeight_, + defaultDensity_, nullptr, defaultFlags_}; + ScreenId screenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); + DMError ret = ScreenManager::GetInstance().SetVirtualScreenFlag(screenId, VirtualScreenFlag::CAST); + ASSERT_EQ(DMError::DM_OK, ret); + ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId); + ASSERT_EQ(DMError::DM_OK, ret); +} + +/** + * @tc.name: SetVirtualScreenFlag02 + * @tc.desc: SetVirtualScreenFlag02 fun + * @tc.type: FUNC + */ +HWTEST_F(ScreenManagerTest, SetVirtualScreenFlag02, Function | SmallTest | Level1) +{ + VirtualScreenOption defaultOption = {defaultName_, defaultWidth_, defaultHeight_, + defaultDensity_, nullptr, defaultFlags_}; + ScreenId screenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); + DMError ret = ScreenManager::GetInstance().SetVirtualScreenFlag(screenId, VirtualScreenFlag::MAX); + ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, ret); + ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId); + ASSERT_EQ(DMError::DM_OK, ret); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/dmserver/include/display_manager_interface.h b/dmserver/include/display_manager_interface.h index a7e4e6eec..4ce610ae4 100644 --- a/dmserver/include/display_manager_interface.h +++ b/dmserver/include/display_manager_interface.h @@ -119,6 +119,8 @@ public: TRANS_ID_GET_AVAILABLE_AREA, TRANS_ID_NOTIFY_FOLD_TO_EXPAND_COMPLETION, TRANS_ID_CONVERT_SCREENID_TO_RSSCREENID, + TRANS_ID_GET_VIRTUAL_SCREEN_FLAG, + TRANS_ID_SET_VIRTUAL_SCREEN_FLAG, }; virtual sptr GetDefaultDisplayInfo() = 0; @@ -235,6 +237,15 @@ public: // unique screen virtual DMError MakeUniqueScreen(const std::vector& screenIds) { return DMError::DM_OK; } + + virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) + { + return VirtualScreenFlag::DEFAULT; + } + virtual DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) + { + return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; + } }; } // namespace OHOS::Rosen diff --git a/etc/wms.para b/etc/wms.para index 10cefe49e..eecfd0787 100644 --- a/etc/wms.para +++ b/etc/wms.para @@ -11,4 +11,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -bootevent.wms.fullscreen.ready=false \ No newline at end of file +bootevent.wms.fullscreen.ready=false +bootevent.wms.ready=false \ No newline at end of file diff --git a/etc/wms.para.dac b/etc/wms.para.dac index cdccccffe..2c8f6c551 100644 --- a/etc/wms.para.dac +++ b/etc/wms.para.dac @@ -11,4 +11,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -bootevent.wms.fullscreen.ready = foundation:foundation:0775 \ No newline at end of file +bootevent.wms.fullscreen.ready = foundation:foundation:0775 +bootevent.wms.ready = foundation:foundation:0775 \ No newline at end of file diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index 921e529af..5121eb6f3 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -204,6 +204,7 @@ enum class ScreenChangeEvent : uint32_t { UPDATE_ROTATION, CHANGE_MODE, VIRTUAL_PIXEL_RATIO_CHANGED, + SCREEN_SWITCH_CHANGE, }; /** @@ -316,6 +317,7 @@ enum class ScreenSourceMode: uint32_t { SCREEN_MIRROR = 1, SCREEN_EXTEND = 2, SCREEN_ALONE = 3, + SCREEN_UNIQUE = 4, }; /** diff --git a/interfaces/innerkits/dm/screen.h b/interfaces/innerkits/dm/screen.h index 5d44ebf71..f246b084f 100644 --- a/interfaces/innerkits/dm/screen.h +++ b/interfaces/innerkits/dm/screen.h @@ -39,6 +39,12 @@ struct VirtualScreenOption { std::vector missionIds_ {}; }; +enum class VirtualScreenFlag : uint32_t { + DEFAULT = 0, + CAST = 1, + MAX = 2, +}; + class Screen : public RefBase { friend class ScreenManager; public: diff --git a/interfaces/innerkits/dm/screen_manager.h b/interfaces/innerkits/dm/screen_manager.h index 6acf7a1f4..eb7149e01 100644 --- a/interfaces/innerkits/dm/screen_manager.h +++ b/interfaces/innerkits/dm/screen_manager.h @@ -295,6 +295,23 @@ public: * @return DM_OK means unregister success, others means unregister failed. */ DMError UnregisterVirtualScreenGroupListener(sptr listener); + + /** + * @brief Get virtual screen flag. + * + * @param screenId virtual screen id. + * @return virtual screen flag + */ + VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId); + + /** + * @brief Set virtual screen flag. + * + * @param screenId virtual screen id. + * @param screenFlag virtual screen flag. + * @return DM_OK means set success, others means failed. + */ + DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag); private: ScreenManager(); ~ScreenManager(); diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index d0808ba89..70d22db24 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -386,6 +386,17 @@ public: }; using IWindowVisibilityListenerSptr = sptr; +/** + * @class IWindowNoInteractionListenerSptr + * + * @brief Listener to observe no interaction event for a long time of window. +*/ +class IWindowNoInteractionListener : virtual public RefBase { +public: + virtual void OnWindowNoInteractionCallback() {}; +}; +using IWindowNoInteractionListenerSptr = sptr; + /** * @class IWindowTitleButtonRectChangedListener * @@ -926,6 +937,12 @@ public: * @param inputEvent Keyboard input event. */ virtual void ConsumeKeyEvent(std::shared_ptr& inputEvent) {} + /** + * @brief Notify KeyEvent to arkui. + * + * @param inputEvent Keyboard input event + */ + virtual bool PreNotifyKeyEvent(const std::shared_ptr& keyEvent) {return false;} /** * @brief Consume PointerEvent from MMI. * @@ -1285,6 +1302,15 @@ public: * @return WMError */ virtual WMError Maximize() { return WMError::WM_OK; } + + /** + * @brief maximize window with layoutOption. + * + * @param option UI layout param. + * @return WM_OK means maximize window ok, others means failed. + */ + virtual WMError Maximize(MaximizeLayoutOption option) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** * @brief maximize the main window according to MaximizeMode. called by ACE when maximize button is clicked. * @@ -1501,14 +1527,6 @@ public: */ virtual void UpdatePiPRect(const Rect& rect, WindowSizeChangeReason reason) {} - /** - * @brief Recovery pip main window. - * - * @param Rect of window. - * @return Errorcode of window. - */ - virtual WMError RecoveryPullPiPMainWindow(const Rect& rect) { return WMError::WM_OK; } - /** * @brief When get focused, keep the keyboard created by other windows, support system window and app subwindow. * @@ -1555,6 +1573,30 @@ public: return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Register listener, if timeout(seconds) pass with no interaction, the listener will be executed. + * + * @param listener IWindowNoInteractionListenerSptr. + * @param timeout uint32_t if timeout(seconds) pass with no interaction, the listener will be executed. + * @return WM_OK means unregister success, others means unregister failed. + */ + virtual WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, + uint32_t timeout) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + + /** + * @brief Unregister window no interaction listener. + * + * @param listener IWindowNoInteractionListenerSptr. + * @return WM_OK means unregister success, others means unregister failed. + */ + virtual WMError UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + /** * @brief Register window status change listener. * @@ -1665,6 +1707,17 @@ public: return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Set the modality of window. + * + * @param isModal bool. + * @return WMError + */ + virtual WMError SetSubWindowModal(bool isModal) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + /** * @brief recovery the main window by function overloading. It is called by JsWindow. * @@ -1680,7 +1733,7 @@ public: * @return WM_OK means add success, others means failed. */ virtual WMError AddExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } - + /** * @brief Remove uiextension window flag. * @@ -1688,6 +1741,17 @@ public: * @return WM_OK means remove success, others means failed. */ virtual WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + + /** + * @brief Make multi-window become landscape or not. + * + * @param isLandscapeMultiWindow means whether multi-window's scale is landscape. + * @return WMError WM_OK means set success, others means failed. + */ + virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) + { + return WMError::WM_OK; + } }; } } diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index ca73ac5a4..b1fa92609 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -78,6 +78,7 @@ enum class WindowType : uint32_t { WINDOW_TYPE_PIP, WINDOW_TYPE_THEME_EDITOR, WINDOW_TYPE_NAVIGATION_INDICATOR, + WINDOW_TYPE_HANDWRITE, ABOVE_APP_SYSTEM_WINDOW_END, SYSTEM_SUB_WINDOW_BASE = 2500, @@ -262,7 +263,9 @@ enum class WindowFlag : uint32_t { WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2, WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3, WINDOW_FLAG_WATER_MARK = 1 << 4, - WINDOW_FLAG_END = 1 << 5, + WINDOW_FLAG_IS_MODAL = 1 << 5, + WINDOW_FLAG_HANDWRITING = 1 << 6, + WINDOW_FLAG_END = 1 << 7, }; /** @@ -659,36 +662,6 @@ enum class PipState : int32_t { ERROR = 6, }; -/** - * @brief Enumerates picture in picture scale level. - */ -enum class PiPScaleLevel : int32_t { - PIP_SCALE_LEVEL_SMALLEST = 0, - PIP_SCALE_LEVEL_BIGGEST = 1, - COUNT = 2, -}; - -/** - * @brief Enumerates picture in picture scale pivot. - */ -enum class PiPScalePivot : int32_t { - UNDEFINED = 0, - START, - MIDDLE, - END, -}; - -/** - * @brief Structure of picture in picture rect info. - */ -struct PiPRectInfo { - PiPScalePivot xPivot_; - PiPScalePivot yPivot_; - uint32_t originWidth_; - uint32_t originHeight_; - PiPScaleLevel level_; -}; - struct PiPTemplateInfo { uint32_t pipTemplateType; uint32_t priority; @@ -818,6 +791,20 @@ enum class CaseType { CASE_STAGE }; +/** + * maximize layout show type + */ +enum ShowType : int32_t { + SHOW, // normally show + HIDE, // show when hover, but hide normally + FORBIDDEN // hide always +}; + +struct MaximizeLayoutOption { + ShowType decor = ShowType::HIDE; + ShowType dock = ShowType::HIDE; +}; + } } #endif // OHOS_ROSEN_WM_COMMON_H diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index e6ac27f11..d9bee5fc9 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -853,17 +853,11 @@ napi_value JsExtensionWindow::OnCreateSubWindowWithOptions(napi_env env, napi_ca return NapiGetUndefined(env); } WindowOption option; - std::string title; - if (!ParseJsValue(argv[1], env, "title", title)) { - napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); - return NapiGetUndefined(env); - } - bool decorEnabled; - if (!ParseJsValue(argv[1], env, "decorEnabled", decorEnabled)) { + if (!ParseSubWindowOptions(env, argv[1], option)) { + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Get invalid options param"); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); return NapiGetUndefined(env); } - option = SetOption(option, title, decorEnabled); NapiAsyncTask::CompleteCallback complete = [weak = extensionWindow_, windowName, option](napi_env env, NapiAsyncTask& task, int32_t status) { if (weak == nullptr) { @@ -901,13 +895,33 @@ void JsExtensionWindow::SetWindowOption(sptr windowOption) windowOption->SetExtensionTag(true); } -WindowOption JsExtensionWindow::SetOption(WindowOption option, std::string title, - bool decorEnabled) +bool JsExtensionWindow::ParseSubWindowOptions(napi_env env, napi_value jsObject, WindowOption& option) { + if (jsObject == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "jsObject is null"); + return false; + } + std::string title; + if (!ParseJsValue(jsObject, env, "title", title)) { + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to title"); + return false; + } + bool decorEnabled; + if (!ParseJsValue(jsObject, env, "decorEnabled", decorEnabled)) { + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to decorEnabled"); + return false; + } + bool isModal = false; + if (ParseJsValue(jsObject, env, "isModal", isModal)) { + TLOGI(WmsLogTag::WMS_UIEXT, "isModal:%{public}d", isModal); + if (isModal) { + option.AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_MODAL); + } + } option.SetSubWindowTitle(title); option.SetSubWindowDecorEnable(decorEnabled); option.SetParentId(hostWindowId_); - return option; + return true; } } // namespace Rosen } // namespace OHOS diff --git a/interfaces/kits/napi/extension_window/js_extension_window.h b/interfaces/kits/napi/extension_window/js_extension_window.h index b404e2d19..80219a924 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.h +++ b/interfaces/kits/napi/extension_window/js_extension_window.h @@ -87,7 +87,7 @@ private: sptr sessionInfo_ = nullptr; std::unique_ptr extensionRegisterManager_ = nullptr; static void SetWindowOption(sptr windowOption); - WindowOption SetOption(WindowOption option, std::string title, bool decorEnabled); + bool ParseSubWindowOptions(napi_env env, napi_value jsObject, WindowOption& option); }; } // namespace Rosen } // namespace OHOS diff --git a/interfaces/kits/napi/picture_in_picture_napi/inner/js_pip_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/inner/js_pip_manager.cpp index be04fddae..ceea6bc8e 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/inner/js_pip_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/inner/js_pip_manager.cpp @@ -23,7 +23,6 @@ namespace Rosen { using namespace AbilityRuntime; using namespace Ace; namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipManager"}; constexpr int32_t NUMBER_ONE = 1; } @@ -50,7 +49,7 @@ JsPipManager::~JsPipManager() void JsPipManager::Finalizer(napi_env env, void* data, void* hint) { - WLOGFD("[NAPI]JsPipManager::Finalizer"); + TLOGD(WmsLogTag::WMS_PIP, "[NAPI]JsPipManager::Finalizer"); std::unique_ptr(static_cast(data)); } @@ -62,12 +61,12 @@ napi_value JsPipManager::InitXComponentController(napi_env env, napi_callback_in napi_value JsPipManager::OnInitXComponentController(napi_env env, napi_callback_info info) { - WLOGFD("[NAPI]JsPipManager::OnInitXComponentController"); + TLOGD(WmsLogTag::WMS_PIP, "[NAPI]JsPipManager::OnInitXComponentController"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < NUMBER_ONE) { - WLOGFE("[NAPI]Argc count is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Argc count is invalid: %{public}zu", argc); return NapiThrowInvalidParam(env); } napi_value xComponentController = argv[0]; @@ -75,28 +74,28 @@ napi_value JsPipManager::OnInitXComponentController(napi_env env, napi_callback_ XComponentController::GetXComponentControllerFromNapiValue(xComponentController); sptr pipWindow = Window::Find(PIP_WINDOW_NAME); if (!pipWindow) { - WLOGFE("[NAPI]Failed to find pip window"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to find pip window"); return NapiGetUndefined(env); } int32_t windowId = static_cast(pipWindow->GetWindowId()); sptr pipController = PictureInPictureManager::GetPipControllerInfo(windowId); if (pipController == nullptr) { - WLOGFE("[NAPI]Failed to get pictureInPictureController"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to get pictureInPictureController"); return NapiGetUndefined(env); } - WLOGFI("[NAPI]set xComponentController to window: %{public}u", windowId); + TLOGI(WmsLogTag::WMS_PIP, "[NAPI]set xComponentController to window: %{public}u", windowId); WMError errCode = pipController->SetXComponentController(xComponentControllerResult); if (errCode != WMError::WM_OK) { - WLOGFE("[NAPI]Failed to set xComponentController"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to set xComponentController"); } return NapiGetUndefined(env); } napi_value JsPipManagerInit(napi_env env, napi_value exportObj) { - WLOGFD("[NAPI]JsPipManager::JsPipManagerInit"); + TLOGD(WmsLogTag::WMS_PIP, "[NAPI]JsPipManager::JsPipManagerInit"); if (env == nullptr || exportObj == nullptr) { - WLOGFE("JsPipManagerInit failed, env or exportObj is null"); + TLOGE(WmsLogTag::WMS_PIP, "JsPipManagerInit failed, env or exportObj is null"); return nullptr; } std::unique_ptr jsPipManager = std::make_unique(); diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp index 961a481dd..ff928b6ac 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_controller.cpp @@ -28,7 +28,6 @@ namespace OHOS { namespace Rosen { using namespace AbilityRuntime; namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipController"}; constexpr int32_t NUMBER_TWO = 2; const std::string STATE_CHANGE_CB = "stateChange"; const std::string CONTROL_PANEL_ACTION_EVENT_CB = "controlPanelActionEvent"; @@ -51,7 +50,7 @@ napi_value CreateJsPipControllerObject(napi_env env, sptr jsPipController = std::make_unique(pipController, env); napi_wrap(env, objValue, jsPipController.release(), JsPipController::Finalizer, nullptr, nullptr); @@ -78,7 +77,7 @@ JsPipController::~JsPipController() void JsPipController::Finalizer(napi_env env, void* data, void* hint) { - WLOGFD("Finalizer is called"); + TLOGD(WmsLogTag::WMS_PIP, "Finalizer is called"); std::unique_ptr(static_cast(data)); } @@ -90,10 +89,10 @@ napi_value JsPipController::StartPictureInPicture(napi_env env, napi_callback_in napi_value JsPipController::OnStartPictureInPicture(napi_env env, napi_callback_info info) { - WLOGI("OnStartPictureInPicture is called"); + TLOGI(WmsLogTag::WMS_PIP, "OnStartPictureInPicture is called"); std::lock_guard lock(pipMutex_); if (PictureInPictureManager::ShouldAbortPipStart()) { - WLOGFI("OnStartPictureInPicture abort"); + TLOGI(WmsLogTag::WMS_PIP, "OnStartPictureInPicture abort"); return NapiGetUndefined(env); } size_t argc = 4; @@ -133,7 +132,7 @@ napi_value JsPipController::StopPictureInPicture(napi_env env, napi_callback_inf napi_value JsPipController::OnStopPictureInPicture(napi_env env, napi_callback_info info) { - WLOGI("OnStopPictureInPicture is called"); + TLOGI(WmsLogTag::WMS_PIP, "OnStopPictureInPicture is called"); std::lock_guard lock(pipMutex_); size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -172,21 +171,21 @@ napi_value JsPipController::SetAutoStartEnabled(napi_env env, napi_callback_info napi_value JsPipController::OnSetAutoStartEnabled(napi_env env, napi_callback_info info) { - WLOGI("OnSetAutoStartEnabled is called"); + TLOGI(WmsLogTag::WMS_PIP, "OnSetAutoStartEnabled is called"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != 1) { - WLOGFE("Argc count is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "Argc count is invalid: %{public}zu", argc); return NapiThrowInvalidParam(env); } bool enable = false; if (!ConvertFromJsValue(env, argv[0], enable)) { - WLOGFE("[NAPI]Failed to convert parameter to bool"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to convert parameter to bool"); return NapiGetUndefined(env); } if (pipController_ == nullptr) { - WLOGFE("[NAPI]OnSetAutoStartEnabled error, controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]OnSetAutoStartEnabled error, controller is nullptr"); return NapiGetUndefined(env); } pipController_->SetAutoStartEnabled(enable); @@ -201,26 +200,26 @@ napi_value JsPipController::UpdateContentSize(napi_env env, napi_callback_info i napi_value JsPipController::OnUpdateContentSize(napi_env env, napi_callback_info info) { - WLOGI("OnUpdateContentSize is called"); + TLOGI(WmsLogTag::WMS_PIP, "OnUpdateContentSize is called"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != NUMBER_TWO) { - WLOGFE("Argc count is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "Argc count is invalid: %{public}zu", argc); return NapiThrowInvalidParam(env); } int32_t width = 0; if (!ConvertFromJsValue(env, argv[0], width) || width <= 0) { - WLOGFE("Failed to convert parameter to uint32_t or parameter is invalid"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to uint32_t or parameter is invalid"); return NapiThrowInvalidParam(env); } int32_t height = 0; if (!ConvertFromJsValue(env, argv[1], height) || height <= 0) { - WLOGFE("Failed to convert parameter to uint32_t or parameter is invalid"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to uint32_t or parameter is invalid"); return NapiThrowInvalidParam(env); } if (pipController_ == nullptr) { - WLOGFE("OnUpdateContentSize error, controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "OnUpdateContentSize error, controller is nullptr"); return NapiThrowInvalidParam(env); } pipController_->UpdateContentSize(width, height); @@ -235,28 +234,28 @@ napi_value JsPipController::RegisterCallback(napi_env env, napi_callback_info in napi_value JsPipController::OnRegisterCallback(napi_env env, napi_callback_info info) { - WLOGI("OnRegisterCallback is called"); + TLOGI(WmsLogTag::WMS_PIP, "OnRegisterCallback is called"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < NUMBER_TWO) { - WLOGFE("JsPipController Params not match: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "JsPipController Params not match: %{public}zu", argc); return NapiThrowInvalidParam(env); } std::string cbType; if (!ConvertFromJsValue(env, argv[0], cbType)) { - WLOGFE("Failed to convert parameter to callbackType"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to callbackType"); return NapiThrowInvalidParam(env); } napi_value value = argv[1]; if (value == nullptr || !NapiIsCallable(env, value)) { - WLOGFE("Callback is nullptr or not callable"); + TLOGE(WmsLogTag::WMS_PIP, "Callback is nullptr or not callable"); return NapiThrowInvalidParam(env); } std::lock_guard lock(mtx_); WmErrorCode ret = RegisterListenerWithType(env, cbType, value); if (ret != WmErrorCode::WM_OK) { - WLOGFE("OnRegisterCallback failed"); + TLOGE(WmsLogTag::WMS_PIP, "OnRegisterCallback failed"); return NapiThrowInvalidParam(env); } return NapiGetUndefined(env); @@ -265,7 +264,7 @@ napi_value JsPipController::OnRegisterCallback(napi_env env, napi_callback_info WmErrorCode JsPipController::RegisterListenerWithType(napi_env env, const std::string& type, napi_value value) { if (IfCallbackRegistered(env, type, value)) { - WLOGFE("Callback already registered!"); + TLOGE(WmsLogTag::WMS_PIP, "Callback already registered!"); return WmErrorCode::WM_ERROR_INVALID_CALLING; } std::shared_ptr callbackRef; @@ -280,7 +279,7 @@ WmErrorCode JsPipController::RegisterListenerWithType(napi_env env, const std::s bool JsPipController::IfCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject) { if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) { - WLOGFI("methodName %{public}s not registered!", type.c_str()); + TLOGI(WmsLogTag::WMS_PIP, "methodName %{public}s not registered!", type.c_str()); return false; } @@ -288,7 +287,7 @@ bool JsPipController::IfCallbackRegistered(napi_env env, const std::string& type bool isEquals = false; napi_strict_equals(env, jsListenerObject, iter->second->GetNapiValue(), &isEquals); if (isEquals) { - WLOGFE("Callback already registered!"); + TLOGE(WmsLogTag::WMS_PIP, "Callback already registered!"); return true; } } @@ -298,11 +297,11 @@ bool JsPipController::IfCallbackRegistered(napi_env env, const std::string& type void JsPipController::ProcessStateChangeRegister() { if (jsCbMap_.empty() || jsCbMap_.find(STATE_CHANGE_CB) == jsCbMap_.end()) { - WLOGFE("Register state change error"); + TLOGE(WmsLogTag::WMS_PIP, "Register state change error"); return; } if (pipController_ == nullptr) { - WLOGFE("controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr"); return; } sptr lifeCycle = new JsPipController::PiPLifeCycleImpl(env_, jsCbMap_[STATE_CHANGE_CB]); @@ -312,11 +311,11 @@ void JsPipController::ProcessStateChangeRegister() void JsPipController::ProcessActionEventRegister() { if (jsCbMap_.empty() || jsCbMap_.find(CONTROL_PANEL_ACTION_EVENT_CB) == jsCbMap_.end()) { - WLOGFE("Register action event error"); + TLOGE(WmsLogTag::WMS_PIP, "Register action event error"); return; } if (pipController_ == nullptr) { - WLOGFE("controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr"); return; } sptr actionObserver = @@ -327,7 +326,7 @@ void JsPipController::ProcessActionEventRegister() void JsPipController::ProcessStateChangeUnRegister() { if (pipController_ == nullptr) { - WLOGFE("controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr"); return; } pipController_->SetPictureInPictureLifecycle(nullptr); @@ -336,7 +335,7 @@ void JsPipController::ProcessStateChangeUnRegister() void JsPipController::ProcessActionEventUnRegister() { if (pipController_ == nullptr) { - WLOGFE("controller is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr"); return; } pipController_->SetPictureInPictureActionObserver(nullptr); @@ -350,23 +349,22 @@ napi_value JsPipController::UnregisterCallback(napi_env env, napi_callback_info napi_value JsPipController::OnUnregisterCallback(napi_env env, napi_callback_info info) { - WLOGI("OnUnregisterCallback is called"); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != 1) { - WLOGFE("JsPipController Params not match: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "JsPipController Params not match: %{public}zu", argc); return NapiThrowInvalidParam(env); } std::string cbType; if (!ConvertFromJsValue(env, argv[0], cbType)) { - WLOGFE("Failed to convert parameter to string"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to string"); return NapiThrowInvalidParam(env); } std::lock_guard lock(mtx_); WmErrorCode ret = UnRegisterListenerWithType(env, cbType); if (ret != WmErrorCode::WM_OK) { - WLOGFE("OnUnregisterCallback failed"); + TLOGE(WmsLogTag::WMS_PIP, "OnUnregisterCallback failed"); napi_throw(env, CreateJsError(env, static_cast(ret))); } return NapiGetUndefined(env); @@ -375,7 +373,7 @@ napi_value JsPipController::OnUnregisterCallback(napi_env env, napi_callback_inf WmErrorCode JsPipController::UnRegisterListenerWithType(napi_env env, const std::string& type) { if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) { - WLOGFI("methodName %{public}s not registered!", type.c_str()); + TLOGI(WmsLogTag::WMS_PIP, "methodName %{public}s not registered!", type.c_str()); return WmErrorCode::WM_ERROR_INVALID_CALLING; } jsCbMap_.erase(type); @@ -386,11 +384,10 @@ WmErrorCode JsPipController::UnRegisterListenerWithType(napi_env env, const std: void CallJsMethod(napi_env env, napi_value method, napi_value const* argv, size_t argc) { if (method == nullptr) { - WLOGFE("empty method, call method failed"); + TLOGE(WmsLogTag::WMS_PIP, "empty method, call method failed"); return; } if (env == nullptr) { - WLOGFE("env_ nullptr"); return; } napi_call_function(env, NapiGetUndefined(env), method, argc, argv, nullptr); @@ -398,44 +395,38 @@ void CallJsMethod(napi_env env, napi_value method, napi_value const* argv, size_ void JsPipController::PiPLifeCycleImpl::OnPreparePictureInPictureStart() { - WLOGI("OnPreparePictureInPictureStart"); OnPipListenerCallback(PipState::ABOUT_TO_START, 0); } void JsPipController::PiPLifeCycleImpl::OnPictureInPictureStart() { - WLOGI("OnPictureInPictureStart"); OnPipListenerCallback(PipState::STARTED, 0); } void JsPipController::PiPLifeCycleImpl::OnPreparePictureInPictureStop() { - WLOGI("OnPreparePictureInPictureStop"); OnPipListenerCallback(PipState::ABOUT_TO_STOP, 0); } void JsPipController::PiPLifeCycleImpl::OnPictureInPictureStop() { - WLOGI("OnPictureInPictureStop"); OnPipListenerCallback(PipState::STOPPED, 0); } void JsPipController::PiPLifeCycleImpl::OnRestoreUserInterface() { - WLOGI("OnRestoreUserInterface"); OnPipListenerCallback(PipState::ABOUT_TO_RESTORE, 0); } void JsPipController::PiPLifeCycleImpl::OnPictureInPictureOperationError(int32_t errorCode) { - WLOGI("OnPictureInPictureOperationError"); OnPipListenerCallback(PipState::ERROR, errorCode); } void JsPipController::PiPLifeCycleImpl::OnPipListenerCallback(PipState state, int32_t errorCode) { std::lock_guard lock(mtx_); - WLOGI("OnPipListenerCallback is called, state: %{public}d", static_cast(state)); + TLOGI(WmsLogTag::WMS_PIP, "OnPipListenerCallback is called, state: %{public}d", static_cast(state)); auto jsCallback = jsCallBack_; std::string error = std::to_string(errorCode); std::unique_ptr complete = std::make_unique ( @@ -454,7 +445,7 @@ void JsPipController::PiPLifeCycleImpl::OnPipListenerCallback(PipState state, in void JsPipController::PiPActionObserverImpl::OnActionEvent(const std::string& actionEvent, int32_t statusCode) { std::lock_guard lock(mtx_); - WLOGI("OnActionEvent is called, actionEvent: %{public}s", actionEvent.c_str()); + TLOGI(WmsLogTag::WMS_PIP, "OnActionEvent is called, actionEvent: %{public}s", actionEvent.c_str()); auto jsCallback = jsCallBack_; std::unique_ptr complete = std::make_unique ( [jsCallback, actionEvent, statusCode] (napi_env env, NapiAsyncTask &task, int32_t status) { diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 4fc05e688..d04a26ff6 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -26,9 +26,6 @@ namespace OHOS { namespace Rosen { using namespace AbilityRuntime; using namespace Ace; -namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsPipWindowManager"}; -} std::mutex JsPipWindowManager::mutex_; @@ -44,7 +41,7 @@ static bool GetControlGroupFromJs(napi_env env, napi_value controlGroup, std::ve napi_value getElementValue = nullptr; napi_get_element(env, controlGroup, i, &getElementValue); if (!ConvertFromJsValue(env, getElementValue, controlType)) { - WLOGE("Failed to convert parameter to controlType"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert parameter to controlType"); return false; } controls.push_back(controlType); @@ -102,7 +99,7 @@ JsPipWindowManager::~JsPipWindowManager() void JsPipWindowManager::Finalizer(napi_env env, void* data, void* hint) { - WLOGFD("Finalizer"); + TLOGD(WmsLogTag::WMS_PIP, "Finalizer"); std::unique_ptr(static_cast(data)); } @@ -114,7 +111,7 @@ napi_value JsPipWindowManager::IsPipEnabled(napi_env env, napi_callback_info inf napi_value JsPipWindowManager::OnIsPipEnabled(napi_env env, napi_callback_info info) { - WLOGFD("OnIsPipEnabled called"); + TLOGD(WmsLogTag::WMS_PIP, "OnIsPipEnabled called"); return CreateJsValue(env, true); } @@ -126,24 +123,24 @@ napi_value JsPipWindowManager::CreatePipController(napi_env env, napi_callback_i napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback_info info) { - WLOGI("OnCreatePipController called"); + TLOGI(WmsLogTag::WMS_PIP, "OnCreatePipController called"); std::lock_guard lock(mutex_); size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - WLOGFE("Missing args when creating pipController"); + TLOGE(WmsLogTag::WMS_PIP, "Missing args when creating pipController"); return NapiThrowInvalidParam(env); } napi_value config = argv[0]; if (config == nullptr) { - WLOGFE("Failed to convert object to pip Configuration"); + TLOGE(WmsLogTag::WMS_PIP, "Failed to convert object to pip Configuration"); return NapiThrowInvalidParam(env); } PipOption pipOption; int32_t errCode = GetPictureInPictureOptionFromJs(env, config, pipOption); if (errCode == -1) { - WLOGFE("Configuration is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "Configuration is invalid: %{public}zu", argc); return NapiThrowInvalidParam(env); } napi_value callback = nullptr; @@ -172,9 +169,9 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback napi_value JsPipWindowManagerInit(napi_env env, napi_value exportObj) { - WLOGFD("JsPipWindowManagerInit"); + TLOGD(WmsLogTag::WMS_PIP, "JsPipWindowManagerInit"); if (env == nullptr || exportObj == nullptr) { - WLOGFE("JsPipWindowManagerInit env or exportObj is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "JsPipWindowManagerInit env or exportObj is nullptr"); return nullptr; } std::unique_ptr jsPipManager = std::make_unique(); diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index c495d6b7d..29c479182 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -757,49 +757,64 @@ napi_value JsWindowManager::OnUnregisterWindowManagerCallback(napi_env env, napi return NapiGetUndefined(env); } -static void GetTopWindowTask(void* contextPtr, napi_env env, NapiAsyncTask& task, bool newApi) +static napi_value GetTopWindowTask(void* contextPtr, napi_env env, napi_value callback, bool newApi) { - std::string windowName; - sptr window = nullptr; - AppExecFwk::Ability* ability = nullptr; - bool isOldApi = GetAPI7Ability(env, ability); - int32_t error; - if (isOldApi) { - if (ability->GetWindow() == nullptr) { - error = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : + struct TopWindowInfoList { + sptr window = nullptr; + AppExecFwk::Ability* ability = nullptr; + int32_t errorCode = 0; + std::string errMsg = ""; + }; + std::shared_ptr lists = std::make_shared(); + bool isOldApi = GetAPI7Ability(env, lists->ability); + NapiAsyncTask::ExecuteCallback execute = [lists, isOldApi, newApi, contextPtr]() { + if (lists == nullptr) { + return; + } + if (isOldApi) { + if (lists->ability->GetWindow() == nullptr) { + lists->errorCode = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : + static_cast(WMError::WM_ERROR_NULLPTR); + lists->errMsg = "FA mode can not get ability window"; + return; + } + lists->window = Window::GetTopWindowWithId(lists->ability->GetWindow()->GetWindowId()); + } else { + auto context = static_cast*>(contextPtr); + if (contextPtr == nullptr || context == nullptr) { + lists->errorCode = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : + static_cast(WMError::WM_ERROR_NULLPTR); + lists->errMsg = "Stage mode without context"; + return; + } + lists->window = Window::GetTopWindowWithContext(context->lock()); + } + }; + NapiAsyncTask::CompleteCallback complete = [lists, newApi](napi_env env, NapiAsyncTask& task, int32_t status) { + if (lists == nullptr) { + int32_t error = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : static_cast(WMError::WM_ERROR_NULLPTR); - task.Reject(env, CreateJsError(env, error, "FA mode can not get ability window")); - WLOGE("FA mode can not get ability window"); + task.Reject(env, CreateJsError(env, error, "napi abnormal")); return; } - window = Window::GetTopWindowWithId(ability->GetWindow()->GetWindowId()); - } else { - auto context = static_cast*>(contextPtr); - if (contextPtr == nullptr || context == nullptr) { - error = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : + if (lists->errorCode != 0) { + task.Reject(env, CreateJsError(env, lists->errorCode, lists->errMsg)); + WLOGFE("%{public}s", lists->errMsg.c_str()); + return; + } + if (lists->window == nullptr) { + auto error = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : static_cast(WMError::WM_ERROR_NULLPTR); - task.Reject(env, CreateJsError(env, error, "Stage mode without context")); - WLOGFE("Stage mode without context"); + task.Reject(env, CreateJsError(env, error, "Get top window failed")); return; } - window = Window::GetTopWindowWithContext(context->lock()); - } - if (window == nullptr) { - error = newApi ? static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY) : - static_cast(WMError::WM_ERROR_NULLPTR); - task.Reject(env, CreateJsError(env, error, "Get top window failed")); - WLOGFE("Get top window failed"); - return; - } - windowName = window->GetWindowName(); - std::shared_ptr jsWindowObj = FindJsWindowObject(windowName); - if (jsWindowObj != nullptr && jsWindowObj->GetNapiValue() != nullptr) { - task.Resolve(env, jsWindowObj->GetNapiValue()); - } else { - task.Resolve(env, CreateJsWindowObject(env, window)); - } - WLOGD("Get top window %{public}s success", windowName.c_str()); - return; + task.Resolve(env, CreateJsWindowObject(env, lists->window)); + WLOGD("Get top window success"); + }; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindowManager::OnGetTopWindow", + env, CreateAsyncTaskWithLastParam(env, callback, std::move(execute), std::move(complete), &result)); + return result; } napi_value JsWindowManager::OnGetTopWindow(napi_env env, napi_callback_info info) @@ -826,20 +841,7 @@ napi_value JsWindowManager::OnGetTopWindow(napi_env env, napi_callback_info info } GetNativeContext(env, nativeContext, contextPtr, errCode); } - - WLOGI("err %{public}u", errCode); - NapiAsyncTask::CompleteCallback complete = - [=](napi_env env, NapiAsyncTask& task, int32_t status) { - if (errCode != WMError::WM_OK) { - task.Reject(env, CreateJsError(env, static_cast(errCode), "Invalidate params")); - return; - } - return GetTopWindowTask(contextPtr, env, task, false); - }; - napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindowManager::OnGetTopWindow", - env, CreateAsyncTaskWithLastParam(env, nativeCallback, nullptr, std::move(complete), &result)); - return result; + return GetTopWindowTask(contextPtr, env, nativeCallback, false); } napi_value JsWindowManager::OnGetLastWindow(napi_env env, napi_callback_info info) @@ -866,14 +868,7 @@ napi_value JsWindowManager::OnGetLastWindow(napi_env env, napi_callback_info inf return NapiGetUndefined(env); } - NapiAsyncTask::CompleteCallback complete = - [=](napi_env env, NapiAsyncTask& task, int32_t status) { - return GetTopWindowTask(contextPtr, env, task, true); - }; - napi_value result = nullptr; - NapiAsyncTask::Schedule("JsWindowManager::OnGetTopWindow", - env, CreateAsyncTaskWithLastParam(env, nativeCallback, nullptr, std::move(complete), &result)); - return result; + return GetTopWindowTask(contextPtr, env, nativeCallback, true); } napi_value JsWindowManager::OnSetWindowLayoutMode(napi_env env, napi_callback_info info) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index f8d2f58d7..827c21bba 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -45,7 +45,7 @@ using namespace AbilityRuntime; namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsWindow"}; constexpr Rect g_emptyRect = {0, 0, 0, 0}; - constexpr int32_t MIN_DECOR_HEIGHT = 48; + constexpr int32_t MIN_DECOR_HEIGHT = 37; constexpr int32_t MAX_DECOR_HEIGHT = 112; } @@ -308,6 +308,20 @@ napi_value JsWindow::SetSpecificSystemBarEnabled(napi_env env, napi_callback_inf return (me != nullptr) ? me->OnSetSpecificSystemBarEnabled(env, info) : nullptr; } +napi_value JsWindow::EnableLandscapeMultiWindow(napi_env env, napi_callback_info info) +{ + WLOGI("EnableLandscapeMultiWindow"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnEnableLandscapeMultiWindow(env, info) : nullptr; +} + +napi_value JsWindow::DisableLandscapeMultiWindow(napi_env env, napi_callback_info info) +{ + WLOGI("DisableLandscapeMultiWindow"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnDisableLandscapeMultiWindow(env, info) : nullptr; +} + napi_value JsWindow::SetSystemBarProperties(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::WMS_IMMS, "SetSystemBarProperties"); @@ -315,6 +329,13 @@ napi_value JsWindow::SetSystemBarProperties(napi_env env, napi_callback_info inf return (me != nullptr) ? me->OnSetSystemBarProperties(env, info) : nullptr; } +napi_value JsWindow::GetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info) +{ + TLOGD(WmsLogTag::WMS_IMMS, "GetWindowSystemBarPropertiesSync"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnGetWindowSystemBarPropertiesSync(env, info) : nullptr; +} + napi_value JsWindow::SetWindowSystemBarProperties(napi_env env, napi_callback_info info) { TLOGD(WmsLogTag::WMS_IMMS, "SetWindowSystemBarProperties"); @@ -658,6 +679,13 @@ napi_value JsWindow::SetWaterMarkFlag(napi_env env, napi_callback_info info) return (me != nullptr) ? me->OnSetWaterMarkFlag(env, info) : nullptr; } +napi_value JsWindow::SetHandwritingFlag(napi_env env, napi_callback_info info) +{ + WLOGI("SetHandwritingFlag"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetHandwritingFlag(env, info) : nullptr; +} + napi_value JsWindow::SetAspectRatio(napi_env env, napi_callback_info info) { WLOGI("[NAPI]SetAspectRatio"); @@ -721,6 +749,13 @@ napi_value JsWindow::SetWindowDecorVisible(napi_env env, napi_callback_info info return (me != nullptr) ? me->OnSetWindowDecorVisible(env, info) : nullptr; } +napi_value JsWindow::SetSubWindowModal(napi_env env, napi_callback_info info) +{ + TLOGI(WmsLogTag::WMS_DIALOG, "[NAPI]SetSubWindowModal"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetSubWindowModal(env, info) : nullptr; +} + napi_value JsWindow::SetWindowDecorHeight(napi_env env, napi_callback_info info) { WLOGI("[NAPI]SetWindowDecorHeight"); @@ -1539,10 +1574,12 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i WLOGFE("Window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } + constexpr size_t ARGC_MIN = 2; + constexpr size_t ARGC_MAX = 3; size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc < 2) { // 2: params num + if (argc < ARGC_MIN || argc > ARGC_MAX) { WLOGFE("Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } @@ -1551,12 +1588,20 @@ napi_value JsWindow::OnRegisterWindowCallback(napi_env env, napi_callback_info i WLOGFE("Failed to convert parameter to callbackType"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - napi_value value = argv[1]; - if (!NapiIsCallable(env, value)) { - WLOGI("Callback(info->argv[1]) is not callable"); + size_t cbIndex = argc - 1; + napi_value callback = argv[cbIndex]; + if (!NapiIsCallable(env, callback)) { + WLOGI("Callback(info->argv[%{public}zu]) is not callable", cbIndex); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - WmErrorCode ret = registerManager_->RegisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, env, value); + + napi_value parameter = nullptr; + if (argc > ARGC_MIN) { + parameter = argv[cbIndex - 1]; + } + + WmErrorCode ret = registerManager_->RegisterListener(windowToken_, cbType, CaseType::CASE_WINDOW, + env, callback, parameter); if (ret != WmErrorCode::WM_OK) { return NapiThrowError(env, ret); } @@ -1915,10 +1960,9 @@ napi_value JsWindow::OnSetFullScreen(napi_env env, napi_callback_info info) if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { + TLOGE(WmsLogTag::WMS_IMMS, "SetFullScreen failed, ret = %{public}d", ret); task.Reject(env, CreateJsError(env, static_cast(ret), "Window SetFullScreen failed.")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set full screen end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; napi_value lastParam = (argc <= 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); @@ -1965,11 +2009,10 @@ napi_value JsWindow::OnSetLayoutFullScreen(napi_env env, napi_callback_info info if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { + TLOGE(WmsLogTag::WMS_IMMS, "SetLayoutFullScreen failed, ret = %{public}d", ret); task.Reject(env, CreateJsError(env, static_cast(ret), "Window OnSetLayoutFullScreen failed.")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set layout full screen end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; napi_value lastParam = (argc <= 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); napi_value result = nullptr; @@ -2007,8 +2050,8 @@ napi_value JsWindow::OnSetWindowLayoutFullScreen(napi_env env, napi_callback_inf [weakToken, isLayoutFullScreen](napi_env env, NapiAsyncTask& task, int32_t status) { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - task.Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); + task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), "Invalidate params.")); return; } @@ -2016,11 +2059,10 @@ napi_value JsWindow::OnSetWindowLayoutFullScreen(napi_env env, napi_callback_inf if (ret == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { + TLOGE(WmsLogTag::WMS_IMMS, "SetWindowLayoutFullScreen failed, ret = %{public}d", ret); task.Reject(env, CreateJsError(env, static_cast(ret), "Window OnSetLayoutFullScreen failed.")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set window layout full screen end, " - "ret = %{public}d", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; napi_value lastParam = (argc <= 1) ? nullptr : @@ -2031,6 +2073,28 @@ napi_value JsWindow::OnSetWindowLayoutFullScreen(napi_env env, napi_callback_inf return result; } +static WMError SetSystemBarPropertiesByFlags(std::map& systemBarPropertyFlags, + std::map& systemBarProperties, wptr weakToken) +{ + auto weakWindow = weakToken.promote(); + WMError ret = WMError::WM_OK; + WMError err = WMError::WM_OK; + + for (auto it : systemBarPropertyFlags) { + WindowType type = it.first; + SystemBarPropertyFlag flag = it.second; + if (flag.enableFlag || flag.backgroundColorFlag || flag.contentColorFlag) { + err = weakWindow->SetSystemBarProperty(type, systemBarProperties.at(type)); + if (err != WMError::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty failed, ret = %{public}d", err); + ret = err; + } + } + } + + return ret; +} + napi_value JsWindow::OnSetSystemBarEnable(napi_env env, napi_callback_info info) { WMError errCode = WMError::WM_OK; @@ -2046,6 +2110,7 @@ napi_value JsWindow::OnSetSystemBarEnable(napi_env env, napi_callback_info info) std::map systemBarPropertyFlags; if (errCode == WMError::WM_OK && !GetSystemBarStatus(systemBarProperties, systemBarPropertyFlags, env, info, windowToken_)) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to systemBarProperties"); errCode = WMError::WM_ERROR_INVALID_PARAM; } wptr weakToken(windowToken_); @@ -2053,6 +2118,7 @@ napi_value JsWindow::OnSetSystemBarEnable(napi_env env, napi_callback_info info) (napi_env env, NapiAsyncTask& task, int32_t status) mutable { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); errCode = WMError::WM_ERROR_NULLPTR; } if (errCode != WMError::WM_OK) { @@ -2060,18 +2126,14 @@ napi_value JsWindow::OnSetSystemBarEnable(napi_env env, napi_callback_info info) return; } UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, weakToken); - WMError ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR)); - ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR)); + WMError ret = SetSystemBarPropertiesByFlags( + systemBarPropertyFlags, systemBarProperties, weakToken); if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { task.Reject(env, CreateJsError(env, static_cast(ret), "JsWindow::OnSetSystemBarEnable failed")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set system bar enable end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; napi_value lastParam = nullptr; if (argc > 0 && GetType(env, argv[0]) == napi_function) { @@ -2096,6 +2158,7 @@ napi_value JsWindow::OnSetWindowSystemBarEnable(napi_env env, napi_callback_info napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (errCode == WmErrorCode::WM_OK && (argc < 1 || // 1: params num !GetSystemBarStatus(systemBarProperties, systemBarPropertyFlags, env, info, windowToken_))) { + TLOGE(WmsLogTag::WMS_IMMS, "invalid param or argc:%{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } wptr weakToken(windowToken_); @@ -2104,18 +2167,13 @@ napi_value JsWindow::OnSetWindowSystemBarEnable(napi_env env, napi_callback_info auto weakWindow = weakToken.promote(); errCode = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : errCode; if (errCode != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); task.Reject(env, CreateJsError(env, static_cast(errCode))); return; } UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, weakToken); - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetSystemBarProperty( - WindowType::WINDOW_TYPE_STATUS_BAR, systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR))); - if (ret != WmErrorCode::WM_OK) { - task.Reject(env, CreateJsError(env, - static_cast(ret), "JsWindow::OnSetWindowSystemBarEnable failed")); - } - ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR))); + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at( + SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, weakToken)); if (ret == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { @@ -2138,26 +2196,27 @@ napi_value JsWindow::OnSetWindowSystemBarEnable(napi_env env, napi_callback_info napi_value JsWindow::OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_info info) { std::map systemBarProperties; - std::map systemBarPropertyFlags; WmErrorCode err = (windowToken_ == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : WmErrorCode::WM_OK; size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); std::string name; if (!ConvertFromJsValue(env, argv[0], name)) { - WLOGFE("Failed to convert parameter to SystemBarName"); + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to SystemBarName"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } if (err == WmErrorCode::WM_OK && (argc < 1 || // 1: params num !GetSpecificBarStatus(systemBarProperties, env, info, windowToken_))) { + TLOGE(WmsLogTag::WMS_IMMS, "invalid param or argc:%{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } wptr weakToken(windowToken_); - NapiAsyncTask::CompleteCallback complete = [weakToken, systemBarProperties, systemBarPropertyFlags, name, err] + NapiAsyncTask::CompleteCallback complete = [weakToken, systemBarProperties, name, err] (napi_env env, NapiAsyncTask& task, int32_t status) mutable { auto weakWindow = weakToken.promote(); err = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : err; if (err != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); task.Reject(env, CreateJsError(env, static_cast(err))); return; } @@ -2175,6 +2234,7 @@ napi_value JsWindow::OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_i if (err == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { + TLOGE(WmsLogTag::WMS_IMMS, "SetSpecificSystemBarEnabled failed, ret = %{public}d", err); task.Reject(env, CreateJsError(env, static_cast(err), "JsWindow::OnSetSpecificSystemBarEnabled failed")); } @@ -2185,10 +2245,72 @@ napi_value JsWindow::OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_i return result; } +napi_value JsWindow::OnEnableLandscapeMultiWindow(napi_env env, napi_callback_info info) +{ + WLOGI("OnEnableLandscapeMultiWindow"); + WmErrorCode err = (windowToken_ == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : WmErrorCode::WM_OK; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [weakToken, err](napi_env env, NapiAsyncTask& task, int32_t status) mutable { + auto weakWindow = weakToken.promote(); + err = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : err; + if (err != WmErrorCode::WM_OK) { + task.Reject(env, CreateJsError(env, static_cast(err))); + return; + } + WMError ret = weakWindow->SetLandscapeMultiWindow(true); + if (ret == WMError::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY), + "JsWindow::OnEnableLandscapeMultiWindow failed")); + } + }; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnEnableLandscapeMultiWindow", + env, CreateAsyncTaskWithLastParam(env, nullptr, nullptr, std::move(complete), &result)); + return result; +} + +napi_value JsWindow::OnDisableLandscapeMultiWindow(napi_env env, napi_callback_info info) +{ + WmErrorCode err = (windowToken_ == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : WmErrorCode::WM_OK; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [weakToken, err](napi_env env, NapiAsyncTask &task, int32_t status) mutable { + auto weakWindow = weakToken.promote(); + err = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : err; + if (err != WmErrorCode::WM_OK) { + task.Reject(env, CreateJsError(env, static_cast(err))); + return; + } + WMError ret = weakWindow->SetLandscapeMultiWindow(false); + if (ret == WMError::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY), + "JsWindow::OnDisableLandscapeMultiWindow failed")); + } + }; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnDisableLandscapeMultiWindow", + env, CreateAsyncTaskWithLastParam(env, nullptr, nullptr, std::move(complete), &result)); + return result; +} + napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info info) { WMError errCode = WMError::WM_OK; if (windowToken_ == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "windowToken_ is nullptr"); errCode = WMError::WM_ERROR_NULLPTR; } size_t argc = 4; @@ -2204,6 +2326,7 @@ napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info i napi_value nativeObj = argv[0]; if (nativeObj == nullptr || !SetSystemBarPropertiesFromJs(env, nativeObj, systemBarProperties, systemBarPropertyFlags, windowToken_)) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to systemBarProperties"); errCode = WMError::WM_ERROR_INVALID_PARAM; } } @@ -2212,6 +2335,7 @@ napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info i (napi_env env, NapiAsyncTask& task, int32_t status) mutable { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "windowToken is nullptr"); errCode = WMError::WM_ERROR_NULLPTR; } if (errCode != WMError::WM_OK) { @@ -2219,18 +2343,14 @@ napi_value JsWindow::OnSetSystemBarProperties(napi_env env, napi_callback_info i return; } UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, weakToken); - WMError ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR)); - ret = weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR)); + WMError ret = SetSystemBarPropertiesByFlags( + systemBarPropertyFlags, systemBarProperties, weakToken); if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { task.Reject(env, CreateJsError(env, static_cast(WMError::WM_ERROR_NULLPTR), "JsWindow::OnSetSystemBarProperties failed")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] set prop end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; napi_value lastParam = (argc <= 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); @@ -2248,6 +2368,7 @@ napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_ napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { // 2: maximum params num + TLOGE(WmsLogTag::WMS_IMMS, "Argc is invalid: %{public}zu", argc); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } std::map systemBarProperties; @@ -2256,6 +2377,7 @@ napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_ napi_value nativeObj = argv[0]; if (nativeObj == nullptr || !SetSystemBarPropertiesFromJs(env, nativeObj, systemBarProperties, systemBarPropertyFlags, windowToken_)) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert parameter to systemBarProperties"); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } } @@ -2269,22 +2391,19 @@ napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_ auto weakWindow = weakToken.promote(); errCode = (weakWindow == nullptr) ? WmErrorCode::WM_ERROR_STATE_ABNORMALLY : errCode; if (errCode != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); task.Reject(env, CreateJsError(env, static_cast(errCode))); return; } UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, weakToken); - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetSystemBarProperty( - WindowType::WINDOW_TYPE_STATUS_BAR, systemBarProperties.at(WindowType::WINDOW_TYPE_STATUS_BAR))); - if (ret != WmErrorCode::WM_OK) { - task.Reject(env, CreateJsError(env, static_cast(ret))); - } - ret = WM_JS_TO_ERROR_CODE_MAP.at( - weakWindow->SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, - systemBarProperties.at(WindowType::WINDOW_TYPE_NAVIGATION_BAR))); - if (ret != WmErrorCode::WM_OK) { - task.Reject(env, CreateJsError(env, static_cast(ret))); + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at( + SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, weakToken)); + if (ret == WmErrorCode::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, CreateJsError(env, + static_cast(ret), "JsWindow::OnSetWindowSystemBarProperties failed")); } - task.Resolve(env, NapiGetUndefined(env)); }; napi_value lastParam = (argc <= 1) ? nullptr : @@ -2295,6 +2414,26 @@ napi_value JsWindow::OnSetWindowSystemBarProperties(napi_env env, napi_callback_ return result; } +napi_value JsWindow::OnGetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info) +{ + wptr weakToken(windowToken_); + auto weakWindow = weakToken.promote(); + if (weakWindow == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "window is null"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + if (!WindowHelper::IsMainWindow(weakWindow->GetType())) { + TLOGE(WmsLogTag::WMS_IMMS, "only main window has right to call"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + } + auto objValue = CreateJsSystemBarPropertiesObject(env, weakWindow); + if (objValue == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "get properties failed"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_SYSTEM_ABNORMALLY); + } + return objValue; +} + static void ParseAvoidAreaParam(napi_env env, napi_callback_info info, WMError& errCode, AvoidAreaType& avoidAreaType) { size_t argc = 4; @@ -2342,6 +2481,7 @@ napi_value JsWindow::OnGetAvoidArea(napi_env env, napi_callback_info info) AvoidArea avoidArea; WMError ret = weakWindow->GetAvoidAreaByType(avoidAreaType, avoidArea); if (ret != WMError::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "GetAvoidArea failed, ret = %{public}d", ret); avoidArea.topRect_ = g_emptyRect; avoidArea.leftRect_ = g_emptyRect; avoidArea.rightRect_ = g_emptyRect; @@ -2351,11 +2491,10 @@ napi_value JsWindow::OnGetAvoidArea(napi_env env, napi_callback_info info) if (avoidAreaObj != nullptr) { task.Resolve(env, avoidAreaObj); } else { + TLOGE(WmsLogTag::WMS_IMMS, "ConvertAvoidAreaToJsValue failed"); task.Reject(env, CreateJsError(env, static_cast(WMError::WM_ERROR_NULLPTR), "JsWindow::OnGetAvoidArea failed")); } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] get avoid area end, ret = %{public}d", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str(), ret); }; size_t argc = 4; napi_value argv[4] = {nullptr}; @@ -2375,6 +2514,7 @@ napi_value JsWindow::OnGetWindowAvoidAreaSync(napi_env env, napi_callback_info i napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { // 1: params num + TLOGE(WmsLogTag::WMS_IMMS, "invalid argc:%{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } AvoidAreaType avoidAreaType = AvoidAreaType::TYPE_SYSTEM; @@ -2390,33 +2530,31 @@ napi_value JsWindow::OnGetWindowAvoidAreaSync(napi_env env, napi_callback_info i WmErrorCode::WM_ERROR_INVALID_PARAM : WmErrorCode::WM_OK; } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { + TLOGE(WmsLogTag::WMS_IMMS, "invalid param"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } wptr weakToken(windowToken_); auto window = weakToken.promote(); if (window == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } // getAvoidRect by avoidAreaType AvoidArea avoidArea; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(window->GetAvoidAreaByType(avoidAreaType, avoidArea)); if (ret != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_IMMS, "GetWindowAvoidAreaSync failed, ret = %{public}d", ret); avoidArea.topRect_ = g_emptyRect; avoidArea.leftRect_ = g_emptyRect; avoidArea.rightRect_ = g_emptyRect; avoidArea.bottomRect_ = g_emptyRect; } - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] get avoid area type %{public}d end, ret %{public}d " - "top{%{public}d,%{public}d,%{public}d,%{public}d}, down{%{public}d,%{public}d,%{public}d,%{public}d}", - window->GetWindowId(), window->GetWindowName().c_str(), avoidAreaType, ret, - avoidArea.topRect_.posX_, avoidArea.topRect_.posY_, avoidArea.topRect_.width_, avoidArea.topRect_.height_, - avoidArea.bottomRect_.posX_, avoidArea.bottomRect_.posY_, avoidArea.bottomRect_.width_, - avoidArea.bottomRect_.height_); napi_value avoidAreaObj = ConvertAvoidAreaToJsValue(env, avoidArea, avoidAreaType); if (avoidAreaObj != nullptr) { return avoidAreaObj; } else { + TLOGE(WmsLogTag::WMS_IMMS, "ConvertAvoidAreaToJsValue failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } } @@ -2974,33 +3112,41 @@ napi_value JsWindow::OnSetWindowKeepScreenOn(napi_env env, napi_callback_info in if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - wptr weakToken(windowToken_); + std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); + NapiAsyncTask::ExecuteCallback execute = [weakToken, keepScreenOn, errCodePtr] () { + if (errCodePtr == nullptr) { + return; + } + auto weakWindow = weakToken.promote(); + if (weakWindow == nullptr) { + *errCodePtr = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + return; + } + *errCodePtr = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetKeepScreenOn(keepScreenOn)); + WLOGI("Window [%{public}u, %{public}s] set keep screen on end", + weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); + }; NapiAsyncTask::CompleteCallback complete = - [weakToken, keepScreenOn](napi_env env, NapiAsyncTask& task, int32_t status) { - auto weakWindow = weakToken.promote(); - if (weakWindow == nullptr) { - task.Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "Invalidate params.")); + [weakToken, keepScreenOn, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCodePtr == nullptr) { + task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "System abnormal.")); return; } - WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetKeepScreenOn(keepScreenOn)); - if (ret == WmErrorCode::WM_OK) { + if (*errCodePtr == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, CreateJsError(env, static_cast(ret), + task.Reject(env, CreateJsError(env, static_cast(*errCodePtr), "Window set keep screen on failed")); } - WLOGI("Window [%{public}u, %{public}s] set keep screen on end", - weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); }; napi_value lastParam = (argc <= 1) ? nullptr : ((argv[1] != nullptr && GetType(env, argv[1]) == napi_function) ? argv[1] : nullptr); napi_value result = nullptr; NapiAsyncTask::Schedule("JsWindow::OnSetWindowKeepScreenOn", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result)); return result; } @@ -4644,6 +4790,57 @@ napi_value JsWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_info info) return result; } +napi_value JsWindow::OnSetHandwritingFlag(napi_env env, napi_callback_info info) +{ + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc < 1) { + WLOGFE("Argc is invalid: %{public}zu", argc); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + + napi_value nativeBool = argv[0]; + if (nativeBool == nullptr) { + WLOGFE("SetHandwritingFlag Invalid window flag"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + + bool isAddFlag = false; + napi_get_value_bool(env, nativeBool, &isAddFlag); + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [weakToken, isAddFlag](napi_env env, NapiAsyncTask& task, int32_t status) { + auto window = weakToken.promote(); + if (window == nullptr) { + task.Reject(env, + CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "OnSetHandwritingFlag failed.")); + return; + } + WMError ret = WMError::WM_OK; + if (isAddFlag) { + ret = window->AddWindowFlag(WindowFlag::WINDOW_FLAG_HANDWRITING); + } else { + ret = window->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_HANDWRITING); + } + if (ret == WMError::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, CreateJsError(env, + static_cast(WM_JS_TO_ERROR_CODE_MAP.at(ret)), "SetHandwritingFlag failed.")); + } + WLOGI("[NAPI]Window [%{public}u, %{public}s] set handwriting flag end, ret = %{public}d", + window->GetWindowId(), window->GetWindowName().c_str(), ret); + }; + + napi_value lastParam = (argc == 1) ? nullptr : + (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnSetHandwritingFlag", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} napi_value JsWindow::OnSetAspectRatio(napi_env env, napi_callback_info info) { @@ -4816,9 +5013,9 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) WLOGFE("[NAPI] maximize interface only support main Window"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); } - + MaximizeLayoutOption option; NapiAsyncTask::CompleteCallback complete = - [weakToken](napi_env env, NapiAsyncTask& task, int32_t status) mutable { + [weakToken, option](napi_env env, NapiAsyncTask& task, int32_t status) mutable { auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { task.Reject(env, @@ -4826,14 +5023,7 @@ napi_value JsWindow::OnMaximize(napi_env env, napi_callback_info info) "OnMaximize failed.")); return; } - WMError ret = weakWindow->Maximize(); - auto uicontent = weakWindow->GetUIContent(); - if (uicontent == nullptr) { - WLOGFE("uicontent is nullptr"); - ret = WMError::WM_ERROR_NULLPTR; - } else { - uicontent->UpdateDecorVisible(false); - } + WMError ret = weakWindow->Maximize(option); if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { @@ -5037,6 +5227,61 @@ napi_value JsWindow::OnSetWindowDecorVisible(napi_env env, napi_callback_info in return NapiGetUndefined(env); } +napi_value JsWindow::OnSetSubWindowModal(napi_env env, napi_callback_info info) +{ + WmErrorCode errCode = WmErrorCode::WM_OK; + bool isModal = false; + size_t argc = 4; + napi_value argv[4] = { nullptr }; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc != 1 || argv[0] == nullptr) { // 1: the param num + errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; + } else { + CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM, napi_get_value_bool(env, argv[0], &isModal)); + } + + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [weakToken, isModal, errCode](napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCode != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_DIALOG, "invalid parameter"); + task.Reject(env, CreateJsError(env, static_cast(errCode), "invalid parameter.")); + return; + } + + WmErrorCode wmErrorCode; + auto window = weakToken.promote(); + if (window == nullptr) { + TLOGE(WmsLogTag::WMS_DIALOG, "window is nullptr"); + wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(WMError::WM_ERROR_NULLPTR); + task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "window is nullptr.")); + return; + } + + if (!WindowHelper::IsSubWindow(window->GetType())) { + TLOGE(WmsLogTag::WMS_DIALOG, "called by invalid window type, type:%{public}d", window->GetType()); + wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; + task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "invalid window type.")); + return; + } + WMError ret = window->SetSubWindowModal(isModal); + if (ret == WMError::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); + TLOGE(WmsLogTag::WMS_DIALOG, "Set subwindow modal failed, ret is %{public}d", wmErrorCode); + task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "Set subwindow modal failed")); + } + TLOGI(WmsLogTag::WMS_DIALOG, "id:%{public}u, name:%{public}s, isModal:%{public}d", + window->GetWindowId(), window->GetWindowName().c_str(), isModal); + }; + napi_value lastParam = nullptr; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::SetSubWindowModal", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; +} + napi_value JsWindow::OnSetWindowDecorHeight(napi_env env, napi_callback_info info) { size_t argc = 4; @@ -5058,7 +5303,7 @@ napi_value JsWindow::OnSetWindowDecorHeight(napi_env env, napi_callback_info inf int32_t height = 0; napi_get_value_int32(env, nativeVal, &height); if (height < MIN_DECOR_HEIGHT || height > MAX_DECOR_HEIGHT) { - WLOGFE("height should greater than 48 or smaller than 112"); + WLOGFE("height should greater than 37 or smaller than 112"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } @@ -5143,6 +5388,8 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setSystemBarEnable", moduleName, JsWindow::SetSystemBarEnable); BindNativeFunction(env, object, "setWindowSystemBarEnable", moduleName, JsWindow::SetWindowSystemBarEnable); BindNativeFunction(env, object, "setSystemBarProperties", moduleName, JsWindow::SetSystemBarProperties); + BindNativeFunction(env, object, "getWindowSystemBarProperties", + moduleName, JsWindow::GetWindowSystemBarPropertiesSync); BindNativeFunction(env, object, "setWindowSystemBarProperties", moduleName, JsWindow::SetWindowSystemBarProperties); BindNativeFunction(env, object, "getAvoidArea", moduleName, JsWindow::GetAvoidArea); @@ -5192,6 +5439,7 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setAspectRatio", moduleName, JsWindow::SetAspectRatio); BindNativeFunction(env, object, "resetAspectRatio", moduleName, JsWindow::ResetAspectRatio); BindNativeFunction(env, object, "setWaterMarkFlag", moduleName, JsWindow::SetWaterMarkFlag); + BindNativeFunction(env, object, "setHandwritingFlag", moduleName, JsWindow::SetHandwritingFlag); BindNativeFunction(env, object, "minimize", moduleName, JsWindow::Minimize); BindNativeFunction(env, object, "maximize", moduleName, JsWindow::Maximize); BindNativeFunction(env, object, "setResizeByDragEnabled", moduleName, JsWindow::SetResizeByDragEnabled); @@ -5205,7 +5453,10 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setSpecificSystemBarEnabled", moduleName, JsWindow::SetSpecificSystemBarEnabled); BindNativeFunction(env, object, "setSingleFrameComposerEnabled", moduleName, JsWindow::SetSingleFrameComposerEnabled); + BindNativeFunction(env, object, "enableLandscapeMultiWindow", moduleName, JsWindow::EnableLandscapeMultiWindow); + BindNativeFunction(env, object, "disableLandscapeMultiWindow", moduleName, JsWindow::DisableLandscapeMultiWindow); BindNativeFunction(env, object, "setWindowDecorVisible", moduleName, JsWindow::SetWindowDecorVisible); + BindNativeFunction(env, object, "setSubWindowModal", moduleName, JsWindow::SetSubWindowModal); BindNativeFunction(env, object, "setWindowDecorHeight", moduleName, JsWindow::SetWindowDecorHeight); BindNativeFunction(env, object, "getWindowDecorHeight", moduleName, JsWindow::GetWindowDecorHeight); BindNativeFunction(env, object, "getTitleButtonRect", moduleName, JsWindow::GetTitleButtonRect); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 87e18073b..670eae9da 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -72,6 +72,7 @@ public: static napi_value SetSystemBarEnable(napi_env env, napi_callback_info info); static napi_value SetWindowSystemBarEnable(napi_env env, napi_callback_info info); static napi_value SetSystemBarProperties(napi_env env, napi_callback_info info); + static napi_value GetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info); static napi_value SetWindowSystemBarProperties(napi_env env, napi_callback_info info); static napi_value GetAvoidArea(napi_env env, napi_callback_info info); static napi_value GetWindowAvoidAreaSync(napi_env env, napi_callback_info info); @@ -111,6 +112,8 @@ public: static napi_value SetWindowLimits(napi_env env, napi_callback_info info); static napi_value SetSpecificSystemBarEnabled(napi_env env, napi_callback_info info); static napi_value SetSingleFrameComposerEnabled(napi_env env, napi_callback_info info); + static napi_value EnableLandscapeMultiWindow(napi_env env, napi_callback_info info); + static napi_value DisableLandscapeMultiWindow(napi_env env, napi_callback_info info); // colorspace, gamut static napi_value IsSupportWideGamut(napi_env env, napi_callback_info info); @@ -137,7 +140,9 @@ public: static napi_value SetBackdropBlur(napi_env env, napi_callback_info info); static napi_value SetBackdropBlurStyle(napi_env env, napi_callback_info info); static napi_value SetWaterMarkFlag(napi_env env, napi_callback_info info); + static napi_value SetHandwritingFlag(napi_env env, napi_callback_info info); static napi_value SetWindowDecorVisible(napi_env env, napi_callback_info info); + static napi_value SetSubWindowModal(napi_env env, napi_callback_info info); static napi_value SetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetTitleButtonRect(napi_env env, napi_callback_info info); @@ -175,6 +180,7 @@ private: napi_value OnSetSystemBarEnable(napi_env env, napi_callback_info info); napi_value OnSetWindowSystemBarEnable(napi_env env, napi_callback_info info); napi_value OnSetSystemBarProperties(napi_env env, napi_callback_info info); + napi_value OnGetWindowSystemBarPropertiesSync(napi_env env, napi_callback_info info); napi_value OnSetWindowSystemBarProperties(napi_env env, napi_callback_info info); napi_value OnLoadContent(napi_env env, napi_callback_info info, bool isLoadedByName); napi_value OnGetUIContext(napi_env env, napi_callback_info info); @@ -195,6 +201,7 @@ private: napi_value OnGetWindowLimits(napi_env env, napi_callback_info info); napi_value OnSetSpecificSystemBarEnabled(napi_env env, napi_callback_info info); napi_value OnSetWindowDecorVisible(napi_env env, napi_callback_info info); + napi_value OnSetSubWindowModal(napi_env env, napi_callback_info info); napi_value OnSetWindowDecorHeight(napi_env env, napi_callback_info info); napi_value OnGetWindowDecorHeight(napi_env env, napi_callback_info info); napi_value OnGetTitleButtonRect(napi_env env, napi_callback_info info); @@ -232,6 +239,8 @@ private: napi_value OnSnapshot(napi_env env, napi_callback_info info); napi_value OnSetSnapshotSkip(napi_env env, napi_callback_info info); napi_value OnSetSingleFrameComposerEnabled(napi_env env, napi_callback_info info); + napi_value OnEnableLandscapeMultiWindow(napi_env env, napi_callback_info info); + napi_value OnDisableLandscapeMultiWindow(napi_env env, napi_callback_info info); // animation Config napi_value OnOpacity(napi_env env, napi_callback_info info); @@ -248,6 +257,7 @@ private: napi_value OnSetBackdropBlur(napi_env env, napi_callback_info info); napi_value OnSetBackdropBlurStyle(napi_env env, napi_callback_info info); napi_value OnSetWaterMarkFlag(napi_env env, napi_callback_info info); + napi_value OnSetHandwritingFlag(napi_env env, napi_callback_info info); sptr windowToken_ = nullptr; std::unique_ptr registerManager_ = nullptr; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index a2fba0b27..1c5cf44c9 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -395,6 +395,25 @@ void JsWindowListener::OnWaterMarkFlagUpdate(bool showWaterMark) env_, std::make_unique(callback, std::move(execute), std::move(complete))); } +void JsWindowListener::OnWindowNoInteractionCallback() +{ + std::unique_ptr complete = std::make_unique ( + [self = weakRef_] (napi_env env, NapiAsyncTask &task, int32_t status) { + auto thisListener = self.promote(); + if (thisListener == nullptr) { + WLOGFE("[NAPI]this listener is nullptr"); + return; + } + thisListener->CallJsMethod(WINDOW_NO_INTERACTION_DETECT_CB.c_str(), nullptr, 0); + } + ); + + napi_ref callback = nullptr; + std::unique_ptr execute = nullptr; + NapiAsyncTask::Schedule("JsWindowListener::OnWindowNoInteractionCallback", env_, + std::make_unique(callback, std::move(execute), std::move(complete))); +} + void JsWindowListener::OnWindowStatusChange(WindowStatus windowstatus) { WLOGFD("[NAPI]OnWindowStatusChange"); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h index 45e60936c..017bc52dd 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h @@ -47,6 +47,7 @@ const std::string WATER_MARK_FLAG_CHANGE_CB = "waterMarkFlagChange"; const std::string WINDOW_STATUS_CHANGE_CB = "windowStatusChange"; const std::string WINDOW_VISIBILITY_CHANGE_CB = "windowVisibilityChange"; const std::string WINDOW_TITLE_BUTTON_RECT_CHANGE_CB = "windowTitleButtonRectChange"; +const std::string WINDOW_NO_INTERACTION_DETECT_CB = "noInteractionDetect"; class JsWindowListener : public IWindowChangeListener, public ISystemBarChangedListener, @@ -61,7 +62,8 @@ class JsWindowListener : public IWindowChangeListener, public IGestureNavigationEnabledChangedListener, public IWindowVisibilityChangedListener, public IWindowTitleButtonRectChangedListener, - public IWindowStatusChangeListener { + public IWindowStatusChangeListener, + public IWindowNoInteractionListener { public: JsWindowListener(napi_env env, std::shared_ptr callback) : env_(env), jsCallBack_(callback), weakRef_(wptr (this)) {} @@ -90,6 +92,7 @@ public: void SetMainEventHandler(); void OnWindowStatusChange(WindowStatus windowstatus) override; void OnWindowVisibilityChangedCallback(const bool isVisible) override; + void OnWindowNoInteractionCallback() override; void OnWindowTitleButtonRectChanged(const TitleButtonRect& titleButtonRect) override; private: uint32_t currentWidth_ = 0; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp index d02b20ad3..5bddf9b2a 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp @@ -16,8 +16,10 @@ #include "singleton_container.h" #include "window_manager.h" #include "window_manager_hilog.h" +#include "js_runtime_utils.h" namespace OHOS { namespace Rosen { +using namespace AbilityRuntime; namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsRegisterManager"}; } @@ -45,6 +47,7 @@ JsWindowRegisterManager::JsWindowRegisterManager() { WINDOW_STATUS_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowStatusChangeRegister }, { WINDOW_TITLE_BUTTON_RECT_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowTitleButtonRectChangeRegister}, { WINDOW_VISIBILITY_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowVisibilityChangeRegister }, + { WINDOW_NO_INTERACTION_DETECT_CB, &JsWindowRegisterManager::ProcessWindowNoInteractionRegister }, }; // white register list for window stage listenerProcess_[CaseType::CASE_STAGE] = { @@ -57,7 +60,7 @@ JsWindowRegisterManager::~JsWindowRegisterManager() } WmErrorCode JsWindowRegisterManager::ProcessWindowChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { WLOGFE("[NAPI]Window is nullptr"); @@ -74,7 +77,7 @@ WmErrorCode JsWindowRegisterManager::ProcessWindowChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "[NAPI]Window is nullptr"); @@ -96,7 +99,7 @@ WmErrorCode JsWindowRegisterManager::ProcessSystemAvoidAreaChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { WLOGFE("[NAPI]Window is nullptr"); @@ -113,7 +116,7 @@ WmErrorCode JsWindowRegisterManager::ProcessAvoidAreaChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { WLOGFE("[NAPI]Window is nullptr"); @@ -130,7 +133,7 @@ WmErrorCode JsWindowRegisterManager::ProcessLifeCycleEventRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { WLOGFE("[NAPI]Window is nullptr"); @@ -147,7 +150,7 @@ WmErrorCode JsWindowRegisterManager::ProcessOccupiedAreaChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { sptr thisListener(listener); WmErrorCode ret = WmErrorCode::WM_OK; @@ -162,7 +165,7 @@ WmErrorCode JsWindowRegisterManager::ProcessSystemBarChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { sptr thisListener(listener); WmErrorCode ret; @@ -177,7 +180,7 @@ WmErrorCode JsWindowRegisterManager::ProcessGestureNavigationEnabledChangeRegist } WmErrorCode JsWindowRegisterManager::ProcessWaterMarkFlagChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { sptr thisListener(listener); WmErrorCode ret; @@ -191,7 +194,7 @@ WmErrorCode JsWindowRegisterManager::ProcessWaterMarkFlagChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { WLOGI("called"); if (window == nullptr) { @@ -208,7 +211,7 @@ WmErrorCode JsWindowRegisterManager::ProcessTouchOutsideRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { WLOGD("called"); if (window == nullptr) { @@ -224,8 +227,28 @@ WmErrorCode JsWindowRegisterManager::ProcessWindowVisibilityChangeRegister(sptr< return ret; } +WmErrorCode JsWindowRegisterManager::ProcessWindowNoInteractionRegister(sptr listener, + sptr window, bool isRegister, napi_env env, napi_value parameter) +{ + if (window == nullptr) { + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + } + sptr thisListener(listener); + + if (!isRegister) { + return WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterWindowNoInteractionListener(thisListener)); + } + + uint32_t timeout = 0; + if (parameter == nullptr || !ConvertFromJsNumber(env, parameter, timeout)) { + WLOGFE("Failed to convert parameter to timeout"); + return WmErrorCode::WM_ERROR_INVALID_PARAM; + } + return WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterWindowNoInteractionListener(thisListener, timeout)); +} + WmErrorCode JsWindowRegisterManager::ProcessScreenshotRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { WLOGI("called"); if (window == nullptr) { @@ -243,7 +266,7 @@ WmErrorCode JsWindowRegisterManager::ProcessScreenshotRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; @@ -259,7 +282,7 @@ WmErrorCode JsWindowRegisterManager::ProcessDialogTargetTouchRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; @@ -274,7 +297,7 @@ WmErrorCode JsWindowRegisterManager::ProcessDialogDeathRecipientRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { WLOGD("called"); if (window == nullptr) { @@ -310,7 +333,7 @@ bool JsWindowRegisterManager::IsCallbackRegistered(napi_env env, std::string typ } WmErrorCode JsWindowRegisterManager::RegisterListener(sptr window, std::string type, - CaseType caseType, napi_env env, napi_value value) + CaseType caseType, napi_env env, napi_value value, napi_value parameter) { std::lock_guard lock(mtx_); if (IsCallbackRegistered(env, type, value)) { @@ -329,7 +352,7 @@ WmErrorCode JsWindowRegisterManager::RegisterListener(sptr window, std:: return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } windowManagerListener->SetMainEventHandler(); - WmErrorCode ret = (this->*listenerProcess_[caseType][type])(windowManagerListener, window, true); + WmErrorCode ret = (this->*listenerProcess_[caseType][type])(windowManagerListener, window, true, env, parameter); if (ret != WmErrorCode::WM_OK) { WLOGFE("[NAPI]Register type %{public}s failed", type.c_str()); return ret; @@ -354,7 +377,7 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr window, std } if (value == nullptr) { for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) { - WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false); + WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false, env, nullptr); if (ret != WmErrorCode::WM_OK) { WLOGFE("[NAPI]Unregister type %{public}s failed, no value", type.c_str()); return ret; @@ -370,7 +393,7 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr window, std continue; } findFlag = true; - WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false); + WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false, env, nullptr); if (ret != WmErrorCode::WM_OK) { WLOGFE("[NAPI]Unregister type %{public}s failed", type.c_str()); return ret; @@ -393,7 +416,7 @@ WmErrorCode JsWindowRegisterManager::UnregisterListener(sptr window, std } WmErrorCode JsWindowRegisterManager::ProcessWindowStatusChangeRegister(sptr listener, - sptr window, bool isRegister) + sptr window, bool isRegister, napi_env env, napi_value parameter) { if (window == nullptr) { WLOGFE("[NAPI]Window is nullptr"); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h index 6503a2b2d..587c30957 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h @@ -29,35 +29,45 @@ public: JsWindowRegisterManager(); ~JsWindowRegisterManager(); WmErrorCode RegisterListener(sptr window, std::string type, - CaseType caseType, napi_env env, napi_value value); + CaseType caseType, napi_env env, napi_value callback, napi_value parameter = nullptr); WmErrorCode UnregisterListener(sptr window, std::string type, CaseType caseType, napi_env env, napi_value value); private: bool IsCallbackRegistered(napi_env env, std::string type, napi_value jsListenerObject); - WmErrorCode ProcessWindowChangeRegister(sptr listener, sptr window, bool isRegister); + WmErrorCode ProcessWindowChangeRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessSystemAvoidAreaChangeRegister(sptr listener, sptr window, - bool isRegister); - WmErrorCode ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister); - WmErrorCode ProcessLifeCycleEventRegister(sptr listener, sptr window, bool isRegister); + bool isRegister, napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessAvoidAreaChangeRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessLifeCycleEventRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessOccupiedAreaChangeRegister(sptr listener, sptr window, - bool isRegister); - WmErrorCode ProcessSystemBarChangeRegister(sptr listener, sptr window, bool isRegister); - WmErrorCode ProcessTouchOutsideRegister(sptr listener, sptr window, bool isRegister); - WmErrorCode ProcessScreenshotRegister(sptr listener, sptr window, bool isRegister); - WmErrorCode ProcessDialogTargetTouchRegister(sptr listener, sptr window, bool isRegister); + bool isRegister, napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessSystemBarChangeRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessTouchOutsideRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessScreenshotRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessDialogTargetTouchRegister(sptr listener, sptr window, bool isRegister, + napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessDialogDeathRecipientRegister(sptr listener, sptr window, - bool isRegister); + bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessGestureNavigationEnabledChangeRegister(sptr listener, - sptr window, bool isRegister); + sptr window, bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessWaterMarkFlagChangeRegister(sptr listener, - sptr window, bool isRegister); + sptr window, bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessWindowVisibilityChangeRegister(sptr listener, sptr window, - bool isRegister); + bool isRegister, napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessWindowNoInteractionRegister(sptr listener, sptr window, + bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessWindowStatusChangeRegister(sptr listener, sptr window, - bool isRegister); + bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessWindowTitleButtonRectChangeRegister(sptr listener, sptr window, - bool isRegister); - using Func = WmErrorCode(JsWindowRegisterManager::*)(sptr, sptr window, bool); + bool isRegister, napi_env env, napi_value parameter = nullptr); + using Func = WmErrorCode(JsWindowRegisterManager::*)(sptr, sptr window, bool, + napi_env env, napi_value parameter); std::map, sptr>> jsCbMap_; std::mutex mtx_; std::map> listenerProcess_; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 15a194e75..6d8e733a0 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -85,6 +85,8 @@ napi_value WindowTypeInit(napi_env env) static_cast(ApiWindowType::TYPE_SYSTEM_TOAST))); napi_set_named_property(env, objValue, "TYPE_GLOBAL_SEARCH", CreateJsValue(env, static_cast(ApiWindowType::TYPE_GLOBAL_SEARCH))); + napi_set_named_property(env, objValue, "TYPE_HANDWRITE", CreateJsValue(env, + static_cast(ApiWindowType::TYPE_HANDWRITE))); return objValue; } @@ -495,6 +497,28 @@ napi_value CreateJsWindowPropertiesObject(napi_env env, sptr& window, co napi_set_named_property(env, objValue, "id", CreateJsValue(env, window->GetWindowId())); return objValue; } + +napi_value CreateJsSystemBarPropertiesObject(napi_env env, sptr& window) +{ + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "Failed to convert SystemBarProperties to jsObject"); + return nullptr; + } + SystemBarProperty status = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); + SystemBarProperty navi = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_BAR); + napi_set_named_property(env, objValue, "statusBarColor", CreateJsValue(env, status.backgroundColor_)); + napi_set_named_property(env, objValue, "statusBarContentColor", CreateJsValue(env, status.contentColor_)); + napi_set_named_property(env, objValue, "isStatusBarLightIcon", + CreateJsValue(env, status.contentColor_ == SYSTEM_COLOR_WHITE)); + napi_set_named_property(env, objValue, "navigationBarColor", CreateJsValue(env, navi.backgroundColor_)); + napi_set_named_property(env, objValue, "navigationBarContentColor", CreateJsValue(env, navi.contentColor_)); + napi_set_named_property(env, objValue, "isNavigationBarLightIcon", + CreateJsValue(env, status.contentColor_ == SYSTEM_COLOR_WHITE)); + return objValue; +} + static std::string GetHexColor(uint32_t color) { std::stringstream ioss; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 6bbe76922..5c13a4694 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -66,6 +66,7 @@ enum class ApiWindowType : uint32_t { TYPE_SYSTEM_TOAST, TYPE_DIVIDER, TYPE_GLOBAL_SEARCH, + TYPE_HANDWRITE, TYPE_END }; @@ -101,6 +102,7 @@ const std::map NATIVE_JS_TO_WINDOW_TYPE_MAP { { WindowType::WINDOW_TYPE_SYSTEM_TOAST, ApiWindowType::TYPE_SYSTEM_TOAST }, { WindowType::WINDOW_TYPE_DOCK_SLICE, ApiWindowType::TYPE_DIVIDER }, { WindowType::WINDOW_TYPE_GLOBAL_SEARCH, ApiWindowType::TYPE_GLOBAL_SEARCH }, + { WindowType::WINDOW_TYPE_HANDWRITE, ApiWindowType::TYPE_HANDWRITE }, }; const std::map JS_TO_NATIVE_WINDOW_TYPE_MAP { @@ -125,6 +127,7 @@ const std::map JS_TO_NATIVE_WINDOW_TYPE_MAP { { ApiWindowType::TYPE_SYSTEM_TOAST, WindowType::WINDOW_TYPE_SYSTEM_TOAST }, { ApiWindowType::TYPE_DIVIDER, WindowType::WINDOW_TYPE_DOCK_SLICE }, { ApiWindowType::TYPE_GLOBAL_SEARCH, WindowType::WINDOW_TYPE_GLOBAL_SEARCH }, + { ApiWindowType::TYPE_HANDWRITE, WindowType::WINDOW_TYPE_HANDWRITE }, }; enum class ApiWindowMode : uint32_t { @@ -191,6 +194,7 @@ struct SystemBarPropertyFlag { napi_value GetRectAndConvertToJsValue(napi_env env, const Rect& rect); napi_value CreateJsWindowPropertiesObject(napi_env env, sptr& window, const Rect& drawableRect); + napi_value CreateJsSystemBarPropertiesObject(napi_env env, sptr& window); bool SetSystemBarPropertiesFromJs(napi_env env, napi_value jsObject, std::map& properties, std::map& propertyFlags, sptr& window); diff --git a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp index ea8694568..768348f91 100644 --- a/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp +++ b/interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp @@ -652,6 +652,14 @@ bool JsWindowStage::ParseSubWindowOptions(napi_env env, napi_value jsObject, Win return false; } + bool isModal = false; + if (ParseJsValue(jsObject, env, "isModal", isModal)) { + TLOGI(WmsLogTag::WMS_DIALOG, "isModal:%{public}d", isModal); + if (isModal) { + option.AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_MODAL); + } + } + return true; } diff --git a/previewer/include/window.h b/previewer/include/window.h index 5d861addb..b4bf20e2e 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -57,7 +57,7 @@ namespace Rosen { class RSSurfaceNode; class RSTransaction; using NotifyNativeWinDestroyFunc = std::function; -using SendRenderDataCallback = bool (*)(const void*, const size_t, const int32_t, const int32_t); +using SendRenderDataCallback = bool (*)(const void*, const size_t, const int32_t, const int32_t, const uint64_t); using ContentInfoCallback = std::function; class IWindowLifeCycle : virtual public RefBase { @@ -102,6 +102,10 @@ class IWindowVisibilityChangedListener : virtual public RefBase { }; using WindowVisibilityListenerSptr = sptr; +class IWindowNoInteractionListener : virtual public RefBase { +}; +using IWindowNoInteractionListenerSptr = sptr; + static WMError DefaultCreateErrCode = WMError::WM_OK; class WINDOW_EXPORT Window : public RefBase { public: @@ -270,7 +274,17 @@ public: virtual WMError GetWindowLimits(WindowLimits& windowLimits) { return WMError::WM_OK; }; virtual WMError RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0; virtual WMError UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0; + virtual WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, + uint32_t timeout) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + virtual WMError UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } virtual WMError SetSingleFrameComposerEnabled(bool enable) = 0; + virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) = 0; virtual WMError SetDecorVisible(bool isVisible) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual WMError SetDecorHeight(int32_t decorHeight) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual WMError GetDecorHeight(int32_t& height) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } @@ -288,7 +302,19 @@ public: { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Set the modality of window. + * + * @param isModal bool. + * @return WMError + */ + virtual WMError SetSubWindowModal(bool isModal) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } virtual WMError Recover(uint32_t reason = 0) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }; + + virtual WMError Maximize(MaximizeLayoutOption option) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } }; } } diff --git a/previewer/include/window_impl.h b/previewer/include/window_impl.h index ee5b02ddb..4b82edb4f 100644 --- a/previewer/include/window_impl.h +++ b/previewer/include/window_impl.h @@ -215,6 +215,8 @@ public: virtual WMError UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) override; virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag) override; virtual WMError SetSingleFrameComposerEnabled(bool enable) override; + virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; + private: static std::map>> windowMap_; static std::map>> subWindowMap_; diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index e859e6cb1..044946fd9 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -242,7 +242,9 @@ enum class WindowFlag : uint32_t { WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2, WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3, WINDOW_FLAG_WATER_MARK = 1 << 4, - WINDOW_FLAG_END = 1 << 5, + WINDOW_FLAG_IS_MODAL = 1 << 5, + WINDOW_FLAG_HANDWRITING = 1 << 6, + WINDOW_FLAG_END = 1 << 7, }; /** @@ -703,6 +705,21 @@ public: return config; } }; + +/** + * maximize layout show type + */ +enum ShowType : int32_t { + SHOW, // normally show + HIDE, // show when hover, but hide normally + FORBIDDEN // hide always +}; + +struct MaximizeLayoutOption { + ShowType decor = ShowType::HIDE; + ShowType dock = ShowType::HIDE; +}; + } } #endif // OHOS_ROSEN_WM_COMMON_H diff --git a/previewer/mock/js_window_register_manager.cpp b/previewer/mock/js_window_register_manager.cpp index 8fbcd9924..f67e9541c 100644 --- a/previewer/mock/js_window_register_manager.cpp +++ b/previewer/mock/js_window_register_manager.cpp @@ -24,7 +24,7 @@ JsWindowRegisterManager::~JsWindowRegisterManager() } WmErrorCode JsWindowRegisterManager::RegisterListener(sptr window, std::string type, - CaseType caseType, napi_env env, napi_value value) + CaseType caseType, napi_env env, napi_value value, napi_value parameter) { return WmErrorCode::WM_OK; } diff --git a/previewer/mock/js_window_register_manager.h b/previewer/mock/js_window_register_manager.h index 4b49110c5..aaeadcf37 100644 --- a/previewer/mock/js_window_register_manager.h +++ b/previewer/mock/js_window_register_manager.h @@ -33,7 +33,7 @@ public: JsWindowRegisterManager(); ~JsWindowRegisterManager(); WmErrorCode RegisterListener(sptr window, std::string type, - CaseType caseType, napi_env env, napi_value value); + CaseType caseType, napi_env env, napi_value value, napi_value parameter = nullptr); WmErrorCode UnregisterListener(sptr window, std::string type, CaseType caseType, napi_env env, napi_value value); }; diff --git a/previewer/src/window_impl.cpp b/previewer/src/window_impl.cpp index cc935c052..b9ec3b913 100644 --- a/previewer/src/window_impl.cpp +++ b/previewer/src/window_impl.cpp @@ -889,5 +889,10 @@ WMError WindowImpl::SetSingleFrameComposerEnabled(bool enable) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + +WMError WindowImpl::SetLandscapeMultiWindow(bool isLandscapeMultiWindow) +{ + return WMError::WM_OK; +} } // namespace Rosen } // namespace OHOS diff --git a/test/common/mock/mock_uicontent.h b/test/common/mock/mock_uicontent.h index d307ebd1b..b4f9ff1a1 100644 --- a/test/common/mock/mock_uicontent.h +++ b/test/common/mock/mock_uicontent.h @@ -45,7 +45,7 @@ public: MOCK_METHOD0(DestroyUIDirector, void()); MOCK_METHOD0(ProcessBackPressed, bool()); MOCK_METHOD1(ProcessPointerEvent, bool(const std::shared_ptr& pointerEvent)); - MOCK_METHOD1(ProcessKeyEvent, bool(const std::shared_ptr& keyEvent)); + MOCK_METHOD2(ProcessKeyEvent, bool(const std::shared_ptr& keyEvent, bool isPreIme)); MOCK_METHOD1(ProcessAxisEvent, bool(const std::shared_ptr& axisEvent)); MOCK_METHOD1(ProcessVsyncEvent, bool(uint64_t timeStampNanos)); MOCK_METHOD1(UpdateConfiguration, void(const std::shared_ptr& config)); diff --git a/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp b/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp index 4ed425e2f..e47b3bf6a 100644 --- a/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp +++ b/test/fuzztest/window_scene/sessioninterface_fuzzer/sessioninterface_fuzzer.cpp @@ -271,6 +271,8 @@ void ProxyInterfaceFuzzTestPart3(const uint8_t* data, size_t size) proxy->TransferExtensionData(*wantParams); proxy->NotifyRemoteReady(); proxy->NotifyExtensionDied(); + int32_t errorCode = 1; + proxy->NotifyExtensionTimeout(errorCode); } void ProxyInterfaceFuzzTest(const uint8_t* data, size_t size) diff --git a/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp b/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp index 9bbd08087..6fefa0040 100644 --- a/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp +++ b/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp @@ -111,6 +111,13 @@ public: } }; +class WindowNoInteractionListener : public IWindowNoInteractionListener { +public: + void OnWindowNoInteractionCallback() override + { + } +}; + class AnimationTransitionController : public IAnimationTransitionController { public: void AnimationForShown() override diff --git a/utils/BUILD.gn b/utils/BUILD.gn index dab8d34a7..ffe298da4 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -48,7 +48,6 @@ ohos_static_library("libwmutil_static") { "src/permission.cpp", "src/persistent_storage.cpp", "src/pip_report.cpp", - "src/pip_util.cpp", "src/screen_group_info.cpp", "src/screen_info.cpp", "src/screenshot_info.cpp", @@ -149,7 +148,6 @@ ohos_shared_library("libwmutil") { "src/permission.cpp", "src/persistent_storage.cpp", "src/pip_report.cpp", - "src/pip_util.cpp", "src/screen_group_info.cpp", "src/screen_info.cpp", "src/surface_draw.cpp", diff --git a/utils/include/client_agent_container.h b/utils/include/client_agent_container.h index 16e7192e4..1a765f9f1 100644 --- a/utils/include/client_agent_container.h +++ b/utils/include/client_agent_container.h @@ -64,9 +64,8 @@ template bool ClientAgentContainer::RegisterAgent(const sptr& agent, T2 type) { std::lock_guard lock(mutex_); - auto iter = std::find_if(agentMap_[type].begin(), agentMap_[type].end(), finder_t(agent->AsObject())); - if (iter != agentMap_[type].end()) { - WLOGFW("failed to register agent"); + if (agent == nullptr) { + WLOGFE("agent is invalid"); return false; } agentMap_[type].insert(agent); @@ -80,14 +79,18 @@ template bool ClientAgentContainer::UnregisterAgent(const sptr& agent, T2 type) { std::lock_guard lock(mutex_); - if (agent == nullptr || agentMap_.count(type) == 0) { - WLOGFE("agent or type is invalid"); + if (agent == nullptr) { + WLOGFE("agent is invalid"); return false; } + if (agentMap_.count(type) == 0) { + WLOGFD("repeat unregister agent"); + return true; + } auto& agents = agentMap_.at(type); - bool ret = UnregisterAgentLocked(agents, agent->AsObject()); + UnregisterAgentLocked(agents, agent->AsObject()); agent->AsObject()->RemoveDeathRecipient(deathRecipient_); - return ret; + return true; } template diff --git a/utils/include/pip_util.h b/utils/include/pip_util.h deleted file mode 100644 index f371de373..000000000 --- a/utils/include/pip_util.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ROSEN_WINDOW_PIP_UTIL_H -#define OHOS_ROSEN_WINDOW_PIP_UTIL_H - -#include "wm_common.h" - -namespace OHOS::Rosen { -class PiPUtil { -public: - static void SetDisplayVpr(const float displayVpr); - static void UpdateRectPivot(const int32_t start, const uint32_t len, const uint32_t totalLen, - PiPScalePivot& pivot); - static void GetRectByPivot(int32_t& start, const uint32_t oldLen, const uint32_t len, const uint32_t totalLen, - const PiPScalePivot& pivot); - static void GetRectByScale(const uint32_t width, const uint32_t height, const PiPScaleLevel& scaleLevel, - Rect& rect, bool isLandscape); - static bool GetValidRect(const int32_t width, const int32_t height, Rect& rect); - static constexpr int32_t SAFE_PADDING_HORIZONTAL_VP = 12; - static constexpr int32_t SAFE_PADDING_VERTICAL_TOP = 150; - static constexpr int32_t SAFE_PADDING_VERTICAL_BOTTOM = 150; -}; -} // namespace OHOS::Rosen -#endif // OHOS_ROSEN_WINDOW_PIP_UTIL_H \ No newline at end of file diff --git a/utils/include/window_manager_hilog.h b/utils/include/window_manager_hilog.h index c68605736..d7d27596b 100644 --- a/utils/include/window_manager_hilog.h +++ b/utils/include/window_manager_hilog.h @@ -62,6 +62,7 @@ enum class WmsLogTag : uint8_t { WMS_KEYBOARD, // C0420B WMS_EVENT, // C0420C WMS_UIEXT, // C0420D + WMS_PIP, // C0420E END = 256, // Last one, do not use }; @@ -81,6 +82,7 @@ const std::unordered_map DOMAIN_CONTENTS_MAP = { { WmsLogTag::WMS_KEYBOARD, "WMSKeyboard" }, { WmsLogTag::WMS_EVENT, "WMSEvent" }, { WmsLogTag::WMS_UIEXT, "WMSUiext" }, + { WmsLogTag::WMS_PIP, "WMSPiP" }, }; #define WMS_FILE_NAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) diff --git a/utils/src/pip_report.cpp b/utils/src/pip_report.cpp index 07ff346b3..3feea653e 100644 --- a/utils/src/pip_report.cpp +++ b/utils/src/pip_report.cpp @@ -21,7 +21,6 @@ namespace OHOS { namespace Rosen { namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "PictureInPictureReport"}; const std::string PNAMEID = "windowManager"; const std::string PVERSION = "1.0"; } @@ -58,9 +57,9 @@ void PiPReporter::SetCurrentPackageName(const std::string &packageName) void PiPReporter::ReportPiPStartWindow(int32_t source, int32_t templateType, int32_t isSuccess, const std::string& errorReason) { - WLOGI("Report start pip widow"); + TLOGI(WmsLogTag::WMS_PIP, "Report start pip widow"); if (source == 0) { - WLOGI("need not report start pip widow"); + TLOGI(WmsLogTag::WMS_PIP, "need not report start pip widow"); return; } std::string eventName = "START_PIP"; @@ -75,16 +74,16 @@ void PiPReporter::ReportPiPStartWindow(int32_t source, int32_t templateType, EVENT_KEY_OPERATION_CODE, isSuccess, EVENT_KEY_OPERATION_ERROR_REASON, errorReason); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPStopWindow(int32_t source, int32_t templateType, int32_t isSuccess, const std::string& errorReason) { - WLOGI("Report stop pip widow"); + TLOGI(WmsLogTag::WMS_PIP, "Report stop pip widow"); if (source == 0) { - WLOGI("need not report stop pip widow"); + TLOGI(WmsLogTag::WMS_PIP, "need not report stop pip widow"); return; } std::string eventName = "STOP_PIP"; @@ -99,13 +98,13 @@ void PiPReporter::ReportPiPStopWindow(int32_t source, int32_t templateType, EVENT_KEY_OPERATION_CODE, isSuccess, EVENT_KEY_OPERATION_ERROR_REASON, errorReason); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPActionEvent(int32_t templateType, const std::string &actionEvent) { - WLOGI("Report pip widow action event"); + TLOGI(WmsLogTag::WMS_PIP, "Report pip widow action event"); std::string eventName = "CONTROL_PANNEL_ACTION_EVENT"; int32_t currentAction = CONTROL_ACTION_MAP[actionEvent]; int32_t ret = HiSysEventWrite( @@ -117,13 +116,13 @@ void PiPReporter::ReportPiPActionEvent(int32_t templateType, const std::string & EVENT_KEY_ACTION_EVENT, currentAction, EVENT_KEY_OPERATION_PACKAGE_NAME, packageName_); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPResize(int32_t scaleLevel, int32_t windowWidth, int32_t windowHeight) { - WLOGI("Report pip widow resize"); + TLOGI(WmsLogTag::WMS_PIP, "Report pip widow resize"); std::string eventName = "RESIZE_PIP_SIZE"; int32_t currentScaleLevel = scaleLevel + 1; int32_t ret = HiSysEventWrite( @@ -136,13 +135,13 @@ void PiPReporter::ReportPiPResize(int32_t scaleLevel, int32_t windowWidth, int32 EVENT_KEY_WINDOW_HEIGHT, windowHeight, EVENT_KEY_OPERATION_PACKAGE_NAME, packageName_); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPRatio(int32_t windowWidth, int32_t windowHeight) { - WLOGI("Report pip widow ratio"); + TLOGI(WmsLogTag::WMS_PIP, "Report pip widow ratio"); std::string eventName = "UPDATE_PIP_RATIO"; int32_t ret = HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, eventName, @@ -153,13 +152,13 @@ void PiPReporter::ReportPiPRatio(int32_t windowWidth, int32_t windowHeight) EVENT_KEY_WINDOW_HEIGHT, windowHeight, EVENT_KEY_OPERATION_PACKAGE_NAME, packageName_); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPRestore() { - WLOGI("Report pip widow restore"); + TLOGI(WmsLogTag::WMS_PIP, "Report pip widow restore"); std::string eventName = "RESOTRE_PIP"; int32_t ret = HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, eventName, @@ -168,13 +167,13 @@ void PiPReporter::ReportPiPRestore() EVENT_KEY_PVERSION, PVERSION, EVENT_KEY_OPERATION_PACKAGE_NAME, packageName_); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } void PiPReporter::ReportPiPMove() { - WLOGI("Report pip widow move"); + TLOGI(WmsLogTag::WMS_PIP, "Report pip widow move"); std::string eventName = "MOVE_PIP"; int32_t ret = HiSysEventWrite( OHOS::HiviewDFX::HiSysEvent::Domain::MULTIWINDOW_UE, eventName, @@ -183,7 +182,7 @@ void PiPReporter::ReportPiPMove() EVENT_KEY_PVERSION, PVERSION, EVENT_KEY_OPERATION_PACKAGE_NAME, packageName_); if (ret != 0) { - WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + TLOGE(WmsLogTag::WMS_PIP, "Write HiSysEvent error, ret:%{public}d", ret); } } } // namespace Rosen diff --git a/utils/src/pip_util.cpp b/utils/src/pip_util.cpp deleted file mode 100644 index 40c94a0e0..000000000 --- a/utils/src/pip_util.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "pip_util.h" - -namespace OHOS { -namespace Rosen { -namespace { - constexpr float DEFAULT_PROPORTION = 0.3; - constexpr int32_t NUMBER_TWO = 2; - constexpr int32_t NUMBER_THREE = 3; - constexpr int32_t NUMBER_FOUR = 4; - constexpr int32_t NUMBER_SEVEN = 7; - float g_vpr = 1.0f; -} - -void PiPUtil::SetDisplayVpr(const float displayVpr) -{ - g_vpr = displayVpr; -} - -void PiPUtil::UpdateRectPivot(const int32_t start, const uint32_t len, const uint32_t totalLen, PiPScalePivot& pivot) -{ - int32_t end = static_cast(totalLen) - start - static_cast(len); - if (start > end) { - pivot = PiPScalePivot::END; - } else if (start < end) { - pivot = PiPScalePivot::START; - } else { - pivot = PiPScalePivot::MIDDLE; - } -} - -void PiPUtil::GetRectByPivot(int32_t& start, const uint32_t oldLen, const uint32_t len, const uint32_t totalLen, - const PiPScalePivot& pivot) -{ - switch (pivot) { - default: - case PiPScalePivot::START: - break; - case PiPScalePivot::MIDDLE: - start = (static_cast(totalLen) - static_cast(len)) / NUMBER_TWO; - break; - case PiPScalePivot::END: - start = start - static_cast(len) + static_cast(oldLen); - break; - } -} - -void CalcWinRectLand(const uint32_t width, const uint32_t height, const uint32_t winWidth, - const uint32_t winHeight, Rect& rect) -{ - if (winWidth == 0 || winHeight == 0) { - return; - } - int32_t heightTmp = - static_cast(height) - PiPUtil::SAFE_PADDING_VERTICAL_TOP - PiPUtil::SAFE_PADDING_VERTICAL_BOTTOM; - int32_t safePaddingHorizontal = static_cast(PiPUtil::SAFE_PADDING_HORIZONTAL_VP * g_vpr); - if (winWidth <= winHeight) { - int32_t widthTmp = (NUMBER_THREE * static_cast(width) - - NUMBER_SEVEN * safePaddingHorizontal) / NUMBER_FOUR; - rect.width_ = static_cast(widthTmp); - rect.height_ = rect.width_ * winHeight / winWidth; - if (rect.height_ > static_cast(heightTmp)) { - rect.height_ = static_cast(heightTmp); - rect.width_ = rect.height_ * winWidth / winHeight; - } - } else { - rect.height_ = static_cast(heightTmp); - rect.width_ = rect.height_ * winWidth / winHeight; - } -} - -void PiPUtil::GetRectByScale(const uint32_t width, const uint32_t height, const PiPScaleLevel& scaleLevel, - Rect& rect, bool isLandscape) -{ - uint32_t winWidth = rect.width_; - uint32_t winHeight = rect.height_; - if (winWidth == 0 || winHeight == 0) { - return; - } - int32_t safePaddingHorizontal = static_cast(SAFE_PADDING_HORIZONTAL_VP * g_vpr); - switch (scaleLevel) { - default: - case PiPScaleLevel::PIP_SCALE_LEVEL_SMALLEST: { - float shortBorder = static_cast(width < height ? width : height) * DEFAULT_PROPORTION; - if (winWidth < winHeight) { - rect.width_ = static_cast(shortBorder); - rect.height_ = rect.width_ * winHeight / winWidth; - } else { - rect.height_ = static_cast(shortBorder); - rect.width_ = rect.height_ * winWidth / winHeight; - } - break; - } - case PiPScaleLevel::PIP_SCALE_LEVEL_BIGGEST: { - if (isLandscape) { - CalcWinRectLand(width, height, winWidth, winHeight, rect); - } else { - int32_t widthTmp = 0; - if (winWidth < winHeight) { - widthTmp = (NUMBER_THREE * static_cast(width) - - NUMBER_SEVEN * safePaddingHorizontal) / NUMBER_FOUR; - } else { - widthTmp = static_cast(width) - NUMBER_TWO * safePaddingHorizontal; - } - rect.width_ = static_cast(widthTmp); - rect.height_ = rect.width_ * winHeight / winWidth; - } - break; - } - } -} - -bool PiPUtil::GetValidRect(const int32_t width, const int32_t height, Rect& rect) -{ - int32_t safePaddingHorizontal = static_cast(SAFE_PADDING_HORIZONTAL_VP * g_vpr); - bool hasChanged = false; - if (rect.posX_ < safePaddingHorizontal) { - rect.posX_ = safePaddingHorizontal; - hasChanged = true; - } else if ((rect.posX_ + static_cast(rect.width_)) > (width - safePaddingHorizontal)) { - rect.posX_ = width - safePaddingHorizontal - static_cast(rect.width_); - hasChanged = true; - } - if (rect.posY_ < SAFE_PADDING_VERTICAL_TOP) { - rect.posY_ = SAFE_PADDING_VERTICAL_TOP; - hasChanged = true; - } else if ((rect.posY_ + static_cast(rect.height_)) > (height - SAFE_PADDING_VERTICAL_BOTTOM)) { - rect.posY_ = height - SAFE_PADDING_VERTICAL_BOTTOM - static_cast(rect.height_); - hasChanged = true; - } - return hasChanged; -} -} // namespace Rosen -} // namespace OHOS \ No newline at end of file diff --git a/utils/test/unittest/BUILD.gn b/utils/test/unittest/BUILD.gn index deafdfc71..ef9c1d43e 100644 --- a/utils/test/unittest/BUILD.gn +++ b/utils/test/unittest/BUILD.gn @@ -23,7 +23,6 @@ group("unittest") { ":utils_cutout_info_test", ":utils_display_info_test", ":utils_perform_reporter_test", - ":utils_pip_util_test", ":utils_screen_group_info_test", ":utils_screen_info_test", ":utils_string_test", @@ -236,19 +235,6 @@ ohos_unittest("utils_window_transition_info_test") { ] } -ohos_unittest("utils_pip_util_test") { - module_out_path = module_out_path - - sources = [ "pip_util_test.cpp" ] - - deps = [ ":utils_unittest_common" ] - - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - ] -} - ## Build dm_unittest_common.a {{{ config("utils_unittest_common_public_config") { include_dirs = [ diff --git a/utils/test/unittest/pip_util_test.cpp b/utils/test/unittest/pip_util_test.cpp deleted file mode 100644 index 0a1ee9ba1..000000000 --- a/utils/test/unittest/pip_util_test.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "pip_util.h" - -using namespace testing; -using namespace testing::ext; - -namespace OHOS { -namespace Rosen { -class PiPUtilTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp() override; - void TearDown() override; -}; - -void PiPUtilTest::SetUpTestCase() -{ -} - -void PiPUtilTest::TearDownTestCase() -{ -} - -void PiPUtilTest::SetUp() -{ -} - -void PiPUtilTest::TearDown() -{ -} - -namespace { -/** - * @tc.name: UpdateRectPivot - * @tc.desc: UpdateRectPivot test - * @tc.type: FUNC - */ -HWTEST_F(PiPUtilTest, UpdateRectPivot, Function | SmallTest | Level2) -{ - auto pivot1 = PiPScalePivot::UNDEFINED; - PiPUtil::UpdateRectPivot(10, 20, 100, pivot1); - ASSERT_EQ(PiPScalePivot::START, pivot1); - - auto pivot2 = PiPScalePivot::UNDEFINED; - PiPUtil::UpdateRectPivot(40, 20, 100, pivot2); - ASSERT_EQ(PiPScalePivot::MIDDLE, pivot2); - - auto pivot3 = PiPScalePivot::UNDEFINED; - PiPUtil::UpdateRectPivot(70, 20, 100, pivot3); - ASSERT_EQ(PiPScalePivot::END, pivot3); -} - -/** - * @tc.name: GetRectByPivot - * @tc.desc: GetRectByPivot test - * @tc.type: FUNC - */ -HWTEST_F(PiPUtilTest, GetRectByPivot, Function | SmallTest | Level2) -{ - auto pivot1 = PiPScalePivot::UNDEFINED; - int32_t start1 = 100; - PiPUtil::GetRectByPivot(start1, 100, 200, 300, pivot1); - ASSERT_EQ(100, start1); - - auto pivot2 = PiPScalePivot::UNDEFINED; - int32_t start2 = 100; - PiPUtil::GetRectByPivot(start2, 100, 200, 300, pivot2); - ASSERT_EQ(100, start2); - - auto pivot3 = PiPScalePivot::UNDEFINED; - int32_t start3 = 100; - PiPUtil::GetRectByPivot(start3, 100, 200, 300, pivot3); - ASSERT_EQ(100, start3); -} - -/** - * @tc.name: GetRectByScale - * @tc.desc: GetRectByScale test - * @tc.type: FUNC - */ -HWTEST_F(PiPUtilTest, GetRectByScale, Function | SmallTest | Level2) -{ - Rect rect1 = {0, 0, 100, 100}; - auto level1 = PiPScaleLevel::PIP_SCALE_LEVEL_SMALLEST; - PiPUtil::GetRectByScale(200, 200, level1, rect1, false); - ASSERT_EQ(60, rect1.width_); - ASSERT_EQ(60, rect1.height_); - - Rect rect2 = {0, 0, 100, 100}; - auto level2 = PiPScaleLevel::PIP_SCALE_LEVEL_SMALLEST; - PiPUtil::GetRectByScale(200, 200, level2, rect2, false); - ASSERT_EQ(60, rect2.width_); - ASSERT_EQ(60, rect2.height_); -} - -/** - * @tc.name: GetValidRect - * @tc.desc: GetValidRect test - * @tc.type: FUNC - */ -HWTEST_F(PiPUtilTest, GetValidRect, Function | SmallTest | Level2) -{ - Rect rect1 = {0, PiPUtil::SAFE_PADDING_VERTICAL_TOP, 100, 100}; - ASSERT_EQ(true, PiPUtil::GetValidRect(1000, 1000, rect1)); - ASSERT_EQ(PiPUtil::SAFE_PADDING_HORIZONTAL_VP, rect1.posX_); - ASSERT_EQ(PiPUtil::SAFE_PADDING_VERTICAL_TOP, rect1.posY_); - - Rect rect2 = {1000, PiPUtil::SAFE_PADDING_VERTICAL_TOP, 100, 100}; - ASSERT_EQ(true, PiPUtil::GetValidRect(1000, 1000, rect2)); - ASSERT_EQ(1000 - rect2.width_ - PiPUtil::SAFE_PADDING_HORIZONTAL_VP, rect2.posX_); - ASSERT_EQ(PiPUtil::SAFE_PADDING_VERTICAL_TOP, rect2.posY_); - - Rect rect3 = {PiPUtil::SAFE_PADDING_HORIZONTAL_VP, 0, 100, 100}; - ASSERT_EQ(true, PiPUtil::GetValidRect(1000, 1000, rect3)); - ASSERT_EQ(PiPUtil::SAFE_PADDING_HORIZONTAL_VP, rect3.posX_); - ASSERT_EQ(PiPUtil::SAFE_PADDING_VERTICAL_TOP, rect3.posY_); - - Rect rect4 = {PiPUtil::SAFE_PADDING_HORIZONTAL_VP, 1000, 100, 100}; - ASSERT_EQ(true, PiPUtil::GetValidRect(1000, 1000, rect4)); - ASSERT_EQ(PiPUtil::SAFE_PADDING_HORIZONTAL_VP, rect4.posX_); - ASSERT_EQ(1000 - 100 - PiPUtil::SAFE_PADDING_VERTICAL_BOTTOM, rect4.posY_); - - Rect rect5 = {PiPUtil::SAFE_PADDING_HORIZONTAL_VP, PiPUtil::SAFE_PADDING_VERTICAL_TOP, 100, 100}; - ASSERT_EQ(false, PiPUtil::GetValidRect(1000, 1000, rect5)); - ASSERT_EQ(PiPUtil::SAFE_PADDING_HORIZONTAL_VP, rect5.posX_); - ASSERT_EQ(PiPUtil::SAFE_PADDING_VERTICAL_TOP, rect5.posY_); -} -} -} // namespace Rosen -} // namespace OHOS \ No newline at end of file diff --git a/window_scene/common/include/session_permission.h b/window_scene/common/include/session_permission.h index 7236b2118..822483e6e 100644 --- a/window_scene/common/include/session_permission.h +++ b/window_scene/common/include/session_permission.h @@ -35,6 +35,7 @@ public: static bool IsSACalling(); static bool VerifyCallingPermission(const std::string& permissionName); static bool IsSameBundleNameAsCalling(const std::string& bundleName); + static bool IsStartedByUIExtension(); }; } // Rosen } // OHOS diff --git a/window_scene/common/src/session_permission.cpp b/window_scene/common/src/session_permission.cpp index 54ab04f44..67bb8aaa4 100644 --- a/window_scene/common/src/session_permission.cpp +++ b/window_scene/common/src/session_permission.cpp @@ -234,5 +234,38 @@ bool SessionPermission::IsSameBundleNameAsCalling(const std::string& bundleName) return false; } } + +bool SessionPermission::IsStartedByUIExtension() +{ + auto bundleManagerServiceProxy_ = GetBundleManagerProxy(); + if (!bundleManagerServiceProxy_) { + WLOGFE("failed to get BundleManagerServiceProxy"); + return false; + } + + int uid = IPCSkeleton::GetCallingUid(); + // reset ipc identity + std::string identity = IPCSkeleton::ResetCallingIdentity(); + std::string bundleName; + bundleManagerServiceProxy_->GetNameForUid(uid, bundleName); + AppExecFwk::BundleInfo bundleInfo; + // 200000 use uid to caculate userId + int userId = uid / 200000; + bool result = bundleManagerServiceProxy_->GetBundleInfo(bundleName, + AppExecFwk::BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO, bundleInfo, userId); + // set ipc identity to raw + IPCSkeleton::SetCallingIdentity(identity); + if (!result) { + WLOGFE("failed to query extension ability info, bundleName:%{public}s, userId:%{public}d", + bundleName.c_str(), userId); + return false; + } + + auto extensionInfo = std::find_if(bundleInfo.extensionInfos.begin(), bundleInfo.extensionInfos.end(), + [](AppExecFwk::ExtensionAbilityInfo extensionInfo) { + return (extensionInfo.type == AppExecFwk::ExtensionAbilityType::SYS_COMMON_UI); + }); + return extensionInfo != bundleInfo.extensionInfos.end(); +} } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/intention_event/src/intention_event_manager.cpp b/window_scene/intention_event/src/intention_event_manager.cpp index cd3a07875..4db2ef127 100644 --- a/window_scene/intention_event/src/intention_event_manager.cpp +++ b/window_scene/intention_event/src/intention_event_manager.cpp @@ -285,6 +285,8 @@ void IntentionEventManager::InputEventListener::OnInputEvent(std::shared_ptrSendKeyEventToUI(keyEvent, true); + TLOGI(WmsLogTag::WMS_EVENT, "SendKeyEventToUI isConsumed = %{public}d", static_cast(isConsumed)); #ifdef IMF_ENABLE bool isKeyboardEvent = IsKeyboardEvent(keyEvent); if (isKeyboardEvent) { diff --git a/window_scene/interfaces/include/ws_common.h b/window_scene/interfaces/include/ws_common.h index c0babfd60..4eeabc6f7 100644 --- a/window_scene/interfaces/include/ws_common.h +++ b/window_scene/interfaces/include/ws_common.h @@ -200,6 +200,7 @@ struct SessionInfo { bool isSystemInput_ = false; bool isAsyncModalBinding_ = false; bool isSetPointerAreas_ = false; + bool isCastSession_ = false; }; enum class SessionFlag : uint32_t { diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp index 222970ef7..163683720 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp @@ -230,7 +230,8 @@ void JsRootSceneSession::PendingSessionActivationInner(std::shared_ptrpersistentId_); napi_call_function(env_ref, NapiGetUndefined(env_ref), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); }; @@ -250,7 +251,8 @@ void JsRootSceneSession::PendingSessionActivation(SessionInfo& info) if (info.want != nullptr) { bool isNeedBackToOther = info.want->GetBoolParam(AAFwk::Want::PARAM_BACK_TO_OTHER_MISSION_STACK, false); - TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]isNeedBackToOther: %{public}d", isNeedBackToOther); + TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]session: %{public}d isNeedBackToOther: %{public}d", + sceneSession->GetPersistentId(), isNeedBackToOther); if (isNeedBackToOther) { int32_t realCallerSessionId = SceneSessionManager::GetInstance().GetFocusedSession(); if (realCallerSessionId == sceneSession->GetPersistentId()) { diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index d5211a1a1..3da7fa0ad 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -58,6 +58,7 @@ const std::string TOUCH_OUTSIDE_CB = "touchOutside"; const std::string WINDOW_DRAG_HOT_AREA_CB = "windowDragHotArea"; const std::string SESSIONINFO_LOCKEDSTATE_CHANGE_CB = "sessionInfoLockedStateChange"; const std::string PREPARE_CLOSE_PIP_SESSION = "prepareClosePiPSession"; +const std::string LANDSCAPE_MULTI_WINDOW_CB = "landscapeMultiWindow"; constexpr int SCALE_ARG_COUNT = 4; constexpr int ARG_INDEX_0 = 0; constexpr int ARG_INDEX_1 = 1; @@ -209,6 +210,7 @@ void JsSceneSession::InitListenerFuncs() { WINDOW_DRAG_HOT_AREA_CB, &JsSceneSession::ProcessWindowDragHotAreaRegister }, { SESSIONINFO_LOCKEDSTATE_CHANGE_CB, &JsSceneSession::ProcessSessionInfoLockedStateChangeRegister }, { PREPARE_CLOSE_PIP_SESSION, &JsSceneSession::ProcessPrepareClosePiPSessionRegister}, + { LANDSCAPE_MULTI_WINDOW_CB, &JsSceneSession::ProcessLandscapeMultiWindowRegister }, }; } @@ -287,6 +289,40 @@ void JsSceneSession::ProcessSessionInfoLockedStateChangeRegister() WLOGFD("ProcessSessionInfoLockedStateChangeRegister success"); } +void JsSceneSession::ProcessLandscapeMultiWindowRegister() +{ + WLOGFD("ProcessLandscapeMultiWindowRegister"); + auto sessionchangeCallback = sessionchangeCallback_.promote(); + if (sessionchangeCallback == nullptr) { + WLOGFE("sessionchangeCallback is nullptr"); + return; + } + sessionchangeCallback->onSetLandscapeMultiWindowFunc_ = std::bind(&JsSceneSession::SetLandscapeMultiWindow, + this, std::placeholders::_1); + WLOGFD("ProcessLandscapeMultiWindowRegister success"); +} + +void JsSceneSession::SetLandscapeMultiWindow(bool isLandscapeMultiWindow) +{ + WLOGFI("[NAPI]SetLandScapeMultiWindow, isLandscapeMultiWindow: %{public}u", isLandscapeMultiWindow); + auto iter = jsCbMap_.find(LANDSCAPE_MULTI_WINDOW_CB); + if (iter == jsCbMap_.end()) { + return; + } + auto jsCallBack = iter->second; + auto task = [isLandscapeMultiWindow, jsCallBack, env = env_]() { + if (!jsCallBack) { + WLOGFE("[NAPI]jsCallBack is nullptr"); + return; + } + napi_value jsSessionLandscapeMultiWindowObj = CreateJsValue(env, isLandscapeMultiWindow); + napi_value argv[] = {jsSessionLandscapeMultiWindowObj}; + napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); + }; + taskScheduler_->PostMainThreadTask(task, + "SetLandscapeMultiWindow, isLandscapeMultiWindow:" + std::to_string(isLandscapeMultiWindow)); +} + void JsSceneSession::OnSessionInfoLockedStateChange(bool lockedState) { WLOGFI("[NAPI]OnSessionInfoLockedStateChange, state: %{public}u", lockedState); @@ -970,7 +1006,7 @@ napi_value JsSceneSession::SetOffset(napi_env env, napi_callback_info info) { napi_value JsSceneSession::SetPipActionEvent(napi_env env, napi_callback_info info) { - WLOGI("[NAPI]SetPipActionEvent"); + TLOGI(WmsLogTag::WMS_PIP, "[NAPI]SetPipActionEvent"); JsSceneSession *me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetPipActionEvent(env, info) : nullptr; } @@ -1480,7 +1516,7 @@ void JsSceneSession::OnRaiseAboveTarget(int32_t subWindowId) void JsSceneSession::OnSessionFocusableChange(bool isFocusable) { - TLOGI(WmsLogTag::WMS_FOCUS, "[NAPI]OnSessionFocusableChange, state: %{public}u", isFocusable); + TLOGD(WmsLogTag::WMS_FOCUS, "[NAPI]OnSessionFocusableChange, state: %{public}u", isFocusable); std::shared_ptr jsCallBack = nullptr; { std::shared_lock lock(jsCbMapMutex_); @@ -1997,6 +2033,7 @@ void JsSceneSession::OnSystemBarPropertyChange(const std::unordered_map lock(jsCbMapMutex_); auto iter = jsCbMap_.find(SYSTEMBAR_PROPERTY_CHANGE_CB); if (iter == jsCbMap_.end()) { + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]fail to find systemBar property change callback"); return; } jsCallBack = iter->second; @@ -2312,19 +2349,19 @@ void JsSceneSession::ProcessPrepareClosePiPSessionRegister() { auto sessionchangeCallback = sessionchangeCallback_.promote(); if (sessionchangeCallback == nullptr) { - WLOGFE("sessionchangeCallback is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "sessionchangeCallback is nullptr"); return; } sessionchangeCallback->onPrepareClosePiPSession_ = [weak = weak_from_this()]() { auto weakJsSceneSession = weak.lock(); if (weakJsSceneSession) weakJsSceneSession->OnPrepareClosePiPSession(); }; - WLOGFD("ProcessPrepareClosePiPSessionRegister success"); + TLOGD(WmsLogTag::WMS_PIP, "ProcessPrepareClosePiPSessionRegister success"); } void JsSceneSession::OnPrepareClosePiPSession() { - WLOGFI("[NAPI]OnPrepareClosePiPSession"); + TLOGI(WmsLogTag::WMS_PIP, "[NAPI]OnPrepareClosePiPSession"); std::shared_ptr jsCallBack = nullptr; { std::shared_lock lock(jsCbMapMutex_); @@ -2336,7 +2373,7 @@ void JsSceneSession::OnPrepareClosePiPSession() } auto task = [jsCallBack, env = env_]() { if (!jsCallBack) { - WLOGFE("[NAPI]jsCallBack is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]jsCallBack is nullptr"); return; } napi_value argv[] = {}; @@ -2430,14 +2467,14 @@ napi_value JsSceneSession::OnSetPipActionEvent(napi_env env, napi_callback_info napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - WLOGFE("[NAPI]Argc count is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Argc count is invalid: %{public}zu", argc); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); } std::string action; if (!ConvertFromJsValue(env, argv[0], action)) { - WLOGFE("[NAPI]Failed to convert parameter to string"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to convert parameter to string"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); @@ -2445,7 +2482,7 @@ napi_value JsSceneSession::OnSetPipActionEvent(napi_env env, napi_callback_info int32_t status = -1; if (argc > 1) { if (!ConvertFromJsValue(env, argv[1], status)) { - WLOGFE("[NAPI]Failed to convert parameter to int"); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Failed to convert parameter to int"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); @@ -2454,9 +2491,7 @@ napi_value JsSceneSession::OnSetPipActionEvent(napi_env env, napi_callback_info auto session = weakSession_.promote(); if (session == nullptr) { - WLOGFE("[NAPI]Session is nullptr"); - napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), - "Session is nullptr")); + TLOGE(WmsLogTag::WMS_PIP, "[NAPI]Session is nullptr"); return NapiGetUndefined(env); } session->SetPipActionEvent(action, status); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h index 1851e8732..9bd81ef71 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h @@ -116,6 +116,7 @@ private: void ProcessWindowDragHotAreaRegister(); void ProcessSessionInfoLockedStateChangeRegister(); void ProcessPrepareClosePiPSessionRegister(); + void ProcessLandscapeMultiWindowRegister(); void ChangeSessionVisibilityWithStatusBar(SessionInfo& info, bool visible); void ChangeSessionVisibilityWithStatusBarInner(std::shared_ptr sessionInfo, bool visible); @@ -153,6 +154,7 @@ private: void OnWindowDragHotArea(int32_t type, const SizeChangeReason& reason); void OnSessionInfoLockedStateChange(bool lockedState); void OnPrepareClosePiPSession(); + void SetLandscapeMultiWindow(bool isLandscapeMultiWindow); napi_env env_; wptr weakSession_ = nullptr; 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 2b555b743..81b6a010e 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 @@ -57,7 +57,6 @@ const std::string OUTSIDE_DOWN_EVENT_CB = "outsideDownEvent"; const std::string START_UI_ABILITY_ERROR = "startUIAbilityError"; const std::string ARG_DUMP_HELP = "-h"; const std::string SHIFT_FOCUS_CB = "shiftFocus"; -const std::string SHOW_PIP_MAIN_WINDOW_CB = "showPiPMainWindow"; const std::string CALLING_WINDOW_ID_CHANGE_CB = "callingWindowIdChange"; } // namespace @@ -146,7 +145,6 @@ JsSceneSessionManager::JsSceneSessionManager(napi_env env) : env_(env) { STATUS_BAR_ENABLED_CHANGE_CB, &JsSceneSessionManager::ProcessStatusBarEnabledChangeListener}, { OUTSIDE_DOWN_EVENT_CB, &JsSceneSessionManager::ProcessOutsideDownEvent }, { SHIFT_FOCUS_CB, &JsSceneSessionManager::ProcessShiftFocus }, - { SHOW_PIP_MAIN_WINDOW_CB, &JsSceneSessionManager::ProcessShowPiPMainWindow }, { START_UI_ABILITY_ERROR, &JsSceneSessionManager::ProcessStartUIAbilityErrorRegister}, { GESTURE_NAVIGATION_ENABLED_CHANGE_CB, &JsSceneSessionManager::ProcessGestureNavigationEnabledChangeListener }, @@ -324,22 +322,6 @@ void JsSceneSessionManager::OnShiftFocus(int32_t persistentId) taskScheduler_->PostMainThreadTask(task, "OnShiftFocus, PID:" + std::to_string(persistentId)); } -void JsSceneSessionManager::OnShowPiPMainWindow(int32_t persistentId) -{ - WLOGFI("[NAPI]OnShowPiPMainWindow"); - auto iter = jsCbMap_.find(SHOW_PIP_MAIN_WINDOW_CB); - if (iter == jsCbMap_.end()) { - return; - } - - auto jsCallBack = iter->second; - auto task = [this, persistentId, jsCallBack, env = env_]() { - napi_value argv[] = {CreateJsValue(env, persistentId)}; - napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); - }; - taskScheduler_->PostMainThreadTask(task, "OnShowPiPMainWindow, persistentId:" + std::to_string(persistentId)); -} - void JsSceneSessionManager::OnCallingWindowIdChange(const uint32_t windowId) { TLOGD(WmsLogTag::WMS_KEYBOARD, "[NAPI]OnCallingWindowIdChange"); @@ -438,15 +420,6 @@ void JsSceneSessionManager::ProcessShiftFocus() SceneSessionManager::GetInstance().SetSCBUnfocusedListener(unfocusedCallback); } -void JsSceneSessionManager::ProcessShowPiPMainWindow() -{ - ProcessShowPiPMainWindowFunc func = [this](int32_t persistentId) { - WLOGFD("ProcessShowPiPMainWindow called, persistentId: %{public}d", persistentId); - this->OnShowPiPMainWindow(persistentId); - }; - SceneSessionManager::GetInstance().SetShowPiPMainWindowListener(func); -} - void JsSceneSessionManager::ProcessCallingWindowIdChangeRegister() { ProcessCallingWindowIdChangeFunc func = [this](uint32_t callingWindowId) { @@ -901,6 +874,8 @@ napi_value JsSceneSessionManager::CreateAbilityItemInfo(napi_env env, const AppE napi_set_named_property(env, objValue, "continuable", CreateJsValue(env, abilityInfo.continuable)); napi_set_named_property(env, objValue, "removeSessionAfterTerminate", CreateJsValue(env, abilityInfo.removeMissionAfterTerminate)); + napi_set_named_property(env, objValue, "preferMultiWindowOrientation", + CreateJsValue(env, abilityInfo.preferMultiWindowOrientation)); return objValue; } 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 717073c4b..0409c14b4 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 @@ -123,7 +123,6 @@ private: void OnOutsideDownEvent(int32_t x, int32_t y); void OnStartUIAbilityError(const uint32_t errorCode); void OnShiftFocus(int32_t persistentId); - void OnShowPiPMainWindow(int32_t persistentId); void OnCallingWindowIdChange(const uint32_t callingWindowId); void ProcessCreateSystemSessionRegister(); void ProcessRecoverSceneSessionRegister(); @@ -132,7 +131,6 @@ private: void ProcessStartUIAbilityErrorRegister(); void ProcessOutsideDownEvent(); void ProcessShiftFocus(); - void ProcessShowPiPMainWindow(); void ProcessCallingWindowIdChangeRegister(); bool IsCallbackRegistered(napi_env env, const std::string& type, napi_value jsListenerObject); void RegisterDumpRootSceneElementInfoListener(); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp index 7767e40fb..23becb989 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.cpp @@ -645,6 +645,7 @@ napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo) napi_set_named_property(env, objValue, "abilityName", CreateJsValue(env, sessionInfo.abilityName_)); napi_set_named_property(env, objValue, "appIndex", CreateJsValue(env, sessionInfo.appIndex_)); napi_set_named_property(env, objValue, "isSystem", CreateJsValue(env, sessionInfo.isSystem_)); + napi_set_named_property(env, objValue, "isCastSession", CreateJsValue(env, sessionInfo.isCastSession_)); napi_set_named_property(env, objValue, "persistentId", CreateJsValue(env, static_cast(sessionInfo.persistentId_))); napi_set_named_property(env, objValue, "callerPersistentId", @@ -956,6 +957,7 @@ napi_value SessionTypeInit(napi_env env) SetTypeProperty(objValue, env, "TYPE_PIP", JsSessionType::TYPE_PIP); SetTypeProperty(objValue, env, "TYPE_THEME_EDITOR", JsSessionType::TYPE_THEME_EDITOR); SetTypeProperty(objValue, env, "TYPE_NAVIGATION_INDICATOR", JsSessionType::TYPE_NAVIGATION_INDICATOR); + SetTypeProperty(objValue, env, "TYPE_HANDWRITE", JsSessionType::TYPE_HANDWRITE); return objValue; } diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h index 94e2eb701..9fb8748dc 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h @@ -61,6 +61,7 @@ enum class JsSessionType : uint32_t { TYPE_NAVIGATION_INDICATOR, TYPE_SEARCHING_BAR, TYPE_SYSTEM_SUB_WINDOW, + TYPE_HANDWRITE, }; // should same with bundlemanager ability info @@ -113,6 +114,7 @@ const std::map WINDOW_TO_JS_SESSION_TYPE_MAP { { WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, JsSessionType::TYPE_NAVIGATION_INDICATOR }, { WindowType::WINDOW_TYPE_SEARCHING_BAR, JsSessionType::TYPE_SEARCHING_BAR }, { WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW, JsSessionType::TYPE_SYSTEM_SUB_WINDOW }, + { WindowType::WINDOW_TYPE_HANDWRITE, JsSessionType::TYPE_HANDWRITE }, }; const std::map JS_SESSION_TO_WINDOW_TYPE_MAP { @@ -148,6 +150,7 @@ const std::map JS_SESSION_TO_WINDOW_TYPE_MAP { { JsSessionType::TYPE_NAVIGATION_INDICATOR, WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR }, { JsSessionType::TYPE_SEARCHING_BAR, WindowType::WINDOW_TYPE_SEARCHING_BAR }, { JsSessionType::TYPE_SYSTEM_SUB_WINDOW, WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW }, + { JsSessionType::TYPE_HANDWRITE, WindowType::WINDOW_TYPE_HANDWRITE }, }; const std::map WINDOW_ORIENTATION_TO_JS_SESSION_MAP { diff --git a/window_scene/screen_session_manager/include/screen_session_manager_client.h b/window_scene/screen_session_manager/include/screen_session_manager_client.h index 8a3f944e0..63f52c6b6 100644 --- a/window_scene/screen_session_manager/include/screen_session_manager_client.h +++ b/window_scene/screen_session_manager/include/screen_session_manager_client.h @@ -66,6 +66,7 @@ public: FoldStatus GetFoldStatus(); std::shared_ptr GetScreenSnapshot(ScreenId screenId, float scaleX, float scaleY); sptr GetScreenSessionById(const ScreenId id); + ScreenId GetDefaultScreenId(); protected: ScreenSessionManagerClient() = default; diff --git a/window_scene/screen_session_manager/src/screen_session_manager_client.cpp b/window_scene/screen_session_manager/src/screen_session_manager_client.cpp index c811a0685..4cdc49f86 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager_client.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager_client.cpp @@ -361,4 +361,13 @@ sptr ScreenSessionManagerClient::GetScreenSessionById(const Scree } return iter->second; } + +ScreenId ScreenSessionManagerClient::GetDefaultScreenId() +{ + auto iter = screenSessionMap_.begin(); + if (iter != screenSessionMap_.end()) { + return iter->first; + } + return SCREEN_ID_INVALID; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/BUILD.gn b/window_scene/session/BUILD.gn index 1e6c60d2d..2d7db5825 100755 --- a/window_scene/session/BUILD.gn +++ b/window_scene/session/BUILD.gn @@ -73,6 +73,8 @@ ohos_shared_library("scene_session") { "${window_base_path}/utils:libwmutil", "${window_base_path}/window_scene/common:window_scene_common", "${window_base_path}/window_scene/intention_event/service:intention_event_anr_manager", + "${window_base_path}/window_scene/screen_session_manager:screen_session_manager_client", + "${window_base_path}/window_scene/session:screen_session", ] public_deps = diff --git a/window_scene/session/container/include/window_event_channel.h b/window_scene/session/container/include/window_event_channel.h index 45cf4a526..0bb450f02 100644 --- a/window_scene/session/container/include/window_event_channel.h +++ b/window_scene/session/container/include/window_event_channel.h @@ -39,7 +39,8 @@ public: WSError TransferBackpressedEventForConsumed(bool& isConsumed) override; WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; WSError TransferPointerEvent(const std::shared_ptr& pointerEvent) override; - WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) override; + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent = false) override; WSError TransferFocusActiveEvent(bool isFocusActive) override; WSError TransferFocusState(bool focusState) override; WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, @@ -52,6 +53,8 @@ public: Accessibility::AccessibilityElementInfo& info) override; WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, int32_t action, int64_t baseParent) override; + WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, + int32_t eventType, int64_t timeMs) override; private: void PrintKeyEvent(const std::shared_ptr& event); diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index 4a306f283..7256b924b 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -39,20 +39,49 @@ class ISessionStage : public IRemoteBroker { public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISessionStage"); + // IPC interface + virtual WSError SetActive(bool active) = 0; + virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, + const std::shared_ptr& rsTransaction = nullptr) = 0; + virtual void UpdateDensity() = 0; + virtual WSError HandleBackEvent() = 0; + virtual WSError MarkProcessed(int32_t eventId) = 0; + virtual WSError UpdateFocus(bool isFocused) = 0; + virtual WSError NotifyDestroy() = 0; + virtual WSError NotifyCloseExistPipWindow() = 0; + virtual WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) = 0; + virtual WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, + AAFwk::WantParams& reWantParams) = 0; + virtual void NotifyOccupiedAreaChangeInfo(sptr info) = 0; + virtual WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; + virtual void NotifyScreenshot() = 0; + virtual void DumpSessionElementInfo(const std::vector& params) = 0; + virtual WSError NotifyTouchOutside() = 0; + virtual WSError NotifyWindowVisibility(bool isVisible) = 0; + virtual WSError UpdateWindowMode(WindowMode mode) = 0; + virtual void NotifyForegroundInteractiveStatus(bool interactive) = 0; + virtual WSError UpdateMaximizeMode(MaximizeMode mode) = 0; + virtual void NotifySessionForeground(uint32_t reason, bool withAnimation) = 0; + virtual void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) = 0; + virtual WSError UpdateTitleInTargetPos(bool isShow, int32_t height) = 0; + virtual void NotifyTransformChange(const Transform& transform) = 0; + virtual WSError NotifyDialogStateChange(bool isForeground) = 0; + virtual WSError SetPipActionEvent(const std::string& action, int32_t status) = 0; + virtual WSError UpdateDisplayId(uint64_t displayId) = 0; + virtual void NotifyDisplayMove(DisplayId from, DisplayId to) = 0; + + // **Non** IPC interface virtual void NotifyBackpressedEvent(bool& isConsumed) {} virtual void NotifyPointerEvent(const std::shared_ptr& pointerEvent) {} virtual void NotifyKeyEvent(const std::shared_ptr& keyEvent, bool& isConsumed, bool notifyInputMethod = true) {} virtual void NotifyFocusActiveEvent(bool isFocusActive) {} virtual void NotifyFocusStateEvent(bool focusState) {} + virtual bool NotifyOnKeyPreImeEvent(const std::shared_ptr& keyEvent) {return false;} virtual int32_t GetPersistentId() const { return -1; } - virtual WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) - { - return WSError::WS_OK; - } virtual WSError NotifySearchElementInfoByAccessibilityId(int64_t elementId, int32_t mode, int64_t baseParent, std::list& infos) { @@ -78,39 +107,11 @@ public: { return WSError::WS_OK; } - virtual WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, - AAFwk::WantParams& reWantParams) - { - return WSErrorCode::WS_OK; - } - virtual WSError NotifyDialogStateChange(bool isForeground) + virtual WSError NotifyAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) { return WSError::WS_OK; } - virtual WSError SetActive(bool active) = 0; - virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, - const std::shared_ptr& rsTransaction = nullptr) = 0; - virtual void UpdateDensity() = 0; - virtual WSError HandleBackEvent() = 0; - virtual WSError MarkProcessed(int32_t eventId) = 0; - virtual WSError UpdateFocus(bool isFocused) = 0; - virtual WSError NotifyDestroy() = 0; - virtual WSError NotifyCloseExistPipWindow() = 0; - virtual void NotifyOccupiedAreaChangeInfo(sptr info) = 0; - virtual WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) = 0; - virtual void NotifyScreenshot() = 0; - virtual void DumpSessionElementInfo(const std::vector& params) = 0; - virtual WSError NotifyTouchOutside() = 0; - virtual WSError NotifyWindowVisibility(bool isVisible) = 0; - virtual WSError UpdateWindowMode(WindowMode mode) = 0; - virtual void NotifyForegroundInteractiveStatus(bool interactive) = 0; - virtual WSError UpdateMaximizeMode(MaximizeMode mode) = 0; - virtual void NotifySessionForeground(uint32_t reason, bool withAnimation) = 0; - virtual void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) = 0; - virtual WSError UpdateTitleInTargetPos(bool isShow, int32_t height) = 0; - virtual void NotifyTransformChange(const Transform& transform) = 0; - virtual WSError SetPipActionEvent(const std::string& action, int32_t status) = 0; - virtual WSError UpdateDisplayId(uint64_t displayId) = 0; }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 5bf2f7271..c0dcf88ca 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -47,6 +47,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_NOTIFY_DIALOG_STATE_CHANGE, TRANS_ID_SET_PIP_ACTION_EVENT, TRANS_ID_NOTIFY_DISPLAYID_CHANGE, + TRANS_ID_NOTIFY_DISPLAY_MOVE, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index 3efe0d072..ac2cb8c6f 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -57,6 +57,7 @@ public: WSError NotifyDialogStateChange(bool isForeground) override; WSError SetPipActionEvent(const std::string& action, int32_t status) override; WSError UpdateDisplayId(uint64_t displayId) override; + void NotifyDisplayMove(DisplayId from, DisplayId to) override; private: static inline BrokerDelegator delegator_; diff --git a/window_scene/session/container/include/zidl/session_stage_stub.h b/window_scene/session/container/include/zidl/session_stage_stub.h index 75a51ac92..6638c0270 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -62,6 +62,7 @@ private: int HandleNotifyDialogStateChange(MessageParcel& data, MessageParcel& reply); int HandleSetPipActionEvent(MessageParcel& data, MessageParcel& reply); int HandleUpdateDisplayId(MessageParcel& data, MessageParcel& reply); + int HandleNotifyDisplayMove(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H diff --git a/window_scene/session/container/include/zidl/window_event_channel_interface.h b/window_scene/session/container/include/zidl/window_event_channel_interface.h index 10628a317..46f9c8f0e 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_interface.h +++ b/window_scene/session/container/include/zidl/window_event_channel_interface.h @@ -40,7 +40,8 @@ public: // transfer sync key event for weather consumed virtual WSError TransferBackpressedEventForConsumed(bool& isConsumed) = 0; - virtual WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) = 0; + virtual WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent = false) = 0; virtual WSError TransferFocusActiveEvent(bool isFocusActive) = 0; virtual WSError TransferFocusState(bool focusState) = 0; virtual WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, @@ -53,6 +54,8 @@ public: Accessibility::AccessibilityElementInfo& info) = 0; virtual WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, int32_t action, int64_t baseParent) = 0; + virtual WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) = 0; }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_WINDOW_EVENT_CHANNEL_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/window_event_channel_proxy.h b/window_scene/session/container/include/zidl/window_event_channel_proxy.h index 538fbe2b8..f81bd1dc6 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_proxy.h +++ b/window_scene/session/container/include/zidl/window_event_channel_proxy.h @@ -34,7 +34,8 @@ public: WSError TransferBackpressedEventForConsumed(bool& isConsumed) override; WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; WSError TransferPointerEvent(const std::shared_ptr& pointerEvent) override; - WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) override; + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent = false) override; WSError TransferFocusActiveEvent(bool isFocusActive) override; WSError TransferFocusState(bool focusState) override; WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, @@ -47,6 +48,8 @@ public: Accessibility::AccessibilityElementInfo& info) override; WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, int32_t action, int64_t baseParent) override; + WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) override; private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/session/container/include/zidl/window_event_channel_stub.h b/window_scene/session/container/include/zidl/window_event_channel_stub.h index eb5cb45cd..ec3217352 100644 --- a/window_scene/session/container/include/zidl/window_event_channel_stub.h +++ b/window_scene/session/container/include/zidl/window_event_channel_stub.h @@ -46,6 +46,7 @@ private: int HandleTransferFindFocusedElementInfo(MessageParcel& data, MessageParcel& reply); int HandleTransferFocusMoveSearch(MessageParcel& data, MessageParcel& reply); int HandleTransferExecuteAction(MessageParcel& data, MessageParcel& reply); + int HandleTransferAccessibilityHoverEvent(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_WINDOW_EVENT_CHANNEL_STUB_H diff --git a/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h b/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h index f5b4ebdac..ca3528838 100644 --- a/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/window_event_ipc_interface_code.h @@ -32,8 +32,9 @@ enum class WindowEventInterfaceCode { TRANS_ID_TRANSFER_FOCUS_MOVE_SEARCH, TRANS_ID_TRANSFER_EXECUTE_ACTION, TRANS_ID_TRANSFER_CLEAR_FOCUS, + TRANS_ID_TRANSFER_ACCESSIBILITY_HOVER_EVENT, }; } // namespace Rosen } // namespace OHOS -#endif // WINDOW_EVENT_IPC_INTERFACE_CODE_H \ No newline at end of file +#endif // WINDOW_EVENT_IPC_INTERFACE_CODE_H diff --git a/window_scene/session/container/src/window_event_channel.cpp b/window_scene/session/container/src/window_event_channel.cpp index b96bde5bf..c92806613 100644 --- a/window_scene/session/container/src/window_event_channel.cpp +++ b/window_scene/session/container/src/window_event_channel.cpp @@ -79,7 +79,7 @@ WSError WindowEventChannel::TransferBackpressedEventForConsumed(bool& isConsumed } WSError WindowEventChannel::TransferKeyEventForConsumed( - const std::shared_ptr& keyEvent, bool& isConsumed) + const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent) { WLOGFD("WindowEventChannel receive key event"); if (!sessionStage_) { @@ -90,6 +90,12 @@ WSError WindowEventChannel::TransferKeyEventForConsumed( WLOGFE("keyEvent is nullptr"); return WSError::WS_ERROR_NULLPTR; } + if (isPreImeEvent) { + isConsumed = sessionStage_->NotifyOnKeyPreImeEvent(keyEvent); + TLOGI(WmsLogTag::WMS_EVENT, "TransferKeyEventForConsumed isConsumed = %{public}d", + static_cast(isConsumed)); + return WSError::WS_OK; + } DelayedSingleton::GetInstance()->SetSessionStage(keyEvent->GetId(), sessionStage_); sessionStage_->NotifyKeyEvent(keyEvent, isConsumed); keyEvent->MarkProcessed(); @@ -262,4 +268,14 @@ WSError WindowEventChannel::TransferExecuteAction(int64_t elementId, } return sessionStage_->NotifyExecuteAction(elementId, actionArguments, action, baseParent); } + +WSError WindowEventChannel::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, + int32_t eventType, int64_t timeMs) +{ + if (!sessionStage_) { + WLOGFE("session stage is null!"); + return WSError::WS_ERROR_NULLPTR; + } + return sessionStage_->NotifyAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index 0dbeffa26..e8fa024da 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -631,4 +631,31 @@ WSError SessionStageProxy::SetPipActionEvent(const std::string& action, int32_t } return WSError::WS_OK; } + +void SessionStageProxy::NotifyDisplayMove(DisplayId from, DisplayId to) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return; + } + + if (!data.WriteUint64(from)) { + WLOGFE("Write from id failed"); + return; + } + + if (!data.WriteUint64(to)) { + WLOGFE("Write to id failed"); + return; + } + + if (Remote()->SendRequest(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAY_MOVE), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest notify display move failed"); + return; + } +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index fd0f51c0e..619aa6122 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -77,6 +77,8 @@ const std::map SessionStageStub::stubFuncMap_{ &SessionStageStub::HandleSetPipActionEvent), std::make_pair(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAYID_CHANGE), &SessionStageStub::HandleUpdateDisplayId), + std::make_pair(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAY_MOVE), + &SessionStageStub::HandleNotifyDisplayMove), }; int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) @@ -151,7 +153,7 @@ int SessionStageStub::HandleNotifyDestroy(MessageParcel& data, MessageParcel& re int SessionStageStub::HandleNotifyCloseExistPipWindow(MessageParcel& data, MessageParcel& reply) { - WLOGFD("Notify Pip AlreadyExists"); + TLOGD(WmsLogTag::WMS_PIP, "Notify Pip AlreadyExists"); WSError errCode = NotifyCloseExistPipWindow(); reply.WriteUint32(static_cast(errCode)); return ERR_NONE; @@ -334,10 +336,10 @@ int SessionStageStub::HandleNotifyDialogStateChange(MessageParcel& data, Message int SessionStageStub::HandleSetPipActionEvent(MessageParcel& data, MessageParcel& reply) { - WLOGD("HandleSetPipActionEvent"); + TLOGD(WmsLogTag::WMS_PIP, "HandleSetPipActionEvent"); std::string action = data.ReadString(); if (action.empty()) { - WLOGFE("SessionStageStub pip action event is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "SessionStageStub pip action event is nullptr"); return ERR_INVALID_VALUE; } int32_t status; @@ -356,4 +358,13 @@ int SessionStageStub::HandleUpdateDisplayId(MessageParcel& data, MessageParcel& reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } + +int SessionStageStub::HandleNotifyDisplayMove(MessageParcel& data, MessageParcel& reply) +{ + WLOGD("HandleNotifyDisplayMove!"); + DisplayId from = static_cast(data.ReadUint64()); + DisplayId to = static_cast(data.ReadUint64()); + NotifyDisplayMove(from, to); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp b/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp index 4593dbcf5..aba341e1c 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_proxy.cpp @@ -47,7 +47,11 @@ WSError WindowEventChannelProxy::TransferKeyEvent(const std::shared_ptrSendRequest(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_KEY_EVENT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -103,7 +107,7 @@ WSError WindowEventChannelProxy::TransferBackpressedEventForConsumed(bool& isCon } WSError WindowEventChannelProxy::TransferKeyEventForConsumed( - const std::shared_ptr& keyEvent, bool& isConsumed) + const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent) { MessageParcel data; MessageParcel reply; @@ -117,7 +121,10 @@ WSError WindowEventChannelProxy::TransferKeyEventForConsumed( WLOGFE("Failed to write key event"); return WSError::WS_ERROR_IPC_FAILED; } - + if (!data.WriteBool(isPreImeEvent)) { + WLOGFE("Write bool failed"); + return WSError::WS_ERROR_IPC_FAILED; + } if (Remote()->SendRequest(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_KEY_EVENT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -374,4 +381,32 @@ WSError WindowEventChannelProxy::TransferExecuteAction(int64_t elementId, int32_t ret = reply.ReadInt32(); return static_cast(ret); } + +WSError WindowEventChannelProxy::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, + int32_t eventType, int64_t timeMs) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteFloat(pointX) || + !data.WriteFloat(pointY) || + !data.WriteInt32(sourceType) || + !data.WriteInt32(eventType) || + !data.WriteInt64(timeMs)) { + WLOGFE("Write TransferAccessibilityHoverEvent data failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (Remote()->SendRequest( + static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_ACCESSIBILITY_HOVER_EVENT), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + int32_t ret = reply.ReadInt32(); + return static_cast(ret); +} } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp index d18ddc173..6294195a2 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp @@ -52,6 +52,8 @@ const std::map WindowEventChannelStub::stu &WindowEventChannelStub::HandleTransferFocusMoveSearch), std::make_pair(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_EXECUTE_ACTION), &WindowEventChannelStub::HandleTransferExecuteAction), + std::make_pair(static_cast(WindowEventInterfaceCode::TRANS_ID_TRANSFER_ACCESSIBILITY_HOVER_EVENT), + &WindowEventChannelStub::HandleTransferAccessibilityHoverEvent), }; int WindowEventChannelStub::OnRemoteRequest(uint32_t code, MessageParcel &data, @@ -79,7 +81,7 @@ int WindowEventChannelStub::HandleTransferBackpressedEvent(MessageParcel& data, WSError errCode = TransferBackpressedEventForConsumed(isConsumed); reply.WriteBool(isConsumed); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -95,11 +97,12 @@ int WindowEventChannelStub::HandleTransferKeyEvent(MessageParcel& data, MessageP WLOGFE("Read Key Event failed"); return ERR_INVALID_DATA; } + bool isPreImeEvent = data.ReadBool(); bool isConsumed = false; - WSError errCode = TransferKeyEventForConsumed(keyEvent, isConsumed); + WSError errCode = TransferKeyEventForConsumed(keyEvent, isConsumed, isPreImeEvent); reply.WriteBool(isConsumed); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -116,7 +119,7 @@ int WindowEventChannelStub::HandleTransferPointerEvent(MessageParcel& data, Mess return ERR_INVALID_DATA; } WSError errCode = TransferPointerEvent(pointerEvent); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -124,7 +127,7 @@ int WindowEventChannelStub::HandleTransferFocusActiveEvent(MessageParcel& data, { bool isFocusActive = data.ReadBool(); WSError errCode = TransferFocusActiveEvent(isFocusActive); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -132,7 +135,7 @@ int WindowEventChannelStub::HandleTransferFocusStateEvent(MessageParcel& data, M { bool focusState = data.ReadBool(); WSError errCode = TransferFocusState(focusState); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } @@ -156,8 +159,8 @@ int WindowEventChannelStub::HandleTransferSearchElementInfo(MessageParcel& data, std::list infos; WSError errCode = TransferSearchElementInfo(elementId, mode, baseParent, infos); if (errCode != WSError::WS_OK) { - WLOGFE("Failed to TransferSearchElementInfo:%{public}d", static_cast(errCode)); - return static_cast(errCode); + WLOGFE("Failed to TransferSearchElementInfo:%{public}d", static_cast(errCode)); + return static_cast(errCode); } int64_t count = static_cast(infos.size()); if (!reply.WriteInt64(count)) { @@ -194,8 +197,8 @@ int WindowEventChannelStub::HandleTransferSearchElementInfosByText(MessageParcel std::list infos; WSError errCode = TransferSearchElementInfosByText(elementId, text, baseParent, infos); if (errCode != WSError::WS_OK) { - WLOGFE("Failed to HandleTransferSearchElementInfosByText:%{public}d", static_cast(errCode)); - return static_cast(errCode); + WLOGFE("Failed to HandleTransferSearchElementInfosByText:%{public}d", static_cast(errCode)); + return static_cast(errCode); } int64_t count = static_cast(infos.size()); if (!reply.WriteInt64(count)) { @@ -232,8 +235,8 @@ int WindowEventChannelStub::HandleTransferFindFocusedElementInfo(MessageParcel& Accessibility::AccessibilityElementInfo info; WSError errCode = TransferFindFocusedElementInfo(elementId, focusType, baseParent, info); if (errCode != WSError::WS_OK) { - WLOGFE("Failed to TransferFindFocusedElementInfo:%{public}d", static_cast(errCode)); - return static_cast(errCode); + WLOGFE("Failed to TransferFindFocusedElementInfo:%{public}d", static_cast(errCode)); + return static_cast(errCode); } Accessibility::AccessibilityElementInfoParcel infoParcel(info); if (!reply.WriteParcelable(&infoParcel)) { @@ -263,8 +266,8 @@ int WindowEventChannelStub::HandleTransferFocusMoveSearch(MessageParcel& data, M Accessibility::AccessibilityElementInfo info; WSError errCode = TransferFocusMoveSearch(elementId, direction, baseParent, info); if (errCode != WSError::WS_OK) { - WLOGFE("Failed to TransferFocusMoveSearch:%{public}d", static_cast(errCode)); - return static_cast(errCode); + WLOGFE("Failed to TransferFocusMoveSearch:%{public}d", static_cast(errCode)); + return static_cast(errCode); } Accessibility::AccessibilityElementInfoParcel infoParcel(info); if (!reply.WriteParcelable(&infoParcel)) { @@ -314,7 +317,27 @@ int WindowEventChannelStub::HandleTransferExecuteAction(MessageParcel& data, Mes return ERR_INVALID_DATA; } WSError errCode = TransferExecuteAction(elementId, actionArguments, action, baseParent); - reply.WriteUint32(static_cast(errCode)); + reply.WriteInt32(static_cast(errCode)); + return ERR_NONE; +} + +int WindowEventChannelStub::HandleTransferAccessibilityHoverEvent(MessageParcel& data, MessageParcel& reply) +{ + float pointX = 0; + float pointY = 0; + int32_t sourceType = 0; + int32_t eventType = 0; + int64_t timeMs = 0; + if (!data.ReadFloat(pointX) || + !data.ReadFloat(pointY) || + !data.ReadInt32(sourceType) || + !data.ReadInt32(eventType) || + !data.ReadInt64(timeMs)) { + WLOGFE("Read HandleTransferAccessibilityHoverEvent data failed!"); + return ERR_INVALID_DATA; + }; + WSError errCode = TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); + reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } } diff --git a/window_scene/session/host/include/scene_persistent_storage.h b/window_scene/session/host/include/scene_persistent_storage.h index 785a8e7ed..ae844605c 100644 --- a/window_scene/session/host/include/scene_persistent_storage.h +++ b/window_scene/session/host/include/scene_persistent_storage.h @@ -29,7 +29,6 @@ enum class ScenePersistentStorageType : uint32_t { UKNOWN = 0, ASPECT_RATIO, MAXIMIZE_STATE, - PIP_INFO, }; class ScenePersistentStorage { @@ -60,12 +59,6 @@ public: key.c_str(), static_cast(value)); break; } - case ScenePersistentStorageType::PIP_INFO: { - pref->PutInt(key, value); - WLOGD("[ScenePersistentStorage] Insert PicutreInPicture info, key %{public}s, value %{public}d", - key.c_str(), static_cast(value)); - break; - } default: WLOGW("[ScenePersistentStorage] Unknown storage type!"); } @@ -93,12 +86,6 @@ public: key.c_str(), static_cast(value)); break; } - case ScenePersistentStorageType::PIP_INFO: { - value = pref->GetInt(key); - WLOGD("[ScenePersistentStorage] Get PicutreInPicture info, key: %{public}s, value:%{public}d", - key.c_str(), static_cast(value)); - break; - } default: WLOGW("[ScenePersistentStorage] Unknown storage type!"); } diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index ec4dda36b..76c9ae692 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -60,6 +60,7 @@ using ClearCallbackMapFunc = std::function; using OnOutsideDownEvent = std::function; using NotifyAddOrRemoveSecureSessionFunc = std::function& sceneSession)>; +using NotifyLandscapeMultiWindowSessionFunc = std::function; class SceneSession : public Session { public: // callback for notify SceneSessionManager @@ -73,7 +74,6 @@ public: NotifyWindowPidChangeCallback onWindowInputPidChangeCallback_; NotifySessionTouchOutsideCallback onSessionTouchOutside_; GetAINavigationBarArea onGetAINavigationBarArea_; - RecoveryCallback onRecoveryPullPiPMainWindow_; OnOutsideDownEvent onOutsideDownEvent_; NotifyAddOrRemoveSecureSessionFunc onHandleSecureSessionShouldHide_; }; @@ -95,6 +95,7 @@ public: NotifyTouchOutsideFunc OnTouchOutside_; ClearCallbackMapFunc clearCallbackFunc_; NotifyPrepareClosePiPSessionFunc onPrepareClosePiPSession_; + NotifyLandscapeMultiWindowSessionFunc onSetLandscapeMultiWindowFunc_; }; // func for change window scene pattern property @@ -146,13 +147,13 @@ public: WSError SetTextFieldAvoidInfo(double textFieldPositionY, double textFieldHeight) override; WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) override; void NotifyPiPWindowPrepareClose() override; - WSError RecoveryPullPiPMainWindow(int32_t persistentId, const Rect& rect) override; void SetScale(float scaleX, float scaleY, float pivotX, float pivotY) override; void RequestHideKeyboard(bool isAppColdStart = false); WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; WSError SendPointEventForMoveDrag(const std::shared_ptr& pointerEvent) override; void NotifyOutsideDownEvent(const std::shared_ptr& pointerEvent); void SetForegroundInteractiveStatus(bool interactive) override; + WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; WSError SetKeepScreenOn(bool keepScreenOn); void SetParentPersistentId(int32_t parentId); @@ -216,7 +217,7 @@ public: void RegisterSessionChangeCallback(const sptr& sessionChangeCallback); void ClearSpecificSessionCbMap(); void SendPointerEventToUI(std::shared_ptr pointerEvent); - void SendKeyEventToUI(std::shared_ptr keyEvent); + bool SendKeyEventToUI(std::shared_ptr keyEvent, bool isPreImeEvent = false); bool IsStartMoving() const; void SetIsStartMoving(const bool startMoving); bool ShouldHideNonSecureWindows() const; @@ -227,6 +228,7 @@ public: bool IsExtWindowHasWaterMarkFlag(); void RomoveExtWindowFlags(int32_t extPersistentId); void ClearExtWindowFlags(); + void NotifyDisplayMove(DisplayId from, DisplayId to); void SetSessionState(SessionState state) override; void UpdateSessionState(SessionState state) override; @@ -240,6 +242,10 @@ public: static MaximizeMode maximizeMode_; static std::map windowDragHotAreaMap_; + WSRect callingWindowRestoringRect_ = {0, 0, 0, 0}; + WSRect callingWindowNewRect_ = {0, 0, 0, 0}; + bool needUpdateSessionRect_ = false; + protected: void NotifyIsCustomAnimationPlaying(bool isPlaying); void SetMoveDragCallback(); @@ -277,12 +283,7 @@ private: void SetSurfaceBounds(const WSRect &rect); void UpdateWinRectForSystemBar(WSRect& rect); bool UpdateInputMethodSessionRect(const WSRect& rect, WSRect& newWinRect, WSRect& newRequestRect); - void OnPiPMoveCallback(const WSRect& rect, const SizeChangeReason& reason); - bool InitPiPRectInfo(); - void ClearPiPRectPivotInfo(); - void SavePiPRectInfo(); - void GetNewPiPRect(const uint32_t displayWidth, const uint32_t displayHeight, Rect& rect); - void ProcessUpdatePiPRect(SizeChangeReason reason); + void HandleCastScreenConnection(SessionInfo& info, sptr session); NotifySessionRectChangeFunc sessionRectChangeFunc_; static wptr enterSession_; @@ -293,7 +294,6 @@ private: WSRect lastSafeRect = { 0, 0, 0, 0 }; std::vector> subSession_; bool needDefaultAnimationFlag_ = true; - PiPRectInfo pipRectInfo_; PiPTemplateInfo pipTemplateInfo_; std::atomic_bool isStartMoving_ { false }; std::atomic_bool isVisibleForAccessibility_ { true }; @@ -301,7 +301,7 @@ private: std::set secureExtSessionSet_; std::shared_mutex extWindowFlagsMapMutex_; std::map extWindowFlagsMap_; - + }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H \ No newline at end of file diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 48fbd5275..799a7bacb 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -76,7 +76,8 @@ using GetStateFromManagerFunc = std::function; using NotifySessionInfoLockedStateChangeFunc = std::function; using NotifySystemSessionPointerEventFunc = std::function pointerEvent)>; using NotifySessionInfoChangeNotifyManagerFunc = std::function; -using NotifySystemSessionKeyEventFunc = std::function keyEvent)>; +using NotifySystemSessionKeyEventFunc = std::function keyEvent, + bool isPreImeEvent)>; class ILifecycleListener { public: @@ -86,6 +87,7 @@ public: virtual void OnBackground() = 0; virtual void OnDisconnect() = 0; virtual void OnExtensionDied() = 0; + virtual void OnExtensionTimeout(int32_t errorCode) = 0; virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) = 0; }; @@ -126,6 +128,7 @@ public: void NotifyBackground(); void NotifyDisconnect(); void NotifyExtensionDied() override; + void NotifyExtensionTimeout(int32_t errorCode) override; void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; @@ -141,13 +144,17 @@ public: Accessibility::AccessibilityElementInfo& info); virtual WSError TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent, Accessibility::AccessibilityElementInfo& info); + virtual WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, + int32_t action, int64_t baseParent); + WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs); + virtual WSError NotifyClientToUpdateRect(std::shared_ptr rsTransaction) { return WSError::WS_OK; } WSError TransferBackPressedEventForConsumed(bool& isConsumed); - WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed); + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent = false); WSError TransferFocusActiveEvent(bool isFocusActive); WSError TransferFocusStateEvent(bool focusState); - virtual WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, - int32_t action, int64_t baseParent); virtual WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) { return WSError::WS_OK; } int32_t GetPersistentId() const; diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index 30179961f..fe0bf0b62 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -62,6 +62,7 @@ public: virtual WSError PendingSessionActivation(const sptr abilitySessionInfo) { return WSError::WS_OK; } virtual WSError TerminateSession(const sptr abilitySessionInfo) { return WSError::WS_OK; } + virtual WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) { return WSError::WS_OK; } virtual WSError ChangeSessionVisibilityWithStatusBar(const sptr abilitySessionInfo, bool isShow) { return WSError::WS_OK; } virtual WSError NotifySessionException( @@ -78,6 +79,7 @@ public: } virtual void NotifyRemoteReady() {} virtual void NotifyExtensionDied() {} + virtual void NotifyExtensionTimeout(int32_t errorCode) {} virtual void TriggerBindModalUIExtension() {} virtual void NotifySyncOn() {} virtual void NotifyAsyncOn() {} @@ -88,7 +90,6 @@ public: virtual void NotifyPiPWindowPrepareClose() {} virtual WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) { return WSError::WS_OK; } - virtual WSError RecoveryPullPiPMainWindow(int32_t persistentId, const Rect& rect) { return WSError::WS_OK; } virtual WSError ProcessPointDownSession(int32_t posX, int32_t posY) { return WSError::WS_OK; } virtual WSError SendPointEventForMoveDrag(const std::shared_ptr& pointerEvent) { diff --git a/window_scene/session/host/include/zidl/session_ipc_interface_code.h b/window_scene/session/host/include/zidl/session_ipc_interface_code.h index f5cc8d8f0..147582333 100644 --- a/window_scene/session/host/include/zidl/session_ipc_interface_code.h +++ b/window_scene/session/host/include/zidl/session_ipc_interface_code.h @@ -50,6 +50,7 @@ enum class SessionInterfaceCode { TRANS_ID_RAISE_APP_MAIN_WINDOW, TRANS_ID_PROCESS_POINT_DOWN_SESSION, TRANS_ID_SEND_POINTEREVENT_FOR_MOVE_DRAG, + TRANS_ID_SET_LANDSCAPE_MULTI_WINDOW, // Extension TRANS_ID_TRANSFER_ABILITY_RESULT = 500, @@ -60,11 +61,11 @@ enum class SessionInterfaceCode { TRANS_ID_NOTIFY_SYNC_ON, TRANS_ID_NOTIFY_REPORT_ACCESSIBILITY_EVENT, TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION, + TRANS_ID_NOTIFY_EXTENSION_TIMEOUT, //PictureInPicture TRANS_ID_NOTIFY_PIP_WINDOW_PREPARE_CLOSE = 800, TRANS_ID_UPDATE_PIP_RECT, - TRANS_ID_RECOVERY_PULL_PIP_MAIN_WINDOW, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index 63800c72f..015c7496d 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -55,6 +55,7 @@ public: WSError SetSessionProperty(const sptr& property) override; WSError SetAspectRatio(float ratio) override; WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) override; + WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override; WSError RaiseAboveTarget(int32_t subWindowId) override; WSError RaiseAppMainWindowToTop() override; @@ -67,11 +68,11 @@ public: void NotifySyncOn() override; void NotifyAsyncOn() override; void NotifyExtensionDied() override; + void NotifyExtensionTimeout(int32_t errorCode) override; void TriggerBindModalUIExtension() override; void NotifyPiPWindowPrepareClose() override; WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) override; - WSError RecoveryPullPiPMainWindow(int32_t persistentId, const Rect& rect) override; WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; WSError SendPointEventForMoveDrag(const std::shared_ptr& pointerEvent) override; private: diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 21c84ef29..03ad76f4f 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -64,6 +64,7 @@ private: int HandleSessionException(MessageParcel& data, MessageParcel& reply); int HandleProcessPointDownSession(MessageParcel& data, MessageParcel& reply); int HandleSendPointerEvenForMoveDrag(MessageParcel& data, MessageParcel& reply); + int HandleSetLandscapeMultiWindow(MessageParcel& data, MessageParcel& reply); // extension extension int HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply); @@ -72,6 +73,7 @@ private: int HandleNotifySyncOn(MessageParcel& data, MessageParcel& reply); int HandleNotifyAsyncOn(MessageParcel& data, MessageParcel& reply); int HandleNotifyExtensionDied(MessageParcel& data, MessageParcel& reply); + int HandleNotifyExtensionTimeout(MessageParcel& data, MessageParcel& reply); int HandleTriggerBindModalUIExtension(MessageParcel& data, MessageParcel& reply); int HandleTransferAccessibilityEvent(MessageParcel& data, MessageParcel& reply); static const std::map stubFuncMap_; @@ -79,7 +81,6 @@ private: // PictureInPicture int HandleNotifyPiPWindowPrepareClose(MessageParcel& data, MessageParcel& reply); int HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply); - int HandleRecoveryPullPiPMainWindow(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/scene_persistent_storage.cpp b/window_scene/session/host/src/scene_persistent_storage.cpp index 70dad6e16..759ec3786 100644 --- a/window_scene/session/host/src/scene_persistent_storage.cpp +++ b/window_scene/session/host/src/scene_persistent_storage.cpp @@ -74,7 +74,6 @@ void ScenePersistentStorage::InitDir(std::string dir) storagePath_ = { { ScenePersistentStorageType::ASPECT_RATIO, saveDir_ + "/session_window_aspect_ratio" }, { ScenePersistentStorageType::MAXIMIZE_STATE, saveDir_ + "/session_window_maximize_state" }, - { ScenePersistentStorageType::PIP_INFO, saveDir_ + "/session_pip_window_location_info" }, }; } diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 5216f7e57..378d8092d 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -31,7 +31,8 @@ #include "common/include/session_permission.h" #include "interfaces/include/ws_common.h" #include "pixel_map.h" -#include "pip_util.h" +#include "session/screen/include/screen_session.h" +#include "screen_session_manager/include/screen_session_manager_client.h" #include "session/host/include/scene_persistent_storage.h" #include "session/host/include/session_utils.h" #include "display_manager.h" @@ -40,8 +41,9 @@ #include "window_manager_hilog.h" #include "wm_math.h" #include +#include "screen_manager.h" +#include "screen.h" #include "singleton_container.h" -#include "pip_report.h" namespace OHOS::Rosen { namespace { @@ -231,10 +233,6 @@ WSError SceneSession::Disconnect(bool isFromClient) session->snapshot_.reset(); } } - if (WindowHelper::IsPipWindow(session->GetWindowType()) && - session->GetWindowMode() == WindowMode::WINDOW_MODE_PIP) { - session->SavePiPRectInfo(); - } session->Session::Disconnect(isFromClient); session->isTerminating = false; if (session->specificCallback_ != nullptr) { @@ -652,15 +650,16 @@ WSError SceneSession::BindDialogSessionTarget(const sptr& sceneSes WSError SceneSession::SetSystemBarProperty(WindowType type, SystemBarProperty systemBarProperty) { + TLOGD(WmsLogTag::WMS_IMMS, "persistentId():%{public}u type:%{public}u" + "enable:%{public}u bgColor:%{public}x Color:%{public}x", + GetPersistentId(), static_cast(type), + systemBarProperty.enable_, systemBarProperty.backgroundColor_, systemBarProperty.contentColor_); auto property = GetSessionProperty(); if (property == nullptr) { + TLOGE(WmsLogTag::WMS_DIALOG, "property is null"); return WSError::WS_ERROR_NULLPTR; } property->SetSystemBarProperty(type, systemBarProperty); - TLOGI(WmsLogTag::WMS_IMMS, "SceneSession SetSystemBarProperty persistentId():%{public}u type:%{public}u" - "enable:%{public}u bgColor:%{public}x Color:%{public}x", - GetPersistentId(), static_cast(type), - systemBarProperty.enable_, systemBarProperty.backgroundColor_, systemBarProperty.contentColor_); if (sessionChangeCallback_ != nullptr && sessionChangeCallback_->OnSystemBarPropertyChange_) { sessionChangeCallback_->OnSystemBarPropertyChange_(property->GetSystemBarProperty()); } @@ -776,6 +775,10 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) if (Session::GetFloatingScale() <= miniScale) { return; } + if (Session::GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING && + rect.height_ < rect.width_) { + return; + } float vpr = 3.5f; // 3.5f: default pixel ratio auto display = DisplayManager::GetInstance().GetDefaultDisplay(); if (display) { @@ -838,12 +841,12 @@ void SceneSession::GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea) } sptr cutoutInfo = display->GetCutoutInfo(); if (cutoutInfo == nullptr) { - TLOGI(WmsLogTag::WMS_IMMS, "GetCutoutAvoidArea There is no CutoutInfo"); + TLOGI(WmsLogTag::WMS_IMMS, "There is no CutoutInfo"); return; } std::vector cutoutAreas = cutoutInfo->GetBoundingRects(); if (cutoutAreas.empty()) { - TLOGI(WmsLogTag::WMS_IMMS, "GetCutoutAvoidArea There is no cutoutAreas"); + TLOGI(WmsLogTag::WMS_IMMS, "There is no cutoutAreas"); return; } for (auto& cutoutArea : cutoutAreas) { @@ -885,20 +888,23 @@ AvoidArea SceneSession::GetAvoidAreaByType(AvoidAreaType type) session->GetSystemAvoidArea(rect, avoidArea); return avoidArea; } - case AvoidAreaType::TYPE_KEYBOARD: { - session->GetKeyboardAvoidArea(rect, avoidArea); - return avoidArea; - } case AvoidAreaType::TYPE_CUTOUT: { session->GetCutoutAvoidArea(rect, avoidArea); return avoidArea; } + case AvoidAreaType::TYPE_SYSTEM_GESTURE: { + return avoidArea; + } + case AvoidAreaType::TYPE_KEYBOARD: { + session->GetKeyboardAvoidArea(rect, avoidArea); + return avoidArea; + } case AvoidAreaType::TYPE_NAVIGATION_INDICATOR: { session->GetAINavigationBarArea(rect, avoidArea); return avoidArea; } default: { - TLOGI(WmsLogTag::WMS_IMMS, "cannot find avoidAreaType:%{public}u, id:%{public}d", + TLOGE(WmsLogTag::WMS_IMMS, "cannot find avoidAreaType:%{public}u, id:%{public}d", type, session->GetPersistentId()); return avoidArea; } @@ -917,7 +923,7 @@ WSError SceneSession::UpdateAvoidArea(const sptr& avoidArea, AvoidAre WSError SceneSession::SetPipActionEvent(const std::string& action, int32_t status) { - WLOGFI("action: %{public}s, status: %{public}d", action.c_str(), status); + TLOGI(WmsLogTag::WMS_PIP, "action: %{public}s, status: %{public}d", action.c_str(), status); if (GetWindowType() != WindowType::WINDOW_TYPE_PIP || GetWindowMode() != WindowMode::WINDOW_MODE_PIP) { return WSError::WS_ERROR_INVALID_TYPE; } @@ -1137,18 +1143,6 @@ WSError SceneSession::TransferPointerEvent(const std::shared_ptrGetWindowMode() == WindowMode::WINDOW_MODE_PIP && - WindowHelper::IsPipWindow(property->GetWindowType())) { - if (!moveDragController_) { - WLOGFE("moveDragController is null"); - return Session::TransferPointerEvent(pointerEvent, needNotifyClient); - } - if (moveDragController_->ConsumeMoveEvent(pointerEvent, winRect_)) { - pointerEvent->MarkProcessed(); - return WSError::WS_OK; - } - } - bool raiseEnabled = property->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG && property->GetRaiseEnabled() && (action == MMI::PointerEvent::POINTER_ACTION_DOWN || action == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN); if (raiseEnabled) { @@ -1358,7 +1352,6 @@ void SceneSession::OnMoveDragCallback(const SizeChangeReason& reason) HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::OnMoveDragCallback [%d, %d, %u, %u]", rect.posX_, rect.posY_, rect.width_, rect.height_); SetSurfaceBounds(rect); - OnPiPMoveCallback(rect, reason); if (reason != SizeChangeReason::MOVE) { UpdateSizeChangeReason(reason); UpdateRect(rect, reason); @@ -1409,7 +1402,7 @@ void SceneSession::SetSurfaceBounds(const WSRect& rect) surfaceNode_->SetBounds(0, 0, rect.width_, rect.height_); surfaceNode_->SetFrame(0, 0, rect.width_, rect.height_); } else if (WindowHelper::IsPipWindow(GetWindowType()) && surfaceNode_) { - WLOGFD("PipWindow setSurfaceBounds"); + TLOGD(WmsLogTag::WMS_PIP, "PipWindow setSurfaceBounds"); surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_); surfaceNode_->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_); } else if (WindowHelper::IsSubWindow(GetWindowType()) && surfaceNode_) { @@ -1938,12 +1931,6 @@ WSError SceneSession::ChangeSessionVisibilityWithStatusBar( if (session->changeSessionVisibilityWithStatusBarFunc_) { session->changeSessionVisibilityWithStatusBarFunc_(info, visible); } - SessionState oldState = session->GetSessionState(); - SessionState newState = visible == false ? SessionState::STATE_BACKGROUND : SessionState::STATE_FOREGROUND; - if (oldState != newState) { - session->SetSessionState(newState); - session->NotifySessionStateChange(newState); - } return WSError::WS_OK; }; @@ -2002,6 +1989,7 @@ WSError SceneSession::PendingSessionActivation(const sptr ab ", windowMode: %{public}d, caller persistentId: %{public}d", info.callState_, info.persistentId_, info.callingTokenId_, info.uiAbilityId_, info.windowMode, info.callerPersistentId_); + session->HandleCastScreenConnection(info, session); if (session->pendingSessionActivationFunc_) { session->pendingSessionActivationFunc_(info); } @@ -2011,6 +1999,32 @@ WSError SceneSession::PendingSessionActivation(const sptr ab return WSError::WS_OK; } +void SceneSession::HandleCastScreenConnection(SessionInfo& info, sptr session) +{ + ScreenId defScreenId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId(); + if (defScreenId == info.screenId_) { + return; + } + auto flag = Rosen::ScreenManager::GetInstance().GetVirtualScreenFlag(info.screenId_); + if (flag != VirtualScreenFlag::CAST) { + return; + } + TLOGI(WmsLogTag::WMS_LIFE, "Get exist session state :%{public}d persistentId:%{public}d", + session->GetSessionState(), info.callerPersistentId_); + if (session->GetSessionState() != SessionState::STATE_FOREGROUND && + session->GetSessionState() != SessionState::STATE_ACTIVE) { + TLOGI(WmsLogTag::WMS_LIFE, "Get exist session state is not foreground"); + return; + } + info.isCastSession_ = true; + std::vector mirrorIds { info.screenId_ }; + Rosen::DMError ret = Rosen::ScreenManager::GetInstance().MakeUniqueScreen(mirrorIds); + if (ret != Rosen::DMError::DM_OK) { + TLOGE(WmsLogTag::WMS_LIFE, "MakeUniqueScreen failed,ret: %{public}d", ret); + return; + } +} + WSError SceneSession::TerminateSession(const sptr abilitySessionInfo) { auto task = [weakThis = wptr(this), abilitySessionInfo]() { @@ -2151,37 +2165,41 @@ bool SceneSession::RemoveSubSession(int32_t persistentId) void SceneSession::NotifyPiPWindowPrepareClose() { - WLOGFD("NotifyPiPWindowPrepareClose"); + TLOGD(WmsLogTag::WMS_PIP, "NotifyPiPWindowPrepareClose"); auto task = [weakThis = wptr(this)]() { auto session = weakThis.promote(); if (!session) { - WLOGFE("session is null"); + TLOGE(WmsLogTag::WMS_PIP, "session is null"); return; } if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onPrepareClosePiPSession_) { session->sessionChangeCallback_->onPrepareClosePiPSession_(); } - WLOGFD("NotifyPiPWindowPrepareClose, id: %{public}d", session->GetPersistentId()); + TLOGD(WmsLogTag::WMS_PIP, "NotifyPiPWindowPrepareClose, id: %{public}d", session->GetPersistentId()); return; }; PostTask(task, "NotifyPiPWindowPrepareClose"); } -WSError SceneSession::RecoveryPullPiPMainWindow(int32_t persistentId, const Rect& rect) +WSError SceneSession::SetLandscapeMultiWindow(bool isLandscapeMultiWindow) { - WLOGFD("NotifyRecoveryPullPiPMainWindow"); - auto task = [weakThis = wptr(this), persistentId, rect]() { + WLOGFD("NotifySetLandscapeMultiWindow"); + auto task = [weakThis = wptr(this), isLandscapeMultiWindow]() { auto session = weakThis.promote(); if (!session) { WLOGFE("session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } - if (session->specificCallback_ != nullptr) { - session->specificCallback_->onRecoveryPullPiPMainWindow_(persistentId, rect); + if (session->sessionChangeCallback_ && + session->sessionChangeCallback_->onSetLandscapeMultiWindowFunc_) { + session->sessionChangeCallback_->onSetLandscapeMultiWindowFunc_( + isLandscapeMultiWindow); } + WLOGFD("NotifySetLandscapeMultiWindow, id: %{public}d, isLandscapeMultiWindow: %{public}u", + session->GetPersistentId(), isLandscapeMultiWindow); return WSError::WS_OK; }; - PostTask(task, "RecoveryPullPiPMainWindow"); + PostTask(task, "NotifySetLandscapeMultiWindow"); return WSError::WS_OK; } @@ -2231,127 +2249,6 @@ WSError SceneSession::SetTextFieldAvoidInfo(double textFieldPositionY, double te return WSError::WS_OK; } -void SceneSession::OnPiPMoveCallback(const WSRect& rect, const SizeChangeReason& reason) -{ - if (!WindowHelper::IsPipWindow(GetWindowType())) { - return; - } - if (reason == SizeChangeReason::MOVE) { - NotifySessionRectChange(rect, reason); - } - if (reason == SizeChangeReason::DRAG_END) { - ClearPiPRectPivotInfo(); - ScenePersistentStorage::Insert("pip_window_pos_x", rect.posX_, ScenePersistentStorageType::PIP_INFO); - ScenePersistentStorage::Insert("pip_window_pos_y", rect.posY_, ScenePersistentStorageType::PIP_INFO); - } -} - -bool SceneSession::InitPiPRectInfo() -{ - auto requestRect = GetSessionRequestRect(); - if (requestRect.width_ == 0 || requestRect.height_ == 0) { - return false; - } - ClearPiPRectPivotInfo(); - pipRectInfo_.originWidth_ = requestRect.width_; - pipRectInfo_.originHeight_ = requestRect.height_; - int32_t level = 0; - ScenePersistentStorage::Get("pip_window_level", level, ScenePersistentStorageType::PIP_INFO); - pipRectInfo_.level_ = static_cast(level); - return true; -} - -void SceneSession::ClearPiPRectPivotInfo() -{ - pipRectInfo_.xPivot_ = PiPScalePivot::UNDEFINED; - pipRectInfo_.yPivot_ = PiPScalePivot::UNDEFINED; -} - -void SceneSession::SavePiPRectInfo() -{ - ScenePersistentStorage::Insert("pip_window_level", static_cast(pipRectInfo_.level_), - ScenePersistentStorageType::PIP_INFO); -} - -void SceneSession::GetNewPiPRect(const uint32_t displayWidth, const uint32_t displayHeight, Rect& rect) -{ - auto display = DisplayManager::GetInstance().GetDefaultDisplay(); - if (!display) { - WLOGFE("cannot find display"); - return; - } - Rotation rotation = display->GetRotation(); - bool isLandscape = rotation == Rotation::ROTATION_90 || rotation == Rotation::ROTATION_270; - PiPUtil::GetRectByScale(displayWidth, displayHeight, pipRectInfo_.level_, rect, isLandscape); - WLOGFD("scale rect = (%{public}d, %{public}d, %{public}d, %{public}d)", - rect.posX_, rect.posY_, rect.width_, rect.height_); - auto sessionRect = GetSessionRect(); - WLOGFD("session rect = (%{public}d, %{public}d, %{public}d, %{public}d)", - sessionRect.posX_, sessionRect.posY_, sessionRect.width_, sessionRect.height_); - bool isMoveOrDrag = moveDragController_ && - (moveDragController_->GetStartDragFlag() || moveDragController_->GetStartMoveFlag()); - if (sessionRect.width_ != 0 && sessionRect.height_ != 0 && !isMoveOrDrag) { - if (pipRectInfo_.xPivot_ == PiPScalePivot::UNDEFINED || pipRectInfo_.yPivot_ == PiPScalePivot::UNDEFINED) { - // If no anchor, create anchor - PiPUtil::UpdateRectPivot(sessionRect.posX_, sessionRect.width_, displayWidth, pipRectInfo_.xPivot_); - PiPUtil::UpdateRectPivot(sessionRect.posY_, sessionRect.height_, displayHeight, pipRectInfo_.yPivot_); - } - PiPUtil::GetRectByPivot(rect.posX_, sessionRect.width_, rect.width_, displayWidth, pipRectInfo_.xPivot_); - PiPUtil::GetRectByPivot(rect.posY_, sessionRect.height_, rect.height_, displayHeight, pipRectInfo_.yPivot_); - WLOGFD("pivot rect = (%{public}d, %{public}d, %{public}d, %{public}d)", - rect.posX_, rect.posY_, rect.width_, rect.height_); - } - PiPUtil::GetValidRect(displayWidth, displayHeight, rect); - WLOGFD("valid rect = (%{public}d, %{public}d, %{public}d, %{public}d)", - rect.posX_, rect.posY_, rect.width_, rect.height_); -} - -void SceneSession::ProcessUpdatePiPRect(SizeChangeReason reason) -{ - if (!WindowHelper::IsPipWindow(GetWindowType())) { - WLOGFW("Session is not PiP type!"); - return; - } - auto display = DisplayManager::GetInstance().GetDefaultDisplay(); - if (!display) { - WLOGFE("can't find display info"); - return; - } - uint32_t displayWidth = static_cast(display->GetWidth()); - uint32_t displayHeight = static_cast(display->GetHeight()); - float displayVpr = display->GetVirtualPixelRatio(); - if (displayVpr < 0.0f) { - displayVpr = 1.5f; - } - PiPUtil::SetDisplayVpr(displayVpr); - - // default pos of phone is the right top - Rect rect = { 0, 0, pipRectInfo_.originWidth_, pipRectInfo_.originHeight_ }; - if (reason != SizeChangeReason::ROTATION) { - ScenePersistentStorage::Get("pip_window_pos_x", rect.posX_, ScenePersistentStorageType::PIP_INFO); - ScenePersistentStorage::Get("pip_window_pos_y", rect.posY_, ScenePersistentStorageType::PIP_INFO); - } - if (rect.posX_ == 0) { - rect.posX_ = displayWidth; - } - WLOGFD("window rect: (%{public}d, %{public}d, %{public}u, %{public}u)", - rect.posX_, rect.posY_, rect.width_, rect.height_); - - GetNewPiPRect(displayWidth, displayHeight, rect); - WLOGFD("window new rect: (%{public}d, %{public}d, %{public}u, %{public}u)", - rect.posX_, rect.posY_, rect.width_, rect.height_); - ScenePersistentStorage::Insert("pip_window_pos_x", rect.posX_, ScenePersistentStorageType::PIP_INFO); - ScenePersistentStorage::Insert("pip_window_pos_y", rect.posY_, ScenePersistentStorageType::PIP_INFO); - - WSRect newRect = SessionHelper::TransferToWSRect(rect); - SetSessionRect(newRect); - SetSessionRequestRect(newRect); - Session::UpdateRect(newRect, reason); - NotifySessionRectChange(newRect, reason); - SingletonContainer::Get() - .ReportPiPResize(static_cast(pipRectInfo_.level_), newRect.width_, newRect.height_); -} - WSError SceneSession::UpdatePiPRect(const Rect& rect, SizeChangeReason reason) { if (!WindowHelper::IsPipWindow(GetWindowType())) { @@ -2360,7 +2257,7 @@ WSError SceneSession::UpdatePiPRect(const Rect& rect, SizeChangeReason reason) auto task = [weakThis = wptr(this), rect, reason]() { auto session = weakThis.promote(); if (!session || session->isTerminating) { - WLOGE("SceneSession::UpdatePiPRect session is null or is terminating"); + TLOGE(WmsLogTag::WMS_PIP, "SceneSession::UpdatePiPRect session is null or is terminating"); return WSError::WS_ERROR_INVALID_OPERATION; } WSRect wsRect = SessionHelper::TransferToWSRect(rect); @@ -2382,12 +2279,13 @@ void SceneSession::SendPointerEventToUI(std::shared_ptr point } } -void SceneSession::SendKeyEventToUI(std::shared_ptr keyEvent) +bool SceneSession::SendKeyEventToUI(std::shared_ptr keyEvent, bool isPreImeEvent) { std::lock_guard lock(keyEventMutex_); if (systemSessionKeyEventFunc_ != nullptr) { - systemSessionKeyEventFunc_(keyEvent); + return systemSessionKeyEventFunc_(keyEvent, isPreImeEvent); } + return false; } WSError SceneSession::UpdateSizeChangeReason(SizeChangeReason reason) @@ -2533,6 +2431,14 @@ bool SceneSession::IsExtWindowHasWaterMarkFlag() } return isExtWindowHasWaterMarkFlag; } + +void SceneSession::NotifyDisplayMove(DisplayId from, DisplayId to) +{ + if (sessionStage_) { + sessionStage_->NotifyDisplayMove(from, to); + } +} + void SceneSession::RomoveExtWindowFlags(int32_t extPersistentId) { std::shared_lock lock(extWindowFlagsMapMutex_); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 037513d16..1003c7208 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -330,6 +330,7 @@ void Session::NotifyDisconnect() void Session::NotifyExtensionDied() { + TLOGI(WmsLogTag::WMS_UIEXT, "NotifyExtensionDied called in session(persistentId:%{public}d).", persistentId_); auto lifecycleListeners = GetListeners(); std::lock_guard lock(lifecycleListenersMutex_); for (auto& listener : lifecycleListeners) { @@ -339,6 +340,19 @@ void Session::NotifyExtensionDied() } } +void Session::NotifyExtensionTimeout(int32_t errorCode) +{ + TLOGI(WmsLogTag::WMS_UIEXT, "NotifyExtensionTimeout(errorCode:%{public}d) in session(persistentId:%{public}d).", + errorCode, persistentId_); + auto lifecycleListeners = GetListeners(); + std::lock_guard lock(lifecycleListenersMutex_); + for (auto& listener : lifecycleListeners) { + if (!listener.expired()) { + listener.lock()->OnExtensionTimeout(errorCode); + } + } +} + void Session::NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) { @@ -784,6 +798,13 @@ WSError Session::Connect(const sptr& sessionStage, const sptrSetDisplayId(GetSessionInfo().screenId_); } + Rect rect = { + winRect_.posX_, + winRect_.posY_, + static_cast(winRect_.width_), + static_cast(winRect_.height_) + }; + property->SetWindowRect(rect); SetSessionProperty(property); if (property) { property->SetPersistentId(GetPersistentId()); @@ -952,7 +973,8 @@ WSError Session::Background() isActive_ = false; } if (state != SessionState::STATE_INACTIVE) { - TLOGW(WmsLogTag::WMS_LIFE, "Background state invalid! state:%{public}u", state); + TLOGW(WmsLogTag::WMS_LIFE, "Background state invalid! id: %{public}d, state: %{public}u", + GetPersistentId(), state); return WSError::WS_ERROR_INVALID_SESSION; } UpdateSessionState(SessionState::STATE_BACKGROUND); @@ -1722,7 +1744,8 @@ WSError Session::TransferBackPressedEventForConsumed(bool& isConsumed) return windowEventChannel_->TransferBackpressedEventForConsumed(isConsumed); } -WSError Session::TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) +WSError Session::TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent) { if (!windowEventChannel_) { WLOGFE("windowEventChannel_ is null"); @@ -1732,7 +1755,7 @@ WSError Session::TransferKeyEventForConsumed(const std::shared_ptrTransferKeyEventForConsumed(keyEvent, isConsumed); + return windowEventChannel_->TransferKeyEventForConsumed(keyEvent, isConsumed, isPreImeEvent); } WSError Session::TransferFocusActiveEvent(bool isFocusActive) @@ -1883,7 +1906,7 @@ void Session::NotifySessionStateChange(const SessionState& state) void Session::SetSessionFocusableChangeListener(const NotifySessionFocusableChangeFunc& func) { sessionFocusableChangeFunc_ = func; - sessionFocusableChangeFunc_(GetFocusable()); + NotifySessionFocusableChange(GetFocusable()); } void Session::SetSessionTouchableChangeListener(const NotifySessionTouchableChangeFunc& func) @@ -1899,7 +1922,7 @@ void Session::SetClickListener(const NotifyClickFunc& func) void Session::NotifySessionFocusableChange(bool isFocusable) { - WLOGFI("Notify session focusable change, id: %{public}d, focusable: %{public}u", GetPersistentId(), isFocusable); + TLOGI(WmsLogTag::WMS_FOCUS, "id: %{public}d, focusable: %{public}u", GetPersistentId(), isFocusable); if (sessionFocusableChangeFunc_) { sessionFocusableChangeFunc_(isFocusable); } @@ -2421,6 +2444,16 @@ WSError Session::TransferExecuteAction(int64_t elementId, const std::mapTransferExecuteAction(elementId, actionArguments, action, baseParent); } +WSError Session::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) +{ + if (!windowEventChannel_) { + WLOGFE("windowEventChannel_ is null"); + return WSError::WS_ERROR_NULLPTR; + } + return windowEventChannel_->TransferAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); +} + void Session::SetSessionInfoLockedStateChangeListener(const NotifySessionInfoLockedStateChangeFunc& func) { sessionInfoLockedStateChangeFunc_ = func; diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 2555b4e82..45414c74a 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -214,6 +214,8 @@ WSError SessionProxy::Connect(const sptr& sessionStage, const spt if (needUpdate) { property->SetWindowMode(static_cast(reply.ReadUint32())); } + Rect rect = { reply.ReadInt32(), reply.ReadInt32(), reply.ReadUint32(), reply.ReadUint32() }; + property->SetWindowRect(rect); } int32_t ret = reply.ReadInt32(); return static_cast(ret); @@ -753,6 +755,28 @@ WSError SessionProxy::UpdateWindowSceneAfterCustomAnimation(bool isAdd) return static_cast(ret); } +WSError SessionProxy::SetLandscapeMultiWindow(bool isLandscapeMultiWindow) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteBool(isLandscapeMultiWindow)) { + WLOGFE("Write isLandscapeMultiWindow failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (Remote()->SendRequest(static_cast(SessionInterfaceCode::TRANS_ID_SET_LANDSCAPE_MULTI_WINDOW), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + int32_t ret = reply.ReadInt32(); + return static_cast(ret); +} + WSError SessionProxy::TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) { MessageParcel data; @@ -865,6 +889,25 @@ void SessionProxy::NotifyExtensionDied() } } +void SessionProxy::NotifyExtensionTimeout(int32_t errorCode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed"); + return; + } + if (!data.WriteInt32(static_cast(errorCode))) { + TLOGE(WmsLogTag::WMS_UIEXT, "errorCode write failed."); + return; + } + if (Remote()->SendRequest(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_TIMEOUT), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed"); + } +} + void SessionProxy::TriggerBindModalUIExtension() { MessageParcel data; @@ -984,43 +1027,6 @@ WSError SessionProxy::UpdatePiPRect(const Rect& rect, SizeChangeReason reason) return static_cast(ret); } -WSError SessionProxy::RecoveryPullPiPMainWindow(int32_t persistentId, const Rect& rect) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!data.WriteInterfaceToken(GetDescriptor())) { - WLOGFE("writeInterfaceToken failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (!data.WriteInt32(persistentId)) { - WLOGFE("WriteInterfaceToken failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (!data.WriteInt32(rect.posX_)) { - WLOGFE("Write posX_ failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (!data.WriteInt32(rect.posY_)) { - WLOGFE("Write posY_ failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (!data.WriteUint32(rect.width_)) { - WLOGFE("Write width_ failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (!data.WriteUint32(rect.height_)) { - WLOGFE("Write height_ failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - if (Remote()->SendRequest(static_cast(SessionInterfaceCode::TRANS_ID_RECOVERY_PULL_PIP_MAIN_WINDOW), - data, reply, option) != ERR_NONE) { - WLOGFE("SendRequest failed"); - return WSError::WS_ERROR_IPC_FAILED; - } - return WSError::WS_OK; -} - WSError SessionProxy::ProcessPointDownSession(int32_t posX, int32_t posY) { MessageParcel data; diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 6c03add94..996969a0e 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -77,6 +77,8 @@ const std::map SessionStub::stubFuncMap_ { &SessionStub::HandleSetWindowAnimationFlag), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_CUSTOM_ANIMATION), &SessionStub::HandleUpdateWindowSceneAfterCustomAnimation), + std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_SET_LANDSCAPE_MULTI_WINDOW), + &SessionStub::HandleSetLandscapeMultiWindow), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_RAISE_ABOVE_TARGET), &SessionStub::HandleRaiseAboveTarget), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_RAISE_APP_MAIN_WINDOW), @@ -106,6 +108,8 @@ const std::map SessionStub::stubFuncMap_ { &SessionStub::HandleNotifySyncOn), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DIED), &SessionStub::HandleNotifyExtensionDied), + std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_TIMEOUT), + &SessionStub::HandleNotifyExtensionTimeout), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION), &SessionStub::HandleTriggerBindModalUIExtension), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_REPORT_ACCESSIBILITY_EVENT), @@ -114,8 +118,6 @@ const std::map SessionStub::stubFuncMap_ { &SessionStub::HandleNotifyPiPWindowPrepareClose), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_PIP_RECT), &SessionStub::HandleUpdatePiPRect), - std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_RECOVERY_PULL_PIP_MAIN_WINDOW), - &SessionStub::HandleRecoveryPullPiPMainWindow) }; int SessionStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) @@ -237,6 +239,12 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply) reply.WriteUint32(static_cast(property->GetWindowMode())); } property->SetIsNeedUpdateWindowMode(false); + + Rect winRect = property->GetWindowRect(); + reply.WriteInt32(winRect.posX_); + reply.WriteInt32(winRect.posY_); + reply.WriteUint32(winRect.width_); + reply.WriteUint32(winRect.height_); } reply.WriteUint32(static_cast(errCode)); return ERR_NONE; @@ -474,6 +482,15 @@ int SessionStub::HandleUpdateWindowSceneAfterCustomAnimation(MessageParcel& data return ERR_NONE; } +int SessionStub::HandleSetLandscapeMultiWindow(MessageParcel& data, MessageParcel& reply) +{ + WLOGD("HandleSetLandscapeMultiWindow!"); + bool isLandscapeMultiWindow = data.ReadBool(); + const WSError errCode = SetLandscapeMultiWindow(isLandscapeMultiWindow); + reply.WriteUint32(static_cast(errCode)); + return ERR_NONE; +} + int SessionStub::HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply) { WLOGFD("HandleTransferAbilityResult!"); @@ -527,6 +544,17 @@ int SessionStub::HandleNotifyExtensionDied(MessageParcel& data, MessageParcel& r return ERR_NONE; } +int SessionStub::HandleNotifyExtensionTimeout(MessageParcel& data, MessageParcel& reply) +{ + int32_t errorCode = 0; + if (!data.ReadInt32(errorCode)) { + TLOGE(WmsLogTag::WMS_UIEXT, "Read eventId from parcel failed!"); + return ERR_INVALID_DATA; + } + NotifyExtensionTimeout(errorCode); + return ERR_NONE; +} + int SessionStub::HandleTriggerBindModalUIExtension(MessageParcel& data, MessageParcel& reply) { WLOGFD("called"); @@ -549,14 +577,14 @@ int SessionStub::HandleTransferAccessibilityEvent(MessageParcel& data, MessagePa int SessionStub::HandleNotifyPiPWindowPrepareClose(MessageParcel& data, MessageParcel& reply) { - WLOGFD("HandleNotifyPiPWindowPrepareClose"); + TLOGD(WmsLogTag::WMS_PIP, "HandleNotifyPiPWindowPrepareClose"); NotifyPiPWindowPrepareClose(); return ERR_NONE; } int SessionStub::HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply) { - WLOGFD("HandleUpdatePiPRect!"); + TLOGD(WmsLogTag::WMS_PIP, "HandleUpdatePiPRect!"); Rect rect = {data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32()}; auto reason = static_cast(data.ReadInt32()); WSError errCode = UpdatePiPRect(rect, reason); @@ -564,20 +592,6 @@ int SessionStub::HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply) return ERR_NONE; } -int SessionStub::HandleRecoveryPullPiPMainWindow(MessageParcel& data, MessageParcel& reply) -{ - WLOGFD("HandleNotifyRecoveryPullPiPMainWindow"); - int32_t persistentId = 0; - if (!data.ReadInt32(persistentId)) { - WLOGFE("Read eventId from parcel failed!"); - return ERR_INVALID_DATA; - } - Rect rect = {data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32()}; - WSError errCode = RecoveryPullPiPMainWindow(persistentId, rect); - reply.WriteUint32(static_cast(errCode)); - return ERR_NONE; -} - int SessionStub::HandleProcessPointDownSession(MessageParcel& data, MessageParcel& reply) { WLOGFD("HandleProcessPointDownSession!"); diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index de41fb8ac..3ae3ac97b 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -136,6 +136,9 @@ public: void SetHdrFormats(std::vector&& hdrFormats); void SetColorSpaces(std::vector&& colorSpaces); + VirtualScreenFlag GetVirtualScreenFlag(); + void SetVirtualScreenFlag(VirtualScreenFlag screenFlag); + std::string name_ { "UNKNOW" }; ScreenId screenId_ {}; ScreenId rsId_ {}; @@ -174,6 +177,7 @@ private: ScreenState screenState_ { ScreenState::INIT }; std::vector screenChangeListenerList_; ScreenCombination combination_ { ScreenCombination::SCREEN_ALONE }; + VirtualScreenFlag screenFlag_ { VirtualScreenFlag::DEFAULT }; bool hasPrivateWindowForeground_ = false; std::recursive_mutex mutex_; std::function updateToInputManagerCallback_ = nullptr; diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 847fc48a9..7e9deab40 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -360,6 +360,16 @@ void ScreenSession::SetUpdateToInputManagerCallback(std::function u updateToInputManagerCallback_ = updateToInputManagerCallback; } +VirtualScreenFlag ScreenSession::GetVirtualScreenFlag() +{ + return screenFlag_; +} + +void ScreenSession::SetVirtualScreenFlag(VirtualScreenFlag screenFlag) +{ + screenFlag_ = screenFlag; +} + void ScreenSession::UpdateToInputManager(RRect bounds, int rotation, FoldDisplayMode foldDisplayMode) { bool needUpdateToInputManager = false; @@ -533,14 +543,11 @@ Rotation ScreenSession::CalcRotation(Orientation orientation, FoldDisplayMode fo DisplayOrientation ScreenSession::CalcDisplayOrientation(Rotation rotation, FoldDisplayMode foldDisplayMode) const { - sptr info = GetActiveScreenMode(); - if (info == nullptr) { - return DisplayOrientation::UNKNOWN; - } // vertical: phone(Plugin screen); horizontal: pad & external screen - bool isVerticalScreen = info->width_ < info->height_; + bool isVerticalScreen = property_.GetPhyWidth() < property_.GetPhyHeight(); if (foldDisplayMode != FoldDisplayMode::UNKNOWN) { - isVerticalScreen = info->width_ > info->height_; + WLOGD("foldDisplay is verticalScreen when width is greater than height"); + isVerticalScreen = property_.GetPhyWidth() > property_.GetPhyHeight(); } switch (rotation) { case Rotation::ROTATION_0: { @@ -578,6 +585,9 @@ ScreenSourceMode ScreenSession::GetSourceMode() const case ScreenCombination::SCREEN_ALONE: { return ScreenSourceMode::SCREEN_ALONE; } + case ScreenCombination::SCREEN_UNIQUE: { + return ScreenSourceMode::SCREEN_UNIQUE; + } default: { return ScreenSourceMode::SCREEN_ALONE; } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 39c8016b0..1c631a9e5 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -77,7 +77,6 @@ using WindowChangedFunc = std::function& session)>; using CmpFunc = std::function>& lhs, std::pair>& rhs)>; -using ProcessShowPiPMainWindowFunc = std::function; using ProcessStartUIAbilityErrorFunc = std::function; using NotifySCBAfterUpdateFocusFunc = std::function; using ProcessCallingWindowIdChangeFunc = std::function; @@ -149,7 +148,6 @@ public: void SetShiftFocusListener(const ProcessShiftFocusFunc& func); void SetSCBFocusedListener(const NotifySCBAfterUpdateFocusFunc& func); void SetSCBUnfocusedListener(const NotifySCBAfterUpdateFocusFunc& func); - void SetShowPiPMainWindowListener(const ProcessShowPiPMainWindowFunc& func); void SetCallingWindowIdChangeListenser(const ProcessCallingWindowIdChangeFunc& func); const AppWindowSceneConfig& GetWindowSceneConfig() const; WSError ProcessBackEvent(); @@ -246,7 +244,6 @@ public: WSError RegisterIAbilityManagerCollaborator(int32_t type, const sptr &impl) override; WSError UnregisterIAbilityManagerCollaborator(int32_t type) override; - WSError RecoveryPullPiPMainWindow(const int32_t& persistentId, const Rect& rect); bool IsInputEventEnabled(); void SetEnableInputEvent(bool enabled); @@ -349,6 +346,8 @@ private: void RegisterRequestFocusStatusNotifyManagerFunc(sptr& sceneSession); void RegisterGetStateFromManagerFunc(sptr& sceneSession); + void UpdateCallingWindowIdAndPosition(const sptr& property, + const sptr& sceneSession); void RelayoutKeyBoard(sptr sceneSession); void RestoreCallingSessionSizeIfNeed(); void ResizeSoftInputCallingSessionIfNeed(const sptr& sceneSession, bool isInputUpdated = false); @@ -463,7 +462,6 @@ private: ProcessShiftFocusFunc shiftFocusFunc_; NotifySCBAfterUpdateFocusFunc notifySCBAfterFocusedFunc_; NotifySCBAfterUpdateFocusFunc notifySCBAfterUnfocusedFunc_; - ProcessShowPiPMainWindowFunc showPiPMainWindowFunc_; ProcessCallingWindowIdChangeFunc callingWindowIdChangeFunc_; ProcessStartUIAbilityErrorFunc startUIAbilityErrorFunc_; ProcessVirtualPixelRatioChangeFunc processVirtualPixelRatioChangeFunc_ = nullptr; @@ -478,9 +476,6 @@ private: bool needBlockNotifyUnfocusStatus_ {false}; bool isScreenLocked_ {false}; bool isPrepareTerminateEnable_ {false}; - WSRect callingWindowRestoringRect_ = {0, 0, 0, 0}; - WSRect callingWindowNewRect_ = {0, 0, 0, 0}; - bool needUpdateSessionRect_ = false; bool openDebugTrace {false}; int32_t currentUserId_; std::atomic enableInputEvent_ = true; @@ -562,6 +557,7 @@ private: bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); WSError GetAppMainSceneSession(sptr& sceneSession, int32_t persistentId); WSError HandleSecureSessionShouldHide(const sptr& sceneSession); + void HandleCastScreenDisConnection(const sptr sceneSession); }; } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/include/screen_session_manager.h b/window_scene/session_manager/include/screen_session_manager.h index 307aa65a7..3e04b1d6e 100644 --- a/window_scene/session_manager/include/screen_session_manager.h +++ b/window_scene/session_manager/include/screen_session_manager.h @@ -76,6 +76,7 @@ public: virtual DMError UnregisterDisplayManagerAgent(const sptr& displayManagerAgent, DisplayManagerAgentType type) override; + bool IsFastFingerprintReason(PowerStateChangeReason reason); bool WakeUpBegin(PowerStateChangeReason reason) override; bool WakeUpEnd() override; bool SuspendBegin(PowerStateChangeReason reason) override; @@ -177,6 +178,7 @@ public: void SetDisplayBoundary(const sptr screenSession); void BlockScreenOnByCV(void); + bool BlockSetDisplayState(); //Fold Screen void SetFoldDisplayMode(const FoldDisplayMode displayMode) override; @@ -226,6 +228,8 @@ public: void NotifyAvailableAreaChanged(DMRect area); void NotifyFoldToExpandCompletion(bool foldToExpand) override; + VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) override; + DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) override; protected: ScreenSessionManager(); virtual ~ScreenSessionManager() = default; @@ -244,7 +248,8 @@ private: void CreateScreenProperty(ScreenId screenId, ScreenProperty& property); sptr GetScreenSessionInner(ScreenId screenId, ScreenProperty property); void FreeDisplayMirrorNodeInner(const sptr mirrorSession); - + DMError MirrorUniqueSwitch(const std::vector& screenIds); + void MirrorSwitchNotify(ScreenId screenId); ScreenId GetDefaultScreenId(); void NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, @@ -330,6 +335,12 @@ private: std::mutex screenOnMutex_; std::condition_variable screenOnCV_; + + std::atomic prePowerStateChangeReason = PowerStateChangeReason::STATE_CHANGE_REASON_UNKNOWN; + std::atomic lastWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_INIT; + std::atomic currentWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_INIT; + std::atomic buttonBlock_ = false; + //Fold Screen std::map phyScreenPropMap_; mutable std::recursive_mutex phyScreenPropMapMutex_; diff --git a/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h b/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h index c9ec95e5d..9e427d878 100644 --- a/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/screen_session_manager_proxy.h @@ -142,6 +142,8 @@ public: virtual DMError GetAvailableArea(DisplayId displayId, DMRect& area) override; void NotifyFoldToExpandCompletion(bool foldToExpand) override; + VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) override; + DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) override; private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 47120de5b..6c503b3f6 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -244,7 +244,17 @@ std::map> SceneSessionDirtyManager::GetDialogSession for (const auto& elem: sessionMap) { const auto& session = elem.second; - if (session != nullptr && session->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) { + if (session == nullptr) { + continue; + } + bool isModalSubWindow = false; + auto property = session->GetSessionProperty(); + if (property != nullptr) { + bool isSubWindow = WindowHelper::IsSubWindow(property->GetWindowType()); + bool isModal = property->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_IS_MODAL); + isModalSubWindow = isSubWindow && isModal; + } + if (isModalSubWindow || session->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) { const auto& parentSession = session->GetParentSession(); if (parentSession == nullptr) { continue; @@ -428,6 +438,11 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr .zOrder = zOrder, .transform = transformData }; + if (sceneSession->GetSessionProperty()->GetWindowFlags() & + static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING)) { + WLOGFI("Add handwrite flag for session, id: %{public}d", windowId); + windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_HANDWRITE; + } return windowInfo; } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 2725a57a0..b16e03dd1 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -44,6 +44,8 @@ #include #include #include "transaction/rs_sync_transaction_controller.h" +#include "screen_manager.h" +#include "screen.h" #ifdef POWERMGR_DISPLAY_MANAGER_ENABLE #include @@ -88,7 +90,6 @@ #include "softbus_bus_center.h" #include "window_manager.h" #include "perform_reporter.h" -#include "pip_util.h" #include "focus_change_info.h" #include "anr_manager.h" @@ -886,6 +887,7 @@ WSError SceneSessionManager::UpdateParentSessionForDialog(const sptrGetParentPersistentId(); + sceneSession->SetParentPersistentId(parentPersistentId); if (property->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG && parentPersistentId != INVALID_SESSION_ID) { auto parentSession = GetSceneSession(parentPersistentId); if (parentSession == nullptr) { @@ -924,8 +926,6 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onSessionTouchOutside_ = std::bind(&SceneSessionManager::NotifySessionTouchOutside, this, std::placeholders::_1); specificCb->onGetAINavigationBarArea_ = std::bind(&SceneSessionManager::GetAINavigationBarArea, this); - specificCb->onRecoveryPullPiPMainWindow_ = std::bind(&SceneSessionManager::RecoveryPullPiPMainWindow, - this, std::placeholders::_1, std::placeholders::_2); specificCb->onOutsideDownEvent_ = std::bind(&SceneSessionManager::OnOutsideDownEvent, this, std::placeholders::_1, std::placeholders::_2); specificCb->onHandleSecureSessionShouldHide_ = std::bind(&SceneSessionManager::HandleSecureSessionShouldHide, @@ -1211,6 +1211,10 @@ sptr SceneSessionManager::SetAbilitySessionInfo(const sptruserId = currentUserId_; abilitySessionInfo->isClearSession = sessionInfo.isClearSession; abilitySessionInfo->processOptions = sessionInfo.processOptions; + if (scnSession->GetSessionProperty()) { + abilitySessionInfo->want.SetParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, + static_cast(scnSession->GetSessionProperty()->GetDisplayId())); + } if (sessionInfo.want != nullptr) { abilitySessionInfo->want = *sessionInfo.want; } else { @@ -1561,6 +1565,7 @@ WSError SceneSessionManager::RequestSceneSessionDestruction( TLOGE(WmsLogTag::WMS_MAIN, "session is nullptr"); return WSError::WS_ERROR_NULLPTR; } + HandleCastScreenDisConnection(scnSession); auto persistentId = scnSession->GetPersistentId(); RequestSessionUnfocus(persistentId); lastUpdatedAvoidArea_.erase(persistentId); @@ -1598,6 +1603,26 @@ WSError SceneSessionManager::RequestSceneSessionDestruction( return WSError::WS_OK; } +void SceneSessionManager::HandleCastScreenDisConnection(const sptr sceneSession) +{ + auto sessionInfo = sceneSession->GetSessionInfo(); + ScreenId defScreenId = ScreenSessionManagerClient::GetInstance().GetDefaultScreenId(); + if (defScreenId == sessionInfo.screenId_) { + return; + } + auto flag = Rosen::ScreenManager::GetInstance().GetVirtualScreenFlag(sessionInfo.screenId_); + if (flag != VirtualScreenFlag::CAST) { + return; + } + std::vector mirrorIds { sessionInfo.screenId_ }; + ScreenId groupId; + Rosen::DMError ret = Rosen::ScreenManager::GetInstance().MakeMirror(0, mirrorIds, groupId); + if (ret != Rosen::DMError::DM_OK) { + TLOGI(WmsLogTag::WMS_LIFE, "MakeMirror failed,ret: %{public}d", ret); + return; + } +} + WSError SceneSessionManager::RequestSceneSessionDestructionInner( sptr &scnSession, sptr scnSessionInfo, const bool needRemoveSession) { @@ -1705,6 +1730,20 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW) { + auto extensionParentSession = GetSceneSession(property->GetParentPersistentId()); + SessionInfo sessionInfo = extensionParentSession->GetSessionInfo(); + AAFwk::UIExtensionHostInfo hostInfo; + AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionRootHostInfo(token, hostInfo); + if (sessionInfo.bundleName_ != hostInfo.elementName_.GetBundleName()) { + WLOGE("The hostWindow is not thie parentwindow ! parentwindow bundleName: %{public}s, " + "hostwindow bundleName: %{public}s", sessionInfo.bundleName_.c_str(), + hostInfo.elementName_.GetBundleName().c_str()); + return WSError::WS_ERROR_INVALID_WINDOW; + } + } + // WINDOW_TYPE_SYSTEM_ALARM_WINDOW has been deprecated, will be deleted after 5 versions. if (property->GetWindowType() == WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW) { WLOGFE("The alarm window has been deprecated!"); @@ -1777,7 +1816,7 @@ bool SceneSessionManager::CheckPiPPriority(const PiPTemplateInfo& pipTemplateInf if (session && session->GetWindowMode() == WindowMode::WINDOW_MODE_PIP && pipTemplateInfo.priority < session->GetPiPTemplateInfo().priority && IsSessionVisible(session)) { - WLOGFE("create pip window failed, reason: low priority."); + TLOGE(WmsLogTag::WMS_PIP, "create pip window failed, reason: low priority."); return false; } } @@ -1804,8 +1843,12 @@ bool SceneSessionManager::CheckSystemWindowPermission(const sptrSetSystemBarProperty(iter.first, iter.second); - WLOGFD("SetSystemBarProperty: %{public}d, enable: %{public}d", - static_cast(iter.first), iter.second.enable_); + TLOGD(WmsLogTag::WMS_IMMS, "SetSystemBarProperty: %{public}d, enable: %{public}d", + static_cast(iter.first), iter.second.enable_); } } NotifyWindowInfoChange(property->GetPersistentId(), WindowUpdateType::WINDOW_UPDATE_PROPERTY); @@ -2765,12 +2808,7 @@ WMError SceneSessionManager::HandleUpdateProperty(const sptrGetSessionProperty() != nullptr) { - sceneSession->GetSessionProperty()->SetCallingWindow(property->GetCallingWindow()); - } - if (callingWindowIdChangeFunc_ != nullptr) { - callingWindowIdChangeFunc_(property->GetCallingWindow()); - } + UpdateCallingWindowIdAndPosition(property, sceneSession); break; } case WSPropertyChangeAction::ACTION_UPDATE_DECOR_ENABLE: { @@ -3641,7 +3679,7 @@ WSError SceneSessionManager::RequestSessionFocusImmediately(int32_t persistentId WSError SceneSessionManager::RequestSessionFocus(int32_t persistentId, bool byForeground) { - TLOGI(WmsLogTag::WMS_FOCUS, "RequestSessionFocus, id: %{public}d, by foreground: %{public}d", + TLOGD(WmsLogTag::WMS_FOCUS, "RequestSessionFocus, id: %{public}d, by foreground: %{public}d", persistentId, byForeground); WSError basicCheckRet = RequestFocusBasicCheck(persistentId); if (basicCheckRet != WSError::WS_OK) { @@ -3679,7 +3717,7 @@ WSError SceneSessionManager::RequestSessionFocus(int32_t persistentId, bool byFo WSError SceneSessionManager::RequestSessionUnfocus(int32_t persistentId) { - TLOGI(WmsLogTag::WMS_FOCUS, "RequestSessionUnfocus, id: %{public}d", persistentId); + TLOGD(WmsLogTag::WMS_FOCUS, "RequestSessionUnfocus, id: %{public}d", persistentId); if (persistentId == INVALID_SESSION_ID) { WLOGFE("id is invalid"); return WSError::WS_ERROR_INVALID_SESSION; @@ -3836,12 +3874,6 @@ void SceneSessionManager::SetSCBUnfocusedListener(const NotifySCBAfterUpdateFocu notifySCBAfterUnfocusedFunc_ = func; } -void SceneSessionManager::SetShowPiPMainWindowListener(const ProcessShowPiPMainWindowFunc& func) -{ - WLOGFD("SetShowPiPMainWindowListener"); - showPiPMainWindowFunc_ = func; -} - void SceneSessionManager::SetCallingWindowIdChangeListenser(const ProcessCallingWindowIdChangeFunc& func) { WLOGFD("SetCallingWindowIdChangeListenser"); @@ -5112,7 +5144,6 @@ WSError SceneSessionManager::BindDialogSessionTarget(uint64_t persistentId, sptr return WSError::WS_ERROR_INVALID_PARAM; } scnSession->SetParentSession(parentSession); - scnSession->SetParentPersistentId(parentSession->GetPersistentId()); UpdateParentSessionForDialog(scnSession, scnSession->GetSessionProperty()); TLOGI(WmsLogTag::WMS_DIALOG, "Bind dialog success, dialog id %{public}" PRIu64 ", parentId %{public}d", persistentId, parentSession->GetPersistentId()); @@ -5274,7 +5305,7 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( const WSRect& softInputSessionRect = sceneSession->GetSessionRect(); WSRect callingSessionRect; if (isInputUpdated && isCallingSessionFloating) { - callingSessionRect = callingWindowRestoringRect_; + callingSessionRect = callingSession_->callingWindowRestoringRect_; } else { callingSessionRect = callingSession_->GetSessionRect(); } @@ -5294,13 +5325,13 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( } if (!isInputUpdated) { - callingWindowRestoringRect_ = callingSessionRect; + callingSession_->callingWindowRestoringRect_ = callingSessionRect; } NotifyOccupiedAreaChangeInfo(sceneSession, newRect, softInputSessionRect); if (isCallingSessionFloating && callingSessionRect.posY_ > statusHeight) { - needUpdateSessionRect_ = true; + callingSession_->needUpdateSessionRect_ = true; callingSession_->UpdateSessionRect(newRect, SizeChangeReason::UNDEFINED); - callingWindowNewRect_ = callingSession_->GetSessionRect(); + callingSession_->callingWindowNewRect_ = callingSession_->GetSessionRect(); } } @@ -5331,16 +5362,18 @@ void SceneSessionManager::RestoreCallingSessionSizeIfNeed() } WSRect overlapRect = { 0, 0, 0, 0 }; - NotifyOccupiedAreaChangeInfo(callingSession_, callingWindowRestoringRect_, overlapRect); - if (!SessionHelper::IsEmptyRect(callingWindowRestoringRect_)) { - if (needUpdateSessionRect_ && callingSession_->GetSessionProperty() && + NotifyOccupiedAreaChangeInfo(callingSession_, callingSession_->callingWindowRestoringRect_, overlapRect); + if (!SessionHelper::IsEmptyRect(callingSession_->callingWindowRestoringRect_)) { + if (callingSession_->needUpdateSessionRect_ && callingSession_->GetSessionProperty() && callingSession_->GetSessionProperty()->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING && - callingSession_->GetSessionRect() == callingWindowNewRect_) { - callingSession_->UpdateSessionRect(callingWindowRestoringRect_, SizeChangeReason::UNDEFINED); + callingSession_->GetSessionRect() == callingSession_->callingWindowNewRect_) { + callingSession_->UpdateSessionRect(callingSession_->callingWindowRestoringRect_, + SizeChangeReason::UNDEFINED); } } - needUpdateSessionRect_ = false; - callingWindowRestoringRect_ = { 0, 0, 0, 0 }; + callingSession_->needUpdateSessionRect_ = false; + callingSession_->callingWindowRestoringRect_ = { 0, 0, 0, 0 }; + callingSession_->callingWindowNewRect_ = {0, 0, 0, 0}; } WSError SceneSessionManager::SetSessionGravity(int32_t persistentId, SessionGravity gravity, uint32_t percent) @@ -5421,6 +5454,40 @@ void SceneSessionManager::RelayoutKeyBoard(sptr sceneSession) sceneSession->UpdateSessionRect(SessionHelper::TransferToWSRect(requestRect), SizeChangeReason::UNDEFINED); } +void SceneSessionManager::UpdateCallingWindowIdAndPosition(const sptr& property, + const sptr& sceneSession) +{ + if (sceneSession->GetSessionProperty() == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Failed to update calling window id: %{public}d", property->GetCallingWindow()); + return; + } + uint32_t curWindowId = sceneSession->GetSessionProperty()->GetCallingWindow(); + uint32_t newWindowId = property->GetCallingWindow(); + TLOGI(WmsLogTag::WMS_KEYBOARD, "CallingWindow curId: %{public}d, newId: %{public}d", curWindowId, newWindowId); + // When calling window id changes, restore the old calling window, raise the new calling window. + if (curWindowId != INVALID_WINDOW_ID && newWindowId != curWindowId && callingSession_ != nullptr) { + RestoreCallingSessionSizeIfNeed(); + + callingSession_ = GetSceneSession(newWindowId); + if (callingSession_ == nullptr) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "Using focusedSession id: %{public}d", focusedSessionId_); + callingSession_ = GetSceneSession(focusedSessionId_); + if (callingSession_ == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Calling window id invalid,Calling session is null"); + return; + } else { + newWindowId = focusedSessionId_; + } + } + ResizeSoftInputCallingSessionIfNeed(sceneSession); + } + sceneSession->GetSessionProperty()->SetCallingWindow(newWindowId); + + if (callingWindowIdChangeFunc_ != nullptr) { + callingWindowIdChangeFunc_(newWindowId); + } +} + void SceneSessionManager::InitPersistentStorage() { if (ScenePersistentStorage::HasKey("maximize_state", ScenePersistentStorageType::MAXIMIZE_STATE)) { @@ -6563,31 +6630,6 @@ WSError SceneSessionManager::UnregisterIAbilityManagerCollaborator(int32_t type) return WSError::WS_OK; } -WSError SceneSessionManager::RecoveryPullPiPMainWindow(const int32_t& persistentId, const Rect& rect) -{ - auto scnSession = GetSceneSession(persistentId); - if (scnSession == nullptr) { - WLOGFE("scnSession is nullptr, persistentId: %{public}d", persistentId); - return WSError::WS_ERROR_NULLPTR; - } - if (!WindowHelper::IsPipWindow(scnSession->GetWindowType())) { - WLOGFE("not pip window"); - return WSError::WS_DO_NOTHING; - } - auto task = [this, scnSession, rect, persistentId]() { - if (!showPiPMainWindowFunc_) { - WLOGFE("showPiPMainWindowFunc_ init error, persistentId: %{public}d", persistentId); - return WSError::WS_DO_NOTHING; - } - showPiPMainWindowFunc_(scnSession->GetParentPersistentId()); - WSRect rectPos = SessionHelper::TransferToWSRect(rect); - scnSession->UpdateSessionRect(rectPos, SizeChangeReason::RECOVER); - return WSError::WS_OK; - }; - taskScheduler_->PostAsyncTask(task, "RecoveryPullPiPMainWindow"); - return WSError::WS_OK; -} - bool SceneSessionManager::CheckCollaboratorType(int32_t type) { if (type != CollaboratorType::RESERVE_TYPE && type != CollaboratorType::OTHERS_TYPE) { @@ -6836,6 +6878,8 @@ WSError SceneSessionManager::UpdateSessionDisplayId(int32_t persistentId, uint64 scnSession->GetSessionProperty()->SetDisplayId(screenId); WLOGFD("Session move display %{public}" PRIu64" from %{public}" PRIu64"", screenId, fromScreenId); NotifySessionUpdate(scnSession->GetSessionInfo(), ActionType::MOVE_DISPLAY, fromScreenId); + scnSession->NotifyDisplayMove(fromScreenId, screenId); + scnSession->UpdateDensity(); return WSError::WS_OK; } diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index ce3ba8f54..3b6d4bfca 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -52,7 +52,8 @@ const std::string SCREEN_SESSION_MANAGER_THREAD = "OS_ScreenSessionManager"; const std::string SCREEN_SESSION_MANAGER_SCREEN_POWER_THREAD = "OS_ScreenSessionManager_ScreenPower"; const std::string SCREEN_CAPTURE_PERMISSION = "ohos.permission.CAPTURE_SCREEN"; const std::string BOOTEVENT_BOOT_COMPLETED = "bootevent.boot.completed"; -const int CV_WAIT_MS = 300; +const int32_t SLEEP_10_MS = 10 * 1000; // 10ms +const int32_t CV_WAIT_MS = 300; const std::u16string DEFAULT_USTRING = u"error"; const std::string DEFAULT_STRING = "error"; const std::string ARG_DUMP_HELP = "-h"; @@ -295,11 +296,10 @@ void ScreenSessionManager::RegisterScreenChangeListener() void ScreenSessionManager::RegisterRefreshRateModeChangeListener() { - WLOGFI("Register refreshrate mode change listener."); auto res = rsInterface_.RegisterHgmRefreshRateModeChangeCallback( [this](int32_t refreshRateMode) { OnHgmRefreshRateModeChange(refreshRateMode); }); if (res != StatusCode::SUCCESS) { - WLOGFE("Register refreshrate mode change listener failed, retry after 50 ms."); + WLOGFE("Register refresh rate mode change listener failed, retry after 50 ms."); auto task = [this]() { RegisterRefreshRateModeChangeListener(); }; taskScheduler_->PostAsyncTask(task, "RegisterRefreshRateModeChangeListener", 50); // Retry after 50 ms. } @@ -374,9 +374,15 @@ void ScreenSessionManager::OnScreenChange(ScreenId screenId, ScreenEvent screenE clientProxy_->OnScreenConnectionChanged(screenId, ScreenEvent::CONNECTED, screenSession->GetRSScreenId(), screenSession->GetName()); } + if (screenSession->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) { + NotifyScreenConnected(screenSession->ConvertToScreenInfo()); + } return; } if (screenEvent == ScreenEvent::DISCONNECTED) { + if (screenSession->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) { + NotifyScreenDisconnected(screenSession->GetScreenId()); + } if (phyMirrorEnable) { FreeDisplayMirrorNodeInner(screenSession); } @@ -769,6 +775,10 @@ sptr ScreenSessionManager::GetScreenSessionInner(ScreenId screenI } WLOGFI("GetScreenSessionInner: nodeId:%{public}" PRIu64 "", nodeId); session = new ScreenSession(screenId, property, nodeId, defScreenId); + session->SetVirtualScreenFlag(VirtualScreenFlag::CAST); + session->SetName("CastEngine"); + session->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); + NotifyScreenChanged(session->ConvertToScreenInfo(), ScreenChangeEvent::SCREEN_SWITCH_CHANGE); } else { session = new ScreenSession(screenId, property, defScreenId); } @@ -888,19 +898,31 @@ ScreenId ScreenSessionManager::GetDefaultScreenId() bool ScreenSessionManager::WakeUpBegin(PowerStateChangeReason reason) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:WakeUpBegin(%u)", reason); - WLOGFI("[UL_POWER]WakeUpBegin remove suspend begin task"); + currentWakeUpReason_ = reason; + WLOGFI("[UL_POWER]WakeUpBegin remove suspend begin task, reason: %{public}u", static_cast(reason)); + blockScreenPowerChange_ = false; taskScheduler_->RemoveTask("suspendBeginTask"); if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_COLLABORATION) { isMultiScreenCollaboration_ = true; return true; } + // Handling Power Button Conflicts + if (IsFastFingerprintReason(lastWakeUpReason_) && reason == PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY) { + WLOGFI("[UL_POWER]WakeUpBegin buttonBlock_ is true"); + buttonBlock_ = true; + screenOnCV_.notify_all(); + usleep(SLEEP_10_MS); + } + lastWakeUpReason_ = reason; + return NotifyDisplayPowerEvent(DisplayPowerEvent::WAKE_UP, EventStatus::BEGIN, reason); } bool ScreenSessionManager::WakeUpEnd() { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:WakeUpEnd"); + WLOGFI("[UL_POWER]WakeUpEnd enter"); if (isMultiScreenCollaboration_) { isMultiScreenCollaboration_ = false; return true; @@ -912,7 +934,14 @@ bool ScreenSessionManager::WakeUpEnd() bool ScreenSessionManager::SuspendBegin(PowerStateChangeReason reason) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:SuspendBegin(%u)", reason); - WLOGFI("[UL_POWER]SuspendBegin block screen power change is true"); + WLOGFI("[UL_POWER]SuspendBegin block screen power change is true, reason: %{public}u", + static_cast(reason)); + lastWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_INIT; + if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF) { + sessionDisplayPowerController_->SuspendBegin(reason); + lastWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF; + return NotifyDisplayPowerEvent(DisplayPowerEvent::SLEEP, EventStatus::BEGIN, reason); + } blockScreenPowerChange_ = true; auto suspendBeginTask = [this]() { WLOGFI("[UL_POWER]SuspendBegin delay task start"); @@ -941,14 +970,46 @@ bool ScreenSessionManager::SuspendEnd() PowerStateChangeReason::STATE_CHANGE_REASON_INIT); } +bool ScreenSessionManager::BlockSetDisplayState() +{ + return prePowerStateChangeReason == PowerStateChangeReason::POWER_BUTTON; +} + bool ScreenSessionManager::SetDisplayState(DisplayState state) { WLOGFI("[UL_POWER]SetDisplayState enter"); return sessionDisplayPowerController_->SetDisplayState(state); } +bool ScreenSessionManager::IsFastFingerprintReason(PowerStateChangeReason reason) +{ + switch (reason) { + case PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT : { + [[fallthrough]]; + } + case PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_SUCCESS : { + [[fallthrough]]; + } + case PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_ON : { + [[fallthrough]]; + } + case PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF : { + return true; + } + default: { + return false; + } + } +} + void ScreenSessionManager::BlockScreenOnByCV(void) { + // Handling Power Button Conflicts + if (buttonBlock_ && currentWakeUpReason_ != PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY) { + WLOGFI("[UL_POWER]BlockScreenOnByCV exit because buttonBlock_"); + return; + } + if (keyguardDrawnDone_ == false) { WLOGFI("[UL_POWER]screenOnCV_ set"); needScreenOnWhenKeyguardNotify_ = true; @@ -1004,22 +1065,44 @@ bool ScreenSessionManager::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowe bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) { + WLOGFI("[UL_POWER]state: %{public}u, reason: %{public}u", + static_cast(state), static_cast(reason)); ScreenPowerStatus status; if (blockScreenPowerChange_) { WLOGFI("[UL_POWER]SetScreenPowerForAll block screen power change"); return true; } + // Handling Power Button Conflicts + if (buttonBlock_ && reason != PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY && + state == ScreenPowerState::POWER_ON) { + WLOGFI("[UL_POWER]SetScreenPowerForAll exit because buttonBlock_"); + buttonBlock_ = false; + return true; + } + switch (state) { case ScreenPowerState::POWER_ON: { + if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT) { + status = ScreenPowerStatus::POWER_STATUS_ON_ADVANCED; + WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON_ADVANCED"); + } else { + status = ScreenPowerStatus::POWER_STATUS_ON; + WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON"); + } keyguardDrawnDone_ = false; WLOGFI("[UL_POWER]SetScreenPowerForAll keyguardDrawnDone_ is false"); - status = ScreenPowerStatus::POWER_STATUS_ON; break; } case ScreenPowerState::POWER_OFF: { + if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF) { + status = ScreenPowerStatus::POWER_STATUS_OFF_ADVANCED; + WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_OFF_ADVANCED"); + } else { + status = ScreenPowerStatus::POWER_STATUS_OFF; + WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_OFF"); + } keyguardDrawnDone_ = false; WLOGFI("[UL_POWER]SetScreenPowerForAll keyguardDrawnDone_ is false"); - status = ScreenPowerStatus::POWER_STATUS_OFF; break; } default: { @@ -1027,6 +1110,7 @@ bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerSta return false; } } + prePowerStateChangeReason = reason; return SetScreenPower(status, reason); } @@ -1043,17 +1127,26 @@ bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateCh taskScheduler_->RemoveTask("screenOnTask"); } + // Handling Power Button Conflicts + if (buttonBlock_ && reason != PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY && + status != ScreenPowerStatus::POWER_STATUS_OFF) { + WLOGFI("[UL_POWER]SetScreenPower exit because buttonBlock_"); + buttonBlock_ = false; + return true; + } + if (foldScreenController_ != nullptr) { rsInterface_.SetScreenPowerStatus(foldScreenController_->GetCurrentScreenId(), status); } else { for (auto screenId : screenIds) { rsInterface_.SetScreenPowerStatus(screenId, status); - HandlerSensor(status); } } + HandlerSensor(status); if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_COLLABORATION) { return true; } + buttonBlock_ = false; return NotifyDisplayPowerEvent(status == ScreenPowerStatus::POWER_STATUS_ON ? DisplayPowerEvent::DISPLAY_ON : DisplayPowerEvent::DISPLAY_OFF, EventStatus::END, reason); } @@ -1066,7 +1159,8 @@ void ScreenSessionManager::SetKeyguardDrawnDoneFlag(bool flag) void ScreenSessionManager::HandlerSensor(ScreenPowerStatus status) { auto isPhone = system::GetParameter("const.product.devicetype", "unknown") == "phone"; - if (isPhone) { + auto isTablet = system::GetParameter("const.product.devicetype", "unknown") == "tablet"; + if (isPhone || isTablet) { if (status == ScreenPowerStatus::POWER_STATUS_ON) { WLOGFI("subscribe rotation sensor when phone turn on"); ScreenSensorConnector::SubscribeRotationSensor(); @@ -1679,10 +1773,8 @@ DMError ScreenSessionManager::DestroyVirtualScreen(ScreenId screenId) } // virtual screen destroy callback to notify scb - WLOGFI("destroy callback virtual screen"); + WLOGFI("destroy virtual screen"); OnVirtualScreenChange(screenId, ScreenEvent::DISCONNECTED); - - WLOGI("DestroyVirtualScreen Enter"); std::lock_guard lock(screenSessionMapMutex_); ScreenId rsScreenId = SCREEN_ID_INVALID; screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId); @@ -1753,6 +1845,15 @@ DMError ScreenSessionManager::DisableMirror(bool disableOrNot) return DMError::DM_OK; } +void ScreenSessionManager::MirrorSwitchNotify(ScreenId screenId) +{ + auto mirrorScreen = GetScreenSession(screenId); + if (mirrorScreen != nullptr && mirrorScreen->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) { + mirrorScreen->SetScreenCombination(ScreenCombination::SCREEN_MIRROR); + NotifyScreenChanged(mirrorScreen->ConvertToScreenInfo(), ScreenChangeEvent::SCREEN_SWITCH_CHANGE); + } +} + DMError ScreenSessionManager::MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenIds, ScreenId& screenGroupId) { @@ -1765,12 +1866,20 @@ DMError ScreenSessionManager::MakeMirror(ScreenId mainScreenId, std::vectorGetVirtualScreenFlag() != VirtualScreenFlag::CAST) { + continue; + } + OnVirtualScreenChange(screenId, ScreenEvent::DISCONNECTED); + } HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:MakeMirror"); auto mainScreen = GetScreenSession(mainScreenId); if (mainScreen == nullptr || allMirrorScreenIds.empty()) { @@ -1788,6 +1897,9 @@ DMError ScreenSessionManager::MakeMirror(ScreenId mainScreenId, std::vectorgroupSmsId_; + for (ScreenId screenId : allMirrorScreenIds) { + MirrorSwitchNotify(screenId); + } return DMError::DM_OK; } @@ -1843,6 +1955,85 @@ DMError ScreenSessionManager::StopScreens(const std::vector& screenIds return DMError::DM_OK; } +VirtualScreenFlag ScreenSessionManager::GetVirtualScreenFlag(ScreenId screenId) +{ + if (!SessionPermission::IsSystemCalling()) { + WLOGFE("permission denied!"); + return VirtualScreenFlag::DEFAULT; + } + auto screen = GetScreenSession(screenId); + if (screen == nullptr) { + WLOGFE("get virtual screen flag screen session null"); + return VirtualScreenFlag::DEFAULT; + } + return screen->GetVirtualScreenFlag(); +} + +DMError ScreenSessionManager::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) +{ + if (!SessionPermission::IsSystemCalling()) { + WLOGFE("permission denied!"); + return DMError::DM_ERROR_NOT_SYSTEM_APP; + } + if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) { + WLOGFE("set virtual screen flag range error"); + return DMError::DM_ERROR_INVALID_PARAM; + } + auto screen = GetScreenSession(screenId); + if (screen == nullptr) { + WLOGFE("set virtual screen flag screen session null"); + return DMError::DM_ERROR_INVALID_PARAM; + } + screen->SetVirtualScreenFlag(screenFlag); + return DMError::DM_OK; +} + +DMError ScreenSessionManager::MirrorUniqueSwitch(const std::vector& screenIds) +{ + WLOGFI("MirrorUniqueSwitch enter"); + auto defaultScreen = GetDefaultScreenSession(); + if (!defaultScreen) { + WLOGFE("Default screen is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + defaultScreen->groupSmsId_ = 1; + std::lock_guard lock(screenSessionMapMutex_); + auto iter = smsScreenGroupMap_.find(defaultScreen->groupSmsId_); + if (iter != smsScreenGroupMap_.end()) { + smsScreenGroupMap_.erase(iter); + } + for (ScreenId screenId : screenIds) { + auto screen = GetScreenSession(screenId); + if (screen == nullptr || screen->GetVirtualScreenFlag() != VirtualScreenFlag::CAST) { + continue; + } + OnVirtualScreenChange(screenId, ScreenEvent::DISCONNECTED); + } + ScreenId uniqueScreenId = screenIds[0]; + WLOGFI("disconnect virtual screen end make unique screenId %{public}" PRIu64".", uniqueScreenId); + auto group = GetAbstractScreenGroup(defaultScreen->groupSmsId_); + if (group == nullptr) { + group = AddToGroupLocked(defaultScreen); + if (group == nullptr) { + WLOGFE("group is nullptr"); + return DMError::DM_ERROR_NULLPTR; + } + NotifyScreenGroupChanged(defaultScreen->ConvertToScreenInfo(), ScreenGroupChangeEvent::ADD_TO_GROUP); + } + Point point; + std::vector startPoints; + startPoints.insert(startPoints.begin(), screenIds.size(), point); + ChangeScreenGroup(group, screenIds, startPoints, true, ScreenCombination::SCREEN_UNIQUE); + auto uniqueScreen = GetScreenSession(uniqueScreenId); + if (uniqueScreen != nullptr && uniqueScreen->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) { + uniqueScreen->SetScreenCombination(ScreenCombination::SCREEN_UNIQUE); + NotifyScreenChanged(uniqueScreen->ConvertToScreenInfo(), ScreenChangeEvent::SCREEN_SWITCH_CHANGE); + } + // virtual screen create callback to notify scb + OnVirtualScreenChange(uniqueScreenId, ScreenEvent::CONNECTED); + return DMError::DM_OK; +} + DMError ScreenSessionManager::MakeUniqueScreen(const std::vector& screenIds) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { @@ -1854,12 +2045,17 @@ DMError ScreenSessionManager::MakeUniqueScreen(const std::vector& scre WLOGFE("MakeUniqueScreen screen is empty"); return DMError::DM_ERROR_INVALID_PARAM; } + ScreenId uniqueScreenId = screenIds[0]; + auto uniqueScreen = GetScreenSession(uniqueScreenId); + if (uniqueScreen != nullptr && uniqueScreen->GetVirtualScreenFlag() == VirtualScreenFlag::CAST) { + return MirrorUniqueSwitch(screenIds); + } for (auto screenId : screenIds) { ScreenId rsScreenId = SCREEN_ID_INVALID; bool res = ConvertScreenIdToRsScreenId(screenId, rsScreenId); WLOGFI("unique screenId: %{public}" PRIu64" rsScreenId: %{public}" PRIu64"", screenId, rsScreenId); if (!res) { - WLOGFE("convert screenid to rsScreenId failed"); + WLOGFE("convert screenId to rsScreenId failed"); continue; } auto screenSession = GetScreenSession(screenId); @@ -1879,7 +2075,6 @@ DMError ScreenSessionManager::MakeUniqueScreen(const std::vector& scre return DMError::DM_OK; } - DMError ScreenSessionManager::MakeExpand(std::vector screenId, std::vector startPoint, ScreenId& screenGroupId) diff --git a/window_scene/session_manager/src/session_display_power_controller.cpp b/window_scene/session_manager/src/session_display_power_controller.cpp index 6bb75bf52..5f7da18e3 100644 --- a/window_scene/session_manager/src/session_display_power_controller.cpp +++ b/window_scene/session_manager/src/session_display_power_controller.cpp @@ -34,11 +34,11 @@ bool SessionDisplayPowerController::SuspendBegin(PowerStateChangeReason reason) bool SessionDisplayPowerController::SetDisplayState(DisplayState state) { - WLOGFI("state:%{public}u", state); + WLOGFI("[UL_POWER]state:%{public}u", state); { std::lock_guard lock(mutex_); - if (displayState_ == state) { - WLOGFE("state is already set"); + if (displayState_ == state && ScreenSessionManager::GetInstance().BlockSetDisplayState()) { + WLOGFE("[UL_POWER]state is already set"); return false; } } @@ -67,7 +67,7 @@ bool SessionDisplayPowerController::SetDisplayState(DisplayState state) break; } default: { - WLOGFW("unknown DisplayState!"); + WLOGFW("[UL_POWER]unknown DisplayState!"); return false; } } @@ -83,7 +83,7 @@ DisplayState SessionDisplayPowerController::GetDisplayState(DisplayId displayId) void SessionDisplayPowerController::NotifyDisplayEvent(DisplayEvent event) { - WLOGFI("DisplayEvent:%{public}u", event); + WLOGFI("[UL_POWER]DisplayEvent:%{public}u", event); if (event == DisplayEvent::UNLOCK) { std::map> emptyMap; displayStateChangeListener_(DISPLAY_ID_INVALID, nullptr, emptyMap, DisplayStateChangeType::BEFORE_UNLOCK); diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp index 83a748ad1..225b53527 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -2166,4 +2166,55 @@ void ScreenSessionManagerProxy::NotifyFoldToExpandCompletion(bool foldToExpand) return; } } + +VirtualScreenFlag ScreenSessionManagerProxy::GetVirtualScreenFlag(ScreenId screenId) +{ + if (screenId == SCREEN_ID_INVALID) { + return VirtualScreenFlag::DEFAULT; + } + MessageOption option(MessageOption::TF_SYNC); + MessageParcel reply; + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return VirtualScreenFlag::DEFAULT; + } + if (!data.WriteUint64(screenId)) { + WLOGFE("Write screenId failed"); + return VirtualScreenFlag::DEFAULT; + } + if (Remote()->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_GET_VIRTUAL_SCREEN_FLAG), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return VirtualScreenFlag::DEFAULT; + } + return static_cast(reply.ReadUint32()); +} + +DMError ScreenSessionManagerProxy::SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) +{ + if (screenId == SCREEN_ID_INVALID) { + return DMError::DM_ERROR_INVALID_PARAM; + } + if (screenFlag < VirtualScreenFlag::DEFAULT || screenFlag >= VirtualScreenFlag::MAX) { + return DMError::DM_ERROR_INVALID_PARAM; + } + MessageOption option(MessageOption::TF_ASYNC); + MessageParcel reply; + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("WriteInterfaceToken failed"); + return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteUint64(screenId) || !data.WriteUint32(static_cast(screenFlag))) { + WLOGFE("Write screenId or screenFlag failed"); + return DMError::DM_ERROR_WRITE_DATA_FAILED; + } + if (Remote()->SendRequest(static_cast(DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_FLAG), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return DMError::DM_ERROR_IPC_FAILED; + } + return static_cast(reply.ReadInt32()); +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp index 54c3f10f9..1059d599e 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp @@ -652,6 +652,19 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& NotifyFoldToExpandCompletion(foldToExpand); break; } + case DisplayManagerMessage::TRANS_ID_GET_VIRTUAL_SCREEN_FLAG: { + ScreenId screenId = static_cast(data.ReadUint64()); + VirtualScreenFlag screenFlag = GetVirtualScreenFlag(screenId); + reply.WriteUint32(static_cast(screenFlag)); + break; + } + case DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_FLAG: { + ScreenId screenId = static_cast(data.ReadUint64()); + VirtualScreenFlag screenFlag = static_cast(data.ReadUint32()); + DMError setRet = SetVirtualScreenFlag(screenId, screenFlag); + reply.WriteInt32(static_cast(setRet)); + break; + } default: WLOGFW("unknown transaction code"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); diff --git a/window_scene/test/mock/mock_session_stage.h b/window_scene/test/mock/mock_session_stage.h index e5abb9b77..28d3d5a29 100644 --- a/window_scene/test/mock/mock_session_stage.h +++ b/window_scene/test/mock/mock_session_stage.h @@ -34,6 +34,8 @@ public: MOCK_METHOD0(NotifyDestroy, WSError(void)); MOCK_METHOD1(UpdateFocus, WSError(bool isFocused)); MOCK_METHOD1(NotifyTransferComponentData, WSError(const AAFwk::WantParams& wantParams)); + MOCK_METHOD2(NotifyTransferComponentDataSync, WSErrorCode(const AAFwk::WantParams& wantParams, + AAFwk::WantParams& reWantParams)); MOCK_METHOD1(MarkProcessed, WSError(int32_t eventId)); MOCK_METHOD1(NotifyOccupiedAreaChangeInfo, void(sptr info)); MOCK_METHOD2(UpdateAvoidArea, WSError(const sptr& avoidArea, AvoidAreaType type)); @@ -50,8 +52,10 @@ public: MOCK_METHOD1(UpdateWindowDrawingContentInfo, void(const WindowDrawingContentInfo& info)); MOCK_METHOD1(NotifyWindowVisibility, WSError(bool isVisible)); MOCK_METHOD1(NotifyTransformChange, void(const Transform& transform)); + MOCK_METHOD1(NotifyDialogStateChange, WSError(bool isForeground)); MOCK_METHOD2(SetPipActionEvent, WSError(const std::string& action, int32_t status)); MOCK_METHOD1(UpdateDisplayId, WSError(uint64_t displayId)); + MOCK_METHOD2(NotifyDisplayMove, void(DisplayId from, DisplayId to)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/mock/mock_session_stub.h b/window_scene/test/mock/mock_session_stub.h index 3c44015a8..460178658 100644 --- a/window_scene/test/mock/mock_session_stub.h +++ b/window_scene/test/mock/mock_session_stub.h @@ -69,6 +69,7 @@ public: MOCK_METHOD2(HandleTransferExtensionData, int(MessageParcel &data, MessageParcel &reply)); MOCK_METHOD2(HandleNotifyRemoteReady, int(MessageParcel &data, MessageParcel &reply)); MOCK_METHOD2(HandleNotifyExtensionDied, int(MessageParcel &data, MessageParcel &reply)); + MOCK_METHOD2(HandleNotifyExtensionTimeout, int(MessageParcel &data, MessageParcel &reply)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 7157473dd..706aafd5a 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -1789,6 +1789,38 @@ HWTEST_F(SceneSessionManagerTest, GetSceneSessionVectorByType, Function | SmallT ASSERT_EQ(ret, 0); } +/** + * @tc.name: StartUIAbilityBySCB + * @tc.desc: StartUIAbilityBySCB + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, StartUIAbilityBySCB, Function | SmallTest | Level3) +{ + SessionInfo info; + info.abilityName_ = "StartUIAbilityBySCB"; + info.bundleName_ = "StartUIAbilityBySCB"; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sceneSession->SetSessionState(SessionState::STATE_ACTIVE); + int32_t ret = ssm_->StartUIAbilityBySCB(sceneSession); + EXPECT_EQ(ret, 2097202); +} + +/** + * @tc.name: ChangeUIAbilityVisibilityBySCB + * @tc.desc: ChangeUIAbilityVisibilityBySCB + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, ChangeUIAbilityVisibilityBySCB, Function | SmallTest | Level3) +{ + SessionInfo info; + info.abilityName_ = "ChangeUIAbilityVisibilityBySCB"; + info.bundleName_ = "ChangeUIAbilityVisibilityBySCB"; + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + sceneSession->SetSessionState(SessionState::STATE_ACTIVE); + int32_t ret = ssm_->ChangeUIAbilityVisibilityBySCB(sceneSession, true); + EXPECT_EQ(ret, 2097202); +} + /** * @tc.name: RegisterInputMethodShownFunc * @tc.desc: SceneSesionManager register input method show func diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 4fef236f5..e10a701f1 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -2767,37 +2767,6 @@ HWTEST_F(SceneSessionTest, SetLastSafeRect, Function | SmallTest | Level2) EXPECT_EQ(6, result.height_); } -/** - * @tc.name: RecoveryPullPiPMainWindow - * @tc.desc: * @tc.name: RecoveryPullPiPMainWindow - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionTest, RecoveryPullPiPMainWindow, Function | SmallTest | Level2) -{ - SessionInfo info; - info.abilityName_ = "SetLastSafeRect"; - info.bundleName_ = "SetLastSafeRect"; - sptr scensession; - sptr specificSession = - new SceneSession::SpecificSessionCallback(); - scensession = new (std::nothrow) SceneSession(info, specificSession); - Rect rec = {3, 4, 5, 6}; - scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback(); - auto prepareClosePiPSessionFunc = [scensession]() { - scensession->NotifyUILostFocus(); - }; - scensession->sessionChangeCallback_->onPrepareClosePiPSession_ = prepareClosePiPSessionFunc; - auto recoveryPullPiPMainWindowFunc = [scensession](int32_t persistentId, Rect rect) { - rect.posX_ = persistentId; - rect.posY_ = persistentId; - rect.width_ = persistentId; - rect.height_ = persistentId; - }; - scensession->specificCallback_->onRecoveryPullPiPMainWindow_ = recoveryPullPiPMainWindowFunc; - scensession->NotifyPiPWindowPrepareClose(); - EXPECT_EQ(WSError::WS_OK, scensession->RecoveryPullPiPMainWindow(5, rec)); -} - /** * @tc.name: GetSessionTargetRect * @tc.desc: * @tc.name: GetSessionTargetRect @@ -2829,32 +2798,6 @@ HWTEST_F(SceneSessionTest, GetSessionTargetRect, Function | SmallTest | Level2) EXPECT_NE(nullptr, scensession->moveDragController_); } -/** - * @tc.name: OnPiPMoveCallback - * @tc.desc: * @tc.name: OnPiPMoveCallback - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionTest, OnPiPMoveCallback, Function | SmallTest | Level2) -{ - SessionInfo info; - info.abilityName_ = "OnPiPMoveCallback"; - info.bundleName_ = "SetTextFieldAvoidInfo"; - sptr scensession; - sptr specificSession = - new SceneSession::SpecificSessionCallback(); - scensession = new (std::nothrow) SceneSession(info, specificSession); - WSError res = scensession->SetTextFieldAvoidInfo(3.1415927, 2.718); - EXPECT_EQ(WSError::WS_OK, res); - sptr session = new (std::nothrow) Session(info); - EXPECT_NE(nullptr, session->property_); - sptr property = new WindowSessionProperty(); - property->SetWindowType(WindowType::WINDOW_TYPE_PIP); - WSRect rect = {5, 6, 7, 8}; - scensession->OnPiPMoveCallback(rect, SizeChangeReason::MOVE); - scensession->OnPiPMoveCallback(rect, SizeChangeReason::DRAG_END); - EXPECT_EQ(WindowType::WINDOW_TYPE_PIP, property->GetWindowType()); -} - /* * @tc.name: SetPipActionEvent * @tc.desc: * @tc.name: SetPipActionEvent @@ -2950,6 +2893,32 @@ HWTEST_F(SceneSessionTest, AddOrRemoveSecureExtSession, Function | SmallTest | L sceneSession->AddOrRemoveSecureExtSession(12345, false); EXPECT_TRUE(sceneSession->secureExtSessionSet_.empty()); } + +/** + * @tc.name: ChangeSessionVisibilityWithStatusBar + * @tc.desc: * @tc.name: ChangeSessionVisibilityWithStatusBar + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, ChangeSessionVisibilityWithStatusBar, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "ChangeSessionVisibilityWithStatusBar"; + info.bundleName_ = "ChangeSessionVisibilityWithStatusBar"; + + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sceneSession->isActive_ = true; + + sptr info1 = nullptr; + WSError result = sceneSession->ChangeSessionVisibilityWithStatusBar(info1, false); + ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); + + sptr abilitySessionInfo = new AAFwk::SessionInfo(); + result = sceneSession->ChangeSessionVisibilityWithStatusBar(abilitySessionInfo, false); + ASSERT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION); + delete sceneSession; +} + } } } \ No newline at end of file diff --git a/window_scene/test/unittest/session_proxy_test.cpp b/window_scene/test/unittest/session_proxy_test.cpp index 705a717ee..16a623cae 100644 --- a/window_scene/test/unittest/session_proxy_test.cpp +++ b/window_scene/test/unittest/session_proxy_test.cpp @@ -430,6 +430,21 @@ HWTEST_F(SessionProxyTest, NotifyExtensionDied, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionDied end"; } +/** + * @tc.name: NotifyExtensionTimeout + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(SessionProxyTest, NotifyExtensionTimeout, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeout start"; + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + SessionProxy* sProxy = new(std::nothrow) SessionProxy(iRemoteObjectMocker); + sProxy->NotifyExtensionTimeout(2); + + GTEST_LOG_(INFO) << "SessionProxyTest: NotifyExtensionTimeout end"; +} + /** * @tc.name: UpdateWindowAnimationFlag * @tc.desc: normal function diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index ba623d1e1..6b046456c 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -172,6 +172,8 @@ HWTEST_F(SessionStubTest, sessionStubTest02, Function | SmallTest | Level2) ASSERT_EQ(0, res); res = session_->HandleNotifyExtensionDied(data, reply); ASSERT_EQ(0, res); + res = session_->HandleNotifyExtensionTimeout(data, reply); + ASSERT_EQ(0, res); } /** @@ -238,22 +240,6 @@ HWTEST_F(SessionStubTest, HandleUpdatePiPRect004, Function | SmallTest | Level2) ASSERT_EQ(0, res); } -/** - * @tc.name: HandleRecoveryPullPiPMainWindow005 - * @tc.desc: sessionStub sessionStubTest - * @tc.type: FUNC - * @tc.require: #I6JLSI - */ -HWTEST_F(SessionStubTest, HandleRecoveryPullPiPMainWindow005, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - data.WriteBool(true); - sptr iRemoteObjectMocker = new IRemoteObjectMocker(); - auto res = session_->HandleRecoveryPullPiPMainWindow(data, reply); - ASSERT_EQ(0, res); -} - /** * @tc.name: HandleProcessPointDownSession006 * @tc.desc: sessionStub sessionStubTest diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index c937029e8..d14df4192 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -43,7 +43,8 @@ public: WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; WSError TransferPointerEvent(const std::shared_ptr& pointerEvent) override; WSError TransferFocusActiveEvent(bool isFocusActive) override; - WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) override; + WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, + bool isPreImeEvent = false) override; WSError TransferFocusState(bool focusState) override; WSError TransferBackpressedEventForConsumed(bool& isConsumed) override; WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent, @@ -56,6 +57,8 @@ public: Accessibility::AccessibilityElementInfo& info) override; WSError TransferExecuteAction(int64_t elementId, const std::map& actionArguments, int32_t action, int64_t baseParent) override; + WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) override; sptr AsObject() override { @@ -79,7 +82,7 @@ WSError TestWindowEventChannel::TransferFocusActiveEvent(bool isFocusActive) } WSError TestWindowEventChannel::TransferKeyEventForConsumed( - const std::shared_ptr& keyEvent, bool& isConsumed) + const std::shared_ptr& keyEvent, bool& isConsumed, bool isPreImeEvent) { return WSError::WS_OK; } @@ -124,6 +127,12 @@ WSError TestWindowEventChannel::TransferExecuteAction(int64_t elementId, return WSError::WS_OK; } +WSError TestWindowEventChannel::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, + int32_t eventType, int64_t timeMs) +{ + return WSError::WS_OK; +} + class WindowSessionTest : public testing::Test { public: static void SetUpTestCase(); @@ -1257,6 +1266,20 @@ HWTEST_F(WindowSessionTest, NotifyExtensionDied, Function | SmallTest | Level2) ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false)); } +/** + * @tc.name: NotifyExtensionTimeout + * @tc.desc: NotifyExtensionTimeout Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest, NotifyExtensionTimeout, Function | SmallTest | Level2) +{ + ASSERT_NE(session_, nullptr); + session_->state_ = SessionState::STATE_DISCONNECT; + session_->NotifyExtensionTimeout(3); + + ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false)); +} + /** * @tc.name: SetAspectRatio * @tc.desc: SetAspectRatio Test @@ -2881,6 +2904,34 @@ HWTEST_F(WindowSessionTest, IsTerminated49, Function | SmallTest | Level2) ASSERT_EQ(false, res); } +/** + * @tc.name: SetSystemActive48 + * @tc.desc: SetSystemActive + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest, SetChangeSessionVisibilityWithStatusBarEventListener, Function | SmallTest | Level2) +{ + int resultValue = 0; + NotifyChangeSessionVisibilityWithStatusBarFunc func1 = [&resultValue](SessionInfo& info, const bool visible) { + resultValue = 1; + }; + NotifyChangeSessionVisibilityWithStatusBarFunc func2 = [&resultValue](SessionInfo& info, const bool visible) { + resultValue = 2; + }; + + session_->SetChangeSessionVisibilityWithStatusBarEventListener(func1); + ASSERT_NE(session_->changeSessionVisibilityWithStatusBarFunc_, nullptr); + + SessionInfo info; + session_->changeSessionVisibilityWithStatusBarFunc_(info, true); + ASSERT_EQ(resultValue, 1); + + session_->SetChangeSessionVisibilityWithStatusBarEventListener(func2); + ASSERT_NE(session_->changeSessionVisibilityWithStatusBarFunc_, nullptr); + session_->changeSessionVisibilityWithStatusBarFunc_(info, true); + ASSERT_EQ(resultValue, 2); +} + } } // namespace Rosen -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/wm/include/picture_in_picture_controller.h b/wm/include/picture_in_picture_controller.h index 6cc496df6..273120bef 100644 --- a/wm/include/picture_in_picture_controller.h +++ b/wm/include/picture_in_picture_controller.h @@ -62,8 +62,6 @@ public: void SetAutoStartEnabled(bool enable); void IsAutoStartEnabled(bool& enable) const; void UpdateContentSize(int32_t width, int32_t height); - void StartMove(); - void DoScale(); void DoActionEvent(const std::string& actionName, int32_t status); void RestorePictureInPictureWindow(); void SetPictureInPictureLifecycle(sptr listener); diff --git a/wm/include/picture_in_picture_manager.h b/wm/include/picture_in_picture_manager.h index 748439435..f571d0090 100644 --- a/wm/include/picture_in_picture_manager.h +++ b/wm/include/picture_in_picture_manager.h @@ -45,8 +45,6 @@ public: static void DoRestore(); static void DoClose(bool destroyWindow, bool needAnim); - static void DoStartMove(); - static void DoScale(); static void DoActionEvent(const std::string& actionName, int32_t status); static void AutoStartPipWindow(std::string navigationId); private: diff --git a/wm/include/root_scene.h b/wm/include/root_scene.h index 91473995e..54e6d42fa 100644 --- a/wm/include/root_scene.h +++ b/wm/include/root_scene.h @@ -55,6 +55,8 @@ public: density_ = density; } + void SetDisplayOrientation(int32_t orientation); + float GetDisplayDensity() { return density_; @@ -94,6 +96,7 @@ private: std::shared_ptr eventHandler_; sptr launcherService_; float density_ = 1.0f; + int32_t orientation_; WindowType type_ = WindowType::WINDOW_TYPE_SCENE_BOARD; std::string name_ = "EntryView"; std::function frameLayoutFinishCb_ = nullptr; diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index 9b8307077..4e69aaba8 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -58,6 +58,8 @@ public: Accessibility::AccessibilityElementInfo& info) override; WSError NotifyExecuteAction(int64_t elementId, const std::map& actionAguments, int32_t action, int64_t baseParent) override; + WSError NotifyAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, + int64_t timeMs) override; WMError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; WMError Destroy(bool needNotifyServer, bool needClearListener = true) override; diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index 9ff6ff259..d3beb2472 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -262,7 +262,7 @@ public: void UpdateZoomTransform(const Transform& trans, bool isDisplayZoomOn); void PerformBack() override; void NotifyForegroundInteractiveStatus(bool interactive); - + virtual bool PreNotifyKeyEvent(const std::shared_ptr& keyEvent) override; virtual WMError NapiSetUIContent(const std::string& contentInfo, napi_env env, napi_value storage, bool isdistributed, sptr token, AppExecFwk::Ability* ability) override; virtual WMError SetUIContentByName(const std::string& contentInfo, napi_env env, napi_value storage, diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 67b746887..6b9f8cb20 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -51,12 +51,12 @@ public: WMError SetTextFieldAvoidInfo(double textFieldPositionY, double textFieldHeight) override; void PreProcessCreate(); void SetDefaultProperty(); - WSError SetActive(bool active) override; WMError DisableAppWindowDecor() override; bool IsDecorEnable() const override; WMError Minimize() override; WMError MaximizeFloating() override; WMError Maximize() override; + WMError Maximize(MaximizeLayoutOption option) override; WMError Recover() override; WMError Recover(uint32_t reason) override; void StartMove() override; @@ -133,10 +133,10 @@ public: void NotifySessionForeground(uint32_t reason, bool withAnimation) override; void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WMError NotifyPrepareClosePiPWindow() override; - WMError RecoveryPullPiPMainWindow(const Rect& rect) override; void UpdateSubWindowState(const WindowType& type); WMError SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) override; void ConsumePointerEvent(const std::shared_ptr& pointerEvent) override; + void ConsumeKeyEvent(std::shared_ptr& keyEvent) override; WSError NotifyDialogStateChange(bool isForeground) override; WMError HideNonSecureWindows(bool shouldHide) override; diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 8029fd563..f8c63a397 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -49,6 +49,8 @@ public: ~WindowSessionImpl(); void ConsumePointerEvent(const std::shared_ptr& pointerEvent) override; void ConsumeKeyEvent(std::shared_ptr& inputEvent) override; + bool PreNotifyKeyEvent(const std::shared_ptr& keyEvent) override; + virtual bool NotifyOnKeyPreImeEvent(const std::shared_ptr& keyEvent) override; static sptr Find(const std::string& name); static std::vector> GetSubWindow(int parentId); // inherits from window @@ -116,9 +118,12 @@ public: bool notifyInputMethod = true) override; void NotifyOccupiedAreaChangeInfo(sptr info) override; void NotifyForegroundInteractiveStatus(bool interactive) override; + void NotifyDisplayMove(DisplayId from, DisplayId to) override; WMError RegisterLifeCycleListener(const sptr& listener) override; WMError UnregisterLifeCycleListener(const sptr& listener) override; + WMError RegisterDisplayMoveListener(sptr& listener) override; + WMError UnregisterDisplayMoveListener(sptr& listener) override; WMError RegisterWindowChangeListener(const sptr& listener) override; WMError UnregisterWindowChangeListener(const sptr& listener) override; WMError RegisterAvoidAreaChangeListener(sptr& listener) override; @@ -133,6 +138,9 @@ public: WMError UnregisterTouchOutsideListener(const sptr& listener) override; WMError RegisterWindowVisibilityChangeListener(const IWindowVisibilityListenerSptr& listener) override; WMError UnregisterWindowVisibilityChangeListener(const IWindowVisibilityListenerSptr& listener) override; + WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, + uint32_t timeout) override; + WMError UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) override; void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) override; WMError RegisterScreenshotListener(const sptr& listener) override; WMError UnregisterScreenshotListener(const sptr& listener) override; @@ -157,6 +165,9 @@ public: void UpdateTitleButtonVisibility(); WSError NotifyDestroy() override; WSError NotifyCloseExistPipWindow() override; + WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) override; + WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, + AAFwk::WantParams& reWantParams) override; void NotifyAvoidAreaChange(const sptr& avoidArea, AvoidAreaType type); WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; void NotifyTouchDialogTarget(int32_t posX = 0, int32_t posY = 0) override; @@ -167,7 +178,9 @@ public: virtual void SetColorSpace(ColorSpace colorSpace) override; virtual ColorSpace GetColorSpace() override; WSError NotifyTouchOutside() override; + WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; WSError NotifyWindowVisibility(bool isVisible) override; + WSError NotifyNoInteractionTimeout(); WMError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; WindowState state_ { WindowState::STATE_INITIAL }; @@ -176,6 +189,7 @@ public: void NotifySessionForeground(uint32_t reason, bool withAnimation) override; void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WSError UpdateTitleInTargetPos(bool isShow, int32_t height) override; + WSError NotifyDialogStateChange(bool isForeground) override; bool IsMainHandlerAvailable() const override; WSError SetPipActionEvent(const std::string& action, int32_t status) override; @@ -184,6 +198,7 @@ public: WMError RegisterWindowStatusChangeListener(const sptr& listener) override; WMError UnregisterWindowStatusChangeListener(const sptr& listener) override; WMError SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) override; + virtual WMError SetSubWindowModal(bool isModal) override; virtual WMError SetDecorVisible(bool isVisible) override; virtual WMError SetDecorHeight(int32_t decorHeight) override; virtual WMError GetDecorHeight(int32_t& height) override; @@ -225,6 +240,8 @@ protected: WMError RegisterExtensionAvoidAreaChangeListener(sptr& listener); WMError UnregisterExtensionAvoidAreaChangeListener(sptr& listener); + void RefreshNoInteractionTimeoutMonitor(int32_t eventId); + sptr hostSession_; std::unique_ptr uiContent_; std::shared_ptr context_; @@ -259,6 +276,7 @@ private: template WMError RegisterListener(std::vector>& holder, const sptr& listener); template WMError UnregisterListener(std::vector>& holder, const sptr& listener); template EnableIfSame>> GetListeners(); + template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template @@ -276,6 +294,8 @@ private: template EnableIfSame> GetListeners(); template + EnableIfSame> GetListeners(); + template EnableIfSame>> GetListeners(); template void ClearUselessListeners(std::map& listeners, int32_t persistentId); @@ -306,9 +326,12 @@ private: static std::recursive_mutex screenshotListenerMutex_; static std::recursive_mutex touchOutsideListenerMutex_; static std::recursive_mutex windowVisibilityChangeListenerMutex_; + static std::recursive_mutex windowNoInteractionListenerMutex_; static std::recursive_mutex windowStatusChangeListenerMutex_; static std::recursive_mutex windowTitleButtonRectChangeListenerMutex_; + static std::recursive_mutex displayMoveListenerMutex_; static std::map>> lifecycleListeners_; + static std::map>> displayMoveListeners_; static std::map>> windowChangeListeners_; static std::map>> avoidAreaChangeListeners_; static std::map>> dialogDeathRecipientListeners_; @@ -317,6 +340,7 @@ private: static std::map>> screenshotListeners_; static std::map>> touchOutsideListeners_; static std::map> windowVisibilityChangeListeners_; + static std::map> windowNoInteractionListeners_; static std::map>> windowStatusChangeListeners_; static std::map>> windowTitleButtonRectChangeListeners_; @@ -324,6 +348,9 @@ private: // FA only sptr aceAbilityHandler_; + std::atomic lastInteractionEventId_ { -1 }; + std::atomic noInteractionTimeout_ { 0 }; // ms + WindowSizeChangeReason lastSizeChangeReason_ = WindowSizeChangeReason::END; bool postTaskDone_ = false; int16_t rotationAnimationCount_ { 0 }; diff --git a/wm/src/picture_in_picture_controller.cpp b/wm/src/picture_in_picture_controller.cpp index ef7704a06..6c172b9a1 100644 --- a/wm/src/picture_in_picture_controller.cpp +++ b/wm/src/picture_in_picture_controller.cpp @@ -29,8 +29,6 @@ namespace OHOS { namespace Rosen { namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "PictureInPictureController"}; - constexpr int32_t DELAY_ANIM = 500; constexpr int32_t SUCCESS = 1; constexpr int32_t FAILED = 0; constexpr uint32_t PIP_LOW_PRIORITY = 0; @@ -40,7 +38,7 @@ namespace { static uint32_t GetPipPriority(uint32_t pipTemplateType) { if (pipTemplateType < 0 || pipTemplateType >= static_cast(PipTemplateType::END)) { - WLOGFE("param invalid, pipTemplateType is %{public}d", pipTemplateType); + TLOGE(WmsLogTag::WMS_PIP, "param invalid, pipTemplateType is %{public}d", pipTemplateType); return PIP_LOW_PRIORITY; } if (pipTemplateType == static_cast(PipTemplateType::VIDEO_PLAY) || @@ -66,10 +64,10 @@ PictureInPictureController::~PictureInPictureController() WMError PictureInPictureController::CreatePictureInPictureWindow() { - WLOGI("CreatePictureInPictureWindow is called, mainWindow:%{public}u", mainWindowId_); + TLOGI(WmsLogTag::WMS_PIP, "CreatePictureInPictureWindow is called, mainWindow:%{public}u", mainWindowId_); sptr thisController = this; if (pipOption_ == nullptr || pipOption_->GetContext() == nullptr) { - WLOGFE("Get PictureInPictureOption failed"); + TLOGE(WmsLogTag::WMS_PIP, "Create pip failed, invalid pipOption"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } auto context = static_cast*>(pipOption_->GetContext()); @@ -77,12 +75,11 @@ WMError PictureInPictureController::CreatePictureInPictureWindow() SingletonContainer::Get().SetCurrentPackageName(abilityContext->GetApplicationInfo()->name); sptr windowOption = new(std::nothrow) WindowOption(); if (windowOption == nullptr) { - WLOGFE("Get WindowOption failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } mainWindowXComponentController_ = pipOption_->GetXComponentController(); if (mainWindowXComponentController_ == nullptr || mainWindow_ == nullptr) { - WLOGFE("mainWindowXComponentController or main window is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "mainWindowXComponentController or mainWindow is nullptr"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } UpdateXComponentPositionAndSize(); @@ -98,7 +95,7 @@ WMError PictureInPictureController::CreatePictureInPictureWindow() pipTemplateInfo.priority = GetPipPriority(pipOption_->GetPipTemplate()); sptr window = Window::CreatePiP(windowOption, pipTemplateInfo, context->lock(), errCode); if (window == nullptr || errCode != WMError::WM_OK) { - WLOGFE("Window create failed, reason: %{public}d", errCode); + TLOGE(WmsLogTag::WMS_PIP, "Window create failed, reason: %{public}d", errCode); return WMError::WM_ERROR_PIP_CREATE_FAILED; } window_ = window; @@ -109,30 +106,30 @@ WMError PictureInPictureController::CreatePictureInPictureWindow() WMError PictureInPictureController::ShowPictureInPictureWindow(StartPipType startType) { - WLOGD("ShowPictureInPictureWindow is called"); + TLOGD(WmsLogTag::WMS_PIP, "ShowPictureInPictureWindow is called"); if (window_ == nullptr) { - WLOGFD("window_ is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "window is null when show pip"); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), - pipOption_->GetPipTemplate(), FAILED, "window_ is nullptr"); + pipOption_->GetPipTemplate(), FAILED, "window is nullptr"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; } if (pipLifeCycleListener_ != nullptr) { pipLifeCycleListener_->OnPreparePictureInPictureStart(); } if (pipOption_ == nullptr) { - WLOGFE("Get PictureInPicture option failed"); + TLOGE(WmsLogTag::WMS_PIP, "Get PictureInPicture option failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } window_->SetUIContentByAbc(PIP_CONTENT_PATH, env_, nullptr, nullptr); WMError errCode = window_->Show(0, false); if (errCode != WMError::WM_OK) { - WLOGFD("window_ show failed, err: %{public}u", errCode); + TLOGE(WmsLogTag::WMS_PIP, "window show failed, err: %{public}u", errCode); int32_t err = static_cast(errCode); if (pipLifeCycleListener_ != nullptr) { pipLifeCycleListener_->OnPictureInPictureOperationError(err); } SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), - pipOption_->GetPipTemplate(), FAILED, "window_ show failed"); + pipOption_->GetPipTemplate(), FAILED, "window show failed"); return WMError::WM_ERROR_PIP_INTERNAL_ERROR; } uint32_t requestWidth = 0; @@ -152,25 +149,25 @@ WMError PictureInPictureController::ShowPictureInPictureWindow(StartPipType star WMError PictureInPictureController::StartPictureInPicture(StartPipType startType) { - WLOGI("StartPictureInPicture called"); + TLOGI(WmsLogTag::WMS_PIP, "StartPictureInPicture called"); std::lock_guard lock(mutex_); if (curState_ == PipWindowState::STATE_STARTING || curState_ == PipWindowState::STATE_STARTED) { - WLOGFW("pip window is starting, state: %{public}u, pipWindow: %{public}u, mainWindow: %{public}u", + TLOGW(WmsLogTag::WMS_PIP, "pipWindow is starting, state: %{public}u, id: %{public}u, mainWindow: %{public}u", curState_, window_->GetWindowId(), mainWindowId_); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), pipOption_->GetPipTemplate(), FAILED, "Pip window is starting"); return WMError::WM_ERROR_PIP_REPEAT_OPERATION; } if (pipOption_ == nullptr || pipOption_->GetContext() == nullptr) { - WLOGFE("Get PictureInPictureOption failed"); + TLOGE(WmsLogTag::WMS_PIP, "Get PictureInPictureOption failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } if (mainWindow_ == nullptr) { - WLOGFE("Init main window failed"); + TLOGE(WmsLogTag::WMS_PIP, "Init main window failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } if (!IsPullPiPAndHandleNavigation()) { - WLOGFE("Navigation operate failed"); + TLOGE(WmsLogTag::WMS_PIP, "Navigation operate failed"); return WMError::WM_ERROR_PIP_CREATE_FAILED; } curState_ = PipWindowState::STATE_STARTING; @@ -178,7 +175,7 @@ WMError PictureInPictureController::StartPictureInPicture(StartPipType startType // if current controller is not the active one, but belongs to the same mainWindow, reserve pipWindow if (PictureInPictureManager::IsAttachedToSameWindow(mainWindowId_)) { window_ = PictureInPictureManager::GetCurrentWindow(); - WLOGFD("Reuse pipWindow: %{public}u as attached to the same mainWindow: %{public}u", + TLOGE(WmsLogTag::WMS_PIP, "Reuse pipWindow: %{public}u as attached to the same mainWindow: %{public}u", window_->GetWindowId(), mainWindowId_); PictureInPictureManager::DoClose(false, false); mainWindowXComponentController_ = pipOption_->GetXComponentController(); @@ -204,7 +201,7 @@ WMError PictureInPictureController::StartPictureInPictureInner(StartPipType star WMError errCode = CreatePictureInPictureWindow(); if (errCode != WMError::WM_OK) { curState_ = PipWindowState::STATE_UNDEFINED; - WLOGFE("Create pip window failed, err: %{public}u", errCode); + TLOGE(WmsLogTag::WMS_PIP, "Create pip window failed, err: %{public}u", errCode); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), pipOption_->GetPipTemplate(), FAILED, "Create pip window failed"); return errCode; @@ -212,7 +209,7 @@ WMError PictureInPictureController::StartPictureInPictureInner(StartPipType star errCode = ShowPictureInPictureWindow(startType); if (errCode != WMError::WM_OK) { curState_ = PipWindowState::STATE_UNDEFINED; - WLOGFE("Show pip window failed, err: %{public}u", errCode); + TLOGE(WmsLogTag::WMS_PIP, "Show pip window failed, err: %{public}u", errCode); SingletonContainer::Get().ReportPiPStartWindow(static_cast(startType), pipOption_->GetPipTemplate(), FAILED, "Show pip window failed"); return errCode; @@ -226,13 +223,13 @@ WMError PictureInPictureController::StartPictureInPictureInner(StartPipType star WMError PictureInPictureController::StopPictureInPictureFromClient() { if (!window_) { - WLOGFE("window is null"); + TLOGE(WmsLogTag::WMS_PIP, "window is null"); SingletonContainer::Get().ReportPiPStopWindow(static_cast(StopPipType::USER_STOP), pipOption_->GetPipTemplate(), FAILED, "window is null"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; } if (curState_ == PipWindowState::STATE_STOPPING || curState_ == PipWindowState::STATE_STOPPED) { - WLOGFE("Repeat stop request, curState: %{public}u", curState_); + TLOGE(WmsLogTag::WMS_PIP, "Repeat stop request, curState: %{public}u", curState_); SingletonContainer::Get().ReportPiPStopWindow(static_cast(StopPipType::USER_STOP), pipOption_->GetPipTemplate(), FAILED, "Repeat stop request"); return WMError::WM_ERROR_PIP_REPEAT_OPERATION; @@ -248,16 +245,16 @@ WMError PictureInPictureController::StopPictureInPictureFromClient() WMError PictureInPictureController::StopPictureInPicture(bool destroyWindow, StopPipType stopPipType) { - WLOGI("StopPictureInPicture is called, destroyWindow: %{public}u", destroyWindow); + TLOGD(WmsLogTag::WMS_PIP, "StopPictureInPicture is called, destroyWindow: %{public}u", destroyWindow); std::lock_guard lock(mutex_); if (curState_ == PipWindowState::STATE_STOPPING || curState_ == PipWindowState::STATE_STOPPED) { - WLOGFE("Repeat stop request, curState: %{public}u", curState_); + TLOGE(WmsLogTag::WMS_PIP, "Repeat stop request, curState: %{public}u", curState_); SingletonContainer::Get().ReportPiPStopWindow(static_cast(stopPipType), pipOption_->GetPipTemplate(), FAILED, "Repeat stop request"); return WMError::WM_ERROR_PIP_REPEAT_OPERATION; } if (window_ == nullptr) { - WLOGFE("window_ is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "window is nullptr when stop pip"); SingletonContainer::Get().ReportPiPStopWindow(static_cast(stopPipType), pipOption_->GetPipTemplate(), FAILED, "window_ is nullptr"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; @@ -284,16 +281,16 @@ WMError PictureInPictureController::StopPictureInPictureInner(StopPipType stopTy auto task = [weakThis = wptr(this), currentStopType = stopType, currentPipOption = pipOption_]() { auto session = weakThis.promote(); if (!session || !session->window_) { - WLOGFE("session is null"); + TLOGE(WmsLogTag::WMS_PIP, "pipController is null in stopping task"); SingletonContainer::Get().ReportPiPStopWindow(static_cast(currentStopType), - currentPipOption->GetPipTemplate(), FAILED, "session is null"); + currentPipOption->GetPipTemplate(), FAILED, "pipController is null"); return WMError::WM_ERROR_PIP_INTERNAL_ERROR; } session->ResetExtController(); WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(session->window_->Destroy()); if (ret != WmErrorCode::WM_OK) { session->curState_ = PipWindowState::STATE_UNDEFINED; - WLOGFE("Window destroy failed"); + TLOGE(WmsLogTag::WMS_PIP, "Window destroy failed, err:%{public}u", ret); int32_t err = static_cast(ret); if (session->pipLifeCycleListener_ != nullptr) { session->pipLifeCycleListener_->OnPictureInPictureOperationError(err); @@ -315,7 +312,7 @@ WMError PictureInPictureController::StopPictureInPictureInner(StopPipType stopTy session->mainWindow_->GetUIContent(), navId); if (navController) { navController->DeletePIPMode(session->handleId_); - WLOGFI("Delete pip mode id: %{public}d", session->handleId_); + TLOGI(WmsLogTag::WMS_PIP, "Delete pip mode id: %{public}d", session->handleId_); } } SingletonContainer::Get().ReportPiPStopWindow(static_cast(currentStopType), @@ -347,12 +344,13 @@ void PictureInPictureController::SetPipWindow(sptr window) void PictureInPictureController::SetAutoStartEnabled(bool enable) { - WLOGI("SetAutoStartEnabled called, enable: %{public}u, mainWindow: %{public}u", enable, mainWindowId_); + TLOGI(WmsLogTag::WMS_PIP, + "SetAutoStartEnabled called, enable: %{public}u, mainWindow: %{public}u", enable, mainWindowId_); isAutoStartEnabled_ = enable; if (isAutoStartEnabled_) { // cache navigation here as we cannot get containerId while BG if (!IsPullPiPAndHandleNavigation()) { - WLOGFE("Navigation operate failed"); + TLOGE(WmsLogTag::WMS_PIP, "Navigation operate failed"); return; } PictureInPictureManager::AttachAutoStartController(handleId_, weakRef_); @@ -366,7 +364,7 @@ void PictureInPictureController::SetAutoStartEnabled(bool enable) auto navController = NavigationController::GetNavigationController(mainWindow_->GetUIContent(), navId); if (navController) { navController->DeletePIPMode(handleId_); - WLOGFI("Delete pip mode id: %{public}d", handleId_); + TLOGI(WmsLogTag::WMS_PIP, "Delete pip mode id: %{public}d", handleId_); } } } @@ -385,48 +383,27 @@ PipWindowState PictureInPictureController::GetControllerState() void PictureInPictureController::UpdateContentSize(int32_t width, int32_t height) { if (width <= 0 || height <= 0) { - WLOGFE("invalid size"); + TLOGE(WmsLogTag::WMS_PIP, "invalid size"); return; } if (curState_ != PipWindowState::STATE_STARTED) { - WLOGFD("UpdateContentSize is disabled when state: %{public}u", curState_); + TLOGD(WmsLogTag::WMS_PIP, "UpdateContentSize is disabled when state: %{public}u", curState_); return; } if (window_ == nullptr) { - WLOGFE("pipWindow not exist"); + TLOGE(WmsLogTag::WMS_PIP, "pipWindow not exist"); return; } - WLOGI("UpdateContentSize window: %{public}u width:%{public}u height:%{public}u", + TLOGI(WmsLogTag::WMS_PIP, "UpdateContentSize window: %{public}u width:%{public}u height:%{public}u", window_->GetWindowId(), width, height); Rect rect = {0, 0, width, height}; window_->UpdatePiPRect(rect, WindowSizeChangeReason::PIP_RATIO_CHANGE); } -void PictureInPictureController::StartMove() -{ - if (window_ == nullptr) { - WLOGFE("pipWindow not exist"); - return; - } - WLOGI("StartMove is called, window: %{public}u", window_->GetWindowId()); - SingletonContainer::Get().ReportPiPMove(); - window_->StartMove(); -} - -void PictureInPictureController::DoScale() -{ - if (window_ == nullptr) { - WLOGFE("PiPWindow is not exist"); - return; - } - WLOGI("DoScale is called, window: %{public}u", window_->GetWindowId()); -} - void PictureInPictureController::PipMainWindowLifeCycleImpl::AfterBackground() { - WLOGI("PipMainWindowLifeCycleImpl AfterBackground is called"); if (!PowerMgr::PowerMgrClient::GetInstance().IsScreenOn()) { - WLOGFI("disable auto start as screen is off"); + TLOGI(WmsLogTag::WMS_PIP, "disable auto start as screen is off"); return; } PictureInPictureManager::AutoStartPipWindow(navigationId_); @@ -434,14 +411,14 @@ void PictureInPictureController::PipMainWindowLifeCycleImpl::AfterBackground() void PictureInPictureController::PipMainWindowLifeCycleImpl::BackgroundFailed(int32_t type) { - WLOGI("PipMainWindowLifeCycleImpl BackgroundFailed"); + TLOGD(WmsLogTag::WMS_PIP, "PipMainWindowLifeCycleImpl BackgroundFailed"); } void PictureInPictureController::DoActionEvent(const std::string& actionName, int32_t status) { - WLOGFD("actionName: %{public}s", actionName.c_str()); + TLOGD(WmsLogTag::WMS_PIP, "actionName: %{public}s", actionName.c_str()); if (pipActionObserver_ == nullptr) { - WLOGFE("pipActionObserver is not registered"); + TLOGE(WmsLogTag::WMS_PIP, "pipActionObserver is not registered"); return; } SingletonContainer::Get().ReportPiPActionEvent(pipOption_->GetPipTemplate(), actionName); @@ -450,41 +427,26 @@ void PictureInPictureController::DoActionEvent(const std::string& actionName, in void PictureInPictureController::RestorePictureInPictureWindow() { - if (window_ == nullptr || mainWindow_ == nullptr) { - WLOGFE("window or main window is nullptr"); - return; - } - WLOGFI("restore pipWindow %{public}u to [%{public}u, %{public}u, %{public}u, %{public}u]", window_->GetWindowId(), - windowRect_.posX_, windowRect_.posY_, windowRect_.width_, windowRect_.height_); if (pipLifeCycleListener_) { pipLifeCycleListener_->OnRestoreUserInterface(); } - window_->RecoveryPullPiPMainWindow(windowRect_); + if (mainWindow_ == nullptr) { + TLOGI(WmsLogTag::WMS_PIP, "main window is nullptr"); + return; + } std::string navId = pipOption_->GetNavigationId(); if (navId != "") { auto navController = NavigationController::GetNavigationController(mainWindow_->GetUIContent(), navId); if (navController) { navController->PushInPIP(handleId_); - WLOGFI("Push in pip handleId: %{public}d", handleId_); + TLOGI(WmsLogTag::WMS_PIP, "Push in pip handleId: %{public}d", handleId_); } else { - WLOGFE("navController is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "navController is nullptr"); } } - auto stopPipTask = [weakThis = wptr(this)]() { - auto session = weakThis.promote(); - if (!session) { - WLOGFE("session is null"); - return; - } - session->StopPictureInPicture(true, StopPipType::NULL_STOP); - }; - if (handler_ == nullptr) { - WLOGFE("handler is nullptr"); - return; - } - handler_->PostTask(stopPipTask, "wms:RestorePictureInPictureWindow", DELAY_ANIM); + StopPictureInPicture(true, StopPipType::NULL_STOP); SingletonContainer::Get().ReportPiPRestore(); - WLOGFI("restore pip main window finished"); + TLOGI(WmsLogTag::WMS_PIP, "restore pip main window finished"); } void PictureInPictureController::UpdateXComponentPositionAndSize() @@ -499,40 +461,40 @@ void PictureInPictureController::UpdateXComponentPositionAndSize() windowRect_.height_ = static_cast(height); windowRect_.posX_ = static_cast(posX); windowRect_.posY_ = static_cast(posY); - WLOGFD("position width: %{public}u, height: %{public}u, posX: %{public}d, posY: %{public}d", + TLOGD(WmsLogTag::WMS_PIP, "position width: %{public}u, height: %{public}u, posX: %{public}d, posY: %{public}d", windowRect_.width_, windowRect_.height_, windowRect_.posX_, windowRect_.posY_); } void PictureInPictureController::ResetExtController() { - WLOGI("ResetExtController is called"); + TLOGI(WmsLogTag::WMS_PIP, "ResetExtController is called"); if (mainWindowXComponentController_ == nullptr || pipXComponentController_ == nullptr) { - WLOGFE("error when reset XComponentController"); + TLOGE(WmsLogTag::WMS_PIP, "error when resetExtController, one of the xComponentController is null"); return; } XComponentControllerErrorCode errorCode = mainWindowXComponentController_->ResetExtController(pipXComponentController_); if (errorCode != XComponentControllerErrorCode::XCOMPONENT_CONTROLLER_NO_ERROR) { - WLOGFE("swap xComponent failed, errorCode: %{public}u", errorCode); + TLOGE(WmsLogTag::WMS_PIP, "swap xComponent failed, errorCode: %{public}u", errorCode); } } WMError PictureInPictureController::SetXComponentController(std::shared_ptr xComponentController) { - WLOGI("SetXComponentController is called"); + TLOGD(WmsLogTag::WMS_PIP, "SetXComponentController is called"); pipXComponentController_ = xComponentController; if (window_ == nullptr) { - WLOGFE("window_ is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "window is nullptr when set XComponentController"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; } if (mainWindowXComponentController_ == nullptr || pipXComponentController_ == nullptr) { - WLOGFE("window_ is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "error when setXController, one of the xComponentController is null"); return WMError::WM_ERROR_PIP_STATE_ABNORMALLY; } XComponentControllerErrorCode errorCode = mainWindowXComponentController_->SetExtController(pipXComponentController_); if (errorCode != XComponentControllerErrorCode::XCOMPONENT_CONTROLLER_NO_ERROR) { - WLOGFE("swap xComponent failed, errorCode: %{public}u", errorCode); + TLOGE(WmsLogTag::WMS_PIP, "swap xComponent failed, errorCode: %{public}u", errorCode); return WMError::WM_ERROR_PIP_INTERNAL_ERROR; } if (pipLifeCycleListener_ != nullptr) { @@ -543,13 +505,11 @@ WMError PictureInPictureController::SetXComponentController(std::shared_ptr listener) { - WLOGFD("SetPictureInPictureLifecycle is called"); pipLifeCycleListener_ = listener; } void PictureInPictureController::SetPictureInPictureActionObserver(sptr listener) { - WLOGFD("SetPictureInPictureActionObserver is called"); pipActionObserver_ = listener; } @@ -566,11 +526,11 @@ sptr PictureInPictureController::GetPictureInPictureActionOb bool PictureInPictureController::IsPullPiPAndHandleNavigation() { if (pipOption_->GetNavigationId() == "") { - WLOGFI("App not use navigation"); + TLOGI(WmsLogTag::WMS_PIP, "App not use navigation"); return true; } if (mainWindow_ == nullptr) { - WLOGFE("Main window init error"); + TLOGE(WmsLogTag::WMS_PIP, "Main window init error"); return false; } std::string navId = pipOption_->GetNavigationId(); @@ -579,19 +539,19 @@ bool PictureInPictureController::IsPullPiPAndHandleNavigation() if (navController->IsNavDestinationInTopStack()) { handleId_ = navController->GetTopHandle(); if (handleId_ != -1) { - WLOGFD("Top handle id : %{public}d", handleId_); + TLOGD(WmsLogTag::WMS_PIP, "Top handle id : %{public}d", handleId_); navController->SetInPIPMode(handleId_); return true; } else { - WLOGFE("Get top handle error"); + TLOGE(WmsLogTag::WMS_PIP, "Get top handle error"); return false; } } else { - WLOGFE("Top is not navDestination"); + TLOGE(WmsLogTag::WMS_PIP, "Top is not navDestination"); return false; } } else { - WLOGFE("Get navController error"); + TLOGE(WmsLogTag::WMS_PIP, "Get navController error"); } return false; } diff --git a/wm/src/picture_in_picture_manager.cpp b/wm/src/picture_in_picture_manager.cpp index 5d9dbcfb7..dd92cd636 100644 --- a/wm/src/picture_in_picture_manager.cpp +++ b/wm/src/picture_in_picture_manager.cpp @@ -25,7 +25,6 @@ namespace OHOS { namespace Rosen { namespace { - constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "PictureInPictureManager"}; const std::string ACTION_CLOSE = "close"; const std::string ACTION_RESTORE = "restore"; } @@ -51,20 +50,20 @@ bool PictureInPictureManager::ShouldAbortPipStart() void PictureInPictureManager::PutPipControllerInfo(int32_t windowId, sptr pipController) { - WLOGD("PutPipControllerInfo called, windowId %{public}u", windowId); + TLOGD(WmsLogTag::WMS_PIP, "PutPipControllerInfo called, windowId %{public}u", windowId); windowToControllerMap_.insert(std::make_pair(windowId, pipController)); } void PictureInPictureManager::RemovePipControllerInfo(int32_t windowId) { - WLOGD("RemovePipControllerInfo called, windowId %{public}u", windowId); + TLOGD(WmsLogTag::WMS_PIP, "RemovePipControllerInfo called, windowId %{public}u", windowId); windowToControllerMap_.erase(windowId); } sptr PictureInPictureManager::GetPipControllerInfo(int32_t windowId) { if (windowToControllerMap_.empty() || windowToControllerMap_.find(windowId) == windowToControllerMap_.end()) { - WLOGE("GetPipControllerInfo error, %{public}d not registered!", windowId); + TLOGE(WmsLogTag::WMS_PIP, "GetPipControllerInfo error, %{public}d not registered!", windowId); return nullptr; } return windowToControllerMap_[windowId]; @@ -81,19 +80,19 @@ bool PictureInPictureManager::IsActiveController(wptr pipController) { - WLOGD("SetActiveController called"); + TLOGD(WmsLogTag::WMS_PIP, "SetActiveController called"); activeController_ = pipController; } void PictureInPictureManager::RemoveActiveController(wptr pipController) { - WLOGD("RemoveActiveController called"); + TLOGD(WmsLogTag::WMS_PIP, "RemoveActiveController called"); if (!IsActiveController(pipController)) { return; } @@ -103,7 +102,7 @@ void PictureInPictureManager::RemoveActiveController(wptr pipController) { - WLOGD("AttachAutoStartController, %{public}u", handleId); + TLOGD(WmsLogTag::WMS_PIP, "AttachAutoStartController, %{public}u", handleId); if (pipController == nullptr) { return; } @@ -128,14 +127,14 @@ void PictureInPictureManager::AttachAutoStartController(int32_t handleId, void PictureInPictureManager::DetachAutoStartController(int32_t handleId, wptr pipController) { - WLOGD("Detach active pipController, %{public}u", handleId); + TLOGD(WmsLogTag::WMS_PIP, "Detach active pipController, %{public}u", handleId); autoStartControllerMap_.erase(handleId); if (autoStartController_ == nullptr) { return; } if (pipController != nullptr && pipController.GetRefPtr() != autoStartController_.GetRefPtr()) { - WLOGFE("not same pip controller or no active pip controller"); + TLOGE(WmsLogTag::WMS_PIP, "not same pip controller or no active pip controller"); return; } sptr mainWindow = WindowSceneSessionImpl::GetMainWindowWithId( @@ -148,7 +147,7 @@ void PictureInPictureManager::DetachAutoStartController(int32_t handleId, bool PictureInPictureManager::IsAttachedToSameWindow(uint32_t windowId) { - WLOGD("IsAttachedToSameWindow called %{public}u", windowId); + TLOGD(WmsLogTag::WMS_PIP, "IsAttachedToSameWindow called %{public}u", windowId); if (!HasActiveController()) { return false; } @@ -165,7 +164,7 @@ sptr PictureInPictureManager::GetCurrentWindow() void PictureInPictureManager::DoRestore() { - WLOGD("DoRestore is called"); + TLOGD(WmsLogTag::WMS_PIP, "DoRestore is called"); if (!HasActiveController()) { return; } @@ -174,7 +173,7 @@ void PictureInPictureManager::DoRestore() void PictureInPictureManager::DoClose(bool destroyWindow, bool byPriority) { - WLOGD("DoClose is called"); + TLOGD(WmsLogTag::WMS_PIP, "DoClose is called"); if (!HasActiveController()) { return; } @@ -187,27 +186,9 @@ void PictureInPictureManager::DoClose(bool destroyWindow, bool byPriority) activeController_->StopPictureInPicture(destroyWindow, currentStopType); } -void PictureInPictureManager::DoStartMove() -{ - WLOGD("DoStartMove is called"); - if (!HasActiveController()) { - return; - } - activeController_->StartMove(); -} - -void PictureInPictureManager::DoScale() -{ - WLOGD("DoScale is called"); - if (!HasActiveController()) { - return; - } - activeController_->DoScale(); -} - void PictureInPictureManager::DoActionEvent(const std::string& actionName, int32_t status) { - WLOGD("DoActionEvent is called"); + TLOGD(WmsLogTag::WMS_PIP, "DoActionEvent is called"); if (!HasActiveController()) { return; } @@ -222,13 +203,13 @@ void PictureInPictureManager::DoActionEvent(const std::string& actionName, int32 void PictureInPictureManager::AutoStartPipWindow(std::string navigationId) { - WLOGD("AutoStartPipWindow is called, navId: %{public}s", navigationId.c_str()); + TLOGD(WmsLogTag::WMS_PIP, "AutoStartPipWindow is called, navId: %{public}s", navigationId.c_str()); if (autoStartController_ == nullptr) { - WLOGFE("autoStartController_ is null"); + TLOGE(WmsLogTag::WMS_PIP, "autoStartController_ is null"); return; } if (navigationId == "") { - WLOGFI("No use navigationId for auto start"); + TLOGI(WmsLogTag::WMS_PIP, "No use navigationId for auto start"); autoStartController_->StartPictureInPicture(StartPipType::AUTO_START); return; } @@ -237,20 +218,20 @@ void PictureInPictureManager::AutoStartPipWindow(std::string navigationId) if (mainWindow) { auto navController = NavigationController::GetNavigationController(mainWindow->GetUIContent(), navigationId); if (!navController) { - WLOGFE("navController is nullptr"); + TLOGE(WmsLogTag::WMS_PIP, "navController is nullptr"); return; } if (navController->IsNavDestinationInTopStack()) { int handleId = navController->GetTopHandle(); if (autoStartControllerMap_.empty() || autoStartControllerMap_.find(handleId) == autoStartControllerMap_.end()) { - WLOGFE("GetNAvController info error, %{public}d not registered", handleId); + TLOGE(WmsLogTag::WMS_PIP, "GetNAvController info error, %{public}d not registered", handleId); return; } auto pipController = autoStartControllerMap_[handleId]; pipController->StartPictureInPicture(StartPipType::AUTO_START); } else { - WLOGFE("Top is not navDestination"); + TLOGE(WmsLogTag::WMS_PIP, "Top is not navDestination"); } } } diff --git a/wm/src/root_scene.cpp b/wm/src/root_scene.cpp index 2d1398c4f..05de1cfbb 100644 --- a/wm/src/root_scene.cpp +++ b/wm/src/root_scene.cpp @@ -121,6 +121,11 @@ void RootScene::LoadContent(const std::string& contentUrl, napi_env env, napi_va }); } +void RootScene::SetDisplayOrientation(int32_t orientation) +{ + orientation_ = orientation; +} + void RootScene::UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason reason) { if (uiContent_ == nullptr) { @@ -131,6 +136,7 @@ void RootScene::UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason re config.SetSize(rect.width_, rect.height_); config.SetPosition(rect.posX_, rect.posY_); config.SetDensity(density_); + config.SetOrientation(orientation_); uiContent_->UpdateViewportConfig(config, reason); } diff --git a/wm/src/window.cpp b/wm/src/window.cpp index 4e8b89861..5e5bb53c6 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -146,17 +146,17 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo return nullptr; } if (!option || option->GetWindowName().empty()) { - WLOGE("host window session is nullptr:%{public}u or option is null: %{public}u", + TLOGE(WmsLogTag::WMS_PIP, "host window session is nullptr:%{public}u or option is null: %{public}u", option->GetWindowName().empty(), option == nullptr); return nullptr; } if (!WindowHelper::IsPipWindow(option->GetWindowType())) { - WLOGE("window type is not pip window."); + TLOGE(WmsLogTag::WMS_PIP, "window type is not pip window."); return nullptr; } sptr windowSessionImpl = new(std::nothrow) WindowSceneSessionImpl(option); if (windowSessionImpl == nullptr) { - WLOGFE("malloc windowSessionImpl failed."); + TLOGE(WmsLogTag::WMS_PIP, "malloc windowSessionImpl failed."); return nullptr; } if (windowSessionImpl->GetProperty() != nullptr) { @@ -165,7 +165,7 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo WMError error = windowSessionImpl->Create(context, nullptr); if (error != WMError::WM_OK) { errCode = error; - WLOGFD("Create pip window with session, error: %{public}u", static_cast(errCode)); + TLOGD(WmsLogTag::WMS_PIP, "Create pip window with session, error: %{public}u", static_cast(errCode)); return nullptr; } return windowSessionImpl; diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 86a45baf0..71a9b589e 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -518,6 +518,17 @@ WSError WindowExtensionSessionImpl::NotifyExecuteAction(int64_t elementId, return WSError::WS_OK; } +WSError WindowExtensionSessionImpl::NotifyAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, + int32_t eventType, int64_t timeMs) +{ + if (uiContent_ == nullptr) { + WLOGFE("NotifyExecuteAction error, no uiContent_"); + return WSError::WS_ERROR_NO_UI_CONTENT_ERROR; + } + uiContent_->HandleAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); + return WSError::WS_OK; +} + WMError WindowExtensionSessionImpl::TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) { diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index a880189b3..417946da9 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -1231,6 +1231,14 @@ WMError WindowImpl::Create(uint32_t parentId, const std::shared_ptr& keyEvent) +{ + if (uiContent_ != nullptr) { + return uiContent_->ProcessKeyEvent(keyEvent, true); + } + return false; +} + void WindowImpl::InitAbilityInfo() { AbilityInfo info; diff --git a/wm/src/window_input_channel.cpp b/wm/src/window_input_channel.cpp index 42ed2a16e..3ac8e185f 100644 --- a/wm/src/window_input_channel.cpp +++ b/wm/src/window_input_channel.cpp @@ -18,6 +18,7 @@ #include #endif // IMF_ENABLE #include "window_manager_hilog.h" +#include "window_helper.h" namespace OHOS { namespace Rosen { @@ -73,7 +74,8 @@ void WindowInputChannel::HandleKeyEvent(std::shared_ptr& keyEvent return; } } - + bool isConsumed = window_->PreNotifyKeyEvent(keyEvent); + TLOGI(WmsLogTag::WMS_EVENT, "PreNotifyKeyEvent isConsumed = %{public}d", static_cast(isConsumed)); #ifdef IMF_ENABLE bool isKeyboardEvent = IsKeyboardEvent(keyEvent); if (isKeyboardEvent) { @@ -102,10 +104,14 @@ void WindowInputChannel::HandleKeyEvent(std::shared_ptr& keyEvent void WindowInputChannel::HandlePointerEvent(std::shared_ptr& pointerEvent) { if (pointerEvent == nullptr) { - WLOGFE("pointerEvent is nullptr"); + TLOGE(WmsLogTag::WMS_EVENT, "pointerEvent is nullptr"); + return; + } + if (window_ == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "window_ is nullptr"); return; } - WLOGFD("Receive pointer event, Id: %{public}u, action: %{public}d", + TLOGD(WmsLogTag::WMS_EVENT, "Receive pointer event, Id: %{public}u, action: %{public}d", window_->GetWindowId(), pointerEvent->GetPointerAction()); if ((window_->GetType() == WindowType::WINDOW_TYPE_DIALOG) && (pointerEvent->GetAgentWindowId() != pointerEvent->GetTargetWindowId())) { @@ -119,7 +125,27 @@ void WindowInputChannel::HandlePointerEvent(std::shared_ptr& pointerEvent->MarkProcessed(); return; } - WLOGFD("Dispatch move event, windowId: %{public}u, action: %{public}d", + + bool isModal = window_->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_IS_MODAL); + bool isSubWindow = WindowHelper::IsSubWindow(window_->GetType()); + if (isModal && isSubWindow) { + MMI::PointerEvent::PointerItem pointerItem; + bool validPointItem = pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem); + bool outsideWindow = !WindowHelper::IsPointInTargetRectWithBound(pointerItem.GetDisplayX(), + pointerItem.GetDisplayY(), window_->GetRect()); + auto action = pointerEvent->GetPointerAction(); + bool isTargetAction = (action == MMI::PointerEvent::POINTER_ACTION_DOWN || + action == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN); + bool isInterceptAction = isTargetAction || action == MMI::PointerEvent::POINTER_ACTION_MOVE; + if (validPointItem && outsideWindow && isInterceptAction) { + if (isTargetAction) { + window_->NotifyTouchDialogTarget(pointerItem.GetDisplayX(), pointerItem.GetDisplayY()); + } + pointerEvent->MarkProcessed(); + return; + } + } + TLOGD(WmsLogTag::WMS_EVENT, "Dispatch move event, windowId: %{public}u, action: %{public}d", window_->GetWindowId(), pointerEvent->GetPointerAction()); window_->ConsumePointerEvent(pointerEvent); } diff --git a/wm/src/window_manager.cpp b/wm/src/window_manager.cpp index 55a2dc724..5e52ee801 100644 --- a/wm/src/window_manager.cpp +++ b/wm/src/window_manager.cpp @@ -315,7 +315,7 @@ WMError WindowManager::RegisterFocusChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS, pImpl_->focusChangedListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->focusChangedListenerAgent_ = nullptr; } else { @@ -368,7 +368,7 @@ WMError WindowManager::RegisterSystemBarChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR, pImpl_->systemBarChangedListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->systemBarChangedListenerAgent_ = nullptr; } else { @@ -444,7 +444,7 @@ WMError WindowManager::RegisterWindowUpdateListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE, pImpl_->windowUpdateListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->windowUpdateListenerAgent_ = nullptr; } else { @@ -496,7 +496,7 @@ WMError WindowManager::RegisterVisibilityChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY, pImpl_->windowVisibilityListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->windowVisibilityListenerAgent_ = nullptr; } else { @@ -550,7 +550,7 @@ WMError WindowManager::RegisterCameraFloatWindowChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT, pImpl_->cameraFloatWindowChangedListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->cameraFloatWindowChangedListenerAgent_ = nullptr; } else { @@ -609,7 +609,7 @@ WMError WindowManager::RegisterWaterMarkFlagChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG, pImpl_->waterMarkFlagChangeAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->waterMarkFlagChangeAgent_ = nullptr; } else { @@ -675,7 +675,7 @@ WMError WindowManager::RegisterGestureNavigationEnabledChangedListener( WLOGFE("Create windowManagerAgent object failed!"); ret = WMError::WM_ERROR_NULLPTR; } - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFE("RegisterWindowManagerAgent failed!"); pImpl_->gestureNavigationEnabledAgent_ = nullptr; } else { @@ -743,7 +743,7 @@ void WindowManager::UpdateFocusChangeInfo(const sptr& focusChan WLOGFE("focusChangeInfo is nullptr."); return; } - TLOGI(WmsLogTag::WMS_FOCUS, "window focus change: %{public}d, id: %{public}u", focused, focusChangeInfo->windowId_); + TLOGD(WmsLogTag::WMS_FOCUS, "window focus change: %{public}d, id: %{public}u", focused, focusChangeInfo->windowId_); if (focused) { pImpl_->NotifyFocused(focusChangeInfo); } else { @@ -867,7 +867,7 @@ WMError WindowManager::RegisterDrawingContentChangedListener(const sptr().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE, pImpl_->windowDrawingContentListenerAgent_); - if (ret != WMError::WM_OK && ret != WMError::WM_ERROR_REPEAT_OPERATION) { + if (ret != WMError::WM_OK) { WLOGFW("RegisterWindowManagerAgent failed!"); pImpl_->windowDrawingContentListenerAgent_ = nullptr; } else { diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 786bcada4..605c6fa94 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -92,7 +92,7 @@ bool WindowSceneSessionImpl::IsValidSystemWindowType(const WindowType& type) type == WindowType::WINDOW_TYPE_VOLUME_OVERLAY || type == WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR || type == WindowType::WINDOW_TYPE_SYSTEM_TOAST || type == WindowType::WINDOW_TYPE_SYSTEM_FLOAT || type == WindowType::WINDOW_TYPE_PIP || type == WindowType::WINDOW_TYPE_GLOBAL_SEARCH || - type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW)) { + type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW || type == WindowType::WINDOW_TYPE_HANDWRITE)) { TLOGI(WmsLogTag::WMS_SYSTEM, "Invalid type: %{public}u", type); return false; } @@ -467,6 +467,7 @@ void WindowSceneSessionImpl::ConsumePointerEventInner(const std::shared_ptrGetId()); } bool isPointUp = (action == MMI::PointerEvent::POINTER_ACTION_UP || @@ -511,6 +512,13 @@ void WindowSceneSessionImpl::ConsumePointerEvent(const std::shared_ptr& keyEvent) +{ + bool isConsumed = false; + NotifyKeyEvent(keyEvent, isConsumed, false); + RefreshNoInteractionTimeoutMonitor(keyEvent->GetId()); +} + void WindowSceneSessionImpl::RegisterSessionRecoverListener(bool isSpecificSession) { WLOGFD("[WMSRecover] persistentId = %{public}d, isSpecificSession = %{public}s", @@ -605,6 +613,9 @@ WindowLimits WindowSceneSessionImpl::GetSystemSizeLimits(uint32_t displayWidth, MIN_FLOATING_WIDTH, vpr); systemLimits.minHeight_ = UpdateConfigVal(0, displayHeight, windowSystemConfig_.miniHeightOfSubWindow_, MIN_FLOATING_HEIGHT, vpr); + } else if (WindowHelper::IsSystemWindow(GetType()) && GetType() != WindowType::WINDOW_TYPE_DIALOG) { + systemLimits.minWidth_ = 0; + systemLimits.minHeight_ = 0; } else { systemLimits.minWidth_ = static_cast(MIN_FLOATING_WIDTH * vpr); systemLimits.minHeight_ = static_cast(MIN_FLOATING_HEIGHT * vpr); @@ -739,6 +750,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation) hostSession_->RaiseAppMainWindowToTop(); } NotifyAfterForeground(true, false); + RefreshNoInteractionTimeoutMonitor(-1); return WMError::WM_OK; } @@ -778,6 +790,7 @@ WMError WindowSceneSessionImpl::Show(uint32_t reason, bool withAnimation) state_ = WindowState::STATE_SHOWN; requestState_ = WindowState::STATE_SHOWN; NotifyAfterForeground(); + RefreshNoInteractionTimeoutMonitor(-1); } else { NotifyForegroundFailed(ret); } @@ -904,27 +917,6 @@ void WindowSceneSessionImpl::SetDefaultProperty() } } -WSError WindowSceneSessionImpl::SetActive(bool active) -{ - WLOGFI("[WMSCom] active status: %{public}d", active); - if (!WindowHelper::IsMainWindow(GetType())) { - if (hostSession_ == nullptr) { - WLOGFD("hostSession_ nullptr"); - return WSError::WS_ERROR_INVALID_WINDOW; - } - WSError ret = hostSession_->UpdateActiveStatus(active); - if (ret != WSError::WS_OK) { - return ret; - } - } - if (active) { - NotifyAfterActive(); - } else { - NotifyAfterInactive(); - } - return WSError::WS_OK; -} - void WindowSceneSessionImpl::DestroySubWindow() { const int32_t& parentPersistentId = property_->GetParentPersistentId(); @@ -1119,7 +1111,8 @@ void WindowSceneSessionImpl::UpdateFloatingWindowSizeBySizeLimits(uint32_t& widt // get new limit config with the settings of system and app const auto& sizeLimits = property_->GetWindowLimits(); // limit minimum size of floating (not system type) window - if (!WindowHelper::IsSystemWindow(property_->GetWindowType())) { + if ((!WindowHelper::IsSystemWindow(property_->GetWindowType())) || + (property_->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG)) { width = std::max(sizeLimits.minWidth_, width); height = std::max(sizeLimits.minHeight_, height); } @@ -1162,6 +1155,12 @@ WMError WindowSceneSessionImpl::Resize(uint32_t width, uint32_t height) TLOGW(WmsLogTag::WMS_LAYOUT, "Unsupported operation for pip window"); return WMError::WM_ERROR_INVALID_OPERATION; } + + if (GetMode() != WindowMode::WINDOW_MODE_FLOATING) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Unsupport operation for full screen window. WindowId: %{public}d", + GetWindowId()); + return WMError::WM_ERROR_INVALID_OPERATION; + } // Float camera window has special limits LimitCameraFloatWindowMininumSize(width, height); @@ -1276,8 +1275,6 @@ WmErrorCode WindowSceneSessionImpl::RaiseAboveTarget(int32_t subWindowId) WMError WindowSceneSessionImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea) { uint32_t windowId = GetWindowId(); - TLOGI(WmsLogTag::WMS_IMMS, - "GetAvoidAreaByType windowId:%{public}u type:%{public}u", windowId, static_cast(type)); WindowMode mode = GetMode(); if (type != AvoidAreaType::TYPE_KEYBOARD && mode != WindowMode::WINDOW_MODE_FULLSCREEN && @@ -1292,9 +1289,16 @@ WMError WindowSceneSessionImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea return WMError::WM_OK; } if (hostSession_ == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "hostSession_ is null"); return WMError::WM_ERROR_NULLPTR; } avoidArea = hostSession_->GetAvoidAreaByType(type); + TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] type %{public}d " + "top{%{public}d, %{public}d, %{public}d, %{public}d}, down{%{public}d, %{public}d, %{public}d, %{public}d}", + windowId, GetWindowName().c_str(), type, + avoidArea.topRect_.posX_, avoidArea.topRect_.posY_, avoidArea.topRect_.width_, avoidArea.topRect_.height_, + avoidArea.bottomRect_.posX_, avoidArea.bottomRect_.posY_, avoidArea.bottomRect_.width_, + avoidArea.bottomRect_.height_); return WMError::WM_OK; } @@ -1364,8 +1368,8 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreenByApiVersion(bool status) WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) { - TLOGI(WmsLogTag::WMS_IMMS, - "winId:%{public}u status:%{public}d", GetWindowId(), static_cast(status)); + TLOGI(WmsLogTag::WMS_IMMS, "winId:%{public}u %{public}s status:%{public}d", + GetWindowId(), GetWindowName().c_str(), static_cast(status)); if (hostSession_ == nullptr) { return WMError::WM_ERROR_NULLPTR; } @@ -1413,7 +1417,7 @@ SystemBarProperty WindowSceneSessionImpl::GetSystemBarPropertyByType(WindowType WMError WindowSceneSessionImpl::NotifyWindowSessionProperty() { - TLOGD(WmsLogTag::WMS_IMMS, "NotifyWindowSessionProperty called windowId:%{public}u", GetWindowId()); + TLOGD(WmsLogTag::WMS_IMMS, "windowId:%{public}u", GetWindowId()); if (IsWindowSessionInvalid()) { TLOGE(WmsLogTag::WMS_IMMS, "session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; @@ -1424,16 +1428,11 @@ WMError WindowSceneSessionImpl::NotifyWindowSessionProperty() WMError WindowSceneSessionImpl::NotifySpecificWindowSessionProperty(WindowType type, const SystemBarProperty& property) { - WLOGFD("NotifySpecificWindowSessionProperty called windowId:%{public}u", GetWindowId()); + TLOGD(WmsLogTag::WMS_IMMS, "windowId:%{public}u", GetWindowId()); if (IsWindowSessionInvalid()) { - WLOGFE("session is invalid"); + TLOGE(WmsLogTag::WMS_IMMS, "session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; } - if ((state_ == WindowState::STATE_CREATED && - property_->GetModeSupportInfo() != WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN) || - state_ == WindowState::STATE_HIDDEN) { - return WMError::WM_OK; - } if (type == WindowType::WINDOW_TYPE_STATUS_BAR) { UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_STATUS_PROPS); } else if (type == WindowType::WINDOW_TYPE_NAVIGATION_BAR) { @@ -1444,62 +1443,44 @@ WMError WindowSceneSessionImpl::NotifySpecificWindowSessionProperty(WindowType t return WMError::WM_OK; } -WMError WindowSceneSessionImpl::SetSystemBarProperty(WindowType type, const SystemBarProperty& property) +WMError WindowSceneSessionImpl::SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) { - TLOGI(WmsLogTag::WMS_IMMS, "SetSystemBarProperty windowId:%{public}u type:%{public}u" + TLOGI(WmsLogTag::WMS_IMMS, "windowId:%{public}u %{public}s type:%{public}u" "enable:%{public}u bgColor:%{public}x Color:%{public}x", - GetWindowId(), static_cast(type), + GetWindowId(), GetWindowName().c_str(), static_cast(type), property.enable_, property.backgroundColor_, property.contentColor_); if (!((state_ > WindowState::STATE_INITIAL) && (state_ < WindowState::STATE_BOTTOM))) { - TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty windowId:%{public}u state is invalid", GetWindowId()); + TLOGE(WmsLogTag::WMS_IMMS, "windowId:%{public}u state is invalid", GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } else if (GetSystemBarPropertyByType(type) == property) { - TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty windowId:%{public}u property is same", GetWindowId()); + TLOGI(WmsLogTag::WMS_IMMS, "windowId:%{public}u property is same", GetWindowId()); return WMError::WM_OK; } if (property_ == nullptr) { + TLOGE(WmsLogTag::WMS_IMMS, "property_ is null"); return WMError::WM_ERROR_NULLPTR; } isSystembarPropertiesSet_ = true; property_->SetSystemBarProperty(type, property); - WMError ret = NotifyWindowSessionProperty(); + WMError ret = NotifySpecificWindowSessionProperty(type, property); if (ret != WMError::WM_OK) { - TLOGE(WmsLogTag::WMS_IMMS, "NotifyWindowSessionProperty winId:%{public}u errCode:%{public}d", + TLOGE(WmsLogTag::WMS_IMMS, "winId:%{public}u errCode:%{public}d", GetWindowId(), static_cast(ret)); } return ret; } -WMError WindowSceneSessionImpl::SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) +WMError WindowSceneSessionImpl::SetSystemBarProperty(WindowType type, const SystemBarProperty& property) { - WLOGFI("SetSystemBarProperty windowId:%{public}u type:%{public}u" - "enable:%{public}u bgColor:%{public}x Color:%{public}x", - GetWindowId(), static_cast(type), - property.enable_, property.backgroundColor_, property.contentColor_); - if (!((state_ > WindowState::STATE_INITIAL) && (state_ < WindowState::STATE_BOTTOM))) { - return WMError::WM_ERROR_INVALID_WINDOW; - } else if (GetSystemBarPropertyByType(type) == property) { - return WMError::WM_OK; - } - - if (property_ == nullptr) { - return WMError::WM_ERROR_NULLPTR; - } - isSystembarPropertiesSet_ = true; - property_->SetSystemBarProperty(type, property); - WMError ret = NotifySpecificWindowSessionProperty(type, property); - if (ret != WMError::WM_OK) { - WLOGFE("NotifySpecificWindowSessionProperty winId:%{public}u errCode:%{public}d", - GetWindowId(), static_cast(ret)); - } - return ret; + return SetSpecificBarProperty(type, property); } WMError WindowSceneSessionImpl::SetFullScreen(bool status) { TLOGI(WmsLogTag::WMS_IMMS, - "winId:%{public}u status:%{public}d", GetWindowId(), static_cast(status)); + "winId:%{public}u %{public}s status:%{public}d", + GetWindowId(), GetWindowName().c_str(), static_cast(status)); if (hostSession_ == nullptr) { return WMError::WM_ERROR_NULLPTR; } @@ -1584,6 +1565,23 @@ WMError WindowSceneSessionImpl::Maximize() return WMError::WM_OK; } +WMError WindowSceneSessionImpl::Maximize(MaximizeLayoutOption option) +{ + if (option.dock != ShowType::HIDE || option.decor == ShowType::FORBIDDEN) { + WLOGE("[WMLayout] dock cannot be hide always! dock is not hide: %{public}d", option.dock != ShowType::HIDE); + return WMError::WM_ERROR_INVALID_PARAM; + } + if (!WindowHelper::IsMainWindow(GetType())) { + WLOGFE("maximize fail, not main window"); + return WMError::WM_ERROR_INVALID_CALLING; + } + if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { + return WMError::WM_ERROR_INVALID_WINDOW; + } + property_->SetIsLayoutFullScreen(option.decor == ShowType::HIDE); + return SetFullScreen(true); +} + WMError WindowSceneSessionImpl::MaximizeFloating() { WLOGFI("WindowSceneSessionImpl::MaximizeFloating id: %{public}d", GetPersistentId()); @@ -1910,6 +1908,10 @@ WMError WindowSceneSessionImpl::AddWindowFlag(WindowFlag flag) WLOGI("Can not add window flag WINDOW_FLAG_SHOW_WHEN_LOCKED"); return WMError::WM_ERROR_INVALID_PERMISSION; } + if (flag == WindowFlag::WINDOW_FLAG_HANDWRITING && !SessionPermission::IsSystemCalling()) { + WLOGI("Can not add window flag WINDOW_FLAG_HANDWRITING"); + return WMError::WM_ERROR_NOT_SYSTEM_APP; + } uint32_t updateFlags = property_->GetWindowFlags() | (static_cast(flag)); return SetWindowFlags(updateFlags); } @@ -2551,17 +2553,6 @@ WSError WindowSceneSessionImpl::UpdateWindowMode(WindowMode mode) return static_cast(ret); } -WMError WindowSceneSessionImpl::RecoveryPullPiPMainWindow(const Rect& rect) -{ - WLOGFI("RecoveryPullPiPMainWindow"); - if (hostSession_ && property_->GetWindowType() == WindowType::WINDOW_TYPE_PIP) { - hostSession_->RecoveryPullPiPMainWindow(GetPersistentId(), rect); - return WMError::WM_OK; - } - WLOGFW("not pip window, nothing to do"); - return WMError::WM_DO_NOTHING; -} - WMError WindowSceneSessionImpl::UpdateWindowModeImmediately(WindowMode mode) { if (state_ == WindowState::STATE_CREATED || state_ == WindowState::STATE_HIDDEN) { @@ -2627,7 +2618,7 @@ WSError WindowSceneSessionImpl::UpdateTitleInTargetPos(bool isShow, int32_t heig WMError WindowSceneSessionImpl::NotifyPrepareClosePiPWindow() { - WLOGFD("NotifyPrepareClosePiPWindow type: %{public}u", GetType()); + TLOGD(WmsLogTag::WMS_PIP, "NotifyPrepareClosePiPWindow type: %{public}u", GetType()); if (!WindowHelper::IsPipWindow(GetType())) { return WMError::WM_DO_NOTHING; } diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index a6683215e..93fd6551f 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -62,6 +62,7 @@ constexpr int32_t ANIMATION_TIME = 400; } std::map>> WindowSessionImpl::lifecycleListeners_; +std::map>> WindowSessionImpl::displayMoveListeners_; std::map>> WindowSessionImpl::windowChangeListeners_; std::map>> WindowSessionImpl::avoidAreaChangeListeners_; std::map>> WindowSessionImpl::dialogDeathRecipientListeners_; @@ -70,6 +71,7 @@ std::map>> WindowSessionI std::map>> WindowSessionImpl::screenshotListeners_; std::map>> WindowSessionImpl::touchOutsideListeners_; std::map> WindowSessionImpl::windowVisibilityChangeListeners_; +std::map> WindowSessionImpl::windowNoInteractionListeners_; std::map>> WindowSessionImpl::windowTitleButtonRectChangeListeners_; std::recursive_mutex WindowSessionImpl::lifeCycleListenerMutex_; @@ -81,8 +83,10 @@ std::recursive_mutex WindowSessionImpl::occupiedAreaChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::screenshotListenerMutex_; std::recursive_mutex WindowSessionImpl::touchOutsideListenerMutex_; std::recursive_mutex WindowSessionImpl::windowVisibilityChangeListenerMutex_; +std::recursive_mutex WindowSessionImpl::windowNoInteractionListenerMutex_; std::recursive_mutex WindowSessionImpl::windowStatusChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::windowTitleButtonRectChangeListenerMutex_; +std::recursive_mutex WindowSessionImpl::displayMoveListenerMutex_; std::map>> WindowSessionImpl::windowSessionMap_; std::shared_mutex WindowSessionImpl::windowSessionMutex_; std::map>> WindowSessionImpl::subWindowSessionMap_; @@ -350,6 +354,19 @@ void WindowSessionImpl::ConsumeKeyEvent(std::shared_ptr& keyEvent NotifyKeyEvent(keyEvent, isConsumed, false); } +bool WindowSessionImpl::PreNotifyKeyEvent(const std::shared_ptr& keyEvent) +{ + if (uiContent_ != nullptr) { + return uiContent_->ProcessKeyEvent(keyEvent, true); + } + return false; +} + +bool WindowSessionImpl::NotifyOnKeyPreImeEvent(const std::shared_ptr& keyEvent) +{ + return PreNotifyKeyEvent(keyEvent); +} + WMError WindowSessionImpl::Show(uint32_t reason, bool withAnimation) { TLOGI(WmsLogTag::WMS_LIFE, "Window Show [name:%{public}s, id:%{public}d, type:%{public}u], reason:%{public}u \ @@ -968,6 +985,16 @@ WMError WindowSessionImpl::HideNonSystemFloatingWindows(bool shouldHide) return UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_HIDE_NON_SYSTEM_FLOATING_WINDOWS); } +WMError WindowSessionImpl::SetLandscapeMultiWindow(bool isLandscapeMultiWindow) +{ + WLOGI("SetLandscapeMultiWindow"); + if (IsWindowSessionInvalid()) { + return WMError::WM_ERROR_INVALID_WINDOW; + } + hostSession_->SetLandscapeMultiWindow(isLandscapeMultiWindow); + return WMError::WM_OK; +} + WMError WindowSessionImpl::SetSingleFrameComposerEnabled(bool enable) { WLOGFD("Set the enable flag of single frame composer."); @@ -1114,6 +1141,20 @@ WMError WindowSessionImpl::RegisterLifeCycleListener(const sptr& listener) +{ + WLOGFD("RegisterDisplayMoveListener"); + std::lock_guard lockListener(displayMoveListenerMutex_); + return RegisterListener(displayMoveListeners_[GetPersistentId()], listener); +} + +WMError WindowSessionImpl::UnregisterDisplayMoveListener(sptr& listener) +{ + WLOGFD("UnregisterDisplayMoveListener"); + std::lock_guard lockListener(displayMoveListenerMutex_); + return UnregisterListener(displayMoveListeners_[GetPersistentId()], listener); +} + WMError WindowSessionImpl::RegisterOccupiedAreaChangeListener(const sptr& listener) { WLOGFD("Start register"); @@ -1174,6 +1215,12 @@ WMError WindowSessionImpl::SetDecorVisible(bool isVisible) return WMError::WM_OK; } +WMError WindowSessionImpl::SetSubWindowModal(bool isModal) +{ + return isModal ? AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_MODAL) : + RemoveWindowFlag(WindowFlag::WINDOW_FLAG_IS_MODAL); +} + WMError WindowSessionImpl::SetDecorHeight(int32_t decorHeight) { if (uiContent_ == nullptr) { @@ -1427,6 +1474,10 @@ EnableIfSame lockListener(displayMoveListenerMutex_); + ClearUselessListeners(displayMoveListeners_, persistentId); + } { std::lock_guard lockListener(lifeCycleListenerMutex_); ClearUselessListeners(lifecycleListeners_, persistentId); @@ -1753,9 +1804,30 @@ WSError WindowSessionImpl::NotifyDestroy() return WSError::WS_OK; } +template +EnableIfSame>> WindowSessionImpl::GetListeners() +{ + std::vector> displayMoveListeners; + for (auto& listener : displayMoveListeners_[GetPersistentId()]) { + displayMoveListeners.push_back(listener); + } + return displayMoveListeners; +} + +void WindowSessionImpl::NotifyDisplayMove(DisplayId from, DisplayId to) +{ + std::lock_guard lockListener(displayMoveListenerMutex_); + auto displayMoveListeners = GetListeners(); + for (auto& listener : displayMoveListeners) { + if (listener != nullptr) { + listener->OnDisplayMove(from, to); + } + } +} + WSError WindowSessionImpl::NotifyCloseExistPipWindow() { - WLOGFD("WindowSessionImpl::NotifyCloseExistPipWindow"); + TLOGD(WmsLogTag::WMS_PIP, "WindowSessionImpl::NotifyCloseExistPipWindow"); PictureInPictureManager::DoClose(true, true); return WSError::WS_OK; } @@ -1888,6 +1960,17 @@ void WindowSessionImpl::NotifyAvoidAreaChange(const sptr& avoidArea, } } +WSError WindowSessionImpl::NotifyTransferComponentData(const AAFwk::WantParams& wantParams) +{ + return WSError::WS_OK; +} + +WSErrorCode WindowSessionImpl::NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, + AAFwk::WantParams& reWantParams) +{ + return WSErrorCode::WS_OK; +} + WSError WindowSessionImpl::UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) { TLOGI(WmsLogTag::WMS_IMMS, @@ -1902,7 +1985,7 @@ WSError WindowSessionImpl::UpdateAvoidArea(const sptr& avoidArea, Avo WSError WindowSessionImpl::SetPipActionEvent(const std::string& action, int32_t status) { - WLOGFI("action: %{public}s, status: %{public}d", action.c_str(), status); + TLOGI(WmsLogTag::WMS_PIP, "action: %{public}s, status: %{public}d", action.c_str(), status); PictureInPictureManager::DoActionEvent(action, status); return WSError::WS_OK; } @@ -2025,6 +2108,28 @@ WMError WindowSessionImpl::UnregisterWindowVisibilityChangeListener(const IWindo return ret; } +WMError WindowSessionImpl::RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, + uint32_t timeout) +{ + constexpr uint32_t S_TO_MS_RATIO = 1000; + noInteractionTimeout_.store(timeout * S_TO_MS_RATIO); // s -> ms. + WLOGFD("Start to register window no interaction listener."); + std::lock_guard lockListener(windowNoInteractionListenerMutex_); + return RegisterListener(windowNoInteractionListeners_[GetPersistentId()], listener); +} + +WMError WindowSessionImpl::UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) +{ + WLOGFD("Start to unregister window no interaction listener."); + std::lock_guard lockListener(windowNoInteractionListenerMutex_); + WMError ret = UnregisterListener(windowNoInteractionListeners_[GetPersistentId()], listener); + if (windowNoInteractionListeners_[GetPersistentId()].empty()) { + noInteractionTimeout_.store(0); + lastInteractionEventId_.store(-1); + } + return ret; +} + template EnableIfSame> WindowSessionImpl::GetListeners() { @@ -2035,6 +2140,16 @@ EnableIfSame +EnableIfSame> WindowSessionImpl::GetListeners() +{ + std::vector noInteractionListeners; + for (auto& listener : windowNoInteractionListeners_[GetPersistentId()]) { + noInteractionListeners.push_back(listener); + } + return noInteractionListeners; +} + WSError WindowSessionImpl::NotifyWindowVisibility(bool isVisible) { WLOGFD("Notify window visibility Change, window: name=%{public}s, id=%{public}u, isVisible:%{public}d", @@ -2049,6 +2164,20 @@ WSError WindowSessionImpl::NotifyWindowVisibility(bool isVisible) return WSError::WS_OK; } +WSError WindowSessionImpl::NotifyNoInteractionTimeout() +{ + WLOGFD("Notify window no interaction timeout, window: name=%{public}s, id=%{public}u", + GetWindowName().c_str(), GetPersistentId()); + std::lock_guard lockListener(windowNoInteractionListenerMutex_); + auto noInteractionListeners = GetListeners(); + for (auto& listener : noInteractionListeners) { + if (listener != nullptr) { + listener->OnWindowNoInteractionCallback(); + } + } + return WSError::WS_OK; +} + void WindowSessionImpl::NotifyPointerEvent(const std::shared_ptr& pointerEvent) { if (!pointerEvent) { @@ -2416,6 +2545,11 @@ WSError WindowSessionImpl::UpdateTitleInTargetPos(bool isShow, int32_t height) return WSError::WS_OK; } +WSError WindowSessionImpl::NotifyDialogStateChange(bool isForeground) +{ + return WSError::WS_OK; +} + void WindowSessionImpl::UpdatePiPRect(const Rect& rect, WindowSizeChangeReason reason) { if (IsWindowSessionInvalid()) { @@ -2462,5 +2596,37 @@ void WindowSessionImpl::NotifyTransformChange(const Transform& transform) } } +void WindowSessionImpl::RefreshNoInteractionTimeoutMonitor(int32_t eventId) +{ + { + std::lock_guard lockListener(windowNoInteractionListenerMutex_); + if (windowNoInteractionListeners_[GetPersistentId()].empty()) { + return; + } + } + + this->lastInteractionEventId_.store(eventId); + auto task = [sessionWptr = wptr(this), eventId]() { + auto session = sessionWptr.promote(); + if (session == nullptr) { + WLOGFE("windowInteractionMonitor task running failed, window session is null"); + return; + } + if (eventId != session->lastInteractionEventId_.load()) { + WLOGFD("event id of windowInteractionMonitor has been changed, need not notify!"); + return; + } + if (session->state_ != WindowState::STATE_SHOWN) { + WLOGFD("window state is not show, need not notify!"); + return; + } + + session->NotifyNoInteractionTimeout(); + return; + }; + + handler_->PostTask(task, noInteractionTimeout_.load()); +} + } // namespace Rosen } // namespace OHOS diff --git a/wm/test/unittest/picture_in_picture_controller_test.cpp b/wm/test/unittest/picture_in_picture_controller_test.cpp index 77d62efd7..c8a12d905 100644 --- a/wm/test/unittest/picture_in_picture_controller_test.cpp +++ b/wm/test/unittest/picture_in_picture_controller_test.cpp @@ -234,9 +234,6 @@ HWTEST_F(PictureInPictureControllerTest, StartMove, Function | SmallTest | Level sptr pipControl = new PictureInPictureController(option, mw, 100, nullptr); GTEST_LOG_(INFO) << "TearDownCasecccccc"; - pipControl->StartMove(); - pipControl->DoScale(); - sptr pipMainWindowLifeCycleImpl = new PictureInPictureController::PipMainWindowLifeCycleImpl(navigationId); GTEST_LOG_(INFO) << "TearDownCasecccccc3"; diff --git a/wm/test/unittest/window_impl_test.cpp b/wm/test/unittest/window_impl_test.cpp index 027a5f9ce..64dd41ed0 100644 --- a/wm/test/unittest/window_impl_test.cpp +++ b/wm/test/unittest/window_impl_test.cpp @@ -2855,7 +2855,7 @@ HWTEST_F(WindowImplTest, ConsumeKeyEvent, Function | SmallTest | Level3) window->property_->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; window->uiContent_ = std::make_unique(); Ace::UIContentMocker* content = reinterpret_cast(window->uiContent_.get()); - EXPECT_CALL(*content, ProcessKeyEvent(_)); + EXPECT_CALL(*content, ProcessKeyEvent(_, _)); window->ConsumeKeyEvent(keyEvent); window->inputEventConsumer_.reset(new MockInputEventConsumer); diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 382c8b1bc..0b9082e91 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -165,6 +165,36 @@ HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession02, Function } } +/** + * @tc.name: CreateAndConnectSpecificSession03 + * @tc.desc: CreateAndConnectSpecificSession + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession03, Function | SmallTest | Level2) +{ + sptr option_ = new (std::nothrow) WindowOption(); + option_->SetWindowTag(WindowTag::SUB_WINDOW); + option_->SetWindowName("ChildWindow0003"); + option_->SetExtensionTag(true); + sptr parentscenesession_ = new (std::nothrow) WindowSceneSessionImpl(option_); + ASSERT_NE(nullptr, parentscenesession_); + + SessionInfo sessionInfo_ = { "CreateTestBundle0", "CreateTestModule0", "CreateTestAbility0" }; + sptr session_ = new (std::nothrow) SessionMocker(sessionInfo_); + ASSERT_NE(nullptr, session_); + ASSERT_EQ(WMError::WM_OK, parentscenesession_->Create(abilityContext_, session_)); + + parentscenesession_->property_->SetParentPersistentId(102); + parentscenesession_->property_->SetParentId(102); + parentscenesession_->property_->type_ = WindowType::APP_MAIN_WINDOW_BASE; + parentscenesession_->hostSession_ = session_; + + parentscenesession_->property_->type_ = WindowType::APP_SUB_WINDOW_BASE; + if (parentscenesession_->CreateAndConnectSpecificSession() == WMError::WM_OK) { + ASSERT_EQ(WMError::WM_OK, parentscenesession_->CreateAndConnectSpecificSession()); + } +} + /** * @tc.name: RecoverAndReconnectSceneSession * @tc.desc: RecoverAndReconnectSceneSession @@ -527,6 +557,7 @@ HWTEST_F(WindowSceneSessionImplTest, SetActive01, Function | SmallTest | Level2) windowscenesession->hostSession_ = session; ASSERT_EQ(WSError::WS_OK, windowscenesession->SetActive(false)); + ASSERT_EQ(WSError::WS_OK, windowscenesession->SetActive(true)); } /** @@ -2015,6 +2046,76 @@ HWTEST_F(WindowSceneSessionImplTest, SetWindowLimits01, Function | SmallTest | L ASSERT_EQ(windowSizeLimits.minWidth_, 1000); ASSERT_EQ(windowSizeLimits.minHeight_, 1000); } + +/** + * @tc.name: Maximize01 + * @tc.desc: test errorCode + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, Maximize02, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("Maximize02"); + option->SetDisplayId(0); + + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + window->property_->SetWindowName("Maximize02"); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + window->property_->SetPersistentId(2); + + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(nullptr, session); + window->hostSession_ = session; + + MaximizeLayoutOption layoutOption; + // not support subWinodw call + ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, window->Maximize(layoutOption)); + + // window not support fullscreen + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Maximize(layoutOption)); +} + +/** + * @tc.name: Maximize02 + * @tc.desc: test maximizeLayoutOption + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest, Maximize03, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("Maximize03"); + option->SetDisplayId(0); + + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + window->property_->SetWindowName("Maximize03"); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + window->property_->SetPersistentId(2); + + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(nullptr, session); + window->hostSession_ = session; + + ASSERT_NE(nullptr, window); + MaximizeLayoutOption layoutOption; + // dock can not be hide from maximize interface! + layoutOption.dock = ShowType::FORBIDDEN; + auto ret = window->Maximize(layoutOption); + ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, ret); + layoutOption.dock = ShowType::HIDE; + layoutOption.decor = ShowType::HIDE; + ASSERT_NE(WMError::WM_ERROR_INVALID_PARAM, window->Maximize(layoutOption)); + layoutOption.dock = ShowType::HIDE; + layoutOption.decor = ShowType::SHOW; + ASSERT_NE(WMError::WM_ERROR_INVALID_PARAM, window->Maximize(layoutOption)); +} } } // namespace Rosen } // namespace OHOS diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index cabf86841..6be037b1d 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -863,6 +863,12 @@ HWTEST_F(WindowSessionImplTest, RegisterListener01, Function | SmallTest | Level res = window->UnregisterWindowStatusChangeListener(listener5); ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); + sptr listener6 = nullptr; + res = window->RegisterDisplayMoveListener(listener6); + ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); + res = window->UnregisterDisplayMoveListener(listener6); + ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); + GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener01 end"; } @@ -917,6 +923,33 @@ HWTEST_F(WindowSessionImplTest, RegisterListener02, Function | SmallTest | Level GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener02 end"; } +/** + * @tc.name: NotifyDisplayMove + * @tc.desc: NotifyDisplayMove + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, NotifyDisplayMove, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyDisplayMove start"; + sptr option = new WindowOption(); + option->SetWindowName("NotifyDisplayMove"); + sptr window = new WindowSessionImpl(option); + + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", + "CreateTestAbility"}; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(nullptr, session); + ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session)); + + int res = 0; + DisplayId from = 0; + DisplayId to = 2; + window->NotifyDisplayMove(from, to); + ASSERT_EQ(res, 0); + + GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyDisplayMove end"; +} + /** * @tc.name: NotifyAfterForeground * @tc.desc: NotifyAfterForeground @@ -1586,6 +1619,25 @@ HWTEST_F(WindowSessionImplTest, SetDecorVisible, Function | SmallTest | Level2) GTEST_LOG_(INFO) << "WindowSessionImplTest: SetDecorVisibletest01 end"; } +/** + * @tc.name: SetSubWindowModal + * @tc.desc: SetSubWindowModal and check the retCode + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, SetSubWindowModal, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetSubWindowModaltest01 start"; + sptr option = new WindowOption(); + ASSERT_NE(option, nullptr); + option->SetWindowName("SetSubWindowModal"); + sptr window = new (std::nothrow) WindowSessionImpl(option); + ASSERT_NE(window, nullptr); + bool isModal = true; + WMError res = window->SetSubWindowModal(isModal); + ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetSubWindowModaltest01 end"; +} + /** * @tc.name: SetDecorHeight * @tc.desc: SetDecorHeight and check the retCode @@ -1698,6 +1750,26 @@ HWTEST_F(WindowSessionImplTest, SetPipActionEvent, Function | SmallTest | Level2 ASSERT_EQ(res, WSError::WS_OK); GTEST_LOG_(INFO) << "WindowSessionImplTest: SetPipActionEvent end"; } + +/** + * @tc.name: SetUIContentInner + * @tc.desc: SetUIContentInner Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, SetUIContentInner, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetUIContentInner start"; + sptr option = new WindowOption(); + ASSERT_NE(option, nullptr); + option->SetWindowName("SetUIContentInner"); + option->SetExtensionTag(true); + sptr window = new (std::nothrow) WindowSessionImpl(option); + ASSERT_NE(window, nullptr); + string url = ""; + WMError res = window->SetUIContentInner(url, nullptr, nullptr, WindowSetUIContentType::DEFAULT, nullptr); + ASSERT_EQ(res, WMError::WM_ERROR_INVALID_PARAM); + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetUIContentInner end"; +} } } // namespace Rosen } // namespace OHOS diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 8968c66a5..525b25112 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -911,6 +911,22 @@ HWTEST_F(WindowTest, ConsumeKeyEvent, Function | SmallTest | Level2) ASSERT_EQ(WMError::WM_OK, window->Destroy()); } +/** + * @tc.name: PreNotifyKeyEvent + * @tc.desc: get + * @tc.type: FUNC + */ +HWTEST_F(WindowTest, PreNotifyKeyEvent, Function | SmallTest | Level2) +{ + sptr window = new Window(); + ASSERT_NE(nullptr, window); + auto ret = WMError::WM_OK; + std::shared_ptr inputEvent = nullptr; + window->PreNotifyKeyEvent(inputEvent); + ASSERT_EQ(WMError::WM_OK, ret); + ASSERT_EQ(WMError::WM_OK, window->Destroy()); +} + /** * @tc.name: ConsumePointerEvent * @tc.desc: get @@ -2267,6 +2283,19 @@ HWTEST_F(WindowTest, FlushFrameRate, Function | SmallTest | Level2) window->FlushFrameRate(rate); ASSERT_EQ(WMError::WM_OK, window->Destroy()); } + +/** + * @tc.name: Maximize01 + * @tc.desc: maximize interface Test + * @tc.type: FUNC + */ +HWTEST_F(WindowTest, Maximize01, Function | SmallTest | Level2) +{ + sptr window = new Window(); + ASSERT_NE(nullptr, window); + MaximizeLayoutOption option; + ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->Maximize(option)); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/wmserver/BUILD.gn b/wmserver/BUILD.gn index 0bec4801e..a832510fd 100644 --- a/wmserver/BUILD.gn +++ b/wmserver/BUILD.gn @@ -133,7 +133,7 @@ ohos_shared_library("sms") { if (scene_board_enabled) { group("libwms") { - deps = [] + deps = [ "../etc:wms_etc" ] } } else { ohos_shared_library("libwms") { diff --git a/wmserver/src/mock_session_manager_service.cpp b/wmserver/src/mock_session_manager_service.cpp index 044664c73..bd0755dc3 100644 --- a/wmserver/src/mock_session_manager_service.cpp +++ b/wmserver/src/mock_session_manager_service.cpp @@ -57,6 +57,7 @@ const std::string ARG_DUMP_WINDOW = "-w"; const std::string KEY_SCENE_BOARD_TEST_ENABLE = "persist.scb.testmode.enable"; const std::string SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard"; const std::string TEST_MODULE_NAME_SUFFIX = "_test"; +const std::string BOOTEVENT_WMS_READY = "bootevent.wms.ready"; } // namespace class ClientListenerDeathRecipient : public IRemoteObject::DeathRecipient { @@ -187,7 +188,7 @@ bool MockSessionManagerService::SetSessionManagerService(const sptr& windowManagerAgent, WindowManagerAgentType type) { - return wmAgentContainer_.RegisterAgent(windowManagerAgent, type) ? WMError::WM_OK : - WMError::WM_ERROR_REPEAT_OPERATION; + return wmAgentContainer_.RegisterAgent( + windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR; } WMError WindowManagerAgentController::UnregisterWindowManagerAgent(const sptr& windowManagerAgent, WindowManagerAgentType type) { - return wmAgentContainer_.UnregisterAgent(windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR; + return wmAgentContainer_.UnregisterAgent( + windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR; } void WindowManagerAgentController::UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index f87226ac2..614234af0 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -59,6 +59,7 @@ WM_IMPLEMENT_SINGLE_INSTANCE(WindowManagerService) const bool REGISTER_RESULT = SceneBoardJudgement::IsSceneBoardEnabled() ? false : SystemAbility::MakeAndRegisterAbility(&SingletonContainer::Get()); +const std::string BOOTEVENT_WMS_READY = "bootevent.wms.ready"; WindowManagerService::WindowManagerService() : SystemAbility(WINDOW_MANAGER_SERVICE_ID, true), rsInterface_(RSInterfaces::GetInstance()), @@ -108,7 +109,7 @@ void WindowManagerService::OnStart() sptr windowInfoQueriedListener = new WindowInfoQueriedListener(); DisplayManagerServiceInner::GetInstance().RegisterWindowInfoQueriedListener(windowInfoQueriedListener); - + system::SetParameter(BOOTEVENT_WMS_READY.c_str(), "true"); AddSystemAbilityListener(RENDER_SERVICE); AddSystemAbilityListener(ABILITY_MGR_SERVICE_ID); AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); -- Gitee From 36922342a93e31c8121cd5f8fb271d6499e7baa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=81=E7=94=9F=E5=BE=B7?= Date: Tue, 26 Mar 2024 16:10:29 +0800 Subject: [PATCH 205/385] =?UTF-8?q?=E6=97=A0=E4=BA=A4=E4=BA=92=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E6=94=AF=E6=8C=81=E5=A4=9A=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 祁生德 --- interfaces/innerkits/wm/window.h | 21 ++++++- .../window_napi/js_window_listener.cpp | 10 ++++ .../window_napi/js_window_listener.h | 3 + .../js_window_register_manager.cpp | 17 +++++- previewer/include/window.h | 3 +- wm/include/window_session_impl.h | 7 +-- wm/src/window_session_impl.cpp | 58 +++++++++---------- 7 files changed, 78 insertions(+), 41 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 70d22db24..4038fad76 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -393,7 +393,24 @@ using IWindowVisibilityListenerSptr = sptr; */ class IWindowNoInteractionListener : virtual public RefBase { public: + /** + * @brief Observe event when no interaction for a long time. + */ virtual void OnWindowNoInteractionCallback() {}; + + /** + * @brief Set timeout of the listener. + * + * @param timeout. + */ + virtual void SetTimeout(int64_t timeout) {}; + + /** + * @brief get timeout of the listener. + * + * @return timeout. + */ + virtual int64_t GetTimeout() const { return 0;}; }; using IWindowNoInteractionListenerSptr = sptr; @@ -1577,11 +1594,9 @@ public: * @brief Register listener, if timeout(seconds) pass with no interaction, the listener will be executed. * * @param listener IWindowNoInteractionListenerSptr. - * @param timeout uint32_t if timeout(seconds) pass with no interaction, the listener will be executed. * @return WM_OK means unregister success, others means unregister failed. */ - virtual WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, - uint32_t timeout) + virtual WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index 1c5cf44c9..d75f85917 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -395,6 +395,16 @@ void JsWindowListener::OnWaterMarkFlagUpdate(bool showWaterMark) env_, std::make_unique(callback, std::move(execute), std::move(complete))); } +void JsWindowListener::SetTimeout(int64_t timeout) +{ + noInteractionTimeout_ = timeout; +} + +int64_t JsWindowListener::GetTimeout() const +{ + return noInteractionTimeout_; +} + void JsWindowListener::OnWindowNoInteractionCallback() { std::unique_ptr complete = std::make_unique ( diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h index 017bc52dd..a9020726d 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h @@ -94,11 +94,14 @@ public: void OnWindowVisibilityChangedCallback(const bool isVisible) override; void OnWindowNoInteractionCallback() override; void OnWindowTitleButtonRectChanged(const TitleButtonRect& titleButtonRect) override; + void SetTimeout(int64_t timeout) override; + int64_t GetTimeout() const override; private: uint32_t currentWidth_ = 0; uint32_t currentHeight_ = 0; WindowState state_ {WindowState::STATE_INITIAL}; void LifeCycleCallBack(LifeCycleEventType eventType); + int64_t noInteractionTimeout_ = 0; napi_env env_ = nullptr; std::shared_ptr jsCallBack_; wptr weakRef_ = nullptr; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp index 5bddf9b2a..83148eaf1 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp @@ -214,7 +214,7 @@ WmErrorCode JsWindowRegisterManager::ProcessWindowVisibilityChangeRegister(sptr< sptr window, bool isRegister, napi_env env, napi_value parameter) { WLOGD("called"); - if (window == nullptr) { + if (window == nullptr || listener == nullptr) { return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } sptr thisListener(listener); @@ -239,12 +239,23 @@ WmErrorCode JsWindowRegisterManager::ProcessWindowNoInteractionRegister(sptrUnregisterWindowNoInteractionListener(thisListener)); } - uint32_t timeout = 0; + int64_t timeout = 0; if (parameter == nullptr || !ConvertFromJsNumber(env, parameter, timeout)) { WLOGFE("Failed to convert parameter to timeout"); return WmErrorCode::WM_ERROR_INVALID_PARAM; } - return WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterWindowNoInteractionListener(thisListener, timeout)); + + constexpr int64_t S_TO_MS_RATIO = 1000; + constexpr int64_t NO_INTERACTION_MAX = LLONG_MAX / S_TO_MS_RATIO; + if (timeout <= 0 || (timeout > NO_INTERACTION_MAX)) { + WLOGFE("invalid parameter: no-interaction-timeout %{public}" PRId64 " is not in(0s~%{public}" PRId64, + timeout, NO_INTERACTION_MAX); + return WmErrorCode::WM_ERROR_INVALID_PARAM; + } + + thisListener->SetTimeout(timeout * S_TO_MS_RATIO); + + return WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterWindowNoInteractionListener(thisListener)); } WmErrorCode JsWindowRegisterManager::ProcessScreenshotRegister(sptr listener, diff --git a/previewer/include/window.h b/previewer/include/window.h index b4bf20e2e..1a30bf548 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -274,8 +274,7 @@ public: virtual WMError GetWindowLimits(WindowLimits& windowLimits) { return WMError::WM_OK; }; virtual WMError RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0; virtual WMError UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener) = 0; - virtual WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, - uint32_t timeout) + virtual WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index f8c63a397..e150b0f19 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -138,8 +138,7 @@ public: WMError UnregisterTouchOutsideListener(const sptr& listener) override; WMError RegisterWindowVisibilityChangeListener(const IWindowVisibilityListenerSptr& listener) override; WMError UnregisterWindowVisibilityChangeListener(const IWindowVisibilityListenerSptr& listener) override; - WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, - uint32_t timeout) override; + WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) override; WMError UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) override; void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) override; WMError RegisterScreenshotListener(const sptr& listener) override; @@ -180,7 +179,7 @@ public: WSError NotifyTouchOutside() override; WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; WSError NotifyWindowVisibility(bool isVisible) override; - WSError NotifyNoInteractionTimeout(); + WSError NotifyNoInteractionTimeout(const IWindowNoInteractionListenerSptr& listener); WMError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; WindowState state_ { WindowState::STATE_INITIAL }; @@ -316,6 +315,7 @@ private: void UpdateRectForRotation(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason, const std::shared_ptr& rsTransaction = nullptr); void NotifyRotationAnimationEnd(); + void SubmitNoInteractionMonitorTask(int32_t eventId, const IWindowNoInteractionListenerSptr& listener); static std::recursive_mutex lifeCycleListenerMutex_; static std::recursive_mutex windowChangeListenerMutex_; @@ -349,7 +349,6 @@ private: sptr aceAbilityHandler_; std::atomic lastInteractionEventId_ { -1 }; - std::atomic noInteractionTimeout_ { 0 }; // ms WindowSizeChangeReason lastSizeChangeReason_ = WindowSizeChangeReason::END; bool postTaskDone_ = false; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 93fd6551f..4aaa3cc42 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2108,14 +2108,13 @@ WMError WindowSessionImpl::UnregisterWindowVisibilityChangeListener(const IWindo return ret; } -WMError WindowSessionImpl::RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener, - uint32_t timeout) +WMError WindowSessionImpl::RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) { - constexpr uint32_t S_TO_MS_RATIO = 1000; - noInteractionTimeout_.store(timeout * S_TO_MS_RATIO); // s -> ms. WLOGFD("Start to register window no interaction listener."); std::lock_guard lockListener(windowNoInteractionListenerMutex_); - return RegisterListener(windowNoInteractionListeners_[GetPersistentId()], listener); + WMError ret = RegisterListener(windowNoInteractionListeners_[GetPersistentId()], listener); + SubmitNoInteractionMonitorTask(this->lastInteractionEventId_.load(), listener); + return ret; } WMError WindowSessionImpl::UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) @@ -2124,7 +2123,6 @@ WMError WindowSessionImpl::UnregisterWindowNoInteractionListener(const IWindowNo std::lock_guard lockListener(windowNoInteractionListenerMutex_); WMError ret = UnregisterListener(windowNoInteractionListeners_[GetPersistentId()], listener); if (windowNoInteractionListeners_[GetPersistentId()].empty()) { - noInteractionTimeout_.store(0); lastInteractionEventId_.store(-1); } return ret; @@ -2164,17 +2162,16 @@ WSError WindowSessionImpl::NotifyWindowVisibility(bool isVisible) return WSError::WS_OK; } -WSError WindowSessionImpl::NotifyNoInteractionTimeout() +WSError WindowSessionImpl::NotifyNoInteractionTimeout(const IWindowNoInteractionListenerSptr& listener) { - WLOGFD("Notify window no interaction timeout, window: name=%{public}s, id=%{public}u", - GetWindowName().c_str(), GetPersistentId()); - std::lock_guard lockListener(windowNoInteractionListenerMutex_); - auto noInteractionListeners = GetListeners(); - for (auto& listener : noInteractionListeners) { - if (listener != nullptr) { - listener->OnWindowNoInteractionCallback(); - } + if (listener == nullptr) { + WLOGFE("invalid listener: nullptr"); + return WSError::WS_ERROR_NULLPTR; } + WLOGFD("Notify window no interaction timeout, window: name=%{public}s, id=%{public}u, timeout=%{public}" PRId64, + GetWindowName().c_str(), GetPersistentId(), listener->GetTimeout()); + + listener->OnWindowNoInteractionCallback(); return WSError::WS_OK; } @@ -2596,17 +2593,10 @@ void WindowSessionImpl::NotifyTransformChange(const Transform& transform) } } -void WindowSessionImpl::RefreshNoInteractionTimeoutMonitor(int32_t eventId) +void WindowSessionImpl::SubmitNoInteractionMonitorTask(int32_t eventId, + const IWindowNoInteractionListenerSptr& listener) { - { - std::lock_guard lockListener(windowNoInteractionListenerMutex_); - if (windowNoInteractionListeners_[GetPersistentId()].empty()) { - return; - } - } - - this->lastInteractionEventId_.store(eventId); - auto task = [sessionWptr = wptr(this), eventId]() { + auto task = [sessionWptr = wptr(this), eventId, listenerWptr = wptr(listener)]() { auto session = sessionWptr.promote(); if (session == nullptr) { WLOGFE("windowInteractionMonitor task running failed, window session is null"); @@ -2620,12 +2610,22 @@ void WindowSessionImpl::RefreshNoInteractionTimeoutMonitor(int32_t eventId) WLOGFD("window state is not show, need not notify!"); return; } - - session->NotifyNoInteractionTimeout(); - return; + session->NotifyNoInteractionTimeout(listenerWptr.promote()); }; + handler_->PostTask(task, listener->GetTimeout()); +} - handler_->PostTask(task, noInteractionTimeout_.load()); +void WindowSessionImpl::RefreshNoInteractionTimeoutMonitor(int32_t eventId) +{ + std::lock_guard lockListener(windowNoInteractionListenerMutex_); + if (windowNoInteractionListeners_[GetPersistentId()].empty()) { + return; + } + this->lastInteractionEventId_.store(eventId); + auto noInteractionListeners = GetListeners(); + for (const auto& listenerItem : noInteractionListeners) { + SubmitNoInteractionMonitorTask(eventId, listenerItem); + } } } // namespace Rosen -- Gitee From f9fe0e8882967bf67f62b494191014960ac59b62 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Tue, 26 Mar 2024 21:15:05 +0800 Subject: [PATCH 206/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A8=A1=E6=9D=BF=E6=8E=A7=E4=BB=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window.cpp b/wm/src/window.cpp index f693151f9..0eac990fb 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -203,7 +203,7 @@ sptr Window::GetMainWindowWithContext(const std::shared_ptr Date: Tue, 26 Mar 2024 13:31:12 +0000 Subject: [PATCH 207/385] update window_scene/session_manager/src/scene_session_dirty_manager.cpp. Signed-off-by: chengyiyi --- .../session_manager/src/scene_session_dirty_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 6c503b3f6..1b17fbcaf 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -441,7 +441,7 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr if (sceneSession->GetSessionProperty()->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING)) { WLOGFI("Add handwrite flag for session, id: %{public}d", windowId); - windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_HANDWRITE; + windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_HANDWRITING; } return windowInfo; } -- Gitee From 28357f27b48372b777a5a3f40e2e69f71d318ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E6=B0=B8=E9=BE=99?= Date: Wed, 27 Mar 2024 01:27:06 +0000 Subject: [PATCH 208/385] update window_scene/session_manager/include/scene_session_manager.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 熊永龙 --- 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 da7ef1e05..ebf987875 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -540,7 +540,7 @@ private: void NotifyCreateSubSession(int32_t persistentId, sptr session); void CacheSubSessionForRecovering(sptr sceneSession, const sptr& property); void RecoverCachedSubSession(int32_t persistentId); - void RecoverWindowSessionProperty(int32_t persistentId); + void NotifySessionUnfocusedToClient(int32_t persistentId); void NotifyCreateSpecificSession(sptr session, sptr property, const WindowType& type); sptr CreateSceneSession(const SessionInfo& sessionInfo, sptr property); -- Gitee From f0db440f8e62aa8afa6935fcfc8372b1e3a5a517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E6=B0=B8=E9=BE=99?= Date: Wed, 27 Mar 2024 01:35:36 +0000 Subject: [PATCH 209/385] update window_scene/session_manager/src/scene_session_manager.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 熊永龙 --- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 413dc59f1..594441331 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1770,7 +1770,7 @@ WSError SceneSessionManager::RecoverAndConnectSpecificSession(const sptrGetPersistentId()); + NotifySessionUnfocusedToClient(sceneSession->GetPersistentId()); session = sceneSession; return WSError::WS_OK; } -- Gitee From e292f9a4f02817bcc0ca8d5c533beef732a25bdc Mon Sep 17 00:00:00 2001 From: db Date: Tue, 26 Mar 2024 17:34:48 +0800 Subject: [PATCH 210/385] change return value to hex Signed-off-by: db --- .../window_napi/js_window_utils.cpp | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 5d3a3dbfa..2e40fbbdf 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -496,6 +496,20 @@ napi_value CreateJsWindowPropertiesObject(napi_env env, sptr& window, co return objValue; } +static std::string GetHexColor(uint32_t color) +{ + std::stringstream ioss; + std::string temp; + ioss << std::setiosflags(std::ios::uppercase) << std::hex << color; + ioss >> temp; + int count = RGBA_LENGTH - static_cast(temp.length()); + std::string tmpColor(count, '0'); + tmpColor += temp; + std::string finalColor("#"); + finalColor += tmpColor; + return finalColor; +} + napi_value CreateJsSystemBarPropertiesObject(napi_env env, sptr& window) { napi_value objValue = nullptr; @@ -506,31 +520,21 @@ napi_value CreateJsSystemBarPropertiesObject(napi_env env, sptr& window) } SystemBarProperty status = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); SystemBarProperty navi = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_BAR); - napi_set_named_property(env, objValue, "statusBarColor", CreateJsValue(env, status.backgroundColor_)); - napi_set_named_property(env, objValue, "statusBarContentColor", CreateJsValue(env, status.contentColor_)); + napi_set_named_property(env, objValue, "statusBarColor", + CreateJsValue(env, GetHexColor(status.backgroundColor_))); + napi_set_named_property(env, objValue, "statusBarContentColor", + CreateJsValue(env, GetHexColor(status.contentColor_))); napi_set_named_property(env, objValue, "isStatusBarLightIcon", CreateJsValue(env, status.contentColor_ == SYSTEM_COLOR_WHITE)); - napi_set_named_property(env, objValue, "navigationBarColor", CreateJsValue(env, navi.backgroundColor_)); - napi_set_named_property(env, objValue, "navigationBarContentColor", CreateJsValue(env, navi.contentColor_)); + napi_set_named_property(env, objValue, "navigationBarColor", + CreateJsValue(env, GetHexColor(navi.backgroundColor_))); + napi_set_named_property(env, objValue, "navigationBarContentColor", + CreateJsValue(env, GetHexColor(navi.contentColor_))); napi_set_named_property(env, objValue, "isNavigationBarLightIcon", CreateJsValue(env, status.contentColor_ == SYSTEM_COLOR_WHITE)); return objValue; } -static std::string GetHexColor(uint32_t color) -{ - std::stringstream ioss; - std::string temp; - ioss << std::setiosflags(std::ios::uppercase) << std::hex << color; - ioss >> temp; - int count = RGBA_LENGTH - static_cast(temp.length()); - std::string tmpColor(count, '0'); - tmpColor += temp; - std::string finalColor("#"); - finalColor += tmpColor; - return finalColor; -} - static napi_value CreateJsSystemBarRegionTintObject(napi_env env, const SystemBarRegionTint& tint) { napi_value objValue = nullptr; -- Gitee From 9d61d4310a5d39ef7b5e1acf31a494c84514e5c5 Mon Sep 17 00:00:00 2001 From: zhangkai Date: Wed, 27 Mar 2024 10:09:25 +0800 Subject: [PATCH 211/385] checkAspectRatio Signed-off-by: zhangkai Change-Id: Ic53607c552363e348c23e18f5e09d5ab77959c59 --- wm/src/window_impl.cpp | 8 ++++++-- wmserver/src/window_layout_policy_cascade.cpp | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 417946da9..e650f3dfb 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -920,8 +920,12 @@ WMError WindowImpl::SetAspectRatio(float ratio) WLOGFD("window is hidden or created! id: %{public}u, ratio: %{public}f ", property_->GetWindowId(), ratio); return WMError::WM_OK; } - UpdateProperty(PropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO); - return WMError::WM_OK; + auto ret = UpdateProperty(PropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO); + if (ret != WMError::WM_OK) { + WLOGFE("Set AspectRatio failed. errorCode: %{public}u", ret); + return ret; + } + return ret; } WMError WindowImpl::ResetAspectRatio() diff --git a/wmserver/src/window_layout_policy_cascade.cpp b/wmserver/src/window_layout_policy_cascade.cpp index 6c4e98a72..9ce702404 100644 --- a/wmserver/src/window_layout_policy_cascade.cpp +++ b/wmserver/src/window_layout_policy_cascade.cpp @@ -446,6 +446,7 @@ void WindowLayoutPolicyCascade::UpdateLayoutRect(const sptr& node) winRect = cascadeRectsMap_[displayId].secondaryRect_; break; case WindowMode::WINDOW_MODE_FULLSCREEN: { + UpdateWindowSizeLimits(node); bool needAvoid = (node->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_NEED_AVOID)); winRect = needAvoid ? limitRectMap_[displayId] : DisplayGroupInfo::GetInstance().GetDisplayRect(displayId); auto displayInfo = DisplayGroupInfo::GetInstance().GetDisplayInfo(displayId); -- Gitee From 1b6b5aa4fa33e681a7254a52918cb5846da464eb Mon Sep 17 00:00:00 2001 From: zhangyao Date: Tue, 26 Mar 2024 06:48:20 +0000 Subject: [PATCH 212/385] =?UTF-8?q?Description:=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E7=8E=87=E5=9B=9E=E8=B0=83=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=97=B6=E6=9C=BA=20IssueNo:=20https://gitee.com/openharmony/w?= =?UTF-8?q?indow=5Fwindow=5Fmanager/issues/I9BLJI=20Feature=20or=20Bugfix:?= =?UTF-8?q?=20Feature=20Binary=20Source:No=20Signed-off-by:=20zhangyao=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/screen_session_manager.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 3b6d4bfca..b2d1659f0 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -164,7 +164,6 @@ void ScreenSessionManager::Init() } RegisterScreenChangeListener(); - RegisterRefreshRateModeChangeListener(); bool isPcDevice = system::GetParameter("const.product.devicetype", "unknown") == "2in1"; if (isPcDevice) { @@ -296,12 +295,14 @@ void ScreenSessionManager::RegisterScreenChangeListener() void ScreenSessionManager::RegisterRefreshRateModeChangeListener() { - auto res = rsInterface_.RegisterHgmRefreshRateModeChangeCallback( - [this](int32_t refreshRateMode) { OnHgmRefreshRateModeChange(refreshRateMode); }); - if (res != StatusCode::SUCCESS) { - WLOGFE("Register refresh rate mode change listener failed, retry after 50 ms."); - auto task = [this]() { RegisterRefreshRateModeChangeListener(); }; - taskScheduler_->PostAsyncTask(task, "RegisterRefreshRateModeChangeListener", 50); // Retry after 50 ms. + static bool isRegisterRefreshRateListener = false; + if (!isRegisterRefreshRateListener) { + auto res = rsInterface_.RegisterHgmRefreshRateModeChangeCallback( + [this](int32_t refreshRateMode) { OnHgmRefreshRateModeChange(refreshRateMode); }); + if (res != StatusCode::SUCCESS) { + WLOGFE("Register refresh rate mode change listener failed."); + } + isRegisterRefreshRateListener = true; } } @@ -852,6 +853,7 @@ sptr ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre } SetHdrFormats(screenId, session); SetColorSpaces(screenId, session); + RegisterRefreshRateModeChangeListener(); return session; } -- Gitee From b2cae98b58718996368c26fe95213e0fcd4c4090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Wed, 27 Mar 2024 11:21:19 +0800 Subject: [PATCH 213/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../napi/window_runtime/window_napi/js_window.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 9a491604a..2950d176b 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5308,20 +5308,16 @@ napi_value JsWindow::OnGetTitleButtonRect(napi_env env, napi_callback_info info) napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) { - WmErrorCode errCode = WmErrorCode::WM_OK; size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; + WLOGFE("Argc is invalid: %{public}zu", argc); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } std::vector> windowMask; - if (errCode == WmErrorCode::WM_OK) { - if (!GetWindowMaskFromJsValue(env, argv[0], windowMask)) { - errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; - } - } - if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { + if (!GetWindowMaskFromJsValue(env, argv[0], windowMask)) { + WLOGFE("GetWindowMaskFromJsValue failed"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } wptr weakToken(windowToken_); -- Gitee From 935561c74471e398c4849cf529018388c06e65a3 Mon Sep 17 00:00:00 2001 From: qintongtong Date: Wed, 27 Mar 2024 11:27:24 +0800 Subject: [PATCH 214/385] =?UTF-8?q?=E4=BF=AE=E5=A4=8DkeyEvent=E9=94=81?= =?UTF-8?q?=E9=98=BB=E5=A1=9E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qintongtong Change-Id: I47e3174af9ec408a8e40e2d95f0e7bf6b149dc31 --- window_scene/intention_event/src/intention_event_manager.cpp | 3 +++ window_scene/session/host/include/session.h | 2 +- window_scene/session/host/src/scene_session.cpp | 2 +- window_scene/session/host/src/session.cpp | 2 +- wm/src/window_input_channel.cpp | 3 +++ 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/window_scene/intention_event/src/intention_event_manager.cpp b/window_scene/intention_event/src/intention_event_manager.cpp index 4db2ef127..2452280a9 100644 --- a/window_scene/intention_event/src/intention_event_manager.cpp +++ b/window_scene/intention_event/src/intention_event_manager.cpp @@ -287,6 +287,9 @@ void IntentionEventManager::InputEventListener::OnInputEvent(std::shared_ptrSendKeyEventToUI(keyEvent, true); TLOGI(WmsLogTag::WMS_EVENT, "SendKeyEventToUI isConsumed = %{public}d", static_cast(isConsumed)); + if (isConsumed) { + return; + } #ifdef IMF_ENABLE bool isKeyboardEvent = IsKeyboardEvent(keyEvent); if (isKeyboardEvent) { diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 42b5d490c..da8892dd3 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -496,7 +496,7 @@ protected: sptr parentSession_; mutable std::mutex pointerEventMutex_; - mutable std::mutex keyEventMutex_; + mutable std::shared_mutex keyEventMutex_; private: void HandleDialogForeground(); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1c1aa35b6..39a559142 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2390,7 +2390,7 @@ void SceneSession::SendPointerEventToUI(std::shared_ptr point bool SceneSession::SendKeyEventToUI(std::shared_ptr keyEvent, bool isPreImeEvent) { - std::lock_guard lock(keyEventMutex_); + std::shared_lock lock(keyEventMutex_); if (systemSessionKeyEventFunc_ != nullptr) { return systemSessionKeyEventFunc_(keyEvent, isPreImeEvent); } diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index ae4f6c89e..c6379445d 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -2462,7 +2462,7 @@ void Session::SetNotifySystemSessionPointerEventFunc(const NotifySystemSessionPo void Session::SetNotifySystemSessionKeyEventFunc(const NotifySystemSessionKeyEventFunc& func) { - std::lock_guard lock(keyEventMutex_); + std::unique_lock lock(keyEventMutex_); systemSessionKeyEventFunc_ = func; } diff --git a/wm/src/window_input_channel.cpp b/wm/src/window_input_channel.cpp index 7846de8ad..2c8b1cc97 100644 --- a/wm/src/window_input_channel.cpp +++ b/wm/src/window_input_channel.cpp @@ -75,6 +75,9 @@ void WindowInputChannel::HandleKeyEvent(std::shared_ptr& keyEvent } bool isConsumed = window_->PreNotifyKeyEvent(keyEvent); TLOGI(WmsLogTag::WMS_EVENT, "PreNotifyKeyEvent isConsumed = %{public}d", static_cast(isConsumed)); + if (isConsumed) { + return; + } #ifdef IMF_ENABLE bool isKeyboardEvent = IsKeyboardEvent(keyEvent); if (isKeyboardEvent) { -- Gitee From 158832a18dcbf9ae99dda78f6fd362a97ed9c731 Mon Sep 17 00:00:00 2001 From: liubo Date: Tue, 26 Mar 2024 18:56:11 +0800 Subject: [PATCH 215/385] =?UTF-8?q?Description:=20DMS=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=95=B4=E6=94=B9=20IssueNo:https://gitee.com/openharmony/wind?= =?UTF-8?q?ow=5Fwindow=5Fmanager/issues/I9BTL2=20Feature=20or=20Bugfix:=20?= =?UTF-8?q?Bugfix=20Binary=20Source:No=20Signed-off-by:=20liubo419=20Please=20enter=20the=20commit=20message=20for?= =?UTF-8?q?=20your=20changes.=20Lines=20starting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dm/src/display_manager.cpp | 2 +- dm/src/display_manager_adapter.cpp | 4 ++-- dm/src/screen_manager.cpp | 2 +- .../src/screen_session_manager_client.cpp | 4 ++-- .../session_manager/src/zidl/screen_session_manager_proxy.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dm/src/display_manager.cpp b/dm/src/display_manager.cpp index 02745c0a6..c28fcdca3 100644 --- a/dm/src/display_manager.cpp +++ b/dm/src/display_manager.cpp @@ -358,7 +358,7 @@ bool DisplayManager::Impl::CheckSizeValid(const Media::Size& size, int32_t oriHe void DisplayManager::Impl::ClearDisplayStateCallback() { std::lock_guard lock(mutex_); - WLOGFI("[UL_POWER]Clear displaystatecallback enter"); + WLOGFD("[UL_POWER]Clear displaystatecallback enter"); displayStateCallback_ = nullptr; if (displayStateAgent_ != nullptr) { WLOGFI("[UL_POWER]UnregisterDisplayManagerAgent enter and displayStateAgent_ is cleared"); diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index 3f00521cb..448b02921 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -410,7 +410,7 @@ void DMSDeathRecipient::OnRemoteDied(const wptr& wptrDeath) BaseAdapter::~BaseAdapter() { - WLOGFI("BaseAdapter destory!"); + WLOGFD("BaseAdapter destory!"); std::lock_guard lock(mutex_); displayManagerServiceProxy_ = nullptr; } @@ -502,7 +502,7 @@ sptr DisplayManagerAdapter::GetDisplayInfo(DisplayId displayId) sptr DisplayManagerAdapter::GetCutoutInfo(DisplayId displayId) { - WLOGFI("DisplayManagerAdapter::GetCutoutInfo"); + WLOGFD("DisplayManagerAdapter::GetCutoutInfo"); if (displayId == DISPLAY_ID_INVALID) { WLOGFE("screen id is invalid"); return nullptr; diff --git a/dm/src/screen_manager.cpp b/dm/src/screen_manager.cpp index d3a3aae5d..bea67ba9c 100644 --- a/dm/src/screen_manager.cpp +++ b/dm/src/screen_manager.cpp @@ -646,7 +646,7 @@ bool ScreenManager::Impl::UpdateScreenInfoLocked(sptr screenInfo) } auto iter = screenMap_.find(screenId); if (iter != screenMap_.end() && iter->second != nullptr) { - WLOGFI("get screen in screen map"); + WLOGFD("get screen in screen map"); iter->second->UpdateScreenInfo(screenInfo); return true; } diff --git a/window_scene/screen_session_manager/src/screen_session_manager_client.cpp b/window_scene/screen_session_manager/src/screen_session_manager_client.cpp index 11ea16b1c..0b508b63b 100644 --- a/window_scene/screen_session_manager/src/screen_session_manager_client.cpp +++ b/window_scene/screen_session_manager/src/screen_session_manager_client.cpp @@ -310,9 +310,9 @@ void ScreenSessionManagerClient::SetScreenPrivacyState(bool hasPrivate) WLOGFE("screenSessionManager_ is null"); return; } - WLOGFI("Begin calling the SetScreenPrivacyState() of screenSessionManager_, hasPrivate: %{public}d", hasPrivate); + WLOGFD("Begin calling the SetScreenPrivacyState() of screenSessionManager_, hasPrivate: %{public}d", hasPrivate); screenSessionManager_->SetScreenPrivacyState(hasPrivate); - WLOGFI("End calling the SetScreenPrivacyState() of screenSessionManager_"); + WLOGFD("End calling the SetScreenPrivacyState() of screenSessionManager_"); } void ScreenSessionManagerClient::UpdateAvailableArea(ScreenId screenId, DMRect area) diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp index b0d8e4245..65c2d0571 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -1294,7 +1294,7 @@ void ScreenSessionManagerProxy::RemoveVirtualScreenFromGroup(std::vector ScreenSessionManagerProxy::GetDisplaySnapshot(DisplayId displayId, DmErrorCode* errorCode) { - WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot enter"); + WLOGFD("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot enter"); sptr remote = Remote(); if (remote == nullptr) { WLOGFW("SCB: ScreenSessionManagerProxy::GetDisplaySnapshot: remote is nullptr"); -- Gitee From 613611a203f7b4944a6065a7d5b1fa13aaa07ab4 Mon Sep 17 00:00:00 2001 From: "yangfei110@huawei.com" Date: Tue, 26 Mar 2024 21:00:53 +0800 Subject: [PATCH 216/385] add log for display move Signed-off-by: yangfei110@huawei.com Change-Id: Idbc9e8830fc646166a341fb32ea656240d905378 --- window_scene/session/host/src/scene_session.cpp | 2 ++ .../session_manager/src/scene_session_manager.cpp | 10 +++++----- wm/include/window_session_impl.h | 2 +- wm/src/window_session_impl.cpp | 15 ++++++++------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 378d8092d..84d2697a7 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2436,6 +2436,8 @@ void SceneSession::NotifyDisplayMove(DisplayId from, DisplayId to) { if (sessionStage_) { sessionStage_->NotifyDisplayMove(from, to); + } else { + WLOGFE("Notify display move failed, sessionStage is null"); } } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index b16e03dd1..5c784feed 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1211,16 +1211,16 @@ sptr SceneSessionManager::SetAbilitySessionInfo(const sptruserId = currentUserId_; abilitySessionInfo->isClearSession = sessionInfo.isClearSession; abilitySessionInfo->processOptions = sessionInfo.processOptions; - if (scnSession->GetSessionProperty()) { - abilitySessionInfo->want.SetParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, - static_cast(scnSession->GetSessionProperty()->GetDisplayId())); - } if (sessionInfo.want != nullptr) { abilitySessionInfo->want = *sessionInfo.want; } else { abilitySessionInfo->want.SetElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); } + if (scnSession->GetSessionProperty()) { + abilitySessionInfo->want.SetParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, + static_cast(scnSession->GetSessionProperty()->GetDisplayId())); + } return abilitySessionInfo; } @@ -6876,7 +6876,7 @@ WSError SceneSessionManager::UpdateSessionDisplayId(int32_t persistentId, uint64 return WSError::WS_ERROR_NULLPTR; } scnSession->GetSessionProperty()->SetDisplayId(screenId); - WLOGFD("Session move display %{public}" PRIu64" from %{public}" PRIu64"", screenId, fromScreenId); + WLOGFD("Session move display %{public}" PRIu64 " from %{public}" PRIu64, screenId, fromScreenId); NotifySessionUpdate(scnSession->GetSessionInfo(), ActionType::MOVE_DISPLAY, fromScreenId); scnSession->NotifyDisplayMove(fromScreenId, screenId); scnSession->UpdateDensity(); diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index f8c63a397..778728125 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -329,7 +329,7 @@ private: static std::recursive_mutex windowNoInteractionListenerMutex_; static std::recursive_mutex windowStatusChangeListenerMutex_; static std::recursive_mutex windowTitleButtonRectChangeListenerMutex_; - static std::recursive_mutex displayMoveListenerMutex_; + static std::mutex displayMoveListenerMutex_; static std::map>> lifecycleListeners_; static std::map>> displayMoveListeners_; static std::map>> windowChangeListeners_; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 93fd6551f..05cf6af9e 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -86,7 +86,7 @@ std::recursive_mutex WindowSessionImpl::windowVisibilityChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::windowNoInteractionListenerMutex_; std::recursive_mutex WindowSessionImpl::windowStatusChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::windowTitleButtonRectChangeListenerMutex_; -std::recursive_mutex WindowSessionImpl::displayMoveListenerMutex_; +std::mutex WindowSessionImpl::displayMoveListenerMutex_; std::map>> WindowSessionImpl::windowSessionMap_; std::shared_mutex WindowSessionImpl::windowSessionMutex_; std::map>> WindowSessionImpl::subWindowSessionMap_; @@ -1143,15 +1143,15 @@ WMError WindowSessionImpl::RegisterLifeCycleListener(const sptr& listener) { - WLOGFD("RegisterDisplayMoveListener"); - std::lock_guard lockListener(displayMoveListenerMutex_); + WLOGFD("start register"); + std::lock_guard lockListener(displayMoveListenerMutex_); return RegisterListener(displayMoveListeners_[GetPersistentId()], listener); } WMError WindowSessionImpl::UnregisterDisplayMoveListener(sptr& listener) { - WLOGFD("UnregisterDisplayMoveListener"); - std::lock_guard lockListener(displayMoveListenerMutex_); + WLOGFD("Start unregister"); + std::lock_guard lockListener(displayMoveListenerMutex_); return UnregisterListener(displayMoveListeners_[GetPersistentId()], listener); } @@ -1475,7 +1475,7 @@ EnableIfSame lockListener(displayMoveListenerMutex_); + std::lock_guard lockListener(displayMoveListenerMutex_); ClearUselessListeners(displayMoveListeners_, persistentId); } { @@ -1816,7 +1816,8 @@ EnableIfSame>> W void WindowSessionImpl::NotifyDisplayMove(DisplayId from, DisplayId to) { - std::lock_guard lockListener(displayMoveListenerMutex_); + WLOGFD("Notify display move from %{public}" PRIu64 " to %{public}" PRIu64, from, to); + std::lock_guard lockListener(displayMoveListenerMutex_); auto displayMoveListeners = GetListeners(); for (auto& listener : displayMoveListeners) { if (listener != nullptr) { -- Gitee From 399b2d9aa3bd35bf2258aac53251d8f36d5080aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Wed, 27 Mar 2024 14:45:18 +0800 Subject: [PATCH 217/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- interfaces/kits/napi/window_runtime/window_napi/js_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 2950d176b..eb4808b9a 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5339,7 +5339,7 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetWindowMask(windowMask)); if (ret != WmErrorCode::WM_OK) { task.Reject(env, CreateJsError(env, static_cast(ret))); - WLOGI("Window [%{public}u, %{public}s] set window mask failed", + WLOGFE("Window [%{public}u, %{public}s] set window mask failed", weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); return; } -- Gitee From 78945f6526a51085936580ae3269f3eac13b90f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Wed, 27 Mar 2024 14:57:27 +0800 Subject: [PATCH 218/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../kits/napi/window_runtime/window_napi/js_window_utils.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index b31f29ad3..0744d0fb8 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -844,6 +844,10 @@ bool GetWindowMaskFromJsValue(napi_env env, napi_value jsObject, std::vector elementArray; napi_value getElementValue = nullptr; -- Gitee From 6ca8c279a457a80a2a215cf4a47485e69f60e617 Mon Sep 17 00:00:00 2001 From: wanganjie Date: Wed, 27 Mar 2024 15:13:13 +0800 Subject: [PATCH 219/385] update log Signed-off-by: wanganjie --- .../session_manager/src/scene_session_manager.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c5846c829..72d5ddb23 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7274,13 +7274,13 @@ WSError SceneSessionManager::HandleSecureExtSessionShouldHide(int32_t persistent WSError SceneSessionManager::AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) { - TLOGD(WmsLogTag::WMS_UIEXT, "AddOrRemoveSecureSession, persistentId=%{public}d, shouldHide=%{public}u", - persistentId, shouldHide); + TLOGD(WmsLogTag::WMS_UIEXT, "persistentId=%{public}d, shouldHide=%{public}u", persistentId, shouldHide); auto task = [this, persistentId, shouldHide]() { std::shared_lock lock(sceneSessionMapMutex_); auto iter = sceneSessionMap_.find(persistentId); if (iter == sceneSessionMap_.end()) { - TLOGE(WmsLogTag::WMS_UIEXT, "Session with persistentId %{public}d not found", persistentId); + TLOGE(WmsLogTag::WMS_UIEXT, "AddOrRemoveSecureSession: Session with persistentId %{public}d not found", + persistentId); return WSError::WS_ERROR_INVALID_SESSION; } @@ -7295,8 +7295,8 @@ WSError SceneSessionManager::AddOrRemoveSecureSession(int32_t persistentId, bool WSError SceneSessionManager::AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide) { - TLOGD(WmsLogTag::WMS_UIEXT, "AddOrRemoveSecureExtSession, persistentId=%{public}d, parentId=%{public}d, " - "shouldHide=%{public}u", persistentId, parentId, shouldHide); + TLOGD(WmsLogTag::WMS_UIEXT, "persistentId=%{public}d, parentId=%{public}d, shouldHide=%{public}u", persistentId, + parentId, shouldHide); if (!SessionPermission::IsSystemCalling()) { TLOGE(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows permission denied!"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -7306,7 +7306,8 @@ WSError SceneSessionManager::AddOrRemoveSecureExtSession(int32_t persistentId, i std::shared_lock lock(sceneSessionMapMutex_); auto iter = sceneSessionMap_.find(parentId); if (iter == sceneSessionMap_.end()) { - TLOGD(WmsLogTag::WMS_UIEXT, "Parent session with persistentId %{public}d not found", parentId); + TLOGD(WmsLogTag::WMS_UIEXT, "AddOrRemoveSecureExtSession: Parent session with persistentId %{public}d not " + "found", parentId); // process UIExtension that created by SceneBoard return HandleSecureExtSessionShouldHide(persistentId, shouldHide); } -- Gitee From 92e1c283f7e28b7ca1ec2ea62e6a3c73b958576c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Wed, 27 Mar 2024 15:15:03 +0800 Subject: [PATCH 220/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- window_scene/session_manager/src/scene_session_manager.cpp | 3 ++- 1 file changed, 2 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 82d7cbc55..b33adf7a8 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2845,8 +2845,9 @@ WMError SceneSessionManager::HandleUpdateProperty(const sptrGetSessionProperty() != nullptr) { sceneSession->GetSessionProperty()->SetWindowMask(property->GetWindowMask()); sceneSession->GetSessionProperty()->SetIsShaped(property->GetIsShaped()); + FlushWindowInfoToMMI(); } - FlushWindowInfoToMMI(); + break; } default: break; -- Gitee From f443d5231d5423b159e8388a5eb83d3279c0e1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Wed, 27 Mar 2024 15:28:10 +0800 Subject: [PATCH 221/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../kits/napi/window_runtime/window_napi/js_window_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 0744d0fb8..6ba6b1760 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -844,7 +844,7 @@ bool GetWindowMaskFromJsValue(napi_env env, napi_value jsObject, std::vector 1920) { WLOGFE("Invalid window mask"); return false; } -- Gitee From ae66cd71c052b03ba3a2c09fb47259d6fdfb667a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Wed, 27 Mar 2024 07:46:04 +0000 Subject: [PATCH 222/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../js_scene_session_manager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 53aa0a7c9..cbbacbd78 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -47,7 +47,7 @@ constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "JsScen constexpr int WAIT_FOR_SECONDS = 2; constexpr int MIN_ARG_COUNT = 3; constexpr int ARG_INDEX_1 = 1; -constexpr int ARG_INDEX_2 = 2; +constexpr int ARG_INDEX_TWO = 2; constexpr int ARG_INDEX_3 = 3; const std::string CREATE_SYSTEM_SESSION_CB = "createSpecificSession"; const std::string RECOVER_SCENE_SESSION_CB = "recoverSceneSession"; @@ -1800,7 +1800,7 @@ napi_value JsSceneSessionManager::OnRequestFocusStatus(napi_env env, napi_callba return NapiGetUndefined(env); } bool byForeground = false; - if (!ConvertFromJsValue(env, argv[ARG_INDEX_2], byForeground)) { + if (!ConvertFromJsValue(env, argv[ARG_INDEX_TWO], byForeground)) { WLOGFE("[NAPI]Failed to convert parameter to byForeground"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); @@ -1952,9 +1952,9 @@ napi_value JsSceneSessionManager::OnNotifyAINavigationBarShowStatus(napi_env env "Input parameter is missing or invalid")); return NapiGetUndefined(env); } - int32_t displayId = -1; - if (!ConvertFromJsValue(env, argv[ARG_INDEX_2], displayId)) { - WLOGFE("[NAPI]Failed to convert parameter to displayId"); + int64_t displayId = -1; + if (!ConvertFromJsValue(env, argv[ARG_INDEX_TWO], displayId)) { + TLOGE(WmsLogTag::WMS_LIFE, "[NAPI]Failed to convert parameter to displayId"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); return NapiGetUndefined(env); @@ -2071,7 +2071,7 @@ napi_value JsSceneSessionManager::OnReportData(napi_env env, napi_callback_info } std::unordered_map mapPayload; - if (!ConvertStringMapFromJs(env, argv[ARG_INDEX_2], mapPayload)) { + if (!ConvertStringMapFromJs(env, argv[ARG_INDEX_TWO], mapPayload)) { WLOGFE("[NAPI]Failed to convert parameter to pauloadPid"); napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), "Input parameter is missing or invalid")); -- Gitee From 2663844db07f4cc242bf394407401a5e44228a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Wed, 27 Mar 2024 07:48:17 +0000 Subject: [PATCH 223/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session_manager/include/scene_session_manager.h | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index ad7231cfd..9ad418d9d 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -489,6 +489,7 @@ private: sptr appAnrListener_; bool isAINavigationBarVisible_ = false; + std::shared_mutex currAINavigationBarAreaMapMutex_; std::map currAINavigationBarAreaMap_; std::shared_ptr eventLoop_; -- Gitee From 518b5e0e41453d20d20e1b3d17d24629b265abe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Wed, 27 Mar 2024 08:01:26 +0000 Subject: [PATCH 224/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../src/scene_session_manager.cpp | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 9c4e940d8..2166c67bf 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -862,6 +862,10 @@ sptr SceneSessionManager::GetSceneSessionByName(const std::string& std::vector> SceneSessionManager::GetSceneSessionVectorByType( WindowType type, uint64_t displayId) { + if (displayId == DISPLAY_ID_INVALID) { + TLOGE(WmsLogTag::WMS_LIFE, "displayId is invalid"); + return {}; + } std::vector> sceneSessionVector; std::shared_lock lock(sceneSessionMapMutex_); for (const auto &item : sceneSessionMap_) { @@ -6167,15 +6171,23 @@ WSError SceneSessionManager::NotifyAINavigationBarShowStatus(bool isVisible, WSR "area{%{public}d,%{public}d,%{public}d,%{public}d}, displayId: %{public}" PRIu64"", isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_, displayId); auto task = [this, isVisible, barArea, displayId]() { - if (isAINavigationBarVisible_ != isVisible || currAINavigationBarAreaMap_.count(displayId) < 1 || - currAINavigationBarAreaMap_[displayId] != barArea) { - isAINavigationBarVisible_ = isVisible; - currAINavigationBarAreaMap_.clear(); - currAINavigationBarAreaMap_[displayId] = barArea; - if (!isVisible && !barArea.IsEmpty()) { + bool isNeedUpdate = false; + { + std::unique_lock lock(currAINavigationBarAreaMapMutex_); + isNeedUpdate = isAINavigationBarVisible_ != isVisible || + currAINavigationBarAreaMap_.count(displayId) == 0 || + currAINavigationBarAreaMap_[displayId] != barArea; + if (isNeedUpdate) { + isAINavigationBarVisible_ = isVisible; + currAINavigationBarAreaMap_.clear(); + currAINavigationBarAreaMap_[displayId] = barArea; + } + if (isNeedUpdate && !isVisible && !barArea.IsEmpty()) { WLOGFD("NotifyAINavigationBarShowStatus: barArea should be empty if invisible"); currAINavigationBarAreaMap_[displayId] = WSRect(); } + } + if (isNeedUpdate) { WLOGFI("NotifyAINavigationBarShowStatus: enter: %{public}u, {%{public}d,%{public}d,%{public}d,%{public}d}", isVisible, barArea.posX_, barArea.posY_, barArea.width_, barArea.height_); for (auto persistentId : avoidAreaListenerSessionSet_) { @@ -6208,7 +6220,8 @@ void SceneSessionManager::NotifySessionAINavigationBarChange(int32_t persistentI WSRect SceneSessionManager::GetAINavigationBarArea(uint64_t displayId) { - if (currAINavigationBarAreaMap_.count(displayId) < 1) { + std::shared_lock lock(currAINavigationBarAreaMapMutex_); + if (currAINavigationBarAreaMap_.count(displayId) == 0) { return {}; } return currAINavigationBarAreaMap_[displayId]; -- Gitee From 7452255397f1bb3ff1a787f2d1ed44ed2b28fdb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Wed, 27 Mar 2024 08:04:00 +0000 Subject: [PATCH 225/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- window_scene/session_manager/src/screen_scene_config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/screen_scene_config.cpp b/window_scene/session_manager/src/screen_scene_config.cpp index 0184347bd..47aa7455c 100644 --- a/window_scene/session_manager/src/screen_scene_config.cpp +++ b/window_scene/session_manager/src/screen_scene_config.cpp @@ -286,7 +286,7 @@ DMRect ScreenSceneConfig::CalcCutoutBoundaryRect(std::string svgPath) std::vector ScreenSceneConfig::GetCutoutBoundaryRect(uint64_t displayId) { - if (cutoutBoundaryRectMap_.count(displayId) < 1) { + if (cutoutBoundaryRectMap_.count(displayId) == 0) { return {}; } return cutoutBoundaryRectMap_[displayId]; -- Gitee From ad9c10d561138d7ad5e9596d90b17ba1da957725 Mon Sep 17 00:00:00 2001 From: wanganjie Date: Wed, 27 Mar 2024 16:21:13 +0800 Subject: [PATCH 226/385] modify according to review Signed-off-by: wanganjie --- .../session_manager/src/scene_session_manager.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 72d5ddb23..366eab5cc 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7221,7 +7221,7 @@ void SceneSessionManager::HideNonSecureFloatingWindows(size_t sizeBefore, size_t auto session = item.second; if (session && session->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT) { session->NotifyForceHideChange(shouldHide); - TLOGD(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows name=%{public}s, persistendId=%{public}d, " + TLOGI(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows name=%{public}s, persistendId=%{public}d, " "shouldHide=%{public}u", session->GetWindowName().c_str(), item.first, shouldHide); } } @@ -7237,8 +7237,13 @@ void SceneSessionManager::HideNonSecureSubWindows(const sptr& scen auto subSessions = sceneSession->GetSubSession(); for (const auto& subSession: subSessions) { + if (subSession == nullptr) { + TLOGD(WmsLogTag::WMS_UIEXT, "sub session is nullptr"); + continue; + } + subSession->NotifyForceHideChange(shouldHide); - TLOGD(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows name=%{public}s, persistendId=%{public}d, " + TLOGI(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows name=%{public}s, persistendId=%{public}d, " "shouldHide=%{public}u", subSession->GetWindowName().c_str(), subSession->GetPersistentId(), shouldHide); } @@ -7274,7 +7279,7 @@ WSError SceneSessionManager::HandleSecureExtSessionShouldHide(int32_t persistent WSError SceneSessionManager::AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) { - TLOGD(WmsLogTag::WMS_UIEXT, "persistentId=%{public}d, shouldHide=%{public}u", persistentId, shouldHide); + TLOGI(WmsLogTag::WMS_UIEXT, "persistentId=%{public}d, shouldHide=%{public}u", persistentId, shouldHide); auto task = [this, persistentId, shouldHide]() { std::shared_lock lock(sceneSessionMapMutex_); auto iter = sceneSessionMap_.find(persistentId); @@ -7295,7 +7300,7 @@ WSError SceneSessionManager::AddOrRemoveSecureSession(int32_t persistentId, bool WSError SceneSessionManager::AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide) { - TLOGD(WmsLogTag::WMS_UIEXT, "persistentId=%{public}d, parentId=%{public}d, shouldHide=%{public}u", persistentId, + TLOGI(WmsLogTag::WMS_UIEXT, "persistentId=%{public}d, parentId=%{public}d, shouldHide=%{public}u", persistentId, parentId, shouldHide); if (!SessionPermission::IsSystemCalling()) { TLOGE(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows permission denied!"); -- Gitee From 2cb4416aa4f45a9bbf4578f8ad1309d190a1d389 Mon Sep 17 00:00:00 2001 From: h00833914 Date: Tue, 26 Mar 2024 08:27:39 +0000 Subject: [PATCH 227/385] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E9=99=8D=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: h00833914 Change-Id: I39560d73ac681c1fdd1ebc98925f78a978b9a89d --- window_scene/session_manager/src/screen_session_manager.cpp | 6 +++--- .../session_manager/src/session_listener_controller.cpp | 2 +- wm/src/window_extension_session_impl.cpp | 2 +- wm/src/window_session_impl.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 186658e61..b1d5a1819 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -2699,7 +2699,7 @@ std::shared_ptr ScreenSessionManager::GetScreenSnapshot(Display std::shared_ptr ScreenSessionManager::GetDisplaySnapshot(DisplayId displayId, DmErrorCode* errorCode) { - WLOGFI("GetDisplaySnapshot ENTER!"); + WLOGFD("ENTER!"); if (system::GetBoolParameter("persist.edm.disallow_screenshot", false)) { WLOGFI("GetDisplaySnapshot was disabled by edm!"); @@ -2968,7 +2968,7 @@ void ScreenSessionManager::OnScreenshot(sptr info) } auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::SCREENSHOT_EVENT_LISTENER); if (agents.empty()) { - WLOGFI("OnScreenshot agents empty"); + WLOGFD("agents empty"); return; } WLOGFI("onScreenshot"); @@ -3648,7 +3648,7 @@ void ScreenSessionManager::CheckAndSendHiSysEvent(const std::string& eventName, { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "ssm:CheckAndSendHiSysEvent"); if (Permission::CheckIsCallingBundleName(bundleName) == false) { - WLOGI("BundleName not in whitelist!"); + WLOGD("BundleName not in whitelist!"); return; } int32_t eventRet = HiSysEventWrite( diff --git a/window_scene/session_manager/src/session_listener_controller.cpp b/window_scene/session_manager/src/session_listener_controller.cpp index 2bfaf350b..5c0b2261a 100644 --- a/window_scene/session_manager/src/session_listener_controller.cpp +++ b/window_scene/session_manager/src/session_listener_controller.cpp @@ -338,7 +338,7 @@ template void SessionListenerController::CallListeners(F func, Args&& ... args) { std::lock_guard guard(listenerLock_); - WLOGFI("CallListeners size: %{public}d ", static_cast(sessionListeners_.size())); + WLOGFD("size: %{public}d ", static_cast(sessionListeners_.size())); for (auto listener : sessionListeners_) { if (listener) { (listener->*func)(std::forward(args)...); diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 71a9b589e..b7c52a48b 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -676,7 +676,7 @@ void WindowExtensionSessionImpl::CheckAndRemoveExtWindowFlags() WMError WindowExtensionSessionImpl::SetExtWindowFlags(uint32_t flags) { - TLOGI(WmsLogTag::WMS_UIEXT, "SetExtWindowFlags extensionWindowFlags_:%{public}u, flags:%{public}u", + TLOGD(WmsLogTag::WMS_UIEXT, "extensionWindowFlags_:%{public}u, flags:%{public}u", extensionWindowFlags_, flags); if (IsWindowSessionInvalid()) { TLOGI(WmsLogTag::WMS_UIEXT, "session is invalid"); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 93fd6551f..05e0a8f44 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2313,7 +2313,7 @@ bool WindowSessionImpl::IsKeyboardEvent(const std::shared_ptr& ke bool isKeyFN = (keyCode == MMI::KeyEvent::KEYCODE_FN); bool isKeyBack = (keyCode == MMI::KeyEvent::KEYCODE_BACK); bool isKeyboard = (keyCode >= MMI::KeyEvent::KEYCODE_0 && keyCode <= MMI::KeyEvent::KEYCODE_NUMPAD_RIGHT_PAREN); - WLOGI("isKeyFN: %{public}d, isKeyboard: %{public}d", isKeyFN, isKeyboard); + WLOGD("isKeyFN: %{public}d, isKeyboard: %{public}d", isKeyFN, isKeyboard); return (isKeyFN || isKeyboard || isKeyBack); } -- Gitee From b64b2b5b66c3df0529215271fa7477d097256e6e Mon Sep 17 00:00:00 2001 From: lijie176 Date: Wed, 27 Mar 2024 16:31:36 +0800 Subject: [PATCH 228/385] =?UTF-8?q?=E5=A2=9E=E5=8A=A0TDD=E5=92=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijie176 --- .../container/include/window_event_channel.h | 12 ++ .../container/src/window_event_channel.cpp | 63 +++---- .../src/zidl/window_event_channel_stub.cpp | 13 +- .../session/host/include/extension_session.h | 17 +- .../session/host/src/extension_session.cpp | 111 ++++++------- .../test/mock/mock_window_event_channel.h | 2 + .../test/unittest/extension_session_test.cpp | 154 ++++++++++++++++++ .../window_event_channel_proxy_test.cpp | 16 ++ .../window_event_channel_stub_test.cpp | 15 ++ .../unittest/window_event_channel_test.cpp | 51 ++++++ 10 files changed, 350 insertions(+), 104 deletions(-) diff --git a/window_scene/session/container/include/window_event_channel.h b/window_scene/session/container/include/window_event_channel.h index 7e817be3a..13317b31b 100644 --- a/window_scene/session/container/include/window_event_channel.h +++ b/window_scene/session/container/include/window_event_channel.h @@ -20,6 +20,7 @@ #include #include +#include "iremote_proxy.h" #include "accessibility_element_info.h" #include "interfaces/include/ws_common.h" @@ -27,6 +28,17 @@ #include "session/container/include/zidl/window_event_channel_stub.h" namespace OHOS::Rosen { +class WindowEventChannelListenerProxy : public IRemoteProxy { +public: + explicit WindowEventChannelListenerProxy(const sptr& impl) + : IRemoteProxy(impl) {} + virtual ~WindowEventChannelListenerProxy() = default; + + void OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) override; +private: + static inline BrokerDelegator delegator_; +}; + class WindowEventChannel : public WindowEventChannelStub { public: explicit WindowEventChannel(sptr iSessionStage) : sessionStage_(iSessionStage) diff --git a/window_scene/session/container/src/window_event_channel.cpp b/window_scene/session/container/src/window_event_channel.cpp index beadb8d03..243568071 100644 --- a/window_scene/session/container/src/window_event_channel.cpp +++ b/window_scene/session/container/src/window_event_channel.cpp @@ -22,7 +22,6 @@ #include #include -#include "iremote_proxy.h" #include "anr_handler.h" #include "window_manager_hilog.h" @@ -31,42 +30,33 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowEventChannel" }; } -class WindowEventChannelListenerProxy : public IRemoteProxy { -public: - explicit WindowEventChannelListenerProxy(const sptr& impl) - : IRemoteProxy(impl) {} - virtual ~WindowEventChannelListenerProxy() = default; - - void OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) override - { - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); - if (!data.WriteInterfaceToken(GetDescriptor())) { - TLOGE(WmsLogTag::WMS_EVENT, "WriteInterfaceToken failed"); - return; - } +void WindowEventChannelListenerProxy::OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_EVENT, "WriteInterfaceToken failed"); + return; + } - if (!data.WriteBool(isConsumed)) { - TLOGE(WmsLogTag::WMS_EVENT, "isConsumed write failed."); - return; - } + if (!data.WriteBool(isConsumed)) { + TLOGE(WmsLogTag::WMS_EVENT, "isConsumed write failed."); + return; + } - if (!data.WriteInt32(static_cast(retCode))) { - TLOGE(WmsLogTag::WMS_EVENT, "retCode write failed."); - return; - } + if (!data.WriteInt32(static_cast(retCode))) { + TLOGE(WmsLogTag::WMS_EVENT, "retCode write failed."); + return; + } - if (Remote()->SendRequest(static_cast( - WindowEventChannelListenerMessage::TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC), - data, reply, option) != ERR_NONE) { - TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed"); - return; - } + if (Remote()->SendRequest(static_cast( + WindowEventChannelListenerMessage::TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed"); + return; } -private: - static inline BrokerDelegator delegator_; -}; +} WSError WindowEventChannel::TransferKeyEvent(const std::shared_ptr& keyEvent) { @@ -144,14 +134,15 @@ WSError WindowEventChannel::TransferKeyEventForConsumedAsync( const std::shared_ptr& keyEvent, bool isPreImeEvent, const sptr& listener) { bool isConsumed = false; - auto ret = TransferKeyEventForConsumed(keyEvent, isConsumed); + auto ret = TransferKeyEventForConsumed(keyEvent, isConsumed, isPreImeEvent); auto wecListener = iface_cast(listener); if (wecListener == nullptr) { - TLOGD(WmsLogTag::WMS_EVENT, "listener is null."); + TLOGE(WmsLogTag::WMS_EVENT, "listener is null."); return ret; } - WLOGFD("TransferKeyEventForConsumedAsync finished with isConsumed:%{public}d ret:%{public}d", isConsumed, ret); + TLOGD(WmsLogTag::WMS_EVENT, "TransferKeyEventForConsumedAsync finished with isConsumed:%{public}d ret:%{public}d", + isConsumed, ret); wecListener->OnTransferKeyEventForConsumed(isConsumed, ret); return ret; } diff --git a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp index 037f016c5..59a4c6464 100644 --- a/window_scene/session/container/src/zidl/window_event_channel_stub.cpp +++ b/window_scene/session/container/src/zidl/window_event_channel_stub.cpp @@ -110,7 +110,6 @@ int WindowEventChannelStub::HandleTransferKeyEvent(MessageParcel& data, MessageP int WindowEventChannelStub::HandleTransferKeyEventAsync(MessageParcel& data, MessageParcel& reply) { - WLOGFD("TransferKeyEvent!"); auto keyEvent = MMI::KeyEvent::Create(); if (keyEvent == nullptr) { TLOGE(WmsLogTag::WMS_EVENT, "Failed to create key event!"); @@ -120,10 +119,18 @@ int WindowEventChannelStub::HandleTransferKeyEventAsync(MessageParcel& data, Mes TLOGE(WmsLogTag::WMS_EVENT, "Read Key Event failed"); return ERR_INVALID_DATA; } - bool isPreImeEvent = data.ReadBool(); + bool isPreImeEvent = false; + if (!data.ReadBool(isPreImeEvent)) { + TLOGE(WmsLogTag::WMS_EVENT, "Read Key Event failed"); + return ERR_INVALID_DATA; + } sptr listener = data.ReadRemoteObject(); - WSError errCode = TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, listener); + if (listener == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "ReadRemoteObject failed"); + return ERR_INVALID_DATA; + } + WSError errCode = TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, listener); reply.WriteUint32(static_cast(errCode)); return ERR_NONE; } diff --git a/window_scene/session/host/include/extension_session.h b/window_scene/session/host/include/extension_session.h index e6869fdab..838551afd 100644 --- a/window_scene/session/host/include/extension_session.h +++ b/window_scene/session/host/include/extension_session.h @@ -15,12 +15,28 @@ #ifndef OHOS_ROSEN_WINDOW_SCENE_EXTENSION_SESSION_H #define OHOS_ROSEN_WINDOW_SCENE_EXTENSION_SESSION_H +#include +#include "key_event.h" #include "want.h" #include "session/host/include/session.h" namespace OHOS::Rosen { +class WindowEventChannelListener : public IRemoteStub { +public: + explicit WindowEventChannelListener() = default; + void SetTransferKeyEventForConsumedParams(std::shared_ptr>& isConsumedPromise, + std::shared_ptr& retCode); + void ResetTransferKeyEventForConsumedParams(); + void OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) override; + int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; +private: + std::mutex transferKeyEventForConsumedMutex_; + std::shared_ptr> isConsumedPromise_; + std::shared_ptr retCode_; +}; + using NotifyTransferAbilityResultFunc = std::function; using NotifyTransferExtensionDataFunc = std::function; using NotifyRemoteReadyFunc = std::function; @@ -62,7 +78,6 @@ public: void NotifyAsyncOn() override; void TriggerBindModalUIExtension() override; void RegisterExtensionSessionEventCallback(const sptr& extSessionEventCallback); - WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed); WSError TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, bool& isTimeOut, bool isPreImeEvent = false); sptr GetExtensionSessionEventCallback(); diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index 2c3801075..9162dd24c 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -13,9 +13,6 @@ * limitations under the License. */ -#include - -#include "key_event.h" #include "session/host/include/extension_session.h" #include "ipc_skeleton.h" @@ -28,63 +25,54 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "ExtensionSession" }; } // namespace -class WindowEventChannelListener : public IRemoteStub { -public: - explicit WindowEventChannelListener() = default; +void WindowEventChannelListener::SetTransferKeyEventForConsumedParams( + std::shared_ptr>& isConsumedPromise, std::shared_ptr& retCode) +{ + std::lock_guard lock(transferKeyEventForConsumedMutex_); + isConsumedPromise_ = isConsumedPromise; + retCode_ = retCode; +} - void SetTransferKeyEventForConsumedParams(std::shared_ptr>& isConsumedPromise, - std::shared_ptr& retCode) - { - std::lock_guard lock(transferKeyEventForConsumedMutex_); - isConsumedPromise_ = isConsumedPromise; - retCode_ = retCode; - } +void WindowEventChannelListener::ResetTransferKeyEventForConsumedParams() +{ + std::lock_guard lock(transferKeyEventForConsumedMutex_); + isConsumedPromise_ = nullptr; + retCode_ = nullptr; +} - void ReSetTransferKeyEventForConsumedParams() - { - std::lock_guard lock(transferKeyEventForConsumedMutex_); - isConsumedPromise_ = nullptr; - retCode_ = nullptr; +void WindowEventChannelListener::OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) +{ + std::lock_guard lock(transferKeyEventForConsumedMutex_); + if (isConsumedPromise_ == nullptr || retCode_ == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "Promise or ret is null in WindowEventChannelListener."); + return; } + isConsumedPromise_->set_value(isConsumed); + *retCode_ = retCode; +} - void OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) override - { - std::lock_guard lock(transferKeyEventForConsumedMutex_); - if (isConsumedPromise_ == nullptr || retCode_ == nullptr) { - TLOGE(WmsLogTag::WMS_EVENT, "Promise or ret is null in WindowEventChannelListener."); - return; - } - isConsumedPromise_->set_value(isConsumed); - *retCode_ = retCode; +int32_t WindowEventChannelListener::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, + MessageOption &option) +{ + if (data.ReadInterfaceToken() != GetDescriptor()) { + TLOGE(WmsLogTag::WMS_EVENT, "InterfaceToken check failed"); + return -1; } - int32_t OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override - { - if (data.ReadInterfaceToken() != GetDescriptor()) { - TLOGE(WmsLogTag::WMS_EVENT, "InterfaceToken check failed"); - return -1; + auto msgId = static_cast(code); + switch (msgId) { + case WindowEventChannelListenerMessage::TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC: { + bool isConsumed = data.ReadBool(); + WSError retCode = static_cast(data.ReadInt32()); + OnTransferKeyEventForConsumed(isConsumed, retCode); + break; } - - auto msgId = static_cast(code); - switch (msgId) { - case WindowEventChannelListenerMessage::TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC: { - bool isConsumed = data.ReadBool(); - WSError retCode = static_cast(data.ReadInt32()); - OnTransferKeyEventForConsumed(isConsumed, retCode); - break; - } - default: - TLOGE(WmsLogTag::WMS_EVENT, "unknown transaction code %{public}d", code); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - return 0; + default: + TLOGE(WmsLogTag::WMS_EVENT, "unknown transaction code %{public}d", code); + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } -private: - std::mutex transferKeyEventForConsumedMutex_; - std::shared_ptr> isConsumedPromise_; - std::shared_ptr retCode_; -}; + return 0; +} ExtensionSession::ExtensionSession(const SessionInfo& info) : Session(info) { @@ -189,17 +177,9 @@ void ExtensionSession::RegisterExtensionSessionEventCallback( extSessionEventCallback_ = extSessionEventCallback; } -WSError ExtensionSession::TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed) -{ - bool isTimeout = false; - bool isPreImeEvent = false; - return TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); -} - WSError ExtensionSession::TransferKeyEventForConsumed(const std::shared_ptr& keyEvent, bool& isConsumed, bool& isTimeout, bool isPreImeEvent) { - TLOGD(WmsLogTag::WMS_EVENT, "TransferKeyEventForConsumed in , id:%{public}d", keyEvent->GetId()); if (!windowEventChannel_) { TLOGE(WmsLogTag::WMS_EVENT, "windowEventChannel_ is null"); return WSError::WS_ERROR_NULLPTR; @@ -208,15 +188,18 @@ WSError ExtensionSession::TransferKeyEventForConsumed(const std::shared_ptrGetId()); sptr listener = new WindowEventChannelListener(); - if (listener == nullptr) { + auto isConsumedPromise = std::make_shared>(); + std::shared_ptr retCode = std::make_shared(WSError::WS_OK); + bool isAllocedNullptr = (listener == nullptr) || (isConsumedPromise == nullptr) || (retCode == nullptr); + if (isAllocedNullptr) { TLOGE(WmsLogTag::WMS_EVENT, "Created WindowEventChannelListener is nullptr."); return WSError::WS_ERROR_NULLPTR; } - auto isConsumedPromise = std::make_shared>(); - std::shared_ptr retCode = std::make_shared(WSError::WS_OK); listener->SetTransferKeyEventForConsumedParams(isConsumedPromise, retCode); auto ret = windowEventChannel_->TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, listener); @@ -225,7 +208,7 @@ WSError ExtensionSession::TransferKeyEventForConsumed(const std::shared_ptrReSetTransferKeyEventForConsumedParams(); + listener->ResetTransferKeyEventForConsumedParams(); isTimeout = true; keyEvent->MarkProcessed(); } else { diff --git a/window_scene/test/mock/mock_window_event_channel.h b/window_scene/test/mock/mock_window_event_channel.h index b14b2ea96..3e88a0996 100644 --- a/window_scene/test/mock/mock_window_event_channel.h +++ b/window_scene/test/mock/mock_window_event_channel.h @@ -26,6 +26,8 @@ public: ~WindowEventChannelMocker() {}; MOCK_METHOD1(TransferKeyEvent, WSError(const std::shared_ptr& keyEvent)); MOCK_METHOD1(TransferPointerEvent, WSError(const std::shared_ptr& pointerEvent)); + MOCK_METHOD3(TransferKeyEventForConsumedAsync, WSError(const std::shared_ptr& keyEvent, + bool isPreImeEvent, const sptr& listener)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/extension_session_test.cpp b/window_scene/test/unittest/extension_session_test.cpp index 5c11efc69..946c3518e 100644 --- a/window_scene/test/unittest/extension_session_test.cpp +++ b/window_scene/test/unittest/extension_session_test.cpp @@ -18,6 +18,9 @@ #include "accessibility_event_info.h" #include "session_info.h" #include "interfaces/include/ws_common.h" +#include "key_event.h" +#include "mock/mock_session_stage.h" +#include "mock/mock_window_event_channel.h" using namespace testing; using namespace testing::ext; @@ -248,6 +251,157 @@ HWTEST_F(ExtensionSessionTest, TransferAccessibilityEvent, Function | SmallTest ASSERT_EQ(result, WSError::WS_OK); } +/** + * @tc.name: TransferKeyEventForConsumed01 + * @tc.desc: TransferKeyEventForConsumed not timeout + * @tc.type: FUNC + */ +HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed01, Function | SmallTest | Level1) +{ + SessionInfo info; + info.abilityName_ = "SetBrightness"; + info.bundleName_ = "SetBrightness1"; + ExtensionSession extensionSession_(info); + ASSERT_NE(extensionSession_, nullptr); + + sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); + sptr mockEventChannel = new (std::nothrow) WindowEventChannelMocker(mockSessionStage); + extensionSession_.windowEventChannel_ = mockEventChannel; + EXPECT_CALL(*mockEventChannel, TransferKeyEventForConsumedAsync) + .WillOnce([](const std::shared_ptr &keyEvent, + bool isPreImeEvent, + const sptr &listener) { + auto wecListener = iface_cast(listener); + wecListener->OnTransferKeyEventForConsumed(true, WSError::WS_OK); + return WSError::WS_OK; + }); + + auto keyEvent = MMI::KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + bool isConsumed = false; + bool isTimeout = false; + bool isPreImeEvent = false; + + WSError result = extensionSession_.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); + ASSERT_EQ(result, WSError::WS_OK); + ASSERT_EQ(isTimeout, false); +} + +/** + * @tc.name: TransferKeyEventForConsumed02 + * @tc.desc: TransferKeyEventForConsumed timeout + * @tc.type: FUNC + */ +HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed02, Function | SmallTest | Level1) +{ + SessionInfo info; + info.abilityName_ = "SetBrightness"; + info.bundleName_ = "SetBrightness1"; + ExtensionSession extensionSession_(info); + ASSERT_NE(extensionSession_, nullptr); + + sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); + sptr mockEventChannel = new (std::nothrow) WindowEventChannelMocker(mockSessionStage); + extensionSession_.windowEventChannel_ = mockEventChannel; + EXPECT_CALL(*mockEventChannel, TransferKeyEventForConsumedAsync); + + auto keyEvent = MMI::KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + bool isConsumed = false; + bool isTimeout = false; + bool isPreImeEvent = false; + + WSError result = extensionSession_.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); + ASSERT_EQ(result, WSError::WS_OK); + ASSERT_EQ(isTimeout, true); +} + +/** + * @tc.name: TransferKeyEventForConsumed03 + * @tc.desc: TransferKeyEventForConsumed windowEventChannel_ nullptr + * @tc.type: FUNC + */ +HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed03, Function | SmallTest | Level1) +{ + SessionInfo info; + info.abilityName_ = "SetBrightness"; + info.bundleName_ = "SetBrightness1"; + ExtensionSession extensionSession_(info); + ASSERT_NE(extensionSession_, nullptr); + + auto keyEvent = MMI::KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + bool isConsumed = false; + bool isTimeout = false; + bool isPreImeEvent = false; + + WSError result = extensionSession_.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); + ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); +} + +/** + * @tc.name: TransferKeyEventForConsumed04 + * @tc.desc: TransferKeyEventForConsumed keyEvent nullptr + * @tc.type: FUNC + */ +HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed04, Function | SmallTest | Level1) +{ + SessionInfo info; + info.abilityName_ = "SetBrightness"; + info.bundleName_ = "SetBrightness1"; + ExtensionSession extensionSession_(info); + ASSERT_NE(extensionSession_, nullptr); + + sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); + sptr mockEventChannel = new (std::nothrow) WindowEventChannelMocker(mockSessionStage); + extensionSession_.windowEventChannel_ = mockEventChannel; + + auto keyEvent = nullptr; + bool isConsumed = false; + bool isTimeout = false; + bool isPreImeEvent = false; + + WSError result = extensionSession_.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); + ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); +} + +/** + * @tc.name: WindowEventChannelListenerOnRemoteRequest01 + * @tc.desc: WindowEventChannelListenerOnRemoteRequest01 test + * @tc.type: FUNC + */ +HWTEST_F(ExtensionSessionTest, WindowEventChannelListenerOnRemoteRequest01, Function | SmallTest | Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(WindowEventChannelListener::GetDescriptor()); + data.WriteBool(true); + data.WriteInt32(0); + uint32_t code = static_cast(IWindowEventChannelListener::WindowEventChannelListenerMessage:: + TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC); + WindowEventChannelListener listener; + ASSERT_EQ(listener.OnRemoteRequest(code, data, reply, option), 0); +} + +/** + * @tc.name: WindowEventChannelListenerOnRemoteRequest02 + * @tc.desc: WindowEventChannelListenerOnRemoteRequest02 test + * @tc.type: FUNC + */ +HWTEST_F(ExtensionSessionTest, WindowEventChannelListenerOnRemoteRequest02, Function | SmallTest | Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(WindowEventChannelListener::GetDescriptor()); + data.WriteBool(true); + data.WriteInt32(0); + uint32_t code = static_cast(10001); + WindowEventChannelListener listener; + ASSERT_EQ(listener.OnRemoteRequest(code, data, reply, option), IPC_STUB_UNKNOW_TRANS_ERR); +} + /** * @tc.name: UpdateAvoidArea * @tc.desc: test function : UpdateAvoidArea diff --git a/window_scene/test/unittest/window_event_channel_proxy_test.cpp b/window_scene/test/unittest/window_event_channel_proxy_test.cpp index d446ff6a3..8d8d38684 100644 --- a/window_scene/test/unittest/window_event_channel_proxy_test.cpp +++ b/window_scene/test/unittest/window_event_channel_proxy_test.cpp @@ -110,6 +110,22 @@ HWTEST_F(WindowEventChannelProxyTest, TransferKeyEventForConsumed, Function | Sm ASSERT_EQ(WSError::WS_OK, res); } +/** + * @tc.name: TransferKeyEventForConsumedAsync + * @tc.desc: test function : TransferKeyEventForConsumedAsync + * @tc.type: FUNC + */ +HWTEST_F(WindowEventChannelProxyTest, TransferKeyEventForConsumedAsync, Function | SmallTest | Level1) +{ + auto keyEvent = MMI::KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + bool isPreImeEvent = false; + sptr iRemoteObjectMocker = new (std::nothrow) IRemoteObjectMocker(); + WSError res = windowEventChannelProxy_->TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, + iRemoteObjectMocker); + ASSERT_EQ(WSError::WS_OK, res); +} + /** * @tc.name: TransferFocusActiveEvent * @tc.desc: test function : TransferFocusActiveEvent diff --git a/window_scene/test/unittest/window_event_channel_stub_test.cpp b/window_scene/test/unittest/window_event_channel_stub_test.cpp index ef6eb4280..1d7ad7b91 100644 --- a/window_scene/test/unittest/window_event_channel_stub_test.cpp +++ b/window_scene/test/unittest/window_event_channel_stub_test.cpp @@ -122,6 +122,21 @@ HWTEST_F(WindowEventChannelStubTest, HandleTransferKeyEvent02, Function | SmallT ASSERT_EQ(5, windowEventChannelStub_->HandleTransferKeyEvent(data, reply)); } +/** + * @tc.name: HandleTransferKeyEventAsync + * @tc.desc: test function : HandleTransferKeyEventAsync + * @tc.type: FUNC + */ +HWTEST_F(WindowEventChannelStubTest, HandleTransferKeyEventAsync, Function | SmallTest | Level1) +{ + MessageParcel data; + MessageParcel reply; + + data.WriteBool(true); + ASSERT_TRUE((windowEventChannelStub_ != nullptr)); + ASSERT_EQ(5, windowEventChannelStub_->HandleTransferKeyEventAsync(data, reply)); +} + /** * @tc.name: HandleTransferPointerEvent01 * @tc.desc: test function : HandleTransferPointerEvent01 diff --git a/window_scene/test/unittest/window_event_channel_test.cpp b/window_scene/test/unittest/window_event_channel_test.cpp index f06a02d50..becb77fe9 100644 --- a/window_scene/test/unittest/window_event_channel_test.cpp +++ b/window_scene/test/unittest/window_event_channel_test.cpp @@ -21,6 +21,7 @@ #include "mock/mock_window_event_channel.h" #include "session/container/include/window_event_channel.h" #include "window_manager_hilog.h" +#include "iremote_object_mocker.h" using namespace testing; using namespace testing::ext; @@ -198,6 +199,56 @@ HWTEST_F(WindowEventChannelTest, TransferKeyEventForConsumed, Function | SmallTe ASSERT_EQ(res, WSError::WS_OK); } +/** + * @tc.name: TransferKeyEventForConsumedAsync01 + * @tc.desc: normal function TransferKeyEventForConsumedAsync01 + * @tc.type: FUNC + */ +HWTEST_F(WindowEventChannelTest, TransferKeyEventForConsumedAsync01, Function | SmallTest | Level2) +{ + auto keyEvent = MMI::KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + bool isPreImeEvent = false; + + sptr sessionStage = new SessionStageMocker(); + sptr windowEventChannel = new WindowEventChannel(sessionStage); + ASSERT_NE(windowEventChannel, nullptr); + auto res = windowEventChannel->TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, nullptr); + ASSERT_EQ(res, WSError::WS_OK); +} + +/** + * @tc.name: TransferKeyEventForConsumedAsync02 + * @tc.desc: normal function TransferKeyEventForConsumedAsync02 + * @tc.type: FUNC + */ +HWTEST_F(WindowEventChannelTest, TransferKeyEventForConsumedAsync02, Function | SmallTest | Level2) +{ + auto keyEvent = MMI::KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + bool isPreImeEvent = false; + + sptr sessionStage = new SessionStageMocker(); + sptr windowEventChannel = new WindowEventChannel(sessionStage); + ASSERT_NE(windowEventChannel, nullptr); + sptr iRemoteObjectMocker = new (std::nothrow) IRemoteObjectMocker(); + auto res = windowEventChannel->TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, iRemoteObjectMocker); + ASSERT_EQ(res, WSError::WS_OK); +} + +/** + * @tc.name: WindowEventChannelListenerProxyOnTransferKeyEventForConsumed + * @tc.desc: normal function WindowEventChannelListenerProxyOnTransferKeyEventForConsumed + * @tc.type: FUNC + */ +HWTEST_F(WindowEventChannelTest, WindowEventChannelListenerProxyOnTransferKeyEventForConsumed, + Function | SmallTest | Level2) +{ + sptr iRemoteObjectMocker = new (std::nothrow) IRemoteObjectMocker(); + WindowEventChannelListenerProxy listenerProxy(iRemoteObjectMocker); + listenerProxy.OnTransferKeyEventForConsumed(true, WSError::WS_OK); +} + /** * @tc.name: TransferFocusActiveEvent * @tc.desc: normal function TransferFocusActiveEvent -- Gitee From 5e02affa63132745160ff5d85d964b3eee9d7414 Mon Sep 17 00:00:00 2001 From: qintongtong Date: Sat, 23 Mar 2024 14:14:00 +0800 Subject: [PATCH 229/385] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E7=AA=97=E5=8F=A3=E5=8F=AF?= =?UTF-8?q?=E8=A7=A6=E6=91=B8=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qintongtong Change-Id: I472ab4fd3809ed15c960f8767ac6dcbe6383acb2 --- .../window_runtime/window_napi/js_window.cpp | 50 +++++++++++ .../window_runtime/window_napi/js_window.h | 2 + .../window_napi/js_window_utils.cpp | 87 +++++++++++++++++++ .../window_napi/js_window_utils.h | 3 + 4 files changed, 142 insertions(+) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index dcc8d855f..c6aecaa52 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -470,6 +470,13 @@ napi_value JsWindow::SetTouchable(napi_env env, napi_callback_info info) return (me != nullptr) ? me->OnSetTouchable(env, info) : nullptr; } +napi_value JsWindow::SetTouchableAreas(napi_env env, napi_callback_info info) +{ + TLOGI(WmsLogTag::WMS_EVENT, "SetTouchableAreas"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetTouchableAreas(env, info) : nullptr; +} + napi_value JsWindow::SetResizeByDragEnabled(napi_env env, napi_callback_info info) { WLOGI("SetResizeByDragEnabled"); @@ -3237,6 +3244,48 @@ napi_value JsWindow::OnSetTouchable(napi_env env, napi_callback_info info) return result; } +napi_value JsWindow::OnSetTouchableAreas(napi_env env, napi_callback_info info) +{ + if (!Permission::IsSystemCalling()) { + TLOGE(WmsLogTag::WMS_EVENT, "OnSetTouchableAreas permission denied!"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP); + } + if (windowToken_ == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "WindowToken_ is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + Rect windowRect = windowToken_->GetRect(); + std::vector touchableAreas; + WmErrorCode errCode = ParseTouchableAreas(env, info, windowRect, touchableAreas); + if (errCode != WmErrorCode::WM_OK) { + return NapiThrowError(env, errCode); + } + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = + [weakToken, touchableAreas](napi_env env, NapiAsyncTask& task, int32_t status) { + auto weakWindow = weakToken.promote(); + if (weakWindow == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "CompleteCallback window is nullptr"); + task.Reject(env, CreateJsError(env, + static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); + return; + } + WMError ret = weakWindow->SetTouchHotAreas(touchableAreas); + if (ret == WMError::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + WmErrorCode wmErrorCode = WM_JS_TO_ERROR_CODE_MAP.at(ret); + task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "OnSetTouchableAreas failed")); + } + TLOGI(WmsLogTag::WMS_EVENT, "Window [%{public}u, %{public}s] setTouchableAreas end", + weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); + }; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnSetTouchableAreas", + env, CreateAsyncTaskWithLastParam(env, nullptr, nullptr, std::move(complete), &result)); + return result; +} + napi_value JsWindow::OnSetResizeByDragEnabled(napi_env env, napi_callback_info info) { WMError errCode = WMError::WM_OK; @@ -5199,6 +5248,7 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setPrivacyMode", moduleName, JsWindow::SetPrivacyMode); BindNativeFunction(env, object, "setWindowPrivacyMode", moduleName, JsWindow::SetWindowPrivacyMode); BindNativeFunction(env, object, "setTouchable", moduleName, JsWindow::SetTouchable); + BindNativeFunction(env, object, "setTouchableAreas", moduleName, JsWindow::SetTouchableAreas); BindNativeFunction(env, object, "setWindowTouchable", moduleName, JsWindow::SetWindowTouchable); BindNativeFunction(env, object, "setTransparent", moduleName, JsWindow::SetTransparent); BindNativeFunction(env, object, "setCallingWindow", moduleName, JsWindow::SetCallingWindow); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 536868632..ec95bf3e8 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -92,6 +92,7 @@ public: static napi_value SetPrivacyMode(napi_env env, napi_callback_info info); static napi_value SetWindowPrivacyMode(napi_env env, napi_callback_info info); static napi_value SetTouchable(napi_env env, napi_callback_info info); + static napi_value SetTouchableAreas(napi_env env, napi_callback_info info); static napi_value SetResizeByDragEnabled(napi_env env, napi_callback_info info); static napi_value SetRaiseByClickEnabled(napi_env env, napi_callback_info info); static napi_value HideNonSystemFloatingWindows(napi_env env, napi_callback_info info); @@ -222,6 +223,7 @@ private: napi_value OnSetPrivacyMode(napi_env env, napi_callback_info info); napi_value OnSetWindowPrivacyMode(napi_env env, napi_callback_info info); napi_value OnSetTouchable(napi_env env, napi_callback_info info); + napi_value OnSetTouchableAreas(napi_env env, napi_callback_info info); napi_value OnSetResizeByDragEnabled(napi_env env, napi_callback_info info); napi_value OnSetRaiseByClickEnabled(napi_env env, napi_callback_info info); napi_value OnHideNonSystemFloatingWindows(napi_env env, napi_callback_info info); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 5d3a3dbfa..af8ee1bfc 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -27,6 +27,7 @@ namespace Rosen { using namespace AbilityRuntime; namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsUtils"}; + constexpr int32_t MAX_TOUCHABLE_AREAS = 10; } napi_value WindowTypeInit(napi_env env) @@ -623,6 +624,92 @@ bool GetSystemBarStatus(std::map& systemBarProper return true; } +bool ParseAndCheckRect(napi_env env, napi_value jsObject, + const Rect& windowRect, Rect& touchableRect) +{ + int32_t data = 0; + if (ParseJsValue(jsObject, env, "left", data)) { + touchableRect.posX_ = data; + } else { + TLOGE(WmsLogTag::WMS_EVENT, "Failed to convert object:legt"); + return false; + } + if (ParseJsValue(jsObject, env, "top", data)) { + touchableRect.posY_ = data; + } else { + TLOGE(WmsLogTag::WMS_EVENT, "Failed to convert object:top"); + return false; + } + uint32_t udata = 0; + if (ParseJsValue(jsObject, env, "width", udata)) { + touchableRect.width_ = udata; + } else { + TLOGE(WmsLogTag::WMS_EVENT, "Failed to convert object:width"); + return false; + } + if (ParseJsValue(jsObject, env, "height", udata)) { + touchableRect.height_ = udata; + } else { + TLOGE(WmsLogTag::WMS_EVENT, "Failed to convert object:height"); + return false; + } + if ((touchableRect.posX_ < 0) || (touchableRect.posY_ < 0) || + (touchableRect.posX_ > static_cast(windowRect.width_)) || + (touchableRect.posY_ > static_cast(windowRect.height_)) || + (touchableRect.width_ > (windowRect.width_ - static_cast(touchableRect.posX_))) || + (touchableRect.height_ > (windowRect.height_ - static_cast(touchableRect.posY_)))) { + TLOGE(WmsLogTag::WMS_EVENT, "Outside the window area"); + return false; + } + return true; +} + +WmErrorCode ParseTouchableAreas(napi_env env, napi_callback_info info, + const Rect& windowRect, std::vector& touchableAreas) +{ + WmErrorCode errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc != 1) { + TLOGE(WmsLogTag::WMS_EVENT, "Argc is invalid:%{public}zu", argc); + return errCode; + } + if (GetType(env, argv[0]) != napi_object) { + TLOGE(WmsLogTag::WMS_EVENT, "GetType error"); + return errCode; + } + napi_value nativeArray = argv[0]; + if (nativeArray == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "Failed to convert parameter"); + return errCode; + } + uint32_t size = 0; + napi_get_array_length(env, nativeArray, &size); + if (size > MAX_TOUCHABLE_AREAS) { + TLOGE(WmsLogTag::WMS_EVENT, "Exceeded maximum limit"); + return errCode; + } + errCode = WmErrorCode::WM_OK; + for (uint32_t i = 0; i < size; i++) { + napi_value getElementValue = nullptr; + napi_get_element(env, nativeArray, i, &getElementValue); + if (getElementValue == nullptr) { + TLOGE(WmsLogTag::WMS_EVENT, "Failed to get element"); + errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; + break; + } + Rect touchableArea; + if (ParseAndCheckRect(env, getElementValue, windowRect, touchableArea)) { + touchableAreas.emplace_back(touchableArea); + } else { + errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; + break; + } + } + return errCode; +} + bool GetSpecificBarStatus(std::map& systemBarProperties, napi_env env, napi_callback_info info, sptr& window) { diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 5f683bbb5..5b494faef 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -198,6 +198,9 @@ struct SystemBarPropertyFlag { bool GetSystemBarStatus(std::map& systemBarProperties, std::map& systemBarpropertyFlags, napi_env env, napi_callback_info info, sptr& window); + bool ParseAndCheckRect(napi_env env, napi_value jsObject, const Rect& windowRect, Rect& touchableRect); + WmErrorCode ParseTouchableAreas(napi_env env, napi_callback_info info, const Rect& windowRect, + std::vector& touchableAreas); bool GetSpecificBarStatus(std::map& systemBarProperties, napi_env env, napi_callback_info info, sptr& window); napi_value CreateJsSystemBarRegionTintArrayObject(napi_env env, -- Gitee From 3e40ab6fd67fec602aee2cef01cd4de735be7fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=B0=94=E9=BE=99?= Date: Wed, 27 Mar 2024 11:12:39 +0000 Subject: [PATCH 230/385] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=81=BF=E8=AE=A9?= =?UTF-8?q?=E5=8C=BAdisplayId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 神气龙 --- .../session/host/src/scene_session.cpp | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index f9ce176a7..461d4e586 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -784,8 +784,11 @@ void SceneSession::GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea) avoidArea.topRect_.width_ = display->GetWidth(); return; } - std::vector> statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( - WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); + std::vector> statusBarVector; + if (specificCallback_ != nullptr && specificCallback_->onGetSceneSessionVectorByType_) { + statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( + WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); + } for (auto& statusBar : statusBarVector) { if (!(statusBar->isVisible_)) { continue; @@ -811,8 +814,11 @@ void SceneSession::GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea) TLOGE(WmsLogTag::WMS_IMMS, "Failed to get session property"); return; } - std::vector> inputMethodVector = specificCallback_->onGetSceneSessionVectorByType_( - WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, GetSessionProperty()->GetDisplayId()); + std::vector> inputMethodVector; + if (specificCallback_ != nullptr && specificCallback_->onGetSceneSessionVectorByType_) { + inputMethodVector = specificCallback_->onGetSceneSessionVectorByType_( + WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, GetSessionProperty()->GetDisplayId()); + } for (auto& inputMethod : inputMethodVector) { if (inputMethod->GetSessionState() != SessionState::STATE_FOREGROUND && inputMethod->GetSessionState() != SessionState::STATE_ACTIVE) { @@ -871,7 +877,10 @@ void SceneSession::GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea) TLOGE(WmsLogTag::WMS_IMMS, "Failed to get session property"); return; } - WSRect barArea = specificCallback_->onGetAINavigationBarArea_(GetSessionProperty()->GetDisplayId()); + WSRect barArea; + if (specificCallback_ != nullptr && specificCallback_->onGetAINavigationBarArea_) { + barArea = specificCallback_->onGetAINavigationBarArea_(GetSessionProperty()->GetDisplayId()); + } CalculateAvoidAreaRect(rect, barArea, avoidArea); } @@ -1376,8 +1385,11 @@ void SceneSession::UpdateWinRectForSystemBar(WSRect& rect) return; } float tmpPosY = 0.0; - std::vector> statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( - WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); + std::vector> statusBarVector; + if (specificCallback_->onGetSceneSessionVectorByType_) { + statusBarVector = specificCallback_->onGetSceneSessionVectorByType_( + WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); + } for (auto& statusBar : statusBarVector) { if (!(statusBar->isVisible_)) { continue; -- Gitee From 68fc572bee511a4e911991f7b04b759c969e586a Mon Sep 17 00:00:00 2001 From: dengbing Date: Wed, 27 Mar 2024 14:36:59 +0000 Subject: [PATCH 231/385] =?UTF-8?q?update=20window=5Fscene/session=5Fmanag?= =?UTF-8?q?er/src/scene=5Fsession=5Fmanager.cpp.=20=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E4=BF=AE=E6=94=B9parentId=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dengbing --- 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 b16e03dd1..279f5e91a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -887,7 +887,6 @@ WSError SceneSessionManager::UpdateParentSessionForDialog(const sptrGetParentPersistentId(); - sceneSession->SetParentPersistentId(parentPersistentId); if (property->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG && parentPersistentId != INVALID_SESSION_ID) { auto parentSession = GetSceneSession(parentPersistentId); if (parentSession == nullptr) { @@ -5144,6 +5143,7 @@ WSError SceneSessionManager::BindDialogSessionTarget(uint64_t persistentId, sptr return WSError::WS_ERROR_INVALID_PARAM; } scnSession->SetParentSession(parentSession); + scnSession->SetParentPersistenId(parentSession->GetPersistentId()); UpdateParentSessionForDialog(scnSession, scnSession->GetSessionProperty()); TLOGI(WmsLogTag::WMS_DIALOG, "Bind dialog success, dialog id %{public}" PRIu64 ", parentId %{public}d", persistentId, parentSession->GetPersistentId()); -- Gitee From 7431e0eff0504e870b914482b09c61ba2233b45b Mon Sep 17 00:00:00 2001 From: dengbing Date: Wed, 27 Mar 2024 14:49:09 +0000 Subject: [PATCH 232/385] =?UTF-8?q?update=20window=5Fscene/session=5Fmanag?= =?UTF-8?q?er/src/scene=5Fsession=5Fmanager.cpp.=20=E5=9B=9E=E9=80=805401,?= =?UTF-8?q?=E4=BF=AE=E6=94=B9parentId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dengbing --- 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 279f5e91a..e80638ce5 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -5143,7 +5143,7 @@ WSError SceneSessionManager::BindDialogSessionTarget(uint64_t persistentId, sptr return WSError::WS_ERROR_INVALID_PARAM; } scnSession->SetParentSession(parentSession); - scnSession->SetParentPersistenId(parentSession->GetPersistentId()); + scnSession->SetParentPersistentId(parentSession->GetPersistentId()); UpdateParentSessionForDialog(scnSession, scnSession->GetSessionProperty()); TLOGI(WmsLogTag::WMS_DIALOG, "Bind dialog success, dialog id %{public}" PRIu64 ", parentId %{public}d", persistentId, parentSession->GetPersistentId()); -- Gitee From 280eef53d79451ffdcd28992c4d5b4502ca6fd10 Mon Sep 17 00:00:00 2001 From: meikun4 Date: Wed, 27 Mar 2024 16:11:05 +0800 Subject: [PATCH 233/385] windowRectChange api Signed-off-by: meikun4 --- interfaces/innerkits/wm/window.h | 38 +++++++++++++++++ .../window_napi/js_window_listener.cpp | 41 ++++++++++++++++++ .../window_napi/js_window_listener.h | 6 ++- .../js_window_register_manager.cpp | 17 ++++++++ .../window_napi/js_window_register_manager.h | 2 + .../window_napi/js_window_utils.h | 30 +++++++++++++ .../session/host/include/scene_session.h | 1 + window_scene/session/host/include/session.h | 1 + .../host/include/zidl/session_interface.h | 4 ++ .../include/zidl/session_ipc_interface_code.h | 1 + .../session/host/include/zidl/session_proxy.h | 2 + .../session/host/include/zidl/session_stub.h | 1 + .../session/host/src/scene_session.cpp | 29 ++++++++++--- .../session/host/src/zidl/session_proxy.cpp | 23 ++++++++++ .../session/host/src/zidl/session_stub.cpp | 10 +++++ .../test/unittest/session_stub_test.cpp | 16 +++++++ wm/include/window_session_impl.h | 7 ++++ wm/src/window_session_impl.cpp | 42 +++++++++++++++++++ wm/test/unittest/window_session_impl_test.cpp | 6 +++ wm/test/unittest/window_test.cpp | 30 +++++++++++++ 20 files changed, 301 insertions(+), 6 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index f3641a560..de82563a5 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -428,6 +428,22 @@ public: virtual void OnWindowTitleButtonRectChanged(const TitleButtonRect& titleButtonRect) {} }; +/** + * @class IWindowRectChangeListener + * + * @brief IWindowRectChangeListener is used to observe the window rect and its changing reason when window changed. + */ +class IWindowRectChangeListener : virtual public RefBase { +public: + /** + * @brief Notify caller when window rect changed. + * + * @param Rect Rect of the current window. + * @param reason Reason for window size change. + */ + virtual void OnRectChange(Rect rect, WindowSizeChangeReason reason) {} +}; + static WMError DefaultCreateErrCode = WMError::WM_OK; class Window : virtual public RefBase { public: @@ -1774,6 +1790,28 @@ public: { return WMError::WM_OK; } + + /** + * @brief Register window rect change listener. + * + * @param listener IWindowRectChangeListener. + * @return WM_OK means register success, others means register failed. + */ + virtual WMError RegisterWindowRectChangeListener(const sptr& listener) + { + return WMError::WM_OK; + } + + /** + * @brief Unregister window rect change listener. + * + * @param listener IWindowRectChangeListener. + * @return WM_OK means unregister success, others means unregister failed. + */ + virtual WMError UnregisterWindowRectChangeListener(const sptr& listener) + { + return WMError::WM_OK; + } }; } } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index d75f85917..8653e1eff 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -502,5 +502,46 @@ void JsWindowListener::OnWindowTitleButtonRectChanged(const TitleButtonRect& tit NapiAsyncTask::Schedule("JsWindowListener::OnWindowTitleButtonRectChanged", env_, std::make_unique(callback, std::move(execute), std::move(complete))); } + +void JsWindowListener::OnRectChange(Rect rect, WindowSizeChangeReason reason) +{ + RectChangeReason rectChangReason = JS_SIZE_CHANGE_REASON.at(reason); + // js callback should run in js thread + auto jsCallback = [self = weakRef_, rect, rectChangReason, env = env_] () { + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsWindowListener::OnRectChange"); + auto thisListener = self.promote(); + if (thisListener == nullptr || env == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "this listener or env is nullptr"); + return; + } + napi_handle_scope scope = nullptr; + napi_open_handle_scope(env, &scope); + napi_value objValue = nullptr; + napi_create_object(env, &objValue); + if (objValue == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to create js object"); + return; + } + napi_value rectObjValue = GetRectAndConvertToJsValue(env, rect); + if (rectObjValue == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to create rect js object"); + return; + } + napi_set_named_property(env, objValue, "rect", rectObjValue); + napi_set_named_property(env, objValue, "reason", CreateJsValue(env, rectChangReason)); + napi_value argv[] = {objValue}; + thisListener->CallJsMethod(WINDOW_RECT_CHANGE_CB.c_str(), argv, ArraySize(argv)); + napi_close_handle_scope(env, scope); + }; + + if (!eventHandler_) { + TLOGE(WmsLogTag::WMS_LAYOUT, "get main event handler failed!"); + return; + } + eventHandler_->PostTask(jsCallback, "wms:JsWindowRectListener::OnRectChange", 0, + AppExecFwk::EventQueue::Priority::IMMEDIATE); + currentWidth_ = rect.width_; + currentHeight_ = rect.height_; +} } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h index a9020726d..f4d883caf 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h @@ -48,6 +48,7 @@ const std::string WINDOW_STATUS_CHANGE_CB = "windowStatusChange"; const std::string WINDOW_VISIBILITY_CHANGE_CB = "windowVisibilityChange"; const std::string WINDOW_TITLE_BUTTON_RECT_CHANGE_CB = "windowTitleButtonRectChange"; const std::string WINDOW_NO_INTERACTION_DETECT_CB = "noInteractionDetect"; +const std::string WINDOW_RECT_CHANGE_CB = "windowRectChange"; class JsWindowListener : public IWindowChangeListener, public ISystemBarChangedListener, @@ -63,7 +64,8 @@ class JsWindowListener : public IWindowChangeListener, public IWindowVisibilityChangedListener, public IWindowTitleButtonRectChangedListener, public IWindowStatusChangeListener, - public IWindowNoInteractionListener { + public IWindowNoInteractionListener, + public IWindowRectChangeListener { public: JsWindowListener(napi_env env, std::shared_ptr callback) : env_(env), jsCallBack_(callback), weakRef_(wptr (this)) {} @@ -96,6 +98,8 @@ public: void OnWindowTitleButtonRectChanged(const TitleButtonRect& titleButtonRect) override; void SetTimeout(int64_t timeout) override; int64_t GetTimeout() const override; + void OnRectChange(Rect rect, WindowSizeChangeReason reason) override; + private: uint32_t currentWidth_ = 0; uint32_t currentHeight_ = 0; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp index 64621334f..e2e290fa1 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.cpp @@ -48,6 +48,7 @@ JsWindowRegisterManager::JsWindowRegisterManager() { WINDOW_TITLE_BUTTON_RECT_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowTitleButtonRectChangeRegister}, { WINDOW_VISIBILITY_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowVisibilityChangeRegister }, { WINDOW_NO_INTERACTION_DETECT_CB, &JsWindowRegisterManager::ProcessWindowNoInteractionRegister }, + { WINDOW_RECT_CHANGE_CB, &JsWindowRegisterManager::ProcessWindowRectChangeRegister }, }; // white register list for window stage listenerProcess_[CaseType::CASE_STAGE] = { @@ -442,5 +443,21 @@ WmErrorCode JsWindowRegisterManager::ProcessWindowStatusChangeRegister(sptr listener, + sptr window, bool isRegister, napi_env env, napi_value parameter) +{ + if (window == nullptr) { + return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + } + sptr thisListener(listener); + WmErrorCode ret = WmErrorCode::WM_OK; + if (isRegister) { + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->RegisterWindowRectChangeListener(thisListener)); + } else { + ret = WM_JS_TO_ERROR_CODE_MAP.at(window->UnregisterWindowRectChangeListener(thisListener)); + } + return ret; +} } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h index 587c30957..39faee588 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_register_manager.h @@ -66,6 +66,8 @@ private: bool isRegister, napi_env env, napi_value parameter = nullptr); WmErrorCode ProcessWindowTitleButtonRectChangeRegister(sptr listener, sptr window, bool isRegister, napi_env env, napi_value parameter = nullptr); + WmErrorCode ProcessWindowRectChangeRegister(sptr listener, sptr window, + bool isRegister, napi_env env, napi_value parameter = nullptr); using Func = WmErrorCode(JsWindowRegisterManager::*)(sptr, sptr window, bool, napi_env env, napi_value parameter); std::map, sptr>> jsCbMap_; diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index 694f00ea0..da9101bc4 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -197,6 +197,36 @@ const std::map NATIVE_TO_JS_ORIENTATION_MAP { {Orientation::LOCKED, ApiOrientation::LOCKED }, }; +enum class RectChangeReason : uint32_t { + UNDEFINED = 0, + MAXIMIZE, + RECOVER, + MOVE, + DRAG, + DRAG_START, + DRAG_END, +}; + +const std::map JS_SIZE_CHANGE_REASON { + { WindowSizeChangeReason::UNDEFINED, RectChangeReason::UNDEFINED }, + { WindowSizeChangeReason::MAXIMIZE, RectChangeReason::MAXIMIZE }, + { WindowSizeChangeReason::RECOVER, RectChangeReason::RECOVER }, + { WindowSizeChangeReason::ROTATION, RectChangeReason::UNDEFINED }, + { WindowSizeChangeReason::DRAG, RectChangeReason::DRAG }, + { WindowSizeChangeReason::DRAG_START, RectChangeReason::DRAG_START }, + { WindowSizeChangeReason::DRAG_END, RectChangeReason::DRAG_END }, + { WindowSizeChangeReason::RESIZE, RectChangeReason::UNDEFINED }, + { WindowSizeChangeReason::MOVE, RectChangeReason::MOVE }, + { WindowSizeChangeReason::HIDE, RectChangeReason::UNDEFINED }, + { WindowSizeChangeReason::TRANSFORM, RectChangeReason::UNDEFINED }, + { WindowSizeChangeReason::CUSTOM_ANIMATION_SHOW, RectChangeReason::UNDEFINED }, + { WindowSizeChangeReason::FULL_TO_SPLIT, RectChangeReason::UNDEFINED }, + { WindowSizeChangeReason::SPLIT_TO_FULL, RectChangeReason::UNDEFINED }, + { WindowSizeChangeReason::FULL_TO_FLOATING, RectChangeReason::UNDEFINED }, + { WindowSizeChangeReason::FLOATING_TO_FULL, RectChangeReason::UNDEFINED }, + { WindowSizeChangeReason::END, RectChangeReason::UNDEFINED }, +}; + struct SystemBarPropertyFlag { bool enableFlag; bool backgroundColorFlag; diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 76c9ae692..60e1ab8b2 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -241,6 +241,7 @@ public: static void ClearEnterWindow(); static MaximizeMode maximizeMode_; static std::map windowDragHotAreaMap_; + WSError UpdateRectChangeListenerRegistered(bool isRegister) override; WSRect callingWindowRestoringRect_ = {0, 0, 0, 0}; WSRect callingWindowNewRect_ = {0, 0, 0, 0}; diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 7a82d4ff8..42de8f666 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -502,6 +502,7 @@ protected: mutable std::mutex pointerEventMutex_; mutable std::shared_mutex keyEventMutex_; + bool rectChangeListenerRegistered_ = false; private: void HandleDialogForeground(); diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index fe0bf0b62..743e9bd3d 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -95,6 +95,10 @@ public: { return WSError::WS_OK; } + virtual WSError UpdateRectChangeListenerRegistered(bool isRegister) + { + return WSError::WS_OK; + } }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/zidl/session_ipc_interface_code.h b/window_scene/session/host/include/zidl/session_ipc_interface_code.h index 147582333..ecf2f16c9 100644 --- a/window_scene/session/host/include/zidl/session_ipc_interface_code.h +++ b/window_scene/session/host/include/zidl/session_ipc_interface_code.h @@ -51,6 +51,7 @@ enum class SessionInterfaceCode { TRANS_ID_PROCESS_POINT_DOWN_SESSION, TRANS_ID_SEND_POINTEREVENT_FOR_MOVE_DRAG, TRANS_ID_SET_LANDSCAPE_MULTI_WINDOW, + TRANS_ID_UPDATE_RECTCHANGE_LISTENER_REGISTERED, // Extension TRANS_ID_TRANSFER_ABILITY_RESULT = 500, diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index 015c7496d..ae77f4ada 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -75,6 +75,8 @@ public: WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) override; WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; WSError SendPointEventForMoveDrag(const std::shared_ptr& pointerEvent) override; + WSError UpdateRectChangeListenerRegistered(bool isRegister) override; + private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 03ad76f4f..8b8e3772a 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -65,6 +65,7 @@ private: int HandleProcessPointDownSession(MessageParcel& data, MessageParcel& reply); int HandleSendPointerEvenForMoveDrag(MessageParcel& data, MessageParcel& reply); int HandleSetLandscapeMultiWindow(MessageParcel& data, MessageParcel& reply); + int HandleUpdateRectChangeListenerRegistered(MessageParcel& data, MessageParcel& reply); // extension extension int HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 620626f9e..81c50298f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -415,7 +415,8 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason, WLOGFE("session is null"); return WSError::WS_ERROR_DESTROYED_OBJECT; } - if (session->winRect_ == rect) { + if (session->winRect_ == rect && session->reason_ != SizeChangeReason::UNDEFINED && + session->reason_ != SizeChangeReason::DRAG_END) { TLOGD(WmsLogTag::WMS_LAYOUT, "skip same rect update id:%{public}d rect:%{public}s!", session->GetPersistentId(), rect.ToString().c_str()); return WSError::WS_OK; @@ -429,7 +430,8 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason, "SceneSession::UpdateRect%d [%d, %d, %u, %u]", session->GetPersistentId(), rect.posX_, rect.posY_, rect.width_, rect.height_); // position change no need to notify client, since frame layout finish will notify - if (NearEqual(rect.width_, session->winRect_.width_) && NearEqual(rect.height_, session->winRect_.height_)) { + if (NearEqual(rect.width_, session->winRect_.width_) && NearEqual(rect.height_, session->winRect_.height_) && + (session->reason_ != SizeChangeReason::MOVE || !session->rectChangeListenerRegistered_)) { TLOGI(WmsLogTag::WMS_LAYOUT, "position change no need notify client id:%{public}d, rect:%{public}s, \ preRect: %{public}s", session->GetPersistentId(), rect.ToString().c_str(), session->winRect_.ToString().c_str()); @@ -482,8 +484,10 @@ WSError SceneSession::NotifyClientToUpdateRect(std::shared_ptr rs } // clear after use if (ret == WSError::WS_OK || session->sessionInfo_.isSystem_) { - session->reason_ = SizeChangeReason::UNDEFINED; - session->isDirty_ = false; + if (session->reason_ != SizeChangeReason::DRAG) { + session->reason_ = SizeChangeReason::UNDEFINED; + session->isDirty_ = false; + } } return ret; }; @@ -1352,8 +1356,8 @@ void SceneSession::OnMoveDragCallback(const SizeChangeReason& reason) HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::OnMoveDragCallback [%d, %d, %u, %u]", rect.posX_, rect.posY_, rect.width_, rect.height_); SetSurfaceBounds(rect); + UpdateSizeChangeReason(reason); if (reason != SizeChangeReason::MOVE) { - UpdateSizeChangeReason(reason); UpdateRect(rect, reason); } if (reason == SizeChangeReason::DRAG_END) { @@ -2454,4 +2458,19 @@ void SceneSession::ClearExtWindowFlags() std::shared_lock lock(extWindowFlagsMapMutex_); extWindowFlagsMap_.clear(); } + +WSError SceneSession::UpdateRectChangeListenerRegistered(bool isRegister) +{ + auto task = [weakThis = wptr(this), isRegister]() { + auto session = weakThis.promote(); + if (!session) { + TLOGE(WmsLogTag::WMS_LAYOUT, "session is null"); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + session->rectChangeListenerRegistered_ = isRegister; + return WSError::WS_OK; + }; + PostTask(task, "UpdateRectChangeListenerRegistered"); + return WSError::WS_OK; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 45414c74a..107c5bf4d 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -1072,4 +1072,27 @@ WSError SessionProxy::SendPointEventForMoveDrag(const std::shared_ptr(reply.ReadInt32()); } + +WSError SessionProxy::UpdateRectChangeListenerRegistered(bool isRegister) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteBool(isRegister)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "write isRegister failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (Remote()->SendRequest( + static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_RECTCHANGE_LISTENER_REGISTERED), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + int32_t ret = reply.ReadInt32(); + return static_cast(ret); +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 996969a0e..0f7569885 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -48,6 +48,8 @@ const std::map SessionStub::stubFuncMap_ { &SessionStub::HandleShow), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_HIDE), &SessionStub::HandleHide), + std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_RECTCHANGE_LISTENER_REGISTERED), + &SessionStub::HandleUpdateRectChangeListenerRegistered), std::make_pair(static_cast(SessionInterfaceCode::TRANS_ID_UPDATE_ACTIVE_STATUS), &SessionStub::HandleUpdateActivateStatus), @@ -614,4 +616,12 @@ int SessionStub::HandleSendPointerEvenForMoveDrag(MessageParcel& data, MessagePa reply.WriteUint32(static_cast(errCode)); return ERR_NONE; } + +int SessionStub::HandleUpdateRectChangeListenerRegistered(MessageParcel& data, MessageParcel& reply) +{ + bool isRegister = data.ReadBool(); + WSError errCode = UpdateRectChangeListenerRegistered(isRegister); + reply.WriteUint32(static_cast(errCode)); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index 6b046456c..5378bb6ce 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -271,6 +271,22 @@ HWTEST_F(SessionStubTest, HandleSendPointerEvenForMoveDrag007, Function | SmallT auto res = session_->HandleSendPointerEvenForMoveDrag(data, reply); ASSERT_EQ(-1, res); } + +/** + * @tc.name: HandleUpdateRectChangeListenerRegistered008 + * @tc.desc: sessionStub sessionStubTest + * @tc.type: FUNC + * @tc.require: #I6JLSI + */ +HWTEST_F(SessionStubTest, HandleUpdateRectChangeListenerRegistered008, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + data.WriteBool(true); + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + auto res = session_->HandleUpdateRectChangeListenerRegistered(data, reply); + ASSERT_EQ(-1, res); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index ad5945cee..a6fd6e79b 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -209,6 +209,9 @@ public: void NotifyWindowTitleButtonRectChange(TitleButtonRect titleButtonRect); void RecoverSessionListener(); void SetDefaultDisplayIdIfNeed(); + WMError RegisterWindowRectChangeListener(const sptr& listener) override; + WMError UnregisterWindowRectChangeListener(const sptr& listener) override; + protected: WMError Connect(); bool IsWindowSessionInvalid() const; @@ -301,6 +304,8 @@ private: RSSurfaceNode::SharedPtr CreateSurfaceNode(std::string name, WindowType type); template EnableIfSame>> GetListeners(); + template + EnableIfSame>> GetListeners(); void NotifyUIContentFocusStatus(); void NotifyAfterUnfocused(bool needNotifyUiContent = true); @@ -330,6 +335,7 @@ private: static std::recursive_mutex windowStatusChangeListenerMutex_; static std::recursive_mutex windowTitleButtonRectChangeListenerMutex_; static std::mutex displayMoveListenerMutex_; + static std::mutex windowRectChangeListenerMutex_; static std::map>> lifecycleListeners_; static std::map>> displayMoveListeners_; static std::map>> windowChangeListeners_; @@ -344,6 +350,7 @@ private: static std::map>> windowStatusChangeListeners_; static std::map>> windowTitleButtonRectChangeListeners_; + static std::map>> windowRectChangeListeners_; // FA only sptr aceAbilityHandler_; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index b59bf378a..dac1e77be 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -74,6 +74,7 @@ std::map> WindowSessionImpl: std::map> WindowSessionImpl::windowNoInteractionListeners_; std::map>> WindowSessionImpl::windowTitleButtonRectChangeListeners_; +std::map>> WindowSessionImpl::windowRectChangeListeners_; std::recursive_mutex WindowSessionImpl::lifeCycleListenerMutex_; std::recursive_mutex WindowSessionImpl::windowChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::avoidAreaChangeListenerMutex_; @@ -87,6 +88,7 @@ std::recursive_mutex WindowSessionImpl::windowNoInteractionListenerMutex_; std::recursive_mutex WindowSessionImpl::windowStatusChangeListenerMutex_; std::recursive_mutex WindowSessionImpl::windowTitleButtonRectChangeListenerMutex_; std::mutex WindowSessionImpl::displayMoveListenerMutex_; +std::mutex WindowSessionImpl::windowRectChangeListenerMutex_; std::map>> WindowSessionImpl::windowSessionMap_; std::shared_mutex WindowSessionImpl::windowSessionMutex_; std::map>> WindowSessionImpl::subWindowSessionMap_; @@ -1383,6 +1385,35 @@ void WindowSessionImpl::NotifyWindowTitleButtonRectChange(TitleButtonRect titleB } } +template +EnableIfSame>> WindowSessionImpl::GetListeners() +{ + std::vector> windowRectChangeListeners; + for (auto& listener : windowRectChangeListeners_[GetPersistentId()]) { + windowRectChangeListeners.push_back(listener); + } + return windowRectChangeListeners; +} + +WMError WindowSessionImpl::RegisterWindowRectChangeListener(const sptr& listener) +{ + std::lock_guard lockListener(windowRectChangeListenerMutex_); + WMError ret = RegisterListener(windowRectChangeListeners_[GetPersistentId()], listener); + if (ret == WMError::WM_OK) { + hostSession_->UpdateRectChangeListenerRegistered(true); + } + return ret; +} + +WMError WindowSessionImpl::UnregisterWindowRectChangeListener(const sptr& listener) +{ + std::lock_guard lockListener(windowRectChangeListenerMutex_); + WMError ret = UnregisterListener(windowRectChangeListeners_[GetPersistentId()], listener); + hostSession_->UpdateRectChangeListenerRegistered(false); + return ret; +} + void WindowSessionImpl::RecoverSessionListener() { auto persistentId = GetPersistentId(); @@ -1510,6 +1541,10 @@ void WindowSessionImpl::ClearListenersById(int32_t persistentId) std::lock_guard lockListener(windowTitleButtonRectChangeListenerMutex_); ClearUselessListeners(windowTitleButtonRectChangeListeners_, persistentId); } + { + std::lock_guard lockListener(windowRectChangeListenerMutex_); + ClearUselessListeners(windowRectChangeListeners_, persistentId); + } } void WindowSessionImpl::RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) @@ -1867,6 +1902,13 @@ void WindowSessionImpl::NotifySizeChange(Rect rect, WindowSizeChangeReason reaso listener->OnSizeChange(rect, reason); } } + std::lock_guard lockRectListener(windowRectChangeListenerMutex_); + auto windowRectChangeListeners = GetListeners(); + for (auto& listener : windowRectChangeListeners) { + if (listener != nullptr) { + listener->OnRectChange(rect, reason); + } + } } WMError WindowSessionImpl::RegisterAvoidAreaChangeListener(sptr& listener) diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 6be037b1d..da228ceb0 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -869,6 +869,12 @@ HWTEST_F(WindowSessionImplTest, RegisterListener01, Function | SmallTest | Level res = window->UnregisterDisplayMoveListener(listener6); ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); + sptr listener7 = nullptr; + res = window->RegisterWindowRectChangeListener(listener7); + ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); + res = window->UnregisterWindowRectChangeListener(listener7); + ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR); + GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterListener01 end"; } diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 2d5b18b8e..35b8e05e4 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -2305,6 +2305,36 @@ HWTEST_F(WindowTest, Maximize01, Function | SmallTest | Level2) MaximizeLayoutOption option; ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, window->Maximize(option)); } + +/** + * @tc.name: RegisterWindowRectChangeListener + * @tc.desc: get + * @tc.type: FUNC + */ +HWTEST_F(WindowTest, RegisterWindowRectChangeListener, Function | SmallTest | Level2) +{ + sptr window = new Window(); + ASSERT_NE(nullptr, window); + sptr listener = nullptr; + auto ret = window->RegisterWindowRectChangeListener(listener); + ASSERT_EQ(WMError::WM_OK, ret); + ASSERT_EQ(WMError::WM_OK, window->Destroy()); +} + +/** + * @tc.name: UnregisterWindowRectChangeListener + * @tc.desc: get + * @tc.type: FUNC + */ +HWTEST_F(WindowTest, UnregisterWindowRectChangeListener, Function | SmallTest | Level2) +{ + sptr window = new Window(); + ASSERT_NE(nullptr, window); + sptr listener = nullptr; + auto ret = window->UnregisterWindowRectChangeListener(listener); + ASSERT_EQ(WMError::WM_OK, ret); + ASSERT_EQ(WMError::WM_OK, window->Destroy()); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From 6cda9387c99c35c0f95e0812a4360ae94b19bd53 Mon Sep 17 00:00:00 2001 From: Ning Yuanfeng Date: Thu, 28 Mar 2024 12:26:17 +0800 Subject: [PATCH 234/385] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=80=E5=87=BA?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E6=97=B6=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=8B=89=E8=B5=B7=E5=8F=8A=E6=8E=A7=E5=88=B6=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6post=E5=88=B0=E4=B8=BB=E7=BA=BF=E7=A8=8B=E6=89=A7?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ning Yuanfeng --- .../src/scene_session_manager.cpp | 12 ++++++++++-- wm/src/picture_in_picture_controller.cpp | 18 ++++++++++++++++-- wm/src/window.cpp | 2 +- wm/src/window_session_impl.cpp | 5 ++++- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c16746acd..938e3dfa3 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1757,8 +1757,16 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_PIP && !CheckPiPPriority(property->GetPiPTemplateInfo())) { - return WSError::WS_DO_NOTHING; + if (property->GetWindowType() == WindowType::WINDOW_TYPE_PIP) { + if (!CheckPiPPriority(property->GetPiPTemplateInfo())) { + TLOGI(WmsLogTag::WMS_PIP, "skip create pip window by priority"); + return WSError::WS_DO_NOTHING; + } + auto parentSession = GetSceneSession(property->GetParentPersistentId()); + if (parentSession->GetSessionState() == SessionState::STATE_DISCONNECT) { + TLOGI(WmsLogTag::WMS_PIP, "skip create pip window as parent window disconnected"); + return WSError::WS_DO_NOTHING; + } } TLOGI(WmsLogTag::WMS_LIFE, "create specific start, name: %{public}s, type: %{public}d", property->GetWindowName().c_str(), property->GetWindowType()); diff --git a/wm/src/picture_in_picture_controller.cpp b/wm/src/picture_in_picture_controller.cpp index 0592fefb5..f9a5ed25f 100644 --- a/wm/src/picture_in_picture_controller.cpp +++ b/wm/src/picture_in_picture_controller.cpp @@ -29,6 +29,7 @@ namespace OHOS { namespace Rosen { namespace { + constexpr int32_t DELAY_ANIM = 500; constexpr int32_t SUCCESS = 1; constexpr int32_t FAILED = 0; constexpr uint32_t PIP_LOW_PRIORITY = 0; @@ -96,7 +97,7 @@ WMError PictureInPictureController::CreatePictureInPictureWindow() pipTemplateInfo.priority = GetPipPriority(pipOption_->GetPipTemplate()); sptr window = Window::CreatePiP(windowOption, pipTemplateInfo, context->lock(), errCode); if (window == nullptr || errCode != WMError::WM_OK) { - TLOGE(WmsLogTag::WMS_PIP, "Window create failed, reason: %{public}d", errCode); + TLOGW(WmsLogTag::WMS_PIP, "Window create failed, reason: %{public}d", errCode); return WMError::WM_ERROR_PIP_CREATE_FAILED; } window_ = window; @@ -445,7 +446,20 @@ void PictureInPictureController::RestorePictureInPictureWindow() TLOGE(WmsLogTag::WMS_PIP, "navController is nullptr"); } } - StopPictureInPicture(true, StopPipType::NULL_STOP); + if (handler_) { + auto stopTask = [weakThis = wptr(this)]() { + auto controller = weakThis.promote(); + if (!controller) { + TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr"); + return; + } + controller->StopPictureInPicture(true, StopPipType::NULL_STOP); + }; + handler_->PostTask(stopTask, "wms:StopPictureInPicture_restore", DELAY_ANIM); + } else { + TLOGW(WmsLogTag::WMS_PIP, "StopPictureInPicture no delay while restore"); + StopPictureInPicture(true, StopPipType::NULL_STOP); + } SingletonContainer::Get().ReportPiPRestore(); TLOGI(WmsLogTag::WMS_PIP, "restore pip main window finished"); } diff --git a/wm/src/window.cpp b/wm/src/window.cpp index 13eca6e37..3bf2e7bf4 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -168,7 +168,7 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo WMError error = windowSessionImpl->Create(context, nullptr); if (error != WMError::WM_OK) { errCode = error; - TLOGD(WmsLogTag::WMS_PIP, "Create pip window with session, error: %{public}u", static_cast(errCode)); + TLOGW(WmsLogTag::WMS_PIP, "Create pip window with session, error: %{public}u", static_cast(errCode)); return nullptr; } return windowSessionImpl; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index dac1e77be..d898023ed 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2029,7 +2029,10 @@ WSError WindowSessionImpl::UpdateAvoidArea(const sptr& avoidArea, Avo WSError WindowSessionImpl::SetPipActionEvent(const std::string& action, int32_t status) { TLOGI(WmsLogTag::WMS_PIP, "action: %{public}s, status: %{public}d", action.c_str(), status); - PictureInPictureManager::DoActionEvent(action, status); + auto task = [action, status]() { + PictureInPictureManager::DoActionEvent(action, status); + }; + handler_->PostTask(task, "WMS_WindowSessionImpl_SetPipActionEvent"); return WSError::WS_OK; } -- Gitee From f631dd1c1b61f0b30166fef3ce43645e0c77f17c Mon Sep 17 00:00:00 2001 From: Ning Yuanfeng Date: Thu, 28 Mar 2024 12:31:26 +0800 Subject: [PATCH 235/385] =?UTF-8?q?=E9=80=82=E9=85=8DTDD=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ning Yuanfeng --- .idea/workspace.xml | 112 +++++++++++++++++ 0001-post.patch | 117 ++++++++++++++++++ .../picture_in_picture_controller_test.cpp | 21 +++- 3 files changed, 245 insertions(+), 5 deletions(-) create mode 100644 .idea/workspace.xml create mode 100644 0001-post.patch diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 000000000..3fc1baf3c --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1710483187512 + + + + + + + + + + + + - - \ No newline at end of file diff --git a/0001-post.patch b/0001-post.patch deleted file mode 100644 index f13957aef..000000000 --- a/0001-post.patch +++ /dev/null @@ -1,117 +0,0 @@ -From 6cda9387c99c35c0f95e0812a4360ae94b19bd53 Mon Sep 17 00:00:00 2001 -From: Ning Yuanfeng -Date: Thu, 28 Mar 2024 12:26:17 +0800 -Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=80=E5=87=BA=E5=BA=94?= - =?UTF-8?q?=E7=94=A8=E6=97=B6=E7=94=BB=E4=B8=AD=E7=94=BB=E8=87=AA=E5=8A=A8?= - =?UTF-8?q?=E6=8B=89=E8=B5=B7=E5=8F=8A=E6=8E=A7=E5=88=B6=E4=BA=8B=E4=BB=B6?= - =?UTF-8?q?post=E5=88=B0=E4=B8=BB=E7=BA=BF=E7=A8=8B=E6=89=A7=E8=A1=8C?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Signed-off-by: Ning Yuanfeng ---- - .../src/scene_session_manager.cpp | 12 ++++++++++-- - wm/src/picture_in_picture_controller.cpp | 18 ++++++++++++++++-- - wm/src/window.cpp | 2 +- - wm/src/window_session_impl.cpp | 5 ++++- - 4 files changed, 31 insertions(+), 6 deletions(-) - -diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp -index c16746acd..938e3dfa3 100644 ---- a/window_scene/session_manager/src/scene_session_manager.cpp -+++ b/window_scene/session_manager/src/scene_session_manager.cpp -@@ -1757,8 +1757,16 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_PIP && !CheckPiPPriority(property->GetPiPTemplateInfo())) { -- return WSError::WS_DO_NOTHING; -+ if (property->GetWindowType() == WindowType::WINDOW_TYPE_PIP) { -+ if (!CheckPiPPriority(property->GetPiPTemplateInfo())) { -+ TLOGI(WmsLogTag::WMS_PIP, "skip create pip window by priority"); -+ return WSError::WS_DO_NOTHING; -+ } -+ auto parentSession = GetSceneSession(property->GetParentPersistentId()); -+ if (parentSession->GetSessionState() == SessionState::STATE_DISCONNECT) { -+ TLOGI(WmsLogTag::WMS_PIP, "skip create pip window as parent window disconnected"); -+ return WSError::WS_DO_NOTHING; -+ } - } - TLOGI(WmsLogTag::WMS_LIFE, "create specific start, name: %{public}s, type: %{public}d", - property->GetWindowName().c_str(), property->GetWindowType()); -diff --git a/wm/src/picture_in_picture_controller.cpp b/wm/src/picture_in_picture_controller.cpp -index 0592fefb5..f9a5ed25f 100644 ---- a/wm/src/picture_in_picture_controller.cpp -+++ b/wm/src/picture_in_picture_controller.cpp -@@ -29,6 +29,7 @@ - namespace OHOS { - namespace Rosen { - namespace { -+ constexpr int32_t DELAY_ANIM = 500; - constexpr int32_t SUCCESS = 1; - constexpr int32_t FAILED = 0; - constexpr uint32_t PIP_LOW_PRIORITY = 0; -@@ -96,7 +97,7 @@ WMError PictureInPictureController::CreatePictureInPictureWindow() - pipTemplateInfo.priority = GetPipPriority(pipOption_->GetPipTemplate()); - sptr window = Window::CreatePiP(windowOption, pipTemplateInfo, context->lock(), errCode); - if (window == nullptr || errCode != WMError::WM_OK) { -- TLOGE(WmsLogTag::WMS_PIP, "Window create failed, reason: %{public}d", errCode); -+ TLOGW(WmsLogTag::WMS_PIP, "Window create failed, reason: %{public}d", errCode); - return WMError::WM_ERROR_PIP_CREATE_FAILED; - } - window_ = window; -@@ -445,7 +446,20 @@ void PictureInPictureController::RestorePictureInPictureWindow() - TLOGE(WmsLogTag::WMS_PIP, "navController is nullptr"); - } - } -- StopPictureInPicture(true, StopPipType::NULL_STOP); -+ if (handler_) { -+ auto stopTask = [weakThis = wptr(this)]() { -+ auto controller = weakThis.promote(); -+ if (!controller) { -+ TLOGE(WmsLogTag::WMS_PIP, "controller is nullptr"); -+ return; -+ } -+ controller->StopPictureInPicture(true, StopPipType::NULL_STOP); -+ }; -+ handler_->PostTask(stopTask, "wms:StopPictureInPicture_restore", DELAY_ANIM); -+ } else { -+ TLOGW(WmsLogTag::WMS_PIP, "StopPictureInPicture no delay while restore"); -+ StopPictureInPicture(true, StopPipType::NULL_STOP); -+ } - SingletonContainer::Get().ReportPiPRestore(); - TLOGI(WmsLogTag::WMS_PIP, "restore pip main window finished"); - } -diff --git a/wm/src/window.cpp b/wm/src/window.cpp -index 13eca6e37..3bf2e7bf4 100644 ---- a/wm/src/window.cpp -+++ b/wm/src/window.cpp -@@ -168,7 +168,7 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo - WMError error = windowSessionImpl->Create(context, nullptr); - if (error != WMError::WM_OK) { - errCode = error; -- TLOGD(WmsLogTag::WMS_PIP, "Create pip window with session, error: %{public}u", static_cast(errCode)); -+ TLOGW(WmsLogTag::WMS_PIP, "Create pip window with session, error: %{public}u", static_cast(errCode)); - return nullptr; - } - return windowSessionImpl; -diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp -index dac1e77be..d898023ed 100644 ---- a/wm/src/window_session_impl.cpp -+++ b/wm/src/window_session_impl.cpp -@@ -2029,7 +2029,10 @@ WSError WindowSessionImpl::UpdateAvoidArea(const sptr& avoidArea, Avo - WSError WindowSessionImpl::SetPipActionEvent(const std::string& action, int32_t status) - { - TLOGI(WmsLogTag::WMS_PIP, "action: %{public}s, status: %{public}d", action.c_str(), status); -- PictureInPictureManager::DoActionEvent(action, status); -+ auto task = [action, status]() { -+ PictureInPictureManager::DoActionEvent(action, status); -+ }; -+ handler_->PostTask(task, "WMS_WindowSessionImpl_SetPipActionEvent"); - return WSError::WS_OK; - } - --- -2.42.0.windows.2 - -- Gitee From 11ea9e39fc5528368838d2f1970c2149fffa4410 Mon Sep 17 00:00:00 2001 From: liubo Date: Thu, 28 Mar 2024 14:11:32 +0800 Subject: [PATCH 237/385] =?UTF-8?q?Description:=20=E6=89=A7=E8=A1=8Chidump?= =?UTF-8?q?er=E5=91=BD=E4=BB=A4=E5=AF=BC=E8=87=B4foundation=E8=BF=9B?= =?UTF-8?q?=E7=A8=8Bcrash=20IssueNo:https://gitee.com/openharmony/window?= =?UTF-8?q?=5Fwindow=5Fmanager/issues/I9C9U2=20Feature=20or=20Bugfix:=20Bu?= =?UTF-8?q?gfix=20Binary=20Source:No=20Signed-off-by:=20liubo419=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/session_manager/src/screen_session_dumper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/screen_session_dumper.cpp b/window_scene/session_manager/src/screen_session_dumper.cpp index 641a98594..48fb3f773 100644 --- a/window_scene/session_manager/src/screen_session_dumper.cpp +++ b/window_scene/session_manager/src/screen_session_dumper.cpp @@ -69,7 +69,7 @@ void ScreenSessionDumper::ExcuteDumpCmd() WLOGFE("dump permission denied!"); return; } - if (params_[0] == ARG_DUMP_ALL) { // dump all info command + if (!params_.empty() && params_[0] == ARG_DUMP_ALL) { // dump all info command ShowAllScreenInfo(); } OutputDumpInfo(); -- Gitee From 71c09bccc404330993ce2f075f13f419cbf6ed15 Mon Sep 17 00:00:00 2001 From: ywx1281675 Date: Thu, 28 Mar 2024 14:41:36 +0800 Subject: [PATCH 238/385] =?UTF-8?q?=E5=A4=8D=E7=94=A8ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ywx1281675 Change-Id: I8d056d0e12f5f75ae4c90ad124dc8428b234763f --- window_scene/session_manager/src/scene_session_manager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 525d2b572..c3e1743b7 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -984,8 +984,7 @@ sptr SceneSessionManager::CreateSceneSession(const SessionInfo& se sptr SceneSessionManager::RequestSceneSession(const SessionInfo& sessionInfo, sptr property) { - if (sessionInfo.persistentId_ != 0 && !sessionInfo.isPersistentRecover_ && - sessionInfo.bundleName_.find("hmsapp.samplemanagement") == std::string::npos) { + if (sessionInfo.persistentId_ != 0 && !sessionInfo.isPersistentRecover_) { auto session = GetSceneSession(sessionInfo.persistentId_); if (session != nullptr) { NotifySessionUpdate(sessionInfo, ActionType::SINGLE_START); -- Gitee From ebcab0f983b36b6e00a9da51baeebcc3b193a88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Thu, 28 Mar 2024 15:30:51 +0800 Subject: [PATCH 239/385] add safe config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- dm/BUILD.gn | 3 +++ interfaces/kits/napi/common/BUILD.gn | 3 +++ utils/BUILD.gn | 3 +++ wm/BUILD.gn | 3 +++ 4 files changed, 12 insertions(+) diff --git a/dm/BUILD.gn b/dm/BUILD.gn index 06716d8ee..179f7a33c 100644 --- a/dm/BUILD.gn +++ b/dm/BUILD.gn @@ -43,6 +43,9 @@ ohos_static_library("libdm_static") { cfi = true cfi_cross_dso = true debug = false + integer_overflow = true + ubsan = true + boundary_sanitize = true } sources = [ "../dmserver/src/display_manager_proxy.cpp", diff --git a/interfaces/kits/napi/common/BUILD.gn b/interfaces/kits/napi/common/BUILD.gn index 5873c9577..44d589116 100644 --- a/interfaces/kits/napi/common/BUILD.gn +++ b/interfaces/kits/napi/common/BUILD.gn @@ -38,6 +38,9 @@ ohos_static_library("dm_napi_common") { cfi = true cfi_cross_dso = true debug = false + integer_overflow = true + ubsan = true + boundary_sanitize = true } sources = [ "dm_napi_common.cpp" ] diff --git a/utils/BUILD.gn b/utils/BUILD.gn index ffe298da4..58f291d07 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -36,6 +36,9 @@ ohos_static_library("libwmutil_static") { cfi = true cfi_cross_dso = true debug = false + integer_overflow = true + ubsan = true + boundary_sanitize = true } sources = [ "src/accessibility_window_info.cpp", diff --git a/wm/BUILD.gn b/wm/BUILD.gn index 09f23ded2..7a510ad5d 100644 --- a/wm/BUILD.gn +++ b/wm/BUILD.gn @@ -41,6 +41,9 @@ ohos_static_library("libwm_static") { cfi = true cfi_cross_dso = true debug = false + integer_overflow = true + ubsan = true + boundary_sanitize = true } include_dirs = [ "../utils/include", -- Gitee From 0e0916fe53adb4936281bb0d6adb3feb167c9a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Thu, 28 Mar 2024 15:49:01 +0800 Subject: [PATCH 240/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../kits/napi/window_runtime/window_napi/js_window_utils.cpp | 2 +- .../kits/napi/window_runtime/window_napi/js_window_utils.h | 1 + .../session_manager/src/scene_session_dirty_manager.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp index 6ba6b1760..59e0f886d 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp @@ -844,7 +844,7 @@ bool GetWindowMaskFromJsValue(napi_env env, napi_value jsObject, std::vector 1920) { + if (size == 0 || size > WINDOW_MAX_WIDTH) { WLOGFE("Invalid window mask"); return false; } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h index c4ffd28de..e964a9b7b 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_utils.h @@ -33,6 +33,7 @@ namespace OHOS { namespace Rosen { constexpr int32_t RGB_LENGTH = 6; constexpr int32_t RGBA_LENGTH = 8; +constexpr int32_t WINDOW_MAX_WIDTH = 1920; #define CHECK_NAPI_RETCODE(errCode, code, call) \ do { \ diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 1be356c31..6b0b519b2 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -423,7 +423,7 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr std::vector touchHotAreas; std::vector pointerHotAreas; UpdateHotAreas(sceneSession, touchHotAreas, pointerHotAreas); - auto windowMask = sceneSession->GetSessionProperty()->GetWindowMask(); + auto windowMask = sceneSession->GetSessionProperty()->GetWindowMask().GetRefPtr(); MMI::WindowInfo windowInfo = { .id = windowId, .pid = sceneSession->IsStartMoving() ? static_cast(getpid()) : pid, -- Gitee From dd42ff7c61f2df6ffcc321598044ac58efc7854a Mon Sep 17 00:00:00 2001 From: qintongtong Date: Wed, 27 Mar 2024 21:17:21 +0800 Subject: [PATCH 241/385] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=88=86=E5=8F=91?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=A1=A5=E9=BD=90/=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=8E=87=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qintongtong Change-Id: Ia059076284a3e97bacbfb3bb21eeee06cca279ae --- .../src/intention_event_manager.cpp | 3 ++- .../container/src/window_event_channel.cpp | 4 ++-- .../session/host/src/scene_session.cpp | 3 +++ .../src/scene_input_manager.cpp | 18 +++++++-------- .../src/scene_session_dirty_manager.cpp | 22 +++++++++---------- wm/src/window_input_channel.cpp | 3 ++- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/window_scene/intention_event/src/intention_event_manager.cpp b/window_scene/intention_event/src/intention_event_manager.cpp index 4db2ef127..a409a0a27 100644 --- a/window_scene/intention_event/src/intention_event_manager.cpp +++ b/window_scene/intention_event/src/intention_event_manager.cpp @@ -286,7 +286,8 @@ void IntentionEventManager::InputEventListener::OnInputEvent(std::shared_ptrSendKeyEventToUI(keyEvent, true); - TLOGI(WmsLogTag::WMS_EVENT, "SendKeyEventToUI isConsumed = %{public}d", static_cast(isConsumed)); + TLOGI(WmsLogTag::WMS_EVENT, "SendKeyEventToUI id:%{public}d isConsumed = %{public}d", + keyEvent->GetId(), static_cast(isConsumed)); #ifdef IMF_ENABLE bool isKeyboardEvent = IsKeyboardEvent(keyEvent); if (isKeyboardEvent) { diff --git a/window_scene/session/container/src/window_event_channel.cpp b/window_scene/session/container/src/window_event_channel.cpp index cfc73d201..66e4cbe7a 100644 --- a/window_scene/session/container/src/window_event_channel.cpp +++ b/window_scene/session/container/src/window_event_channel.cpp @@ -92,8 +92,8 @@ WSError WindowEventChannel::TransferKeyEventForConsumed( } if (isPreImeEvent) { isConsumed = sessionStage_->NotifyOnKeyPreImeEvent(keyEvent); - TLOGI(WmsLogTag::WMS_EVENT, "TransferKeyEventForConsumed isConsumed = %{public}d", - static_cast(isConsumed)); + TLOGI(WmsLogTag::WMS_EVENT, "NotifyOnKeyPreImeEvent id:%{public}d isConsumed:%{public}d", + keyEvent->GetId(), static_cast(isConsumed)); return WSError::WS_OK; } DelayedSingleton::GetInstance()->SetSessionStage(keyEvent->GetId(), sessionStage_); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 1fd834691..4793cdb10 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2215,6 +2215,9 @@ void SceneSession::SendPointerEventToUI(std::shared_ptr point std::lock_guard lock(pointerEventMutex_); if (systemSessionPointerEventFunc_ != nullptr) { systemSessionPointerEventFunc_(pointerEvent); + } else { + TLOGE(WmsLogTag::WMS_EVENT, "PointerEventFunc_ nullptr, id:%{public}d", pointerEvent->GetId()); + pointerEvent->MarkProcessed(); } } diff --git a/window_scene/session_manager/src/scene_input_manager.cpp b/window_scene/session_manager/src/scene_input_manager.cpp index 993ddcec9..d7526c59e 100644 --- a/window_scene/session_manager/src/scene_input_manager.cpp +++ b/window_scene/session_manager/src/scene_input_manager.cpp @@ -261,16 +261,14 @@ void SceneInputManager::FlushFullInfoToMMI(const std::vector& .focusWindowId = focusId, .windowsInfo = windowInfoList, .displaysInfo = displayInfos}; - for (const auto& displayInfo : displayGroupInfo.displaysInfo) { - TLOGD(WmsLogTag::WMS_EVENT, "[EventDispatch] - %s", DumpDisplayInfo(displayInfo).c_str()); - } - std::string windowinfolst = "windowinfo "; - for (const auto& windowInfo : displayGroupInfo.windowsInfo) { - windowinfolst.append(DumpWindowInfo(windowInfo).append(" || ")); - } - TLOGD(WmsLogTag::WMS_EVENT, "[EventDispatch] - %s", windowinfolst.c_str()); - TLOGI(WmsLogTag::WMS_EVENT, "[WMSEvent] UpdateDisplayInfo windowListSize: %{public}d", - static_cast(windowInfoList.size())); + for (const auto& displayInfo : displayGroupInfo.displaysInfo) { + TLOGD(WmsLogTag::WMS_EVENT, "[EventDispatch] - %s", DumpDisplayInfo(displayInfo).c_str()); + } + std::string windowinfolst = "windowinfo "; + for (const auto& windowInfo : displayGroupInfo.windowsInfo) { + windowinfolst.append(DumpWindowInfo(windowInfo).append(" || ")); + } + TLOGD(WmsLogTag::WMS_EVENT, "[EventDispatch] - %s", windowinfolst.c_str()); MMI::InputManager::GetInstance()->UpdateDisplayInfo(displayGroupInfo); } diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 47120de5b..6b4c1029c 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -349,28 +349,28 @@ void SceneSessionDirtyManager::UpdatePointerAreas(sptr sceneSessio vpr = screenSession->GetScreenProperty().GetDensity(); } } - int32_t pointerArea_Five_PX = static_cast(POINTER_CHANGE_AREA_FIVE * vpr); - int32_t pointerArea_Sexteen_PX = static_cast(POINTER_CHANGE_AREA_SEXTEEN * vpr); + int32_t pointerArea_Five_Px = static_cast(POINTER_CHANGE_AREA_FIVE * vpr); + int32_t pointerArea_Sexteen_Px = static_cast(POINTER_CHANGE_AREA_SEXTEEN * vpr); if (sceneSession->GetSessionInfo().isSetPointerAreas_) { pointerChangeAreas = {POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, - POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_PX, pointerArea_Sexteen_PX, - pointerArea_Five_PX, pointerArea_Sexteen_PX, pointerArea_Five_PX}; + POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_Px, pointerArea_Sexteen_Px, + pointerArea_Five_Px, pointerArea_Sexteen_Px, pointerArea_Five_Px}; return; } auto limits = sceneSession->GetSessionProperty()->GetWindowLimits(); if (limits.minWidth_ == limits.maxWidth_ && limits.minHeight_ != limits.maxHeight_) { - pointerChangeAreas = {POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_PX, + pointerChangeAreas = {POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_Px, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, - pointerArea_Five_PX, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT}; + pointerArea_Five_Px, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT}; } else if (limits.minWidth_ != limits.maxWidth_ && limits.minHeight_ == limits.maxHeight_) { pointerChangeAreas = {POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, - POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_PX, POINTER_CHANGE_AREA_DEFAULT, - POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_PX}; + POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_Px, POINTER_CHANGE_AREA_DEFAULT, + POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_Px}; } else if (limits.minWidth_ != limits.maxWidth_ && limits.minHeight_ != limits.maxHeight_) { - pointerChangeAreas = {pointerArea_Sexteen_PX, pointerArea_Five_PX, - pointerArea_Sexteen_PX, pointerArea_Five_PX, pointerArea_Sexteen_PX, - pointerArea_Five_PX, pointerArea_Sexteen_PX, pointerArea_Five_PX}; + pointerChangeAreas = {pointerArea_Sexteen_Px, pointerArea_Five_Px, + pointerArea_Sexteen_Px, pointerArea_Five_Px, pointerArea_Sexteen_Px, + pointerArea_Five_Px, pointerArea_Sexteen_Px, pointerArea_Five_Px}; } } else { WLOGFD("UpdatePointerAreas sceneSession is: %{public}d dragEnabled is false", sceneSession->GetPersistentId()); diff --git a/wm/src/window_input_channel.cpp b/wm/src/window_input_channel.cpp index 7846de8ad..0b82258cb 100644 --- a/wm/src/window_input_channel.cpp +++ b/wm/src/window_input_channel.cpp @@ -74,7 +74,8 @@ void WindowInputChannel::HandleKeyEvent(std::shared_ptr& keyEvent } } bool isConsumed = window_->PreNotifyKeyEvent(keyEvent); - TLOGI(WmsLogTag::WMS_EVENT, "PreNotifyKeyEvent isConsumed = %{public}d", static_cast(isConsumed)); + TLOGI(WmsLogTag::WMS_EVENT, "PreNotifyKeyEvent id:%{public}d isConsumed:%{public}d", + keyEvent->GetId(), static_cast(isConsumed)); #ifdef IMF_ENABLE bool isKeyboardEvent = IsKeyboardEvent(keyEvent); if (isKeyboardEvent) { -- Gitee From 32c79ae066a5120ef8c2155aaf389c9f7e95307f Mon Sep 17 00:00:00 2001 From: zhangyao Date: Thu, 28 Mar 2024 07:55:32 +0000 Subject: [PATCH 242/385] =?UTF-8?q?Description:=20DMS=E9=80=82=E9=85=8DRS?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E7=8E=87=E5=9B=9E=E8=B0=83=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20IssueNo:https://gitee.com/openharmony/window=5Fwindow=5Fmana?= =?UTF-8?q?ger/issues/I99KAI=20Feature=20or=20Bugfix:=20Feature=20Binary?= =?UTF-8?q?=20Source:No=20Signed-off-by:=20zhangyao=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/innerkits/dm/dm_common.h | 20 +++--------- previewer/include/dm_common.h | 20 +++--------- .../include/screen_session_manager.h | 4 +-- .../src/screen_session_manager.cpp | 31 +++++++------------ 4 files changed, 24 insertions(+), 51 deletions(-) diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index 5121eb6f3..4146730c1 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -217,22 +217,12 @@ enum class ScreenGroupChangeEvent : uint32_t { }; /** - * @brief Enumerates refresh rate modes. + * @brief Enumerates max refresh rates. */ -enum class RefreshRateMode : int32_t { - SMART = -1, - NORMAL = 1, - MIDDLE = 2, - HIGH = 3, -}; - -/** - * @brief Enumerates refresh rates. - */ -enum class RefreshRate : uint32_t { - NORMAL = 60, - MIDDLE = 90, - HIGH = 120, +enum class MaxRefreshrate : uint32_t { + MAX_REFRESHRATE_60 = 60, + MAX_REFRESHRATE_90 = 90, + MAX_REFRESHRATE_120 = 120, }; /** diff --git a/previewer/include/dm_common.h b/previewer/include/dm_common.h index 9a958ff41..aef4381fe 100644 --- a/previewer/include/dm_common.h +++ b/previewer/include/dm_common.h @@ -217,22 +217,12 @@ enum class ScreenGroupChangeEvent : uint32_t { }; /** - * @brief Enumerates refreshrate modes. + * @brief Enumerates max refresh rates. */ -enum class RefreshRateMode : int32_t { - SMART = -1, - NORMAL = 1, - MIDDLE = 2, - HIGH = 3, -}; - -/** - * @brief Enumerates refreshrates. - */ -enum class RefreshRate : uint32_t { - NORMAL = 60, - MIDDLE = 90, - HIGH = 120, +enum class MaxRefreshrate : uint32_t { + MAX_REFRESHRATE_60 = 60, + MAX_REFRESHRATE_90 = 90, + MAX_REFRESHRATE_120 = 120, }; /** diff --git a/window_scene/session_manager/include/screen_session_manager.h b/window_scene/session_manager/include/screen_session_manager.h index 993efb424..0c1d6dd72 100644 --- a/window_scene/session_manager/include/screen_session_manager.h +++ b/window_scene/session_manager/include/screen_session_manager.h @@ -243,8 +243,8 @@ private: void ConfigureWaterfallDisplayCompressionParams(); void RegisterScreenChangeListener(); void OnScreenChange(ScreenId screenId, ScreenEvent screenEvent); - void RegisterRefreshRateModeChangeListener(); - void OnHgmRefreshRateModeChange(int32_t refreshRateMode); + void RegisterRefreshRateChangeListener(); + void OnHgmRefreshRateChange(int32_t refreshRateModeName); sptr GetOrCreateScreenSession(ScreenId screenId); void CreateScreenProperty(ScreenId screenId, ScreenProperty& property); sptr GetScreenSessionInner(ScreenId screenId, ScreenProperty property); diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 161ecc13d..2e32c3799 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -293,16 +293,17 @@ void ScreenSessionManager::RegisterScreenChangeListener() } } -void ScreenSessionManager::RegisterRefreshRateModeChangeListener() +void ScreenSessionManager::RegisterRefreshRateChangeListener() { static bool isRegisterRefreshRateListener = false; if (!isRegisterRefreshRateListener) { auto res = rsInterface_.RegisterHgmRefreshRateModeChangeCallback( - [this](int32_t refreshRateMode) { OnHgmRefreshRateModeChange(refreshRateMode); }); + [this](int32_t refreshRateModeName) { OnHgmRefreshRateChange(refreshRateModeName); }); if (res != StatusCode::SUCCESS) { WLOGFE("Register refresh rate mode change listener failed."); + } else { + isRegisterRefreshRateListener = true; } - isRegisterRefreshRateListener = true; } } @@ -402,24 +403,16 @@ void ScreenSessionManager::OnScreenChange(ScreenId screenId, ScreenEvent screenE } } -void ScreenSessionManager::OnHgmRefreshRateModeChange(int32_t refreshRateMode) +void ScreenSessionManager::OnHgmRefreshRateChange(int32_t refreshRateModeName) { GetDefaultScreenId(); - WLOGFI("Set refreshRateMode: %{public}d, defaultscreenid: %{public}" PRIu64"", refreshRateMode, defaultScreenId_); + WLOGFI("Set refreshRateModeName: %{public}d, defaultscreenid: %{public}" PRIu64"", + refreshRateModeName, defaultScreenId_); uint32_t refreshRate; - RefreshRateMode mode = static_cast(refreshRateMode); - switch (mode) { - case RefreshRateMode::NORMAL : - refreshRate = static_cast(RefreshRate::NORMAL); - break; - case RefreshRateMode::MIDDLE : - refreshRate = static_cast(RefreshRate::MIDDLE); - break; - case RefreshRateMode::HIGH : - refreshRate = static_cast(RefreshRate::HIGH); - break; - default: - refreshRate = static_cast(RefreshRate::HIGH); + if (refreshRateModeName == -1) { + refreshRate = static_cast(MaxRefreshrate::MAX_REFRESHRATE_120); + } else { + refreshRate = static_cast(refreshRateModeName); } sptr screenSession = GetScreenSession(defaultScreenId_); if (screenSession) { @@ -853,7 +846,7 @@ sptr ScreenSessionManager::GetOrCreateScreenSession(ScreenId scre } SetHdrFormats(screenId, session); SetColorSpaces(screenId, session); - RegisterRefreshRateModeChangeListener(); + RegisterRefreshRateChangeListener(); return session; } -- Gitee From cc03c003ef654ae53a8fb2a025b3e4c537b112ba Mon Sep 17 00:00:00 2001 From: lijie176 Date: Thu, 28 Mar 2024 16:22:30 +0800 Subject: [PATCH 243/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=92=8Ckeyevent=E7=9A=84MarkProcessed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijie176 --- window_scene/session/host/src/extension_session.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index 9162dd24c..21d12226b 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -203,14 +203,14 @@ WSError ExtensionSession::TransferKeyEventForConsumed(const std::shared_ptrSetTransferKeyEventForConsumedParams(isConsumedPromise, retCode); auto ret = windowEventChannel_->TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, listener); - constexpr int64_t TRANSFER_KEY_EVENT_TIMEOUT_TIME_MS = 1000; + // Timeout cannot exceed APP_INPUT_BLOCK + constexpr int64_t TRANSFER_KEY_EVENT_TIMEOUT_TIME_MS = 4000; auto isConsumedFuture = isConsumedPromise->get_future().share(); if (isConsumedFuture.wait_for(std::chrono::milliseconds(TRANSFER_KEY_EVENT_TIMEOUT_TIME_MS)) == std::future_status::timeout) { // Prevent external variables from being used after the lifecycle ends. listener->ResetTransferKeyEventForConsumedParams(); isTimeout = true; - keyEvent->MarkProcessed(); } else { isTimeout = false; isConsumed = isConsumedFuture.get(); -- Gitee From f74c9d0944e5c9fbb46ea32e3784ba2a3782e59c Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Thu, 28 Mar 2024 08:29:59 +0000 Subject: [PATCH 244/385] update previewer/include/wm_common.h. Signed-off-by: chengyiyi --- previewer/include/wm_common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/previewer/include/wm_common.h b/previewer/include/wm_common.h index 044946fd9..1345072f3 100644 --- a/previewer/include/wm_common.h +++ b/previewer/include/wm_common.h @@ -76,6 +76,7 @@ enum class WindowType : uint32_t { WINDOW_TYPE_PIP, WINDOW_TYPE_THEME_EDITOR, WINDOW_TYPE_NAVIGATION_INDICATOR, + WINDOW_TYPE_HANDWRITE, ABOVE_APP_SYSTEM_WINDOW_END, SYSTEM_SUB_WINDOW_BASE = 2500, -- Gitee From d3b91909ceb81d0b9fb5a306d8e7b268a5a52133 Mon Sep 17 00:00:00 2001 From: shark_00783 Date: Thu, 28 Mar 2024 16:43:53 +0800 Subject: [PATCH 245/385] =?UTF-8?q?UIExtension=E5=88=9B=E5=BB=BA=E5=AD=90?= =?UTF-8?q?=E7=AA=97=E9=98=B2=E5=B5=8C=E5=A5=97=E4=BF=A1=E6=81=AF=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shark_00783 --- wm/include/window_session_impl.h | 3 ++- wm/src/window_extension_session_impl.cpp | 2 +- wm/src/window_session_impl.cpp | 5 +++-- wm/test/unittest/window_session_impl_test.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index a6fd6e79b..2a69dad9e 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -268,7 +268,8 @@ protected: bool needRemoveWindowInputChannel_ = false; float virtualPixelRatio_ { 1.0f }; bool escKeyEventTriggered_ = false; - static bool isUIExtensionAbility_; + // Check whether the UIExtensionAbility process is started + static bool isUIExtensionAbilityProcess_; private: //Trans between colorGamut and colorSpace diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index b7c52a48b..4cfce5bd0 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -65,7 +65,7 @@ WMError WindowExtensionSessionImpl::Create(const std::shared_ptr>> WindowSession std::shared_mutex WindowSessionImpl::windowSessionMutex_; std::map>> WindowSessionImpl::subWindowSessionMap_; std::map>> WindowSessionImpl::windowStatusChangeListeners_; -bool WindowSessionImpl::isUIExtensionAbility_ = false; +bool WindowSessionImpl::isUIExtensionAbilityProcess_ = false; #define CALL_LIFECYCLE_LISTENER(windowLifecycleCb, listeners) \ do { \ @@ -738,7 +738,8 @@ WMError WindowSessionImpl::SetUIContentInner(const std::string& contentInfo, nap switch (type) { default: case WindowSetUIContentType::DEFAULT: - if (isUIExtensionAbility_ && property_->GetExtensionFlag() == true) { + if (isUIExtensionAbilityProcess_ && property_->GetExtensionFlag() == true) { + // subWindow created by UIExtensionAbility uiContent->SetUIExtensionSubWindow(true); uiContent->SetUIExtensionAbilityProcess(true); } diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index da228ceb0..099dad3f5 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -1771,7 +1771,7 @@ HWTEST_F(WindowSessionImplTest, SetUIContentInner, Function | SmallTest | Level2 option->SetExtensionTag(true); sptr window = new (std::nothrow) WindowSessionImpl(option); ASSERT_NE(window, nullptr); - string url = ""; + std::string url = ""; WMError res = window->SetUIContentInner(url, nullptr, nullptr, WindowSetUIContentType::DEFAULT, nullptr); ASSERT_EQ(res, WMError::WM_ERROR_INVALID_PARAM); GTEST_LOG_(INFO) << "WindowSessionImplTest: SetUIContentInner end"; -- Gitee From 7df6247dd7f996b616f1956a75f76adbc183bcca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=81=E7=94=9F=E5=BE=B7?= Date: Thu, 28 Mar 2024 16:43:33 +0800 Subject: [PATCH 246/385] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=97=A0=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E4=BA=8B=E4=BB=B6=EF=BC=8C=E6=8E=A5=E5=8F=A3=E8=AF=84?= =?UTF-8?q?=E5=AE=A1=E6=84=8F=E8=A7=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 祁生德 --- .../kits/napi/window_runtime/window_napi/js_window_listener.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h index f4d883caf..15d4145b5 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h @@ -47,7 +47,7 @@ const std::string WATER_MARK_FLAG_CHANGE_CB = "waterMarkFlagChange"; const std::string WINDOW_STATUS_CHANGE_CB = "windowStatusChange"; const std::string WINDOW_VISIBILITY_CHANGE_CB = "windowVisibilityChange"; const std::string WINDOW_TITLE_BUTTON_RECT_CHANGE_CB = "windowTitleButtonRectChange"; -const std::string WINDOW_NO_INTERACTION_DETECT_CB = "noInteractionDetect"; +const std::string WINDOW_NO_INTERACTION_DETECT_CB = "noInteractionDetected"; const std::string WINDOW_RECT_CHANGE_CB = "windowRectChange"; class JsWindowListener : public IWindowChangeListener, -- Gitee From 676e57100baee2670dea0b1d948bc01d45eda32f Mon Sep 17 00:00:00 2001 From: zhangkai Date: Thu, 28 Mar 2024 17:25:38 +0800 Subject: [PATCH 247/385] revert floating window check when resize Signed-off-by: zhangkai Change-Id: I073a5840edfbbfba8f5fd232af9976ff889ae6ba --- wm/src/window_scene_session_impl.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 192701328..7134549be 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1143,11 +1143,6 @@ WMError WindowSceneSessionImpl::Resize(uint32_t width, uint32_t height) return WMError::WM_ERROR_INVALID_OPERATION; } - if (GetMode() != WindowMode::WINDOW_MODE_FLOATING) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Unsupport operation for full screen window. WindowId: %{public}d", - GetWindowId()); - return WMError::WM_ERROR_INVALID_OPERATION; - } // Float camera window has special limits LimitCameraFloatWindowMininumSize(width, height); -- Gitee From 52f4eb07e553b7b4c81635a9daf50e75218f4ce4 Mon Sep 17 00:00:00 2001 From: Ning Yuanfeng Date: Thu, 28 Mar 2024 17:32:27 +0800 Subject: [PATCH 248/385] =?UTF-8?q?=E6=9B=B4=E6=96=B0liuc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ning Yuanfeng --- wm/src/picture_in_picture_controller.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/wm/src/picture_in_picture_controller.cpp b/wm/src/picture_in_picture_controller.cpp index f9a5ed25f..f5fac30be 100644 --- a/wm/src/picture_in_picture_controller.cpp +++ b/wm/src/picture_in_picture_controller.cpp @@ -398,6 +398,7 @@ void PictureInPictureController::UpdateContentSize(int32_t width, int32_t height } TLOGI(WmsLogTag::WMS_PIP, "UpdateContentSize window: %{public}u width:%{public}u height:%{public}u", window_->GetWindowId(), width, height); + pipOption_->SetContentSize(static_cast(width), static_cast(height)); Rect rect = {0, 0, width, height}; window_->UpdatePiPRect(rect, WindowSizeChangeReason::PIP_RATIO_CHANGE); } -- Gitee From 3e43ac4a36226b145a2cf0d032254574412ea2f1 Mon Sep 17 00:00:00 2001 From: Ning Yuanfeng Date: Thu, 28 Mar 2024 17:56:17 +0800 Subject: [PATCH 249/385] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=98=E5=8E=9F?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ning Yuanfeng --- wm/src/picture_in_picture_controller.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wm/src/picture_in_picture_controller.cpp b/wm/src/picture_in_picture_controller.cpp index f5fac30be..fa6cb82f1 100644 --- a/wm/src/picture_in_picture_controller.cpp +++ b/wm/src/picture_in_picture_controller.cpp @@ -396,6 +396,20 @@ void PictureInPictureController::UpdateContentSize(int32_t width, int32_t height TLOGE(WmsLogTag::WMS_PIP, "pipWindow not exist"); return; } + if (mainWindowXComponentController_) { + float posX = 0; + float posY = 0; + float newWidth = 0; + float newHeight = 0; + mainWindowXComponentController_->GetGlobalPosition(posX, posY); + mainWindowXComponentController_->GetSize(newWidth, newHeight); + if (windowRect_.width_ != static_cast(newWidth) || + windowRect_.height_ != static_cast(newHeight) || + windowRect_.posX_ != static_cast(posX) || windowRect_.posY_ != static_cast(posY)) { + Rect r = {posX, posY, newWidth, newHeight}; + window_->UpdatePiPRect(r, WindowSizeChangeReason::TRANSFORM); + } + } TLOGI(WmsLogTag::WMS_PIP, "UpdateContentSize window: %{public}u width:%{public}u height:%{public}u", window_->GetWindowId(), width, height); pipOption_->SetContentSize(static_cast(width), static_cast(height)); -- Gitee From d55bedfea12198ea2ef8d1118f3807d9f6973cb5 Mon Sep 17 00:00:00 2001 From: Ning Yuanfeng Date: Thu, 28 Mar 2024 20:22:15 +0800 Subject: [PATCH 250/385] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ning Yuanfeng --- 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 938e3dfa3..2cb7420fc 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1763,7 +1763,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetParentPersistentId()); - if (parentSession->GetSessionState() == SessionState::STATE_DISCONNECT) { + if (parentSession != nullptr && parentSession->GetSessionState() == SessionState::STATE_DISCONNECT) { TLOGI(WmsLogTag::WMS_PIP, "skip create pip window as parent window disconnected"); return WSError::WS_DO_NOTHING; } -- Gitee From fa882e081457579dfac4fd2e99df7fe6c90a4c76 Mon Sep 17 00:00:00 2001 From: xuhaodong Date: Thu, 28 Mar 2024 20:53:02 +0800 Subject: [PATCH 251/385] =?UTF-8?q?xts=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuhaodong --- window_scene/session_manager/src/scene_session_manager.cpp | 3 ++- 1 file changed, 2 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 c16746acd..3ecc5ac2d 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -5283,7 +5283,8 @@ void SceneSessionManager::ResizeSoftInputCallingSessionIfNeed( bool isCallingSessionFloating = callingSession_->GetSessionProperty() && callingSession_->GetSessionProperty()->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING; - const WSRect& softInputSessionRect = sceneSession->GetSessionRect(); + const WSRect& softInputSessionRect = (sceneSession->GetSessionRect().height_ != 0) ? + sceneSession->GetSessionRect() : sceneSession->GetSessionRequestRect(); WSRect callingSessionRect; if (isInputUpdated && isCallingSessionFloating) { callingSessionRect = callingSession_->callingWindowRestoringRect_; -- Gitee From c455dcf01dd01c0bb5e395d51750a2fc25ac51e0 Mon Sep 17 00:00:00 2001 From: c00512769 Date: Thu, 28 Mar 2024 13:50:55 +0000 Subject: [PATCH 252/385] Description:Configure Cutout information IssueNo:https://gitee.com/openharmony/window_window_manager/issues/I9BUQA Feature or Bugfix:Feature Binary Source:No Signed-off-by: achao --- .../include/screen_scene_config.h | 4 + .../src/screen_cutout_controller.cpp | 2 +- .../src/screen_scene_config.cpp | 75 +++++++++++++------ .../src/screen_session_manager.cpp | 5 ++ .../unittest/screen_scene_config_test.cpp | 48 +++++++++++- 5 files changed, 109 insertions(+), 25 deletions(-) diff --git a/window_scene/session_manager/include/screen_scene_config.h b/window_scene/session_manager/include/screen_scene_config.h index 17b37b60f..f394faa32 100644 --- a/window_scene/session_manager/include/screen_scene_config.h +++ b/window_scene/session_manager/include/screen_scene_config.h @@ -35,17 +35,21 @@ public: static const std::map& GetStringConfig(); static void DumpConfig(); static std::vector GetCutoutBoundaryRect(uint64_t displayId); + static std::vector GetSubCutoutBoundaryRect(); static void SetCutoutSvgPath(uint64_t displayId, const std::string& svgPath); + static void SetSubCutoutSvgPath(const std::string& svgPath); static bool IsWaterfallDisplay(); static void SetCurvedCompressionAreaInLandscape(); static std::vector GetCurvedScreenBoundaryConfig(); static uint32_t GetCurvedCompressionAreaInLandscape(); private: + static std::map xmlNodeMap_; static std::map enableConfig_; static std::map> intNumbersConfig_; static std::map stringConfig_; static std::map> cutoutBoundaryRectMap_; + static std::vector subCutoutBoundaryRect_; static bool isWaterfallDisplay_; static bool isScreenCompressionEnableInLandscape_; static uint32_t curvedAreaInLandscape_; diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index 01d9fcc87..4e94e61f4 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -60,7 +60,7 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& std::vector displayBoundaryRects; if (ScreenSessionManager::GetInstance().IsFoldable() && (ScreenSessionManager::GetInstance().GetFoldStatus() == FoldStatus::FOLDED)) { - displayBoundaryRects = {{ 507, 18, 66, 66}}; // x:507, y:18, w:66, h:66 + displayBoundaryRects = ScreenSceneConfig::GetSubCutoutBoundaryRect(); } else { displayBoundaryRects = ScreenSceneConfig::GetCutoutBoundaryRect(displayId); } diff --git a/window_scene/session_manager/src/screen_scene_config.cpp b/window_scene/session_manager/src/screen_scene_config.cpp index 47aa7455c..7aa4a621b 100644 --- a/window_scene/session_manager/src/screen_scene_config.cpp +++ b/window_scene/session_manager/src/screen_scene_config.cpp @@ -34,20 +34,40 @@ namespace OHOS::Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DMS_SCREEN_SESSION_MANAGER, "ScreenSceneConfig"}; -constexpr char IS_WATERFALL_DISPLAY[] = "isWaterfallDisplay"; -constexpr char CURVED_SCREEN_BOUNDARY[] = "curvedScreenBoundary"; -constexpr char CURVED_AREA_IN_LANDSCAPE[] = "waterfallAreaCompressionSizeWhenHorzontal"; -constexpr char IS_CURVED_COMPRESS_ENABLED[] = "isWaterfallAreaCompressionEnableWhenHorizontal"; constexpr uint32_t NO_WATERFALL_DISPLAY_COMPRESSION_SIZE = 0; +enum XmlNodeElement { + DPI = 0, + IS_WATERFALL_DISPLAY, + CURVED_SCREEN_BOUNDARY, + CURVED_AREA_IN_LANDSCAPE, + IS_CURVED_COMPRESS_ENABLED, + BUILD_IN_DEFAULT_ORIENTATION, + DEFAULT_DEVICE_ROTATION_OFFSET, + DEFAULT_DISPLAY_CUTOUT_PATH, + SUB_DISPLAY_CUTOUT_PATH +}; } std::map ScreenSceneConfig::enableConfig_; std::map> ScreenSceneConfig::intNumbersConfig_; std::map ScreenSceneConfig::stringConfig_; std::map> ScreenSceneConfig::cutoutBoundaryRectMap_; +std::vector ScreenSceneConfig::subCutoutBoundaryRect_; bool ScreenSceneConfig::isWaterfallDisplay_ = false; bool ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false; uint32_t ScreenSceneConfig::curvedAreaInLandscape_ = 0; +std::map ScreenSceneConfig::xmlNodeMap_ = { + {DPI, "dpi"}, + {IS_WATERFALL_DISPLAY, "isWaterfallDisplay"}, + {CURVED_SCREEN_BOUNDARY, "curvedScreenBoundary"}, + {CURVED_AREA_IN_LANDSCAPE, "waterfallAreaCompressionSizeWhenHorzontal"}, + {IS_CURVED_COMPRESS_ENABLED, "isWaterfallAreaCompressionEnableWhenHorizontal"}, + {BUILD_IN_DEFAULT_ORIENTATION, "buildInDefaultOrientation"}, + {DEFAULT_DEVICE_ROTATION_OFFSET, "defaultDeviceRotationOffset"}, + {DEFAULT_DISPLAY_CUTOUT_PATH, "defaultDisplayCutoutPath"}, + {SUB_DISPLAY_CUTOUT_PATH, "subDisplayCutoutPath"} +}; + std::vector ScreenSceneConfig::Split(std::string str, std::string pattern) { @@ -118,23 +138,21 @@ bool ScreenSceneConfig::LoadConfigXml() continue; } - auto nodeName = curNodePtr->name; - if (!xmlStrcmp(nodeName, reinterpret_cast(IS_WATERFALL_DISPLAY)) || - !xmlStrcmp(nodeName, reinterpret_cast(IS_CURVED_COMPRESS_ENABLED))) { + std::string nodeName(reinterpret_cast(curNodePtr->name)); + if ((xmlNodeMap_[IS_WATERFALL_DISPLAY] == nodeName) || + (xmlNodeMap_[IS_CURVED_COMPRESS_ENABLED] == nodeName)) { ReadEnableConfigInfo(curNodePtr); - continue; - } - if (!xmlStrcmp(nodeName, reinterpret_cast("dpi")) || - !xmlStrcmp(nodeName, reinterpret_cast("defaultDeviceRotationOffset")) || - !xmlStrcmp(nodeName, reinterpret_cast(CURVED_SCREEN_BOUNDARY)) || - !xmlStrcmp(nodeName, reinterpret_cast(CURVED_AREA_IN_LANDSCAPE)) || - !xmlStrcmp(nodeName, reinterpret_cast("buildInDefaultOrientation"))) { + } else if ((xmlNodeMap_[DPI] == nodeName) || + (xmlNodeMap_[CURVED_SCREEN_BOUNDARY] == nodeName) || + (xmlNodeMap_[CURVED_AREA_IN_LANDSCAPE] == nodeName) || + (xmlNodeMap_[BUILD_IN_DEFAULT_ORIENTATION] == nodeName) || + (xmlNodeMap_[DEFAULT_DEVICE_ROTATION_OFFSET] == nodeName)) { ReadIntNumbersConfigInfo(curNodePtr); - continue; - } - if (!xmlStrcmp(nodeName, reinterpret_cast("defaultDisplayCutoutPath"))) { + } else if ((xmlNodeMap_[DEFAULT_DISPLAY_CUTOUT_PATH] == nodeName) || + (xmlNodeMap_[SUB_DISPLAY_CUTOUT_PATH] == nodeName)) { ReadStringConfigInfo(curNodePtr); - continue; + } else { + WLOGFI("xml config node name is not match, nodeName:%{public}s", nodeName.c_str()); } } xmlFreeDoc(docPtr); @@ -189,9 +207,9 @@ void ScreenSceneConfig::ReadEnableConfigInfo(const xmlNodePtr& currNode) std::string nodeName = reinterpret_cast(currNode->name); if (!xmlStrcmp(enable, reinterpret_cast("true"))) { enableConfig_[nodeName] = true; - if (IS_WATERFALL_DISPLAY == nodeName) { + if (xmlNodeMap_[IS_WATERFALL_DISPLAY] == nodeName) { isWaterfallDisplay_ = true; - } else if (IS_CURVED_COMPRESS_ENABLED == nodeName) { + } else if (xmlNodeMap_[IS_CURVED_COMPRESS_ENABLED] == nodeName) { isScreenCompressionEnableInLandscape_ = true; } } else { @@ -251,6 +269,12 @@ void ScreenSceneConfig::SetCutoutSvgPath(uint64_t displayId, const std::string& cutoutBoundaryRectMap_[displayId].emplace_back(CalcCutoutBoundaryRect(svgPath)); } +void ScreenSceneConfig::SetSubCutoutSvgPath(const std::string& svgPath) +{ + subCutoutBoundaryRect_.clear(); + subCutoutBoundaryRect_.emplace_back(CalcCutoutBoundaryRect(svgPath)); +} + DMRect ScreenSceneConfig::CalcCutoutBoundaryRect(std::string svgPath) { DMRect emptyRect = { 0, 0, 0, 0 }; @@ -292,6 +316,11 @@ std::vector ScreenSceneConfig::GetCutoutBoundaryRect(uint64_t displayId) return cutoutBoundaryRectMap_[displayId]; } +std::vector ScreenSceneConfig::GetSubCutoutBoundaryRect() +{ + return subCutoutBoundaryRect_; +} + bool ScreenSceneConfig::IsWaterfallDisplay() { return isWaterfallDisplay_; @@ -299,8 +328,8 @@ bool ScreenSceneConfig::IsWaterfallDisplay() void ScreenSceneConfig::SetCurvedCompressionAreaInLandscape() { - if (intNumbersConfig_[CURVED_AREA_IN_LANDSCAPE].size() > 0) { - curvedAreaInLandscape_ = static_cast(intNumbersConfig_[CURVED_AREA_IN_LANDSCAPE][0]); + if (intNumbersConfig_[xmlNodeMap_[CURVED_AREA_IN_LANDSCAPE]].size() > 0) { + curvedAreaInLandscape_ = static_cast(intNumbersConfig_[xmlNodeMap_[CURVED_AREA_IN_LANDSCAPE]][0]); } else { WLOGFW("waterfallAreaCompressionSizeWhenHorzontal value is not exist"); } @@ -308,7 +337,7 @@ void ScreenSceneConfig::SetCurvedCompressionAreaInLandscape() std::vector ScreenSceneConfig::GetCurvedScreenBoundaryConfig() { - return intNumbersConfig_[CURVED_SCREEN_BOUNDARY]; + return intNumbersConfig_[xmlNodeMap_[CURVED_SCREEN_BOUNDARY]]; } uint32_t ScreenSceneConfig::GetCurvedCompressionAreaInLandscape() diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 2e32c3799..b211cbab1 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -263,6 +263,11 @@ void ScreenSessionManager::ConfigureScreenScene() WLOGFD("defaultDisplayCutoutPath = %{public}s.", defaultDisplayCutoutPath.c_str()); ScreenSceneConfig::SetCutoutSvgPath(GetDefaultScreenId(), defaultDisplayCutoutPath); } + if (stringConfig.count("subDisplayCutoutPath") != 0) { + std::string subDisplayCutoutPath = static_cast(stringConfig["subDisplayCutoutPath"]); + WLOGFD("subDisplayCutoutPath = %{public}s.", subDisplayCutoutPath.c_str()); + ScreenSceneConfig::SetSubCutoutSvgPath(subDisplayCutoutPath); + } ConfigureWaterfallDisplayCompressionParams(); if (numbersConfig.count("buildInDefaultOrientation") != 0) { diff --git a/window_scene/test/unittest/screen_scene_config_test.cpp b/window_scene/test/unittest/screen_scene_config_test.cpp index e33697d41..f6bc2d17d 100644 --- a/window_scene/test/unittest/screen_scene_config_test.cpp +++ b/window_scene/test/unittest/screen_scene_config_test.cpp @@ -246,7 +246,11 @@ HWTEST_F(ScreenSceneConfigTest, ReadStringConfigInfo, Function | SmallTest | Lev readCount++; continue; } - + if (!xmlStrcmp(nodeName, reinterpret_cast("subDisplayCutoutPath"))) { + ScreenSceneConfig::ReadStringConfigInfo(curNodePtr); + readCount++; + continue; + } if (!xmlStrcmp(nodeName, reinterpret_cast("dpi"))) { ScreenSceneConfig::ReadStringConfigInfo(curNodePtr); readCount++; @@ -315,6 +319,17 @@ HWTEST_F(ScreenSceneConfigTest, GetCutoutBoundaryRect, Function | SmallTest | Le ASSERT_FALSE(result.size() > 0); } +/** + * @tc.name: GetSubCutoutBoundaryRect + * @tc.desc: GetSubCutoutBoundaryRect func + * @tc.type: FUNC + */ +HWTEST_F(ScreenSceneConfigTest, GetSubCutoutBoundaryRect, Function | SmallTest | Level3) +{ + auto result = ScreenSceneConfig::GetSubCutoutBoundaryRect(); + ASSERT_TRUE(result.size() > 0); +} + /** * @tc.name: IsWaterfallDisplay * @tc.desc: IsWaterfallDisplay func @@ -375,6 +390,37 @@ HWTEST_F(ScreenSceneConfigTest, SetCutoutSvgPath, Function | SmallTest | Level3) ASSERT_NE(0, result_.size()); } +/** + * @tc.name: SetSubCutoutSvgPath + * @tc.desc: SetSubCutoutSvgPath func + * @tc.type: FUNC + */ +HWTEST_F(ScreenSceneConfigTest, SetSubCutoutSvgPath, Function | SmallTest | Level3) +{ + ScreenSceneConfig::SetSubCutoutSvgPath("oo"); + auto result = ScreenSceneConfig::GetSubCutoutBoundaryRect(); + ASSERT_NE(0, result.size()); +} + +/** + * @tc.name: SetSubCutoutSvgPath01 + * @tc.desc: SetSubCutoutSvgPath func + * @tc.type: FUNC + */ +HWTEST_F(ScreenSceneConfigTest, SetSubCutoutSvgPath01, Function | SmallTest | Level3) +{ + ScreenSceneConfig::SetSubCutoutSvgPath("M507 18 L573 18 v 66 h -66 Z"); + std::vector result = ScreenSceneConfig::GetSubCutoutBoundaryRect(); + if (result.size() <= 0) { + ASSERT_EQ(0, result.size()); + } + DMRect targetRect{507, 18, 66, 66}; // the rect size after svg parsing + EXPECT_EQ(result[0].posX_, targetRect.posX_); + EXPECT_EQ(result[0].posY_, targetRect.posY_); + EXPECT_EQ(result[0].width_, targetRect.width_); + EXPECT_EQ(result[0].height_, targetRect.height_); +} + /** * @tc.name: SetCurvedCompressionAreaInLandscape * @tc.desc: SetCurvedCompressionAreaInLandscape func -- Gitee From 93e73d0e73557c67dc0dac9411934baeaf8dc27c Mon Sep 17 00:00:00 2001 From: lijie176 Date: Thu, 28 Mar 2024 22:38:27 +0800 Subject: [PATCH 253/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lijie176 --- .../container/include/window_event_channel.h | 3 +- .../container/src/window_event_channel.cpp | 9 ++-- .../session/host/include/extension_session.h | 7 +-- .../session/host/src/extension_session.cpp | 11 ++--- .../test/unittest/extension_session_test.cpp | 44 +++++++++---------- 5 files changed, 34 insertions(+), 40 deletions(-) diff --git a/window_scene/session/container/include/window_event_channel.h b/window_scene/session/container/include/window_event_channel.h index 13317b31b..5eca0bcdb 100644 --- a/window_scene/session/container/include/window_event_channel.h +++ b/window_scene/session/container/include/window_event_channel.h @@ -20,8 +20,8 @@ #include #include -#include "iremote_proxy.h" #include "accessibility_element_info.h" +#include "iremote_proxy.h" #include "interfaces/include/ws_common.h" #include "session/container/include/zidl/session_stage_interface.h" @@ -35,6 +35,7 @@ public: virtual ~WindowEventChannelListenerProxy() = default; void OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) override; + private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/session/container/src/window_event_channel.cpp b/window_scene/session/container/src/window_event_channel.cpp index 243568071..d4b341ccb 100644 --- a/window_scene/session/container/src/window_event_channel.cpp +++ b/window_scene/session/container/src/window_event_channel.cpp @@ -54,7 +54,6 @@ void WindowEventChannelListenerProxy::OnTransferKeyEventForConsumed(bool isConsu WindowEventChannelListenerMessage::TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC), data, reply, option) != ERR_NONE) { TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed"); - return; } } @@ -135,15 +134,15 @@ WSError WindowEventChannel::TransferKeyEventForConsumedAsync( { bool isConsumed = false; auto ret = TransferKeyEventForConsumed(keyEvent, isConsumed, isPreImeEvent); - auto wecListener = iface_cast(listener); - if (wecListener == nullptr) { + auto channelListener = iface_cast(listener); + if (channelListener == nullptr) { TLOGE(WmsLogTag::WMS_EVENT, "listener is null."); return ret; } - TLOGD(WmsLogTag::WMS_EVENT, "TransferKeyEventForConsumedAsync finished with isConsumed:%{public}d ret:%{public}d", + TLOGD(WmsLogTag::WMS_EVENT, "finished with isConsumed:%{public}d ret:%{public}d", isConsumed, ret); - wecListener->OnTransferKeyEventForConsumed(isConsumed, ret); + channelListener->OnTransferKeyEventForConsumed(isConsumed, ret); return ret; } diff --git a/window_scene/session/host/include/extension_session.h b/window_scene/session/host/include/extension_session.h index 838551afd..a3438feb5 100644 --- a/window_scene/session/host/include/extension_session.h +++ b/window_scene/session/host/include/extension_session.h @@ -26,11 +26,12 @@ namespace OHOS::Rosen { class WindowEventChannelListener : public IRemoteStub { public: explicit WindowEventChannelListener() = default; - void SetTransferKeyEventForConsumedParams(std::shared_ptr>& isConsumedPromise, - std::shared_ptr& retCode); + void SetTransferKeyEventForConsumedParams(const std::shared_ptr>& isConsumedPromise, + const std::shared_ptr& retCode); void ResetTransferKeyEventForConsumedParams(); void OnTransferKeyEventForConsumed(bool isConsumed, WSError retCode) override; - int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; + private: std::mutex transferKeyEventForConsumedMutex_; std::shared_ptr> isConsumedPromise_; diff --git a/window_scene/session/host/src/extension_session.cpp b/window_scene/session/host/src/extension_session.cpp index 21d12226b..e327486b0 100644 --- a/window_scene/session/host/src/extension_session.cpp +++ b/window_scene/session/host/src/extension_session.cpp @@ -26,7 +26,7 @@ constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "Extens } // namespace void WindowEventChannelListener::SetTransferKeyEventForConsumedParams( - std::shared_ptr>& isConsumedPromise, std::shared_ptr& retCode) + const std::shared_ptr>& isConsumedPromise, const std::shared_ptr& retCode) { std::lock_guard lock(transferKeyEventForConsumedMutex_); isConsumedPromise_ = isConsumedPromise; @@ -51,8 +51,8 @@ void WindowEventChannelListener::OnTransferKeyEventForConsumed(bool isConsumed, *retCode_ = retCode; } -int32_t WindowEventChannelListener::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) +int32_t WindowEventChannelListener::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, + MessageOption& option) { if (data.ReadInterfaceToken() != GetDescriptor()) { TLOGE(WmsLogTag::WMS_EVENT, "InterfaceToken check failed"); @@ -199,7 +199,6 @@ WSError ExtensionSession::TransferKeyEventForConsumed(const std::shared_ptrSetTransferKeyEventForConsumedParams(isConsumedPromise, retCode); auto ret = windowEventChannel_->TransferKeyEventForConsumedAsync(keyEvent, isPreImeEvent, listener); @@ -214,9 +213,7 @@ WSError ExtensionSession::TransferKeyEventForConsumed(const std::shared_ptrGetId()); diff --git a/window_scene/test/unittest/extension_session_test.cpp b/window_scene/test/unittest/extension_session_test.cpp index 946c3518e..c65fab6c9 100644 --- a/window_scene/test/unittest/extension_session_test.cpp +++ b/window_scene/test/unittest/extension_session_test.cpp @@ -261,18 +261,18 @@ HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed01, Function | SmallTe SessionInfo info; info.abilityName_ = "SetBrightness"; info.bundleName_ = "SetBrightness1"; - ExtensionSession extensionSession_(info); - ASSERT_NE(extensionSession_, nullptr); + ExtensionSession extensionSession(info); + ASSERT_NE(extensionSession, nullptr); sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); sptr mockEventChannel = new (std::nothrow) WindowEventChannelMocker(mockSessionStage); - extensionSession_.windowEventChannel_ = mockEventChannel; + extensionSession.windowEventChannel_ = mockEventChannel; EXPECT_CALL(*mockEventChannel, TransferKeyEventForConsumedAsync) .WillOnce([](const std::shared_ptr &keyEvent, - bool isPreImeEvent, - const sptr &listener) { - auto wecListener = iface_cast(listener); - wecListener->OnTransferKeyEventForConsumed(true, WSError::WS_OK); + bool isPreImeEvent, + const sptr &listener) { + auto channelListener = iface_cast(listener); + channelListener->OnTransferKeyEventForConsumed(true, WSError::WS_OK); return WSError::WS_OK; }); @@ -281,8 +281,7 @@ HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed01, Function | SmallTe bool isConsumed = false; bool isTimeout = false; bool isPreImeEvent = false; - - WSError result = extensionSession_.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); + WSError result = extensionSession.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); ASSERT_EQ(result, WSError::WS_OK); ASSERT_EQ(isTimeout, false); } @@ -297,12 +296,12 @@ HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed02, Function | SmallTe SessionInfo info; info.abilityName_ = "SetBrightness"; info.bundleName_ = "SetBrightness1"; - ExtensionSession extensionSession_(info); - ASSERT_NE(extensionSession_, nullptr); + ExtensionSession extensionSession(info); + ASSERT_NE(extensionSession, nullptr); sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); sptr mockEventChannel = new (std::nothrow) WindowEventChannelMocker(mockSessionStage); - extensionSession_.windowEventChannel_ = mockEventChannel; + extensionSession.windowEventChannel_ = mockEventChannel; EXPECT_CALL(*mockEventChannel, TransferKeyEventForConsumedAsync); auto keyEvent = MMI::KeyEvent::Create(); @@ -310,8 +309,7 @@ HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed02, Function | SmallTe bool isConsumed = false; bool isTimeout = false; bool isPreImeEvent = false; - - WSError result = extensionSession_.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); + WSError result = extensionSession.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); ASSERT_EQ(result, WSError::WS_OK); ASSERT_EQ(isTimeout, true); } @@ -326,16 +324,15 @@ HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed03, Function | SmallTe SessionInfo info; info.abilityName_ = "SetBrightness"; info.bundleName_ = "SetBrightness1"; - ExtensionSession extensionSession_(info); - ASSERT_NE(extensionSession_, nullptr); + ExtensionSession extensionSession(info); + ASSERT_NE(extensionSession, nullptr); auto keyEvent = MMI::KeyEvent::Create(); ASSERT_NE(keyEvent, nullptr); bool isConsumed = false; bool isTimeout = false; bool isPreImeEvent = false; - - WSError result = extensionSession_.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); + WSError result = extensionSession.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); } @@ -349,19 +346,18 @@ HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed04, Function | SmallTe SessionInfo info; info.abilityName_ = "SetBrightness"; info.bundleName_ = "SetBrightness1"; - ExtensionSession extensionSession_(info); - ASSERT_NE(extensionSession_, nullptr); + ExtensionSession extensionSession(info); + ASSERT_NE(extensionSession, nullptr); sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); sptr mockEventChannel = new (std::nothrow) WindowEventChannelMocker(mockSessionStage); - extensionSession_.windowEventChannel_ = mockEventChannel; + extensionSession.windowEventChannel_ = mockEventChannel; auto keyEvent = nullptr; bool isConsumed = false; bool isTimeout = false; bool isPreImeEvent = false; - - WSError result = extensionSession_.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); + WSError result = extensionSession.TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR); } @@ -379,7 +375,7 @@ HWTEST_F(ExtensionSessionTest, WindowEventChannelListenerOnRemoteRequest01, Func data.WriteBool(true); data.WriteInt32(0); uint32_t code = static_cast(IWindowEventChannelListener::WindowEventChannelListenerMessage:: - TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC); + TRANS_ID_ON_TRANSFER_KEY_EVENT_FOR_CONSUMED_ASYNC); WindowEventChannelListener listener; ASSERT_EQ(listener.OnRemoteRequest(code, data, reply, option), 0); } -- Gitee From d7479b3844ed54cddd25ceca48f8baf57ad7d928 Mon Sep 17 00:00:00 2001 From: huangji731 Date: Thu, 28 Mar 2024 17:58:34 +0800 Subject: [PATCH 254/385] https://gitee.com/openharmony/window_window_manager/issues/I9CGBZ Signed-off-by: huangji731 --- dm/test/unittest/screen_manager_test.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/dm/test/unittest/screen_manager_test.cpp b/dm/test/unittest/screen_manager_test.cpp index 6d59bdcbb..1475d40cc 100644 --- a/dm/test/unittest/screen_manager_test.cpp +++ b/dm/test/unittest/screen_manager_test.cpp @@ -512,7 +512,7 @@ HWTEST_F(ScreenManagerTest, RegisterVirtualScreenGroupListener02, Function | Sma /** * @tc.name: SetVirtualScreenFlag01 - * @tc.desc: SetVirtualScreenFlag01 fun + * @tc.desc: SetVirtualScreenFlag01 cast flag * @tc.type: FUNC */ HWTEST_F(ScreenManagerTest, SetVirtualScreenFlag01, Function | SmallTest | Level1) @@ -528,7 +528,7 @@ HWTEST_F(ScreenManagerTest, SetVirtualScreenFlag01, Function | SmallTest | Level /** * @tc.name: SetVirtualScreenFlag02 - * @tc.desc: SetVirtualScreenFlag02 fun + * @tc.desc: SetVirtualScreenFlag02 max flag * @tc.type: FUNC */ HWTEST_F(ScreenManagerTest, SetVirtualScreenFlag02, Function | SmallTest | Level1) @@ -542,6 +542,24 @@ HWTEST_F(ScreenManagerTest, SetVirtualScreenFlag02, Function | SmallTest | Level ASSERT_EQ(DMError::DM_OK, ret); } +/** + * @tc.name: GetVirtualScreenFlag01 + * @tc.desc: GetVirtualScreenFlag01 get cast + * @tc.type: FUNC + */ +HWTEST_F(ScreenManagerTest, GetVirtualScreenFlag01, Function | SmallTest | Level1) +{ + VirtualScreenOption defaultOption = {defaultName_, defaultWidth_, defaultHeight_, + defaultDensity_, nullptr, defaultFlags_}; + ScreenId screenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption); + DMError ret = ScreenManager::GetInstance().SetVirtualScreenFlag(screenId, VirtualScreenFlag::CAST); + ASSERT_EQ(DMError::DM_OK, ret); + VirtualScreenFlag screenFlag = ScreenManager::GetInstance().GetVirtualScreenFlag(screenId); + ASSERT_EQ(VirtualScreenFlag::CAST, screenFlag); + ret = ScreenManager::GetInstance().DestroyVirtualScreen(screenId); + ASSERT_EQ(DMError::DM_OK, ret); +} + /** * @tc.name: SetVirtualMirrorScreenScaleMode01 * @tc.desc: SetVirtualMirrorScreenScaleMode01 fun -- Gitee From 3c56b91386671bd2d05cba5daf799a50f3d4fd3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Fri, 29 Mar 2024 09:46:23 +0800 Subject: [PATCH 255/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- wm/src/window_scene_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 8b1f0de70..163c89f3b 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2811,7 +2811,7 @@ std::unique_ptr WindowSceneSessionImpl::HandleWindowMask( Media::InitializationOptions opts; opts.size.width = maskWidth; opts.size.height = maskHeight; - opts.pixelFormat = Media::PixelFormat::RGBA_8888; + opts.pixelFormat = Media::PixelFormat::ALPHA_8; opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE; opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE; uint32_t length = maskWidth * maskHeight; -- Gitee From 19c12e46adc780e925ad93fb6158109e8b37a900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Fri, 29 Mar 2024 15:08:23 +0800 Subject: [PATCH 256/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../session_manager/src/scene_session_dirty_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 6b0b519b2..58e123844 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -423,7 +423,7 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr std::vector touchHotAreas; std::vector pointerHotAreas; UpdateHotAreas(sceneSession, touchHotAreas, pointerHotAreas); - auto windowMask = sceneSession->GetSessionProperty()->GetWindowMask().GetRefPtr(); + auto pixelMap = sceneSession->GetSessionProperty()->GetWindowMask().GetRefPtr(); MMI::WindowInfo windowInfo = { .id = windowId, .pid = sceneSession->IsStartMoving() ? static_cast(getpid()) : pid, @@ -438,7 +438,7 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr .pointerChangeAreas = pointerChangeAreas, .zOrder = zOrder, .transform = transformData, - .windowMask = windowMask + .pixelMap = pixelMap }; return windowInfo; } -- Gitee From 492b1d72edf8a35736b73db5fb8c3f65a4fecef1 Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Fri, 29 Mar 2024 07:23:19 +0000 Subject: [PATCH 257/385] update interfaces/kits/napi/window_runtime/window_napi/js_window.cpp. Signed-off-by: chengyiyi --- .../window_runtime/window_napi/js_window.cpp | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 827c21bba..260200b7d 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -4809,36 +4809,40 @@ napi_value JsWindow::OnSetHandwritingFlag(napi_env env, napi_callback_info info) bool isAddFlag = false; napi_get_value_bool(env, nativeBool, &isAddFlag); wptr weakToken(windowToken_); + std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); + NapiAsyncTask::ExecuteCallback execute = [weakToken, isAddFlag, errCodePtr] () { + if (errCodePtr == nullptr) { + return; + } + auto weakWindow = weakToken.promote(); + if (weakWindow == nullptr) { + *errCodePtr = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + return; + } + WMError ret = isAddFlag ? weakWindow->AddWindowFlag(WindowFlag::WINDOW_FLAG_HANDWRITING) : + weakWindow->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_HANDWRITING); + *errCodePtr = WM_JS_TO_ERROR_CODE_MAP.at(ret); + WLOGI("Window [%{public}u, %{public}s] set handwriting flag on end", + weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); + }; NapiAsyncTask::CompleteCallback complete = - [weakToken, isAddFlag](napi_env env, NapiAsyncTask& task, int32_t status) { - auto window = weakToken.promote(); - if (window == nullptr) { - task.Reject(env, - CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "OnSetHandwritingFlag failed.")); + [weakToken, isAddFlag, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCodePtr == nullptr) { + task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "System abnormal.")); return; } - WMError ret = WMError::WM_OK; - if (isAddFlag) { - ret = window->AddWindowFlag(WindowFlag::WINDOW_FLAG_HANDWRITING); - } else { - ret = window->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_HANDWRITING); - } - if (ret == WMError::WM_OK) { + if (*errCodePtr == WmErrorCode::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); } else { - task.Reject(env, CreateJsError(env, - static_cast(WM_JS_TO_ERROR_CODE_MAP.at(ret)), "SetHandwritingFlag failed.")); + task.Reject(env, CreateJsError(env, static_cast(*errCodePtr), "SetHandwritingFlag failed.")); } - WLOGI("[NAPI]Window [%{public}u, %{public}s] set handwriting flag end, ret = %{public}d", - window->GetWindowId(), window->GetWindowName().c_str(), ret); }; - napi_value lastParam = (argc == 1) ? nullptr : - (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); + napi_value lastParam = (argc == 1) ? nullptr : (GetType(env, argv[1]) == napi_function ? argv[1] : nullptr); napi_value result = nullptr; NapiAsyncTask::Schedule("JsWindow::OnSetHandwritingFlag", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result)); return result; } -- Gitee From d78d4d365c8e0f3b32ebb6b108e921435129394f Mon Sep 17 00:00:00 2001 From: liubo Date: Fri, 29 Mar 2024 15:36:09 +0800 Subject: [PATCH 258/385] =?UTF-8?q?Description:=20DMS=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E9=99=8D=E7=BA=A7=20IssueNo:https://gitee.com/openharmony/wind?= =?UTF-8?q?ow=5Fwindow=5Fmanager/issues/I9CP4X=20Feature=20or=20Bugfix:=20?= =?UTF-8?q?Bugfix=20Binary=20Source:No=20Signed-off-by:=20liubo419=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dm/src/display_manager.cpp | 4 ++-- dm/src/display_manager_adapter.cpp | 4 ++-- dm/src/screen_manager.cpp | 4 ++-- interfaces/kits/napi/display_runtime/js_display_manager.cpp | 2 +- .../session_manager/src/zidl/screen_session_manager_proxy.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dm/src/display_manager.cpp b/dm/src/display_manager.cpp index c28fcdca3..bd265c427 100644 --- a/dm/src/display_manager.cpp +++ b/dm/src/display_manager.cpp @@ -1142,7 +1142,7 @@ DMError DisplayManager::Impl::RegisterDisplayModeListener(sptr lock(mutex_); displayManagerListener_ = nullptr; displayStateAgent_ = nullptr; diff --git a/dm/src/display_manager_adapter.cpp b/dm/src/display_manager_adapter.cpp index 448b02921..ea16dee00 100644 --- a/dm/src/display_manager_adapter.cpp +++ b/dm/src/display_manager_adapter.cpp @@ -400,7 +400,7 @@ void DMSDeathRecipient::OnRemoteDied(const wptr& wptrDeath) WLOGFE("object is null"); return; } - WLOGFI("dms OnRemoteDied"); + WLOGFD("dms OnRemoteDied"); adapter_.Clear(); SingletonContainer::Get().OnRemoteDied(); SingletonContainer::Get().OnRemoteDied(); @@ -417,7 +417,7 @@ BaseAdapter::~BaseAdapter() void BaseAdapter::Clear() { - WLOGFI("BaseAdapter Clear!"); + WLOGFD("BaseAdapter Clear!"); std::lock_guard lock(mutex_); if ((displayManagerServiceProxy_ != nullptr) && (displayManagerServiceProxy_->AsObject() != nullptr)) { displayManagerServiceProxy_->AsObject()->RemoveDeathRecipient(dmsDeath_); diff --git a/dm/src/screen_manager.cpp b/dm/src/screen_manager.cpp index bea67ba9c..b1f33080b 100644 --- a/dm/src/screen_manager.cpp +++ b/dm/src/screen_manager.cpp @@ -639,7 +639,7 @@ bool ScreenManager::Impl::UpdateScreenInfoLocked(sptr screenInfo) return false; } ScreenId screenId = screenInfo->GetScreenId(); - WLOGFI("screenId:%{public}" PRIu64".", screenId); + WLOGFD("screenId:%{public}" PRIu64".", screenId); if (screenId == SCREEN_ID_INVALID) { WLOGFE("displayId is invalid."); return false; @@ -662,7 +662,7 @@ bool ScreenManager::Impl::isAllListenersRemoved() const void ScreenManager::Impl::OnRemoteDied() { - WLOGFI("dms is died"); + WLOGFD("dms is died"); std::lock_guard lock(mutex_); screenManagerListener_ = nullptr; virtualScreenAgent_ = nullptr; diff --git a/interfaces/kits/napi/display_runtime/js_display_manager.cpp b/interfaces/kits/napi/display_runtime/js_display_manager.cpp index 163cde95d..fc9a43731 100644 --- a/interfaces/kits/napi/display_runtime/js_display_manager.cpp +++ b/interfaces/kits/napi/display_runtime/js_display_manager.cpp @@ -45,7 +45,7 @@ explicit JsDisplayManager(napi_env env) { static void Finalizer(napi_env env, void* data, void* hint) { - WLOGI("Finalizer is called"); + WLOGD("Finalizer is called"); std::unique_ptr(static_cast(data)); } diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp index 65c2d0571..8de3b814c 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -1444,7 +1444,7 @@ sptr ScreenSessionManagerProxy::GetScreenInfoById(ScreenId screenId) return nullptr; } for (auto& mode : info->GetModes()) { - WLOGFI("info modes is id: %{public}u, width: %{public}u, height: %{public}u, refreshRate: %{public}u", + WLOGFD("info modes is id: %{public}u, width: %{public}u, height: %{public}u, refreshRate: %{public}u", mode->id_, mode->width_, mode->height_, mode->refreshRate_); } return info; -- Gitee From d4c036604f6c72a8464d69d9b634d5e500fcbc44 Mon Sep 17 00:00:00 2001 From: lilili Date: Thu, 28 Mar 2024 14:53:10 +0800 Subject: [PATCH 259/385] =?UTF-8?q?=E3=80=90=E7=89=B9=E6=80=A7=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E3=80=91=E5=8F=A0=E5=8A=A0=E5=9C=BA=E6=99=AF=E8=AF=86?= =?UTF-8?q?=E5=88=AB=EF=BC=9A=E4=B8=BB=E5=B1=8F=E7=9A=84=E5=88=86=E5=B1=8F?= =?UTF-8?q?/=E6=82=AC=E6=B5=AE=E7=AA=97=E5=9C=BA=E6=99=AF=E8=AF=86?= =?UTF-8?q?=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lilili --- interfaces/innerkits/wm/window_manager.h | 30 ++++++++ interfaces/innerkits/wm/wm_common.h | 10 +++ window_scene/session/host/include/session.h | 2 + window_scene/session/host/src/session.cpp | 13 ++++ .../include/scene_session_manager.h | 3 + .../session_manager_agent_controller.h | 1 + .../src/scene_session_manager.cpp | 47 ++++++++++++ .../src/session_manager_agent_controller.cpp | 12 +++ wm/include/window_manager_agent.h | 1 + .../zidl/window_manager_agent_interface.h | 5 +- wm/include/zidl/window_manager_agent_proxy.h | 1 + wm/src/window_manager.cpp | 75 +++++++++++++++++++ wm/src/window_manager_agent.cpp | 5 ++ wm/src/zidl/window_manager_agent_proxy.cpp | 22 ++++++ wm/src/zidl/window_manager_agent_stub.cpp | 5 ++ .../include/window_manager_agent_controller.h | 1 + .../src/window_manager_agent_controller.cpp | 8 ++ 17 files changed, 240 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/wm/window_manager.h b/interfaces/innerkits/wm/window_manager.h index 414e51230..d00125447 100644 --- a/interfaces/innerkits/wm/window_manager.h +++ b/interfaces/innerkits/wm/window_manager.h @@ -86,6 +86,21 @@ public: virtual void OnUnfocused(const sptr& focusChangeInfo) = 0; }; +/** + * @class IWindowModeChangedListener + * + * @brief Listener to observe window mode change. + */ +class IWindowModeChangedListener : virtual public RefBase { +public: + /** + * @brief Notify caller when window mode update. + * + * @param mode Window mode. + */ + virtual void OnWindowModeUpdate(WindowModeType mode) = 0; +}; + /** * @class ISystemBarChangedListener * @@ -279,6 +294,20 @@ public: * @return WM_OK means unregister success, others means unregister failed. */ WMError UnregisterFocusChangedListener(const sptr& listener); + /** + * @brief Register window mode listener. + * + * @param listener IWindowModeChangedListener. + * @return WM_OK means register success, others means register failed. + */ + WMError RegisterWindowModeChangedListener(const sptr& listener); + /** + * @brief Unregister window mode listener. + * + * @param listener IWindowModeChangedListener. + * @return WM_OK means unregister success, others means unregister failed. + */ + WMError UnregisterWindowModeChangedListener(const sptr& listener); /** * @brief Register system bar changed listener. * @@ -502,6 +531,7 @@ private: void UpdateFocusStatus(uint32_t windowId, const sptr& abilityToken, WindowType windowType, DisplayId displayId, bool focused) const; void UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) const; + void UpdateWindowModeTypeInfo(WindowModeType type) const; void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) const; void NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type) const; diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 349d904af..c55129f13 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -102,6 +102,16 @@ enum class WindowMode : uint32_t { WINDOW_MODE_PIP }; +/** + * @brief Enumerates modeType of window. + */ +enum class WindowModeType : uint8_t { + WINDOW_MODE_SPLIT_FLOATING = 0, + WINDOW_MODE_SPLIT = 1, + WINDOW_MODE_FLOATING = 2, + WINDOW_MODE_OTHER = 3 +}; + /** * @brief Enumerates mode supported of window. */ diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 42de8f666..fdac38507 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -379,6 +379,7 @@ public: bool IsSystemInput(); bool GetForegroundInteractiveStatus() const; virtual void SetForegroundInteractiveStatus(bool interactive); + void RegisterWindowModeChangedCallback(const std::function& callback); protected: class SessionLifeCycleTask : public virtual RefBase { @@ -537,6 +538,7 @@ private: std::shared_ptr handler_; std::shared_ptr mainHandler_; std::shared_ptr exportHandler_; + std::function windowModeCallback_; mutable std::shared_mutex propertyMutex_; sptr property_; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index d4141d5f3..e6657fb57 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1985,6 +1985,13 @@ void Session::NotifyUILostFocus() } } +void Session::RegisterWindowModeChangedCallback(const std::function& callback) +{ + if (callback != nullptr) { + windowModeCallback_ = callback; + } +} + void Session::PresentFoucusIfNeed(int32_t pointerAction) { WLOGFD("OnClick down, id: %{public}d", GetPersistentId()); @@ -2056,11 +2063,17 @@ WSError Session::UpdateWindowMode(WindowMode mode) } else if (state_ == SessionState::STATE_DISCONNECT) { property_->SetWindowMode(mode); property_->SetIsNeedUpdateWindowMode(true); + if (windowModeCallback_) { + windowModeCallback_(); + } } else { property_->SetWindowMode(mode); if (mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || mode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) { property_->SetMaximizeMode(MaximizeMode::MODE_RECOVER); } + if (windowModeCallback_) { + windowModeCallback_(); + } return sessionStage_->UpdateWindowMode(mode); } return WSError::WS_OK; diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 48e6660d9..d4cf8b6fc 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -490,6 +490,7 @@ private: bool isAINavigationBarVisible_ = false; std::shared_mutex currAINavigationBarAreaMapMutex_; std::map currAINavigationBarAreaMap_; + WindowModeType lastWindowModeType_ { WindowModeType::WINDOW_MODE_OTHER }; std::shared_ptr eventLoop_; std::shared_ptr eventHandler_; @@ -564,6 +565,8 @@ private: WSError HandleSecureSessionShouldHide(const sptr& sceneSession); WSError HandleSecureExtSessionShouldHide(int32_t persistentId, bool shouldHide); void HandleCastScreenDisConnection(const sptr sceneSession); + void ProcessSplitFloating(); + void NotifyRSSWindowModeTypeUpdate(bool inSplit, bool inFloating); }; } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/include/session_manager_agent_controller.h b/window_scene/session_manager/include/session_manager_agent_controller.h index 35372bff7..d8de9ff87 100644 --- a/window_scene/session_manager/include/session_manager_agent_controller.h +++ b/window_scene/session_manager/include/session_manager_agent_controller.h @@ -35,6 +35,7 @@ public: void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); void UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused); + void UpdateWindowModeTypeInfo(WindowModeType type); void NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type); void NotifyWaterMarkFlagChangedResult(bool hasWaterMark); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c16746acd..cc54dc183 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1018,6 +1018,10 @@ sptr SceneSessionManager::RequestSceneSession(const SessionInfo& s sessionInfo.screenId_); } sceneSession->SetEventHandler(taskScheduler_->GetEventHandler(), eventHandler_); + auto windowModeCallback = [this]() { + ProcessSplitFloating(); + }; + sceneSession->RegisterWindowModeChangedCallback(windowModeCallback); if (sessionInfo.isSystem_) { sceneSession->SetCallingPid(IPCSkeleton::GetCallingRealPid()); sceneSession->SetCallingUid(IPCSkeleton::GetCallingUid()); @@ -4258,6 +4262,49 @@ __attribute__((no_sanitize("cfi"))) void SceneSessionManager::OnSessionStateChan default: break; } + ProcessSplitFloating(); +} + +void SceneSessionManager::ProcessSplitFloating() +{ + bool inSplit = false; + bool inFloating = false; + for (const auto& session : sceneSessionMap_) { + if (session.second == nullptr || !Rosen::SceneSessionManager::GetInstance().IsSessionVisible(session.second)) { + continue; + } + auto mode = session.second->GetWindowMode(); + if (mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || mode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) { + inSplit = true; + } + if (mode == WindowMode::WINDOW_MODE_FLOATING) { + inFloating = true; + } + } + NotifyRSSWindowModeTypeUpdate(inSplit, inFloating); +} + +void SceneSessionManager::NotifyRSSWindowModeTypeUpdate(bool inSplit, bool inFloating) +{ + WindowModeType type; + if (inSplit) { + if (inFloating) { + type = WindowModeType::WINDOW_MODE_SPLIT_FLOATING; + } else { + type = WindowModeType::WINDOW_MODE_SPLIT; + } + } else { + if (inFloating) { + type = WindowModeType::WINDOW_MODE_FLOATING; + } else { + type = WindowModeType::WINDOW_MODE_OTHER; + } + } + if (lastWindowModeType_ == type) { + return; + } + lastWindowModeType_ = type; + SessionManagerAgentController::GetInstance().UpdateWindowModeTypeInfo(type); } void SceneSessionManager::ProcessSubSessionForeground(sptr& sceneSession) diff --git a/window_scene/session_manager/src/session_manager_agent_controller.cpp b/window_scene/session_manager/src/session_manager_agent_controller.cpp index 59d9723f5..c6e0e6358 100644 --- a/window_scene/session_manager/src/session_manager_agent_controller.cpp +++ b/window_scene/session_manager/src/session_manager_agent_controller.cpp @@ -58,6 +58,18 @@ void SessionManagerAgentController::UpdateFocusChangeInfo(const sptr(type)); + for (auto& agent : smAgentContainer_.GetAgentsByType( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE)) { + if (agent != nullptr) { + agent->UpdateWindowModeTypeInfo(type); + } + } +} + void SessionManagerAgentController::NotifyAccessibilityWindowInfo( const std::vector>& infos, WindowUpdateType type) { diff --git a/wm/include/window_manager_agent.h b/wm/include/window_manager_agent.h index 95e75371f..081838634 100644 --- a/wm/include/window_manager_agent.h +++ b/wm/include/window_manager_agent.h @@ -31,6 +31,7 @@ public: void NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type) override; void UpdateWindowVisibilityInfo(const std::vector>& visibilityInfos) override; + void UpdateWindowModeTypeInfo(WindowModeType type) override; void UpdateWindowDrawingContentInfo( const std::vector>& windowDrawingContentInfos) override; void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override; diff --git a/wm/include/zidl/window_manager_agent_interface.h b/wm/include/zidl/window_manager_agent_interface.h index 1345231f3..c0660cb57 100644 --- a/wm/include/zidl/window_manager_agent_interface.h +++ b/wm/include/zidl/window_manager_agent_interface.h @@ -31,6 +31,7 @@ enum class WindowManagerAgentType : uint32_t { WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT, WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG, WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED, + WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE, }; class IWindowManagerAgent : public IRemoteBroker { @@ -38,7 +39,7 @@ public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowManagerAgent"); enum class WindowManagerAgentMsg : uint32_t { - TRANS_ID_UPDATE_FOCUS = 1, + TRANS_ID_UPDATE_FOCUS = 1, TRANS_ID_UPDATE_SYSTEM_BAR_PROPS, TRANS_ID_UPDATE_WINDOW_STATUS, TRANS_ID_UPDATE_WINDOW_VISIBILITY, @@ -46,9 +47,11 @@ public: TRANS_ID_UPDATE_CAMERA_FLOAT, TRANS_ID_UPDATE_WATER_MARK_FLAG, TRANS_ID_UPDATE_GESTURE_NAVIGATION_ENABLED, + TRANS_ID_UPDATE_WINDOW_MODE_TYPE, }; virtual void UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) = 0; + virtual void UpdateWindowModeTypeInfo(WindowModeType type) = 0; virtual void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) = 0; virtual void NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type) = 0; diff --git a/wm/include/zidl/window_manager_agent_proxy.h b/wm/include/zidl/window_manager_agent_proxy.h index 0a8c5866a..59f880c85 100644 --- a/wm/include/zidl/window_manager_agent_proxy.h +++ b/wm/include/zidl/window_manager_agent_proxy.h @@ -32,6 +32,7 @@ public: void NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type) override; void UpdateWindowVisibilityInfo(const std::vector>& visibilityInfos) override; + void UpdateWindowModeTypeInfo(WindowModeType type) override; void UpdateWindowDrawingContentInfo( const std::vector>& windowDrawingContentInfos) override; void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override; diff --git a/wm/src/window_manager.cpp b/wm/src/window_manager.cpp index 5e52ee801..6f809f896 100644 --- a/wm/src/window_manager.cpp +++ b/wm/src/window_manager.cpp @@ -50,6 +50,7 @@ public: void NotifyUnfocused(uint32_t windowId, const sptr& abilityToken, WindowType windowType, DisplayId displayId); void NotifyFocused(const sptr& focusChangeInfo); + void NotifyWindowModeChange(WindowModeType type); void NotifyUnfocused(const sptr& focusChangeInfo); void NotifySystemBarChanged(DisplayId displayId, const SystemBarRegionTints& tints); void NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type); @@ -66,6 +67,8 @@ public: sptr wmsConnectionChangedListener_; std::vector> focusChangedListeners_; sptr focusChangedListenerAgent_; + std::vector> windowModeListeners_; + sptr windowModeListenerAgent_; std::vector> systemBarChangedListeners_; sptr systemBarChangedListenerAgent_; std::vector> windowUpdateListeners_; @@ -138,6 +141,20 @@ void WindowManager::Impl::NotifyUnfocused(const sptr& focusChan } } +void WindowManager::Impl::NotifyWindowModeChange(WindowModeType type) +{ + TLOGI(WmsLogTag::WMS_MAIN, "WindowManager::Impl UpdateWindowModeTypeInfo type: %{public}d", + static_cast(type)); + std::vector> windowModeListeners; + { + std::lock_guard lock(mutex_); + windowModeListeners = windowModeListeners_; + } + for (auto &listener : windowModeListeners) { + listener->OnWindowModeUpdate(type); + } +} + void WindowManager::Impl::NotifySystemBarChanged(DisplayId displayId, const SystemBarRegionTints& tints) { for (auto tint : tints) { @@ -354,6 +371,59 @@ WMError WindowManager::UnregisterFocusChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + TLOGE(WmsLogTag::WMS_MAIN, "listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + + std::lock_guard lock(pImpl_->mutex_); + WMError ret = WMError::WM_OK; + if (pImpl_->windowModeListenerAgent_ == nullptr) { + pImpl_->windowModeListenerAgent_ = new WindowManagerAgent(); + } + ret = SingletonContainer::Get().RegisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE, pImpl_->windowModeListenerAgent_); + if (ret != WMError::WM_OK) { + TLOGW(WmsLogTag::WMS_MAIN, "RegisterWindowManagerAgent failed!"); + pImpl_->windowModeListenerAgent_ = nullptr; + return ret; + } + auto iter = std::find(pImpl_->windowModeListeners_.begin(), pImpl_->windowModeListeners_.end(), listener); + if (iter != pImpl_->windowModeListeners_.end()) { + TLOGW(WmsLogTag::WMS_MAIN, "Listener is already registered."); + return WMError::WM_OK; + } + pImpl_->windowModeListeners_.push_back(listener); + return ret; +} + +WMError WindowManager::UnregisterWindowModeChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + TLOGE(WmsLogTag::WMS_MAIN, "listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + + std::lock_guard lock(pImpl_->mutex_); + auto iter = std::find(pImpl_->windowModeListeners_.begin(), pImpl_->windowModeListeners_.end(), listener); + if (iter == pImpl_->windowModeListeners_.end()) { + TLOGE(WmsLogTag::WMS_MAIN, "could not find this listener"); + return WMError::WM_OK; + } + pImpl_->windowModeListeners_.erase(iter); + WMError ret = WMError::WM_OK; + if (pImpl_->windowModeListeners_.empty() && pImpl_->windowModeListenerAgent_ != nullptr) { + ret = SingletonContainer::Get().UnregisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE, pImpl_->windowModeListenerAgent_); + if (ret == WMError::WM_OK) { + pImpl_->windowModeListenerAgent_ = nullptr; + } + } + return ret; +} + WMError WindowManager::RegisterSystemBarChangedListener(const sptr& listener) { if (listener == nullptr) { @@ -751,6 +821,11 @@ void WindowManager::UpdateFocusChangeInfo(const sptr& focusChan } } +void WindowManager::UpdateWindowModeTypeInfo(WindowModeType type) const +{ + pImpl_->NotifyWindowModeChange(type); +} + void WindowManager::UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) const { diff --git a/wm/src/window_manager_agent.cpp b/wm/src/window_manager_agent.cpp index fa8caf22b..79e3ffe98 100644 --- a/wm/src/window_manager_agent.cpp +++ b/wm/src/window_manager_agent.cpp @@ -25,6 +25,11 @@ void WindowManagerAgent::UpdateFocusChangeInfo(const sptr& focu SingletonContainer::Get().UpdateFocusChangeInfo(focusChangeInfo, focused); } +void WindowManagerAgent::UpdateWindowModeTypeInfo(WindowModeType type) +{ + SingletonContainer::Get().UpdateWindowModeTypeInfo(type); +} + void WindowManagerAgent::UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) { SingletonContainer::Get().UpdateSystemBarRegionTints(displayId, tints); diff --git a/wm/src/zidl/window_manager_agent_proxy.cpp b/wm/src/zidl/window_manager_agent_proxy.cpp index 1c947fc82..8e25f2300 100644 --- a/wm/src/zidl/window_manager_agent_proxy.cpp +++ b/wm/src/zidl/window_manager_agent_proxy.cpp @@ -55,6 +55,28 @@ void WindowManagerAgentProxy::UpdateFocusChangeInfo(const sptr& } } +void WindowManagerAgentProxy::UpdateWindowModeTypeInfo(WindowModeType type) +{ + MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_MAIN, "WriteInterfaceToken failed"); + return; + } + + if (!data.WriteUint8(static_cast(type))) { + TLOGE(WmsLogTag::WMS_MAIN, "Write displayId failed"); + return; + } + + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (Remote()->SendRequest(static_cast(WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed"); + } +} + void WindowManagerAgentProxy::UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) { MessageParcel data; diff --git a/wm/src/zidl/window_manager_agent_stub.cpp b/wm/src/zidl/window_manager_agent_stub.cpp index d841692ae..21a354b62 100644 --- a/wm/src/zidl/window_manager_agent_stub.cpp +++ b/wm/src/zidl/window_manager_agent_stub.cpp @@ -41,6 +41,11 @@ int WindowManagerAgentStub::OnRemoteRequest(uint32_t code, MessageParcel& data, UpdateFocusChangeInfo(info, focused); break; } + case WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE: { + WindowModeType type = static_cast(data.ReadUint8()); + UpdateWindowModeTypeInfo(type); + break; + } case WindowManagerAgentMsg::TRANS_ID_UPDATE_SYSTEM_BAR_PROPS: { DisplayId displayId = data.ReadUint64(); SystemBarRegionTints tints; diff --git a/wmserver/include/window_manager_agent_controller.h b/wmserver/include/window_manager_agent_controller.h index 5d1c4c70c..121aaff28 100644 --- a/wmserver/include/window_manager_agent_controller.h +++ b/wmserver/include/window_manager_agent_controller.h @@ -32,6 +32,7 @@ public: WindowManagerAgentType type); void UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused); + void UpdateWindowModeTypeInfo(WindowModeType type); void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints); void NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type); void UpdateWindowVisibilityInfo(const std::vector>& windowVisibilityInfos); diff --git a/wmserver/src/window_manager_agent_controller.cpp b/wmserver/src/window_manager_agent_controller.cpp index 7d7165acd..5397bbb81 100644 --- a/wmserver/src/window_manager_agent_controller.cpp +++ b/wmserver/src/window_manager_agent_controller.cpp @@ -45,6 +45,14 @@ void WindowManagerAgentController::UpdateFocusChangeInfo(const sptrUpdateWindowModeTypeInfo(type); + } +} + void WindowManagerAgentController::UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) { WLOGFD("tints size: %{public}u", static_cast(tints.size())); -- Gitee From 24cf568a81a541ff7e1cd43908d9f2a8d0c36b5b Mon Sep 17 00:00:00 2001 From: zhangyao Date: Fri, 29 Mar 2024 01:50:19 +0000 Subject: [PATCH 260/385] =?UTF-8?q?Description:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E7=94=B5=E6=8E=A5=E5=8F=A3=E7=9A=84=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=9D=83=E9=99=90=E7=AE=A1=E6=8E=A7=20IssueNo:https:/?= =?UTF-8?q?/gitee.com/openharmony/window=5Fwindow=5Fmanager/issues/I9CJZE?= =?UTF-8?q?=20Feature=20or=20Bugfix:=20Feature=20Binary=20Source:No=20Sign?= =?UTF-8?q?ed-off-by:=20zhangyao=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/screen_session_manager.h | 1 + .../src/screen_session_manager.cpp | 43 ++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/include/screen_session_manager.h b/window_scene/session_manager/include/screen_session_manager.h index 0c1d6dd72..78d28e0f9 100644 --- a/window_scene/session_manager/include/screen_session_manager.h +++ b/window_scene/session_manager/include/screen_session_manager.h @@ -260,6 +260,7 @@ private: std::string TransferTypeToString(ScreenType type) const; void CheckAndSendHiSysEvent(const std::string& eventName, const std::string& bundleName) const; void HandlerSensor(ScreenPowerStatus status); + bool GetPowerStatus(ScreenPowerState state, PowerStateChangeReason reason, ScreenPowerStatus& status); // notify scb virtual screen change void OnVirtualScreenChange(ScreenId screenId, ScreenEvent screenEvent); diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 2e32c3799..de953904e 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -893,6 +893,10 @@ ScreenId ScreenSessionManager::GetDefaultScreenId() bool ScreenSessionManager::WakeUpBegin(PowerStateChangeReason reason) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:WakeUpBegin(%u)", reason); + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + WLOGFE("WakeUpBegin permission denied!"); + return false; + } currentWakeUpReason_ = reason; WLOGFI("[UL_POWER]WakeUpBegin remove suspend begin task, reason: %{public}u", static_cast(reason)); @@ -917,6 +921,10 @@ bool ScreenSessionManager::WakeUpBegin(PowerStateChangeReason reason) bool ScreenSessionManager::WakeUpEnd() { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:WakeUpEnd"); + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + WLOGFE("WakeUpEnd permission denied!"); + return false; + } WLOGFI("[UL_POWER]WakeUpEnd enter"); if (isMultiScreenCollaboration_) { isMultiScreenCollaboration_ = false; @@ -929,6 +937,10 @@ bool ScreenSessionManager::WakeUpEnd() bool ScreenSessionManager::SuspendBegin(PowerStateChangeReason reason) { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:SuspendBegin(%u)", reason); + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + WLOGFE("SuspendBegin permission denied!"); + return false; + } WLOGFI("[UL_POWER]SuspendBegin block screen power change is true, reason: %{public}u", static_cast(reason)); lastWakeUpReason_ = PowerStateChangeReason::STATE_CHANGE_REASON_INIT; @@ -954,6 +966,10 @@ bool ScreenSessionManager::SuspendBegin(PowerStateChangeReason reason) bool ScreenSessionManager::SuspendEnd() { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + WLOGFE("SuspendEnd permission denied!"); + return false; + } WLOGFI("[UL_POWER]SuspendEnd enter"); HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER]ssm:SuspendEnd"); blockScreenPowerChange_ = false; @@ -972,6 +988,10 @@ bool ScreenSessionManager::BlockSetDisplayState() bool ScreenSessionManager::SetDisplayState(DisplayState state) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + WLOGFE("SetDisplayState permission denied!"); + return false; + } WLOGFI("[UL_POWER]SetDisplayState enter"); return sessionDisplayPowerController_->SetDisplayState(state); } @@ -1060,6 +1080,10 @@ bool ScreenSessionManager::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowe bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + WLOGFE("SetScreenPowerForAll permission denied!"); + return false; + } WLOGFI("[UL_POWER]state: %{public}u, reason: %{public}u", static_cast(state), static_cast(reason)); ScreenPowerStatus status; @@ -1075,6 +1099,18 @@ bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerSta return true; } + if (!GetPowerStatus(state, reason, status)) { + return false; + } + keyguardDrawnDone_ = false; + WLOGFI("[UL_POWER]SetScreenPowerForAll keyguardDrawnDone_ is false"); + prePowerStateChangeReason = reason; + return SetScreenPower(status, reason); +} + +bool ScreenSessionManager::GetPowerStatus(ScreenPowerState state, PowerStateChangeReason reason, + ScreenPowerStatus& status) +{ switch (state) { case ScreenPowerState::POWER_ON: { if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT) { @@ -1084,8 +1120,6 @@ bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerSta status = ScreenPowerStatus::POWER_STATUS_ON; WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON"); } - keyguardDrawnDone_ = false; - WLOGFI("[UL_POWER]SetScreenPowerForAll keyguardDrawnDone_ is false"); break; } case ScreenPowerState::POWER_OFF: { @@ -1096,8 +1130,6 @@ bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerSta status = ScreenPowerStatus::POWER_STATUS_OFF; WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_OFF"); } - keyguardDrawnDone_ = false; - WLOGFI("[UL_POWER]SetScreenPowerForAll keyguardDrawnDone_ is false"); break; } default: { @@ -1105,8 +1137,7 @@ bool ScreenSessionManager::SetScreenPowerForAll(ScreenPowerState state, PowerSta return false; } } - prePowerStateChangeReason = reason; - return SetScreenPower(status, reason); + return true; } bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateChangeReason reason) -- Gitee From e8f0fc996e8f4cea392d98bcc774b5d8bb9572aa Mon Sep 17 00:00:00 2001 From: h00833914 Date: Fri, 29 Mar 2024 08:36:54 +0000 Subject: [PATCH 261/385] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E9=99=8D=E9=87=8D=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: h00833914 Change-Id: I4eed6f71ea09086f9bb68740e02bb50a838f8453 --- wm/include/window_scene_session_impl.h | 2 ++ wm/src/window_scene_session_impl.cpp | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 0866e3bd7..0436ce00b 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -181,6 +181,8 @@ private: const MMI::PointerEvent::PointerItem& pointerItem, int32_t sourceType, float vpr, const WSRect& rect); bool enableDefaultAnimation_ = true; sptr animationTransitionController_; + uint32_t setSameSystembarPropertyCnt_ = 0; + uint32_t getAvoidAreaCnt_ = 0; }; } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 625406ae7..59a384179 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1296,9 +1296,10 @@ WMError WindowSceneSessionImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea return WMError::WM_ERROR_NULLPTR; } avoidArea = hostSession_->GetAvoidAreaByType(type); - TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] type %{public}d " + getAvoidAreaCnt_++; + TLOGI(WmsLogTag::WMS_IMMS, "Window [%{public}u, %{public}s] type %{public}d %{public}u times, " "top{%{public}d, %{public}d, %{public}d, %{public}d}, down{%{public}d, %{public}d, %{public}d, %{public}d}", - windowId, GetWindowName().c_str(), type, + windowId, GetWindowName().c_str(), type, getAvoidAreaCnt_, avoidArea.topRect_.posX_, avoidArea.topRect_.posY_, avoidArea.topRect_.width_, avoidArea.topRect_.height_, avoidArea.bottomRect_.posX_, avoidArea.bottomRect_.posY_, avoidArea.bottomRect_.width_, avoidArea.bottomRect_.height_); @@ -1448,17 +1449,22 @@ WMError WindowSceneSessionImpl::NotifySpecificWindowSessionProperty(WindowType t WMError WindowSceneSessionImpl::SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) { - TLOGI(WmsLogTag::WMS_IMMS, "windowId:%{public}u %{public}s type:%{public}u" - "enable:%{public}u bgColor:%{public}x Color:%{public}x", - GetWindowId(), GetWindowName().c_str(), static_cast(type), - property.enable_, property.backgroundColor_, property.contentColor_); if (!((state_ > WindowState::STATE_INITIAL) && (state_ < WindowState::STATE_BOTTOM))) { TLOGE(WmsLogTag::WMS_IMMS, "windowId:%{public}u state is invalid", GetWindowId()); return WMError::WM_ERROR_INVALID_WINDOW; } else if (GetSystemBarPropertyByType(type) == property) { - TLOGI(WmsLogTag::WMS_IMMS, "windowId:%{public}u property is same", GetWindowId()); + setSameSystembarPropertyCnt_++; + TLOGI(WmsLogTag::WMS_IMMS, "windowId:%{public}u %{public}s set same property %{public}u times, " + "type:%{public}u, enable:%{public}u bgColor:%{public}x Color:%{public}x", + GetWindowId(), GetWindowName().c_str(), setSameSystembarPropertyCnt_, + static_cast(type), property.enable_, property.backgroundColor_, property.contentColor_); return WMError::WM_OK; } + setSameSystembarPropertyCnt_ = 0; + TLOGI(WmsLogTag::WMS_IMMS, "windowId:%{public}u %{public}s type:%{public}u, " + "enable:%{public}u bgColor:%{public}x Color:%{public}x", + GetWindowId(), GetWindowName().c_str(), static_cast(type), + property.enable_, property.backgroundColor_, property.contentColor_); if (property_ == nullptr) { TLOGE(WmsLogTag::WMS_IMMS, "property_ is null"); -- Gitee From 4e76b4e0e212074faeb675cbfc6f23e60a2de713 Mon Sep 17 00:00:00 2001 From: shark_00783 Date: Fri, 29 Mar 2024 17:13:40 +0800 Subject: [PATCH 262/385] =?UTF-8?q?tdd=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shark_00783 --- wm/test/unittest/window_session_impl_test.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index 099dad3f5..f32c13fa9 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -1771,9 +1771,17 @@ HWTEST_F(WindowSessionImplTest, SetUIContentInner, Function | SmallTest | Level2 option->SetExtensionTag(true); sptr window = new (std::nothrow) WindowSessionImpl(option); ASSERT_NE(window, nullptr); + window->property_->SetPersistentId(1); std::string url = ""; - WMError res = window->SetUIContentInner(url, nullptr, nullptr, WindowSetUIContentType::DEFAULT, nullptr); - ASSERT_EQ(res, WMError::WM_ERROR_INVALID_PARAM); + WMError res1 = window->SetUIContentInner(url, nullptr, nullptr, WindowSetUIContentType::DEFAULT, nullptr); + ASSERT_EQ(res1, WMError::WM_ERROR_INVALID_WINDOW); + + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(nullptr, session); + window->hostSession_ = session; + WMError res2 = window->SetUIContentInner(url, nullptr, nullptr, WindowSetUIContentType::DEFAULT, nullptr); + ASSERT_EQ(res2, WMError::WM_ERROR_INVALID_PARAM); GTEST_LOG_(INFO) << "WindowSessionImplTest: SetUIContentInner end"; } } -- Gitee From edff7dbeda31510f147a0c619d252bda235e6245 Mon Sep 17 00:00:00 2001 From: zhangkai Date: Fri, 29 Mar 2024 11:04:24 +0800 Subject: [PATCH 263/385] log bug fix Signed-off-by: zhangkai Change-Id: I98a0a9712072bba95ce2f2f26639ce93e34f04c1 --- wm/src/window_impl.cpp | 3 ++- wm/src/window_session_impl.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 417946da9..543922627 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -1169,7 +1169,7 @@ void WindowImpl::SetDefaultDisplayIdIfNeed() SingletonContainer::Get().GetDefaultDisplayId(); defaultDisplayId = (defaultDisplayId == DISPLAY_ID_INVALID)? 0 : defaultDisplayId; property_->SetDisplayId(defaultDisplayId); - WLOGFI("Reset displayId to %{public}llu", defaultDisplayId); + WLOGFI("Reset displayId to %{public}" PRIu64, defaultDisplayId); } } @@ -1180,6 +1180,7 @@ WMError WindowImpl::Create(uint32_t parentId, const std::shared_ptrSetDisplayId(DISPLAY_ID_INVALID); SetDefaultDisplayIdIfNeed(); context_ = context; sptr window(this); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 610e94e41..34af05a2d 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -309,7 +309,7 @@ void WindowSessionImpl::SetDefaultDisplayIdIfNeed() SingletonContainer::Get().GetDefaultDisplayId(); defaultDisplayId = (defaultDisplayId == DISPLAY_ID_INVALID)? 0 : defaultDisplayId; property_->SetDisplayId(defaultDisplayId); - WLOGFI("Reset displayId to %{public}llu", defaultDisplayId); + WLOGFI("Reset displayId to %{public}" PRIu64, defaultDisplayId); } } -- Gitee From 1d9b94ff42a1bb953a11451afded2e37bb2a5774 Mon Sep 17 00:00:00 2001 From: wanganjie Date: Fri, 29 Mar 2024 19:22:32 +0800 Subject: [PATCH 264/385] =?UTF-8?q?=E4=BF=AE=E5=A4=8DUIExtensoin=E7=9A=84p?= =?UTF-8?q?ersistentId=E4=B8=8D=E5=94=AF=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wanganjie --- window_scene/session/host/src/session.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index d4141d5f3..3956ad6ca 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -2205,8 +2205,17 @@ void Session::GeneratePersistentId(bool isExtension, int32_t persistentId) while (g_persistentIdSet.count(g_persistentId)) { g_persistentId++; } - persistentId_ = isExtension ? static_cast( - g_persistentId.load()) | 0x40000000 : static_cast(g_persistentId.load()) & 0x3fffffff; + if (isExtension) { + constexpr uint32_t pidLength = 18; + constexpr uint32_t pidMask = (1 << pidLength) - 1; + constexpr uint32_t persistentIdLength = 12; + constexpr uint32_t persistentIdMask = (1 << persistentIdLength) - 1; + uint32_t assembledPersistentId = ((static_cast(getpid()) & pidMask) << persistentIdLength) | + (static_cast(g_persistentId.load()) & persistentIdMask); + persistentId_ = assembledPersistentId | 0x40000000; + } else { + persistentId_ = static_cast(g_persistentId.load()) & 0x3fffffff; + } g_persistentIdSet.insert(g_persistentId); WLOGFI("GeneratePersistentId, persistentId: %{public}d, persistentId_: %{public}d", persistentId, persistentId_); } -- Gitee From 1e1e178ce7d6a67dbd21630ca8c68692d3aac4ba Mon Sep 17 00:00:00 2001 From: link <18727210873@163.com> Date: Wed, 27 Mar 2024 17:18:53 +0800 Subject: [PATCH 265/385] window profile info report Signed-off-by: link <18727210873@163.com> --- utils/include/perform_reporter.h | 8 ++++ utils/src/perform_reporter.cpp | 16 +++++++ utils/test/unittest/perform_reporter_test.cpp | 18 ++++++++ .../include/scene_session_manager.h | 2 +- .../src/scene_session_manager.cpp | 43 +++++++++++++++++++ 5 files changed, 86 insertions(+), 1 deletion(-) diff --git a/utils/include/perform_reporter.h b/utils/include/perform_reporter.h index 4ee2ddee9..943ebec4f 100644 --- a/utils/include/perform_reporter.h +++ b/utils/include/perform_reporter.h @@ -26,6 +26,13 @@ namespace OHOS { namespace Rosen { +struct WindowProfileInfo { + std::string bundleName = ""; + int32_t windowVisibleState = -1; + int32_t windowLocatedScreen = -1; + int32_t windowSceneMode = -1; +}; + class PerformReporter { public: PerformReporter(const std::string& tag, const std::vector& timeSpiltsMs, uint32_t reportInterval = 50); @@ -68,6 +75,7 @@ public: void ReportStartWindow(const std::string& bundleName, const std::string& windowName); void ReportRecordedInfos(); void ReportContainerStartBegin(int32_t missionId, const std::string& bundleName, int64_t timestamp); + int32_t ReportWindowProfileInfo(const WindowProfileInfo& windowProfileInfo); private: void UpdateReportInfo(FullInfoMap& infoMap, const std::string& bundleName, diff --git a/utils/src/perform_reporter.cpp b/utils/src/perform_reporter.cpp index a5f6ac98d..550e9acc4 100644 --- a/utils/src/perform_reporter.cpp +++ b/utils/src/perform_reporter.cpp @@ -297,5 +297,21 @@ void WindowInfoReporter::ClearRecordedInfos() windowDestoryReportInfos_.clear(); windowNavigationBarReportInfos_.clear(); } + +int32_t WindowInfoReporter::ReportWindowProfileInfo(const WindowProfileInfo& windowProfileInfo) +{ + std::string eventName = "WINDOW_PROFILE_INFORMATION"; + int32_t ret = HiSysEventWrite( + OHOS::HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER, eventName, + OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, + "BUNDLE_NAME", windowProfileInfo.bundleName, + "WINDOW_VISIBLE_STATE", windowProfileInfo.windowVisibleState, + "WINDOW_LOCATED_SCREEN", windowProfileInfo.windowLocatedScreen, + "WINDOW_SCENE_MODE", windowProfileInfo.windowSceneMode); + if (ret != 0) { + WLOGFE("Write HiSysEvent error, ret:%{public}d", ret); + } + return ret; +} } } \ No newline at end of file diff --git a/utils/test/unittest/perform_reporter_test.cpp b/utils/test/unittest/perform_reporter_test.cpp index 23863ed70..130629785 100644 --- a/utils/test/unittest/perform_reporter_test.cpp +++ b/utils/test/unittest/perform_reporter_test.cpp @@ -406,6 +406,24 @@ HWTEST_F(PerformReporterTest, ClearRecordedInfos016, Function | SmallTest | Leve windowInfoReporter.ClearRecordedInfos(); ASSERT_EQ(res, 0); } + +/** + * @tc.name: ReportWindowProfileInfo017 + * @tc.desc: ReportWindowProfileInfo test + * @tc.type: FUNC + */ +HWTEST_F(PerformReporterTest, ReportWindowProfileInfo017, Function | SmallTest | Level2) +{ + int32_t res = 0; + WindowProfileInfo windowProfileInfo; + windowProfileInfo.bundleName = "bundleName"; + windowProfileInfo.windowLocatedScreen = 0; + windowProfileInfo.windowSceneMode = 102; + windowProfileInfo.windowVisibleState = 2; + WindowInfoReporter windowInfoReporter; + res = windowInfoReporter.ReportWindowProfileInfo(windowProfileInfo); + ASSERT_EQ(res, 0); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 1c631a9e5..854e68acf 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -59,7 +59,6 @@ namespace AncoConsts { constexpr const char* ANCO_MISSION_ID = "ohos.anco.param.missionId"; constexpr const char* ANCO_SESSION_ID = "ohos.anco.param.sessionId"; } - class SceneSession; class AccessibilityWindowInfo; using NotifyCreateSystemSessionFunc = std::function& session)>; @@ -433,6 +432,7 @@ private: const sptr& sceneSession); void ClosePipWindowIfExist(WindowType type); WSError DestroyAndDisconnectSpecificSessionInner(sptr sceneSession); + void ReportWindowProfileInfos(); sptr rootSceneSession_; std::weak_ptr rootSceneContextWeak_; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index b16e03dd1..5c785b5dc 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -5251,6 +5251,7 @@ void SceneSessionManager::StartWindowInfoReportLoop() } auto task = [this]() { WindowInfoReporter::GetInstance().ReportRecordedInfos(); + ReportWindowProfileInfos(); isReportTaskStart_ = false; StartWindowInfoReportLoop(); }; @@ -7314,4 +7315,46 @@ WSError SceneSessionManager::UpdateExtWindowFlags(int32_t parentId, int32_t pers taskScheduler_->PostAsyncTask(task, "UpdateExtWindowFlags"); return WSError::WS_OK; } + +void SceneSessionManager::ReportWindowProfileInfos() +{ + enum class WindowVisibleState : int32_t { + FOCUSBLE = 0, + VISIBLE, + MINIMIZED, + OCCLUSION + }; + std::map> sceneSessionMapCopy; + { + std::shared_lock lock(sceneSessionMapMutex_); + sceneSessionMapCopy = sceneSessionMap_; + } + auto focusWindowId = GetFocusedSession(); + for (const auto& elem : sceneSessionMapCopy) { + auto curSession = elem.second; + if (curSession == nullptr || curSession->GetSessionInfo().isSystem_ || + curSession->GetWindowType() != WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) { + continue; + } + WindowProfileInfo windowProfileInfo; + windowProfileInfo.bundleName = curSession->GetSessionInfo().bundleName_; + windowProfileInfo.windowLocatedScreen = static_cast( + curSession->GetSessionProperty()->GetDisplayId()); + windowProfileInfo.windowSceneMode = static_cast(curSession->GetWindowMode()); + if (focusWindowId == static_cast(curSession->GetWindowId())) { + windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::FOCUSBLE); + } else if (curSession->GetSessionState() == SessionState::STATE_BACKGROUND) { + windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::MINIMIZED); + } else if (!curSession->GetVisible()) { + windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::OCCLUSION); + } else { + windowProfileInfo.windowVisibleState = static_cast(WindowVisibleState::VISIBLE); + } + WindowInfoReporter::GetInstance().ReportWindowProfileInfo(windowProfileInfo); + WLOGFD("ReportWindowProfileInfo, bundleName:%{public}s, windowVisibleState:%{public}d, " + "windowLocatedScreen:%{public}d, windowSceneMode:%{public}d", + windowProfileInfo.bundleName.c_str(), windowProfileInfo.windowVisibleState, + windowProfileInfo.windowLocatedScreen, windowProfileInfo.windowSceneMode); + } +} } // namespace OHOS::Rosen -- Gitee From d4df85ebbee28d55784d717a252aecfa013bcd28 Mon Sep 17 00:00:00 2001 From: w00574628 Date: Fri, 29 Mar 2024 15:50:44 +0800 Subject: [PATCH 266/385] Rectification of log duplication rate Signed-off-by: wulehui --- window_scene/session/host/src/scene_session.cpp | 4 ++-- .../session_manager/src/scene_session_manager.cpp | 2 +- wm/src/window_scene_session_impl.cpp | 5 ++++- wm/src/window_session_impl.cpp | 10 +++++----- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index f187fc746..22c8c07fc 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2395,8 +2395,8 @@ void SceneSession::RequestHideKeyboard(bool isAppColdStart) "isAppColdStart: %{public}d", session->GetPersistentId(), isAppColdStart); if (MiscServices::InputMethodController::GetInstance()) { MiscServices::InputMethodController::GetInstance()->RequestHideInput(); - TLOGI(WmsLogTag::WMS_KEYBOARD, "Notify inputMethod framework hide keyboard end, id: %{public}d", - session->GetPersistentId()); + } else { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Get instance failed, Notify Input framework close keyboard failed."); } }; PostExportTask(task, "RequestHideKeyboard"); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index cfef238ca..c9c417b59 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -5453,9 +5453,9 @@ void SceneSessionManager::UpdateCallingWindowIdAndPosition(const sptrGetSessionProperty()->GetCallingWindow(); uint32_t newWindowId = property->GetCallingWindow(); - TLOGI(WmsLogTag::WMS_KEYBOARD, "CallingWindow curId: %{public}d, newId: %{public}d", curWindowId, newWindowId); // When calling window id changes, restore the old calling window, raise the new calling window. if (curWindowId != INVALID_WINDOW_ID && newWindowId != curWindowId && callingSession_ != nullptr) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "CallingWindow curId: %{public}d, newId: %{public}d", curWindowId, newWindowId); RestoreCallingSessionSizeIfNeed(); callingSession_ = GetSceneSession(newWindowId); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 625406ae7..5d9d7f8d0 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2499,7 +2499,10 @@ WMError WindowSceneSessionImpl::SetCallingWindow(uint32_t callingWindowId) TLOGE(WmsLogTag::WMS_KEYBOARD, "Set calling window id failed, property_ is nullptr!"); return WMError::WM_ERROR_NULLPTR; } - TLOGI(WmsLogTag::WMS_KEYBOARD, "Set calling window id: %{public}d", callingWindowId); + if (callingWindowId != property_->GetCallingWindow()) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "Set calling window id form %{public}d to: %{public}d", + property_->GetCallingWindow(), callingWindowId); + } property_->SetCallingWindow(callingWindowId); return UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_CALLING_WINDOW); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index e2981a166..91667a820 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1589,10 +1589,10 @@ static void RequestInputMethodCloseKeyboard(bool isNeedKeyboard, bool keepKeyboa { if (!isNeedKeyboard && !keepKeyboardFlag) { #ifdef IMF_ENABLE - TLOGI(WmsLogTag::WMS_KEYBOARD, "Notify InputMethod framework close keyboard start."); if (MiscServices::InputMethodController::GetInstance()) { MiscServices::InputMethodController::GetInstance()->RequestHideInput(); - TLOGI(WmsLogTag::WMS_KEYBOARD, "Notify InputMethod framework close keyboard end."); + } else { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Get instance failed, Notify Input framework close keyboard failed."); } #endif } @@ -1608,6 +1608,7 @@ void WindowSessionImpl::NotifyUIContentFocusStatus() auto task = [weak = wptr(this)]() { auto window = weak.promote(); if (!window) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "window is null, Notify input framework close keyboard failed."); return; } bool isNeedKeyboard = false; @@ -1620,14 +1621,13 @@ void WindowSessionImpl::NotifyUIContentFocusStatus() } // whether keep the keyboard created by other windows, support system window and app subwindow. bool keepKeyboardFlag = (window->property_) ? window->property_->GetKeepKeyboardFlag() : false; - TLOGI(WmsLogTag::WMS_KEYBOARD, "isNeedKeyboard: %{public}d, keepKeyboardFlag: %{public}d", - isNeedKeyboard, keepKeyboardFlag); + TLOGI(WmsLogTag::WMS_KEYBOARD, "id: %{public}d, isNeedKeyboard: %{public}d, keepKeyboardFlag: %{public}d", + window->GetPersistentId(), isNeedKeyboard, keepKeyboardFlag); RequestInputMethodCloseKeyboard(isNeedKeyboard, keepKeyboardFlag); }; std::lock_guard lock(mutex_); if (uiContent_ != nullptr) { uiContent_->SetOnWindowFocused(task); - TLOGI(WmsLogTag::WMS_KEYBOARD, "set need soft keyboard callback success!"); } } -- Gitee From 43235ed2727eef32a92d693f0562bd1ce326ba04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Sat, 30 Mar 2024 10:05:37 +0800 Subject: [PATCH 267/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- wm/include/window_scene_session_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 37f857393..91170573d 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -139,7 +139,7 @@ public: void ConsumeKeyEvent(std::shared_ptr& keyEvent) override; WSError NotifyDialogStateChange(bool isForeground) override; WMError HideNonSecureWindows(bool shouldHide) override; - WMError SetWindowMask(const std::vector>& windowMsak) override; + virtual WMError SetWindowMask(const std::vector>& windowMsak) override; protected: void DestroySubWindow(); -- Gitee From ab664cb09e7fad7cc357c720afff563369143863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cduyulu=E2=80=9D?= <“duyulu@huawei.com”> Date: Fri, 29 Mar 2024 13:09:28 +0800 Subject: [PATCH 268/385] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: “duyulu” <“duyulu@huawei.com”> --- bundle.json | 27 +++++++++++++ .../display_manager_agent_controller_test.cpp | 2 +- extension/window_extension/BUILD.gn | 6 +-- .../napi/picture_in_picture_napi/BUILD.gn | 5 +-- interfaces/kits/napi/window_runtime/BUILD.gn | 3 -- test/demo/BUILD.gn | 27 ++++--------- window_scene/intention_event/BUILD.gn | 2 +- window_scene/intention_event/service/BUILD.gn | 3 +- .../kits/napi/scene_session_manager/BUILD.gn | 7 +--- window_scene/session/BUILD.gn | 13 ++++--- window_scene/session_manager/BUILD.gn | 38 +++++++++++++------ wm/BUILD.gn | 8 ++-- wmserver/BUILD.gn | 13 ++++--- 13 files changed, 88 insertions(+), 66 deletions(-) diff --git a/bundle.json b/bundle.json index 4a89667dc..9eeccc465 100755 --- a/bundle.json +++ b/bundle.json @@ -159,6 +159,15 @@ "header_base": "//foundation/window/window_manager/utils/include" } }, + { + "type": "so", + "name": "//foundation/window/window_manager/utils:libwmutil_static", + "header": { + "header_files": [ + ], + "header_base": "//foundation/window/window_manager/utils/include" + } + }, { "type": "so", "name": "//foundation/window/window_manager/dm:libdm", @@ -299,6 +308,24 @@ "header_base": "//foundation/window/window_manager/previewer/include" } }, + { + "type": "so", + "name": "//foundation/window/window_manager/wmserver:libwms", + "header": { + "header_files": [ + ], + "header_base": "//foundation/window/window_manager/wmserver/include" + } + }, + { + "type": "so", + "name": "//foundation/window/window_manager/dmserver:libdms", + "header": { + "header_files": [ + ], + "header_base": "//foundation/window/window_manager/dmserver/include" + } + }, { "type": "so", "name": "//foundation/window/window_manager/previewer:previewer_window_napi", diff --git a/dmserver/test/unittest/display_manager_agent_controller_test.cpp b/dmserver/test/unittest/display_manager_agent_controller_test.cpp index 5dc5489f4..d498b4b48 100644 --- a/dmserver/test/unittest/display_manager_agent_controller_test.cpp +++ b/dmserver/test/unittest/display_manager_agent_controller_test.cpp @@ -16,7 +16,7 @@ #include #include "display_manager_agent_controller.h" -#include "../../dm/include/display_manager_agent_default.h" +#include "display_manager_agent_default.h" #include "scene_board_judgement.h" using namespace testing; diff --git a/extension/window_extension/BUILD.gn b/extension/window_extension/BUILD.gn index 9c4d961c5..5a7881311 100644 --- a/extension/window_extension/BUILD.gn +++ b/extension/window_extension/BUILD.gn @@ -84,10 +84,7 @@ ohos_shared_library("libwindow_extension") { config("window_extension_module_private_config") { visibility = [ ":*" ] - include_dirs = [ - "include", - "${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime", - ] + include_dirs = [ "include" ] } ## Build libwindow_extension_module.so @@ -108,6 +105,7 @@ ohos_shared_library("window_extension_module") { deps = [ ":libwindow_extension" ] external_deps = [ + "ability_runtime:ability_context_native", "ability_runtime:abilitykit_native", "common_event_service:cesfwk_innerkits", "hilog:libhilog", diff --git a/interfaces/kits/napi/picture_in_picture_napi/BUILD.gn b/interfaces/kits/napi/picture_in_picture_napi/BUILD.gn index 9bfa97b44..43f829c71 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/BUILD.gn +++ b/interfaces/kits/napi/picture_in_picture_napi/BUILD.gn @@ -16,10 +16,7 @@ import("../../../../windowmanager_aafwk.gni") config("pip_config") { visibility = [ ":*" ] - include_dirs = [ - "../../../../wm/include", - "${arkui_path}/ace_engine/interface/inner_api/ace", - ] + include_dirs = [ "../../../../wm/include" ] } ohos_shared_library("pipwindow_napi") { diff --git a/interfaces/kits/napi/window_runtime/BUILD.gn b/interfaces/kits/napi/window_runtime/BUILD.gn index bf425c981..d77cf3416 100644 --- a/interfaces/kits/napi/window_runtime/BUILD.gn +++ b/interfaces/kits/napi/window_runtime/BUILD.gn @@ -36,9 +36,6 @@ config("window_native_kit_config") { "../../../../utils/include", "../../../../wm/include", "../../../../wmserver/include", - - # because of pixle_map.h - "//foundation/multimedia/image_framework/interfaces/innerkits/include", ] } diff --git a/test/demo/BUILD.gn b/test/demo/BUILD.gn index 834a88317..07fb240f7 100644 --- a/test/demo/BUILD.gn +++ b/test/demo/BUILD.gn @@ -32,13 +32,11 @@ ohos_executable("demo_mirror_screen_listener") { include_dirs = [ "../common/utils/include" ] - deps = [ - "${window_base_path}/dm:libdm", - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base:librender_service_base", - ] + deps = [ "${window_base_path}/dm:libdm" ] external_deps = [ "c_utils:utils", + "graphic_2d:librender_service_base", "hilog:libhilog", ] @@ -101,13 +99,11 @@ ohos_executable("demo_system_sub_window") { "../common/utils/include", ] - deps = [ - "${window_base_path}/wm:libwm", - "//foundation/graphic/graphic_2d/rosen/modules/render_service_base:librender_service_base", - ] + deps = [ "${window_base_path}/wm:libwm" ] external_deps = [ "c_utils:utils", + "graphic_2d:librender_service_base", "hilog:libhilog", ] @@ -118,12 +114,7 @@ ohos_executable("demo_system_sub_window") { ohos_executable("demo_freeze_display") { sources = [ "demo_freeze_display.cpp" ] - include_dirs = [ - "../../interfaces/innerkits/dm", - - # pixel_map.h - "//foundation/multimedia/image_framework/interfaces/innerkits/include", - ] + include_dirs = [ "../../interfaces/innerkits/dm" ] deps = [ "${window_base_path}/dm:libdm" ] external_deps = [ "c_utils:utils", @@ -142,13 +133,11 @@ ohos_executable("demo_water_mark_listener") { "${window_base_path}/test/common/utils/include", ] - deps = [ - "${graphic_base_path}/graphic_2d/rosen/modules/render_service_base:librender_service_base", - "${window_base_path}/wm:libwm", - ] + deps = [ "${window_base_path}/wm:libwm" ] external_deps = [ "c_utils:utils", + "graphic_2d:librender_service_base", "hilog:libhilog", ] @@ -169,7 +158,6 @@ ohos_executable("demo_session_manager") { ] deps = [ - "${graphic_base_path}/graphic_2d/rosen/modules/render_service_base:librender_service_base", "${window_base_path}/dm:libdm", "${window_base_path}/window_scene/session_manager:session_manager", "${window_base_path}/wm:libwm", @@ -177,6 +165,7 @@ ohos_executable("demo_session_manager") { external_deps = [ "c_utils:utils", + "graphic_2d:librender_service_base", "hilog:libhilog", "ipc:ipc_core", ] diff --git a/window_scene/intention_event/BUILD.gn b/window_scene/intention_event/BUILD.gn index 339872eb7..6787383a7 100644 --- a/window_scene/intention_event/BUILD.gn +++ b/window_scene/intention_event/BUILD.gn @@ -25,7 +25,6 @@ ohos_shared_library("libintention_event") { "./include", "${window_base_path}/wm/include", "${window_base_path}/window_scene/session/host/include", - "${accessibility_path}/interfaces/innerkits/common/include/", ] sources = [ "src/intention_event_manager.cpp" ] @@ -39,6 +38,7 @@ ohos_shared_library("libintention_event") { external_deps = [ "ability_runtime:app_manager", + "accessibility:accessibility_common", "ace_engine:ace_uicontent", "c_utils:utils", "eventhandler:libeventhandler", diff --git a/window_scene/intention_event/service/BUILD.gn b/window_scene/intention_event/service/BUILD.gn index 8d3c61a10..3a6330b37 100644 --- a/window_scene/intention_event/service/BUILD.gn +++ b/window_scene/intention_event/service/BUILD.gn @@ -16,7 +16,6 @@ import("../../../windowmanager_aafwk.gni") config("intention_event_public_config") { include_dirs = [ - "${accessibility_path}/interfaces/innerkits/common/include/", "anr_manager/include", "event_stage/include", "timer_manager/include", @@ -48,7 +47,7 @@ ohos_shared_library("intention_event_anr_manager") { ] public_configs = [ ":intention_event_public_config" ] - + public_external_deps = [ "accessibility:accessibility_common" ] external_deps = [ "ability_base:want", "c_utils:utils", diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/BUILD.gn b/window_scene/interfaces/kits/napi/scene_session_manager/BUILD.gn index cd0be7515..9fd9f12df 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/scene_session_manager/BUILD.gn @@ -16,12 +16,7 @@ import("../../../../../windowmanager_aafwk.gni") config("scene_session_manager_napi_config") { visibility = [ ":*" ] - include_dirs = [ - "${window_base_path}/wm/include", - - # for ui_content - "${arkui_path}/ace_engine/interfaces/inner_api/ace", - ] + include_dirs = [ "${window_base_path}/wm/include" ] } ohos_shared_library("scenesessionmanager_napi") { diff --git a/window_scene/session/BUILD.gn b/window_scene/session/BUILD.gn index 2d7db5825..94b7b27f1 100755 --- a/window_scene/session/BUILD.gn +++ b/window_scene/session/BUILD.gn @@ -29,12 +29,8 @@ config("session_public_config") { # for WMError Code "${window_base_path}/interfaces/innerkits/wm", - # for mouse style - "${multimodalinput_path}/input/util/common/include", - #for element "${accessibility_path}/common/interface/include/parcel", - "${accessibility_path}/interfaces/innerkits/common/include", ] } @@ -99,7 +95,10 @@ ohos_shared_library("scene_session") { "ipc:ipc_single", "preferences:native_preferences", ] - + public_external_deps = [ + "accessibility:accessibility_common", + "input:libmmi-util", + ] defines = [] if (defined(global_parts_info) && @@ -159,6 +158,10 @@ ohos_shared_library("screen_session") { "hitrace:hitrace_meter", "init:libbegetutil", ] + public_external_deps = [ + "accessibility:accessibility_common", + "input:libmmi-util", + ] innerapi_tags = [ "platformsdk" ] part_name = "window_manager" diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index 349858a50..4c65eca77 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -27,8 +27,6 @@ config("session_manager_public_config") { "${window_base_path}/window_scene/session_manager_service/include", # for session_manager - "${multimodalinput_path}/input/interfaces/native/innerkits/event/include", - "${multimodalinput_path}/input/util/common/include", "${ability_runtime_inner_api_path}/ability_manager/include", "${ability_runtime_inner_api_path}/app_manager/include", "${window_base_path}/wmserver/include", @@ -41,21 +39,17 @@ config("session_manager_public_config") { "${window_base_path}/dmserver/include", # for scene session manager - "${ability_runtime_inner_api_path}/session_handler/include", - "${resourceschedule_path}/ffrt/interfaces/kits", "${window_base_path}/interfaces/innerkits/wm", "${window_base_path}/wmserver/include", - "${graphic_base_path}/graphic_2d/rosen/modules/animation/window_animation/include", - "${window_base_path}/window_scene/screen_session_manager/include", + "${resourceschedule_path}/ffrt/interfaces/kits", + "${graphic_base_path}/graphic_2d/rosen/modules/animation/window_animation/include", # for window_manager_hilog "${window_base_path}/utils/include", "${window_base_path}/wm/include", "${window_base_path}/wm/include/zidl", - - "${accessibility_path}/interfaces/innerkits/common/include/", ] } @@ -97,7 +91,12 @@ ohos_shared_library("scene_session_manager") { "${window_base_path}/window_scene/session:screen_session", "//third_party/libxml2:libxml2", ] - + public_external_deps = [ + "ability_runtime:session_handler", + "accessibility:accessibility_common", + "input:libmmi-client", + "input:libmmi-util", + ] external_deps = [ "ability_base:session_info", "ability_base:want", @@ -214,7 +213,12 @@ ohos_shared_library("screen_session_manager") { cflags_cc = [ "-std=c++17" ] public_configs = [ ":session_manager_public_config" ] - + public_external_deps = [ + "ability_runtime:session_handler", + "accessibility:accessibility_common", + "input:libmmi-client", + "input:libmmi-util", + ] deps = [ "${window_base_path}/utils:libwmutil", "${window_base_path}/window_scene/common:window_scene_common", @@ -297,7 +301,12 @@ ohos_shared_library("session_manager") { public_configs = [ ":session_manager_public_config" ] deps = [ "${window_base_path}/utils:libwmutil" ] - + public_external_deps = [ + "ability_runtime:session_handler", + "accessibility:accessibility_common", + "input:libmmi-client", + "input:libmmi-util", + ] external_deps = [ "ability_base:session_info", "ability_base:want", @@ -333,7 +342,12 @@ ohos_shared_library("session_manager_lite") { cflags_cc = [ "-std=c++17" ] public_configs = [ ":session_manager_public_config" ] - + public_external_deps = [ + "ability_runtime:session_handler", + "accessibility:accessibility_common", + "input:libmmi-client", + "input:libmmi-util", + ] deps = [] external_deps = [ diff --git a/wm/BUILD.gn b/wm/BUILD.gn index 09f23ded2..b80fde049 100644 --- a/wm/BUILD.gn +++ b/wm/BUILD.gn @@ -22,7 +22,6 @@ config("libwm_private_config") { "../wmserver/include", "../wmserver/include/zidl", "../window_scene/session/host/include", - "//foundation/arkui/napi", # because of ability_context.h ] } @@ -47,7 +46,6 @@ ohos_static_library("libwm_static") { "../window_scene/intention_event/service/anr_manager/include", "../window_scene/intention_event/framework/anr_handler/include", "${window_base_path}/window_scene/intention_event/include", - "${accessibility_path}/interfaces/innerkits/common/include/", ] sources = [ @@ -104,6 +102,7 @@ ohos_static_library("libwm_static") { "ability_runtime:ability_context_native", "ability_runtime:ability_manager", "ability_runtime:app_manager", + "accessibility:accessibility_common", "ace_engine:ace_uicontent", "ace_engine:ace_xcomponent_controller", "bundle_framework:appexecfwk_core", @@ -118,6 +117,7 @@ ohos_static_library("libwm_static") { "init:libbegetutil", "input:libmmi-client", "ipc:ipc_single", + "napi:ace_napi", "samgr:samgr_proxy", ] @@ -186,7 +186,6 @@ ohos_shared_library("libwm") { "../window_scene/intention_event/service/anr_manager/include", "../window_scene/intention_event/framework/anr_handler/include", "${window_base_path}/window_scene/intention_event/include", - "${accessibility_path}/interfaces/innerkits/common/include/", ] sources = [ @@ -243,6 +242,7 @@ ohos_shared_library("libwm") { "ability_runtime:ability_context_native", "ability_runtime:ability_manager", "ability_runtime:app_manager", + "accessibility:accessibility_common", "ace_engine:ace_uicontent", "ace_engine:ace_xcomponent_controller", "bundle_framework:appexecfwk_core", @@ -257,6 +257,7 @@ ohos_shared_library("libwm") { "init:libbegetutil", "input:libmmi-client", "ipc:ipc_single", + "napi:ace_napi", "samgr:samgr_proxy", ] @@ -334,6 +335,7 @@ ohos_shared_library("libwm_lite") { "hilog:libhilog", "init:libbegetutil", "ipc:ipc_single", + "napi:ace_napi", "samgr:samgr_proxy", ] diff --git a/wmserver/BUILD.gn b/wmserver/BUILD.gn index a832510fd..04c759483 100644 --- a/wmserver/BUILD.gn +++ b/wmserver/BUILD.gn @@ -52,9 +52,6 @@ config("libmockwms_config") { "${window_base_path}/window_scene/session_manager_service/include", # for session_manager - "${multimodalinput_path}/input/interfaces/native/innerkits/event/include", - "${multimodalinput_path}/input/util/common/include", - "${ability_runtime_inner_api_path}/ability_manager/include", "${window_base_path}/wmserver/include", "${window_base_path}/wmserver/include/zidl", @@ -68,7 +65,6 @@ config("libmockwms_config") { # for scene session manager "${window_base_path}/interfaces/innerkits/wm", "${window_base_path}/wmserver/include", - "${graphic_base_path}/graphic_2d/rosen/modules/animation/window_animation/include", "${graphic_base_path}/graphic_2d/rosen/modules/platform/image_native", # for window_manager_hilog @@ -76,8 +72,6 @@ config("libmockwms_config") { "${window_base_path}/wm/include", "${window_base_path}/wm/include/zidl", - - "${accessibility_path}/interfaces/innerkits/common/include/", ] } @@ -118,6 +112,13 @@ ohos_shared_library("sms") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] + public_external_deps = [ + "ability_runtime:ability_manager", + "accessibility:accessibility_common", + "graphic_2d:window_animation", + "input:libmmi-client", + "input:libmmi-util", + ] if (scene_board_enabled) { deps += [ "${window_base_path}/window_scene/session_manager_service:session_manager_service" ] } -- Gitee From 7950c7745e65ae73b8ab9b33c6c56276c34f9513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Sat, 30 Mar 2024 11:48:28 +0800 Subject: [PATCH 269/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- interfaces/innerkits/wm/window.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 923b2d5c1..33032393f 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1779,18 +1779,7 @@ public: * @return WM_OK means remove success, others means failed. */ virtual WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } - - /** - * @brief Set Shaped Window Mask. - * - * @param windowMask Mask of the shaped window. - * @return WM_OK means set success, others means failed. - */ - virtual WMError SetWindowMask(const std::vector>& windowMask) - { - return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; - } - + /** * @brief Make multi-window become landscape or not. * @@ -1823,6 +1812,17 @@ public: { return WMError::WM_OK; } + + /** + * @brief Set Shaped Window Mask. + * + * @param windowMask Mask of the shaped window. + * @return WM_OK means set success, others means failed. + */ + virtual WMError SetWindowMask(const std::vector>& windowMask) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } }; } } -- Gitee From 947203d813bcebcae2fe478bd258ed8317d56852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Sat, 30 Mar 2024 14:39:21 +0800 Subject: [PATCH 270/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- previewer/include/window.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/previewer/include/window.h b/previewer/include/window.h index 1a30bf548..19977cc89 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -314,6 +314,11 @@ public: virtual WMError Recover(uint32_t reason = 0) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }; virtual WMError Maximize(MaximizeLayoutOption option) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + + virtual WMError SetWindowMask(const std::vector>& windowMask) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } }; } } -- Gitee From 0b13c1a79e0f8fdac0fc18d2109c9da7171d6f06 Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Sat, 30 Mar 2024 06:51:29 +0000 Subject: [PATCH 271/385] update window_scene/session_manager/src/scene_session_dirty_manager.cpp. Signed-off-by: chengyiyi --- .../session_manager/src/scene_session_dirty_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 1b17fbcaf..e4d6d229d 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -438,8 +438,8 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr .zOrder = zOrder, .transform = transformData }; - if (sceneSession->GetSessionProperty()->GetWindowFlags() & - static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING)) { + if (sceneSession->GetSessionProperty() != nullptr && (sceneSession->GetSessionProperty()->GetWindowFlags() & + static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING))) { WLOGFI("Add handwrite flag for session, id: %{public}d", windowId); windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_HANDWRITING; } -- Gitee From 4c176137ca7d98fdecd59a9d745bcb8ee515e43d Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Sat, 30 Mar 2024 07:00:00 +0000 Subject: [PATCH 272/385] update window_scene/session_manager/src/scene_session_dirty_manager.cpp. Signed-off-by: chengyiyi --- .../session_manager/src/scene_session_dirty_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index e4d6d229d..6057e4f3d 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -438,7 +438,8 @@ MMI::WindowInfo SceneSessionDirtyManager::GetWindowInfo(const sptr .zOrder = zOrder, .transform = transformData }; - if (sceneSession->GetSessionProperty() != nullptr && (sceneSession->GetSessionProperty()->GetWindowFlags() & + auto property = sceneSession->GetSessionProperty(); + if (property != nullptr && (property->GetWindowFlags() & static_cast(WindowFlag::WINDOW_FLAG_HANDWRITING))) { WLOGFI("Add handwrite flag for session, id: %{public}d", windowId); windowInfo.flags |= MMI::WindowInfo::FLAG_BIT_HANDWRITING; -- Gitee From 9a2b2ff38d1edc791b72c39e2267f42c6211751a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Sat, 30 Mar 2024 15:11:28 +0800 Subject: [PATCH 273/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- interfaces/innerkits/wm/window.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 33032393f..2e5f0871f 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1779,7 +1779,7 @@ public: * @return WM_OK means remove success, others means failed. */ virtual WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } - + /** * @brief Make multi-window become landscape or not. * @@ -1813,12 +1813,12 @@ public: return WMError::WM_OK; } - /** + /** * @brief Set Shaped Window Mask. * * @param windowMask Mask of the shaped window. * @return WM_OK means set success, others means failed. - */ + */ virtual WMError SetWindowMask(const std::vector>& windowMask) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; -- Gitee From 21c903e677312b4e3105b59c251f6683e53e2944 Mon Sep 17 00:00:00 2001 From: yang-yuanzhou Date: Fri, 29 Mar 2024 14:43:36 +0800 Subject: [PATCH 274/385] =?UTF-8?q?=E8=99=9A=E6=8B=9F=E5=B1=8F=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E9=9C=80=E6=B1=82=E9=81=97=E7=95=99=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=8E=8B=E6=B5=8B=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yang-yuanzhou --- dmserver/src/display_manager_proxy.cpp | 3 ++- dmserver/src/display_manager_stub.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dmserver/src/display_manager_proxy.cpp b/dmserver/src/display_manager_proxy.cpp index 6fe48cc20..2419710e2 100644 --- a/dmserver/src/display_manager_proxy.cpp +++ b/dmserver/src/display_manager_proxy.cpp @@ -138,7 +138,8 @@ ScreenId DisplayManagerProxy::CreateVirtualScreen(VirtualScreenOption virtualOpt } bool res = data.WriteString(virtualOption.name_) && data.WriteUint32(virtualOption.width_) && data.WriteUint32(virtualOption.height_) && data.WriteFloat(virtualOption.density_) && - data.WriteInt32(virtualOption.flags_) && data.WriteBool(virtualOption.isForShot_); + data.WriteInt32(virtualOption.flags_) && data.WriteBool(virtualOption.isForShot_) && + data.WriteUInt64Vector(virtualOption.missionIds_); if (virtualOption.surface_ != nullptr && virtualOption.surface_->GetProducer() != nullptr) { res = res && data.WriteBool(true) && diff --git a/dmserver/src/display_manager_stub.cpp b/dmserver/src/display_manager_stub.cpp index dee29cf1f..0b118cdf2 100644 --- a/dmserver/src/display_manager_stub.cpp +++ b/dmserver/src/display_manager_stub.cpp @@ -64,6 +64,8 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, float density = data.ReadFloat(); int32_t flags = data.ReadInt32(); bool isForShot = data.ReadBool(); + std::vector missionIds; + data.ReadUInt64Vector(&missionIds); bool isSurfaceValid = data.ReadBool(); sptr surface = nullptr; if (isSurfaceValid) { @@ -79,7 +81,8 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, .density_ = density, .surface_ = surface, .flags_ = flags, - .isForShot_ = isForShot + .isForShot_ = isForShot, + .missionIds_ = missionIds }; ScreenId screenId = CreateVirtualScreen(virScrOption, virtualScreenAgent); reply.WriteUint64(static_cast(screenId)); -- Gitee From bd08a975caf40fedb48cd9b90f91cb50f5779d62 Mon Sep 17 00:00:00 2001 From: zhangyao Date: Sat, 30 Mar 2024 07:50:13 +0000 Subject: [PATCH 275/385] =?UTF-8?q?Description:=E6=80=A5=E9=80=9F=E6=8C=87?= =?UTF-8?q?=E7=BA=B9=E9=9C=80=E6=B1=82=E8=A1=A5=E5=85=85tdd=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=20IssueNo:https://gitee.com/openhar?= =?UTF-8?q?mony/window=5Fwindow=5Fmanager/issues/I9B455=20Feature=20or=20B?= =?UTF-8?q?ugfix:=20Feature=20Binary=20Source:No=20Signed-off-by:=20zhangy?= =?UTF-8?q?ao=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unittest/screen_session_manager_test.cpp | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/window_scene/test/unittest/screen_session_manager_test.cpp b/window_scene/test/unittest/screen_session_manager_test.cpp index fd8ad1e38..e18eaebf6 100644 --- a/window_scene/test/unittest/screen_session_manager_test.cpp +++ b/window_scene/test/unittest/screen_session_manager_test.cpp @@ -80,6 +80,142 @@ HWTEST_F(ScreenSessionManagerTest, RegisterDisplayManagerAgent, Function | Small EXPECT_EQ(DMError::DM_OK, ssm_->UnregisterDisplayManagerAgent(displayManagerAgent, type)); } +/** + * @tc.name: WakeupBegin + * @tc.desc: WakeupBegin test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, WakeUpBegin, Function | SmallTest | Level3) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + EXPECT_NE(displayManagerAgent, nullptr); + + DisplayManagerAgentType type = DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER; + EXPECT_EQ(DMError::DM_OK, ssm_->RegisterDisplayManagerAgent(displayManagerAgent, type)); + + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject()); + if (screenId != VIRTUAL_SCREEN_ID) { + ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID); + } + + PowerStateChangeReason reason = PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY; + ASSERT_EQ(true, ssm_->WakeUpBegin(reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT; + ASSERT_EQ(true, ssm_->WakeUpBegin(reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_SUCCESS; + ASSERT_EQ(true, ssm_->WakeUpBegin(reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_ON; + ASSERT_EQ(true, ssm_->WakeUpBegin(reason)); + + EXPECT_EQ(DMError::DM_OK, ssm_->DestroyVirtualScreen(screenId)); + EXPECT_EQ(DMError::DM_OK, ssm_->UnregisterDisplayManagerAgent(displayManagerAgent, type)); +} + +/** + * @tc.name: SuspendBegin + * @tc.desc: SuspendBegin test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SuspendBegin, Function | SmallTest | Level3) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + EXPECT_NE(displayManagerAgent, nullptr); + + DisplayManagerAgentType type = DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER; + EXPECT_EQ(DMError::DM_OK, ssm_->RegisterDisplayManagerAgent(displayManagerAgent, type)); + + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject()); + if (screenId != VIRTUAL_SCREEN_ID) { + ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID); + } + + PowerStateChangeReason reason = PowerStateChangeReason::STATE_CHANGE_REASON_HARD_KEY; + ASSERT_EQ(true, ssm_->SuspendBegin(reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF; + ASSERT_EQ(true, ssm_->SuspendBegin(reason)); + + EXPECT_EQ(DMError::DM_OK, ssm_->DestroyVirtualScreen(screenId)); + EXPECT_EQ(DMError::DM_OK, ssm_->UnregisterDisplayManagerAgent(displayManagerAgent, type)); +} + +/** + * @tc.name: SetScreenPowerForAll + * @tc.desc: SetScreenPowerForAll test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, SetScreenPowerForAll, Function | SmallTest | Level3) +{ + sptr displayManagerAgent = new(std::nothrow) DisplayManagerAgentDefault(); + EXPECT_NE(displayManagerAgent, nullptr); + + DisplayManagerAgentType type = DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER; + EXPECT_EQ(DMError::DM_OK, ssm_->RegisterDisplayManagerAgent(displayManagerAgent, type)); + + VirtualScreenOption virtualOption; + virtualOption.name_ = "createVirtualOption"; + auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject()); + if (screenId != VIRTUAL_SCREEN_ID) { + ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID); + } + + PowerStateChangeReason reason = PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY; + ScreenPowerState state = ScreenPowerState::POWER_ON; + ASSERT_EQ(true, ssm_->SetScreenPowerForAll(state, reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT; + ASSERT_EQ(true, ssm_->SetScreenPowerForAll(state, reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_SUCCESS; + ASSERT_EQ(true, ssm_->SetScreenPowerForAll(state, reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_ON; + ASSERT_EQ(true, ssm_->SetScreenPowerForAll(state, reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_HARD_KEY; + state = ScreenPowerState::POWER_OFF; + ASSERT_EQ(true, ssm_->SetScreenPowerForAll(state, reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF; + ASSERT_EQ(true, ssm_->SetScreenPowerForAll(state, reason)); + + EXPECT_EQ(DMError::DM_OK, ssm_->DestroyVirtualScreen(screenId)); + EXPECT_EQ(DMError::DM_OK, ssm_->UnregisterDisplayManagerAgent(displayManagerAgent, type)); +} + +/** + * @tc.name: IsFastFingerprintReason + * @tc.desc: IsFastFingerprintReason test + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerTest, IsFastFingerprintReason, Function | SmallTest | Level3) +{ + PowerStateChangeReason reason = PowerStateChangeReason::STATE_CHANGE_REASON_POWER_KEY; + ASSERT_EQ(false, ssm_->IsFastFingerprintReason(reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT; + ASSERT_EQ(true, ssm_->IsFastFingerprintReason(reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_SUCCESS; + ASSERT_EQ(true, ssm_->IsFastFingerprintReason(reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_ON; + ASSERT_EQ(true, ssm_->IsFastFingerprintReason(reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF; + ASSERT_EQ(true, ssm_->IsFastFingerprintReason(reason)); + + reason = PowerStateChangeReason::STATE_CHANGE_REASON_HARD_KEY; + ASSERT_EQ(false, ssm_->IsFastFingerprintReason(reason)); +} + /** * @tc.name: ScreenChange * @tc.desc: ScreenChange test -- Gitee From 7c1ac0c009a657eee9d45d1a7371fd01058b918a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Sat, 30 Mar 2024 15:55:22 +0800 Subject: [PATCH 276/385] =?UTF-8?q?scene=5Fsession=5Fmanager=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=8E=A5=E5=8F=A3getFocusSessionElement=EF=BC=8CgetFo?= =?UTF-8?q?cusSessionInfo=E5=A2=9E=E5=8A=A0isSaCalling=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=EF=BC=8CTerminateSessionNew=E5=A2=9EIsSameBu?= =?UTF-8?q?ndleNameAsCalling=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- .../include/scene_session_manager.h | 3 ++- .../src/scene_session_manager.cpp | 27 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 48e6660d9..77b327261 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -192,7 +192,8 @@ public: WSError PendingSessionToForeground(const sptr &token) override; WSError PendingSessionToBackgroundForDelegator(const sptr &token) override; WSError GetFocusSessionToken(sptr &token) override; - + WSError GetFocusSessionElement(AppExecFwk::ElementName &elemnt); + WSError RegisterSessionListener(const sptr& listener) override; WSError UnRegisterSessionListener(const sptr& listener) override; WSError GetSessionInfos(const std::string& deviceId, int32_t numMax, diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c16746acd..43eef99fc 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4918,6 +4918,10 @@ WSError SceneSessionManager::TerminateSessionNew(const sptr TLOGE(WmsLogTag::WMS_LIFE, "TerminateSessionNew:fail to find session by token."); return WSError::WS_ERROR_INVALID_PARAM; } + if (!SessionPermission::IsSameBundleNameAsCalling(sceneSession->GetSessionInfo().bundleName_)) { + WLOGFE("TerminateSessionNew calling denied!"); + return WSError::WS_ERROR_INVALID_CALLING; + } const WSError& errCode = sceneSession->TerminateSessionNew(info, needStartCaller); return errCode; }; @@ -6006,6 +6010,10 @@ WSError SceneSessionManager::PendingSessionToBackgroundForDelegator(const sptr &token) { + if (!SessionPermission::IsSACalling()) { + WLOGFE("GetFocusSessionToken permission denied!"); + return WSError::WS_ERROR_INVALID_PERMISSION; + } auto task = [this, &token]() { WLOGFD("run GetFocusSessionToken with focusedSessionId: %{public}d", focusedSessionId_); auto sceneSession = GetSceneSession(focusedSessionId_); @@ -6017,11 +6025,28 @@ WSError SceneSessionManager::GetFocusSessionToken(sptr &token) } return WSError::WS_OK; } - return WSError::WS_ERROR_INVALID_PARAM; + return WSError::WS_ERROR_INVALID_SESSION; }; return taskScheduler_->PostSyncTask(task, "GetFocusSessionToken"); } +WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName &elemnt) +{ + auto task = [this, &token]() { + WLOGFD("run GetFocusSessionElement with focusedSessionId: %{public}d", focusedSessionId_); + auto sceneSession = GetSceneSession(focusedSessionId_); + if (sceneSession) { + auto sessionInfo = sceneSession->GetSessionInfo(); + AAFwk::Want want; + want.SetElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); + element = want.getElement; + return WSError::WS_OK; + } + return WSError::WS_ERROR_INVALID_SESSION; + }; + return taskScheduler_->PostSyncTask(task, "GetFocusSessionElement"); +} + WSError SceneSessionManager::UpdateSessionAvoidAreaListener(int32_t& persistentId, bool haveListener) { auto task = [this, persistentId, haveListener]() { -- Gitee From 032273b70b3994ab7ec08a91711acd244409649f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Sat, 30 Mar 2024 16:06:04 +0800 Subject: [PATCH 277/385] =?UTF-8?q?scene=5Fsession=5Fmanager=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3getFocusWindowInfo=E6=96=B0=E5=A2=9EisSaCalling?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 43eef99fc..170ec7e77 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -3089,6 +3089,10 @@ int32_t SceneSessionManager::GetFocusedSession() const void SceneSessionManager::GetFocusWindowInfo(FocusChangeInfo& focusInfo) { + if (!SessionPermission::IsSACalling()) { + WLOGFE("GetFocusWindowInfo permission denied!"); + return; + } auto sceneSession = GetSceneSession(focusedSessionId_); if (sceneSession) { WLOGFD("Get focus session info success"); -- Gitee From a3e4fa0914cc6086d5e2535df73a312109f66743 Mon Sep 17 00:00:00 2001 From: l30030525 Date: Sat, 30 Mar 2024 16:12:33 +0800 Subject: [PATCH 278/385] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=AE=BF=E4=B8=BB?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BD=8D=E7=BD=AE=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- interfaces/innerkits/wm/window.h | 8 ++++++ .../include/scene_session_manager.h | 1 + .../zidl/scene_session_manager_interface.h | 5 ++++ .../zidl/scene_session_manager_proxy.h | 1 + .../include/zidl/scene_session_manager_stub.h | 1 + .../src/scene_session_manager.cpp | 25 +++++++++++++++++ .../src/zidl/scene_session_manager_proxy.cpp | 28 +++++++++++++++++++ .../src/zidl/scene_session_manager_stub.cpp | 16 +++++++++++ wm/include/window_adapter.h | 1 + wm/include/window_extension_session_impl.h | 1 + wm/src/window_adapter.cpp | 6 ++++ wm/src/window_extension_session_impl.cpp | 11 ++++++++ .../include/zidl/window_manager_interface.h | 5 ++++ 13 files changed, 109 insertions(+) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index de82563a5..04ff72237 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1812,6 +1812,14 @@ public: { return WMError::WM_OK; } + + /** + * @brief Get the rect of host window. + * + * @param hostWindowId window Id of the host window. + * @return Rect of window. + */ + virtual Rect GetHostWindowRect(int32_t hostWindowId) { return {}; } }; } } diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 84fc0711d..c4e6e1ca2 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -291,6 +291,7 @@ public: int32_t StartUIAbilityBySCB(sptr& sceneSessions); int32_t ChangeUIAbilityVisibilityBySCB(sptr& sceneSessions, bool visibility); WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) override; + WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect) override; public: std::shared_ptr GetTaskScheduler() {return taskScheduler_;}; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h index 6dfda7020..4973013e1 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h @@ -100,6 +100,7 @@ public: TRANS_ID_ADD_OR_REMOVE_SECURE_SESSION, TRANS_ID_ADD_OR_REMOVE_SECURE_EXT_SESSION, TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS, + TRANS_ID_GET_HOST_WINDOW_RECT, }; virtual WSError SetSessionLabel(const sptr &token, const std::string &label) = 0; @@ -219,6 +220,10 @@ public: { return WSError::WS_OK; } + WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect) override + { + return WSError::WS_OK; + } }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_INTERFACE_H diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h index 98ec59107..22f55bc0d 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h @@ -97,6 +97,7 @@ public: WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) override; WSError AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide) override; WSError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags) override; + WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect) override; private: template diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_stub.h b/window_scene/session_manager/include/zidl/scene_session_manager_stub.h index b0bda9491..d773d91a3 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_stub.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_stub.h @@ -90,6 +90,7 @@ private: int HandleAddOrRemoveSecureSession(MessageParcel& data, MessageParcel& reply); int HandleAddOrRemoveSecureExtSession(MessageParcel& data, MessageParcel& reply); int HandleUpdateExtWindowFlags(MessageParcel& data, MessageParcel& reply); + int HandleGetHostWindowRect(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_STUB_H \ No newline at end of file diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index f6d0a9a14..31911d6f2 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7455,4 +7455,29 @@ void SceneSessionManager::ReportWindowProfileInfos() windowProfileInfo.windowLocatedScreen, windowProfileInfo.windowSceneMode); } } + +WSError SceneSessionManager::GetHostWindowRect(int32_t hostWindowId, Rect& rect) +{ + TLOGI(WmsLogTag::WMS_UIEXT, "GetHostWindowRect, hostWindowId:%{public}d", hostWindowId); + if (!SessionPermission::IsSystemCalling()) { + TLOGE(WmsLogTag::WMS_UIEXT, "GetHostWindowRect permission denied!"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + auto task = [this, hostWindowId, &rect]() { + auto sceneSession = GetSceneSession(hostWindowId); + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_UIEXT, "Session with persistentId %{public}d not found", hostWindowId); + return WSError::WS_ERROR_INVALID_SESSION; + } + if (!sceneSession->GetSessionProperty()) { + TLOGE(WmsLogTag::WMS_UIEXT, "scene session property is nullptr"); + return WSError::WS_ERROR_INVALID_SESSION; + } + Rect persrect = sceneSession->GetSessionProperty()->GetWindowRect(); + rect = persrect; + return WSError::WS_OK; + }; + taskScheduler_->PostSyncTask(task, "GetHostWindowRect"); + return WSError::WS_OK; +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index 3cf269cbf..faaee7da5 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -1583,4 +1583,32 @@ WSError SceneSessionManagerProxy::UpdateExtWindowFlags(int32_t parentId, int32_t } return static_cast(reply.ReadInt32()); } + +WSError SceneSessionManagerProxy::GetHostWindowRect(int32_t hostWindowId, Rect& rect) +{ + TLOGD(WmsLogTag::WMS_UIEXT, "run SceneSessionManagerProxy::GetHostWindowRect"); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed."); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteInt32(hostWindowId)) { + TLOGE(WmsLogTag::WMS_UIEXT, "Write hostWindowId failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (Remote()->SendRequest( + static_cast(SceneSessionManagerMessage::TRANS_ID_GET_HOST_WINDOW_RECT), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest GetHostWindowRect failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + auto PosX = reply.ReadInt32(); + auto PosY = reply.ReadInt32(); + auto height = reply.ReadUint32(); + auto width = reply.ReadUint32(); + rect = {PosX, PosY, height, width}; + return static_cast(reply.ReadInt32()); +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index bcd564580..f2fd60200 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -140,6 +140,8 @@ const std::map SceneSessionManagerStub::s &SceneSessionManagerStub::HandleAddOrRemoveSecureExtSession), std::make_pair(static_cast(SceneSessionManagerMessage::TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS), &SceneSessionManagerStub::HandleUpdateExtWindowFlags), + std::make_pair(static_cast(SceneSessionManagerMessage::TRANS_ID_GET_HOST_WINDOW_RECT), + &SceneSessionManagerStub::HandleGetHostWindowRect), }; int SceneSessionManagerStub::OnRemoteRequest(uint32_t code, @@ -843,4 +845,18 @@ int SceneSessionManagerStub::HandleUpdateExtWindowFlags(MessageParcel &data, Mes reply.WriteInt32(static_cast(ret)); return ERR_NONE; } + +int SceneSessionManagerStub::HandleGetHostWindowRect(MessageParcel &data, MessageParcel &reply) +{ + TLOGI(WmsLogTag::WMS_UIEXT, "run HandleGetHostWindowRect!"); + int32_t hostWindowId = data.ReadInt32(); + Rect rect; + WSError ret = GetHostWindowRect(hostWindowId, rect); + reply.WriteInt32(rect.posX_); + reply.WriteInt32(rect.posY_); + reply.WriteUint32(rect.height_); + reply.WriteUint32(rect.width_); + reply.WriteInt32(static_cast(ret)); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/wm/include/window_adapter.h b/wm/include/window_adapter.h index 18b03a950..77c2b2817 100644 --- a/wm/include/window_adapter.h +++ b/wm/include/window_adapter.h @@ -119,6 +119,7 @@ public: virtual WMError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide); virtual WMError AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide); virtual WMError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags); + virtual WMError GetHostWindowRect(int32_t hostWindowId, Rect& rect); private: static inline SingletonDelegator delegator; bool InitWMSProxy(); diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index 4e69aaba8..d1994368c 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -84,6 +84,7 @@ public: WMError HideNonSecureWindows(bool shouldHide) override; WMError AddExtensionWindowFlag(ExtensionWindowFlag flag) override; WMError RemoveExtensionWindowFlag(ExtensionWindowFlag flag) override; + Rect GetHostWindowRect(int32_t hostWindowId) override; protected: NotifyTransferComponentDataFunc notifyTransferComponentDataFunc_; diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index b48e9e0f4..c749bec75 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -606,5 +606,11 @@ WMError WindowAdapter::UpdateExtWindowFlags(int32_t parentId, int32_t persistent return static_cast(windowManagerServiceProxy_->UpdateExtWindowFlags(parentId, persistentId, extWindowFlags)); } + +WMError WindowAdapter::GetHostWindowRect(int32_t hostWindowId, Rect& rect) +{ + INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING); + return static_cast(windowManagerServiceProxy_->GetHostWindowRect(hostWindowId, rect)); +} } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 4cfce5bd0..8495814ae 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -699,5 +699,16 @@ WMError WindowExtensionSessionImpl::UpdateExtWindowFlags() return SingletonContainer::Get().UpdateExtWindowFlags(property_->GetParentId(), GetPersistentId(), extensionWindowFlags_); } + +Rect WindowExtensionSessionImpl::GetHostWindowRect(int32_t hostWindowId) +{ + Rect rect; + if (hostWindowId != property_->GetParentId()) { + TLOGE(WmsLogTag::WMS_UIEXT, "hostWindowId is invalid"); + return rect; + } + SingletonContainer::Get().GetHostWindowRect(hostWindowId, rect); + return rect; +} } // namespace Rosen } // namespace OHOS diff --git a/wmserver/include/zidl/window_manager_interface.h b/wmserver/include/zidl/window_manager_interface.h index 6385e087e..031f02db4 100644 --- a/wmserver/include/zidl/window_manager_interface.h +++ b/wmserver/include/zidl/window_manager_interface.h @@ -84,6 +84,7 @@ public: TRANS_ID_GET_MAXIMIZE_MODE, TRANS_ID_GET_FOCUS_WINDOW_INFO, TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS, + TRANS_ID_GET_HOST_WINDOW_RECT, }; virtual WMError CreateWindow(sptr& window, sptr& property, const std::shared_ptr& surfaceNode, @@ -201,6 +202,10 @@ public: { return WSError::WS_OK; } + virtual WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect) + { + return WSError::WS_OK; + } }; } } -- Gitee From a1f726b8f44e41990a161955387d274d70ec8057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Sat, 30 Mar 2024 16:13:17 +0800 Subject: [PATCH 279/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 5 ++--- interfaces/kits/napi/window_runtime/window_napi/js_window.h | 1 + wm/include/window_scene_session_impl.h | 2 +- wm/src/window_scene_session_impl.cpp | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 029d1d296..61b653963 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -5407,16 +5407,15 @@ napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) wptr weakToken(windowToken_); NapiAsyncTask::CompleteCallback complete = [weakToken, windowMask](napi_env env, NapiAsyncTask& task, int32_t status) { - WmErrorCode wmErrorCode; auto weakWindow = weakToken.promote(); if (weakWindow == nullptr) { - wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; + WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_STATE_ABNORMALLY; task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "Invalidate params")); return; } if (!WindowHelper::IsSubWindow(weakWindow->GetType()) && !WindowHelper::IsAppFloatingWindow(weakWindow->GetType())) { - wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; + WmErrorCode wmErrorCode = WmErrorCode::WM_ERROR_INVALID_CALLING; task.Reject(env, CreateJsError(env, static_cast(wmErrorCode), "Invalidate window type")); return; } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 03032400e..58f5eddb8 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -148,6 +148,7 @@ public: static napi_value GetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetTitleButtonRect(napi_env env, napi_callback_info info); static napi_value SetWindowMask(napi_env env, napi_callback_info info); + private: std::string GetWindowName(); static bool ParseScaleOption(napi_env env, napi_value jsObject, Transform& trans); diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 0b82e4967..299a0cffa 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -140,7 +140,7 @@ public: void ConsumeKeyEvent(std::shared_ptr& keyEvent) override; WSError NotifyDialogStateChange(bool isForeground) override; WMError HideNonSecureWindows(bool shouldHide) override; - virtual WMError SetWindowMask(const std::vector>& windowMsak) override; + virtual WMError SetWindowMask(const std::vector>& windowMask) override; protected: void DestroySubWindow(); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 5314d78a7..2849c4047 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2842,7 +2842,7 @@ std::unique_ptr WindowSceneSessionImpl::HandleWindowMask( opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE; opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE; uint32_t length = maskWidth * maskHeight; - uint32_t *data = new (std::nothrow) uint32_t[length]; + uint32_t* data = new (std::nothrow) uint32_t[length]; if (data == nullptr) { WLOGFE("data is nullptr"); return nullptr; @@ -2860,7 +2860,7 @@ std::unique_ptr WindowSceneSessionImpl::HandleWindowMask( WMError WindowSceneSessionImpl::SetWindowMask(const std::vector>& windowMask) { - WLOGFI("SetWindowMask, WindowId : %{public}u", GetWindowId()); + WLOGFI("SetWindowMask, WindowId: %{public}u", GetWindowId()); if (IsWindowSessionInvalid()) { WLOGFE("session is invalid"); return WMError::WM_ERROR_INVALID_WINDOW; @@ -2872,7 +2872,7 @@ WMError WindowSceneSessionImpl::SetWindowMask(const std::vector(*mask)); + auto rsMask = RSMask::CreatePixelMapMask(std::make_shared(*mask)); surfaceNode_->SetCornerRadius(0.0f); surfaceNode_->SetShadowRadius(0.0f); surfaceNode_->SetMask(RSMask); // RS interface to set mask -- Gitee From b4b3b8cc805cf68cad73ab024fb8efbf1c2cd38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=AA=A5=E8=B6=8A?= <2394868634@qq.com> Date: Sat, 30 Mar 2024 16:15:18 +0800 Subject: [PATCH 280/385] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 周骥越 <2394868634@qq.com> --- wm/src/window_scene_session_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 2849c4047..a72e77240 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -2875,7 +2875,7 @@ WMError WindowSceneSessionImpl::SetWindowMask(const std::vector(*mask)); surfaceNode_->SetCornerRadius(0.0f); surfaceNode_->SetShadowRadius(0.0f); - surfaceNode_->SetMask(RSMask); // RS interface to set mask + surfaceNode_->SetMask(rsMask); // RS interface to set mask RSTransaction::FlushImplicitTransaction(); property_->SetWindowMask(mask); -- Gitee From e570f977dd259f04dec31d0a06ddd6d35e5679a8 Mon Sep 17 00:00:00 2001 From: chengyiyi Date: Sat, 30 Mar 2024 09:36:39 +0000 Subject: [PATCH 281/385] update interfaces/kits/napi/window_runtime/window_napi/js_window.cpp. Signed-off-by: chengyiyi --- .../kits/napi/window_runtime/window_napi/js_window.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 260200b7d..646edbe60 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -4805,12 +4805,11 @@ napi_value JsWindow::OnSetHandwritingFlag(napi_env env, napi_callback_info info) WLOGFE("SetHandwritingFlag Invalid window flag"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - bool isAddFlag = false; napi_get_value_bool(env, nativeBool, &isAddFlag); wptr weakToken(windowToken_); std::shared_ptr errCodePtr = std::make_shared(WmErrorCode::WM_OK); - NapiAsyncTask::ExecuteCallback execute = [weakToken, isAddFlag, errCodePtr] () { + NapiAsyncTask::ExecuteCallback execute = [weakToken, isAddFlag, errCodePtr]() { if (errCodePtr == nullptr) { return; } @@ -4829,7 +4828,7 @@ napi_value JsWindow::OnSetHandwritingFlag(napi_env env, napi_callback_info info) [weakToken, isAddFlag, errCodePtr](napi_env env, NapiAsyncTask& task, int32_t status) { if (errCodePtr == nullptr) { task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), - "System abnormal.")); + "System abnormal.")); return; } if (*errCodePtr == WmErrorCode::WM_OK) { -- Gitee From b25ca9359ddd01e2bb9a62fae9e1a623a251704a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Sat, 30 Mar 2024 17:37:36 +0800 Subject: [PATCH 282/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 170ec7e77..29cc2190b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6034,7 +6034,7 @@ WSError SceneSessionManager::GetFocusSessionToken(sptr &token) return taskScheduler_->PostSyncTask(task, "GetFocusSessionToken"); } -WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName &elemnt) +WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName &element) { auto task = [this, &token]() { WLOGFD("run GetFocusSessionElement with focusedSessionId: %{public}d", focusedSessionId_); @@ -6043,7 +6043,7 @@ WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName &ele auto sessionInfo = sceneSession->GetSessionInfo(); AAFwk::Want want; want.SetElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); - element = want.getElement; + element = want.getElement(); return WSError::WS_OK; } return WSError::WS_ERROR_INVALID_SESSION; -- Gitee From 8a63cd4bc415b6ffcfddf5e303a860b3bed0f845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Sat, 30 Mar 2024 17:40:22 +0800 Subject: [PATCH 283/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- window_scene/session_manager/include/scene_session_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 77b327261..32a37fed3 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -192,8 +192,8 @@ public: WSError PendingSessionToForeground(const sptr &token) override; WSError PendingSessionToBackgroundForDelegator(const sptr &token) override; WSError GetFocusSessionToken(sptr &token) override; - WSError GetFocusSessionElement(AppExecFwk::ElementName &elemnt); - + WSError GetFocusSessionElement(AppExecFwk::ElementName &element); + WSError RegisterSessionListener(const sptr& listener) override; WSError UnRegisterSessionListener(const sptr& listener) override; WSError GetSessionInfos(const std::string& deviceId, int32_t numMax, -- Gitee From 2bbeda37bd658bdaeb4843471623d0d6f6737419 Mon Sep 17 00:00:00 2001 From: l30030525 Date: Sat, 30 Mar 2024 18:03:14 +0800 Subject: [PATCH 284/385] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=AE=BF=E4=B8=BB?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BD=8D=E7=BD=AE=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- .../session_manager/src/scene_session_manager.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 31911d6f2..b21aacc07 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7469,12 +7469,8 @@ WSError SceneSessionManager::GetHostWindowRect(int32_t hostWindowId, Rect& rect) TLOGE(WmsLogTag::WMS_UIEXT, "Session with persistentId %{public}d not found", hostWindowId); return WSError::WS_ERROR_INVALID_SESSION; } - if (!sceneSession->GetSessionProperty()) { - TLOGE(WmsLogTag::WMS_UIEXT, "scene session property is nullptr"); - return WSError::WS_ERROR_INVALID_SESSION; - } - Rect persrect = sceneSession->GetSessionProperty()->GetWindowRect(); - rect = persrect; + WSRect persrect = sceneSession->GetSessionRect(); + rect = {persrect.posX_, persrect.posY_, persrect.width_, persrect.height_ }; return WSError::WS_OK; }; taskScheduler_->PostSyncTask(task, "GetHostWindowRect"); -- Gitee From 28964cbc2ef7af37bf09ec8f6de34100a569e1e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E7=80=9A=E6=9E=970424?= Date: Sat, 30 Mar 2024 18:07:51 +0800 Subject: [PATCH 285/385] =?UTF-8?q?=E6=96=B0=E5=A2=9Etdd=E6=A1=88=E4=BE=8B?= =?UTF-8?q?session=5Fstub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 闫瀚林0424 Change-Id: I93edc6caed4694f906717ef5b0e88e2c09e6a929 --- .../test/unittest/session_stub_test.cpp | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index 5378bb6ce..b0fa43acb 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -287,6 +287,107 @@ HWTEST_F(SessionStubTest, HandleUpdateRectChangeListenerRegistered008, Function auto res = session_->HandleUpdateRectChangeListenerRegistered(data, reply); ASSERT_EQ(-1, res); } + +/** + * @tc.name: HandleShow009 + * @tc.desc: sessionStub sessionStubTest + * @tc.type: FUNC + * @tc.require: #I6JLSI + */ +HWTEST_F(SessionStubTest, HandleShow009, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + data.WriteBool(true); + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + auto res = session_->HandleShow(data, reply); + ASSERT_EQ(0, res); +} + +/** + * @tc.name: HandleHide010 + * @tc.desc: sessionStub sessionStubTest + * @tc.type: FUNC + * @tc.require: #I6JLSI + */ +HWTEST_F(SessionStubTest, HandleHide010, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + data.WriteBool(true); + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + auto res = session_->HandleHide(data, reply); + ASSERT_EQ(0, res); +} + +/** + * @tc.name: HandlePendingSessionActivation011 + * @tc.desc: sessionStub sessionStubTest + * @tc.type: FUNC + * @tc.require: #I6JLSI + */ +HWTEST_F(SessionStubTest, HandlePendingSessionActivation011, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + data.WriteBool(true); + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + AAFwk::Want options; + EXPECT_NE(data.WriteString("HandlePendingSessionActivation"), false); + EXPECT_NE(data.WriteParcelable(&options), false); + ASSERT_EQ(data.WriteUint32(1), true); + ASSERT_EQ(data.WriteUint64(2), true); + auto res = session_->HandlePendingSessionActivation(data, reply); + ASSERT_EQ(0, res); +} + +/** + * @tc.name: HandleNotifySyncOn012 + * @tc.desc: sessionStub sessionStubTest + * @tc.type: FUNC + * @tc.require: #I6JLSI + */ +HWTEST_F(SessionStubTest, HandleNotifySyncOn012, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + data.WriteBool(true); + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + auto res = session_->HandleNotifySyncOn(data, reply); + ASSERT_EQ(0, res); +} + +/** + * @tc.name: HandleNotifyAsyncOn013 + * @tc.desc: sessionStub sessionStubTest + * @tc.type: FUNC + * @tc.require: #I6JLSI + */ +HWTEST_F(SessionStubTest, HandleNotifyAsyncOn013, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + data.WriteBool(true); + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + auto res = session_->HandleNotifyAsyncOn(data, reply); + ASSERT_EQ(0, res); +} + +/** + * @tc.name: HandleNotifyExtensionTimeout014 + * @tc.desc: sessionStub sessionStubTest + * @tc.type: FUNC + * @tc.require: #I6JLSI + */ +HWTEST_F(SessionStubTest, HandleNotifyExtensionTimeout014, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + data.WriteBool(true); + sptr iRemoteObjectMocker = new IRemoteObjectMocker(); + auto res = session_->HandleNotifyExtensionTimeout(data, reply); + ASSERT_EQ(0, res); +} } } // namespace Rosen } // namespace OHOS \ No newline at end of file -- Gitee From 44ab55588c6fa131d6ec710100840574caa5468f Mon Sep 17 00:00:00 2001 From: s30053401 Date: Sat, 30 Mar 2024 18:47:51 +0800 Subject: [PATCH 286/385] =?UTF-8?q?libwm=5Flite=E6=96=B0=E5=A2=9E=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- interfaces/innerkits/wm/window_manager_lite.h | 63 ++++ window_scene/session_manager/BUILD.gn | 7 +- .../include/scene_session_manager_lite.h | 6 + .../scene_session_manager_lite_interface.h | 7 + .../zidl/scene_session_manager_lite_proxy.h | 6 + .../zidl/scene_session_manager_lite_stub.h | 4 + .../src/scene_session_manager_lite.cpp | 22 ++ .../zidl/scene_session_manager_lite_proxy.cpp | 112 +++++++ .../zidl/scene_session_manager_lite_stub.cpp | 66 ++++ wm/BUILD.gn | 91 +++++- wm/include/window_adapter_lite.h | 11 +- wm/include/window_manager_agent_lite.h | 42 +++ wm/src/window_adapter_lite.cpp | 32 +- wm/src/window_manager_agent_lite.cpp | 41 +++ wm/src/window_manager_lite.cpp | 309 +++++++++++++++++- .../zidl/window_manager_lite_interface.h | 11 +- 16 files changed, 803 insertions(+), 27 deletions(-) create mode 100644 wm/include/window_manager_agent_lite.h create mode 100644 wm/src/window_manager_agent_lite.cpp diff --git a/interfaces/innerkits/wm/window_manager_lite.h b/interfaces/innerkits/wm/window_manager_lite.h index 0c6bf3b2d..836eb656a 100644 --- a/interfaces/innerkits/wm/window_manager_lite.h +++ b/interfaces/innerkits/wm/window_manager_lite.h @@ -24,6 +24,9 @@ #include "wm_single_instance.h" #include "wm_common.h" #include "focus_change_info.h" +#include "window_visibility_info.h" +#include "window_drawing_content_info.h" +#include "window_manager.h" namespace OHOS { namespace Rosen { @@ -34,9 +37,45 @@ namespace Rosen { */ class WindowManagerLite { WM_DECLARE_SINGLE_INSTANCE_BASE(WindowManagerLite); +friend class WindowManagerAgentLite; friend class WMSDeathRecipient; friend class SSMDeathRecipient; public: + /** + * @brief Register focus changed listener. + * + * @param listener IFocusChangedListener. + * @return WM_OK means register success, others means register failed. + */ + WMError RegisterFocusChangedListener(const sptr& listener); + /** + * @brief Unregister focus changed listener. + * + * @param listener IFocusChangedListener. + * @return WM_OK means unregister success, others means unregister failed. + */ + WMError UnregisterFocusChangedListener(const sptr& listener); + /** + * @brief Register visibility changed listener. + * + * @param listener IVisibilityChangedListener. + * @return WM_OK means register success, others means register failed. + */ + WMError RegisterVisibilityChangedListener(const sptr& listener); + /** + * @brief Unregister visibility changed listener. + * + * @param listener IVisibilityChangedListener. + * @return WM_OK means unregister success, others means unregister failed. + */ + WMError UnregisterVisibilityChangedListener(const sptr& listener); + /** + * @brief Get visibility window info. + * + * @param infos Visible window infos + * @return WM_OK means get success, others means get failed. + */ + WMError GetVisibilityWindowInfo(std::vector>& infos) const; /** * @brief Get focus window. * @@ -44,12 +83,36 @@ public: * @return FocusChangeInfo object about focus window. */ void GetFocusWindowInfo(FocusChangeInfo& focusInfo); + /** + * @brief Register drawingcontent changed listener. + * + * @param listener IDrawingContentChangedListener. + * @return WM_OK means register success, others means register failed. + */ + WMError RegisterDrawingContentChangedListener(const sptr& listener); + + /** + * @brief Unregister drawingcontent changed listener. + * + * @param listener IDrawingContentChangedListener. + * @return WM_OK means unregister success, others means unregister failed. + */ + WMError UnregisterDrawingContentChangedListener(const sptr& listener); private: WindowManagerLite(); ~WindowManagerLite(); std::recursive_mutex mutex_; + class Impl; + std::unique_ptr pImpl_; bool destroyed_ = false; + void UpdateFocusStatus(uint32_t windowId, const sptr& abilityToken, WindowType windowType, + DisplayId displayId, bool focused) const; + void UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) const; + void UpdateWindowVisibilityInfo( + const std::vector>& windowVisibilityInfos) const; + void UpdateWindowDrawingContentInfo( + const std::vector>& windowDrawingContentInfos) const; void OnRemoteDied(); }; } // namespace Rosen diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index 349858a50..492448ed0 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -21,6 +21,7 @@ config("session_manager_public_config") { "${window_base_path}/interfaces/innerkits/wm", "${window_base_path}/interfaces/include", "${window_base_path}/window_scene", + "${window_base_path}/window_scene/common/include", "${window_base_path}/window_scene/interfaces/include", "${window_base_path}/window_scene/session_manager/include", "${window_base_path}/window_scene/session_manager/include/zidl", @@ -334,7 +335,11 @@ ohos_shared_library("session_manager_lite") { public_configs = [ ":session_manager_public_config" ] - deps = [] + deps = [ + "${window_base_path}/utils:libwmutil", + "${window_base_path}/utils:libwmutil_base", + "${window_base_path}/window_scene/common:window_scene_common", + ] external_deps = [ "ability_base:session_info", diff --git a/window_scene/session_manager/include/scene_session_manager_lite.h b/window_scene/session_manager/include/scene_session_manager_lite.h index e2c892e35..c9ab0c186 100644 --- a/window_scene/session_manager/include/scene_session_manager_lite.h +++ b/window_scene/session_manager/include/scene_session_manager_lite.h @@ -50,6 +50,12 @@ public: WSError MoveSessionsToBackground(const std::vector& sessionIds, std::vector& result) override; void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override; + WMError RegisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent) override; + WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent) override; + WMError CheckWindowId(int32_t windowId, int32_t &pid) override; + WMError GetVisibilityWindowInfo(std::vector>& infos) override; protected: SceneSessionManagerLite() = default; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h index 6209caf41..ee6029fdd 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h @@ -18,6 +18,8 @@ #include #include "interfaces/include/ws_common.h" +#include "interfaces/include/ws_common_inner.h" +#include "common/include/window_session_property.h" #include "session_info.h" #include "mission_listener_interface.h" #include "mission_info.h" @@ -58,6 +60,11 @@ public: TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND, //window manager message TRANS_ID_GET_FOCUS_SESSION_INFO, + TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT, + TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT, + TRANS_ID_GET_WINDOW_INFO, + TRANS_ID_CHECK_WINDOW_ID, + TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID, }; virtual WSError SetSessionLabel(const sptr& token, const std::string& label) = 0; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h index f6fbb8d0a..837ac3e8d 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h @@ -50,6 +50,12 @@ public: WSError ClearAllSessions() override; void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override; + WMError RegisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent) override; + WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent) override; + WMError CheckWindowId(int32_t windowId, int32_t &pid) override; + WMError GetVisibilityWindowInfo(std::vector>& infos) override; private: template diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h index d96136232..6c273df40 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h @@ -56,6 +56,10 @@ private: int HandleMoveSessionsToBackground(MessageParcel& data, MessageParcel& reply); //for window manager service int HandleGetFocusSessionInfo(MessageParcel& data, MessageParcel& reply); + int HandleRegisterWindowManagerAgent(MessageParcel &data, MessageParcel &reply); + int HandleUnregisterWindowManagerAgent(MessageParcel &data, MessageParcel &reply); + int HandleCheckWindowId(MessageParcel &data, MessageParcel &reply); + int HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_STUB_H \ No newline at end of file diff --git a/window_scene/session_manager/src/scene_session_manager_lite.cpp b/window_scene/session_manager/src/scene_session_manager_lite.cpp index 699c107c5..bf98166d7 100644 --- a/window_scene/session_manager/src/scene_session_manager_lite.cpp +++ b/window_scene/session_manager/src/scene_session_manager_lite.cpp @@ -158,4 +158,26 @@ void SceneSessionManagerLite::GetFocusWindowInfo(FocusChangeInfo& focusInfo) { return SceneSessionManager::GetInstance().GetFocusWindowInfo(focusInfo); } + +WMError SceneSessionManagerLite::RegisterWindowManagerAgent(WindowManagerAgentType type, + const sptr & windowManagerAgent) +{ + return SceneSessionManager::GetInstance().RegisterWindowManagerAgent(type, windowManagerAgent); +} + +WMError SceneSessionManagerLite::UnregisterWindowManagerAgent(WindowManagerAgentType type, + const sptr & windowManagerAgent) +{ + return SceneSessionManager::GetInstance().UnregisterWindowManagerAgent(type, windowManagerAgent); +} + +WMError SceneSessionManagerLite::CheckWindowId(int32_t windowId, int32_t& pid) +{ + return SceneSessionManager::GetInstance().CheckWindowId(windowId, pid); +} + +WMError SceneSessionManagerLite::GetVisibilityWindowInfo(std::vector >& infos) +{ + return SceneSessionManager::GetInstance().GetVisibilityWindowInfo(infos); +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp index 5042c924e..36adde9f2 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp @@ -22,6 +22,7 @@ #include "marshalling_helper.h" #include "window_manager_hilog.h" +#include "window_session_property.h" namespace OHOS::Rosen { namespace { @@ -586,4 +587,115 @@ void SceneSessionManagerLiteProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo } } +WMError SceneSessionManagerLiteProxy::RegisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent) +{ + MessageOption option; + MessageParcel reply; + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("Write InterfaceToken failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!data.WriteUint32(static_cast(type))) { + WLOGFE("Write type failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) { + WLOGFE("Write IWindowManagerAgent failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (Remote()->SendRequest(static_cast( + SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT), data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + + return static_cast(reply.ReadInt32()); +} + +WMError SceneSessionManagerLiteProxy::UnregisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent) +{ + MessageParcel reply; + MessageOption option; + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("Write InterfaceToken failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!data.WriteUint32(static_cast(type))) { + WLOGFE("Write type failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) { + WLOGFE("Write IWindowManagerAgent failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (Remote()->SendRequest(static_cast( + SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT), data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + + return static_cast(reply.ReadInt32()); +} + +WMError SceneSessionManagerLiteProxy::CheckWindowId(int32_t windowId, int32_t &pid) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("Failed to write interfaceToken"); + return WMError::WM_ERROR_IPC_FAILED; + } + if (!data.WriteInt32(windowId)) { + WLOGFE("Failed to write windowId"); + return WMError::WM_ERROR_IPC_FAILED; + } + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + int32_t ret = remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CHECK_WINDOW_ID), + data, reply, option); + if (ret != ERR_NONE) { + WLOGFE("Send request failed, ret:%{public}d", ret); + return WMError::WM_ERROR_IPC_FAILED; + } + if (!reply.ReadInt32(pid)) { + WLOGFE("Failed to read pid"); + return WMError::WM_ERROR_IPC_FAILED; + } + return WMError::WM_OK; +} + +WMError SceneSessionManagerLiteProxy::GetVisibilityWindowInfo(std::vector>& infos) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("GetVisibilityWindowInfo Write interfaceToken failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + if (Remote()->SendRequest(static_cast( + SceneSessionManagerLiteMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID), data, reply, option) != ERR_NONE) { + return WMError::WM_ERROR_IPC_FAILED; + } + if (!MarshallingHelper::UnmarshallingVectorParcelableObj(reply, infos)) { + WLOGFE("read visibility window infos failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + return static_cast(reply.ReadInt32()); +} + } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index ffdb94f94..4c93ebd4b 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -68,6 +68,14 @@ const std::map SceneSessionManagerLit // for window manager service std::make_pair(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_INFO), &SceneSessionManagerLiteStub::HandleGetFocusSessionInfo), + std::make_pair(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT), + &SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent), + std::make_pair(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT), + &SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent), + std::make_pair(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CHECK_WINDOW_ID), + &SceneSessionManagerLiteStub::HandleCheckWindowId), + std::make_pair(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID), + &SceneSessionManagerLiteStub::HandleGetVisibilityWindowInfo), }; int SceneSessionManagerLiteStub::OnRemoteRequest(uint32_t code, @@ -304,4 +312,62 @@ int SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(MessageParcel& data, return ERR_NONE; } +int SceneSessionManagerLiteStub::HandleCheckWindowId(MessageParcel &data, MessageParcel &reply) +{ + WLOGFI("run HandleCheckWindowId!"); + int32_t windowId = INVALID_WINDOW_ID; + if (!data.ReadInt32(windowId)) { + WLOGE("Failed to readInt32 windowId"); + return ERR_INVALID_DATA; + } + int32_t pid = INVALID_PID; + WMError errCode = CheckWindowId(windowId, pid); + if (errCode != WMError::WM_OK) { + WLOGE("Failed to checkWindowId(%{public}d)", pid); + return ERR_INVALID_DATA; + } + if (!reply.WriteInt32(pid)) { + WLOGE("Failed to WriteInt32 pid"); + return ERR_INVALID_DATA; + } + return ERR_NONE; +} + + +int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel &data, MessageParcel &reply) +{ + WLOGFI("[Test]run HandleRegisterWindowManagerAgent!"); + auto type = static_cast(data.ReadUint32()); + sptr windowManagerAgentObject = data.ReadRemoteObject(); + sptr windowManagerAgentProxy = + iface_cast(windowManagerAgentObject); + WMError errCode = RegisterWindowManagerAgent(type, windowManagerAgentProxy); + reply.WriteInt32(static_cast(errCode)); + return ERR_NONE; +} + +int SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent(MessageParcel &data, MessageParcel &reply) +{ + WLOGFI("[Test]run HandleUnregisterWindowManagerAgent!"); + auto type = static_cast(data.ReadUint32()); + sptr windowManagerAgentObject = data.ReadRemoteObject(); + sptr windowManagerAgentProxy = + iface_cast(windowManagerAgentObject); + WMError errCode = UnregisterWindowManagerAgent(type, windowManagerAgentProxy); + reply.WriteInt32(static_cast(errCode)); + return ERR_NONE; +} + +int SceneSessionManagerLiteStub::HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply) +{ + std::vector> infos; + WMError errCode = GetVisibilityWindowInfo(infos); + if (!MarshallingHelper::MarshallingVectorParcelableObj(reply, infos)) { + WLOGFE("Write visibility window infos failed"); + return -1; + } + reply.WriteInt32(static_cast(errCode)); + return ERR_NONE; +} + } // namespace OHOS::Rosen diff --git a/wm/BUILD.gn b/wm/BUILD.gn index 7a510ad5d..08d284ab1 100644 --- a/wm/BUILD.gn +++ b/wm/BUILD.gn @@ -312,34 +312,89 @@ ohos_shared_library("libwm") { ## Build libwm_lite.so ohos_shared_library("libwm_lite") { - include_dirs = [ "../utils/include" ] - sources = [ - "src/window_adapter_lite.cpp", - "src/window_manager_lite.cpp", - "src/window_option.cpp", - ] - - configs = [ - ":libwm_private_config", - "../resources/config/build:coverage_flags", - ] - - public_configs = [ ":libwm_public_config" ] - - deps = [ - "${window_base_path}/utils:libwmutil_base", - "${window_base_path}/window_scene/session_manager:session_manager_lite", - ] + defines = [] + if (scene_board_enabled) { + defines += [ "USE_ADAPTER_LITE" ] + include_dirs = [ + "../utils/include", + "${accessibility_path}/interfaces/innerkits/common/include/", + ] + sources = [ + "src/window_adapter_lite.cpp", + "src/window_manager_agent_lite.cpp", + "src/window_manager_lite.cpp", + "src/window_option.cpp", + "src/zidl/window_manager_agent_stub.cpp", + ] + + configs = [ + ":libwm_private_config", + "../resources/config/build:coverage_flags", + ] + + public_configs = [ ":libwm_public_config" ] + + deps = [ + "${window_base_path}/utils:libwmutil", + "${window_base_path}/window_scene/interfaces/innerkits:libwsutils", + "${window_base_path}/window_scene/session_manager:session_manager_lite", + ] + + public_deps = [ "${window_base_path}/utils:libwmutil_base" ] + } external_deps = [ + "accessibility:accessibility_common", "bundle_framework:appexecfwk_core", "c_utils:utils", "hilog:libhilog", "init:libbegetutil", + "input:libmmi-client", "ipc:ipc_single", "samgr:samgr_proxy", ] + if (efficiency_manager_enable) { + external_deps += [ "efficiency_manager:suspend_manager_client" ] + defines += [ "EFFICIENCY_MANAGER_ENABLE" ] + } + + if (defined(global_parts_info)) { + if (defined( + global_parts_info.hmosresourceschedule_frame_aware_sched_override)) { + defines += [ "FRAME_TRACE_ENABLE" ] + external_deps += [ "frame_aware_sched_override:frame_trace_intf" ] + } else if (defined(global_parts_info.resourceschedule_frame_aware_sched)) { + defines += [ "FRAME_TRACE_ENABLE" ] + external_deps += [ "frame_aware_sched:frame_trace_intf" ] + } + } + + if (defined(global_parts_info) && + defined(global_parts_info.resourceschedule_resource_schedule_service)) { + external_deps += [ "resource_schedule_service:ressched_client" ] + defines += [ "RESOURCE_SCHEDULE_SERVICE_ENABLE" ] + } + + if (!defined(global_parts_info) || + defined(global_parts_info.inputmethod_imf)) { + imf_enable = true + } else { + imf_enable = false + } + + if (defined(global_parts_info) && + defined(global_parts_info.powermgr_power_manager)) { + external_deps += [ "power_manager:powermgr_client" ] + defines += [ "POWER_MANAGER_ENABLE" ] + } + print("imf_enable: ", imf_enable) + + if (imf_enable == true) { + external_deps += [ "imf:inputmethod_client" ] + defines += [ "IMF_ENABLE" ] + } + part_name = "window_manager" subsystem_name = "window" } diff --git a/wm/include/window_adapter_lite.h b/wm/include/window_adapter_lite.h index c94c7a492..a6e6671b6 100644 --- a/wm/include/window_adapter_lite.h +++ b/wm/include/window_adapter_lite.h @@ -17,7 +17,10 @@ #define OHOS_WINDOW_ADAPTER_LITE_H #include +#include +#include "singleton_delegator.h" +#include "window_property.h" #include "wm_single_instance.h" #include "zidl/window_manager_lite_interface.h" @@ -32,9 +35,15 @@ class WindowAdapterLite { WM_DECLARE_SINGLE_INSTANCE(WindowAdapterLite); public: virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo); - + virtual WMError RegisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent); + virtual WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent); + virtual WMError CheckWindowId(int32_t windowId, int32_t &pid); + virtual WMError GetVisibilityWindowInfo(std::vector>& infos); virtual void ClearWindowAdapter(); private: + static inline SingletonDelegator delegator; bool InitSSMProxy(); std::recursive_mutex mutex_; diff --git a/wm/include/window_manager_agent_lite.h b/wm/include/window_manager_agent_lite.h new file mode 100644 index 000000000..3fa5ead87 --- /dev/null +++ b/wm/include/window_manager_agent_lite.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_WINDOW_MANAGER_AGENT_LITE_H +#define OHOS_WINDOW_MANAGER_AGENT_LITE_H + +#include "window_manager_lite.h" +#include "zidl/window_manager_agent_stub.h" + +namespace OHOS { +namespace Rosen { +class WindowManagerAgentLite : public WindowManagerAgentStub { +public: + WindowManagerAgentLite() = default; + ~WindowManagerAgentLite() = default; + + void UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) override; + void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& props) override {}; + void NotifyAccessibilityWindowInfo(const std::vector>& infos, + WindowUpdateType type) override {}; + void UpdateWindowVisibilityInfo(const std::vector>& visibilityInfos) override; + void UpdateWindowDrawingContentInfo( + const std::vector>& windowDrawingContentInfos) override; + void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override {}; + void NotifyWaterMarkFlagChangedResult(bool showWaterMark) override {}; + void NotifyGestureNavigationEnabledResult(bool enable) override {}; +}; +} // namespace Rosen +} // namespace OHOS +#endif // OHOS_WINDOW_MANAGER_AGENT_H diff --git a/wm/src/window_adapter_lite.cpp b/wm/src/window_adapter_lite.cpp index e3d044116..306466e5a 100644 --- a/wm/src/window_adapter_lite.cpp +++ b/wm/src/window_adapter_lite.cpp @@ -14,11 +14,12 @@ */ #include "window_adapter_lite.h" +#include #include "window_manager_hilog.h" +#include "wm_common.h" +#include "scene_board_judgement.h" #include "session_manager_lite.h" #include "focus_change_info.h" -#include "singleton_delegator.h" - namespace OHOS { namespace Rosen { @@ -35,6 +36,32 @@ WM_IMPLEMENT_SINGLE_INSTANCE(WindowAdapterLite) } \ } while (false) +WMError WindowAdapterLite::RegisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent) +{ + INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); + return windowManagerServiceProxy_->RegisterWindowManagerAgent(type, windowManagerAgent); +} + +WMError WindowAdapterLite::UnregisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent) +{ + INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); + return windowManagerServiceProxy_->UnregisterWindowManagerAgent(type, windowManagerAgent); +} + +WMError WindowAdapterLite::CheckWindowId(int32_t windowId, int32_t &pid) +{ + INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); + return windowManagerServiceProxy_->CheckWindowId(windowId, pid); +} + +WMError WindowAdapterLite::GetVisibilityWindowInfo(std::vector>& infos) +{ + INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); + return windowManagerServiceProxy_->GetVisibilityWindowInfo(infos); +} + bool WindowAdapterLite::InitSSMProxy() { std::lock_guard lock(mutex_); @@ -66,7 +93,6 @@ void WindowAdapterLite::ClearWindowAdapter() if ((windowManagerServiceProxy_ != nullptr) && (windowManagerServiceProxy_->AsObject() != nullptr)) { windowManagerServiceProxy_->AsObject()->RemoveDeathRecipient(wmsDeath_); } - std::lock_guard lock(mutex_); isProxyValid_ = false; } diff --git a/wm/src/window_manager_agent_lite.cpp b/wm/src/window_manager_agent_lite.cpp new file mode 100644 index 000000000..7dc23e922 --- /dev/null +++ b/wm/src/window_manager_agent_lite.cpp @@ -0,0 +1,41 @@ + +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "window_manager_agent_lite.h" +#include "foundation/window/window_manager/interfaces/innerkits/wm/window_manager_lite.h" +#include "singleton_container.h" +#include "wm_common.h" + +namespace OHOS { +namespace Rosen { +void WindowManagerAgentLite::UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) +{ + SingletonContainer::Get().UpdateFocusChangeInfo(focusChangeInfo, focused); +} + +void WindowManagerAgentLite::UpdateWindowVisibilityInfo(const std::vector>& visibilityInfos) +{ + SingletonContainer::Get().UpdateWindowVisibilityInfo(visibilityInfos); +} + +void WindowManagerAgentLite::UpdateWindowDrawingContentInfo( + const std::vector>& windowDrawingContentInfos) +{ + SingletonContainer::Get().UpdateWindowDrawingContentInfo(windowDrawingContentInfos); +} + +} // namespace Rosen +} // namespace OHOS diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index eb76dc641..490c5bd0f 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -18,24 +18,129 @@ #include #include +#include "input_manager.h" + #include "marshalling_helper.h" #include "window_adapter_lite.h" +#include "window_manager_agent_lite.h" #include "window_manager_hilog.h" #include "wm_common.h" #include "i_window_checker.h" -#include "singleton_delegator.h" - namespace OHOS { namespace Rosen { namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowManagerLite"}; +struct WindowChecker : public MMI::IWindowChecker { +public: + WindowChecker() = default; + ~WindowChecker() = default; + int32_t CheckWindowId(int32_t windowId) const override; +}; } WM_IMPLEMENT_SINGLE_INSTANCE(WindowManagerLite) -WindowManagerLite::WindowManagerLite() +class WindowManagerLite::Impl { +public: + explicit Impl(std::recursive_mutex& mutex) : mutex_(mutex) {} + void NotifyFocused(uint32_t windowId, const sptr& abilityToken, + WindowType windowType, DisplayId displayId); + void NotifyUnfocused(uint32_t windowId, const sptr& abilityToken, + WindowType windowType, DisplayId displayId); + void NotifyFocused(const sptr& focusChangeInfo); + void NotifyUnfocused(const sptr& focusChangeInfo); + void NotifyWindowVisibilityInfoChanged(const std::vector>& windowVisibilityInfos); + void NotifyWindowDrawingContentInfoChanged(const std::vector>& + windowDrawingContentInfos); + + static inline SingletonDelegator delegator_; + + std::recursive_mutex& mutex_; + std::vector> focusChangedListeners_; + sptr focusChangedListenerAgent_; + std::vector> windowUpdateListeners_; + sptr windowUpdateListenerAgent_; + std::vector> windowVisibilityListeners_; + sptr windowVisibilityListenerAgent_; + std::vector> windowDrawingContentListeners_; + sptr windowDrawingContentListenerAgent_; +}; + +void WindowManagerLite::Impl::NotifyFocused(const sptr& focusChangeInfo) +{ + WLOGFD("[WMSFocus]NotifyFocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", + focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, + static_cast(focusChangeInfo->windowType_)); + std::vector> focusChangeListeners; + { + std::lock_guard lock(mutex_); + focusChangeListeners = focusChangedListeners_; + } + WLOGFD("NotifyFocused listeners: %{public}zu", focusChangeListeners.size()); + for (auto& listener : focusChangeListeners) { + listener->OnFocused(focusChangeInfo); + } +} + +void WindowManagerLite::Impl::NotifyUnfocused(const sptr& focusChangeInfo) +{ + WLOGFD("[WMSFocus]NotifyUnfocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", + focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, + static_cast(focusChangeInfo->windowType_)); + std::vector> focusChangeListeners; + { + std::lock_guard lock(mutex_); + focusChangeListeners = focusChangedListeners_; + } + WLOGFD("NotifyUnfocused listeners: %{public}zu", focusChangeListeners.size()); + for (auto& listener : focusChangeListeners) { + listener->OnUnfocused(focusChangeInfo); + } +} + +void WindowManagerLite::Impl::NotifyWindowVisibilityInfoChanged( + const std::vector>& windowVisibilityInfos) +{ + std::vector> visibilityChangeListeners; + { + std::lock_guard lock(mutex_); + visibilityChangeListeners = windowVisibilityListeners_; + } + for (auto& listener : visibilityChangeListeners) { + WLOGD("Notify WindowVisibilityInfo to caller"); + listener->OnWindowVisibilityChanged(windowVisibilityInfos); + } +} + +void WindowManagerLite::Impl::NotifyWindowDrawingContentInfoChanged( + const std::vector>& windowDrawingContentInfos) +{ + std::vector> windowDrawingContentChangeListeners; + { + std::lock_guard lock(mutex_); + windowDrawingContentChangeListeners = windowDrawingContentListeners_; + } + for (auto& listener : windowDrawingContentChangeListeners) { + WLOGFD("Notify windowDrawingContentInfo to caller"); + listener->OnWindowDrawingContentChanged(windowDrawingContentInfos); + } +} + +WindowManagerLite::WindowManagerLite() : pImpl_(std::make_unique(mutex_)) { + auto windowChecker = std::make_shared(); + MMI::InputManager::GetInstance()->SetWindowCheckerHandler(windowChecker); +} + +int32_t WindowChecker::CheckWindowId(int32_t windowId) const +{ + int32_t pid = INVALID_PID; + WMError ret = SingletonContainer::Get().CheckWindowId(windowId, pid); + if (ret != WMError::WM_OK) { + WLOGFE("Window(%{public}d) do not allow styles to be set", windowId); + } + return pid; } WindowManagerLite::~WindowManagerLite() @@ -44,12 +149,153 @@ WindowManagerLite::~WindowManagerLite() destroyed_ = true; } +WMError WindowManagerLite::RegisterFocusChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + WLOGFE("listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + + std::lock_guard lock(pImpl_->mutex_); + WMError ret = WMError::WM_OK; + if (pImpl_->focusChangedListenerAgent_ == nullptr) { + pImpl_->focusChangedListenerAgent_ = new WindowManagerAgentLite(); + ret = SingletonContainer::Get().RegisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS, pImpl_->focusChangedListenerAgent_); + } + if (ret != WMError::WM_OK) { + WLOGFW("RegisterWindowManagerAgent failed !"); + pImpl_->focusChangedListenerAgent_ = nullptr; + } else { + auto iter = std::find(pImpl_->focusChangedListeners_.begin(), pImpl_->focusChangedListeners_.end(), listener); + if (iter != pImpl_->focusChangedListeners_.end()) { + WLOGFW("Listener is already registered."); + return WMError::WM_OK; + } + pImpl_->focusChangedListeners_.push_back(listener); + } + return ret; +} + +WMError WindowManagerLite::UnregisterFocusChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + WLOGFE("listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + + std::lock_guard lock(pImpl_->mutex_); + auto iter = std::find(pImpl_->focusChangedListeners_.begin(), pImpl_->focusChangedListeners_.end(), listener); + if (iter == pImpl_->focusChangedListeners_.end()) { + WLOGFE("could not find this listener"); + return WMError::WM_OK; + } + pImpl_->focusChangedListeners_.erase(iter); + WMError ret = WMError::WM_OK; + if (pImpl_->focusChangedListeners_.empty() && pImpl_->focusChangedListenerAgent_ != nullptr) { + ret = SingletonContainer::Get().UnregisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS, pImpl_->focusChangedListenerAgent_); + if (ret == WMError::WM_OK) { + pImpl_->focusChangedListenerAgent_ = nullptr; + } + } + return ret; +} + +WMError WindowManagerLite::RegisterVisibilityChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + WLOGFE("listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + std::lock_guard lock(pImpl_->mutex_); + WMError ret = WMError::WM_OK; + if (pImpl_->windowVisibilityListenerAgent_ == nullptr) { + pImpl_->windowVisibilityListenerAgent_ = new WindowManagerAgentLite(); + ret = SingletonContainer::Get().RegisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY, + pImpl_->windowVisibilityListenerAgent_); + } + if (ret != WMError::WM_OK) { + WLOGFW("RegisterWindowManagerAgent failed !"); + pImpl_->windowVisibilityListenerAgent_ = nullptr; + } else { + auto iter = std::find(pImpl_->windowVisibilityListeners_.begin(), pImpl_->windowVisibilityListeners_.end(), + listener); + if (iter != pImpl_->windowVisibilityListeners_.end()) { + WLOGFW("Listener is already registered."); + return WMError::WM_OK; + } + pImpl_->windowVisibilityListeners_.emplace_back(listener); + } + return ret; +} + +WMError WindowManagerLite::UnregisterVisibilityChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + WLOGFE("listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + std::lock_guard lock(pImpl_->mutex_); + pImpl_->windowVisibilityListeners_.erase(std::remove_if(pImpl_->windowVisibilityListeners_.begin(), + pImpl_->windowVisibilityListeners_.end(), [listener](sptr registeredListener) { + return registeredListener == listener; + }), pImpl_->windowVisibilityListeners_.end()); + + WMError ret = WMError::WM_OK; + if (pImpl_->windowVisibilityListeners_.empty() && pImpl_->windowVisibilityListenerAgent_ != nullptr) { + ret = SingletonContainer::Get().UnregisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY, + pImpl_->windowVisibilityListenerAgent_); + if (ret == WMError::WM_OK) { + pImpl_->windowVisibilityListenerAgent_ = nullptr; + } + } + return ret; +} + void WindowManagerLite::GetFocusWindowInfo(FocusChangeInfo& focusInfo) { WLOGFI("Get Focus window info lite"); SingletonContainer::Get().GetFocusWindowInfo(focusInfo); } +void WindowManagerLite::UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) const +{ + if (focusChangeInfo == nullptr) { + WLOGFE("focusChangeInfo is nullptr."); + return; + } + WLOGFD("[WMSFocus]window focus change: %{public}d, id: %{public}u", focused, focusChangeInfo->windowId_); + if (focused) { + pImpl_->NotifyFocused(focusChangeInfo); + } else { + pImpl_->NotifyUnfocused(focusChangeInfo); + } +} + +void WindowManagerLite::UpdateWindowVisibilityInfo( + const std::vector>& windowVisibilityInfos) const +{ + pImpl_->NotifyWindowVisibilityInfoChanged(windowVisibilityInfos); +} + +WMError WindowManagerLite::GetVisibilityWindowInfo(std::vector>& infos) const +{ + WMError ret = SingletonContainer::Get().GetVisibilityWindowInfo(infos); + if (ret != WMError::WM_OK) { + WLOGFE("get window visibility info failed"); + } + return ret; +} + +void WindowManagerLite::UpdateWindowDrawingContentInfo( + const std::vector>& windowDrawingContentInfos) const +{ + pImpl_->NotifyWindowDrawingContentInfoChanged(windowDrawingContentInfos); +} + void WindowManagerLite::OnRemoteDied() { WLOGI("wms is died"); @@ -58,6 +304,63 @@ void WindowManagerLite::OnRemoteDied() WLOGE("Already destroyed"); return; } + pImpl_->focusChangedListenerAgent_ = nullptr; + pImpl_->windowUpdateListenerAgent_ = nullptr; + pImpl_->windowVisibilityListenerAgent_ = nullptr; + pImpl_->windowDrawingContentListenerAgent_ = nullptr; +} + +WMError WindowManagerLite::RegisterDrawingContentChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + WLOGFE("listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + std::lock_guard lock(pImpl_->mutex_); + WMError ret = WMError::WM_OK; + if (pImpl_->windowDrawingContentListenerAgent_ == nullptr) { + pImpl_->windowDrawingContentListenerAgent_ = new WindowManagerAgentLite(); + ret = SingletonContainer::Get().RegisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE, + pImpl_->windowDrawingContentListenerAgent_); + } + if (ret != WMError::WM_OK) { + WLOGFW("RegisterWindowManagerAgent failed !"); + pImpl_->windowDrawingContentListenerAgent_ = nullptr; + } else { + auto iter = std::find(pImpl_->windowDrawingContentListeners_.begin(), + pImpl_->windowDrawingContentListeners_.end(), listener); + if (iter != pImpl_->windowDrawingContentListeners_.end()) { + WLOGFW("Listener is already registered."); + return WMError::WM_OK; + } + pImpl_->windowDrawingContentListeners_.emplace_back(listener); + } + return ret; +} + +WMError WindowManagerLite::UnregisterDrawingContentChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + WLOGFE("listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + std::lock_guard lock(pImpl_->mutex_); + pImpl_->windowDrawingContentListeners_.erase(std::remove_if(pImpl_->windowDrawingContentListeners_.begin(), + pImpl_->windowDrawingContentListeners_.end(), + [listener](sptr registeredListener) { return registeredListener == listener; }), + pImpl_->windowDrawingContentListeners_.end()); + + WMError ret = WMError::WM_OK; + if (pImpl_->windowDrawingContentListeners_.empty() && pImpl_->windowDrawingContentListenerAgent_ != nullptr) { + ret = SingletonContainer::Get().UnregisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE, + pImpl_->windowDrawingContentListenerAgent_); + if (ret == WMError::WM_OK) { + pImpl_->windowDrawingContentListenerAgent_ = nullptr; + } + } + return ret; } } // namespace Rosen diff --git a/wmserver/include/zidl/window_manager_lite_interface.h b/wmserver/include/zidl/window_manager_lite_interface.h index fd094d4f3..85309c102 100644 --- a/wmserver/include/zidl/window_manager_lite_interface.h +++ b/wmserver/include/zidl/window_manager_lite_interface.h @@ -18,7 +18,10 @@ #include -#include "focus_change_info.h" +#include "window_property.h" +#include "window_transition_info.h" +#include "zidl/window_manager_agent_interface.h" +#include "interfaces/include/ws_common.h" namespace OHOS { namespace MMI { @@ -30,7 +33,13 @@ class IWindowManagerLite : public IRemoteBroker { public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowManagerLite"); // do not need enum + virtual WMError RegisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent) = 0; + virtual WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, + const sptr& windowManagerAgent) = 0; + virtual WMError GetVisibilityWindowInfo(std::vector>& infos) { return WMError::WM_OK; }; virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo) = 0; + virtual WMError CheckWindowId(int32_t windowId, int32_t &pid) = 0; }; } } -- Gitee From b5d7d33ec13b756a0b2a90d1f8e658e62651fecb Mon Sep 17 00:00:00 2001 From: wanganjie Date: Sat, 30 Mar 2024 19:39:55 +0800 Subject: [PATCH 287/385] =?UTF-8?q?UIExtension=E9=9A=90=E8=97=8F=E9=9D=9E?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E7=AA=97=E5=8F=A3=E6=98=AF=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E9=9D=9E=E5=AE=89=E5=85=A8=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E7=9A=84=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wanganjie --- window_scene/session_manager/src/scene_session_manager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index cfef238ca..2bce70b5a 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1737,6 +1737,13 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_FLOAT && !secureSessionSet_.empty()) || + (SessionHelper::IsSubWindow(property->GetWindowType()) && + secureSessionSet_.find(property->GetParentPersistentId()) != secureSessionSet_.end())) { + TLOGE(WmsLogTag::WMS_UIEXT, "create non-secure windows permission denied!"); + return WSError::WS_ERROR_INVALID_OPERATION; + } + if (SessionPermission::IsStartedByUIExtension() && property->GetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW) { auto extensionParentSession = GetSceneSession(property->GetParentPersistentId()); -- Gitee From 225f699de7da8865748f27bd30c72cfca295453d Mon Sep 17 00:00:00 2001 From: wanganjie Date: Sat, 30 Mar 2024 19:45:22 +0800 Subject: [PATCH 288/385] update Signed-off-by: wanganjie --- 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 2bce70b5a..ac05a219f 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1740,7 +1740,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_FLOAT && !secureSessionSet_.empty()) || (SessionHelper::IsSubWindow(property->GetWindowType()) && secureSessionSet_.find(property->GetParentPersistentId()) != secureSessionSet_.end())) { - TLOGE(WmsLogTag::WMS_UIEXT, "create non-secure windows permission denied!"); + TLOGE(WmsLogTag::WMS_UIEXT, "create non-secure window permission denied!"); return WSError::WS_ERROR_INVALID_OPERATION; } -- Gitee From 99da196ae066600887103ac2b44b3b04003b9956 Mon Sep 17 00:00:00 2001 From: zhangyao Date: Sat, 30 Mar 2024 12:15:12 +0000 Subject: [PATCH 289/385] =?UTF-8?q?Description:=20DMS=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E7=AE=A1?= =?UTF-8?q?=E6=8E=A7=20IssueNo:=20https://gitee.com/openharmony/window=5Fw?= =?UTF-8?q?indow=5Fmanager/issues/I9CX8W=20Feature=20or=20Bugfix:=20Featur?= =?UTF-8?q?e=20Binary=20Source:No=20Signed-off-by:=20zhangyao=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../session_manager/src/screen_session_manager.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index ad87a210c..7b18255c5 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -1057,6 +1057,10 @@ void ScreenSessionManager::NotifyScreenshot(DisplayId displayId) bool ScreenSessionManager::SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + WLOGFE("SetSpecifiedScreenPower permission denied!"); + return false; + } WLOGFI("[UL_POWER]SetSpecifiedScreenPower: screen id:%{public}" PRIu64 ", state:%{public}u", screenId, state); ScreenPowerStatus status; @@ -2900,6 +2904,10 @@ void ScreenSessionManager::NotifyPrivateSessionStateChanged(bool hasPrivate) void ScreenSessionManager::SetScreenPrivacyState(bool hasPrivate) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + WLOGFE("SetScreenPrivacyState permission denied!"); + return; + } WLOGFI("SetScreenPrivacyState enter, hasPrivate: %{public}d", hasPrivate); ScreenId id = GetDefaultScreenId(); auto screenSession = GetScreenSession(id); -- Gitee From e9540f62f912b3be36e84266cb3e1d31cf208ec2 Mon Sep 17 00:00:00 2001 From: z00514981 Date: Thu, 28 Mar 2024 17:20:55 +0800 Subject: [PATCH 290/385] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86=E6=8B=86?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie19ac442d1b08636ab200953765e3d98e32546e2 Signed-off-by: z00514981 --- .../session/host/include/main_session.h | 9 + .../session/host/include/scb_system_session.h | 11 + .../session/host/include/scene_session.h | 3 +- window_scene/session/host/include/session.h | 35 ++- .../session/host/include/sub_session.h | 8 + .../session/host/include/system_session.h | 22 ++ .../session/host/src/main_session.cpp | 80 +++++++ .../session/host/src/scb_system_session.cpp | 97 +++++++++ .../session/host/src/scene_session.cpp | 71 ++++--- window_scene/session/host/src/session.cpp | 201 +----------------- window_scene/session/host/src/sub_session.cpp | 64 ++++++ .../session/host/src/system_session.cpp | 172 ++++++++++++++- 12 files changed, 525 insertions(+), 248 deletions(-) diff --git a/window_scene/session/host/include/main_session.h b/window_scene/session/host/include/main_session.h index 33e978528..ecc762200 100644 --- a/window_scene/session/host/include/main_session.h +++ b/window_scene/session/host/include/main_session.h @@ -24,7 +24,16 @@ public: MainSession(const SessionInfo& info, const sptr& specificCallback); ~MainSession(); + WSError Reconnect(const sptr& sessionStage, const sptr& eventChannel, + const std::shared_ptr& surfaceNode, sptr property = nullptr, + sptr token = nullptr, int32_t pid = -1, int32_t uid = -1) override; WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; + void NotifyForegroundInteractiveStatus(bool interactive) override; + WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; + +protected: + void UpdatePointerArea(const WSRect& rect) override; + bool CheckPointerEventDispatch(const std::shared_ptr& pointerEvent) const override; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_MAIN_SESSION_H diff --git a/window_scene/session/host/include/scb_system_session.h b/window_scene/session/host/include/scb_system_session.h index 64deb5563..6bce13cf0 100644 --- a/window_scene/session/host/include/scb_system_session.h +++ b/window_scene/session/host/include/scb_system_session.h @@ -24,6 +24,17 @@ public: SCBSystemSession(const SessionInfo& info, const sptr& specificCallback); ~SCBSystemSession(); WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; + + WSError NotifyClientToUpdateRect(std::shared_ptr rsTransaction) override; + void PresentFocusIfPointDown() override; + WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; + void PresentFoucusIfNeed(int32_t pointerAcrion) override; + WSError UpdateFocus(bool isFocused) override; + WSError UpdateWindowMode(WindowMode mode) override; + WSError SetSystemSceneBlockingFocus(bool blocking) override; + +protected: + void UpdatePointerArea(const WSRect& rect) override; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SCB_SYSTEM_SESSION_H diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 249cae772..acf5c37bb 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -111,7 +111,7 @@ public: const std::shared_ptr& surfaceNode, SystemSessionConfig& systemConfig, sptr property = nullptr, sptr token = nullptr, int32_t pid = -1, int32_t uid = -1) override; - WSError Reconnect(const sptr& sessionStage, const sptr& eventChannel, + virtual WSError Reconnect(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, sptr property = nullptr, sptr token = nullptr, int32_t pid = -1, int32_t uid = -1); WSError Foreground(sptr property) override; @@ -252,6 +252,7 @@ protected: void NotifyIsCustomAnimationPlaying(bool isPlaying); void SetMoveDragCallback(); std::string GetRatioPreferenceKey(); + WSError NotifyClientToUpdateRectTask(wptr weakThis, std::shared_ptr rsTransaction); std::string GetRectInfo(const WSRect& rect) { diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 9ace5861e..f674f6d51 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -236,7 +236,7 @@ public: void SetSystemConfig(const SystemSessionConfig& systemConfig); void SetSnapshotScale(const float snapshotScale); void SetBackPressedListenser(const NotifyBackPressedFunc& func); - WSError ProcessBackEvent(); // send back event to session_stage + virtual WSError ProcessBackEvent(); // send back event to session_stage WSError MarkProcessed(int32_t eventId) override; sptr GetScenePersistence() const; @@ -265,11 +265,11 @@ public: void NotifyUIRequestFocus(); virtual void NotifyUILostFocus(); bool GetStateFromManager(const ManagerState key); - void PresentFoucusIfNeed(int32_t pointerAcrion); - WSError UpdateFocus(bool isFocused); + virtual void PresentFoucusIfNeed(int32_t pointerAcrion); + virtual WSError UpdateFocus(bool isFocused); WSError NotifyFocusStatus(bool isFocused); - WSError UpdateWindowMode(WindowMode mode); - WSError SetSystemSceneBlockingFocus(bool blocking); + virtual WSError UpdateWindowMode(WindowMode mode); + virtual WSError SetSystemSceneBlockingFocus(bool blocking); bool GetBlockingFocus() const; WSError SetFocusable(bool isFocusable); bool NeedNotify() const; @@ -323,13 +323,13 @@ public: float GetPivotX() const; float GetPivotY() const; - void SetNotifyCallingSessionUpdateRectFunc(const NotifyCallingSessionUpdateRectFunc& func); - void NotifyCallingSessionUpdateRect(); - void SetNotifyCallingSessionForegroundFunc(const NotifyCallingSessionForegroundFunc& func); - void NotifyCallingSessionForeground(); - void SetNotifyCallingSessionBackgroundFunc(const NotifyCallingSessionBackgroundFunc& func); + virtual void SetNotifyCallingSessionUpdateRectFunc(const NotifyCallingSessionUpdateRectFunc& func) { return; }; + virtual void NotifyCallingSessionUpdateRect() { return; }; + virtual void SetNotifyCallingSessionForegroundFunc(const NotifyCallingSessionForegroundFunc& func) { return; }; + virtual void NotifyCallingSessionForeground() { return; }; + virtual void SetNotifyCallingSessionBackgroundFunc(const NotifyCallingSessionBackgroundFunc& func) { return; }; + virtual void NotifyCallingSessionBackground() { return; }; void SetRaiseToAppTopForPointDownFunc(const NotifyRaiseToTopForPointDownFunc& func); - void NotifyCallingSessionBackground(); void NotifyScreenshot(); void RemoveLifeCycleTask(const LifeCycleTaskType &taskType); void PostLifeCycleTask(Task &&task, const std::string &name, const LifeCycleTaskType &taskType); @@ -338,7 +338,7 @@ public: void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits); void HandlePointDownDialog(); bool CheckDialogOnForeground(); - void PresentFocusIfPointDown(); + virtual void PresentFocusIfPointDown(); void ResetSnapshot(); std::shared_ptr GetSnapshotPixelMap(const float oriScale = 1.0f, const float newScale = 1.0f); virtual std::vector GetTouchHotAreas() const @@ -372,7 +372,7 @@ public: WSRectF UpdateHotRect(const WSRect& rect); WSError RaiseToAppTopForPointDown(); - void NotifyForegroundInteractiveStatus(bool interactive); + virtual void NotifyForegroundInteractiveStatus(bool interactive); WSError UpdateTitleInTargetPos(bool isShow, int32_t height); void SetNotifySystemSessionPointerEventFunc(const NotifySystemSessionPointerEventFunc& func); void SetNotifySystemSessionKeyEventFunc(const NotifySystemSessionKeyEventFunc& func); @@ -401,11 +401,9 @@ protected: WSRectF UpdateTopBottomArea(const WSRectF& rect, MMI::WindowArea area); WSRectF UpdateLeftRightArea(const WSRectF& rect, MMI::WindowArea area); WSRectF UpdateInnerAngleArea(const WSRectF& rect, MMI::WindowArea area); - void UpdatePointerArea(const WSRect& rect); - bool CheckPointerEventDispatch(const std::shared_ptr& pointerEvent) const; - bool CheckKeyEventDispatch(const std::shared_ptr& keyEvent) const; + virtual void UpdatePointerArea(const WSRect& rect); + virtual bool CheckPointerEventDispatch(const std::shared_ptr& pointerEvent) const; bool IsTopDialog() const; - bool NeedSystemPermission(WindowType type); void HandlePointDownDialog(int32_t pointAction); void PostTask(Task&& task, const std::string& name = "sessionTask", int64_t delayTime = 0); @@ -472,9 +470,6 @@ protected: NotifySessionSnapshotFunc notifySessionSnapshotFunc_; NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_; NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_; - NotifyCallingSessionUpdateRectFunc notifyCallingSessionUpdateRectFunc_; - NotifyCallingSessionForegroundFunc notifyCallingSessionForegroundFunc_; - NotifyCallingSessionBackgroundFunc notifyCallingSessionBackgroundFunc_; NotifyRaiseToTopForPointDownFunc raiseToTopForPointDownFunc_; NotifySessionInfoLockedStateChangeFunc sessionInfoLockedStateChangeFunc_; NotifySystemSessionPointerEventFunc systemSessionPointerEventFunc_; diff --git a/window_scene/session/host/include/sub_session.h b/window_scene/session/host/include/sub_session.h index 099ce8d40..d26c9cc25 100644 --- a/window_scene/session/host/include/sub_session.h +++ b/window_scene/session/host/include/sub_session.h @@ -26,7 +26,15 @@ public: WSError Show(sptr property) override; WSError Hide() override; + WSError Reconnect(const sptr& sessionStage, const sptr& eventChannel, + const std::shared_ptr& surfaceNode, sptr property = nullptr, + sptr token = nullptr, int32_t pid = -1, int32_t uid = -1) override; WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; + WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; + +protected: + void UpdatePointerArea(const WSRect& rect) override; + bool CheckPointerEventDispatch(const std::shared_ptr& pointerEvent) const override; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SUB_SESSION_H diff --git a/window_scene/session/host/include/system_session.h b/window_scene/session/host/include/system_session.h index 75997ebb2..2950392fb 100644 --- a/window_scene/session/host/include/system_session.h +++ b/window_scene/session/host/include/system_session.h @@ -26,11 +26,33 @@ public: WSError Show(sptr property) override; WSError Hide() override; + WSError Reconnect(const sptr& sessionStage, const sptr& eventChannel, + const std::shared_ptr& surfaceNode, sptr property = nullptr, + sptr token = nullptr, int32_t pid = -1, int32_t uid = -1) override; WSError Disconnect(bool isFromClient = false) override; WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; + void SetNotifyCallingSessionUpdateRectFunc(const NotifyCallingSessionUpdateRectFunc& func) override; + void NotifyCallingSessionUpdateRect() override; + void SetNotifyCallingSessionForegroundFunc(const NotifyCallingSessionForegroundFunc& func) override; + void NotifyCallingSessionForeground() override; + void SetNotifyCallingSessionBackgroundFunc(const NotifyCallingSessionBackgroundFunc& func) override; + void NotifyCallingSessionBackground() override; + WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; + WSError ProcessBackEvent() override; + + WSError NotifyClientToUpdateRect(std::shared_ptr rsTransaction) override; + +protected: + bool CheckKeyEventDispatch(const std::shared_ptr& keyEvent) const; + private: void UpdateCameraFloatWindowStatus(bool isShowing); + bool NeedSystemPermission(WindowType type); + + NotifyCallingSessionUpdateRectFunc notifyCallingSessionUpdateRectFunc_; + NotifyCallingSessionForegroundFunc notifyCallingSessionForegroundFunc_; + NotifyCallingSessionBackgroundFunc notifyCallingSessionBackgroundFunc_; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SYSTEM_SESSION_H diff --git a/window_scene/session/host/src/main_session.cpp b/window_scene/session/host/src/main_session.cpp index b12ad603f..fb63926aa 100644 --- a/window_scene/session/host/src/main_session.cpp +++ b/window_scene/session/host/src/main_session.cpp @@ -17,6 +17,8 @@ #include +#include "key_event.h" +#include "pointer_event.h" #include "session_helper.h" #include "session/host/include/scene_persistent_storage.h" #include "window_manager_hilog.h" @@ -59,6 +61,31 @@ MainSession::~MainSession() WLOGD("~MainSession, id: %{public}d", GetPersistentId()); } +WSError MainSession::Reconnect(const sptr& sessionStage, const sptr& eventChannel, + const std::shared_ptr& surfaceNode, sptr property, sptr token, + int32_t pid, int32_t uid) +{ + return PostSyncTask([weakThis = wptr(this), sessionStage, eventChannel, surfaceNode, property, token, pid, uid]() { + auto session = weakThis.promote(); + if (!session) { + WLOGFE("session is null"); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + WSError ret = session->Session::Reconnect(sessionStage, eventChannel, surfaceNode, property, token, pid, uid); + WindowState windowState = property->GetWindowState(); + if (ret == WSError::WS_OK) { + if (windowState == WindowState::STATE_SHOWN) { + session->isActive_ = true; + session->UpdateSessionState(SessionState::STATE_ACTIVE); + } else { + session->isActive_ = false; + session->UpdateSessionState(SessionState::STATE_BACKGROUND); + } + } + return ret; + }); +} + WSError MainSession::ProcessPointDownSession(int32_t posX, int32_t posY) { const auto& id = GetPersistentId(); @@ -70,4 +97,57 @@ WSError MainSession::ProcessPointDownSession(int32_t posX, int32_t posY) PresentFocusIfPointDown(); return SceneSession::ProcessPointDownSession(posX, posY); } + +void MainSession::NotifyForegroundInteractiveStatus(bool interactive) +{ + SetForegroundInteractiveStatus(interactive); + if (!IsSessionValid() || !sessionStage_) { + return; + } + const auto& state = GetSessionState(); + if (isVisible_ || state == SessionState::STATE_ACTIVE || state == SessionState::STATE_FOREGROUND) { + WLOGFI("NotifyForegroundInteractiveStatus %{public}d", interactive); + sessionStage_->NotifyForegroundInteractiveStatus(interactive); + } +} + +WSError MainSession::TransferKeyEvent(const std::shared_ptr& keyEvent) +{ + if (!IsSessionValid()) { + return WSError::WS_ERROR_INVALID_SESSION; + } + if (keyEvent == nullptr) { + WLOGFE("KeyEvent is nullptr"); + return WSError::WS_ERROR_NULLPTR; + } + if (CheckDialogOnForeground()) { + TLOGD(WmsLogTag::WMS_DIALOG, "Has dialog on foreground, not transfer pointer event"); + return WSError::WS_ERROR_INVALID_PERMISSION; + } + + WSError ret = Session::TransferKeyEvent(keyEvent); + return ret; +} + +void MainSession::UpdatePointerArea(const WSRect& rect) +{ + if (GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING) { + return; + } + Session::UpdatePointerArea(rect); +} + +bool MainSession::CheckPointerEventDispatch(const std::shared_ptr& pointerEvent) const +{ + auto sessionState = GetSessionState(); + int32_t action = pointerEvent->GetPointerAction(); + if (sessionState != SessionState::STATE_FOREGROUND && + sessionState != SessionState::STATE_ACTIVE && + action != MMI::PointerEvent::POINTER_ACTION_LEAVE_WINDOW) { + WLOGFW("Current Session Info: [persistentId: %{public}d, " + "state: %{public}d, action:%{public}d]", GetPersistentId(), state_, action); + return false; + } + return true; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/scb_system_session.cpp b/window_scene/session/host/src/scb_system_session.cpp index cca88bd62..d53fa0c24 100644 --- a/window_scene/session/host/src/scb_system_session.cpp +++ b/window_scene/session/host/src/scb_system_session.cpp @@ -15,6 +15,9 @@ #include "session/host/include/scb_system_session.h" +#include +#include "key_event.h" +#include "pointer_event.h" #include #include "window_manager_hilog.h" @@ -50,4 +53,98 @@ WSError SCBSystemSession::ProcessPointDownSession(int32_t posX, int32_t posY) PresentFocusIfPointDown(); return SceneSession::ProcessPointDownSession(posX, posY); } + +WSError SCBSystemSession::NotifyClientToUpdateRect(std::shared_ptr rsTransaction) +{ + auto task = [weakThis = wptr(this), rsTransaction]() { + auto session = weakThis.promote(); + WSError ret = session->NotifyClientToUpdateRectTask(weakThis, rsTransaction); + if (session->specificCallback_ != nullptr && session->specificCallback_->onUpdateAvoidArea_ != nullptr) { + session->specificCallback_->onUpdateAvoidArea_(session->GetPersistentId()); + } + // clear after use + if (session->reason_ != SizeChangeReason::DRAG) { + session->reason_ = SizeChangeReason::UNDEFINED; + session->isDirty_ = false; + } + return ret; + }; + PostTask(task, "NotifyClientToUpdateRect"); + return WSError::WS_OK; +} + +void SCBSystemSession::PresentFocusIfPointDown() +{ + WLOGFI("PresentFocusIfPointDown, id: %{public}d, type: %{public}d", GetPersistentId(), GetWindowType()); + if (!isFocused_ && GetFocusable()) { + NotifyRequestFocusStatusNotifyManager(true, false); + NotifyClick(); + } +} + +WSError SCBSystemSession::TransferKeyEvent(const std::shared_ptr& keyEvent) +{ + if (keyEvent == nullptr) { + WLOGFE("KeyEvent is nullptr"); + return WSError::WS_ERROR_NULLPTR; + } + + WSError ret = Session::TransferKeyEvent(keyEvent); + return ret; +} + +void SCBSystemSession::PresentFoucusIfNeed(int32_t pointerAction) +{ + WLOGFD("OnClick down, id: %{public}d", GetPersistentId()); + if (pointerAction == MMI::PointerEvent::POINTER_ACTION_DOWN || + pointerAction == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN) { + if (!isFocused_ && GetFocusable()) { + NotifyRequestFocusStatusNotifyManager(true, false); + NotifyClick(); + } + } +} + +WSError SCBSystemSession::UpdateFocus(bool isFocused) +{ + if (isFocused_ == isFocused) { + TLOGD(WmsLogTag::WMS_FOCUS, "Session focus do not change"); + return WSError::WS_DO_NOTHING; + } + isFocused_ = isFocused; + // notify scb arkui focus + if (isFocused) { + HiSysEventWrite( + OHOS::HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER, + "FOCUS_WINDOW", + OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, + "PID", getpid(), + "UID", getuid(), + "BUNDLE_NAME", sessionInfo_.bundleName_); + NotifyUIRequestFocus(); + } else { + NotifyUILostFocus(); + } + return WSError::WS_OK; +} + +WSError SCBSystemSession::UpdateWindowMode(WindowMode mode) +{ + WLOGFD("session is system, id: %{public}d, mode: %{public}d, name: %{public}s, state: %{public}u", + GetPersistentId(), static_cast(mode), sessionInfo_.bundleName_.c_str(), state_); + return WSError::WS_ERROR_INVALID_SESSION; +} + +WSError SCBSystemSession::SetSystemSceneBlockingFocus(bool blocking) +{ + TLOGD(WmsLogTag::WMS_FOCUS, "Session set blocking focus, id: %{public}d, mode: %{public}d", + GetPersistentId(), blocking); + blockingFocus_ = blocking; + return WSError::WS_OK; +} + +void SCBSystemSession::UpdatePointerArea(const WSRect& rect) +{ + return; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index f187fc746..9e686752f 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -451,40 +451,49 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason, return WSError::WS_OK; } +WSError SceneSession::NotifyClientToUpdateRectTask( + wptr weakThis, std::shared_ptr rsTransaction) +{ + auto session = weakThis.promote(); + if (!session) { + WLOGFE("session is null"); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + TLOGD(WmsLogTag::WMS_LAYOUT, "id:%{public}d, reason:%{public}d, rect:%{public}s", + session->GetPersistentId(), session->reason_, session->winRect_.ToString().c_str()); + bool isMoveOrDrag = session->moveDragController_ && + (session->moveDragController_->GetStartDragFlag() || session->moveDragController_->GetStartMoveFlag()); + if (isMoveOrDrag && session->reason_ == SizeChangeReason::UNDEFINED) { + TLOGD(WmsLogTag::WMS_LAYOUT, "skip redundant rect update!"); + return WSError::WS_ERROR_REPEAT_OPERATION; + } + WSError ret = WSError::WS_OK; + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, + "SceneSession::NotifyClientToUpdateRect%d [%d, %d, %u, %u] reason:%u", + session->GetPersistentId(), session->winRect_.posX_, + session->winRect_.posY_, session->winRect_.width_, session->winRect_.height_, session->reason_); + // once reason is undefined, not use rsTransaction + // when rotation, sync cnt++ in marshalling. Although reason is undefined caused by resize + if (session->reason_ == SizeChangeReason::UNDEFINED || session->reason_ == SizeChangeReason::MOVE || + session->reason_ == SizeChangeReason::RESIZE) { + ret = session->Session::UpdateRect(session->winRect_, session->reason_, nullptr); + } else { + ret = session->Session::UpdateRect(session->winRect_, session->reason_, rsTransaction); + } + + return ret; +} + WSError SceneSession::NotifyClientToUpdateRect(std::shared_ptr rsTransaction) { auto task = [weakThis = wptr(this), rsTransaction]() { auto session = weakThis.promote(); - if (!session) { - WLOGFE("session is null"); - return WSError::WS_ERROR_DESTROYED_OBJECT; - } - TLOGD(WmsLogTag::WMS_LAYOUT, "NotifyClientToUpdateRect id:%{public}d, reason:%{public}d, rect:%{public}s", - session->GetPersistentId(), session->reason_, session->winRect_.ToString().c_str()); - bool isMoveOrDrag = session->moveDragController_ && - (session->moveDragController_->GetStartDragFlag() || session->moveDragController_->GetStartMoveFlag()); - if (isMoveOrDrag && session->reason_ == SizeChangeReason::UNDEFINED) { - TLOGD(WmsLogTag::WMS_LAYOUT, "skip redundant rect update!"); - return WSError::WS_ERROR_REPEAT_OPERATION; - } - WSError ret = WSError::WS_OK; - HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, - "SceneSession::NotifyClientToUpdateRect%d [%d, %d, %u, %u] reason:%u", - session->GetPersistentId(), session->winRect_.posX_, - session->winRect_.posY_, session->winRect_.width_, session->winRect_.height_, session->reason_); - // once reason is undefined, not use rsTransaction - // when rotation, sync cnt++ in marshalling. Although reason is undefined caused by resize - if (session->reason_ == SizeChangeReason::UNDEFINED || session->reason_ == SizeChangeReason::MOVE || - session->reason_ == SizeChangeReason::RESIZE) { - ret = session->Session::UpdateRect(session->winRect_, session->reason_, nullptr); - } else { - ret = session->Session::UpdateRect(session->winRect_, session->reason_, rsTransaction); - } - if ((ret == WSError::WS_OK || session->sessionInfo_.isSystem_) && session->specificCallback_ != nullptr) { - session->specificCallback_->onUpdateAvoidArea_(session->GetPersistentId()); - } - // clear after use - if (ret == WSError::WS_OK || session->sessionInfo_.isSystem_) { + WSError ret = session->NotifyClientToUpdateRectTask(weakThis, rsTransaction); + if (ret == WSError::WS_OK) { + if (session->specificCallback_ != nullptr) { + session->specificCallback_->onUpdateAvoidArea_(session->GetPersistentId()); + } + // clear after use if (session->reason_ != SizeChangeReason::DRAG) { session->reason_ = SizeChangeReason::UNDEFINED; session->isDirty_ = false; @@ -982,7 +991,7 @@ WSError SceneSession::HandleEnterWinwdowArea(int32_t displayX, int32_t displayY) auto windowType = Session::GetWindowType(); auto iter = Session::windowAreas_.cend(); - if (!Session::IsSystemSession() && + if (!IsSystemSession() && Session::GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING && (windowType == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW || WindowHelper::IsSubWindow(windowType))) { iter = Session::windowAreas_.cbegin(); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index e6657fb57..1c3c2bb3c 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -686,14 +686,6 @@ WSRectF Session::UpdateHotRect(const WSRect& rect) void Session::UpdatePointerArea(const WSRect& rect) { - if (IsSystemSession()) { - return; - } - if (!((GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW || - (WindowHelper::IsSubWindow(GetWindowType()) && property_->IsDecorEnable())) && - GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING)) { - return; - } if (preRect_ == rect) { WLOGFD("The window area does not change"); return; @@ -742,9 +734,6 @@ WSError Session::UpdateRect(const WSRect& rect, SizeChangeReason reason, WLOGFE("sessionStage_ is nullptr"); } UpdatePointerArea(winRect_); - if (GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { - NotifyCallingSessionUpdateRect(); - } return WSError::WS_OK; } @@ -763,14 +752,6 @@ WSError Session::UpdateDensity() return WSError::WS_OK; } -void Session::NotifyCallingSessionUpdateRect() -{ - if (notifyCallingSessionUpdateRectFunc_) { - WLOGFI("Notify calling window that input method update rect"); - notifyCallingSessionUpdateRectFunc_(persistentId_); - } -} - WSError Session::Connect(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, SystemSessionConfig& systemConfig, sptr property, sptr token, int32_t pid, int32_t uid) @@ -847,19 +828,6 @@ WSError Session::Reconnect(const sptr& sessionStage, const sptrGetPersistentId(); callingPid_ = pid; callingUid_ = uid; - WindowState windowState = property->GetWindowState(); - auto type = property->GetWindowType(); - if (windowState == WindowState::STATE_SHOWN || SessionHelper::IsSubWindow(type)) { - isActive_ = true; - if (SessionHelper::IsMainWindow(type) || type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { - UpdateSessionState(SessionState::STATE_ACTIVE); - } else { - UpdateSessionState(SessionState::STATE_FOREGROUND); - } - } else { - isActive_ = false; - UpdateSessionState(SessionState::STATE_BACKGROUND); - } bufferAvailable_ = true; return WSError::WS_OK; } @@ -894,14 +862,6 @@ WSError Session::Foreground(sptr property) return WSError::WS_OK; } -void Session::NotifyCallingSessionForeground() -{ - if (notifyCallingSessionForegroundFunc_) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "Notify calling window that input method shown"); - notifyCallingSessionForegroundFunc_(persistentId_); - } -} - void Session::HandleDialogBackground() { const auto& type = GetWindowType(); @@ -990,14 +950,6 @@ WSError Session::Background() return WSError::WS_OK; } -void Session::NotifyCallingSessionBackground() -{ - if (notifyCallingSessionBackgroundFunc_) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "Notify calling window that input method hide"); - notifyCallingSessionBackgroundFunc_(); - } -} - WSError Session::Disconnect(bool isFromClient) { auto state = GetSessionState(); @@ -1055,15 +1007,6 @@ WSError Session::SetActive(bool active) void Session::NotifyForegroundInteractiveStatus(bool interactive) { SetForegroundInteractiveStatus(interactive); - if (!IsSessionValid() || !sessionStage_) { - return; - } - const auto& state = GetSessionState(); - if (WindowHelper::IsMainWindow(GetWindowType()) && - (isVisible_ || state == SessionState::STATE_ACTIVE || state == SessionState::STATE_FOREGROUND)) { - WLOGFI("NotifyForegroundInteractiveStatus %{public}d", interactive); - sessionStage_->NotifyForegroundInteractiveStatus(interactive); - } } void Session::SetForegroundInteractiveStatus(bool interactive) @@ -1331,21 +1274,6 @@ WSError Session::PendingSessionToBackgroundForDelegator() return WSError::WS_OK; } -void Session::SetNotifyCallingSessionUpdateRectFunc(const NotifyCallingSessionUpdateRectFunc& func) -{ - notifyCallingSessionUpdateRectFunc_ = func; -} - -void Session::SetNotifyCallingSessionForegroundFunc(const NotifyCallingSessionForegroundFunc& func) -{ - notifyCallingSessionForegroundFunc_ = func; -} - -void Session::SetNotifyCallingSessionBackgroundFunc(const NotifyCallingSessionBackgroundFunc& func) -{ - notifyCallingSessionBackgroundFunc_ = func; -} - void Session::SetRaiseToAppTopForPointDownFunc(const NotifyRaiseToTopForPointDownFunc& func) { raiseToTopForPointDownFunc_ = func; @@ -1452,52 +1380,6 @@ bool Session::CheckDialogOnForeground() bool Session::CheckPointerEventDispatch(const std::shared_ptr& pointerEvent) const { - auto windowType = GetWindowType(); - bool isSystemWindow = GetSessionInfo().isSystem_; - auto sessionState = GetSessionState(); - int32_t action = pointerEvent->GetPointerAction(); - auto isPC = system::GetParameter("const.product.devicetype", "unknown") == "2in1"; - if (!isSystemWindow && - (WindowHelper::IsMainWindow(windowType) || (WindowHelper::IsSubWindow(windowType) && isPC)) && - sessionState != SessionState::STATE_FOREGROUND && - sessionState != SessionState::STATE_ACTIVE && - action != MMI::PointerEvent::POINTER_ACTION_LEAVE_WINDOW) { - WLOGFW("Current Session Info: [persistentId: %{public}d, isSystemWindow: %{public}d," - "state: %{public}d, action:%{public}d]", GetPersistentId(), isSystemWindow, state_, action); - return false; - } - return true; -} - -bool Session::CheckKeyEventDispatch(const std::shared_ptr& keyEvent) const -{ - if (GetWindowType() != WindowType::WINDOW_TYPE_DIALOG) { - return true; - } - - auto currentRect = winRect_; - if (!isRSVisible_ || currentRect.width_ == 0 || currentRect.height_ == 0) { - WLOGE("Error size: [width: %{public}d, height: %{public}d], isRSVisible_: %{public}d," - " persistentId: %{public}d", - currentRect.width_, currentRect.height_, isRSVisible_, GetPersistentId()); - return false; - } - - auto parentSession = GetParentSession(); - if (parentSession == nullptr) { - WLOGFW("Dialog parent is null"); - return false; - } - auto parentSessionState = parentSession->GetSessionState(); - if ((parentSessionState != SessionState::STATE_FOREGROUND && - parentSessionState != SessionState::STATE_ACTIVE) || - (state_ != SessionState::STATE_FOREGROUND && - state_ != SessionState::STATE_ACTIVE)) { - TLOGE(WmsLogTag::WMS_DIALOG, "Dialog's parent info : [persistentId: %{publicd}d, state:%{public}d];" - "Dialog info:[persistentId: %{publicd}d, state:%{public}d]", - parentSession->GetPersistentId(), parentSessionState, GetPersistentId(), state_); - return false; - } return true; } @@ -1560,9 +1442,7 @@ void Session::PresentFocusIfPointDown() if (!isFocused_ && GetFocusable()) { NotifyRequestFocusStatusNotifyManager(true, false); } - if (!sessionInfo_.isSystem_ || (!isFocused_ && GetFocusable())) { - NotifyClick(); - } + NotifyClick(); } void Session::HandlePointDownDialog() @@ -1682,38 +1562,6 @@ WSError Session::TransferPointerEvent(const std::shared_ptr& WSError Session::TransferKeyEvent(const std::shared_ptr& keyEvent) { - if (!IsSystemSession() && !IsSessionValid()) { - return WSError::WS_ERROR_INVALID_SESSION; - } - if (keyEvent == nullptr) { - WLOGFE("KeyEvent is nullptr"); - return WSError::WS_ERROR_NULLPTR; - } - if (GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) { - if (CheckDialogOnForeground()) { - TLOGD(WmsLogTag::WMS_DIALOG, "Has dialog on foreground, not transfer pointer event"); - return WSError::WS_ERROR_INVALID_PERMISSION; - } - } else if (GetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW) { - if (parentSession_ && parentSession_->CheckDialogOnForeground()) { - TLOGD(WmsLogTag::WMS_DIALOG, "Its main window has dialog on foreground, not transfer pointer event"); - return WSError::WS_ERROR_INVALID_PERMISSION; - } - } else if (GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) { - if (keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_BACK) { - return WSError::WS_ERROR_INVALID_PERMISSION; - } - if (parentSession_ && parentSession_->CheckDialogOnForeground() && - !IsTopDialog()) { - return WSError::WS_ERROR_INVALID_PERMISSION; - } - } - - if (!CheckKeyEventDispatch(keyEvent)) { - WLOGFW("Do not dispatch the key event."); - return WSError::WS_DO_NOTHING; - } - WLOGFD("Session TransferKeyEvent eventId:%{public}d persistentId:%{public}d bundleName:%{public}s pid:%{public}d", keyEvent->GetId(), persistentId_, callingBundleName_.c_str(), callingPid_); if (DelayedSingleton::GetInstance()->IsANRTriggered(persistentId_)) { @@ -2000,9 +1848,7 @@ void Session::PresentFoucusIfNeed(int32_t pointerAction) if (!isFocused_ && GetFocusable()) { NotifyRequestFocusStatusNotifyManager(true, false); } - if (!sessionInfo_.isSystem_ || (!isFocused_ && GetFocusable())) { - NotifyClick(); - } + NotifyClick(); } } @@ -2014,19 +1860,8 @@ WSError Session::UpdateFocus(bool isFocused) } isFocused_ = isFocused; // notify scb arkui focus - if (isFocused) { - if (sessionInfo_.isSystem_) { - HiSysEventWrite( - OHOS::HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER, - "FOCUS_WINDOW", - OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, - "PID", getpid(), - "UID", getuid(), - "BUNDLE_NAME", sessionInfo_.bundleName_); - NotifyUIRequestFocus(); - } - } else { - NotifyUILostFocus(); + if (!isFocused) { + NotifyUILostFocus(); } return WSError::WS_OK; } @@ -2045,12 +1880,6 @@ WSError Session::UpdateWindowMode(WindowMode mode) { WLOGFD("Session update window mode, id: %{public}d, mode: %{public}d", GetPersistentId(), static_cast(mode)); - if (sessionInfo_.isSystem_) { - WLOGFD("session is system, id: %{public}d, name: %{public}s, state: %{public}u", - GetPersistentId(), sessionInfo_.bundleName_.c_str(), state_); - return WSError::WS_ERROR_INVALID_SESSION; - } - if (property_ == nullptr) { WLOGFD("id: %{public}d property is nullptr", persistentId_); return WSError::WS_ERROR_NULLPTR; @@ -2081,14 +1910,9 @@ WSError Session::UpdateWindowMode(WindowMode mode) WSError Session::SetSystemSceneBlockingFocus(bool blocking) { - TLOGD(WmsLogTag::WMS_FOCUS, "Session set blocking focus, id: %{public}d, mode: %{public}d", + TLOGW(WmsLogTag::WMS_FOCUS, "Session set blocking focus, id: %{public}d, mode: %{public}d, Session is not system.", GetPersistentId(), blocking); - if (!sessionInfo_.isSystem_) { - TLOGW(WmsLogTag::WMS_FOCUS, "Session is not system."); - return WSError::WS_ERROR_INVALID_SESSION; - } - blockingFocus_ = blocking; - return WSError::WS_OK; + return WSError::WS_ERROR_INVALID_SESSION; } bool Session::GetBlockingFocus() const @@ -2187,10 +2011,6 @@ WSError Session::ProcessBackEvent() if (!IsSessionValid()) { return WSError::WS_ERROR_INVALID_SESSION; } - if (GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) { - TLOGI(WmsLogTag::WMS_DIALOG, "this is dialog, id: %{public}d", GetPersistentId()); - return WSError::WS_OK; - } return sessionStage_->HandleBackEvent(); } @@ -2490,15 +2310,6 @@ WSError Session::UpdateTitleInTargetPos(bool isShow, int32_t height) return sessionStage_->UpdateTitleInTargetPos(isShow, height); } -bool Session::NeedSystemPermission(WindowType type) -{ - return !(WindowHelper::IsAppWindow(type) || type == WindowType::WINDOW_TYPE_UI_EXTENSION || - type == WindowType::WINDOW_TYPE_SCENE_BOARD || type == WindowType::WINDOW_TYPE_SYSTEM_FLOAT || - type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW || type == WindowType::WINDOW_TYPE_TOAST || - type == WindowType::WINDOW_TYPE_DRAGGING_EFFECT || type == WindowType::WINDOW_TYPE_APP_LAUNCHING || - type == WindowType::WINDOW_TYPE_PIP); -} - void Session::SetNotifySystemSessionPointerEventFunc(const NotifySystemSessionPointerEventFunc& func) { std::lock_guard lock(pointerEventMutex_); diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index b13833386..882a275ec 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -15,6 +15,9 @@ #include "session/host/include/sub_session.h" +#include "key_event.h" +#include "parameters.h" +#include "pointer_event.h" #include "window_manager_hilog.h" namespace OHOS::Rosen { @@ -84,6 +87,25 @@ WSError SubSession::Hide() return WSError::WS_OK; } +WSError SubSession::Reconnect(const sptr& sessionStage, const sptr& eventChannel, + const std::shared_ptr& surfaceNode, sptr property, sptr token, + int32_t pid, int32_t uid) +{ + return PostSyncTask([weakThis = wptr(this), sessionStage, eventChannel, surfaceNode, property, token, pid, uid]() { + auto session = weakThis.promote(); + if (!session) { + WLOGFE("session is null"); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + WSError ret = session->Session::Reconnect(sessionStage, eventChannel, surfaceNode, property, token, pid, uid); + if (ret == WSError::WS_OK) { + session->isActive_ = true; + session->UpdateSessionState(SessionState::STATE_FOREGROUND); + } + return ret; + }); +} + WSError SubSession::ProcessPointDownSession(int32_t posX, int32_t posY) { const auto& id = GetPersistentId(); @@ -98,4 +120,46 @@ WSError SubSession::ProcessPointDownSession(int32_t posX, int32_t posY) PresentFocusIfPointDown(); return SceneSession::ProcessPointDownSession(posX, posY); } + +WSError SubSession::TransferKeyEvent(const std::shared_ptr& keyEvent) +{ + if (!IsSessionValid()) { + return WSError::WS_ERROR_INVALID_SESSION; + } + if (keyEvent == nullptr) { + WLOGFE("KeyEvent is nullptr"); + return WSError::WS_ERROR_NULLPTR; + } + if (parentSession_ && parentSession_->CheckDialogOnForeground()) { + TLOGD(WmsLogTag::WMS_DIALOG, "Its main window has dialog on foreground, not transfer pointer event"); + return WSError::WS_ERROR_INVALID_PERMISSION; + } + + WSError ret = Session::TransferKeyEvent(keyEvent); + return ret; +} + +void SubSession::UpdatePointerArea(const WSRect& rect) +{ + auto property = GetSessionProperty(); + if (!(property->IsDecorEnable() && GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING)) { + return; + } + Session::UpdatePointerArea(rect); +} + +bool SubSession::CheckPointerEventDispatch(const std::shared_ptr& pointerEvent) const +{ + auto sessionState = GetSessionState(); + int32_t action = pointerEvent->GetPointerAction(); + auto isPC = system::GetParameter("const.product.devicetype", "unknown") == "2in1"; + if (isPC && sessionState != SessionState::STATE_FOREGROUND && + sessionState != SessionState::STATE_ACTIVE && + action != MMI::PointerEvent::POINTER_ACTION_LEAVE_WINDOW) { + WLOGFW("Current Session Info: [persistentId: %{public}d, " + "state: %{public}d, action:%{public}d]", GetPersistentId(), state_, action); + return false; + } + return true; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/system_session.cpp b/window_scene/session/host/src/system_session.cpp index 6b6a5a22e..587a01da8 100644 --- a/window_scene/session/host/src/system_session.cpp +++ b/window_scene/session/host/src/system_session.cpp @@ -14,7 +14,9 @@ */ #include "session/host/include/system_session.h" + #include "common/include/session_permission.h" +#include "key_event.h" #include "session/host/include/session.h" #include "window_helper.h" #include "window_manager_hilog.h" @@ -83,7 +85,7 @@ WSError SystemSession::Show(sptr property) WSError SystemSession::Hide() { auto type = GetWindowType(); - if (WindowHelper::IsSystemWindow(type) && Session::NeedSystemPermission(type)) { + if (WindowHelper::IsSystemWindow(type) && NeedSystemPermission(type)) { if (type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { if (!SessionPermission::IsStartedByInputMethod()) { TLOGE(WmsLogTag::WMS_LIFE, "Hide permission denied, keyboard is not hidden by current input method"); @@ -122,6 +124,37 @@ WSError SystemSession::Hide() return WSError::WS_OK; } +WSError SystemSession::Reconnect(const sptr& sessionStage, const sptr& eventChannel, + const std::shared_ptr& surfaceNode, sptr property, sptr token, + int32_t pid, int32_t uid) +{ + return PostSyncTask([weakThis = wptr(this), sessionStage, eventChannel, surfaceNode, property, token, pid, uid]() { + auto session = weakThis.promote(); + if (!session) { + WLOGFE("session is null"); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + WSError ret = session->Session::Reconnect(sessionStage, eventChannel, surfaceNode, property, token, pid, uid); + if (ret != WSError::WS_OK) { + return ret; + } + WindowState windowState = property->GetWindowState(); + WindowType type = property->GetWindowType(); + if (windowState == WindowState::STATE_SHOWN) { + session->isActive_ = true; + if (type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { + session->UpdateSessionState(SessionState::STATE_ACTIVE); + } else { + session->UpdateSessionState(SessionState::STATE_FOREGROUND); + } + } else { + session->isActive_ = false; + session->UpdateSessionState(SessionState::STATE_BACKGROUND); + } + return WSError::WS_OK; + }); +} + WSError SystemSession::Disconnect(bool isFromClient) { auto task = [weakThis = wptr(this), isFromClient]() { @@ -160,4 +193,141 @@ WSError SystemSession::ProcessPointDownSession(int32_t posX, int32_t posY) PresentFocusIfPointDown(); return SceneSession::ProcessPointDownSession(posX, posY); } + +void SystemSession::SetNotifyCallingSessionUpdateRectFunc(const NotifyCallingSessionUpdateRectFunc& func) +{ + notifyCallingSessionUpdateRectFunc_ = func; +} + +void SystemSession::SetNotifyCallingSessionForegroundFunc(const NotifyCallingSessionForegroundFunc& func) +{ + notifyCallingSessionForegroundFunc_ = func; +} + +void SystemSession::SetNotifyCallingSessionBackgroundFunc(const NotifyCallingSessionBackgroundFunc& func) +{ + notifyCallingSessionBackgroundFunc_ = func; +} + +void SystemSession::NotifyCallingSessionUpdateRect() +{ + if ((GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) && notifyCallingSessionUpdateRectFunc_) { + WLOGFI("Notify calling window that input method update rect"); + notifyCallingSessionUpdateRectFunc_(persistentId_); + } +} + +void SystemSession::NotifyCallingSessionForeground() +{ + if ((GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) && notifyCallingSessionForegroundFunc_) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "Notify calling window that input method shown"); + notifyCallingSessionForegroundFunc_(persistentId_); + } +} + +void SystemSession::NotifyCallingSessionBackground() +{ + if ((GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) && notifyCallingSessionBackgroundFunc_) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "Notify calling window that input method hide"); + notifyCallingSessionBackgroundFunc_(); + } +} + +WSError SystemSession::TransferKeyEvent(const std::shared_ptr& keyEvent) +{ + if (!IsSessionValid()) { + return WSError::WS_ERROR_INVALID_SESSION; + } + if (keyEvent == nullptr) { + WLOGFE("KeyEvent is nullptr"); + return WSError::WS_ERROR_NULLPTR; + } + if (GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) { + if (keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_BACK) { + return WSError::WS_ERROR_INVALID_PERMISSION; + } + if (parentSession_ && parentSession_->CheckDialogOnForeground() && + !IsTopDialog()) { + return WSError::WS_ERROR_INVALID_PERMISSION; + } + if (!CheckKeyEventDispatch(keyEvent)) { + WLOGFW("Do not dispatch the key event."); + return WSError::WS_DO_NOTHING; + } + } + + WSError ret = Session::TransferKeyEvent(keyEvent); + return ret; +} + +WSError SystemSession::ProcessBackEvent() +{ + if (!IsSessionValid()) { + return WSError::WS_ERROR_INVALID_SESSION; + } + if (GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) { + TLOGI(WmsLogTag::WMS_DIALOG, "this is dialog, id: %{public}d", GetPersistentId()); + return WSError::WS_OK; + } + return sessionStage_->HandleBackEvent(); +} + +WSError SystemSession::NotifyClientToUpdateRect(std::shared_ptr rsTransaction) +{ + auto task = [weakThis = wptr(this), rsTransaction]() { + auto session = weakThis.promote(); + WSError ret = session->NotifyClientToUpdateRectTask(weakThis, rsTransaction); + if (ret == WSError::WS_OK) { + if (session->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { + session->NotifyCallingSessionUpdateRect(); + } + if (session->specificCallback_ != nullptr && session->specificCallback_->onUpdateAvoidArea_ != nullptr) { + session->specificCallback_->onUpdateAvoidArea_(session->GetPersistentId()); + } + if (session->reason_ != SizeChangeReason::DRAG) { + session->reason_ = SizeChangeReason::UNDEFINED; + session->isDirty_ = false; + } + } + return ret; + }; + PostTask(task, "NotifyClientToUpdateRect"); + return WSError::WS_OK; +} + +bool SystemSession::CheckKeyEventDispatch(const std::shared_ptr& keyEvent) const +{ + auto currentRect = winRect_; + if (!GetVisible() || currentRect.width_ == 0 || currentRect.height_ == 0) { + WLOGE("Error size: [width: %{public}d, height: %{public}d], isRSVisible_: %{public}d," + " persistentId: %{public}d", + currentRect.width_, currentRect.height_, GetVisible(), GetPersistentId()); + return false; + } + + auto parentSession = GetParentSession(); + if (parentSession == nullptr) { + WLOGFW("Dialog parent is null"); + return false; + } + auto parentSessionState = parentSession->GetSessionState(); + if ((parentSessionState != SessionState::STATE_FOREGROUND && + parentSessionState != SessionState::STATE_ACTIVE) || + (state_ != SessionState::STATE_FOREGROUND && + state_ != SessionState::STATE_ACTIVE)) { + TLOGE(WmsLogTag::WMS_DIALOG, "Dialog's parent info : [persistentId: %{publicd}d, state:%{public}d];" + "Dialog info:[persistentId: %{publicd}d, state:%{public}d]", + parentSession->GetPersistentId(), parentSessionState, GetPersistentId(), state_); + return false; + } + return true; +} + +bool SystemSession::NeedSystemPermission(WindowType type) +{ + return !(type == WindowType::WINDOW_TYPE_SCENE_BOARD || type == WindowType::WINDOW_TYPE_SYSTEM_FLOAT || + type == WindowType::WINDOW_TYPE_SYSTEM_SUB_WINDOW || type == WindowType::WINDOW_TYPE_TOAST || + type == WindowType::WINDOW_TYPE_DRAGGING_EFFECT || type == WindowType::WINDOW_TYPE_APP_LAUNCHING || + type == WindowType::WINDOW_TYPE_PIP); +} } // namespace OHOS::Rosen -- Gitee From 5e72041f6ef73e38641859e7795ff1b1d4689dc6 Mon Sep 17 00:00:00 2001 From: zhangkai Date: Sat, 30 Mar 2024 16:23:17 +0800 Subject: [PATCH 291/385] sub widnow avoid return base avoid area Signed-off-by: zhangkai Change-Id: I5ac182f2af8c6fe029e480ce2bd5a8ec3dce0f00 --- wm/src/window_scene_session_impl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 192701328..496b854a2 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1277,6 +1277,13 @@ WMError WindowSceneSessionImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea static_cast(type), static_cast(mode)); return WMError::WM_OK; } + if (mode == WindowMode::WINDOW_MODE_FLOATING && + (WindowHelper::IsSubWindow(GetType()) || WindowHelper::IsSystemSubWindow(GetType()))) { + TLOGI(WmsLogTag::WMS_IMMS,"Window: %{public}u, avoidAreaType:%{public}u," + "windowMode:%{public}u, return default avoid area for sub window.", + GetWindowId(), static_cast(type), static_cast(mode)); + return WMError::WM_OK; + } if (hostSession_ == nullptr) { return WMError::WM_ERROR_NULLPTR; } -- Gitee From 9849ecebef0ac3c2a186fcb33a94613b30c94ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sat, 30 Mar 2024 15:28:50 +0000 Subject: [PATCH 292/385] update wm/include/window_manager_agent_lite.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- wm/include/window_manager_agent_lite.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/include/window_manager_agent_lite.h b/wm/include/window_manager_agent_lite.h index 3fa5ead87..5a5b51e97 100644 --- a/wm/include/window_manager_agent_lite.h +++ b/wm/include/window_manager_agent_lite.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at -- Gitee From f1ccc12113666bfc93ddcbeeb6b9094cd23eb549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sat, 30 Mar 2024 15:30:28 +0000 Subject: [PATCH 293/385] update window_scene/session_manager/src/scene_session_manager_lite.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- .../session_manager/src/scene_session_manager_lite.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager_lite.cpp b/window_scene/session_manager/src/scene_session_manager_lite.cpp index bf98166d7..b50b0364d 100644 --- a/window_scene/session_manager/src/scene_session_manager_lite.cpp +++ b/window_scene/session_manager/src/scene_session_manager_lite.cpp @@ -160,13 +160,13 @@ void SceneSessionManagerLite::GetFocusWindowInfo(FocusChangeInfo& focusInfo) } WMError SceneSessionManagerLite::RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr & windowManagerAgent) + const sptr& windowManagerAgent) { return SceneSessionManager::GetInstance().RegisterWindowManagerAgent(type, windowManagerAgent); } WMError SceneSessionManagerLite::UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr & windowManagerAgent) + const sptr& windowManagerAgent) { return SceneSessionManager::GetInstance().UnregisterWindowManagerAgent(type, windowManagerAgent); } @@ -176,7 +176,7 @@ WMError SceneSessionManagerLite::CheckWindowId(int32_t windowId, int32_t& pid) return SceneSessionManager::GetInstance().CheckWindowId(windowId, pid); } -WMError SceneSessionManagerLite::GetVisibilityWindowInfo(std::vector >& infos) +WMError SceneSessionManagerLite::GetVisibilityWindowInfo(std::vector>& infos) { return SceneSessionManager::GetInstance().GetVisibilityWindowInfo(infos); } -- Gitee From d79f28efec3fc569da42d28bafcff04e551ce0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sat, 30 Mar 2024 15:31:08 +0000 Subject: [PATCH 294/385] update wm/src/window_manager_agent_lite.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- wm/src/window_manager_agent_lite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/window_manager_agent_lite.cpp b/wm/src/window_manager_agent_lite.cpp index 7dc23e922..2af8c686d 100644 --- a/wm/src/window_manager_agent_lite.cpp +++ b/wm/src/window_manager_agent_lite.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at -- Gitee From 3e37dc21a70e7d030e2e65b00da5ed69caee1d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sat, 30 Mar 2024 15:32:37 +0000 Subject: [PATCH 295/385] update window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- .../include/zidl/scene_session_manager_lite_interface.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h index ee6029fdd..783957321 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h @@ -17,14 +17,14 @@ #define OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_INTERFACE_H #include +#include "common/include/window_session_property.h" +#include "iability_manager_collaborator.h" #include "interfaces/include/ws_common.h" #include "interfaces/include/ws_common_inner.h" -#include "common/include/window_session_property.h" -#include "session_info.h" -#include "mission_listener_interface.h" #include "mission_info.h" +#include "mission_listener_interface.h" #include "mission_snapshot.h" -#include "iability_manager_collaborator.h" +#include "session_info.h" #include "zidl/window_manager_lite_interface.h" namespace OHOS::Media { class PixelMap; -- Gitee From bb30957eecbdc2203ee54d705c80ac69f948286d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sat, 30 Mar 2024 15:35:04 +0000 Subject: [PATCH 296/385] update wm/src/window_manager_lite.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- wm/src/window_manager_lite.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index 490c5bd0f..c01ee208d 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -19,13 +19,12 @@ #include #include "input_manager.h" - +#include "i_window_checker.h" #include "marshalling_helper.h" #include "window_adapter_lite.h" #include "window_manager_agent_lite.h" #include "window_manager_hilog.h" #include "wm_common.h" -#include "i_window_checker.h" namespace OHOS { namespace Rosen { -- Gitee From 6b621c030ef450bb238870f0febc803f93ea65e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sat, 30 Mar 2024 15:36:17 +0000 Subject: [PATCH 297/385] update wmserver/include/zidl/window_manager_lite_interface.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- wmserver/include/zidl/window_manager_lite_interface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wmserver/include/zidl/window_manager_lite_interface.h b/wmserver/include/zidl/window_manager_lite_interface.h index 85309c102..d7e888b2c 100644 --- a/wmserver/include/zidl/window_manager_lite_interface.h +++ b/wmserver/include/zidl/window_manager_lite_interface.h @@ -18,10 +18,10 @@ #include +#include "interfaces/include/ws_common.h" #include "window_property.h" #include "window_transition_info.h" #include "zidl/window_manager_agent_interface.h" -#include "interfaces/include/ws_common.h" namespace OHOS { namespace MMI { -- Gitee From 09d90ca12b4a8e59c5c67736d22488221f0d81e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sat, 30 Mar 2024 15:43:04 +0000 Subject: [PATCH 298/385] update wm/src/window_manager_lite.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- wm/src/window_manager_lite.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index c01ee208d..10c936f22 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -68,7 +68,7 @@ public: void WindowManagerLite::Impl::NotifyFocused(const sptr& focusChangeInfo) { - WLOGFD("[WMSFocus]NotifyFocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", + TLOGD("[WMSFocus]NotifyFocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, static_cast(focusChangeInfo->windowType_)); std::vector> focusChangeListeners; @@ -84,7 +84,7 @@ void WindowManagerLite::Impl::NotifyFocused(const sptr& focusCh void WindowManagerLite::Impl::NotifyUnfocused(const sptr& focusChangeInfo) { - WLOGFD("[WMSFocus]NotifyUnfocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", + TLOGD("[WMSFocus]NotifyUnfocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, static_cast(focusChangeInfo->windowType_)); std::vector> focusChangeListeners; @@ -158,7 +158,7 @@ WMError WindowManagerLite::RegisterFocusChangedListener(const sptr lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->focusChangedListenerAgent_ == nullptr) { - pImpl_->focusChangedListenerAgent_ = new WindowManagerAgentLite(); + pImpl_->focusChangedListenerAgent_ = new (std::no_throw) WindowManagerAgentLite(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS, pImpl_->focusChangedListenerAgent_); } @@ -210,7 +210,7 @@ WMError WindowManagerLite::RegisterVisibilityChangedListener(const sptr lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->windowVisibilityListenerAgent_ == nullptr) { - pImpl_->windowVisibilityListenerAgent_ = new WindowManagerAgentLite(); + pImpl_->windowVisibilityListenerAgent_ = new (std::no_throw) WindowManagerAgentLite(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY, pImpl_->windowVisibilityListenerAgent_); @@ -318,7 +318,7 @@ WMError WindowManagerLite::RegisterDrawingContentChangedListener(const sptr lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->windowDrawingContentListenerAgent_ == nullptr) { - pImpl_->windowDrawingContentListenerAgent_ = new WindowManagerAgentLite(); + pImpl_->windowDrawingContentListenerAgent_ = new (std::no_throw) WindowManagerAgentLite(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE, pImpl_->windowDrawingContentListenerAgent_); -- Gitee From 2162f80ec8599251d6293487cbc0297ce6a3f5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sat, 30 Mar 2024 15:48:21 +0000 Subject: [PATCH 299/385] =?UTF-8?q?listener=E5=88=A4=E7=A9=BA=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- wm/src/window_manager_lite.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index 10c936f22..715676147 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -78,6 +78,9 @@ void WindowManagerLite::Impl::NotifyFocused(const sptr& focusCh } WLOGFD("NotifyFocused listeners: %{public}zu", focusChangeListeners.size()); for (auto& listener : focusChangeListeners) { + if (listener == nullptr) { + continue; + } listener->OnFocused(focusChangeInfo); } } @@ -94,6 +97,9 @@ void WindowManagerLite::Impl::NotifyUnfocused(const sptr& focus } WLOGFD("NotifyUnfocused listeners: %{public}zu", focusChangeListeners.size()); for (auto& listener : focusChangeListeners) { + if (listener == nullptr) { + continue; + } listener->OnUnfocused(focusChangeInfo); } } @@ -108,6 +114,9 @@ void WindowManagerLite::Impl::NotifyWindowVisibilityInfoChanged( } for (auto& listener : visibilityChangeListeners) { WLOGD("Notify WindowVisibilityInfo to caller"); + if (listener == nullptr) { + continue; + } listener->OnWindowVisibilityChanged(windowVisibilityInfos); } } @@ -122,6 +131,9 @@ void WindowManagerLite::Impl::NotifyWindowDrawingContentInfoChanged( } for (auto& listener : windowDrawingContentChangeListeners) { WLOGFD("Notify windowDrawingContentInfo to caller"); + if (listener == nullptr) { + continue; + } listener->OnWindowDrawingContentChanged(windowDrawingContentInfos); } } -- Gitee From c2ee58ce56786c242e71bfa79468a9d694d6dd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sun, 31 Mar 2024 01:16:46 +0000 Subject: [PATCH 300/385] =?UTF-8?q?=E5=AF=B9focusChangeInfo=E5=88=A4?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- wm/src/window_manager_lite.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index 715676147..daf395625 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -68,9 +68,12 @@ public: void WindowManagerLite::Impl::NotifyFocused(const sptr& focusChangeInfo) { - TLOGD("[WMSFocus]NotifyFocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", - focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, - static_cast(focusChangeInfo->windowType_)); + if (focusChangeInfo != nullptr) { + TLOGD("[WMSFocus]NotifyFocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", + focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, + static_cast(focusChangeInfo->windowType_)); + } + std::vector> focusChangeListeners; { std::lock_guard lock(mutex_); @@ -87,9 +90,12 @@ void WindowManagerLite::Impl::NotifyFocused(const sptr& focusCh void WindowManagerLite::Impl::NotifyUnfocused(const sptr& focusChangeInfo) { - TLOGD("[WMSFocus]NotifyUnfocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", - focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, - static_cast(focusChangeInfo->windowType_)); + if (focusChangeInfo != nullptr) { + TLOGD("[WMSFocus]NotifyUnfocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", + focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, + static_cast(focusChangeInfo->windowType_)); + } + std::vector> focusChangeListeners; { std::lock_guard lock(mutex_); -- Gitee From 92373fa82430a879e153a00021e03d1bd5ad794c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sun, 31 Mar 2024 01:31:13 +0000 Subject: [PATCH 301/385] =?UTF-8?q?=E5=AF=B9=E5=8F=82=E6=95=B0=E5=88=A4?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- .../zidl/scene_session_manager_lite_stub.cpp | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index 4c93ebd4b..9f357487b 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -99,6 +99,9 @@ int SceneSessionManagerLiteStub::OnRemoteRequest(uint32_t code, int SceneSessionManagerLiteStub::HandleSetSessionLabel(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleSetSessionLabel!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } sptr token = data.ReadRemoteObject(); std::string label = data.ReadString(); WSError errCode = SetSessionLabel(token, label); @@ -109,6 +112,9 @@ int SceneSessionManagerLiteStub::HandleSetSessionLabel(MessageParcel &data, Mess int SceneSessionManagerLiteStub::HandleSetSessionIcon(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleSetSessionIcon!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } sptr token = data.ReadRemoteObject(); std::shared_ptr icon(data.ReadParcelable()); WSError errCode = SetSessionIcon(token, icon); @@ -119,6 +125,9 @@ int SceneSessionManagerLiteStub::HandleSetSessionIcon(MessageParcel &data, Messa int SceneSessionManagerLiteStub::HandleIsValidSessionIds(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleIsValidSessionIds!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } std::vector sessionIds; data.ReadInt32Vector(&sessionIds); std::vector results; @@ -129,6 +138,9 @@ int SceneSessionManagerLiteStub::HandleIsValidSessionIds(MessageParcel &data, Me int SceneSessionManagerLiteStub::HandlePendingSessionToForeground(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandlePendingSessionToForeground!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } sptr token = data.ReadRemoteObject(); const WSError& errCode = PendingSessionToForeground(token); reply.WriteUint32(static_cast(errCode)); @@ -138,6 +150,9 @@ int SceneSessionManagerLiteStub::HandlePendingSessionToForeground(MessageParcel int SceneSessionManagerLiteStub::HandlePendingSessionToBackgroundForDelegator(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandlePendingSessionToBackground!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } sptr token = data.ReadRemoteObject(); const WSError& errCode = PendingSessionToBackgroundForDelegator(token); reply.WriteInt32(static_cast(errCode)); @@ -147,6 +162,9 @@ int SceneSessionManagerLiteStub::HandlePendingSessionToBackgroundForDelegator(Me int SceneSessionManagerLiteStub::HandleRegisterSessionListener(MessageParcel& data, MessageParcel& reply) { WLOGFD("run HandleRegisterSessionListener!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } sptr listener = iface_cast(data.ReadRemoteObject()); WSError errCode = RegisterSessionListener(listener); reply.WriteInt32(static_cast(errCode)); @@ -156,6 +174,9 @@ int SceneSessionManagerLiteStub::HandleRegisterSessionListener(MessageParcel& da int SceneSessionManagerLiteStub::HandleUnRegisterSessionListener(MessageParcel& data, MessageParcel& reply) { WLOGFD("run HandleUnRegisterSessionListener!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } sptr listener = iface_cast(data.ReadRemoteObject()); WSError errCode = UnRegisterSessionListener(listener); reply.WriteInt32(static_cast(errCode)); @@ -165,6 +186,9 @@ int SceneSessionManagerLiteStub::HandleUnRegisterSessionListener(MessageParcel& int SceneSessionManagerLiteStub::HandleGetSessionInfos(MessageParcel& data, MessageParcel& reply) { WLOGFD("run HandleGetSessionInfos!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } std::string deviceId = Str16ToStr8(data.ReadString16()); int numMax = data.ReadInt32(); std::vector missionInfos; @@ -185,6 +209,9 @@ int SceneSessionManagerLiteStub::HandleGetSessionInfos(MessageParcel& data, Mess int SceneSessionManagerLiteStub::HandleGetSessionInfo(MessageParcel& data, MessageParcel& reply) { WLOGFD("run HandleGetSessionInfo!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } SessionInfoBean info; std::string deviceId = Str16ToStr8(data.ReadString16()); int32_t persistentId = data.ReadInt32(); @@ -203,6 +230,9 @@ int SceneSessionManagerLiteStub::HandleGetSessionInfo(MessageParcel& data, Messa int SceneSessionManagerLiteStub::HandleTerminateSessionNew(MessageParcel& data, MessageParcel& reply) { + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } WLOGFD("run HandleTerminateSessionNew"); sptr abilitySessionInfo = data.ReadParcelable(); bool needStartCaller = data.ReadBool(); @@ -213,6 +243,9 @@ int SceneSessionManagerLiteStub::HandleTerminateSessionNew(MessageParcel& data, int SceneSessionManagerLiteStub::HandleGetFocusSessionToken(MessageParcel &data, MessageParcel &reply) { + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } WLOGFD("run HandleGetFocusSessionToken!"); sptr token = nullptr; const WSError& errCode = GetFocusSessionToken(token); @@ -223,6 +256,9 @@ int SceneSessionManagerLiteStub::HandleGetFocusSessionToken(MessageParcel &data, int SceneSessionManagerLiteStub::HandleSetSessionContinueState(MessageParcel &data, MessageParcel &reply) { + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } WLOGFD("HandleSetSessionContinueState"); sptr token = data.ReadRemoteObject(); auto continueState = static_cast(data.ReadInt32()); @@ -234,6 +270,9 @@ int SceneSessionManagerLiteStub::HandleSetSessionContinueState(MessageParcel &da int SceneSessionManagerLiteStub::HandleGetSessionSnapshot(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleGetSessionSnapshot!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } std::string deviceId = Str16ToStr8(data.ReadString16()); int32_t persistentId = data.ReadInt32(); bool isLowResolution = data.ReadBool(); @@ -247,6 +286,9 @@ int SceneSessionManagerLiteStub::HandleGetSessionSnapshot(MessageParcel &data, M int SceneSessionManagerLiteStub::HandleClearSession(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleClearSession!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } int32_t persistentId = data.ReadInt32(); const WSError& ret = ClearSession(persistentId); reply.WriteUint32(static_cast(ret)); @@ -256,6 +298,9 @@ int SceneSessionManagerLiteStub::HandleClearSession(MessageParcel &data, Message int SceneSessionManagerLiteStub::HandleClearAllSessions(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleClearAllSessions!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } const WSError& ret = ClearAllSessions(); reply.WriteUint32(static_cast(ret)); return ERR_NONE; @@ -264,6 +309,9 @@ int SceneSessionManagerLiteStub::HandleClearAllSessions(MessageParcel &data, Mes int SceneSessionManagerLiteStub::HandleLockSession(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleLockSession!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } int32_t sessionId = data.ReadInt32(); const WSError& ret = LockSession(sessionId); reply.WriteUint32(static_cast(ret)); @@ -273,6 +321,9 @@ int SceneSessionManagerLiteStub::HandleLockSession(MessageParcel &data, MessageP int SceneSessionManagerLiteStub::HandleUnlockSession(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleUnlockSession!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } int32_t sessionId = data.ReadInt32(); const WSError& ret = UnlockSession(sessionId); reply.WriteUint32(static_cast(ret)); @@ -282,6 +333,9 @@ int SceneSessionManagerLiteStub::HandleUnlockSession(MessageParcel &data, Messag int SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleMoveSessionsToForeground!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } std::vector sessionIds; data.ReadInt32Vector(&sessionIds); int32_t topSessionId = data.ReadInt32(); @@ -293,6 +347,9 @@ int SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(MessageParcel &d int SceneSessionManagerLiteStub::HandleMoveSessionsToBackground(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleMoveSessionsToBackground!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } std::vector sessionIds; data.ReadInt32Vector(&sessionIds); std::vector result; @@ -306,6 +363,9 @@ int SceneSessionManagerLiteStub::HandleMoveSessionsToBackground(MessageParcel &d int SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(MessageParcel& data, MessageParcel& reply) { WLOGFI("run HandleGetFocusSessionInfo lite!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } FocusChangeInfo focusInfo; GetFocusWindowInfo(focusInfo); reply.WriteParcelable(&focusInfo); @@ -315,6 +375,9 @@ int SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(MessageParcel& data, int SceneSessionManagerLiteStub::HandleCheckWindowId(MessageParcel &data, MessageParcel &reply) { WLOGFI("run HandleCheckWindowId!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } int32_t windowId = INVALID_WINDOW_ID; if (!data.ReadInt32(windowId)) { WLOGE("Failed to readInt32 windowId"); @@ -337,6 +400,9 @@ int SceneSessionManagerLiteStub::HandleCheckWindowId(MessageParcel &data, Messag int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel &data, MessageParcel &reply) { WLOGFI("[Test]run HandleRegisterWindowManagerAgent!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } auto type = static_cast(data.ReadUint32()); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = @@ -349,6 +415,9 @@ int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel int SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent(MessageParcel &data, MessageParcel &reply) { WLOGFI("[Test]run HandleUnregisterWindowManagerAgent!"); + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } auto type = static_cast(data.ReadUint32()); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = @@ -360,6 +429,9 @@ int SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent(MessageParce int SceneSessionManagerLiteStub::HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply) { + if (data == nullptr || reply == nullptr) { + return ERR_INVALID_DATA; + } std::vector> infos; WMError errCode = GetVisibilityWindowInfo(infos); if (!MarshallingHelper::MarshallingVectorParcelableObj(reply, infos)) { -- Gitee From 8cc8161ee34c3527c6d7574a1b5d885e4a678a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sun, 31 Mar 2024 01:38:55 +0000 Subject: [PATCH 302/385] =?UTF-8?q?=E8=BF=98=E5=8E=9Futils:libwmutil=5Fsta?= =?UTF-8?q?tic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- bundle.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bundle.json b/bundle.json index 6d6c86abc..9eeccc465 100755 --- a/bundle.json +++ b/bundle.json @@ -159,6 +159,15 @@ "header_base": "//foundation/window/window_manager/utils/include" } }, + { + "type": "so", + "name": "//foundation/window/window_manager/utils:libwmutil_static", + "header": { + "header_files": [ + ], + "header_base": "//foundation/window/window_manager/utils/include" + } + }, { "type": "so", "name": "//foundation/window/window_manager/dm:libdm", -- Gitee From 5aca7e89cb1d8a4e71d7eb50fe3fcbb350dc6a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sun, 31 Mar 2024 02:00:59 +0000 Subject: [PATCH 303/385] =?UTF-8?q?=E6=B8=85=E9=99=A4data=E5=88=A4?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- .../zidl/scene_session_manager_lite_stub.cpp | 72 ------------------- 1 file changed, 72 deletions(-) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index 9f357487b..4c93ebd4b 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -99,9 +99,6 @@ int SceneSessionManagerLiteStub::OnRemoteRequest(uint32_t code, int SceneSessionManagerLiteStub::HandleSetSessionLabel(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleSetSessionLabel!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } sptr token = data.ReadRemoteObject(); std::string label = data.ReadString(); WSError errCode = SetSessionLabel(token, label); @@ -112,9 +109,6 @@ int SceneSessionManagerLiteStub::HandleSetSessionLabel(MessageParcel &data, Mess int SceneSessionManagerLiteStub::HandleSetSessionIcon(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleSetSessionIcon!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } sptr token = data.ReadRemoteObject(); std::shared_ptr icon(data.ReadParcelable()); WSError errCode = SetSessionIcon(token, icon); @@ -125,9 +119,6 @@ int SceneSessionManagerLiteStub::HandleSetSessionIcon(MessageParcel &data, Messa int SceneSessionManagerLiteStub::HandleIsValidSessionIds(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleIsValidSessionIds!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } std::vector sessionIds; data.ReadInt32Vector(&sessionIds); std::vector results; @@ -138,9 +129,6 @@ int SceneSessionManagerLiteStub::HandleIsValidSessionIds(MessageParcel &data, Me int SceneSessionManagerLiteStub::HandlePendingSessionToForeground(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandlePendingSessionToForeground!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } sptr token = data.ReadRemoteObject(); const WSError& errCode = PendingSessionToForeground(token); reply.WriteUint32(static_cast(errCode)); @@ -150,9 +138,6 @@ int SceneSessionManagerLiteStub::HandlePendingSessionToForeground(MessageParcel int SceneSessionManagerLiteStub::HandlePendingSessionToBackgroundForDelegator(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandlePendingSessionToBackground!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } sptr token = data.ReadRemoteObject(); const WSError& errCode = PendingSessionToBackgroundForDelegator(token); reply.WriteInt32(static_cast(errCode)); @@ -162,9 +147,6 @@ int SceneSessionManagerLiteStub::HandlePendingSessionToBackgroundForDelegator(Me int SceneSessionManagerLiteStub::HandleRegisterSessionListener(MessageParcel& data, MessageParcel& reply) { WLOGFD("run HandleRegisterSessionListener!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } sptr listener = iface_cast(data.ReadRemoteObject()); WSError errCode = RegisterSessionListener(listener); reply.WriteInt32(static_cast(errCode)); @@ -174,9 +156,6 @@ int SceneSessionManagerLiteStub::HandleRegisterSessionListener(MessageParcel& da int SceneSessionManagerLiteStub::HandleUnRegisterSessionListener(MessageParcel& data, MessageParcel& reply) { WLOGFD("run HandleUnRegisterSessionListener!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } sptr listener = iface_cast(data.ReadRemoteObject()); WSError errCode = UnRegisterSessionListener(listener); reply.WriteInt32(static_cast(errCode)); @@ -186,9 +165,6 @@ int SceneSessionManagerLiteStub::HandleUnRegisterSessionListener(MessageParcel& int SceneSessionManagerLiteStub::HandleGetSessionInfos(MessageParcel& data, MessageParcel& reply) { WLOGFD("run HandleGetSessionInfos!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } std::string deviceId = Str16ToStr8(data.ReadString16()); int numMax = data.ReadInt32(); std::vector missionInfos; @@ -209,9 +185,6 @@ int SceneSessionManagerLiteStub::HandleGetSessionInfos(MessageParcel& data, Mess int SceneSessionManagerLiteStub::HandleGetSessionInfo(MessageParcel& data, MessageParcel& reply) { WLOGFD("run HandleGetSessionInfo!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } SessionInfoBean info; std::string deviceId = Str16ToStr8(data.ReadString16()); int32_t persistentId = data.ReadInt32(); @@ -230,9 +203,6 @@ int SceneSessionManagerLiteStub::HandleGetSessionInfo(MessageParcel& data, Messa int SceneSessionManagerLiteStub::HandleTerminateSessionNew(MessageParcel& data, MessageParcel& reply) { - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } WLOGFD("run HandleTerminateSessionNew"); sptr abilitySessionInfo = data.ReadParcelable(); bool needStartCaller = data.ReadBool(); @@ -243,9 +213,6 @@ int SceneSessionManagerLiteStub::HandleTerminateSessionNew(MessageParcel& data, int SceneSessionManagerLiteStub::HandleGetFocusSessionToken(MessageParcel &data, MessageParcel &reply) { - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } WLOGFD("run HandleGetFocusSessionToken!"); sptr token = nullptr; const WSError& errCode = GetFocusSessionToken(token); @@ -256,9 +223,6 @@ int SceneSessionManagerLiteStub::HandleGetFocusSessionToken(MessageParcel &data, int SceneSessionManagerLiteStub::HandleSetSessionContinueState(MessageParcel &data, MessageParcel &reply) { - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } WLOGFD("HandleSetSessionContinueState"); sptr token = data.ReadRemoteObject(); auto continueState = static_cast(data.ReadInt32()); @@ -270,9 +234,6 @@ int SceneSessionManagerLiteStub::HandleSetSessionContinueState(MessageParcel &da int SceneSessionManagerLiteStub::HandleGetSessionSnapshot(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleGetSessionSnapshot!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } std::string deviceId = Str16ToStr8(data.ReadString16()); int32_t persistentId = data.ReadInt32(); bool isLowResolution = data.ReadBool(); @@ -286,9 +247,6 @@ int SceneSessionManagerLiteStub::HandleGetSessionSnapshot(MessageParcel &data, M int SceneSessionManagerLiteStub::HandleClearSession(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleClearSession!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } int32_t persistentId = data.ReadInt32(); const WSError& ret = ClearSession(persistentId); reply.WriteUint32(static_cast(ret)); @@ -298,9 +256,6 @@ int SceneSessionManagerLiteStub::HandleClearSession(MessageParcel &data, Message int SceneSessionManagerLiteStub::HandleClearAllSessions(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleClearAllSessions!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } const WSError& ret = ClearAllSessions(); reply.WriteUint32(static_cast(ret)); return ERR_NONE; @@ -309,9 +264,6 @@ int SceneSessionManagerLiteStub::HandleClearAllSessions(MessageParcel &data, Mes int SceneSessionManagerLiteStub::HandleLockSession(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleLockSession!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } int32_t sessionId = data.ReadInt32(); const WSError& ret = LockSession(sessionId); reply.WriteUint32(static_cast(ret)); @@ -321,9 +273,6 @@ int SceneSessionManagerLiteStub::HandleLockSession(MessageParcel &data, MessageP int SceneSessionManagerLiteStub::HandleUnlockSession(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleUnlockSession!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } int32_t sessionId = data.ReadInt32(); const WSError& ret = UnlockSession(sessionId); reply.WriteUint32(static_cast(ret)); @@ -333,9 +282,6 @@ int SceneSessionManagerLiteStub::HandleUnlockSession(MessageParcel &data, Messag int SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleMoveSessionsToForeground!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } std::vector sessionIds; data.ReadInt32Vector(&sessionIds); int32_t topSessionId = data.ReadInt32(); @@ -347,9 +293,6 @@ int SceneSessionManagerLiteStub::HandleMoveSessionsToForeground(MessageParcel &d int SceneSessionManagerLiteStub::HandleMoveSessionsToBackground(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleMoveSessionsToBackground!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } std::vector sessionIds; data.ReadInt32Vector(&sessionIds); std::vector result; @@ -363,9 +306,6 @@ int SceneSessionManagerLiteStub::HandleMoveSessionsToBackground(MessageParcel &d int SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(MessageParcel& data, MessageParcel& reply) { WLOGFI("run HandleGetFocusSessionInfo lite!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } FocusChangeInfo focusInfo; GetFocusWindowInfo(focusInfo); reply.WriteParcelable(&focusInfo); @@ -375,9 +315,6 @@ int SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(MessageParcel& data, int SceneSessionManagerLiteStub::HandleCheckWindowId(MessageParcel &data, MessageParcel &reply) { WLOGFI("run HandleCheckWindowId!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } int32_t windowId = INVALID_WINDOW_ID; if (!data.ReadInt32(windowId)) { WLOGE("Failed to readInt32 windowId"); @@ -400,9 +337,6 @@ int SceneSessionManagerLiteStub::HandleCheckWindowId(MessageParcel &data, Messag int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel &data, MessageParcel &reply) { WLOGFI("[Test]run HandleRegisterWindowManagerAgent!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } auto type = static_cast(data.ReadUint32()); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = @@ -415,9 +349,6 @@ int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel int SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent(MessageParcel &data, MessageParcel &reply) { WLOGFI("[Test]run HandleUnregisterWindowManagerAgent!"); - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } auto type = static_cast(data.ReadUint32()); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = @@ -429,9 +360,6 @@ int SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent(MessageParce int SceneSessionManagerLiteStub::HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply) { - if (data == nullptr || reply == nullptr) { - return ERR_INVALID_DATA; - } std::vector> infos; WMError errCode = GetVisibilityWindowInfo(infos); if (!MarshallingHelper::MarshallingVectorParcelableObj(reply, infos)) { -- Gitee From e82ac3d4c2953c1f67e02fa97cdd213e9dca14ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sun, 31 Mar 2024 02:11:49 +0000 Subject: [PATCH 304/385] std::nothrow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- wm/src/window_manager_lite.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index daf395625..40a1d1bf3 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -69,7 +69,7 @@ public: void WindowManagerLite::Impl::NotifyFocused(const sptr& focusChangeInfo) { if (focusChangeInfo != nullptr) { - TLOGD("[WMSFocus]NotifyFocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", + WLOGFD("[WMSFocus]NotifyFocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, static_cast(focusChangeInfo->windowType_)); } @@ -91,7 +91,7 @@ void WindowManagerLite::Impl::NotifyFocused(const sptr& focusCh void WindowManagerLite::Impl::NotifyUnfocused(const sptr& focusChangeInfo) { if (focusChangeInfo != nullptr) { - TLOGD("[WMSFocus]NotifyUnfocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", + WLOGFD("[WMSFocus]NotifyUnfocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, static_cast(focusChangeInfo->windowType_)); } @@ -176,7 +176,7 @@ WMError WindowManagerLite::RegisterFocusChangedListener(const sptr lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->focusChangedListenerAgent_ == nullptr) { - pImpl_->focusChangedListenerAgent_ = new (std::no_throw) WindowManagerAgentLite(); + pImpl_->focusChangedListenerAgent_ = new (std::nothrow) WindowManagerAgentLite(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS, pImpl_->focusChangedListenerAgent_); } @@ -228,7 +228,7 @@ WMError WindowManagerLite::RegisterVisibilityChangedListener(const sptr lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->windowVisibilityListenerAgent_ == nullptr) { - pImpl_->windowVisibilityListenerAgent_ = new (std::no_throw) WindowManagerAgentLite(); + pImpl_->windowVisibilityListenerAgent_ = new (std::nothrow) WindowManagerAgentLite(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY, pImpl_->windowVisibilityListenerAgent_); @@ -336,7 +336,7 @@ WMError WindowManagerLite::RegisterDrawingContentChangedListener(const sptr lock(pImpl_->mutex_); WMError ret = WMError::WM_OK; if (pImpl_->windowDrawingContentListenerAgent_ == nullptr) { - pImpl_->windowDrawingContentListenerAgent_ = new (std::no_throw) WindowManagerAgentLite(); + pImpl_->windowDrawingContentListenerAgent_ = new (std::nothrow) WindowManagerAgentLite(); ret = SingletonContainer::Get().RegisterWindowManagerAgent( WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_DRAWING_STATE, pImpl_->windowDrawingContentListenerAgent_); -- Gitee From 1ff29feee24e560fc57febf3b69b947a7e95e141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sun, 31 Mar 2024 03:00:31 +0000 Subject: [PATCH 305/385] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- interfaces/innerkits/wm/window_manager_lite.h | 8 +- .../zidl/scene_session_manager_lite_proxy.cpp | 172 +++++++++++++++--- .../zidl/scene_session_manager_lite_stub.cpp | 4 +- wm/src/window_manager_lite.cpp | 20 +- 4 files changed, 165 insertions(+), 39 deletions(-) diff --git a/interfaces/innerkits/wm/window_manager_lite.h b/interfaces/innerkits/wm/window_manager_lite.h index 836eb656a..24d43a5fc 100644 --- a/interfaces/innerkits/wm/window_manager_lite.h +++ b/interfaces/innerkits/wm/window_manager_lite.h @@ -16,17 +16,17 @@ #ifndef OHOS_ROSEN_WINDOW_MANAGER_LITE_H #define OHOS_ROSEN_WINDOW_MANAGER_LITE_H +#include #include #include #include #include -#include -#include "wm_single_instance.h" -#include "wm_common.h" #include "focus_change_info.h" -#include "window_visibility_info.h" #include "window_drawing_content_info.h" #include "window_manager.h" +#include "window_visibility_info.h" +#include "wm_common.h" +#include "wm_single_instance.h" namespace OHOS { namespace Rosen { diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp index 36adde9f2..aefbc0a89 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp @@ -49,7 +49,12 @@ WSError SceneSessionManagerLiteProxy::SetSessionLabel(const sptr return WSError::WS_ERROR_IPC_FAILED; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_LABEL), + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_LABEL), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -77,7 +82,12 @@ WSError SceneSessionManagerLiteProxy::SetSessionIcon(const sptr & return WSError::WS_ERROR_IPC_FAILED; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_ICON), + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_ICON), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -101,7 +111,12 @@ WSError SceneSessionManagerLiteProxy::IsValidSessionIds( return WSError::WS_ERROR_IPC_FAILED; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_IS_VALID_SESSION_IDS), + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_IS_VALID_SESSION_IDS), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -127,7 +142,12 @@ WSError SceneSessionManagerLiteProxy::PendingSessionToForeground(const sptrSendRequest(static_cast( + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_PENDING_SESSION_TO_FOREGROUND), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -152,7 +172,12 @@ WSError SceneSessionManagerLiteProxy::PendingSessionToBackgroundForDelegator(con return WSError::WS_ERROR_IPC_FAILED; } - if (Remote()->SendRequest(static_cast( + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -179,7 +204,13 @@ WSError SceneSessionManagerLiteProxy::RegisterSessionListener(const sptrSendRequest(static_cast( + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_SESSION_LISTENER), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -206,7 +237,13 @@ WSError SceneSessionManagerLiteProxy::UnRegisterSessionListener(const sptrSendRequest( + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest( static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_SESSION_LISTENER), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -234,7 +271,13 @@ WSError SceneSessionManagerLiteProxy::GetSessionInfos(const std::string& deviceI WLOGFE("GetSessionInfos numMax write failed."); return WSError::WS_ERROR_IPC_FAILED; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFOS), + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFOS), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -266,7 +309,13 @@ WSError SceneSessionManagerLiteProxy::GetSessionInfo(const std::string& deviceId WLOGFE("GetSessionInfo write persistentId failed."); return WSError::WS_ERROR_IPC_FAILED; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFO_BY_ID), + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFO_BY_ID), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -321,7 +370,13 @@ WSError SceneSessionManagerLiteProxy::TerminateSessionNew(const sptrSendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_TERMINATE_SESSION_NEW), + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_TERMINATE_SESSION_NEW), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -340,7 +395,12 @@ WSError SceneSessionManagerLiteProxy::GetFocusSessionToken(sptr & return WSError::WS_ERROR_IPC_FAILED; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN), + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -376,7 +436,12 @@ WSError SceneSessionManagerLiteProxy::GetSessionSnapshot(const std::string& devi return WSError::WS_ERROR_INVALID_PARAM; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_SNAPSHOT), + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_SNAPSHOT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -408,7 +473,13 @@ WSError SceneSessionManagerLiteProxy::SetSessionContinueState(const sptrSendRequest(static_cast( + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_CONTINUE_STATE), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -432,7 +503,13 @@ WSError SceneSessionManagerLiteProxy::LockSession(int32_t sessionId) WLOGFE("Write persistentId failed"); return WSError::WS_ERROR_INVALID_PARAM; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_LOCK_SESSION), + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_LOCK_SESSION), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -455,7 +532,13 @@ WSError SceneSessionManagerLiteProxy::UnlockSession(int32_t sessionId) WLOGFE("Write persistentId failed"); return WSError::WS_ERROR_INVALID_PARAM; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UNLOCK_SESSION), + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UNLOCK_SESSION), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -482,7 +565,13 @@ WSError SceneSessionManagerLiteProxy::MoveSessionsToForeground(const std::vector WLOGFE("Write topSessionId failed"); return WSError::WS_ERROR_INVALID_PARAM; } - if (Remote()->SendRequest(static_cast( + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -510,7 +599,13 @@ WSError SceneSessionManagerLiteProxy::MoveSessionsToBackground(const std::vector WLOGFE("Write result failed"); return WSError::WS_ERROR_INVALID_PARAM; } - if (Remote()->SendRequest(static_cast( + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -536,7 +631,12 @@ WSError SceneSessionManagerLiteProxy::ClearSession(int32_t persistentId) return WSError::WS_ERROR_INVALID_PARAM; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_SESSION), + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_SESSION), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -555,7 +655,12 @@ WSError SceneSessionManagerLiteProxy::ClearAllSessions() return WSError::WS_ERROR_INVALID_PARAM; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_ALL_SESSIONS), + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_ALL_SESSIONS), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -574,7 +679,12 @@ void SceneSessionManagerLiteProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo return; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_INFO), + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_INFO), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return; @@ -608,7 +718,12 @@ WMError SceneSessionManagerLiteProxy::RegisterWindowManagerAgent(WindowManagerAg return WMError::WM_ERROR_IPC_FAILED; } - if (Remote()->SendRequest(static_cast( + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WMError::WM_ERROR_IPC_FAILED; @@ -638,7 +753,12 @@ WMError SceneSessionManagerLiteProxy::UnregisterWindowManagerAgent(WindowManager return WMError::WM_ERROR_IPC_FAILED; } - if (Remote()->SendRequest(static_cast( + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WMError::WM_ERROR_IPC_FAILED; @@ -687,7 +807,13 @@ WMError SceneSessionManagerLiteProxy::GetVisibilityWindowInfo(std::vectorSendRequest(static_cast( + + sptr remote = Remote(); + if (remote == nullptr) { + WLOGFE("remote is nullptr"); + return WMError::WM_ERROR_NULLPTR; + } + if (remote->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID), data, reply, option) != ERR_NONE) { return WMError::WM_ERROR_IPC_FAILED; } diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index 4c93ebd4b..3a7861767 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -336,7 +336,7 @@ int SceneSessionManagerLiteStub::HandleCheckWindowId(MessageParcel &data, Messag int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel &data, MessageParcel &reply) { - WLOGFI("[Test]run HandleRegisterWindowManagerAgent!"); + WLOGFI("run HandleRegisterWindowManagerAgent!"); auto type = static_cast(data.ReadUint32()); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = @@ -348,7 +348,7 @@ int SceneSessionManagerLiteStub::HandleRegisterWindowManagerAgent(MessageParcel int SceneSessionManagerLiteStub::HandleUnregisterWindowManagerAgent(MessageParcel &data, MessageParcel &reply) { - WLOGFI("[Test]run HandleUnregisterWindowManagerAgent!"); + WLOGFI("run HandleUnregisterWindowManagerAgent!"); auto type = static_cast(data.ReadUint32()); sptr windowManagerAgentObject = data.ReadRemoteObject(); sptr windowManagerAgentProxy = diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index 40a1d1bf3..f67c144f1 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -68,11 +68,12 @@ public: void WindowManagerLite::Impl::NotifyFocused(const sptr& focusChangeInfo) { - if (focusChangeInfo != nullptr) { - WLOGFD("[WMSFocus]NotifyFocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", - focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, - static_cast(focusChangeInfo->windowType_)); + if (focusChangeInfo == nullptr) { + return; } + WLOGFD("[WMSFocus]NotifyFocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", + focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, + static_cast(focusChangeInfo->windowType_)); std::vector> focusChangeListeners; { @@ -90,11 +91,12 @@ void WindowManagerLite::Impl::NotifyFocused(const sptr& focusCh void WindowManagerLite::Impl::NotifyUnfocused(const sptr& focusChangeInfo) { - if (focusChangeInfo != nullptr) { - WLOGFD("[WMSFocus]NotifyUnfocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", - focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, - static_cast(focusChangeInfo->windowType_)); + if (focusChangeInfo == nullptr) { + return; } + WLOGFD("[WMSFocus]NotifyUnfocused [%{public}u; %{public}" PRIu64"; %{public}d; %{public}d; %{public}u]", + focusChangeInfo->windowId_, focusChangeInfo->displayId_, focusChangeInfo->pid_, focusChangeInfo->uid_, + static_cast(focusChangeInfo->windowType_)); std::vector> focusChangeListeners; { @@ -119,7 +121,6 @@ void WindowManagerLite::Impl::NotifyWindowVisibilityInfoChanged( visibilityChangeListeners = windowVisibilityListeners_; } for (auto& listener : visibilityChangeListeners) { - WLOGD("Notify WindowVisibilityInfo to caller"); if (listener == nullptr) { continue; } @@ -136,7 +137,6 @@ void WindowManagerLite::Impl::NotifyWindowDrawingContentInfoChanged( windowDrawingContentChangeListeners = windowDrawingContentListeners_; } for (auto& listener : windowDrawingContentChangeListeners) { - WLOGFD("Notify windowDrawingContentInfo to caller"); if (listener == nullptr) { continue; } -- Gitee From 3936e6928a5b4c732e1fd24d8188abb69a327ee9 Mon Sep 17 00:00:00 2001 From: liwei Date: Sun, 31 Mar 2024 10:49:35 +0800 Subject: [PATCH 306/385] Modify_Screenshot_Notify Signed-off-by: liwei --- .../js_embeddable_window_stage.cpp | 54 +++---- .../extension_window/js_extension_window.cpp | 138 +++++++++--------- .../js_extension_window_listener.cpp | 46 +++--- .../js_extension_window_register_manager.cpp | 31 ++-- .../js_extension_window_utils.cpp | 16 +- .../src/scene_session_manager.cpp | 9 +- 6 files changed, 150 insertions(+), 144 deletions(-) diff --git a/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp b/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp index fa2c5ec64..9c0219c5c 100644 --- a/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp +++ b/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp @@ -40,62 +40,62 @@ JsEmbeddableWindowStage::~JsEmbeddableWindowStage() void JsEmbeddableWindowStage::Finalizer(napi_env env, void* data, void* hint) { - WLOGI("[NAPI]Finalizer"); + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]Finalizer"); std::unique_ptr(static_cast(data)); } napi_value JsEmbeddableWindowStage::GetMainWindow(napi_env env, napi_callback_info info) { - WLOGFD("[NAPI]GetMainWindow"); + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]GetMainWindow"); JsEmbeddableWindowStage* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetMainWindow(env, info) : nullptr; } napi_value JsEmbeddableWindowStage::GetMainWindowSync(napi_env env, napi_callback_info info) { - WLOGFD("[NAPI]GetMainWindowSync"); + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]GetMainWindowSync"); JsEmbeddableWindowStage* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetMainWindowSync(env, info) : nullptr; } napi_value JsEmbeddableWindowStage::On(napi_env env, napi_callback_info info) { - WLOGFD("[NAPI]On"); + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]On"); JsEmbeddableWindowStage* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnEvent(env, info) : nullptr; } napi_value JsEmbeddableWindowStage::Off(napi_env env, napi_callback_info info) { - WLOGFD("[NAPI]Off"); + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]Off"); JsEmbeddableWindowStage* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OffEvent(env, info) : nullptr; } napi_value JsEmbeddableWindowStage::LoadContent(napi_env env, napi_callback_info info) { - WLOGFD("[NAPI]LoadContent"); + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]LoadContent"); JsEmbeddableWindowStage* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnLoadContent(env, info, false) : nullptr; } napi_value JsEmbeddableWindowStage::LoadContentByName(napi_env env, napi_callback_info info) { - WLOGFD("[NAPI]LoadContentByName"); + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]LoadContentByName"); JsEmbeddableWindowStage* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnLoadContent(env, info, true) : nullptr; } napi_value JsEmbeddableWindowStage::CreateSubWindow(napi_env env, napi_callback_info info) { - WLOGFD("[NAPI]CreateSubWindow"); + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]CreateSubWindow"); JsEmbeddableWindowStage* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnCreateSubWindow(env, info) : nullptr; } napi_value JsEmbeddableWindowStage::GetSubWindow(napi_env env, napi_callback_info info) { - WLOGFD("[NAPI]GetSubWindow"); + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]GetSubWindow"); JsEmbeddableWindowStage* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetSubWindow(env, info) : nullptr; } @@ -143,7 +143,7 @@ napi_value JsEmbeddableWindowStage::OnGetMainWindow(napi_env env, napi_callback_ if (windowImpl != nullptr) { task.Resolve(env, Rosen::JsExtensionWindow::CreateJsExtensionWindowObject(env, windowImpl, sessionInfo)); - WLOGI("[NAPI]Get main window [%{public}u, %{public}s]", + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]Get main window [%{public}u, %{public}s]", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str()); } else { task.Reject(env, CreateJsError(env, @@ -165,7 +165,7 @@ napi_value JsEmbeddableWindowStage::OnGetMainWindow(napi_env env, napi_callback_ napi_value JsEmbeddableWindowStage::OnGetMainWindowSync(napi_env env, napi_callback_info info) { if (windowExtensionSessionImpl_ == nullptr) { - WLOGFE("[NAPI]window is null"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]window is null"); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); return NapiGetUndefined(env); } @@ -178,14 +178,14 @@ napi_value JsEmbeddableWindowStage::OnEvent(napi_env env, napi_callback_info inf { sptr windowImpl = windowExtensionSessionImpl_; if (windowImpl == nullptr) { - WLOGFE("[NAPI]windowImpl is null"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]windowImpl is null"); return NapiGetUndefined(env); } size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 2) { // 2: minimum param nums - WLOGFE("[NAPI]argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]argc is invalid: %{public}zu", argc); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); return NapiGetUndefined(env); } @@ -193,13 +193,13 @@ napi_value JsEmbeddableWindowStage::OnEvent(napi_env env, napi_callback_info inf // Parse argv[0] as string std::string eventString; if (!ConvertFromJsValue(env, argv[0], eventString)) { - WLOGFE("[NAPI]Failed to convert parameter to string"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to convert parameter to string"); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); return NapiGetUndefined(env); } napi_value value = argv[1]; if (!NapiIsCallable(env, value)) { - WLOGFE("[NAPI]Callback(argv[1]) is not callable"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Callback(argv[1]) is not callable"); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); return NapiGetUndefined(env); } @@ -207,10 +207,10 @@ napi_value JsEmbeddableWindowStage::OnEvent(napi_env env, napi_callback_info inf WmErrorCode ret = extwinRegisterManager_->RegisterListener(windowImpl, eventString, CaseType::CASE_STAGE, env, value); if (ret != WmErrorCode::WM_OK) { - WLOGFE("[NAPI]RegisterListener fail"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]RegisterListener fail"); return NapiThrowError(env, ret); } - WLOGI("[NAPI]Window [%{public}u, %{public}s] register event %{public}s", + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]Window [%{public}u, %{public}s] register event %{public}s", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), eventString.c_str()); return NapiGetUndefined(env); @@ -220,7 +220,7 @@ napi_value JsEmbeddableWindowStage::OffEvent(napi_env env, napi_callback_info in { sptr windowImpl = windowExtensionSessionImpl_; if (windowImpl == nullptr) { - WLOGFE("[NAPI]windowImpl is null"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]windowImpl is null"); return NapiGetUndefined(env); } size_t argc = 4; @@ -229,12 +229,12 @@ napi_value JsEmbeddableWindowStage::OffEvent(napi_env env, napi_callback_info in // Parse argv[0] as string std::string eventString; if (!ConvertFromJsValue(env, argv[0], eventString)) { - WLOGFE("[NAPI]Failed to convert parameter to string"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to convert parameter to string"); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); return NapiGetUndefined(env); } if (eventString.compare("windowStageEvent") != 0) { - WLOGFE("[NAPI]Envent %{public}s is invalid", eventString.c_str()); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Envent %{public}s is invalid", eventString.c_str()); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); return NapiGetUndefined(env); } @@ -253,10 +253,10 @@ napi_value JsEmbeddableWindowStage::OffEvent(napi_env env, napi_callback_info in } } if (ret != WmErrorCode::WM_OK) { - WLOGFE("[NAPI]UnregisterListener fail"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]UnregisterListener fail"); return NapiThrowError(env, ret); } - WLOGI("[NAPI]Window [%{public}u, %{public}s] unregister event %{public}s", + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]Window [%{public}u, %{public}s] unregister event %{public}s", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), eventString.c_str()); return NapiGetUndefined(env); @@ -278,7 +278,7 @@ static void LoadContentTask(std::shared_ptr contentStorage, std } else { task.Reject(env, CreateJsError(env, static_cast(ret), "Window load content failed")); } - WLOGI("[NAPI]Window [%{public}u, %{public}s] load content end, ret = %{public}d", + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]Window [%{public}u, %{public}s] load content end, ret = %{public}d", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), ret); return; } @@ -291,7 +291,7 @@ napi_value JsEmbeddableWindowStage::OnLoadContent(napi_env env, napi_callback_in napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (!ConvertFromJsValue(env, argv[0], contextUrl)) { - WLOGFE("[NAPI]Failed to convert parameter to context url"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to convert parameter to context url"); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } napi_value storage = nullptr; @@ -307,7 +307,7 @@ napi_value JsEmbeddableWindowStage::OnLoadContent(napi_env env, napi_callback_in callBack = value2; } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - WLOGFE("[NAPI]Window scene is null or get invalid param"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window scene is null or get invalid param"); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); return NapiGetUndefined(env); } @@ -325,7 +325,7 @@ napi_value JsEmbeddableWindowStage::OnLoadContent(napi_env env, napi_callback_in napi_env env, NapiAsyncTask& task, int32_t status) { if (window == nullptr) { task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); - WLOGFE("[NAPI]Get windowExtensionSessionImpl failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Get windowExtensionSessionImpl failed"); return; } LoadContentTask(contentStorage, contextUrl, window, env, task, parentToken, isLoadedByName); @@ -339,7 +339,7 @@ napi_value JsEmbeddableWindowStage::OnLoadContent(napi_env env, napi_callback_in napi_value JsEmbeddableWindowStage::CreateJsEmbeddableWindowStage(napi_env env, sptr window, sptr sessionInfo) { - WLOGFD("[NAPI]CreateJsEmbeddableWindowStage"); + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]CreateJsEmbeddableWindowStage"); napi_value objValue = nullptr; napi_create_object(env, &objValue); diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index e7078a3e1..1cd40e37b 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -49,12 +49,12 @@ JsExtensionWindow::~JsExtensionWindow() {} napi_value JsExtensionWindow::CreateJsExtensionWindow(napi_env env, sptr window, int32_t hostWindowId) { - WLOGI("JsExtensionWindow CreateJsExtensionWindow"); + TLOGI(WmsLogTag::WMS_UIEXT, "JsExtensionWindow CreateJsExtensionWindow"); napi_value objValue = nullptr; napi_create_object(env, &objValue); if (env == nullptr || window == nullptr) { - WLOGFE("JsExtensionWindow env or window is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "JsExtensionWindow env or window is nullptr"); return nullptr; } @@ -83,12 +83,12 @@ napi_value JsExtensionWindow::CreateJsExtensionWindow(napi_env env, sptr window, sptr sessionInfo) { - WLOGI("JsExtensionWindow CreateJsExtensionWindow"); + TLOGI(WmsLogTag::WMS_UIEXT, "JsExtensionWindow CreateJsExtensionWindow"); napi_value objValue = nullptr; napi_create_object(env, &objValue); if (env == nullptr || window == nullptr) { - WLOGFE("JsExtensionWindow env or window is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "JsExtensionWindow env or window is nullptr"); return nullptr; } @@ -126,41 +126,41 @@ napi_value JsExtensionWindow::CreateJsExtensionWindowObject(napi_env env, sptr(static_cast(data)); } napi_value JsExtensionWindow::GetWindowAvoidArea(napi_env env, napi_callback_info info) { - WLOGI("GetWindowAvoidArea is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "GetWindowAvoidArea is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetWindowAvoidArea(env, info) : nullptr; } napi_value JsExtensionWindow::RegisterExtensionWindowCallback(napi_env env, napi_callback_info info) { - WLOGI("RegisterExtensionWindowCallback is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "RegisterExtensionWindowCallback is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnRegisterExtensionWindowCallback(env, info) : nullptr; } napi_value JsExtensionWindow::UnRegisterExtensionWindowCallback(napi_env env, napi_callback_info info) { - WLOGI("UnRegisterExtensionWindowCallback is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "UnRegisterExtensionWindowCallback is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnUnRegisterExtensionWindowCallback(env, info) : nullptr; } napi_value JsExtensionWindow::HideNonSecureWindows(napi_env env, napi_callback_info info) { - WLOGI("HideNonSecureWindows is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnHideNonSecureWindows(env, info) : nullptr; } napi_value JsExtensionWindow::CreateSubWindowWithOptions(napi_env env, napi_callback_info info) { - WLOGI("CreateSubWindowWithOptions is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "CreateSubWindowWithOptions is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnCreateSubWindowWithOptions(env, info) : nullptr; } @@ -174,112 +174,112 @@ napi_value JsExtensionWindow::SetWaterMarkFlag(napi_env env, napi_callback_info napi_value JsExtensionWindow::LoadContent(napi_env env, napi_callback_info info) { - WLOGI("LoadContent is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "LoadContent is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnLoadContent(env, info, false) : nullptr; } napi_value JsExtensionWindow::LoadContentByName(napi_env env, napi_callback_info info) { - WLOGI("LoadContentByName is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "LoadContentByName is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnLoadContent(env, info, true) : nullptr; } napi_value JsExtensionWindow::ShowWindow(napi_env env, napi_callback_info info) { - WLOGI("ShowWindow is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "ShowWindow is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnShowWindow(env, info) : nullptr; } napi_value JsExtensionWindow::IsWindowShowingSync(napi_env env, napi_callback_info info) { - WLOGI("IsShowing is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "IsShowing is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnIsWindowShowingSync(env, info) : nullptr; } napi_value JsExtensionWindow::SetUIContent(napi_env env, napi_callback_info info) { - WLOGI("LoadContent is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "LoadContent is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetUIContent(env, info) : nullptr; } napi_value JsExtensionWindow::DestroyWindow(napi_env env, napi_callback_info info) { - WLOGI("Destroy is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "Destroy is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnDestroyWindow(env, info) : nullptr; } napi_value JsExtensionWindow::SetWindowBackgroundColorSync(napi_env env, napi_callback_info info) { - WLOGI("SetBackgroundColor is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "SetBackgroundColor is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetWindowBackgroundColorSync(env, info) : nullptr; } napi_value JsExtensionWindow::GetWindowPropertiesSync(napi_env env, napi_callback_info info) { - WLOGD("GetProperties is called"); + TLOGD(WmsLogTag::WMS_UIEXT, "GetProperties is called"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetWindowPropertiesSync(env, info) : nullptr; } napi_value JsExtensionWindow::MoveWindowTo(napi_env env, napi_callback_info info) { - WLOGD("MoveTo"); + TLOGD(WmsLogTag::WMS_UIEXT, "MoveTo"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnMoveWindowTo(env, info) : nullptr; } napi_value JsExtensionWindow::ResizeWindow(napi_env env, napi_callback_info info) { - WLOGI("Resize"); + TLOGI(WmsLogTag::WMS_UIEXT, "Resize"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnResizeWindow(env, info) : nullptr; } napi_value JsExtensionWindow::SetSpecificSystemBarEnabled(napi_env env, napi_callback_info info) { - WLOGI("SetSystemBarEnable"); + TLOGI(WmsLogTag::WMS_UIEXT, "SetSystemBarEnable"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetSpecificSystemBarEnabled(env, info) : nullptr; } napi_value JsExtensionWindow::SetPreferredOrientation(napi_env env, napi_callback_info info) { - WLOGD("SetPreferredOrientation"); + TLOGD(WmsLogTag::WMS_UIEXT, "SetPreferredOrientation"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetPreferredOrientation(env, info) : nullptr; } napi_value JsExtensionWindow::GetPreferredOrientation(napi_env env, napi_callback_info info) { - WLOGD("GetPreferredOrientation"); + TLOGD(WmsLogTag::WMS_UIEXT, "GetPreferredOrientation"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetPreferredOrientation(env, info) : nullptr; } napi_value JsExtensionWindow::GetUIContext(napi_env env, napi_callback_info info) { - WLOGD("GetUIContext"); + TLOGD(WmsLogTag::WMS_UIEXT, "GetUIContext"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnGetUIContext(env, info) : nullptr; } napi_value JsExtensionWindow::SetWindowBrightness(napi_env env, napi_callback_info info) { - WLOGI("SetBrightness"); + TLOGI(WmsLogTag::WMS_UIEXT, "SetBrightness"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetWindowBrightness(env, info) : nullptr; } napi_value JsExtensionWindow::SetWindowKeepScreenOn(napi_env env, napi_callback_info info) { - WLOGI("SetKeepScreenOn"); + TLOGI(WmsLogTag::WMS_UIEXT, "SetKeepScreenOn"); JsExtensionWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetWindowKeepScreenOn(env, info) : nullptr; } @@ -308,7 +308,7 @@ static void LoadContentTask(std::shared_ptr contentStorage, std } else { task.Reject(env, CreateJsError(env, static_cast(ret), "Window load content failed")); } - WLOGI("Window [%{public}u, %{public}s] load content end, ret = %{public}d", + TLOGI(WmsLogTag::WMS_UIEXT, "Window [%{public}u, %{public}s] load content end, ret = %{public}d", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), ret); return; } @@ -434,11 +434,11 @@ napi_value JsExtensionWindow::OnGetWindowPropertiesSync(napi_env env, napi_callb { sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { - WLOGFW("window is nullptr or get invalid param"); + TLOGW(WmsLogTag::WMS_UIEXT, "window is nullptr or get invalid param"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } auto objValue = CreateJsExtensionWindowProperties(env, windowImpl); - WLOGI("Window [%{public}u, %{public}s] get properties end", + TLOGI(WmsLogTag::WMS_UIEXT, "Window [%{public}u, %{public}s] get properties end", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str()); if (objValue != nullptr) { return objValue; @@ -457,20 +457,20 @@ napi_value JsExtensionWindow::OnDestroyWindow(napi_env env, napi_callback_info i NapiAsyncTask::CompleteCallback complete = [this, extwin = extensionWindow_](napi_env env, NapiAsyncTask& task, int32_t status) { if (extwin == nullptr) { - WLOGFE("extensionWindow is null"); + TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow is null"); task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); return; } sptr windowImpl = extwin->GetWindow(); if (windowImpl == nullptr) { - WLOGFE("window is nullptr or get invalid param"); + TLOGE(WmsLogTag::WMS_UIEXT, "window is nullptr or get invalid param"); task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); return; } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowImpl->Destroy()); - WLOGI("Window [%{public}u, %{public}s] destroy end, ret = %{public}d", + TLOGI(WmsLogTag::WMS_UIEXT, "Window [%{public}u, %{public}s] destroy end, ret = %{public}d", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), ret); if (ret != WmErrorCode::WM_OK) { task.Reject(env, @@ -496,11 +496,11 @@ napi_value JsExtensionWindow::OnIsWindowShowingSync(napi_env env, napi_callback_ { sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { - WLOGFE("window is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "window is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } bool state = (windowImpl->GetWindowState() == WindowState::STATE_SHOWN); - WLOGI("Window [%{public}u, %{public}s] get show state end, state = %{public}u", + TLOGI(WmsLogTag::WMS_UIEXT, "Window [%{public}u, %{public}s] get show state end, state = %{public}u", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), state); return CreateJsValue(env, state); } @@ -510,7 +510,7 @@ napi_value JsExtensionWindow::OnShowWindow(napi_env env, napi_callback_info info NapiAsyncTask::CompleteCallback complete = [extwin = extensionWindow_](napi_env env, NapiAsyncTask& task, int32_t status) { if (extwin == nullptr) { - WLOGFE("extensionWindow is null"); + TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow is null"); task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); return; @@ -519,11 +519,11 @@ napi_value JsExtensionWindow::OnShowWindow(napi_env env, napi_callback_info info if (windowImpl == nullptr) { task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); - WLOGFE("window is nullptr or get invalid param"); + TLOGE(WmsLogTag::WMS_UIEXT, "window is nullptr or get invalid param"); return; } WMError ret = windowImpl->Show(0, false); - WLOGI("Window [%{public}u, %{public}s] show with ret = %{public}d", + TLOGI(WmsLogTag::WMS_UIEXT, "Window [%{public}u, %{public}s] show with ret = %{public}d", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), ret); if (ret == WMError::WM_OK) { task.Resolve(env, NapiGetUndefined(env)); @@ -531,7 +531,7 @@ napi_value JsExtensionWindow::OnShowWindow(napi_env env, napi_callback_info info task.Reject(env, CreateJsError(env, static_cast(WM_JS_TO_ERROR_CODE_MAP.at(ret)), "Window show failed")); } - WLOGI("Window [%{public}u, %{public}s] show end, ret = %{public}d", + TLOGI(WmsLogTag::WMS_UIEXT, "Window [%{public}u, %{public}s] show end, ret = %{public}d", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), ret); }; napi_value result = nullptr; @@ -552,12 +552,12 @@ napi_value JsExtensionWindow::OnSetUIContent(napi_env env, napi_callback_info in napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { // 2 maximum param num - WLOGFE("Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_UIEXT, "Argc is invalid: %{public}zu", argc); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } std::string contextUrl; if (errCode == WmErrorCode::WM_OK && !ConvertFromJsValue(env, argv[0], contextUrl)) { - WLOGFE("Failed to convert parameter to context url"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to context url"); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } napi_value callBack = nullptr; @@ -574,7 +574,7 @@ napi_value JsExtensionWindow::OnSetUIContent(napi_env env, napi_callback_info in [extwin = extensionWindow_, contentStorage, contextUrl, parentToken] (napi_env env, NapiAsyncTask& task, int32_t status) { if (extwin == nullptr) { - WLOGFE("Window is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "Window is nullptr"); task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); return; @@ -589,14 +589,14 @@ napi_value JsExtensionWindow::OnSetUIContent(napi_env env, napi_callback_info in napi_value JsExtensionWindow::OnLoadContent(napi_env env, napi_callback_info info, bool isLoadedByName) { - WLOGI("OnLoadContent is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "OnLoadContent is called"); WmErrorCode errCode = WmErrorCode::WM_OK; size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); std::string contextUrl; if (!ConvertFromJsValue(env, argv[0], contextUrl)) { - WLOGI("Failed to convert parameter to context url"); + TLOGI(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to context url"); errCode = WmErrorCode::WM_ERROR_INVALID_PARAM; } napi_value storage = nullptr; @@ -612,7 +612,7 @@ napi_value JsExtensionWindow::OnLoadContent(napi_env env, napi_callback_info inf callBack = value2; } if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { - WLOGI("Window is null or get invalid param"); + TLOGI(WmsLogTag::WMS_UIEXT, "Window is null or get invalid param"); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); return NapiGetUndefined(env); } @@ -629,7 +629,7 @@ napi_value JsExtensionWindow::OnLoadContent(napi_env env, napi_callback_info inf [extwin = extensionWindow_, contentStorage, contextUrl, parentToken, isLoadedByName]( napi_env env, NapiAsyncTask& task, int32_t status) { if (extwin == nullptr) { - WLOGFE("Window is nullptr or get invalid param"); + TLOGE(WmsLogTag::WMS_UIEXT, "Window is nullptr or get invalid param"); task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY))); return; } @@ -643,7 +643,7 @@ napi_value JsExtensionWindow::OnLoadContent(napi_env env, napi_callback_info inf napi_value JsExtensionWindow::OnGetWindowAvoidArea(napi_env env, napi_callback_info info) { - WLOGI("OnGetWindowAvoidArea is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "OnGetWindowAvoidArea is called"); WmErrorCode errCode = WmErrorCode::WM_OK; size_t argc = 4; @@ -669,7 +669,7 @@ napi_value JsExtensionWindow::OnGetWindowAvoidArea(napi_env env, napi_callback_i } if (extensionWindow_ == nullptr) { - WLOGFE("extensionWindow_ is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STAGE_ABNORMALLY))); return CreateJsValue(env, static_cast(WmErrorCode::WM_ERROR_STAGE_ABNORMALLY)); } @@ -677,7 +677,7 @@ napi_value JsExtensionWindow::OnGetWindowAvoidArea(napi_env env, napi_callback_i AvoidArea avoidArea; WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(extensionWindow_->GetAvoidAreaByType(avoidAreaType, avoidArea)); if (ret != WmErrorCode::WM_OK) { - WLOGFE("OnGetAvoidAreaByType failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "OnGetAvoidAreaByType failed"); avoidArea.topRect_ = g_emptyRect; avoidArea.leftRect_ = g_emptyRect; avoidArea.rightRect_ = g_emptyRect; @@ -685,10 +685,10 @@ napi_value JsExtensionWindow::OnGetWindowAvoidArea(napi_env env, napi_callback_i } napi_value avoidAreaObj = ConvertAvoidAreaToJsValue(env, avoidArea, avoidAreaType); if (avoidAreaObj != nullptr) { - WLOGI("avoidAreaObj is finish"); + TLOGI(WmsLogTag::WMS_UIEXT, "avoidAreaObj is finish"); return avoidAreaObj; } else { - WLOGFE("avoidAreaObj is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "avoidAreaObj is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } } @@ -697,33 +697,33 @@ napi_value JsExtensionWindow::OnRegisterExtensionWindowCallback(napi_env env, na { sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { - WLOGFE("WindowImpl is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "WindowImpl is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 2) { // 2: params num - WLOGFE("Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_UIEXT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } std::string cbType; if (!ConvertFromJsValue(env, argv[0], cbType)) { - WLOGFE("Failed to convert parameter to callbackType"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to callbackType"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } napi_value value = argv[1]; if (!NapiIsCallable(env, value)) { - WLOGFE("Callback(info->argv[1]) is not callable"); + TLOGE(WmsLogTag::WMS_UIEXT, "Callback(info->argv[1]) is not callable"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } WmErrorCode ret = extensionRegisterManager_->RegisterListener(windowImpl, cbType, CaseType::CASE_WINDOW, env, value); if (ret != WmErrorCode::WM_OK) { - WLOGFE("Callback(info->argv[1]) is not callable"); + TLOGE(WmsLogTag::WMS_UIEXT, "Callback(info->argv[1]) is not callable"); return NapiThrowError(env, ret); } - WLOGI("Register end, window [%{public}u, %{public}s], type = %{public}s", + TLOGI(WmsLogTag::WMS_UIEXT, "Register end, window [%{public}u, %{public}s], type = %{public}s", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), cbType.c_str()); return NapiGetUndefined(env); } @@ -732,19 +732,19 @@ napi_value JsExtensionWindow::OnUnRegisterExtensionWindowCallback(napi_env env, { sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { - WLOGFE("windowImpl is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "windowImpl is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - WLOGFE("Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_UIEXT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } std::string cbType; if (!ConvertFromJsValue(env, argv[0], cbType)) { - WLOGFE("Failed to convert parameter to callbackType"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to callbackType"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } @@ -765,7 +765,7 @@ napi_value JsExtensionWindow::OnUnRegisterExtensionWindowCallback(napi_env env, if (ret != WmErrorCode::WM_OK) { return NapiThrowError(env, ret); } - WLOGI("UnRegister end, window [%{public}u, %{public}s], type = %{public}s", + TLOGI(WmsLogTag::WMS_UIEXT, "UnRegister end, window [%{public}u, %{public}s], type = %{public}s", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), cbType.c_str()); return NapiGetUndefined(env); } @@ -773,24 +773,24 @@ napi_value JsExtensionWindow::OnUnRegisterExtensionWindowCallback(napi_env env, napi_value JsExtensionWindow::OnHideNonSecureWindows(napi_env env, napi_callback_info info) { if (extensionWindow_ == nullptr) { - WLOGFE("extensionWindow_ is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "extensionWindow_ is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } sptr windowImpl = extensionWindow_->GetWindow(); if (windowImpl == nullptr) { - WLOGFE("windowImpl is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "windowImpl is nullptr"); return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); } size_t argc = 4; napi_value argv[4] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc < 1) { - WLOGFE("Argc is invalid: %{public}zu", argc); + TLOGE(WmsLogTag::WMS_UIEXT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } bool shouldHide = false; if (!ConvertFromJsValue(env, argv[0], shouldHide)) { - WLOGFE("Failed to convert parameter to bool"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert parameter to bool"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } @@ -799,7 +799,7 @@ napi_value JsExtensionWindow::OnHideNonSecureWindows(napi_env env, napi_callback if (ret != WmErrorCode::WM_OK) { return NapiThrowError(env, ret); } - WLOGI("OnHideNonSecureWindows end, window [%{public}u, %{public}s], shouldHide:%{public}u", + TLOGI(WmsLogTag::WMS_UIEXT, "OnHideNonSecureWindows end, window [%{public}u, %{public}s], shouldHide:%{public}u", windowImpl->GetWindowId(), windowImpl->GetWindowName().c_str(), shouldHide); return NapiGetUndefined(env); } @@ -840,14 +840,14 @@ napi_value JsExtensionWindow::OnSetWaterMarkFlag(napi_env env, napi_callback_inf napi_value JsExtensionWindow::GetProperties(napi_env env, napi_callback_info info) { - WLOGI("GetProperties is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "GetProperties is called"); napi_value jsThis; NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &jsThis, nullptr)); JsExtensionWindow* jsExtensionWindow = nullptr; NAPI_CALL(env, napi_unwrap(env, jsThis, reinterpret_cast(&jsExtensionWindow))); if (!jsExtensionWindow || !jsExtensionWindow->extensionWindow_) { - WLOGFE("window is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "window is nullptr"); return nullptr; } sptr window = jsExtensionWindow->extensionWindow_->GetWindow(); @@ -861,7 +861,7 @@ napi_value JsExtensionWindow::OnCreateSubWindowWithOptions(napi_env env, napi_ca napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); std::string windowName; if (!ConvertFromJsValue(env, argv[0], windowName)) { - WLOGFE("[NAPI]Failed to convert parameter to windowName"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to convert parameter to windowName"); napi_throw(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_INVALID_PARAM))); return NapiGetUndefined(env); } @@ -891,7 +891,7 @@ napi_value JsExtensionWindow::OnCreateSubWindowWithOptions(napi_env env, napi_ca return; } task.Resolve(env, CreateJsWindowObject(env, window)); - WLOGI("[NAPI]Create sub window %{public}s end", windowName.c_str()); + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]Create sub window %{public}s end", windowName.c_str()); }; napi_value callback = (argv[2] != nullptr && GetType(env, argv[2]) == napi_function) ? argv[2] : nullptr; napi_value result = nullptr; diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp index 272ddd61c..bfc746b0b 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -37,7 +37,7 @@ const std::string KEYBOARD_HEIGHT_CHANGE_CB = "keyboardHeightChange"; JsExtensionWindowListener::~JsExtensionWindowListener() { - WLOGI("[NAPI]~JsExtensionWindowListener"); + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]~JsExtensionWindowListener"); } void JsExtensionWindowListener::SetMainEventHandler() @@ -51,14 +51,14 @@ void JsExtensionWindowListener::SetMainEventHandler() void JsExtensionWindowListener::CallJsMethod(const char* methodName, napi_value const * argv, size_t argc) { - WLOGI("[NAPI]CallJsMethod methodName = %{public}s", methodName); + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]CallJsMethod methodName = %{public}s", methodName); if (env_ == nullptr || jsCallBack_ == nullptr) { - WLOGFE("[NAPI]env_ nullptr or jsCallBack_ is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]env_ nullptr or jsCallBack_ is nullptr"); return; } napi_value method = jsCallBack_->GetNapiValue(); if (method == nullptr) { - WLOGFE("[NAPI]Failed to get method callback from object"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Failed to get method callback from object"); return; } napi_value result = nullptr; @@ -69,9 +69,10 @@ void JsExtensionWindowListener::CallJsMethod(const char* methodName, napi_value void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction) { - WLOGI("[NAPI]OnSizeChange, [%{public}u, %{public}u], reason=%{public}u", rect.width_, rect.height_, reason); + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]OnSizeChange, [%{public}u, %{public}u], reason=%{public}u", + rect.width_, rect.height_, reason); if (currentWidth_ == rect.width_ && currentHeight_ == rect.height_ && reason != WindowSizeChangeReason::DRAG_END) { - WLOGFD("[NAPI]no need to change size"); + TLOGD(WmsLogTag::WMS_UIEXT, "[NAPI]no need to change size"); return; } // js callback should run in js thread @@ -79,7 +80,7 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsExtensionWindowListener::OnSizeChange"); auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { - WLOGFE("[NAPI]this listener or eng is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]this listener or eng is nullptr"); return; } napi_handle_scope scope = nullptr; @@ -87,7 +88,7 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r napi_value objValue = nullptr; napi_create_object(eng, &objValue); if (objValue == nullptr) { - WLOGFE("Failed to convert rect to jsObject"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert rect to jsObject"); return; } napi_set_named_property(eng, objValue, "width", CreateJsValue(eng, rect.width_)); @@ -100,7 +101,7 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r jsCallback(); } else { if (!eventHandler_) { - WLOGFE("get main event handler failed!"); + TLOGE(WmsLogTag::WMS_UIEXT, "get main event handler failed!"); return; } eventHandler_->PostTask(jsCallback, "wms:JsExtensionWindowListener::OnSizeChange", 0, @@ -112,18 +113,18 @@ void JsExtensionWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason r void JsExtensionWindowListener::OnModeChange(WindowMode mode, bool hasDeco) { - WLOGI("[NAPI]OnModeChange %{public}u", mode); + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]OnModeChange %{public}u", mode); } void JsExtensionWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) { - WLOGFI("[NAPI]OnAvoidAreaChanged"); + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]OnAvoidAreaChanged"); // js callback should run in js thread std::unique_ptr complete = std::make_unique ( [self = weakRef_, avoidArea, type, eng = env_] (napi_env env, NapiAsyncTask &task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { - WLOGFE("[NAPI]this listener or eng is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]this listener or eng is nullptr"); return; } napi_value avoidAreaValue = ConvertAvoidAreaToJsValue(env, avoidArea, type); @@ -137,7 +138,7 @@ void JsExtensionWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, Av napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - WLOGFE("Failed to get object"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to get object"); return; } napi_set_named_property(env, objValue, "type", @@ -158,15 +159,16 @@ void JsExtensionWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, Av void JsExtensionWindowListener::OnSizeChange(const sptr& info, const std::shared_ptr& rsTransaction) { - WLOGI("[NAPI]OccupiedAreaChangeInfo, type: %{public}d, input rect:[%{public}d, %{public}d, %{public}d, %{public}d]", - static_cast(info->type_), info->rect_.posX_, info->rect_.posY_, info->rect_.width_, - info->rect_.height_); + TLOGI(WmsLogTag::WMS_UIEXT, + "[NAPI]OccupiedAreaChangeInfo, type: %{public}d, input rect:[%{public}d, %{public}d, %{public}d, %{public}d]", + static_cast(info->type_), info->rect_.posX_, info->rect_.posY_, info->rect_.width_, + info->rect_.height_); // js callback should run in js thread std::unique_ptr complete = std::make_unique ( [self = weakRef_, info, eng = env_] (napi_env env, NapiAsyncTask& task, int32_t status) { auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { - WLOGFE("[NAPI]this listener or eng is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]this listener or eng is nullptr"); return; } napi_value argv[] = {CreateJsValue(eng, info->rect_.height_)}; @@ -183,12 +185,12 @@ void JsExtensionWindowListener::OnSizeChange(const sptr& static void LifeCycleCallBack(LifeCycleEventType eventType, wptr weakRef, napi_env env, std::shared_ptr eventHandler) { - WLOGI("LifeCycleCallBack, envent type: %{public}u", eventType); + TLOGI(WmsLogTag::WMS_UIEXT, "LifeCycleCallBack, envent type: %{public}u", eventType); auto task = [self = weakRef, eventType, eng = env] () { HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "JsExtensionWindowListener::LifeCycleCallBack"); auto thisListener = self.promote(); if (thisListener == nullptr || eng == nullptr) { - WLOGFE("this listener or eng is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "this listener or eng is nullptr"); return; } napi_handle_scope scope = nullptr; @@ -198,7 +200,7 @@ static void LifeCycleCallBack(LifeCycleEventType eventType, wptrPostTask(task, "wms:JsExtensionWindowListener::LifeCycleCallBack", 0, @@ -211,7 +213,7 @@ void JsExtensionWindowListener::AfterForeground() LifeCycleCallBack(LifeCycleEventType::FOREGROUND, weakRef_, env_, eventHandler_); state_ = WindowState::STATE_SHOWN; } else { - WLOGFD("window is already shown"); + TLOGD(WmsLogTag::WMS_UIEXT, "window is already shown"); } } @@ -221,7 +223,7 @@ void JsExtensionWindowListener::AfterBackground() LifeCycleCallBack(LifeCycleEventType::BACKGROUND, weakRef_, env_, eventHandler_); state_ = WindowState::STATE_HIDDEN; } else { - WLOGFD("window is already hide"); + TLOGD(WmsLogTag::WMS_UIEXT, "window is already hide"); } } diff --git a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp index 06390de38..568c466b7 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp @@ -49,7 +49,7 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessWindowChangeRegister(sptr window, bool isRegister) { if (window == nullptr) { - WLOGFE("[NAPI]Window is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window is nullptr"); return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } sptr thisListener(listener); @@ -66,7 +66,7 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessAvoidAreaChangeRegister(spt sptr window, bool isRegister) { if (window == nullptr) { - WLOGFE("[NAPI]Window is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Window is nullptr"); return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } sptr thisListener(listener); @@ -83,7 +83,7 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessLifeCycleEventRegister(sptr sptr window, bool isRegister) { if (window == nullptr) { - WLOGFE("Window is nullptr"); + TLOGE(WmsLogTag::WMS_UIEXT, "Window is nullptr"); return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } sptr thisListener(listener); @@ -99,7 +99,7 @@ WmErrorCode JsExtensionWindowRegisterManager::ProcessLifeCycleEventRegister(sptr bool JsExtensionWindowRegisterManager::IsCallbackRegistered(napi_env env, std::string type, napi_value jsListenerObject) { if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) { - WLOGI("[NAPI]Method %{public}s has not been registered", type.c_str()); + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]Method %{public}s has not been registered", type.c_str()); return false; } @@ -107,7 +107,7 @@ bool JsExtensionWindowRegisterManager::IsCallbackRegistered(napi_env env, std::s bool isEquals = false; napi_strict_equals(env, jsListenerObject, iter->first->GetNapiValue(), &isEquals); if (isEquals) { - WLOGFE("[NAPI]Method %{public}s has already been registered", type.c_str()); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Method %{public}s has already been registered", type.c_str()); return true; } } @@ -122,7 +122,7 @@ WmErrorCode JsExtensionWindowRegisterManager::RegisterListener(sptr wind return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } if (listenerProcess_[caseType].count(type) == 0) { - WLOGFE("[NAPI]Type %{public}s is not supported", type.c_str()); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Type %{public}s is not supported", type.c_str()); return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } napi_ref result = nullptr; @@ -131,17 +131,17 @@ WmErrorCode JsExtensionWindowRegisterManager::RegisterListener(sptr wind sptr extensionWindowListener = new(std::nothrow) JsExtensionWindowListener(env, callbackRef); if (extensionWindowListener == nullptr) { - WLOGFE("[NAPI]New JsExtensionWindowListener failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]New JsExtensionWindowListener failed"); return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } extensionWindowListener->SetMainEventHandler(); WmErrorCode ret = (this->*listenerProcess_[caseType][type])(extensionWindowListener, window, true); if (ret != WmErrorCode::WM_OK) { - WLOGFE("[NAPI]Register type %{public}s failed", type.c_str()); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Register type %{public}s failed", type.c_str()); return ret; } jsCbMap_[type][callbackRef] = extensionWindowListener; - WLOGI("[NAPI]Register type %{public}s success! callback map size: %{public}zu", type.c_str(), + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]Register type %{public}s success! callback map size: %{public}zu", type.c_str(), jsCbMap_[type].size()); return WmErrorCode::WM_OK; } @@ -151,18 +151,18 @@ WmErrorCode JsExtensionWindowRegisterManager::UnregisterListener(sptr wi { std::lock_guard lock(mtx_); if (jsCbMap_.empty() || jsCbMap_.find(type) == jsCbMap_.end()) { - WLOGFE("[NAPI]Type %{public}s was not registered", type.c_str()); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Type %{public}s was not registered", type.c_str()); return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } if (listenerProcess_[caseType].count(type) == 0) { - WLOGFE("[NAPI]Type %{public}s is not supported", type.c_str()); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Type %{public}s is not supported", type.c_str()); return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } if (value == nullptr) { for (auto it = jsCbMap_[type].begin(); it != jsCbMap_[type].end();) { WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false); if (ret != WmErrorCode::WM_OK) { - WLOGFE("[NAPI]Unregister type %{public}s failed, no value", type.c_str()); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Unregister type %{public}s failed, no value", type.c_str()); return ret; } jsCbMap_[type].erase(it++); @@ -178,18 +178,19 @@ WmErrorCode JsExtensionWindowRegisterManager::UnregisterListener(sptr wi findFlag = true; WmErrorCode ret = (this->*listenerProcess_[caseType][type])(it->second, window, false); if (ret != WmErrorCode::WM_OK) { - WLOGFE("[NAPI]Unregister type %{public}s failed", type.c_str()); + TLOGE(WmsLogTag::WMS_UIEXT, "[NAPI]Unregister type %{public}s failed", type.c_str()); return ret; } jsCbMap_[type].erase(it); break; } if (!findFlag) { - WLOGFE("[NAPI]Unregister type %{public}s failed because not found callback!", type.c_str()); + TLOGE(WmsLogTag::WMS_UIEXT, + "[NAPI]Unregister type %{public}s failed because not found callback!", type.c_str()); return WmErrorCode::WM_ERROR_STATE_ABNORMALLY; } } - WLOGI("[NAPI]Unregister type %{public}s success! callback map size: %{public}zu", + TLOGI(WmsLogTag::WMS_UIEXT, "[NAPI]Unregister type %{public}s success! callback map size: %{public}zu", type.c_str(), jsCbMap_[type].size()); // erase type when there is no callback in one type if (jsCbMap_[type].empty()) { diff --git a/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp b/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp index d9f1cc191..e56ecdf78 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp @@ -31,7 +31,7 @@ napi_value GetRectAndConvertToJsValue(napi_env env, const Rect& rect) napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - WLOGFE("Failed to convert rect to jsObject"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert rect to jsObject"); return nullptr; } napi_set_named_property(env, objValue, "left", CreateJsValue(env, rect.posX_)); @@ -46,7 +46,7 @@ napi_value ConvertAvoidAreaToJsValue(napi_env env, const AvoidArea& avoidArea, A napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - WLOGFE("Failed to convert avoidArea to jsObject"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert avoidArea to jsObject"); return nullptr; } napi_set_named_property(env, objValue, "visible", @@ -60,18 +60,18 @@ napi_value ConvertAvoidAreaToJsValue(napi_env env, const AvoidArea& avoidArea, A napi_value CreateJsExtensionWindowPropertiesObject(napi_env env, sptr& window) { - WLOGI("CreateJsExtensionWindowPropertiesObject is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "CreateJsExtensionWindowPropertiesObject is called"); napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - WLOGFE("Failed to convert windowProperties to jsObject"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert windowProperties to jsObject"); return nullptr; } Rect windowRect = window->GetRect(); napi_value windowRectObj = GetRectAndConvertToJsValue(env, windowRect); if (windowRectObj == nullptr) { - WLOGFE("GetWindowRect Failed"); + TLOGE(WmsLogTag::WMS_UIEXT, "GetWindowRect Failed"); } napi_set_named_property(env, objValue, "uiExtensionHostWindowProxyRect", windowRectObj); return objValue; @@ -79,18 +79,18 @@ napi_value CreateJsExtensionWindowPropertiesObject(napi_env env, sptr& w napi_value CreateJsExtensionWindowProperties(napi_env env, sptr& window) { - WLOGI("CreateJsWindowPropertiesObject is called"); + TLOGI(WmsLogTag::WMS_UIEXT, "CreateJsWindowPropertiesObject is called"); napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - WLOGFE("Failed to convert windowProperties to jsObject"); + TLOGE(WmsLogTag::WMS_UIEXT, "Failed to convert windowProperties to jsObject"); return nullptr; } Rect windowRect = window->GetRect(); napi_value windowRectObj = GetRectAndConvertToJsValue(env, windowRect); if (windowRectObj == nullptr) { - WLOGFE("GetWindowRect failed!"); + TLOGE(WmsLogTag::WMS_UIEXT, "GetWindowRect failed!"); } napi_set_named_property(env, objValue, "windowRect", windowRectObj); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 0e1371f5d..985039d85 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6469,9 +6469,12 @@ void DisplayChangeListener::OnScreenshot(DisplayId displayId) void SceneSessionManager::OnScreenshot(DisplayId displayId) { auto task = [this, displayId]() { - auto sceneSession = GetSceneSession(focusedSessionId_); - if (sceneSession) { - sceneSession->NotifyScreenshot(); + for (const auto& iter: sceneSessionMap_) { + auto sceneSession = iter.second; + auto state = sceneSession->GetSessionState(); + if (state == SessionState::STATE_FOREGROUND || state == SessionState::STATE_ACTIVE) { + sceneSession->NotifyScreenshot(); + } } }; taskScheduler_->PostAsyncTask(task, "OnScreenshot:PID:" + std::to_string(displayId)); -- Gitee From 1cf948f660a0c6fe7c415462c83bcb4b0f98c89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5?= Date: Sun, 31 Mar 2024 03:10:35 +0000 Subject: [PATCH 307/385] =?UTF-8?q?=E5=8F=96=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- .../zidl/scene_session_manager_lite_proxy.cpp | 150 +++--------------- 1 file changed, 20 insertions(+), 130 deletions(-) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp index aefbc0a89..72cebf3d0 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp @@ -49,12 +49,7 @@ WSError SceneSessionManagerLiteProxy::SetSessionLabel(const sptr return WSError::WS_ERROR_IPC_FAILED; } - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_LABEL), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_LABEL), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -82,12 +77,7 @@ WSError SceneSessionManagerLiteProxy::SetSessionIcon(const sptr & return WSError::WS_ERROR_IPC_FAILED; } - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_ICON), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_ICON), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -111,12 +101,7 @@ WSError SceneSessionManagerLiteProxy::IsValidSessionIds( return WSError::WS_ERROR_IPC_FAILED; } - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_IS_VALID_SESSION_IDS), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_IS_VALID_SESSION_IDS), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -142,12 +127,7 @@ WSError SceneSessionManagerLiteProxy::PendingSessionToForeground(const sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast( + if (Remote()->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_PENDING_SESSION_TO_FOREGROUND), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -172,12 +152,7 @@ WSError SceneSessionManagerLiteProxy::PendingSessionToBackgroundForDelegator(con return WSError::WS_ERROR_IPC_FAILED; } - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast( + if (Remote()->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -204,13 +179,7 @@ WSError SceneSessionManagerLiteProxy::RegisterSessionListener(const sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast( + if (Remote()->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_SESSION_LISTENER), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -237,13 +206,7 @@ WSError SceneSessionManagerLiteProxy::UnRegisterSessionListener(const sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest( + if (Remote()->SendRequest( static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_SESSION_LISTENER), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -271,13 +234,7 @@ WSError SceneSessionManagerLiteProxy::GetSessionInfos(const std::string& deviceI WLOGFE("GetSessionInfos numMax write failed."); return WSError::WS_ERROR_IPC_FAILED; } - - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFOS), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFOS), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -309,13 +266,7 @@ WSError SceneSessionManagerLiteProxy::GetSessionInfo(const std::string& deviceId WLOGFE("GetSessionInfo write persistentId failed."); return WSError::WS_ERROR_IPC_FAILED; } - - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFO_BY_ID), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_MISSION_INFO_BY_ID), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -370,13 +321,7 @@ WSError SceneSessionManagerLiteProxy::TerminateSessionNew(const sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_TERMINATE_SESSION_NEW), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_TERMINATE_SESSION_NEW), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -395,12 +340,7 @@ WSError SceneSessionManagerLiteProxy::GetFocusSessionToken(sptr & return WSError::WS_ERROR_IPC_FAILED; } - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -436,12 +376,7 @@ WSError SceneSessionManagerLiteProxy::GetSessionSnapshot(const std::string& devi return WSError::WS_ERROR_INVALID_PARAM; } - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_SNAPSHOT), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_SESSION_SNAPSHOT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -473,13 +408,7 @@ WSError SceneSessionManagerLiteProxy::SetSessionContinueState(const sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast( + if (Remote()->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_CONTINUE_STATE), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -503,13 +432,7 @@ WSError SceneSessionManagerLiteProxy::LockSession(int32_t sessionId) WLOGFE("Write persistentId failed"); return WSError::WS_ERROR_INVALID_PARAM; } - - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_LOCK_SESSION), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_LOCK_SESSION), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -532,13 +455,7 @@ WSError SceneSessionManagerLiteProxy::UnlockSession(int32_t sessionId) WLOGFE("Write persistentId failed"); return WSError::WS_ERROR_INVALID_PARAM; } - - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UNLOCK_SESSION), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_UNLOCK_SESSION), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -565,13 +482,7 @@ WSError SceneSessionManagerLiteProxy::MoveSessionsToForeground(const std::vector WLOGFE("Write topSessionId failed"); return WSError::WS_ERROR_INVALID_PARAM; } - - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast( + if (Remote()->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -599,13 +510,7 @@ WSError SceneSessionManagerLiteProxy::MoveSessionsToBackground(const std::vector WLOGFE("Write result failed"); return WSError::WS_ERROR_INVALID_PARAM; } - - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast( + if (Remote()->SendRequest(static_cast( SceneSessionManagerLiteMessage::TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); @@ -631,12 +536,7 @@ WSError SceneSessionManagerLiteProxy::ClearSession(int32_t persistentId) return WSError::WS_ERROR_INVALID_PARAM; } - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_SESSION), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_SESSION), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -655,12 +555,7 @@ WSError SceneSessionManagerLiteProxy::ClearAllSessions() return WSError::WS_ERROR_INVALID_PARAM; } - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_ALL_SESSIONS), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_CLEAR_ALL_SESSIONS), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; @@ -679,12 +574,7 @@ void SceneSessionManagerLiteProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo return; } - sptr remote = Remote(); - if (remote == nullptr) { - WLOGFE("remote is nullptr"); - return WMError::WM_ERROR_NULLPTR; - } - if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_INFO), + if (Remote()->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_INFO), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return; -- Gitee From 614b2db858db1e91f1e476ebd636382ed5e28438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 09:00:40 +0800 Subject: [PATCH 308/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- window_scene/session_manager/src/scene_session_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 29cc2190b..a609c6e00 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6036,14 +6036,14 @@ WSError SceneSessionManager::GetFocusSessionToken(sptr &token) WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName &element) { - auto task = [this, &token]() { + auto task = [this, &element]() { WLOGFD("run GetFocusSessionElement with focusedSessionId: %{public}d", focusedSessionId_); auto sceneSession = GetSceneSession(focusedSessionId_); if (sceneSession) { auto sessionInfo = sceneSession->GetSessionInfo(); AAFwk::Want want; want.SetElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); - element = want.getElement(); + element = want.GetElement(); return WSError::WS_OK; } return WSError::WS_ERROR_INVALID_SESSION; -- Gitee From 74a6880600eba7fb3e8dd3b8a97d31174253472f Mon Sep 17 00:00:00 2001 From: LiPeng Date: Thu, 28 Mar 2024 14:14:56 +0800 Subject: [PATCH 309/385] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=A0=8F=E6=8C=89=E9=92=AE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LiPeng --- interfaces/innerkits/wm/window.h | 13 ++ .../window_runtime/window_napi/js_window.cpp | 65 ++++++++ .../window_runtime/window_napi/js_window.h | 2 + previewer/include/window.h | 4 + wm/include/window_session_impl.h | 10 ++ wm/src/window_session_impl.cpp | 44 +++++- wm/test/unittest/BUILD.gn | 1 + .../window_scene_session_impl_test.cpp | 143 ++++++++++++++++++ 8 files changed, 280 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 2e5f0871f..382dd7c37 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -1684,6 +1684,19 @@ public: */ virtual WMError SetDecorVisible(bool isVisible) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + /** + * @brief Set whether to display the maximize, minimize, split buttons of main window. + * + * @param isMaximizeVisible Display maximize button if true, or hide maximize button if false. + * @param isMinimizeVisible Display minimize button if true, or hide minimize button if false. + * @param isSplitVisible Display split button if true, or hide split button if false. + * @return Errorcode of window. + */ + virtual WMError SetTitleButtonVisible(bool isMaximizeVisible, bool isMinimizeVisible, bool isSplitVisible) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + /** * @brief Set decor height of window. * diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 32189217d..e61ac4747 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -791,6 +791,13 @@ napi_value JsWindow::GetTitleButtonRect(napi_env env, napi_callback_info info) return (me != nullptr) ? me->OnGetTitleButtonRect(env, info) : nullptr; } +napi_value JsWindow::SetTitleButtonVisible(napi_env env, napi_callback_info info) +{ + TLOGI(WmsLogTag::WMS_LAYOUT, "[NAPI]SetTitleButtonVisible"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetTitleButtonVisible(env, info) : nullptr; +} + napi_value JsWindow::SetWindowMask(napi_env env, napi_callback_info info) { WLOGI("[NAPI]SetWindowMask"); @@ -5451,6 +5458,63 @@ napi_value JsWindow::OnGetTitleButtonRect(napi_env env, napi_callback_info info) return TitleButtonAreaObj; } +static inline bool GetNativeBool(napi_env env, napi_value nativeVal, bool* flag) +{ + if (nativeVal == nullptr) { + return false; + } + napi_get_value_bool(env, nativeVal, flag); + return true; +} + +napi_value JsWindow::OnSetTitleButtonVisible(napi_env env, napi_callback_info info) +{ + if (!Permission::IsSystemCalling()) { + TLOGE(WmsLogTag::WMS_LAYOUT, "set title button visible permission denied!"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP); + } + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc != 3) { // 3: params num + WLOGFE("Argc is invalid: %{public}zu", argc); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + constexpr size_t IS_MAX_ARGC = 0; + constexpr size_t IS_MIN_ARGC = 1; + constexpr size_t IS_SPLIT_ARGC = 2; + bool isMaximizeVisible = true; + if (!GetNativeBool(env, argv[IS_MAX_ARGC], &isMaximizeVisible)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isMaximizeVisible"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + bool isMinimizeVisible = true; + if (!GetNativeBool(env, argv[IS_MIN_ARGC], &isMinimizeVisible)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isMinimizeVisible"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + bool isSplitVisible = true; + if (!GetNativeBool(env, argv[IS_SPLIT_ARGC], &isSplitVisible)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isSplitVisible"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + if (windowToken_ == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken_ is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + WMError errCode = windowToken_->SetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible, isSplitVisible); + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(errCode); + if (ret != WmErrorCode::WM_OK) { + TLOGE(WmsLogTag::WMS_LAYOUT, "set title button visible failed!"); + return NapiThrowError(env, ret); + } + TLOGI(WmsLogTag::WMS_LAYOUT, + "Window [%{public}u, %{public}s] set title button visible [%{public}d, %{public}d, %{public}d]", + windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), isMaximizeVisible, isMinimizeVisible, + isSplitVisible); + return NapiGetUndefined(env); +} + napi_value JsWindow::OnSetWindowMask(napi_env env, napi_callback_info info) { size_t argc = 4; @@ -5603,6 +5667,7 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setWindowDecorHeight", moduleName, JsWindow::SetWindowDecorHeight); BindNativeFunction(env, object, "getWindowDecorHeight", moduleName, JsWindow::GetWindowDecorHeight); BindNativeFunction(env, object, "getTitleButtonRect", moduleName, JsWindow::GetTitleButtonRect); + BindNativeFunction(env, object, "setTitleButtonVisible", moduleName, JsWindow::SetTitleButtonVisible); BindNativeFunction(env, object, "setWindowMask", moduleName, JsWindow::SetWindowMask); } } // namespace Rosen diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 40ca610db..26a36003e 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -148,6 +148,7 @@ public: static napi_value SetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetWindowDecorHeight(napi_env env, napi_callback_info info); static napi_value GetTitleButtonRect(napi_env env, napi_callback_info info); + static napi_value SetTitleButtonVisible(napi_env env, napi_callback_info info); static napi_value SetWindowMask(napi_env env, napi_callback_info info); private: @@ -210,6 +211,7 @@ private: napi_value OnSetWindowDecorHeight(napi_env env, napi_callback_info info); napi_value OnGetWindowDecorHeight(napi_env env, napi_callback_info info); napi_value OnGetTitleButtonRect(napi_env env, napi_callback_info info); + napi_value OnSetTitleButtonVisible(napi_env env, napi_callback_info info); // colorspace, gamut napi_value OnIsSupportWideGamut(napi_env env, napi_callback_info info); diff --git a/previewer/include/window.h b/previewer/include/window.h index 19977cc89..18e04def0 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -285,6 +285,10 @@ public: virtual WMError SetSingleFrameComposerEnabled(bool enable) = 0; virtual WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) = 0; virtual WMError SetDecorVisible(bool isVisible) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + virtual WMError SetTitleButtonVisible(bool isMaximizeVisible, bool isMinimizeVisible, bool isSplitVisible) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } virtual WMError SetDecorHeight(int32_t decorHeight) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual WMError GetDecorHeight(int32_t& height) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } virtual WMError GetTitleButtonArea(TitleButtonRect& titleButtonRect) diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 2a69dad9e..2bf0ea5c8 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -43,6 +43,13 @@ namespace { template using EnableIfSame = typename std::enable_if, Ret>::type; } + +struct WindowTitleVisibleFlags { + bool isMaximizeVisible = true; + bool isMinimizeVisible = true; + bool isSplitVisible = true; +}; + class WindowSessionImpl : public Window, public virtual SessionStageStub { public: explicit WindowSessionImpl(const sptr& option); @@ -145,6 +152,7 @@ public: WMError UnregisterScreenshotListener(const sptr& listener) override; void SetAceAbilityHandler(const sptr& handler) override; void SetInputEventConsumer(const std::shared_ptr& inputEventConsumer) override; + WMError SetTitleButtonVisible(bool isMaximizeVisible, bool isMinimizeVisible, bool isSplitVisible) override; WMError SetBackgroundColor(const std::string& color) override; virtual Orientation GetRequestedOrientation() override; @@ -322,6 +330,7 @@ private: const std::shared_ptr& rsTransaction = nullptr); void NotifyRotationAnimationEnd(); void SubmitNoInteractionMonitorTask(int32_t eventId, const IWindowNoInteractionListenerSptr& listener); + void GetTitleButtonVisible(bool isPC, bool &hideMaximizeButton, bool &hideMinimizeButton, bool &hideSplitButton); static std::recursive_mutex lifeCycleListenerMutex_; static std::recursive_mutex windowChangeListenerMutex_; @@ -364,6 +373,7 @@ private: bool isMainHandlerAvailable_ = true; std::string subWindowTitle_ = { "" }; + WindowTitleVisibleFlags windowTitleVisibleFlags_; }; } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index ad6572055..840b4801e 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -545,6 +545,26 @@ void WindowSessionImpl::NotifyRotationAnimationEnd() uiContent_->NotifyRotationAnimationEnd(); } +void WindowSessionImpl::GetTitleButtonVisible(bool isPC, bool &hideMaximizeButton, bool &hideMinimizeButton, + bool &hideSplitButton) +{ + if (!isPC) { + return; + } + if (hideMaximizeButton > !windowTitleVisibleFlags_.isMaximizeVisible) { + TLOGW(WmsLogTag::WMS_LAYOUT, "isMaximizeVisible param INVALID"); + } + hideMaximizeButton = hideMaximizeButton || (!windowTitleVisibleFlags_.isMaximizeVisible); + if (hideMinimizeButton > !windowTitleVisibleFlags_.isMinimizeVisible) { + TLOGW(WmsLogTag::WMS_LAYOUT, "isMinimizeVisible param INVALID"); + } + hideMinimizeButton = hideMinimizeButton || (!windowTitleVisibleFlags_.isMinimizeVisible); + if (hideSplitButton > !windowTitleVisibleFlags_.isSplitVisible) { + TLOGW(WmsLogTag::WMS_LAYOUT, "isSplitVisible param INVALID"); + } + hideSplitButton = hideSplitButton || (!windowTitleVisibleFlags_.isSplitVisible); +} + void WindowSessionImpl::UpdateDensity() { auto preRect = GetRect(); @@ -688,8 +708,11 @@ void WindowSessionImpl::UpdateTitleButtonVisibility() (GetMode() == WindowMode::WINDOW_MODE_FLOATING || WindowHelper::IsSplitWindowMode(GetMode()))) || (!(modeSupportInfo & WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING) && GetMode() == WindowMode::WINDOW_MODE_FULLSCREEN); - WLOGFI("[hideSplit, hideMaximize]: [%{public}d, %{public}d]", hideSplitButton, hideMaximizeButton); - uiContent_->HideWindowTitleButton(hideSplitButton, hideMaximizeButton, false); + bool hideMinimizeButton = false; + GetTitleButtonVisible(isPC, hideMaximizeButton, hideMinimizeButton, hideSplitButton); + TLOGI(WmsLogTag::WMS_LAYOUT, "[hideSplit, hideMaximize, hideMinimizeButton]: [%{public}d, %{public}d, %{public}d]", + hideSplitButton, hideMaximizeButton, hideMinimizeButton); + uiContent_->HideWindowTitleButton(hideSplitButton, hideMaximizeButton, hideMinimizeButton); } WMError WindowSessionImpl::NapiSetUIContent(const std::string& contentInfo, napi_env env, napi_value storage, @@ -1559,6 +1582,23 @@ void WindowSessionImpl::SetInputEventConsumer(const std::shared_ptr +#include #include "ability_context_impl.h" #include "display_info.h" #include "display_manager.h" @@ -2155,6 +2156,148 @@ HWTEST_F(WindowSceneSessionImplTest, Maximize03, Function | SmallTest | Level2) layoutOption.decor = ShowType::SHOW; ASSERT_NE(WMError::WM_ERROR_INVALID_PARAM, window->Maximize(layoutOption)); } + +/** + * @tc.name: GetTitleButtonVisible01 + * @tc.desc: GetTitleButtonVisible + * @tc.type: FUNC +*/ +HWTEST_F(WindowSceneSessionImplTest, GetTitleButtonVisible01, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("GetTitleButtonVisible01"); + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + uint32_t modeSupportInfo = 1 | (1 << 1) | (1 << 2); + window->property_->SetModeSupportInfo(modeSupportInfo); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + // show Maximize, Minimize, Split buttons. + window->windowTitleVisibleFlags_ = { false, false, false }; + bool hideMaximizeButton = false; + bool hideMinimizeButton = false; + bool hideSplitButton = false; + window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton); + ASSERT_EQ(hideMaximizeButton, true); + ASSERT_EQ(hideMinimizeButton, true); + ASSERT_EQ(hideSplitButton, true); +} + +/** + * @tc.name: GetTitleButtonVisible02 + * @tc.desc: GetTitleButtonVisible + * @tc.type: FUNC +*/ +HWTEST_F(WindowSceneSessionImplTest, GetTitleButtonVisible02, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("GetTitleButtonVisible02"); + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + // only not support WINDOW_MODE_SUPPORT_SPLIT + uint32_t modeSupportInfo = 1 | (1 << 1); + window->property_->SetModeSupportInfo(modeSupportInfo); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + // show Maximize, Minimize, Split buttons. + window->windowTitleVisibleFlags_ = { true, true, true }; + bool hideMaximizeButton = false; + bool hideMinimizeButton = false; + bool hideSplitButton = false; + window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton); + ASSERT_EQ(hideMaximizeButton, false); + ASSERT_EQ(hideMinimizeButton, false); + ASSERT_EQ(hideSplitButton, true); +} + +/** + * @tc.name: GetTitleButtonVisible03 + * @tc.desc: GetTitleButtonVisible + * @tc.type: FUNC +*/ +HWTEST_F(WindowSceneSessionImplTest, GetTitleButtonVisible03, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("GetTitleButtonVisible03"); + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + // only not support WINDOW_MODE_SUPPORT_SPLIT + uint32_t modeSupportInfo = 1 | (1 << 1) | (1 << 2); + window->property_->SetModeSupportInfo(modeSupportInfo); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + // show Maximize, Minimize, Split buttons. + window->windowTitleVisibleFlags_ = { false, false, false }; + bool hideMaximizeButton = false; + bool hideMinimizeButton = false; + bool hideSplitButton = false; + window->GetTitleButtonVisible(false, hideMaximizeButton, hideMinimizeButton, hideSplitButton); + ASSERT_EQ(hideMaximizeButton, false); + ASSERT_EQ(hideMinimizeButton, false); + ASSERT_EQ(hideSplitButton, false); +} + +/** + * @tc.name: SetTitleButtonVisible01 + * @tc.desc: SetTitleButtonVisible + * @tc.type: FUNC +*/ +HWTEST_F(WindowSceneSessionImplTest, SetTitleButtonVisible01, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetTitleButtonVisible01 start"; + sptr option = new WindowOption(); + ASSERT_NE(option, nullptr); + option->SetWindowName("SetTitleButtonVisible"); + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(window, nullptr); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + WMError res = window->SetTitleButtonVisible(false, false, false); + ASSERT_EQ(res, WMError::WM_ERROR_INVALID_CALLING); + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetTitleButtonVisible01 end"; +} + +/** + * @tc.name: SetTitleButtonVisible02 + * @tc.desc: SetTitleButtonVisible + * @tc.type: FUNC +*/ +HWTEST_F(WindowSceneSessionImplTest, SetTitleButtonVisible02, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetTitleButtonVisible02 start"; + sptr option = new WindowOption(); + ASSERT_NE(option, nullptr); + option->SetWindowName("SetTitleButtonVisible"); + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(window, nullptr); + window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + WMError res = window->SetTitleButtonVisible(false, false, false); + ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetTitleButtonVisible02 end"; +} + +/** + * @tc.name: SetTitleButtonVisible03 + * @tc.desc: SetTitleButtonVisible + * @tc.type: FUNC +*/ +HWTEST_F(WindowSceneSessionImplTest, SetTitleButtonVisible03, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetTitleButtonVisible03 start"; + sptr option = new WindowOption(); + ASSERT_NE(option, nullptr); + option->SetWindowName("SetTitleButtonVisible"); + sptr window = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(window, nullptr); + window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + window->uiContent_ = std::make_unique(); + WMError res = window->SetTitleButtonVisible(false, false, false); + std::string deviceType = system::GetParameter("const.product.devicetype", "unknown"); + if (deviceType == "phone") { + ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); + } + if (deviceType == "2in1") { + ASSERT_EQ(res, WMError::WM_OK); + } + GTEST_LOG_(INFO) << "WindowSessionImplTest: SetTitleButtonVisible03 end"; +} } } // namespace Rosen } // namespace OHOS -- Gitee From 4ffac4a38e93744dca10faa26cae1592bd55135a Mon Sep 17 00:00:00 2001 From: wanganjie Date: Mon, 1 Apr 2024 09:21:37 +0800 Subject: [PATCH 310/385] =?UTF-8?q?=E5=87=8F=E5=B0=91=E5=9C=88=E5=A4=8D?= =?UTF-8?q?=E6=9D=82=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wanganjie --- 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 ac05a219f..dd20ad643 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1737,9 +1737,10 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_FLOAT && !secureSessionSet_.empty()) || + bool shouldBlock = (property->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT && !secureSessionSet_.empty()) || (SessionHelper::IsSubWindow(property->GetWindowType()) && - secureSessionSet_.find(property->GetParentPersistentId()) != secureSessionSet_.end())) { + secureSessionSet_.find(property->GetParentPersistentId()) != secureSessionSet_.end()); + if (shouldBlock) { TLOGE(WmsLogTag::WMS_UIEXT, "create non-secure window permission denied!"); return WSError::WS_ERROR_INVALID_OPERATION; } -- Gitee From 276dc4f522827f747afc25bfed003920ad938799 Mon Sep 17 00:00:00 2001 From: liubo Date: Mon, 1 Apr 2024 09:19:13 +0800 Subject: [PATCH 311/385] =?UTF-8?q?Description:=20=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E6=95=B4=E6=94=B9=20IssueNo:https://gitee.co?= =?UTF-8?q?m/openharmony/window=5Fwindow=5Fmanager/issues/I9CWFO=20Feature?= =?UTF-8?q?=20or=20Bugfix:=20Bugfix=20Binary=20Source:No=20Signed-off-by:?= =?UTF-8?q?=20liubo419=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dmserver/src/abstract_display_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index f9cb2f849..a0e9edd27 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -309,7 +309,7 @@ void AbstractDisplayController::ProcessDisplayCompression(sptr a WLOGFI("Enter"); auto absDisplay = GetAbstractDisplayByAbsScreen(absScreen); DisplayId defaultDisplayId = GetDefaultDisplayId(); - if (absDisplay->GetId() != defaultDisplayId) { + if (absDisplay == nullptr || absDisplay->GetId() != defaultDisplayId) { return; } uint32_t sizeInVp = DisplayCutoutController::GetWaterfallAreaCompressionSizeWhenHorizontal(); -- Gitee From d1df70cb098bf8dd312acc1415890b6d1f8d768b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 10:37:08 +0800 Subject: [PATCH 312/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- .../include/scene_session_manager.h | 2 +- .../zidl/scene_session_manager_interface.h | 2 ++ .../zidl/scene_session_manager_proxy.h | 1 + .../include/zidl/scene_session_manager_stub.h | 2 ++ .../src/scene_session_manager.cpp | 2 +- .../src/zidl/scene_session_manager_proxy.cpp | 23 +++++++++++++++++++ .../src/zidl/scene_session_manager_stub.cpp | 12 ++++++++++ 7 files changed, 42 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 32a37fed3..5a69680c2 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -192,7 +192,7 @@ public: WSError PendingSessionToForeground(const sptr &token) override; WSError PendingSessionToBackgroundForDelegator(const sptr &token) override; WSError GetFocusSessionToken(sptr &token) override; - WSError GetFocusSessionElement(AppExecFwk::ElementName &element); + WSError GetFocusSessionElement(sptr &element) override; WSError RegisterSessionListener(const sptr& listener) override; WSError UnRegisterSessionListener(const sptr& listener) override; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h index 6dfda7020..ec9fc73ef 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h @@ -66,6 +66,7 @@ public: TRANS_ID_PENDING_SESSION_TO_FOREGROUND, TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR, TRANS_ID_GET_FOCUS_SESSION_TOKEN, + TRANS_ID_GET_FOCUS_SESSION_ELEMENT, TRANS_ID_CHECK_WINDOW_ID, TRANS_ID_REGISTER_SESSION_LISTENER, TRANS_ID_UNREGISTER_SESSION_LISTENER, @@ -110,6 +111,7 @@ public: virtual WSError PendingSessionToForeground(const sptr &token) = 0; virtual WSError PendingSessionToBackgroundForDelegator(const sptr &token) = 0; virtual WSError GetFocusSessionToken(sptr &token) = 0; + virtual WSError GetFocusSessionElement(sptr &element) = 0; virtual WSError RegisterSessionListener(const sptr& listener) = 0; virtual WSError UnRegisterSessionListener(const sptr& listener) = 0; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h index 98ec59107..ac9c1188b 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h @@ -60,6 +60,7 @@ public: WSError PendingSessionToForeground(const sptr &token) override; WSError PendingSessionToBackgroundForDelegator(const sptr &token) override; WSError GetFocusSessionToken(sptr &token) override; + WSError GetFocusSessionElement(sptr &element) override; WMError CheckWindowId(int32_t windowId, int32_t &pid) override; WSError RegisterSessionListener(const sptr& listener) override; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_stub.h b/window_scene/session_manager/include/zidl/scene_session_manager_stub.h index b0bda9491..d5e43bf84 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_stub.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_stub.h @@ -53,6 +53,8 @@ private: int HandlePendingSessionToForeground(MessageParcel &data, MessageParcel &reply); int HandlePendingSessionToBackgroundForDelegator(MessageParcel &data, MessageParcel &reply); int HandleGetFocusSessionToken(MessageParcel &data, MessageParcel &reply); + int HandleGetFocusSessionElement(MessageParcel &data, MessageParcel &reply); + int HandleSetGestureNavigationEnabled(MessageParcel &data, MessageParcel &reply); int HandleSetSessionGravity(MessageParcel &data, MessageParcel &reply); int HandleCheckWindowId(MessageParcel &data, MessageParcel &reply); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index a609c6e00..0d05293bd 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6034,7 +6034,7 @@ WSError SceneSessionManager::GetFocusSessionToken(sptr &token) return taskScheduler_->PostSyncTask(task, "GetFocusSessionToken"); } -WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName &element) +WSError SceneSessionManager::GetFocusSessionElement(sptr &element) { auto task = [this, &element]() { WLOGFD("run GetFocusSessionElement with focusedSessionId: %{public}d", focusedSessionId_); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index 3cf269cbf..e099f60c9 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -995,6 +995,29 @@ WSError SceneSessionManagerProxy::GetFocusSessionToken(sptr &toke return static_cast(reply.ReadInt32()); } +WSError SceneSessionManagerProxy::GetFocusSessionElement(sptr &element) +{ + WLOGFD("run SceneSessionManagerProxy::GetFocusSessionElement"); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("Write interfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + + if (Remote()->SendRequest(static_cast(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_ELEMENT), + data, reply, option) != ERR_NONE) { + WLOGFE("SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + element = reply.ReadRemoteObject(); + if (element == nullptr) { + WLOGFD("get element null."); + } + return static_cast(reply.ReadInt32()); +} + WMError SceneSessionManagerProxy::CheckWindowId(int32_t windowId, int32_t &pid) { MessageParcel data; diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index bcd564580..5584bc500 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -65,6 +65,8 @@ const std::map SceneSessionManagerStub::s &SceneSessionManagerStub::HandlePendingSessionToBackgroundForDelegator), std::make_pair(static_cast(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN), &SceneSessionManagerStub::HandleGetFocusSessionToken), + std::make_pair(static_cast(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_ELEMENT), + &SceneSessionManagerStub::HandleGetFocusSessionElement), std::make_pair(static_cast(SceneSessionManagerMessage::TRANS_ID_CHECK_WINDOW_ID), &SceneSessionManagerStub::HandleCheckWindowId), std::make_pair(static_cast(SceneSessionManagerMessage::TRANS_ID_SET_GESTURE_NAVIGATION_ENABLED), @@ -519,6 +521,16 @@ int SceneSessionManagerStub::HandleGetFocusSessionToken(MessageParcel &data, Mes return ERR_NONE; } +int SceneSessionManagerStub::HandleGetFocusSessionElement(MessageParcel &data, MessageParcel &reply) +{ + WLOGFD("run HandleGetFocusSessionElement!"); + sptr element = nullptr; + const WSError& errCode = GetFocusSessionElement(element); + reply.WriteRemoteObject(element); + reply.WriteInt32(static_cast(errCode)); + return ERR_NONE; +} + int SceneSessionManagerStub::HandleCheckWindowId(MessageParcel &data, MessageParcel &reply) { WLOGFI("run HandleCheckWindowId!"); -- Gitee From a727c3b68ecceeb118f14428794f4c3735230776 Mon Sep 17 00:00:00 2001 From: lilili Date: Mon, 1 Apr 2024 10:48:27 +0800 Subject: [PATCH 313/385] =?UTF-8?q?=E3=80=90UT=E3=80=91=E3=80=90=E7=89=B9?= =?UTF-8?q?=E6=80=A7=E9=9C=80=E6=B1=82=E3=80=91=E5=8F=A0=E5=8A=A0=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E8=AF=86=E5=88=AB=EF=BC=9A=E4=B8=BB=E5=B1=8F=E7=9A=84?= =?UTF-8?q?=E5=88=86=E5=B1=8F/=E6=82=AC=E6=B5=AE=E7=AA=97=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lilili --- .../src/scene_session_manager.cpp | 2 + .../session_manager_agent_controller_test.cpp | 15 ++++ wm/test/unittest/BUILD.gn | 1 + .../window_manager_agent_stub_test.cpp | 57 +++++++++++++ wm/test/unittest/window_manager_test.cpp | 83 +++++++++++++++++++ 5 files changed, 158 insertions(+) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index cc54dc183..d330836b5 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -4304,6 +4304,8 @@ void SceneSessionManager::NotifyRSSWindowModeTypeUpdate(bool inSplit, bool inFlo return; } lastWindowModeType_ = type; + TLOGI(WmsLogTag::WMS_MAIN, "Notify RSS Window Mode Type Update, type : %{public}d", + static_cast(type)); SessionManagerAgentController::GetInstance().UpdateWindowModeTypeInfo(type); } diff --git a/window_scene/test/unittest/session_manager_agent_controller_test.cpp b/window_scene/test/unittest/session_manager_agent_controller_test.cpp index 6bd20a15e..683c2d230 100644 --- a/window_scene/test/unittest/session_manager_agent_controller_test.cpp +++ b/window_scene/test/unittest/session_manager_agent_controller_test.cpp @@ -97,6 +97,21 @@ HWTEST_F(SessionManagerAgentControllerTest, UpdateFocusChangeInfo, Function | Sm windowManagerAgent, type)); } +/** + * @tc.name: UpdateWindowModeTypeInfo + * @tc.desc: UpdateWindowModeTypeInfo Test + * @tc.type: FUNC + */ +HWTEST_F(SessionManagerAgentControllerTest, UpdateWindowModeTypeInfo, Function | SmallTest | Level3) +{ + SessionManagerAgentController::GetInstance().UpdateWindowModeTypeInfo(WindowModeType::WINDOW_MODE_SPLIT); + + sptr windowManagerAgent = new WindowManagerAgent(); + WindowManagerAgentType type = WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE; + ASSERT_EQ(WMError::WM_OK, SessionManagerAgentController::GetInstance().RegisterWindowManagerAgent( + windowManagerAgent, type)); +} + /** * @tc.name: NotifyAccessibilityWindowInfo * @tc.desc: NotifyAccessibilityWindowInfo Test diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index 9db705038..c2d551456 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -450,6 +450,7 @@ ohos_static_library("wm_unittest_common") { "${window_base_path}/utils:libwmutil", "${window_base_path}/window_scene/common:window_scene_common", "${window_base_path}/window_scene/session:scene_session", + "${window_base_path}/window_scene/session_manager:scene_session_manager", "${window_base_path}/wm:libwm", "${window_base_path}/wmserver:libwms", "//commonlibrary/c_utils/base:utils", diff --git a/wm/test/unittest/window_manager_agent_stub_test.cpp b/wm/test/unittest/window_manager_agent_stub_test.cpp index ea08d9a09..02f8ee612 100644 --- a/wm/test/unittest/window_manager_agent_stub_test.cpp +++ b/wm/test/unittest/window_manager_agent_stub_test.cpp @@ -232,6 +232,63 @@ HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest10, Function | SmallTest | L int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + +/** + * @tc.name: OnRemoteRequest11 + * @tc.desc: test InterfaceToken check failed + * @tc.type: FUNC + */ +HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest11, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(u"error.GetDescriptor"); + + uint32_t code = static_cast( + IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, -1); +} + +/** + * @tc.name: OnRemoteRequest12 + * @tc.desc: test TRANS_ID_UPDATE_WINDOW_MODE_TYPE + * @tc.type: FUNC + */ +HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest12, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor()); + data.WriteUint8(static_cast(WindowModeType::WINDOW_MODE_FLOATING)); + uint32_t code = static_cast( + IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest13 + * @tc.desc: test TRANS_ID_UPDATE_WINDOW_MODE_TYPE success + * @tc.type: FUNC + */ +HWTEST_F(WindowManagerAgentStubTest, OnRemoteRequest13, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(WindowManagerAgentStub::GetDescriptor()); + + uint32_t code = static_cast( + IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} } } } diff --git a/wm/test/unittest/window_manager_test.cpp b/wm/test/unittest/window_manager_test.cpp index 5989fa6b3..07399480c 100644 --- a/wm/test/unittest/window_manager_test.cpp +++ b/wm/test/unittest/window_manager_test.cpp @@ -17,6 +17,7 @@ #include "window_manager.h" #include "mock_window_adapter.h" #include "singleton_mocker.h" +#include "scene_session_manager.h" #include "window_manager.cpp" @@ -58,6 +59,14 @@ public: }; }; +class TestWindowModeChangedListener : public IWindowModeChangedListener { +public: + void OnWindowModeUpdate(WindowModeType mode) override + { + WLOGI("TestWindowModeChangedListener"); + }; +}; + class TestWaterMarkFlagChangeListener : public IWaterMarkFlagChangedListener { public: void OnWaterMarkFlagUpdate(bool showWaterMark) override @@ -365,6 +374,80 @@ HWTEST_F(WindowManagerTest, UnregisterWindowUpdateListener01, Function | SmallTe windowManager.pImpl_->windowUpdateListeners_ = oldListeners; } +/** + * @tc.name: RegisterWindowModeChangedListener01 + * @tc.desc: check RegisterWindowModeChangedListener + * @tc.type: FUNC + */ +HWTEST_F(WindowManagerTest, RegisterWindowModeChangedListener01, Function | SmallTest | Level2) +{ + auto &windowManager = WindowManager::GetInstance(); + auto oldWindowManagerAgent = windowManager.pImpl_->windowModeListenerAgent_; + auto oldListeners = windowManager.pImpl_->windowModeListeners_; + windowManager.pImpl_->windowModeListenerAgent_ = nullptr; + windowManager.pImpl_->windowModeListeners_.clear(); + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.RegisterWindowModeChangedListener(nullptr)); + + sptr listener = new TestWindowModeChangedListener(); + std::unique_ptr m = std::make_unique(); + EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_NULLPTR)); + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.RegisterWindowModeChangedListener(listener)); + ASSERT_EQ(nullptr, windowManager.pImpl_->windowModeListenerAgent_); + + EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); + ASSERT_EQ(WMError::WM_OK, windowManager.RegisterWindowModeChangedListener(listener)); + ASSERT_EQ(1, windowManager.pImpl_->windowModeListeners_.size()); + + // to check that the same listner can not be registered twice + EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); + ASSERT_EQ(WMError::WM_OK, windowManager.RegisterWindowModeChangedListener(listener)); + ASSERT_EQ(1, windowManager.pImpl_->windowModeListeners_.size()); + + windowManager.pImpl_->windowModeListenerAgent_ = oldWindowManagerAgent; + windowManager.pImpl_->windowModeListeners_ = oldListeners; +} + +/** + * @tc.name: UnregisterWindowModeChangedListener01 + * @tc.desc: check UnregisterWindowModeChangedListener + * @tc.type: FUNC + */ +HWTEST_F(WindowManagerTest, UnregisterWindowModeChangedListener01, Function | SmallTest | Level2) +{ + auto &windowManager = WindowManager::GetInstance(); + auto oldWindowManagerAgent = windowManager.pImpl_->windowModeListenerAgent_; + auto oldListeners = windowManager.pImpl_->windowModeListeners_; + windowManager.pImpl_->windowModeListenerAgent_ = new WindowManagerAgent(); + windowManager.pImpl_->windowModeListeners_.clear(); + + // check nullpter + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowManager.UnregisterWindowModeChangedListener(nullptr)); + + sptr listener1 = new TestWindowModeChangedListener(); + sptr listener2 = new TestWindowModeChangedListener(); + ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterWindowModeChangedListener(listener1)); + + std::unique_ptr m = std::make_unique(); + EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); + windowManager.RegisterWindowModeChangedListener(listener1); + EXPECT_CALL(m->Mock(), RegisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); + windowManager.RegisterWindowModeChangedListener(listener2); + ASSERT_EQ(2, windowManager.pImpl_->windowModeListeners_.size()); + + ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterWindowModeChangedListener(listener1)); + EXPECT_CALL(m->Mock(), UnregisterWindowManagerAgent(_, _)).Times(1).WillOnce(Return(WMError::WM_OK)); + ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterWindowModeChangedListener(listener2)); + ASSERT_EQ(0, windowManager.pImpl_->windowModeListeners_.size()); + ASSERT_EQ(nullptr, windowManager.pImpl_->windowModeListenerAgent_); + + windowManager.pImpl_->windowModeListeners_.emplace_back(listener1); + ASSERT_EQ(WMError::WM_OK, windowManager.UnregisterWindowModeChangedListener(listener1)); + ASSERT_EQ(0, windowManager.pImpl_->windowModeListeners_.size()); + + windowManager.pImpl_->windowModeListenerAgent_ = oldWindowManagerAgent; + windowManager.pImpl_->windowModeListeners_ = oldListeners; +} + /** * @tc.name: RegisterSystemBarChangedListener01 * @tc.desc: check RegisterSystemBarChangedListener -- Gitee From 77413221db6b00eaf00ef3cff831c2c0817e507f Mon Sep 17 00:00:00 2001 From: LiPeng Date: Sat, 30 Mar 2024 01:50:39 +0000 Subject: [PATCH 314/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=EF=BC=8C=E5=A4=8D=E7=94=A8=E7=8E=B0=E6=9C=89?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LiPeng --- .../window_runtime/window_napi/js_window.cpp | 21 ++++++------------- .../window_scene_session_impl_test.cpp | 14 ++++++------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index e61ac4747..2f20c7c73 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -47,6 +47,9 @@ namespace { constexpr Rect g_emptyRect = {0, 0, 0, 0}; constexpr int32_t MIN_DECOR_HEIGHT = 37; constexpr int32_t MAX_DECOR_HEIGHT = 112; + constexpr size_t INDEX_ZERO = 0; + constexpr size_t INDEX_ONE = 1; + constexpr size_t INDEX_TWO = 2; } static thread_local std::map> g_jsWindowMap; @@ -5458,15 +5461,6 @@ napi_value JsWindow::OnGetTitleButtonRect(napi_env env, napi_callback_info info) return TitleButtonAreaObj; } -static inline bool GetNativeBool(napi_env env, napi_value nativeVal, bool* flag) -{ - if (nativeVal == nullptr) { - return false; - } - napi_get_value_bool(env, nativeVal, flag); - return true; -} - napi_value JsWindow::OnSetTitleButtonVisible(napi_env env, napi_callback_info info) { if (!Permission::IsSystemCalling()) { @@ -5480,21 +5474,18 @@ napi_value JsWindow::OnSetTitleButtonVisible(napi_env env, napi_callback_info in WLOGFE("Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - constexpr size_t IS_MAX_ARGC = 0; - constexpr size_t IS_MIN_ARGC = 1; - constexpr size_t IS_SPLIT_ARGC = 2; bool isMaximizeVisible = true; - if (!GetNativeBool(env, argv[IS_MAX_ARGC], &isMaximizeVisible)) { + if (!ConvertFromJsValue(env, argv[INDEX_ZERO], isMaximizeVisible)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isMaximizeVisible"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } bool isMinimizeVisible = true; - if (!GetNativeBool(env, argv[IS_MIN_ARGC], &isMinimizeVisible)) { + if (!ConvertFromJsValue(env, argv[INDEX_ONE], isMinimizeVisible)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isMinimizeVisible"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } bool isSplitVisible = true; - if (!GetNativeBool(env, argv[IS_SPLIT_ARGC], &isSplitVisible)) { + if (!ConvertFromJsValue(env, argv[INDEX_TWO], isSplitVisible)) { TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to isSplitVisible"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index fd2a99a44..8187630e3 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -2205,7 +2205,7 @@ HWTEST_F(WindowSceneSessionImplTest, GetTitleButtonVisible02, Function | SmallTe window->GetTitleButtonVisible(true, hideMaximizeButton, hideMinimizeButton, hideSplitButton); ASSERT_EQ(hideMaximizeButton, false); ASSERT_EQ(hideMinimizeButton, false); - ASSERT_EQ(hideSplitButton, true); + ASSERT_EQ(hideSplitButton, false); } /** @@ -2225,13 +2225,13 @@ HWTEST_F(WindowSceneSessionImplTest, GetTitleButtonVisible03, Function | SmallTe window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); // show Maximize, Minimize, Split buttons. window->windowTitleVisibleFlags_ = { false, false, false }; - bool hideMaximizeButton = false; - bool hideMinimizeButton = false; - bool hideSplitButton = false; + bool hideMaximizeButton = true; + bool hideMinimizeButton = true; + bool hideSplitButton = true; window->GetTitleButtonVisible(false, hideMaximizeButton, hideMinimizeButton, hideSplitButton); - ASSERT_EQ(hideMaximizeButton, false); - ASSERT_EQ(hideMinimizeButton, false); - ASSERT_EQ(hideSplitButton, false); + ASSERT_EQ(hideMaximizeButton, true); + ASSERT_EQ(hideMinimizeButton, true); + ASSERT_EQ(hideSplitButton, true); } /** -- Gitee From 50a9daa8bec2aa7d3ec2df19486f0cbf3604d492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 11:04:27 +0800 Subject: [PATCH 315/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- .../include/scene_session_manager.h | 2 +- .../include/zidl/scene_session_manager_interface.h | 2 +- .../include/zidl/scene_session_manager_proxy.h | 2 +- .../session_manager/src/scene_session_manager.cpp | 2 +- .../src/zidl/scene_session_manager_proxy.cpp | 4 ++-- .../unittest/scene_session_manager_stub_test.cpp | 14 ++++++++++++++ .../test/unittest/scene_session_manager_test.cpp | 11 +++++++++++ 7 files changed, 31 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 5a69680c2..67167b886 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -192,7 +192,7 @@ public: WSError PendingSessionToForeground(const sptr &token) override; WSError PendingSessionToBackgroundForDelegator(const sptr &token) override; WSError GetFocusSessionToken(sptr &token) override; - WSError GetFocusSessionElement(sptr &element) override; + WSError GetFocusSessionElement(AppExecFwk::ElementName &element) override; WSError RegisterSessionListener(const sptr& listener) override; WSError UnRegisterSessionListener(const sptr& listener) override; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h index ec9fc73ef..9dcdef984 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h @@ -111,7 +111,7 @@ public: virtual WSError PendingSessionToForeground(const sptr &token) = 0; virtual WSError PendingSessionToBackgroundForDelegator(const sptr &token) = 0; virtual WSError GetFocusSessionToken(sptr &token) = 0; - virtual WSError GetFocusSessionElement(sptr &element) = 0; + virtual WSError GetFocusSessionElement(AppExecFwk::ElementName &element) = 0; virtual WSError RegisterSessionListener(const sptr& listener) = 0; virtual WSError UnRegisterSessionListener(const sptr& listener) = 0; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h index ac9c1188b..1b477b270 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h @@ -60,7 +60,7 @@ public: WSError PendingSessionToForeground(const sptr &token) override; WSError PendingSessionToBackgroundForDelegator(const sptr &token) override; WSError GetFocusSessionToken(sptr &token) override; - WSError GetFocusSessionElement(sptr &element) override; + WSError GetFocusSessionElement(AppExecFwk::ElementName &element) override; WMError CheckWindowId(int32_t windowId, int32_t &pid) override; WSError RegisterSessionListener(const sptr& listener) override; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 0d05293bd..a609c6e00 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6034,7 +6034,7 @@ WSError SceneSessionManager::GetFocusSessionToken(sptr &token) return taskScheduler_->PostSyncTask(task, "GetFocusSessionToken"); } -WSError SceneSessionManager::GetFocusSessionElement(sptr &element) +WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName &element) { auto task = [this, &element]() { WLOGFD("run GetFocusSessionElement with focusedSessionId: %{public}d", focusedSessionId_); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index e099f60c9..bc9ef516e 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -995,7 +995,7 @@ WSError SceneSessionManagerProxy::GetFocusSessionToken(sptr &toke return static_cast(reply.ReadInt32()); } -WSError SceneSessionManagerProxy::GetFocusSessionElement(sptr &element) +WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName &element) { WLOGFD("run SceneSessionManagerProxy::GetFocusSessionElement"); MessageParcel data; @@ -1012,7 +1012,7 @@ WSError SceneSessionManagerProxy::GetFocusSessionElement(sptr(reply.ReadInt32()); diff --git a/window_scene/test/unittest/scene_session_manager_stub_test.cpp b/window_scene/test/unittest/scene_session_manager_stub_test.cpp index 544cc6c0e..e123228c4 100644 --- a/window_scene/test/unittest/scene_session_manager_stub_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_stub_test.cpp @@ -170,6 +170,20 @@ HWTEST_F(SceneSessionManagerStubTest, HandleGetFocusSessionInfo, Function | Smal EXPECT_EQ(res, ERR_NONE); } +/** + * @tc.name: HandleGetFocusSessionElement + * @tc.desc: test HandleGetFocusSessionElement + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerStubTest, HandleGetFocusSessionElement, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + + int res = stub_->HandleGetFocusSessionElement(data, reply); + EXPECT_EQ(res, ERR_NONE); +} + /** * @tc.name: HandleSetSessionLabel * @tc.desc: test HandleSetSessionLabel diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 7c0816fc6..32ed04f22 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -1764,6 +1764,17 @@ HWTEST_F(SceneSessionManagerTest, GetSceneSession, Function | SmallTest | Level3 ASSERT_EQ(ssm_->GetSceneSession(persistentId), nullptr); } +/** + * @tc.name: GetFocusSessionElement + * @tc.desc: SceneSesionManager get focus session element + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, GetFocusSessionElement, Function | SmallTest | Level3) +{ + AppExecFwk::ElementName element; + ASSERT_EQ(ssm_->GetFocusSessionElement(element), 0); +} + /** * @tc.name: GetSceneSessionByName * @tc.desc: SceneSesionManager get scene session by name -- Gitee From 1ef12adbd39f43a7909a9161ddca0f39792d2d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 11:06:45 +0800 Subject: [PATCH 316/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- .../session_manager/src/zidl/scene_session_manager_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index 5584bc500..5d7d0ce26 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -524,7 +524,7 @@ int SceneSessionManagerStub::HandleGetFocusSessionToken(MessageParcel &data, Mes int SceneSessionManagerStub::HandleGetFocusSessionElement(MessageParcel &data, MessageParcel &reply) { WLOGFD("run HandleGetFocusSessionElement!"); - sptr element = nullptr; + AppExecFwk::ElementName element; const WSError& errCode = GetFocusSessionElement(element); reply.WriteRemoteObject(element); reply.WriteInt32(static_cast(errCode)); -- Gitee From 069d583da70b8ac90cfd2ac6e582dd9c10b94a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 11:38:33 +0800 Subject: [PATCH 317/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- .../session_manager/src/zidl/scene_session_manager_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index 5d7d0ce26..0d5ad08b5 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -526,7 +526,7 @@ int SceneSessionManagerStub::HandleGetFocusSessionElement(MessageParcel &data, M WLOGFD("run HandleGetFocusSessionElement!"); AppExecFwk::ElementName element; const WSError& errCode = GetFocusSessionElement(element); - reply.WriteRemoteObject(element); + reply.WriteParcelable(element); reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } -- Gitee From 49cc2990956db55ee808aaa8e021d93e675d79ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 12:52:03 +0800 Subject: [PATCH 318/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- .../session_manager/src/zidl/scene_session_manager_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index bc9ef516e..9a6bd585a 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -1011,7 +1011,7 @@ WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; } - element = reply.ReadRemoteObject(); + element = reply.ReadParcelable(); if (element == null) { WLOGFD("get element null."); } -- Gitee From 97f5cf07a74df3c8515f2f59fa3e630625ef2117 Mon Sep 17 00:00:00 2001 From: t30053014 <1180300204@alu.hit.edu.cn> Date: Mon, 1 Apr 2024 14:18:31 +0800 Subject: [PATCH 319/385] Signed-off-by: t30053014 <1180300204@alu.hit.edu.cn> modified: window_scene/session_manager/include/fold_screen_controller/fold_screen_sensor_manager.h modified: window_scene/session_manager/include/screen_session_manager.h modified: window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp modified: window_scene/session_manager/src/screen_session_manager.cpp --- .../fold_screen_sensor_manager.h | 6 +++-- .../include/screen_session_manager.h | 1 + .../fold_screen_sensor_manager.cpp | 25 +++++++++++-------- .../src/screen_session_manager.cpp | 5 ++++ 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/window_scene/session_manager/include/fold_screen_controller/fold_screen_sensor_manager.h b/window_scene/session_manager/include/fold_screen_controller/fold_screen_sensor_manager.h index 6611a710d..1be4f3ceb 100644 --- a/window_scene/session_manager/include/fold_screen_controller/fold_screen_sensor_manager.h +++ b/window_scene/session_manager/include/fold_screen_controller/fold_screen_sensor_manager.h @@ -34,6 +34,8 @@ class FoldScreenSensorManager : public RefBase { WM_DECLARE_SINGLE_INSTANCE_BASE(FoldScreenSensorManager); public: + void RegisterPostureCallback(); + void UnRegisterPostureCallback(); void UnRegisterHallCallback(); @@ -44,6 +46,8 @@ public: void HandleHallData(const SensorEvent * const event); + bool allowPosture = true; + private: sptr foldScreenPolicy_; @@ -57,8 +61,6 @@ private: int allowUseSensorForAlta = 0; - void RegisterPostureCallback(); - void RegisterHallCallback(); void HandleSensorData(float, int); diff --git a/window_scene/session_manager/include/screen_session_manager.h b/window_scene/session_manager/include/screen_session_manager.h index 78d28e0f9..9050c7c07 100644 --- a/window_scene/session_manager/include/screen_session_manager.h +++ b/window_scene/session_manager/include/screen_session_manager.h @@ -33,6 +33,7 @@ #include "screen.h" #include "screen_cutout_controller.h" #include "fold_screen_controller/fold_screen_controller.h" +include "fold_screen_controller/fold_screen_sensor_manager.h" namespace OHOS::Rosen { class RSInterfaces; diff --git a/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp b/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp index db34238ec..af1ca887d 100644 --- a/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp +++ b/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp @@ -59,7 +59,11 @@ WM_IMPLEMENT_SINGLE_INSTANCE(FoldScreenSensorManager); FoldScreenSensorManager::FoldScreenSensorManager() { - RegisterPostureCallback(); + if (allowPosture) { + RegisterPostureCallback(); + } else { + WLOGFI("Duplicate registration posture is not allowed."); + } RegisterHallCallback(); } @@ -79,6 +83,9 @@ void FoldScreenSensorManager::RegisterPostureCallback() WLOGFI("RegisterPostureCallback, activateRet: %{public}d", activateRet); if (subscribeRet != SENSOR_SUCCESS || setBatchRet != SENSOR_SUCCESS || activateRet != SENSOR_SUCCESS) { WLOGFE("RegisterPostureCallback failed."); + } else { + allowPosture = false; + WLOGFI("FoldScreenSensorManager.RegisterPostureCallback success."); } } @@ -87,6 +94,7 @@ void FoldScreenSensorManager::UnRegisterPostureCallback() int32_t deactivateRet = DeactivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); int32_t unsubscribeRet = UnsubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); if (deactivateRet == SENSOR_SUCCESS && unsubscribeRet == SENSOR_SUCCESS) { + allowPosture = true; WLOGFI("FoldScreenSensorManager.UnRegisterPostureCallback success."); } } @@ -195,12 +203,9 @@ void FoldScreenSensorManager::HandleSensorData(float angle, int hall) void FoldScreenSensorManager::UpdateSwitchScreenBoundaryForAlta(float angle, int hall) { - if (!PowerMgr::PowerMgrClient::GetInstance().IsScreenOn()) { + if (hall == HALL_FOLDED_THRESHOLD || !PowerMgr::PowerMgrClient::GetInstance().IsScreenOn()) { allowUseSensorForAlta = SMALLER_BOUNDARY_FLAG; - } - if (angle >= LARGER_BOUNDARY_FOR_ALTA_THRESHOLD) { - allowUseSensorForAlta = LARGER_BOUNDARY_FLAG; - } else if (hall == HALL_FOLDED_THRESHOLD) { + } else if (angle >= LARGER_BOUNDARY_FOR_ALTA_THRESHOLD) { allowUseSensorForAlta = SMALLER_BOUNDARY_FLAG; } } @@ -213,16 +218,14 @@ FoldStatus FoldScreenSensorManager::TransferAngleToScreenState(float angle, int } FoldStatus state; - if (std::isgreaterequal(angle, ALTA_HALF_FOLDED_MAX_THRESHOLD)) { - return FoldStatus::EXPAND; - } - if (allowUseSensorForAlta == SMALLER_BOUNDARY_FLAG) { if (hall == HALL_FOLDED_THRESHOLD) { state = FoldStatus::FOLDED; } else if (std::islessequal(angle, ALTA_HALF_FOLDED_MAX_THRESHOLD - ALTA_HALF_FOLDED_BUFFER) && hall == HALL_THRESHOLD) { state = FoldStatus::HALF_FOLD; + } else if (std::isgreaterequal(angle, ALTA_HALF_FOLDED_MAX_THRESHOLD)) { + state = FoldStatus::EXPAND; } else { state = mState_; if (state == FoldStatus::UNKNOWN) { @@ -239,6 +242,8 @@ FoldStatus FoldScreenSensorManager::TransferAngleToScreenState(float angle, int } else if (std::islessequal(angle, ALTA_HALF_FOLDED_MAX_THRESHOLD - ALTA_HALF_FOLDED_BUFFER) && std::isgreater(angle, CLOSE_ALTA_HALF_FOLDED_MIN_THRESHOLD + ALTA_HALF_FOLDED_BUFFER)) { state = FoldStatus::HALF_FOLD; + } else if (std::isgreaterequal(angle, ALTA_HALF_FOLDED_MAX_THRESHOLD)) { + state = FoldStatus::EXPAND; } else { state = mState_; if (state == FoldStatus::UNKNOWN) { diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index 7b18255c5..d8dfd28dd 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -1122,6 +1122,11 @@ bool ScreenSessionManager::GetPowerStatus(ScreenPowerState state, PowerStateChan { switch (state) { case ScreenPowerState::POWER_ON: { + if (g_foldScreenFlag && FoldScreenSensorManager::GetInstance().allowPosture) { + FoldScreenSensorManager::GetInstance().RegisterPostureCallback(); + } else { + WLOGFI("Duplicate registration posture is not allowed."); + } if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT) { status = ScreenPowerStatus::POWER_STATUS_ON_ADVANCED; WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON_ADVANCED"); -- Gitee From c8e77df221c57c9be157e2922cb6ec466a356fb2 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 14:21:55 +0800 Subject: [PATCH 320/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../js_pip_window_manager.cpp | 5 +++++ wm/include/window_impl.h | 1 + wm/src/window.cpp | 8 ++++---- wm/src/window_impl.cpp | 19 +++++++++++++++++++ wm/test/unittest/window_test.cpp | 6 +----- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 04305336e..7802f313f 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -242,6 +242,11 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback return; } sptr mainWindow = Window::GetMainWindowWithContext(context->lock()); + if (mainWindow == nullptr) { + task.Reject(env, CreateJsError(env, static_cast( + WMError::WM_ERROR_PIP_INTERNAL_ERROR), "mainWindow is nullptr.")); + return; + } sptr pipController = new PictureInPictureController(pipOptionPtr, mainWindow, mainWindow->GetWindowId(), env); task.Resolve(env, CreateJsPipControllerObject(env, pipController)); diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index d3beb2472..92f754160 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -111,6 +111,7 @@ public: static sptr Find(const std::string& id); static sptr GetTopWindowWithContext(const std::shared_ptr& context = nullptr); static sptr GetTopWindowWithId(uint32_t mainWinId); + static sptr GetMainWindowWithContext(const std::shared_ptr& context = nullptr); static std::vector> GetSubWindow(uint32_t parantId); static void UpdateConfigurationForAll(const std::shared_ptr& configuration); virtual std::shared_ptr GetSurfaceNode() const override; diff --git a/wm/src/window.cpp b/wm/src/window.cpp index 3bf2e7bf4..16f3ab82a 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -142,9 +142,6 @@ sptr Window::Create(sptr& option, const std::shared_ptr Window::CreatePiP(sptr& option, const PiPTemplateInfo& pipTemplateInfo, const std::shared_ptr& context, WMError& errCode) { - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - return nullptr; - } if (!option) { TLOGE(WmsLogTag::WMS_PIP, "option is null."); return nullptr; @@ -157,6 +154,9 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo TLOGE(WmsLogTag::WMS_PIP, "window type is not pip window."); return nullptr; } + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return Create(option->GetWindowName(), option, context, errCode); + } sptr windowSessionImpl = new(std::nothrow) WindowSceneSessionImpl(option); if (windowSessionImpl == nullptr) { TLOGE(WmsLogTag::WMS_PIP, "malloc windowSessionImpl failed."); @@ -206,7 +206,7 @@ sptr Window::GetMainWindowWithContext(const std::shared_ptr WindowImpl::GetTopWindowWithContext(const std::shared_ptr WindowImpl::GetMainWindowWithContext(const std::shared_ptr& context) +{ + if (windowMap_.empty()) { + WLOGFE("Please create mainWindow First!"); + return nullptr; + } + uint32_t mainWinId = INVALID_WINDOW_ID; + for (auto iter = windowMap_.begin(); iter != windowMap_.end(); iter++) { + auto win = iter->second.second; + if (context.get() == win->GetContext().get() && WindowHelper::IsMainWindow(win->GetType())) { + mainWinId = win->GetWindowId(); + WLOGI("GetMainWindow Find MainWinId:%{public}u.", win->GetWindowId()); + return win; + } + } + WLOGFE("Cannot find main Window!"); + return nullptr; +} + std::vector> WindowImpl::GetSubWindow(uint32_t parentId) { if (subWindowMap_.find(parentId) == subWindowMap_.end()) { diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index 35b8e05e4..d3bcf239f 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -127,11 +127,7 @@ HWTEST_F(WindowTest, CreatePiP, Function | SmallTest | Level2) ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); option->SetWindowType(WindowType::WINDOW_TYPE_PIP); option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); - if (SceneBoardJudgement::IsSceneBoardEnabled()) { - ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); - } else { - ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); - } + ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); } /** -- Gitee From 116b6a759d55358bb8aa1c264806f5f4fa2b21f7 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 14:28:53 +0800 Subject: [PATCH 321/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/window_impl.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index f776c3340..95768bcf2 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -235,11 +235,9 @@ sptr WindowImpl::GetMainWindowWithContext(const std::shared_ptrsecond.second; if (context.get() == win->GetContext().get() && WindowHelper::IsMainWindow(win->GetType())) { - mainWinId = win->GetWindowId(); WLOGI("GetMainWindow Find MainWinId:%{public}u.", win->GetWindowId()); return win; } -- Gitee From 39d37dd0d3cd928355b63c897e51c46c6226ef17 Mon Sep 17 00:00:00 2001 From: wanganjie Date: Mon, 1 Apr 2024 14:32:27 +0800 Subject: [PATCH 322/385] update Signed-off-by: wanganjie --- 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 dd20ad643..bd93c3684 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1739,7 +1739,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_FLOAT && !secureSessionSet_.empty()) || (SessionHelper::IsSubWindow(property->GetWindowType()) && - secureSessionSet_.find(property->GetParentPersistentId()) != secureSessionSet_.end()); + secureSessionSet_.find(property->GetParentPersistentId()) != secureSessionSet_.end()); if (shouldBlock) { TLOGE(WmsLogTag::WMS_UIEXT, "create non-secure window permission denied!"); return WSError::WS_ERROR_INVALID_OPERATION; -- Gitee From 33db6ed3198239323f4581b325af90a3eacd18af Mon Sep 17 00:00:00 2001 From: t30053014 <1180300204@alu.hit.edu.cn> Date: Mon, 1 Apr 2024 14:46:47 +0800 Subject: [PATCH 323/385] Signed-off-by: t30053014 <1180300204@alu.hit.edu.cn> modified: window_scene/session_manager/include/screen_session_manager.h --- window_scene/session_manager/include/screen_session_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/include/screen_session_manager.h b/window_scene/session_manager/include/screen_session_manager.h index 9050c7c07..5d12e5ad8 100644 --- a/window_scene/session_manager/include/screen_session_manager.h +++ b/window_scene/session_manager/include/screen_session_manager.h @@ -33,7 +33,7 @@ #include "screen.h" #include "screen_cutout_controller.h" #include "fold_screen_controller/fold_screen_controller.h" -include "fold_screen_controller/fold_screen_sensor_manager.h" +#include "fold_screen_controller/fold_screen_sensor_manager.h" namespace OHOS::Rosen { class RSInterfaces; -- Gitee From e9251fa276588a94b06d3b0e53d39017eaaeeed5 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 15:06:51 +0800 Subject: [PATCH 324/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../js_pip_window_manager.cpp | 5 +++++ wm/include/window_impl.h | 1 - wm/src/window.cpp | 8 ++++---- wm/src/window_impl.cpp | 17 ----------------- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 7802f313f..54beae223 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -234,6 +234,11 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback } NapiAsyncTask::CompleteCallback complete = [=](napi_env env, NapiAsyncTask& task, int32_t status) { + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + task.Reject(env, CreateJsError(env, static_cast( + WMError::WM_ERROR_DEVICE_NOT_SUPPORT), "device not support pip.")); + return; + } sptr pipOptionPtr = new PipOption(pipOption); auto context = static_cast*>(pipOptionPtr->GetContext()); if (context == nullptr) { diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index 92f754160..d3beb2472 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -111,7 +111,6 @@ public: static sptr Find(const std::string& id); static sptr GetTopWindowWithContext(const std::shared_ptr& context = nullptr); static sptr GetTopWindowWithId(uint32_t mainWinId); - static sptr GetMainWindowWithContext(const std::shared_ptr& context = nullptr); static std::vector> GetSubWindow(uint32_t parantId); static void UpdateConfigurationForAll(const std::shared_ptr& configuration); virtual std::shared_ptr GetSurfaceNode() const override; diff --git a/wm/src/window.cpp b/wm/src/window.cpp index 16f3ab82a..3bf2e7bf4 100644 --- a/wm/src/window.cpp +++ b/wm/src/window.cpp @@ -142,6 +142,9 @@ sptr Window::Create(sptr& option, const std::shared_ptr Window::CreatePiP(sptr& option, const PiPTemplateInfo& pipTemplateInfo, const std::shared_ptr& context, WMError& errCode) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + return nullptr; + } if (!option) { TLOGE(WmsLogTag::WMS_PIP, "option is null."); return nullptr; @@ -154,9 +157,6 @@ sptr Window::CreatePiP(sptr& option, const PiPTemplateInfo TLOGE(WmsLogTag::WMS_PIP, "window type is not pip window."); return nullptr; } - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { - return Create(option->GetWindowName(), option, context, errCode); - } sptr windowSessionImpl = new(std::nothrow) WindowSceneSessionImpl(option); if (windowSessionImpl == nullptr) { TLOGE(WmsLogTag::WMS_PIP, "malloc windowSessionImpl failed."); @@ -206,7 +206,7 @@ sptr Window::GetMainWindowWithContext(const std::shared_ptr WindowImpl::GetTopWindowWithContext(const std::shared_ptr WindowImpl::GetMainWindowWithContext(const std::shared_ptr& context) -{ - if (windowMap_.empty()) { - WLOGFE("Please create mainWindow First!"); - return nullptr; - } - for (auto iter = windowMap_.begin(); iter != windowMap_.end(); iter++) { - auto win = iter->second.second; - if (context.get() == win->GetContext().get() && WindowHelper::IsMainWindow(win->GetType())) { - WLOGI("GetMainWindow Find MainWinId:%{public}u.", win->GetWindowId()); - return win; - } - } - WLOGFE("Cannot find main Window!"); - return nullptr; -} - std::vector> WindowImpl::GetSubWindow(uint32_t parentId) { if (subWindowMap_.find(parentId) == subWindowMap_.end()) { -- Gitee From d34d7ebb379a3206ca4eba00dc692287099acb22 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 15:07:46 +0800 Subject: [PATCH 325/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/test/unittest/window_test.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wm/test/unittest/window_test.cpp b/wm/test/unittest/window_test.cpp index d3bcf239f..35b8e05e4 100644 --- a/wm/test/unittest/window_test.cpp +++ b/wm/test/unittest/window_test.cpp @@ -127,7 +127,11 @@ HWTEST_F(WindowTest, CreatePiP, Function | SmallTest | Level2) ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); option->SetWindowType(WindowType::WINDOW_TYPE_PIP); option->SetWindowMode(WindowMode::WINDOW_MODE_PIP); - ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + if (SceneBoardJudgement::IsSceneBoardEnabled()) { + ASSERT_NE(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + } else { + ASSERT_EQ(nullptr, Window::CreatePiP(option, pipTemplateInfo, abilityContext_)); + } } /** -- Gitee From 3c2b4913c540d48519e9733a8687cdfaffde67b3 Mon Sep 17 00:00:00 2001 From: cuifeihe Date: Mon, 1 Apr 2024 15:20:11 +0800 Subject: [PATCH 326/385] =?UTF-8?q?Description:=20=E5=9C=A8DisplayManager:?= =?UTF-8?q?:OnRemoteDied=E4=B8=AD=E5=A2=9E=E5=8A=A0=E5=88=A4=E7=A9=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91=20IssueNo:=20https://gitee.com/openharmony/w?= =?UTF-8?q?indow=5Fwindow=5Fmanager/issues/I9D9SK=20Signed-off-by:=20cuife?= =?UTF-8?q?ihe=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dm/src/display_manager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dm/src/display_manager.cpp b/dm/src/display_manager.cpp index bd265c427..f523558f4 100644 --- a/dm/src/display_manager.cpp +++ b/dm/src/display_manager.cpp @@ -1465,6 +1465,10 @@ void DisplayManager::Impl::OnRemoteDied() void DisplayManager::OnRemoteDied() { + if (pImpl_ == nullptr) { + WLOGFE("dms is dying, pImpl_ is nullptr"); + return; + } pImpl_->OnRemoteDied(); } -- Gitee From 9761066ed3de0c683dc5a92d13b4e2b8d5b8a80c Mon Sep 17 00:00:00 2001 From: t30053014 <1180300204@alu.hit.edu.cn> Date: Mon, 1 Apr 2024 15:45:22 +0800 Subject: [PATCH 327/385] Signed-off-by: t30053014 <1180300204@alu.hit.edu.cn> modified: window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp modified: window_scene/session_manager/src/screen_session_manager.cpp --- .../fold_screen_sensor_manager.cpp | 2 +- .../src/screen_session_manager.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp b/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp index af1ca887d..e270204b8 100644 --- a/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp +++ b/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp @@ -206,7 +206,7 @@ void FoldScreenSensorManager::UpdateSwitchScreenBoundaryForAlta(float angle, int if (hall == HALL_FOLDED_THRESHOLD || !PowerMgr::PowerMgrClient::GetInstance().IsScreenOn()) { allowUseSensorForAlta = SMALLER_BOUNDARY_FLAG; } else if (angle >= LARGER_BOUNDARY_FOR_ALTA_THRESHOLD) { - allowUseSensorForAlta = SMALLER_BOUNDARY_FLAG; + allowUseSensorForAlta = LARGER_BOUNDARY_FLAG; } } diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index d8dfd28dd..db3cdc0c4 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -1122,16 +1122,16 @@ bool ScreenSessionManager::GetPowerStatus(ScreenPowerState state, PowerStateChan { switch (state) { case ScreenPowerState::POWER_ON: { - if (g_foldScreenFlag && FoldScreenSensorManager::GetInstance().allowPosture) { - FoldScreenSensorManager::GetInstance().RegisterPostureCallback(); - } else { - WLOGFI("Duplicate registration posture is not allowed."); - } if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_PRE_BRIGHT) { status = ScreenPowerStatus::POWER_STATUS_ON_ADVANCED; WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON_ADVANCED"); } else { status = ScreenPowerStatus::POWER_STATUS_ON; + if (g_foldScreenFlag && FoldScreenSensorManager::GetInstance().allowPosture) { + FoldScreenSensorManager::GetInstance().RegisterPostureCallback(); + } else { + WLOGFI("Duplicate registration posture is not allowed."); + } WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON"); } break; @@ -1165,6 +1165,11 @@ bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateCh if (status == ScreenPowerStatus::POWER_STATUS_OFF) { taskScheduler_->RemoveTask("screenOnTask"); + if (g_foldScreenFlag && !FoldScreenSensorManager::GetInstance().allowPosture) { + OHOS::Rosen::FoldScreenSensorManager::GetInstance().UnRegisterPostureCallback(); + } else { + WLOGFI("Duplicate unregistration posture is not allowed."); + } } // Handling Power Button Conflicts -- Gitee From 474f23954503ed94b3379553cba33aae166e00db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 15:52:39 +0800 Subject: [PATCH 328/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- .../src/zidl/scene_session_manager_proxy.cpp | 6 ++++-- .../session_manager/src/zidl/scene_session_manager_stub.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index 9a6bd585a..9275b965d 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -1011,8 +1011,10 @@ WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; } - element = reply.ReadParcelable(); - if (element == null) { + sptr el = reply.ReadParcelable(); + if (el) { + element = *el; + } else { WLOGFD("get element null."); } return static_cast(reply.ReadInt32()); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index 0d5ad08b5..e5966ea9d 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -526,7 +526,7 @@ int SceneSessionManagerStub::HandleGetFocusSessionElement(MessageParcel &data, M WLOGFD("run HandleGetFocusSessionElement!"); AppExecFwk::ElementName element; const WSError& errCode = GetFocusSessionElement(element); - reply.WriteParcelable(element); + reply.WriteParcelable(&element); reply.WriteInt32(static_cast(errCode)); return ERR_NONE; } -- Gitee From 5fd4e7d03a40cab3cd12f304ed5b87dc5ed7dc82 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 15:53:24 +0800 Subject: [PATCH 329/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 54beae223..95045f9c5 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -234,7 +234,7 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback } NapiAsyncTask::CompleteCallback complete = [=](napi_env env, NapiAsyncTask& task, int32_t status) { - if (SceneBoardJudgement::IsSceneBoardEnabled()) { + if (!SceneBoardJudgement::IsSceneBoardEnabled()) { task.Reject(env, CreateJsError(env, static_cast( WMError::WM_ERROR_DEVICE_NOT_SUPPORT), "device not support pip.")); return; -- Gitee From 679b2efc803ad61157dfb390d30a9fb5f659ccef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 16:23:54 +0800 Subject: [PATCH 330/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- .../test/unittest/scene_session_manager_test.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 32ed04f22..7c0816fc6 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -1764,17 +1764,6 @@ HWTEST_F(SceneSessionManagerTest, GetSceneSession, Function | SmallTest | Level3 ASSERT_EQ(ssm_->GetSceneSession(persistentId), nullptr); } -/** - * @tc.name: GetFocusSessionElement - * @tc.desc: SceneSesionManager get focus session element - * @tc.type: FUNC -*/ -HWTEST_F(SceneSessionManagerTest, GetFocusSessionElement, Function | SmallTest | Level3) -{ - AppExecFwk::ElementName element; - ASSERT_EQ(ssm_->GetFocusSessionElement(element), 0); -} - /** * @tc.name: GetSceneSessionByName * @tc.desc: SceneSesionManager get scene session by name -- Gitee From 8262e743da2b0c8edcc2ee62e29514900b7b85d6 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 16:26:38 +0800 Subject: [PATCH 331/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../napi/picture_in_picture_napi/js_pip_window_manager.cpp | 3 ++- wm/include/picture_in_picture_manager.h | 1 + wm/src/picture_in_picture_manager.cpp | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 95045f9c5..bbadcbacd 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -20,6 +20,7 @@ #include "js_runtime_utils.h" #include "window_manager_hilog.h" #include "window.h" +#include "picture_in_picture_manager.h" #include "xcomponent_controller.h" namespace OHOS { @@ -234,7 +235,7 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback } NapiAsyncTask::CompleteCallback complete = [=](napi_env env, NapiAsyncTask& task, int32_t status) { - if (!SceneBoardJudgement::IsSceneBoardEnabled()) { + if (PictureInPictureManager::IsSupportPiP()) { task.Reject(env, CreateJsError(env, static_cast( WMError::WM_ERROR_DEVICE_NOT_SUPPORT), "device not support pip.")); return; diff --git a/wm/include/picture_in_picture_manager.h b/wm/include/picture_in_picture_manager.h index f571d0090..cccad835a 100644 --- a/wm/include/picture_in_picture_manager.h +++ b/wm/include/picture_in_picture_manager.h @@ -28,6 +28,7 @@ public: PictureInPictureManager(); ~PictureInPictureManager(); static bool ShouldAbortPipStart(); + static bool IsSupportPiP(); static void PutPipControllerInfo(int32_t windowId, sptr pipController); static void RemovePipControllerInfo(int32_t windowId); static void AttachActivePipController(sptr pipController); diff --git a/wm/src/picture_in_picture_manager.cpp b/wm/src/picture_in_picture_manager.cpp index 4480f7f36..c847c14b2 100644 --- a/wm/src/picture_in_picture_manager.cpp +++ b/wm/src/picture_in_picture_manager.cpp @@ -43,6 +43,11 @@ PictureInPictureManager::~PictureInPictureManager() { } +bool IsSupportPiP() +{ + return SceneBoardJudgement::IsSceneBoardEnabled(); +} + bool PictureInPictureManager::ShouldAbortPipStart() { return activeController_ != nullptr && activeController_->GetControllerState() == PiPWindowState::STATE_STARTING; -- Gitee From 432895bfd8007181f69f789d74ed0ab60243ae65 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 16:29:12 +0800 Subject: [PATCH 332/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/include/picture_in_picture_manager.h | 1 + 1 file changed, 1 insertion(+) diff --git a/wm/include/picture_in_picture_manager.h b/wm/include/picture_in_picture_manager.h index cccad835a..f71b12aac 100644 --- a/wm/include/picture_in_picture_manager.h +++ b/wm/include/picture_in_picture_manager.h @@ -20,6 +20,7 @@ #include "picture_in_picture_controller.h" #include "window.h" #include "wm_common.h" +#include "scene_board_judgement.h" namespace OHOS { namespace Rosen { -- Gitee From e78c08e9c31ca3d60339331f4e93f8028e21be38 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 16:29:48 +0800 Subject: [PATCH 333/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/picture_in_picture_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/picture_in_picture_manager.cpp b/wm/src/picture_in_picture_manager.cpp index c847c14b2..d7eaed10c 100644 --- a/wm/src/picture_in_picture_manager.cpp +++ b/wm/src/picture_in_picture_manager.cpp @@ -43,7 +43,7 @@ PictureInPictureManager::~PictureInPictureManager() { } -bool IsSupportPiP() +bool PictureInPictureManager::IsSupportPiP() { return SceneBoardJudgement::IsSceneBoardEnabled(); } -- Gitee From 172c8d82ad8edb2da30bb51b4750bd713e3b4219 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 16:44:58 +0800 Subject: [PATCH 334/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- .../kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index bbadcbacd..11cb75a02 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -235,7 +235,7 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback } NapiAsyncTask::CompleteCallback complete = [=](napi_env env, NapiAsyncTask& task, int32_t status) { - if (PictureInPictureManager::IsSupportPiP()) { + if (!PictureInPictureManager::IsSupportPiP()) { task.Reject(env, CreateJsError(env, static_cast( WMError::WM_ERROR_DEVICE_NOT_SUPPORT), "device not support pip.")); return; -- Gitee From 6cd4e5cab0115e7229d85f45f359e91186fb211d Mon Sep 17 00:00:00 2001 From: xuyangyang Date: Mon, 1 Apr 2024 16:50:14 +0800 Subject: [PATCH 335/385] add tdd ut case Signed-off-by: xuyangyang Change-Id: I2ca7788db857548a09023b1e0dfde7f530189ef7 --- .../screen_session_manager_stub_test.cpp | 342 ++++++++++++++++++ 1 file changed, 342 insertions(+) diff --git a/window_scene/test/unittest/screen_session_manager_stub_test.cpp b/window_scene/test/unittest/screen_session_manager_stub_test.cpp index fef4bac1e..8a8a79557 100644 --- a/window_scene/test/unittest/screen_session_manager_stub_test.cpp +++ b/window_scene/test/unittest/screen_session_manager_stub_test.cpp @@ -905,6 +905,348 @@ HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest39, Function | SmallTest | int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } + +/** + * @tc.name: OnRemoteRequest40 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest40, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_SPACE); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest41 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest41, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_COLOR_SPACE); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest42 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest42, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_HDR_FORMAT); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest43 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest43, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_HDR_FORMAT); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest44 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest44, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_SUPPORTED_HDR_FORMAT); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest45 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest45, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_PIXEL_FORMAT); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest46 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest46, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_PIXEL_FORMAT); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest47 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest47, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_TRANSFORM); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest48 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest48, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_GAMUT_MAP); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest49 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest49, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_GAMUT_MAP); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest050 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest050, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_GAMUT); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest051 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest051, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_GET_COLOR_GAMUT); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest052 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest052, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_DENSITY_IN_CURRENT_RESOLUTION); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest053 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest053, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_RESOLUTION); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest054 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest054, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest055 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest055, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_CANVAS_ROTATION); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest056 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest056, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + +/** + * @tc.name: OnRemoteRequest057 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest057, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast( + IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER); + int res = stub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} } } } \ No newline at end of file -- Gitee From d6fdd1e761f91c4095329736e39597d8a2e69a4b Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 17:14:25 +0800 Subject: [PATCH 336/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/include/picture_in_picture_manager.h | 1 - wm/src/picture_in_picture_manager.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/include/picture_in_picture_manager.h b/wm/include/picture_in_picture_manager.h index f71b12aac..cccad835a 100644 --- a/wm/include/picture_in_picture_manager.h +++ b/wm/include/picture_in_picture_manager.h @@ -20,7 +20,6 @@ #include "picture_in_picture_controller.h" #include "window.h" #include "wm_common.h" -#include "scene_board_judgement.h" namespace OHOS { namespace Rosen { diff --git a/wm/src/picture_in_picture_manager.cpp b/wm/src/picture_in_picture_manager.cpp index d7eaed10c..9c407474c 100644 --- a/wm/src/picture_in_picture_manager.cpp +++ b/wm/src/picture_in_picture_manager.cpp @@ -21,6 +21,7 @@ #include "window_manager_hilog.h" #include "window_scene_session_impl.h" #include "wm_common.h" +#include "scene_board_judgement.h" namespace OHOS { namespace Rosen { -- Gitee From 8e5c5e5625e9b7766095bf2d237527beabf30eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Mon, 1 Apr 2024 09:16:56 +0000 Subject: [PATCH 337/385] update window_scene/test/unittest/screen_session_manager_stub_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 --- .../screen_session_manager_stub_test.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/window_scene/test/unittest/screen_session_manager_stub_test.cpp b/window_scene/test/unittest/screen_session_manager_stub_test.cpp index 8a8a79557..31b790810 100644 --- a/window_scene/test/unittest/screen_session_manager_stub_test.cpp +++ b/window_scene/test/unittest/screen_session_manager_stub_test.cpp @@ -1221,25 +1221,6 @@ HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest056, Function | SmallTest MessageParcel reply; MessageOption option; - data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); - data.WriteBool(false); - uint32_t code = static_cast( - IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SURFACE); - int res = stub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(res, 0); -} - -/** - * @tc.name: OnRemoteRequest057 - * @tc.desc: normal function - * @tc.type: FUNC - */ -HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest057, Function | SmallTest | Level2) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); data.WriteBool(false); uint32_t code = static_cast( -- Gitee From 6397258887bcf4fc7eee17cd774b12eccb84cf0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A5=AD=E5=90=8E=E6=B3=A2=E6=B3=A2=E8=B7=AF?= Date: Fri, 29 Mar 2024 09:46:44 +0800 Subject: [PATCH 338/385] [uiextension sync] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 饭后波波路 --- window_scene/session/host/include/session.h | 2 +- window_scene/session/host/src/session.cpp | 5 ----- wm/src/window_extension_session_impl.cpp | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 42de8f666..566b5411d 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -191,7 +191,7 @@ public: virtual WSError SetActive(bool active); virtual WSError UpdateSizeChangeReason(SizeChangeReason reason); - SizeChangeReason GetSizeChangeReason() const; + SizeChangeReason GetSizeChangeReason() const { return reason_; } virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr); WSError UpdateDensity(); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index d4141d5f3..239803161 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -721,11 +721,6 @@ WSError Session::UpdateSizeChangeReason(SizeChangeReason reason) return WSError::WS_OK; } -SizeChangeReason Session::GetSizeChangeReason() const -{ - return reason_; -} - WSError Session::UpdateRect(const WSRect& rect, SizeChangeReason reason, const std::shared_ptr& rsTransaction) { diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 4cfce5bd0..b0cb839c2 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -401,7 +401,6 @@ WSError WindowExtensionSessionImpl::UpdateRect(const WSRect& rect, SizeChangeRea } property_->SetWindowRect(wmRect); if (wmReason == WindowSizeChangeReason::ROTATION) { - auto preRect = GetRect(); UpdateRectForRotation(wmRect, preRect, wmReason, rsTransaction); } else { NotifySizeChange(wmRect, wmReason); -- Gitee From 2a2878563235c2d7d67eee906518b54243f19894 Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Mon, 1 Apr 2024 17:23:58 +0800 Subject: [PATCH 339/385] add GetSessionManagerServiceProxy Signed-off-by: redking-zhong --- window_scene/session_manager/BUILD.gn | 5 ++++- .../session_manager/include/session_manager_lite.h | 2 ++ window_scene/session_manager/src/session_manager.cpp | 8 ++------ window_scene/session_manager/src/session_manager_lite.cpp | 7 +++++++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index 573074be8..16af045fd 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -301,7 +301,10 @@ ohos_shared_library("session_manager") { public_configs = [ ":session_manager_public_config" ] - deps = [ "${window_base_path}/utils:libwmutil" ] + deps = [ + "${window_base_path}/utils:libwmutil", + "session_manager_lite", + ] public_external_deps = [ "ability_runtime:session_handler", "accessibility:accessibility_common", diff --git a/window_scene/session_manager/include/session_manager_lite.h b/window_scene/session_manager/include/session_manager_lite.h index c86746027..1fecd4f27 100644 --- a/window_scene/session_manager/include/session_manager_lite.h +++ b/window_scene/session_manager/include/session_manager_lite.h @@ -40,6 +40,8 @@ public: sptr GetSceneSessionManagerLiteProxy(); sptr GetScreenSessionManagerLiteProxy(); + sptr GetSessionManagerServiceProxy(); + void SaveSessionListener(const sptr& listener); void DeleteSessionListener(const sptr& listener); void RecoverSessionManagerService(const sptr& sessionManagerService); diff --git a/window_scene/session_manager/src/session_manager.cpp b/window_scene/session_manager/src/session_manager.cpp index 9bcdb9e19..ae7671d68 100644 --- a/window_scene/session_manager/src/session_manager.cpp +++ b/window_scene/session_manager/src/session_manager.cpp @@ -21,6 +21,7 @@ #include "session_manager_service_recover_interface.h" #include "singleton_delegator.h" #include "window_manager_hilog.h" +#include "session_manager_lite.h" namespace OHOS::Rosen { namespace { @@ -155,12 +156,7 @@ void SessionManager::InitSessionManagerServiceProxy() mockSessionManagerServiceProxy_->RegisterSMSRecoverListener(smsRecoverListener_); } - sptr remoteObject2 = mockSessionManagerServiceProxy_->GetSessionManagerService(); - if (!remoteObject2) { - WLOGFE("Remote object2 is nullptr"); - return; - } - sessionManagerServiceProxy_ = iface_cast(remoteObject2); + sessionManagerServiceProxy_ = SessionManagerLite::GetInstance().GetSessionManagerServiceProxy(); if (!sessionManagerServiceProxy_) { WLOGFE("sessionManagerServiceProxy_ is nullptr"); } diff --git a/window_scene/session_manager/src/session_manager_lite.cpp b/window_scene/session_manager/src/session_manager_lite.cpp index 2d291e474..741c0784a 100644 --- a/window_scene/session_manager/src/session_manager_lite.cpp +++ b/window_scene/session_manager/src/session_manager_lite.cpp @@ -138,6 +138,13 @@ sptr SessionManagerLite::GetScreenSessionManagerLiteP return screenSessionManagerLiteProxy_; } +sptr SessionManagerLite::GetSessionManagerServiceProxy() +{ + std::lock_guard lock(mutx_); + InitSessionManagerServiceProxy(); + return SessionManagerServiceProxy_; +} + void SessionManagerLite::SaveSessionListener(const sptr& listener) { std::lock_guard guard(listenerLock_); -- Gitee From 04a1abeaca79dba5de5f8bfc97fcf5e05260c0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Mon, 1 Apr 2024 09:34:52 +0000 Subject: [PATCH 340/385] update window_scene/test/unittest/screen_session_manager_stub_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 --- .../test/unittest/screen_session_manager_stub_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/test/unittest/screen_session_manager_stub_test.cpp b/window_scene/test/unittest/screen_session_manager_stub_test.cpp index 31b790810..b299ba79f 100644 --- a/window_scene/test/unittest/screen_session_manager_stub_test.cpp +++ b/window_scene/test/unittest/screen_session_manager_stub_test.cpp @@ -1186,7 +1186,7 @@ HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest054, Function | SmallTest data.WriteInterfaceToken(ScreenSessionManagerStub::GetDescriptor()); data.WriteBool(false); uint32_t code = static_cast( - IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_VIRTUAL_SCREEN_SCALE_MODE); + IDisplayManager::DisplayManagerMessage::TRANS_ID_SCREEN_SET_COLOR_SPACE); int res = stub_->OnRemoteRequest(code, data, reply, option); EXPECT_EQ(res, 0); } @@ -1226,7 +1226,7 @@ HWTEST_F(ScreenSessionManagerStubTest, OnRemoteRequest056, Function | SmallTest uint32_t code = static_cast( IDisplayManager::DisplayManagerMessage::TRANS_ID_GET_SCREEN_POWER); int res = stub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(res, 0); + EXPECT_EQ(res, -1); } } } -- Gitee From a40ef3b2caea0ba2b9efdd07b6044be1e1b96bcc Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Mon, 1 Apr 2024 17:40:19 +0800 Subject: [PATCH 341/385] add GetSessionManagerServiceProxy Signed-off-by: redking-zhong --- window_scene/session_manager/BUILD.gn | 2 +- window_scene/session_manager/src/session_manager_lite.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index 16af045fd..bea1625e5 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -303,7 +303,7 @@ ohos_shared_library("session_manager") { deps = [ "${window_base_path}/utils:libwmutil", - "session_manager_lite", + ":session_manager_lite", ] public_external_deps = [ "ability_runtime:session_handler", diff --git a/window_scene/session_manager/src/session_manager_lite.cpp b/window_scene/session_manager/src/session_manager_lite.cpp index 741c0784a..664e7112b 100644 --- a/window_scene/session_manager/src/session_manager_lite.cpp +++ b/window_scene/session_manager/src/session_manager_lite.cpp @@ -140,7 +140,7 @@ sptr SessionManagerLite::GetScreenSessionManagerLiteP sptr SessionManagerLite::GetSessionManagerServiceProxy() { - std::lock_guard lock(mutx_); + std::lock_guard lock(mutex_); InitSessionManagerServiceProxy(); return SessionManagerServiceProxy_; } -- Gitee From f401ee55552101fc3ed7aae509aa8ccde52b1273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 19:01:28 +0800 Subject: [PATCH 342/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- .../session_manager/include/scene_session_manager.h | 4 ++-- .../include/zidl/scene_session_manager_interface.h | 2 +- .../include/zidl/scene_session_manager_proxy.h | 2 +- .../include/zidl/scene_session_manager_stub.h | 3 +-- .../session_manager/src/scene_session_manager.cpp | 8 +++----- .../src/zidl/scene_session_manager_proxy.cpp | 9 ++++----- .../src/zidl/scene_session_manager_stub.cpp | 4 ++-- .../test/unittest/scene_session_manager_stub_test.cpp | 1 - 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 67167b886..dbdac3318 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -192,8 +192,8 @@ public: WSError PendingSessionToForeground(const sptr &token) override; WSError PendingSessionToBackgroundForDelegator(const sptr &token) override; WSError GetFocusSessionToken(sptr &token) override; - WSError GetFocusSessionElement(AppExecFwk::ElementName &element) override; - + WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override; + WSError RegisterSessionListener(const sptr& listener) override; WSError UnRegisterSessionListener(const sptr& listener) override; WSError GetSessionInfos(const std::string& deviceId, int32_t numMax, diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h index 9dcdef984..ab1e7490f 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h @@ -111,7 +111,7 @@ public: virtual WSError PendingSessionToForeground(const sptr &token) = 0; virtual WSError PendingSessionToBackgroundForDelegator(const sptr &token) = 0; virtual WSError GetFocusSessionToken(sptr &token) = 0; - virtual WSError GetFocusSessionElement(AppExecFwk::ElementName &element) = 0; + virtual WSError GetFocusSessionElement(AppExecFwk::ElementName& element) = 0; virtual WSError RegisterSessionListener(const sptr& listener) = 0; virtual WSError UnRegisterSessionListener(const sptr& listener) = 0; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h index 1b477b270..ceb6c024f 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h @@ -60,7 +60,7 @@ public: WSError PendingSessionToForeground(const sptr &token) override; WSError PendingSessionToBackgroundForDelegator(const sptr &token) override; WSError GetFocusSessionToken(sptr &token) override; - WSError GetFocusSessionElement(AppExecFwk::ElementName &element) override; + WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override; WMError CheckWindowId(int32_t windowId, int32_t &pid) override; WSError RegisterSessionListener(const sptr& listener) override; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_stub.h b/window_scene/session_manager/include/zidl/scene_session_manager_stub.h index d5e43bf84..99f2c4153 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_stub.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_stub.h @@ -53,8 +53,7 @@ private: int HandlePendingSessionToForeground(MessageParcel &data, MessageParcel &reply); int HandlePendingSessionToBackgroundForDelegator(MessageParcel &data, MessageParcel &reply); int HandleGetFocusSessionToken(MessageParcel &data, MessageParcel &reply); - int HandleGetFocusSessionElement(MessageParcel &data, MessageParcel &reply); - + int HandleGetFocusSessionElement(MessageParcel& data, MessageParcel& reply); int HandleSetGestureNavigationEnabled(MessageParcel &data, MessageParcel &reply); int HandleSetSessionGravity(MessageParcel &data, MessageParcel &reply); int HandleCheckWindowId(MessageParcel &data, MessageParcel &reply); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index a609c6e00..c6ff523be 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6012,7 +6012,7 @@ WSError SceneSessionManager::PendingSessionToBackgroundForDelegator(const sptrPostSyncTask(task, "PendingSessionToBackgroundForDelegator"); } -WSError SceneSessionManager::GetFocusSessionToken(sptr &token) +WSError SceneSessionManager::GetFocusSessionToken(sptr& token) { if (!SessionPermission::IsSACalling()) { WLOGFE("GetFocusSessionToken permission denied!"); @@ -6034,16 +6034,14 @@ WSError SceneSessionManager::GetFocusSessionToken(sptr &token) return taskScheduler_->PostSyncTask(task, "GetFocusSessionToken"); } -WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName &element) +WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName& element) { auto task = [this, &element]() { WLOGFD("run GetFocusSessionElement with focusedSessionId: %{public}d", focusedSessionId_); auto sceneSession = GetSceneSession(focusedSessionId_); if (sceneSession) { auto sessionInfo = sceneSession->GetSessionInfo(); - AAFwk::Want want; - want.SetElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); - element = want.GetElement(); + element = ElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); return WSError::WS_OK; } return WSError::WS_ERROR_INVALID_SESSION; diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index 9275b965d..e862d5114 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -995,7 +995,7 @@ WSError SceneSessionManagerProxy::GetFocusSessionToken(sptr &toke return static_cast(reply.ReadInt32()); } -WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName &element) +WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName& element) { WLOGFD("run SceneSessionManagerProxy::GetFocusSessionElement"); MessageParcel data; @@ -1005,15 +1005,14 @@ WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName WLOGFE("Write interfaceToken failed"); return WSError::WS_ERROR_IPC_FAILED; } - if (Remote()->SendRequest(static_cast(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_ELEMENT), data, reply, option) != ERR_NONE) { WLOGFE("SendRequest failed"); return WSError::WS_ERROR_IPC_FAILED; } - sptr el = reply.ReadParcelable(); - if (el) { - element = *el; + sptr ret = reply.ReadParcelable(); + if (ret) { + element = *ret; } else { WLOGFD("get element null."); } diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index e5966ea9d..a74aafd58 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -521,11 +521,11 @@ int SceneSessionManagerStub::HandleGetFocusSessionToken(MessageParcel &data, Mes return ERR_NONE; } -int SceneSessionManagerStub::HandleGetFocusSessionElement(MessageParcel &data, MessageParcel &reply) +int SceneSessionManagerStub::HandleGetFocusSessionElement(MessageParcel& data, MessageParcel& reply) { WLOGFD("run HandleGetFocusSessionElement!"); AppExecFwk::ElementName element; - const WSError& errCode = GetFocusSessionElement(element); + const WSError errCode = GetFocusSessionElement(element); reply.WriteParcelable(&element); reply.WriteInt32(static_cast(errCode)); return ERR_NONE; diff --git a/window_scene/test/unittest/scene_session_manager_stub_test.cpp b/window_scene/test/unittest/scene_session_manager_stub_test.cpp index e123228c4..84f1262e1 100644 --- a/window_scene/test/unittest/scene_session_manager_stub_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_stub_test.cpp @@ -179,7 +179,6 @@ HWTEST_F(SceneSessionManagerStubTest, HandleGetFocusSessionElement, Function | S { MessageParcel data; MessageParcel reply; - int res = stub_->HandleGetFocusSessionElement(data, reply); EXPECT_EQ(res, ERR_NONE); } -- Gitee From 9d41223c277723a76b63afb42590eda9912d7ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 19:06:35 +0800 Subject: [PATCH 343/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- window_scene/session_manager/include/scene_session_manager.h | 1 - 1 file changed, 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 dbdac3318..bc4ff6de3 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -193,7 +193,6 @@ public: WSError PendingSessionToBackgroundForDelegator(const sptr &token) override; WSError GetFocusSessionToken(sptr &token) override; WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override; - WSError RegisterSessionListener(const sptr& listener) override; WSError UnRegisterSessionListener(const sptr& listener) override; WSError GetSessionInfos(const std::string& deviceId, int32_t numMax, -- Gitee From 82a1ff09a746db7ed6a7f02a288a97dc30accca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 19:09:02 +0800 Subject: [PATCH 344/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- .../session_manager/src/zidl/scene_session_manager_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index a74aafd58..db5642884 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -525,7 +525,7 @@ int SceneSessionManagerStub::HandleGetFocusSessionElement(MessageParcel& data, M { WLOGFD("run HandleGetFocusSessionElement!"); AppExecFwk::ElementName element; - const WSError errCode = GetFocusSessionElement(element); + WSError errCode = GetFocusSessionElement(element); reply.WriteParcelable(&element); reply.WriteInt32(static_cast(errCode)); return ERR_NONE; -- Gitee From d8b6082d1efd51a675be5a52c9f6f2265ddfa199 Mon Sep 17 00:00:00 2001 From: l30030525 Date: Mon, 1 Apr 2024 19:21:17 +0800 Subject: [PATCH 345/385] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E4=BB=85=E5=AF=B9UIExtension=E5=88=9B=E5=BB=BA=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E9=89=B4=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- 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 ffd4edae8..39d31a2f1 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1749,8 +1749,8 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW) { + if (property->GetWindowType() == WindowType::WINDOW_TYPE_APP_SUB_WINDOW && + property->GetExtensionFlag() == true && SessionPermission::IsStartedByUIExtension()) { auto extensionParentSession = GetSceneSession(property->GetParentPersistentId()); SessionInfo sessionInfo = extensionParentSession->GetSessionInfo(); AAFwk::UIExtensionHostInfo hostInfo; -- Gitee From 610f9c258fe734a0a6066e64bdf31a0e0b8d1a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 19:27:40 +0800 Subject: [PATCH 346/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- window_scene/session_manager/src/scene_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c6ff523be..fbc86e0df 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6041,7 +6041,7 @@ WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName& ele auto sceneSession = GetSceneSession(focusedSessionId_); if (sceneSession) { auto sessionInfo = sceneSession->GetSessionInfo(); - element = ElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); + element = AppExecFwk::ElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); return WSError::WS_OK; } return WSError::WS_ERROR_INVALID_SESSION; -- Gitee From bc5d29da21a71085ac21dc33b6eea6b1392ed4b6 Mon Sep 17 00:00:00 2001 From: t30053014 <1180300204@alu.hit.edu.cn> Date: Mon, 1 Apr 2024 19:35:28 +0800 Subject: [PATCH 347/385] Signed-off-by: t30053014 <1180300204@alu.hit.edu.cn> modified: interfaces/innerkits/dm/dm_common.h modified: window_scene/session_manager/include/screen_session_manager.h modified: window_scene/session_manager/src/fold_screen_controller/dual_display_device_policy.cpp modified: window_scene/session_manager/src/screen_session_manager.cpp --- interfaces/innerkits/dm/dm_common.h | 1 + .../include/screen_session_manager.h | 2 +- .../dual_display_device_policy.cpp | 12 ++++---- .../src/screen_session_manager.cpp | 29 ++++++++++--------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index 4146730c1..29b8b47ee 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -66,6 +66,7 @@ enum class PowerStateChangeReason : uint32_t { STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_SUCCESS = 27, STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_ON = 28, STATE_CHANGE_REASON_PRE_BRIGHT_AUTH_FAIL_SCREEN_OFF = 29, + STATE_CHANGE_REASON_DISPLAY_SWITCH = 30, STATE_CHANGE_REASON_REMOTE = 100, STATE_CHANGE_REASON_UNKNOWN = 1000, }; diff --git a/window_scene/session_manager/include/screen_session_manager.h b/window_scene/session_manager/include/screen_session_manager.h index 5d12e5ad8..cbf4fcd5d 100644 --- a/window_scene/session_manager/include/screen_session_manager.h +++ b/window_scene/session_manager/include/screen_session_manager.h @@ -260,7 +260,7 @@ private: bool OnRemoteDied(const sptr& agent); std::string TransferTypeToString(ScreenType type) const; void CheckAndSendHiSysEvent(const std::string& eventName, const std::string& bundleName) const; - void HandlerSensor(ScreenPowerStatus status); + void HandlerSensor(ScreenPowerStatus status, PowerStateChangeReason reason); bool GetPowerStatus(ScreenPowerState state, PowerStateChangeReason reason, ScreenPowerStatus& status); // notify scb virtual screen change diff --git a/window_scene/session_manager/src/fold_screen_controller/dual_display_device_policy.cpp b/window_scene/session_manager/src/fold_screen_controller/dual_display_device_policy.cpp index a7152b9b3..69d48fab2 100644 --- a/window_scene/session_manager/src/fold_screen_controller/dual_display_device_policy.cpp +++ b/window_scene/session_manager/src/fold_screen_controller/dual_display_device_policy.cpp @@ -270,7 +270,7 @@ void DualDisplayDevicePolicy::ChangeScreenDisplayModeToMain(sptr screenId_ = SCREEN_ID_FULL; ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false); ScreenSessionManager::GetInstance().SetScreenPower(ScreenPowerStatus::POWER_STATUS_OFF, - PowerStateChangeReason::POWER_BUTTON); + PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH); }; screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMainOff, "screenOnMainOffTask"); SendPropertyChangeResult(screenSession, SCREEN_ID_MAIN, ScreenPropertyChangeReason::FOLD_SCREEN_FOLDING); @@ -280,7 +280,7 @@ void DualDisplayDevicePolicy::ChangeScreenDisplayModeToMain(sptr screenId_ = SCREEN_ID_MAIN; ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false); ScreenSessionManager::GetInstance().SetScreenPower(ScreenPowerStatus::POWER_STATUS_ON, - PowerStateChangeReason::POWER_BUTTON); + PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH); PowerMgr::PowerMgrClient::GetInstance().RefreshActivity(); }; screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnMainOn, "screenOnMainOnTask"); @@ -292,7 +292,7 @@ void DualDisplayDevicePolicy::ChangeScreenDisplayModeToMain(sptr screenId_ = SCREEN_ID_FULL; ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false); ScreenSessionManager::GetInstance().SetScreenPower(ScreenPowerStatus::POWER_STATUS_OFF, - PowerStateChangeReason::POWER_BUTTON); + PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH); }; screenPowerTaskScheduler_->PostAsyncTask(taskScreenOffMainOff, "screenOffMainOffTask"); SendPropertyChangeResult(screenSession, SCREEN_ID_MAIN, ScreenPropertyChangeReason::FOLD_SCREEN_FOLDING); @@ -322,7 +322,7 @@ void DualDisplayDevicePolicy::ChangeScreenDisplayModeToFull(sptr screenId_ = SCREEN_ID_MAIN; ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false); ScreenSessionManager::GetInstance().SetScreenPower(ScreenPowerStatus::POWER_STATUS_OFF, - PowerStateChangeReason::POWER_BUTTON); + PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH); }; screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnFullOff, "screenOnFullOffTask"); SendPropertyChangeResult(screenSession, SCREEN_ID_FULL, ScreenPropertyChangeReason::FOLD_SCREEN_EXPAND); @@ -332,7 +332,7 @@ void DualDisplayDevicePolicy::ChangeScreenDisplayModeToFull(sptr screenId_ = SCREEN_ID_FULL; ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false); ScreenSessionManager::GetInstance().SetScreenPower(ScreenPowerStatus::POWER_STATUS_ON, - PowerStateChangeReason::POWER_BUTTON); + PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH); PowerMgr::PowerMgrClient::GetInstance().RefreshActivity(); }; screenPowerTaskScheduler_->PostAsyncTask(taskScreenOnFullOn, "screenOnFullOnTask"); @@ -344,7 +344,7 @@ void DualDisplayDevicePolicy::ChangeScreenDisplayModeToFull(sptr screenId_ = SCREEN_ID_MAIN; ScreenSessionManager::GetInstance().SetKeyguardDrawnDoneFlag(false); ScreenSessionManager::GetInstance().SetScreenPower(ScreenPowerStatus::POWER_STATUS_OFF, - PowerStateChangeReason::POWER_BUTTON); + PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH); }; screenPowerTaskScheduler_->PostAsyncTask(taskScreenOffFullOff, "screenOffFullOffTask"); SendPropertyChangeResult(screenSession, SCREEN_ID_FULL, ScreenPropertyChangeReason::FOLD_SCREEN_EXPAND); diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index db3cdc0c4..d4f26ed42 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -1127,11 +1127,6 @@ bool ScreenSessionManager::GetPowerStatus(ScreenPowerState state, PowerStateChan WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON_ADVANCED"); } else { status = ScreenPowerStatus::POWER_STATUS_ON; - if (g_foldScreenFlag && FoldScreenSensorManager::GetInstance().allowPosture) { - FoldScreenSensorManager::GetInstance().RegisterPostureCallback(); - } else { - WLOGFI("Duplicate registration posture is not allowed."); - } WLOGFI("[UL_POWER]Set ScreenPowerStatus: POWER_STATUS_ON"); } break; @@ -1165,11 +1160,6 @@ bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateCh if (status == ScreenPowerStatus::POWER_STATUS_OFF) { taskScheduler_->RemoveTask("screenOnTask"); - if (g_foldScreenFlag && !FoldScreenSensorManager::GetInstance().allowPosture) { - OHOS::Rosen::FoldScreenSensorManager::GetInstance().UnRegisterPostureCallback(); - } else { - WLOGFI("Duplicate unregistration posture is not allowed."); - } } // Handling Power Button Conflicts @@ -1187,7 +1177,7 @@ bool ScreenSessionManager::SetScreenPower(ScreenPowerStatus status, PowerStateCh rsInterface_.SetScreenPowerStatus(screenId, status); } } - HandlerSensor(status); + HandlerSensor(status, reason); if (reason == PowerStateChangeReason::STATE_CHANGE_REASON_COLLABORATION) { return true; } @@ -1201,17 +1191,28 @@ void ScreenSessionManager::SetKeyguardDrawnDoneFlag(bool flag) keyguardDrawnDone_ = flag; } -void ScreenSessionManager::HandlerSensor(ScreenPowerStatus status) +void ScreenSessionManager::HandlerSensor(ScreenPowerStatus status, PowerStateChangeReason reason) { auto isPhone = system::GetParameter("const.product.devicetype", "unknown") == "phone"; auto isTablet = system::GetParameter("const.product.devicetype", "unknown") == "tablet"; if (isPhone || isTablet) { if (status == ScreenPowerStatus::POWER_STATUS_ON) { - WLOGFI("subscribe rotation sensor when phone turn on"); + WLOGFI("subscribe rotation and posture sensor when phone turn on"); ScreenSensorConnector::SubscribeRotationSensor(); + if (g_foldScreenFlag && FoldScreenSensorManager::GetInstance().allowPosture) { + FoldScreenSensorManager::GetInstance().RegisterPostureCallback(); + } else { + WLOGFI("Duplicate register posture is not allowed."); + } } else if (status == ScreenPowerStatus::POWER_STATUS_OFF || status == ScreenPowerStatus::POWER_STATUS_SUSPEND) { - WLOGFI("unsubscribe rotation sensor when phone turn off"); + WLOGFI("unsubscribe rotation and posture sensor when phone turn off"); ScreenSensorConnector::UnsubscribeRotationSensor(); + if (g_foldScreenFlag && !FoldScreenSensorManager::GetInstance().allowPosture && + reason != PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH) { + FoldScreenSensorManager::GetInstance().UnRegisterPostureCallback(); + } else { + WLOGFI("Duplicate unregister, or not fold product, switch screen reason, failed unregister posture."); + } } else { WLOGFI("SetScreenPower state not support"); } -- Gitee From 065150e35ee821fef2eacd1137343d43cf178285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=86=B2?= Date: Mon, 1 Apr 2024 19:42:30 +0800 Subject: [PATCH 348/385] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗冲 --- window_scene/session_manager/src/scene_session_manager.cpp | 3 ++- 1 file changed, 2 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 fbc86e0df..169411911 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6041,7 +6041,8 @@ WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName& ele auto sceneSession = GetSceneSession(focusedSessionId_); if (sceneSession) { auto sessionInfo = sceneSession->GetSessionInfo(); - element = AppExecFwk::ElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); + element = AppExecFwk::ElementName("", sessionInfo.bundleName_, + sessionInfo.abilityName_, sessionInfo.moduleName_); return WSError::WS_OK; } return WSError::WS_ERROR_INVALID_SESSION; -- Gitee From 22d565365daee289ad001e6e425edacb224a6df0 Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 20:07:30 +0800 Subject: [PATCH 349/385] =?UTF-8?q?=E7=94=BB=E4=B8=AD=E7=94=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangminghai <892696242@qq.com> --- wm/src/picture_in_picture_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wm/src/picture_in_picture_controller.cpp b/wm/src/picture_in_picture_controller.cpp index fa6cb82f1..55584e481 100644 --- a/wm/src/picture_in_picture_controller.cpp +++ b/wm/src/picture_in_picture_controller.cpp @@ -38,7 +38,7 @@ namespace { } static uint32_t GetPipPriority(uint32_t pipTemplateType) { - if (pipTemplateType < 0 || pipTemplateType >= static_cast(PiPTemplateType::END)) { + if (pipTemplateType >= static_cast(PiPTemplateType::END)) { TLOGE(WmsLogTag::WMS_PIP, "param invalid, pipTemplateType is %{public}d", pipTemplateType); return PIP_LOW_PRIORITY; } -- Gitee From fd3420a7efe5c2ce2c34b85524be8924e263c229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E7=80=9A=E6=9E=970424?= Date: Mon, 1 Apr 2024 12:54:24 +0000 Subject: [PATCH 350/385] update window_scene/test/unittest/session_stub_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 闫瀚林0424 --- window_scene/test/unittest/session_stub_test.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index b0fa43acb..ee0c208b1 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -299,7 +299,6 @@ HWTEST_F(SessionStubTest, HandleShow009, Function | SmallTest | Level2) MessageParcel data; MessageParcel reply; data.WriteBool(true); - sptr iRemoteObjectMocker = new IRemoteObjectMocker(); auto res = session_->HandleShow(data, reply); ASSERT_EQ(0, res); } @@ -315,7 +314,6 @@ HWTEST_F(SessionStubTest, HandleHide010, Function | SmallTest | Level2) MessageParcel data; MessageParcel reply; data.WriteBool(true); - sptr iRemoteObjectMocker = new IRemoteObjectMocker(); auto res = session_->HandleHide(data, reply); ASSERT_EQ(0, res); } @@ -331,7 +329,6 @@ HWTEST_F(SessionStubTest, HandlePendingSessionActivation011, Function | SmallTes MessageParcel data; MessageParcel reply; data.WriteBool(true); - sptr iRemoteObjectMocker = new IRemoteObjectMocker(); AAFwk::Want options; EXPECT_NE(data.WriteString("HandlePendingSessionActivation"), false); EXPECT_NE(data.WriteParcelable(&options), false); @@ -352,7 +349,6 @@ HWTEST_F(SessionStubTest, HandleNotifySyncOn012, Function | SmallTest | Level2) MessageParcel data; MessageParcel reply; data.WriteBool(true); - sptr iRemoteObjectMocker = new IRemoteObjectMocker(); auto res = session_->HandleNotifySyncOn(data, reply); ASSERT_EQ(0, res); } @@ -368,7 +364,6 @@ HWTEST_F(SessionStubTest, HandleNotifyAsyncOn013, Function | SmallTest | Level2) MessageParcel data; MessageParcel reply; data.WriteBool(true); - sptr iRemoteObjectMocker = new IRemoteObjectMocker(); auto res = session_->HandleNotifyAsyncOn(data, reply); ASSERT_EQ(0, res); } @@ -384,7 +379,6 @@ HWTEST_F(SessionStubTest, HandleNotifyExtensionTimeout014, Function | SmallTest MessageParcel data; MessageParcel reply; data.WriteBool(true); - sptr iRemoteObjectMocker = new IRemoteObjectMocker(); auto res = session_->HandleNotifyExtensionTimeout(data, reply); ASSERT_EQ(0, res); } -- Gitee From 295d312983a6e386a3e96e38e2965a48ed2dc4ec Mon Sep 17 00:00:00 2001 From: wangminghai <892696242@qq.com> Date: Mon, 1 Apr 2024 15:12:49 +0000 Subject: [PATCH 351/385] update interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp. Signed-off-by: wangminghai <892696242@qq.com> --- .../napi/picture_in_picture_napi/js_pip_window_manager.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp index 11cb75a02..3c6d53f18 100644 --- a/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp +++ b/interfaces/kits/napi/picture_in_picture_napi/js_pip_window_manager.cpp @@ -248,11 +248,6 @@ napi_value JsPipWindowManager::OnCreatePipController(napi_env env, napi_callback return; } sptr mainWindow = Window::GetMainWindowWithContext(context->lock()); - if (mainWindow == nullptr) { - task.Reject(env, CreateJsError(env, static_cast( - WMError::WM_ERROR_PIP_INTERNAL_ERROR), "mainWindow is nullptr.")); - return; - } sptr pipController = new PictureInPictureController(pipOptionPtr, mainWindow, mainWindow->GetWindowId(), env); task.Resolve(env, CreateJsPipControllerObject(env, pipController)); -- Gitee From ae225a856c8f04a46238d62cc105d42c22787f3d Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Tue, 2 Apr 2024 09:06:39 +0800 Subject: [PATCH 352/385] updata Signed-off-by: redking-zhong --- window_scene/session_manager/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index bea1625e5..adf81861a 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -304,7 +304,7 @@ ohos_shared_library("session_manager") { deps = [ "${window_base_path}/utils:libwmutil", ":session_manager_lite", - ] + ] public_external_deps = [ "ability_runtime:session_handler", "accessibility:accessibility_common", -- Gitee From 9292f3ba02fc1a6fe2f17e1123a8e98d35b2dc1b Mon Sep 17 00:00:00 2001 From: l30030525 Date: Tue, 2 Apr 2024 09:35:09 +0800 Subject: [PATCH 353/385] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E4=BB=85=E5=AF=B9UIExtension=E5=88=9B=E5=BB=BA=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E9=89=B4=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- .../common/src/session_permission.cpp | 11 +++---- .../src/scene_session_manager.cpp | 2 +- .../window_scene_session_impl_test.cpp | 32 +++++++++---------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/window_scene/common/src/session_permission.cpp b/window_scene/common/src/session_permission.cpp index 67bb8aaa4..3bb964132 100644 --- a/window_scene/common/src/session_permission.cpp +++ b/window_scene/common/src/session_permission.cpp @@ -237,8 +237,8 @@ bool SessionPermission::IsSameBundleNameAsCalling(const std::string& bundleName) bool SessionPermission::IsStartedByUIExtension() { - auto bundleManagerServiceProxy_ = GetBundleManagerProxy(); - if (!bundleManagerServiceProxy_) { + auto bundleManagerServiceProxy = GetBundleManagerProxy(); + if (!bundleManagerServiceProxy) { WLOGFE("failed to get BundleManagerServiceProxy"); return false; } @@ -247,11 +247,10 @@ bool SessionPermission::IsStartedByUIExtension() // reset ipc identity std::string identity = IPCSkeleton::ResetCallingIdentity(); std::string bundleName; - bundleManagerServiceProxy_->GetNameForUid(uid, bundleName); + bundleManagerServiceProxy->GetNameForUid(uid, bundleName); AppExecFwk::BundleInfo bundleInfo; - // 200000 use uid to caculate userId - int userId = uid / 200000; - bool result = bundleManagerServiceProxy_->GetBundleInfo(bundleName, + int userId = uid / 200000; // 200000 use uid to caculate userId + bool result = bundleManagerServiceProxy->GetBundleInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO, bundleInfo, userId); // set ipc identity to raw IPCSkeleton::SetCallingIdentity(identity); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 39d31a2f1..0c6afabfb 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1756,7 +1756,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetUIExtensionRootHostInfo(token, hostInfo); if (sessionInfo.bundleName_ != hostInfo.elementName_.GetBundleName()) { - WLOGE("The hostWindow is not thie parentwindow ! parentwindow bundleName: %{public}s, " + WLOGE("The hostWindow is not this parentwindow ! parentwindow bundleName: %{public}s, " "hostwindow bundleName: %{public}s", sessionInfo.bundleName_.c_str(), hostInfo.elementName_.GetBundleName().c_str()); return WSError::WS_ERROR_INVALID_WINDOW; diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 8187630e3..59eef89e6 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -173,26 +173,26 @@ HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession02, Function */ HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession03, Function | SmallTest | Level2) { - sptr option_ = new (std::nothrow) WindowOption(); - option_->SetWindowTag(WindowTag::SUB_WINDOW); - option_->SetWindowName("ChildWindow0003"); - option_->SetExtensionTag(true); - sptr parentscenesession_ = new (std::nothrow) WindowSceneSessionImpl(option_); - ASSERT_NE(nullptr, parentscenesession_); + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowTag(WindowTag::SUB_WINDOW); + option->SetWindowName("ChildWindow0003"); + option->SetExtensionTag(true); + sptr parentSceneSession = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, parentSceneSession); SessionInfo sessionInfo_ = { "CreateTestBundle0", "CreateTestModule0", "CreateTestAbility0" }; - sptr session_ = new (std::nothrow) SessionMocker(sessionInfo_); - ASSERT_NE(nullptr, session_); - ASSERT_EQ(WMError::WM_OK, parentscenesession_->Create(abilityContext_, session_)); + sptr session = new (std::nothrow) SessionMocker(sessionInfo_); + ASSERT_NE(nullptr, session); + ASSERT_EQ(WMError::WM_OK, parentSceneSession->Create(abilityContext_, session)); - parentscenesession_->property_->SetParentPersistentId(102); - parentscenesession_->property_->SetParentId(102); - parentscenesession_->property_->type_ = WindowType::APP_MAIN_WINDOW_BASE; - parentscenesession_->hostSession_ = session_; + parentSceneSession->property_->SetParentPersistentId(102); + parentSceneSession->property_->SetParentId(102); + parentSceneSession->property_->type_ = WindowType::APP_MAIN_WINDOW_BASE; + parentSceneSession->hostSession_ = session; - parentscenesession_->property_->type_ = WindowType::APP_SUB_WINDOW_BASE; - if (parentscenesession_->CreateAndConnectSpecificSession() == WMError::WM_OK) { - ASSERT_EQ(WMError::WM_OK, parentscenesession_->CreateAndConnectSpecificSession()); + parentSceneSession->property_->type_ = WindowType::APP_SUB_WINDOW_BASE; + if (parentSceneSession->CreateAndConnectSpecificSession() == WMError::WM_OK) { + ASSERT_EQ(WMError::WM_OK, parentSceneSession->CreateAndConnectSpecificSession()); } } -- Gitee From 8b617ecdd0f0b22eca59ba7938666a6b0999cf42 Mon Sep 17 00:00:00 2001 From: l30030525 Date: Tue, 2 Apr 2024 09:38:24 +0800 Subject: [PATCH 354/385] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E4=BB=85=E5=AF=B9UIExtension=E5=88=9B=E5=BB=BA=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E9=89=B4=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- wm/test/unittest/window_scene_session_impl_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 59eef89e6..2ef79af12 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -180,8 +180,8 @@ HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession03, Function sptr parentSceneSession = new (std::nothrow) WindowSceneSessionImpl(option); ASSERT_NE(nullptr, parentSceneSession); - SessionInfo sessionInfo_ = { "CreateTestBundle0", "CreateTestModule0", "CreateTestAbility0" }; - sptr session = new (std::nothrow) SessionMocker(sessionInfo_); + SessionInfo sessionInfo = { "CreateTestBundle0", "CreateTestModule0", "CreateTestAbility0" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); ASSERT_NE(nullptr, session); ASSERT_EQ(WMError::WM_OK, parentSceneSession->Create(abilityContext_, session)); -- Gitee From 59eda5daf4069bc64d2f4d9140f2e8cc25c08e37 Mon Sep 17 00:00:00 2001 From: s30053401 Date: Tue, 2 Apr 2024 10:18:47 +0800 Subject: [PATCH 355/385] =?UTF-8?q?=E5=A2=9E=E5=8A=A0RegisterWindowModeCha?= =?UTF-8?q?ngedListener=E5=92=8CUnregisterWindowModeChangedListener?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- bundle.json | 1 + interfaces/innerkits/wm/window_manager_lite.h | 15 ++++ .../include/scene_session_manager_lite.h | 1 + .../src/scene_session_manager_lite.cpp | 6 ++ wm/BUILD.gn | 4 +- wm/include/window_manager_agent_lite.h | 1 + wm/src/window_manager_agent_lite.cpp | 5 ++ wm/src/window_manager_lite.cpp | 70 +++++++++++++++++++ 8 files changed, 101 insertions(+), 2 deletions(-) diff --git a/bundle.json b/bundle.json index 9eeccc465..c232b02e1 100755 --- a/bundle.json +++ b/bundle.json @@ -133,6 +133,7 @@ "header_files": [ "window_accessibility_controller.h", "window_manager.h", + "window_manager_lite.h", "window_option.h", "wm_common.h", "occupied_area_change_info.h" diff --git a/interfaces/innerkits/wm/window_manager_lite.h b/interfaces/innerkits/wm/window_manager_lite.h index 24d43a5fc..b39c8d045 100644 --- a/interfaces/innerkits/wm/window_manager_lite.h +++ b/interfaces/innerkits/wm/window_manager_lite.h @@ -98,6 +98,20 @@ public: * @return WM_OK means unregister success, others means unregister failed. */ WMError UnregisterDrawingContentChangedListener(const sptr& listener); + /** + * @brief Register window mode listener. + * + * @param listener IWindowModeChangedListener. + * @return WM_OK means register success, others means register failed. + */ + WMError RegisterWindowModeChangedListener(const sptr& listener); + /** + * @brief Unregister window mode listener. + * + * @param listener IWindowModeChangedListener. + * @return WM_OK means unregister success, others means unregister failed. + */ + WMError UnregisterWindowModeChangedListener(const sptr& listener); private: WindowManagerLite(); ~WindowManagerLite(); @@ -113,6 +127,7 @@ private: const std::vector>& windowVisibilityInfos) const; void UpdateWindowDrawingContentInfo( const std::vector>& windowDrawingContentInfos) const; + void UpdateWindowModeTypeInfo(WindowModeType type) const; void OnRemoteDied(); }; } // namespace Rosen diff --git a/window_scene/session_manager/include/scene_session_manager_lite.h b/window_scene/session_manager/include/scene_session_manager_lite.h index c9ab0c186..99132bba4 100644 --- a/window_scene/session_manager/include/scene_session_manager_lite.h +++ b/window_scene/session_manager/include/scene_session_manager_lite.h @@ -56,6 +56,7 @@ public: const sptr& windowManagerAgent) override; WMError CheckWindowId(int32_t windowId, int32_t &pid) override; WMError GetVisibilityWindowInfo(std::vector>& infos) override; + WSError UpdateWindowMode(int32_t persistentId, int32_t windowMode); protected: SceneSessionManagerLite() = default; diff --git a/window_scene/session_manager/src/scene_session_manager_lite.cpp b/window_scene/session_manager/src/scene_session_manager_lite.cpp index b50b0364d..1fc5436e3 100644 --- a/window_scene/session_manager/src/scene_session_manager_lite.cpp +++ b/window_scene/session_manager/src/scene_session_manager_lite.cpp @@ -180,4 +180,10 @@ WMError SceneSessionManagerLite::GetVisibilityWindowInfo(std::vector>& infos, WindowUpdateType type) override {}; void UpdateWindowVisibilityInfo(const std::vector>& visibilityInfos) override; + void UpdateWindowModeTypeInfo(WindowModeType type) override; void UpdateWindowDrawingContentInfo( const std::vector>& windowDrawingContentInfos) override; void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override {}; diff --git a/wm/src/window_manager_agent_lite.cpp b/wm/src/window_manager_agent_lite.cpp index 2af8c686d..8b85caa93 100644 --- a/wm/src/window_manager_agent_lite.cpp +++ b/wm/src/window_manager_agent_lite.cpp @@ -37,5 +37,10 @@ void WindowManagerAgentLite::UpdateWindowDrawingContentInfo( SingletonContainer::Get().UpdateWindowDrawingContentInfo(windowDrawingContentInfos); } +void WindowManagerAgentLite::UpdateWindowModeTypeInfo(WindowModeType type) +{ + SingletonContainer::Get().UpdateWindowModeTypeInfo(type); +} + } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index f67c144f1..21d3ee1e3 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -52,6 +52,7 @@ public: void NotifyWindowVisibilityInfoChanged(const std::vector>& windowVisibilityInfos); void NotifyWindowDrawingContentInfoChanged(const std::vector>& windowDrawingContentInfos); + void NotifyWindowModeChange(WindowModeType type); static inline SingletonDelegator delegator_; @@ -64,6 +65,8 @@ public: sptr windowVisibilityListenerAgent_; std::vector> windowDrawingContentListeners_; sptr windowDrawingContentListenerAgent_; + std::vector> windowModeListeners_; + sptr windowModeListenerAgent_; }; void WindowManagerLite::Impl::NotifyFocused(const sptr& focusChangeInfo) @@ -144,6 +147,20 @@ void WindowManagerLite::Impl::NotifyWindowDrawingContentInfoChanged( } } +void WindowManagerLite::Impl::NotifyWindowModeChange(WindowModeType type) +{ + TLOGI(WmsLogTag::WMS_MAIN, "WindowManager::Impl UpdateWindowModeTypeInfo type: %{public}d", + static_cast(type)); + std::vector> windowModeListeners; + { + std::lock_guard lock(mutex_); + windowModeListeners = windowModeListeners_; + } + for (auto &listener : windowModeListeners) { + listener->OnWindowModeUpdate(type); + } +} + WindowManagerLite::WindowManagerLite() : pImpl_(std::make_unique(mutex_)) { auto windowChecker = std::make_shared(); @@ -380,5 +397,58 @@ WMError WindowManagerLite::UnregisterDrawingContentChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + TLOGE(WmsLogTag::WMS_MAIN, "listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + + std::lock_guard lock(pImpl_->mutex_); + WMError ret = WMError::WM_OK; + if (pImpl_->windowModeListenerAgent_ == nullptr) { + pImpl_->windowModeListenerAgent_ = new (std::nothrow) WindowManagerAgentLite(); + } + ret = SingletonContainer::Get().RegisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE, pImpl_->windowModeListenerAgent_); + if (ret != WMError::WM_OK) { + TLOGW(WmsLogTag::WMS_MAIN, "RegisterWindowManagerAgent failed!"); + pImpl_->windowModeListenerAgent_ = nullptr; + return ret; + } + auto iter = std::find(pImpl_->windowModeListeners_.begin(), pImpl_->windowModeListeners_.end(), listener); + if (iter != pImpl_->windowModeListeners_.end()) { + TLOGW(WmsLogTag::WMS_MAIN, "Listener is already registered."); + return WMError::WM_OK; + } + pImpl_->windowModeListeners_.push_back(listener); + return ret; +} + +WMError WindowManagerLite::UnregisterWindowModeChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + TLOGE(WmsLogTag::WMS_MAIN, "listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + + std::lock_guard lock(pImpl_->mutex_); + auto iter = std::find(pImpl_->windowModeListeners_.begin(), pImpl_->windowModeListeners_.end(), listener); + if (iter == pImpl_->windowModeListeners_.end()) { + TLOGE(WmsLogTag::WMS_MAIN, "could not find this listener"); + return WMError::WM_OK; + } + pImpl_->windowModeListeners_.erase(iter); + WMError ret = WMError::WM_OK; + if (pImpl_->windowModeListeners_.empty() && pImpl_->windowModeListenerAgent_ != nullptr) { + ret = SingletonContainer::Get().UnregisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE, pImpl_->windowModeListenerAgent_); + if (ret == WMError::WM_OK) { + pImpl_->windowModeListenerAgent_ = nullptr; + } + } + return ret; +} + } // namespace Rosen } // namespace OHOS -- Gitee From feb21e791506d8c817f65f6f07034118af4d2de0 Mon Sep 17 00:00:00 2001 From: s30053401 Date: Tue, 2 Apr 2024 10:18:47 +0800 Subject: [PATCH 356/385] =?UTF-8?q?=E5=A2=9E=E5=8A=A0RegisterWindowModeCha?= =?UTF-8?q?ngedListener=E5=92=8CUnregisterWindowModeChangedListener?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙健 --- bundle.json | 1 + interfaces/innerkits/wm/window_manager_lite.h | 15 ++++ .../include/scene_session_manager_lite.h | 1 + .../src/scene_session_manager_lite.cpp | 6 ++ wm/BUILD.gn | 4 +- wm/include/window_manager_agent_lite.h | 1 + wm/src/window_manager_agent_lite.cpp | 5 ++ wm/src/window_manager_lite.cpp | 70 +++++++++++++++++++ 8 files changed, 101 insertions(+), 2 deletions(-) diff --git a/bundle.json b/bundle.json index 9eeccc465..c232b02e1 100755 --- a/bundle.json +++ b/bundle.json @@ -133,6 +133,7 @@ "header_files": [ "window_accessibility_controller.h", "window_manager.h", + "window_manager_lite.h", "window_option.h", "wm_common.h", "occupied_area_change_info.h" diff --git a/interfaces/innerkits/wm/window_manager_lite.h b/interfaces/innerkits/wm/window_manager_lite.h index 24d43a5fc..b39c8d045 100644 --- a/interfaces/innerkits/wm/window_manager_lite.h +++ b/interfaces/innerkits/wm/window_manager_lite.h @@ -98,6 +98,20 @@ public: * @return WM_OK means unregister success, others means unregister failed. */ WMError UnregisterDrawingContentChangedListener(const sptr& listener); + /** + * @brief Register window mode listener. + * + * @param listener IWindowModeChangedListener. + * @return WM_OK means register success, others means register failed. + */ + WMError RegisterWindowModeChangedListener(const sptr& listener); + /** + * @brief Unregister window mode listener. + * + * @param listener IWindowModeChangedListener. + * @return WM_OK means unregister success, others means unregister failed. + */ + WMError UnregisterWindowModeChangedListener(const sptr& listener); private: WindowManagerLite(); ~WindowManagerLite(); @@ -113,6 +127,7 @@ private: const std::vector>& windowVisibilityInfos) const; void UpdateWindowDrawingContentInfo( const std::vector>& windowDrawingContentInfos) const; + void UpdateWindowModeTypeInfo(WindowModeType type) const; void OnRemoteDied(); }; } // namespace Rosen diff --git a/window_scene/session_manager/include/scene_session_manager_lite.h b/window_scene/session_manager/include/scene_session_manager_lite.h index c9ab0c186..99132bba4 100644 --- a/window_scene/session_manager/include/scene_session_manager_lite.h +++ b/window_scene/session_manager/include/scene_session_manager_lite.h @@ -56,6 +56,7 @@ public: const sptr& windowManagerAgent) override; WMError CheckWindowId(int32_t windowId, int32_t &pid) override; WMError GetVisibilityWindowInfo(std::vector>& infos) override; + WSError UpdateWindowMode(int32_t persistentId, int32_t windowMode); protected: SceneSessionManagerLite() = default; diff --git a/window_scene/session_manager/src/scene_session_manager_lite.cpp b/window_scene/session_manager/src/scene_session_manager_lite.cpp index b50b0364d..107120f1a 100644 --- a/window_scene/session_manager/src/scene_session_manager_lite.cpp +++ b/window_scene/session_manager/src/scene_session_manager_lite.cpp @@ -180,4 +180,10 @@ WMError SceneSessionManagerLite::GetVisibilityWindowInfo(std::vector>& infos, WindowUpdateType type) override {}; void UpdateWindowVisibilityInfo(const std::vector>& visibilityInfos) override; + void UpdateWindowModeTypeInfo(WindowModeType type) override; void UpdateWindowDrawingContentInfo( const std::vector>& windowDrawingContentInfos) override; void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override {}; diff --git a/wm/src/window_manager_agent_lite.cpp b/wm/src/window_manager_agent_lite.cpp index 2af8c686d..8b85caa93 100644 --- a/wm/src/window_manager_agent_lite.cpp +++ b/wm/src/window_manager_agent_lite.cpp @@ -37,5 +37,10 @@ void WindowManagerAgentLite::UpdateWindowDrawingContentInfo( SingletonContainer::Get().UpdateWindowDrawingContentInfo(windowDrawingContentInfos); } +void WindowManagerAgentLite::UpdateWindowModeTypeInfo(WindowModeType type) +{ + SingletonContainer::Get().UpdateWindowModeTypeInfo(type); +} + } // namespace Rosen } // namespace OHOS diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index f67c144f1..21d3ee1e3 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -52,6 +52,7 @@ public: void NotifyWindowVisibilityInfoChanged(const std::vector>& windowVisibilityInfos); void NotifyWindowDrawingContentInfoChanged(const std::vector>& windowDrawingContentInfos); + void NotifyWindowModeChange(WindowModeType type); static inline SingletonDelegator delegator_; @@ -64,6 +65,8 @@ public: sptr windowVisibilityListenerAgent_; std::vector> windowDrawingContentListeners_; sptr windowDrawingContentListenerAgent_; + std::vector> windowModeListeners_; + sptr windowModeListenerAgent_; }; void WindowManagerLite::Impl::NotifyFocused(const sptr& focusChangeInfo) @@ -144,6 +147,20 @@ void WindowManagerLite::Impl::NotifyWindowDrawingContentInfoChanged( } } +void WindowManagerLite::Impl::NotifyWindowModeChange(WindowModeType type) +{ + TLOGI(WmsLogTag::WMS_MAIN, "WindowManager::Impl UpdateWindowModeTypeInfo type: %{public}d", + static_cast(type)); + std::vector> windowModeListeners; + { + std::lock_guard lock(mutex_); + windowModeListeners = windowModeListeners_; + } + for (auto &listener : windowModeListeners) { + listener->OnWindowModeUpdate(type); + } +} + WindowManagerLite::WindowManagerLite() : pImpl_(std::make_unique(mutex_)) { auto windowChecker = std::make_shared(); @@ -380,5 +397,58 @@ WMError WindowManagerLite::UnregisterDrawingContentChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + TLOGE(WmsLogTag::WMS_MAIN, "listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + + std::lock_guard lock(pImpl_->mutex_); + WMError ret = WMError::WM_OK; + if (pImpl_->windowModeListenerAgent_ == nullptr) { + pImpl_->windowModeListenerAgent_ = new (std::nothrow) WindowManagerAgentLite(); + } + ret = SingletonContainer::Get().RegisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE, pImpl_->windowModeListenerAgent_); + if (ret != WMError::WM_OK) { + TLOGW(WmsLogTag::WMS_MAIN, "RegisterWindowManagerAgent failed!"); + pImpl_->windowModeListenerAgent_ = nullptr; + return ret; + } + auto iter = std::find(pImpl_->windowModeListeners_.begin(), pImpl_->windowModeListeners_.end(), listener); + if (iter != pImpl_->windowModeListeners_.end()) { + TLOGW(WmsLogTag::WMS_MAIN, "Listener is already registered."); + return WMError::WM_OK; + } + pImpl_->windowModeListeners_.push_back(listener); + return ret; +} + +WMError WindowManagerLite::UnregisterWindowModeChangedListener(const sptr& listener) +{ + if (listener == nullptr) { + TLOGE(WmsLogTag::WMS_MAIN, "listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + + std::lock_guard lock(pImpl_->mutex_); + auto iter = std::find(pImpl_->windowModeListeners_.begin(), pImpl_->windowModeListeners_.end(), listener); + if (iter == pImpl_->windowModeListeners_.end()) { + TLOGE(WmsLogTag::WMS_MAIN, "could not find this listener"); + return WMError::WM_OK; + } + pImpl_->windowModeListeners_.erase(iter); + WMError ret = WMError::WM_OK; + if (pImpl_->windowModeListeners_.empty() && pImpl_->windowModeListenerAgent_ != nullptr) { + ret = SingletonContainer::Get().UnregisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_MODE, pImpl_->windowModeListenerAgent_); + if (ret == WMError::WM_OK) { + pImpl_->windowModeListenerAgent_ = nullptr; + } + } + return ret; +} + } // namespace Rosen } // namespace OHOS -- Gitee From 1c6fb6fe1eab441837075b852798a2db779ade99 Mon Sep 17 00:00:00 2001 From: l30030525 Date: Tue, 2 Apr 2024 10:23:11 +0800 Subject: [PATCH 357/385] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=AE=BF=E4=B8=BB?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BD=8D=E7=BD=AE=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- window_scene/session_manager/src/scene_session_manager.cpp | 6 +++--- .../src/zidl/scene_session_manager_proxy.cpp | 2 +- .../session_manager/src/zidl/scene_session_manager_stub.cpp | 4 ++-- wm/include/window_adapter.h | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index b21aacc07..352f361fc 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7458,7 +7458,7 @@ void SceneSessionManager::ReportWindowProfileInfos() WSError SceneSessionManager::GetHostWindowRect(int32_t hostWindowId, Rect& rect) { - TLOGI(WmsLogTag::WMS_UIEXT, "GetHostWindowRect, hostWindowId:%{public}d", hostWindowId); + TLOGI(WmsLogTag::WMS_UIEXT, "hostWindowId:%{public}d", hostWindowId); if (!SessionPermission::IsSystemCalling()) { TLOGE(WmsLogTag::WMS_UIEXT, "GetHostWindowRect permission denied!"); return WSError::WS_ERROR_NOT_SYSTEM_APP; @@ -7469,8 +7469,8 @@ WSError SceneSessionManager::GetHostWindowRect(int32_t hostWindowId, Rect& rect) TLOGE(WmsLogTag::WMS_UIEXT, "Session with persistentId %{public}d not found", hostWindowId); return WSError::WS_ERROR_INVALID_SESSION; } - WSRect persrect = sceneSession->GetSessionRect(); - rect = {persrect.posX_, persrect.posY_, persrect.width_, persrect.height_ }; + WSRect hostsrect = sceneSession->GetSessionRect(); + rect = {hostsrect.posX_, hostsrect.posY_, hostsrect.width_, hostsrect.height_}; return WSError::WS_OK; }; taskScheduler_->PostSyncTask(task, "GetHostWindowRect"); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index faaee7da5..0291191ef 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -1589,7 +1589,7 @@ WSError SceneSessionManagerProxy::GetHostWindowRect(int32_t hostWindowId, Rect& TLOGD(WmsLogTag::WMS_UIEXT, "run SceneSessionManagerProxy::GetHostWindowRect"); MessageParcel data; MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); + MessageOption option; if (!data.WriteInterfaceToken(GetDescriptor())) { TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed."); return WSError::WS_ERROR_IPC_FAILED; diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index f2fd60200..280617037 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -846,9 +846,9 @@ int SceneSessionManagerStub::HandleUpdateExtWindowFlags(MessageParcel &data, Mes return ERR_NONE; } -int SceneSessionManagerStub::HandleGetHostWindowRect(MessageParcel &data, MessageParcel &reply) +int SceneSessionManagerStub::HandleGetHostWindowRect(MessageParcel& data, MessageParcel& reply) { - TLOGI(WmsLogTag::WMS_UIEXT, "run HandleGetHostWindowRect!"); + TLOGD(WmsLogTag::WMS_UIEXT, "run HandleGetHostWindowRect!"); int32_t hostWindowId = data.ReadInt32(); Rect rect; WSError ret = GetHostWindowRect(hostWindowId, rect); diff --git a/wm/include/window_adapter.h b/wm/include/window_adapter.h index 77c2b2817..e72c4b5bd 100644 --- a/wm/include/window_adapter.h +++ b/wm/include/window_adapter.h @@ -120,6 +120,7 @@ public: virtual WMError AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide); virtual WMError UpdateExtWindowFlags(int32_t parentId, int32_t persistentId, uint32_t extWindowFlags); virtual WMError GetHostWindowRect(int32_t hostWindowId, Rect& rect); + private: static inline SingletonDelegator delegator; bool InitWMSProxy(); -- Gitee From 855ab7418552714ff962fbd885776b2e750f5a2e Mon Sep 17 00:00:00 2001 From: l30030525 Date: Tue, 2 Apr 2024 10:31:09 +0800 Subject: [PATCH 358/385] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=AE=BF=E4=B8=BB?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BD=8D=E7=BD=AE=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- 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 04b9f6bce..1e1c0d783 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7477,8 +7477,8 @@ WSError SceneSessionManager::GetHostWindowRect(int32_t hostWindowId, Rect& rect) TLOGE(WmsLogTag::WMS_UIEXT, "Session with persistentId %{public}d not found", hostWindowId); return WSError::WS_ERROR_INVALID_SESSION; } - WSRect hostsrect = sceneSession->GetSessionRect(); - rect = {hostsrect.posX_, hostsrect.posY_, hostsrect.width_, hostsrect.height_}; + WSRect hostRect = sceneSession->GetSessionRect(); + rect = {hostRect.posX_, hostRect.posY_, hostRect.width_, hostRect.height_}; return WSError::WS_OK; }; taskScheduler_->PostSyncTask(task, "GetHostWindowRect"); -- Gitee From bed86a69ba644e6a16659a36bbb16db5e0a71de3 Mon Sep 17 00:00:00 2001 From: l30030525 Date: Tue, 2 Apr 2024 10:33:25 +0800 Subject: [PATCH 359/385] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=AE=BF=E4=B8=BB?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BD=8D=E7=BD=AE=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30030525 --- .../src/zidl/scene_session_manager_proxy.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index 0291191ef..67921fbcb 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -1604,11 +1604,11 @@ WSError SceneSessionManagerProxy::GetHostWindowRect(int32_t hostWindowId, Rect& TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest GetHostWindowRect failed"); return WSError::WS_ERROR_IPC_FAILED; } - auto PosX = reply.ReadInt32(); - auto PosY = reply.ReadInt32(); + auto posX = reply.ReadInt32(); + auto posY = reply.ReadInt32(); auto height = reply.ReadUint32(); auto width = reply.ReadUint32(); - rect = {PosX, PosY, height, width}; + rect = {posX, posY, height, width}; return static_cast(reply.ReadInt32()); } } // namespace OHOS::Rosen -- Gitee From e93ea4f5b4fa9a167653c7fc3e286e89247c3f01 Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Tue, 2 Apr 2024 10:40:33 +0800 Subject: [PATCH 360/385] updata Signed-off-by: redking-zhong --- window_scene/session_manager/src/session_manager_lite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/src/session_manager_lite.cpp b/window_scene/session_manager/src/session_manager_lite.cpp index 664e7112b..bd7d449a5 100644 --- a/window_scene/session_manager/src/session_manager_lite.cpp +++ b/window_scene/session_manager/src/session_manager_lite.cpp @@ -142,7 +142,7 @@ sptr SessionManagerLite::GetSessionManagerServiceProxy() { std::lock_guard lock(mutex_); InitSessionManagerServiceProxy(); - return SessionManagerServiceProxy_; + return sessionManagerServiceProxy_; } void SessionManagerLite::SaveSessionListener(const sptr& listener) -- Gitee From d14b6e50a919326f1511f2d75d710ed15a0d449c Mon Sep 17 00:00:00 2001 From: t30053014 <1180300204@alu.hit.edu.cn> Date: Tue, 2 Apr 2024 10:39:33 +0800 Subject: [PATCH 361/385] Signed-off-by: t30053014 <1180300204@alu.hit.edu.cn> modified: window_scene/session_manager/include/fold_screen_controller/fold_screen_sensor_manager.h modified: window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp modified: window_scene/session_manager/src/screen_session_manager.cpp --- .../fold_screen_sensor_manager.h | 4 +- .../fold_screen_sensor_manager.cpp | 46 ++++++++++--------- .../src/screen_session_manager.cpp | 9 ++-- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/window_scene/session_manager/include/fold_screen_controller/fold_screen_sensor_manager.h b/window_scene/session_manager/include/fold_screen_controller/fold_screen_sensor_manager.h index 1be4f3ceb..b5b06b987 100644 --- a/window_scene/session_manager/include/fold_screen_controller/fold_screen_sensor_manager.h +++ b/window_scene/session_manager/include/fold_screen_controller/fold_screen_sensor_manager.h @@ -46,8 +46,6 @@ public: void HandleHallData(const SensorEvent * const event); - bool allowPosture = true; - private: sptr foldScreenPolicy_; @@ -79,6 +77,8 @@ private: uint16_t globalHall = USHRT_MAX; + bool allowPosture_ = true; + typedef struct EXTHALLData { float flag = 0.0; float hall = 0.0; diff --git a/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp b/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp index e270204b8..7864f66e9 100644 --- a/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp +++ b/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp @@ -59,11 +59,7 @@ WM_IMPLEMENT_SINGLE_INSTANCE(FoldScreenSensorManager); FoldScreenSensorManager::FoldScreenSensorManager() { - if (allowPosture) { - RegisterPostureCallback(); - } else { - WLOGFI("Duplicate registration posture is not allowed."); - } + RegisterPostureCallback(); RegisterHallCallback(); } @@ -74,28 +70,36 @@ void FoldScreenSensorManager::SetFoldScreenPolicy(sptr foldScr void FoldScreenSensorManager::RegisterPostureCallback() { - postureUser.callback = SensorPostureDataCallback; - int32_t subscribeRet = SubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); - WLOGFI("RegisterPostureCallback, subscribeRet: %{public}d", subscribeRet); - int32_t setBatchRet = SetBatch(SENSOR_TYPE_ID_POSTURE, &postureUser, POSTURE_INTERVAL, POSTURE_INTERVAL); - WLOGFI("RegisterPostureCallback, setBatchRet: %{public}d", setBatchRet); - int32_t activateRet = ActivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); - WLOGFI("RegisterPostureCallback, activateRet: %{public}d", activateRet); - if (subscribeRet != SENSOR_SUCCESS || setBatchRet != SENSOR_SUCCESS || activateRet != SENSOR_SUCCESS) { - WLOGFE("RegisterPostureCallback failed."); + if (allowPosture_) { + postureUser.callback = SensorPostureDataCallback; + int32_t subscribeRet = SubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); + WLOGFI("RegisterPostureCallback, subscribeRet: %{public}d", subscribeRet); + int32_t setBatchRet = SetBatch(SENSOR_TYPE_ID_POSTURE, &postureUser, POSTURE_INTERVAL, POSTURE_INTERVAL); + WLOGFI("RegisterPostureCallback, setBatchRet: %{public}d", setBatchRet); + int32_t activateRet = ActivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); + WLOGFI("RegisterPostureCallback, activateRet: %{public}d", activateRet); + if (subscribeRet != SENSOR_SUCCESS || setBatchRet != SENSOR_SUCCESS || activateRet != SENSOR_SUCCESS) { + WLOGFE("RegisterPostureCallback failed."); + } else { + allowPosture_ = false; + WLOGFI("FoldScreenSensorManager.RegisterPostureCallback success."); + } } else { - allowPosture = false; - WLOGFI("FoldScreenSensorManager.RegisterPostureCallback success."); + WLOGFI("Duplicate register posture is not allowed."); } } void FoldScreenSensorManager::UnRegisterPostureCallback() { - int32_t deactivateRet = DeactivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); - int32_t unsubscribeRet = UnsubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); - if (deactivateRet == SENSOR_SUCCESS && unsubscribeRet == SENSOR_SUCCESS) { - allowPosture = true; - WLOGFI("FoldScreenSensorManager.UnRegisterPostureCallback success."); + if (!allowPosture_) { + int32_t deactivateRet = DeactivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); + int32_t unsubscribeRet = UnsubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); + if (deactivateRet == SENSOR_SUCCESS && unsubscribeRet == SENSOR_SUCCESS) { + allowPosture_ = true; + WLOGFI("FoldScreenSensorManager.UnRegisterPostureCallback success."); + } + } else { + WLOGFI("Duplicate unregister posture is not allowed."); } } diff --git a/window_scene/session_manager/src/screen_session_manager.cpp b/window_scene/session_manager/src/screen_session_manager.cpp index d4f26ed42..c35a023b7 100644 --- a/window_scene/session_manager/src/screen_session_manager.cpp +++ b/window_scene/session_manager/src/screen_session_manager.cpp @@ -1199,19 +1199,18 @@ void ScreenSessionManager::HandlerSensor(ScreenPowerStatus status, PowerStateCha if (status == ScreenPowerStatus::POWER_STATUS_ON) { WLOGFI("subscribe rotation and posture sensor when phone turn on"); ScreenSensorConnector::SubscribeRotationSensor(); - if (g_foldScreenFlag && FoldScreenSensorManager::GetInstance().allowPosture) { + if (g_foldScreenFlag && reason != PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH) { FoldScreenSensorManager::GetInstance().RegisterPostureCallback(); } else { - WLOGFI("Duplicate register posture is not allowed."); + WLOGFI("not fold product, switch screen reason, failed register posture."); } } else if (status == ScreenPowerStatus::POWER_STATUS_OFF || status == ScreenPowerStatus::POWER_STATUS_SUSPEND) { WLOGFI("unsubscribe rotation and posture sensor when phone turn off"); ScreenSensorConnector::UnsubscribeRotationSensor(); - if (g_foldScreenFlag && !FoldScreenSensorManager::GetInstance().allowPosture && - reason != PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH) { + if (g_foldScreenFlag && reason != PowerStateChangeReason::STATE_CHANGE_REASON_DISPLAY_SWITCH) { FoldScreenSensorManager::GetInstance().UnRegisterPostureCallback(); } else { - WLOGFI("Duplicate unregister, or not fold product, switch screen reason, failed unregister posture."); + WLOGFI("not fold product, switch screen reason, failed unregister posture."); } } else { WLOGFI("SetScreenPower state not support"); -- Gitee From 3c2b104fb615267376e6e64b7be9a5fe0e85802f Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Tue, 2 Apr 2024 11:27:38 +0800 Subject: [PATCH 362/385] updata Signed-off-by: redking-zhong --- window_scene/session_manager/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index adf81861a..19c9f7740 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -302,8 +302,8 @@ ohos_shared_library("session_manager") { public_configs = [ ":session_manager_public_config" ] deps = [ - "${window_base_path}/utils:libwmutil", ":session_manager_lite", + "${window_base_path}/utils:libwmutil", ] public_external_deps = [ "ability_runtime:session_handler", -- Gitee From 8750b607f740ef21b3764a057fa86c2ebfc9b1bc Mon Sep 17 00:00:00 2001 From: liubo Date: Mon, 1 Apr 2024 19:05:41 +0800 Subject: [PATCH 363/385] =?UTF-8?q?Description:=20=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E6=95=B4=E6=94=B9=20IssueNo:https://gitee.co?= =?UTF-8?q?m/openharmony/window=5Fwindow=5Fmanager/issues/I9DE6C=20Feature?= =?UTF-8?q?=20or=20Bugfix:=20Bugfix=20Binary=20Source:No=20Signed-off-by:?= =?UTF-8?q?=20liubo419=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/zidl/screen_session_manager_lite_proxy.cpp | 10 ++++++++++ .../src/zidl/screen_session_manager_lite_stub.cpp | 6 ++++++ .../src/zidl/screen_session_manager_proxy.cpp | 10 ++++++++++ .../src/zidl/screen_session_manager_stub.cpp | 13 ++++++++++--- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_lite_proxy.cpp index 8bae55664..a5304d1c9 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_lite_proxy.cpp @@ -41,6 +41,11 @@ DMError ScreenSessionManagerLiteProxy::RegisterDisplayManagerAgent( return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; } + if (displayManagerAgent == nullptr) { + WLOGFE("IDisplayManagerAgent is null"); + return DMError::DM_ERROR_INVALID_PARAM; + } + if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) { WLOGFE("Write IDisplayManagerAgent failed"); return DMError::DM_ERROR_IPC_FAILED; @@ -71,6 +76,11 @@ DMError ScreenSessionManagerLiteProxy::UnregisterDisplayManagerAgent( return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED; } + if (displayManagerAgent == nullptr) { + WLOGFE("IDisplayManagerAgent is null"); + return DMError::DM_ERROR_INVALID_PARAM; + } + if (!data.WriteRemoteObject(displayManagerAgent->AsObject())) { WLOGFE("Write IWindowManagerAgent failed"); return DMError::DM_ERROR_IPC_FAILED; diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_lite_stub.cpp index 626286a90..f5028e86b 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_lite_stub.cpp @@ -79,6 +79,9 @@ int ScreenSessionManagerLiteStub::HandleRegisterDisplayManagerAgent(MessageParce { WLOGFD("run HandleRegisterDisplayManagerAgent!"); auto agent = iface_cast(data.ReadRemoteObject()); + if (agent == nullptr) { + return ERR_INVALID_DATA; + } auto type = static_cast(data.ReadUint32()); DMError ret = RegisterDisplayManagerAgent(agent, type); reply.WriteInt32(static_cast(ret)); @@ -89,6 +92,9 @@ int ScreenSessionManagerLiteStub::HandleUnRegisterDisplayManagerAgent(MessagePar { WLOGFD("run HandleUnRegisterDisplayManagerAgent!"); auto agent = iface_cast(data.ReadRemoteObject()); + if (agent == nullptr) { + return ERR_INVALID_DATA; + } auto type = static_cast(data.ReadUint32()); DMError ret = UnregisterDisplayManagerAgent(agent, type); reply.WriteInt32(static_cast(ret)); diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp index 8de3b814c..4e43a4f8a 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_proxy.cpp @@ -548,6 +548,11 @@ DMError ScreenSessionManagerProxy::RegisterDisplayManagerAgent(const sptrAsObject())) { WLOGFE("Write IDisplayManagerAgent failed"); return DMError::DM_ERROR_IPC_FAILED; @@ -577,6 +582,11 @@ DMError ScreenSessionManagerProxy::UnregisterDisplayManagerAgent(const sptrAsObject())) { WLOGFE("Write IWindowManagerAgent failed"); return DMError::DM_ERROR_IPC_FAILED; diff --git a/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp index 0bea9607a..ae1441628 100644 --- a/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/screen_session_manager_stub.cpp @@ -27,6 +27,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_DMS_SCREEN_SESSION_MANAGER, "ScreenSessionManagerStub" }; const static uint32_t MAX_SCREEN_SIZE = 32; +const static uint32_t ERR_INVALID_DATA = -1; } int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, @@ -35,7 +36,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& WLOGFD("OnRemoteRequest code is %{public}u", code); if (data.ReadInterfaceToken() != GetDescriptor()) { WLOGFE("InterfaceToken check failed"); - return -1; + return ERR_INVALID_DATA; } DisplayManagerMessage msgId = static_cast(code); switch (msgId) { @@ -46,6 +47,9 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& } case DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT: { auto agent = iface_cast(data.ReadRemoteObject()); + if (agent == nullptr) { + return ERR_INVALID_DATA; + } auto type = static_cast(data.ReadUint32()); DMError ret = RegisterDisplayManagerAgent(agent, type); reply.WriteInt32(static_cast(ret)); @@ -53,6 +57,9 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& } case DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_MANAGER_AGENT: { auto agent = iface_cast(data.ReadRemoteObject()); + if (agent == nullptr) { + return ERR_INVALID_DATA; + } auto type = static_cast(data.ReadUint32()); DMError ret = UnregisterDisplayManagerAgent(agent, type); reply.WriteInt32(static_cast(ret)); @@ -108,7 +115,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& ScreenId dmsScreenId; if (!data.ReadUint64(dmsScreenId)) { WLOGFE("fail to read dmsScreenId."); - return -1; + return ERR_INVALID_DATA; } reply.WriteUint32(static_cast(GetScreenPower(dmsScreenId))); break; @@ -615,7 +622,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& sptr info = DisplayChangeInfo::Unmarshalling(data); if (!info) { WLOGFE("Read DisplayChangeInfo failed"); - return -1; + return ERR_INVALID_DATA; } NotifyDisplayChangeInfoChanged(info); break; -- Gitee From 7ea5ca2cf19cef910a7e0c28ac1929521cedc9eb Mon Sep 17 00:00:00 2001 From: qintongtong Date: Fri, 29 Mar 2024 09:27:51 +0800 Subject: [PATCH 364/385] =?UTF-8?q?fix:=E4=BB=A3=E7=A0=81=E6=A3=80?= =?UTF-8?q?=E8=A7=86=E5=91=BD=E5=90=8D=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qintongtong Change-Id: I20c97615c06aa04b4b1d4b4c4ac18bdea76799b6 --- .../src/scene_session_dirty_manager.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_dirty_manager.cpp b/window_scene/session_manager/src/scene_session_dirty_manager.cpp index 216e23bb5..c36a5084b 100644 --- a/window_scene/session_manager/src/scene_session_dirty_manager.cpp +++ b/window_scene/session_manager/src/scene_session_dirty_manager.cpp @@ -34,7 +34,7 @@ constexpr float DIRECTION180 = 180 ; constexpr float DIRECTION270 = 270 ; constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionDirtyManager"}; constexpr unsigned int POINTER_CHANGE_AREA_COUNT = 8; -constexpr int POINTER_CHANGE_AREA_SEXTEEN = 16; +constexpr int POINTER_CHANGE_AREA_SIXTEEN = 16; constexpr int POINTER_CHANGE_AREA_DEFAULT = 0; constexpr int POINTER_CHANGE_AREA_FIVE = 5; constexpr int UPDATE_TASK_DURATION = 10; @@ -359,28 +359,28 @@ void SceneSessionDirtyManager::UpdatePointerAreas(sptr sceneSessio vpr = screenSession->GetScreenProperty().GetDensity(); } } - int32_t pointerArea_Five_Px = static_cast(POINTER_CHANGE_AREA_FIVE * vpr); - int32_t pointerArea_Sexteen_Px = static_cast(POINTER_CHANGE_AREA_SEXTEEN * vpr); + int32_t pointerAreaFivePx = static_cast(POINTER_CHANGE_AREA_FIVE * vpr); + int32_t pointerAreaSixteenPx = static_cast(POINTER_CHANGE_AREA_SIXTEEN * vpr); if (sceneSession->GetSessionInfo().isSetPointerAreas_) { pointerChangeAreas = {POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, - POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_Px, pointerArea_Sexteen_Px, - pointerArea_Five_Px, pointerArea_Sexteen_Px, pointerArea_Five_Px}; + POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx, pointerAreaSixteenPx, + pointerAreaFivePx, pointerAreaSixteenPx, pointerAreaFivePx}; return; } auto limits = sceneSession->GetSessionProperty()->GetWindowLimits(); if (limits.minWidth_ == limits.maxWidth_ && limits.minHeight_ != limits.maxHeight_) { - pointerChangeAreas = {POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_Px, + pointerChangeAreas = {POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, - pointerArea_Five_Px, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT}; + pointerAreaFivePx, POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT}; } else if (limits.minWidth_ != limits.maxWidth_ && limits.minHeight_ == limits.maxHeight_) { pointerChangeAreas = {POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, - POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_Px, POINTER_CHANGE_AREA_DEFAULT, - POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, pointerArea_Five_Px}; + POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx, POINTER_CHANGE_AREA_DEFAULT, + POINTER_CHANGE_AREA_DEFAULT, POINTER_CHANGE_AREA_DEFAULT, pointerAreaFivePx}; } else if (limits.minWidth_ != limits.maxWidth_ && limits.minHeight_ != limits.maxHeight_) { - pointerChangeAreas = {pointerArea_Sexteen_Px, pointerArea_Five_Px, - pointerArea_Sexteen_Px, pointerArea_Five_Px, pointerArea_Sexteen_Px, - pointerArea_Five_Px, pointerArea_Sexteen_Px, pointerArea_Five_Px}; + pointerChangeAreas = {pointerAreaSixteenPx, pointerAreaFivePx, + pointerAreaSixteenPx, pointerAreaFivePx, pointerAreaSixteenPx, + pointerAreaFivePx, pointerAreaSixteenPx, pointerAreaFivePx}; } } else { WLOGFD("UpdatePointerAreas sceneSession is: %{public}d dragEnabled is false", sceneSession->GetPersistentId()); -- Gitee From b093ee80b35c630d3d2be637204f2165147b2e6e Mon Sep 17 00:00:00 2001 From: t30053014 <1180300204@alu.hit.edu.cn> Date: Tue, 2 Apr 2024 16:19:24 +0800 Subject: [PATCH 365/385] Signed-off-by: t30053014 <1180300204@alu.hit.edu.cn> modified: window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp --- .../fold_screen_sensor_manager.cpp | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp b/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp index 7864f66e9..f12685a66 100644 --- a/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp +++ b/window_scene/session_manager/src/fold_screen_controller/fold_screen_sensor_manager.cpp @@ -70,36 +70,36 @@ void FoldScreenSensorManager::SetFoldScreenPolicy(sptr foldScr void FoldScreenSensorManager::RegisterPostureCallback() { - if (allowPosture_) { - postureUser.callback = SensorPostureDataCallback; - int32_t subscribeRet = SubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); - WLOGFI("RegisterPostureCallback, subscribeRet: %{public}d", subscribeRet); - int32_t setBatchRet = SetBatch(SENSOR_TYPE_ID_POSTURE, &postureUser, POSTURE_INTERVAL, POSTURE_INTERVAL); - WLOGFI("RegisterPostureCallback, setBatchRet: %{public}d", setBatchRet); - int32_t activateRet = ActivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); - WLOGFI("RegisterPostureCallback, activateRet: %{public}d", activateRet); - if (subscribeRet != SENSOR_SUCCESS || setBatchRet != SENSOR_SUCCESS || activateRet != SENSOR_SUCCESS) { - WLOGFE("RegisterPostureCallback failed."); - } else { - allowPosture_ = false; - WLOGFI("FoldScreenSensorManager.RegisterPostureCallback success."); - } - } else { + if (!allowPosture_) { WLOGFI("Duplicate register posture is not allowed."); + return; + } + + postureUser.callback = SensorPostureDataCallback; + int32_t subscribeRet = SubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); + int32_t setBatchRet = SetBatch(SENSOR_TYPE_ID_POSTURE, &postureUser, POSTURE_INTERVAL, POSTURE_INTERVAL); + int32_t activateRet = ActivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); + WLOGFI("RegisterPostureCallback, subscribeRet: %{public}d, setBatchRet: %{public}d, activateRet: %{public}d", + subscribeRet, setBatchRet, activateRet); + if (subscribeRet != SENSOR_SUCCESS || setBatchRet != SENSOR_SUCCESS || activateRet != SENSOR_SUCCESS) { + WLOGFE("RegisterPostureCallback failed."); + } else { + allowPosture_ = false; + WLOGFI("FoldScreenSensorManager.RegisterPostureCallback success."); } } void FoldScreenSensorManager::UnRegisterPostureCallback() { - if (!allowPosture_) { - int32_t deactivateRet = DeactivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); - int32_t unsubscribeRet = UnsubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); - if (deactivateRet == SENSOR_SUCCESS && unsubscribeRet == SENSOR_SUCCESS) { - allowPosture_ = true; - WLOGFI("FoldScreenSensorManager.UnRegisterPostureCallback success."); - } - } else { + if (allowPosture_) { WLOGFI("Duplicate unregister posture is not allowed."); + return; + } + int32_t deactivateRet = DeactivateSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); + int32_t unsubscribeRet = UnsubscribeSensor(SENSOR_TYPE_ID_POSTURE, &postureUser); + if (deactivateRet == SENSOR_SUCCESS && unsubscribeRet == SENSOR_SUCCESS) { + allowPosture_ = true; + WLOGFI("FoldScreenSensorManager.UnRegisterPostureCallback success."); } } -- Gitee From d0ce37063fef6f6ddcb72e4d065ed20c2e074b85 Mon Sep 17 00:00:00 2001 From: xuzirong Date: Mon, 1 Apr 2024 10:08:11 +0800 Subject: [PATCH 366/385] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=B8=BB=E7=AA=97=E5=8F=A3=E7=BD=AE=E9=A1=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuzirong --- interfaces/innerkits/wm/window.h | 13 +++++ .../window_runtime/window_napi/js_window.cpp | 55 +++++++++++++++++++ .../window_runtime/window_napi/js_window.h | 2 + previewer/include/window.h | 2 + .../common/include/window_session_property.h | 3 + .../common/src/window_session_property.cpp | 13 ++++- .../interfaces/include/ws_common_inner.h | 1 + .../js_scene_session.cpp | 44 +++++++++++++++ .../scene_session_manager/js_scene_session.h | 2 + .../session/host/include/main_session.h | 2 + .../session/host/include/scene_session.h | 4 ++ .../session/host/src/main_session.cpp | 28 ++++++++++ .../include/scene_session_manager.h | 1 + .../src/scene_session_manager.cpp | 19 +++++++ .../unittest/scene_session_manager_test.cpp | 20 +++++++ .../test/unittest/scene_session_test.cpp | 22 ++++++++ .../unittest/window_session_property_test.cpp | 13 +++++ wm/include/window_session_impl.h | 2 + wm/src/window_session_impl.cpp | 19 +++++++ wm/test/unittest/BUILD.gn | 1 + wm/test/unittest/window_session_impl_test.cpp | 45 +++++++++++++++ 21 files changed, 310 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 2e5f0871f..62c29f4c4 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -656,6 +656,19 @@ public: * @return WMError */ virtual WMError SetWindowMode(WindowMode mode) { return WMError::WM_OK; } + /** + * @brief Set whether the window is topmost + * + * @param topmost whether window is topmost + * @return WMError + */ + virtual WMError SetTopmost(bool topmost) { return WMError::WM_OK; } + /** + * @brief Get whether window is topmost + * + * @return True means window is topmost + */ + virtual bool IsTopmost() const { return false; } /** * @brief Set alpha of window. * diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 32189217d..201764956 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -434,6 +434,13 @@ napi_value JsWindow::SetWindowFocusable(napi_env env, napi_callback_info info) return (me != nullptr) ? me->OnSetWindowFocusable(env, info) : nullptr; } +napi_value JsWindow::SetTopmost(napi_env env, napi_callback_info info) +{ + TLOGI(WmsLogTag::WMS_LAYOUT, "SetTopmost"); + JsWindow* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnSetTopmost(env, info) : nullptr; +} + napi_value JsWindow::SetKeepScreenOn(napi_env env, napi_callback_info info) { WLOGI("SetKeepScreenOn"); @@ -3085,6 +3092,53 @@ napi_value JsWindow::OnSetWindowFocusable(napi_env env, napi_callback_info info) return result; } +napi_value JsWindow::OnSetTopmost(napi_env env, napi_callback_info info) +{ + if (!Permission::IsSystemCalling()) { + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]SetTopmost permission denied!"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_NOT_SYSTEM_APP); + } + if (windowToken_ == nullptr) { + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } + if (!WindowHelper::IsMainWindow(windowToken_->GetType())) { + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]SetTopmost is not allowed since window is not main window"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_CALLING); + } + + size_t argc = 4; + napi_value argv[4] = {nullptr}; + napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); + if (argc != 1 || argv[0] == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu. Failed to convert parameter to topmost", argc); + return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); + } + bool topmost = false; + napi_get_value_bool(env, argv[0], &topmost); + + wptr weakToken(windowToken_); + NapiAsyncTask::CompleteCallback complete = [weakToken, topmost](napi_env env, NapiAsyncTask& task, int32_t status) { + auto weakWindow = weakToken.promote(); + if (weakWindow == nullptr) { + task.Reject(env, CreateJsError(env, static_cast(WmErrorCode::WM_ERROR_STATE_ABNORMALLY), + "Invalidate params.")); + return; + } + WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(weakWindow->SetTopmost(topmost)); + if (ret == WmErrorCode::WM_OK) { + task.Resolve(env, NapiGetUndefined(env)); + } else { + task.Reject(env, CreateJsError(env, static_cast(ret), "Window set topmost failed")); + } + TLOGI(WmsLogTag::WMS_LAYOUT, "Window [%{public}u, %{public}s] set topmost end", + weakWindow->GetWindowId(), weakWindow->GetWindowName().c_str()); + }; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JsWindow::OnSetTopmost", + env, CreateAsyncTaskWithLastParam(env, nullptr, nullptr, std::move(complete), &result)); + return result; +} + napi_value JsWindow::OnSetKeepScreenOn(napi_env env, napi_callback_info info) { WMError errCode = WMError::WM_OK; @@ -5547,6 +5601,7 @@ void BindFunctions(napi_env env, napi_value object, const char *moduleName) BindNativeFunction(env, object, "setWindowBackgroundColor", moduleName, JsWindow::SetWindowBackgroundColorSync); BindNativeFunction(env, object, "setBrightness", moduleName, JsWindow::SetBrightness); BindNativeFunction(env, object, "setWindowBrightness", moduleName, JsWindow::SetWindowBrightness); + BindNativeFunction(env, object, "setTopmost", moduleName, JsWindow::SetTopmost); BindNativeFunction(env, object, "setDimBehind", moduleName, JsWindow::SetDimBehind); BindNativeFunction(env, object, "setFocusable", moduleName, JsWindow::SetFocusable); BindNativeFunction(env, object, "setWindowFocusable", moduleName, JsWindow::SetWindowFocusable); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.h b/interfaces/kits/napi/window_runtime/window_napi/js_window.h index 40ca610db..04073a681 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.h @@ -85,6 +85,7 @@ public: static napi_value SetDimBehind(napi_env env, napi_callback_info info); static napi_value SetFocusable(napi_env env, napi_callback_info info); static napi_value SetWindowFocusable(napi_env env, napi_callback_info info); + static napi_value SetTopmost(napi_env env, napi_callback_info info); static napi_value SetKeepScreenOn(napi_env env, napi_callback_info info); static napi_value SetWindowKeepScreenOn(napi_env env, napi_callback_info info); static napi_value SetWakeUpScreen(napi_env env, napi_callback_info info); @@ -225,6 +226,7 @@ private: napi_value OnSetDimBehind(napi_env env, napi_callback_info info); napi_value OnSetFocusable(napi_env env, napi_callback_info info); napi_value OnSetWindowFocusable(napi_env env, napi_callback_info info); + napi_value OnSetTopmost(napi_env env, napi_callback_info info); napi_value OnSetKeepScreenOn(napi_env env, napi_callback_info info); napi_value OnSetWindowKeepScreenOn(napi_env env, napi_callback_info info); napi_value OnSetWakeUpScreen(napi_env env, napi_callback_info info); diff --git a/previewer/include/window.h b/previewer/include/window.h index 19977cc89..f97f9396e 100644 --- a/previewer/include/window.h +++ b/previewer/include/window.h @@ -267,6 +267,8 @@ public: virtual WMError SetResizeByDragEnabled(bool dragEnabled) = 0; virtual WMError SetRaiseByClickEnabled(bool raiseEnabled) = 0; virtual WmErrorCode RaiseAboveTarget(int32_t subWindowId) = 0; + virtual WMError SetTopmost(bool topmost) { return WMError::WM_OK; } + virtual bool IsTopmost() const { return false; } virtual WMError HideNonSystemFloatingWindows(bool shouldHide) = 0; virtual bool IsFloatingWindowAppType() const { return false; } virtual WmErrorCode KeepKeyboardOnFocus(bool keepKeyboardFlag) = 0; diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 73f127776..bb21c93ec 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -69,6 +69,8 @@ public: void SetAnimationFlag(uint32_t animationFlag); void SetTransform(const Transform& trans); void SetWindowFlags(uint32_t flags); + void SetTopmost(bool topmost); + bool IsTopmost() const; void AddWindowFlag(WindowFlag flag); void SetModeSupportInfo(uint32_t modeSupportInfo); void SetFloatingWindowAppType(bool isAppType); @@ -165,6 +167,7 @@ private: bool tokenState_ { false }; bool turnScreenOn_ = false; bool keepScreenOn_ = false; + bool topmost_ = false; Orientation requestedOrientation_ = Orientation::UNSPECIFIED; bool isPrivacyMode_ { false }; bool isSystemPrivacyMode_ { false }; diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 50c56ecec..440e26923 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -219,6 +219,16 @@ void WindowSessionProperty::SetWindowFlags(uint32_t flags) flags_ = flags; } +void WindowSessionProperty::SetTopmost(bool topmost) +{ + topmost_ = topmost; +} + +bool WindowSessionProperty::IsTopmost() const +{ + return topmost_; +} + void WindowSessionProperty::AddWindowFlag(WindowFlag flag) { flags_ |= static_cast(flag); @@ -607,7 +617,7 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const parcel.WriteUint32(accessTokenId_) && parcel.WriteUint32(static_cast(maximizeMode_)) && parcel.WriteUint32(static_cast(requestedOrientation_)) && parcel.WriteUint32(static_cast(windowMode_)) && - parcel.WriteUint32(flags_) && parcel.WriteBool(raiseEnabled_) && + parcel.WriteUint32(flags_) && parcel.WriteBool(raiseEnabled_) && parcel.WriteBool(topmost_) && parcel.WriteBool(isDecorEnable_) && parcel.WriteBool(dragEnabled_) && parcel.WriteBool(hideNonSystemFloatingWindows_) && parcel.WriteBool(forceHide_) && MarshallingWindowLimits(parcel) && parcel.WriteFloat(brightness_) && @@ -654,6 +664,7 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) property->SetWindowMode(static_cast(parcel.ReadUint32())); property->SetWindowFlags(parcel.ReadUint32()); property->SetRaiseEnabled(parcel.ReadBool()); + property->SetTopmost(parcel.ReadBool()); property->SetDecorEnable(parcel.ReadBool()); property->SetDragEnabled(parcel.ReadBool()); property->SetHideNonSystemFloatingWindows(parcel.ReadBool()); diff --git a/window_scene/interfaces/include/ws_common_inner.h b/window_scene/interfaces/include/ws_common_inner.h index f2904fcea..c55eb9ea1 100644 --- a/window_scene/interfaces/include/ws_common_inner.h +++ b/window_scene/interfaces/include/ws_common_inner.h @@ -53,6 +53,7 @@ enum class WSPropertyChangeAction : uint32_t { ACTION_UPDATE_NAVIGATION_INDICATOR_PROPS = 1 << 26, ACTION_UPDATE_TEXTFIELD_AVOID_INFO = 1 << 27, ACTION_UPDATE_WINDOW_MASK = 1 << 28, + ACTION_UPDATE_TOPMOST = 1 << 29, }; enum class AreaType : uint32_t { diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index 3da7fa0ad..14e701347 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -37,6 +37,7 @@ const std::string RAISE_TO_TOP_POINT_DOWN_CB = "raiseToTopForPointDown"; const std::string BACK_PRESSED_CB = "backPressed"; const std::string SESSION_FOCUSABLE_CHANGE_CB = "sessionFocusableChange"; const std::string SESSION_TOUCHABLE_CHANGE_CB = "sessionTouchableChange"; +const std::string SESSION_TOP_MOST_CHANGE_CB = "sessionTopmostChange"; const std::string CLICK_CB = "click"; const std::string TERMINATE_SESSION_CB = "terminateSession"; const std::string TERMINATE_SESSION_CB_NEW = "terminateSessionNew"; @@ -188,6 +189,7 @@ void JsSceneSession::InitListenerFuncs() { BACK_PRESSED_CB, &JsSceneSession::ProcessBackPressedRegister }, { SESSION_FOCUSABLE_CHANGE_CB, &JsSceneSession::ProcessSessionFocusableChangeRegister }, { SESSION_TOUCHABLE_CHANGE_CB, &JsSceneSession::ProcessSessionTouchableChangeRegister }, + { SESSION_TOP_MOST_CHANGE_CB, &JsSceneSession::ProcessSessionTopmostChangeRegister }, { CLICK_CB, &JsSceneSession::ProcessClickRegister }, { TERMINATE_SESSION_CB, &JsSceneSession::ProcessTerminateSessionRegister }, { TERMINATE_SESSION_CB_NEW, &JsSceneSession::ProcessTerminateSessionRegisterNew }, @@ -670,6 +672,24 @@ void JsSceneSession::ProcessSessionFocusableChangeRegister() TLOGD(WmsLogTag::WMS_FOCUS, "ProcessSessionFocusableChangeRegister success"); } +void JsSceneSession::ProcessSessionTopmostChangeRegister() +{ + auto sessionchangeCallback = sessionchangeCallback_.promote(); + if (sessionchangeCallback == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "sessionchangeCallback is nullptr"); + return; + } + sessionchangeCallback->onSessionTopmostChange_ = + std::bind(&JsSceneSession::OnSessionTopmostChange, this, std::placeholders::_1); + auto session = weakSession_.promote(); + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "session is nullptr"); + return; + } + sessionchangeCallback->onSessionTopmostChange_(session->IsTopmost()); + TLOGD(WmsLogTag::WMS_LAYOUT, "ProcessSessionTopmostChangeRegister success"); +} + void JsSceneSession::ProcessSessionTouchableChangeRegister() { NotifySessionTouchableChangeFunc func = [weak = weak_from_this()](bool touchable) { @@ -1562,6 +1582,30 @@ void JsSceneSession::OnSessionTouchableChange(bool touchable) taskScheduler_->PostMainThreadTask(task, "OnSessionTouchableChange: state " + std::to_string(touchable)); } +void JsSceneSession::OnSessionTopmostChange(bool topmost) +{ + TLOGI(WmsLogTag::WMS_LAYOUT, "[NAPI]OnSessionTopmostChange, state: %{public}u", topmost); + std::shared_ptr jsCallBack = nullptr; + { + std::shared_lock lock(jsCbMapMutex_); + auto iter = jsCbMap_.find(SESSION_TOP_MOST_CHANGE_CB); + if (iter == jsCbMap_.end()) { + return; + } + jsCallBack = iter->second; + } + auto task = [topmost, jsCallBack, env = env_]() { + if (!jsCallBack) { + TLOGE(WmsLogTag::WMS_LAYOUT, "[NAPI]jsCallBack is nullptr"); + return; + } + napi_value jsSessionTouchableObj = CreateJsValue(env, topmost); + napi_value argv[] = {jsSessionTouchableObj}; + napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); + }; + taskScheduler_->PostMainThreadTask(task, "OnSessionTopmostChange: state " + std::to_string(topmost)); +} + void JsSceneSession::OnClick() { WLOGFD("[NAPI]OnClick"); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h index 9bd81ef71..7818a4adb 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h @@ -95,6 +95,7 @@ private: void ProcessBackPressedRegister(); void ProcessSessionFocusableChangeRegister(); void ProcessSessionTouchableChangeRegister(); + void ProcessSessionTopmostChangeRegister(); void ProcessClickRegister(); void ProcessTerminateSessionRegister(); void ProcessTerminateSessionRegisterNew(); @@ -134,6 +135,7 @@ private: void OnBackPressed(bool needMoveToBackground); void OnSessionFocusableChange(bool isFocusable); void OnSessionTouchableChange(bool touchable); + void OnSessionTopmostChange(bool topmost); void OnClick(); void TerminateSession(const SessionInfo& info); void TerminateSessionNew(const SessionInfo& info, bool needStartCaller); diff --git a/window_scene/session/host/include/main_session.h b/window_scene/session/host/include/main_session.h index ecc762200..60b59fe47 100644 --- a/window_scene/session/host/include/main_session.h +++ b/window_scene/session/host/include/main_session.h @@ -30,6 +30,8 @@ public: WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; void NotifyForegroundInteractiveStatus(bool interactive) override; WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; + WSError SetTopmost(bool topmost) override; + bool IsTopmost() const override; protected: void UpdatePointerArea(const WSRect& rect) override; diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index acf5c37bb..b5a2b7bcc 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -45,6 +45,7 @@ using RecoveryCallback = std::function; using NotifyBindDialogSessionFunc = std::function& session)>; using NotifySessionRectChangeFunc = std::function; using NotifySessionEventFunc = std::function; +using NotifySessionTopmostChangeFunc = std::function; using NotifyRaiseToTopFunc = std::function; using SetWindowPatternOpacityFunc = std::function; using NotifyIsCustomAnimationPlayingCallback = std::function; @@ -83,6 +84,7 @@ public: struct SessionChangeCallback : public RefBase { NotifyBindDialogSessionFunc onBindDialogTarget_; NotifySessionRectChangeFunc onRectChange_; + NotifySessionTopmostChangeFunc onSessionTopmostChange_; NotifyRaiseToTopFunc onRaiseToTop_; NotifySessionEventFunc OnSessionEvent_; NotifySystemBarPropertyChangeFunc OnSystemBarPropertyChange_; @@ -167,6 +169,8 @@ public: void SetCollaboratorType(int32_t collaboratorType); void SetSelfToken(sptr selfToken); void SetLastSafeRect(WSRect rect); + virtual WSError SetTopmost(bool topmost) { return WSError::WS_ERROR_INVALID_CALLING; }; + virtual bool IsTopmost() const { return false; }; WSError SetSystemBarProperty(WindowType type, SystemBarProperty systemBarProperty); void SetAbilitySessionInfo(std::shared_ptr abilityInfo); void SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func); diff --git a/window_scene/session/host/src/main_session.cpp b/window_scene/session/host/src/main_session.cpp index fb63926aa..5844c0fc7 100644 --- a/window_scene/session/host/src/main_session.cpp +++ b/window_scene/session/host/src/main_session.cpp @@ -150,4 +150,32 @@ bool MainSession::CheckPointerEventDispatch(const std::shared_ptrGetSessionProperty(); + if (property) { + TLOGI(WmsLogTag::WMS_LAYOUT, "Notify session topmost change, id: %{public}d, topmost: %{public}u", + session->GetPersistentId(), topmost); + property->SetTopmost(topmost); + if (session->sessionChangeCallback_ && session->sessionChangeCallback_->onSessionTopmostChange_) { + session->sessionChangeCallback_->onSessionTopmostChange_(topmost); + } + } + }; + PostTask(task, "SetTopmost"); + return WSError::WS_OK; +} + +bool MainSession::IsTopmost() const +{ + return GetSessionProperty()->IsTopmost(); +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 84fc0711d..d016f37ef 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -357,6 +357,7 @@ private: WSError UpdateParentSessionForDialog(const sptr& sceneSession, sptr property); void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); void UpdateFocusableProperty(int32_t persistentId); + WMError UpdateTopmostProperty(const sptr &property, const sptr &sceneSession); std::vector> GetSceneSessionVectorByType(WindowType type, uint64_t displayId); bool UpdateSessionAvoidAreaIfNeed(const int32_t& persistentId, const sptr& sceneSession, const AvoidArea& avoidArea, AvoidAreaType avoidAreaType); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 0e1371f5d..832d54d14 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -2841,12 +2841,27 @@ WMError SceneSessionManager::HandleUpdateProperty(const sptr& property, + const sptr& sceneSession) +{ + if (!SessionPermission::IsSystemCalling()) { + TLOGE(WmsLogTag::WMS_LAYOUT, "UpdateTopmostProperty permission denied!"); + return WMError::WM_ERROR_NOT_SYSTEM_APP; + } + + sceneSession->SetTopmost(property->IsTopmost()); + return WMError::WM_OK; +} + void SceneSessionManager::UpdateHideNonSystemFloatingWindows(const sptr& property, const sptr& sceneSession) { @@ -3789,6 +3804,10 @@ WSError SceneSessionManager::RequestFocusSpecificCheck(sptr& scene // blocking-type session will block lower zOrder request focus auto focusedSession = GetSceneSession(focusedSessionId_); if (focusedSession) { + if (focusedSession->IsTopmost() && sceneSession->IsAppSession()) { + // return ok if focused session is topmost + return WSError::WS_OK; + } bool isBlockingType = focusedSession->IsAppSession() || (focusedSession->GetSessionInfo().isSystem_ && focusedSession->GetBlockingFocus()); if (byForeground && isBlockingType && sceneSession->GetZOrder() < focusedSession->GetZOrder()) { diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 7c0816fc6..7f847d241 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -19,6 +19,7 @@ #include "session_manager/include/scene_session_manager.h" #include "session_info.h" #include "session/host/include/scene_session.h" +#include "session/host/include/main_session.h" #include "window_manager_agent.h" #include "session_manager.h" #include "zidl/window_manager_agent_interface.h" @@ -3025,6 +3026,25 @@ HWTEST_F(SceneSessionManagerTest, NotifyWindowExtensionVisibilityChange, Functio ASSERT_EQ(result, WSError::WS_OK); } +/** + * @tc.name: UpdateTopmostProperty + * @tc.desc: test UpdateTopmostProperty + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, UpdateTopmostProperty, Function | SmallTest | Level3) +{ + SessionInfo info; + info.abilityName_ = "UpdateTopmostProperty"; + info.bundleName_ = "UpdateTopmostProperty"; + sptr property = new WindowSessionProperty(); + property->SetTopmost(true); + property->SetSystemCalling(true); + sptr scenesession = new (std::nothrow) MainSession(info, nullptr); + scenesession->SetSessionProperty(property); + WMError result = ssm_->UpdateTopmostProperty(property, scenesession); + ASSERT_EQ(WMError::WM_OK, result); +} + /** * @tc.name: NotifySessionForeground * @tc.desc: SceneSesionManager NotifySessionForeground diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 3428ab233..8d882aecb 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -17,6 +17,7 @@ #include "session/host/include/scene_session.h" #include "session/host/include/sub_session.h" #include "session/host/include/system_session.h" +#include "session/host/include/main_session.h" #include "wm_common.h" #include "mock/mock_session_stage.h" #include "input_event.h" @@ -1306,6 +1307,27 @@ HWTEST_F(SceneSessionTest, OnSessionEvent, Function | SmallTest | Level2) ASSERT_EQ(result, WSError::WS_OK); } +/** + * @tc.name: SetTopmost + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest, SetTopmost, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "SetTopmost"; + info.bundleName_ = "SetTopmost"; + sptr session_; + sptr scenesession = new (std::nothrow) MainSession(info, nullptr); + EXPECT_NE(scenesession, nullptr); + + sptr property = new(std::nothrow) WindowSessionProperty(); + scenesession->SetSessionProperty(property); + auto result = scenesession->SetTopmost(false); + ASSERT_EQ(result, WSError::WS_OK); + ASSERT_FALSE(scenesession->IsTopmost()); +} + /** * @tc.name: SetAspectRatio2 * @tc.desc: normal function diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 628f911a1..53f31b7ae 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -137,6 +137,19 @@ HWTEST_F(WindowSessionPropertyTest, SetBrightness, Function | SmallTest | Level2 ASSERT_NE(property->GetBrightness(), 0); } +/** + * @tc.name: SetTopmost + * @tc.desc: SetTopmost test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionPropertyTest, SetTopmost, Function | SmallTest | Level2) +{ + bool topmost = true; + WindowSessionProperty windowSessionProperty; + windowSessionProperty.SetTopmost(topmost); + ASSERT_TRUE(windowSessionProperty.IsTopmost()); +} + /** * @tc.name: GetParentId * @tc.desc: GetParentId test diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index 2a69dad9e..adc5d1da2 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -76,6 +76,8 @@ public: WindowState GetRequestWindowState() const; WMError SetFocusable(bool isFocusable) override; WMError SetTouchable(bool isTouchable) override; + WMError SetTopmost(bool topmost) override; + bool IsTopmost() const override; WMError SetResizeByDragEnabled(bool dragEnabled) override; WMError SetRaiseByClickEnabled(bool raiseEnabled) override; WMError HideNonSystemFloatingWindows(bool shouldHide) override; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index ad6572055..d5fc6653e 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -951,6 +951,25 @@ WMError WindowSessionImpl::SetTouchable(bool isTouchable) return UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_TOUCHABLE); } +WMError WindowSessionImpl::SetTopmost(bool topmost) +{ + WLOGFD("set topmost"); + auto isPC = system::GetParameter("const.product.devicetype", "unknown") == "2in1"; + if (!isPC) { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + if (IsWindowSessionInvalid()) { + return WMError::WM_ERROR_INVALID_WINDOW; + } + property_->SetTopmost(topmost); + return UpdateProperty(WSPropertyChangeAction::ACTION_UPDATE_TOPMOST); +} + +bool WindowSessionImpl::IsTopmost() const +{ + return property_->IsTopmost(); +} + WMError WindowSessionImpl::SetResizeByDragEnabled(bool dragEnabled) { WLOGFD("set dragEnabled"); diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index 9db705038..f07797433 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -127,6 +127,7 @@ ohos_unittest("wm_window_session_impl_test") { external_deps = [ "c_utils:utils", "hilog:libhilog", + "init:libbegetutil", ] } diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index f32c13fa9..3f21e3631 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -19,6 +19,7 @@ #include "mock_session.h" #include "window_session_impl.h" #include "mock_uicontent.h" +#include "parameters.h" using namespace testing; using namespace testing::ext; @@ -1606,6 +1607,50 @@ HWTEST_F(WindowSessionImplTest, SetSingleFrameComposerEnabled01, Function | Smal ASSERT_EQ(retCode, WMError::WM_OK); } +/** + * @tc.name: SetTopmost + * @tc.desc: SetTopmost + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, SetTopmost, Function | SmallTest | Level2) +{ + sptr option = new WindowOption(); + option->SetWindowName("SetTopmost"); + sptr window = new (std::nothrow) WindowSessionImpl(option); + ASSERT_NE(nullptr, window); + auto isPC = system::GetParameter("const.product.devicetype", "unknown") == "2in1"; + WMError res = window->SetTopmost(true); + if (!isPC) { + ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, res); + return; + } + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, res); + + window->property_->SetPersistentId(1); + SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(nullptr, session); + window->hostSession_ = session; + window->state_ = WindowState::STATE_CREATED; + res = window->SetTopmost(true); + ASSERT_EQ(WMError::WM_DO_NOTHING, res); +} + +/** + * @tc.name: IsTopmost + * @tc.desc: IsTopmost + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, IsTopmost, Function | SmallTest | Level2) +{ + sptr option = new WindowOption(); + option->SetWindowName("IsTopmost"); + sptr window = new WindowSessionImpl(option); + ASSERT_NE(window, nullptr); + bool res = window->IsTopmost(); + ASSERT_FALSE(res); +} + /** * @tc.name: SetDecorVisible * @tc.desc: SetDecorVisible and check the retCode -- Gitee From e7b46e4958e67865f8ebc65368dbd8c5bd42cf04 Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Tue, 2 Apr 2024 17:03:24 +0800 Subject: [PATCH 367/385] =?UTF-8?q?=E6=B7=BB=E5=8A=A0cfi=E5=B1=8F=E8=94=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: redking-zhong --- window_scene/session/host/src/session.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 13b4f4215..8b1450570 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -752,6 +752,7 @@ WSError Session::UpdateDensity() return WSError::WS_OK; } +__attribute__((no_sanitize("cfi"))) WSError Session::Connect(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, SystemSessionConfig& systemConfig, sptr property, sptr token, int32_t pid, int32_t uid) -- Gitee From c464eca95400f99b5b18df6c3b9270c2d100ada8 Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Tue, 2 Apr 2024 17:33:34 +0800 Subject: [PATCH 368/385] =?UTF-8?q?=E6=B7=BB=E5=8A=A0cfi=E5=B1=8F=E8=94=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: redking-zhong --- window_scene/session/host/src/session.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 8b1450570..5ef319a06 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -752,10 +752,11 @@ WSError Session::UpdateDensity() return WSError::WS_OK; } -__attribute__((no_sanitize("cfi"))) -WSError Session::Connect(const sptr& sessionStage, const sptr& eventChannel, - const std::shared_ptr& surfaceNode, SystemSessionConfig& systemConfig, - sptr property, sptr token, int32_t pid, int32_t uid) +__attribute__((no_sanitize("cfi"))) WSError Session::Connect(const sptr& sessionStage, + const sptr& eventChannel, + const std::shared_ptr& surfaceNode, + SystemSessionConfig& systemConfig, sptr property, + sptr token, int32_t pid, int32_t uid) { TLOGI(WmsLogTag::WMS_LIFE, "Connect session, id: %{public}d, state: %{public}u, isTerminating: %{public}d", GetPersistentId(), static_cast(GetSessionState()), isTerminating); -- Gitee From dd3baf22a8790ce0253dfb91f5fabd8c8a30d39c Mon Sep 17 00:00:00 2001 From: xuyangyang Date: Tue, 2 Apr 2024 18:08:41 +0800 Subject: [PATCH 369/385] add TDD ut case Signed-off-by: xuyangyang Change-Id: If58d6d712adc946aa7b68daa6f3cb488382551ec --- test/systemtest/wms/window_animation_transition_test.cpp | 6 +++--- test/systemtest/wms/window_display_zoom_test.cpp | 9 +++------ test/systemtest/wms/window_effect_test.cpp | 3 +-- test/systemtest/wms/window_layout_test.cpp | 4 ++-- test/systemtest/wms/window_raisetoapptop_test.cpp | 2 +- test/systemtest/wms/window_split_test.cpp | 4 ++-- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/test/systemtest/wms/window_animation_transition_test.cpp b/test/systemtest/wms/window_animation_transition_test.cpp index d3ef7a8ba..d63c07aeb 100644 --- a/test/systemtest/wms/window_animation_transition_test.cpp +++ b/test/systemtest/wms/window_animation_transition_test.cpp @@ -107,7 +107,7 @@ HWTEST_F(WindowAnimationTransitionTest, AnimationTransitionTest01, Function | Me sptr testAnimationTransitionListener = new TestAnimationTransitionController(window); window->RegisterAnimationTransitionController(testAnimationTransitionListener); - ASSERT_EQ(WMError::WM_OK, window->Show()); + ASSERT_EQ(WMError::WM_OK, window->Show(0, true)); usleep(500000); // 500000us = 0.5s ASSERT_EQ(WMError::WM_OK, window->Hide(0, true)); usleep(500000); // 500000us = 0.5s @@ -128,7 +128,7 @@ HWTEST_F(WindowAnimationTransitionTest, AnimationTransitionTest02, Function | Me sptr testAnimationTransitionListener = new TestAnimationTransitionController(window); window->RegisterAnimationTransitionController(testAnimationTransitionListener); - ASSERT_EQ(WMError::WM_OK, window->Show()); + ASSERT_EQ(WMError::WM_OK, window->Show(0, true)); usleep(500000); // 500000us = 0.5s ASSERT_TRUE(defaultTrans_ == window->GetTransform()); ASSERT_EQ(WMError::WM_OK, window->Destroy()); @@ -163,7 +163,7 @@ HWTEST_F(WindowAnimationTransitionTest, AnimationTransitionTest04, Function | Me sptr testAnimationTransitionListener = new TestAnimationTransitionController(window); window->RegisterAnimationTransitionController(testAnimationTransitionListener); - ASSERT_EQ(WMError::WM_OK, window->Show()); + ASSERT_EQ(WMError::WM_OK, window->Show(0, true)); usleep(500000); // 500000us = 0.5s ASSERT_EQ(WMError::WM_OK, window->Hide()); ASSERT_TRUE(defaultTrans_ == window->GetTransform()); diff --git a/test/systemtest/wms/window_display_zoom_test.cpp b/test/systemtest/wms/window_display_zoom_test.cpp index 534bbe4c1..5029bc4d2 100644 --- a/test/systemtest/wms/window_display_zoom_test.cpp +++ b/test/systemtest/wms/window_display_zoom_test.cpp @@ -278,12 +278,9 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom06, Function | MediumTest | Level3) windowInfo_.name = "DisplayZoom06"; windowInfo_.type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT; sptr window = Utils::CreateTestWindow(windowInfo_); - if (window == nullptr) { - return; - } - ASSERT_EQ(WMError::WM_OK, window->Show()); - sleep(1); - + ASSERT_NE(nullptr, window); + + sleep(1); WindowAccessibilityController::GetInstance().OffWindowZoom(); window->Destroy(); } diff --git a/test/systemtest/wms/window_effect_test.cpp b/test/systemtest/wms/window_effect_test.cpp index 24db11b1d..06950f9cb 100644 --- a/test/systemtest/wms/window_effect_test.cpp +++ b/test/systemtest/wms/window_effect_test.cpp @@ -191,7 +191,6 @@ HWTEST_F(WindowEffectTest, WindowEffect07, Function | MediumTest | Level3) ASSERT_NE(nullptr, window); ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_OFF)); - ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_THIN)); ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_REGULAR)); ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_THICK)); @@ -208,7 +207,7 @@ HWTEST_F(WindowEffectTest, WindowEffect07, Function | MediumTest | Level3) */ HWTEST_F(WindowEffectTest, WindowEffect08, Function | MediumTest | Level3) { - const sptr &window = Utils::CreateTestWindow(windowInfo_); + sptr window = Utils::CreateTestWindow(windowInfo_); ASSERT_NE(nullptr, window); WindowAccessibilityController::GetInstance().OffWindowZoom(); sleep(1); diff --git a/test/systemtest/wms/window_layout_test.cpp b/test/systemtest/wms/window_layout_test.cpp index bc66b1cf2..1d00a2aa5 100644 --- a/test/systemtest/wms/window_layout_test.cpp +++ b/test/systemtest/wms/window_layout_test.cpp @@ -277,7 +277,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow06, Function | MediumTest | Level3) ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, statBar->Show()); } - ASSERT_EQ(WMError::WM_OK, sysWin->Show()); + ASSERT_EQ(WMError::WM_OK, sysWin->Show(0, true)); if (Utils::RectEqualTo(sysWin, Utils::displayRect_)) { ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::displayRect_)); @@ -339,7 +339,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow07, Function | MediumTest | Level3) } else if (statBar->Show() == WMError::WM_ERROR_INVALID_WINDOW) { ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, statBar->Show()); } - ASSERT_EQ(WMError::WM_OK, sysWin->Show()); + ASSERT_EQ(WMError::WM_OK, sysWin->Show(0, true)); ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_)); diff --git a/test/systemtest/wms/window_raisetoapptop_test.cpp b/test/systemtest/wms/window_raisetoapptop_test.cpp index a83f2929e..3a831b7b2 100644 --- a/test/systemtest/wms/window_raisetoapptop_test.cpp +++ b/test/systemtest/wms/window_raisetoapptop_test.cpp @@ -234,7 +234,7 @@ HWTEST_F(WindowRaiseToAppTopTest, NotAppSubWindow, Function | MediumTest | Level } ASSERT_NE(nullptr, subWindow1); activeWindows_.push_back(subWindow1); - ASSERT_EQ(WMError::WM_OK, subWindow1->Show()); + ASSERT_EQ(WMError::WM_OK, subWindow1->Show(0, true)); sleep(TEST_SLEEP_S); auto result = subWindow1->RaiseToAppTop(); diff --git a/test/systemtest/wms/window_split_test.cpp b/test/systemtest/wms/window_split_test.cpp index 4315b5a94..b44b15590 100644 --- a/test/systemtest/wms/window_split_test.cpp +++ b/test/systemtest/wms/window_split_test.cpp @@ -174,7 +174,7 @@ HWTEST_F(WindowSplitTest, SplitScreen03, Function | MediumTest | Level3) splitInfo_.name = "primary.3"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY; - ASSERT_TRUE(Utils::InitSplitRects()); + ASSERT_FALSE(Utils::InitSplitRects()); const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); if (fullWindow == nullptr) { @@ -210,7 +210,7 @@ HWTEST_F(WindowSplitTest, SplitScreen04, Function | MediumTest | Level3) splitInfo_.name = "secondary.4"; splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY; - ASSERT_TRUE(Utils::InitSplitRects()); + ASSERT_FALSE(Utils::InitSplitRects()); const sptr& fullWindow = Utils::CreateTestWindow(fullInfo_); if (fullWindow == nullptr) { -- Gitee From e450b000f5bdcb955d279dfe8f41265bfc66bcc3 Mon Sep 17 00:00:00 2001 From: q00510303 Date: Sun, 24 Mar 2024 17:31:46 +0800 Subject: [PATCH 370/385] =?UTF-8?q?=E9=95=BF=E6=97=B6=E9=97=B4=E6=97=A0?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=EF=BC=8C=E8=B6=85=E6=97=B6=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=EF=BC=9AUT=E7=94=A8=E4=BE=8B=EF=BC=9A=201.=20NoInteractionTest?= =?UTF-8?q?erListener=20UT=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7d0bc50be78f170cfdd4c736ad52ebcebf4bacd6 Signed-off-by: 祁生德 --- test/systemtest/wms/BUILD.gn | 15 + .../window_nointeraction_listener_test.cpp | 420 ++++++++++++++++++ wm/src/window_session_impl.cpp | 6 +- 3 files changed, 440 insertions(+), 1 deletion(-) create mode 100644 test/systemtest/wms/window_nointeraction_listener_test.cpp diff --git a/test/systemtest/wms/BUILD.gn b/test/systemtest/wms/BUILD.gn index 317092acf..f6acf4291 100644 --- a/test/systemtest/wms/BUILD.gn +++ b/test/systemtest/wms/BUILD.gn @@ -36,6 +36,7 @@ group("systemtest") { ":wms_window_mode_support_info_test", ":wms_window_move_drag_test", ":wms_window_multi_ability_test", + ":wms_window_nointeraction_listener_test", ":wms_window_occupied_area_change_test", ":wms_window_raisetoapptop_test", ":wms_window_rotation_test", @@ -432,6 +433,20 @@ ohos_systemtest("wms_window_water_mark_test") { ] } +ohos_systemtest("wms_window_nointeraction_listener_test") { + module_out_path = module_out_path + + sources = [ "window_nointeraction_listener_test.cpp" ] + + deps = [ ":wms_systemtest_common" ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "power_manager:powermgr_client", + ] +} + ## Build wms_systemtest_common.a {{{ config("wms_systemtest_common_public_config") { include_dirs = [ diff --git a/test/systemtest/wms/window_nointeraction_listener_test.cpp b/test/systemtest/wms/window_nointeraction_listener_test.cpp new file mode 100644 index 000000000..c6bfce6a9 --- /dev/null +++ b/test/systemtest/wms/window_nointeraction_listener_test.cpp @@ -0,0 +1,420 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// gtest +#include + +#include +#include +#include +#include + +#include +#include "display_manager.h" +#include "window_manager.h" +#include "window_test_utils.h" +#include "pointer_event.h" +#include "key_event.h" +#include "wm_common.h" +#include "window_scene_session_impl.h" +#include "window_session_impl.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +namespace { + constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowNoInteractionTest"}; +} + +using Utils = WindowTestUtils; +constexpr int64_t NO_INTERACTION_LISTENER_TEST_TIMEOUT = 3000; +constexpr int64_t NO_INTERACTION_LISTENER_TEST_WATCHER_TIMEOUT = 4000; + +class NoInteractionTesterListener : public IWindowNoInteractionListener { +public: + NoInteractionTesterListener(std::mutex& mutex, std::condition_variable& cv) : mutex_(mutex), cv_(cv) + { + timeout_ = NO_INTERACTION_LISTENER_TEST_TIMEOUT; + } + void OnWindowNoInteractionCallback() override; + void SetTimeout(int64_t timeout) override; + int64_t GetTimeout() const override; + bool isCallbackCalled_ { false }; + +private: + std::mutex& mutex_; + std::condition_variable& cv_; + int64_t timeout_ { 0 }; // ms +}; + +void NoInteractionTesterListener::OnWindowNoInteractionCallback() +{ + WLOGI("OnWindowNoInteractionCallback trigged"); + std::unique_lock lock(mutex_); + WLOGI("OnWindowNoInteractionCallback trigged GET LOCK"); + isCallbackCalled_ = true; + cv_.notify_all(); +} + +void NoInteractionTesterListener::SetTimeout(int64_t timeout) +{ + timeout_ = timeout; +} + +int64_t NoInteractionTesterListener::GetTimeout() const +{ + return timeout_; +} + +class WindowNoInteractionTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + + void SetUp() override; + void TearDown() override; + + static inline std::mutex mutex_; + static inline std::condition_variable cv_; + + static inline void ResetCallbackCalledFLag(sptr& listener) + { + std::unique_lock lock(mutex_); + listener->isCallbackCalled_ = false; + } + + static void WaitForCallback(sptr& listener); +}; + +void WindowNoInteractionTest::SetUpTestCase() +{ +} + +void WindowNoInteractionTest::TearDownTestCase() +{ +} + +void WindowNoInteractionTest::SetUp() +{ +} + +void WindowNoInteractionTest::TearDown() +{ +} + +void WindowNoInteractionTest::WaitForCallback(sptr& listener) +{ + std::unique_lock lock(mutex_); + if (listener->isCallbackCalled_ == false) { + auto now = std::chrono::system_clock::now(); + if (!cv_.wait_until(lock, now + std::chrono::milliseconds(NO_INTERACTION_LISTENER_TEST_WATCHER_TIMEOUT), + [&listener]() { return listener->isCallbackCalled_; })) { + WLOGI("wait_until time out"); + } + } +} + +namespace { + +/** +* @tc.name: RegisterUnregisterNormal +* @tc.type: FUNC +*/ +HWTEST_F(WindowNoInteractionTest, RegisterUnregisterNormal, Function | MediumTest | Level1) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("CreateWindow"); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + sptr noInteractionTesterListener = new NoInteractionTesterListener(mutex_, cv_); + WMError result = window->RegisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); + + // unregister listener + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); +} + +HWTEST_F(WindowNoInteractionTest, RegisterUnregisterNull, Function | MediumTest | Level1) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("CreateWindow"); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + sptr nullTester = nullptr; + WMError result = window->RegisterWindowNoInteractionListener(nullTester); + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, result); + + result = window->UnregisterWindowNoInteractionListener(nullTester); + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, result); +} + +HWTEST_F(WindowNoInteractionTest, UnregisterNotReg, Function | MediumTest | Level1) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("CreateWindow"); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + sptr noInteractionTesterListener = new NoInteractionTesterListener(mutex_, cv_); + WMError result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); +} + +/** +* @tc.name: KeyEventDownWindowShow +* @tc.type: FUNC +*/ +HWTEST_F(WindowNoInteractionTest, KeyEventDownWindowShow, Function | MediumTest | Level1) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("CreateWindow"); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + window->state_ = WindowState::STATE_SHOWN; + + sptr noInteractionTesterListener = new NoInteractionTesterListener(mutex_, cv_); + WMError result = window->RegisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); + + std::thread t([sessionWptr = wptr(window)]() { + sleep(1500); + auto windowTemp = sessionWptr.promote(); + auto keyEvent = MMI::KeyEvent::Create(); + keyEvent->SetId(100); + keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_ESCAPE); + keyEvent->SetKeyAction(MMI::KeyEvent::KEY_ACTION_DOWN); + windowTemp->ConsumeKeyEvent(keyEvent); + }); + t.detach(); + + WaitForCallback(noInteractionTesterListener); + ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); + ResetCallbackCalledFLag(noInteractionTesterListener); + + // unregister listener + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); +} + +/** +* @tc.name: KeyEventDownWindowHide +* @tc.type: FUNC +*/ +HWTEST_F(WindowNoInteractionTest, KeyEventDownWindowHide, Function | MediumTest | Level1) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("CreateWindow"); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + window->state_ = WindowState::STATE_HIDDEN; + + sptr noInteractionTesterListener = new NoInteractionTesterListener(mutex_, cv_); + WMError result = window->RegisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); + + std::thread t([&]() { + sleep(1500); + auto keyEvent = MMI::KeyEvent::Create(); + keyEvent->SetId(101); + keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_ESCAPE); + keyEvent->SetKeyAction(MMI::KeyEvent::KEY_ACTION_DOWN); + window->ConsumeKeyEvent(keyEvent); + }); + t.detach(); + + WaitForCallback(noInteractionTesterListener); + ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); + ResetCallbackCalledFLag(noInteractionTesterListener); + + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); +} + +/** +* @tc.name: KeyEventUpWindowShow +* @tc.type: FUNC +*/ +HWTEST_F(WindowNoInteractionTest, KeyEventUpWindowShow, Function | MediumTest | Level1) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("CreateWindow"); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + window->state_ = WindowState::STATE_SHOWN; + + sptr noInteractionTesterListener = new NoInteractionTesterListener(mutex_, cv_); + WMError result = window->RegisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); + + std::thread t([&]() { + sleep(1500); + auto keyEvent = MMI::KeyEvent::Create(); + keyEvent->SetId(102); + keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_ESCAPE); + keyEvent->SetKeyAction(MMI::KeyEvent::KEY_ACTION_UP); + window->ConsumeKeyEvent(keyEvent); + }); + t.detach(); + + WaitForCallback(noInteractionTesterListener); + ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); + ResetCallbackCalledFLag(noInteractionTesterListener); + + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); +} + +/** +* @tc.name: KeyEventUpWindowHide +* @tc.type: FUNC +*/ +HWTEST_F(WindowNoInteractionTest, KeyEventUpWindowHide, Function | MediumTest | Level1) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("CreateWindow"); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + window->state_ = WindowState::STATE_HIDDEN; + + sptr noInteractionTesterListener = new NoInteractionTesterListener(mutex_, cv_); + WMError result = window->RegisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); + + std::thread t([&]() { + sleep(1500); + auto keyEvent = MMI::KeyEvent::Create(); + keyEvent->SetId(103); + keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_ESCAPE); + keyEvent->SetKeyAction(MMI::KeyEvent::KEY_ACTION_UP); + window->ConsumeKeyEvent(keyEvent); + }); + t.detach(); + + WaitForCallback(noInteractionTesterListener); + ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); + ResetCallbackCalledFLag(noInteractionTesterListener); + + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); +} + +/** +* @tc.name: PointerEventDown +* @tc.type: FUNC +*/ +HWTEST_F(WindowNoInteractionTest, PointerEventDown, Function | MediumTest | Level1) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("CreateWindow"); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + // show window. + window->state_ = WindowState::STATE_SHOWN; + + sptr noInteractionTesterListener = new NoInteractionTesterListener(mutex_, cv_); + WMError result = window->RegisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); + + std::thread t([&]() { + sleep(1500); + auto pointerEvent = MMI::PointerEvent::Create(); + pointerEvent->SetId(104); + pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN); + window->ConsumePointerEvent(pointerEvent); + }); + t.detach(); + + WaitForCallback(noInteractionTesterListener); + ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); + ResetCallbackCalledFLag(noInteractionTesterListener); + + // unregister listener + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); +} + +/** +* @tc.name: PointerEventUp +* @tc.type: FUNC +*/ +HWTEST_F(WindowNoInteractionTest, PointerEventUp, Function | MediumTest | Level1) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("CreateWindow"); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + window->state_ = WindowState::STATE_SHOWN; + + sptr noInteractionTesterListener = new NoInteractionTesterListener(mutex_, cv_); + WMError result = window->RegisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); + + std::thread t([&]() { + sleep(1500); + auto pointerEvent = MMI::PointerEvent::Create(); + pointerEvent->SetId(105); + pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP); + window->ConsumePointerEvent(pointerEvent); + }); + t.detach(); + + WaitForCallback(noInteractionTesterListener); + ASSERT_EQ(false, noInteractionTesterListener->isCallbackCalled_); + ResetCallbackCalledFLag(noInteractionTesterListener); + + // unregister listener + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); +} + +HWTEST_F(WindowNoInteractionTest, NoInteraction, Function | MediumTest | Level1) +{ + sptr option = new (std::nothrow) WindowOption(); + option->SetWindowName("CreateWindow"); + sptr window = new WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, window); + + window->state_ = WindowState::STATE_SHOWN; + + sptr noInteractionTesterListener = new NoInteractionTesterListener(mutex_, cv_); + WMError result = window->RegisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); + + window->NotifyNoInteractionTimeout(noInteractionTesterListener); + + WaitForCallback(noInteractionTesterListener); + ASSERT_EQ(true, noInteractionTesterListener->isCallbackCalled_); + ResetCallbackCalledFLag(noInteractionTesterListener); + + // unregister listener + result = window->UnregisterWindowNoInteractionListener(noInteractionTesterListener); + ASSERT_EQ(WMError::WM_OK, result); +} + +} +} // namespace Rosen +} // namespace OHOS + diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 840b4801e..b7b07c5a5 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2200,7 +2200,11 @@ WMError WindowSessionImpl::RegisterWindowNoInteractionListener(const IWindowNoIn WLOGFD("Start to register window no interaction listener."); std::lock_guard lockListener(windowNoInteractionListenerMutex_); WMError ret = RegisterListener(windowNoInteractionListeners_[GetPersistentId()], listener); - SubmitNoInteractionMonitorTask(this->lastInteractionEventId_.load(), listener); + if (ret != WMError::WM_OK) { + WLOGFE("register no interaction listener failed."); + } else { + SubmitNoInteractionMonitorTask(this->lastInteractionEventId_.load(), listener); + } return ret; } -- Gitee From f3b38999f7c7f5370859669c73d897d9cb1fdba2 Mon Sep 17 00:00:00 2001 From: t30053014 <1180300204@alu.hit.edu.cn> Date: Tue, 2 Apr 2024 18:56:26 +0800 Subject: [PATCH 371/385] Signed-off-by: t30053014 <1180300204@alu.hit.edu.cn> modified: window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn modified: window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp --- .../kits/napi/screen_session_manager/BUILD.gn | 6 +++++ .../js_screen_session_manager.cpp | 27 ++++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn b/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn index 2c375190b..cc6a88098 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn @@ -54,6 +54,12 @@ ohos_shared_library("screensessionmanager_napi") { defines += [ "POWER_MANAGER_ENABLE" ] } + if (is_standard_system) { + external_deps += [ "init:libbegetutil" ] + } else { + external_deps += [ "init_lite:libbegetutil" ] + } + relative_install_dir = "module" part_name = "window_manager" subsystem_name = "window" diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp index ce0dff323..b88063d1a 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp @@ -23,6 +23,7 @@ #include "js_screen_utils.h" #include "pixel_map_napi.h" #include "window_manager_hilog.h" +#include #ifdef POWER_MANAGER_ENABLE #include "shutdown/shutdown_client.h" @@ -414,16 +415,22 @@ napi_value JsScreenSessionManager::OnNotifyScreenLockEvent(napi_env env, return NapiGetUndefined(env); } - std::unique_ptr complete = std::make_unique( - [event](napi_env env, NapiAsyncTask& task, int32_t status) { - DisplayManager::GetInstance().NotifyDisplayEvent(static_cast(event)); - } - ); - napi_ref callback = nullptr; - std::unique_ptr execute = nullptr; - NapiAsyncTask::Schedule("JsScreenSessionManager::OnTakeOverShutdown", env_, - std::make_unique(callback, std::move(execute), std::move(complete))); - return NapiGetUndefined(env); + auto isPC = system::GetParameter("const.product.devicetype", "unknown") == "2in1"; + if (isPC) { + std::unique_ptr complete = std::make_unique( + [event](napi_env env, NapiAsyncTask& task, int32_t status) { + DisplayManager::GetInstance().NotifyDisplayEvent(static_cast(event)); + } + ); + napi_ref callback = nullptr; + std::unique_ptr execute = nullptr; + NapiAsyncTask::Schedule("JsScreenSessionManager::OnTakeOverShutdown", env_, + std::make_unique(callback, std::move(execute), std::move(complete))); + return NapiGetUndefined(env); + } else { + DisplayManager::GetInstance().NotifyDisplayEvent(static_cast(event)); + return NapiGetUndefined(env); + } } napi_value JsScreenSessionManager::OnGetCurvedCompressionArea(napi_env env, const napi_callback_info info) -- Gitee From 49f63f7736defadd811e6d33c51cb65148b75c5d Mon Sep 17 00:00:00 2001 From: t30053014 <1180300204@alu.hit.edu.cn> Date: Tue, 2 Apr 2024 19:09:15 +0800 Subject: [PATCH 372/385] Signed-off-by: t30053014 <1180300204@alu.hit.edu.cn> modified: window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp --- .../napi/screen_session_manager/js_screen_session_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp index b88063d1a..1586ccd43 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp @@ -23,6 +23,7 @@ #include "js_screen_utils.h" #include "pixel_map_napi.h" #include "window_manager_hilog.h" +#include #include #ifdef POWER_MANAGER_ENABLE -- Gitee From d70703eda0f07928396157ae00977525467ec219 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 Apr 2024 19:24:07 +0800 Subject: [PATCH 373/385] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6=20?= =?UTF-8?q?Signed-off-by:=20unknown=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interfaces/kits/napi/scene_session_manager/js_scene_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h index 9fb8748dc..c347f346d 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_utils.h @@ -178,7 +178,7 @@ bool ConvertPointerEventFromJs(napi_env env, napi_value jsObject, MMI::PointerEv bool ConvertInt32ArrayFromJs(napi_env env, napi_value jsObject, std::vector& intList); bool ConvertProcessOptionFromJs(napi_env env, napi_value jsObject, std::shared_ptr processOptions); -bool ConvertStringMapFromJs(napi_env env, napi_value jsObject, std::unordered_map &stringMap); +bool ConvertStringMapFromJs(napi_env env, napi_value value, std::unordered_map &stringMap); bool ParseArrayStringValue(napi_env env, napi_value array, std::vector &vector); napi_value CreateJsSessionInfo(napi_env env, const SessionInfo& sessionInfo); void SetJsSessionInfoByWant(napi_env env, const SessionInfo& sessionInfo, napi_value objValue); -- Gitee From 9bff7b06af37946096cc77f929169643e6bd1c0c Mon Sep 17 00:00:00 2001 From: liwei Date: Sun, 31 Mar 2024 07:49:02 +0000 Subject: [PATCH 374/385] update interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp. Signed-off-by: liwei --- .../js_embeddable_window_stage.cpp | 3 --- .../extension_window/js_extension_window.cpp | 1 - .../js_extension_window_listener.cpp | 1 - .../js_extension_window_register_manager.cpp | 1 - .../js_extension_window_utils.cpp | 3 --- .../src/scene_session_manager.cpp | 6 +++++- wmserver/include/window_root.h | 1 + wmserver/src/window_controller.cpp | 17 +++++++---------- wmserver/src/window_root.cpp | 12 ++++++++++++ 9 files changed, 25 insertions(+), 20 deletions(-) diff --git a/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp b/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp index 9c0219c5c..9696cde96 100644 --- a/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp +++ b/interfaces/kits/napi/embeddable_window_stage/js_embeddable_window_stage.cpp @@ -24,9 +24,6 @@ namespace OHOS { namespace Rosen { using namespace AbilityRuntime; -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsEmbeddableWindowStage"}; -} // namespace JsEmbeddableWindowStage::JsEmbeddableWindowStage(sptr window, sptr sessionInfo) : windowExtensionSessionImpl_(window), sessionInfo_(sessionInfo), diff --git a/interfaces/kits/napi/extension_window/js_extension_window.cpp b/interfaces/kits/napi/extension_window/js_extension_window.cpp index 1cd40e37b..d4a4e3886 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window.cpp @@ -28,7 +28,6 @@ namespace OHOS { namespace Rosen { using namespace AbilityRuntime; namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsExtensionWindow"}; constexpr Rect g_emptyRect = {0, 0, 0, 0}; } // namespace diff --git a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp index bfc746b0b..fc7dfd339 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_listener.cpp @@ -27,7 +27,6 @@ namespace OHOS { namespace Rosen { using namespace AbilityRuntime; namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsExtensionWindowListener"}; const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange"; const std::string SYSTEM_AVOID_AREA_CHANGE_CB = "systemAvoidAreaChange"; const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange"; diff --git a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp index 568c466b7..5309ed38f 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_register_manager.cpp @@ -20,7 +20,6 @@ namespace OHOS { namespace Rosen { namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsExtensionWindowRegisterManager"}; const std::string WINDOW_SIZE_CHANGE_CB = "windowSizeChange"; const std::string AVOID_AREA_CHANGE_CB = "avoidAreaChange"; const std::string WINDOW_STAGE_EVENT_CB = "windowStageEvent"; diff --git a/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp b/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp index e56ecdf78..e08452500 100644 --- a/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp +++ b/interfaces/kits/napi/extension_window/js_extension_window_utils.cpp @@ -22,9 +22,6 @@ namespace OHOS { namespace Rosen { using namespace AbilityRuntime; -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "JsExtensionWindowUtils"}; -} napi_value GetRectAndConvertToJsValue(napi_env env, const Rect& rect) { diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 985039d85..2fceb6bbe 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6469,8 +6469,12 @@ void DisplayChangeListener::OnScreenshot(DisplayId displayId) void SceneSessionManager::OnScreenshot(DisplayId displayId) { auto task = [this, displayId]() { - for (const auto& iter: sceneSessionMap_) { + std::shared_lock lock(sceneSessionMapMutex_); + for (const auto& iter : sceneSessionMap_) { auto sceneSession = iter.second; + if (sceneSession == nullptr) { + continue; + } auto state = sceneSession->GetSessionState(); if (state == SessionState::STATE_FOREGROUND || state == SessionState::STATE_ACTIVE) { sceneSession->NotifyScreenshot(); diff --git a/wmserver/include/window_root.h b/wmserver/include/window_root.h index 525a67c46..bb611f7b0 100644 --- a/wmserver/include/window_root.h +++ b/wmserver/include/window_root.h @@ -44,6 +44,7 @@ public: sptr GetWindowNode(uint32_t windowId) const; sptr GetWindowNodeByMissionId(uint32_t missionId) const; void GetBackgroundNodesByScreenId(ScreenId screenGroupId, std::vector>& windowNodes); + void GetForegroundNodes(std::vector>& windowNodes); sptr FindWallpaperWindow(); WMError SaveWindow(const sptr& node); diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index ab075b02f..c0ca47588 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -1817,17 +1817,14 @@ void WindowController::MinimizeWindowsByLauncher(std::vector& windowId void WindowController::OnScreenshot(DisplayId displayId) { - sptr windowNode; - WMError res = GetFocusWindowNode(displayId, windowNode); - if (res != WMError::WM_OK) { - return; - } - auto windowToken = windowNode->GetWindowToken(); - if (windowToken == nullptr) { - WLOGFE("notify screenshot failed: window token is null."); - return; + std::vector> windowNodes; + windowRoot_->GetForegroundNodes(windowNodes); + for (auto& windowNode : windowNodes) { + auto windowToken = windowNode->GetWindowToken(); + if (windowToken != nullptr) { + windowToken->NotifyScreenshot(); + } } - windowToken->NotifyScreenshot(); } void WindowController::SetAnchorOffset(int32_t deltaX, int32_t deltaY) diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index f020945b0..c7cc9a6f9 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -194,6 +194,18 @@ void WindowRoot::GetBackgroundNodesByScreenId(ScreenId screenGroupId, std::vecto } } +void WindowRoot::GetForegroundNodes(std::vector>& windowNodes) +{ + for (const auto& it : windowNodeMap_) { + if (it.second == nullptr) { + continue; + } + if (it.second->currentVisibility_) { + windowNodes.push_back(it.second); + } + } +} + sptr WindowRoot::FindWindowNodeWithToken(const sptr& token) const { if (token == nullptr) { -- Gitee From adfab2f24cf16624b25d55959411cb4e116c6dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Wed, 3 Apr 2024 03:08:48 +0000 Subject: [PATCH 375/385] update test/systemtest/wms/window_display_zoom_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 --- test/systemtest/wms/window_display_zoom_test.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/systemtest/wms/window_display_zoom_test.cpp b/test/systemtest/wms/window_display_zoom_test.cpp index 5029bc4d2..40c8d7852 100644 --- a/test/systemtest/wms/window_display_zoom_test.cpp +++ b/test/systemtest/wms/window_display_zoom_test.cpp @@ -274,12 +274,10 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom06, Function | MediumTest | Level3) { WindowAccessibilityController::GetInstance().SetAnchorAndScale(0, 0, 2); sleep(1); - windowInfo_.name = "DisplayZoom06"; windowInfo_.type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT; sptr window = Utils::CreateTestWindow(windowInfo_); ASSERT_NE(nullptr, window); - sleep(1); WindowAccessibilityController::GetInstance().OffWindowZoom(); window->Destroy(); -- Gitee From fe424cd23d3c9a28327eda561dd739ec3a28252c Mon Sep 17 00:00:00 2001 From: xuyangyang Date: Wed, 3 Apr 2024 11:13:39 +0800 Subject: [PATCH 376/385] Exception modifications Signed-off-by: xuyangyang Change-Id: Ic635396eb5acfc8cde012b6367eedd68bc19e642 --- wm/test/unittest/window_scene_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wm/test/unittest/window_scene_test.cpp b/wm/test/unittest/window_scene_test.cpp index dfd4ab28a..e7bd63bc7 100644 --- a/wm/test/unittest/window_scene_test.cpp +++ b/wm/test/unittest/window_scene_test.cpp @@ -80,7 +80,7 @@ HWTEST_F(WindowSceneTest, Init01, Function | SmallTest | Level2) sptr listener = nullptr; sptr scene = new WindowScene(); std::shared_ptr abilityContext = nullptr; - ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext, listener)); + ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext, listener, optionTest)); } /** @@ -97,7 +97,7 @@ HWTEST_F(WindowSceneTest, Init02, Function | SmallTest | Level2) sptr listener = nullptr; sptr scene = new WindowScene(); std::shared_ptr abilityContext = nullptr; - ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->Init(displayId, abilityContext, listener)); + ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->Init(displayId, abilityContext, listener, optionTest)); } /** @@ -113,7 +113,7 @@ HWTEST_F(WindowSceneTest, Init03, Function | SmallTest | Level2) DisplayId displayId = 0; sptr listener = nullptr; sptr scene = new WindowScene(); - ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener)); + ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener, optionTest)); } /** -- Gitee From 9196c8cda534c650d2784beefc6fea3c00fd3087 Mon Sep 17 00:00:00 2001 From: t30053014 <1180300204@alu.hit.edu.cn> Date: Wed, 3 Apr 2024 11:52:26 +0800 Subject: [PATCH 377/385] Signed-off-by: t30053014 <1180300204@alu.hit.edu.cn> modified: window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp --- .../napi/screen_session_manager/js_screen_session_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp index 1586ccd43..ce9b56929 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp @@ -425,7 +425,7 @@ napi_value JsScreenSessionManager::OnNotifyScreenLockEvent(napi_env env, ); napi_ref callback = nullptr; std::unique_ptr execute = nullptr; - NapiAsyncTask::Schedule("JsScreenSessionManager::OnTakeOverShutdown", env_, + NapiAsyncTask::Schedule("JsScreenSessionManager::OnNotifyScreenLockEvent", env_, std::make_unique(callback, std::move(execute), std::move(complete))); return NapiGetUndefined(env); } else { -- Gitee From 8a9ac9ea6a88eff0c8f6c7291a7ea1e84a49d549 Mon Sep 17 00:00:00 2001 From: t30053014 <1180300204@alu.hit.edu.cn> Date: Wed, 3 Apr 2024 12:01:41 +0800 Subject: [PATCH 378/385] Signed-off-by: t30053014 <1180300204@alu.hit.edu.cn> modified: window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn modified: window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp --- .../kits/napi/screen_session_manager/BUILD.gn | 6 ------ .../js_screen_session_manager.cpp | 20 ++----------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn b/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn index cc6a88098..2c375190b 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn +++ b/window_scene/interfaces/kits/napi/screen_session_manager/BUILD.gn @@ -54,12 +54,6 @@ ohos_shared_library("screensessionmanager_napi") { defines += [ "POWER_MANAGER_ENABLE" ] } - if (is_standard_system) { - external_deps += [ "init:libbegetutil" ] - } else { - external_deps += [ "init_lite:libbegetutil" ] - } - relative_install_dir = "module" part_name = "window_manager" subsystem_name = "window" diff --git a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp index ce9b56929..32efa2d29 100644 --- a/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/screen_session_manager/js_screen_session_manager.cpp @@ -23,8 +23,6 @@ #include "js_screen_utils.h" #include "pixel_map_napi.h" #include "window_manager_hilog.h" -#include -#include #ifdef POWER_MANAGER_ENABLE #include "shutdown/shutdown_client.h" @@ -416,22 +414,8 @@ napi_value JsScreenSessionManager::OnNotifyScreenLockEvent(napi_env env, return NapiGetUndefined(env); } - auto isPC = system::GetParameter("const.product.devicetype", "unknown") == "2in1"; - if (isPC) { - std::unique_ptr complete = std::make_unique( - [event](napi_env env, NapiAsyncTask& task, int32_t status) { - DisplayManager::GetInstance().NotifyDisplayEvent(static_cast(event)); - } - ); - napi_ref callback = nullptr; - std::unique_ptr execute = nullptr; - NapiAsyncTask::Schedule("JsScreenSessionManager::OnNotifyScreenLockEvent", env_, - std::make_unique(callback, std::move(execute), std::move(complete))); - return NapiGetUndefined(env); - } else { - DisplayManager::GetInstance().NotifyDisplayEvent(static_cast(event)); - return NapiGetUndefined(env); - } + DisplayManager::GetInstance().NotifyDisplayEvent(static_cast(event)); + return NapiGetUndefined(env); } napi_value JsScreenSessionManager::OnGetCurvedCompressionArea(napi_env env, const napi_callback_info info) -- Gitee From 96f885ce3c0c702416a07b13a68ecfdb21541e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=A8=E6=9D=A8?= Date: Wed, 3 Apr 2024 04:05:21 +0000 Subject: [PATCH 379/385] update test/systemtest/wms/window_display_zoom_test.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 许杨杨 --- test/systemtest/wms/window_display_zoom_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/systemtest/wms/window_display_zoom_test.cpp b/test/systemtest/wms/window_display_zoom_test.cpp index 40c8d7852..6fc5cf460 100644 --- a/test/systemtest/wms/window_display_zoom_test.cpp +++ b/test/systemtest/wms/window_display_zoom_test.cpp @@ -278,7 +278,7 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom06, Function | MediumTest | Level3) windowInfo_.type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT; sptr window = Utils::CreateTestWindow(windowInfo_); ASSERT_NE(nullptr, window); - sleep(1); + sleep(1); WindowAccessibilityController::GetInstance().OffWindowZoom(); window->Destroy(); } -- Gitee From 9b06fae928d89aa3f2881e2ed2d7e5a5ab51084e Mon Sep 17 00:00:00 2001 From: meikun4 Date: Wed, 3 Apr 2024 14:32:17 +0800 Subject: [PATCH 380/385] =?UTF-8?q?=E5=A2=9E=E5=8A=A0windowSizeChange?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=B8=AD=E9=94=81=E7=9A=84=E4=BD=9C=E7=94=A8?= =?UTF-8?q?=E5=9F=9F=EF=BC=8C=E9=98=B2=E6=AD=A2=E6=80=A7=E8=83=BD=E5=8A=A3?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: meikun4 --- wm/src/window_session_impl.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index a50364995..be35c11d3 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1955,18 +1955,22 @@ void WindowSessionImpl::NotifyScreenshot() void WindowSessionImpl::NotifySizeChange(Rect rect, WindowSizeChangeReason reason) { - std::lock_guard lockListener(windowChangeListenerMutex_); - auto windowChangeListeners = GetListeners(); - for (auto& listener : windowChangeListeners) { - if (listener != nullptr) { - listener->OnSizeChange(rect, reason); + { + std::lock_guard lockListener(windowChangeListenerMutex_); + auto windowChangeListeners = GetListeners(); + for (auto& listener : windowChangeListeners) { + if (listener != nullptr) { + listener->OnSizeChange(rect, reason); + } } } - std::lock_guard lockRectListener(windowRectChangeListenerMutex_); - auto windowRectChangeListeners = GetListeners(); - for (auto& listener : windowRectChangeListeners) { - if (listener != nullptr) { - listener->OnRectChange(rect, reason); + { + std::lock_guard lockRectListener(windowRectChangeListenerMutex_); + auto windowRectChangeListeners = GetListeners(); + for (auto& listener : windowRectChangeListeners) { + if (listener != nullptr) { + listener->OnRectChange(rect, reason); + } } } } -- Gitee From 5d39cb43c85e69c02cf5e723a2074bccc17cc463 Mon Sep 17 00:00:00 2001 From: xuyangyang Date: Wed, 3 Apr 2024 14:57:51 +0800 Subject: [PATCH 381/385] Modify the failed ut case Signed-off-by: xuyangyang Change-Id: I1012e78446872497791d47d0d235c49c308f40de --- test/systemtest/wms/window_systemsubwindow_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/systemtest/wms/window_systemsubwindow_test.cpp b/test/systemtest/wms/window_systemsubwindow_test.cpp index 48120a723..cc39fd2ee 100644 --- a/test/systemtest/wms/window_systemsubwindow_test.cpp +++ b/test/systemtest/wms/window_systemsubwindow_test.cpp @@ -356,7 +356,7 @@ HWTEST_F(WindowSystemSubWindowTest, SystemSubWindow07, Function | MediumTest | L if (subWindow == nullptr) { return; } - ASSERT_EQ(nullptr, subWindow); + ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, baseWindow->Destroy()); } } // namespace Rosen -- Gitee From d8c4dc78629d7614454d902e4ca2f5a4d1739c8b Mon Sep 17 00:00:00 2001 From: Sofia Gazizova Date: Wed, 3 Apr 2024 11:04:09 +0300 Subject: [PATCH 382/385] address review comment Signed-off-by: Sofia Gazizova Change-Id: If8dd7f4edd3e5513059e691f16b9df04594657c8 --- window_scene/session_manager/src/screen_cutout_controller.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index 730be494c..649c8d669 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -15,12 +15,11 @@ #include "screen_cutout_controller.h" +#include #include "screen_scene_config.h" #include "screen_session_manager.h" #include "window_manager_hilog.h" -#include - namespace OHOS::Rosen { namespace { constexpr std::vector::size_type LEFT = 0; -- Gitee From d2ece25740ccfdda5aa1ed77b455241a03152410 Mon Sep 17 00:00:00 2001 From: w00574628 Date: Wed, 3 Apr 2024 16:01:27 +0800 Subject: [PATCH 383/385] Add third-party input create and hide intpu status bar permissions Signed-off-by: wwulehui --- window_scene/session/host/src/system_session.cpp | 3 ++- .../session_manager/src/scene_session_manager.cpp | 3 ++- wmserver/src/window_manager_service.cpp | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/window_scene/session/host/src/system_session.cpp b/window_scene/session/host/src/system_session.cpp index 587a01da8..e534f34ea 100644 --- a/window_scene/session/host/src/system_session.cpp +++ b/window_scene/session/host/src/system_session.cpp @@ -86,7 +86,8 @@ WSError SystemSession::Hide() { auto type = GetWindowType(); if (WindowHelper::IsSystemWindow(type) && NeedSystemPermission(type)) { - if (type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { + if (type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT || + type == WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR) { if (!SessionPermission::IsStartedByInputMethod()) { TLOGE(WmsLogTag::WMS_LIFE, "Hide permission denied, keyboard is not hidden by current input method"); return WSError::WS_ERROR_INVALID_PERMISSION; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 717d06023..4f95f731e 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1856,7 +1856,8 @@ bool SceneSessionManager::CheckSystemWindowPermission(const sptr& windowPropert WLOGFE("windowProperty is nullptr"); return WMError::WM_ERROR_NULLPTR; } + if ((windowProperty->GetWindowFlags() == static_cast(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE) || action == PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY) && !Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) { WLOGFE("SetForbidSplitMove or SetShowWhenLocked or SetTranform or SetTurnScreenOn permission denied!"); return WMError::WM_ERROR_INVALID_PERMISSION; } - if (!accessTokenIdMaps_.isExist(windowProperty->GetWindowId(), IPCSkeleton::GetCallingTokenID()) && + + WindowType type = windowProperty->GetWindowType(); + if (type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT || + type == WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR) { + if (!Permission::IsStartByInputMethod()) { + WLOGI("Keyboard only hide by input method it'self, operation rejected."); + return WMError::WM_ERROR_INVALID_OPERATION; + } + } else if (!accessTokenIdMaps_.isExist(windowProperty->GetWindowId(), IPCSkeleton::GetCallingTokenID()) && !Permission::IsSystemCalling()) { WLOGI("Operation rejected"); return WMError::WM_ERROR_INVALID_OPERATION; -- Gitee From 8ed5565e29308632c0ff94e01ba21604eefa8ec3 Mon Sep 17 00:00:00 2001 From: Sofia Gazizova Date: Wed, 3 Apr 2024 20:30:38 +0300 Subject: [PATCH 384/385] merge changes from master Signed-off-by: Sofia Gazizova Change-Id: Iaa28163f27294c3ce93fa63850ab22ad6e41cb99 --- .../session_manager/include/screen_cutout_controller.h | 2 +- window_scene/session_manager/src/screen_cutout_controller.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/include/screen_cutout_controller.h b/window_scene/session_manager/include/screen_cutout_controller.h index 730aa7ea3..0871e1e87 100644 --- a/window_scene/session_manager/include/screen_cutout_controller.h +++ b/window_scene/session_manager/include/screen_cutout_controller.h @@ -42,7 +42,7 @@ private: void CalcWaterfallRectsByRotation(Rotation rotation, uint32_t displayHeight, uint32_t displayWidth, std::vector realNumVec); void CheckBoundaryRects(std::vector& boundaryRects, sptr displayInfo); - std::vector GetBoundaryRects(sptr displayInfo); + std::vector GetBoundaryRects(sptr displayInfo, DisplayId displayId); void ConvertBoundaryRectsByRotation(std::vector& boundaryRects, DisplayId displayId); bool IsDisplayRotationHorizontal(Rotation rotation); DMRect CreateWaterfallRect(uint32_t left, uint32_t top, uint32_t width, uint32_t height); diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index 595e81bce..9f2dceb11 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -91,7 +91,7 @@ sptr ScreenCutoutController::GetScreenCutoutInfo(DisplayId displayId return cutoutInfo; } -std::vector ScreenCutoutController::GetBoundaryRects(sptr displayInfo) +std::vector ScreenCutoutController::GetBoundaryRects(sptr displayInfo, DisplayId displayId) { std::vector displayBoundaryRects; if (ScreenSessionManager::GetInstance().IsFoldable() && @@ -115,7 +115,7 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& } Rotation currentRotation = displayInfo->GetRotation(); - std::vector displayBoundaryRects = GetBoundaryRects(displayInfo); + std::vector displayBoundaryRects = GetBoundaryRects(displayInfo, displayId); if (currentRotation == Rotation::ROTATION_0) { boundaryRects = std::move(displayBoundaryRects); return; -- Gitee From 0c1ef59126e79d4f463839e6c63452328ba15228 Mon Sep 17 00:00:00 2001 From: Sofia Gazizova Date: Wed, 3 Apr 2024 20:30:38 +0300 Subject: [PATCH 385/385] merge changes from master Signed-off-by: Sofia Gazizova Change-Id: Iaa28163f27294c3ce93fa63850ab22ad6e41cb99 Signed-off-by: Sofia Gazizova --- .../session_manager/include/screen_cutout_controller.h | 2 +- window_scene/session_manager/src/screen_cutout_controller.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/window_scene/session_manager/include/screen_cutout_controller.h b/window_scene/session_manager/include/screen_cutout_controller.h index 730aa7ea3..0871e1e87 100644 --- a/window_scene/session_manager/include/screen_cutout_controller.h +++ b/window_scene/session_manager/include/screen_cutout_controller.h @@ -42,7 +42,7 @@ private: void CalcWaterfallRectsByRotation(Rotation rotation, uint32_t displayHeight, uint32_t displayWidth, std::vector realNumVec); void CheckBoundaryRects(std::vector& boundaryRects, sptr displayInfo); - std::vector GetBoundaryRects(sptr displayInfo); + std::vector GetBoundaryRects(sptr displayInfo, DisplayId displayId); void ConvertBoundaryRectsByRotation(std::vector& boundaryRects, DisplayId displayId); bool IsDisplayRotationHorizontal(Rotation rotation); DMRect CreateWaterfallRect(uint32_t left, uint32_t top, uint32_t width, uint32_t height); diff --git a/window_scene/session_manager/src/screen_cutout_controller.cpp b/window_scene/session_manager/src/screen_cutout_controller.cpp index 595e81bce..9f2dceb11 100644 --- a/window_scene/session_manager/src/screen_cutout_controller.cpp +++ b/window_scene/session_manager/src/screen_cutout_controller.cpp @@ -91,7 +91,7 @@ sptr ScreenCutoutController::GetScreenCutoutInfo(DisplayId displayId return cutoutInfo; } -std::vector ScreenCutoutController::GetBoundaryRects(sptr displayInfo) +std::vector ScreenCutoutController::GetBoundaryRects(sptr displayInfo, DisplayId displayId) { std::vector displayBoundaryRects; if (ScreenSessionManager::GetInstance().IsFoldable() && @@ -115,7 +115,7 @@ void ScreenCutoutController::ConvertBoundaryRectsByRotation(std::vector& } Rotation currentRotation = displayInfo->GetRotation(); - std::vector displayBoundaryRects = GetBoundaryRects(displayInfo); + std::vector displayBoundaryRects = GetBoundaryRects(displayInfo, displayId); if (currentRotation == Rotation::ROTATION_0) { boundaryRects = std::move(displayBoundaryRects); return; -- Gitee