From 6a9dc4e60509ceeef64509dff40296ca5c9c99a3 Mon Sep 17 00:00:00 2001 From: David Pursell Date: Thu, 7 Apr 2016 11:25:48 -0700 Subject: adb: support forwarding TCP port 0. This CL adds support to forward or reverse TCP port 0 to allow the system to automatically select an open port. The resolved port number will be printed to stdout: $ adb forward tcp:0 tcp:8000 12345 $ adb reverse tcp:0 tcp:9000 23456 This allows testing to be more robust by not hardcoding TCP ports which may already be in use. Forwarding port 0 is a host-only change and will work with any device, but reversing port 0 requires the device to be updated with a new adbd binary. This CL also does a little bit of cleanup such as moving the alistener class out of adb.h, and adds some error checking and additional tests. Bug: 28051746 Test: python -m unittest discover Test: adb_test Test: `adb forward` and `adb reverse` with tcp:0 Change-Id: Icaa87346685b403ab5da7f0e6aa186aa091da572 --- client/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client/main.cpp') diff --git a/client/main.cpp b/client/main.cpp index 27b7109..65640ad 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -117,7 +117,7 @@ int adb_server_main(int is_daemon, int server_port, int ack_reply_fd) { std::string error; std::string local_name = android::base::StringPrintf("tcp:%d", server_port); - if (install_listener(local_name, "*smartsocket*", nullptr, 0, &error)) { + if (install_listener(local_name, "*smartsocket*", nullptr, 0, nullptr, &error)) { fatal("could not install *smartsocket* listener: %s", error.c_str()); } -- cgit v1.2.3