From 771b8a41971e41086e072cbe8c74a2200acf55c9 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Sat, 11 Jan 2025 04:51:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20[tool]=20Add=20a=20wirelessly=20?= =?UTF-8?q?connected=20device=20name=20as=20`displayName`=20(#160497)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An improvement for #144634. A wirelessly connected device will displayed as `Target device 1 (wireless)` in various of places. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --- .../lib/src/android/android_device.dart | 2 +- .../lib/src/commands/attach.dart | 7 +- .../lib/src/commands/custom_devices.dart | 2 +- .../lib/src/commands/daemon.dart | 4 +- .../flutter_tools/lib/src/commands/drive.dart | 2 +- .../flutter_tools/lib/src/commands/run.dart | 7 +- .../lib/src/commands/screenshot.dart | 2 +- packages/flutter_tools/lib/src/device.dart | 10 +- .../flutter_tools/lib/src/ios/devices.dart | 6 +- .../lib/src/isolated/resident_web_runner.dart | 5 +- .../lib/src/proxied_devices/devices.dart | 2 +- .../lib/src/resident_devtools_handler.dart | 5 +- .../lib/src/resident_runner.dart | 21 ++- packages/flutter_tools/lib/src/run_cold.dart | 4 +- .../lib/src/runner/target_devices.dart | 12 +- .../commands.shard/hermetic/attach_test.dart | 6 + .../commands.shard/hermetic/daemon_test.dart | 3 + .../commands.shard/hermetic/doctor_test.dart | 3 + .../commands.shard/hermetic/drive_test.dart | 3 + .../hermetic/proxied_devices_test.dart | 3 + .../commands.shard/hermetic/run_test.dart | 3 + .../hermetic/screenshot_command_test.dart | 3 + .../android/adb_log_reader_test.dart | 3 + .../test/general.shard/cold_test.dart | 3 + .../ios/ios_device_start_prebuilt_test.dart | 6 + .../resident_runner_helpers.dart | 3 + .../resident_web_runner_cold_test.dart | 3 + .../resident_web_runner_test.dart | 3 + .../runner/target_devices_test.dart | 154 ++++++++++-------- .../general.shard/terminal_handler_test.dart | 3 + .../flutter_tools/test/src/fake_devices.dart | 3 + 31 files changed, 198 insertions(+), 98 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index b48f05d5ba..694e1953ef 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -1085,7 +1085,7 @@ class AdbLogReader extends DeviceLogReader { ]); } final Process process = await processManager.start(device.adbCommandForDevice(args)); - return AdbLogReader._(process, device.name, logger); + return AdbLogReader._(process, device.displayName, logger); } int? _appPid; diff --git a/packages/flutter_tools/lib/src/commands/attach.dart b/packages/flutter_tools/lib/src/commands/attach.dart index 8a7f539782..1a63d65c15 100644 --- a/packages/flutter_tools/lib/src/commands/attach.dart +++ b/packages/flutter_tools/lib/src/commands/attach.dart @@ -310,7 +310,7 @@ known, it can be explicitly provided to attach via the command-line, e.g. logger: _logger, ); - _logger.printStatus('Waiting for a connection from Flutter on ${device.name}...'); + _logger.printStatus('Waiting for a connection from Flutter on ${device.displayName}...'); final Status discoveryStatus = _logger.startSpinner( timeout: const Duration(seconds: 30), slowWarningCallback: () { @@ -421,7 +421,10 @@ known, it can be explicitly provided to attach via the command-line, e.g. if (runner.exited || !runner.isWaitingForVmService) { break; } - _logger.printStatus('Waiting for a new connection from Flutter on ${device.name}...'); + _logger.printStatus( + 'Waiting for a new connection from Flutter on ' + '${device.displayName}...', + ); } } on RPCError catch (err) { if (err.code == RPCErrorKind.kServiceDisappeared.code || diff --git a/packages/flutter_tools/lib/src/commands/custom_devices.dart b/packages/flutter_tools/lib/src/commands/custom_devices.dart index 175d600d7c..a11500f486 100644 --- a/packages/flutter_tools/lib/src/commands/custom_devices.dart +++ b/packages/flutter_tools/lib/src/commands/custom_devices.dart @@ -434,7 +434,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { if (config.usesPortForwarding) { final CustomDevicePortForwarder portForwarder = CustomDevicePortForwarder( - deviceName: device.name, + deviceName: device.displayName, forwardPortCommand: config.forwardPortCommand!, forwardPortSuccessRegex: config.forwardPortSuccessRegex!, processManager: _processManager, diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index a39ae6b5ba..fbcf6a7f30 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -681,7 +681,7 @@ class AppDomain extends Domain { if (!await device.supportsRuntimeMode(options.buildInfo.mode)) { throw Exception( '${sentenceCase(options.buildInfo.friendlyModeName)} ' - 'mode is not supported for ${device.name}.', + 'mode is not supported for ${device.displayName}.', ); } @@ -1388,7 +1388,7 @@ class DevToolsDomain extends Domain { Future> _deviceToMap(Device device) async { return { 'id': device.id, - 'name': device.name, + 'name': device.displayName, 'platform': getNameForTargetPlatform(await device.targetPlatform), 'emulator': await device.isLocalEmulator, 'category': device.category?.toString(), diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart index 956ee2e99c..8b969cad90 100644 --- a/packages/flutter_tools/lib/src/commands/drive.dart +++ b/packages/flutter_tools/lib/src/commands/drive.dart @@ -285,7 +285,7 @@ class DriveCommand extends RunCommandBase { throwToolExit(null); } if (screenshot != null && !device.supportsScreenshot) { - _logger.printError('Screenshot not supported for ${device.name}.'); + _logger.printError('Screenshot not supported for ${device.displayName}.'); } final bool web = device is WebServerDevice || device is ChromiumDevice; diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index 5bac0d98d8..5677bd2c47 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -856,12 +856,15 @@ class RunCommand extends RunCommandBase { if (!await device.supportsRuntimeMode(buildMode)) { throwToolExit( '${sentenceCase(getFriendlyModeName(buildMode))} ' - 'mode is not supported by ${device.name}.', + 'mode is not supported by ${device.displayName}.', ); } if (hotMode) { if (!device.supportsHotReload) { - throwToolExit('Hot reload is not supported by ${device.name}. Run with "--no-hot".'); + throwToolExit( + 'Hot reload is not supported by ${device.displayName}. ' + 'Run with "--no-hot".', + ); } } } diff --git a/packages/flutter_tools/lib/src/commands/screenshot.dart b/packages/flutter_tools/lib/src/commands/screenshot.dart index 2879fa43de..441338e748 100644 --- a/packages/flutter_tools/lib/src/commands/screenshot.dart +++ b/packages/flutter_tools/lib/src/commands/screenshot.dart @@ -85,7 +85,7 @@ class ScreenshotCommand extends FlutterCommand { throwToolExit('Must have a connected device for screenshot type $screenshotType'); } if (!device!.supportsScreenshot) { - throwToolExit('Screenshot not supported for ${device!.name}.'); + throwToolExit('Screenshot not supported for ${device!.displayName}.'); } default: if (vmServiceUrl == null) { diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index 0a5052a831..a1afbda16a 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -609,6 +609,14 @@ abstract class Device { String get name; + String get displayName { + String result = name; + if (isWirelesslyConnected) { + result += ' (wireless)'; + } + return result; + } + bool get supportsStartPaused => true; /// Whether it is an emulated device running on localhost. @@ -813,7 +821,7 @@ abstract class Device { supportIndicator += ' ($type)'; } table.add([ - '${device.name} (${device.category})', + '${device.displayName} (${device.category})', device.id, await device.targetPlatformDisplayName, '${await device.sdkNameAndVersion}$supportIndicator', diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart index 7ee363f18d..58415c06b3 100644 --- a/packages/flutter_tools/lib/src/ios/devices.dart +++ b/packages/flutter_tools/lib/src/ios/devices.dart @@ -572,6 +572,10 @@ class IOSDevice extends Device { // If debugging with a wireless device and the timeout is reached, remind the // user to allow local network permissions. if (isWirelesslyConnected) { + _logger.printError( + '\nYour debugging device seems wirelessly connected. ' + 'Consider plugging it in and trying again.', + ); _logger.printError( '\nClick "Allow" to the prompt asking if you would like to find and connect devices on your local network. ' 'This is required for wireless debugging. If you selected "Don\'t Allow", ' @@ -1148,7 +1152,7 @@ class IOSDeviceLogReader extends DeviceLogReader { iMobileDevice, device.majorSdkVersion, device.id, - device.name, + device.displayName, device.isWirelesslyConnected, device.isCoreDevice, appName, diff --git a/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart b/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart index f7d1288499..6d8371531b 100644 --- a/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart @@ -255,7 +255,7 @@ class ResidentWebRunner extends ResidentRunner { final String modeName = debuggingOptions.buildInfo.friendlyModeName; _logger.printStatus( 'Launching ${getDisplayPath(target, _fileSystem)} ' - 'on ${device!.device!.name} in $modeName mode...', + 'on ${device!.device!.displayName} in $modeName mode...', ); if (device!.device is ChromiumDevice) { _chromiumLauncher = (device!.device! as ChromiumDevice).chromeLauncher; @@ -578,7 +578,8 @@ Please provide a valid TCP port (an integer between 0 and 65535, inclusive). packageConfig: device!.devFS!.lastPackageConfig ?? debuggingOptions.buildInfo.packageConfig, ); final Status devFSStatus = _logger.startProgress( - 'Waiting for connection from debug service on ${device!.device!.name}...', + 'Waiting for connection from debug service on ' + '${device!.device!.displayName}...', ); final UpdateFSReport report = await device!.devFS!.update( mainUri: await _generateEntrypoint( diff --git a/packages/flutter_tools/lib/src/proxied_devices/devices.dart b/packages/flutter_tools/lib/src/proxied_devices/devices.dart index f5083a60a3..591a1a33fd 100644 --- a/packages/flutter_tools/lib/src/proxied_devices/devices.dart +++ b/packages/flutter_tools/lib/src/proxied_devices/devices.dart @@ -505,7 +505,7 @@ class _ProxiedLogReader extends DeviceLogReader { final PrebuiltApplicationPackage? applicationPackage; @override - String get name => device.name; + String get name => device.displayName; final StreamController _logLinesStreamController = StreamController(); Stream? _logLines; diff --git a/packages/flutter_tools/lib/src/resident_devtools_handler.dart b/packages/flutter_tools/lib/src/resident_devtools_handler.dart index 1bc222b314..32f6968433 100644 --- a/packages/flutter_tools/lib/src/resident_devtools_handler.dart +++ b/packages/flutter_tools/lib/src/resident_devtools_handler.dart @@ -184,7 +184,10 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler { queryParameters: {'uri': '${device!.vmService!.httpAddress}'}, ) .toString(); - _logger.printStatus('Launching Flutter DevTools for ${device.device!.name} at $devToolsUrl'); + _logger.printStatus( + 'Launching Flutter DevTools for ' + '${device.device!.displayName} at $devToolsUrl', + ); unawaited(Chrome.start([devToolsUrl])); } launchedInBrowser = true; diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index a89bc5d3c4..77985714a8 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -436,7 +436,7 @@ class FlutterDevice { final String modeName = hotRunner.debuggingOptions.buildInfo.friendlyModeName; globals.printStatus( 'Launching ${getDisplayPath(hotRunner.mainPath, globals.fs)} ' - 'on ${device!.name} in $modeName mode...', + 'on ${device!.displayName} in $modeName mode...', ); final TargetPlatform targetPlatform = await device!.targetPlatform; @@ -476,7 +476,7 @@ class FlutterDevice { final LaunchResult result = await futureResult; if (!result.started) { - globals.printError('Error launching application on ${device!.name}.'); + globals.printError('Error launching application on ${device!.displayName}.'); await stopEchoingDeviceLog(); return 2; } @@ -513,7 +513,7 @@ class FlutterDevice { final bool prebuiltMode = coldRunner.applicationBinary != null; globals.printStatus( 'Launching ${getDisplayPath(coldRunner.mainPath, globals.fs)} ' - 'on ${device!.name} in $modeName mode...', + 'on ${device!.displayName} in $modeName mode...', ); final Map platformArgs = {}; @@ -532,7 +532,7 @@ class FlutterDevice { ); if (!result.started) { - globals.printError('Error running application on ${device!.name}.'); + globals.printError('Error running application on ${device!.displayName}.'); await stopEchoingDeviceLog(); return 2; } @@ -557,7 +557,7 @@ class FlutterDevice { required PackageConfig packageConfig, }) async { final Status devFSStatus = globals.logger.startProgress( - 'Syncing files to device ${device!.name}...', + 'Syncing files to device ${device!.displayName}...', progressId: 'devFS.update', ); UpdateFSReport report; @@ -922,7 +922,9 @@ abstract class ResidentHandlers { if (!device.device!.supportsScreenshot && !supportsServiceProtocol) { return; } - final Status status = logger.startProgress('Taking screenshot for ${device.device!.name}...'); + final Status status = logger.startProgress( + 'Taking screenshot for ${device.device!.displayName}...', + ); final File outputFile = getUniqueFile(fileSystem!.currentDirectory, 'flutter', 'png'); try { @@ -1456,8 +1458,8 @@ abstract class ResidentRunner extends ResidentHandlers { if (includeVmService) { // Caution: This log line is parsed by device lab tests. globals.printStatus( - 'A Dart VM Service on ${device.device!.name} is available at: ' - '${device.vmService!.httpAddress}', + 'A Dart VM Service on ${device.device!.displayName} ' + 'is available at: ${device.vmService!.httpAddress}', ); } if (includeDevtools) { @@ -1473,7 +1475,8 @@ abstract class ResidentRunner extends ResidentHandlers { if (uri != null) { globals.printStatus( 'The Flutter DevTools debugger and profiler ' - 'on ${device.device!.name} is available at: ${urlToDisplayString(uri)}', + 'on ${device.device!.displayName} ' + 'is available at: ${urlToDisplayString(uri)}', ); } } diff --git a/packages/flutter_tools/lib/src/run_cold.dart b/packages/flutter_tools/lib/src/run_cold.dart index 40a49cc6e8..55572904e8 100644 --- a/packages/flutter_tools/lib/src/run_cold.dart +++ b/packages/flutter_tools/lib/src/run_cold.dart @@ -104,14 +104,14 @@ class ColdRunner extends ResidentRunner { if (device!.vmService == null) { continue; } - globals.printTrace('Connected to ${device.device!.name}'); + globals.printTrace('Connected to ${device.device!.displayName}'); } if (traceStartup) { // Only trace startup for the first device. final FlutterDevice device = flutterDevices.first; if (device.vmService != null) { - globals.printStatus('Tracing startup on ${device.device!.name}.'); + globals.printStatus('Tracing startup on ${device.device!.displayName}.'); final String outputPath = globals.platform.environment[kFlutterTestOutputsDirEnvName] ?? getBuildDirectory(); await downloadStartupTrace( diff --git a/packages/flutter_tools/lib/src/runner/target_devices.dart b/packages/flutter_tools/lib/src/runner/target_devices.dart index 13b4aa673f..ce200cd5f3 100644 --- a/packages/flutter_tools/lib/src/runner/target_devices.dart +++ b/packages/flutter_tools/lib/src/runner/target_devices.dart @@ -352,7 +352,7 @@ class TargetDevices { void _displayDeviceOptions(List devices) { int count = 1; for (final Device device in devices) { - _logger.printStatus(_chooseDeviceOptionMessage(count, device.name, device.id)); + _logger.printStatus(_chooseDeviceOptionMessage(count, device.displayName, device.id)); count++; } } @@ -416,7 +416,7 @@ class TargetDevicesWithExtendedWirelessDeviceDiscovery extends TargetDevices { Future _waitForIOSDeviceToConnect(IOSDevice device) async { for (final DeviceDiscovery discoverer in _deviceManager.deviceDiscoverers) { if (discoverer is IOSDevices) { - _logger.printStatus('Waiting for ${device.name} to connect...'); + _logger.printStatus('Waiting for ${device.displayName} to connect...'); final Status waitingStatus = _logger.startSpinner( timeout: const Duration(seconds: 30), warningColor: TerminalColor.red, @@ -494,13 +494,13 @@ class TargetDevicesWithExtendedWirelessDeviceDiscovery extends TargetDevices { if (matchedDevice is IOSDevice) { // If the only matching device is not paired, print a warning if (!matchedDevice.isPaired) { - _logger.printStatus(flutterSpecifiedDeviceUnpaired(matchedDevice.name)); + _logger.printStatus(flutterSpecifiedDeviceUnpaired(matchedDevice.displayName)); return null; } // If the only matching device does not have Developer Mode enabled, // print a warning if (!matchedDevice.devModeEnabled) { - _logger.printStatus(flutterSpecifiedDeviceDevModeDisabled(matchedDevice.name)); + _logger.printStatus(flutterSpecifiedDeviceDevModeDisabled(matchedDevice.displayName)); return null; } @@ -516,12 +516,12 @@ class TargetDevicesWithExtendedWirelessDeviceDiscovery extends TargetDevices { for (final IOSDevice device in specifiedDevices.whereType()) { // Print warning for every matching unpaired device. if (!device.isPaired) { - _logger.printStatus(flutterSpecifiedDeviceUnpaired(device.name)); + _logger.printStatus(flutterSpecifiedDeviceUnpaired(device.displayName)); } // Print warning for every matching device that does not have Developer Mode enabled. if (!device.devModeEnabled) { - _logger.printStatus(flutterSpecifiedDeviceDevModeDisabled(device.name)); + _logger.printStatus(flutterSpecifiedDeviceDevModeDisabled(device.displayName)); } } } diff --git a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart index f08b4e809c..184642b8d0 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart @@ -1742,6 +1742,9 @@ class FakeAndroidDevice extends Fake implements AndroidDevice { @override String get name => 'd$id'; + @override + String get displayName => name; + @override Future get isLocalEmulator async => false; @@ -1857,6 +1860,9 @@ class FakeIOSDevice extends Fake implements IOSDevice { @override final String name = 'name'; + @override + String get displayName => name; + @override Future get targetPlatform async => TargetPlatform.ios; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart index 3523a91a2e..9a9663eeea 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart @@ -1175,6 +1175,9 @@ class FakeAndroidDevice extends Fake implements AndroidDevice { @override final String name = 'android device'; + @override + String get displayName => name; + @override Future get emulatorId async => 'device'; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart index 9c387a3533..b8136a9786 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart @@ -1526,6 +1526,9 @@ class FakeDevice extends Fake implements Device { @override String get name => 'name'; + @override + String get displayName => name; + @override String get id => 'device-id'; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart index 500315332b..95dd5a7a2e 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart @@ -618,6 +618,9 @@ class ScreenshotDevice extends Fake implements Device { @override final String name = 'FakeDevice'; + @override + String get displayName => name; + @override final Category category = Category.mobile; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/proxied_devices_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/proxied_devices_test.dart index 1fb31566f0..3bba6eef2c 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/proxied_devices_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/proxied_devices_test.dart @@ -263,6 +263,9 @@ class FakeAndroidDevice extends Fake implements AndroidDevice { @override final String name = 'device'; + @override + String get displayName => name; + @override Future get emulatorId async => 'device'; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart index d53d844f44..bf339a0a87 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart @@ -1632,6 +1632,9 @@ class FakeDevice extends Fake implements Device { @override String get name => 'FakeDevice'; + @override + String get displayName => name; + @override Future get targetPlatform async => _targetPlatform; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart index 1655acc4ac..a5a072eeb9 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/screenshot_command_test.dart @@ -207,6 +207,9 @@ class _ScreenshotDevice extends Fake implements Device { @override final String name; + @override + String get displayName => name; + @override final String id; diff --git a/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart b/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart index a00ff36bd7..b274449e49 100644 --- a/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart +++ b/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart @@ -248,6 +248,9 @@ class FakeAndroidDevice extends Fake implements AndroidDevice { @override String get name => 'test-device'; + @override + String get displayName => name; + @override Future get apiVersion => Future.value(_apiVersion); diff --git a/packages/flutter_tools/test/general.shard/cold_test.dart b/packages/flutter_tools/test/general.shard/cold_test.dart index 57e3477f43..0b0b75c9d9 100644 --- a/packages/flutter_tools/test/general.shard/cold_test.dart +++ b/packages/flutter_tools/test/general.shard/cold_test.dart @@ -209,6 +209,9 @@ class FakeDevice extends Fake implements Device { @override String get name => 'test'; + @override + String get displayName => name; + @override Future get targetPlatform async => TargetPlatform.tester; diff --git a/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart b/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart index 7998cdb52f..36eb6666f8 100644 --- a/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart @@ -362,6 +362,12 @@ void main() { 'The Dart VM Service was not discovered after 45 seconds. This is taking much longer than expected...', ), ); + expect( + logger.errorText, + contains( + 'Your debugging device seems wirelessly connected. Consider plugging it in and trying again.', + ), + ); expect( logger.errorText, contains( diff --git a/packages/flutter_tools/test/general.shard/resident_runner_helpers.dart b/packages/flutter_tools/test/general.shard/resident_runner_helpers.dart index bca5f86e53..3062386a53 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_helpers.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_helpers.dart @@ -396,6 +396,9 @@ class FakeDevice extends Fake implements Device { @override String get name => 'FakeDevice'; + @override + String get displayName => name; + @override late DartDevelopmentService dds = FakeDartDevelopmentService(); diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart index 4731adb7b3..681ed97b64 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart @@ -237,6 +237,9 @@ class FakeWebDevice extends Fake implements Device { @override String get name => 'web'; + @override + String get displayName => name; + @override Future stopApp(ApplicationPackage? app, {String? userIdentifier}) async { return true; diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart index f30b02ae76..3befdcfd35 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart @@ -1584,6 +1584,9 @@ class FakeDevice extends Fake implements Device { @override String name = 'FakeDevice'; + @override + String get displayName => name; + int count = 0; @override diff --git a/packages/flutter_tools/test/general.shard/runner/target_devices_test.dart b/packages/flutter_tools/test/general.shard/runner/target_devices_test.dart index 50f7763c4b..66de89b756 100644 --- a/packages/flutter_tools/test/general.shard/runner/target_devices_test.dart +++ b/packages/flutter_tools/test/general.shard/runner/target_devices_test.dart @@ -330,8 +330,8 @@ No supported devices found with name or id matching 'target-device'. No supported devices found with name or id matching 'target-device'. The following devices were found: -no-match-1 (mobile) • xxx • android • Android 10 -no-match-2 (mobile) • xxx • android • Android 10 +no-match-1 (mobile) • xxx • android • Android 10 +no-match-2 (wireless) (mobile) • xxx • android • Android 10 '''), ); expect(devices, isNull); @@ -386,7 +386,7 @@ target-device (mobile) • xxx • android • Android 10 (unsupported) No supported devices found with name or id matching 'target-device'. The following devices were found: -not-a-match-2 (mobile) • xxx • android • Android 10 +not-a-match-2 (wireless) (mobile) • xxx • android • Android 10 '''), ); expect(devices, isNull); @@ -678,10 +678,10 @@ Connected devices: target-device-1 (mobile) • xxx • android • Android 10 Wirelessly connected devices: -target-device-5 (mobile) • xxx • android • Android 10 +target-device-5 (wireless) (mobile) • xxx • android • Android 10 [1]: target-device-1 (xxx) -[2]: target-device-5 (xxx) +[2]: target-device-5 (wireless) (xxx) '''), ); expect(devices, [wirelessAndroidDevice1]); @@ -732,11 +732,11 @@ target-device-2 (mobile) • xxx • android • Android 10 Connected devices: Wirelessly connected devices: -target-device-5 (mobile) • xxx • android • Android 10 -target-device-6 (mobile) • xxx • android • Android 10 +target-device-5 (wireless) (mobile) • xxx • android • Android 10 +target-device-6 (wireless) (mobile) • xxx • android • Android 10 -[1]: target-device-5 (xxx) -[2]: target-device-6 (xxx) +[1]: target-device-5 (wireless) (xxx) +[2]: target-device-6 (wireless) (xxx) '''), ); expect(devices, [wirelessAndroidDevice1]); @@ -776,8 +776,8 @@ target-device-1 (mobile) • xxx • android • Android 10 target-device-4 (mobile) • xxx • android • Android 10 Wirelessly connected devices: -target-device-5 (mobile) • xxx • android • Android 10 -target-device-8 (mobile) • xxx • android • Android 10 +target-device-5 (wireless) (mobile) • xxx • android • Android 10 +target-device-8 (wireless) (mobile) • xxx • android • Android 10 '''), ); expect(devices, isNull); @@ -825,8 +825,8 @@ target-device-2 (mobile) • xxx • android • Android 10 More than one device connected; please specify a device with the '-d ' flag, or use '-d all' to act on all devices. Wirelessly connected devices: -target-device-5 (mobile) • xxx • android • Android 10 -target-device-6 (mobile) • xxx • android • Android 10 +target-device-5 (wireless) (mobile) • xxx • android • Android 10 +target-device-6 (wireless) (mobile) • xxx • android • Android 10 '''), ); expect(devices, isNull); @@ -872,13 +872,13 @@ target-device-1 (mobile) • xxx • android • Android 10 target-device-4 (mobile) • xxx • android • Android 10 Wirelessly connected devices: -target-device-5 (mobile) • xxx • android • Android 10 -target-device-8 (mobile) • xxx • android • Android 10 +target-device-5 (wireless) (mobile) • xxx • android • Android 10 +target-device-8 (wireless) (mobile) • xxx • android • Android 10 [1]: target-device-1 (xxx) [2]: target-device-4 (xxx) -[3]: target-device-5 (xxx) -[4]: target-device-8 (xxx) +[3]: target-device-5 (wireless) (xxx) +[4]: target-device-8 (wireless) (xxx) '''), ); expect(devices, [attachedUnsupportedForProjectAndroidDevice]); @@ -929,11 +929,11 @@ target-device-2 (mobile) • xxx • android • Android 10 Found 2 devices with name or id matching target-device: Wirelessly connected devices: -target-device-5 (mobile) • xxx • android • Android 10 -target-device-6 (mobile) • xxx • android • Android 10 +target-device-5 (wireless) (mobile) • xxx • android • Android 10 +target-device-6 (wireless) (mobile) • xxx • android • Android 10 -[1]: target-device-5 (xxx) -[2]: target-device-6 (xxx) +[1]: target-device-5 (wireless) (xxx) +[2]: target-device-6 (wireless) (xxx) '''), ); expect(devices, [wirelessAndroidDevice1]); @@ -994,8 +994,8 @@ target-device-1 (mobile) • xxx • android • Android 10 target-device-4 (mobile) • xxx • android • Android 10 Wirelessly connected devices: -target-device-5 (mobile) • xxx • android • Android 10 -target-device-8 (mobile) • xxx • android • Android 10 +target-device-5 (wireless) (mobile) • xxx • android • Android 10 +target-device-8 (wireless) (mobile) • xxx • android • Android 10 '''), ); expect(devices, isNull); @@ -1042,8 +1042,8 @@ target-device-2 (mobile) • xxx • android • Android 10 Found 2 devices with name or id matching target-device: Wirelessly connected devices: -target-device-5 (mobile) • xxx • android • Android 10 -target-device-6 (mobile) • xxx • android • Android 10 +target-device-5 (wireless) (mobile) • xxx • android • Android 10 +target-device-6 (wireless) (mobile) • xxx • android • Android 10 '''), ); expect(devices, isNull); @@ -1308,10 +1308,10 @@ No devices found yet. Checking for wireless devices... No supported devices connected. The following devices were found, but are not supported by this project: -target-device-3 (mobile) • xxx • ios • iOS 16 (unsupported) -target-device-4 (mobile) • xxx • ios • iOS 16 -target-device-7 (mobile) • xxx • ios • iOS 16 (unsupported) -target-device-8 (mobile) • xxx • ios • iOS 16 +target-device-3 (mobile) • xxx • ios • iOS 16 (unsupported) +target-device-4 (mobile) • xxx • ios • iOS 16 +target-device-7 (wireless) (mobile) • xxx • ios • iOS 16 (unsupported) +target-device-8 (wireless) (mobile) • xxx • ios • iOS 16 If you would like your app to run on ios, consider running `flutter create .` to generate projects for these platforms. '''), ); @@ -1420,8 +1420,8 @@ No devices found yet. Checking for wireless devices... No supported devices found with name or id matching 'target-device'. The following devices were found: -no-match-1 (mobile) • xxx • ios • iOS 16 -no-match-2 (mobile) • xxx • ios • iOS 16 +no-match-1 (mobile) • xxx • ios • iOS 16 +no-match-2 (wireless) (mobile) • xxx • ios • iOS 16 '''), ); expect(devices, isNull); @@ -1592,7 +1592,7 @@ Checking for wireless devices... No supported devices found with name or id matching 'target-device'. The following devices were found: -not-a-match (mobile) • xxx • ios • iOS 16 +not-a-match (wireless) (mobile) • xxx • ios • iOS 16 '''), ); expect(devices, isNull); @@ -1652,11 +1652,11 @@ No devices found yet. Checking for wireless devices... No devices found. The following devices were found, but are not supported by this project: -target-device-10 (mobile) • xxx • fuchsia-arm64 • tester -target-device-3 (mobile) • xxx • ios • iOS 16 (unsupported) -target-device-4 (mobile) • xxx • ios • iOS 16 -target-device-7 (mobile) • xxx • ios • iOS 16 (unsupported) -target-device-8 (mobile) • xxx • ios • iOS 16 +target-device-10 (mobile) • xxx • fuchsia-arm64 • tester +target-device-3 (mobile) • xxx • ios • iOS 16 (unsupported) +target-device-4 (mobile) • xxx • ios • iOS 16 +target-device-7 (wireless) (mobile) • xxx • ios • iOS 16 (unsupported) +target-device-8 (wireless) (mobile) • xxx • ios • iOS 16 If you would like your app to run on fuchsia or ios, consider running `flutter create .` to generate projects for these platforms. '''), ); @@ -1926,7 +1926,7 @@ Checking for wireless devices... expect( logger.statusText, equals(''' -Waiting for target-device to connect... +Waiting for target-device (wireless) to connect... '''), ); expect(devices, [exactMatchWirelessDevice]); @@ -1953,7 +1953,7 @@ Waiting for target-device to connect... expect( logger.statusText, equals(''' -Waiting for target-device-1 to connect... +Waiting for target-device-1 (wireless) to connect... '''), ); expect(devices, [partialMatchWirelessDevice]); @@ -2174,11 +2174,11 @@ target-device-1 (mobile) • xxx • ios • iOS 16 target-device-2 (mobile) • xxx • ios • iOS 16 Wirelessly connected devices: -target-device-5 (mobile) • xxx • ios • iOS 16 +target-device-5 (wireless) (mobile) • xxx • ios • iOS 16 [1]: target-device-1 (xxx) [2]: target-device-2 (xxx) -[3]: target-device-5 (xxx) +[3]: target-device-5 (wireless) (xxx) Please choose one (or "q" to quit): '''), ); expect(devices, [connectedWirelessIOSDevice1]); @@ -2253,11 +2253,11 @@ No devices found yet. Checking for wireless devices... Connected devices: Wirelessly connected devices: -target-device-5 (mobile) • xxx • ios • iOS 16 -target-device-6 (mobile) • xxx • ios • iOS 16 +target-device-5 (wireless) (mobile) • xxx • ios • iOS 16 +target-device-6 (wireless) (mobile) • xxx • ios • iOS 16 -[1]: target-device-5 (xxx) -[2]: target-device-6 (xxx) +[1]: target-device-5 (wireless) (xxx) +[2]: target-device-6 (wireless) (xxx) '''), ); expect(devices, [connectedWirelessIOSDevice1]); @@ -2303,11 +2303,11 @@ target-device-1 (mobile) • xxx • ios • iOS 16 target-device-2 (mobile) • xxx • ios • iOS 16 Wirelessly connected devices: -target-device-5 (mobile) • xxx • ios • iOS 16 +target-device-5 (wireless) (mobile) • xxx • ios • iOS 16 [1]: target-device-1 (xxx) [2]: target-device-2 (xxx) -[3]: target-device-5 (xxx) +[3]: target-device-5 (wireless) (xxx) '''), ); expect(devices, [attachedIOSDevice1]); @@ -2424,11 +2424,11 @@ target-device-1 (mobile) • xxx • ios • iOS 16 target-device-2 (mobile) • xxx • ios • iOS 16 Wirelessly connected devices: -target-device-5 (mobile) • xxx • ios • iOS 16 +target-device-5 (wireless) (mobile) • xxx • ios • iOS 16 [1]: target-device-1 (xxx) [2]: target-device-2 (xxx) -[3]: target-device-5 (xxx) +[3]: target-device-5 (wireless) (xxx) Please choose one (or "q" to quit): '''), ); @@ -2490,8 +2490,8 @@ target-device-2 (mobile) • xxx • ios • iOS 16 target-device-4 (mobile) • xxx • ios • iOS 16 Wirelessly connected devices: -target-device-5 (mobile) • xxx • ios • iOS 16 -target-device-8 (mobile) • xxx • ios • iOS 16 +target-device-5 (wireless) (mobile) • xxx • ios • iOS 16 +target-device-8 (wireless) (mobile) • xxx • ios • iOS 16 '''), ); expect(devices, isNull); @@ -2547,8 +2547,8 @@ No devices found yet. Checking for wireless devices... More than one device connected; please specify a device with the '-d ' flag, or use '-d all' to act on all devices. Wirelessly connected devices: -target-device-5 (mobile) • xxx • ios • iOS 16 -target-device-6 (mobile) • xxx • ios • iOS 16 +target-device-5 (wireless) (mobile) • xxx • ios • iOS 16 +target-device-6 (wireless) (mobile) • xxx • ios • iOS 16 '''), ); expect(devices, isNull); @@ -2619,13 +2619,13 @@ target-device-1 (mobile) • xxx • ios • iOS 16 target-device-4 (mobile) • xxx • ios • iOS 16 Wirelessly connected devices: -target-device-5 (mobile) • xxx • ios • iOS 16 -target-device-8 (mobile) • xxx • ios • iOS 16 +target-device-5 (wireless) (mobile) • xxx • ios • iOS 16 +target-device-8 (wireless) (mobile) • xxx • ios • iOS 16 [1]: target-device-1 (xxx) [2]: target-device-4 (xxx) -[3]: target-device-5 (xxx) -[4]: target-device-8 (xxx) +[3]: target-device-5 (wireless) (xxx) +[4]: target-device-8 (wireless) (xxx) Please choose one (or "q" to quit): '''), ); expect(devices, [connectedWirelessIOSDevice1]); @@ -2698,11 +2698,11 @@ No devices found yet. Checking for wireless devices... Found 2 devices with name or id matching target-device: Wirelessly connected devices: -target-device-5 (mobile) • xxx • ios • iOS 16 -target-device-6 (mobile) • xxx • ios • iOS 16 +target-device-5 (wireless) (mobile) • xxx • ios • iOS 16 +target-device-6 (wireless) (mobile) • xxx • ios • iOS 16 -[1]: target-device-5 (xxx) -[2]: target-device-6 (xxx) +[1]: target-device-5 (wireless) (xxx) +[2]: target-device-6 (wireless) (xxx) '''), ); expect(devices, [connectedWirelessIOSDevice1]); @@ -2782,8 +2782,8 @@ target-device-1 (mobile) • xxx • ios • iOS 16 target-device-4 (mobile) • xxx • ios • iOS 16 Wirelessly connected devices: -target-device-5 (mobile) • xxx • ios • iOS 16 -target-device-8 (mobile) • xxx • ios • iOS 16 +target-device-5 (wireless) (mobile) • xxx • ios • iOS 16 +target-device-8 (wireless) (mobile) • xxx • ios • iOS 16 '''), ); expect(devices, isNull); @@ -2840,8 +2840,8 @@ No devices found yet. Checking for wireless devices... Found 2 devices with name or id matching target-device: Wirelessly connected devices: -target-device-5 (mobile) • xxx • ios • iOS 16 -target-device-6 (mobile) • xxx • ios • iOS 16 +target-device-5 (wireless) (mobile) • xxx • ios • iOS 16 +target-device-6 (wireless) (mobile) • xxx • ios • iOS 16 '''), ); expect(devices, isNull); @@ -3189,6 +3189,15 @@ class FakeDevice extends Fake implements Device { @override String name; + @override + String get displayName { + String result = name; + if (isWirelesslyConnected) { + result += ' (wireless)'; + } + return result; + } + @override final bool ephemeral; @@ -3204,6 +3213,9 @@ class FakeDevice extends Fake implements Device { @override DeviceConnectionInterface connectionInterface; + @override + bool get isWirelesslyConnected => connectionInterface == DeviceConnectionInterface.wireless; + @override bool isConnected; @@ -3282,6 +3294,15 @@ class FakeIOSDevice extends Fake implements IOSDevice { @override String name; + @override + String get displayName { + String result = name; + if (isWirelesslyConnected) { + result += ' (wireless)'; + } + return result; + } + @override final bool ephemeral; @@ -3303,6 +3324,9 @@ class FakeIOSDevice extends Fake implements IOSDevice { @override DeviceConnectionInterface connectionInterface; + @override + bool get isWirelesslyConnected => connectionInterface == DeviceConnectionInterface.wireless; + @override bool isConnected; diff --git a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart index 6e51f11acc..2227564591 100644 --- a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart +++ b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart @@ -1306,6 +1306,9 @@ class FakeDevice extends Fake implements Device { @override String get name => 'Fake Device'; + @override + String get displayName => name; + @override DartDevelopmentService dds = DartDevelopmentService(logger: FakeLogger()); diff --git a/packages/flutter_tools/test/src/fake_devices.dart b/packages/flutter_tools/test/src/fake_devices.dart index 7b76a18ae8..65cfa78c25 100644 --- a/packages/flutter_tools/test/src/fake_devices.dart +++ b/packages/flutter_tools/test/src/fake_devices.dart @@ -146,6 +146,9 @@ class FakeDevice extends Device { @override final String name; + @override + String get displayName => name; + @override Future startApp( ApplicationPackage? package, {