Merge "liblog: remove __android_logger_property_get_bool()"
This commit is contained in:
commit
3b8b444fce
3 changed files with 6 additions and 77 deletions
|
|
@ -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 /* <key>, persist.<key>, ro.<key> */
|
||||
#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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue