summaryrefslogtreecommitdiff
path: root/services.cpp
diff options
context:
space:
mode:
authorDavid Pursell <dpursell@google.com>2015-09-30 13:35:42 -0700
committerDavid Pursell <dpursell@google.com>2015-09-30 15:40:09 -0700
commit83ce030d4e5f984d4c075c403dd18a0ca81b1a87 (patch)
tree5671a74ce54040916cb3e51eaa9d0a717aa9b819 /services.cpp
parent94c44016909a3c19827107b732790ff5de98ef40 (diff)
downloadadb-83ce030d4e5f984d4c075c403dd18a0ca81b1a87.tar.gz
adb: put legacy shell: service back in.
ddmlib does not use the ADB client, but instead connects directly to the adb server. This breaks some of the assumptions I previously made when enabling the shell protocol. To fix this, the adb server now defaults to no protocol for the standalone command, and the shell protocol must be explicitly requested by the client. For example: shell:echo foo -- no shell protocol shell,v2:echo foo -- shell protocol As long as I was touching the shell service arguments I also changed them to no longer duplicate the command-line arguments. This allows more flexibility to change the adb client CLI if necessary and makes the code more readable. Bug: http://b/24148636 Change-Id: I28d5ae578cf18cbe79347dc89cea1750ff4571a8
Diffstat (limited to 'services.cpp')
-rw-r--r--services.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/services.cpp b/services.cpp
index 1153c31..e832b1e 100644
--- a/services.cpp
+++ b/services.cpp
@@ -46,6 +46,7 @@
#include "adb_utils.h"
#include "file_sync_service.h"
#include "remount_service.h"
+#include "services.h"
#include "shell_service.h"
#include "transport.h"
@@ -195,34 +196,38 @@ void reverse_service(int fd, void* arg)
}
// Shell service string can look like:
-// shell[args]:[command]
-// Currently the only supported args are -T (force raw) and -t (force PTY).
+// shell[,arg1,arg2,...]:[command]
static int ShellService(const std::string& args, const atransport* transport) {
size_t delimiter_index = args.find(':');
if (delimiter_index == std::string::npos) {
LOG(ERROR) << "No ':' found in shell service arguments: " << args;
return -1;
}
+
const std::string service_args = args.substr(0, delimiter_index);
const std::string command = args.substr(delimiter_index + 1);
- SubprocessType type;
- if (service_args.empty()) {
- // Default: use PTY for interactive, raw for non-interactive.
- type = (command.empty() ? SubprocessType::kPty : SubprocessType::kRaw);
- } else if (service_args == "-T") {
- type = SubprocessType::kRaw;
- } else if (service_args == "-t") {
- type = SubprocessType::kPty;
- } else {
- LOG(ERROR) << "Unsupported shell service arguments: " << args;
- return -1;
+ // Defaults:
+ // PTY for interactive, raw for non-interactive.
+ // No protocol.
+ SubprocessType type(command.empty() ? SubprocessType::kPty
+ : SubprocessType::kRaw);
+ SubprocessProtocol protocol = SubprocessProtocol::kNone;
+
+ for (const std::string& arg : android::base::Split(service_args, ",")) {
+ if (arg == kShellServiceArgRaw) {
+ type = SubprocessType::kRaw;
+ } else if (arg == kShellServiceArgPty) {
+ type = SubprocessType::kPty;
+ } else if (arg == kShellServiceArgShellProtocol) {
+ protocol = SubprocessProtocol::kShell;
+ }
+ else if (!arg.empty()) {
+ LOG(ERROR) << "Unsupported shell service arguments: " << args;
+ return -1;
+ }
}
- SubprocessProtocol protocol =
- (transport->CanUseFeature(kFeatureShell2) ? SubprocessProtocol::kShell
- : SubprocessProtocol::kNone);
-
return StartSubprocess(command.c_str(), type, protocol);
}