An action block that executes a shell command through ADB, on the local or a remote Android device.
The fiber will pause until the command has completed.
When only executing commands on the local device then using the Shell command privileged block is preferable since it only has to connect to the ADB daemon once, making it faster and more reliable.
The command should be formatted as it would when executed at a shell prompt (without adb shell
prefix),
that includes proper escaping. Use the cliEncode function when including a filename or other text as an argument.
The standard output and error will contain the full text as generated by the command during its execution.
The exit code is usually set to 0
(zero) for a successful execution of the command.
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.