| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library android; | 5 library android; |
| 6 | 6 |
| 7 import "dart:async"; | 7 import "dart:async"; |
| 8 import "dart:convert" show LineSplitter, UTF8; | 8 import "dart:convert" show LineSplitter, UTF8; |
| 9 import "dart:core"; | 9 import "dart:core"; |
| 10 import "dart:io"; | 10 import "dart:io"; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 getOutput(process.stderr), | 50 getOutput(process.stderr), |
| 51 process.exitCode]; | 51 process.exitCode]; |
| 52 return Future.wait(futures).then((results) { | 52 return Future.wait(futures).then((results) { |
| 53 bool success = results[2] == 0; | 53 bool success = results[2] == 0; |
| 54 if (!success) { | 54 if (!success) { |
| 55 var error = "Running: '\$ $executable ${args.join(' ')}' failed:" | 55 var error = "Running: '\$ $executable ${args.join(' ')}' failed:" |
| 56 "stdout: \n ${results[0]}" | 56 "stdout: \n ${results[0]}" |
| 57 "stderr: \n ${results[1]}" | 57 "stderr: \n ${results[1]}" |
| 58 "exitCode: \n ${results[2]}"; | 58 "exitCode: \n ${results[2]}"; |
| 59 throw new Exception(error); | 59 throw new Exception(error); |
| 60 } else { |
| 61 DebugLogger.info("Success: $executable finished"); |
| 60 } | 62 } |
| 61 return results[0]; | 63 return results[0]; |
| 62 }); | 64 }); |
| 63 }); | 65 }); |
| 64 } | 66 } |
| 65 | 67 |
| 66 /** | 68 /** |
| 67 * Helper class to loop through all adb ports. | 69 * Helper class to loop through all adb ports. |
| 68 * | 70 * |
| 69 * The ports come in pairs: | 71 * The ports come in pairs: |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 if (_deviceId != null) { | 294 if (_deviceId != null) { |
| 293 var extendedAdbArgs = ['-s', _deviceId]; | 295 var extendedAdbArgs = ['-s', _deviceId]; |
| 294 extendedAdbArgs.addAll(adbArgs); | 296 extendedAdbArgs.addAll(adbArgs); |
| 295 adbArgs = extendedAdbArgs; | 297 adbArgs = extendedAdbArgs; |
| 296 } | 298 } |
| 297 return _executeCommandGetOutput("adb", adbArgs); | 299 return _executeCommandGetOutput("adb", adbArgs); |
| 298 } | 300 } |
| 299 } | 301 } |
| 300 | 302 |
| 301 /** | 303 /** |
| 302 * Helper to list all adb devicess available. | 304 * Helper to list all adb devices available. |
| 303 */ | 305 */ |
| 304 class AdbHelper { | 306 class AdbHelper { |
| 305 static RegExp _deviceLineRegexp = | 307 static RegExp _deviceLineRegexp = |
| 306 new RegExp(r'^([a-zA-Z0-9_-]+)[ \t]+device$', multiLine: true); | 308 new RegExp(r'^([a-zA-Z0-9_-]+)[ \t]+device$', multiLine: true); |
| 307 | 309 |
| 308 static Future<List<String>> listDevices() { | 310 static Future<List<String>> listDevices() { |
| 309 return Process.run('adb', ['devices']).then((ProcessResult result) { | 311 return Process.run('adb', ['devices']).then((ProcessResult result) { |
| 310 if (result.exitCode != 0) { | 312 if (result.exitCode != 0) { |
| 311 throw new Exception("Could not list devices [stdout: ${result.stdout}," | 313 throw new Exception("Could not list devices [stdout: ${result.stdout}," |
| 312 "stderr: ${result.stderr}]"); | 314 "stderr: ${result.stderr}]"); |
| 313 } | 315 } |
| 314 return _deviceLineRegexp.allMatches(result.stdout) | 316 return _deviceLineRegexp.allMatches(result.stdout) |
| 315 .map((Match m) => m.group(1)).toList(); | 317 .map((Match m) => m.group(1)).toList(); |
| 316 }); | 318 }); |
| 317 } | 319 } |
| 318 } | 320 } |
| 319 | 321 |
| 320 /** | 322 /** |
| 321 * Represents an android intent. | 323 * Represents an android intent. |
| 322 */ | 324 */ |
| 323 class Intent { | 325 class Intent { |
| 324 String action; | 326 String action; |
| 325 String package; | 327 String package; |
| 326 String activity; | 328 String activity; |
| 327 String dataUri; | 329 String dataUri; |
| 328 | 330 |
| 329 Intent(this.action, this.package, this.activity, [this.dataUri]); | 331 Intent(this.action, this.package, this.activity, [this.dataUri]); |
| 330 } | 332 } |
| 331 | 333 |
| OLD | NEW |