Merge "init: report createProcessGroup failure."
diff --git a/adb/adb.cpp b/adb/adb.cpp
index 3f14f1a..c3f1a96 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -329,8 +329,6 @@
void handle_packet(apacket *p, atransport *t)
{
- asocket *s;
-
D("handle_packet() %c%c%c%c", ((char*) (&(p->msg.command)))[0],
((char*) (&(p->msg.command)))[1],
((char*) (&(p->msg.command)))[2],
@@ -339,7 +337,7 @@
switch(p->msg.command){
case A_SYNC:
- if(p->msg.arg0){
+ if (p->msg.arg0){
send_packet(p, t);
#if ADB_HOST
send_connect(t);
@@ -384,8 +382,8 @@
if (t->online && p->msg.arg0 != 0 && p->msg.arg1 == 0) {
char *name = (char*) p->data;
name[p->msg.data_length > 0 ? p->msg.data_length - 1 : 0] = 0;
- s = create_local_service_socket(name, t);
- if(s == 0) {
+ asocket* s = create_local_service_socket(name, t);
+ if (s == nullptr) {
send_close(0, p->msg.arg0, t);
} else {
s->peer = create_remote_socket(p->msg.arg0, t);
@@ -398,7 +396,8 @@
case A_OKAY: /* READY(local-id, remote-id, "") */
if (t->online && p->msg.arg0 != 0 && p->msg.arg1 != 0) {
- if((s = find_local_socket(p->msg.arg1, 0))) {
+ asocket* s = find_local_socket(p->msg.arg1, 0);
+ if (s) {
if(s->peer == 0) {
/* On first READY message, create the connection. */
s->peer = create_remote_socket(p->msg.arg0, t);
@@ -422,7 +421,8 @@
case A_CLSE: /* CLOSE(local-id, remote-id, "") or CLOSE(0, remote-id, "") */
if (t->online && p->msg.arg1 != 0) {
- if((s = find_local_socket(p->msg.arg1, p->msg.arg0))) {
+ asocket* s = find_local_socket(p->msg.arg1, p->msg.arg0);
+ if (s) {
/* According to protocol.txt, p->msg.arg0 might be 0 to indicate
* a failed OPEN only. However, due to a bug in previous ADB
* versions, CLOSE(0, remote-id, "") was also used for normal
@@ -445,11 +445,12 @@
case A_WRTE: /* WRITE(local-id, remote-id, <data>) */
if (t->online && p->msg.arg0 != 0 && p->msg.arg1 != 0) {
- if((s = find_local_socket(p->msg.arg1, p->msg.arg0))) {
+ asocket* s = find_local_socket(p->msg.arg1, p->msg.arg0);
+ if (s) {
unsigned rid = p->msg.arg0;
p->len = p->msg.data_length;
- if(s->enqueue(s, p) == 0) {
+ if (s->enqueue(s, p) == 0) {
D("Enqueue the socket");
send_ready(s->id, rid, t);
}
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index b815fef..477edc1 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -872,19 +872,18 @@
* we hang up.
*/
static int adb_sideload_host(const char* fn) {
- printf("loading: '%s'", fn);
- fflush(stdout);
+ fprintf(stderr, "loading: '%s'...\n", fn);
std::string content;
if (!android::base::ReadFileToString(fn, &content)) {
- printf("\n");
- fprintf(stderr, "* cannot read '%s' *\n", fn);
+ fprintf(stderr, "failed: %s\n", strerror(errno));
return -1;
}
const uint8_t* data = reinterpret_cast<const uint8_t*>(content.data());
unsigned sz = content.size();
+ fprintf(stderr, "connecting...\n");
std::string service =
android::base::StringPrintf("sideload-host:%d:%d", sz, SIDELOAD_HOST_BLOCK_SIZE);
std::string error;
@@ -892,7 +891,7 @@
if (fd < 0) {
// Try falling back to the older sideload method. Maybe this
// is an older device that doesn't support sideload-host.
- printf("\n");
+ fprintf(stderr, "falling back to older sideload method...\n");
return adb_download_buffer("sideload", fn, data, sz, true);
}
@@ -1093,12 +1092,10 @@
return true;
}
- // Give adbd 500ms to kill itself, then wait-for-device for it to come back up.
- adb_sleep_ms(500);
- TransportType type;
- const char* serial;
- adb_get_transport(&type, &serial);
- return wait_for_device("wait-for-any", type, serial);
+ // Give adbd some time to kill itself and come back up.
+ // We can't use wait-for-device because devices (e.g. adb over network) might not come back.
+ adb_sleep_ms(3000);
+ return true;
}
// Connects to the device "shell" service with |command| and prints the
diff --git a/adb/sockets.cpp b/adb/sockets.cpp
index b2555d0..4ed1c45 100644
--- a/adb/sockets.cpp
+++ b/adb/sockets.cpp
@@ -410,7 +410,7 @@
#endif
int fd = service_to_fd(name, transport);
if (fd < 0) {
- return 0;
+ return nullptr;
}
asocket* s = create_local_socket(fd);
diff --git a/rootdir/init.zygote32.rc b/rootdir/init.zygote32.rc
index 0ca38b9..4b76383 100644
--- a/rootdir/init.zygote32.rc
+++ b/rootdir/init.zygote32.rc
@@ -1,5 +1,6 @@
service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
class main
+ priority -20
socket zygote stream 660 root system
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
diff --git a/rootdir/init.zygote32_64.rc b/rootdir/init.zygote32_64.rc
index 1646c0f..2efd8e2 100644
--- a/rootdir/init.zygote32_64.rc
+++ b/rootdir/init.zygote32_64.rc
@@ -1,5 +1,6 @@
service zygote /system/bin/app_process32 -Xzygote /system/bin --zygote --start-system-server --socket-name=zygote
class main
+ priority -20
socket zygote stream 660 root system
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
@@ -9,6 +10,7 @@
service zygote_secondary /system/bin/app_process64 -Xzygote /system/bin --zygote --socket-name=zygote_secondary
class main
+ priority -20
socket zygote_secondary stream 660 root system
onrestart restart zygote
writepid /dev/cpuset/foreground/tasks /sys/fs/cgroup/stune/foreground/tasks
diff --git a/rootdir/init.zygote64.rc b/rootdir/init.zygote64.rc
index b477c8e..342a561 100644
--- a/rootdir/init.zygote64.rc
+++ b/rootdir/init.zygote64.rc
@@ -1,5 +1,6 @@
service zygote /system/bin/app_process64 -Xzygote /system/bin --zygote --start-system-server
class main
+ priority -20
socket zygote stream 660 root system
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
diff --git a/rootdir/init.zygote64_32.rc b/rootdir/init.zygote64_32.rc
index 633a981..b3ac7b0 100644
--- a/rootdir/init.zygote64_32.rc
+++ b/rootdir/init.zygote64_32.rc
@@ -1,5 +1,6 @@
service zygote /system/bin/app_process64 -Xzygote /system/bin --zygote --start-system-server --socket-name=zygote
class main
+ priority -20
socket zygote stream 660 root system
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
@@ -9,6 +10,7 @@
service zygote_secondary /system/bin/app_process32 -Xzygote /system/bin --zygote --socket-name=zygote_secondary
class main
+ priority -20
socket zygote_secondary stream 660 root system
onrestart restart zygote
writepid /dev/cpuset/foreground/tasks /sys/fs/cgroup/stune/foreground/tasks