diff --git a/adapter/ohos/entrance/hap_asset_provider.cpp b/adapter/ohos/entrance/hap_asset_provider.cpp index 9b487a59a1759360455e8f712db4928f9cbca362..83f45a74059a3519c08660dd5f231713588a796e 100644 --- a/adapter/ohos/entrance/hap_asset_provider.cpp +++ b/adapter/ohos/entrance/hap_asset_provider.cpp @@ -42,6 +42,12 @@ bool HapAssetProvider::IsValid() const return true; } +void HapAssetProvider::Reload() +{ + LOGI("Reload runtimeExtractor"); + runtimeExtractor_ = AbilityRuntime::RuntimeExtractor::Create(hapPath_); +} + class HapAssetMapping : public fml::Mapping { public: explicit HapAssetMapping(const std::ostringstream& ostream) diff --git a/adapter/ohos/entrance/hap_asset_provider.h b/adapter/ohos/entrance/hap_asset_provider.h index 811b0d4175a460e19656a9fb2ad081a0ccf239f1..78c002bc03759e67bef465fa9d8ba745de5e5c9c 100644 --- a/adapter/ohos/entrance/hap_asset_provider.h +++ b/adapter/ohos/entrance/hap_asset_provider.h @@ -46,6 +46,8 @@ public: void GetAssetList(const std::string& path, std::vector& assetList) override; + void Reload() override; + private: mutable std::mutex mutex_; std::string hapPath_; diff --git a/adapter/ohos/entrance/ui_content_impl.cpp b/adapter/ohos/entrance/ui_content_impl.cpp index 3ebd6bb7d88aefaab3ba40db5d8f46dffbc2a137..be13727cf0db5e8d153aa51a5ab5be055cffbc78 100644 --- a/adapter/ohos/entrance/ui_content_impl.cpp +++ b/adapter/ohos/entrance/ui_content_impl.cpp @@ -1222,7 +1222,10 @@ void UIContentImpl::ReloadForm() LOGI("ReloadForm startUrl = %{public}s", startUrl_.c_str()); auto container = Platform::AceContainer::GetContainer(instanceId_); auto flutterAssetManager = AceType::DynamicCast(container->GetAssetManager()); + flutterAssetManager->ReloadProvider(); Platform::AceContainer::ClearEngineCache(instanceId_); + Platform::AceContainer::RunPage(instanceId_, Platform::AceContainer::GetContainer(instanceId_)->GeneratePageId(), + startUrl_, ""); } void UIContentImpl::Focus() diff --git a/frameworks/base/resource/asset_manager.h b/frameworks/base/resource/asset_manager.h index c04a90309a75d62bbcf5804a09a39ca69c82d9d7..09df67dc68072da5cb05f13a4471593ff53f22e1 100644 --- a/frameworks/base/resource/asset_manager.h +++ b/frameworks/base/resource/asset_manager.h @@ -63,6 +63,8 @@ public: virtual std::string GetAppLibPathKey() const = 0; virtual void GetAssetList(const std::string& path, std::vector& assetList) const = 0; + + virtual void Reload() {} }; } // namespace OHOS::Ace diff --git a/frameworks/core/common/flutter/flutter_asset_manager.cpp b/frameworks/core/common/flutter/flutter_asset_manager.cpp index de4b056332278ac61f9fc3e2523bd4599d7aa823..b37daa353a7fa90e3c897c89948296aa8c5179b8 100644 --- a/frameworks/core/common/flutter/flutter_asset_manager.cpp +++ b/frameworks/core/common/flutter/flutter_asset_manager.cpp @@ -54,4 +54,11 @@ void FlutterAssetManager::GetAssetList(const std::string& path, std::vectorReload(); + } +} + } // namespace OHOS::Ace diff --git a/frameworks/core/common/flutter/flutter_asset_manager.h b/frameworks/core/common/flutter/flutter_asset_manager.h index 702e19ae896b34f6fe22607c1dfa97ba4a5dfbaa..fbc8fceccb8db1d0cfcb1b705c582ab067a4fff5 100644 --- a/frameworks/core/common/flutter/flutter_asset_manager.h +++ b/frameworks/core/common/flutter/flutter_asset_manager.h @@ -100,6 +100,8 @@ public: void GetAssetList(const std::string& path, std::vector& assetList) const override; + void ReloadProvider(); + private: std::deque> providers_; std::vector packagePath_;