| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 std::string command = "pm clear " + package; | 153 std::string command = "pm clear " + package; |
| 154 Status status = ExecuteHostShellCommand(device_serial, command, &response); | 154 Status status = ExecuteHostShellCommand(device_serial, command, &response); |
| 155 if (!status.IsOk()) | 155 if (!status.IsOk()) |
| 156 return status; | 156 return status; |
| 157 if (response.find("Success") == std::string::npos) | 157 if (response.find("Success") == std::string::npos) |
| 158 return Status(kUnknownError, "Failed to clear data for " + package + | 158 return Status(kUnknownError, "Failed to clear data for " + package + |
| 159 " on device " + device_serial + ": " + response); | 159 " on device " + device_serial + ": " + response); |
| 160 return Status(kOk); | 160 return Status(kOk); |
| 161 } | 161 } |
| 162 | 162 |
| 163 Status AdbImpl::SetDebugApp( |
| 164 const std::string& device_serial, const std::string& package) { |
| 165 std::string response; |
| 166 return ExecuteHostShellCommand( |
| 167 device_serial, "am set-debug-app --persistent " + package, &response); |
| 168 } |
| 169 |
| 163 Status AdbImpl::Launch( | 170 Status AdbImpl::Launch( |
| 164 const std::string& device_serial, const std::string& package, | 171 const std::string& device_serial, const std::string& package, |
| 165 const std::string& activity) { | 172 const std::string& activity) { |
| 166 std::string response; | 173 std::string response; |
| 167 Status status = ExecuteHostShellCommand( | 174 Status status = ExecuteHostShellCommand( |
| 168 device_serial, | 175 device_serial, |
| 169 "am start -W -n " + package + "/" + activity + " -d data:,", | 176 "am start -W -n " + package + "/" + activity + " -d data:,", |
| 170 &response); | 177 &response); |
| 171 if (!status.IsOk()) | 178 if (!status.IsOk()) |
| 172 return status; | 179 return status; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 246 |
| 240 Status AdbImpl::ExecuteHostShellCommand( | 247 Status AdbImpl::ExecuteHostShellCommand( |
| 241 const std::string& device_serial, | 248 const std::string& device_serial, |
| 242 const std::string& shell_command, | 249 const std::string& shell_command, |
| 243 std::string* response) { | 250 std::string* response) { |
| 244 return ExecuteCommand( | 251 return ExecuteCommand( |
| 245 "host:transport:" + device_serial + "|shell:" + shell_command, | 252 "host:transport:" + device_serial + "|shell:" + shell_command, |
| 246 response); | 253 response); |
| 247 } | 254 } |
| 248 | 255 |
| OLD | NEW |