diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2022-01-12 14:45:38 +0000 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2022-01-14 16:56:21 +0000 |
commit | 944b10951883421c2b719b3d7059bb66ad871f81 (patch) | |
tree | 8ad41f5f6285428688c5d79dd5f00dacd726656d | |
parent | 07a734205992b0de7d8153529bcd7a9364a87c63 (diff) | |
download | libnativehelper-944b10951883421c2b719b3d7059bb66ad871f81.tar.gz |
Use libartd if system property is empty.
This simplifies continuous testing of the debug apex.
Test: boot with debug apex
Bug: 214049018
Change-Id: I486c26f6c20d7cdf3d367b98b3ff6b62e003f700
-rw-r--r-- | JniInvocation.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/JniInvocation.c b/JniInvocation.c index 9cfb084..c6a2a69 100644 --- a/JniInvocation.c +++ b/JniInvocation.c @@ -23,14 +23,25 @@ #include <sys/system_properties.h> #endif +#include <errno.h> #include <jni.h> #include <stdbool.h> #include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include "DlHelp.h" // Name the default library providing the JNI Invocation API. static const char* kDefaultJniInvocationLibrary = "libart.so"; +static const char* kDebugJniInvocationLibrary = "libartd.so"; +#if defined(__LP64__) +#define LIB_DIR "lib64" +#else +#define LIB_DIR "lib" +#endif +static const char* kDebugJniInvocationLibraryPath = "/apex/com.android.art/" LIB_DIR "/libartd.so"; struct JniInvocationImpl { // Name of library providing JNI_ method implementations. @@ -118,10 +129,19 @@ const char* JniInvocationGetLibraryWith(const char* library, if (library != NULL) { return library; } + // Choose the system_preferred_library (if provided). - if (system_preferred_library != NULL) { + if (system_preferred_library != NULL && system_preferred_library[0] != '\0') { return system_preferred_library; } + + // Try to use the debug library. + struct stat st; + if (stat(kDebugJniInvocationLibraryPath, &st) == 0) { + return kDebugJniInvocationLibrary; + } else if (errno != ENOENT) { + ALOGW("Failed to stat %s: %s", kDebugJniInvocationLibraryPath, strerror(errno)); + } } return kDefaultJniInvocationLibrary; } |