Merge "adbd: add logging to troubleshoot usb issues."

am: 5550901152

Change-Id: I3ca18fdd1c55eaca10ad790a6678a7e9e8e974bb
This commit is contained in:
Josh Gao 2017-07-27 00:46:21 +00:00 committed by android-build-merger
commit 07c337bb7d
3 changed files with 19 additions and 14 deletions

View file

@ -217,8 +217,8 @@ void send_auth_request(atransport* t) {
send_packet(p, t); send_packet(p, t);
} }
void adbd_auth_verified(atransport *t) void adbd_auth_verified(atransport* t) {
{ LOG(INFO) << "adb client authorized";
handle_online(t); handle_online(t);
send_connect(t); send_connect(t);
} }

View file

@ -235,6 +235,8 @@ static const struct {
}; };
bool init_functionfs(struct usb_handle* h) { bool init_functionfs(struct usb_handle* h) {
LOG(INFO) << "initializing functionfs";
ssize_t ret; ssize_t ret;
struct desc_v1 v1_descriptor; struct desc_v1 v1_descriptor;
struct desc_v2 v2_descriptor; struct desc_v2 v2_descriptor;
@ -255,10 +257,10 @@ bool init_functionfs(struct usb_handle* h) {
v2_descriptor.os_desc = os_desc_compat; v2_descriptor.os_desc = os_desc_compat;
if (h->control < 0) { // might have already done this before if (h->control < 0) { // might have already done this before
D("OPENING %s", USB_FFS_ADB_EP0); LOG(INFO) << "opening control endpoint " << USB_FFS_ADB_EP0;
h->control = adb_open(USB_FFS_ADB_EP0, O_RDWR); h->control = adb_open(USB_FFS_ADB_EP0, O_RDWR);
if (h->control < 0) { if (h->control < 0) {
D("[ %s: cannot open control endpoint: errno=%d]", USB_FFS_ADB_EP0, errno); PLOG(ERROR) << "cannot open control endpoint " << USB_FFS_ADB_EP0;
goto err; goto err;
} }
@ -289,13 +291,13 @@ bool init_functionfs(struct usb_handle* h) {
h->bulk_out = adb_open(USB_FFS_ADB_OUT, O_RDWR); h->bulk_out = adb_open(USB_FFS_ADB_OUT, O_RDWR);
if (h->bulk_out < 0) { if (h->bulk_out < 0) {
D("[ %s: cannot open bulk-out ep: errno=%d ]", USB_FFS_ADB_OUT, errno); PLOG(ERROR) << "cannot open bulk-out endpoint " << USB_FFS_ADB_OUT;
goto err; goto err;
} }
h->bulk_in = adb_open(USB_FFS_ADB_IN, O_RDWR); h->bulk_in = adb_open(USB_FFS_ADB_IN, O_RDWR);
if (h->bulk_in < 0) { if (h->bulk_in < 0) {
D("[ %s: cannot open bulk-in ep: errno=%d ]", USB_FFS_ADB_IN, errno); PLOG(ERROR) << "cannot open bulk-in endpoint " << USB_FFS_ADB_IN;
goto err; goto err;
} }
@ -356,12 +358,13 @@ static void usb_ffs_open_thread(void* x) {
while (true) { while (true) {
if (init_functionfs(usb)) { if (init_functionfs(usb)) {
LOG(INFO) << "functionfs successfully initialized";
break; break;
} }
std::this_thread::sleep_for(1s); std::this_thread::sleep_for(1s);
} }
D("[ usb_thread - registering device ]"); LOG(INFO) << "registering usb transport";
register_usb_transport(usb, 0, 0, 1); register_usb_transport(usb, 0, 0, 1);
} }
@ -430,6 +433,8 @@ static void usb_ffs_kick(usb_handle* h) {
} }
static void usb_ffs_close(usb_handle* h) { static void usb_ffs_close(usb_handle* h) {
LOG(INFO) << "closing functionfs transport";
h->kicked = false; h->kicked = false;
adb_close(h->bulk_out); adb_close(h->bulk_out);
adb_close(h->bulk_in); adb_close(h->bulk_in);

View file

@ -120,24 +120,24 @@ err_msg:
static int remote_read(apacket *p, atransport *t) static int remote_read(apacket *p, atransport *t)
{ {
if (usb_read(t->usb, &p->msg, sizeof(amessage))) { if (usb_read(t->usb, &p->msg, sizeof(amessage))) {
D("remote usb: read terminated (message)"); PLOG(ERROR) << "remote usb: read terminated (message)";
return -1; return -1;
} }
if (!check_header(p, t)) { if (!check_header(p, t)) {
D("remote usb: check_header failed"); LOG(ERROR) << "remote usb: check_header failed";
return -1; return -1;
} }
if (p->msg.data_length) { if (p->msg.data_length) {
if (usb_read(t->usb, p->data, p->msg.data_length)) { if (usb_read(t->usb, p->data, p->msg.data_length)) {
D("remote usb: terminated (data)"); PLOG(ERROR) << "remote usb: terminated (data)";
return -1; return -1;
} }
} }
if (!check_data(p)) { if (!check_data(p)) {
D("remote usb: check_data failed"); LOG(ERROR) << "remote usb: check_data failed";
return -1; return -1;
} }
@ -150,12 +150,12 @@ static int remote_write(apacket *p, atransport *t)
unsigned size = p->msg.data_length; unsigned size = p->msg.data_length;
if (usb_write(t->usb, &p->msg, sizeof(amessage))) { if (usb_write(t->usb, &p->msg, sizeof(amessage))) {
D("remote usb: 1 - write terminated"); PLOG(ERROR) << "remote usb: 1 - write terminated";
return -1; return -1;
} }
if(p->msg.data_length == 0) return 0; if (p->msg.data_length == 0) return 0;
if (usb_write(t->usb, &p->data, size)) { if (usb_write(t->usb, &p->data, size)) {
D("remote usb: 2 - write terminated"); PLOG(ERROR) << "remote usb: 2 - write terminated";
return -1; return -1;
} }