From 62068bfb4a78506f4f101b26c994e5ad7026fb54 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Tue, 28 Jul 2020 11:55:30 -0700 Subject: [PATCH] liblog: remove __android_logger_property_get_bool() All users have been moved to other, more suitable, interfaces. Test: build Merged-In: Ic4eb1f0ed6e35d8d6f7e63b80546f4e8bbe163e2 Change-Id: Ic4eb1f0ed6e35d8d6f7e63b80546f4e8bbe163e2 --- liblog/include/private/android_logger.h | 8 --- liblog/liblog.map.txt | 1 - liblog/properties.cpp | 74 ++----------------------- 3 files changed, 6 insertions(+), 77 deletions(-) diff --git a/liblog/include/private/android_logger.h b/liblog/include/private/android_logger.h index d3b72bcee..de4c430e3 100644 --- a/liblog/include/private/android_logger.h +++ b/liblog/include/private/android_logger.h @@ -144,14 +144,6 @@ int __android_log_security_bwrite(int32_t tag, const void* payload, size_t len); int __android_log_security_bswrite(int32_t tag, const char* payload); int __android_log_security(); /* Device Owner is present */ -#define BOOL_DEFAULT_FLAG_TRUE_FALSE 0x1 -#define BOOL_DEFAULT_FALSE 0x0 /* false if property not present */ -#define BOOL_DEFAULT_TRUE 0x1 /* true if property not present */ -#define BOOL_DEFAULT_FLAG_PERSIST 0x2 /* , persist., ro. */ -#define BOOL_DEFAULT_FLAG_ENG 0x4 /* off for user */ -#define BOOL_DEFAULT_FLAG_SVELTE 0x8 /* off for low_ram */ -bool __android_logger_property_get_bool(const char* key, int flag); - #define LOG_BUFFER_SIZE (256 * 1024) /* Tuned with ro.logd.size per-platform \ */ #define LOG_BUFFER_MIN_SIZE (64 * 1024UL) diff --git a/liblog/liblog.map.txt b/liblog/liblog.map.txt index 161fcf1a9..2e0110171 100644 --- a/liblog/liblog.map.txt +++ b/liblog/liblog.map.txt @@ -85,7 +85,6 @@ LIBLOG_PRIVATE { __android_log_pmsg_file_read; __android_log_pmsg_file_write; __android_logger_get_buffer_size; - __android_logger_property_get_bool; android_openEventTagMap; android_log_processBinaryLogBuffer; android_log_processLogBuffer; diff --git a/liblog/properties.cpp b/liblog/properties.cpp index bb64008a7..2a30a0bb0 100644 --- a/liblog/properties.cpp +++ b/liblog/properties.cpp @@ -390,21 +390,6 @@ int __android_log_security() { * need not guess our intentions. */ -/* Property helper */ -static bool check_flag(const char* prop, const char* flag) { - const char* cp = strcasestr(prop, flag); - if (!cp) { - return false; - } - /* We only will document comma (,) */ - static const char sep[] = ",:;|+ \t\f"; - if ((cp != prop) && !strchr(sep, cp[-1])) { - return false; - } - cp += strlen(flag); - return !*cp || !!strchr(sep, *cp); -} - /* cache structure */ struct cache_property { struct cache cache; @@ -422,56 +407,6 @@ static void refresh_cache_property(struct cache_property* cache, const char* key __system_property_read(cache->cache.pinfo, 0, cache->property); } -/* get boolean with the logger twist that supports eng adjustments */ -bool __android_logger_property_get_bool(const char* key, int flag) { - struct cache_property property = {{NULL, 0xFFFFFFFF}, {0}}; - if (flag & BOOL_DEFAULT_FLAG_PERSIST) { - char newkey[strlen("persist.") + strlen(key) + 1]; - snprintf(newkey, sizeof(newkey), "ro.%s", key); - refresh_cache_property(&property, newkey); - property.cache.pinfo = NULL; - property.cache.serial = 0xFFFFFFFF; - snprintf(newkey, sizeof(newkey), "persist.%s", key); - refresh_cache_property(&property, newkey); - property.cache.pinfo = NULL; - property.cache.serial = 0xFFFFFFFF; - } - - refresh_cache_property(&property, key); - - if (check_flag(property.property, "true")) { - return true; - } - if (check_flag(property.property, "false")) { - return false; - } - if (property.property[0]) { - flag &= ~(BOOL_DEFAULT_FLAG_ENG | BOOL_DEFAULT_FLAG_SVELTE); - } - if (check_flag(property.property, "eng")) { - flag |= BOOL_DEFAULT_FLAG_ENG; - } - /* this is really a "not" flag */ - if (check_flag(property.property, "svelte")) { - flag |= BOOL_DEFAULT_FLAG_SVELTE; - } - - if (flag & (BOOL_DEFAULT_FLAG_SVELTE | BOOL_DEFAULT_FLAG_ENG)) { - flag &= ~BOOL_DEFAULT_FLAG_TRUE_FALSE; - flag |= BOOL_DEFAULT_TRUE; - } - - if ((flag & BOOL_DEFAULT_FLAG_SVELTE) && - __android_logger_property_get_bool("ro.config.low_ram", BOOL_DEFAULT_FALSE)) { - return false; - } - if ((flag & BOOL_DEFAULT_FLAG_ENG) && !__android_log_is_debuggable()) { - return false; - } - - return (flag & BOOL_DEFAULT_FLAG_TRUE_FALSE) != BOOL_DEFAULT_FALSE; -} - bool __android_logger_valid_buffer_size(unsigned long value) { return LOG_BUFFER_MIN_SIZE <= value && value <= LOG_BUFFER_MAX_SIZE; } @@ -573,9 +508,12 @@ unsigned long __android_logger_get_buffer_size(log_id_t logId) { default_size = do_cache2_property_size(&global); if (!default_size) { - default_size = __android_logger_property_get_bool("ro.config.low_ram", BOOL_DEFAULT_FALSE) - ? LOG_BUFFER_MIN_SIZE /* 64K */ - : LOG_BUFFER_SIZE; /* 256K */ + char value[PROP_VALUE_MAX] = {}; + if (__system_property_get("ro.config.low_ram", value) == 0 || strcmp(value, "true") != 0) { + default_size = LOG_BUFFER_SIZE; + } else { + default_size = LOG_BUFFER_MIN_SIZE; + } } snprintf(key_persist, sizeof(key_persist), "%s.%s", global_tunable,