Android TV HDMI

Am i completly out of luck?

Is there anyway to listen to everything the TV is doing so i can try and find the command?

So i feel like i am getting a little closer, i ran ADB Logcat and manually switched some HDMI Inputs over.

Some of the results are below it looks like these are the commands that the TV is performing when i switch HDMI inputs, I have tried to copy and past them into the select.source service but had no luck, maybe they have to formatted differently?

The HW numbers HW5-8 are different for each input that i select

MtkTvInput(HDMIInputService): MtkTvInput onTune(content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW6)
onTuneStarted content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW6 inputid =com.mediatek.tvinput/.hdmi.HDMIInputService/HW6
MtkTvInput(HDMIInputService): MtkTvInput onSetMain: false info:com.mediatek.tvinput/.hdmi.HDMIInputService/HW5 selectedInput:com.mediatek.tvinput/.hdmi.HDMIInputService/HW5 state:3
PlayTvActivity:TvInputCallBack: onVideoAvailable com.mediatek.tvinput/.hdmi.HDMIInputService/HW7
ActivityManager: START u0 {act=android.intent.action.VIEW dat=content://android.media.tv/passthrough/com.mediatek.tvinput/.hdmi.HDMIInputService/HW6 flg=0x10000000 cmp=org.droidtv.playtv/.PlayTvActivity (has extras)} from uid 1000

I Have filtered everything for HDMI here:
HDMI LOG

And here is the full logcat log that ran
1st Half
2nd Half

This part seems to be the most interesting when I click a new HDMI source

10-14 10:18:16.654  5058  5058 D SourceElementCallback: onElementClick position:7
10-14 10:18:16.656  5058  5058 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1611 android.content.ContextWrapper.bindService:698 org.droidtv.channels.sources.SourcesUtils.bindToLoggingService:743 org.droidtv.channels.sources.SourcesUtils.switchTo:327 org.droidtv.channels.sources.SourceElementCallback.onElementClick:82
10-14 10:18:16.658  5058  5058 D SourcesUtils: PASSTHROUGH sourceUri:content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5
10-14 10:18:16.660  3878  3972 D org.droidtv.candeebug.Gateway: Returning successfully for event: {"event-type":"unknown.28","boot-count":9,"standby-count":9,"kernel-time":4030979,"data":{"original-event-type":28,"InputName":"Computer","uiname":"HDMI 1","ver":1}}
10-14 10:18:16.661  3878  5242 D org.droidtv.candeebug.h.a: Updated total event size to: 6815
10-14 10:18:16.670  2325  5682 I ActivityManager: START u0 {act=android.intent.action.VIEW dat=content://android.media.tv/passthrough/com.mediatek.tvinput/.hdmi.HDMIInputService/HW5 flg=0x10000000 cmp=org.droidtv.playtv/.PlayTvActivity (has extras)} from uid 1000
10-14 10:18:16.673  3540  3540 D PlayTvActivity: onNewIntent Action android.intent.action.VIEW data content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5
10-14 10:18:16.673  3540  3540 D PlayTvActivity: device ID =5
10-14 10:18:16.673  3540  3540 D PlayTvActivity: onNewIntent: ACTION_VIEW fav_list_id -1
10-14 10:18:16.685  3540  3540 D PlayTvActivity: onResume STATE_STARTED
10-14 10:18:16.686  3540  3540 D TvSessionManager: setStreamType value true

Here’s a wild guess based on what you posted and https://gist.github.com/mcfrojd/9e6875e1db5c089b1e3ddeb7dba0f304#starts-specific-twitch-stream-if-stream-is-live:

am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput/.hdmi.HDMIInputService/HW6
1 Like

it’s so close

i used
‘’’

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput/.hdmi.HDMIInputService/HW5 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

but that returns with
“Warning: Activity not started, intent has been delivered to currently running top-most instance.”

It made the screen flash so that’s something

I can’t get the above to work sadly, the service just restarts and doesn’t change input.

Now, I have installed Alexa on the TV and she can only change the HDMI input with voice aswell, can’t do it in a routine (sigh) but i was monitoring the log as saw she used an MQTT message to do it

10-15 10:39:25.993  6785 13554 I AWSIotMqttManager: message arrived on topic: prod/000068070a268a81
10-15 10:39:25.994  6785 13547 D IoTMessengerService: Message arrived:
10-15 10:39:25.994  6785 13547 D IoTMessengerService:    Topic: prod/000068070a268a81
10-15 10:39:25.994  6785 13547 D IoTMessengerService:  Message: {"input":"HDMI 2","command-id":"6ae46719-2b87-429b-800a-b7f0bc9af392"}
10-15 10:39:25.996  6785 13547 D InputController:  doTune input =hdmi2

Is there a way to connect to Alexas MQTT broker and broadcast the same message?

Can you use the learn_sendevent service to capture button presses, then manually send them in order to scroll through the HDMI sources?

If so, then you could setup a script or ADB command that checks the HDMI source via dumpsys activity starter | grep -o "HW[0-9]" | head -n 1 (source) and scrolls through the sources until you get to the desired input.

Thanks for sharing your journey! I am trying to do the same thing

with a little fiddling and logcat I now have a working command :slight_smile: -strangely enough you need to keep the %2F to get it working

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

2 Likes

@AlexanderK79 This is perfect! thank you! also thank you for replying on Stackoverflow aswell.

@JeffLIrion is it worthwhile adding this to the addon? perhaps as alternative for people who can’t get the HDMI commands to work? (specifically Philips 2020 model TVs)

And thank you to everyone else who helped along the way :slight_smile:

i’m so happy

I suggest contributing the solution here: https://gist.github.com/mcfrojd/9e6875e1db5c089b1e3ddeb7dba0f304

I don’t think all Android TV / Fire TV devices support changing the HDMI input, so at this time I won’t add it to the androidtv package. Also, the Home Assistant integration already uses apps as sources, so another service would need to be added to allow changing the HDMI input. At least for now, I think that using the androidtv.adb_command service with this command is an acceptable solution.

I was exactly in the same situation, thank you for the solution! :smiley: