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

5 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

3 Likes

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:

This works for hdmi1 but what about the other hdmi?

I answer to myself. You have to replace HW5 with HW6, HW7 or HW8 (HDMI2, HDMI3, HDMI4)

1 Like

Thank you AlexanderK79! I searched very long. Because also on the logitech harminy the direct choose of hdmi1 wasn’t working after the last update from philips. I don’t understand this, why do they forbid to change the source directly?

So now I can build something for my family that they can watch TV without problems.

1 Like

tell me what commands are needed for hassio Home Assistant OS 5.12

sir i have problem that after a os update the passthrough option missing please any adb command is there to enable pass through option

I’m trying to do the same thing for my TCL Android TV and JBL Link Bar (also runs Android TV). Does anyone have any experience with either of these platforms?

Hello,
I’m have the same problem, but any answer not work…
When i use comannd:
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
I have this error:
Error: Activity class {org.droidtv.playtv/org.droidtv.playtv.PlayTvActivity} does not exist.
Can you help me?

Thanks,

I had the same problem. I ran ADB logcat and found the command to be a little different. “adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.droidlogic.tvinput%2F.services.Hdmi1InputService%2FHW5” Even then I still got the same error as you. I then deleted “-n org.droidtv.playtv/.PlayTvActivity -f 0x10000000” It then changed inputs no problem.

Hi have the same issue with TCL TV

this is the logcat when i change on HDMI1 with the remote:

