HDMI CEC ( Control HDMI attached TV/device )

Hello all,

I have a project, involving Android TV box and TV attached to it.
I need to check the power status of the TV (is on or off ) and to send the proper command to wake it up, or to send it to sleep.

All this are possible with HDMI CEC ( info here: https://source.android.com/devices/tv/hdmi-cec )
I did not find any extension for this, i tried to find alternate approach.

I find that i can send commands to the service via SHELL

BUT i also find that :

“Access to the HDMI-CEC service is guarded with the protection level SignatureOrSystem. Only system components or the apps placed in /system/priv-app can access the service. This is to protect the service from abuse by apps with malicious intent.”

So I am stuck again and i need some help.

Does anyone had faced such need/issue ? and how you solved it ?

If any Extension Developer can make extension for this, let me know. I will pay for the work.
(then the extension will be free for the community )

For the protocol:

  • TV BOX is not rooted!
  • Both TV and TV Box are CEC capable.

CEC Commands: https://www.cec-o-matic.com/
Andorid CEC Info: https://source.android.com/devices/tv/hdmi-cec
CEC at RosberyPI : Exec, HDMI-CEC and powering on/off the TV - Beginners - openHAB Community
Java “HDMI-CEC Manager” - core/java/android/hardware/hdmi/HdmiControlManager.java - platform/frameworks/base - Git at Google
It may help to develop extension from this.

and others, via search …


1 Like

I’m curious why you need to know the TV power status ?
I’m work with android tv box. All TV box i know they run (turn on) without checking TV power status. If TV power status if off only you can close your app but you can’t shutdown TV box.

I have hundreds of Tv boxes and TV’s. I use them for company signage and a kind of KIOSK terminal.
All of that Tv Boxes are in different places and often people turn OFF the display (TV). Example: when they close their place at end of working day, they turn it OFF. And the next day they “forgot” to turn it on.

The TV box (when is powered on) sends signal to TV and it wakes up too. This works, if they both are powered off. The TV is in SLEEP status, so if it turned off, i can periodically check the status and send a signal to wake it up.
I want to do that by the app, so not to use any external services.

If TV power status if off only you can close your app but you can’t shutdown TV box.

Not true.
If TV power off is pressed HDMI-CEC can send back signal to TV BOX. Depending on settings it will go sleep mode too. If the box go SLEEP too, we cant do anything.
If the box is still alive, by sending back command to TV it will wake up. Also i will know the status and i will write it to database, so we can check the actual usage of the tv box and display time.

Is possible to send signal to tv to power on from you tv box ?? :thinking:
I’m interested !!! I’m working on an iptv app for a cable company

I am still stuck at the right to access service,

TV’s most of the time are in SLEEP MODE. When you press POWER OFF button, it sends it to sleep mode. So you can easy power it on by your remote control or any service or network command.

The way your TV BOX send wake signal to TV and TV powers on too, your app can do the same.
Both devices must be CEC enabled. In some TV Boxes HDM-CEC is not implemented or need some extra stuff.

KODI can control device via hdmi-cec. So they had implement something more in the app.

I think, when i have “access” to the service, i will be able to control many options.
( see the documentation, you can send OSD message, control volume, control brightness, contrast … )

Thanks so much for you info.
I’m read and I’ll investigate this weekend…
If found any interesting post here or send PM.
Wich app (how to) you autorun your app after TV box is power on ?

You can add it to Autorun, but is not enough.

Before TvBoxes i used TV’s with android in them. I found one app “Start and Stay”. App runs as a service in your device. You can add any app to her list, and you have options such:

  • auto run app
  • delay start
  • start app , if app is closed by user
  • persist mode ( app if closed, it runs it almost immediately )

I have the app as APK, because it think is not anymore at google play store.

I will share info in this topic too.

1 Like

Without exclusive access to the system, HDM-CEC cannot be controlled.
APP must be system app and be signed with system certificate in order to have the privilege.

Some workaround with ROOTED / SuperUser access it may be achieved:


1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.