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
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp
index 3be379a..a9b2246 100644
--- a/libnativeloader/library_namespaces.cpp
+++ b/libnativeloader/library_namespaces.cpp
@@ -52,7 +52,7 @@
 // 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 @@
 // "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 @@
   // ... 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 @@
 
   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 fff3191..6faa78c 100644
--- a/libnativeloader/native_loader_namespace.cpp
+++ b/libnativeloader/native_loader_namespace.cpp
@@ -35,7 +35,7 @@
 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 @@
   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 @@
     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 d07c431..ee84f61 100644
--- a/libnativeloader/native_loader_namespace.h
+++ b/libnativeloader/native_loader_namespace.h
@@ -60,7 +60,7 @@
 
   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 88964b7..4648377 100644
--- a/libnativeloader/native_loader_test.cpp
+++ b/libnativeloader/native_loader_test.cpp
@@ -92,7 +92,7 @@
 
 // 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 @@
       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 @@
                            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));
     }