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
8893e89d
Unverified
Commit
8893e89d
authored
Mar 24, 2021
by
Jenn Magder
Committed by
GitHub
Mar 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate device_port_forwarder to null safety (#78949)
parent
3c24f167
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
112 additions
and
78 deletions
+112
-78
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+1
-0
attach.dart
packages/flutter_tools/lib/src/commands/attach.dart
+1
-0
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+1
-0
desktop_device.dart
packages/flutter_tools/lib/src/desktop_device.dart
+1
-0
device.dart
packages/flutter_tools/lib/src/device.dart
+1
-55
device_port_forwader.dart
packages/flutter_tools/lib/src/device_port_forwader.dart
+61
-0
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+1
-0
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+1
-0
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+1
-0
protocol_discovery.dart
packages/flutter_tools/lib/src/protocol_discovery.dart
+1
-0
flutter_tester.dart
packages/flutter_tools/lib/src/tester/flutter_tester.dart
+1
-0
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+1
-0
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+1
-0
android_device_port_forwarder_test.dart
...ral.shard/android/android_device_port_forwarder_test.dart
+1
-1
desktop_device_test.dart
...flutter_tools/test/general.shard/desktop_device_test.dart
+1
-0
device_port_forwarder_test.dart
..._tools/test/general.shard/device_port_forwarder_test.dart
+30
-0
device_test.dart
packages/flutter_tools/test/general.shard/device_test.dart
+0
-20
fuchsia_device_test.dart
...tools/test/general.shard/fuchsia/fuchsia_device_test.dart
+1
-0
devices_test.dart
...es/flutter_tools/test/general.shard/ios/devices_test.dart
+1
-0
ios_device_start_prebuilt_test.dart
...est/general.shard/ios/ios_device_start_prebuilt_test.dart
+1
-0
simulators_test.dart
...flutter_tools/test/general.shard/ios/simulators_test.dart
+1
-0
mdns_discovery_test.dart
...flutter_tools/test/general.shard/mdns_discovery_test.dart
+1
-1
protocol_discovery_test.dart
...ter_tools/test/general.shard/protocol_discovery_test.dart
+1
-1
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+1
-0
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
8893e89d
...
...
@@ -21,6 +21,7 @@ import '../base/process.dart';
import
'../build_info.dart'
;
import
'../convert.dart'
;
import
'../device.dart'
;
import
'../device_port_forwader.dart'
;
import
'../project.dart'
;
import
'../protocol_discovery.dart'
;
...
...
packages/flutter_tools/lib/src/commands/attach.dart
View file @
8893e89d
...
...
@@ -19,6 +19,7 @@ import '../build_info.dart';
import
'../commands/daemon.dart'
;
import
'../compile.dart'
;
import
'../device.dart'
;
import
'../device_port_forwader.dart'
;
import
'../fuchsia/fuchsia_device.dart'
;
import
'../globals.dart'
as
globals
;
import
'../ios/devices.dart'
;
...
...
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
8893e89d
...
...
@@ -20,6 +20,7 @@ import '../base/utils.dart';
import
'../build_info.dart'
;
import
'../convert.dart'
;
import
'../device.dart'
;
import
'../device_port_forwader.dart'
;
import
'../emulator.dart'
;
import
'../features.dart'
;
import
'../globals.dart'
as
globals
;
...
...
packages/flutter_tools/lib/src/desktop_device.dart
View file @
8893e89d
...
...
@@ -19,6 +19,7 @@ import 'build_info.dart';
import
'convert.dart'
;
import
'devfs.dart'
;
import
'device.dart'
;
import
'device_port_forwader.dart'
;
import
'protocol_discovery.dart'
;
/// A partial implementation of Device for desktop-class devices to inherit
...
...
packages/flutter_tools/lib/src/device.dart
View file @
8893e89d
...
...
@@ -20,7 +20,6 @@ import 'base/config.dart';
import
'base/context.dart'
;
import
'base/dds.dart'
;
import
'base/file_system.dart'
;
import
'base/io.dart'
;
import
'base/logger.dart'
;
import
'base/os.dart'
;
import
'base/platform.dart'
;
...
...
@@ -29,6 +28,7 @@ import 'base/user_messages.dart' hide userMessages;
import
'base/utils.dart'
;
import
'build_info.dart'
;
import
'devfs.dart'
;
import
'device_port_forwader.dart'
;
import
'features.dart'
;
import
'fuchsia/fuchsia_device.dart'
;
import
'fuchsia/fuchsia_sdk.dart'
;
...
...
@@ -989,43 +989,6 @@ class LaunchResult {
}
}
class
ForwardedPort
{
ForwardedPort
(
this
.
hostPort
,
this
.
devicePort
)
:
context
=
null
;
ForwardedPort
.
withContext
(
this
.
hostPort
,
this
.
devicePort
,
this
.
context
);
final
int
hostPort
;
final
int
devicePort
;
final
Process
context
;
@override
String
toString
()
=>
'ForwardedPort HOST:
$hostPort
to DEVICE:
$devicePort
'
;
/// Kill subprocess (if present) used in forwarding.
void
dispose
()
{
if
(
context
!=
null
)
{
context
.
kill
();
}
}
}
/// Forward ports from the host machine to the device.
abstract
class
DevicePortForwarder
{
/// Returns a Future that completes with the current list of forwarded
/// ports for this device.
List
<
ForwardedPort
>
get
forwardedPorts
;
/// Forward [hostPort] on the host to [devicePort] on the device.
/// If [hostPort] is null or zero, will auto select a host port.
/// Returns a Future that completes with the host port.
Future
<
int
>
forward
(
int
devicePort
,
{
int
hostPort
});
/// Stops forwarding [forwardedPort].
Future
<
void
>
unforward
(
ForwardedPort
forwardedPort
);
/// Cleanup allocated resources, like [forwardedPorts].
Future
<
void
>
dispose
();
}
/// Read the log for a particular device.
abstract
class
DeviceLogReader
{
String
get
name
;
...
...
@@ -1074,23 +1037,6 @@ class NoOpDeviceLogReader implements DeviceLogReader {
void
dispose
()
{
}
}
// A port forwarder which does not support forwarding ports.
class
NoOpDevicePortForwarder
implements
DevicePortForwarder
{
const
NoOpDevicePortForwarder
();
@override
Future
<
int
>
forward
(
int
devicePort
,
{
int
hostPort
})
async
=>
devicePort
;
@override
List
<
ForwardedPort
>
get
forwardedPorts
=>
<
ForwardedPort
>[];
@override
Future
<
void
>
unforward
(
ForwardedPort
forwardedPort
)
async
{
}
@override
Future
<
void
>
dispose
()
async
{
}
}
/// Append --null_assertions to any existing Dart VM flags if
/// [debuggingOptions.nullAssertions] is true.
String
computeDartVmFlags
(
DebuggingOptions
debuggingOptions
)
{
...
...
packages/flutter_tools/lib/src/device_port_forwader.dart
0 → 100644
View file @
8893e89d
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'base/io.dart'
;
class
ForwardedPort
{
ForwardedPort
(
this
.
hostPort
,
this
.
devicePort
)
:
context
=
null
;
ForwardedPort
.
withContext
(
this
.
hostPort
,
this
.
devicePort
,
this
.
context
);
final
int
hostPort
;
final
int
devicePort
;
final
Process
?
context
;
@override
String
toString
()
=>
'ForwardedPort HOST:
$hostPort
to DEVICE:
$devicePort
'
;
/// Kill subprocess (if present) used in forwarding.
void
dispose
()
{
if
(
context
!=
null
)
{
context
!.
kill
();
}
}
}
/// Forward ports from the host machine to the device.
abstract
class
DevicePortForwarder
{
/// Returns a Future that completes with the current list of forwarded
/// ports for this device.
List
<
ForwardedPort
>
get
forwardedPorts
;
/// Forward [hostPort] on the host to [devicePort] on the device.
/// If [hostPort] is null or zero, will auto select a host port.
/// Returns a Future that completes with the host port.
Future
<
int
>
forward
(
int
devicePort
,
{
int
?
hostPort
});
/// Stops forwarding [forwardedPort].
Future
<
void
>
unforward
(
ForwardedPort
forwardedPort
);
/// Cleanup allocated resources, like [forwardedPorts].
Future
<
void
>
dispose
();
}
// A port forwarder which does not support forwarding ports.
class
NoOpDevicePortForwarder
implements
DevicePortForwarder
{
const
NoOpDevicePortForwarder
();
@override
Future
<
int
>
forward
(
int
devicePort
,
{
int
?
hostPort
})
async
=>
devicePort
;
@override
List
<
ForwardedPort
>
get
forwardedPorts
=>
<
ForwardedPort
>[];
@override
Future
<
void
>
unforward
(
ForwardedPort
forwardedPort
)
async
{
}
@override
Future
<
void
>
dispose
()
async
{
}
}
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
8893e89d
...
...
@@ -21,6 +21,7 @@ import '../base/process.dart';
import
'../base/time.dart'
;
import
'../build_info.dart'
;
import
'../device.dart'
;
import
'../device_port_forwader.dart'
;
import
'../globals.dart'
as
globals
;
import
'../project.dart'
;
import
'../vmservice.dart'
;
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
8893e89d
...
...
@@ -21,6 +21,7 @@ import '../base/utils.dart';
import
'../build_info.dart'
;
import
'../convert.dart'
;
import
'../device.dart'
;
import
'../device_port_forwader.dart'
;
import
'../globals.dart'
as
globals
;
import
'../macos/xcode.dart'
;
import
'../project.dart'
;
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
8893e89d
...
...
@@ -21,6 +21,7 @@ import '../build_info.dart';
import
'../convert.dart'
;
import
'../devfs.dart'
;
import
'../device.dart'
;
import
'../device_port_forwader.dart'
;
import
'../globals.dart'
as
globals
;
import
'../macos/xcode.dart'
;
import
'../project.dart'
;
...
...
packages/flutter_tools/lib/src/protocol_discovery.dart
View file @
8893e89d
...
...
@@ -11,6 +11,7 @@ import 'package:meta/meta.dart';
import
'base/io.dart'
;
import
'base/logger.dart'
;
import
'device.dart'
;
import
'device_port_forwader.dart'
;
import
'globals.dart'
as
globals
;
/// Discovers a specific service protocol on a device, and forwards the service
...
...
packages/flutter_tools/lib/src/tester/flutter_tester.dart
View file @
8893e89d
...
...
@@ -21,6 +21,7 @@ import '../bundle.dart';
import
'../desktop_device.dart'
;
import
'../devfs.dart'
;
import
'../device.dart'
;
import
'../device_port_forwader.dart'
;
import
'../project.dart'
;
import
'../protocol_discovery.dart'
;
import
'../version.dart'
;
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
8893e89d
...
...
@@ -16,6 +16,7 @@ import '../base/platform.dart';
import
'../base/version.dart'
;
import
'../build_info.dart'
;
import
'../device.dart'
;
import
'../device_port_forwader.dart'
;
import
'../features.dart'
;
import
'../project.dart'
;
import
'chrome.dart'
;
...
...
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
8893e89d
...
...
@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/base/terminal.dart';
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/attach.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device_port_forwader.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:flutter_tools/src/project.dart'
;
...
...
packages/flutter_tools/test/general.shard/android/android_device_port_forwarder_test.dart
View file @
8893e89d
...
...
@@ -7,7 +7,7 @@
import
'package:flutter_tools/src/android/android_device.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device
_port_forwader
.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
packages/flutter_tools/test/general.shard/desktop_device_test.dart
View file @
8893e89d
...
...
@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/build_info.dart';
import
'package:flutter_tools/src/desktop_device.dart'
;
import
'package:flutter_tools/src/devfs.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device_port_forwader.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:meta/meta.dart'
;
...
...
packages/flutter_tools/test/general.shard/device_port_forwarder_test.dart
0 → 100644
View file @
8893e89d
// Copyright 2014 The Flutter Authors. All rights reserved.
// 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/device_port_forwader.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
void
main
(
)
{
testUsingContext
(
'dispose does not throw exception if no process is present'
,
()
{
final
ForwardedPort
forwardedPort
=
ForwardedPort
(
123
,
456
);
expect
(
forwardedPort
.
context
,
isNull
);
forwardedPort
.
dispose
();
});
testUsingContext
(
'dispose kills process if process was available'
,
()
{
final
MockProcess
mockProcess
=
MockProcess
();
final
ForwardedPort
forwardedPort
=
ForwardedPort
.
withContext
(
123
,
456
,
mockProcess
);
forwardedPort
.
dispose
();
expect
(
forwardedPort
.
context
,
isNotNull
);
verify
(
mockProcess
.
kill
());
});
}
class
MockProcess
extends
Mock
implements
Process
{}
packages/flutter_tools/test/general.shard/device_test.dart
View file @
8893e89d
...
...
@@ -5,7 +5,6 @@
// @dart = 2.8
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/base/user_messages.dart'
;
...
...
@@ -481,24 +480,6 @@ void main() {
});
});
group
(
'ForwardedPort'
,
()
{
group
(
'dispose()'
,
()
{
testUsingContext
(
'does not throw exception if no process is present'
,
()
{
final
ForwardedPort
forwardedPort
=
ForwardedPort
(
123
,
456
);
expect
(
forwardedPort
.
context
,
isNull
);
forwardedPort
.
dispose
();
});
testUsingContext
(
'kills process if process was available'
,
()
{
final
MockProcess
mockProcess
=
MockProcess
();
final
ForwardedPort
forwardedPort
=
ForwardedPort
.
withContext
(
123
,
456
,
mockProcess
);
forwardedPort
.
dispose
();
expect
(
forwardedPort
.
context
,
isNotNull
);
verify
(
mockProcess
.
kill
());
});
});
});
group
(
'JSON encode devices'
,
()
{
testUsingContext
(
'Consistency of JSON representation'
,
()
async
{
expect
(
...
...
@@ -555,4 +536,3 @@ class TestDeviceManager extends DeviceManager {
class
MockTerminal
extends
Mock
implements
AnsiTerminal
{}
class
MockDeviceDiscovery
extends
Mock
implements
DeviceDiscovery
{}
class
FakeFlutterProject
extends
Fake
implements
FlutterProject
{}
class
MockProcess
extends
Mock
implements
Process
{}
packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart
View file @
8893e89d
...
...
@@ -21,6 +21,7 @@ import 'package:flutter_tools/src/base/time.dart';
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device_port_forwader.dart'
;
import
'package:flutter_tools/src/fuchsia/amber_ctl.dart'
;
import
'package:flutter_tools/src/fuchsia/application_package.dart'
;
import
'package:flutter_tools/src/fuchsia/fuchsia_dev_finder.dart'
;
...
...
packages/flutter_tools/test/general.shard/ios/devices_test.dart
View file @
8893e89d
...
...
@@ -18,6 +18,7 @@ import 'package:flutter_tools/src/base/platform.dart';
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device_port_forwader.dart'
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:flutter_tools/src/ios/ios_deploy.dart'
;
import
'package:flutter_tools/src/ios/ios_workflow.dart'
;
...
...
packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart
View file @
8893e89d
...
...
@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/base/platform.dart';
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device_port_forwader.dart'
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:flutter_tools/src/ios/ios_deploy.dart'
;
import
'package:flutter_tools/src/ios/iproxy.dart'
;
...
...
packages/flutter_tools/test/general.shard/ios/simulators_test.dart
View file @
8893e89d
...
...
@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/platform.dart';
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/devfs.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device_port_forwader.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/ios/plist_parser.dart'
;
import
'package:flutter_tools/src/ios/simulators.dart'
;
...
...
packages/flutter_tools/test/general.shard/mdns_discovery_test.dart
View file @
8893e89d
...
...
@@ -7,7 +7,7 @@
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device
_port_forwader
.dart'
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:flutter_tools/src/mdns_discovery.dart'
;
import
'package:flutter_tools/src/project.dart'
;
...
...
packages/flutter_tools/test/general.shard/protocol_discovery_test.dart
View file @
8893e89d
...
...
@@ -4,7 +4,7 @@
// @dart = 2.8
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/device
_port_forwader
.dart'
;
import
'package:flutter_tools/src/protocol_discovery.dart'
;
import
'package:fake_async/fake_async.dart'
;
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
8893e89d
...
...
@@ -9,6 +9,7 @@ import 'dart:async';
import
'package:flutter_tools/src/application_package.dart'
;
import
'package:flutter_tools/src/base/dds.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/device_port_forwader.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/resident_devtools_handler.dart'
;
import
'package:flutter_tools/src/version.dart'
;
...
...
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