aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-11-20 18:23:57 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-11-20 18:23:57 +0000
commit38ad1847c2a8265ee09c9785aa4cba455c81686c (patch)
treeabb998782b2c9c00d554fc3f03421a03675c5b99
parent8ce73afe0947f7f53ad6139890e2bf8edeeaf7bf (diff)
parentd29b78abc660f088d2be5655f84b35d32a0cc9bc (diff)
downloadandroid_libnativehelper-38ad1847c2a8265ee09c9785aa4cba455c81686c.tar.gz
android_libnativehelper-38ad1847c2a8265ee09c9785aa4cba455c81686c.tar.bz2
android_libnativehelper-38ad1847c2a8265ee09c9785aa4cba455c81686c.zip
Merge tag 'android-4.4_r1.2' into cm-11.0
Android 4.4 Release 1.2
-rw-r--r--JniInvocation.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/JniInvocation.cpp b/JniInvocation.cpp
index e78cff8..acd019a 100644
--- a/JniInvocation.cpp
+++ b/JniInvocation.cpp
@@ -18,6 +18,7 @@
#include <dlfcn.h>
#include <stdlib.h>
+#include <string.h>
#include <cstddef>
@@ -47,12 +48,17 @@ JniInvocation::~JniInvocation() {
}
}
+#ifdef HAVE_ANDROID_OS
+static const char* kLibrarySystemProperty = "persist.sys.dalvik.vm.lib";
+#endif
+static const char* kLibraryFallback = "libdvm.so";
+
bool JniInvocation::Init(const char* library) {
#ifdef HAVE_ANDROID_OS
char default_library[PROPERTY_VALUE_MAX];
- property_get("persist.sys.dalvik.vm.lib", default_library, "libdvm.so");
+ property_get(kLibrarySystemProperty, default_library, kLibraryFallback);
#else
- const char* default_library = "libdvm.so";
+ const char* default_library = kLibraryFallback;
#endif
if (library == NULL) {
library = default_library;
@@ -60,8 +66,24 @@ bool JniInvocation::Init(const char* library) {
handle_ = dlopen(library, RTLD_NOW);
if (handle_ == NULL) {
- ALOGE("Failed to dlopen %s: %s", library, dlerror());
- return false;
+ if (strcmp(library, kLibraryFallback) == 0) {
+ // Nothing else to try.
+ ALOGE("Failed to dlopen %s: %s", library, dlerror());
+ return false;
+ }
+ // Note that this is enough to get something like the zygote
+ // running, we can't property_set here to fix this for the future
+ // because we are root and not the system user. See
+ // RuntimeInit.commonInit for where we fix up the property to
+ // avoid future fallbacks. http://b/11463182
+ ALOGW("Falling back from %s to %s after dlopen error: %s",
+ library, kLibraryFallback, dlerror());
+ library = kLibraryFallback;
+ handle_ = dlopen(library, RTLD_NOW);
+ if (handle_ == NULL) {
+ ALOGE("Failed to dlopen %s: %s", library, dlerror());
+ return false;
+ }
}
if (!FindSymbol(reinterpret_cast<void**>(&JNI_GetDefaultJavaVMInitArgs_),
"JNI_GetDefaultJavaVMInitArgs")) {