diff --git a/adapter/ohos/entrance/ui_session/ui_session_manager.cpp b/adapter/ohos/entrance/ui_session/ui_session_manager.cpp index 70095adf3af..08077dbd8b7 100644 --- a/adapter/ohos/entrance/ui_session/ui_session_manager.cpp +++ b/adapter/ohos/entrance/ui_session/ui_session_manager.cpp @@ -183,4 +183,14 @@ void UiSessionManager::ReportInspectorTreeValue(const std::string& data) } } } + +void UiSessionManager::OnRouterChange(const std::string& path, const std::string& event) +{ + if (GetRouterChangeEventRegistered()) { + auto value = InspectorJsonUtil::Create(true); + value->Put("path", path.c_str()); + value->Put("event", event.c_str()); + ReportRouterChangeEvent(value->ToString()); + } +} } // namespace OHOS::Ace diff --git a/frameworks/core/components_ng/pattern/navigation/navigation_group_node.cpp b/frameworks/core/components_ng/pattern/navigation/navigation_group_node.cpp index 88615012296..5809d269612 100644 --- a/frameworks/core/components_ng/pattern/navigation/navigation_group_node.cpp +++ b/frameworks/core/components_ng/pattern/navigation/navigation_group_node.cpp @@ -15,6 +15,9 @@ #include "core/components_ng/pattern/navigation/navigation_group_node.h" +#if !defined(PREVIEW) && !defined(ACE_UNITTEST) +#include "interfaces/inner_api/ui_session/ui_session_manager.h" +#endif #include "base/log/ace_checker.h" #include "base/log/ace_performance_check.h" #include "base/memory/ace_type.h" @@ -588,6 +591,9 @@ void NavigationGroupNode::TransitionWithPop(const RefPtr& preNode, co SetNeedSetInvisible(false); } isOnAnimation_ = true; +#if !defined(PREVIEW) && !defined(ACE_UNITTEST) + UiSessionManager::GetInstance().OnRouterChange(navigationPathInfo_, "navigationPopPage"); +#endif } void NavigationGroupNode::TransitionWithPush(const RefPtr& preNode, const RefPtr& curNode, @@ -767,6 +773,9 @@ void NavigationGroupNode::TransitionWithPush(const RefPtr& preNode, c nodeMap, endTime - startTime, navigation->GetNavigationPathInfo()); }); } +#if !defined(PREVIEW) && !defined(ACE_UNITTEST) + UiSessionManager::GetInstance().OnRouterChange(navigationPathInfo_, "navigationPushPage"); +#endif } std::shared_ptr NavigationGroupNode::BackButtonAnimation( diff --git a/frameworks/core/components_ng/pattern/stage/stage_manager.cpp b/frameworks/core/components_ng/pattern/stage/stage_manager.cpp index c608ec6095a..b08e5c95e6d 100644 --- a/frameworks/core/components_ng/pattern/stage/stage_manager.cpp +++ b/frameworks/core/components_ng/pattern/stage/stage_manager.cpp @@ -17,12 +17,15 @@ #include +#if !defined(PREVIEW) && !defined(ACE_UNITTEST) +#include "interfaces/inner_api/ui_session/ui_session_manager.h" +#endif #include "base/geometry/ng/size_t.h" #include "base/log/ace_checker.h" #include "base/log/ace_performance_check.h" -#include "base/perfmonitor/perf_monitor.h" -#include "base/perfmonitor/perf_constants.h" #include "base/memory/referenced.h" +#include "base/perfmonitor/perf_constants.h" +#include "base/perfmonitor/perf_monitor.h" #include "base/utils/time_util.h" #include "base/utils/utils.h" #include "core/animation/page_transition_common.h" @@ -188,6 +191,9 @@ bool StageManager::PushPage(const RefPtr& node, bool needHideLast, bo CHECK_NULL_RETURN(pageInfo, false); auto pagePath = pageInfo->GetFullPath(); ACE_SCOPED_TRACE_COMMERCIAL("Router Main Page: %s", pagePath.c_str()); +#if !defined(PREVIEW) && !defined(ACE_UNITTEST) + UiSessionManager::GetInstance().OnRouterChange(pagePath, "routerPushPage"); +#endif } if (needTransition) { pipeline->FlushPipelineImmediately(); diff --git a/interfaces/inner_api/ui_session/ui_session_manager.h b/interfaces/inner_api/ui_session/ui_session_manager.h index c3c8bbabd7b..f02f5ec4328 100644 --- a/interfaces/inner_api/ui_session/ui_session_manager.h +++ b/interfaces/inner_api/ui_session/ui_session_manager.h @@ -71,6 +71,7 @@ public: void SaveInspectorTreeFunction(InspectorFunction&& function); void SetClickEventRegistered(bool status); void SetSearchEventRegistered(bool status); + void OnRouterChange(const std::string& path, const std::string& event); void SetRouterChangeEventRegistered(bool status); void SetComponentChangeEventRegistered(bool status); bool GetClickEventRegistered();