Drop ro.debuggable restriction for NATIVELOADER_DEFAULT_NAMESPACE_LIBS.
To allow running tests on user builds. The (non)existence of the
environment variable itself serves fine as a toggle, and it is hard to
inject into the zygote environment on a user build anyway.
Also a few other cleanups from comments on
https://r.android.com/1689792.
Test: art/test/testrunner/testrunner.py --target --64 --optimizing
Bug: 130340935
Change-Id: I1843a8bbfb5dadc560919022d1f2123eb652be5a
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index 545d04b..2deb5ef 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -29,7 +29,6 @@
#include <android-base/file.h>
#include <android-base/macros.h>
-#include <android-base/properties.h>
#include <android-base/strings.h>
#include <android-base/thread_annotations.h>
#include <nativebridge/native_bridge.h>
@@ -48,12 +47,11 @@
#if defined(ART_TARGET_ANDROID)
// NATIVELOADER_DEFAULT_NAMESPACE_LIBS is an environment variable that can be
-// used when ro.debuggable is true to list extra libraries (separated by ":")
-// that libnativeloader will load from the default namespace. The libraries
-// must be listed without paths, and then LD_LIBRARY_PATH is typically set to the
-// directories to load them from. The libraries will be available in all
-// classloader namespaces, and also in the fallback namespace used when no
-// classloader is given.
+// used to list extra libraries (separated by ":") that libnativeloader will
+// load from the default namespace. The libraries must be listed without paths,
+// and then LD_LIBRARY_PATH is typically set to the directories to load them
+// from. The libraries will be available in all classloader namespaces, and also
+// in the fallback namespace used when no classloader is given.
//
// kNativeloaderExtraLibs is the name of that fallback namespace.
//
@@ -64,11 +62,6 @@
// test libraries that depend on ART internal libraries.
constexpr const char* kNativeloaderExtraLibs = "nativeloader-extra-libs";
-bool Debuggable() {
- static bool debuggable = android::base::GetBoolProperty("ro.debuggable", false);
- return debuggable;
-}
-
using android::nativeloader::LibraryNamespaces;
std::mutex g_namespaces_mutex;
@@ -124,11 +117,8 @@
// If the given path matches a library in NATIVELOADER_DEFAULT_NAMESPACE_LIBS
// then load it in the nativeloader-extra-libs namespace, otherwise return
-// nullptr without error. This is only enabled if the ro.debuggable is true.
+// nullptr without error.
Result<void*> TryLoadNativeloaderExtraLib(const char* path) {
- if (!Debuggable()) {
- return nullptr;
- }
const char* links = getenv("NATIVELOADER_DEFAULT_NAMESPACE_LIBS");
if (links == nullptr || *links == 0) {
return nullptr;
@@ -166,11 +156,9 @@
if (!ns.ok()) {
return ns;
}
- if (Debuggable()) {
- Result<void> linked = CreateNativeloaderDefaultNamespaceLibsLink(*ns.value());
- if (!linked.ok()) {
- return linked.error();
- }
+ Result<void> linked = CreateNativeloaderDefaultNamespaceLibsLink(*ns.value());
+ if (!linked.ok()) {
+ return linked.error();
}
return ns;
}
@@ -190,7 +178,7 @@
#if defined(ART_TARGET_ANDROID)
std::lock_guard<std::mutex> guard(g_namespaces_mutex);
g_namespaces->Reset();
- delete(g_nativeloader_extra_libs_namespace);
+ delete g_nativeloader_extra_libs_namespace;
g_nativeloader_extra_libs_namespace = nullptr;
#endif
}
diff --git a/test/knownfailures.json b/test/knownfailures.json
index 6034b94..0ca8aa3 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -1402,6 +1402,7 @@
"817-hiddenapi",
"900-hello-plugin"],
"variant": "target",
- "description": ["TODO(b/186654484): Disabled after the switch to avoid allow_all_shared_libs from the ART namespace to system."]
+ "bug": "b/186654484",
+ "description": ["Disabled after the switch to avoid allow_all_shared_libs from the ART namespace to system."]
}
]