diff --git a/dev/devicelab/lib/framework/adb.dart b/dev/devicelab/lib/framework/adb.dart index 2ae5aadfec0..7a1c3d2a585 100644 --- a/dev/devicelab/lib/framework/adb.dart +++ b/dev/devicelab/lib/framework/adb.dart @@ -307,27 +307,12 @@ class IosDeviceDiscovery implements DeviceDiscovery { _workingDevice = allDevices[new math.Random().nextInt(allDevices.length)]; } - // Physical device line format to be matched: - // My iPhone (10.3.2) [75b90e947c5f429fa67f3e9169fda0d89f0492f1] - // - // Other formats in output (desktop, simulator) to be ignored: - // my-mac-pro [2C10513E-4dA5-405C-8EF5-C44353DB3ADD] - // iPhone 6s (9.3) [F6CEE7CF-81EB-4448-81B4-1755288C7C11] (Simulator) - static final RegExp _deviceRegex = new RegExp(r'^.* +\(.*\) +\[(.*)\]$'); - @override Future> discoverDevices() async { - final List iosDeviceIDs = []; - final Iterable deviceLines = (await eval('instruments', ['-s', 'devices'])) - .split('\n') - .map((String line) => line.trim()); - for (String line in deviceLines) { - final Match match = _deviceRegex.firstMatch(line); - if (match != null) { - final String deviceID = match.group(1); - iosDeviceIDs.add(deviceID); - } - } + // TODO(yjbanov): use the -k UniqueDeviceID option, which requires much less parsing. + final List iosDeviceIDs = grep('UniqueDeviceID', from: await eval('ideviceinfo', [])) + .map((String line) => line.split(' ').last).toList(); + if (iosDeviceIDs.isEmpty) throw 'No connected iOS devices found.';