diff options
author | Justin Yun <justinyun@google.com> | 2020-02-18 11:29:07 +0900 |
---|---|---|
committer | Justin Yun <justinyun@google.com> | 2020-02-21 10:40:23 +0900 |
commit | eb4f08c577ca3d39d14ada321ea5f9c7444bd06a (patch) | |
tree | 0018cd8ff6e7d0705d0662be909e0ff61b4d84f2 /libnativeloader/library_namespaces.cpp | |
parent | 272b36d1b5cbab951239b32ed679a9dbc4ffdf1a (diff) |
Use a different VNDK namespace for product apps
As product partition may have a different VNDK version than that of
vendor partition, they may not share the same VNDK namespace for
their apps.
Define a new vndk_product namespace in the system section for product
apps that uses ro.product.vndk.version.
Bug: 149063221
Test: atest libnativeloader_test
Change-Id: I1bb76617104a49b0d11af13d2f116959a18390a3
Diffstat (limited to 'libnativeloader/library_namespaces.cpp')
-rw-r--r-- | libnativeloader/library_namespaces.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp index 3d74e2d3e5..dfbdefd53d 100644 --- a/libnativeloader/library_namespaces.cpp +++ b/libnativeloader/library_namespaces.cpp @@ -42,6 +42,7 @@ namespace { // vendor and system namespaces. constexpr const char* kVendorNamespaceName = "sphal"; constexpr const char* kVndkNamespaceName = "vndk"; +constexpr const char* kVndkProductNamespaceName = "vndk_product"; constexpr const char* kArtNamespaceName = "com_android_art"; constexpr const char* kNeuralNetworksNamespaceName = "com_android_neuralnetworks"; constexpr const char* kCronetNamespaceName = "com_android_cronet"; @@ -172,12 +173,12 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t std::string system_exposed_libraries = default_public_libraries(); std::string namespace_name = kClassloaderNamespaceName; - bool unbundled_vendor_or_product_app = false; + ApkOrigin unbundled_app_origin = APK_ORIGIN_DEFAULT; if ((apk_origin == APK_ORIGIN_VENDOR || (apk_origin == APK_ORIGIN_PRODUCT && is_product_vndk_version_defined())) && !is_shared) { - unbundled_vendor_or_product_app = true; + unbundled_app_origin = apk_origin; // For vendor / product apks, give access to the vendor / product lib even though // they are treated as unbundled; the libs and apks are still bundled // together in the vendor / product partition. @@ -275,11 +276,22 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t } } - // Give access to VNDK-SP libraries from the 'vndk' namespace. - if (unbundled_vendor_or_product_app && !vndksp_libraries().empty()) { + // Give access to VNDK-SP libraries from the 'vndk' namespace for unbundled vendor apps. + if (unbundled_app_origin == APK_ORIGIN_VENDOR && !vndksp_libraries_vendor().empty()) { auto vndk_ns = NativeLoaderNamespace::GetExportedNamespace(kVndkNamespaceName, is_bridged); if (vndk_ns.ok()) { - linked = app_ns->Link(*vndk_ns, vndksp_libraries()); + linked = app_ns->Link(*vndk_ns, vndksp_libraries_vendor()); + if (!linked.ok()) { + return linked.error(); + } + } + } + + // Give access to VNDK-SP libraries from the 'vndk_product' namespace for unbundled product apps. + if (unbundled_app_origin == APK_ORIGIN_PRODUCT && !vndksp_libraries_product().empty()) { + auto vndk_ns = NativeLoaderNamespace::GetExportedNamespace(kVndkProductNamespaceName, is_bridged); + if (vndk_ns.ok()) { + linked = app_ns->Link(*vndk_ns, vndksp_libraries_product()); if (!linked.ok()) { return linked.error(); } |