Merge "adb: fix forward --list, --remove(-all) with multiple devices."

am: 32acd3171a

Change-Id: If122eee9334922f39a29ed0f2d543dec78e0661d
This commit is contained in:
Josh Gao 2018-07-23 18:08:00 -07:00 committed by android-build-merger
commit 8aef0f7a5b
1 changed files with 21 additions and 20 deletions

View File

@ -924,25 +924,6 @@ int launch_server(const std::string& socket_spec) {
// This returns 1 on success, 0 on failure, and -1 to indicate this is not
// a forwarding-related request.
int handle_forward_request(const char* service, atransport* transport, int reply_fd) {
if (!strcmp(service, "list-forward")) {
// Create the list of forward redirections.
std::string listeners = format_listeners();
#if ADB_HOST
SendOkay(reply_fd);
#endif
return SendProtocolString(reply_fd, listeners);
}
if (!strcmp(service, "killforward-all")) {
remove_all_listeners();
#if ADB_HOST
/* On the host: 1st OKAY is connect, 2nd OKAY is status */
SendOkay(reply_fd);
#endif
SendOkay(reply_fd);
return 1;
}
if (!strncmp(service, "forward:", 8) || !strncmp(service, "killforward:", 12)) {
// killforward:local
// forward:(norebind:)?local;remote
@ -1205,10 +1186,30 @@ int handle_host_request(const char* service, TransportType type, const char* ser
return SendOkay(reply_fd, response);
}
if (!strcmp(service, "list-forward")) {
// Create the list of forward redirections.
std::string listeners = format_listeners();
#if ADB_HOST
SendOkay(reply_fd);
#endif
return SendProtocolString(reply_fd, listeners);
}
if (!strcmp(service, "killforward-all")) {
remove_all_listeners();
#if ADB_HOST
/* On the host: 1st OKAY is connect, 2nd OKAY is status */
SendOkay(reply_fd);
#endif
SendOkay(reply_fd);
return 1;
}
std::string error;
atransport* t = acquire_one_transport(type, serial, transport_id, nullptr, &error);
if (!t) {
return -1;
SendFail(reply_fd, error);
return 1;
}
int ret = handle_forward_request(service, t, reply_fd);