summaryrefslogtreecommitdiff
path: root/services.cpp
diff options
context:
space:
mode:
authorDavid Pursell <dpursell@google.com>2015-08-31 10:42:13 -0700
committerDavid Pursell <dpursell@google.com>2015-09-11 11:27:50 -0700
commit1f747c622248c3d1f7ae23602d9a51c195e0345c (patch)
tree0db5b47f7c09702433226e54a7fd140df99819b6 /services.cpp
parent5a1015d9b2d4f4f040995827087138c870270e12 (diff)
downloadadb-1f747c622248c3d1f7ae23602d9a51c195e0345c.tar.gz
adb: implement shell protocol.
Adds functionality for handling stdin/stdout/stderr streams and exit codes using the shell protocol. This CL just contains implementation for adbd which will not yet be enabled. Once we have the ability to query transport features from the adb client, another CL will add the implementation for the client side and update the feature list to turn this on. Note: this CL must be submitted together with a minadbd CL to update the service_to_fd() function signature. Bug: http://b/23030641 Change-Id: Ibed55e9c1946d8a35190696163ff63e8fb880238
Diffstat (limited to 'services.cpp')
-rw-r--r--services.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/services.cpp b/services.cpp
index 561431c..d128efc 100644
--- a/services.cpp
+++ b/services.cpp
@@ -225,7 +225,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie)
return s[0];
}
-int service_to_fd(const char* name) {
+int service_to_fd(const char* name, const atransport* transport) {
int ret = -1;
if(!strncmp(name, "tcp:", 4)) {
@@ -267,15 +267,15 @@ int service_to_fd(const char* name) {
ret = create_jdwp_connection_fd(atoi(name+5));
} else if(!strncmp(name, "shell:", 6)) {
const char* args = name + 6;
- if (*args) {
- // Non-interactive session uses a raw subprocess.
- ret = StartSubprocess(args, SubprocessType::kRaw);
- } else {
- // Interactive session uses a PTY subprocess.
- ret = StartSubprocess(args, SubprocessType::kPty);
- }
+ // Use raw for non-interactive, PTY for interactive.
+ SubprocessType type = (*args ? SubprocessType::kRaw : SubprocessType::kPty);
+ SubprocessProtocol protocol =
+ (transport->CanUseFeature(kFeatureShell2) ? SubprocessProtocol::kShell
+ : SubprocessProtocol::kNone);
+ ret = StartSubprocess(args, type, protocol);
} else if(!strncmp(name, "exec:", 5)) {
- ret = StartSubprocess(name + 5, SubprocessType::kRaw);
+ ret = StartSubprocess(name + 5, SubprocessType::kRaw,
+ SubprocessProtocol::kNone);
} else if(!strncmp(name, "sync:", 5)) {
ret = create_service_thread(file_sync_service, NULL);
} else if(!strncmp(name, "remount:", 8)) {
@@ -291,9 +291,10 @@ int service_to_fd(const char* name) {
} else if(!strncmp(name, "backup:", 7)) {
ret = StartSubprocess(android::base::StringPrintf("/system/bin/bu backup %s",
(name + 7)).c_str(),
- SubprocessType::kRaw);
+ SubprocessType::kRaw, SubprocessProtocol::kNone);
} else if(!strncmp(name, "restore:", 8)) {
- ret = StartSubprocess("/system/bin/bu restore", SubprocessType::kRaw);
+ ret = StartSubprocess("/system/bin/bu restore", SubprocessType::kRaw,
+ SubprocessProtocol::kNone);
} else if(!strncmp(name, "tcpip:", 6)) {
int port;
if (sscanf(name + 6, "%d", &port) != 1) {