-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13706 from peak3d/platforminfo
[Binary Addon] Generic interface provider callback
- Loading branch information
Showing
11 changed files
with
274 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2005-2018 Team Kodi | ||
* http://kodi.tv | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with KODI; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "System.h" | ||
#include "addons/binary-addons/AddonDll.h" | ||
#include "addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h" | ||
|
||
#include "platform/android/activity/XBMCApp.h" | ||
|
||
static AddonToKodiFuncTable_android_system function_table; | ||
|
||
namespace ADDON | ||
{ | ||
|
||
void Interface_Android::Register() | ||
{ | ||
function_table.get_jni_env = get_jni_env; | ||
function_table.get_sdk_version = get_sdk_version; | ||
CAddonDll::RegisterInterface(Get); | ||
} | ||
|
||
void* Interface_Android::Get(const std::string &name, const std::string &version) | ||
{ | ||
if (name == INTERFACE_ANDROID_SYSTEM_NAME | ||
&& version >= INTERFACE_ANDROID_SYSTEM_VERSION_MIN | ||
&& version <= INTERFACE_ANDROID_SYSTEM_VERSION) | ||
return &function_table; | ||
|
||
return nullptr; | ||
}; | ||
|
||
void* Interface_Android::get_jni_env() | ||
{ | ||
return xbmc_jnienv(); | ||
} | ||
|
||
int Interface_Android::get_sdk_version() | ||
{ | ||
return CXBMCApp::get()->getActivity()->sdkVersion; | ||
} | ||
|
||
} //namespace ADDON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
/* | ||
* Copyright (C) 2005-2018 Team Kodi | ||
* http://kodi.tv | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with KODI; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include <string> | ||
|
||
namespace ADDON | ||
{ | ||
|
||
struct Interface_Android | ||
{ | ||
static void Register(); | ||
static void* Get(const std::string &name, const std::string &version); | ||
|
||
static void* get_jni_env(); | ||
static int get_sdk_version(); | ||
}; | ||
|
||
} //namespace ADDON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#pragma once | ||
/* | ||
* Copyright (C) 2005-2018 Team Kodi | ||
* http://kodi.tv | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with KODI; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "../../AddonBase.h" | ||
|
||
/* | ||
* For interface between add-on and kodi. | ||
* | ||
* This structure defines the addresses of functions stored inside Kodi which | ||
* are then available for the add-on to call | ||
* | ||
* All function pointers there are used by the C++ interface functions below. | ||
* You find the set of them on xbmc/addons/interfaces/General.cpp | ||
* | ||
* Note: For add-on development itself this is not needed | ||
*/ | ||
|
||
static const char* INTERFACE_ANDROID_SYSTEM_NAME = "ANDROID_SYSTEM"; | ||
static const char* INTERFACE_ANDROID_SYSTEM_VERSION = "1.0.0"; | ||
static const char* INTERFACE_ANDROID_SYSTEM_VERSION_MIN = "1.0.0"; | ||
|
||
struct AddonToKodiFuncTable_android_system | ||
{ | ||
void* (*get_jni_env)(); | ||
int (*get_sdk_version)(); | ||
}; | ||
|
||
//============================================================================== | ||
/// | ||
/// \defgroup cpp_kodi_platform Interface - kodi::platform | ||
/// \ingroup cpp | ||
/// @brief **Android platform specific functions** | ||
/// | ||
/// #include <kodi/platform/android/System.h>" | ||
/// | ||
//------------------------------------------------------------------------------ | ||
|
||
namespace kodi | ||
{ | ||
namespace platform | ||
{ | ||
class CInterfaceAndroidSystem | ||
{ | ||
public: | ||
CInterfaceAndroidSystem() | ||
: m_interface(static_cast<AddonToKodiFuncTable_android_system*>(GetInterface(INTERFACE_ANDROID_SYSTEM_NAME, INTERFACE_ANDROID_SYSTEM_VERSION))) | ||
{}; | ||
|
||
//============================================================================ | ||
/// | ||
/// \ingroup cpp_kodi_platform | ||
/// @brief request an JNI env pointer for the calling thread. | ||
/// JNI env has to be controlled by kodi because of the underlying | ||
/// threading concep. | ||
/// | ||
/// @param[in]: | ||
/// @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 | ||
/// @brief request the android sdk version to e.g. initialize JNIBase. | ||
/// | ||
/// @param[in]: | ||
/// @return Android SDK version | ||
/// | ||
inline int GetSDKVersion() | ||
{ | ||
if (m_interface) | ||
return m_interface->get_sdk_version(); | ||
|
||
return 0; | ||
} | ||
|
||
private: | ||
AddonToKodiFuncTable_android_system *m_interface; | ||
}; | ||
//---------------------------------------------------------------------------- | ||
} /* namespace platform */ | ||
} /* namespace kodi */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters