diff options
author | 2020-01-29 16:09:38 +0900 | |
---|---|---|
committer | 2020-02-07 03:25:40 +0000 | |
commit | 99c19ca707391f0908313c7cee2ef315d2b5cb3c (patch) | |
tree | c5213c3eb212732c88cc455e8ca67c1990d29767 | |
parent | cf0c6ef642517fba3bc9a211acaed742ff39b86d (diff) |
Update platform namespace name
Platform namespace has been renamed as 'system' from linkerconfig
generator. To meet this requirement, libnativeloader should search for
namespace 'system' rather than namespace 'platform'.
Bug: 147987608
Test: m -j passed
Test: atest libnativeloader_test passed
Change-Id: I23d865ac71a80619f291eb9ae0761a2cad5df352
-rw-r--r-- | libnativeloader/library_namespaces.cpp | 8 | ||||
-rw-r--r-- | libnativeloader/native_loader_namespace.cpp | 20 | ||||
-rw-r--r-- | libnativeloader/native_loader_namespace.h | 2 | ||||
-rw-r--r-- | libnativeloader/native_loader_test.cpp | 6 |
4 files changed, 18 insertions, 18 deletions
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp index 3be379a8da..a9b22468ee 100644 --- a/libnativeloader/library_namespaces.cpp +++ b/libnativeloader/library_namespaces.cpp @@ -52,7 +52,7 @@ constexpr const char* kCronetNamespaceName = "cronet"; // classloader, the classloader-namespace namespace associated with that // classloader is selected for dlopen. The namespace is configured so that its // search path is set to the app-local JNI directory and it is linked to the -// platform namespace with the names of libs listed in the public.libraries.txt. +// system namespace with the names of libs listed in the public.libraries.txt. // This way an app can only load its own JNI libraries along with the public libs. constexpr const char* kClassloaderNamespaceName = "classloader-namespace"; // Same thing for vendor APKs. @@ -61,7 +61,7 @@ constexpr const char* kVendorClassloaderNamespaceName = "vendor-classloader-name // "classloader-namespace-shared" or "vendor-classloader-namespace-shared", // respectively. A shared namespace (cf. ANDROID_NAMESPACE_TYPE_SHARED) has // inherited all the libraries of the parent classloader namespace, or the -// platform namespace for the main app classloader. It is used to give full +// system namespace for the main app classloader. It is used to give full // access to the platform libraries for apps bundled in the system image, // including their later updates installed in /data. constexpr const char* kSharedNamespaceSuffix = "-shared"; @@ -241,7 +241,7 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t // ... and link to other namespaces to allow access to some public libraries bool is_bridged = app_ns->IsBridged(); - auto platform_ns = NativeLoaderNamespace::GetPlatformNamespace(is_bridged); + auto platform_ns = NativeLoaderNamespace::GetSystemNamespace(is_bridged); if (!platform_ns) { return platform_ns.error(); } @@ -293,7 +293,7 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, uint32_t t if (!vendor_public_libraries().empty()) { auto vendor_ns = NativeLoaderNamespace::GetExportedNamespace(kVendorNamespaceName, is_bridged); - // when vendor_ns is not configured, link to the platform namespace + // when vendor_ns is not configured, link to the system namespace auto target_ns = vendor_ns ? vendor_ns : platform_ns; if (target_ns) { linked = app_ns->Link(*target_ns, vendor_public_libraries()); diff --git a/libnativeloader/native_loader_namespace.cpp b/libnativeloader/native_loader_namespace.cpp index fff3191a75..6faa78cdde 100644 --- a/libnativeloader/native_loader_namespace.cpp +++ b/libnativeloader/native_loader_namespace.cpp @@ -35,7 +35,7 @@ namespace android { namespace { constexpr const char* kDefaultNamespaceName = "default"; -constexpr const char* kPlatformNamespaceName = "platform"; +constexpr const char* kSystemNamespaceName = "system"; std::string GetLinkerError(bool is_bridged) { const char* msg = is_bridged ? NativeBridgeGetError() : dlerror(); @@ -63,11 +63,11 @@ Result<NativeLoaderNamespace> NativeLoaderNamespace::GetExportedNamespace(const return Errorf("namespace {} does not exist or exported", name); } -// The platform namespace is called "default" for binaries in /system and -// "platform" for those in the Runtime APEX. Try "platform" first since +// The system namespace is called "default" for binaries in /system and +// "system" for those in the Runtime APEX. Try "system" first since // "default" always exists. -Result<NativeLoaderNamespace> NativeLoaderNamespace::GetPlatformNamespace(bool is_bridged) { - auto ns = GetExportedNamespace(kPlatformNamespaceName, is_bridged); +Result<NativeLoaderNamespace> NativeLoaderNamespace::GetSystemNamespace(bool is_bridged) { + auto ns = GetExportedNamespace(kSystemNamespaceName, is_bridged); if (ns) return ns; ns = GetExportedNamespace(kDefaultNamespaceName, is_bridged); if (ns) return ns; @@ -93,12 +93,12 @@ Result<NativeLoaderNamespace> NativeLoaderNamespace::Create( is_bridged = NativeBridgeIsPathSupported(search_paths.c_str()); } - // Fall back to the platform namespace if no parent is set. - auto platform_ns = GetPlatformNamespace(is_bridged); - if (!platform_ns) { - return platform_ns.error(); + // Fall back to the system namespace if no parent is set. + auto system_ns = GetSystemNamespace(is_bridged); + if (!system_ns) { + return system_ns.error(); } - const NativeLoaderNamespace& effective_parent = parent != nullptr ? *parent : *platform_ns; + const NativeLoaderNamespace& effective_parent = parent != nullptr ? *parent : *system_ns; // All namespaces for apps are isolated uint64_t type = ANDROID_NAMESPACE_TYPE_ISOLATED; diff --git a/libnativeloader/native_loader_namespace.h b/libnativeloader/native_loader_namespace.h index d07c431ebd..ee84f61cd8 100644 --- a/libnativeloader/native_loader_namespace.h +++ b/libnativeloader/native_loader_namespace.h @@ -60,7 +60,7 @@ struct NativeLoaderNamespace { static Result<NativeLoaderNamespace> GetExportedNamespace(const std::string& name, bool is_bridged); - static Result<NativeLoaderNamespace> GetPlatformNamespace(bool is_bridged); + static Result<NativeLoaderNamespace> GetSystemNamespace(bool is_bridged); private: explicit NativeLoaderNamespace(const std::string& name, android_namespace_t* ns) diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp index 88964b7a85..46483773e6 100644 --- a/libnativeloader/native_loader_test.cpp +++ b/libnativeloader/native_loader_test.cpp @@ -92,7 +92,7 @@ class Platform { // These represents built-in namespaces created by the linker according to ld.config.txt static std::unordered_map<std::string, Platform::mock_namespace_handle> namespaces = { - {"platform", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("platform"))}, + {"system", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("system"))}, {"default", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("default"))}, {"art", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("art"))}, {"sphal", TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE("sphal"))}, @@ -348,7 +348,7 @@ class NativeLoaderTest_Create : public NativeLoaderTest { ANDROID_NAMESPACE_TYPE_ISOLATED | ANDROID_NAMESPACE_TYPE_ALSO_USED_AS_ANONYMOUS; std::string expected_library_path = library_path; std::string expected_permitted_path = std::string("/data:/mnt/expand:") + permitted_path; - std::string expected_parent_namespace = "platform"; + std::string expected_parent_namespace = "system"; bool expected_link_with_platform_ns = true; bool expected_link_with_art_ns = true; bool expected_link_with_sphal_ns = !vendor_public_libraries().empty(); @@ -378,7 +378,7 @@ class NativeLoaderTest_Create : public NativeLoaderTest { StrEq(expected_permitted_path), NsEq(expected_parent_namespace.c_str()))) .WillOnce(Return(TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE(dex_path.c_str())))); if (expected_link_with_platform_ns) { - EXPECT_CALL(*mock, mock_link_namespaces(Eq(IsBridged()), _, NsEq("platform"), + EXPECT_CALL(*mock, mock_link_namespaces(Eq(IsBridged()), _, NsEq("system"), StrEq(expected_shared_libs_to_platform_ns))) .WillOnce(Return(true)); } |