Merge changes from topic "libvndksupport_cp"
* changes: Make libvndksupport look for default namespace as well. libvndksupport: Change log level and message.
This commit is contained in:
commit
c021b75cfd
1 changed files with 24 additions and 10 deletions
|
|
@ -23,24 +23,38 @@
|
||||||
|
|
||||||
extern struct android_namespace_t* android_get_exported_namespace(const char*);
|
extern struct android_namespace_t* android_get_exported_namespace(const char*);
|
||||||
|
|
||||||
|
static const char* namespace_name = NULL;
|
||||||
|
|
||||||
|
static struct android_namespace_t* get_vendor_namespace() {
|
||||||
|
const char* namespace_names[] = {"sphal", "default", NULL};
|
||||||
|
static struct android_namespace_t* vendor_namespace = NULL;
|
||||||
|
if (vendor_namespace == NULL) {
|
||||||
|
int name_idx = 0;
|
||||||
|
while (namespace_names[name_idx] != NULL) {
|
||||||
|
vendor_namespace = android_get_exported_namespace(namespace_names[name_idx]);
|
||||||
|
if (vendor_namespace != NULL) {
|
||||||
|
namespace_name = namespace_names[name_idx];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
name_idx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vendor_namespace;
|
||||||
|
}
|
||||||
|
|
||||||
void* android_load_sphal_library(const char* name, int flag) {
|
void* android_load_sphal_library(const char* name, int flag) {
|
||||||
struct android_namespace_t* sphal_namespace = android_get_exported_namespace("sphal");
|
struct android_namespace_t* vendor_namespace = get_vendor_namespace();
|
||||||
if (sphal_namespace != NULL) {
|
if (vendor_namespace != NULL) {
|
||||||
const android_dlextinfo dlextinfo = {
|
const android_dlextinfo dlextinfo = {
|
||||||
.flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = sphal_namespace,
|
.flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = vendor_namespace,
|
||||||
};
|
};
|
||||||
void* handle = android_dlopen_ext(name, flag, &dlextinfo);
|
void* handle = android_dlopen_ext(name, flag, &dlextinfo);
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
ALOGE(
|
ALOGE("Could not load %s from %s namespace: %s.", name, namespace_name, dlerror());
|
||||||
"Could not load %s from sphal namespace: %s. ",
|
|
||||||
name, dlerror());
|
|
||||||
}
|
}
|
||||||
return handle;
|
return handle;
|
||||||
} else {
|
} else {
|
||||||
ALOGI(
|
ALOGD("Loading %s from current namespace instead of sphal namespace.", name);
|
||||||
"sphal namespace is not configured for this process. "
|
|
||||||
"Loading %s from the current namespace instead.",
|
|
||||||
name);
|
|
||||||
return dlopen(name, flag);
|
return dlopen(name, flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue