update Android device detection to handle adb error messages (#6521)

This commit is contained in:
Dan Rubel
2016-10-27 12:06:47 +01:00
committed by GitHub
parent ca90656fba
commit 7acc996547
2 changed files with 25 additions and 4 deletions

View File

@@ -629,18 +629,24 @@ final RegExp _kDeviceRegex = new RegExp(r'^(\S+)\s+(\S+)(.*)');
/// [mockAdbOutput] is public for testing.
List<AndroidDevice> getAdbDevices({ String mockAdbOutput }) {
List<AndroidDevice> devices = <AndroidDevice>[];
List<String> output;
String text;
if (mockAdbOutput == null) {
String adbPath = getAdbPath(androidSdk);
if (adbPath == null)
return <AndroidDevice>[];
output = runSync(<String>[adbPath, 'devices', '-l']).trim().split('\n');
text = runSync(<String>[adbPath, 'devices', '-l']);
} else {
output = mockAdbOutput.trim().split('\n');
text = mockAdbOutput;
}
for (String line in output) {
// Check for error messages from adb
if (!text.contains('List of devices')) {
printError(text);
return <AndroidDevice>[];
}
for (String line in text.trim().split('\n')) {
// Skip lines like: * daemon started successfully *
if (line.startsWith('* daemon '))
continue;