Merge \\\"Minor adb style fixes.\\\" am: 35151f49ca am: b94f3c597c
am: 4d6559af5b
Change-Id: If2c53cc93bf2a565df873d5b81eb8248562d45f9
This commit is contained in:
commit
f9e0583e8e
2 changed files with 11 additions and 10 deletions
19
adb/adb.cpp
19
adb/adb.cpp
|
|
@ -329,8 +329,6 @@ static void handle_new_connection(atransport* t, apacket* p) {
|
||||||
|
|
||||||
void handle_packet(apacket *p, atransport *t)
|
void handle_packet(apacket *p, atransport *t)
|
||||||
{
|
{
|
||||||
asocket *s;
|
|
||||||
|
|
||||||
D("handle_packet() %c%c%c%c", ((char*) (&(p->msg.command)))[0],
|
D("handle_packet() %c%c%c%c", ((char*) (&(p->msg.command)))[0],
|
||||||
((char*) (&(p->msg.command)))[1],
|
((char*) (&(p->msg.command)))[1],
|
||||||
((char*) (&(p->msg.command)))[2],
|
((char*) (&(p->msg.command)))[2],
|
||||||
|
|
@ -339,7 +337,7 @@ void handle_packet(apacket *p, atransport *t)
|
||||||
|
|
||||||
switch(p->msg.command){
|
switch(p->msg.command){
|
||||||
case A_SYNC:
|
case A_SYNC:
|
||||||
if(p->msg.arg0){
|
if (p->msg.arg0){
|
||||||
send_packet(p, t);
|
send_packet(p, t);
|
||||||
#if ADB_HOST
|
#if ADB_HOST
|
||||||
send_connect(t);
|
send_connect(t);
|
||||||
|
|
@ -384,8 +382,8 @@ void handle_packet(apacket *p, atransport *t)
|
||||||
if (t->online && p->msg.arg0 != 0 && p->msg.arg1 == 0) {
|
if (t->online && p->msg.arg0 != 0 && p->msg.arg1 == 0) {
|
||||||
char *name = (char*) p->data;
|
char *name = (char*) p->data;
|
||||||
name[p->msg.data_length > 0 ? p->msg.data_length - 1 : 0] = 0;
|
name[p->msg.data_length > 0 ? p->msg.data_length - 1 : 0] = 0;
|
||||||
s = create_local_service_socket(name, t);
|
asocket* s = create_local_service_socket(name, t);
|
||||||
if(s == 0) {
|
if (s == nullptr) {
|
||||||
send_close(0, p->msg.arg0, t);
|
send_close(0, p->msg.arg0, t);
|
||||||
} else {
|
} else {
|
||||||
s->peer = create_remote_socket(p->msg.arg0, t);
|
s->peer = create_remote_socket(p->msg.arg0, t);
|
||||||
|
|
@ -398,7 +396,8 @@ void handle_packet(apacket *p, atransport *t)
|
||||||
|
|
||||||
case A_OKAY: /* READY(local-id, remote-id, "") */
|
case A_OKAY: /* READY(local-id, remote-id, "") */
|
||||||
if (t->online && p->msg.arg0 != 0 && p->msg.arg1 != 0) {
|
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) {
|
if(s->peer == 0) {
|
||||||
/* On first READY message, create the connection. */
|
/* On first READY message, create the connection. */
|
||||||
s->peer = create_remote_socket(p->msg.arg0, t);
|
s->peer = create_remote_socket(p->msg.arg0, t);
|
||||||
|
|
@ -422,7 +421,8 @@ void handle_packet(apacket *p, atransport *t)
|
||||||
|
|
||||||
case A_CLSE: /* CLOSE(local-id, remote-id, "") or CLOSE(0, remote-id, "") */
|
case A_CLSE: /* CLOSE(local-id, remote-id, "") or CLOSE(0, remote-id, "") */
|
||||||
if (t->online && p->msg.arg1 != 0) {
|
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
|
/* According to protocol.txt, p->msg.arg0 might be 0 to indicate
|
||||||
* a failed OPEN only. However, due to a bug in previous ADB
|
* a failed OPEN only. However, due to a bug in previous ADB
|
||||||
* versions, CLOSE(0, remote-id, "") was also used for normal
|
* versions, CLOSE(0, remote-id, "") was also used for normal
|
||||||
|
|
@ -445,11 +445,12 @@ void handle_packet(apacket *p, atransport *t)
|
||||||
|
|
||||||
case A_WRTE: /* WRITE(local-id, remote-id, <data>) */
|
case A_WRTE: /* WRITE(local-id, remote-id, <data>) */
|
||||||
if (t->online && p->msg.arg0 != 0 && p->msg.arg1 != 0) {
|
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;
|
unsigned rid = p->msg.arg0;
|
||||||
p->len = p->msg.data_length;
|
p->len = p->msg.data_length;
|
||||||
|
|
||||||
if(s->enqueue(s, p) == 0) {
|
if (s->enqueue(s, p) == 0) {
|
||||||
D("Enqueue the socket");
|
D("Enqueue the socket");
|
||||||
send_ready(s->id, rid, t);
|
send_ready(s->id, rid, t);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -410,7 +410,7 @@ asocket* create_local_service_socket(const char* name, const atransport* transpo
|
||||||
#endif
|
#endif
|
||||||
int fd = service_to_fd(name, transport);
|
int fd = service_to_fd(name, transport);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
asocket* s = create_local_socket(fd);
|
asocket* s = create_local_socket(fd);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue