summaryrefslogtreecommitdiffstats
path: root/renderscript
diff options
context:
space:
mode:
Diffstat (limited to 'renderscript')
-rw-r--r--renderscript/1.0/default/Device.cpp23
-rw-r--r--renderscript/1.0/vts/functional/Android.bp18
2 files changed, 25 insertions, 16 deletions
diff --git a/renderscript/1.0/default/Device.cpp b/renderscript/1.0/default/Device.cpp
index 3aae06097..4831a8b98 100644
--- a/renderscript/1.0/default/Device.cpp
+++ b/renderscript/1.0/default/Device.cpp
@@ -1,6 +1,9 @@
#include "Context.h"
#include "Device.h"
+#include <android/dlext.h>
+#include <dlfcn.h>
+
namespace android {
namespace hardware {
namespace renderscript {
@@ -39,7 +42,25 @@ dispatchTable loadHAL() {
static_assert(sizeof(size_t) <= sizeof(uint64_t), "RenderScript HIDL Error: sizeof(size_t) > sizeof(uint64_t)");
const char* filename = "libRS_internal.so";
- void* handle = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+ // Try to load libRS_internal.so from the "rs" namespace directly.
+ typedef struct android_namespace_t* (*GetExportedNamespaceFnPtr)(const char*);
+ GetExportedNamespaceFnPtr getExportedNamespace =
+ (GetExportedNamespaceFnPtr)dlsym(RTLD_DEFAULT, "android_get_exported_namespace");
+ void* handle = nullptr;
+ if (getExportedNamespace != nullptr) {
+ android_namespace_t* rs_namespace = getExportedNamespace("rs");
+ if (rs_namespace != nullptr) {
+ const android_dlextinfo dlextinfo = {
+ .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = rs_namespace,
+ };
+ handle = android_dlopen_ext(filename, RTLD_LAZY | RTLD_LOCAL, &dlextinfo);
+ }
+ }
+ if (handle == nullptr) {
+ // if there is no "rs" namespace (in case when this HAL impl is loaded
+ // into a vendor process), then use the plain dlopen.
+ handle = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+ }
dispatchTable dispatchHal = {
.SetNativeLibDir = (SetNativeLibDirFnPtr) nullptr,
diff --git a/renderscript/1.0/vts/functional/Android.bp b/renderscript/1.0/vts/functional/Android.bp
index 5256c1f9d..bf011e6c1 100644
--- a/renderscript/1.0/vts/functional/Android.bp
+++ b/renderscript/1.0/vts/functional/Android.bp
@@ -23,21 +23,9 @@ cc_test {
"VtsScriptTests.cpp",
"bitcode.cpp",
],
- defaults: ["hidl_defaults"],
- shared_libs: [
- "libbase",
- "liblog",
- "libcutils",
- "libhidlbase",
- "libhidltransport",
- "libnativehelper",
- "libutils",
- "libnativewindow",
+ defaults: ["VtsHalTargetTestDefaults"],
+ static_libs: [
"android.hardware.renderscript@1.0",
- ],
- static_libs: ["VtsHalHidlTargetTestBase"],
- cflags: [
- "-O0",
- "-g",
+ "libnativewindow",
],
}