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
1725a26e
Unverified
Commit
1725a26e
authored
Nov 08, 2022
by
Naud Ghebre
Committed by
GitHub
Nov 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (#114834)
parent
a84e369b
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
174 additions
and
100 deletions
+174
-100
fuchsia_remote_connection.dart
...ote_debug_protocol/lib/src/fuchsia_remote_connection.dart
+42
-18
fuchsia_remote_connection_test.dart
...e_debug_protocol/test/fuchsia_remote_connection_test.dart
+132
-82
No files found.
packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart
View file @
1725a26e
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:io'
;
import
'dart:io'
;
import
'package:process/process.dart'
;
import
'package:process/process.dart'
;
...
@@ -506,32 +507,55 @@ class FuchsiaRemoteConnection {
...
@@ -506,32 +507,55 @@ class FuchsiaRemoteConnection {
_pollDartVms
=
true
;
_pollDartVms
=
true
;
}
}
/// Gets the open Dart VM service ports on a remote Fuchsia device.
/// Helper for getDeviceServicePorts() to extract the vm_service_port from
///
/// json response.
/// The method attempts to get service ports through an SSH connection. Upon
List
<
int
>
getVmServicePortFromInspectSnapshot
(
dynamic
inspectSnapshot
)
{
/// successfully getting the VM service ports, returns them as a list of
final
List
<
Map
<
String
,
dynamic
>>
snapshot
=
/// integers. If an empty list is returned, then no Dart VM instances could be
List
<
Map
<
String
,
dynamic
>>.
from
(
inspectSnapshot
as
List
<
dynamic
>);
/// found. An exception is thrown in the event of an actual error when
/// attempting to acquire the ports.
Future
<
List
<
int
>>
getDeviceServicePorts
()
async
{
final
List
<
String
>
portPaths
=
await
_sshCommandRunner
.
run
(
'/bin/find /hub -name vmservice-port'
);
final
List
<
int
>
ports
=
<
int
>[];
final
List
<
int
>
ports
=
<
int
>[];
for
(
final
String
path
in
portPaths
)
{
if
(
path
==
''
)
{
for
(
final
Map
<
String
,
dynamic
>
item
in
snapshot
)
{
if
(!
item
.
containsKey
(
'payload'
)
||
item
[
'payload'
]
==
null
)
{
continue
;
}
final
Map
<
String
,
dynamic
>
payload
=
Map
<
String
,
dynamic
>.
from
(
item
[
'payload'
]
as
Map
<
String
,
dynamic
>);
if
(!
payload
.
containsKey
(
'root'
)
||
payload
[
'root'
]
==
null
)
{
continue
;
continue
;
}
}
final
List
<
String
>
lsOutput
=
final
Map
<
String
,
dynamic
>
root
=
await
_sshCommandRunner
.
run
(
'/bin/ls
$path
'
);
Map
<
String
,
dynamic
>.
from
(
payload
[
'root'
]
as
Map
<
String
,
dynamic
>);
for
(
final
String
line
in
lsOutput
)
{
if
(
line
==
''
)
{
if
(!
root
.
containsKey
(
'vm_service_port'
)
||
root
[
'vm_service_port'
]
==
null
)
{
continue
;
continue
;
}
}
final
int
?
port
=
int
.
tryParse
(
line
);
final
int
?
port
=
int
.
tryParse
(
root
[
'vm_service_port'
]
as
String
);
if
(
port
!=
null
)
{
if
(
port
!=
null
)
{
ports
.
add
(
port
);
ports
.
add
(
port
);
}
}
}
}
return
ports
;
}
/// Gets the open Dart VM service ports on a remote Fuchsia device.
///
/// The method attempts to get service ports through an SSH connection. Upon
/// successfully getting the VM service ports, returns them as a list of
/// integers. If an empty list is returned, then no Dart VM instances could be
/// found. An exception is thrown in the event of an actual error when
/// attempting to acquire the ports.
Future
<
List
<
int
>>
getDeviceServicePorts
()
async
{
final
List
<
String
>
inspectResult
=
await
_sshCommandRunner
.
run
(
"iquery --format json show '**:root:vm_service_port'"
);
final
dynamic
inspectOutputJson
=
jsonDecode
(
inspectResult
.
join
(
'
\n
'
));
final
List
<
int
>
ports
=
getVmServicePortFromInspectSnapshot
(
inspectOutputJson
);
if
(
ports
.
length
>
1
)
{
throw
StateError
(
'More than one Flutter observatory port found'
);
}
}
return
ports
;
return
ports
;
}
}
...
...
packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart
View file @
1725a26e
This diff is collapsed.
Click to expand it.
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