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

Commit 1f0bd32f authored by Mike Lockwood's avatar Mike Lockwood
Browse files

init: Add support for assigning system properties to system properties in init.rc



For example:
    setprop sys.usb.config $persist.sys.usb.config

Change-Id: I7b4e1ed1335906b32621bd96a341b0f94bbee7f5
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent f5cb5b24
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -440,7 +440,24 @@ int do_setkey(int nargs, char **args)

int do_setprop(int nargs, char **args)
{
    property_set(args[1], args[2]);
    const char *name = args[1];
    const char *value = args[2];

    if (value[0] == '$') {
        /* Use the value of a system property if value starts with '$' */
        value++;
        if (value[0] != '$') {
            value = property_get(value);
            if (!value) {
                ERROR("property %s has no value for assigning to %s\n", value, name);
                return -EINVAL;
            }
        } /* else fall through to support double '$' prefix for setting properties
           * to string literals that start with '$'
           */
    }

    property_set(name, value);
    return 0;
}

@@ -522,8 +539,8 @@ int do_sysclktz(int nargs, char **args)

int do_write(int nargs, char **args)
{
    char *path = args[1];
    char *value = args[2];
    const char *path = args[1];
    const char *value = args[2];
    if (value[0] == '$') {
        /* Write the value of a system property if value starts with '$' */
        value++;