Loading liblog/include/log/log_properties.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ extern "C" { extern "C" { #endif #endif /* Returns `1` if the device is debuggable or `0` if not. */ int __android_log_is_debuggable(); int __android_log_is_debuggable(); #ifdef __cplusplus #ifdef __cplusplus Loading liblog/properties.cpp +5 −26 Original line number Original line Diff line number Diff line Loading @@ -294,33 +294,12 @@ int __android_log_is_loggable(int prio, const char* tag, int default_prio) { } } int __android_log_is_debuggable() { int __android_log_is_debuggable() { static uint32_t serial; static int is_debuggable = [] { static struct cache_char tag_cache; char value[PROP_VALUE_MAX] = {}; static const char key[] = "ro.debuggable"; return __system_property_get("ro.debuggable", value) > 0 && !strcmp(value, "1"); int ret; }(); if (tag_cache.c) { /* ro property does not change after set */ ret = tag_cache.c == '1'; } else if (lock()) { struct cache_char temp_cache = {{NULL, 0xFFFFFFFF}, '\0'}; refresh_cache(&temp_cache, key); ret = temp_cache.c == '1'; } else { int change_detected = check_cache(&tag_cache.cache); uint32_t current_serial = __system_property_area_serial(); if (current_serial != serial) { change_detected = 1; } if (change_detected) { refresh_cache(&tag_cache, key); serial = current_serial; } ret = tag_cache.c == '1'; unlock(); } return ret; return is_debuggable; } } /* /* Loading Loading
liblog/include/log/log_properties.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ extern "C" { extern "C" { #endif #endif /* Returns `1` if the device is debuggable or `0` if not. */ int __android_log_is_debuggable(); int __android_log_is_debuggable(); #ifdef __cplusplus #ifdef __cplusplus Loading
liblog/properties.cpp +5 −26 Original line number Original line Diff line number Diff line Loading @@ -294,33 +294,12 @@ int __android_log_is_loggable(int prio, const char* tag, int default_prio) { } } int __android_log_is_debuggable() { int __android_log_is_debuggable() { static uint32_t serial; static int is_debuggable = [] { static struct cache_char tag_cache; char value[PROP_VALUE_MAX] = {}; static const char key[] = "ro.debuggable"; return __system_property_get("ro.debuggable", value) > 0 && !strcmp(value, "1"); int ret; }(); if (tag_cache.c) { /* ro property does not change after set */ ret = tag_cache.c == '1'; } else if (lock()) { struct cache_char temp_cache = {{NULL, 0xFFFFFFFF}, '\0'}; refresh_cache(&temp_cache, key); ret = temp_cache.c == '1'; } else { int change_detected = check_cache(&tag_cache.cache); uint32_t current_serial = __system_property_area_serial(); if (current_serial != serial) { change_detected = 1; } if (change_detected) { refresh_cache(&tag_cache, key); serial = current_serial; } ret = tag_cache.c == '1'; unlock(); } return ret; return is_debuggable; } } /* /* Loading