Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b3848be authored by vichang's avatar vichang Committed by Gerrit Code Review
Browse files

Merge "Expose public libraries from runtime namepsace to classloader namespace"

parents 31fd0ba5 7a20a907
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -103,6 +103,11 @@ static constexpr const char kLlndkNativeLibrariesSystemConfigPathFromRoot[] =
static constexpr const char kVndkspNativeLibrariesSystemConfigPathFromRoot[] =
    "/etc/vndksp.libraries.txt";

static const std::vector<const std::string> kRuntimePublicLibraries = {
    "libicuuc.so",
    "libicui18n.so",
};

// 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
@@ -111,6 +116,8 @@ static constexpr const char* kVendorNamespaceName = "sphal";

static constexpr const char* kVndkNamespaceName = "vndk";

static constexpr const char* kRuntimeNamespaceName = "runtime";

static constexpr const char* kClassloaderNamespaceName = "classloader-namespace";
static constexpr const char* kVendorClassloaderNamespaceName = "vendor-classloader-namespace";

@@ -245,6 +252,8 @@ class LibraryNamespaces {
      }
    }

    std::string runtime_exposed_libraries = base::Join(kRuntimePublicLibraries, ":");

    NativeLoaderNamespace native_loader_ns;
    if (!is_native_bridge) {
      android_namespace_t* android_parent_ns =
@@ -265,11 +274,21 @@ class LibraryNamespaces {
      // which is expected behavior in this case.
      android_namespace_t* vendor_ns = android_get_exported_namespace(kVendorNamespaceName);

      android_namespace_t* runtime_ns = android_get_exported_namespace(kRuntimeNamespaceName);

      if (!android_link_namespaces(ns, nullptr, system_exposed_libraries.c_str())) {
        *error_msg = dlerror();
        return nullptr;
      }

      // Runtime apex does not exist in host, and under certain build conditions.
      if (runtime_ns != nullptr) {
        if (!android_link_namespaces(ns, runtime_ns, runtime_exposed_libraries.c_str())) {
          *error_msg = dlerror();
          return nullptr;
        }
      }

      if (vndk_ns != nullptr && !system_vndksp_libraries_.empty()) {
        // vendor apks are allowed to use VNDK-SP libraries.
        if (!android_link_namespaces(ns, vndk_ns, system_vndksp_libraries_.c_str())) {
@@ -301,12 +320,21 @@ class LibraryNamespaces {
      }

      native_bridge_namespace_t* vendor_ns = NativeBridgeGetExportedNamespace(kVendorNamespaceName);
      native_bridge_namespace_t* runtime_ns =
          NativeBridgeGetExportedNamespace(kRuntimeNamespaceName);

      if (!NativeBridgeLinkNamespaces(ns, nullptr, system_exposed_libraries.c_str())) {
        *error_msg = NativeBridgeGetError();
        return nullptr;
      }

      // Runtime apex does not exist in host, and under certain build conditions.
      if (runtime_ns != nullptr) {
        if (!NativeBridgeLinkNamespaces(ns, runtime_ns, runtime_exposed_libraries.c_str())) {
          *error_msg = NativeBridgeGetError();
          return nullptr;
        }
      }
      if (!vendor_public_libraries_.empty()) {
        if (!NativeBridgeLinkNamespaces(ns, vendor_ns, vendor_public_libraries_.c_str())) {
          *error_msg = NativeBridgeGetError();