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
7e2df440
Commit
7e2df440
authored
Mar 17, 2016
by
John McCutchan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2707 from johnmccutchan/sniff_service_protocol_port
Sniff service protocol port from device
parents
50a249e3
83e6ee36
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
7 deletions
+37
-7
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+18
-5
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+0
-1
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+13
-0
service_protocol.dart
packages/flutter_tools/lib/src/service_protocol.dart
+1
-1
service_protocol_test.dart
packages/flutter_tools/test/service_protocol_test.dart
+5
-0
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
7e2df440
...
...
@@ -17,6 +17,7 @@ import '../build_configuration.dart';
import
'../device.dart'
;
import
'../flx.dart'
as
flx
;
import
'../globals.dart'
;
import
'../service_protocol.dart'
;
import
'../toolchain.dart'
;
import
'adb.dart'
;
import
'android.dart'
;
...
...
@@ -185,12 +186,12 @@ class AndroidDevice extends Device {
return
true
;
}
Future
<
Null
>
_forwardObservatoryPort
(
int
port
)
async
{
bool
portWasZero
=
port
==
0
;
Future
<
Null
>
_forwardObservatoryPort
(
int
devicePort
,
int
port
)
async
{
bool
portWasZero
=
(
port
==
null
)
||
(
port
==
0
)
;
try
{
// Set up port forwarding for observatory.
port
=
await
portForwarder
.
forward
(
observatoryDefault
Port
,
port
=
await
portForwarder
.
forward
(
device
Port
,
hostPort:
port
);
if
(
portWasZero
)
printStatus
(
'Observatory listening on http://127.0.0.1:
$port
'
);
...
...
@@ -214,13 +215,18 @@ class AndroidDevice extends Device {
return
false
;
}
await
_forwardObservatoryPort
(
debugPort
);
if
(
clearLogs
)
this
.
clearLogs
();
runCheckedSync
(
adbCommandForDevice
(<
String
>[
'push'
,
bundlePath
,
_deviceBundlePath
]));
ServiceProtocolDiscovery
serviceProtocolDiscovery
=
new
ServiceProtocolDiscovery
(
logReader
);
// We take this future here but do not wait for completion until *after*
// we start the bundle.
Future
<
int
>
serviceProtocolPort
=
serviceProtocolDiscovery
.
nextPort
();
List
<
String
>
cmd
=
adbCommandForDevice
(<
String
>[
'shell'
,
'am'
,
'start'
,
'-a'
,
'android.intent.action.RUN'
,
...
...
@@ -243,6 +249,13 @@ class AndroidDevice extends Device {
printError
(
result
.
trim
());
return
false
;
}
// Wait for the service protocol port here. This will complete once
// the device has printed "Observatory is listening on..."
int
devicePort
=
await
serviceProtocolPort
;
printTrace
(
'service protocol port =
$devicePort
'
);
await
_forwardObservatoryPort
(
devicePort
,
debugPort
);
return
true
;
}
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
7e2df440
...
...
@@ -199,7 +199,6 @@ class IOSDevice extends Device {
return
false
;
}
printTrace
(
'Installation successful.'
);
return
true
;
}
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
7e2df440
...
...
@@ -16,6 +16,7 @@ import '../build_configuration.dart';
import
'../device.dart'
;
import
'../flx.dart'
as
flx
;
import
'../globals.dart'
;
import
'../service_protocol.dart'
;
import
'../toolchain.dart'
;
import
'mac.dart'
;
...
...
@@ -462,6 +463,13 @@ class IOSSimulator extends Device {
if
(!(
await
_setupUpdatedApplicationBundle
(
app
,
toolchain
)))
return
false
;
ServiceProtocolDiscovery
serviceProtocolDiscovery
=
new
ServiceProtocolDiscovery
(
logReader
);
// We take this future here but do not wait for completion until *after*
// we start the application.
Future
<
int
>
serviceProtocolPort
=
serviceProtocolDiscovery
.
nextPort
();
// Prepare launch arguments.
List
<
String
>
args
=
<
String
>[
"--flx=
${path.absolute(path.join('build', 'app.flx'))}
"
,
...
...
@@ -486,7 +494,12 @@ class IOSSimulator extends Device {
return
false
;
}
// Wait for the service protocol port here. This will complete once
// the device has printed "Observatory is listening on..."
int
devicePort
=
await
serviceProtocolPort
;
printTrace
(
'service protocol port =
$devicePort
'
);
printTrace
(
'Successfully started
${app.name}
on
$id
.'
);
printStatus
(
'Observatory listening on http://127.0.0.1:
$devicePort
'
);
return
true
;
}
...
...
packages/flutter_tools/lib/src/service_protocol.dart
View file @
7e2df440
...
...
@@ -29,7 +29,7 @@ class ServiceProtocolDiscovery {
void
_onLine
(
String
line
)
{
int
portNumber
=
0
;
if
(
line
.
startsWith
(
'Observatory listening on http://'
))
{
if
(
line
.
contains
(
'Observatory listening on http://'
))
{
try
{
RegExp
portExp
=
new
RegExp
(
r"\d+.\d+.\d+.\d+:(\d+)"
);
String
port
=
portExp
.
firstMatch
(
line
).
group
(
1
);
...
...
packages/flutter_tools/test/service_protocol_test.dart
View file @
7e2df440
...
...
@@ -40,6 +40,11 @@ void main() {
const
Duration
(
milliseconds:
100
),
onTimeout:
()
=>
77
);
// Expect the timeout port.
expect
(
port
,
77
);
// Get next port future.
nextPort
=
discoverer
.
nextPort
();
logReader
.
addLine
(
'I/flutter : Observatory listening on http://127.0.0.1:52584'
);
expect
(
await
nextPort
,
52584
);
});
});
}
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