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