Unverified Commit 01507bab authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Revert "Switch the way we retrieve the vm_service_port from /hub to iquery, on...

Revert "Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (#114637)" (#114715)

Causes analysis errors:

```
   info • Specify type annotations • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:513:5 • always_specify_types
   info • Specify type annotations • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:514:10 • always_specify_types
   info • Avoid method calls or property accesses on a "dynamic" target • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:515:11 • avoid_dynamic_calls
   info • Specify type annotations • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:515:48 • always_specify_types
   info • Separate the control structure expression from its statement • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:515:77 • always_put_control_body_on_new_line
   info • Specify type annotations • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:516:7 • always_specify_types
   info • Avoid method calls or property accesses on a "dynamic" target • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:518:11 • avoid_dynamic_calls
   info • Specify type annotations • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:518:51 • always_specify_types
   info • Separate the control structure expression from its statement • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:518:77 • always_put_control_body_on_new_line
   info • Specify type annotations • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:519:7 • always_specify_types
   info • Avoid method calls or property accesses on a "dynamic" target • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:521:11 • avoid_dynamic_calls
   info • Specify type annotations • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:522:21 • always_specify_types
   info • Separate the control structure expression from its statement • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:522:58 • always_put_control_body_on_new_line
  error • The argument type 'dynamic' can't be assigned to the parameter type 'String' • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:524:38 • argument_type_not_assignable
   info • Specify type annotations • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:540:5 • always_specify_types
   info • Avoid escaping inner quotes by converting surrounding quotes • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:541:14 • avoid_escaping_inner_quotes
   info • Specify type annotations • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:542:5 • always_specify_types
  error • The argument type 'dynamic' can't be assigned to the parameter type 'List<dynamic>' • packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart:544:45 • argument_type_not_assignable
   info • Remove unnecessary backslashes in strings • packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart:114:55 • unnecessary_string_escapes
   info • Remove unnecessary backslashes in strings • packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart:204:55 • unnecessary_string_escapes
   info • Remove unnecessary backslashes in strings • packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart:289:55 • unnecessary_string_escapes
```

This reverts commit b187bc47.
parent b187bc47
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:process/process.dart';
......@@ -507,28 +506,6 @@ class FuchsiaRemoteConnection {
_pollDartVms = true;
}
/// Helper for getDeviceServicePorts() to extract the vm_service_port from
/// json response.
List<int> getVmServicePortFromInspectSnapshot(List<dynamic> inspectSnapshot) {
final ports = <int>[];
for (final item in inspectSnapshot) {
if (item['payload'] == null || !(item as Map).containsKey('payload')) continue;
final payload = item['payload'];
if (payload['root'] == null || !(payload as Map).containsKey('root')) continue;
final root = payload['root'];
if (root['vm_service_port'] == null ||
!(root as Map).containsKey('vm_service_port')) continue;
final int? port = int.tryParse(root['vm_service_port']);
if (port != null) {
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
......@@ -537,14 +514,24 @@ class FuchsiaRemoteConnection {
/// found. An exception is thrown in the event of an actual error when
/// attempting to acquire the ports.
Future<List<int>> getDeviceServicePorts() async {
final inspectResult = await _sshCommandRunner
.run('iquery --format json show \'**:root:vm_service_port\'');
final inspectOutputJson = jsonDecode(inspectResult.join('\n'));
final List<int> ports =
getVmServicePortFromInspectSnapshot(inspectOutputJson);
if (ports.length > 1) {
throw StateError('More than one Flutter observatory port found');
final List<String> portPaths = await _sshCommandRunner
.run('/bin/find /hub -name vmservice-port');
final List<int> ports = <int>[];
for (final String path in portPaths) {
if (path == '') {
continue;
}
final List<String> lsOutput =
await _sshCommandRunner.run('/bin/ls $path');
for (final String line in lsOutput) {
if (line == '') {
continue;
}
final int? port = int.tryParse(line);
if (port != null) {
ports.add(port);
}
}
}
return ports;
}
......
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