Re-enable use of instruments for iOS device lookup (#10838)
This reverts commit b2909a245a607995ce7ec286585cd1f643124f57.
This resubmits the following patches:
1. Use Xcode instruments to list devices (#10801)
Eliminates the dependency on idevice_id from libimobiledevice. Instead,
uses Xcode built-in functionality.
2. Make device discovery asynchronous (#10803)
Migrates DeviceDiscovery.devices and all device-specific lookup to be
asynchronous.
diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart
index de3f873..8208adf 100644
--- a/packages/flutter_tools/lib/src/device.dart
+++ b/packages/flutter_tools/lib/src/device.dart
@@ -81,11 +81,17 @@
: getAllConnectedDevices();
}
+ Iterable<DeviceDiscovery> get _platformDiscoverers {
+ return _deviceDiscoverers.where((DeviceDiscovery discoverer) => discoverer.supportsPlatform);
+ }
+
/// Return the list of all connected devices.
- Stream<Device> getAllConnectedDevices() {
- return new Stream<Device>.fromIterable(_deviceDiscoverers
- .where((DeviceDiscovery discoverer) => discoverer.supportsPlatform)
- .expand((DeviceDiscovery discoverer) => discoverer.devices));
+ Stream<Device> getAllConnectedDevices() async* {
+ for (DeviceDiscovery discoverer in _platformDiscoverers) {
+ for (Device device in await discoverer.devices) {
+ yield device;
+ }
+ }
}
}
@@ -97,7 +103,7 @@
/// current environment configuration.
bool get canListAnything;
- List<Device> get devices;
+ Future<List<Device>> get devices;
}
/// A [DeviceDiscovery] implementation that uses polling to discover device adds
@@ -111,13 +117,13 @@
ItemListNotifier<Device> _items;
Timer _timer;
- List<Device> pollingGetDevices();
+ Future<List<Device>> pollingGetDevices();
void startPolling() {
if (_timer == null) {
_items ??= new ItemListNotifier<Device>();
- _timer = new Timer.periodic(_pollingDuration, (Timer timer) {
- _items.updateWithNewList(pollingGetDevices());
+ _timer = new Timer.periodic(_pollingDuration, (Timer timer) async {
+ _items.updateWithNewList(await pollingGetDevices());
});
}
}
@@ -128,8 +134,8 @@
}
@override
- List<Device> get devices {
- _items ??= new ItemListNotifier<Device>.from(pollingGetDevices());
+ Future<List<Device>> get devices async {
+ _items ??= new ItemListNotifier<Device>.from(await pollingGetDevices());
return _items.items;
}