summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h107
1 files changed, 107 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h
new file mode 100644
index 0000000..bee00ef
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h
@@ -0,0 +1,107 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2018 Team Kodi
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../../AddonBase.h"
23
24/*
25 * For interface between add-on and kodi.
26 *
27 * This structure defines the addresses of functions stored inside Kodi which
28 * are then available for the add-on to call
29 *
30 * All function pointers there are used by the C++ interface functions below.
31 * You find the set of them on xbmc/addons/interfaces/General.cpp
32 *
33 * Note: For add-on development itself this is not needed
34 */
35
36static const char* INTERFACE_ANDROID_SYSTEM_NAME = "ANDROID_SYSTEM";
37static const char* INTERFACE_ANDROID_SYSTEM_VERSION = "1.0.0";
38static const char* INTERFACE_ANDROID_SYSTEM_VERSION_MIN = "1.0.0";
39
40struct AddonToKodiFuncTable_android_system
41{
42 void* (*get_jni_env)();
43 int (*get_sdk_version)();
44};
45
46//==============================================================================
47///
48/// \defgroup cpp_kodi_platform Interface - kodi::platform
49/// \ingroup cpp
50/// @brief **Android platform specific functions**
51///
52/// #include <kodi/platform/android/System.h>"
53///
54//------------------------------------------------------------------------------
55
56namespace kodi
57{
58namespace platform
59{
60 class CInterfaceAndroidSystem
61 {
62 public:
63 CInterfaceAndroidSystem()
64 : m_interface(static_cast<AddonToKodiFuncTable_android_system*>(GetInterface(INTERFACE_ANDROID_SYSTEM_NAME, INTERFACE_ANDROID_SYSTEM_VERSION)))
65 {};
66
67 //============================================================================
68 ///
69 /// \ingroup cpp_kodi_platform
70 /// @brief request an JNI env pointer for the calling thread.
71 /// JNI env has to be controlled by kodi because of the underlying
72 /// threading concep.
73 ///
74 /// @param[in]:
75 /// @return JNI env pointer for the calling thread
76 ///
77 inline void * GetJNIEnv()
78 {
79 if (m_interface)
80 return m_interface->get_jni_env();
81
82 return nullptr;
83 }
84 //----------------------------------------------------------------------------
85
86 //============================================================================
87 ///
88 /// \ingroup cpp_kodi_platform
89 /// @brief request the android sdk version to e.g. initialize JNIBase.
90 ///
91 /// @param[in]:
92 /// @return Android SDK version
93 ///
94 inline int GetSDKVersion()
95 {
96 if (m_interface)
97 return m_interface->get_sdk_version();
98
99 return 0;
100 }
101
102 private:
103 AddonToKodiFuncTable_android_system *m_interface;
104 };
105 //----------------------------------------------------------------------------
106} /* namespace platform */
107} /* namespace kodi */