9

My goal is to send HDMI CEC commands from a standard (i.e non-system) app running on an Android box equipped with Pulse-Eight's USB dongle.

Following these instructions I successfully managed to compile libcec for Android and execute it as root on the box, with this command:

echo <my-cec-command> | cec-client -s /dev/ttyACM0

where /dev/ttyACM0 is the device file created by the system when plugging the dongle.

However the permissions of this file prevent the command to be executed by a non-root user (therefore it cannot be executed from my Android app).

On the other hand the app can actually access the USB dongle via the USB Host API of the Android SDK (provided the user grants the permission) and can even be wrapped into a USB serial controller with UsbSerial library.

But I don't see any way to make the bridge between the connection provided by Android's USB Host API and libcec/cec-client. Do you have any idea or suggestion?

sdabet
  • 18,360
  • 11
  • 89
  • 158

1 Answers1

1

The best solution that I have found so far is to use USB Host API + UsbSerial library to read/write CEC packets on the adapter's serial port with pure Java code (no embedded libCEC).

I did some retro-engineering on libCEC to find out the appropriate commands for basic operations like switching TV on & off and setting active source.

And I finally came up with the following UsbCecConnection java class: https://gist.github.com/sdabet/ac4d7711d1a529806cb7b695530b1fac

sdabet
  • 18,360
  • 11
  • 89
  • 158
  • I tried this approach but when I try to list all usb devices through usbManager.getDeviceList() it returns no devices. Any idea why? I've made a post with my approaches but still with no success ( https://stackoverflow.com/questions/45639210/use-libcec-usb-dongle-in-android-app ). Thanks in advance for any guidance. – Eduardo Pinheiro Dec 20 '17 at 18:26