def connect(self, always_log_errors=True):
self._adb_lock.acquire(**LOCK_KWARGS)<EOL>try:<EOL><INDENT>if not self.adb_server_ip:<EOL><INDENT>try:<EOL><INDENT>if self.adbkey:<EOL><INDENT>signer = Signer(self.adbkey)<EOL>self._adb = adb_commands.AdbCommands().ConnectDevice(serial=self.host, rsa_keys=[signer], default_timeout_ms=<NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>self._adb = adb_commands.AdbCommands().ConnectDevice(serial=self.host, default_timeout_ms=<NUM_LIT>)<EOL><DEDENT>self._available = True<EOL><DEDENT>except socket_error as serr:<EOL><INDENT>if self._available or always_log_errors:<EOL><INDENT>if serr.strerror is None:<EOL><INDENT>serr.strerror = "<STR_LIT>"<EOL><DEDENT>logging.warning("<STR_LIT>", self.host, serr.strerror)<EOL><DEDENT>self._adb = None<EOL>self._available = False<EOL><DEDENT>finally:<EOL><INDENT>return self._available<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>self._adb_client = AdbClient(host=self.adb_server_ip, port=self.adb_server_port)<EOL>self._adb_device = self._adb_client.device(self.host)<EOL>self._available = bool(self._adb_device)<EOL><DEDENT>except:<EOL><INDENT>self._available = False<EOL><DEDENT>finally:<EOL><INDENT>return self._available<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>self._adb_lock.release()<EOL><DEDENT>
Connect to an Amazon Fire TV device.

        Will attempt to establish ADB connection to the given host.
        Failure sets state to UNKNOWN and disables sending actions.

        :returns: True if successful, False otherwise