am 06850f9c: am b50d0cd5: Merge "rootdir: Make trusty version readable by dumpstate" into lmp-mr1-dev
* commit '06850f9ccd9c7668a8ab80bdfea00c1b275b5af9':
rootdir: Make trusty version readable by dumpstate
diff --git a/adb/adb.h b/adb/adb.h
index 44e5981..273a143 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -339,6 +339,9 @@
int check_header(apacket *p);
int check_data(apacket *p);
+// Define it if you want to dump packets.
+#define DEBUG_PACKETS 0
+
#if !DEBUG_PACKETS
#define print_packet(tag,p) do {} while (0)
#endif
diff --git a/adb/adb_client.c b/adb/adb_client.c
index eb1720d..ac5e15a 100644
--- a/adb/adb_client.c
+++ b/adb/adb_client.c
@@ -279,7 +279,7 @@
fd = _adb_connect(service);
if(fd == -1) {
- D("_adb_connect error: %s\n", __adb_error);
+ D("_adb_connect error: %s", __adb_error);
} else if(fd == -2) {
fprintf(stderr,"** daemon still not running\n");
}
diff --git a/adb/adb_trace.h b/adb/adb_trace.h
index 8a5d9f8..b8a2f4c 100644
--- a/adb/adb_trace.h
+++ b/adb/adb_trace.h
@@ -73,8 +73,9 @@
if (ADB_TRACING) { \
int save_errno = errno; \
adb_mutex_lock(&D_lock); \
- fprintf(stderr, "%s::%s():", \
- __FILE__, __FUNCTION__); \
+ fprintf(stderr, "%16s: %5d:%5lu | ", \
+ __FUNCTION__, \
+ getpid(), adb_thread_id()); \
errno = save_errno; \
fprintf(stderr, __VA_ARGS__ ); \
fflush(stderr); \
@@ -96,15 +97,16 @@
} while (0)
# define DD(...) \
do { \
- int save_errno = errno; \
- adb_mutex_lock(&D_lock); \
- fprintf(stderr, "%s::%s():", \
- __FILE__, __FUNCTION__); \
- errno = save_errno; \
- fprintf(stderr, __VA_ARGS__ ); \
- fflush(stderr); \
- adb_mutex_unlock(&D_lock); \
- errno = save_errno; \
+ int save_errno = errno; \
+ adb_mutex_lock(&D_lock); \
+ fprintf(stderr, "%16s: %5d:%5lu | ", \
+ __FUNCTION__, \
+ getpid(), adb_thread_id()); \
+ errno = save_errno; \
+ fprintf(stderr, __VA_ARGS__ ); \
+ fflush(stderr); \
+ adb_mutex_unlock(&D_lock); \
+ errno = save_errno; \
} while (0)
#else
# define D(...) \
diff --git a/adb/fdevent.c b/adb/fdevent.c
index 43e600c..f5ecd14 100644
--- a/adb/fdevent.c
+++ b/adb/fdevent.c
@@ -661,6 +661,8 @@
if(adb_socketpair(s)) {
FATAL("cannot create shell-exit socket-pair\n");
}
+ D("socketpair: (%d,%d)", s[0], s[1]);
+
SHELL_EXIT_NOTIFY_FD = s[0];
fdevent *fde;
fde = fdevent_create(s[1], fdevent_subproc_event_func, NULL);
diff --git a/adb/jdwp_service.c b/adb/jdwp_service.c
index cd62b55..3074e42 100644
--- a/adb/jdwp_service.c
+++ b/adb/jdwp_service.c
@@ -415,6 +415,7 @@
__FUNCTION__, strerror(errno));
return -1;
}
+ D("socketpair: (%d,%d)", fds[0], fds[1]);
proc->out_fds[ proc->out_count ] = fds[1];
if (++proc->out_count == 1)
diff --git a/adb/services.c b/adb/services.c
index 21b08dc..2f00d29 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -164,6 +164,7 @@
printf("cannot create service socket pair\n");
return -1;
}
+ D("socketpair: (%d,%d)", s[0], s[1]);
sti = malloc(sizeof(stinfo));
if(sti == 0) fatal("cannot allocate stinfo");
@@ -264,10 +265,11 @@
// 0 is parent socket, 1 is child socket
int sv[2];
- if (unix_socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0) {
+ if (adb_socketpair(sv) < 0) {
printf("[ cannot create socket pair - %s ]\n", strerror(errno));
return -1;
}
+ D("socketpair: (%d,%d)", sv[0], sv[1]);
*pid = fork();
if (*pid < 0) {
diff --git a/adb/sysdeps.h b/adb/sysdeps.h
index cc1f839..8d63d14 100644
--- a/adb/sysdeps.h
+++ b/adb/sysdeps.h
@@ -77,6 +77,11 @@
return 0;
}
+static __inline__ unsigned long adb_thread_id()
+{
+ return GetCurrentThreadId();
+}
+
static __inline__ void close_on_exec(int fd)
{
/* nothing really */
@@ -516,6 +521,12 @@
{
return strtok_r(str, delim, saveptr);
}
+
+static __inline__ unsigned long adb_thread_id()
+{
+ return (unsigned long)pthread_self();
+}
+
#undef strtok_r
#define strtok_r ___xxx_strtok_r
diff --git a/adb/transport.c b/adb/transport.c
index f35880c..7db6a47 100644
--- a/adb/transport.c
+++ b/adb/transport.c
@@ -629,7 +629,7 @@
fatal_errno("cannot open transport socketpair");
}
- D("transport: %s (%d,%d) starting\n", t->serial, s[0], s[1]);
+ D("transport: %s socketpair: (%d,%d) starting", t->serial, s[0], s[1]);
t->transport_socket = s[0];
t->fd = s[1];
@@ -673,6 +673,7 @@
if(adb_socketpair(s)){
fatal_errno("cannot open transport registration socketpair");
}
+ D("socketpair: (%d,%d)", s[0], s[1]);
transport_registration_send = s[0];
transport_registration_recv = s[1];
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index 43d05aa..019d16f 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -295,9 +295,8 @@
" Can override the fs type and/or\n"
" size the bootloader reports.\n"
" getvar <variable> display a bootloader variable\n"
- " boot <kernel> [ <ramdisk> [ <second> ] ] download and boot kernel\n"
- " flash:raw boot <kernel> [ <ramdisk> [ <second> ] ] create bootimage and \n"
- " flash it\n"
+ " boot <kernel> [ <ramdisk> ] download and boot kernel\n"
+ " flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it\n"
" devices list all connected devices\n"
" continue continue with autoboot\n"
" reboot reboot device normally\n"
@@ -325,11 +324,10 @@
}
void *load_bootable_image(const char *kernel, const char *ramdisk,
- const char *secondstage, unsigned *sz,
- const char *cmdline)
+ unsigned *sz, const char *cmdline)
{
- void *kdata = 0, *rdata = 0, *sdata = 0;
- unsigned ksize = 0, rsize = 0, ssize = 0;
+ void *kdata = 0, *rdata = 0;
+ unsigned ksize = 0, rsize = 0;
void *bdata;
unsigned bsize;
@@ -365,18 +363,10 @@
}
}
- if (secondstage) {
- sdata = load_file(secondstage, &ssize);
- if(sdata == 0) {
- fprintf(stderr,"cannot load '%s': %s\n", secondstage, strerror(errno));
- return 0;
- }
- }
-
fprintf(stderr,"creating boot image...\n");
bdata = mkbootimg(kdata, ksize, kernel_offset,
rdata, rsize, ramdisk_offset,
- sdata, ssize, second_offset,
+ 0, 0, second_offset,
page_size, base_addr, tags_offset, &bsize);
if(bdata == 0) {
fprintf(stderr,"failed to create boot.img\n");
@@ -1154,7 +1144,6 @@
} else if(!strcmp(*argv, "boot")) {
char *kname = 0;
char *rname = 0;
- char *sname = 0;
skip(1);
if (argc > 0) {
kname = argv[0];
@@ -1164,11 +1153,7 @@
rname = argv[0];
skip(1);
}
- if (argc > 0) {
- sname = argv[0];
- skip(1);
- }
- data = load_bootable_image(kname, rname, sname, &sz, cmdline);
+ data = load_bootable_image(kname, rname, &sz, cmdline);
if (data == 0) return 1;
fb_queue_download("boot.img", data, sz);
fb_queue_command("boot", "booting");
@@ -1192,18 +1177,14 @@
char *pname = argv[1];
char *kname = argv[2];
char *rname = 0;
- char *sname = 0;
require(3);
- skip(3);
- if (argc > 0) {
- rname = argv[0];
- skip(1);
+ if(argc > 3) {
+ rname = argv[3];
+ skip(4);
+ } else {
+ skip(3);
}
- if (argc > 0) {
- sname = argv[0];
- skip(1);
- }
- data = load_bootable_image(kname, rname, sname, &sz, cmdline);
+ data = load_bootable_image(kname, rname, &sz, cmdline);
if (data == 0) die("cannot load bootable image");
fb_queue_flash(pname, data, sz);
} else if(!strcmp(*argv, "flashall")) {
diff --git a/init/init.c b/init/init.c
index 99474e6..9d7bf27 100644
--- a/init/init.c
+++ b/init/init.c
@@ -542,17 +542,35 @@
return (list_tail(&act->commands) == &cmd->clist);
}
+
+void build_triggers_string(char *name_str, int length, struct action *cur_action) {
+ struct listnode *node;
+ struct trigger *cur_trigger;
+
+ list_for_each(node, &cur_action->triggers) {
+ cur_trigger = node_to_item(node, struct trigger, nlist);
+ if (node != cur_action->triggers.next) {
+ strlcat(name_str, " " , length);
+ }
+ strlcat(name_str, cur_trigger->name , length);
+ }
+}
+
void execute_one_command(void)
{
int ret, i;
char cmd_str[256] = "";
+ char name_str[256] = "";
if (!cur_action || !cur_command || is_last_command(cur_action, cur_command)) {
cur_action = action_remove_queue_head();
cur_command = NULL;
if (!cur_action)
return;
- INFO("processing action %p (%s)\n", cur_action, cur_action->name);
+
+ build_triggers_string(name_str, sizeof(name_str), cur_action);
+
+ INFO("processing action %p (%s)\n", cur_action, name_str);
cur_command = get_first_command(cur_action);
} else {
cur_command = get_next_command(cur_action, cur_command);
@@ -570,7 +588,7 @@
}
}
INFO("command '%s' action=%s status=%d (%s:%d)\n",
- cmd_str, cur_action ? cur_action->name : "", ret, cur_command->filename,
+ cmd_str, cur_action ? name_str : "", ret, cur_command->filename,
cur_command->line);
}
}
diff --git a/init/init.h b/init/init.h
index a7615a3..e03bd53 100644
--- a/init/init.h
+++ b/init/init.h
@@ -37,6 +37,11 @@
char *args[1];
};
+struct trigger {
+ struct listnode nlist;
+ const char *name;
+};
+
struct action {
/* node in list of all actions */
struct listnode alist;
@@ -46,12 +51,15 @@
struct listnode tlist;
unsigned hash;
- const char *name;
+ /* list of actions which triggers the commands*/
+ struct listnode triggers;
struct listnode commands;
struct command *current;
};
+void build_triggers_string(char *name_str, int length, struct action *cur_action);
+
struct socketinfo {
struct socketinfo *next;
const char *name;
diff --git a/init/init_parser.c b/init/init_parser.c
index 6466db2..869dff2 100644
--- a/init/init_parser.c
+++ b/init/init_parser.c
@@ -504,77 +504,92 @@
void action_for_each_trigger(const char *trigger,
void (*func)(struct action *act))
{
- struct listnode *node;
+ struct listnode *node, *node2;
struct action *act;
+ struct trigger *cur_trigger;
+
list_for_each(node, &action_list) {
act = node_to_item(node, struct action, alist);
- if (!strcmp(act->name, trigger)) {
- func(act);
+ list_for_each(node2, &act->triggers) {
+ cur_trigger = node_to_item(node2, struct trigger, nlist);
+ if (!strcmp(cur_trigger->name, trigger)) {
+ func(act);
+ }
}
}
}
+
void queue_property_triggers(const char *name, const char *value)
{
- struct listnode *node;
+ struct listnode *node, *node2;
struct action *act;
+ struct trigger *cur_trigger;
+ bool match;
+ int name_length;
+
list_for_each(node, &action_list) {
act = node_to_item(node, struct action, alist);
- if (!strncmp(act->name, "property:", strlen("property:"))) {
- const char *test = act->name + strlen("property:");
- int name_length = strlen(name);
+ match = !name;
+ list_for_each(node2, &act->triggers) {
+ cur_trigger = node_to_item(node2, struct trigger, nlist);
+ if (!strncmp(cur_trigger->name, "property:", strlen("property:"))) {
+ const char *test = cur_trigger->name + strlen("property:");
+ if (!match) {
+ name_length = strlen(name);
+ if (!strncmp(name, test, name_length) &&
+ test[name_length] == '=' &&
+ (!strcmp(test + name_length + 1, value) ||
+ !strcmp(test + name_length + 1, "*"))) {
+ match = true;
+ continue;
+ }
+ } else {
+ const char* equals = strchr(test, '=');
+ if (equals) {
+ char prop_name[PROP_NAME_MAX + 1];
+ char value[PROP_VALUE_MAX];
+ int length = equals - test;
+ if (length <= PROP_NAME_MAX) {
+ int ret;
+ memcpy(prop_name, test, length);
+ prop_name[length] = 0;
- if (!strncmp(name, test, name_length) &&
- test[name_length] == '=' &&
- (!strcmp(test + name_length + 1, value) ||
- !strcmp(test + name_length + 1, "*"))) {
- action_add_queue_tail(act);
- }
+ /* does the property exist, and match the trigger value? */
+ ret = property_get(prop_name, value);
+ if (ret > 0 && (!strcmp(equals + 1, value) ||
+ !strcmp(equals + 1, "*"))) {
+ continue;
+ }
+ }
+ }
+ }
+ }
+ match = false;
+ break;
+ }
+ if (match) {
+ action_add_queue_tail(act);
}
}
}
void queue_all_property_triggers()
{
- struct listnode *node;
- struct action *act;
- list_for_each(node, &action_list) {
- act = node_to_item(node, struct action, alist);
- if (!strncmp(act->name, "property:", strlen("property:"))) {
- /* parse property name and value
- syntax is property:<name>=<value> */
- const char* name = act->name + strlen("property:");
- const char* equals = strchr(name, '=');
- if (equals) {
- char prop_name[PROP_NAME_MAX + 1];
- char value[PROP_VALUE_MAX];
- int length = equals - name;
- if (length > PROP_NAME_MAX) {
- ERROR("property name too long in trigger %s", act->name);
- } else {
- int ret;
- memcpy(prop_name, name, length);
- prop_name[length] = 0;
-
- /* does the property exist, and match the trigger value? */
- ret = property_get(prop_name, value);
- if (ret > 0 && (!strcmp(equals + 1, value) ||
- !strcmp(equals + 1, "*"))) {
- action_add_queue_tail(act);
- }
- }
- }
- }
- }
+ queue_property_triggers(NULL, NULL);
}
void queue_builtin_action(int (*func)(int nargs, char **args), char *name)
{
struct action *act;
struct command *cmd;
+ struct trigger *cur_trigger;
act = calloc(1, sizeof(*act));
- act->name = name;
+ cur_trigger = calloc(1, sizeof(*cur_trigger));
+ cur_trigger->name = name;
+ list_init(&act->triggers);
+ list_add_tail(&act->triggers, &cur_trigger->nlist);
list_init(&act->commands);
list_init(&act->qlist);
@@ -616,6 +631,7 @@
static void *parse_service(struct parse_state *state, int nargs, char **args)
{
struct service *svc;
+ struct trigger *cur_trigger;
if (nargs < 3) {
parse_error(state, "services must have a name and a program\n");
return 0;
@@ -640,9 +656,12 @@
svc->name = args[1];
svc->classname = "default";
memcpy(svc->args, args + 2, sizeof(char*) * nargs);
+ cur_trigger = calloc(1, sizeof(*cur_trigger));
svc->args[nargs] = 0;
svc->nargs = nargs;
- svc->onrestart.name = "onrestart";
+ list_init(&svc->onrestart.triggers);
+ cur_trigger->name = "onrestart";
+ list_add_tail(&svc->onrestart.triggers, &cur_trigger->nlist);
list_init(&svc->onrestart.commands);
list_add_tail(&service_list, &svc->slist);
return svc;
@@ -826,16 +845,29 @@
static void *parse_action(struct parse_state *state, int nargs, char **args)
{
struct action *act;
+ struct trigger *cur_trigger;
+ int i;
if (nargs < 2) {
parse_error(state, "actions must have a trigger\n");
return 0;
}
- if (nargs > 2) {
- parse_error(state, "actions may not have extra parameters\n");
- return 0;
- }
+
act = calloc(1, sizeof(*act));
- act->name = args[1];
+ list_init(&act->triggers);
+
+ for (i = 1; i < nargs; i++) {
+ if (!(i % 2)) {
+ if (strcmp(args[i], "&&")) {
+ parse_error(state, "& is the only symbol allowed to concatenate actions\n");
+ return 0;
+ } else
+ continue;
+ }
+ cur_trigger = calloc(1, sizeof(*cur_trigger));
+ cur_trigger->name = args[i];
+ list_add_tail(&act->triggers, &cur_trigger->nlist);
+ }
+
list_init(&act->commands);
list_init(&act->qlist);
list_add_tail(&action_list, &act->alist);
diff --git a/init/parser.c b/init/parser.c
index 48e7aec..80bfb09 100644
--- a/init/parser.c
+++ b/init/parser.c
@@ -15,9 +15,10 @@
struct command *cmd;
struct listnode *node;
struct listnode *node2;
+ char name_str[256] = "";
struct socketinfo *si;
int n;
-
+
list_for_each(node, &service_list) {
svc = node_to_item(node, struct service, slist);
RAW("service %s\n", svc->name);
@@ -34,7 +35,11 @@
list_for_each(node, &action_list) {
act = node_to_item(node, struct action, alist);
- RAW("on %s\n", act->name);
+ RAW("on ");
+ build_triggers_string(name_str, sizeof(name_str), act);
+ RAW("%s", name_str);
+ RAW("\n");
+
list_for_each(node2, &act->commands) {
cmd = node_to_item(node2, struct command, clist);
RAW(" %p", cmd->func);
diff --git a/init/readme.txt b/init/readme.txt
index 750d953..0b43fd5 100644
--- a/init/readme.txt
+++ b/init/readme.txt
@@ -123,6 +123,15 @@
Triggers of this form occur when the property <name> is set
to the specific value <value>.
+ One can also test Mutliple properties to execute a group
+ of commands. For example:
+
+ on property:test.a=1 && property:test.b=1
+ setprop test.c 1
+
+ The above stub sets test.c to 1 only when
+ both test.a=1 and test.b=1
+
Commands
--------
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 89f9aa6..b8e959b 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -518,6 +518,7 @@
onrestart restart zygote
onrestart restart media
onrestart restart surfaceflinger
+ onrestart restart inputflinger
onrestart restart drm
service vold /system/bin/vold
@@ -551,6 +552,12 @@
group graphics drmrpc
onrestart restart zygote
+service inputflinger /system/bin/inputflinger
+ class main
+ user system
+ group input
+ onrestart restart zygote
+
service drm /system/bin/drmserver
class main
user drm