OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 276 } |
277 | 277 |
278 void ReceivedResponse(const AndroidDeviceManager::DeviceInfoCallback& callback, | 278 void ReceivedResponse(const AndroidDeviceManager::DeviceInfoCallback& callback, |
279 int result, | 279 int result, |
280 const std::string& response) { | 280 const std::string& response) { |
281 AndroidDeviceManager::DeviceInfo device_info; | 281 AndroidDeviceManager::DeviceInfo device_info; |
282 if (result < 0) { | 282 if (result < 0) { |
283 callback.Run(device_info); | 283 callback.Run(device_info); |
284 return; | 284 return; |
285 } | 285 } |
286 std::vector<std::string> outputs; | 286 std::vector<std::string> outputs = base::SplitStringUsingSubstr( |
287 base::SplitStringUsingSubstr(response, kSeparator, &outputs); | 287 response, kSeparator, base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
288 if (outputs.size() != 5) { | 288 if (outputs.size() != 5) { |
289 callback.Run(device_info); | 289 callback.Run(device_info); |
290 return; | 290 return; |
291 } | 291 } |
292 device_info.connected = true; | 292 device_info.connected = true; |
293 device_info.model = outputs[0]; | 293 device_info.model = outputs[0]; |
294 device_info.screen_size = ParseWindowPolicyResponse(outputs[1]); | 294 device_info.screen_size = ParseWindowPolicyResponse(outputs[1]); |
295 StringMap pid_to_package; | 295 StringMap pid_to_package; |
296 StringMap pid_to_user; | 296 StringMap pid_to_user; |
297 MapProcessesToPackages(outputs[2], &pid_to_package, &pid_to_user); | 297 MapProcessesToPackages(outputs[2], &pid_to_package, &pid_to_user); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 } | 361 } |
362 | 362 |
363 // static | 363 // static |
364 void AndroidDeviceManager::QueryDeviceInfo( | 364 void AndroidDeviceManager::QueryDeviceInfo( |
365 const RunCommandCallback& command_callback, | 365 const RunCommandCallback& command_callback, |
366 const DeviceInfoCallback& callback) { | 366 const DeviceInfoCallback& callback) { |
367 command_callback.Run( | 367 command_callback.Run( |
368 kAllCommands, | 368 kAllCommands, |
369 base::Bind(&ReceivedResponse, callback)); | 369 base::Bind(&ReceivedResponse, callback)); |
370 } | 370 } |
OLD | NEW |