From c7a4995731ea0f168cf88b6a4ba40c15f321d3b5 Mon Sep 17 00:00:00 2001 From: CastagnaIT Date: Mon, 8 Jan 2024 08:33:11 +0100 Subject: [PATCH] [device_utils] check ro.com.google.clientidbase for xiaomi boxes --- resources/lib/common/device_utils.py | 18 +++++++++++++++++- resources/lib/config_wizard.py | 5 ++--- resources/lib/utils/esn.py | 5 ++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/resources/lib/common/device_utils.py b/resources/lib/common/device_utils.py index 186bd585f..b1c955cfc 100644 --- a/resources/lib/common/device_utils.py +++ b/resources/lib/common/device_utils.py @@ -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 @@ -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: diff --git a/resources/lib/config_wizard.py b/resources/lib/config_wizard.py index 179b716ff..a4ab3fb32 100644 --- a/resources/lib/config_wizard.py +++ b/resources/lib/config_wizard.py @@ -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 @@ -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 diff --git a/resources/lib/utils/esn.py b/resources/lib/utils/esn.py index 0a28ab38f..bcbae56b6 100644 --- a/resources/lib/utils/esn.py +++ b/resources/lib/utils/esn.py @@ -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