| 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:collection"; | 10 import "dart:collection"; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 int exitCode = result.exitCode; | 326 int exitCode = result.exitCode; |
| 327 var lines = result | 327 var lines = result |
| 328 .stdout.split('\n') | 328 .stdout.split('\n') |
| 329 .where((line) => line.trim().length > 0) | 329 .where((line) => line.trim().length > 0) |
| 330 .toList(); | 330 .toList(); |
| 331 if (lines.length > 0) { | 331 if (lines.length > 0) { |
| 332 int index = lines.last.indexOf(MARKER); | 332 int index = lines.last.indexOf(MARKER); |
| 333 if (index >= 0) { | 333 if (index >= 0) { |
| 334 exitCode = int.parse( | 334 exitCode = int.parse( |
| 335 lines.last.substring(index + MARKER.length).trim()); | 335 lines.last.substring(index + MARKER.length).trim()); |
| 336 exitCode = exitCode.toSigned(8); | 336 if (exitCode > 128 && exitCode <= 128 + 31) { |
| 337 // Return negative exit codes for signals 1..31 (128+N for signal N) |
| 338 exitCode = 128 - exitCode; |
| 339 } |
| 337 } else { | 340 } else { |
| 338 // In case of timeouts, for example, we won't get the exitcode marker. | 341 // In case of timeouts, for example, we won't get the exitcode marker. |
| 339 assert(result.exitCode != 0); | 342 assert(result.exitCode != 0); |
| 340 } | 343 } |
| 341 } | 344 } |
| 342 return new AdbCommandResult( | 345 return new AdbCommandResult( |
| 343 result.command, result.stdout, result.stderr, exitCode, | 346 result.command, result.stdout, result.stderr, exitCode, |
| 344 result.timedOut); | 347 result.timedOut); |
| 345 } | 348 } |
| 346 | 349 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 430 |
| 428 void releaseDevice(AdbDevice device) { | 431 void releaseDevice(AdbDevice device) { |
| 429 if (_waiter.length > 0) { | 432 if (_waiter.length > 0) { |
| 430 Completer completer = _waiter.removeFirst(); | 433 Completer completer = _waiter.removeFirst(); |
| 431 completer.complete(device); | 434 completer.complete(device); |
| 432 } else { | 435 } else { |
| 433 _idleDevices.add(device); | 436 _idleDevices.add(device); |
| 434 } | 437 } |
| 435 } | 438 } |
| 436 } | 439 } |
| OLD | NEW |