OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/android/common/adb_connection.h" | 5 #include "tools/android/common/adb_connection.h" |
6 | 6 |
7 #include <arpa/inet.h> | 7 #include <arpa/inet.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 bytes_sent += ret; | 76 bytes_sent += ret; |
77 bytes_remaining -= ret; | 77 bytes_remaining -= ret; |
78 } | 78 } |
79 | 79 |
80 const size_t kAdbStatusLength = 4; | 80 const size_t kAdbStatusLength = 4; |
81 char response[kBufferMaxLength]; | 81 char response[kBufferMaxLength]; |
82 int response_length = HANDLE_EINTR(recv(host_socket, response, | 82 int response_length = HANDLE_EINTR(recv(host_socket, response, |
83 kBufferMaxLength, 0)); | 83 kBufferMaxLength, 0)); |
84 if (response_length < kAdbStatusLength || | 84 if (response_length < kAdbStatusLength || |
85 strncmp("OKAY", response, kAdbStatusLength) != 0) { | 85 strncmp("OKAY", response, kAdbStatusLength) != 0) { |
| 86 char fail_msg_buffer[kBufferMaxLength * 3 + 1]; |
| 87 char* p = fail_msg_buffer; |
| 88 for (int i = 0; i < response_length; ++i) { |
| 89 snprintf(p, 3, "%02x,", static_cast<unsigned char>(response[i])); |
| 90 p += 3; |
| 91 } |
| 92 |
| 93 if (p > fail_msg_buffer) |
| 94 *(--p) = 0; // Eliminate the last comma. |
86 LOG(ERROR) << "Bad response from ADB: length: " << response_length | 95 LOG(ERROR) << "Bad response from ADB: length: " << response_length |
87 << " data: " << DumpBinary(response, response_length); | 96 << " data: " << fail_msg_buffer; |
88 HANDLE_EINTR(close(host_socket)); | 97 HANDLE_EINTR(close(host_socket)); |
89 return -1; | 98 return -1; |
90 } | 99 } |
91 | 100 |
92 return host_socket; | 101 return host_socket; |
93 } | 102 } |
94 | 103 |
95 } // namespace tools | 104 } // namespace tools |
96 | 105 |
OLD | NEW |