# ADB protocol set

An action block that sets the protocol that the ADB daemon running on an Android device will use to listen for client connections.

The fiber will pause until the ADB has begun restarting.

This block as limited used since it can only connect to devices that’s already using the TCP/IP protocol or Wireless debugging (Android 11+), but the former may be more reliable.

## Setup

A device has to be configured to accept incoming ADB connections. On Android 11+ devices, enable the Wireless debugging option in system Developer settings. On Android 10 or lower devices, it has to be enabled using a USB connected PC, please read ADB.

Every connection requires authentication in the form of a 2048-bit RSA key-pair. If the TLS option is enable, the public key should be encoded in a self-signed X.509 certificate which is used along with the private key for TLS encryption. If disabled, the private key is used to sign a “challenge-response” sent by the device, but the connection is unencrypted. Click the Install generated key button to create such a key-pair, or create it elsewhere, e.g. with a tool like `openssl`, then install it in system Security settings. Once an alias of an installed key has been chosen, the system will grant Automate perpetual usage, but the secret key material remains inaccessible, e.g. for export or backup.

A key-pair must be manually authorized by the user, click the Pair device button to perform the process. When using Wireless debugging the pairing process first has to be started by clicking the Pair device with pairing code button in system Developer settings, Wireless debugging.

The port for an Wireless debugging connection can change at device reboot, use the Network service discover block with the Android Debug Bridge (ADB) over TLS service type to perform a lookup prior to this block.

A device may refuse additional connections while already connected through USB cable, disconnect it. If an EACCES `SocketException` failure occurs, try disabling the system “Data Saver” feature, for just Automate or globally.

Privacy warning! If the TLS option is disabled the connection may be unencrypted, don’t connect to a remote device over a public network.

## Input arguments

- Protocol — protocol that ADB daemon running on host should use to listen client connections, default is USB.
- TCP/IP port — if protocol is TCP/IP then listen on this port, default is 5555.
- Keychain alias — alias of an 2048-bit RSA private key and certificate stored in the Android system keychain.
- Host or IP address — hostname or IP address of Android device, default is localhost.
- Port — remote port, default is 5555.
- Security — whether to establish a secure TLS connection to an Android 11+ device, default is no, i.e. unencrypted.