diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index 5865744ae7..936bf15c7b 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -202,7 +202,7 @@ class DeviceManager { if (devices.length > 1 && !hasSpecifiedDeviceId) { devices = [ for (Device device in devices) - if (device.isSupportedForProject(flutterProject)) + if (isDeviceSupportedForProject(device, flutterProject)) device ]; } @@ -224,6 +224,8 @@ class DeviceManager { } /// Returns whether the device is supported for the project. + /// + /// This exists to allow the check to be overriden for google3 clients. bool isDeviceSupportedForProject(Device device, FlutterProject flutterProject) { return device.isSupportedForProject(flutterProject); } diff --git a/packages/flutter_tools/test/general.shard/device_test.dart b/packages/flutter_tools/test/general.shard/device_test.dart index e63b01c30d..0e41b14acc 100644 --- a/packages/flutter_tools/test/general.shard/device_test.dart +++ b/packages/flutter_tools/test/general.shard/device_test.dart @@ -116,6 +116,20 @@ void main() { nonEphemeralTwo, ]); }); + + testUsingContext('uses DeviceManager.isDeviceSupportedForProject instead of device.isSupportedForProject', () async { + final List devices = [ + unsupported, + ]; + final TestDeviceManager deviceManager = TestDeviceManager(devices); + deviceManager.isAlwaysSupportedOverride = true; + + final List filtered = await deviceManager.findTargetDevices(FlutterProject.current()); + + expect(filtered, [ + unsupported, + ]); + }); }); } @@ -123,11 +137,20 @@ class TestDeviceManager extends DeviceManager { TestDeviceManager(this.allDevices); final List allDevices; + bool isAlwaysSupportedOverride; @override Stream getAllConnectedDevices() { return Stream.fromIterable(allDevices); } + + @override + bool isDeviceSupportedForProject(Device device, FlutterProject flutterProject) { + if (isAlwaysSupportedOverride != null) { + return isAlwaysSupportedOverride; + } + return super.isDeviceSupportedForProject(device, flutterProject); + } } class _MockDevice extends Device {