mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
@@ -2397,9 +2397,13 @@ void MainThread::DoUpdatePluginInfoInstalled(std::vector<AppExecFwk::PluginBundl
|
||||
application_->UpdateApplicationInfoInstalled(*applicationInfo_);
|
||||
AppLibPathMap appLibPaths {};
|
||||
GetPluginNativeLibPath(pluginBundleInfos, appLibPaths);
|
||||
AbilityRuntime::JsRuntime::SetAppLibPath(appLibPaths, applicationInfo_->isSystemApp);
|
||||
AbilityRuntime::JsRuntime::SetOrUpdateLibPath(appLibPaths, applicationInfo_->isSystemApp);
|
||||
std::vector<std::string> moduleNames;
|
||||
for (const auto &appLibPath : appLibPaths) {
|
||||
moduleNames.emplace_back(appLibPath.first);
|
||||
}
|
||||
if (IsPluginNamespaceInherited()) {
|
||||
AbilityRuntime::JsRuntime::InheritPluginNamespace(pluginModuleNames);
|
||||
AbilityRuntime::JsRuntime::InheritPluginNamespace(moduleNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -919,6 +919,31 @@ void JsRuntime::SetAppLibPath(const AppLibPathMap& appLibPaths, const bool& isSy
|
||||
}
|
||||
}
|
||||
|
||||
void JsRuntime::SetOrUpdateLibPath(const AppLibPathMap& appLibPaths, const bool& isSystemApp)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "SetOrUpdate library path");
|
||||
|
||||
if (appLibPaths.size() == 0) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "no lib path to set");
|
||||
return;
|
||||
}
|
||||
|
||||
auto moduleManager = NativeModuleManager::GetInstance();
|
||||
if (moduleManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "null moduleManager");
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &appLibPath : appLibPaths) {
|
||||
std::string pluginNamespace;
|
||||
if (moduleManager->GetLdNamespaceName(appLibPath.first, pluginNamespace)) {
|
||||
moduleManager->UpdateNamespaceLibPath(appLibPath.first, appLibPath.second);
|
||||
} else {
|
||||
moduleManager->SetAppLibPath(appLibPath.first, appLibPath.second, isSystemApp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JsRuntime::InheritPluginNamespace(const std::vector<std::string> &moduleNames)
|
||||
{
|
||||
auto moduleManager = NativeModuleManager::GetInstance();
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
static std::unique_ptr<JsRuntime> Create(const Options& options);
|
||||
|
||||
static void SetAppLibPath(const AppLibPathMap& appLibPaths, const bool& isSystemApp = false);
|
||||
static void SetOrUpdateLibPath(const AppLibPathMap& appLibPaths, const bool& isSystemApp = false);
|
||||
static void InheritPluginNamespace(const std::vector<std::string> &moduleNames);
|
||||
static void CreatePluginDefaultNamespace(const std::string &lddictorys);
|
||||
|
||||
|
||||
@@ -1956,5 +1956,26 @@ HWTEST_F(JsRuntimeTest, RegisterUncatchableExceptionHandler_0100, TestSize.Level
|
||||
EXPECT_NE(jsRuntime, nullptr);
|
||||
TAG_LOGI(AAFwkTag::TEST, "RegisterUncatchableExceptionHandler_0100 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: JsRuntimeTestSetOrUpdateLibPath_0100
|
||||
* @tc.desc: JsRuntime Test for SetOrUpdateLibPath
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI581RO
|
||||
*/
|
||||
HWTEST_F(JsRuntimeTest, JsRuntimeTestSetOrUpdateLibPath_0100, TestSize.Level2)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "SetOrUpdateLibPath_0100 start");
|
||||
std::string appLibPathKey = TEST_BUNDLE_NAME + TEST_MODULE_NAME;
|
||||
std::string libPath = TEST_LIB_PATH;
|
||||
|
||||
AppLibPathMap appLibPaths {};
|
||||
JsRuntime::SetOrUpdateLibPath(appLibPaths);
|
||||
|
||||
appLibPaths[appLibPathKey].emplace_back(libPath);
|
||||
JsRuntime::SetOrUpdateLibPath(appLibPaths);
|
||||
EXPECT_NE(appLibPaths.size(), 0);
|
||||
TAG_LOGI(AAFwkTag::TEST, "SetOrUpdateLibPath_0100 end");
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
Reference in New Issue
Block a user