Move to C API of libnativeloader.
Test: m
Bug: 119840313
Change-Id: I11c44c46595cde768ee639e6c5a4cce1559e32f7
diff --git a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
index 37c24ef..429ce0e 100644
--- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
+++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
@@ -24,7 +24,7 @@
namespace android {
-class NativeLoaderNamespace;
+struct NativeLoaderNamespace;
class GraphicsEnv {
public:
diff --git a/opengl/libs/EGL/egl_layers.cpp b/opengl/libs/EGL/egl_layers.cpp
index dd8fbfc..f936ac0 100644
--- a/opengl/libs/EGL/egl_layers.cpp
+++ b/opengl/libs/EGL/egl_layers.cpp
@@ -375,12 +375,13 @@
auto app_namespace = android::GraphicsEnv::getInstance().getAppNamespace();
if (app_namespace && !android::base::StartsWith(layer, kSystemLayerLibraryDir)) {
bool native_bridge = false;
- std::string error_message;
- handle = OpenNativeLibrary(app_namespace, layer.c_str(), &native_bridge,
- &error_message);
+ char* error_message = nullptr;
+ handle = OpenNativeLibraryInNamespace(
+ app_namespace, layer.c_str(), &native_bridge, &error_message);
if (!handle) {
ALOGE("Failed to load layer %s with error: %s", layer.c_str(),
- error_message.c_str());
+ error_message);
+ android::NativeLoaderFreeErrorMessage(error_message);
return;
}
diff --git a/vulkan/libvulkan/layers_extensions.cpp b/vulkan/libvulkan/layers_extensions.cpp
index 009b257..ba4cf00 100644
--- a/vulkan/libvulkan/layers_extensions.cpp
+++ b/vulkan/libvulkan/layers_extensions.cpp
@@ -139,12 +139,12 @@
auto app_namespace = android::GraphicsEnv::getInstance().getAppNamespace();
if (app_namespace &&
!android::base::StartsWith(path_, kSystemLayerLibraryDir)) {
- std::string error_msg;
- dlhandle_ = OpenNativeLibrary(
+ char* error_msg = nullptr;
+ dlhandle_ = OpenNativeLibraryInNamespace(
app_namespace, path_.c_str(), &native_bridge_, &error_msg);
if (!dlhandle_) {
- ALOGE("failed to load layer library '%s': %s", path_.c_str(),
- error_msg.c_str());
+ ALOGE("failed to load layer library '%s': %s", path_.c_str(), error_msg);
+ android::NativeLoaderFreeErrorMessage(error_msg);
refcount_ = 0;
return false;
}
@@ -165,9 +165,10 @@
std::lock_guard<std::mutex> lock(mutex_);
if (--refcount_ == 0) {
ALOGV("closing layer library '%s'", path_.c_str());
- std::string error_msg;
+ char* error_msg = nullptr;
if (!android::CloseNativeLibrary(dlhandle_, native_bridge_, &error_msg)) {
- ALOGE("failed to unload library '%s': %s", path_.c_str(), error_msg.c_str());
+ ALOGE("failed to unload library '%s': %s", path_.c_str(), error_msg);
+ android::NativeLoaderFreeErrorMessage(error_msg);
refcount_++;
} else {
dlhandle_ = nullptr;