def async_command(self, command, stdin=None, stdout=None, raw=False,
                    timeout_ms=None):
    """Run the given command on the device asynchronously.

    Input will be read from stdin, output written to stdout.  ADB doesn't
    distinguish between stdout and stdin on the device, so they get interleaved
    into stdout here.  stdin and stdout should be file-like objects, so you
    could use sys.stdin and sys.stdout to emulate the 'adb shell' commandline.

    Args:
      command: The command to run, will be run with /bin/sh -c 'command' on
        the device.
      stdin: File-like object to read from to pipe to the command's stdin.  Can
        be None, in which case nothing will be written to the command's stdin.
      stdout: File-like object to write the command's output to.  Can be None,
        in which case the command's output will be buffered internally, and can
        be access via the return value of wait().
      raw: If True, run the command as per RawCommand (see above).
      timeout_ms: Timeout for the command, in milliseconds.

    Returns:
      An AsyncCommandHandle instance that can be used to send/receive data to
    and from the command or wait on the command to finish.

    Raises:
      AdbStreamUnavailableError: If the remote devices doesn't support the
        shell: service.
    """
    timeout = timeouts.PolledTimeout.from_millis(timeout_ms)
    if raw:
      command = self._to_raw_command(command)
    stream = self.adb_connection.open_stream('shell:%s' % command, timeout)
    if not stream:
      raise usb_exceptions.AdbStreamUnavailableError(
          '%s does not support service: shell', self)
    if raw and stdin is not None:
      # Short delay to make sure the ioctl to set raw mode happens before we do
      # any writes to the stream, if we don't do this bad things happen...
      time.sleep(.1)
    return AsyncCommandHandle(stream, stdin, stdout, timeout, raw)
Run the given command on the device asynchronously.

    Input will be read from stdin, output written to stdout.  ADB doesn't
    distinguish between stdout and stdin on the device, so they get interleaved
    into stdout here.  stdin and stdout should be file-like objects, so you
    could use sys.stdin and sys.stdout to emulate the 'adb shell' commandline.

    Args:
      command: The command to run, will be run with /bin/sh -c 'command' on
        the device.
      stdin: File-like object to read from to pipe to the command's stdin.  Can
        be None, in which case nothing will be written to the command's stdin.
      stdout: File-like object to write the command's output to.  Can be None,
        in which case the command's output will be buffered internally, and can
        be access via the return value of wait().
      raw: If True, run the command as per RawCommand (see above).
      timeout_ms: Timeout for the command, in milliseconds.

    Returns:
      An AsyncCommandHandle instance that can be used to send/receive data to
    and from the command or wait on the command to finish.

    Raises:
      AdbStreamUnavailableError: If the remote devices doesn't support the
        shell: service.