diff options
author | 2024-01-30 21:33:09 +0000 | |
---|---|---|
committer | 2024-02-15 18:22:04 +0000 | |
commit | 8a9b51e34f3769a5e3ea3a4383e3f00489088738 (patch) | |
tree | 37b3705e0387d216b50bc2d1e027b1f8ccf5f914 /libnativeloader/library_namespaces.h | |
parent | 149b912110c31a2e1e69930e48fed8bbfbe04700 (diff) |
Refactorings to make more logic available at the top level in
native_loader.cpp.
- Make the code that determines the partition from the dex path
available to code in native_loader.cpp, and rename it since it'll be
applied to arbitrary paths, not just APK's.
- Move the linker namespace constants to a header file.
- Various other minor code cleanups.
To prepare for a later CL that needs to access these things from
OpenNativeLibrary. No functional changes.
Test: atest libnativeloader_e2e_tests libnativeloader_test
Bug: 237577392
Change-Id: Ifc762bf6d4664b2d477c4ed3af58f149fb4c1189
Diffstat (limited to 'libnativeloader/library_namespaces.h')
-rw-r--r-- | libnativeloader/library_namespaces.h | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/libnativeloader/library_namespaces.h b/libnativeloader/library_namespaces.h index 4871528f47..25edf4faf7 100644 --- a/libnativeloader/library_namespaces.h +++ b/libnativeloader/library_namespaces.h @@ -21,20 +21,40 @@ #error "Not available for host or linux target" #endif -#define LOG_TAG "nativeloader" - -#include "native_loader_namespace.h" - #include <list> #include <string> -#include <android-base/result.h> -#include <jni.h> +#include "android-base/result.h" +#include "jni.h" +#include "native_loader_namespace.h" namespace android::nativeloader { using android::base::Result; +// The device may be configured to have the vendor libraries loaded to a separate namespace. +// For historical reasons this namespace was named sphal but effectively it is intended +// to use to load vendor libraries to separate namespace with controlled interface between +// vendor and system namespaces. +constexpr const char* kVendorNamespaceName = "sphal"; +// Similar to sphal namespace, product namespace provides some product libraries. +constexpr const char* kProductNamespaceName = "product"; + +// vndk namespace for unbundled vendor apps +constexpr const char* kVndkNamespaceName = "vndk"; +// vndk_product namespace for unbundled product apps +constexpr const char* kVndkProductNamespaceName = "vndk_product"; + +// API domains, roughly corresponding to partitions. Interdependencies between +// these must follow API restrictions, while intradependencies do not. +using ApiDomain = enum { + API_DOMAIN_DEFAULT = 0, // Locations other than those below, in particular for ordinary apps + API_DOMAIN_VENDOR = 1, // Vendor partition + API_DOMAIN_PRODUCT = 2, // Product partition +}; + +nativeloader::ApiDomain GetApiDomainFromPath(const std::string& path); + // LibraryNamespaces is a singleton object that manages NativeLoaderNamespace // objects for an app process. Its main job is to create (and configure) a new // NativeLoaderNamespace object for a Java ClassLoader, and to find an existing @@ -53,10 +73,15 @@ class LibraryNamespaces { initialized_ = false; app_main_namespace_ = nullptr; } - Result<NativeLoaderNamespace*> Create(JNIEnv* env, uint32_t target_sdk_version, - jobject class_loader, bool is_shared, jstring dex_path, - jstring java_library_path, jstring java_permitted_path, - jstring uses_library_list); + Result<NativeLoaderNamespace*> Create(JNIEnv* env, + uint32_t target_sdk_version, + jobject class_loader, + ApiDomain api_domain, + bool is_shared, + const std::string& dex_path, + jstring library_path_j, + jstring permitted_path_j, + jstring uses_library_list_j); NativeLoaderNamespace* FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader); private: |