Merge "adb: Fix missing shell protocol usage."

This commit is contained in:
David Pursell 2015-09-15 15:06:42 +00:00 committed by Gerrit Code Review
commit 0af19a0e82
1 changed files with 22 additions and 19 deletions

View File

@ -524,6 +524,20 @@ static std::string format_host_command(const char* command, TransportType type,
return android::base::StringPrintf("%s:%s", prefix, command);
}
// Checks whether the device indicated by |transport_type| and |serial| supports
// |feature|. Returns the response string, which will be empty if the device
// could not be found or the feature is not supported.
static std::string CheckFeature(const std::string& feature,
TransportType transport_type,
const char* serial) {
std::string result, error, command("check-feature:" + feature);
if (!adb_query(format_host_command(command.c_str(), transport_type, serial),
&result, &error)) {
return "";
}
return result;
}
static int adb_download_buffer(const char *service, const char *fn, const void* data, unsigned sz,
bool show_progress)
{
@ -783,12 +797,15 @@ static int send_shell_command(TransportType transport_type, const char* serial,
wait_for_device("wait-for-device", transport_type, serial);
}
read_and_dump(fd);
int rc = adb_close(fd);
if (rc) {
perror("close");
bool use_shell_protocol = !CheckFeature(kFeatureShell2, transport_type,
serial).empty();
int exit_code = read_and_dump(fd, use_shell_protocol);
if (adb_close(fd) < 0) {
PLOG(ERROR) << "failure closing FD " << fd;
}
return rc;
return exit_code;
}
static int logcat(TransportType transport, const char* serial, int argc, const char** argv) {
@ -1013,20 +1030,6 @@ static bool _is_valid_ack_reply_fd(const int ack_reply_fd) {
#endif
}
// Checks whether the device indicated by |transport_type| and |serial| supports
// |feature|. Returns the response string, which will be empty if the device
// could not be found or the feature is not supported.
static std::string CheckFeature(const std::string& feature,
TransportType transport_type,
const char* serial) {
std::string result, error, command("check-feature:" + feature);
if (!adb_query(format_host_command(command.c_str(), transport_type, serial),
&result, &error)) {
return "";
}
return result;
}
int adb_commandline(int argc, const char **argv) {
int no_daemon = 0;
int is_daemon = 0;