From f6cfe69eae7138985ff720d6f48bcd18ee53900d Mon Sep 17 00:00:00 2001 From: zhuhan Date: Thu, 13 Apr 2023 11:27:10 +0800 Subject: [PATCH] ndk nameapace Signed-off-by: zhuhan Change-Id: I146e95060f9cd7fec9ea3769be532e7a91dd8390 --- frameworks/native/appkit/app/main_thread.cpp | 13 ++++++++----- frameworks/native/runtime/js_runtime.cpp | 4 ++-- interfaces/inner_api/runtime/include/js_runtime.h | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 17e39b28b7..e90fcc9fe5 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -136,9 +136,6 @@ void GetNativeLibPath(const BundleInfo &bundleInfo, const HspList &hspList, AppL for (auto &hapInfo : bundleInfo.hapModuleInfos) { HILOG_DEBUG("name: %{public}s, isLibIsolated: %{public}d, nativeLibraryPath: %{public}s", hapInfo.name.c_str(), hapInfo.isLibIsolated, hapInfo.nativeLibraryPath.c_str()); - if (!hapInfo.isLibIsolated) { - continue; - } std::string appLibPathKey = hapInfo.bundleName + "/" + hapInfo.moduleName; // libraries in patch lib path has a higher priority when loading. @@ -151,7 +148,11 @@ void GetNativeLibPath(const BundleInfo &bundleInfo, const HspList &hspList, AppL } std::string libPath = LOCAL_CODE_PATH; - libPath += (libPath.back() == '/') ? hapInfo.nativeLibraryPath : "/" + hapInfo.nativeLibraryPath; + if (hapInfo.isLibIsolated) { + libPath += (libPath.back() == '/') ? hapInfo.nativeLibraryPath : "/" + hapInfo.nativeLibraryPath; + } else { + libPath += (libPath.back() == '/') ? nativeLibraryPath : "/" + nativeLibraryPath; + } HILOG_DEBUG("appLibPathKey: %{private}s, libPath: %{private}s", appLibPathKey.c_str(), libPath.c_str()); appLibPaths[appLibPathKey].emplace_back(libPath); } @@ -1193,7 +1194,9 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con } AppLibPathMap appLibPaths {}; GetNativeLibPath(bundleInfo, hspList, appLibPaths); - AbilityRuntime::JsRuntime::SetAppLibPath(appLibPaths); + bool isSystemApp = bundleInfo.applicationInfo.isSystemApp; + HILOG_DEBUG("the application isSystemApp: %{public}d", isSystemApp); + AbilityRuntime::JsRuntime::SetAppLibPath(appLibPaths, isSystemApp); if (isStageBased) { // Create runtime diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index 8f4837ea4a..5dba10105e 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -607,7 +607,7 @@ bool JsRuntime::InitLoop(const std::shared_ptr& eventRu return true; } -void JsRuntime::SetAppLibPath(const AppLibPathMap& appLibPaths) +void JsRuntime::SetAppLibPath(const AppLibPathMap& appLibPaths, const bool& isSystemApp) { HILOG_DEBUG("Set library path."); @@ -623,7 +623,7 @@ void JsRuntime::SetAppLibPath(const AppLibPathMap& appLibPaths) } for (const auto &appLibPath : appLibPaths) { - moduleManager->SetAppLibPath(appLibPath.first, appLibPath.second); + moduleManager->SetAppLibPath(appLibPath.first, appLibPath.second, isSystemApp); } } diff --git a/interfaces/inner_api/runtime/include/js_runtime.h b/interfaces/inner_api/runtime/include/js_runtime.h index 77acc55333..dd15dbc613 100644 --- a/interfaces/inner_api/runtime/include/js_runtime.h +++ b/interfaces/inner_api/runtime/include/js_runtime.h @@ -61,7 +61,7 @@ public: static std::unique_ptr LoadSystemModuleByEngine(NativeEngine* engine, const std::string& moduleName, NativeValue* const* argv, size_t argc); - static void SetAppLibPath(const AppLibPathMap& appLibPaths); + static void SetAppLibPath(const AppLibPathMap& appLibPaths, const bool& isSystemApp = false); static bool ReadSourceMapData(const std::string& hapPath, std::string& content);