From c7ea97f2bb777b778f7acda733cebf009e4d32f1 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 18 Dec 2017 09:46:33 -0800 Subject: [PATCH] Use idevice_id for devicelab iOS device listing (#13624) This patch migrates iOS device listing from using Xcode instruments to using the libimobiledevice tools idevice_id and ideviceinfo. ideviceinfo was previously incompatible with iOS 11 physical devices; this has now been fixed. In 58fe8237d2ec012ea51a673bc228f6545af8bb3c flutter_tools migrated from libimobiledevice-based device listing on iOS to using Xcode instruments to work around the lack of support for iOS 11. Using instruments entails several downsides, including a significantly higher performance hit, and leaking hung DTServiceHub processes in certain cases when a simulator is running, necessitating workarounds in which we watched for, and cleaned up leaked DTServiceHub processes. This patch returns reverts the move to instruments now that it's no longer necessary. This reverts commit 58fe8237d2ec012ea51a673bc228f6545af8bb3c. --- dev/devicelab/lib/framework/adb.dart | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) 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.';