Unverified Commit e9b935b0 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

use deviceManager discovery in daemon protocol (#28341)

parent c9400889
......@@ -6,7 +6,6 @@ import 'dart:async';
import 'package:meta/meta.dart';
import '../android/android_device.dart';
import '../base/common.dart';
import '../base/context.dart';
import '../base/file_system.dart';
......@@ -17,22 +16,14 @@ import '../base/utils.dart';
import '../build_info.dart';
import '../cache.dart';
import '../convert.dart';
import '../desktop.dart';
import '../device.dart';
import '../emulator.dart';
import '../fuchsia/fuchsia_device.dart';
import '../globals.dart';
import '../ios/devices.dart';
import '../ios/simulators.dart';
import '../linux/linux_device.dart';
import '../macos/macos_device.dart';
import '../resident_runner.dart';
import '../run_cold.dart';
import '../run_hot.dart';
import '../runner/flutter_command.dart';
import '../tester/flutter_tester.dart';
import '../vmservice.dart';
import '../windows/windows_device.dart';
const String protocolVersion = '0.4.2';
......@@ -589,27 +580,21 @@ class DeviceDomain extends Domain {
registerHandler('forward', forward);
registerHandler('unforward', unforward);
addDeviceDiscoverer(FuchsiaDevices());
addDeviceDiscoverer(AndroidDevices());
addDeviceDiscoverer(IOSDevices());
addDeviceDiscoverer(IOSSimulators());
addDeviceDiscoverer(FlutterTesterDevices());
if (flutterDesktopEnabled) {
addDeviceDiscoverer(MacOSDevices());
addDeviceDiscoverer(LinuxDevices());
addDeviceDiscoverer(WindowsDevices());
}
// Use the device manager discovery so that client provided device types
// are usable via the daemon protocol.
deviceManager.deviceDiscoverers.forEach(addDeviceDiscoverer);
}
void addDeviceDiscoverer(PollingDeviceDiscovery discoverer) {
void addDeviceDiscoverer(DeviceDiscovery discoverer) {
if (!discoverer.supportsPlatform)
return;
_discoverers.add(discoverer);
if (discoverer is PollingDeviceDiscovery) {
discoverer.onAdded.listen(_onDeviceEvent('device.added'));
discoverer.onRemoved.listen(_onDeviceEvent('device.removed'));
}
}
Future<void> _serializeDeviceEvents = Future<void>.value();
......
......@@ -11,6 +11,7 @@ import 'base/context.dart';
import 'base/file_system.dart';
import 'base/utils.dart';
import 'build_info.dart';
import 'desktop.dart';
import 'fuchsia/fuchsia_device.dart';
import 'globals.dart';
......@@ -35,10 +36,16 @@ class DeviceManager {
IOSSimulators(),
FuchsiaDevices(),
FlutterTesterDevices(),
] + _conditionalDesktopDevices);
/// Only add desktop devices if the flag is enabled.
static List<DeviceDiscovery> get _conditionalDesktopDevices {
return flutterDesktopEnabled ? <DeviceDiscovery>[
MacOSDevices(),
LinuxDevices(),
WindowsDevices(),
]);
] : <DeviceDiscovery>[];
}
String _specifiedDeviceId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment