Make adb's daemon-port on the host machine configurable.
This is the first CL of a somewhat larger effort which, among other things,
will involve changing the emulator and ddms to talk to adb running on a
configurable port.
The port can be configured using environment variable ANDROID_ADB_SERVER_PORT.
Further CLs will also address the set of ports used for the local transport.
Change-Id: Ib2f431801f0adcd9f2dd290a28005644a36a780a
diff --git a/adb/adb_client.c b/adb/adb_client.c
index 243f0fa..882810a 100644
--- a/adb/adb_client.c
+++ b/adb/adb_client.c
@@ -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;
@@ -174,7 +181,7 @@
}
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;
@@ -204,9 +211,10 @@
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 {
@@ -314,5 +322,3 @@
adb_close(fd);
return 0;
}
-
-