This repository contains the server code for hosting an integration driver that uses ADB for communication for the Unfolded Circle Remotes. It exposes a Remote Entity that can be used to control TVs or any other device based on Android with support for ADB.
Tested on Panasonic Z95B
- The integration relies on ADB (Android Debug Bridge) to communicate with the device. This is useful for devices that don't expose other APIs. The downside is that this protocol is very slow, as such, you should use Bluetooth for as many commands as possible.
- Reauthorization of the ADB connection is required when reinstalling/updating the integration when it is hosted on the remote. This is because the public and private keys are removed when the integration is uninstalled.
- The power states are dumb, it only tracks on or off when triggered via the integration. This is a limitation of the ADB protocol, where it is not possible to query the power state without turning on the device.
- IP and MAC address of the device you want to control.
- When installing on the remote, the remote must be on firmware version 2.6.3 or later or the driver will crash because it can't start adb.
- Developer Settings enabled on the device you want to control. This is usually done by taping 7 times on your device name. Please search for device specific instructions on how to enable Developer Settings.
- The published binary is self-contained and doesn't require any additional software. It's compiled for Linux ARM64 and is meant to be running on the remote.
- Use the Docker Image in the Core Simulator
- Other Operating Systems - Linux, macOS, Windows - are supported. Requires that you have ADB installed.
| Service | Port | Protocol | Location |
|---|---|---|---|
| Server | Random* | HTTP (TCP) | Remote/other computer |
| ADB | 5555** | TCP | Device to control |
| Wake on Lan | 7 and 9 | UDP | Device to control |
* Server port can be adjusted by specifying the desired port with the UC_INTEGRATION_HTTP_PORT environment variable.
** ADB port can be adjusted during configuration if your device uses a different port.
You can send any input keyevent command with the remote entity if it's added to an activity.
A list of commands can be found in the official docs at Android KeyEvent
and here. Make sure to only use the digits in the commands.
You can send any adb shell command with the integration. Use the following prefixes to send commands:
RAW:YOUR_COMMAND- Sends the command as is, without any modifications.APP:YOUR_COMMAND- Starts an application by sendingshell monkey --pct-syskeys 0 -p {YOUR_COMMAND} 1.ACT:YOUR_COMMAND- Starts an activity by sendingshell am start -n {YOUR_COMMAND}.INP:YOUR_COMMAND- Switches input by sendingshell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW{YOUR_COMMAND} -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000.INP_TCL:YOUR_COMMAND- Switches input by sendingshell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.tcl.tvinput%2F.TvPassThroughService%2FHW{YOUR_COMMAND} -f 0x10000000. Make sure to not include theadb shellpart of the command, device IP, ports and similar, as it is already included by the integration. Also make sure that you do not have any spaces between the prefix and the command.
- dotnet 10 SDK.
- or Docker.
- Download
unfolded-circle-adbtv-[version]-remote.tar.gzfrom the release page - Open the remote's Web Configurator
- Click on
Integrations - Click on
Add newand thenInstall custom - Choose the file in step 1 (
unfolded-circle-adbtv-[version]-remote.tar.gz) - Make sure that your device is turned on
- Click on the newly installed integration and follow the on-screen instructions
The application can be configured using the appsettings.json file or environment variables.
Additionally, the application saves configured entities to the configured_entities.json file, which will be saved to the directory specified by the UC_CONFIG_HOME environment variable.
By default, the application logs to stdout.
You can customize the log levels by either modifying the appsettings.json file or by setting environment variables.
TraceDebugInformationWarningError
Trace log level will log the contents of all the incoming and outgoing requests and responses.
{
"Logging": {
"LogLevel": {
"UnfoldedCircle.Server": "Information",
"UnfoldedCircle.AdbTv": "Information",
"Makaretu.Dns": "Warning"
}
}
}Same adjustments to log levels can be made by setting environment variables.
Logging__LogLevel__UnfoldedCircle.Server=InformationLogging__LogLevel__UnfoldedCircle.AdbTv=InformationLogging__LogLevel__Makaretu.Dns=Warning
Execute publish.sh script to build the application for the remote. This will produce a tar.gz file in the root of the repository.
Execute the following from the root of the repository:
docker build -f src/UnfoldedCircle.AdbTv/Dockerfile -t adbtv .dotnet publish ./src/UnfoldedCircle.AdbTv/UnfoldedCircle.AdbTv.csproj -c Release --self-contained -o ./publishThis will produce a self-contained binary in the publish directory in the root of the repository.