Loading adb/OVERVIEW.TXT +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ As a whole, everything works through the following components: (through USB for devices, through TCP for emulators) and provide a few services for clients that run on the host. The ADB server considers that a device is ONLINE when it has succesfully The ADB server considers that a device is ONLINE when it has successfully connected to the adbd program within it. Otherwise, the device is OFFLINE, meaning that the ADB server detected a new device/emulator, but could not connect to the adbd daemon. Loading adb/SERVICES.TXT +6 −6 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ host-usb:<request> host-local:<request> A variant of host-serial used to target the single emulator instance running on the host. This will fail if therre is none or more than one. running on the host. This will fail if there is none or more than one. host:<request> When asking for information related to a device, 'host:' can also be Loading Loading @@ -146,7 +146,7 @@ remount: dev:<path> Opens a device file and connects the client directly to it for read/write purposes. Useful for debugging, but may require special priviledges and thus may not run on all devices. <path> is a full privileges and thus may not run on all devices. <path> is a full path from the root of the filesystem. tcp:<port> Loading @@ -173,7 +173,7 @@ log:<name> framebuffer: This service is used to send snapshots of the framebuffer to a client. It requires sufficient priviledges but works as follow: It requires sufficient privileges but works as follow: After the OKAY, the service sends 16-byte binary structure containing the following fields (little-endian format): Loading @@ -190,14 +190,14 @@ framebuffer: one byte through the channel, which will trigger the service to send it 'size' bytes of framebuffer data. If the adbd daemon doesn't have sufficient priviledges to open If the adbd daemon doesn't have sufficient privileges to open the framebuffer device, the connection is simply closed immediately. dns:<server-name> This service is an exception because it only runs within the ADB server. It is used to implement USB networking, i.e. to provide a network connection to the device through the host machine (note: this is the exact opposite of network thetering). network tethering). It is used to perform a gethostbyname(<address>) on the host and return the corresponding IP address as a 4-byte string. Loading @@ -209,7 +209,7 @@ recover:<size> - creating a file named /tmp/update - reading 'size' bytes from the client and writing them to /tmp/update - when everything is read succesfully, create a file named /tmp/update.start - when everything is read successfully, create a file named /tmp/update.start This service can only work when the device is in recovery mode. Otherwise, the /tmp directory doesn't exist and the connection will be closed immediately. Loading adb/adb.c +23 −15 Original line number Diff line number Diff line Loading @@ -144,9 +144,6 @@ void put_apacket(apacket *p) void handle_online(void) { D("adb: online\n"); #if !ADB_HOST property_set("adb.connected","1"); #endif } void handle_offline(atransport *t) Loading @@ -154,9 +151,6 @@ void handle_offline(atransport *t) D("adb: offline\n"); //Close the associated usb run_transport_disconnects(t); #if !ADB_HOST property_set("adb.connected",""); #endif } #if TRACE_PACKETS Loading Loading @@ -693,7 +687,7 @@ void start_device_log(void) #endif #if ADB_HOST int launch_server() int launch_server(int server_port) { #ifdef HAVE_WIN32_PROC /* we need to start the server in the background */ Loading Loading @@ -828,7 +822,17 @@ int launch_server() } #endif int adb_main(int is_daemon) /* Constructs a local name of form tcp:port. * target_str points to the target string, it's content will be overwritten. * target_size is the capacity of the target string. * server_port is the port number to use for the local name. */ void build_local_name(char* target_str, size_t target_size, int server_port) { snprintf(target_str, target_size, "tcp:%d", server_port); } int adb_main(int is_daemon, int server_port) { #if !ADB_HOST int secure = 0; Loading @@ -851,9 +855,11 @@ int adb_main(int is_daemon) HOST = 1; usb_vendors_init(); usb_init(); local_init(ADB_LOCAL_TRANSPORT_PORT); local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); if(install_listener("tcp:5037", "*smartsocket*", NULL)) { char local_name[30]; build_local_name(local_name, sizeof(local_name), server_port); if(install_listener(local_name, "*smartsocket*", NULL)) { exit(1); } #else Loading @@ -879,7 +885,7 @@ int adb_main(int is_daemon) } } /* don't listen on port 5037 if we are running in secure mode */ /* don't listen on a port (default 5037) if running in secure mode */ /* don't run as root if we are running in secure mode */ if (secure) { struct __user_cap_header_struct header; Loading Loading @@ -912,9 +918,11 @@ int adb_main(int is_daemon) cap.inheritable = 0; capset(&header, &cap); D("Local port 5037 disabled\n"); D("Local port disabled\n"); } else { if(install_listener("tcp:5037", "*smartsocket*", NULL)) { char local_name[30]; build_local_name(local_name, sizeof(local_name), server_port); if(install_listener(local_name, "*smartsocket*", NULL)) { exit(1); } } Loading @@ -935,7 +943,7 @@ int adb_main(int is_daemon) usb_init(); } else { // listen on default port local_init(ADB_LOCAL_TRANSPORT_PORT); local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); } init_jdwp(); #endif Loading Loading @@ -1176,6 +1184,6 @@ int main(int argc, char **argv) } start_device_log(); return adb_main(0); return adb_main(0, DEFAULT_ADB_PORT); #endif } adb/adb.h +4 −4 Original line number Diff line number Diff line Loading @@ -237,8 +237,8 @@ void handle_packet(apacket *p, atransport *t); void send_packet(apacket *p, atransport *t); void get_my_path(char *s, size_t maxLen); int launch_server(); int adb_main(int is_daemon); int launch_server(int server_port); int adb_main(int is_daemon, int server_port); /* transports are ref-counted Loading Loading @@ -358,8 +358,8 @@ typedef enum { #define print_packet(tag,p) do {} while (0) #endif #define ADB_PORT 5037 #define ADB_LOCAL_TRANSPORT_PORT 5555 #define DEFAULT_ADB_PORT 5037 #define DEFAULT_ADB_LOCAL_TRANSPORT_PORT 5555 #define ADB_CLASS 0xff #define ADB_SUBCLASS 0x42 Loading adb/adb_client.c +11 −5 Original line number Diff line number Diff line Loading @@ -16,12 +16,19 @@ static transport_type __adb_transport = kTransportAny; static const char* __adb_serial = NULL; static int __adb_server_port = DEFAULT_ADB_PORT; void adb_set_transport(transport_type type, const char* serial) { __adb_transport = type; __adb_serial = serial; } void adb_set_tcp_specifics(int server_port) { __adb_server_port = server_port; } int adb_get_emulator_console_port(void) { const char* serial = __adb_serial; Loading Loading @@ -174,7 +181,7 @@ int _adb_connect(const char *service) } snprintf(tmp, sizeof tmp, "%04x", len); fd = socket_loopback_client(ADB_PORT, SOCK_STREAM); fd = socket_loopback_client(__adb_server_port, SOCK_STREAM); if(fd < 0) { strcpy(__adb_error, "cannot connect to daemon"); return -2; Loading Loading @@ -204,9 +211,10 @@ int adb_connect(const char *service) int fd = _adb_connect("host:version"); if(fd == -2) { fprintf(stdout,"* daemon not running. starting it now *\n"); fprintf(stdout,"* daemon not running. starting it now on port %d *\n", __adb_server_port); start_server: if(launch_server(0)) { if(launch_server(__adb_server_port)) { fprintf(stderr,"* failed to start daemon *\n"); return -1; } else { Loading Loading @@ -314,5 +322,3 @@ oops: adb_close(fd); return 0; } Loading
adb/OVERVIEW.TXT +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ As a whole, everything works through the following components: (through USB for devices, through TCP for emulators) and provide a few services for clients that run on the host. The ADB server considers that a device is ONLINE when it has succesfully The ADB server considers that a device is ONLINE when it has successfully connected to the adbd program within it. Otherwise, the device is OFFLINE, meaning that the ADB server detected a new device/emulator, but could not connect to the adbd daemon. Loading
adb/SERVICES.TXT +6 −6 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ host-usb:<request> host-local:<request> A variant of host-serial used to target the single emulator instance running on the host. This will fail if therre is none or more than one. running on the host. This will fail if there is none or more than one. host:<request> When asking for information related to a device, 'host:' can also be Loading Loading @@ -146,7 +146,7 @@ remount: dev:<path> Opens a device file and connects the client directly to it for read/write purposes. Useful for debugging, but may require special priviledges and thus may not run on all devices. <path> is a full privileges and thus may not run on all devices. <path> is a full path from the root of the filesystem. tcp:<port> Loading @@ -173,7 +173,7 @@ log:<name> framebuffer: This service is used to send snapshots of the framebuffer to a client. It requires sufficient priviledges but works as follow: It requires sufficient privileges but works as follow: After the OKAY, the service sends 16-byte binary structure containing the following fields (little-endian format): Loading @@ -190,14 +190,14 @@ framebuffer: one byte through the channel, which will trigger the service to send it 'size' bytes of framebuffer data. If the adbd daemon doesn't have sufficient priviledges to open If the adbd daemon doesn't have sufficient privileges to open the framebuffer device, the connection is simply closed immediately. dns:<server-name> This service is an exception because it only runs within the ADB server. It is used to implement USB networking, i.e. to provide a network connection to the device through the host machine (note: this is the exact opposite of network thetering). network tethering). It is used to perform a gethostbyname(<address>) on the host and return the corresponding IP address as a 4-byte string. Loading @@ -209,7 +209,7 @@ recover:<size> - creating a file named /tmp/update - reading 'size' bytes from the client and writing them to /tmp/update - when everything is read succesfully, create a file named /tmp/update.start - when everything is read successfully, create a file named /tmp/update.start This service can only work when the device is in recovery mode. Otherwise, the /tmp directory doesn't exist and the connection will be closed immediately. Loading
adb/adb.c +23 −15 Original line number Diff line number Diff line Loading @@ -144,9 +144,6 @@ void put_apacket(apacket *p) void handle_online(void) { D("adb: online\n"); #if !ADB_HOST property_set("adb.connected","1"); #endif } void handle_offline(atransport *t) Loading @@ -154,9 +151,6 @@ void handle_offline(atransport *t) D("adb: offline\n"); //Close the associated usb run_transport_disconnects(t); #if !ADB_HOST property_set("adb.connected",""); #endif } #if TRACE_PACKETS Loading Loading @@ -693,7 +687,7 @@ void start_device_log(void) #endif #if ADB_HOST int launch_server() int launch_server(int server_port) { #ifdef HAVE_WIN32_PROC /* we need to start the server in the background */ Loading Loading @@ -828,7 +822,17 @@ int launch_server() } #endif int adb_main(int is_daemon) /* Constructs a local name of form tcp:port. * target_str points to the target string, it's content will be overwritten. * target_size is the capacity of the target string. * server_port is the port number to use for the local name. */ void build_local_name(char* target_str, size_t target_size, int server_port) { snprintf(target_str, target_size, "tcp:%d", server_port); } int adb_main(int is_daemon, int server_port) { #if !ADB_HOST int secure = 0; Loading @@ -851,9 +855,11 @@ int adb_main(int is_daemon) HOST = 1; usb_vendors_init(); usb_init(); local_init(ADB_LOCAL_TRANSPORT_PORT); local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); if(install_listener("tcp:5037", "*smartsocket*", NULL)) { char local_name[30]; build_local_name(local_name, sizeof(local_name), server_port); if(install_listener(local_name, "*smartsocket*", NULL)) { exit(1); } #else Loading @@ -879,7 +885,7 @@ int adb_main(int is_daemon) } } /* don't listen on port 5037 if we are running in secure mode */ /* don't listen on a port (default 5037) if running in secure mode */ /* don't run as root if we are running in secure mode */ if (secure) { struct __user_cap_header_struct header; Loading Loading @@ -912,9 +918,11 @@ int adb_main(int is_daemon) cap.inheritable = 0; capset(&header, &cap); D("Local port 5037 disabled\n"); D("Local port disabled\n"); } else { if(install_listener("tcp:5037", "*smartsocket*", NULL)) { char local_name[30]; build_local_name(local_name, sizeof(local_name), server_port); if(install_listener(local_name, "*smartsocket*", NULL)) { exit(1); } } Loading @@ -935,7 +943,7 @@ int adb_main(int is_daemon) usb_init(); } else { // listen on default port local_init(ADB_LOCAL_TRANSPORT_PORT); local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); } init_jdwp(); #endif Loading Loading @@ -1176,6 +1184,6 @@ int main(int argc, char **argv) } start_device_log(); return adb_main(0); return adb_main(0, DEFAULT_ADB_PORT); #endif }
adb/adb.h +4 −4 Original line number Diff line number Diff line Loading @@ -237,8 +237,8 @@ void handle_packet(apacket *p, atransport *t); void send_packet(apacket *p, atransport *t); void get_my_path(char *s, size_t maxLen); int launch_server(); int adb_main(int is_daemon); int launch_server(int server_port); int adb_main(int is_daemon, int server_port); /* transports are ref-counted Loading Loading @@ -358,8 +358,8 @@ typedef enum { #define print_packet(tag,p) do {} while (0) #endif #define ADB_PORT 5037 #define ADB_LOCAL_TRANSPORT_PORT 5555 #define DEFAULT_ADB_PORT 5037 #define DEFAULT_ADB_LOCAL_TRANSPORT_PORT 5555 #define ADB_CLASS 0xff #define ADB_SUBCLASS 0x42 Loading
adb/adb_client.c +11 −5 Original line number Diff line number Diff line Loading @@ -16,12 +16,19 @@ static transport_type __adb_transport = kTransportAny; static const char* __adb_serial = NULL; static int __adb_server_port = DEFAULT_ADB_PORT; void adb_set_transport(transport_type type, const char* serial) { __adb_transport = type; __adb_serial = serial; } void adb_set_tcp_specifics(int server_port) { __adb_server_port = server_port; } int adb_get_emulator_console_port(void) { const char* serial = __adb_serial; Loading Loading @@ -174,7 +181,7 @@ int _adb_connect(const char *service) } snprintf(tmp, sizeof tmp, "%04x", len); fd = socket_loopback_client(ADB_PORT, SOCK_STREAM); fd = socket_loopback_client(__adb_server_port, SOCK_STREAM); if(fd < 0) { strcpy(__adb_error, "cannot connect to daemon"); return -2; Loading Loading @@ -204,9 +211,10 @@ int adb_connect(const char *service) int fd = _adb_connect("host:version"); if(fd == -2) { fprintf(stdout,"* daemon not running. starting it now *\n"); fprintf(stdout,"* daemon not running. starting it now on port %d *\n", __adb_server_port); start_server: if(launch_server(0)) { if(launch_server(__adb_server_port)) { fprintf(stderr,"* failed to start daemon *\n"); return -1; } else { Loading Loading @@ -314,5 +322,3 @@ oops: adb_close(fd); return 0; }