From 880be434a9ec197100fe5c6f0b299353d13b916b Mon Sep 17 00:00:00 2001 From: David Pursell Date: Fri, 4 Sep 2015 16:40:30 -0700 Subject: [PATCH] adb: `features` passes transport features. `adb features` previously returned a list of host features which was not terribly useful. This CL changes functionality to return the transport features instead using the standard targeting args: $ adb features # default target. $ adb -e features $ adb -s 123456 features Also adds a "check-feature" service which is currently unused but will allow the adb client to easily check for a specific feature. Bug: http://b/23824036 Change-Id: Ibc0c420c75f73d363f3bba7705af616ba2059348 --- adb/adb.cpp | 24 +++++++++++++++++++++--- adb/commandline.cpp | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/adb/adb.cpp b/adb/adb.cpp index 14df8a152..dcb6424ec 100644 --- a/adb/adb.cpp +++ b/adb/adb.cpp @@ -1132,9 +1132,27 @@ int handle_host_request(const char* service, TransportType type, } if (!strcmp(service, "features")) { - SendOkay(reply_fd); - SendProtocolString( - reply_fd, android::base::Join(supported_features(), '\n')); + std::string error_msg; + atransport* t = acquire_one_transport(kCsAny, type, serial, &error_msg); + if (t != nullptr) { + SendOkay(reply_fd, android::base::Join(t->features(), '\n')); + } else { + SendFail(reply_fd, error_msg); + } + return 0; + } + + if (!strncmp(service, "check-feature:", strlen("check-feature:"))) { + std::string error_msg; + atransport* t = acquire_one_transport(kCsAny, type, serial, &error_msg); + if (t && t->CanUseFeature(service + strlen("check-feature:"))) { + // We could potentially extend this to reply with the feature + // version if that becomes necessary. + SendOkay(reply_fd, "1"); + } else { + // Empty response means unsupported feature. + SendOkay(reply_fd, ""); + } return 0; } diff --git a/adb/commandline.cpp b/adb/commandline.cpp index 86f926343..4fe0c2588 100644 --- a/adb/commandline.cpp +++ b/adb/commandline.cpp @@ -1444,7 +1444,7 @@ int adb_commandline(int argc, const char **argv) { return 0; } else if (!strcmp(argv[0], "features")) { - return adb_query_command("host:features"); + return adb_query_command(format_host_command("features", transport_type, serial)); } usage();