From a0048c30de82e7076f2d0c335f92685ca0edc284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=9E=E6=BC=AA?= <15575970019@163.com> Date: Thu, 17 Oct 2024 14:55:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=83=E6=9C=8D=E5=8A=A1=E5=88=86=E5=8C=85?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=85=88=E6=9B=B4=E6=96=B0=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E8=A1=A8=E7=84=B6=E5=90=8E=E5=87=BA=E5=8F=91pushpath=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=A0=E6=97=B6=E5=BA=8F=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E9=A1=B5=E9=9D=A2=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 连漪 <15575970019@163.com> --- adapter/ohos/osal/navigation_route_ohos.cpp | 5 ----- adapter/ohos/osal/navigation_route_ohos.h | 5 ++--- .../navpushpathhelper/include/hsp_silentinstall.h | 1 + .../navpushpathhelper/include/hsp_silentinstall_napi.h | 1 + .../navpushpathhelper/navpushpathhelper.js | 7 +++++++ .../navpushpathhelper/src/hsp_silentinstall.cpp | 9 +++++++++ .../navpushpathhelper/src/hsp_silentinstall_napi.cpp | 6 ++++++ .../navpushpathhelper/src/navpushpathhelper.cpp | 1 + .../pattern/navigation/navigation_group_node.cpp | 9 --------- .../components_ng/pattern/navigation/navigation_route.h | 7 +++---- 10 files changed, 30 insertions(+), 21 deletions(-) diff --git a/adapter/ohos/osal/navigation_route_ohos.cpp b/adapter/ohos/osal/navigation_route_ohos.cpp index 8ebcadbcc11..d3dc564fbf4 100644 --- a/adapter/ohos/osal/navigation_route_ohos.cpp +++ b/adapter/ohos/osal/navigation_route_ohos.cpp @@ -54,11 +54,6 @@ void NavigationRouteOhos::InitRouteMap() moduleInfos_ = bundleInfo.hapModuleInfos; } -void NavigationRouteOhos::OnPackageChange() -{ - InitRouteMap(); -} - bool NavigationRouteOhos::GetRouteItem(const std::string& name, NG::RouteItem& info) { AppExecFwk::RouterItem routeItem; diff --git a/adapter/ohos/osal/navigation_route_ohos.h b/adapter/ohos/osal/navigation_route_ohos.h index 40c5c12f575..96c4cd70c9c 100644 --- a/adapter/ohos/osal/navigation_route_ohos.h +++ b/adapter/ohos/osal/navigation_route_ohos.h @@ -43,13 +43,12 @@ public: int32_t LoadPage(const std::string& name) override; bool IsNavigationItemExits(const std::string& name) override; - - void OnPackageChange() override; + + void InitRouteMap() override; private: bool GetRouteItemFromBundle(const std::string& name, AppExecFwk::RouterItem& routeItem); int32_t LoadPageFromHapModule(const std::string& name); - void InitRouteMap(); sptr GetBundleManager(); AppExecFwk::RouterItem GetRouteItem(const std::string name); std::vector allRouteItems_; diff --git a/advanced_ui_component/navpushpathhelper/include/hsp_silentinstall.h b/advanced_ui_component/navpushpathhelper/include/hsp_silentinstall.h index 6337fcf89e7..b52bd4ae84a 100644 --- a/advanced_ui_component/navpushpathhelper/include/hsp_silentinstall.h +++ b/advanced_ui_component/navpushpathhelper/include/hsp_silentinstall.h @@ -28,6 +28,7 @@ public: static int32_t SilentInstall(const std::string& moduleName, const std::function& callback, const std::function& silentInstallErrorCallBack); static bool IsHspExist(const std::string& moduleName, const std::string& pathName); + static void InitRouteMap(); private: static OHOS::sptr GetBundleManager(); diff --git a/advanced_ui_component/navpushpathhelper/include/hsp_silentinstall_napi.h b/advanced_ui_component/navpushpathhelper/include/hsp_silentinstall_napi.h index 4ccee0910b9..1f1cd341676 100644 --- a/advanced_ui_component/navpushpathhelper/include/hsp_silentinstall_napi.h +++ b/advanced_ui_component/navpushpathhelper/include/hsp_silentinstall_napi.h @@ -26,6 +26,7 @@ class HspSilentInstallNapi { public: static napi_value SilentInstall(napi_env env, napi_callback_info info); static napi_value IsHspExist(napi_env env, napi_callback_info info); + static napi_value InitRouteMap(napi_env env, napi_callback_info info); private: struct CallbackData { diff --git a/advanced_ui_component/navpushpathhelper/navpushpathhelper.js b/advanced_ui_component/navpushpathhelper/navpushpathhelper.js index 34baa4c0885..8d804a80d2a 100644 --- a/advanced_ui_component/navpushpathhelper/navpushpathhelper.js +++ b/advanced_ui_component/navpushpathhelper/navpushpathhelper.js @@ -34,6 +34,7 @@ export class NavPushPathHelper { } return new Promise((resolve, reject) => { navPushPathHelperApi.silentInstall(moduleName, () => { + navPushPathHelperApi.initRouteMap(); this.navPathStack_?.pushPath(info, optionParam); resolve(); }, @@ -53,6 +54,7 @@ export class NavPushPathHelper { } return new Promise((resolve, reject) => { navPushPathHelperApi.silentInstall(moduleName, () => { + navPushPathHelperApi.initRouteMap(); this.navPathStack_?.pushDestination(info, optionParam) .then(resolve).catch(reject); }, (error) => { @@ -71,6 +73,7 @@ export class NavPushPathHelper { } return new Promise((resolve, reject) => { navPushPathHelperApi.silentInstall(moduleName, () => { + navPushPathHelperApi.initRouteMap(); this.navPathStack_?.pushPathByName(name, param, onPop, optionParam); resolve(); }, (error) => { @@ -89,6 +92,7 @@ export class NavPushPathHelper { } return new Promise((resolve, reject) => { navPushPathHelperApi.silentInstall(moduleName, () => { + navPushPathHelperApi.initRouteMap(); this.navPathStack_?.pushDestinationByName(name, param, onPop, optionParam) .then(resolve).catch(reject); }, (error) => { @@ -107,6 +111,7 @@ export class NavPushPathHelper { } return new Promise((resolve, reject) => { navPushPathHelperApi.silentInstall(moduleName, () => { + navPushPathHelperApi.initRouteMap(); this.navPathStack_?.replacePath(info, optionParam); resolve(); }, (error) => { @@ -125,6 +130,8 @@ export class NavPushPathHelper { } return new Promise((resolve, reject) => { navPushPathHelperApi.silentInstall(moduleName, () => { + hilog.info(0x3900, tag, `silentInstall success`); + navPushPathHelperApi.initRouteMap(); this.navPathStack_?.replacePathByName(name, param, optionParam); resolve(); }, (error) => { diff --git a/advanced_ui_component/navpushpathhelper/src/hsp_silentinstall.cpp b/advanced_ui_component/navpushpathhelper/src/hsp_silentinstall.cpp index 907871b56d3..c7e82ba5657 100644 --- a/advanced_ui_component/navpushpathhelper/src/hsp_silentinstall.cpp +++ b/advanced_ui_component/navpushpathhelper/src/hsp_silentinstall.cpp @@ -105,4 +105,13 @@ bool HspSilentInstall::IsHspExist(const std::string &moduleName, const std::stri } return false; } + +void HspSilentInstall::InitRouteMap() +{ + auto container = OHOS::Ace::Container::CurrentSafely(); + CHECK_NULL_VOID(container); + auto navigationRoute = container->GetNavigationRoute(); + CHECK_NULL_VOID(navigationRoute); + navigationRoute->InitRouteMap(); +} } // namespace OHOS::NavPushPathHelper \ No newline at end of file diff --git a/advanced_ui_component/navpushpathhelper/src/hsp_silentinstall_napi.cpp b/advanced_ui_component/navpushpathhelper/src/hsp_silentinstall_napi.cpp index 18882737953..8370486d235 100644 --- a/advanced_ui_component/navpushpathhelper/src/hsp_silentinstall_napi.cpp +++ b/advanced_ui_component/navpushpathhelper/src/hsp_silentinstall_napi.cpp @@ -56,6 +56,12 @@ napi_value HspSilentInstallNapi::IsHspExist(napi_env env, napi_callback_info inf return jsResult; } +napi_value HspSilentInstallNapi::InitRouteMap(napi_env env, napi_callback_info info) +{ + HspSilentInstall::InitRouteMap(); + return nullptr; +} + napi_value HspSilentInstallNapi::SilentInstall(napi_env env, napi_callback_info info) { napi_value result = nullptr; diff --git a/advanced_ui_component/navpushpathhelper/src/navpushpathhelper.cpp b/advanced_ui_component/navpushpathhelper/src/navpushpathhelper.cpp index 95a8eefe291..bf54cc18dbe 100644 --- a/advanced_ui_component/navpushpathhelper/src/navpushpathhelper.cpp +++ b/advanced_ui_component/navpushpathhelper/src/navpushpathhelper.cpp @@ -34,6 +34,7 @@ namespace OHOS::NavPushPathHelper { napi_property_descriptor desc[] = { DECLARE_NAPI_FUNCTION("silentInstall", HspSilentInstallNapi::SilentInstall), DECLARE_NAPI_FUNCTION("isHspExist", HspSilentInstallNapi::IsHspExist), + DECLARE_NAPI_FUNCTION("initRouteMap", HspSilentInstallNapi::InitRouteMap), }; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); return exports; 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 71d1f872592..ed4be731e66 100644 --- a/frameworks/core/components_ng/pattern/navigation/navigation_group_node.cpp +++ b/frameworks/core/components_ng/pattern/navigation/navigation_group_node.cpp @@ -32,7 +32,6 @@ #include "core/components_ng/pattern/navigation/navigation_declaration.h" #include "core/components_ng/pattern/navigation/navigation_pattern.h" #include "core/components_ng/pattern/navigation/navigation_title_util.h" -#include "core/event/package/package_event_proxy.h" namespace OHOS::Ace::NG { namespace { @@ -1046,14 +1045,6 @@ void NavigationGroupNode::OnAttachToMainTree(bool recursive) if (!findNavdestination) { pipelineContext->AddNavigationNode(pageId, WeakClaim(this)); } - auto* eventProxy = PackageEventProxy::GetInstance(); - if (eventProxy) { - auto container = OHOS::Ace::Container::CurrentSafely(); - CHECK_NULL_VOID(container); - auto navigationRoute = container->GetNavigationRoute(); - CHECK_NULL_VOID(navigationRoute); - eventProxy->Register(WeakClaim(AceType::RawPtr(navigationRoute))); - } } void NavigationGroupNode::FireHideNodeChange(NavDestinationLifecycle lifecycle) diff --git a/frameworks/core/components_ng/pattern/navigation/navigation_route.h b/frameworks/core/components_ng/pattern/navigation/navigation_route.h index 2e25e568f32..a8454facf79 100644 --- a/frameworks/core/components_ng/pattern/navigation/navigation_route.h +++ b/frameworks/core/components_ng/pattern/navigation/navigation_route.h @@ -19,7 +19,6 @@ #include #include "base/memory/ace_type.h" #include "base/memory/referenced.h" -#include "core/event/package/package_change_listener.h" namespace OHOS::Ace::NG { using NavigationLoadPageCallback = std::function data; }; -class ACE_EXPORT NavigationRoute : public PackageChangeListener { - DECLARE_ACE_TYPE(NavigationRoute, PackageChangeListener); +class ACE_EXPORT NavigationRoute : public AceType { + DECLARE_ACE_TYPE(NavigationRoute, AceType); public: NavigationRoute() = default; ~NavigationRoute() = default; @@ -65,7 +64,7 @@ public: return false; } - void OnPackageChange() override {} + virtual void InitRouteMap() {} protected: NavigationLoadPageCallback callback_; -- Gitee