stop method

Future<void> stop()

Implementation

Future<void> stop() async {
  final socket = _socket;
  _socket = null;
  _lines = null;
  try {
    socket?.write('{"cmd":"quit"}\n');
    await socket?.flush();
    await socket?.close();
  } on Object {
    // already gone
  }
  socket?.destroy();
  final own = _process;
  _process = null;
  if (own != null) await ProcessRegistry.instance.stop('android-server', device: serial, only: own);
  final port = _port;
  _port = null;
  if (port == null) return;
  try {
    await runBounded(adbPath, ['-s', serial, 'forward', '--remove', 'tcp:$port'],
        timeout: const Duration(seconds: 10), phase: 'adb forward remove');
  } on ProcessTimeoutError {
    return;
  }
}