Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
842873c2
Unverified
Commit
842873c2
authored
Apr 04, 2023
by
Victoria Ashworth
Committed by
GitHub
Apr 04, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow --ipv6 flag for flutter attach on iOS devices (#123822)
Allow --ipv6 flag for flutter attach on iOS devices
parent
dbc18bbd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
13 deletions
+81
-13
attach.dart
packages/flutter_tools/lib/src/commands/attach.dart
+17
-5
protocol_discovery.dart
packages/flutter_tools/lib/src/protocol_discovery.dart
+5
-4
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+1
-2
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+58
-2
No files found.
packages/flutter_tools/lib/src/commands/attach.dart
View file @
842873c2
...
...
@@ -219,11 +219,19 @@ known, it can be explicitly provided to attach via the command-line, e.g.
MacOSDesignedForIPadDevices
.
allowDiscovery
=
true
;
await
super
.
validateCommand
();
if
(
await
findTargetDevice
()
==
null
)
{
final
Device
?
targetDevice
=
await
findTargetDevice
();
if
(
targetDevice
==
null
)
{
throwToolExit
(
null
);
}
debugPort
;
if
(
debugPort
==
null
&&
debugUri
==
null
&&
argResults
!.
wasParsed
(
FlutterCommand
.
ipv6Flag
))
{
// Allow --ipv6 for iOS devices even if --debug-port and --debug-url
// are unknown
if
(!
_isIOSDevice
(
targetDevice
)
&&
debugPort
==
null
&&
debugUri
==
null
&&
argResults
!.
wasParsed
(
FlutterCommand
.
ipv6Flag
))
{
throwToolExit
(
'When the --debug-port or --debug-url is unknown, this command determines '
'the value of --ipv6 on its own.'
,
...
...
@@ -311,7 +319,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
}
rethrow
;
}
}
else
if
(
(
device
is
IOSDevice
)
||
(
device
is
IOSSimulator
)
||
(
device
is
MacOSDesignedForIPadD
evice
))
{
}
else
if
(
_isIOSDevice
(
d
evice
))
{
// Protocol Discovery relies on logging. On iOS earlier than 13, logging is gathered using syslog.
// syslog is not available for iOS 13+. For iOS 13+, Protocol Discovery gathers logs from the VMService.
// Since we don't have access to the VMService yet, Protocol Discovery cannot be used for iOS 13+.
...
...
@@ -395,8 +403,6 @@ known, it can be explicitly provided to attach via the command-line, e.g.
);
_logger
.
printStatus
(
'Waiting for a connection from Flutter on
${device.name}
...'
);
vmServiceUri
=
vmServiceDiscovery
.
uris
;
// Determine ipv6 status from the scanned logs.
usesIpv6
=
vmServiceDiscovery
.
ipv6
;
}
}
else
{
vmServiceUri
=
Stream
<
Uri
>
...
...
@@ -544,6 +550,12 @@ known, it can be explicitly provided to attach via the command-line, e.g.
}
Future
<
void
>
_validateArguments
()
async
{
}
bool
_isIOSDevice
(
Device
device
)
{
return
(
device
is
IOSDevice
)
||
(
device
is
IOSSimulator
)
||
(
device
is
MacOSDesignedForIPadDevice
);
}
}
class
HotRunnerFactory
{
...
...
packages/flutter_tools/lib/src/protocol_discovery.dart
View file @
842873c2
...
...
@@ -20,9 +20,10 @@ class ProtocolDiscovery {
required
this
.
throttleDuration
,
this
.
hostPort
,
this
.
devicePort
,
required
this
.
ipv6
,
required
bool
ipv6
,
required
Logger
logger
,
})
:
_logger
=
logger
{
})
:
_logger
=
logger
,
_ipv6
=
ipv6
{
_deviceLogSubscription
=
logReader
.
logLines
.
listen
(
_handleLine
,
onDone:
_stopScrapingLogs
,
...
...
@@ -56,7 +57,7 @@ class ProtocolDiscovery {
final
DevicePortForwarder
?
portForwarder
;
final
int
?
hostPort
;
final
int
?
devicePort
;
final
bool
ipv6
;
final
bool
_
ipv6
;
final
Logger
_logger
;
/// The time to wait before forwarding a new VM Service URIs from [logReader].
...
...
@@ -144,7 +145,7 @@ class ProtocolDiscovery {
hostUri
=
deviceUri
.
replace
(
port:
actualHostPort
);
}
if
(
InternetAddress
(
hostUri
.
host
).
isLoopback
&&
ipv6
)
{
if
(
InternetAddress
(
hostUri
.
host
).
isLoopback
&&
_
ipv6
)
{
hostUri
=
hostUri
.
replace
(
host:
InternetAddress
.
loopbackIPv6
.
host
);
}
return
hostUri
;
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
842873c2
...
...
@@ -603,8 +603,7 @@ abstract class FlutterCommand extends Command<void> {
argParser
.
addFlag
(
ipv6Flag
,
negatable:
false
,
help:
'Binds to IPv6 localhost instead of IPv4 when the flutter tool '
'forwards the host port to a device port. Not used when the '
'"--debug-port" flag is not set.'
,
'forwards the host port to a device port.'
,
hide:
!
verboseHelp
,
);
_usesIpv6Flag
=
true
;
...
...
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
842873c2
...
...
@@ -591,7 +591,7 @@ void main() {
DeviceManager:
()
=>
testDeviceManager
,
});
testUsingContext
(
'exits when ipv6 is specified and debug-port is not'
,
()
async
{
testUsingContext
(
'exits when ipv6 is specified and debug-port is not
on non-iOS device
'
,
()
async
{
testDeviceManager
.
devices
=
<
Device
>[
device
];
final
AttachCommand
command
=
AttachCommand
(
...
...
@@ -615,7 +615,63 @@ void main() {
FileSystem:
()
=>
testFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
DeviceManager:
()
=>
testDeviceManager
,
},);
});
testUsingContext
(
'succeeds when ipv6 is specified and debug-port is not on iOS device'
,
()
async
{
final
FakeIOSDevice
device
=
FakeIOSDevice
(
logReader:
fakeLogReader
,
portForwarder:
portForwarder
,
majorSdkVersion:
12
,
onGetLogReader:
()
{
fakeLogReader
.
addLine
(
'Foo'
);
fakeLogReader
.
addLine
(
'The Dart VM service is listening on http://[::1]:
$devicePort
'
);
return
fakeLogReader
;
},
);
testDeviceManager
.
devices
=
<
Device
>[
device
];
final
Completer
<
void
>
completer
=
Completer
<
void
>();
final
StreamSubscription
<
String
>
loggerSubscription
=
logger
.
stream
.
listen
((
String
message
)
{
if
(
message
==
'[verbose] VM Service URL on device: http://[::1]:
$devicePort
'
)
{
// The "VM Service URL on device" message is output by the ProtocolDiscovery when it found the VM Service.
completer
.
complete
();
}
});
final
FakeHotRunner
hotRunner
=
FakeHotRunner
();
hotRunner
.
onAttach
=
(
Completer
<
DebugConnectionInfo
>?
connectionInfoCompleter
,
Completer
<
void
>?
appStartedCompleter
,
bool
allowExistingDdsInstance
,
bool
enableDevTools
,
)
async
=>
0
;
hotRunner
.
exited
=
false
;
hotRunner
.
isWaitingForVmService
=
false
;
final
FakeHotRunnerFactory
hotRunnerFactory
=
FakeHotRunnerFactory
()
..
hotRunner
=
hotRunner
;
await
createTestCommandRunner
(
AttachCommand
(
hotRunnerFactory:
hotRunnerFactory
,
artifacts:
artifacts
,
stdio:
stdio
,
logger:
logger
,
terminal:
terminal
,
signals:
signals
,
platform:
platform
,
processInfo:
processInfo
,
fileSystem:
testFileSystem
,
)).
run
(<
String
>[
'attach'
,
'--ipv6'
]);
await
completer
.
future
;
expect
(
portForwarder
.
devicePort
,
devicePort
);
expect
(
portForwarder
.
hostPort
,
hostPort
);
await
fakeLogReader
.
dispose
();
await
loggerSubscription
.
cancel
();
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
testFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Logger:
()
=>
logger
,
DeviceManager:
()
=>
testDeviceManager
,
});
testUsingContext
(
'exits when vm-service-port is specified and debug-port is not'
,
()
async
{
device
.
onGetLogReader
=
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment