Add feature list to connection banner.
This allows us to test for features explicitly rather than relying on
the protocol version number, allowing us to fall back gracefully if a
feature is not supported.
This will be needed for the upcoming shell upgrades for stdout/stderr
separation and exit code reporting.
Change-Id: Ibb1d8ad2611f7209901ee76d51346b453e9c5873
diff --git a/adb/transport.cpp b/adb/transport.cpp
index 4a273c4..2ea4d44 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -29,6 +29,7 @@
#include <list>
#include <base/stringprintf.h>
+#include <base/strings.h>
#include "adb.h"
#include "adb_utils.h"
@@ -535,7 +536,7 @@
t = m.transport;
- if(m.action == 0){
+ if (m.action == 0) {
D("transport: %s removing and free'ing %d\n", t->serial, t->transport_socket);
/* IMPORTANT: the remove closes one half of the
@@ -845,6 +846,29 @@
return max_payload;
}
+// The list of features supported by the current system. Will be sent to the
+// other side of the connection in the banner.
+static const FeatureSet gSupportedFeatures = {
+ // None yet.
+};
+
+const FeatureSet& supported_features() {
+ return gSupportedFeatures;
+}
+
+bool atransport::has_feature(const std::string& feature) const {
+ return features_.count(feature) > 0;
+}
+
+void atransport::add_feature(const std::string& feature) {
+ features_.insert(feature);
+}
+
+bool atransport::CanUseFeature(const std::string& feature) const {
+ return has_feature(feature) &&
+ supported_features().count(feature) > 0;
+}
+
#if ADB_HOST
static void append_transport_info(std::string* result, const char* key,
@@ -879,6 +903,9 @@
append_transport_info(result, "product:", t->product, false);
append_transport_info(result, "model:", t->model, true);
append_transport_info(result, "device:", t->device, false);
+ append_transport_info(result, "features:",
+ android::base::Join(t->features(), ',').c_str(),
+ false);
}
*result += '\n';
}