Add timeout flag to devices command, pipe through discovery (#51678)

This commit is contained in:
Jenn Magder
2020-03-16 14:15:00 -07:00
committed by GitHub
parent 0a09b78297
commit 2f216ceee5
23 changed files with 251 additions and 52 deletions

View File

@@ -78,7 +78,7 @@ class MacOSDevices extends PollingDeviceDiscovery {
bool get canListAnything => macOSWorkflow.canListDevices;
@override
Future<List<Device>> pollingGetDevices() async {
Future<List<Device>> pollingGetDevices({ Duration timeout }) async {
if (!canListAnything) {
return const <Device>[];
}

View File

@@ -228,7 +228,10 @@ class XCDevice {
return _xcdevicePath;
}
Future<List<dynamic>> _getAllDevices({bool useCache = false}) async {
Future<List<dynamic>> _getAllDevices({
bool useCache = false,
@required Duration timeout
}) async {
if (!isInstalled) {
_logger.printTrace("Xcode not found. Run 'flutter doctor' for more information.");
return null;
@@ -244,7 +247,7 @@ class XCDevice {
'xcdevice',
'list',
'--timeout',
'1',
timeout.inSeconds.toString(),
],
throwOnError: true,
);
@@ -265,9 +268,9 @@ class XCDevice {
List<dynamic> _cachedListResults;
/// List of devices available over USB.
Future<List<IOSDevice>> getAvailableTetheredIOSDevices() async {
final List<dynamic> allAvailableDevices = await _getAllDevices();
/// [timeout] defaults to 1 second.
Future<List<IOSDevice>> getAvailableTetheredIOSDevices({ Duration timeout }) async {
final List<dynamic> allAvailableDevices = await _getAllDevices(timeout: timeout ?? const Duration(seconds: 1));
if (allAvailableDevices == null) {
return const <IOSDevice>[];
@@ -501,7 +504,10 @@ class XCDevice {
/// List of all devices reporting errors.
Future<List<String>> getDiagnostics() async {
final List<dynamic> allAvailableDevices = await _getAllDevices(useCache: true);
final List<dynamic> allAvailableDevices = await _getAllDevices(
useCache: true,
timeout: const Duration(seconds: 1)
);
if (allAvailableDevices == null) {
return const <String>[];