diff --git a/frameworks/native/runtime/js_module_reader.cpp b/frameworks/native/runtime/js_module_reader.cpp index 03509317f5..1977d0cba5 100755 --- a/frameworks/native/runtime/js_module_reader.cpp +++ b/frameworks/native/runtime/js_module_reader.cpp @@ -262,13 +262,19 @@ std::string JsModuleReader::GetPresetAppHapPath(const std::string& inputPath, co void JsModuleReader::GetHapPathList(const std::string &bundleName, std::vector &hapList) { - auto bundleMgrHelper = DelayedSingleton::GetInstance(); - if (bundleMgrHelper == nullptr) { - TAG_LOGE(AAFwkTag::JSRUNTIME, "null bundleMgrHelper"); + auto systemAbilityManagerClient = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (!systemAbilityManagerClient) { + TAG_LOGE(AAFwkTag::JSRUNTIME, "null systemAbilityManagerClient"); return; } + auto remoteObject = systemAbilityManagerClient->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); + if (!remoteObject) { + TAG_LOGE(AAFwkTag::JSRUNTIME, "null remoteObject"); + return; + } + auto bundleMgrProxy = iface_cast(remoteObject); AppExecFwk::BundleInfo bundleInfo; - auto getInfoResult = bundleMgrHelper->GetBundleInfoForSelf(static_cast(AppExecFwk::GetBundleInfoFlag:: + auto getInfoResult = bundleMgrProxy->GetBundleInfoForSelf(static_cast(AppExecFwk::GetBundleInfoFlag:: GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo); if (getInfoResult != 0 || bundleInfo.hapModuleInfos.empty()) { TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBundleInfoForSelf failed");