Add "exec" service: shell commands with no pty.

To facilitate device scripts that want to read/write binary data from
the host side, this change introduces a new "exec" service that
behaves like "shell" but without creating a pty, which would otherwise
mangle binary data.

After forking, it hooks up stdin/stdout of the child process to
the socket connected through to the host.  The adb transport doesn't
support shutdown(), so the host can't half-close the socket and wait
for device termination.  Instead, the host side now has two explicit
commands "exec-in" and "exec-out" for either sending or receiving
data.

Teach host side copy_to_file() to deal with stdin/stdout special
cases.  Switch device side backup/restore services to use the new
create_subproc_raw under the hood.

(cherry picked from commit 5d9d434efadf1c535c7fea634d5306e18c68ef1f)

Change-Id: I42c18cb5bb907449b458c94450ef6c584d84ecdb
diff --git a/adb/adb.h b/adb/adb.h
index 2504f99..4704abb 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -326,11 +326,6 @@
 int handle_forward_request(const char* service, transport_type ttype, char* serial, int reply_fd);
 
 #if !ADB_HOST
-typedef enum {
-    BACKUP,
-    RESTORE
-} BackupOperation;
-int backup_service(BackupOperation operation, char* args);
 void framebuffer_service(int fd, void *cookie);
 void remount_service(int fd, void *cookie);
 #endif
@@ -418,7 +413,7 @@
 #  define  D(...)          ((void)0)
 #  define  DR(...)         ((void)0)
 #  define  ADB_TRACING     0
-#endif
+#endif /* ADB_TRACE */
 
 
 #if !DEBUG_PACKETS
@@ -476,6 +471,11 @@
 extern int HOST;
 extern int SHELL_EXIT_NOTIFY_FD;
 
+typedef enum {
+    SUBPROC_PTY = 0,
+    SUBPROC_RAW = 1,
+} subproc_mode;
+
 #define CHUNK_SIZE (64*1024)
 
 #if !ADB_HOST