The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __ADB_H |
| 18 | #define __ADB_H |
| 19 | |
| 20 | #include <limits.h> |
Dan Albert | b302d12 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 21 | #include <sys/types.h> |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 22 | |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 23 | #include <base/macros.h> |
| 24 | |
leozwang | f25a6a4 | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 25 | #include "adb_trace.h" |
Dan Albert | bbbbea6 | 2014-11-24 23:34:35 -0800 | [diff] [blame] | 26 | #include "fdevent.h" |
JP Abgrall | 2e5dd6e | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 27 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 28 | #define MAX_PAYLOAD 4096 |
| 29 | |
| 30 | #define A_SYNC 0x434e5953 |
| 31 | #define A_CNXN 0x4e584e43 |
| 32 | #define A_OPEN 0x4e45504f |
| 33 | #define A_OKAY 0x59414b4f |
| 34 | #define A_CLSE 0x45534c43 |
| 35 | #define A_WRTE 0x45545257 |
Benoit Goby | 2cc19e4 | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 36 | #define A_AUTH 0x48545541 |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 37 | |
Dan Albert | b302d12 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 38 | // ADB protocol version. |
| 39 | #define A_VERSION 0x01000000 |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 40 | |
Dan Albert | b302d12 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 41 | // Used for help/version information. |
| 42 | #define ADB_VERSION_MAJOR 1 |
| 43 | #define ADB_VERSION_MINOR 0 |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 44 | |
Dan Albert | b302d12 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 45 | // Increment this when we want to force users to start a new adb server. |
| 46 | #define ADB_SERVER_VERSION 32 |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 47 | |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 48 | class atransport; |
Elliott Hughes | fe7ff81 | 2015-04-17 09:47:42 -0700 | [diff] [blame] | 49 | struct usb_handle; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 50 | |
| 51 | struct amessage { |
| 52 | unsigned command; /* command identifier constant */ |
| 53 | unsigned arg0; /* first argument */ |
| 54 | unsigned arg1; /* second argument */ |
| 55 | unsigned data_length; /* length of payload (0 is allowed) */ |
| 56 | unsigned data_check; /* checksum of data payload */ |
| 57 | unsigned magic; /* command ^ 0xffffffff */ |
| 58 | }; |
| 59 | |
| 60 | struct apacket |
| 61 | { |
| 62 | apacket *next; |
| 63 | |
| 64 | unsigned len; |
| 65 | unsigned char *ptr; |
| 66 | |
| 67 | amessage msg; |
| 68 | unsigned char data[MAX_PAYLOAD]; |
| 69 | }; |
| 70 | |
| 71 | /* An asocket represents one half of a connection between a local and |
| 72 | ** remote entity. A local asocket is bound to a file descriptor. A |
| 73 | ** remote asocket is bound to the protocol engine. |
| 74 | */ |
| 75 | struct asocket { |
| 76 | /* chain pointers for the local/remote list of |
| 77 | ** asockets that this asocket lives in |
| 78 | */ |
| 79 | asocket *next; |
| 80 | asocket *prev; |
| 81 | |
| 82 | /* the unique identifier for this asocket |
| 83 | */ |
| 84 | unsigned id; |
| 85 | |
| 86 | /* flag: set when the socket's peer has closed |
| 87 | ** but packets are still queued for delivery |
| 88 | */ |
| 89 | int closing; |
| 90 | |
Benoit Goby | 88468f3 | 2012-03-16 14:50:07 -0700 | [diff] [blame] | 91 | /* flag: quit adbd when both ends close the |
| 92 | ** local service socket |
| 93 | */ |
| 94 | int exit_on_close; |
| 95 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 96 | /* the asocket we are connected to |
| 97 | */ |
| 98 | |
| 99 | asocket *peer; |
| 100 | |
| 101 | /* For local asockets, the fde is used to bind |
| 102 | ** us to our fd event system. For remote asockets |
| 103 | ** these fields are not used. |
| 104 | */ |
| 105 | fdevent fde; |
| 106 | int fd; |
| 107 | |
| 108 | /* queue of apackets waiting to be written |
| 109 | */ |
| 110 | apacket *pkt_first; |
| 111 | apacket *pkt_last; |
| 112 | |
| 113 | /* enqueue is called by our peer when it has data |
| 114 | ** for us. It should return 0 if we can accept more |
| 115 | ** data or 1 if not. If we return 1, we must call |
| 116 | ** peer->ready() when we once again are ready to |
| 117 | ** receive data. |
| 118 | */ |
| 119 | int (*enqueue)(asocket *s, apacket *pkt); |
| 120 | |
| 121 | /* ready is called by the peer when it is ready for |
| 122 | ** us to send data via enqueue again |
| 123 | */ |
| 124 | void (*ready)(asocket *s); |
| 125 | |
David 'Digit' Turner | e92344d | 2013-12-13 14:09:44 +0100 | [diff] [blame] | 126 | /* shutdown is called by the peer before it goes away. |
| 127 | ** the socket should not do any further calls on its peer. |
| 128 | ** Always followed by a call to close. Optional, i.e. can be NULL. |
| 129 | */ |
| 130 | void (*shutdown)(asocket *s); |
| 131 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 132 | /* close is called by the peer when it has gone away. |
| 133 | ** we are not allowed to make any further calls on the |
| 134 | ** peer once our close method is called. |
| 135 | */ |
| 136 | void (*close)(asocket *s); |
| 137 | |
Benoit Goby | 12dc369 | 2013-02-20 15:04:53 -0800 | [diff] [blame] | 138 | /* A socket is bound to atransport */ |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 139 | atransport *transport; |
| 140 | }; |
| 141 | |
| 142 | |
| 143 | /* the adisconnect structure is used to record a callback that |
| 144 | ** will be called whenever a transport is disconnected (e.g. by the user) |
| 145 | ** this should be used to cleanup objects that depend on the |
| 146 | ** transport (e.g. remote sockets, listeners, etc...) |
| 147 | */ |
| 148 | struct adisconnect |
| 149 | { |
| 150 | void (*func)(void* opaque, atransport* t); |
| 151 | void* opaque; |
| 152 | adisconnect* next; |
| 153 | adisconnect* prev; |
| 154 | }; |
| 155 | |
| 156 | |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 157 | // A transport object models the connection to a remote device or emulator there |
| 158 | // is one transport per connected device/emulator. A "local transport" connects |
| 159 | // through TCP (for the emulator), while a "usb transport" through USB (for real |
| 160 | // devices). |
| 161 | // |
| 162 | // Note that kTransportHost doesn't really correspond to a real transport |
| 163 | // object, it's a special value used to indicate that a client wants to connect |
| 164 | // to a service implemented within the ADB server itself. |
Elliott Hughes | 3aec2ba | 2015-05-05 13:10:43 -0700 | [diff] [blame] | 165 | enum TransportType { |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 166 | kTransportUsb, |
| 167 | kTransportLocal, |
| 168 | kTransportAny, |
| 169 | kTransportHost, |
Elliott Hughes | fe7ff81 | 2015-04-17 09:47:42 -0700 | [diff] [blame] | 170 | }; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 171 | |
Benoit Goby | 2cc19e4 | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 172 | #define TOKEN_SIZE 20 |
| 173 | |
Dan Albert | 9a50f4c | 2015-05-18 16:43:57 -0700 | [diff] [blame] | 174 | enum ConnectionState { |
| 175 | kCsAny = -1, |
| 176 | kCsOffline = 0, |
| 177 | kCsBootloader, |
| 178 | kCsDevice, |
| 179 | kCsHost, |
| 180 | kCsRecovery, |
| 181 | kCsNoPerm, // Insufficient permissions to communicate with the device. |
| 182 | kCsSideload, |
| 183 | kCsUnauthorized, |
| 184 | }; |
| 185 | |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 186 | class atransport { |
| 187 | public: |
| 188 | // TODO(danalbert): We expose waaaaaaay too much stuff because this was |
| 189 | // historically just a struct, but making the whole thing a more idiomatic |
| 190 | // class in one go is a very large change. Given how bad our testing is, |
| 191 | // it's better to do this piece by piece. |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 192 | |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 193 | atransport() { |
| 194 | auth_fde = {}; |
| 195 | transport_fde = {}; |
| 196 | } |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 197 | |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 198 | virtual ~atransport() {} |
| 199 | |
| 200 | int (*read_from_remote)(apacket* p, atransport* t) = nullptr; |
| 201 | int (*write_to_remote)(apacket* p, atransport* t) = nullptr; |
| 202 | void (*close)(atransport* t) = nullptr; |
| 203 | void (*kick)(atransport* t) = nullptr; |
| 204 | |
| 205 | int fd = -1; |
| 206 | int transport_socket = -1; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 207 | fdevent transport_fde; |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 208 | int ref_count = 0; |
| 209 | uint32_t sync_token = 0; |
| 210 | ConnectionState connection_state = kCsOffline; |
| 211 | bool online = false; |
| 212 | TransportType type = kTransportAny; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 213 | |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 214 | // USB handle or socket fd as needed. |
| 215 | usb_handle* usb = nullptr; |
| 216 | int sfd = -1; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 217 | |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 218 | // Used to identify transports for clients. |
| 219 | char* serial = nullptr; |
| 220 | char* product = nullptr; |
| 221 | char* model = nullptr; |
| 222 | char* device = nullptr; |
| 223 | char* devpath = nullptr; |
| 224 | int adb_port = -1; // Use for emulators (local transport) |
| 225 | bool kicked = false; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 226 | |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 227 | // A list of adisconnect callbacks called when the transport is kicked. |
| 228 | adisconnect disconnects = {}; |
Benoit Goby | 2cc19e4 | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 229 | |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 230 | void* key = nullptr; |
| 231 | unsigned char token[TOKEN_SIZE] = {}; |
Benoit Goby | 2cc19e4 | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 232 | fdevent auth_fde; |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 233 | size_t failed_auth_attempts = 0; |
Elliott Hughes | 88b4c85 | 2015-04-30 17:32:03 -0700 | [diff] [blame] | 234 | |
| 235 | const char* connection_state_name() const; |
Dan Albert | ecce503 | 2015-05-18 16:46:31 -0700 | [diff] [blame^] | 236 | |
| 237 | private: |
| 238 | DISALLOW_COPY_AND_ASSIGN(atransport); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | |
| 242 | /* A listener is an entity which binds to a local port |
| 243 | ** and, upon receiving a connection on that port, creates |
| 244 | ** an asocket to connect the new local connection to a |
| 245 | ** specific remote service. |
| 246 | ** |
| 247 | ** TODO: some listeners read from the new connection to |
| 248 | ** determine what exact service to connect to on the far |
| 249 | ** side. |
| 250 | */ |
| 251 | struct alistener |
| 252 | { |
| 253 | alistener *next; |
| 254 | alistener *prev; |
| 255 | |
| 256 | fdevent fde; |
| 257 | int fd; |
| 258 | |
Dan Albert | f30d73c | 2015-02-25 17:51:28 -0800 | [diff] [blame] | 259 | char *local_name; |
| 260 | char *connect_to; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 261 | atransport *transport; |
| 262 | adisconnect disconnect; |
| 263 | }; |
| 264 | |
| 265 | |
| 266 | void print_packet(const char *label, apacket *p); |
| 267 | |
David 'Digit' Turner | e92344d | 2013-12-13 14:09:44 +0100 | [diff] [blame] | 268 | asocket *find_local_socket(unsigned local_id, unsigned remote_id); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 269 | void install_local_socket(asocket *s); |
| 270 | void remove_socket(asocket *s); |
| 271 | void close_all_sockets(atransport *t); |
| 272 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 273 | asocket *create_local_socket(int fd); |
| 274 | asocket *create_local_service_socket(const char *destination); |
| 275 | |
| 276 | asocket *create_remote_socket(unsigned id, atransport *t); |
| 277 | void connect_to_remote(asocket *s, const char *destination); |
| 278 | void connect_to_smartsocket(asocket *s); |
| 279 | |
| 280 | void fatal(const char *fmt, ...); |
| 281 | void fatal_errno(const char *fmt, ...); |
| 282 | |
| 283 | void handle_packet(apacket *p, atransport *t); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 284 | |
Alexey Tarasov | 857f17a | 2009-10-22 02:55:00 +1100 | [diff] [blame] | 285 | void get_my_path(char *s, size_t maxLen); |
Stefan Hilzinger | 92ca4fa | 2010-04-19 12:21:12 +0100 | [diff] [blame] | 286 | int launch_server(int server_port); |
| 287 | int adb_main(int is_daemon, int server_port); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 288 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 289 | /* initialize a transport object's func pointers and state */ |
Stefan Hilzinger | 1ec0342 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 290 | #if ADB_HOST |
| 291 | int get_available_local_transport_index(); |
| 292 | #endif |
Mike Lockwood | b51ae57 | 2009-08-24 15:58:40 -0700 | [diff] [blame] | 293 | int init_socket_transport(atransport *t, int s, int port, int local); |
Dan Albert | 9a50f4c | 2015-05-18 16:43:57 -0700 | [diff] [blame] | 294 | void init_usb_transport(atransport *t, usb_handle *usb, ConnectionState state); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 295 | |
Stefan Hilzinger | 1ec0342 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 296 | #if ADB_HOST |
| 297 | atransport* find_emulator_transport_by_adb_port(int adb_port); |
| 298 | #endif |
Mike Lockwood | 5f2c4a1 | 2009-10-11 23:04:18 -0400 | [diff] [blame] | 299 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 300 | int service_to_fd(const char *name); |
| 301 | #if ADB_HOST |
| 302 | asocket *host_service_to_socket(const char* name, const char *serial); |
| 303 | #endif |
| 304 | |
| 305 | #if !ADB_HOST |
| 306 | int init_jdwp(void); |
| 307 | asocket* create_jdwp_service_socket(); |
| 308 | asocket* create_jdwp_tracker_service_socket(); |
| 309 | int create_jdwp_connection_fd(int jdwp_pid); |
| 310 | #endif |
| 311 | |
Elliott Hughes | 9d07fee | 2015-05-07 21:38:41 -0700 | [diff] [blame] | 312 | int handle_forward_request(const char* service, TransportType type, const char* serial, int reply_fd); |
David 'Digit' Turner | 963a449 | 2013-03-21 21:07:42 +0100 | [diff] [blame] | 313 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 314 | #if !ADB_HOST |
| 315 | void framebuffer_service(int fd, void *cookie); |
Paul Lawrence | 8ba2b02 | 2014-12-03 15:31:57 -0800 | [diff] [blame] | 316 | void set_verity_enabled_state_service(int fd, void* cookie); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 317 | #endif |
| 318 | |
| 319 | /* packet allocator */ |
| 320 | apacket *get_apacket(void); |
| 321 | void put_apacket(apacket *p); |
| 322 | |
leozwang | 1be5462 | 2014-08-15 09:51:27 -0700 | [diff] [blame] | 323 | // Define it if you want to dump packets. |
| 324 | #define DEBUG_PACKETS 0 |
| 325 | |
Benoit Goby | 2cc19e4 | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 326 | #if !DEBUG_PACKETS |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 327 | #define print_packet(tag,p) do {} while (0) |
| 328 | #endif |
| 329 | |
John Michelau | 8733752 | 2010-09-23 17:08:34 -0500 | [diff] [blame] | 330 | #if ADB_HOST_ON_TARGET |
| 331 | /* adb and adbd are coexisting on the target, so use 5038 for adb |
| 332 | * to avoid conflicting with adbd's usage of 5037 |
| 333 | */ |
| 334 | # define DEFAULT_ADB_PORT 5038 |
| 335 | #else |
| 336 | # define DEFAULT_ADB_PORT 5037 |
| 337 | #endif |
| 338 | |
Stefan Hilzinger | 92ca4fa | 2010-04-19 12:21:12 +0100 | [diff] [blame] | 339 | #define DEFAULT_ADB_LOCAL_TRANSPORT_PORT 5555 |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 340 | |
Xavier Ducrohet | 30a4033 | 2009-05-21 17:47:43 -0700 | [diff] [blame] | 341 | #define ADB_CLASS 0xff |
| 342 | #define ADB_SUBCLASS 0x42 |
| 343 | #define ADB_PROTOCOL 0x1 |
Dima Zavin | 3e82491 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 344 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 345 | |
Mike Lockwood | a8b3875 | 2009-08-26 12:50:22 -0700 | [diff] [blame] | 346 | void local_init(int port); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 347 | int local_connect(int port); |
Stefan Hilzinger | 1ec0342 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 348 | int local_connect_arbitrary_ports(int console_port, int adb_port); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 349 | |
| 350 | /* usb host/client interface */ |
| 351 | void usb_init(); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 352 | int usb_write(usb_handle *h, const void *data, int len); |
| 353 | int usb_read(usb_handle *h, void *data, int len); |
| 354 | int usb_close(usb_handle *h); |
| 355 | void usb_kick(usb_handle *h); |
| 356 | |
| 357 | /* used for USB device detection */ |
Xavier Ducrohet | 2ef5fc2 | 2009-05-20 17:33:53 -0700 | [diff] [blame] | 358 | #if ADB_HOST |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 359 | int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol); |
Xavier Ducrohet | 2ef5fc2 | 2009-05-20 17:33:53 -0700 | [diff] [blame] | 360 | #endif |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 361 | |
Dan Albert | f30d73c | 2015-02-25 17:51:28 -0800 | [diff] [blame] | 362 | int adb_commandline(int argc, const char **argv); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 363 | |
Dan Albert | 9a50f4c | 2015-05-18 16:43:57 -0700 | [diff] [blame] | 364 | ConnectionState connection_state(atransport *t); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 365 | |
Dan Albert | 432ffe2 | 2015-02-18 18:22:45 -0800 | [diff] [blame] | 366 | extern const char *adb_device_banner; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 367 | extern int HOST; |
JP Abgrall | 2e5dd6e | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 368 | extern int SHELL_EXIT_NOTIFY_FD; |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 369 | |
| 370 | #define CHUNK_SIZE (64*1024) |
| 371 | |
Andrzej Pietrasiewicz | d7270f2 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 372 | #if !ADB_HOST |
| 373 | #define USB_ADB_PATH "/dev/android_adb" |
| 374 | |
| 375 | #define USB_FFS_ADB_PATH "/dev/usb-ffs/adb/" |
| 376 | #define USB_FFS_ADB_EP(x) USB_FFS_ADB_PATH#x |
| 377 | |
| 378 | #define USB_FFS_ADB_EP0 USB_FFS_ADB_EP(ep0) |
| 379 | #define USB_FFS_ADB_OUT USB_FFS_ADB_EP(ep1) |
| 380 | #define USB_FFS_ADB_IN USB_FFS_ADB_EP(ep2) |
| 381 | #endif |
| 382 | |
Elliott Hughes | 9d07fee | 2015-05-07 21:38:41 -0700 | [diff] [blame] | 383 | int handle_host_request(const char* service, TransportType type, const char* serial, int reply_fd, asocket *s); |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 384 | |
Dan Albert | 056ad0e | 2015-02-18 17:47:33 -0800 | [diff] [blame] | 385 | void handle_online(atransport *t); |
| 386 | void handle_offline(atransport *t); |
| 387 | |
| 388 | void send_connect(atransport *t); |
| 389 | |
The Android Open Source Project | 9ca14dc | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 390 | #endif |