| The Android Open Source Project | dd7bc33 | 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 | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 21 | #include <sys/types.h> | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 22 |  | 
| leozwang | d3fc15f | 2014-07-29 12:50:02 -0700 | [diff] [blame] | 23 | #include "adb_trace.h" | 
| Dan Albert | 630b9af | 2014-11-24 23:34:35 -0800 | [diff] [blame] | 24 | #include "fdevent.h" | 
| JP Abgrall | 408fa57 | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 25 |  | 
| Dan Albert | 818fb4b | 2015-02-18 00:18:25 -0800 | [diff] [blame] | 26 | #ifdef __cplusplus | 
|  | 27 | extern "C" { | 
|  | 28 | #endif | 
|  | 29 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 30 | #define MAX_PAYLOAD 4096 | 
|  | 31 |  | 
|  | 32 | #define A_SYNC 0x434e5953 | 
|  | 33 | #define A_CNXN 0x4e584e43 | 
|  | 34 | #define A_OPEN 0x4e45504f | 
|  | 35 | #define A_OKAY 0x59414b4f | 
|  | 36 | #define A_CLSE 0x45534c43 | 
|  | 37 | #define A_WRTE 0x45545257 | 
| Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 38 | #define A_AUTH 0x48545541 | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 39 |  | 
| Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 40 | // ADB protocol version. | 
|  | 41 | #define A_VERSION 0x01000000 | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 42 |  | 
| Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 43 | // Used for help/version information. | 
|  | 44 | #define ADB_VERSION_MAJOR 1 | 
|  | 45 | #define ADB_VERSION_MINOR 0 | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 46 |  | 
| Dan Albert | 7664901 | 2015-02-24 15:51:19 -0800 | [diff] [blame] | 47 | // Increment this when we want to force users to start a new adb server. | 
|  | 48 | #define ADB_SERVER_VERSION 32 | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 49 |  | 
|  | 50 | typedef struct amessage amessage; | 
|  | 51 | typedef struct apacket apacket; | 
|  | 52 | typedef struct asocket asocket; | 
|  | 53 | typedef struct alistener alistener; | 
|  | 54 | typedef struct aservice aservice; | 
|  | 55 | typedef struct atransport atransport; | 
|  | 56 | typedef struct adisconnect  adisconnect; | 
|  | 57 | typedef struct usb_handle usb_handle; | 
|  | 58 |  | 
|  | 59 | struct amessage { | 
|  | 60 | unsigned command;       /* command identifier constant      */ | 
|  | 61 | unsigned arg0;          /* first argument                   */ | 
|  | 62 | unsigned arg1;          /* second argument                  */ | 
|  | 63 | unsigned data_length;   /* length of payload (0 is allowed) */ | 
|  | 64 | unsigned data_check;    /* checksum of data payload         */ | 
|  | 65 | unsigned magic;         /* command ^ 0xffffffff             */ | 
|  | 66 | }; | 
|  | 67 |  | 
|  | 68 | struct apacket | 
|  | 69 | { | 
|  | 70 | apacket *next; | 
|  | 71 |  | 
|  | 72 | unsigned len; | 
|  | 73 | unsigned char *ptr; | 
|  | 74 |  | 
|  | 75 | amessage msg; | 
|  | 76 | unsigned char data[MAX_PAYLOAD]; | 
|  | 77 | }; | 
|  | 78 |  | 
|  | 79 | /* An asocket represents one half of a connection between a local and | 
|  | 80 | ** remote entity.  A local asocket is bound to a file descriptor.  A | 
|  | 81 | ** remote asocket is bound to the protocol engine. | 
|  | 82 | */ | 
|  | 83 | struct asocket { | 
|  | 84 | /* chain pointers for the local/remote list of | 
|  | 85 | ** asockets that this asocket lives in | 
|  | 86 | */ | 
|  | 87 | asocket *next; | 
|  | 88 | asocket *prev; | 
|  | 89 |  | 
|  | 90 | /* the unique identifier for this asocket | 
|  | 91 | */ | 
|  | 92 | unsigned id; | 
|  | 93 |  | 
|  | 94 | /* flag: set when the socket's peer has closed | 
|  | 95 | ** but packets are still queued for delivery | 
|  | 96 | */ | 
|  | 97 | int    closing; | 
|  | 98 |  | 
| Benoit Goby | f366b36 | 2012-03-16 14:50:07 -0700 | [diff] [blame] | 99 | /* flag: quit adbd when both ends close the | 
|  | 100 | ** local service socket | 
|  | 101 | */ | 
|  | 102 | int    exit_on_close; | 
|  | 103 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 104 | /* the asocket we are connected to | 
|  | 105 | */ | 
|  | 106 |  | 
|  | 107 | asocket *peer; | 
|  | 108 |  | 
|  | 109 | /* For local asockets, the fde is used to bind | 
|  | 110 | ** us to our fd event system.  For remote asockets | 
|  | 111 | ** these fields are not used. | 
|  | 112 | */ | 
|  | 113 | fdevent fde; | 
|  | 114 | int fd; | 
|  | 115 |  | 
|  | 116 | /* queue of apackets waiting to be written | 
|  | 117 | */ | 
|  | 118 | apacket *pkt_first; | 
|  | 119 | apacket *pkt_last; | 
|  | 120 |  | 
|  | 121 | /* enqueue is called by our peer when it has data | 
|  | 122 | ** for us.  It should return 0 if we can accept more | 
|  | 123 | ** data or 1 if not.  If we return 1, we must call | 
|  | 124 | ** peer->ready() when we once again are ready to | 
|  | 125 | ** receive data. | 
|  | 126 | */ | 
|  | 127 | int (*enqueue)(asocket *s, apacket *pkt); | 
|  | 128 |  | 
|  | 129 | /* ready is called by the peer when it is ready for | 
|  | 130 | ** us to send data via enqueue again | 
|  | 131 | */ | 
|  | 132 | void (*ready)(asocket *s); | 
|  | 133 |  | 
| David 'Digit' Turner | 818d641 | 2013-12-13 14:09:44 +0100 | [diff] [blame] | 134 | /* shutdown is called by the peer before it goes away. | 
|  | 135 | ** the socket should not do any further calls on its peer. | 
|  | 136 | ** Always followed by a call to close. Optional, i.e. can be NULL. | 
|  | 137 | */ | 
|  | 138 | void (*shutdown)(asocket *s); | 
|  | 139 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 140 | /* close is called by the peer when it has gone away. | 
|  | 141 | ** we are not allowed to make any further calls on the | 
|  | 142 | ** peer once our close method is called. | 
|  | 143 | */ | 
|  | 144 | void (*close)(asocket *s); | 
|  | 145 |  | 
| Benoit Goby | 9470c2f | 2013-02-20 15:04:53 -0800 | [diff] [blame] | 146 | /* A socket is bound to atransport */ | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 147 | atransport *transport; | 
|  | 148 | }; | 
|  | 149 |  | 
|  | 150 |  | 
|  | 151 | /* the adisconnect structure is used to record a callback that | 
|  | 152 | ** will be called whenever a transport is disconnected (e.g. by the user) | 
|  | 153 | ** this should be used to cleanup objects that depend on the | 
|  | 154 | ** transport (e.g. remote sockets, listeners, etc...) | 
|  | 155 | */ | 
|  | 156 | struct  adisconnect | 
|  | 157 | { | 
|  | 158 | void        (*func)(void*  opaque, atransport*  t); | 
|  | 159 | void*         opaque; | 
|  | 160 | adisconnect*  next; | 
|  | 161 | adisconnect*  prev; | 
|  | 162 | }; | 
|  | 163 |  | 
|  | 164 |  | 
|  | 165 | /* a transport object models the connection to a remote device or emulator | 
|  | 166 | ** there is one transport per connected device/emulator. a "local transport" | 
|  | 167 | ** connects through TCP (for the emulator), while a "usb transport" through | 
|  | 168 | ** USB (for real devices) | 
|  | 169 | ** | 
|  | 170 | ** note that kTransportHost doesn't really correspond to a real transport | 
|  | 171 | ** object, it's a special value used to indicate that a client wants to | 
|  | 172 | ** connect to a service implemented within the ADB server itself. | 
|  | 173 | */ | 
|  | 174 | typedef enum transport_type { | 
|  | 175 | kTransportUsb, | 
|  | 176 | kTransportLocal, | 
|  | 177 | kTransportAny, | 
|  | 178 | kTransportHost, | 
|  | 179 | } transport_type; | 
|  | 180 |  | 
| Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 181 | #define TOKEN_SIZE 20 | 
|  | 182 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 183 | struct atransport | 
|  | 184 | { | 
|  | 185 | atransport *next; | 
|  | 186 | atransport *prev; | 
|  | 187 |  | 
|  | 188 | int (*read_from_remote)(apacket *p, atransport *t); | 
|  | 189 | int (*write_to_remote)(apacket *p, atransport *t); | 
|  | 190 | void (*close)(atransport *t); | 
|  | 191 | void (*kick)(atransport *t); | 
|  | 192 |  | 
|  | 193 | int fd; | 
|  | 194 | int transport_socket; | 
|  | 195 | fdevent transport_fde; | 
|  | 196 | int ref_count; | 
|  | 197 | unsigned sync_token; | 
|  | 198 | int connection_state; | 
| Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 199 | int online; | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 200 | transport_type type; | 
|  | 201 |  | 
|  | 202 | /* usb handle or socket fd as needed */ | 
|  | 203 | usb_handle *usb; | 
|  | 204 | int sfd; | 
|  | 205 |  | 
|  | 206 | /* used to identify transports for clients */ | 
|  | 207 | char *serial; | 
|  | 208 | char *product; | 
| Scott Anderson | e82c2db | 2012-05-25 14:10:02 -0700 | [diff] [blame] | 209 | char *model; | 
|  | 210 | char *device; | 
| Scott Anderson | e109d26 | 2012-04-20 11:21:14 -0700 | [diff] [blame] | 211 | char *devpath; | 
| Stefan Hilzinger | d9d1ca4 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 212 | int adb_port; // Use for emulators (local transport) | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 213 |  | 
|  | 214 | /* a list of adisconnect callbacks called when the transport is kicked */ | 
|  | 215 | int          kicked; | 
|  | 216 | adisconnect  disconnects; | 
| Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 217 |  | 
|  | 218 | void *key; | 
|  | 219 | unsigned char token[TOKEN_SIZE]; | 
|  | 220 | fdevent auth_fde; | 
|  | 221 | unsigned failed_auth_attempts; | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 222 | }; | 
|  | 223 |  | 
|  | 224 |  | 
|  | 225 | /* A listener is an entity which binds to a local port | 
|  | 226 | ** and, upon receiving a connection on that port, creates | 
|  | 227 | ** an asocket to connect the new local connection to a | 
|  | 228 | ** specific remote service. | 
|  | 229 | ** | 
|  | 230 | ** TODO: some listeners read from the new connection to | 
|  | 231 | ** determine what exact service to connect to on the far | 
|  | 232 | ** side. | 
|  | 233 | */ | 
|  | 234 | struct alistener | 
|  | 235 | { | 
|  | 236 | alistener *next; | 
|  | 237 | alistener *prev; | 
|  | 238 |  | 
|  | 239 | fdevent fde; | 
|  | 240 | int fd; | 
|  | 241 |  | 
|  | 242 | const char *local_name; | 
|  | 243 | const char *connect_to; | 
|  | 244 | atransport *transport; | 
|  | 245 | adisconnect  disconnect; | 
|  | 246 | }; | 
|  | 247 |  | 
|  | 248 |  | 
|  | 249 | void print_packet(const char *label, apacket *p); | 
|  | 250 |  | 
| David 'Digit' Turner | 818d641 | 2013-12-13 14:09:44 +0100 | [diff] [blame] | 251 | asocket *find_local_socket(unsigned local_id, unsigned remote_id); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 252 | void install_local_socket(asocket *s); | 
|  | 253 | void remove_socket(asocket *s); | 
|  | 254 | void close_all_sockets(atransport *t); | 
|  | 255 |  | 
|  | 256 | #define  LOCAL_CLIENT_PREFIX  "emulator-" | 
|  | 257 |  | 
|  | 258 | asocket *create_local_socket(int fd); | 
|  | 259 | asocket *create_local_service_socket(const char *destination); | 
|  | 260 |  | 
|  | 261 | asocket *create_remote_socket(unsigned id, atransport *t); | 
|  | 262 | void connect_to_remote(asocket *s, const char *destination); | 
|  | 263 | void connect_to_smartsocket(asocket *s); | 
|  | 264 |  | 
|  | 265 | void fatal(const char *fmt, ...); | 
|  | 266 | void fatal_errno(const char *fmt, ...); | 
|  | 267 |  | 
|  | 268 | void handle_packet(apacket *p, atransport *t); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 269 |  | 
| Alexey Tarasov | 3166410 | 2009-10-22 02:55:00 +1100 | [diff] [blame] | 270 | void get_my_path(char *s, size_t maxLen); | 
| Stefan Hilzinger | a84a42e | 2010-04-19 12:21:12 +0100 | [diff] [blame] | 271 | int launch_server(int server_port); | 
|  | 272 | int adb_main(int is_daemon, int server_port); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 273 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 274 | /* initialize a transport object's func pointers and state */ | 
| Stefan Hilzinger | d9d1ca4 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 275 | #if ADB_HOST | 
|  | 276 | int get_available_local_transport_index(); | 
|  | 277 | #endif | 
| Mike Lockwood | 2f38b69 | 2009-08-24 15:58:40 -0700 | [diff] [blame] | 278 | int  init_socket_transport(atransport *t, int s, int port, int local); | 
| Mike Lockwood | 95b837d | 2009-08-08 12:37:44 -0400 | [diff] [blame] | 279 | void init_usb_transport(atransport *t, usb_handle *usb, int state); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 280 |  | 
| Stefan Hilzinger | d9d1ca4 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 281 | #if ADB_HOST | 
|  | 282 | atransport* find_emulator_transport_by_adb_port(int adb_port); | 
|  | 283 | #endif | 
| Mike Lockwood | 74d7ff8 | 2009-10-11 23:04:18 -0400 | [diff] [blame] | 284 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 285 | int service_to_fd(const char *name); | 
|  | 286 | #if ADB_HOST | 
|  | 287 | asocket *host_service_to_socket(const char*  name, const char *serial); | 
|  | 288 | #endif | 
|  | 289 |  | 
|  | 290 | #if !ADB_HOST | 
|  | 291 | int       init_jdwp(void); | 
|  | 292 | asocket*  create_jdwp_service_socket(); | 
|  | 293 | asocket*  create_jdwp_tracker_service_socket(); | 
|  | 294 | int       create_jdwp_connection_fd(int  jdwp_pid); | 
|  | 295 | #endif | 
|  | 296 |  | 
| David 'Digit' Turner | 2525869 | 2013-03-21 21:07:42 +0100 | [diff] [blame] | 297 | int handle_forward_request(const char* service, transport_type ttype, char* serial, int reply_fd); | 
|  | 298 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 299 | #if !ADB_HOST | 
|  | 300 | void framebuffer_service(int fd, void *cookie); | 
| Paul Lawrence | 982089d | 2014-12-03 15:31:57 -0800 | [diff] [blame] | 301 | // Allow enable-verity to write to system and vendor block devices | 
| Sami Tolvanen | 13449cd | 2015-01-02 13:30:50 +0000 | [diff] [blame] | 302 | int make_block_device_writable(const char* dev); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 303 | void remount_service(int fd, void *cookie); | 
| Paul Lawrence | 982089d | 2014-12-03 15:31:57 -0800 | [diff] [blame] | 304 | void set_verity_enabled_state_service(int fd, void* cookie); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 305 | #endif | 
|  | 306 |  | 
|  | 307 | /* packet allocator */ | 
|  | 308 | apacket *get_apacket(void); | 
|  | 309 | void put_apacket(apacket *p); | 
|  | 310 |  | 
| leozwang | cbf0267 | 2014-08-15 09:51:27 -0700 | [diff] [blame] | 311 | // Define it if you want to dump packets. | 
|  | 312 | #define DEBUG_PACKETS 0 | 
|  | 313 |  | 
| Benoit Goby | d5fcafa | 2012-04-12 12:23:49 -0700 | [diff] [blame] | 314 | #if !DEBUG_PACKETS | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 315 | #define print_packet(tag,p) do {} while (0) | 
|  | 316 | #endif | 
|  | 317 |  | 
| John Michelau | c318833 | 2010-09-23 17:08:34 -0500 | [diff] [blame] | 318 | #if ADB_HOST_ON_TARGET | 
|  | 319 | /* adb and adbd are coexisting on the target, so use 5038 for adb | 
|  | 320 | * to avoid conflicting with adbd's usage of 5037 | 
|  | 321 | */ | 
|  | 322 | #  define DEFAULT_ADB_PORT 5038 | 
|  | 323 | #else | 
|  | 324 | #  define DEFAULT_ADB_PORT 5037 | 
|  | 325 | #endif | 
|  | 326 |  | 
| Stefan Hilzinger | a84a42e | 2010-04-19 12:21:12 +0100 | [diff] [blame] | 327 | #define DEFAULT_ADB_LOCAL_TRANSPORT_PORT 5555 | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 328 |  | 
| Xavier Ducrohet | a481d09 | 2009-05-21 17:47:43 -0700 | [diff] [blame] | 329 | #define ADB_CLASS              0xff | 
|  | 330 | #define ADB_SUBCLASS           0x42 | 
|  | 331 | #define ADB_PROTOCOL           0x1 | 
| Dima Zavin | 3fd82b8 | 2009-05-08 18:25:58 -0700 | [diff] [blame] | 332 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 333 |  | 
| Mike Lockwood | cef31a0 | 2009-08-26 12:50:22 -0700 | [diff] [blame] | 334 | void local_init(int port); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 335 | int  local_connect(int  port); | 
| Stefan Hilzinger | d9d1ca4 | 2010-04-26 10:17:43 +0100 | [diff] [blame] | 336 | int  local_connect_arbitrary_ports(int console_port, int adb_port); | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 337 |  | 
|  | 338 | /* usb host/client interface */ | 
|  | 339 | void usb_init(); | 
|  | 340 | void usb_cleanup(); | 
|  | 341 | int usb_write(usb_handle *h, const void *data, int len); | 
|  | 342 | int usb_read(usb_handle *h, void *data, int len); | 
|  | 343 | int usb_close(usb_handle *h); | 
|  | 344 | void usb_kick(usb_handle *h); | 
|  | 345 |  | 
|  | 346 | /* used for USB device detection */ | 
| Xavier Ducrohet | a09fbd1 | 2009-05-20 17:33:53 -0700 | [diff] [blame] | 347 | #if ADB_HOST | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 348 | int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol); | 
| Xavier Ducrohet | a09fbd1 | 2009-05-20 17:33:53 -0700 | [diff] [blame] | 349 | #endif | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 350 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 351 | int adb_commandline(int argc, char **argv); | 
|  | 352 |  | 
|  | 353 | int connection_state(atransport *t); | 
|  | 354 |  | 
|  | 355 | #define CS_ANY       -1 | 
|  | 356 | #define CS_OFFLINE    0 | 
|  | 357 | #define CS_BOOTLOADER 1 | 
|  | 358 | #define CS_DEVICE     2 | 
|  | 359 | #define CS_HOST       3 | 
|  | 360 | #define CS_RECOVERY   4 | 
| Mike Lockwood | 95b837d | 2009-08-08 12:37:44 -0400 | [diff] [blame] | 361 | #define CS_NOPERM     5 /* Insufficient permissions to communicate with the device */ | 
| Doug Zongker | 447f061 | 2012-01-09 14:54:53 -0800 | [diff] [blame] | 362 | #define CS_SIDELOAD   6 | 
| Benoit Goby | 77e8e58 | 2013-01-15 12:36:47 -0800 | [diff] [blame] | 363 | #define CS_UNAUTHORIZED 7 | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 364 |  | 
| Dan Albert | bd0b750 | 2015-02-18 18:22:45 -0800 | [diff] [blame] | 365 | extern const char *adb_device_banner; | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 366 | extern int HOST; | 
| JP Abgrall | 408fa57 | 2011-03-16 15:57:42 -0700 | [diff] [blame] | 367 | extern int SHELL_EXIT_NOTIFY_FD; | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 368 |  | 
| Jeff Sharkey | 5d9d434 | 2014-05-26 18:30:43 -0700 | [diff] [blame] | 369 | typedef enum { | 
|  | 370 | SUBPROC_PTY = 0, | 
|  | 371 | SUBPROC_RAW = 1, | 
|  | 372 | } subproc_mode; | 
|  | 373 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 374 | #define CHUNK_SIZE (64*1024) | 
|  | 375 |  | 
| Andrzej Pietrasiewicz | fd96db1 | 2012-01-13 15:13:46 +0100 | [diff] [blame] | 376 | #if !ADB_HOST | 
|  | 377 | #define USB_ADB_PATH     "/dev/android_adb" | 
|  | 378 |  | 
|  | 379 | #define USB_FFS_ADB_PATH  "/dev/usb-ffs/adb/" | 
|  | 380 | #define USB_FFS_ADB_EP(x) USB_FFS_ADB_PATH#x | 
|  | 381 |  | 
|  | 382 | #define USB_FFS_ADB_EP0   USB_FFS_ADB_EP(ep0) | 
|  | 383 | #define USB_FFS_ADB_OUT   USB_FFS_ADB_EP(ep1) | 
|  | 384 | #define USB_FFS_ADB_IN    USB_FFS_ADB_EP(ep2) | 
|  | 385 | #endif | 
|  | 386 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 387 | int sendfailmsg(int fd, const char *reason); | 
|  | 388 | int handle_host_request(char *service, transport_type ttype, char* serial, int reply_fd, asocket *s); | 
|  | 389 |  | 
| Dan Albert | ba3a251 | 2015-02-18 17:47:33 -0800 | [diff] [blame] | 390 | void handle_online(atransport *t); | 
|  | 391 | void handle_offline(atransport *t); | 
|  | 392 |  | 
|  | 393 | void send_connect(atransport *t); | 
|  | 394 |  | 
| Dan Albert | 818fb4b | 2015-02-18 00:18:25 -0800 | [diff] [blame] | 395 | #ifdef __cplusplus | 
|  | 396 | } | 
|  | 397 | #endif | 
|  | 398 |  | 
| The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 399 | #endif |