diff options
-rw-r--r-- | xbmc/android/jni/Makefile.in | 1 | ||||
-rw-r--r-- | xbmc/android/jni/SystemProperties.cpp | 32 | ||||
-rw-r--r-- | xbmc/android/jni/SystemProperties.h | 33 | ||||
-rw-r--r-- | xbmc/windowing/egl/EGLNativeTypeAndroid.cpp | 46 | ||||
-rw-r--r-- | xbmc/windowing/egl/EGLNativeTypeAndroid.h | 4 |
5 files changed, 110 insertions, 6 deletions
diff --git a/xbmc/android/jni/Makefile.in b/xbmc/android/jni/Makefile.in index 60468782d8..d108ba701f 100644 --- a/xbmc/android/jni/Makefile.in +++ b/xbmc/android/jni/Makefile.in @@ -51,6 +51,7 @@ SRCS += Window.cpp SRCS += Build.cpp SRCS += KeyCharacterMap.cpp SRCS += Activity.cpp +SRCS += SystemProperties.cpp LIB = jni.a diff --git a/xbmc/android/jni/SystemProperties.cpp b/xbmc/android/jni/SystemProperties.cpp new file mode 100644 index 0000000000..b720894323 --- /dev/null +++ b/xbmc/android/jni/SystemProperties.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2013 Team XBMC + * http://xbmc.org + * + * 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 XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "SystemProperties.h" +#include "jutils/jutils-details.hpp" + +using namespace jni; +const char *CJNISystemProperties::m_classname = "android/os/SystemProperties"; + +std::string CJNISystemProperties::get(const std::string& property, const std::string& defaultValue) +{ + return jcast<std::string>(call_static_method<jhstring>(m_classname, + "get", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", + jcast<jhstring>(property), jcast<jhstring>(defaultValue))); +} diff --git a/xbmc/android/jni/SystemProperties.h b/xbmc/android/jni/SystemProperties.h new file mode 100644 index 0000000000..a044d47ac8 --- /dev/null +++ b/xbmc/android/jni/SystemProperties.h @@ -0,0 +1,33 @@ +#pragma once +/* + * Copyright (C) 2013 Team XBMC + * http://xbmc.org + * + * 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 XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "JNIBase.h" + +class CJNISystemProperties +{ +public: + static std::string get(const std::string& property, const std::string& defaultValue); + +private: + CJNISystemProperties(); + ~CJNISystemProperties() {}; + static const char *m_classname; +}; diff --git a/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp b/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp index 735abcb6e7..35505d1f50 100644 --- a/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp +++ b/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ +#include <stdlib.h> #include "system.h" #include <EGL/egl.h> @@ -25,8 +26,10 @@ #include "guilib/gui3d.h" #include "android/activity/XBMCApp.h" #include "utils/StringUtils.h" +#include "android/jni/SystemProperties.h" CEGLNativeTypeAndroid::CEGLNativeTypeAndroid() + : m_width(0), m_height(0) { } @@ -41,6 +44,22 @@ bool CEGLNativeTypeAndroid::CheckCompatibility() void CEGLNativeTypeAndroid::Initialize() { + m_width = m_height = 0; + + // FIXME: Temporary shield specific hack to obtain HDMI resolution + // Remove and use New Android M API + std::string displaySize = CJNISystemProperties::get("sys.display-size", ""); + CLog::Log(LOGDEBUG, "CEGLNativeTypeAndroid: display-size: %s", displaySize.c_str()); + if (!displaySize.empty()) + { + std::vector<std::string> aSize = StringUtils::Split(displaySize, "x"); + if (aSize.size() == 2) + { + m_width = StringUtils::IsInteger(aSize[0]) ? atoi(aSize[0].c_str()) : 0; + m_height = StringUtils::IsInteger(aSize[1]) ? atoi(aSize[1].c_str()) : 0; + } + } + return; } void CEGLNativeTypeAndroid::Destroy() @@ -58,7 +77,7 @@ bool CEGLNativeTypeAndroid::CreateNativeWindow() { // Android hands us a window, we don't have to create it return true; -} +} bool CEGLNativeTypeAndroid::GetNativeDisplay(XBNativeDisplayType **nativeDisplay) const { @@ -92,10 +111,18 @@ bool CEGLNativeTypeAndroid::GetNativeResolution(RESOLUTION_INFO *res) const if (!nativeWindow) return false; - ANativeWindow_acquire(*nativeWindow); - res->iWidth = ANativeWindow_getWidth(*nativeWindow); - res->iHeight= ANativeWindow_getHeight(*nativeWindow); - ANativeWindow_release(*nativeWindow); + if (!m_width || !m_height) + { + ANativeWindow_acquire(*nativeWindow); + res->iWidth = ANativeWindow_getWidth(*nativeWindow); + res->iHeight= ANativeWindow_getHeight(*nativeWindow); + ANativeWindow_release(*nativeWindow); + } + else + { + res->iWidth = m_width; + res->iHeight = m_height; + } res->fRefreshRate = 60; res->dwFlags= D3DPRESENTFLAG_PROGRESSIVE; @@ -113,7 +140,14 @@ bool CEGLNativeTypeAndroid::GetNativeResolution(RESOLUTION_INFO *res) const bool CEGLNativeTypeAndroid::SetNativeResolution(const RESOLUTION_INFO &res) { - return false; + CLog::Log(LOGDEBUG, "CEGLNativeTypeAndroid: SetNativeResolution: %dx%d", m_width, m_height); + if (m_width && m_height) + { + if (!CXBMCApp::SetBuffersGeometry(m_width, m_height, 0)) + return false; + } + + return true; } bool CEGLNativeTypeAndroid::ProbeResolutions(std::vector<RESOLUTION_INFO> &resolutions) diff --git a/xbmc/windowing/egl/EGLNativeTypeAndroid.h b/xbmc/windowing/egl/EGLNativeTypeAndroid.h index f26215d8cd..8c99c1df23 100644 --- a/xbmc/windowing/egl/EGLNativeTypeAndroid.h +++ b/xbmc/windowing/egl/EGLNativeTypeAndroid.h @@ -46,4 +46,8 @@ public: virtual bool GetPreferredResolution(RESOLUTION_INFO *res) const; virtual bool ShowWindow(bool show); + +protected: + int m_width; + int m_height; }; |