Commit 5aa9a7fc authored by Jason Simmons's avatar Jason Simmons

Forward the observatory (but not the diagnostic server) when in profile mode (#4183)

parent 604c75f1
...@@ -294,20 +294,32 @@ class AndroidDevice extends Device { ...@@ -294,20 +294,32 @@ class AndroidDevice extends Device {
printTrace('Waiting for observatory port to be available...'); printTrace('Waiting for observatory port to be available...');
try { try {
Future<List<int>> scrapeServicePorts = Future.wait( int observatoryDevicePort, diagnosticDevicePort;
<Future<int>>[observatoryDiscovery.nextPort(), diagnosticDiscovery.nextPort()]
); if (options.buildMode == BuildMode.debug) {
List<int> devicePorts = await scrapeServicePorts.timeout(new Duration(seconds: 20)); Future<List<int>> scrapeServicePorts = Future.wait(
int observatoryDevicePort = devicePorts[0]; <Future<int>>[observatoryDiscovery.nextPort(), diagnosticDiscovery.nextPort()]
);
List<int> devicePorts = await scrapeServicePorts.timeout(new Duration(seconds: 20));
observatoryDevicePort = devicePorts[0];
diagnosticDevicePort = devicePorts[1];
} else {
observatoryDevicePort = await observatoryDiscovery.nextPort().timeout(new Duration(seconds: 20));
}
printTrace('observatory port = $observatoryDevicePort'); printTrace('observatory port = $observatoryDevicePort');
int observatoryLocalPort = await options.findBestObservatoryPort(); int observatoryLocalPort = await options.findBestObservatoryPort();
// TODO(devoncarew): Remember the forwarding information (so we can later remove the // TODO(devoncarew): Remember the forwarding information (so we can later remove the
// port forwarding). // port forwarding).
await _forwardPort(ProtocolDiscovery.kObservatoryService, observatoryDevicePort, observatoryLocalPort); await _forwardPort(ProtocolDiscovery.kObservatoryService, observatoryDevicePort, observatoryLocalPort);
int diagnosticDevicePort = devicePorts[1];
printTrace('diagnostic port = $diagnosticDevicePort'); int diagnosticLocalPort;
int diagnosticLocalPort = await options.findBestDiagnosticPort(); if (diagnosticDevicePort != null) {
await _forwardPort(ProtocolDiscovery.kDiagnosticService, diagnosticDevicePort, diagnosticLocalPort); printTrace('diagnostic port = $diagnosticDevicePort');
diagnosticLocalPort = await options.findBestDiagnosticPort();
await _forwardPort(ProtocolDiscovery.kDiagnosticService, diagnosticDevicePort, diagnosticLocalPort);
}
return new LaunchResult.succeeded( return new LaunchResult.succeeded(
observatoryPort: observatoryLocalPort, observatoryPort: observatoryLocalPort,
diagnosticPort: diagnosticLocalPort diagnosticPort: diagnosticLocalPort
......
...@@ -101,7 +101,7 @@ class RunCommand extends RunCommandBase { ...@@ -101,7 +101,7 @@ class RunCommand extends RunCommandBase {
DebuggingOptions options; DebuggingOptions options;
if (getBuildMode() != BuildMode.debug) { if (getBuildMode() == BuildMode.release) {
options = new DebuggingOptions.disabled(getBuildMode()); options = new DebuggingOptions.disabled(getBuildMode());
} else { } else {
options = new DebuggingOptions.enabled( options = new DebuggingOptions.enabled(
......
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