Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sony TV HDMI input detection #227

Closed
axxelh opened this issue Jan 12, 2021 · 4 comments
Closed

Sony TV HDMI input detection #227

axxelh opened this issue Jan 12, 2021 · 4 comments

Comments

@axxelh
Copy link

axxelh commented Jan 12, 2021

Issue 202 added HDMI input info, but that doesn't appear to work on current Sony Android TV implementations.

This command appears to work on my X950H, returning just the port number (ports are 1 indexed, when the routing is 0x0000 internal apps are in use).:

'dumpsys hdmi_control | grep -o 'mActiveRoutingPath: 0x[1-9]' | grep -o [1-9]'

There are several other fields in dumpsys that could be used, but this seemed cleanest to me.

Not sure what the right pattern is for multiple variants of CMD_HDMI_INPUT or detection of subtypes of Android TV so I'm not proposing a patch.

@JeffLIrion
Copy link
Owner

There’s a method for getting device properties:

def get_device_properties(self):
"""Return a dictionary of device properties.
Returns
-------
props : dict
A dictionary with keys ``'wifimac'``, ``'ethmac'``, ``'serialno'``, ``'manufacturer'``, ``'model'``, and ``'sw_version'``
"""

Rather than simply returning the dictionary of device properties, I think it should also store that dictionary. Then other methods could check the device properties and adjust their ADB commands accordingly, similar to how Google TV support is handled. For example, from get_properties():

output = self._adb.shell(constants.CMD_ANDROIDTV_PROPERTIES_LAZY_RUNNING_APPS if not self._is_google_tv else constants.CMD_GOOGLE_TV_PROPERTIES_LAZY_RUNNING_APPS)

@JeffLIrion
Copy link
Owner

With the latest changes that I made, you can customize commands based on the device info. For example, see here:

self._cmd_current_app = constants.CMD_CURRENT_APP_GOOGLE_TV

You could add a _cmd_hdmi_input attribute and customize it for applicable Sony devices.

@martomo
Copy link
Contributor

martomo commented Feb 5, 2021

@axxelh I checked out your suggested command to obtain the HDMI port number, which worked like a charm!

Although the expected hdmi_input value should be a hardware identifier as defined in tv_input module.

On my Sony Bravia KD-55XD7005 were the following hardware definitions, mapped to input using the respective TV Input Manager service intent.

  • HW2 (HDMI 1)
am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.sony.dtv.tvinput.external%2F.ExternalTvInputService%2FHW2 -n com.sony.dtv.tvx/.MainActivity -f 0x10000000
  • HW3 (HDMI 2)
am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.sony.dtv.tvinput.external%2F.ExternalTvInputService%2FHW3 -n com.sony.dtv.tvx/.MainActivity -f 0x10000000
  • HW4 (HDMI 3 / ARC)
am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.sony.dtv.tvinput.external%2F.ExternalTvInputService%2FHW4 -n com.sony.dtv.tvx/.MainActivity -f 0x10000000
  • HW5 (HDMI 4)
am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.sony.dtv.tvinput.external%2F.ExternalTvInputService%2FHW5 -n com.sony.dtv.tvx/.MainActivity -f 0x10000000
  • HW6 (AV1)
am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.sony.dtv.tvinput.external%2F.ExternalTvInputService%2FHW6 -n com.sony.dtv.tvx/.MainActivity -f 0x10000000
  • HW7 (AV2)
am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.sony.dtv.tvinput.external%2F.ExternalTvInputService%2FHW7 -n com.sony.dtv.tvx/.MainActivity -f 0x10000000

In case you are interested, here is my proposed command, as in the linked pull request (66840c2), to obtain hardware identifier for both Sony TV (com.sony.dtv.tvinput.external) and other devices (com.mediatek.tvinput).

dumpsys activity starter | grep -E -o '(ExternalTv|HDMI)InputService/HW[0-9]' -m 1 | grep -o 'HW[0-9]'

@martomo
Copy link
Contributor

martomo commented Feb 17, 2021

@axxelh @JeffLIrion This has been addressed in v0.0.58 with the changes from #236.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants