Perform one-time setup procedure.

        :param timeout:
            a timeout (in seconds) for device discovery
        :param key:
            a path to a public ssh key to use for connection

        This method will allow you to execute :meth:`cmdline()`
        repeatedly without incurring the extra overhead of the setup procedure.

        Note that this procedure needs to be repeated whenever:
        - the target device reboots
        - the local adb server is restarted
        - your ssh keys change

        .. versionadded:: 0.2

def connect(self, timeout=None, key=None):
        """
        Perform one-time setup procedure.

        :param timeout:
            a timeout (in seconds) for device discovery
        :param key:
            a path to a public ssh key to use for connection

        This method will allow you to execute :meth:`cmdline()`
        repeatedly without incurring the extra overhead of the setup procedure.

        Note that this procedure needs to be repeated whenever:
        - the target device reboots
        - the local adb server is restarted
        - your ssh keys change

        .. versionadded:: 0.2
        """
        if self.port is not None:
            return
        self._wait_for_device(timeout)
        self._setup_port_forwarding()
        self._purge_known_hosts_entry()
        self._copy_ssh_key(key)