Ignore target sdk version for the public namespace
This fixes the bug with using the libraries loaded prior to android_set_target_sdk_version call. Bug: http://b/22548808 Change-Id: I3ca2d367b0fa930a437bbb65f780834803d2ef0a
This commit is contained in:
parent
b804b9d67b
commit
3cc35e224c
2 changed files with 9 additions and 2 deletions
|
@ -2255,9 +2255,12 @@ bool init_public_namespace(const char* libs) {
|
|||
g_public_namespace.clear();
|
||||
});
|
||||
|
||||
soinfo* candidate;
|
||||
for (const auto& soname : sonames) {
|
||||
if (!find_loaded_library_by_soname(&g_default_namespace, soname.c_str(), &candidate)) {
|
||||
soinfo* candidate = nullptr;
|
||||
|
||||
find_loaded_library_by_soname(&g_default_namespace, soname.c_str(), &candidate);
|
||||
|
||||
if (candidate == nullptr) {
|
||||
DL_ERR("Error initializing public namespace: \"%s\" was not found"
|
||||
" in the default namespace", soname.c_str());
|
||||
return false;
|
||||
|
|
|
@ -707,6 +707,8 @@ TEST(dlext, ns_smoke) {
|
|||
dlclose(handle2);
|
||||
}
|
||||
|
||||
extern "C" void android_set_application_target_sdk_version(uint32_t target);
|
||||
|
||||
TEST(dlext, ns_isolated) {
|
||||
static const char* root_lib = "libnstest_root_not_isolated.so";
|
||||
std::string path = std::string("libc.so:libc++.so:libdl.so:libm.so:") + g_public_lib;
|
||||
|
@ -715,6 +717,8 @@ TEST(dlext, ns_isolated) {
|
|||
void* handle_public = dlopen((lib_path + "/public_namespace_libs/" + g_public_lib).c_str(), RTLD_NOW);
|
||||
ASSERT_TRUE(handle_public != nullptr) << dlerror();
|
||||
|
||||
android_set_application_target_sdk_version(42U); // something > 23
|
||||
|
||||
ASSERT_TRUE(android_init_public_namespace(path.c_str())) << dlerror();
|
||||
|
||||
android_namespace_t* ns_not_isolated = android_create_namespace("private", nullptr, (lib_path + "/private_namespace_libs").c_str(), false);
|
||||
|
|
Loading…
Reference in a new issue