init: switch property_get to use __system_property_get
Change-Id: I4fc0502a1a5b331087618a4d2e3d90948743d7bd
This commit is contained in:
parent
406c3bb885
commit
2deedfe0b1
5 changed files with 32 additions and 37 deletions
22
init/init.c
22
init/init.c
|
@ -625,7 +625,7 @@ static void import_kernel_nv(char *name, int for_emulator)
|
|||
static void export_kernel_boot_props(void)
|
||||
{
|
||||
char tmp[PROP_VALUE_MAX];
|
||||
const char *pval;
|
||||
int ret;
|
||||
unsigned i;
|
||||
struct {
|
||||
const char *src_prop;
|
||||
|
@ -639,22 +639,24 @@ static void export_kernel_boot_props(void)
|
|||
};
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(prop_map); i++) {
|
||||
pval = property_get(prop_map[i].src_prop);
|
||||
property_set(prop_map[i].dest_prop, pval ?: prop_map[i].def_val);
|
||||
ret = property_get(prop_map[i].src_prop, tmp);
|
||||
if (ret == 0)
|
||||
property_set(prop_map[i].dest_prop, prop_map[i].def_val);
|
||||
}
|
||||
|
||||
pval = property_get("ro.boot.console");
|
||||
if (pval)
|
||||
strlcpy(console, pval, sizeof(console));
|
||||
ret = property_get("ro.boot.console", tmp);
|
||||
if (ret)
|
||||
strlcpy(console, tmp, sizeof(console));
|
||||
|
||||
/* save a copy for init's usage during boot */
|
||||
strlcpy(bootmode, property_get("ro.bootmode"), sizeof(bootmode));
|
||||
property_get("ro.bootmode", tmp);
|
||||
strlcpy(bootmode, tmp, sizeof(bootmode));
|
||||
|
||||
/* if this was given on kernel command line, override what we read
|
||||
* before (e.g. from /proc/cpuinfo), if anything */
|
||||
pval = property_get("ro.boot.hardware");
|
||||
if (pval)
|
||||
strlcpy(hardware, pval, sizeof(hardware));
|
||||
ret = property_get("ro.boot.hardware", tmp);
|
||||
if (ret)
|
||||
strlcpy(hardware, tmp, sizeof(hardware));
|
||||
property_set("ro.hardware", hardware);
|
||||
|
||||
snprintf(tmp, PROP_VALUE_MAX, "%d", revision);
|
||||
|
|
|
@ -208,8 +208,9 @@ int expand_props(char *dst, const char *src, int dst_size)
|
|||
while (*src_ptr && left > 0) {
|
||||
char *c;
|
||||
char prop[PROP_NAME_MAX + 1];
|
||||
const char *prop_val;
|
||||
char prop_val[PROP_VALUE_MAX];
|
||||
int prop_len = 0;
|
||||
int prop_val_len;
|
||||
|
||||
c = strchr(src_ptr, '$');
|
||||
if (!c) {
|
||||
|
@ -267,14 +268,14 @@ int expand_props(char *dst, const char *src, int dst_size)
|
|||
goto err;
|
||||
}
|
||||
|
||||
prop_val = property_get(prop);
|
||||
if (!prop_val) {
|
||||
prop_val_len = property_get(prop, prop_val);
|
||||
if (!prop_val_len) {
|
||||
ERROR("property '%s' doesn't exist while expanding '%s'\n",
|
||||
prop, src);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = push_chars(&dst_ptr, &left, prop_val, strlen(prop_val));
|
||||
ret = push_chars(&dst_ptr, &left, prop_val, prop_val_len);
|
||||
if (ret < 0)
|
||||
goto err_nospace;
|
||||
src_ptr = c;
|
||||
|
@ -545,7 +546,7 @@ void queue_all_property_triggers()
|
|||
const char* equals = strchr(name, '=');
|
||||
if (equals) {
|
||||
char prop_name[PROP_NAME_MAX + 1];
|
||||
const char* value;
|
||||
char value[PROP_VALUE_MAX];
|
||||
int length = equals - name;
|
||||
if (length > PROP_NAME_MAX) {
|
||||
ERROR("property name too long in trigger %s", act->name);
|
||||
|
@ -554,9 +555,8 @@ void queue_all_property_triggers()
|
|||
prop_name[length] = 0;
|
||||
|
||||
/* does the property exist, and match the trigger value? */
|
||||
value = property_get(prop_name);
|
||||
if (value && (!strcmp(equals + 1, value) ||
|
||||
!strcmp(equals + 1, "*"))) {
|
||||
property_get(prop_name, value);
|
||||
if (!strcmp(equals + 1, value) ||!strcmp(equals + 1, "*")) {
|
||||
action_add_queue_tail(act);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,20 +95,19 @@ void keychord_init()
|
|||
void handle_keychord()
|
||||
{
|
||||
struct service *svc;
|
||||
const char* debuggable;
|
||||
const char* adb_enabled;
|
||||
char adb_enabled[PROP_VALUE_MAX];
|
||||
int ret;
|
||||
__u16 id;
|
||||
|
||||
// Only handle keychords if adb is enabled.
|
||||
adb_enabled = property_get("init.svc.adbd");
|
||||
property_get("init.svc.adbd", adb_enabled);
|
||||
ret = read(keychord_fd, &id, sizeof(id));
|
||||
if (ret != sizeof(id)) {
|
||||
ERROR("could not read keychord id\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((adb_enabled && !strcmp(adb_enabled, "running"))) {
|
||||
if (!strcmp(adb_enabled, "running")) {
|
||||
svc = service_find_by_keychord(id);
|
||||
if (svc) {
|
||||
INFO("starting service %s from keychord\n", svc->name);
|
||||
|
|
|
@ -299,19 +299,9 @@ static int check_perms(const char *name, unsigned int uid, unsigned int gid, cha
|
|||
return 0;
|
||||
}
|
||||
|
||||
const char* property_get(const char *name)
|
||||
int property_get(const char *name, char value[PROP_VALUE_MAX])
|
||||
{
|
||||
prop_info *pi;
|
||||
|
||||
if(strlen(name) >= PROP_NAME_MAX) return 0;
|
||||
|
||||
pi = (prop_info*) __system_property_find(name);
|
||||
|
||||
if(pi != 0) {
|
||||
return pi->value;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return __system_property_get(name, value);
|
||||
}
|
||||
|
||||
static void write_persistent_property(const char *name, const char *value)
|
||||
|
@ -598,8 +588,11 @@ int properties_inited(void)
|
|||
|
||||
static void load_override_properties() {
|
||||
#ifdef ALLOW_LOCAL_PROP_OVERRIDE
|
||||
const char *debuggable = property_get("ro.debuggable");
|
||||
if (debuggable && (strcmp(debuggable, "1") == 0)) {
|
||||
char debuggable[PROP_VALUE_MAX];
|
||||
int ret;
|
||||
|
||||
ret = property_get("ro.debuggable", debuggable);
|
||||
if (ret && (strcmp(debuggable, "1") == 0)) {
|
||||
load_properties_from_file(PROP_PATH_LOCAL_OVERRIDE);
|
||||
}
|
||||
#endif /* ALLOW_LOCAL_PROP_OVERRIDE */
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#define _INIT_PROPERTY_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sys/system_properties.h>
|
||||
|
||||
extern void handle_property_set_fd(void);
|
||||
extern void property_init(void);
|
||||
|
@ -25,7 +26,7 @@ extern void property_load_boot_defaults(void);
|
|||
extern void load_persist_props(void);
|
||||
extern void start_property_service(void);
|
||||
void get_property_workspace(int *fd, int *sz);
|
||||
extern const char* property_get(const char *name);
|
||||
extern int property_get(const char *name, char value[PROP_VALUE_MAX]);
|
||||
extern int property_set(const char *name, const char *value);
|
||||
extern int properties_inited();
|
||||
int get_property_set_fd(void);
|
||||
|
|
Loading…
Reference in a new issue