Remove the given stream transport's id from our map of id's.

    If the stream id is actually removed, we send a CLSE message to let the
    remote end know (this happens when we are ack'ing a CLSE message we
    received).  The ADB protocol doesn't say this is a requirement, but ADB
    does it, so we do too.

    Args:
      stream_transport: The stream transport to close.
      timeout: Timeout on the operation.

    Returns:
      True if the id was removed and message sent, False if it was already
    missing from the stream map (already closed).

def close_stream_transport(self, stream_transport, timeout):
    """Remove the given stream transport's id from our map of id's.

    If the stream id is actually removed, we send a CLSE message to let the
    remote end know (this happens when we are ack'ing a CLSE message we
    received).  The ADB protocol doesn't say this is a requirement, but ADB
    does it, so we do too.

    Args:
      stream_transport: The stream transport to close.
      timeout: Timeout on the operation.

    Returns:
      True if the id was removed and message sent, False if it was already
    missing from the stream map (already closed).
    """
    with self._stream_transport_map_lock:
      if stream_transport.local_id in self._stream_transport_map:
        del self._stream_transport_map[stream_transport.local_id]
        # If we never got a remote_id, there's no CLSE message to send.
        if stream_transport.remote_id:
          self.transport.write_message(adb_message.AdbMessage(
              'CLSE', stream_transport.local_id, stream_transport.remote_id),
                                       timeout)
        return True
    return False