Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / Neptune / Source / System / Android / NptAndroidLogConfig.cpp
blob2c4ef69d061eeee43c013e0413c76472f700c8d6
1 extern "C" {
2 #include <sys/system_properties.h>
4 #include <android/log.h>
5 #include <dlfcn.h>
6 #include "NptLogging.h"
8 /*----------------------------------------------------------------------
9 | android_property_get
10 +---------------------------------------------------------------------*/
11 static int android_property_get(const char* name, char* value) {
12 static int (*__real_system_property_get)(const char*, char*) = NULL;
13 if (__real_system_property_get == NULL) {
14 void* handle = dlopen("libc.so", 0);
15 if (!handle) {
16 __android_log_print(ANDROID_LOG_DEBUG, "Neptune", "Cannot dlopen libc.so: %s", dlerror());
17 return 0;
19 __real_system_property_get = reinterpret_cast<int (*)(const char*, char*)>(
20 dlsym(handle, "__system_property_get"));
21 if (!__real_system_property_get) {
22 __android_log_print(ANDROID_LOG_DEBUG, "Neptune", "Cannot resolve __system_property_get(): %s", dlerror());
23 return 0;
26 return (*__real_system_property_get)(name, value);
29 /*----------------------------------------------------------------------
30 | NPT_GetSystemLogConfig
31 +---------------------------------------------------------------------*/
32 NPT_Result
33 NPT_GetSystemLogConfig(NPT_String& config)
35 char android_npt_config[PROP_VALUE_MAX];
36 android_npt_config[0] = 0;
37 int prop_len = android_property_get("persist.neptune_log_config",
38 android_npt_config);
39 if (prop_len > 0) {
40 config = android_npt_config;
41 return NPT_SUCCESS;
42 } else {
43 return NPT_ERROR_NO_SUCH_PROPERTY;