Add DevicePortForwarder with adb fix
diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index f8cdda3..b948515 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart
@@ -151,6 +151,9 @@ /// Get the log reader for this device. DeviceLogReader get logReader; + /// Get the port forwarder for this device. + DevicePortForwarder get portForwarder; + /// Clear the device's logs. void clearLogs(); @@ -186,6 +189,30 @@ String toString() => '$runtimeType $id'; } +class ForwardedPort { + ForwardedPort(this.hostPort, this.devicePort); + + final int hostPort; + final int devicePort; + + String toString() => 'ForwardedPort HOST:$hostPort to DEVICE:$devicePort'; +} + +/// 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, will auto select a host port. + /// Returns a Future that completes with the host port. + Future<int> forward(int devicePort, {int hostPort: null}); + + /// Stops forwarding [forwardedPort]. + Future unforward(ForwardedPort forwardedPort); +} + /// Read the log for a particular device. Subclasses must implement `hashCode` /// and `operator ==` so that log readers that read from the same location can be /// de-duped. For example, two Android devices will both try and log using