Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Unified Diff: base/sys_info_android.cc

Issue 393923002: Workaround removal of __system_property_get in Android NDK. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor style fix Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_android.cc
diff --git a/base/sys_info_android.cc b/base/sys_info_android.cc
index 92eefef6527b0ad29a44be05663e1bf7a9b02442..ab760e5579721843c64244f59d52cf23c037c7cc 100644
--- a/base/sys_info_android.cc
+++ b/base/sys_info_android.cc
@@ -4,6 +4,7 @@
#include "base/sys_info.h"
+#include <dlfcn.h>
#include <sys/system_properties.h>
#include "base/android/sys_utils.h"
@@ -14,6 +15,45 @@
#include "base/strings/stringprintf.h"
#include "base/sys_info_internal.h"
+// TODO(rmcilroy): Update API level when 'L' gets an official API level.
+#if (__ANDROID_API__ >= 9999 /* 'L' */)
+
+namespace {
+
+typedef int (SystemPropertyGetFunction)(const char*, char*);
+
+SystemPropertyGetFunction* DynamicallyLoadRealSystemPropertyGet() {
+ // libc.so should already be open, get a handle to it.
+ void* handle = dlopen("libc.so", RTLD_NOLOAD);
+ if (!handle) {
+ LOG(FATAL) << "Cannot dlopen libc.so: " << dlerror();
+ }
+ SystemPropertyGetFunction* real_system_property_get =
+ reinterpret_cast<SystemPropertyGetFunction*>(
+ dlsym(handle, "__system_property_get"));
+ if (!real_system_property_get) {
+ LOG(FATAL) << "Cannot resolve __system_property_get(): " << dlerror();
+ }
+ return real_system_property_get;
+}
+
+static base::LazyInstance<base::internal::LazySysInfoValue<
+ SystemPropertyGetFunction*, DynamicallyLoadRealSystemPropertyGet> >::Leaky
+ g_lazy_real_system_property_get = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+// Android 'L' removes __system_property_get from the NDK, however it is still
+// a hidden symbol in libc. Until we remove all calls of __system_property_get
+// from Chrome we work around this by defining a weak stub here, which uses
+// dlsym to but ensures that Chrome uses the real system
+// implementatation when loaded. http://crbug.com/392191.
+int __system_property_get(const char* name, char* value) {
+ return g_lazy_real_system_property_get.Get().value()(name, value);
+}
+
+#endif
+
namespace {
// Default version of Android to fall back to when actual version numbers
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698