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
53e04de6
Unverified
Commit
53e04de6
authored
Oct 30, 2021
by
Jenn Magder
Committed by
GitHub
Oct 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate mdns_discovery and ios simulator to null safety (#92124)
parent
b0810bc9
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
214 additions
and
208 deletions
+214
-208
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+1
-1
globals.dart
packages/flutter_tools/lib/src/globals.dart
+0
-2
globals_null_migrated.dart
packages/flutter_tools/lib/src/globals_null_migrated.dart
+2
-0
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+110
-134
mdns_discovery.dart
packages/flutter_tools/lib/src/mdns_discovery.dart
+23
-22
sksl_writer.dart
packages/flutter_tools/lib/src/sksl_writer.dart
+3
-5
simulators_test.dart
...flutter_tools/test/general.shard/ios/simulators_test.dart
+61
-28
mdns_discovery_test.dart
...flutter_tools/test/general.shard/mdns_discovery_test.dart
+14
-16
No files found.
packages/flutter_tools/lib/src/context_runner.dart
View file @
53e04de6
...
...
@@ -44,7 +44,7 @@ import 'flutter_features.dart';
import
'fuchsia/fuchsia_device.dart'
show
FuchsiaDeviceTools
;
import
'fuchsia/fuchsia_sdk.dart'
show
FuchsiaSdk
,
FuchsiaArtifacts
;
import
'fuchsia/fuchsia_workflow.dart'
show
FuchsiaWorkflow
,
fuchsiaWorkflow
;
import
'globals.dart'
as
globals
;
import
'globals
_null_migrated
.dart'
as
globals
;
import
'ios/ios_workflow.dart'
;
import
'ios/iproxy.dart'
;
import
'ios/simulators.dart'
;
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
53e04de6
...
...
@@ -6,9 +6,7 @@
import
'base/context.dart'
;
import
'doctor.dart'
;
import
'ios/simulators.dart'
;
export
'globals_null_migrated.dart'
;
Doctor
get
doctor
=>
context
.
get
<
Doctor
>();
IOSSimulatorUtils
get
iosSimulatorUtils
=>
context
.
get
<
IOSSimulatorUtils
>();
packages/flutter_tools/lib/src/globals_null_migrated.dart
View file @
53e04de6
...
...
@@ -31,6 +31,7 @@ import 'device.dart';
import
'fuchsia/fuchsia_sdk.dart'
;
import
'ios/ios_workflow.dart'
;
import
'ios/plist_parser.dart'
;
import
'ios/simulators.dart'
;
import
'ios/xcodeproj.dart'
;
import
'macos/cocoapods.dart'
;
import
'macos/cocoapods_validator.dart'
;
...
...
@@ -54,6 +55,7 @@ Config get config => context.get<Config>()!;
CrashReporter
?
get
crashReporter
=>
context
.
get
<
CrashReporter
>();
DeviceManager
?
get
deviceManager
=>
context
.
get
<
DeviceManager
>();
HttpClientFactory
?
get
httpClientFactory
=>
context
.
get
<
HttpClientFactory
>();
IOSSimulatorUtils
?
get
iosSimulatorUtils
=>
context
.
get
<
IOSSimulatorUtils
>();
Logger
get
logger
=>
context
.
get
<
Logger
>()!;
OperatingSystemUtils
get
os
=>
context
.
get
<
OperatingSystemUtils
>()!;
Signals
get
signals
=>
context
.
get
<
Signals
>()
??
LocalSignals
.
instance
;
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
53e04de6
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/mdns_discovery.dart
View file @
53e04de6
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'package:multicast_dns/multicast_dns.dart'
;
...
...
@@ -24,9 +22,9 @@ class MDnsObservatoryDiscovery {
/// automatically select which application to use if multiple are advertising
/// Dart observatory ports.
MDnsObservatoryDiscovery
({
MDnsClient
mdnsClient
,
@
required
Logger
logger
,
@
required
Usage
flutterUsage
,
MDnsClient
?
mdnsClient
,
required
Logger
logger
,
required
Usage
flutterUsage
,
}):
_client
=
mdnsClient
??
MDnsClient
(),
_logger
=
logger
,
_flutterUsage
=
flutterUsage
;
...
...
@@ -38,7 +36,7 @@ class MDnsObservatoryDiscovery {
@visibleForTesting
static
const
String
dartObservatoryName
=
'_dartobservatory._tcp.local'
;
static
MDnsObservatoryDiscovery
get
instance
=>
context
.
get
<
MDnsObservatoryDiscovery
>();
static
MDnsObservatoryDiscovery
?
get
instance
=>
context
.
get
<
MDnsObservatoryDiscovery
>();
/// Executes an mDNS query for a Dart Observatory.
///
...
...
@@ -59,7 +57,7 @@ class MDnsObservatoryDiscovery {
/// it will return that instance's information regardless of what application
/// the Observatory instance is for.
@visibleForTesting
Future
<
MDnsObservatoryDiscoveryResult
>
query
({
String
applicationId
,
int
deviceVmservicePort
})
async
{
Future
<
MDnsObservatoryDiscoveryResult
?>
query
({
String
?
applicationId
,
int
?
deviceVmservicePort
})
async
{
_logger
.
printTrace
(
'Checking for advertised Dart observatories...'
);
try
{
await
_client
.
start
();
...
...
@@ -78,7 +76,7 @@ class MDnsObservatoryDiscovery {
.
map
<
String
>((
PtrResourceRecord
record
)
=>
record
.
domainName
)
.
toSet
();
String
domainName
;
String
?
domainName
;
if
(
applicationId
!=
null
)
{
for
(
final
String
name
in
uniqueDomainNames
)
{
if
(
name
.
toLowerCase
().
startsWith
(
applicationId
.
toLowerCase
()))
{
...
...
@@ -93,7 +91,7 @@ class MDnsObservatoryDiscovery {
final
StringBuffer
buffer
=
StringBuffer
();
buffer
.
writeln
(
'There are multiple observatory ports available.'
);
buffer
.
writeln
(
'Rerun this command with one of the following passed in as the appId:'
);
buffer
.
writeln
(
''
);
buffer
.
writeln
();
for
(
final
String
uniqueDomainName
in
uniqueDomainNames
)
{
buffer
.
writeln
(
' flutter attach --app-id
${uniqueDomainName.replaceAll('.$dartObservatoryName', '')}
'
);
}
...
...
@@ -120,15 +118,18 @@ class MDnsObservatoryDiscovery {
.
lookup
<
TxtResourceRecord
>(
ResourceRecordQuery
.
text
(
domainName
),
)
?
.
toList
();
.
toList
();
if
(
txt
==
null
||
txt
.
isEmpty
)
{
return
MDnsObservatoryDiscoveryResult
(
srv
.
first
.
port
,
''
);
}
const
String
authCodePrefix
=
'authCode='
;
final
String
raw
=
txt
.
first
.
text
.
split
(
'
\n
'
).
firstWhere
(
(
String
s
)
=>
s
.
startsWith
(
authCodePrefix
),
orElse:
()
=>
null
,
);
String
?
raw
;
for
(
final
String
record
in
txt
.
first
.
text
.
split
(
'
\n
'
))
{
if
(
record
.
startsWith
(
authCodePrefix
))
{
raw
=
record
;
break
;
}
}
if
(
raw
==
null
)
{
return
MDnsObservatoryDiscoveryResult
(
srv
.
first
.
port
,
''
);
}
...
...
@@ -144,12 +145,12 @@ class MDnsObservatoryDiscovery {
}
}
Future
<
Uri
>
getObservatoryUri
(
String
applicationId
,
Device
device
,
{
Future
<
Uri
?
>
getObservatoryUri
(
String
applicationId
,
Device
device
,
{
bool
usesIpv6
=
false
,
int
hostVmservicePort
,
int
deviceVmservicePort
,
int
?
hostVmservicePort
,
int
?
deviceVmservicePort
,
})
async
{
final
MDnsObservatoryDiscoveryResult
result
=
await
query
(
final
MDnsObservatoryDiscoveryResult
?
result
=
await
query
(
applicationId:
applicationId
,
deviceVmservicePort:
deviceVmservicePort
,
);
...
...
@@ -246,8 +247,8 @@ Future<Uri> buildObservatoryUri(
Device
device
,
String
host
,
int
devicePort
,
[
int
hostVmservicePort
,
String
authCode
,
int
?
hostVmservicePort
,
String
?
authCode
,
])
async
{
String
path
=
'/'
;
if
(
authCode
!=
null
)
{
...
...
@@ -259,8 +260,8 @@ Future<Uri> buildObservatoryUri(
path
+=
'/'
;
}
hostVmservicePort
??=
0
;
final
int
actualHostPort
=
hostVmservicePort
==
0
?
await
device
.
portForwarder
.
forward
(
devicePort
)
:
final
int
?
actualHostPort
=
hostVmservicePort
==
0
?
await
device
.
portForwarder
?
.
forward
(
devicePort
)
:
hostVmservicePort
;
return
Uri
(
scheme:
'http'
,
host:
host
,
port:
actualHostPort
,
path:
path
);
}
packages/flutter_tools/lib/src/sksl_writer.dart
View file @
53e04de6
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'package:file/file.dart'
;
...
...
@@ -15,9 +13,9 @@ import 'convert.dart';
import
'device.dart'
;
import
'globals_null_migrated.dart'
as
globals
;
Future
<
String
>
sharedSkSlWriter
(
Device
device
,
Map
<
String
,
Object
>
data
,
{
File
outputFile
,
Logger
logger
,
Future
<
String
?
>
sharedSkSlWriter
(
Device
device
,
Map
<
String
,
Object
>
data
,
{
File
?
outputFile
,
Logger
?
logger
,
})
async
{
logger
??=
globals
.
logger
;
if
(
data
.
isEmpty
)
{
...
...
packages/flutter_tools/test/general.shard/ios/simulators_test.dart
View file @
53e04de6
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/mdns_discovery_test.dart
View file @
53e04de6
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
...
...
@@ -24,9 +22,9 @@ void main() {
setUp
(()
{
setNetworkInterfaceLister
(
({
bool
includeLoopback
,
bool
includeLinkLocal
,
InternetAddressType
type
,
bool
?
includeLoopback
,
bool
?
includeLinkLocal
,
InternetAddressType
?
type
,
})
async
=>
<
NetworkInterface
>[],
);
});
...
...
@@ -44,7 +42,7 @@ void main() {
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
);
final
int
port
=
(
await
portDiscovery
.
query
())?.
port
;
final
int
?
port
=
(
await
portDiscovery
.
query
())?.
port
;
expect
(
port
,
isNull
);
});
...
...
@@ -56,7 +54,7 @@ void main() {
logger:
logger
,
flutterUsage:
TestUsage
(),
);
final
Uri
uri
=
await
portDiscovery
.
getObservatoryUri
(
final
Uri
?
uri
=
await
portDiscovery
.
getObservatoryUri
(
''
,
FakeIOSDevice
(),
);
...
...
@@ -81,7 +79,7 @@ void main() {
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
);
final
int
port
=
(
await
portDiscovery
.
query
())?.
port
;
final
int
?
port
=
(
await
portDiscovery
.
query
())?.
port
;
expect
(
port
,
123
);
});
...
...
@@ -107,7 +105,7 @@ void main() {
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
);
final
MDnsObservatoryDiscoveryResult
result
=
await
portDiscovery
.
query
();
final
MDnsObservatoryDiscoveryResult
?
result
=
await
portDiscovery
.
query
();
expect
(
result
?.
port
,
123
);
expect
(
result
?.
authCode
,
'xyz/'
);
});
...
...
@@ -157,7 +155,7 @@ void main() {
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
);
final
int
port
=
(
await
portDiscovery
.
query
(
applicationId:
'fiz'
))?.
port
;
final
int
?
port
=
(
await
portDiscovery
.
query
(
applicationId:
'fiz'
))?.
port
;
expect
(
port
,
321
);
});
...
...
@@ -184,7 +182,7 @@ void main() {
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
);
final
int
port
=
(
await
portDiscovery
.
query
(
applicationId:
'bar'
))?.
port
;
final
int
?
port
=
(
await
portDiscovery
.
query
(
applicationId:
'bar'
))?.
port
;
expect
(
port
,
1234
);
});
...
...
@@ -199,7 +197,7 @@ void main() {
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
);
final
int
port
=
(
await
portDiscovery
.
query
(
applicationId:
'bar'
))?.
port
;
final
int
?
port
=
(
await
portDiscovery
.
query
(
applicationId:
'bar'
))?.
port
;
expect
(
port
,
isNull
);
});
...
...
@@ -236,7 +234,7 @@ void main() {
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
);
final
Uri
uri
=
await
portDiscovery
.
getObservatoryUri
(
'bar'
,
device
,
hostVmservicePort:
0
);
final
Uri
?
uri
=
await
portDiscovery
.
getObservatoryUri
(
'bar'
,
device
,
hostVmservicePort:
0
);
expect
(
uri
.
toString
(),
'http://127.0.0.1:123/'
);
});
});
...
...
@@ -255,10 +253,10 @@ class FakeMDnsClient extends Fake implements MDnsClient {
@override
Future
<
void
>
start
({
InternetAddress
listenAddress
,
NetworkInterfacesFactory
interfacesFactory
,
InternetAddress
?
listenAddress
,
NetworkInterfacesFactory
?
interfacesFactory
,
int
mDnsPort
=
5353
,
InternetAddress
mDnsAddress
,
InternetAddress
?
mDnsAddress
,
})
async
{
if
(
osErrorOnStart
)
{
throw
const
OSError
(
'Operation not supported on socket'
,
102
);
...
...
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