OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/chromedriver/chrome/adb_impl.h" | 5 #include "chrome/test/chromedriver/chrome/adb_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 return Status(kUnknownError, "Failed to forward ports to device " + | 112 return Status(kUnknownError, "Failed to forward ports to device " + |
113 device_serial + ": " + response); | 113 device_serial + ": " + response); |
114 } | 114 } |
115 | 115 |
116 Status AdbImpl::SetCommandLineFile(const std::string& device_serial, | 116 Status AdbImpl::SetCommandLineFile(const std::string& device_serial, |
117 const std::string& command_line_file, | 117 const std::string& command_line_file, |
118 const std::string& exec_name, | 118 const std::string& exec_name, |
119 const std::string& args) { | 119 const std::string& args) { |
120 std::string response; | 120 std::string response; |
121 std::string quoted_command = | 121 std::string quoted_command = |
122 base::GetQuotedJSONString(exec_name + " " + args); | 122 base::GetDoubleQuotedJson(exec_name + " " + args); |
123 Status status = ExecuteHostShellCommand( | 123 Status status = ExecuteHostShellCommand( |
124 device_serial, | 124 device_serial, |
125 base::StringPrintf("echo %s > %s; echo $?", | 125 base::StringPrintf("echo %s > %s; echo $?", |
126 quoted_command.c_str(), | 126 quoted_command.c_str(), |
127 command_line_file.c_str()), | 127 command_line_file.c_str()), |
128 &response); | 128 &response); |
129 if (!status.IsOk()) | 129 if (!status.IsOk()) |
130 return status; | 130 return status; |
131 if (response.find("0") == std::string::npos) | 131 if (response.find("0") == std::string::npos) |
132 return Status(kUnknownError, "Failed to set command line file " + | 132 return Status(kUnknownError, "Failed to set command line file " + |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 239 |
240 Status AdbImpl::ExecuteHostShellCommand( | 240 Status AdbImpl::ExecuteHostShellCommand( |
241 const std::string& device_serial, | 241 const std::string& device_serial, |
242 const std::string& shell_command, | 242 const std::string& shell_command, |
243 std::string* response) { | 243 std::string* response) { |
244 return ExecuteCommand( | 244 return ExecuteCommand( |
245 "host:transport:" + device_serial + "|shell:" + shell_command, | 245 "host:transport:" + device_serial + "|shell:" + shell_command, |
246 response); | 246 response); |
247 } | 247 } |
248 | 248 |
OLD | NEW |