Android property system / service and how android sets and gets properties

Each property has a name and value, and they are all in string format. Each process can get/set properties. When the system is initialized, Android will allocate a shared memory area to store the properties. These are done by the “init” daemon. The “init” daemon will start an android property service.


int main(int argc, char **argv)
    queue_builtin_action(property_service_init_action, "property_service_init");

static int property_service_init_action(int nargs, char **args)
    /* read any property files on system or data and
     * fire up the property service.  This must happen
     * after the properties are set above so
     * that /data/local.prop cannot interfere with them.
    return 0;


#define PROP_PATH_RAMDISK_DEFAULT  "/default.prop"
#define PROP_PATH_SYSTEM_BUILD     "/system/build.prop"
#define PROP_PATH_SYSTEM_DEFAULT   "/system/default.prop"
#define PROP_PATH_LOCAL_OVERRIDE   "/data/local.prop"

void start_property_service(void)
    int fd;
    /* Read persistent properties after all default values have been loaded. */
    fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM, 0666, 0, 0);
    if(fd < 0) return;
    fcntl(fd, F_SETFD, FD_CLOEXEC);
    fcntl(fd, F_SETFL, O_NONBLOCK);
    listen(fd, 8);
    property_set_fd = fd;


int property_set(const char *key, const char *value)
    return __system_property_set(key, value);
int property_get(const char *key, char *value, const char *default_value)
    int len;
    len = __system_property_get(key, value);
    if(len > 0) {
        return len;
    if(default_value) {
        len = strlen(default_value);
        memcpy(value, default_value, len + 1);
    return len;


int __system_property_get(const char *name, char *value)
    const prop_info *pi = __system_property_find(name);
    if(pi != 0) {
        return __system_property_read(pi, 0, value);
    } else {
        value[0] = 0;
        return 0;

int __system_property_set(const char *key, const char *value)
    int err;
    prop_msg msg;
    if(key == 0) return -1;
    if(value == 0) value = "";
    if(strlen(key) >= PROP_NAME_MAX) return -1;
    if(strlen(value) >= PROP_VALUE_MAX) return -1;
    memset(&msg, 0, sizeof msg);
    msg.cmd = PROP_MSG_SETPROP;
    strlcpy(, key, sizeof;
    strlcpy(msg.value, value, sizeof msg.value);
    err = send_prop_msg(&msg);
    if(err < 0) {
        return err;
    return 0;

Set system property name to value. Properties are expanded within value.

SHUFFLED :   How to Install ADB & Fastboot on Ubuntu 16.04, 16.10, 17.04, 17.10, 18.04, 18.10

Wait for system property name to be value. Properties are expanded within value. If property name is already set to value, continue immediately.

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply