Show warning when attempting to flutter run on an ios device with developer mode turned off (#125710)
This PR adds a warning when a user attempt to `flutter run -d <device id>` on a device without developer mode enabled. <img width="738" alt="Screenshot 2023-05-09 at 3 53 18 AM" src="https://github.com/flutter/flutter/assets/36148254/6f473a6a-5a0d-438b-9e6f-06d09eb1f3a9"> Also handles multiple partial matches. <img width="788" alt="Screenshot 2023-05-09 at 3 52 24 AM" src="https://github.com/flutter/flutter/assets/36148254/60c82b3c-d501-4a01-95ad-d6309fe39576"> Fixes https://github.com/flutter/flutter/issues/111988
This commit is contained in:
@@ -29,6 +29,8 @@ String _foundSpecifiedDevicesMessage(int count, String deviceId) =>
|
||||
'Found $count devices with name or id matching $deviceId:';
|
||||
String _noMatchingDeviceMessage(String deviceId) => 'No supported devices found with name or id '
|
||||
"matching '$deviceId'.";
|
||||
String flutterSpecifiedDeviceDevModeDisabled(String deviceName) => 'To use '
|
||||
"'$deviceName' for development, enable Developer Mode in Settings → Privacy & Security.";
|
||||
|
||||
/// This class handles functionality of finding and selecting target devices.
|
||||
///
|
||||
@@ -486,18 +488,39 @@ class TargetDevicesWithExtendedWirelessDeviceDiscovery extends TargetDevices {
|
||||
// If there are multiple matches, continue on to wait for all attached
|
||||
// and wireless devices to load so the user can select between all
|
||||
// connected matches.
|
||||
final List<Device> devices = await _getDeviceById(
|
||||
final List<Device> specifiedDevices = await _getDeviceById(
|
||||
includeDevicesUnsupportedByProject: includeDevicesUnsupportedByProject,
|
||||
includeDisconnected: true,
|
||||
);
|
||||
if (devices.length == 1) {
|
||||
Device? matchedDevice = devices.first;
|
||||
|
||||
if (specifiedDevices.length == 1) {
|
||||
Device? matchedDevice = specifiedDevices.first;
|
||||
// If the only matching device does not have Developer Mode enabled,
|
||||
// print a warning
|
||||
if (matchedDevice is IOSDevice && !matchedDevice.devModeEnabled) {
|
||||
_logger.printStatus(
|
||||
flutterSpecifiedDeviceDevModeDisabled(matchedDevice.name)
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!matchedDevice.isConnected && matchedDevice is IOSDevice) {
|
||||
matchedDevice = await _waitForIOSDeviceToConnect(matchedDevice);
|
||||
}
|
||||
|
||||
if (matchedDevice != null && matchedDevice.isConnected) {
|
||||
return <Device>[matchedDevice];
|
||||
}
|
||||
|
||||
} else {
|
||||
for (final Device device in specifiedDevices) {
|
||||
// Print warning for every matching device that does not have Developer Mode enabled.
|
||||
if (device is IOSDevice && !device.devModeEnabled) {
|
||||
_logger.printStatus(
|
||||
flutterSpecifiedDeviceDevModeDisabled(device.name)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user