diff options
Diffstat (limited to 'adb/commandline.c')
-rw-r--r-- | adb/commandline.c | 110 |
1 files changed, 85 insertions, 25 deletions
diff --git a/adb/commandline.c b/adb/commandline.c index 61167b2..2e4cd37 100644 --- a/adb/commandline.c +++ b/adb/commandline.c @@ -107,8 +107,12 @@ void help() " will disconnect from all connected TCP/IP devices.\n" "\n" "device commands:\n" - " adb push <local> <remote> - copy file/dir to device\n" - " adb pull <remote> [<local>] - copy file/dir from device\n" + " adb push [-p] <local> <remote>\n" + " - copy file/dir to device\n" + " ('-p' to display the transfer progress)\n" + " adb pull [-p] <remote> [<local>]\n" + " - copy file/dir from device\n" + " ('-p' to display the transfer progress)\n" " adb sync [ <directory> ] - copy host->device only if changed\n" " (-l means list but don't copy)\n" " (see 'adb help all')\n" @@ -132,6 +136,19 @@ void help() " if <local> is already forwarded\n" " adb forward --remove <local> - remove a specific forward socket connection\n" " adb forward --remove-all - remove all forward socket connections\n" + " adb reverse --list - list all reverse socket connections from device\n" + " adb reverse <remote> <local> - reverse socket connections\n" + " reverse specs are one of:\n" + " tcp:<port>\n" + " localabstract:<unix domain socket name>\n" + " localreserved:<unix domain socket name>\n" + " localfilesystem:<unix domain socket name>\n" + " adb reverse --norebind <remote> <local>\n" + " - same as 'adb reverse <remote> <local>' but fails\n" + " if <remote> is already reversed.\n" + " adb reverse --remove <remote>\n" + " - remove a specific reversed socket connection\n" + " adb reverse --remove-all - remove all reversed socket connections from device\n" " adb jdwp - list PIDs of processes hosting a JDWP transport\n" " adb install [-l] [-r] [-d] [-s] [--algo <algorithm name> --key <hex-encoded key> --iv <hex-encoded iv>] <file>\n" " - push this package file to the device and install it\n" @@ -403,7 +420,7 @@ int adb_download_buffer(const char *service, const char *fn, const void* data, i } int opt = CHUNK_SIZE; - opt = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)); + opt = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (const void *) &opt, sizeof(opt)); total = sz; ptr = data; @@ -678,10 +695,10 @@ static int logcat(transport_type transport, char* serial, int argc, char **argv) return 0; } -static int mkdirs(char *path) +static int mkdirs(const char *path) { int ret; - char *x = path + 1; + char *x = (char *)path + 1; for(;;) { x = adb_dirstart(x); @@ -724,7 +741,7 @@ static int backup(int argc, char** argv) { if (argc < 2) return usage(); adb_unlink(filename); - mkdirs((char *)filename); + mkdirs(filename); outFd = adb_creat(filename, 0640); if (outFd < 0) { fprintf(stderr, "adb: unable to open file %s\n", filename); @@ -922,6 +939,28 @@ static const char *find_product_out_path(const char *hint) return path_buf; } + +static void parse_push_pull_args(char** arg, int narg, char const** path1, char const** path2, + int* show_progress) { + *show_progress = 0; + + if ((narg > 0) && !strcmp(*arg, "-p")) { + *show_progress = 1; + ++arg; + --narg; + } + + if (narg > 0) { + *path1 = *arg; + ++arg; + --narg; + } + + if (narg > 0) { + *path2 = *arg; + } +} + int adb_commandline(int argc, char **argv) { char buf[4096]; @@ -1274,8 +1313,11 @@ top: return 0; } - if(!strcmp(argv[0], "forward")) { + if(!strcmp(argv[0], "forward") || + !strcmp(argv[0], "reverse")) + { char host_prefix[64]; + char reverse = (char) !strcmp(argv[0], "reverse"); char remove = 0; char remove_all = 0; char list = 0; @@ -1304,15 +1346,19 @@ top: } // Determine the <host-prefix> for this command. - if (serial) { - snprintf(host_prefix, sizeof host_prefix, "host-serial:%s", - serial); - } else if (ttype == kTransportUsb) { - snprintf(host_prefix, sizeof host_prefix, "host-usb"); - } else if (ttype == kTransportLocal) { - snprintf(host_prefix, sizeof host_prefix, "host-local"); + if (reverse) { + snprintf(host_prefix, sizeof host_prefix, "reverse"); } else { - snprintf(host_prefix, sizeof host_prefix, "host"); + if (serial) { + snprintf(host_prefix, sizeof host_prefix, "host-serial:%s", + serial); + } else if (ttype == kTransportUsb) { + snprintf(host_prefix, sizeof host_prefix, "host-usb"); + } else if (ttype == kTransportLocal) { + snprintf(host_prefix, sizeof host_prefix, "host-local"); + } else { + snprintf(host_prefix, sizeof host_prefix, "host"); + } } // Implement forward --list @@ -1369,18 +1415,29 @@ top: } if(!strcmp(argv[0], "push")) { - if(argc != 3) return usage(); - return do_sync_push(argv[1], argv[2], 0 /* no verify APK */); + int show_progress = 0; + const char* lpath = NULL, *rpath = NULL; + + parse_push_pull_args(&argv[1], argc - 1, &lpath, &rpath, &show_progress); + + if ((lpath != NULL) && (rpath != NULL)) { + return do_sync_push(lpath, rpath, 0 /* no verify APK */, show_progress); + } + + return usage(); } if(!strcmp(argv[0], "pull")) { - if (argc == 2) { - return do_sync_pull(argv[1], "."); - } else if (argc == 3) { - return do_sync_pull(argv[1], argv[2]); - } else { - return usage(); + int show_progress = 0; + const char* rpath = NULL, *lpath = "."; + + parse_push_pull_args(&argv[1], argc - 1, &rpath, &lpath, &show_progress); + + if (rpath != NULL) { + return do_sync_pull(rpath, lpath, show_progress); } + + return usage(); } if(!strcmp(argv[0], "install")) { @@ -1687,6 +1744,8 @@ int install_app(transport_type transport, char* serial, int argc, char** argv) } else if (!strcmp(argv[i], "--key")) { verify_apk = 0; i++; + } else if (!strcmp(argv[i], "--abi")) { + i++; } } @@ -1718,7 +1777,7 @@ int install_app(transport_type transport, char* serial, int argc, char** argv) } } - err = do_sync_push(apk_file, apk_dest, verify_apk); + err = do_sync_push(apk_file, apk_dest, verify_apk, 0 /* no show progress */); if (err) { goto cleanup_apk; } else { @@ -1726,7 +1785,8 @@ int install_app(transport_type transport, char* serial, int argc, char** argv) } if (verification_file != NULL) { - err = do_sync_push(verification_file, verification_dest, 0 /* no verify APK */); + err = do_sync_push(verification_file, verification_dest, 0 /* no verify APK */, + 0 /* no show progress */); if (err) { goto cleanup_apk; } else { |