diff options
Diffstat (limited to 'init/property_service.cpp')
-rw-r--r-- | init/property_service.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/init/property_service.cpp b/init/property_service.cpp index 52f6b98..fe82bef 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -54,6 +54,7 @@ #include "init.h" #include "util.h" #include "log.h" +#include "vendor_init.h" #define PERSISTENT_PROPERTY_DIR "/data/property" #define FSTAB_PREFIX "/fstab." @@ -149,6 +150,33 @@ int __property_get(const char *name, char *value) return __system_property_get(name, value); } +bool property_get_bool(const char *key, bool default_value) { + if (!key) { + return default_value; + } + + bool result = default_value; + char buf[PROP_VALUE_MAX] = {'\0',}; + + int len = __property_get(key, buf); + if (len == 1) { + char ch = buf[0]; + if (ch == '0' || ch == 'n') { + result = false; + } else if (ch == '1' || ch == 'y') { + result = true; + } + } else if (len > 1) { + if (!strcmp(buf, "no") || !strcmp(buf, "false") || !strcmp(buf, "off")) { + result = false; + } else if (!strcmp(buf, "yes") || !strcmp(buf, "true") || !strcmp(buf, "on")) { + result = true; + } + } + + return result; +} + static void write_persistent_property(const char *name, const char *value) { char tempPath[PATH_MAX]; @@ -518,6 +546,11 @@ void load_persist_props(void) { load_override_properties(); /* Read persistent properties after all default values have been loaded. */ load_persistent_properties(); + + /* update with vendor-specific property runtime + * overrides + */ + vendor_load_properties(); } void load_recovery_id_prop() { @@ -564,6 +597,7 @@ void load_system_props() { load_properties_from_file(PROP_PATH_SYSTEM_BUILD, NULL); load_properties_from_file(PROP_PATH_VENDOR_BUILD, NULL); load_properties_from_file(PROP_PATH_FACTORY, "ro.*"); + load_recovery_id_prop(); } |