aboutsummaryrefslogtreecommitdiffstats
path: root/adb/commandline.c
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-05-24 10:44:35 -0400
committerMike Lockwood <lockwood@android.com>2010-06-02 11:31:26 -0400
commitcbbe79add1410b53ec65936cfb1b74cac68467f0 (patch)
tree4b7c7dc05cbd7026be3a4414eedf0ae6e7924ca4 /adb/commandline.c
parent67d5358e2a870f9e9447517bfa49bf5c6b410a50 (diff)
downloadsystem_core-cbbe79add1410b53ec65936cfb1b74cac68467f0.tar.gz
system_core-cbbe79add1410b53ec65936cfb1b74cac68467f0.tar.bz2
system_core-cbbe79add1410b53ec65936cfb1b74cac68467f0.zip
adb connect and disconnect improvements:
Port number is now optional. Will use default port 5555 if not specified. "adb disconnect" with no additional arguments will disconnect all TCP devices. Change-Id: I7fc26528ed85e66a73b8f6254cea7bf83d98109f Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'adb/commandline.c')
-rw-r--r--adb/commandline.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/adb/commandline.c b/adb/commandline.c
index d1eba5ad..02e4658d 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -100,8 +100,12 @@ void help()
" environment variable is used, which must\n"
" be an absolute path.\n"
" devices - list all connected devices\n"
- " connect <host>:<port> - connect to a device via TCP/IP\n"
- " disconnect <host>:<port> - disconnect from a TCP/IP device\n"
+ " connect <host>[:<port>] - connect to a device via TCP/IP\n"
+ " Port 5555 is used by default if no port number is specified.\n"
+ " disconnect [<host>[:<port>]] - disconnect from a TCP/IP device.\n"
+ " Port 5555 is used by default if no port number is specified.\n"
+ " Using this ocmmand with no additional arguments\n"
+ " will disconnect from all connected TCP/IP devices.\n"
"\n"
"device commands:\n"
" adb push <local> <remote> - copy file/dir to device\n"
@@ -793,13 +797,33 @@ top:
}
}
- if(!strcmp(argv[0], "connect") || !strcmp(argv[0], "disconnect")) {
+ if(!strcmp(argv[0], "connect")) {
char *tmp;
if (argc != 2) {
- fprintf(stderr, "Usage: adb %s <host>:<port>\n", argv[0]);
+ fprintf(stderr, "Usage: adb connect <host>[:<port>]\n");
return 1;
}
- snprintf(buf, sizeof buf, "host:%s:%s", argv[0], argv[1]);
+ snprintf(buf, sizeof buf, "host:connect:%s", argv[1]);
+ tmp = adb_query(buf);
+ if(tmp) {
+ printf("%s\n", tmp);
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+
+ if(!strcmp(argv[0], "disconnect")) {
+ char *tmp;
+ if (argc > 2) {
+ fprintf(stderr, "Usage: adb disconnect [<host>[:<port>]]\n");
+ return 1;
+ }
+ if (argc == 2) {
+ snprintf(buf, sizeof buf, "host:disconnect:%s", argv[1]);
+ } else {
+ snprintf(buf, sizeof buf, "host:disconnect:");
+ }
tmp = adb_query(buf);
if(tmp) {
printf("%s\n", tmp);