Skip to content

Commit

Permalink
[device_utils] check ro.com.google.clientidbase for xiaomi boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
CastagnaIT committed Jan 8, 2024
1 parent 4547c80 commit c7a4995
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
18 changes: 17 additions & 1 deletion resources/lib/common/device_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ def get_machine():
return 'arm'


def is_android_tv(props=None):
"""Check Android properties to determine if the device has an Android TV system"""
if props is None:
props = get_android_system_props()
ret = 'TV' in props.get('ro.build.characteristics', '').upper()
# Xiaomi box devices like Mi Box 3, Mi Box S, Tv Stick, and maybe other models
# don't have "tv" value into ro.build.characteristics
# therefore we check the name from ro.com.google.clientidbase, that at least to the mentioned models are the same
if (not ret and props.get('ro.product.manufacturer', '').upper() == 'XIAOMI'
and props.get('ro.com.google.clientidbase', '').upper() == 'ANDROID-XIAOMI-TV'):
ret = True
return ret


def is_device_4k_capable():
"""Check if the device is 4k capable"""
# Currently only on android is it possible to use 4K
Expand Down Expand Up @@ -177,17 +191,19 @@ def _check_internet():
pass
return False


def get_supported_hdr_types():
"""
Get supported HDR types by the display
:return: supported type as list ['hdr10', 'hlg', 'hdr10+', 'dolbyvision']
"""
if G.KODI_VERSION < 20: # The infolabel 'System.SupportedHDRTypes' is supported from Kodi v20
if G.KODI_VERSION < 20: # The infolabel 'System.SupportedHDRTypes' is supported from Kodi v20
return []
# The infolabel System.SupportedHDRTypes returns the HDR types supported by the hardware as a string:
# "HDR10, HLG, HDR10+, Dolby Vision"
return xbmc.getInfoLabel('System.SupportedHDRTypes').replace(' ', '').lower().split(',')


def get_android_system_props():
"""Get Android system properties by parsing the raw output of getprop into a dictionary"""
try:
Expand Down
5 changes: 2 additions & 3 deletions resources/lib/config_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from xbmcgui import getScreenHeight, getScreenWidth

from resources.lib.common import (get_system_platform, is_device_4k_capable, get_local_string, json_rpc,
get_supported_hdr_types, get_android_system_props, is_device_l1_enabled)
get_supported_hdr_types, is_device_l1_enabled, is_android_tv)
from resources.lib.common.exceptions import InputStreamHelperError
from resources.lib.globals import G
from resources.lib.kodi.ui import show_ok_dialog, ask_for_confirmation
Expand Down Expand Up @@ -84,8 +84,7 @@ def _set_codec_profiles():
# ...we do not enable VP9 because many older mobile devices do not support it
enable_vp9_profiles = False
# ...we enable HEVC by default on tv boxes and 4K capable devices
is_android_tv = 'TV' in get_android_system_props().get('ro.build.characteristics', '').upper()
enable_hevc_profiles = is_android_tv or is_device_4k_capable()
enable_hevc_profiles = is_android_tv() or is_device_4k_capable()
# Get supported HDR types by the display (configuration works from Kodi v20)
supported_hdr_types = get_supported_hdr_types()
if supported_hdr_types and enable_hevc_profiles: # for now only HEVC have HDR/DV
Expand Down
5 changes: 2 additions & 3 deletions resources/lib/utils/esn.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ def regen_esn(esn):

def generate_android_esn(wv_force_sec_lev=None):
"""Generate an ESN if on android or return the one from user_data"""
from resources.lib.common.device_utils import get_system_platform, get_android_system_props
from resources.lib.common.device_utils import get_system_platform, get_android_system_props, is_android_tv
if get_system_platform() == 'android':
props = get_android_system_props()
is_android_tv = 'TV' in props.get('ro.build.characteristics', '').upper()
if is_android_tv:
if is_android_tv(props):
return _generate_esn_android_tv(props, wv_force_sec_lev)
return _generate_esn_android(props, wv_force_sec_lev)
return None
Expand Down

0 comments on commit c7a4995

Please sign in to comment.