blob: 245abd6660a7c14a99764ca9e761149045fb1383 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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 <kodi/platform/android/System.h>".
///
/// ----------------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.cpp}
/// #include <kodi/platform/android/System.h>
///
/// #if defined(ANDROID)
/// kodi::platform::CInterfaceAndroidSystem system;
/// if (system.GetSDKVersion() >= 23)
/// {
/// ...
/// }
/// #endif
/// ~~~~~~~~~~~~~
///
class ATTRIBUTE_HIDDEN CInterfaceAndroidSystem
{
public:
CInterfaceAndroidSystem()
: m_interface(static_cast<AddonToKodiFuncTable_android_system*>(
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 <b>`JNIBase`</b>.
///
/// @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. <b>`org.xbmc.kodi`</b>.
///
/// @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 */
|