02-22 10:05:16.803  2018  2018 I chromium: [2018:2018:INFO:metrics_stat_logger.cc(55)] Metrics stat for the past 60 secs : total=3
02-22 10:05:16.803  2018  2018 I chromium: [metrics_stat_logger] Cast.Discovery.Mdns.ResponderPing=1
02-22 10:05:16.803  2018  2018 I chromium: [metrics_stat_logger] Cast.Discovery.Mdns.SocketPing=1
02-22 10:05:16.803  2018  2018 I chromium: [metrics_stat_logger] Cast.System.Time.Heartbeat=1
02-22 10:05:17.888   634   745 V EventHub: /dev/input/event0 got: time=36142.840972, type=1, code=403, value=1
02-22 10:05:17.888   634   745 V EventHub: event time 36142840972000, now 36142841053420
02-22 10:05:17.888   634   745 V EventHub: /dev/input/event0 got: time=36142.840972, type=0, code=0, value=0
02-22 10:05:17.888   634   745 V EventHub: event time 36142840972000, now 36142841053420
02-22 10:05:17.888   634   745 D InputReader: lxxl  **0** deviceId:65534 type:1 scancode:403 keycode:-1 vlaue:1 flags:-1 count is 2
02-22 10:05:17.888   634   745 D InputReader: lxxl  **1** deviceId:65534 type:0 scancode:0 keycode:16 vlaue:0 flags:32 count is 2
02-22 10:05:17.889   634   745 D WindowManager: interceptKeyTq keycode=167 interactive=true keyguardActive=false policyFlags=22000000
02-22 10:05:17.891   634   744 D WindowManager: interceptKeyTi keyCode=167 down=true repeatCount=0 keyguardOn=false mHomePressed=false canceled=false
02-22 10:05:17.933   634   717 D TvInputManagerService: ===yums=== setSurface1
02-22 10:05:17.933   634   717 D TvInputManagerService: ===yums=== return sessionState
02-22 10:05:17.933   634   717 D TvInputManagerService: ===yums=== setSurface2
02-22 10:05:17.933   634   717 D TvInputManagerService: ===yums=== getSessionLocked session is not null!
02-22 10:05:17.933   634   717 D TvInputManagerService: ===yums=== setSurface4 finally
02-22 10:05:17.934   634  1656 D TvInputManagerService: ===yums=== return sessionState
02-22 10:05:17.934   634  1656 D TvInputManagerService: ===yums=== getSessionLocked session is not null!
02-22 10:05:17.935   634   717 E TvInputHal: nativeRemoveStream,call tvInputHal->removeStream
02-22 10:05:17.935   634   717 E TvInputHal: JTvInputHal::removeStream deviceId:1413744384
02-22 10:05:17.935   634   717 E TvInputHal: streamId:1413744384
02-22 10:05:17.935   634   717 E Surface : [setSidebandStream 118] Surface(0x8632e800) NativeHandle stream=0x0, stream->handle=0x0
02-22 10:05:17.935   634   717 E         : [setSidebandStream 616] HpGraphicBufferProducer(0x84cf4ce0) NativeHandle stream=0x0
02-22 10:05:17.935   634   717 E         : [setSidebandStream 338] IGraphicBufferProducer(0x84cf4e00) NativeHandle stream=0x0
02-22 10:05:17.935   634   717 E         : [setSidebandStream 356] NativeHandle stream is empty, write false
02-22 10:05:17.935   312  1179 E         : [onTransact 904] get stream config empty
02-22 10:05:17.935   312  1179 E         : [onTransact 906] BnGraphicBufferProducer(0xb559e630) NativeHandle stream=0x0
02-22 10:05:17.935   312  1179 E BufferQueueProducer: [] [setSidebandStream 1322] stream=0x0
02-22 10:05:17.935   312  1179 E BufferQueueProducer: [] [setSidebandStream 1324]set sidebande stream:0x0, call onSidebandStreamChanged
02-22 10:05:17.935   312  1179 E BufferLayerConsumer: call listener(0xb3f78c7c) onSidebandStreamChanged
02-22 10:05:17.935   312  1179 E BufferLayer: [onSidebandStreamChanged 796]mSidebandStreamChanged:false
02-22 10:05:17.935   634  1656 D TvInputManagerService: releaseSession(sessionToken=android.os.Binder@5e40d9c)
02-22 10:05:17.935   634  1656 D TvInputManagerService: ===yums=== return sessionState
02-22 10:05:17.935   634  1656 D TvInputManagerService: ===yums=== return sessionState
02-22 10:05:17.935   634  1656 D TvInputManagerService: ===yums=== getSessionLocked session is not null!
02-22 10:05:17.936   634  1656 D TvInputManagerService: mainSessionToken=null
02-22 10:05:17.938   312   312 E BufferLayer: mSidebandStreamChanged, mSidebandStream=0x0, get mSidebandStream and set to hwc layer
02-22 10:05:17.940   634   717 E TvInputHal: JTvInputHal::removeStream connection.mSourceHandle clear
02-22 10:05:17.943   312  1179 E SurfaceFlinger: remove layer (SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3738].
02-22 10:05:17.943   312  1179 E SurfaceFlinger: remove layer (SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3133](0)(0x0xb3f77000).
02-22 10:05:17.943   312  1179 E SurfaceFlinger: remove layer (SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3141](1920, 1080).
02-22 10:05:17.943   312  1179 E SurfaceFlinger: remove layer (SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3145].
02-22 10:05:17.943   312  1179 E SurfaceFlinger: remove layer (SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3155].
02-22 10:05:17.943   312  1179 E SurfaceFlinger: remove layer (SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3161].
02-22 10:05:17.943   312  1179 E SurfaceFlinger: last remove layer (SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3176].
02-22 10:05:17.944   312  1179 E SurfaceFlinger: remove layer (SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3760].
02-22 10:05:17.944   312   341 E SurfaceFlinger: remove layer (Background for -SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3738].
02-22 10:05:17.944   312   341 E SurfaceFlinger: remove layer (Background for -SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3133](0)(0x0xb24d0000).
02-22 10:05:17.944   312   341 E SurfaceFlinger: remove layer (Background for -SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3141](1920, 1080).
02-22 10:05:17.944   312   341 E SurfaceFlinger: remove layer (Background for -SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3145].
02-22 10:05:17.944   312   341 E SurfaceFlinger: remove layer (Background for -SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3155].
02-22 10:05:17.944   312   341 E SurfaceFlinger: remove layer (Background for -SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3161].
02-22 10:05:17.944   312   341 E SurfaceFlinger: last remove layer (Background for -SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3176].
02-22 10:05:17.946   312   341 E SurfaceFlinger: remove layer (Background for -SurfaceView - com.tcl.tv/com.tcl.tv.TVActivity#1)[3760].
**02-22 10:05:17.948   634  1656 D TvInputManagerService: createSessionInternalLocked(inputId=com.tcl.tvpassthrough/.TvPassThroughService/HW1413744128)**
02-22 10:05:17.952   634  1968 D TvInputHardwareManager: surface is null, active config is null, just return true
02-22 10:05:17.953   634   634 D HdmiControlService: deviceSelect--fuli---deviceId:0
02-22 10:05:17.953   634   634 D HdmiCecLocalDeviceTv: deviceSelect--fuli--deviceId: 0
02-22 10:05:17.954   634   634 D HdmiCecLocalDeviceTv: ===fuli=== deviceSelect targetDevice:CEC: logical_address: 0x00 device_type: 0 vendor_id: 7173227 display_name: BeyondTV2 power_status: -1 physical_address: 0x0000 port_id: -1
02-22 10:05:17.957   275   362 D RTKHWC2 : psDisplay:0xa8ead1e0 validate_display flip:582612
02-22 10:05:17.957   275   362 D RTKHWC2 : idx 0: id:192 handle:0xa8ea32c0 ptr:0xa8ed8280 type:2 side:0x0 flag:0x800000
02-22 10:05:17.957   275   362 D RTKHWC2 : visibleRegion 0:0:1920:1080
02-22 10:05:17.957   275   362 D RTKHWC2 : sourceCrop 0.000000:0.000000:1280.000000:720.000000
02-22 10:05:17.957   275   362 D RTKHWC2 : displayFrame 0:0:1920:1080 zOrder=0
02-22 10:05:17.957   275   362 D RTKHWC2 : damage 0:0:0:0
02-22 10:05:17.957   275   362 D RTKHWC2 : idx 1: id:193 handle:0xa8ea2a80 ptr:0xa8ed86e0 type:2 side:0x0 flag:0x800000
02-22 10:05:17.958   275   362 D RTKHWC2 : visibleRegion 0:0:1920:1080
02-22 10:05:17.958   275   362 D RTKHWC2 : sourceCrop 0.000000:0.000000:1920.000000:1080.000000
02-22 10:05:17.958   275   362 D RTKHWC2 : displayFrame 0:0:1920:1080 zOrder=1
02-22 10:05:17.958   275   362 D RTKHWC2 : damage 0:0:0:0
02-22 10:05:17.954   634   634 D HdmiCecLocalDeviceTv: ===fuli=== targetAddress :0
02-22 10:05:17.958   634   634 D HdmiCecLocalDeviceTv: ===fuli=== handleSelectInternalSource

and tried this command:

am start -a android.intent.action.VIEW -d content://com.tcl.tvpassthrough/.TvPassThroughService/HW1413744128 -n com.tcl.tv/.TVActivity -f 0x10000000

but nothing happened.
Someone can helpme?

Did you have any luck with controlling your TCL TV in the end?
I’m trying to do the same myself and it’s popping up with the toast notification saying what the current input is but not changing inputs