adb: add -Tt options to `adb shell`.
Adds -T (no PTY) and -t (force PTY) options to `adb shell` to mimic
ssh options. Small cleanup to send an entire FeatureSet to the adb
client at once to avoid multiple round-trips when querying multiple
features.
Known issue: humans using `adb shell -T` to start a non-PTY interactive
session may experience problems since neither side will have PTY
features like echoing or newline translation. This is probably OK for
now as the -Tt options are primarily useful for scripting.
Bug: http://b/23825231
Change-Id: I4d0df300db0abd1f7410bab59dd4d5b991babda7
diff --git a/adb/adb.cpp b/adb/adb.cpp
index 60966d6..19dd03d 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -334,7 +334,7 @@
#endif
connection_properties.push_back(android::base::StringPrintf(
- "features=%s", android::base::Join(supported_features(), ',').c_str()));
+ "features=%s", FeatureSetToString(supported_features()).c_str()));
return android::base::StringPrintf(
"%s::%s", adb_device_banner,
@@ -396,9 +396,7 @@
} else if (key == "ro.product.device") {
qual_overwrite(&t->device, value);
} else if (key == "features") {
- for (const auto& feature : android::base::Split(value, ",")) {
- t->add_feature(feature);
- }
+ t->SetFeatures(value);
}
}
}
@@ -1149,27 +1147,13 @@
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'));
+ SendOkay(reply_fd, FeatureSetToString(t->features()));
} 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;
- }
-
// remove TCP transport
if (!strncmp(service, "disconnect:", 11)) {
const std::string address(service + 11);