Chromium Code Reviews| Index: base/sys_info_android.cc |
| diff --git a/base/sys_info_android.cc b/base/sys_info_android.cc |
| index 92eefef6527b0ad29a44be05663e1bf7a9b02442..ae02447ab640b3defe341af58e7e228858657080 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,33 @@ |
| #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' */) |
| + |
| +// 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. |
| +int __system_property_get(const char* name, char* value) { |
| + static int (*__real_system_property_get)(const char*, char*) = NULL; |
|
Nico
2014/07/17 16:55:50
Is this always called from the same thread? (I thi
rmcilroy
2014/07/17 18:41:51
Good point. Updated to use a LazyInstance instead
|
| + if (__real_system_property_get == NULL) { |
| + // 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(); |
| + } |
| + __real_system_property_get = reinterpret_cast<int (*)(const char*, char*)>( |
| + dlsym(handle, "__system_property_get")); |
| + if (!__real_system_property_get) { |
| + LOG(FATAL) << "Cannot resolve __system_property_get(): " << dlerror(); |
| + } |
| + } |
| + return (*__real_system_property_get)(name, value); |
| +} |
| + |
| +#endif |
| + |
| namespace { |
| // Default version of Android to fall back to when actual version numbers |