Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4cc88c2 authored by Tom Cherry's avatar Tom Cherry Committed by Automerger Merge Worker
Browse files

Merge "liblog: remove __android_logger_property_get_bool()" am: 3b8b444f am:...

Merge "liblog: remove __android_logger_property_get_bool()" am: 3b8b444f am: 04f4b02a am: 06501495

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1374741

Change-Id: I0bdb574485b6047666ef35c852a589263a8a073e
parents 9e95eeaf 06501495
Loading
Loading
Loading
Loading
+0 −8
Original line number Original line Diff line number Diff line
@@ -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_bswrite(int32_t tag, const char* payload);
int __android_log_security(); /* Device Owner is present */
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_SIZE (256 * 1024) /* Tuned with ro.logd.size per-platform \
                                      */
                                      */
#define LOG_BUFFER_MIN_SIZE (64 * 1024UL)
#define LOG_BUFFER_MIN_SIZE (64 * 1024UL)
+0 −1
Original line number Original line Diff line number Diff line
@@ -85,7 +85,6 @@ LIBLOG_PRIVATE {
    __android_log_pmsg_file_read;
    __android_log_pmsg_file_read;
    __android_log_pmsg_file_write;
    __android_log_pmsg_file_write;
    __android_logger_get_buffer_size;
    __android_logger_get_buffer_size;
    __android_logger_property_get_bool;
    android_openEventTagMap;
    android_openEventTagMap;
    android_log_processBinaryLogBuffer;
    android_log_processBinaryLogBuffer;
    android_log_processLogBuffer;
    android_log_processLogBuffer;
+6 −68
Original line number Original line Diff line number Diff line
@@ -390,21 +390,6 @@ int __android_log_security() {
 * need not guess our intentions.
 * 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 */
/* cache structure */
struct cache_property {
struct cache_property {
  struct cache cache;
  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);
  __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) {
bool __android_logger_valid_buffer_size(unsigned long value) {
  return LOG_BUFFER_MIN_SIZE <= value && value <= LOG_BUFFER_MAX_SIZE;
  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);
  default_size = do_cache2_property_size(&global);
  if (!default_size) {
  if (!default_size) {
    default_size = __android_logger_property_get_bool("ro.config.low_ram", BOOL_DEFAULT_FALSE)
    char value[PROP_VALUE_MAX] = {};
                       ? LOG_BUFFER_MIN_SIZE /* 64K  */
    if (__system_property_get("ro.config.low_ram", value) == 0 || strcmp(value, "true") != 0) {
                       : LOG_BUFFER_SIZE;    /* 256K */
      default_size = LOG_BUFFER_SIZE;
    } else {
      default_size = LOG_BUFFER_MIN_SIZE;
    }
  }
  }


  snprintf(key_persist, sizeof(key_persist), "%s.%s", global_tunable,
  snprintf(key_persist, sizeof(key_persist), "%s.%s", global_tunable,