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