From be933ef2241d79558f91796cc5b3a161f72ebf9c Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 19 Oct 2020 00:52:24 +0200 Subject: sync with upstream --- .../include/kodi/platform/android/System.h | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/platform/android/System.h (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/platform/android') diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/platform/android/System.h b/xbmc/addons/kodi-dev-kit/include/kodi/platform/android/System.h new file mode 100644 index 0000000..245abd6 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/platform/android/System.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "../../AddonBase.h" +#include "../../c-api/platform/android/system.h" + +#ifdef __cplusplus +namespace kodi +{ +namespace platform +{ + +//============================================================================== +/// @defgroup cpp_kodi_platform_CInterfaceAndroidSystem class CInterfaceAndroidSystem +/// @ingroup cpp_kodi_platform +/// @brief **Android platform specific functions**\n +/// C++ class to query Android specific things in Kodi. +/// +/// It has the header is @ref System.h "#include ". +/// +/// ---------------------------------------------------------------------------- +/// +/// **Example:** +/// ~~~~~~~~~~~~~{.cpp} +/// #include +/// +/// #if defined(ANDROID) +/// kodi::platform::CInterfaceAndroidSystem system; +/// if (system.GetSDKVersion() >= 23) +/// { +/// ... +/// } +/// #endif +/// ~~~~~~~~~~~~~ +/// +class ATTRIBUTE_HIDDEN CInterfaceAndroidSystem +{ +public: + CInterfaceAndroidSystem() + : m_interface(static_cast( + GetInterface(INTERFACE_ANDROID_SYSTEM_NAME, INTERFACE_ANDROID_SYSTEM_VERSION))){}; + + //============================================================================ + /// @ingroup cpp_kodi_platform_CInterfaceAndroidSystem + /// @brief Request an JNI env pointer for the calling thread. + /// + /// JNI env has to be controlled by kodi because of the underlying + /// threading concep. + /// + /// @return JNI env pointer for the calling thread + /// + inline void* GetJNIEnv() + { + if (m_interface) + return m_interface->get_jni_env(); + + return nullptr; + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_platform_CInterfaceAndroidSystem + /// @brief Request the android sdk version to e.g. initialize `JNIBase`. + /// + /// @return Android SDK version + /// + inline int GetSDKVersion() + { + if (m_interface) + return m_interface->get_sdk_version(); + + return 0; + } + //---------------------------------------------------------------------------- + + //============================================================================ + /// @ingroup cpp_kodi_platform_CInterfaceAndroidSystem + /// @brief Request the android main class name e.g. `org.xbmc.kodi`. + /// + /// @return package class name + /// + inline std::string GetClassName() + { + if (m_interface) + return m_interface->get_class_name(); + + return std::string(); + } + //---------------------------------------------------------------------------- + +private: + AddonToKodiFuncTable_android_system* m_interface; +}; +//------------------------------------------------------------------------------ + +} /* namespace platform */ +} /* namespace kodi */ +#endif /* __cplusplus */ -- cgit v1.2.3