Commit 3d7f2126 authored by Todd Volkert's avatar Todd Volkert

Merge pull request #142 from flutter/issue_141

Wait for sky server to start before starting device
parents 79ceee73 a57109be
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
library sky_tools.device; library sky_tools.device;
import 'dart:async'; import 'dart:async';
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:math'; import 'dart:math';
...@@ -512,6 +513,9 @@ class AndroidDevice extends Device { ...@@ -512,6 +513,9 @@ class AndroidDevice extends Device {
static const String className = 'AndroidDevice'; static const String className = 'AndroidDevice';
static final String defaultDeviceID = 'default_android_device'; static final String defaultDeviceID = 'default_android_device';
static const String _kFlutterServerStartMessage = 'Serving';
static const Duration _kFlutterServerTimeout = const Duration(seconds: 3);
String productID; String productID;
String modelID; String modelID;
String deviceCodeName; String deviceCodeName;
...@@ -773,8 +777,14 @@ class AndroidDevice extends Device { ...@@ -773,8 +777,14 @@ class AndroidDevice extends Device {
[adbPath, 'forward', observatoryPortString, observatoryPortString]); [adbPath, 'forward', observatoryPortString, observatoryPortString]);
// Actually start the server. // Actually start the server.
await Process.start(sdkBinaryName('pub'), ['run', 'sky_tools:sky_server', _serverPort], Process server = await Process.start(
workingDirectory: serverRoot, mode: ProcessStartMode.DETACHED); sdkBinaryName('pub'), ['run', 'sky_tools:sky_server', _serverPort],
workingDirectory: serverRoot,
mode: ProcessStartMode.DETACHED_WITH_STDIO
);
await server.stdout.transform(UTF8.decoder)
.firstWhere((String value) => value.startsWith(_kFlutterServerStartMessage))
.timeout(_kFlutterServerTimeout);
// Set up reverse port-forwarding so that the Android app can reach the // Set up reverse port-forwarding so that the Android app can reach the
// server running on localhost. // server running on localhost.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment