diff options
author | davilla <davilla@4pi.com> | 2013-06-30 01:08:32 -0400 |
---|---|---|
committer | davilla <davilla@4pi.com> | 2013-06-30 01:08:57 -0400 |
commit | f8b366e8c491d83b0dc42200186976f59e1bcc7d (patch) | |
tree | 495a279aa04c2f8ac55bb74c0b1e54957d66ba95 | |
parent | 66e86e659637e18a867b8d1ba020a89592eef560 (diff) |
jni: consmetic refactor to consistent appearance
68 files changed, 814 insertions, 403 deletions
diff --git a/xbmc/android/jni/ApplicationInfo.cpp b/xbmc/android/jni/ApplicationInfo.cpp index afaaf1ee59..9234a382b7 100644 --- a/xbmc/android/jni/ApplicationInfo.cpp +++ b/xbmc/android/jni/ApplicationInfo.cpp @@ -17,19 +17,20 @@ * <http://www.gnu.org/licenses/>. * */ + #include "ApplicationInfo.h" #include "jutils/jutils-details.hpp" using namespace jni; CJNIApplicationInfo::CJNIApplicationInfo(const jhobject &object) : CJNIBase(object) - ,sourceDir(jcast<std::string>(get_field<jhstring>(m_object, "sourceDir"))) - ,publicSourceDir(jcast<std::string>(get_field<jhstring>(m_object, "publicSourceDir"))) - ,dataDir(jcast<std::string>(get_field<jhstring>(m_object, "dataDir"))) + ,sourceDir( jcast<std::string>(get_field<jhstring>(m_object, "sourceDir"))) + ,publicSourceDir( jcast<std::string>(get_field<jhstring>(m_object, "publicSourceDir"))) + ,dataDir( jcast<std::string>(get_field<jhstring>(m_object, "dataDir"))) ,nativeLibraryDir(jcast<std::string>(get_field<jhstring>(m_object, "nativeLibraryDir"))) - ,packageName(jcast<std::string>(get_field<jhstring>(m_object, "packageName"))) - ,uid(get_field<int>(m_object, "uid")) + ,packageName( jcast<std::string>(get_field<jhstring>(m_object, "packageName"))) + ,uid( get_field<int>(m_object, "uid")) ,targetSdkVersion(get_field<int>(m_object, "targetSdkVersion")) - ,enabled(get_field<jboolean>(m_object, "enabled")) + ,enabled( get_field<jboolean>(m_object, "enabled")) { } diff --git a/xbmc/android/jni/ApplicationInfo.h b/xbmc/android/jni/ApplicationInfo.h index ccc2607cc9..7e421073c4 100644 --- a/xbmc/android/jni/ApplicationInfo.h +++ b/xbmc/android/jni/ApplicationInfo.h @@ -18,6 +18,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIApplicationInfo : public CJNIBase @@ -31,11 +32,12 @@ public: std::string dataDir; std::string nativeLibraryDir; std::string packageName; - int uid; - int targetSdkVersion; - bool enabled; + int uid; + int targetSdkVersion; + bool enabled; private: CJNIApplicationInfo(); }; + typedef std::vector<CJNIApplicationInfo> CJNIApplicationInfos; diff --git a/xbmc/android/jni/AudioManager.cpp b/xbmc/android/jni/AudioManager.cpp index 398d80c42d..597c85b949 100644 --- a/xbmc/android/jni/AudioManager.cpp +++ b/xbmc/android/jni/AudioManager.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "AudioManager.h" #include "jutils/jutils-details.hpp" @@ -27,15 +28,19 @@ int CJNIAudioManager::STREAM_MUSIC(0); void CJNIAudioManager::PopulateStaticFields() { jhclass clazz = find_class("android/media/AudioManager"); - STREAM_MUSIC = (get_static_field<int>(clazz, "STREAM_MUSIC")); + STREAM_MUSIC = (get_static_field<int>(clazz, "STREAM_MUSIC")); } int CJNIAudioManager::getStreamMaxVolume() { - return call_method<jint>(m_object, "getStreamMaxVolume", "(I)I", STREAM_MUSIC); + return call_method<jint>(m_object, + "getStreamMaxVolume", "(I)I", + STREAM_MUSIC); } void CJNIAudioManager::setStreamVolume(int index /* 0 */, int flags /* NONE */) { - call_method<void>(m_object, "setStreamVolume", "(III)V", STREAM_MUSIC, index, flags); + call_method<void>(m_object, + "setStreamVolume", "(III)V", + STREAM_MUSIC, index, flags); } diff --git a/xbmc/android/jni/AudioManager.h b/xbmc/android/jni/AudioManager.h index e9f740884e..a759cd0c52 100644 --- a/xbmc/android/jni/AudioManager.h +++ b/xbmc/android/jni/AudioManager.h @@ -18,20 +18,23 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIAudioManager : public CJNIBase { public: + CJNIAudioManager(const jni::jhobject &object) : CJNIBase(object) {}; + ~CJNIAudioManager() {}; + // Note removal of streamType param. - int getStreamMaxVolume(); + int getStreamMaxVolume(); void setStreamVolume(int index = 0, int flags = 0); static void PopulateStaticFields(); - ~CJNIAudioManager(){}; - CJNIAudioManager(const jni::jhobject &object) : CJNIBase(object){}; private: CJNIAudioManager(); + static int STREAM_MUSIC; }; diff --git a/xbmc/android/jni/BaseColumns.cpp b/xbmc/android/jni/BaseColumns.cpp index c466b26a3b..5bb7cc1ca7 100644 --- a/xbmc/android/jni/BaseColumns.cpp +++ b/xbmc/android/jni/BaseColumns.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "BaseColumns.h" #include "jutils/jutils-details.hpp" @@ -28,6 +29,6 @@ std::string CJNIBaseColumns::_COUNT; void CJNIBaseColumns::PopulateStaticFields() { jhclass clazz = find_class("android/provider/BaseColumns"); - _ID = (jcast<std::string>(get_static_field<jhstring>(clazz, "_ID"))); + _ID = (jcast<std::string>(get_static_field<jhstring>(clazz, "_ID"))); _COUNT = (jcast<std::string>(get_static_field<jhstring>(clazz, "_COUNT"))); } diff --git a/xbmc/android/jni/BaseColumns.h b/xbmc/android/jni/BaseColumns.h index b60a43421c..e31659f808 100644 --- a/xbmc/android/jni/BaseColumns.h +++ b/xbmc/android/jni/BaseColumns.h @@ -18,13 +18,17 @@ * <http://www.gnu.org/licenses/>. * */ + #include <string> + class CJNIBaseColumns { public: + static void PopulateStaticFields(); + static std::string _ID; static std::string _COUNT; - static void PopulateStaticFields(); + private: CJNIBaseColumns(); }; diff --git a/xbmc/android/jni/BitSet.cpp b/xbmc/android/jni/BitSet.cpp index 6ffecd36b6..03aa30132e 100644 --- a/xbmc/android/jni/BitSet.cpp +++ b/xbmc/android/jni/BitSet.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "BitSet.h" #include "jutils/jutils-details.hpp" @@ -29,17 +30,23 @@ CJNIBitSet::CJNIBitSet() : CJNIBase("java.util.BitSet") CJNIBitSet::CJNIBitSet(int bitCount) : CJNIBase("java.util.BitSet") { - m_object = new_object(GetClassName(), "<init>", "(I)V", (jint)bitCount); + m_object = new_object(GetClassName(), + "<init>", "(I)V", + (jint)bitCount); } void CJNIBitSet::flip(int index) { - call_method<void>(m_object, "flip", "(I)V", index); + call_method<void>(m_object, + "flip", "(I)V", + index); } void CJNIBitSet::flip(int fromIndex, int toIndex) { - call_method<void>(m_object, "flip", "(II)V", fromIndex, toIndex); + call_method<void>(m_object, + "flip", "(II)V", + fromIndex, toIndex); } void CJNIBitSet::set(int index) @@ -49,106 +56,140 @@ void CJNIBitSet::set(int index) void CJNIBitSet::set(int fromIndex, bool state) { - call_method<void>(m_object, "fromIndex", "(IZ)V", fromIndex, state); + call_method<void>(m_object, + "fromIndex", "(IZ)V", + fromIndex, state); } void CJNIBitSet::set(int fromIndex, int toIndex) { - call_method<void>(m_object, "set", "(II)V", fromIndex, toIndex); + call_method<void>(m_object, + "set", "(II)V", + fromIndex, toIndex); } void CJNIBitSet::set(int fromIndex, int toIndex, bool state) { - call_method<void>(m_object, "set", "(IIZ)V", fromIndex, toIndex, state); + call_method<void>(m_object, + "set", "(IIZ)V", + fromIndex, toIndex, state); } void CJNIBitSet::clear(int index) { - call_method<void>(m_object, "clear", "(I)V", index); + call_method<void>(m_object, + "clear", "(I)V", + index); } void CJNIBitSet::clear(int fromIndex, int toIndex) { - call_method<void>(m_object, "clear", "(II)V", fromIndex, toIndex); + call_method<void>(m_object, + "clear", "(II)V", + fromIndex, toIndex); } void CJNIBitSet::clear() { - call_method<void>(m_object, "clear", "()V"); + call_method<void>(m_object, + "clear", "()V"); } bool CJNIBitSet::get(int index) { - return call_method<jboolean>(m_object, "get", "(I)V", index); + return call_method<jboolean>(m_object, + "get", "(I)V", + index); } CJNIBitSet CJNIBitSet::get(int fromIndex, int toIndex) { - return call_method<jhobject>(m_object, "get", "(II)V", fromIndex, toIndex); + return call_method<jhobject>(m_object, + "get", "(II)V", + fromIndex, toIndex); } int CJNIBitSet::nextSetBit(int index) { - return call_method<jint>(m_object, "nextSetBit", "(I)I", index); + return call_method<jint>(m_object, + "nextSetBit", "(I)I", + index); } int CJNIBitSet::nextClearBit(int index) { - return call_method<jint>(m_object, "nextClearBit", "(I)I", index); + return call_method<jint>(m_object, + "nextClearBit", "(I)I", + index); } int CJNIBitSet::length() { - return call_method<jint>(m_object, "length", "()I"); + return call_method<jint>(m_object, + "length", "()I"); } bool CJNIBitSet::isEmpty() { - return call_method<jboolean>(m_object, "isEmpty", "()Z"); + return call_method<jboolean>(m_object, + "isEmpty", "()Z"); } bool CJNIBitSet::intersects(const CJNIBitSet &bs) { - return call_method<jboolean>(m_object, "intersects", "(Ljava/util/BitSet;)Z", bs.get_raw()); + return call_method<jboolean>(m_object, + "intersects", "(Ljava/util/BitSet;)Z", + bs.get_raw()); } int CJNIBitSet::cardinality() { - return call_method<jint>(m_object, "cardinality", "()I"); + return call_method<jint>(m_object, + "cardinality", "()I"); } void CJNIBitSet::jand(const CJNIBitSet &bs) { - call_method<void>(m_object, "jand", "(Ljava/util/BitSet;)V", bs.get_raw()); + call_method<void>(m_object, + "jand", "(Ljava/util/BitSet;)V", + bs.get_raw()); } void CJNIBitSet::jor(const CJNIBitSet &bs) { - call_method<void>(m_object, "jor", "(Ljava/util/BitSet;)V", bs.get_raw()); + call_method<void>(m_object, + "jor", "(Ljava/util/BitSet;)V", + bs.get_raw()); } void CJNIBitSet::jxor(const CJNIBitSet &bs) { - call_method<void>(m_object, "jxor", "(Ljava/util/BitSet;)V", bs.get_raw()); + call_method<void>(m_object, + "jxor", "(Ljava/util/BitSet;)V", + bs.get_raw()); } void CJNIBitSet::jandNot(const CJNIBitSet &bs) { - call_method<void>(m_object, "jandNot", "(Ljava/util/BitSet;)V", bs.get_raw()); + call_method<void>(m_object, + "jandNot", "(Ljava/util/BitSet;)V", + bs.get_raw()); } int CJNIBitSet::hashCode() { - return call_method<jint>(m_object, "hashCode", "()I"); + return call_method<jint>(m_object, + "hashCode", "()I"); } int CJNIBitSet::size() { - return call_method<jint>(m_object, "size", "()I"); + return call_method<jint>(m_object, + "size", "()I"); } std::string CJNIBitSet::toString() { - return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "toString", "()Ljava/lang/String;")); } - diff --git a/xbmc/android/jni/BitSet.h b/xbmc/android/jni/BitSet.h index d632cffbc5..d5842d5ff7 100644 --- a/xbmc/android/jni/BitSet.h +++ b/xbmc/android/jni/BitSet.h @@ -18,15 +18,16 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIBitSet : public CJNIBase { public: - ~CJNIBitSet(){}; - CJNIBitSet(const jni::jhobject &object) : CJNIBase(object){}; CJNIBitSet(); CJNIBitSet(int); + CJNIBitSet(const jni::jhobject &object) : CJNIBase(object) {}; + ~CJNIBitSet() {}; void flip(int); void flip(int, int); @@ -39,17 +40,17 @@ public: void clear(); bool get(int); CJNIBitSet get(int, int); - int nextSetBit(int); - int nextClearBit(int); - int length(); + int nextSetBit(int); + int nextClearBit(int); + int length(); bool isEmpty(); bool intersects(const CJNIBitSet &); - int cardinality(); + int cardinality(); void jand(const CJNIBitSet &); void jor(const CJNIBitSet &); void jxor(const CJNIBitSet &); void jandNot(const CJNIBitSet &); - int hashCode(); - int size(); + int hashCode(); + int size(); std::string toString(); }; diff --git a/xbmc/android/jni/Bitmap.h b/xbmc/android/jni/Bitmap.h index cd02c03361..eb1c4ac701 100644 --- a/xbmc/android/jni/Bitmap.h +++ b/xbmc/android/jni/Bitmap.h @@ -18,13 +18,13 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIBitmap : public CJNIBase { public: CJNIBitmap(); - ~CJNIBitmap(){}; - CJNIBitmap(const jni::jhobject &object) : CJNIBase(object){}; - + CJNIBitmap(const jni::jhobject &object) : CJNIBase(object) {}; + ~CJNIBitmap() {}; }; diff --git a/xbmc/android/jni/BitmapDrawable.cpp b/xbmc/android/jni/BitmapDrawable.cpp index f36385d4af..aa4efd9e32 100644 --- a/xbmc/android/jni/BitmapDrawable.cpp +++ b/xbmc/android/jni/BitmapDrawable.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "BitmapDrawable.h" #include "Bitmap.h" #include "jutils/jutils-details.hpp" @@ -31,5 +32,6 @@ CJNIBitmapDrawable::CJNIBitmapDrawable() : CJNIDrawable("android/graphics/drawab CJNIBitmap CJNIBitmapDrawable::getBitmap() { - return (CJNIBitmap)call_method<jhobject>(m_object, "getBitmap", "()Landroid/graphics/Bitmap;"); + return call_method<jhobject>(m_object, + "getBitmap", "()Landroid/graphics/Bitmap;"); } diff --git a/xbmc/android/jni/BitmapDrawable.h b/xbmc/android/jni/BitmapDrawable.h index fe505f9da9..db287ab4d9 100644 --- a/xbmc/android/jni/BitmapDrawable.h +++ b/xbmc/android/jni/BitmapDrawable.h @@ -18,14 +18,18 @@ * <http://www.gnu.org/licenses/>. * */ + #include "Drawable.h" + class CJNIBitmap; + class CJNIBitmapDrawable : public CJNIDrawable { public: CJNIBitmapDrawable(); - CJNIBitmapDrawable(const jni::jhobject &object) : CJNIDrawable(object){}; - CJNIBitmapDrawable(const CJNIDrawable &drawable) : CJNIDrawable(drawable.get_raw()){}; + CJNIBitmapDrawable(const jni::jhobject &object) : CJNIDrawable(object) {}; + CJNIBitmapDrawable(const CJNIDrawable &drawable) : CJNIDrawable(drawable.get_raw()) {}; + ~CJNIBitmapDrawable() {}; + CJNIBitmap getBitmap(); - ~CJNIBitmapDrawable(){}; }; diff --git a/xbmc/android/jni/BroadcastReceiver.h b/xbmc/android/jni/BroadcastReceiver.h index 0ba76bb2b6..78208c3a31 100644 --- a/xbmc/android/jni/BroadcastReceiver.h +++ b/xbmc/android/jni/BroadcastReceiver.h @@ -18,18 +18,21 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIIntent; + class CJNIBroadcastReceiver : public CJNIBase { public: static void _onReceive(JNIEnv *env, jobject context, jobject intent); protected: - virtual void onReceive(CJNIIntent intent)=0; - ~CJNIBroadcastReceiver(){}; CJNIBroadcastReceiver(const std::string &className); + ~CJNIBroadcastReceiver(){}; + + virtual void onReceive(CJNIIntent intent)=0; private: - static CJNIBroadcastReceiver* m_receiverInstance; + static CJNIBroadcastReceiver *m_receiverInstance; }; diff --git a/xbmc/android/jni/CharSequence.cpp b/xbmc/android/jni/CharSequence.cpp index a3d2932e53..23b23167ff 100644 --- a/xbmc/android/jni/CharSequence.cpp +++ b/xbmc/android/jni/CharSequence.cpp @@ -17,11 +17,14 @@ * <http://www.gnu.org/licenses/>. * */ + #include "CharSequence.h" #include "jutils/jutils-details.hpp" + using namespace jni; std::string CJNICharSequence::toString() { - return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "toString", "()Ljava/lang/String;")); } diff --git a/xbmc/android/jni/CharSequence.h b/xbmc/android/jni/CharSequence.h index 80adb065ba..85b88f5f22 100644 --- a/xbmc/android/jni/CharSequence.h +++ b/xbmc/android/jni/CharSequence.h @@ -18,14 +18,17 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNICharSequence : public CJNIBase { public: - ~CJNICharSequence(){}; - CJNICharSequence(const jni::jhobject &object) : CJNIBase(object){}; + CJNICharSequence(const jni::jhobject &object) : CJNIBase(object) {}; + ~CJNICharSequence() {}; + std::string toString(); + private: CJNICharSequence(); }; diff --git a/xbmc/android/jni/ClassLoader.cpp b/xbmc/android/jni/ClassLoader.cpp index d1d685cec3..72f7eb4bc4 100644 --- a/xbmc/android/jni/ClassLoader.cpp +++ b/xbmc/android/jni/ClassLoader.cpp @@ -17,11 +17,15 @@ * <http://www.gnu.org/licenses/>. * */ + #include "ClassLoader.h" #include "jutils/jutils-details.hpp" + using namespace jni; jhclass CJNIClassLoader::loadClass(std::string className) { - return (jhclass)call_method<jhclass>(m_object, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;", jcast<jhstring>(className)); + return call_method<jhclass>(m_object, + "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;", + jcast<jhstring>(className)); } diff --git a/xbmc/android/jni/ClassLoader.h b/xbmc/android/jni/ClassLoader.h index 821c241e93..1976e773cc 100644 --- a/xbmc/android/jni/ClassLoader.h +++ b/xbmc/android/jni/ClassLoader.h @@ -18,14 +18,17 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIClassLoader : public CJNIBase { public: - ~CJNIClassLoader(){}; + CJNIClassLoader(const jni::jhobject &object) : CJNIBase(object) {}; + ~CJNIClassLoader() {}; + jni::jhclass loadClass(std::string className); - CJNIClassLoader(const jni::jhobject &object) : CJNIBase(object){}; + private: CJNIClassLoader(); }; diff --git a/xbmc/android/jni/ConnectivityManager.cpp b/xbmc/android/jni/ConnectivityManager.cpp index e27ae660c2..a33cbf04ed 100644 --- a/xbmc/android/jni/ConnectivityManager.cpp +++ b/xbmc/android/jni/ConnectivityManager.cpp @@ -17,10 +17,13 @@ * <http://www.gnu.org/licenses/>. * */ + #include "ConnectivityManager.h" #include "NetworkInfo.h" #include "jutils/jutils-details.hpp" +using namespace jni; + int CJNIConnectivityManager::TYPE_MOBILE(0); int CJNIConnectivityManager::TYPE_WIFI(0); int CJNIConnectivityManager::TYPE_MOBILE_MMS(0); @@ -32,81 +35,96 @@ int CJNIConnectivityManager::TYPE_BLUETOOTH(0); int CJNIConnectivityManager::TYPE_DUMMY(0); int CJNIConnectivityManager::TYPE_ETHERNET(0); int CJNIConnectivityManager::DEFAULT_NETWORK_PREFERENCE(0); -using namespace jni; void CJNIConnectivityManager::PopulateStaticFields() { jhclass clazz = find_class("android.net.ConnectivityManager"); - TYPE_MOBILE = (get_static_field<int>(clazz, "TYPE_MOBILE")); - TYPE_WIFI = (get_static_field<int>(clazz, "TYPE_WIFI")); - TYPE_MOBILE_MMS = (get_static_field<int>(clazz, "TYPE_MOBILE_MMS")); - TYPE_MOBILE_SUPL = (get_static_field<int>(clazz, "TYPE_MOBILE_SUPL")); - TYPE_MOBILE_DUN = (get_static_field<int>(clazz, "TYPE_MOBILE_DUN")); + TYPE_MOBILE = (get_static_field<int>(clazz, "TYPE_MOBILE")); + TYPE_WIFI = (get_static_field<int>(clazz, "TYPE_WIFI")); + TYPE_MOBILE_MMS = (get_static_field<int>(clazz, "TYPE_MOBILE_MMS")); + TYPE_MOBILE_SUPL = (get_static_field<int>(clazz, "TYPE_MOBILE_SUPL")); + TYPE_MOBILE_DUN = (get_static_field<int>(clazz, "TYPE_MOBILE_DUN")); TYPE_MOBILE_HIPRI = (get_static_field<int>(clazz, "TYPE_MOBILE_HIPRI")); - TYPE_WIMAX = (get_static_field<int>(clazz, "TYPE_WIMAX")); - TYPE_BLUETOOTH = (get_static_field<int>(clazz, "TYPE_BLUETOOTH")); - TYPE_DUMMY = (get_static_field<int>(clazz, "TYPE_DUMMY")); - TYPE_ETHERNET = (get_static_field<int>(clazz, "TYPE_ETHERNET")); + TYPE_WIMAX = (get_static_field<int>(clazz, "TYPE_WIMAX")); + TYPE_BLUETOOTH = (get_static_field<int>(clazz, "TYPE_BLUETOOTH")); + TYPE_DUMMY = (get_static_field<int>(clazz, "TYPE_DUMMY")); + TYPE_ETHERNET = (get_static_field<int>(clazz, "TYPE_ETHERNET")); DEFAULT_NETWORK_PREFERENCE = (get_static_field<int>(clazz, "DEFAULT_NETWORK_PREFERENCE")); } bool CJNIConnectivityManager::isNetworkTypeValid(int networkType) { - return call_method<jboolean>(m_object, "isNetworkTypeValid", "(I)Z", networkType); + return call_method<jboolean>(m_object, + "isNetworkTypeValid", "(I)Z", + networkType); } void CJNIConnectivityManager::setNetworkPreference(int preference) { - return call_method<void>(m_object, "setNetworkPreference", "(I)V", preference); + return call_method<void>(m_object, + "setNetworkPreference", "(I)V", + preference); } int CJNIConnectivityManager::getNetworkPreference() { - return call_method<jint>(m_object, "getNetworkPreference", "()I"); + return call_method<jint>(m_object, + "getNetworkPreference", "()I"); } CJNINetworkInfo CJNIConnectivityManager::getActiveNetworkInfo() { - return (CJNINetworkInfo)call_method<jhobject>(m_object, "getActiveNetworkInfo", "()Landroid/net/NetworkInfo;"); + return call_method<jhobject>(m_object, + "getActiveNetworkInfo", "()Landroid/net/NetworkInfo;"); } CJNINetworkInfo CJNIConnectivityManager::getNetworkInfo(int networkType) { - return (CJNINetworkInfo)call_method<jhobject>(m_object, "getNetworkInfo", "(I)Landroid/net/NetworkInfo;", networkType); + return call_method<jhobject>(m_object, + "getNetworkInfo", "(I)Landroid/net/NetworkInfo;", + networkType); } std::vector<CJNINetworkInfo> CJNIConnectivityManager::getAllNetworkInfo() { JNIEnv *env = xbmc_jnienv(); - jhobjectArray oNetworks = call_method<jhobjectArray>(m_object, "getAllNetworkInfo", "()[Landroid/net/NetworkInfo;"); + + jhobjectArray oNetworks = call_method<jhobjectArray>(m_object, + "getAllNetworkInfo", "()[Landroid/net/NetworkInfo;"); jsize size = env->GetArrayLength(oNetworks.get()); std::vector<CJNINetworkInfo> networks; networks.reserve(size); for(int i = 0; i < size; i++) - { networks.push_back(CJNINetworkInfo(jhobject(env->GetObjectArrayElement(oNetworks.get(), i)))); - } + return networks; } int CJNIConnectivityManager::startUsingNetworkFeature(int networkType, std::string feature) { - return call_method<jint>(m_object, "startUsingNetworkFeature", "(ILjava/lang/String;)I", networkType, jcast<jhstring>(feature)); + return call_method<jint>(m_object, + "startUsingNetworkFeature", "(ILjava/lang/String;)I", + networkType, jcast<jhstring>(feature)); } int CJNIConnectivityManager::stopUsingNetworkFeature(int networkType, std::string feature) { - return call_method<jint>(m_object, "stopUsingNetworkFeature", "(ILjava/lang/String;)I", networkType, jcast<jhstring>(feature)); + return call_method<jint>(m_object, + "stopUsingNetworkFeature", "(ILjava/lang/String;)I", + networkType, jcast<jhstring>(feature)); } bool CJNIConnectivityManager::requestRouteToHost(int networkType, int hostAddress) { - return call_method<jboolean>(m_object, "requestRouteToHost", "(II)Z", networkType, hostAddress); + return call_method<jboolean>(m_object, + "requestRouteToHost", "(II)Z", + networkType, hostAddress); } bool CJNIConnectivityManager::getBackgroundDataSetting() { - return call_method<jboolean>(m_object, "getBackgroundDataSetting", "()Z"); + return call_method<jboolean>(m_object, + "getBackgroundDataSetting", "()Z"); } diff --git a/xbmc/android/jni/ConnectivityManager.h b/xbmc/android/jni/ConnectivityManager.h index 60a53f873c..45fcf7ce0e 100644 --- a/xbmc/android/jni/ConnectivityManager.h +++ b/xbmc/android/jni/ConnectivityManager.h @@ -18,24 +18,28 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNINetworkInfo; + class CJNIConnectivityManager : public CJNIBase { public: - CJNIConnectivityManager(const jni::jhobject &object) : CJNIBase(object){}; + CJNIConnectivityManager(const jni::jhobject &object) : CJNIBase(object) {}; + bool isNetworkTypeValid(int); void setNetworkPreference(int); - int getNetworkPreference(); + int getNetworkPreference(); CJNINetworkInfo getActiveNetworkInfo(); CJNINetworkInfo getNetworkInfo(int); std::vector<CJNINetworkInfo> getAllNetworkInfo(); - int startUsingNetworkFeature(int, std::string); - int stopUsingNetworkFeature(int, std::string); + int startUsingNetworkFeature(int, std::string); + int stopUsingNetworkFeature(int, std::string); bool requestRouteToHost(int, int); bool getBackgroundDataSetting(); + static void PopulateStaticFields(); static int TYPE_MOBILE; static int TYPE_WIFI; static int TYPE_MOBILE_MMS; @@ -48,7 +52,7 @@ public: static int TYPE_ETHERNET; static int DEFAULT_NETWORK_PREFERENCE; - static void PopulateStaticFields(); + private: CJNIConnectivityManager(); }; diff --git a/xbmc/android/jni/ContentResolver.cpp b/xbmc/android/jni/ContentResolver.cpp index 909fb14d18..2578acef51 100644 --- a/xbmc/android/jni/ContentResolver.cpp +++ b/xbmc/android/jni/ContentResolver.cpp @@ -17,31 +17,33 @@ * <http://www.gnu.org/licenses/>. * */ + #include "ContentResolver.h" #include "Cursor.h" #include "jutils/jutils-details.hpp" #include "URI.h" + +using namespace jni; + std::string CJNIContentResolver::SCHEME_CONTENT; std::string CJNIContentResolver::SCHEME_ANDROID_RESOURCE; std::string CJNIContentResolver::SCHEME_FILE; std::string CJNIContentResolver::CURSOR_ITEM_BASE_TYPE; std::string CJNIContentResolver::CURSOR_DIR_BASE_TYPE; -using namespace jni; void CJNIContentResolver::PopulateStaticFields() { jhclass clazz = find_class("android/content/ContentResolver"); - SCHEME_CONTENT = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_CONTENT")); + SCHEME_CONTENT = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_CONTENT")); SCHEME_ANDROID_RESOURCE = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_ANDROID_RESOURCE")); - SCHEME_FILE = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_FILE")); - CURSOR_ITEM_BASE_TYPE = jcast<std::string>(get_static_field<jhstring>(clazz,"CURSOR_ITEM_BASE_TYPE")); - CURSOR_DIR_BASE_TYPE = jcast<std::string>(get_static_field<jhstring>(clazz,"CURSOR_DIR_BASE_TYPE")); + SCHEME_FILE = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_FILE")); + CURSOR_ITEM_BASE_TYPE = jcast<std::string>(get_static_field<jhstring>(clazz,"CURSOR_ITEM_BASE_TYPE")); + CURSOR_DIR_BASE_TYPE = jcast<std::string>(get_static_field<jhstring>(clazz,"CURSOR_DIR_BASE_TYPE")); } CJNICursor CJNIContentResolver::query(const CJNIURI &uri, const std::vector<std::string> &projection, const std::string &selection, const std::vector<std::string> &selectionArgs, const std::string &sortOrder) { - - return (CJNICursor)(call_method<jhobject>(m_object, \ - "query","(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;", \ - uri.get_raw(), jcast<jhobjectArray>(projection), jcast<jhstring>(selection), jcast<jhobjectArray>(selectionArgs), jcast<jhstring>(sortOrder))); + return (CJNICursor)(call_method<jhobject>(m_object, + "query","(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;", + uri.get_raw(), jcast<jhobjectArray>(projection), jcast<jhstring>(selection), jcast<jhobjectArray>(selectionArgs), jcast<jhstring>(sortOrder))); } diff --git a/xbmc/android/jni/ContentResolver.h b/xbmc/android/jni/ContentResolver.h index 1add109df7..d1b0110ebf 100644 --- a/xbmc/android/jni/ContentResolver.h +++ b/xbmc/android/jni/ContentResolver.h @@ -18,24 +18,26 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNICursor; class CJNIURI; + class CJNIContentResolver : public CJNIBase { public: - CJNIContentResolver(const jni::jhobject &object) : CJNIBase(object){}; + CJNIContentResolver(const jni::jhobject &object) : CJNIBase(object) {}; + + CJNICursor query(const CJNIURI &uri, const std::vector<std::string> &projection, const std::string &selection, const std::vector<std::string> &selectionArgs, const std::string &sortOrder); + static void PopulateStaticFields(); static std::string SCHEME_CONTENT; static std::string SCHEME_ANDROID_RESOURCE; static std::string SCHEME_FILE; static std::string CURSOR_ITEM_BASE_TYPE; static std::string CURSOR_DIR_BASE_TYPE; - CJNICursor query(const CJNIURI &uri, const std::vector<std::string> &projection, const std::string &selection, const std::vector<std::string> &selectionArgs, const std::string &sortOrder); - - static void PopulateStaticFields(); private: CJNIContentResolver(); }; diff --git a/xbmc/android/jni/Context.cpp b/xbmc/android/jni/Context.cpp index 529dc7db63..ad32f83a8c 100644 --- a/xbmc/android/jni/Context.cpp +++ b/xbmc/android/jni/Context.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "Context.h" #include "PackageManager.h" #include <android/log.h> @@ -35,12 +36,18 @@ #include "Cursor.h" #include "ConnectivityManager.h" #include "AudioManager.h" +#include "Surface.h" +#include "MediaCodec.h" +#include "MediaCodecInfo.h" +#include "MediaFormat.h" + #include <android/native_activity.h> using namespace jni; jhobject CJNIContext::m_context(0); CJNIContext* CJNIContext::m_appInstance(NULL); + CJNIContext::CJNIContext(const ANativeActivity *nativeActivity) { m_context.reset(nativeActivity->clazz); @@ -67,89 +74,116 @@ void CJNIContext::PopulateStaticFields() CJNIContentResolver::PopulateStaticFields(); CJNIConnectivityManager::PopulateStaticFields(); CJNIAudioManager::PopulateStaticFields(); - + CJNISurface::PopulateStaticFields(); + CJNIMediaCodec::PopulateStaticFields(); + CJNIMediaCodecInfoCodecProfileLevel::PopulateStaticFields(); + CJNIMediaCodecInfoCodecCapabilities::PopulateStaticFields(); + CJNIMediaFormat::PopulateStaticFields(); } CJNIPackageManager CJNIContext::GetPackageManager() { - return (CJNIPackageManager)call_method<jhobject>(m_context, "getPackageManager", "()Landroid/content/pm/PackageManager;"); + return call_method<jhobject>(m_context, + "getPackageManager", "()Landroid/content/pm/PackageManager;"); } void CJNIContext::startActivity(const CJNIIntent &intent) { - call_method<void>(jhobject(m_context), "startActivity", "(Landroid/content/Intent;)V", intent.get_raw()); + call_method<void>(jhobject(m_context), + "startActivity", "(Landroid/content/Intent;)V", + intent.get_raw()); } int CJNIContext::checkCallingOrSelfPermission(const std::string &permission) { - return call_method<int>(m_context, "checkCallingOrSelfPermission", "(Ljava/lang/String;)I", jcast<jhstring>(permission)); + return call_method<int>(m_context, + "checkCallingOrSelfPermission", "(Ljava/lang/String;)I", + jcast<jhstring>(permission)); } jhobject CJNIContext::getSystemService(const std::string &service) { - return call_method<jhobject>(m_context, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;", jcast<jhstring>(service)); + return call_method<jhobject>(m_context, + "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;", + jcast<jhstring>(service)); } CJNIIntent CJNIContext::registerReceiver(const CJNIBroadcastReceiver &receiver, const CJNIIntentFilter &filter) { - return (CJNIIntent)call_method<jhobject>(m_context, "registerReceiver", \ - "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", receiver.get_raw(), filter.get_raw()); + return call_method<jhobject>(m_context, + "registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", + receiver.get_raw(), filter.get_raw()); } CJNIIntent CJNIContext::registerReceiver(const CJNIIntentFilter &filter) { - return (CJNIIntent)call_method<jhobject>(m_context, "registerReceiver", \ - "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", (jobject)NULL, filter.get_raw()); + return call_method<jhobject>(m_context, + "registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", + (jobject)NULL, filter.get_raw()); } void CJNIContext::unregisterReceiver(const CJNIBroadcastReceiver &receiver) { - call_method<void>(m_context, "unregisterReceiver", "(Landroid/content/BroadcastReceiver;)V", receiver.get_raw()); + call_method<void>(m_context, + "unregisterReceiver", "(Landroid/content/BroadcastReceiver;)V", + receiver.get_raw()); } CJNIIntent CJNIContext::sendBroadcast(const CJNIIntent &intent) { - return (CJNIIntent)call_method<jhobject>(m_context, "sendBroadcast", "(Landroid/content/Intent;)V", intent.get_raw()); + return call_method<jhobject>(m_context, + "sendBroadcast", "(Landroid/content/Intent;)V", + intent.get_raw()); } CJNIIntent CJNIContext::getIntent() { - return (CJNIIntent)call_method<jhobject>(m_context, "getIntent", "()Landroid/content/Intent;"); + return call_method<jhobject>(m_context, + "getIntent", "()Landroid/content/Intent;"); } CJNIClassLoader CJNIContext::getClassLoader() { - return (CJNIClassLoader)call_method<jhobject>(m_context, "getClassLoader", "()Ljava/lang/ClassLoader;"); + return call_method<jhobject>(m_context, + "getClassLoader", "()Ljava/lang/ClassLoader;"); } CJNIApplicationInfo CJNIContext::getApplicationInfo() { - return (CJNIApplicationInfo)call_method<jhobject>(m_context, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;"); + return call_method<jhobject>(m_context, + "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;"); } std::string CJNIContext::getPackageResourcePath() { - return jcast<std::string>(call_method<jhstring>(m_context, "getPackageResourcePath", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_context, + "getPackageResourcePath", "()Ljava/lang/String;")); } CJNIFile CJNIContext::getCacheDir() { - return (CJNIFile)call_method<jhobject>(m_context, "getCacheDir", "()Ljava/io/File;"); + return call_method<jhobject>(m_context, + "getCacheDir", "()Ljava/io/File;"); } CJNIFile CJNIContext::getDir(const std::string &path, int mode) { - return (CJNIFile)call_method<jhobject>(m_context, "getDir", "(Ljava/lang/String;I)Ljava/io/File;", jcast<jhstring>(path), mode); + return call_method<jhobject>(m_context, + "getDir", "(Ljava/lang/String;I)Ljava/io/File;", + jcast<jhstring>(path), mode); } CJNIFile CJNIContext::getExternalFilesDir(const std::string &path) { - return (CJNIFile)call_method<jhobject>(m_context, "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;", jcast<jhstring>(path)); + return call_method<jhobject>(m_context, + "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;", + jcast<jhstring>(path)); } CJNIContentResolver CJNIContext::getContentResolver() { - return (CJNIContentResolver)call_method<jhobject>(m_context, "getContentResolver", "()Landroid/content/ContentResolver;"); + return call_method<jhobject>(m_context, + "getContentResolver", "()Landroid/content/ContentResolver;"); } void CJNIContext::_onNewIntent(JNIEnv *env, jobject context, jobject intent) diff --git a/xbmc/android/jni/Context.h b/xbmc/android/jni/Context.h index 8b17e865e2..73d47c05eb 100644 --- a/xbmc/android/jni/Context.h +++ b/xbmc/android/jni/Context.h @@ -18,8 +18,10 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" #include "BroadcastReceiver.h" + class ANativeActivity; class CJNIIntent; class CJNIPackageManager; @@ -29,6 +31,7 @@ class CJNIClassLoader; class CJNIApplicationInfo; class CJNIFile; class CJNIContentResolver; + class CJNIContext { public: @@ -50,13 +53,16 @@ public: static CJNIContentResolver getContentResolver(); static CJNIContext* GetAppInstance() { return m_appInstance; }; static void _onNewIntent(JNIEnv *env, jobject context, jobject intent); + protected: - virtual void onNewIntent(CJNIIntent intent)=0; CJNIContext(const ANativeActivity *nativeActivity); ~CJNIContext(); + virtual void onNewIntent(CJNIIntent intent)=0; + private: CJNIContext(); + void PopulateStaticFields(); void operator=(CJNIContext const&){}; static jni::jhobject m_context; diff --git a/xbmc/android/jni/Cursor.cpp b/xbmc/android/jni/Cursor.cpp index e79cb8e989..a369771719 100644 --- a/xbmc/android/jni/Cursor.cpp +++ b/xbmc/android/jni/Cursor.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "Cursor.h" #include "jutils/jutils-details.hpp" #include "URI.h" @@ -32,150 +33,189 @@ int CJNICursor::FIELD_TYPE_BLOB(0); void CJNICursor::PopulateStaticFields() { jhclass clazz = find_class("android/database/Cursor"); - FIELD_TYPE_NULL = (get_static_field<int>(clazz, "FIELD_TYPE_NULL")); - FIELD_TYPE_INTEGER = (get_static_field<int>(clazz, "FIELD_TYPE_INTEGER")); - FIELD_TYPE_FLOAT = (get_static_field<int>(clazz, "FIELD_TYPE_FLOAT")); - FIELD_TYPE_STRING = (get_static_field<int>(clazz, "FIELD_TYPE_STRING")); - FIELD_TYPE_BLOB = (get_static_field<int>(clazz, "FIELD_TYPE_BLOB")); + FIELD_TYPE_NULL = (get_static_field<int>(clazz, "FIELD_TYPE_NULL")); + FIELD_TYPE_INTEGER = (get_static_field<int>(clazz, "FIELD_TYPE_INTEGER")); + FIELD_TYPE_FLOAT = (get_static_field<int>(clazz, "FIELD_TYPE_FLOAT")); + FIELD_TYPE_STRING = (get_static_field<int>(clazz, "FIELD_TYPE_STRING")); + FIELD_TYPE_BLOB = (get_static_field<int>(clazz, "FIELD_TYPE_BLOB")); } int CJNICursor::getCount() { - return call_method<jint>(m_object, "getCount", "()I"); + return call_method<jint>(m_object, + "getCount", "()I"); } int CJNICursor::getPosition() { - return call_method<jint>(m_object, "getPosition", "()I"); + return call_method<jint>(m_object, + "getPosition", "()I"); } bool CJNICursor::move(int offset) { - return call_method<jboolean>(m_object, "move", "(I)Z", offset); + return call_method<jboolean>(m_object, + "move", "(I)Z", + offset); } bool CJNICursor::moveToPosition(int position) { - return call_method<jboolean>(m_object, "moveToPosition", "(I)Z", position); + return call_method<jboolean>(m_object, + "moveToPosition", "(I)Z", position); } bool CJNICursor::moveToFirst() { - return call_method<jboolean>(m_object, "moveToFirst", "()Z"); + return call_method<jboolean>(m_object, + "moveToFirst", "()Z"); } bool CJNICursor::moveToLast() { - return call_method<jboolean>(m_object, "moveToLast", "()Z"); + return call_method<jboolean>(m_object, + "moveToLast", "()Z"); } bool CJNICursor::moveToNext() { - return call_method<jboolean>(m_object, "moveToNext", "()Z"); + return call_method<jboolean>(m_object, + "moveToNext", "()Z"); } bool CJNICursor::moveToPrevious() { - return call_method<jboolean>(m_object, "moveToPrevious", "()Z"); + return call_method<jboolean>(m_object, + "moveToPrevious", "()Z"); } bool CJNICursor::isFirst() { - return call_method<jboolean>(m_object, "isFirst", "()Z"); + return call_method<jboolean>(m_object, + "isFirst", "()Z"); } bool CJNICursor::isLast() { - return call_method<jboolean>(m_object, "isLast", "()Z"); + return call_method<jboolean>(m_object, + "isLast", "()Z"); } bool CJNICursor::isBeforeFirst() { - return call_method<jboolean>(m_object, "isBeforeFirst", "()Z"); + return call_method<jboolean>(m_object, + "isBeforeFirst", "()Z"); } bool CJNICursor::isAfterLast() { - return call_method<jboolean>(m_object, "isAfterLast", "()Z"); + return call_method<jboolean>(m_object, + "isAfterLast", "()Z"); } int CJNICursor::getColumnIndex(const std::string &columnName) { - return call_method<jint>(m_object, "getColumnIndex", "(Ljava/lang/String;)I", jcast<jhstring>(columnName)); + return call_method<jint>(m_object, + "getColumnIndex", "(Ljava/lang/String;)I", + jcast<jhstring>(columnName)); } std::string CJNICursor::getColumnName(int columnIndex) { - return jcast<std::string>(call_method<jhstring>(m_object, "getColumnName", "(I)Ljava/lang/String;", columnIndex)); + return jcast<std::string>(call_method<jhstring>(m_object, + "getColumnName", "(I)Ljava/lang/String;", + columnIndex)); } std::vector<std::string> CJNICursor::getColumnNames() { - return jcast<std::vector<std::string>>(call_method<jhobjectArray>(m_object, "getColumnNames", "()[Ljava/lang/String;")); + return jcast<std::vector<std::string>>(call_method<jhobjectArray>(m_object, + "getColumnNames", "()[Ljava/lang/String;")); } int CJNICursor::getColumnCount() { - return call_method<jint>(m_object, "getColumnCount", "()I"); + return call_method<jint>(m_object, + "getColumnCount", "()I"); } std::string CJNICursor::getString(int columnIndex) { - return jcast<std::string>(call_method<jhstring>(m_object, "getString", "(I)Ljava/lang/String;", columnIndex)); + return jcast<std::string>(call_method<jhstring>(m_object, + "getString", "(I)Ljava/lang/String;", + columnIndex)); } short CJNICursor::getShort(int columnIndex) { - return call_method<jshort>(m_object, "getShort", "()S", columnIndex); + return call_method<jshort>(m_object, + "getShort", "()S", + columnIndex); } int CJNICursor::getInt(int columnIndex) { - return call_method<jint>(m_object, "getInt", "()I", columnIndex); + return call_method<jint>(m_object, + "getInt", "()I", + columnIndex); } long CJNICursor::getLong(int columnIndex) { - return call_method<jint>(m_object, "getLong", "()J", columnIndex); + return call_method<jint>(m_object, + "getLong", "()J", + columnIndex); } float CJNICursor::getFloat(int columnIndex) { - return call_method<jfloat>(m_object, "getFloat", "()F", columnIndex); + return call_method<jfloat>(m_object, + "getFloat", "()F", + columnIndex); } double CJNICursor::getDouble(int columnIndex) { - return call_method<jdouble>(m_object, "getDouble", "()D", columnIndex); + return call_method<jdouble>(m_object, + "getDouble", "()D", + columnIndex); } int CJNICursor::getType(int columnIndex) { - return call_method<jint>(m_object, "getType", "(I)I", columnIndex); + return call_method<jint>(m_object, + "getType", "(I)I", + columnIndex); } bool CJNICursor::isNull(int columnIndex) { - return call_method<jboolean>(m_object, "isNull", "(I)Z", columnIndex); + return call_method<jboolean>(m_object, + "isNull", "(I)Z", + columnIndex); } void CJNICursor::deactivate() { - call_method<void>(m_object, "deactivate", "()V"); + call_method<void>(m_object, + "deactivate", "()V"); } bool CJNICursor::requery() { - return call_method<jboolean>(m_object, "requery", "()Z"); + return call_method<jboolean>(m_object, + "requery", "()Z"); } void CJNICursor::close() { - call_method<void>(m_object, "close", "()V"); + call_method<void>(m_object, + "close", "()V"); } bool CJNICursor::isClosed() { - return call_method<jboolean>(m_object, "isClosed", "()Z"); + return call_method<jboolean>(m_object, + "isClosed", "()Z"); } diff --git a/xbmc/android/jni/Cursor.h b/xbmc/android/jni/Cursor.h index aad672e1b5..93e042bea6 100644 --- a/xbmc/android/jni/Cursor.h +++ b/xbmc/android/jni/Cursor.h @@ -18,16 +18,20 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" #include "MediaStore.h" + class CJNIURI; + class CJNICursor : public CJNIBase { public: - ~CJNICursor(){}; CJNICursor(const jni::jhobject &object) : CJNIBase(object){}; - int getCount(); - int getPosition(); + ~CJNICursor(){}; + + int getCount(); + int getPosition(); bool move(int offset); bool moveToPosition(int position); bool moveToFirst(); @@ -38,30 +42,31 @@ public: bool isLast(); bool isBeforeFirst(); bool isAfterLast(); - int getColumnIndex(const std::string &columnName); + int getColumnIndex(const std::string &columnName); std::string getColumnName(int columnIndex); std::vector<std::string> getColumnNames(); - int getColumnCount(); + int getColumnCount(); std::string getString(int columnIndex); short getShort(int columnIndex); - int getInt(int columnIndex); + int getInt(int columnIndex); long getLong(int columnIndex); float getFloat(int columnIndex); double getDouble(int columnIndex); - int getType(int columnIndex); + int getType(int columnIndex); bool isNull(int columnIndex); void deactivate(); bool requery(); void close(); bool isClosed(); + static void PopulateStaticFields(); static int FIELD_TYPE_NULL; static int FIELD_TYPE_INTEGER; static int FIELD_TYPE_FLOAT; static int FIELD_TYPE_STRING; static int FIELD_TYPE_BLOB; - static void PopulateStaticFields(); + private: CJNICursor(); }; diff --git a/xbmc/android/jni/DhcpInfo.cpp b/xbmc/android/jni/DhcpInfo.cpp index 6aea820689..db4c205aae 100644 --- a/xbmc/android/jni/DhcpInfo.cpp +++ b/xbmc/android/jni/DhcpInfo.cpp @@ -17,28 +17,31 @@ * <http://www.gnu.org/licenses/>. * */ + #include "DhcpInfo.h" #include "jutils/jutils-details.hpp" using namespace jni; CJNIDhcpInfo::CJNIDhcpInfo(const jhobject &object) : CJNIBase(object) - ,ipAddress(get_field<int>(m_object, "ipAddress")) - ,gateway(get_field<int>(m_object, "gateway")) - ,netmask(get_field<int>(m_object, "netmask")) - ,dns1(get_field<int>(m_object, "dns1")) - ,dns2(get_field<int>(m_object, "dns2")) - ,serverAddress(get_field<int>(m_object, "serverAddress")) - ,leaseDuration(get_field<int>(m_object, "leaseDuration")) + ,ipAddress( get_field<int>(m_object, "ipAddress")) + ,gateway( get_field<int>(m_object, "gateway")) + ,netmask( get_field<int>(m_object, "netmask")) + ,dns1( get_field<int>(m_object, "dns1")) + ,dns2( get_field<int>(m_object, "dns2")) + ,serverAddress( get_field<int>(m_object, "serverAddress")) + ,leaseDuration( get_field<int>(m_object, "leaseDuration")) { } std::string CJNIDhcpInfo::toString() { - return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "toString", "()Ljava/lang/String;")); } int CJNIDhcpInfo::describeContents() { - return call_method<jint>(m_object, "describeContents", "()I"); + return call_method<jint>(m_object, + "describeContents", "()I"); } diff --git a/xbmc/android/jni/DhcpInfo.h b/xbmc/android/jni/DhcpInfo.h index 8774ca2287..cbaa6c0735 100644 --- a/xbmc/android/jni/DhcpInfo.h +++ b/xbmc/android/jni/DhcpInfo.h @@ -18,11 +18,16 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIDhcpInfo : public CJNIBase { public: + CJNIDhcpInfo(); + CJNIDhcpInfo(const jni::jhobject &object); + ~CJNIDhcpInfo(){}; + std::string toString(); int ipAddress; int gateway; @@ -32,9 +37,4 @@ public: int serverAddress; int leaseDuration; int describeContents(); - - CJNIDhcpInfo(); - ~CJNIDhcpInfo(){}; - CJNIDhcpInfo(const jni::jhobject &object); -private: }; diff --git a/xbmc/android/jni/Drawable.h b/xbmc/android/jni/Drawable.h index 17cfa73c7c..cc2dfbfaee 100644 --- a/xbmc/android/jni/Drawable.h +++ b/xbmc/android/jni/Drawable.h @@ -18,13 +18,14 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIDrawable : public CJNIBase { public: CJNIDrawable(); - ~CJNIDrawable(){}; CJNIDrawable(const jni::jhobject &object) : CJNIBase(object){}; CJNIDrawable(std::string classname) : CJNIBase(classname){}; + ~CJNIDrawable(){}; }; diff --git a/xbmc/android/jni/Enum.cpp b/xbmc/android/jni/Enum.cpp index 3472ffda4d..32a039b89b 100644 --- a/xbmc/android/jni/Enum.cpp +++ b/xbmc/android/jni/Enum.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "Enum.h" #include "jutils/jutils-details.hpp" @@ -24,14 +25,17 @@ using namespace jni; std::string CJNIEnum::name() { - return jcast<std::string>(call_method<jhstring>(m_object, "name", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "name", "()Ljava/lang/String;")); } std::string CJNIEnum::toString() { - return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "toString", "()Ljava/lang/String;")); } bool CJNIEnum::equals(const CJNIEnum &object) { - return call_method<jboolean>(m_object, "equals", "(Ljava/lang/Object;)Z", object.get_raw()); + return call_method<jboolean>(m_object, + "equals", "(Ljava/lang/Object;)Z", object.get_raw()); } diff --git a/xbmc/android/jni/Enum.h b/xbmc/android/jni/Enum.h index 13adc474f8..726b415915 100644 --- a/xbmc/android/jni/Enum.h +++ b/xbmc/android/jni/Enum.h @@ -18,13 +18,16 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" + class CJNIEnum : public CJNIBase { public: - CJNIEnum(jni::jhobject const& object) : CJNIBase(object){}; + CJNIEnum(jni::jhobject const& object) : CJNIBase(object) {}; + ~CJNIEnum() {}; + virtual std::string name(); virtual std::string toString(); virtual bool equals(const CJNIEnum &object); - ~CJNIEnum(){}; }; diff --git a/xbmc/android/jni/Environment.cpp b/xbmc/android/jni/Environment.cpp index 502cb5e77c..b9805b976d 100644 --- a/xbmc/android/jni/Environment.cpp +++ b/xbmc/android/jni/Environment.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "Environment.h" #include "File.h" #include "jutils/jutils-details.hpp" @@ -25,15 +26,19 @@ using namespace jni; std::string CJNIEnvironment::getExternalStorageState() { - return jcast<std::string>(call_static_method<jhstring>("android/os/Environment", "getExternalStorageState", "()Ljava/lang/String;")); + return jcast<std::string>(call_static_method<jhstring>("android/os/Environment", + "getExternalStorageState", "()Ljava/lang/String;")); } CJNIFile CJNIEnvironment::getExternalStorageDirectory() { - return (CJNIFile)call_static_method<jhobject>("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;"); + return (CJNIFile)call_static_method<jhobject>("android/os/Environment", + "getExternalStorageDirectory", "()Ljava/io/File;"); } CJNIFile CJNIEnvironment::getExternalStoragePublicDirectory(const std::string &type) { - return (CJNIFile)call_static_method<jhobject>("android/os/Environment", "getExternalStoragePublicDirectory", "(Ljava/lang/String;)Ljava/io/File;", jcast<jhstring>(type)); + return (CJNIFile)call_static_method<jhobject>("android/os/Environment", + "getExternalStoragePublicDirectory", "(Ljava/lang/String;)Ljava/io/File;", + jcast<jhstring>(type)); } diff --git a/xbmc/android/jni/Environment.h b/xbmc/android/jni/Environment.h index 12467655a7..5cc4839137 100644 --- a/xbmc/android/jni/Environment.h +++ b/xbmc/android/jni/Environment.h @@ -18,15 +18,18 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIFile; + class CJNIEnvironment : public CJNIBase { public: - static std::string getExternalStorageState(); - static CJNIFile getExternalStorageDirectory(); - static CJNIFile getExternalStoragePublicDirectory(const std::string &type); + static std::string getExternalStorageState(); + static CJNIFile getExternalStorageDirectory(); + static CJNIFile getExternalStoragePublicDirectory(const std::string &type); + protected: CJNIEnvironment(); ~CJNIEnvironment(){}; diff --git a/xbmc/android/jni/File.cpp b/xbmc/android/jni/File.cpp index 2eeaf2a7dd..9f320cbc3c 100644 --- a/xbmc/android/jni/File.cpp +++ b/xbmc/android/jni/File.cpp @@ -17,11 +17,14 @@ * <http://www.gnu.org/licenses/>. * */ + #include "File.h" #include "jutils/jutils-details.hpp" using namespace jni; + std::string CJNIFile::getAbsolutePath() { - return jcast<std::string>(call_method<jhstring>(m_object, "getAbsolutePath", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getAbsolutePath", "()Ljava/lang/String;")); } diff --git a/xbmc/android/jni/File.h b/xbmc/android/jni/File.h index 63b8897eab..7e272f74d3 100644 --- a/xbmc/android/jni/File.h +++ b/xbmc/android/jni/File.h @@ -18,14 +18,15 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIFile : public CJNIBase { public: CJNIFile(); - ~CJNIFile(){}; CJNIFile(const jni::jhobject &file) : CJNIBase(file){}; + ~CJNIFile(){}; std::string getAbsolutePath(); }; diff --git a/xbmc/android/jni/Intent.cpp b/xbmc/android/jni/Intent.cpp index b4a0cf0b68..a9352bd1e2 100644 --- a/xbmc/android/jni/Intent.cpp +++ b/xbmc/android/jni/Intent.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "Intent.h" #include "jutils/jutils-details.hpp" #include "URI.h" @@ -28,90 +29,121 @@ CJNIIntent::CJNIIntent(const std::string &action) : CJNIBase("android/content/In if(action.empty()) m_object = new_object(GetClassName()); else - m_object = new_object(GetClassName(), "<init>", "(Ljava/lang/String;)V", jcast<jhstring>(action)); + m_object = new_object(GetClassName(), + "<init>", "(Ljava/lang/String;)V", + jcast<jhstring>(action)); } std::string CJNIIntent::getAction() { - return jcast<std::string>(call_method<jhstring>(m_object, "getAction", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getAction", "()Ljava/lang/String;")); } std::string CJNIIntent::getDataString() { - return jcast<std::string>(call_method<jhstring>(m_object, "getDataString", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getDataString", "()Ljava/lang/String;")); } std::string CJNIIntent::getPackage() { - return jcast<std::string>(call_method<jhstring>(m_object, "getPackage", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getPackage", "()Ljava/lang/String;")); } std::string CJNIIntent::getType() { - return jcast<std::string>(call_method<jhstring>(m_object, "getType", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getType", "()Ljava/lang/String;")); } int CJNIIntent::getIntExtra(const std::string &name, int defaultValue) { - return call_method<jint>(m_object, "getIntExtra", "(Ljava/lang/String;I)I", jcast<jhstring>(name), defaultValue); + return call_method<jint>(m_object, + "getIntExtra", "(Ljava/lang/String;I)I", + jcast<jhstring>(name), defaultValue); } bool CJNIIntent::hasExtra(const std::string &name) { - return call_method<jboolean>(m_object, "hasExtra", "(Ljava/lang/String;)Z", jcast<jhstring>(name)); + return call_method<jboolean>(m_object, + "hasExtra", "(Ljava/lang/String;)Z", + jcast<jhstring>(name)); } bool CJNIIntent::hasCategory(const std::string &category) { - return call_method<jboolean>(m_object, "hasCategory", "(Ljava/lang/String;)Z", jcast<jhstring>(category)); + return call_method<jboolean>(m_object, + "hasCategory", "(Ljava/lang/String;)Z", + jcast<jhstring>(category)); } void CJNIIntent::addFlags(int flags) { - call_method<jhobject>(m_object, "addFlags", "(I;)Landroid/content/Intent;", flags); + call_method<jhobject>(m_object, + "addFlags", "(I;)Landroid/content/Intent;", + flags); } void CJNIIntent::addCategory(const std::string &category) { - call_method<jhstring>(m_object, "addCategory", "(Ljava/lang/String;)Landroid/content/Intent;", jcast<jhstring>(category)); + call_method<jhstring>(m_object, + "addCategory", "(Ljava/lang/String;)Landroid/content/Intent;", + jcast<jhstring>(category)); } void CJNIIntent::setAction(const std::string &action) { - call_method<jhobject>(m_object, "setAction", "(Ljava/lang/String;)Landroid/content/Intent;", jcast<jhstring>(action)); + call_method<jhobject>(m_object, + "setAction", "(Ljava/lang/String;)Landroid/content/Intent;", + jcast<jhstring>(action)); } void CJNIIntent::setClassName(const std::string &packageName, const std::string &className) { - call_method<jhobject>(m_object, "setClassName", "(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;", jcast<jhstring>(packageName), jcast<jhstring>(className)); + call_method<jhobject>(m_object, + "setClassName", "(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;", + jcast<jhstring>(packageName), jcast<jhstring>(className)); } void CJNIIntent::setData(const std::string &uri) { - call_method<jhobject>(m_object, "setData", "(Landroid/net/Uri;)Landroid/content/Intent;", jcast<jhstring>(uri)); + call_method<jhobject>(m_object, + "setData", "(Landroid/net/Uri;)Landroid/content/Intent;", + jcast<jhstring>(uri)); } void CJNIIntent::setDataAndType(const CJNIURI &uri, const std::string &type) { - call_method<jhobject>(m_object, "setDataAndType", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;", uri.get_raw(), jcast<jhstring>(type)); + call_method<jhobject>(m_object, + "setDataAndType", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;", + uri.get_raw(), jcast<jhstring>(type)); } void CJNIIntent::setFlags(int flags) { - call_method<jhobject>(m_object, "setFlags", "(I;)Landroid/content/Intent;", flags); + call_method<jhobject>(m_object, + "setFlags", "(I;)Landroid/content/Intent;", + flags); } void CJNIIntent::setPackage(const std::string &packageName) { - call_method<jhobject>(m_object, "setPackage", "(Ljava/lang/String;)Landroid/content/Intent;", jcast<jhstring>(packageName)); + call_method<jhobject>(m_object, + "setPackage", "(Ljava/lang/String;)Landroid/content/Intent;", + jcast<jhstring>(packageName)); } void CJNIIntent::setType(const std::string &type) { - call_method<jhobject>(m_object, "setType", "(Ljava/lang/String;)Landroid/content/Intent;", jcast<jhstring>(type)); + call_method<jhobject>(m_object, + "setType", "(Ljava/lang/String;)Landroid/content/Intent;", + jcast<jhstring>(type)); } CJNIURI CJNIIntent::getData() const { - return (CJNIURI)call_method<jhobject>(m_object, "getData","()Landroid/net/Uri;"); + return (CJNIURI)call_method<jhobject>(m_object, + "getData","()Landroid/net/Uri;"); } diff --git a/xbmc/android/jni/Intent.h b/xbmc/android/jni/Intent.h index d69c7b52cd..cb30b565f7 100644 --- a/xbmc/android/jni/Intent.h +++ b/xbmc/android/jni/Intent.h @@ -18,6 +18,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIURI; @@ -25,15 +26,15 @@ class CJNIIntent : public CJNIBase { public: CJNIIntent(const std::string &action = ""); - ~CJNIIntent(){}; - CJNIIntent(const jni::jhobject &intent) : CJNIBase(intent){}; + CJNIIntent(const jni::jhobject &intent) : CJNIBase(intent) {}; + ~CJNIIntent() {}; std::string getAction(); std::string getDataString(); std::string getPackage(); std::string getType(); - int getIntExtra(const std::string &name, int defaultValue); + int getIntExtra(const std::string &name, int defaultValue); bool hasExtra(const std::string &name); bool hasCategory(const std::string &category); diff --git a/xbmc/android/jni/IntentFilter.cpp b/xbmc/android/jni/IntentFilter.cpp index 98684f5c00..68b1309bb5 100644 --- a/xbmc/android/jni/IntentFilter.cpp +++ b/xbmc/android/jni/IntentFilter.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "IntentFilter.h" #include "jutils/jutils-details.hpp" @@ -29,15 +30,21 @@ CJNIIntentFilter::CJNIIntentFilter() : CJNIBase("android/content/IntentFilter") CJNIIntentFilter::CJNIIntentFilter(const std::string &action) : CJNIBase("android/content/IntentFilter") { - m_object = new_object(GetClassName(), "<init>", "(Ljava/lang/String;)V", jcast<jhstring>(action)); + m_object = new_object(GetClassName(), + "<init>", "(Ljava/lang/String;)V", + jcast<jhstring>(action)); } void CJNIIntentFilter::addAction(std::string action) { - call_method<void>(m_object, "addAction", "(Ljava/lang/String;)V", jcast<jhstring>(action)); + call_method<void>(m_object, + "addAction", "(Ljava/lang/String;)V", + jcast<jhstring>(action)); } void CJNIIntentFilter::addDataScheme(std::string scheme) { - call_method<void>(m_object, "addDataScheme", "(Ljava/lang/String;)V", jcast<jhstring>(scheme)); + call_method<void>(m_object, + "addDataScheme", "(Ljava/lang/String;)V", + jcast<jhstring>(scheme)); } diff --git a/xbmc/android/jni/IntentFilter.h b/xbmc/android/jni/IntentFilter.h index d45320eca8..2a40ec0659 100644 --- a/xbmc/android/jni/IntentFilter.h +++ b/xbmc/android/jni/IntentFilter.h @@ -18,16 +18,17 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIIntentFilter : public CJNIBase { public: CJNIIntentFilter(); + CJNIIntentFilter(const jni::jhobject &object) : CJNIBase(object) {}; CJNIIntentFilter(const std::string &action); + ~CJNIIntentFilter() {}; + void addDataScheme(std::string scheme); void addAction(std::string action); - - ~CJNIIntentFilter(){}; - CJNIIntentFilter(const jni::jhobject &object) : CJNIBase(object){}; }; diff --git a/xbmc/android/jni/JNIBase.cpp b/xbmc/android/jni/JNIBase.cpp index f566f019c5..1b036c0fbd 100644 --- a/xbmc/android/jni/JNIBase.cpp +++ b/xbmc/android/jni/JNIBase.cpp @@ -17,8 +17,11 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" + using namespace jni; + CJNIBase::CJNIBase(std::string classname) { m_className = classname; diff --git a/xbmc/android/jni/JNIBase.h b/xbmc/android/jni/JNIBase.h index 48b29bef7e..94fccb7675 100644 --- a/xbmc/android/jni/JNIBase.h +++ b/xbmc/android/jni/JNIBase.h @@ -18,6 +18,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "jutils/jutils.hpp" class CJNIBase diff --git a/xbmc/android/jni/List.cpp b/xbmc/android/jni/List.cpp index f9f2559f29..9a48551736 100644 --- a/xbmc/android/jni/List.cpp +++ b/xbmc/android/jni/List.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "List.h" #include "jutils/jutils-details.hpp" #include "ScanResult.h" @@ -28,13 +29,16 @@ using namespace jni; template <typename T> T CJNIList<T>::get(int index) { - return (T)call_method<jhobject>(m_object, "get", "(I)Ljava/lang/Object;", index); + return (T)call_method<jhobject>(m_object, + "get", "(I)Ljava/lang/Object;", + index); } template <typename T> int CJNIList<T>::size() { - return m_object.get() ? call_method<jint>(m_object, "size", "()I") : 0; + return m_object.get() ? call_method<jint>(m_object, + "size", "()I") : 0; } template class CJNIList<CJNIScanResult>; diff --git a/xbmc/android/jni/List.h b/xbmc/android/jni/List.h index 1c4d7556e1..5fcf8c366a 100644 --- a/xbmc/android/jni/List.h +++ b/xbmc/android/jni/List.h @@ -18,16 +18,19 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" template <typename T> class CJNIList : public CJNIBase { public: - ~CJNIList(){}; CJNIList(const jni::jhobject &object) : CJNIBase(object){}; - T get(int index); + ~CJNIList(){}; + + T get(int index); int size(); + private: CJNIList(); }; diff --git a/xbmc/android/jni/MediaStore.cpp b/xbmc/android/jni/MediaStore.cpp index 322c7f483a..e3832fab3d 100644 --- a/xbmc/android/jni/MediaStore.cpp +++ b/xbmc/android/jni/MediaStore.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "MediaStore.h" #include "jutils/jutils-details.hpp" @@ -29,14 +30,15 @@ std::string CJNIMediaStoreMediaColumns::TITLE; std::string CJNIMediaStoreMediaColumns::DATE_ADDED; std::string CJNIMediaStoreMediaColumns::DATE_MODIFIED; std::string CJNIMediaStoreMediaColumns::MIME_TYPE; + void CJNIMediaStoreMediaColumns::PopulateStaticFields() { jhclass clazz = find_class("android/provider/MediaStore$MediaColumns"); - DATA = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATA"))); - SIZE = (jcast<std::string>(get_static_field<jhstring>(clazz, "SIZE"))); - DISPLAY_NAME = (jcast<std::string>(get_static_field<jhstring>(clazz, "DISPLAY_NAME"))); - TITLE = (jcast<std::string>(get_static_field<jhstring>(clazz, "TITLE"))); - DATE_ADDED = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATE_ADDED"))); + DATA = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATA"))); + SIZE = (jcast<std::string>(get_static_field<jhstring>(clazz, "SIZE"))); + DISPLAY_NAME = (jcast<std::string>(get_static_field<jhstring>(clazz, "DISPLAY_NAME"))); + TITLE = (jcast<std::string>(get_static_field<jhstring>(clazz, "TITLE"))); + DATE_ADDED = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATE_ADDED"))); DATE_MODIFIED = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATE_MODIFIED"))); - MIME_TYPE = (jcast<std::string>(get_static_field<jhstring>(clazz, "MIME_TYPE"))); + MIME_TYPE = (jcast<std::string>(get_static_field<jhstring>(clazz, "MIME_TYPE"))); } diff --git a/xbmc/android/jni/MediaStore.h b/xbmc/android/jni/MediaStore.h index bfca88f622..aa322e61eb 100644 --- a/xbmc/android/jni/MediaStore.h +++ b/xbmc/android/jni/MediaStore.h @@ -18,11 +18,15 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" #include "BaseColumns.h" + class CJNIMediaStoreMediaColumns : public CJNIBaseColumns { public: + static void PopulateStaticFields(); + static std::string DATA; static std::string SIZE; static std::string DISPLAY_NAME; @@ -30,7 +34,7 @@ public: static std::string DATE_ADDED; static std::string DATE_MODIFIED; static std::string MIME_TYPE; - static void PopulateStaticFields(); + private: CJNIMediaStoreMediaColumns(); }; @@ -38,6 +42,6 @@ private: class CJNIMediaStore : public CJNIBase { public: - ~CJNIMediaStore(){}; - CJNIMediaStore(const jni::jhobject &object) : CJNIBase(object){}; + CJNIMediaStore(const jni::jhobject &object) : CJNIBase(object) {}; + ~CJNIMediaStore() {}; }; diff --git a/xbmc/android/jni/NetworkInfo.cpp b/xbmc/android/jni/NetworkInfo.cpp index 85bb51b03e..7795f7aaca 100644 --- a/xbmc/android/jni/NetworkInfo.cpp +++ b/xbmc/android/jni/NetworkInfo.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "NetworkInfo.h" #include "jutils/jutils-details.hpp" @@ -24,76 +25,91 @@ using namespace jni; int CJNINetworkInfo::getType() const { - return call_method<jint>(m_object, "getType", "()I"); + return call_method<jint>(m_object, + "getType", "()I"); } int CJNINetworkInfo::getSubtype() const { - return call_method<jint>(m_object, "getSubtype", "()I"); + return call_method<jint>(m_object, + "getSubtype", "()I"); } std::string CJNINetworkInfo::getTypeName() const { - return jcast<std::string>(call_method<jhstring>(m_object, "getTypeName", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getTypeName", "()Ljava/lang/String;")); } std::string CJNINetworkInfo::getSubtypeName() const { - return jcast<std::string>(call_method<jhstring>(m_object, "getTypeName", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getTypeName", "()Ljava/lang/String;")); } bool CJNINetworkInfo::isConnectedOrConnecting() const { - return call_method<jboolean>(m_object, "isConnectedOrConnecting", "()Z"); + return call_method<jboolean>(m_object, + "isConnectedOrConnecting", "()Z"); } bool CJNINetworkInfo::isConnected() const { - return call_method<jboolean>(m_object, "isConnected", "()Z"); + return call_method<jboolean>(m_object, + "isConnected", "()Z"); } bool CJNINetworkInfo::isAvailable() const { - return call_method<jboolean>(m_object, "isAvailable", "()Z"); + return call_method<jboolean>(m_object, + "isAvailable", "()Z"); } bool CJNINetworkInfo::isFailover() const { - return call_method<jboolean>(m_object, "isFailover", "()Z"); + return call_method<jboolean>(m_object, + "isFailover", "()Z"); } bool CJNINetworkInfo::isRoaming() const { - return call_method<jboolean>(m_object, "isRoaming", "()Z"); + return call_method<jboolean>(m_object, + "isRoaming", "()Z"); } CJNINetworkInfoState CJNINetworkInfo::getState() const { - return (CJNINetworkInfoState)call_method<jhobject>(m_object, "getState", "()Landroid/net/NetworkInfo$State;"); + return call_method<jhobject>(m_object, + "getState", "()Landroid/net/NetworkInfo$State;"); } CJNINetworkInfoDetailedState CJNINetworkInfo::getDetailedState() const { - return (CJNINetworkInfoDetailedState)call_method<jhobject>(m_object, "getDetailedState", "()Landroid/net/NetworkInfo$DetailedState;"); + return call_method<jhobject>(m_object, + "getDetailedState", "()Landroid/net/NetworkInfo$DetailedState;"); } std::string CJNINetworkInfo::getReason() const { - return jcast<std::string>(call_method<jhstring>(m_object, "getReason", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getReason", "()Ljava/lang/String;")); } std::string CJNINetworkInfo::getExtraInfo() const { - return jcast<std::string>(call_method<jhstring>(m_object, "getExtraInfo", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getExtraInfo", "()Ljava/lang/String;")); } std::string CJNINetworkInfo::toString() const { - return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "toString", "()Ljava/lang/String;")); } int CJNINetworkInfo::describeContents() const { - return call_method<jint>(m_object, "describeContents", "()I"); + return call_method<jint>(m_object, + "describeContents", "()I"); } diff --git a/xbmc/android/jni/NetworkInfo.h b/xbmc/android/jni/NetworkInfo.h index 5fd506631c..ab51cad9d4 100644 --- a/xbmc/android/jni/NetworkInfo.h +++ b/xbmc/android/jni/NetworkInfo.h @@ -18,14 +18,16 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" #include "Enum.h" class CJNINetworkInfoState : public CJNIEnum { public: - ~CJNINetworkInfoState(){}; - CJNINetworkInfoState(const jni::jhobject &object) : CJNIEnum(object){}; + CJNINetworkInfoState(const jni::jhobject &object) : CJNIEnum(object) {}; + ~CJNINetworkInfoState() {}; + private: CJNINetworkInfoState(); }; @@ -33,8 +35,9 @@ private: class CJNINetworkInfoDetailedState : public CJNIEnum { public: - ~CJNINetworkInfoDetailedState(){}; - CJNINetworkInfoDetailedState(const jni::jhobject &object) : CJNIEnum(object){}; + CJNINetworkInfoDetailedState(const jni::jhobject &object) : CJNIEnum(object) {}; + ~CJNINetworkInfoDetailedState() {}; + private: CJNINetworkInfoDetailedState(); }; @@ -42,25 +45,25 @@ private: class CJNINetworkInfo : public CJNIBase { public: + CJNINetworkInfo(); CJNINetworkInfo(const jni::jhobject &object) : CJNIBase(object){}; ~CJNINetworkInfo(){}; - int getType() const; - int getSubtype() const; + + int getType() const; + int getSubtype() const; std::string getTypeName() const; std::string getSubtypeName() const; - bool isConnectedOrConnecting() const; - bool isConnected() const; - bool isAvailable() const; - bool isFailover() const; - bool isRoaming() const; + bool isConnectedOrConnecting() const; + bool isConnected() const; + bool isAvailable() const; + bool isFailover() const; + bool isRoaming() const; CJNINetworkInfoState getState() const; CJNINetworkInfoDetailedState getDetailedState() const; - std::string getReason() const; + std::string getReason() const; std::string getExtraInfo() const; - std::string toString() const; - int describeContents() const; - CJNINetworkInfo(); -private: + std::string toString() const; + int describeContents() const; }; diff --git a/xbmc/android/jni/PackageManager.cpp b/xbmc/android/jni/PackageManager.cpp index cc21a2ecfe..4f85da96c8 100644 --- a/xbmc/android/jni/PackageManager.cpp +++ b/xbmc/android/jni/PackageManager.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "PackageManager.h" #include "Intent.h" #include "Drawable.h" @@ -30,27 +31,35 @@ int CJNIPackageManager::GET_ACTIVITIES(0); void CJNIPackageManager::PopulateStaticFields() { - jhclass clazz = find_class("android/content/pm/PackageManager"); + jhclass clazz = find_class("android/content/pm/PackageManager"); GET_ACTIVITIES = (get_static_field<int>(clazz, "GET_ACTIVITIES")); } CJNIIntent CJNIPackageManager::getLaunchIntentForPackage(const std::string &package) { - return (CJNIIntent)call_method<jhobject>(m_object, "getLaunchIntentForPackage", "(Ljava/lang/String;)Landroid/content/Intent;", jcast<jhstring>(package)); + return call_method<jhobject>(m_object, + "getLaunchIntentForPackage", "(Ljava/lang/String;)Landroid/content/Intent;", + jcast<jhstring>(package)); } CJNIDrawable CJNIPackageManager::getApplicationIcon(const std::string &package) { - return (CJNIDrawable)call_method<jhobject>(m_object, "getApplicationIcon", "(Ljava/lang/String;)Landroid/graphics/drawable/Drawable;", jcast<jhstring>(package)); + return call_method<jhobject>(m_object, + "getApplicationIcon", "(Ljava/lang/String;)Landroid/graphics/drawable/Drawable;", + jcast<jhstring>(package)); } CJNICharSequence CJNIPackageManager::getApplicationLabel(const CJNIApplicationInfo &info) { - return (CJNICharSequence)call_method<jhobject>(m_object, "getApplicationLabel", "(Landroid/content/pm/ApplicationInfo;)Ljava/lang/CharSequence;", info.get_raw()); + return call_method<jhobject>(m_object, + "getApplicationLabel", "(Landroid/content/pm/ApplicationInfo;)Ljava/lang/CharSequence;", + info.get_raw()); } CJNIList<CJNIApplicationInfo> CJNIPackageManager::getInstalledApplications(int flags) { - return (CJNIList<CJNIApplicationInfo>)call_method<jhobject>(m_object, "getInstalledApplications", "(I)Ljava/util/List;", flags); + return call_method<jhobject>(m_object, + "getInstalledApplications", "(I)Ljava/util/List;", + flags); } diff --git a/xbmc/android/jni/PackageManager.h b/xbmc/android/jni/PackageManager.h index 7bf2d01caf..9873c13a54 100644 --- a/xbmc/android/jni/PackageManager.h +++ b/xbmc/android/jni/PackageManager.h @@ -18,6 +18,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" #include "List.h" @@ -25,19 +26,21 @@ class CJNIIntent; class CJNIDrawable; class CJNIApplicationInfo; class CJNICharSequence; + class CJNIPackageManager : public CJNIBase { public: CJNIPackageManager(const jni::jhobject &object) : CJNIBase(object) {}; - ~CJNIPackageManager(){}; + ~CJNIPackageManager() {}; - CJNIIntent getLaunchIntentForPackage(const std::string &package); - CJNIDrawable getApplicationIcon(const std::string &package); + CJNIIntent getLaunchIntentForPackage(const std::string &package); + CJNIDrawable getApplicationIcon(const std::string &package); CJNIList<CJNIApplicationInfo> getInstalledApplications(int flags); - CJNICharSequence getApplicationLabel(const CJNIApplicationInfo &info); + CJNICharSequence getApplicationLabel(const CJNIApplicationInfo &info); + + static void PopulateStaticFields(); + static int GET_ACTIVITIES; - static void PopulateStaticFields(); - static int GET_ACTIVITIES; private: CJNIPackageManager(); }; diff --git a/xbmc/android/jni/PowerManager.cpp b/xbmc/android/jni/PowerManager.cpp index 6ce56d78f0..4bc6f3a2db 100644 --- a/xbmc/android/jni/PowerManager.cpp +++ b/xbmc/android/jni/PowerManager.cpp @@ -17,9 +17,10 @@ * <http://www.gnu.org/licenses/>. * */ + #include "PowerManager.h" -#include "jutils/jutils-details.hpp" #include "WakeLock.h" +#include "jutils/jutils-details.hpp" using namespace jni; @@ -27,22 +28,27 @@ int CJNIPowerManager::FULL_WAKE_LOCK(0); void CJNIPowerManager::PopulateStaticFields() { - jhclass clazz = find_class("android/os/PowerManager"); + jhclass clazz = find_class("android/os/PowerManager"); FULL_WAKE_LOCK = (get_static_field<int>(clazz, "FULL_WAKE_LOCK")); } CJNIWakeLock CJNIPowerManager::newWakeLock(const std::string &name) { - return (CJNIWakeLock)call_method<jhobject>(m_object, "newWakeLock", "(ILjava/lang/String;)Landroid/os/PowerManager$WakeLock;", \ - FULL_WAKE_LOCK, jcast<jhstring>(name)); + return call_method<jhobject>(m_object, + "newWakeLock", "(ILjava/lang/String;)Landroid/os/PowerManager$WakeLock;", + FULL_WAKE_LOCK, jcast<jhstring>(name)); } void CJNIPowerManager::goToSleep(int64_t timestamp) { - call_method<void>(m_object, "goToSleep", "(J)V", (jlong)timestamp); + call_method<void>(m_object, + "goToSleep", "(J)V", + (jlong)timestamp); } void CJNIPowerManager::reboot(const std::string &reason) { - call_method<void>(m_object, "reboot", "(Ljava/lang/String;)V", jcast<jhstring>(reason)); + call_method<void>(m_object, + "reboot", "(Ljava/lang/String;)V", + jcast<jhstring>(reason)); } diff --git a/xbmc/android/jni/PowerManager.h b/xbmc/android/jni/PowerManager.h index 8297614236..19677d20e5 100644 --- a/xbmc/android/jni/PowerManager.h +++ b/xbmc/android/jni/PowerManager.h @@ -18,21 +18,25 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIWakeLock; + class CJNIPowerManager : public CJNIBase { public: - CJNIWakeLock newWakeLock(const std::string &name); - void reboot(const std::string &reason); - void goToSleep(int64_t timestamp); + CJNIPowerManager(const jni::jhobject &object) : CJNIBase(object) {}; + ~CJNIPowerManager() {}; - static void PopulateStaticFields(); - CJNIPowerManager(const jni::jhobject &object) : CJNIBase(object){}; - ~CJNIPowerManager(){}; + CJNIWakeLock newWakeLock(const std::string &name); + void reboot(const std::string &reason); + void goToSleep(int64_t timestamp); + + static void PopulateStaticFields(); private: CJNIPowerManager(); + static int FULL_WAKE_LOCK; }; diff --git a/xbmc/android/jni/ScanResult.cpp b/xbmc/android/jni/ScanResult.cpp index a3572b42b6..b1b46a81ab 100644 --- a/xbmc/android/jni/ScanResult.cpp +++ b/xbmc/android/jni/ScanResult.cpp @@ -17,26 +17,29 @@ * <http://www.gnu.org/licenses/>. * */ + #include "ScanResult.h" #include "jutils/jutils-details.hpp" using namespace jni; CJNIScanResult::CJNIScanResult(const jhobject &object) : CJNIBase(object) - ,SSID(jcast<std::string>(get_field<jhstring>(m_object, "SSID"))) - ,BSSID(jcast<std::string>(get_field<jhstring>(m_object, "BSSID"))) + ,SSID( jcast<std::string>(get_field<jhstring>(m_object, "SSID"))) + ,BSSID( jcast<std::string>(get_field<jhstring>(m_object, "BSSID"))) ,capabilities(jcast<std::string>(get_field<jhstring>(m_object, "capabilities"))) - ,level(get_field<int>(m_object, "level")) - ,frequency(get_field<int>(m_object, "frequency")) + ,level( get_field<int>(m_object, "level")) + ,frequency( get_field<int>(m_object, "frequency")) { } std::string CJNIScanResult::toString() { - return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "toString", "()Ljava/lang/String;")); } int CJNIScanResult::describeContents() { - return call_method<jint>(m_object, "describeContents", "()I"); + return call_method<jint>(m_object, + "describeContents", "()I"); } diff --git a/xbmc/android/jni/ScanResult.h b/xbmc/android/jni/ScanResult.h index dcd575922d..3f12951e85 100644 --- a/xbmc/android/jni/ScanResult.h +++ b/xbmc/android/jni/ScanResult.h @@ -18,22 +18,25 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIScanResult : public CJNIBase { public: CJNIScanResult(const jni::jhobject &object); + ~CJNIScanResult(){}; + std::string SSID; std::string BSSID; std::string capabilities; - int level; - int frequency; + int level; + int frequency; std::string toString(); - int describeContents(); + int describeContents(); - ~CJNIScanResult(){}; private: CJNIScanResult(); }; + typedef std::vector<CJNIScanResult> CJNIScanResults; diff --git a/xbmc/android/jni/StatFs.cpp b/xbmc/android/jni/StatFs.cpp index 5011e876e5..8ec7534ac5 100644 --- a/xbmc/android/jni/StatFs.cpp +++ b/xbmc/android/jni/StatFs.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "StatFs.h" #include "jutils/jutils-details.hpp" @@ -24,31 +25,39 @@ using namespace jni; CJNIStatFs::CJNIStatFs(const std::string &path) : CJNIBase("android/os/StatFs") { - m_object = new_object(GetClassName(), "<init>", "(Ljava/lang/String;)V", jcast<jhstring>(path)); + m_object = new_object(GetClassName(), "<init>", + "(Ljava/lang/String;)V", + jcast<jhstring>(path)); m_object.setGlobal(); } void CJNIStatFs::restat(const std::string &path) { - call_method<void>(m_object, "restat", "(Ljava/lang/String;)V", jcast<jhstring>(path)); + call_method<void>(m_object, + "restat", "(Ljava/lang/String;)V", + jcast<jhstring>(path)); } int CJNIStatFs::getBlockSize() { - return call_method<jint>(m_object, "getBlockSize", "()I"); + return call_method<jint>(m_object, + "getBlockSize", "()I"); } int CJNIStatFs::getBlockCount() { - return call_method<jint>(m_object, "getBlockCount", "()I"); + return call_method<jint>(m_object, + "getBlockCount", "()I"); } int CJNIStatFs::getFreeBlocks() { - return call_method<jint>(m_object, "getFreeBlocks", "()I"); + return call_method<jint>(m_object, + "getFreeBlocks", "()I"); } int CJNIStatFs::getAvailableBlocks() { - return call_method<jint>(m_object, "getAvailableBlocks", "()I"); + return call_method<jint>(m_object, + "getAvailableBlocks", "()I"); } diff --git a/xbmc/android/jni/StatFs.h b/xbmc/android/jni/StatFs.h index 9bc029e119..9fccd33bb5 100644 --- a/xbmc/android/jni/StatFs.h +++ b/xbmc/android/jni/StatFs.h @@ -18,17 +18,19 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIStatFs : public CJNIBase { public: CJNIStatFs(const std::string &path); - CJNIStatFs(const jni::jhobject &object) : CJNIBase(object){}; - ~CJNIStatFs(){}; - void restat(const std::string &path); - int getBlockSize(); - int getBlockCount(); - int getFreeBlocks(); - int getAvailableBlocks(); + CJNIStatFs(const jni::jhobject &object) : CJNIBase(object) {}; + ~CJNIStatFs() {}; + + void restat(const std::string &path); + int getBlockSize(); + int getBlockCount(); + int getFreeBlocks(); + int getAvailableBlocks(); }; diff --git a/xbmc/android/jni/System.cpp b/xbmc/android/jni/System.cpp index a910d34688..79a7150c5e 100644 --- a/xbmc/android/jni/System.cpp +++ b/xbmc/android/jni/System.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "System.h" #include "jutils/jutils-details.hpp" @@ -24,20 +25,28 @@ using namespace jni; std::string CJNISystem::getProperty(const std::string &property) { - return jcast<std::string>(call_static_method<jhstring>("java/lang/System", "getProperty", "(Ljava/lang/String;)Ljava/lang/String;", jcast<jhstring>(property))); + return jcast<std::string>(call_static_method<jhstring>("java/lang/System", + "getProperty", "(Ljava/lang/String;)Ljava/lang/String;", + jcast<jhstring>(property))); } std::string CJNISystem::getProperty(const std::string &property, const std::string &defaultValue) { - return jcast<std::string>(call_static_method<jhstring>("java/lang/System", "getProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", jcast<jhstring>(property), jcast<jhstring>(defaultValue))); + return jcast<std::string>(call_static_method<jhstring>("java/lang/System", + "getProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", + jcast<jhstring>(property), jcast<jhstring>(defaultValue))); } std::string CJNISystem::setProperty(const std::string &property, const std::string &defaultValue) { - return jcast<std::string>(call_static_method<jhstring>("java/lang/System", "setProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", jcast<jhstring>(property), jcast<jhstring>(defaultValue))); + return jcast<std::string>(call_static_method<jhstring>("java/lang/System", + "setProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", + jcast<jhstring>(property), jcast<jhstring>(defaultValue))); } std::string CJNISystem::clearProperty(const std::string &property) { - return jcast<std::string>(call_static_method<jhstring>("java/lang/System", "clearProperty", "(Ljava/lang/String;)Ljava/lang/String;", jcast<jhstring>(property))); + return jcast<std::string>(call_static_method<jhstring>("java/lang/System", + "clearProperty", "(Ljava/lang/String;)Ljava/lang/String;", + jcast<jhstring>(property))); } diff --git a/xbmc/android/jni/System.h b/xbmc/android/jni/System.h index b884f74371..58fb49641f 100644 --- a/xbmc/android/jni/System.h +++ b/xbmc/android/jni/System.h @@ -18,17 +18,18 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNISystem { public: - static std::string getProperty(const std::string &property); - static std::string getProperty(const std::string &property, const std::string &defaultValue); - static std::string setProperty(const std::string &property, const std::string &defaultValue); + static std::string getProperty( const std::string &property); + static std::string getProperty( const std::string &property, const std::string &defaultValue); + static std::string setProperty( const std::string &property, const std::string &defaultValue); static std::string clearProperty(const std::string &property); + private: CJNISystem(); - ~CJNISystem(){}; - + ~CJNISystem() {}; }; diff --git a/xbmc/android/jni/SystemClock.cpp b/xbmc/android/jni/SystemClock.cpp index 1080e4a1da..4906554384 100644 --- a/xbmc/android/jni/SystemClock.cpp +++ b/xbmc/android/jni/SystemClock.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "SystemClock.h" #include "jutils/jutils-details.hpp" @@ -24,6 +25,7 @@ using namespace jni; int64_t CJNISystemClock::uptimeMillis() { - return call_static_method<jlong>("android/os/SystemClock", "uptimeMillis", "()J"); + return call_static_method<jlong>("android/os/SystemClock", + "uptimeMillis", "()J"); } diff --git a/xbmc/android/jni/SystemClock.h b/xbmc/android/jni/SystemClock.h index 3b86fde63e..c82dc788d2 100644 --- a/xbmc/android/jni/SystemClock.h +++ b/xbmc/android/jni/SystemClock.h @@ -18,13 +18,16 @@ * <http://www.gnu.org/licenses/>. * */ -// This class contains only static methods, so no need to inherit from JNIBase. + #include <stdint.h> + +// This class contains only static methods, so no need to inherit from JNIBase. class CJNISystemClock { public: static int64_t uptimeMillis(); + private: - CJNISystemClock(){}; - ~CJNISystemClock(){}; + CJNISystemClock() {}; + ~CJNISystemClock() {}; }; diff --git a/xbmc/android/jni/URI.cpp b/xbmc/android/jni/URI.cpp index df9f2eb737..88bb122564 100644 --- a/xbmc/android/jni/URI.cpp +++ b/xbmc/android/jni/URI.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "URI.h" #include "jutils/jutils-details.hpp" @@ -24,25 +25,31 @@ using namespace jni; CJNIURI CJNIURI::parse(std::string uriString) { - return (CJNIURI)call_static_method<jhobject>("android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;", jcast<jhstring>(uriString)); + return call_static_method<jhobject>("android/net/Uri", + "parse", "(Ljava/lang/String;)Landroid/net/Uri;", + jcast<jhstring>(uriString)); } std::string CJNIURI::getScheme() const { - return jcast<std::string>(call_method<jhstring>(m_object, "getScheme", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getScheme", "()Ljava/lang/String;")); } std::string CJNIURI::toString() const { - return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "toString", "()Ljava/lang/String;")); } std::string CJNIURI::getLastPathSegment() const { - return jcast<std::string>(call_method<jhstring>(m_object, "getLastPathSegment", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getLastPathSegment", "()Ljava/lang/String;")); } std::string CJNIURI::getPath() const { - return jcast<std::string>(call_method<jhstring>(m_object, "getPath", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getPath", "()Ljava/lang/String;")); } diff --git a/xbmc/android/jni/URI.h b/xbmc/android/jni/URI.h index af0c02ffcb..1befc3470a 100644 --- a/xbmc/android/jni/URI.h +++ b/xbmc/android/jni/URI.h @@ -18,18 +18,21 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIURI : public CJNIBase { - public: - CJNIURI(const jni::jhobject &uri) : CJNIBase(uri){}; +public: + CJNIURI(const jni::jhobject &uri) : CJNIBase(uri) {}; + ~CJNIURI() {}; + std::string getScheme() const; - std::string toString() const; + std::string toString() const; std::string getLastPathSegment() const; - std::string getPath() const; + std::string getPath() const; static CJNIURI parse(std::string uriString); - ~CJNIURI(){}; + private: CJNIURI(); }; diff --git a/xbmc/android/jni/WakeLock.cpp b/xbmc/android/jni/WakeLock.cpp index 6dea8a9c28..5058026fb4 100644 --- a/xbmc/android/jni/WakeLock.cpp +++ b/xbmc/android/jni/WakeLock.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "WakeLock.h" #include "jutils/jutils-details.hpp" @@ -24,11 +25,13 @@ using namespace jni; void CJNIWakeLock::acquire() { - call_method<void>(m_object, "acquire", "()V"); + call_method<void>(m_object, + "acquire", "()V"); } void CJNIWakeLock::release() { - call_method<void>(m_object, "release", "()V"); + call_method<void>(m_object, + "release", "()V"); } diff --git a/xbmc/android/jni/WakeLock.h b/xbmc/android/jni/WakeLock.h index cd732da9bd..69773bbf51 100644 --- a/xbmc/android/jni/WakeLock.h +++ b/xbmc/android/jni/WakeLock.h @@ -18,15 +18,18 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" class CJNIWakeLock : public CJNIBase { public: - CJNIWakeLock(const jni::jhobject &wakelock) : CJNIBase(wakelock){}; - ~CJNIWakeLock(){}; + CJNIWakeLock(const jni::jhobject &wakelock) : CJNIBase(wakelock) {}; + ~CJNIWakeLock() {}; + void acquire(); void release(); + protected: CJNIWakeLock(); }; diff --git a/xbmc/android/jni/WifiConfiguration.cpp b/xbmc/android/jni/WifiConfiguration.cpp index 5f147de91a..62a7f9ed4b 100644 --- a/xbmc/android/jni/WifiConfiguration.cpp +++ b/xbmc/android/jni/WifiConfiguration.cpp @@ -17,33 +17,36 @@ * <http://www.gnu.org/licenses/>. * */ + #include "WifiConfiguration.h" #include "jutils/jutils-details.hpp" using namespace jni; CJNIWifiConfiguration::CJNIWifiConfiguration(const jhobject &object) : CJNIBase(object) - ,networkId(get_field<jint>(m_object, "networkId")) - ,status(get_field<jint>(m_object, "status")) - ,SSID(jcast<std::string>(get_field<jhstring>(m_object, "SSID"))) - ,BSSID(jcast<std::string>(get_field<jhstring>(m_object, "BSSID"))) - ,preSharedKey(jcast<std::string>(get_field<jhstring>(m_object, "preSharedKey"))) - ,wepTxKeyIndex(get_field<jint>(m_object, "wepTxKeyIndex")) - ,priority(get_field<jint>(m_object, "priority")) - ,hiddenSSID(get_field<jboolean>(m_object, "hiddenSSID")) - ,allowedKeyManagement(get_field<jhobject>(m_object, "allowedKeyManagement", "Ljava/util/BitSet;")) - ,allowedProtocols(get_field<jhobject>(m_object, "allowedProtocols", "Ljava/util/BitSet;")) + ,networkId( get_field<jint>(m_object, "networkId")) + ,status( get_field<jint>(m_object, "status")) + ,SSID( jcast<std::string>(get_field<jhstring>(m_object, "SSID"))) + ,BSSID( jcast<std::string>(get_field<jhstring>(m_object, "BSSID"))) + ,preSharedKey( jcast<std::string>(get_field<jhstring>(m_object, "preSharedKey"))) + ,wepTxKeyIndex( get_field<jint>(m_object, "wepTxKeyIndex")) + ,priority( get_field<jint>(m_object, "priority")) + ,hiddenSSID( get_field<jboolean>(m_object, "hiddenSSID")) + ,allowedKeyManagement( get_field<jhobject>(m_object, "allowedKeyManagement", "Ljava/util/BitSet;")) + ,allowedProtocols( get_field<jhobject>(m_object, "allowedProtocols", "Ljava/util/BitSet;")) ,allowedPairwiseCiphers(get_field<jhobject>(m_object, "allowedPairwiseCiphers", "Ljava/util/BitSet;")) - ,allowedGroupCiphers(get_field<jhobject>(m_object, "allowedGroupCiphers", "Ljava/util/BitSet;")) + ,allowedGroupCiphers( get_field<jhobject>(m_object, "allowedGroupCiphers", "Ljava/util/BitSet;")) { } std::string CJNIWifiConfiguration::toString() { - return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "toString", "()Ljava/lang/String;")); } int CJNIWifiConfiguration::describeContents() { - return call_method<jint>(m_object, "describeContents", "()I"); + return call_method<jint>(m_object, + "describeContents", "()I"); } diff --git a/xbmc/android/jni/WifiConfiguration.h b/xbmc/android/jni/WifiConfiguration.h index 5855aeaea9..7e4b1e1354 100644 --- a/xbmc/android/jni/WifiConfiguration.h +++ b/xbmc/android/jni/WifiConfiguration.h @@ -18,31 +18,33 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" #include "BitSet.h" + class CJNIWifiConfiguration : public CJNIBase { public: CJNIWifiConfiguration(const jni::jhobject &object); - ~CJNIWifiConfiguration(){}; + ~CJNIWifiConfiguration() {}; - int networkId; - int status; + int networkId; + int status; std::string SSID; std::string BSSID; std::string preSharedKey; // std::string[] wepKeys; - int wepTxKeyIndex; - int priority; - bool hiddenSSID; - CJNIBitSet allowedKeyManagement; - CJNIBitSet allowedProtocols; - CJNIBitSet allowedAuthAlgorithms; - CJNIBitSet allowedPairwiseCiphers; - CJNIBitSet allowedGroupCiphers; + int wepTxKeyIndex; + int priority; + bool hiddenSSID; + CJNIBitSet allowedKeyManagement; + CJNIBitSet allowedProtocols; + CJNIBitSet allowedAuthAlgorithms; + CJNIBitSet allowedPairwiseCiphers; + CJNIBitSet allowedGroupCiphers; std::string toString(); - int describeContents(); + int describeContents(); private: CJNIWifiConfiguration(); diff --git a/xbmc/android/jni/WifiInfo.cpp b/xbmc/android/jni/WifiInfo.cpp index 3c895db400..553f6b9484 100644 --- a/xbmc/android/jni/WifiInfo.cpp +++ b/xbmc/android/jni/WifiInfo.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "WifiInfo.h" #include "jutils/jutils-details.hpp" @@ -24,60 +25,73 @@ using namespace jni; std::string CJNIWifiInfo::getSSID() const { - return jcast<std::string>(call_method<jhstring>(m_object, "getSSID", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getSSID", "()Ljava/lang/String;")); } std::string CJNIWifiInfo::getBSSID() const { - return jcast<std::string>(call_method<jhstring>(m_object, "getBSSID", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getBSSID", "()Ljava/lang/String;")); } int CJNIWifiInfo::getRssi() const { - return call_method<jint>(m_object, "getRssi", "()I"); + return call_method<jint>(m_object, + "getRssi", "()I"); } int CJNIWifiInfo::getLinkSpeed() const { - return call_method<jint>(m_object, "getLinkSpeed", "()I"); + return call_method<jint>(m_object, + "getLinkSpeed", "()I"); } std::string CJNIWifiInfo::getMacAddress() const { - return jcast<std::string>(call_method<jhstring>(m_object, "getMacAddress", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "getMacAddress", "()Ljava/lang/String;")); } int CJNIWifiInfo::getNetworkId() const { - return call_method<jint>(m_object, "getNetworkId", "()I"); + return call_method<jint>(m_object, + "getNetworkId", "()I"); } int CJNIWifiInfo::getIpAddress() const { - return call_method<jint>(m_object, "getIpAddress" , "()I"); + return call_method<jint>(m_object, + "getIpAddress" , "()I"); } bool CJNIWifiInfo::getHiddenSSID() const { - return call_method<jboolean>(m_object, "getHiddenSSID" , "()Z"); + return call_method<jboolean>(m_object, + "getHiddenSSID" , "()Z"); } std::string CJNIWifiInfo::toString() const { - return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;")); + return jcast<std::string>(call_method<jhstring>(m_object, + "toString", "()Ljava/lang/String;")); } int CJNIWifiInfo::describeContents() const { - return call_method<jint>(m_object, "describeContents" , "()I"); + return call_method<jint>(m_object, + "describeContents" , "()I"); } CJNISupplicantState CJNIWifiInfo::getSupplicantState() const { - return call_method<jhobject>(m_object, "getSupplicantState", "()Landroid/net/wifi/SupplicantState;"); + return call_method<jhobject>(m_object, + "getSupplicantState", "()Landroid/net/wifi/SupplicantState;"); } CJNINetworkInfoDetailedState CJNIWifiInfo::getDetailedStateOf(const CJNISupplicantState &suppState) { - return call_static_method<jhobject>("android/net/wifi/WifiInfo", "getDetailedStateOf", "(Landroid/net/wifi/SupplicantState;)Landroid/net/NetworkInfo$DetailedState;", suppState.get_raw()); + return call_static_method<jhobject>("android/net/wifi/WifiInfo", + "getDetailedStateOf", "(Landroid/net/wifi/SupplicantState;)Landroid/net/NetworkInfo$DetailedState;", + suppState.get_raw()); } diff --git a/xbmc/android/jni/WifiInfo.h b/xbmc/android/jni/WifiInfo.h index 504ad0fc3d..2f8c3389bf 100644 --- a/xbmc/android/jni/WifiInfo.h +++ b/xbmc/android/jni/WifiInfo.h @@ -18,6 +18,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" #include "Enum.h" #include "NetworkInfo.h" @@ -25,8 +26,9 @@ class CJNISupplicantState : public CJNIEnum { public: - ~CJNISupplicantState(){}; CJNISupplicantState(const jni::jhobject &object) : CJNIEnum(object){}; + ~CJNISupplicantState(){}; + private: CJNISupplicantState(); }; @@ -36,18 +38,20 @@ class CJNIWifiInfo : public CJNIBase public: CJNIWifiInfo(const jni::jhobject &object) : CJNIBase(object){}; ~CJNIWifiInfo(){}; - std::string getSSID() const; + + std::string getSSID() const; std::string getBSSID() const; - int getRssi() const; - int getLinkSpeed() const; + int getRssi() const; + int getLinkSpeed() const; std::string getMacAddress() const; - int getNetworkId() const; - int getIpAddress() const; - bool getHiddenSSID() const; + int getNetworkId() const; + int getIpAddress() const; + bool getHiddenSSID() const; std::string toString() const; - int describeContents() const; + int describeContents() const; CJNISupplicantState getSupplicantState() const; static CJNINetworkInfoDetailedState getDetailedStateOf(const CJNISupplicantState &suppState); + private: CJNIWifiInfo(); }; diff --git a/xbmc/android/jni/WifiManager.cpp b/xbmc/android/jni/WifiManager.cpp index 8571bf8375..0df4f978b8 100644 --- a/xbmc/android/jni/WifiManager.cpp +++ b/xbmc/android/jni/WifiManager.cpp @@ -17,6 +17,7 @@ * <http://www.gnu.org/licenses/>. * */ + #include "WifiManager.h" #include "DhcpInfo.h" #include "List.h" @@ -30,93 +31,111 @@ using namespace jni; CJNIList<CJNIWifiConfiguration> CJNIWifiManager::getConfiguredNetworks() { - return (CJNIList<CJNIWifiConfiguration>)call_method<jhobject>(m_object, "getConfiguredNetworks" , "()Ljava/util/List;"); + return call_method<jhobject>(m_object, + "getConfiguredNetworks" , "()Ljava/util/List;"); } CJNIList<CJNIScanResult> CJNIWifiManager::getScanResults() { - return (CJNIList<CJNIScanResult>)call_method<jhobject>(m_object, "getScanResults" , "()Ljava/util/List;"); + return call_method<jhobject>(m_object, + "getScanResults" , "()Ljava/util/List;"); } bool CJNIWifiManager::removeNetwork(int netId) { - return call_method<jboolean>(m_object, "removeNetwork", "(I)Z", netId); + return call_method<jboolean>(m_object, + "removeNetwork", "(I)Z", netId); } bool CJNIWifiManager::enableNetwork(int netID, bool disableOthers) { - return call_method<jboolean>(m_object, "enableNetwork", "(IZ)Z", netID, disableOthers); + return call_method<jboolean>(m_object, + "enableNetwork", "(IZ)Z", netID, disableOthers); } bool CJNIWifiManager::disableNetwork(int netID) { - return call_method<jboolean>(m_object, "disableNetwork", "(I)Z", netID); + return call_method<jboolean>(m_object, + "disableNetwork", "(I)Z", netID); } bool CJNIWifiManager::disconnect() { - return call_method<jboolean>(m_object, "disconnect", "()Z"); + return call_method<jboolean>(m_object, + "disconnect", "()Z"); } bool CJNIWifiManager::reconnect() { - return call_method<jboolean>(m_object, "reconnect", "()Z"); + return call_method<jboolean>(m_object, + "reconnect", "()Z"); } bool CJNIWifiManager::reassociate() { - return call_method<jboolean>(m_object, "rassociate", "()Z"); + return call_method<jboolean>(m_object, + "rassociate", "()Z"); } bool CJNIWifiManager::pingSupplicant() { - return call_method<jboolean>(m_object, "pingSupplicant", "()Z"); + return call_method<jboolean>(m_object, + "pingSupplicant", "()Z"); } bool CJNIWifiManager::startScan() { - return call_method<jboolean>(m_object, "startScan", "()Z"); + return call_method<jboolean>(m_object, + "startScan", "()Z"); } CJNIWifiInfo CJNIWifiManager::getConnectionInfo() { - return (CJNIWifiInfo)call_method<jhobject>(m_object, "getConnectionInfo", "()Landroid/net/wifi/WifiInfo;"); + return call_method<jhobject>(m_object, + "getConnectionInfo", "()Landroid/net/wifi/WifiInfo;"); } bool CJNIWifiManager::saveConfiguration() { - return call_method<jboolean>(m_object, "saveConfiguration", "()Z"); + return call_method<jboolean>(m_object, + "saveConfiguration", "()Z"); } CJNIDhcpInfo CJNIWifiManager::getDhcpInfo() { - return call_method<jhobject>(m_object, "getDhcpInfo", "()Landroid/net/DhcpInfo;"); + return call_method<jhobject>(m_object, + "getDhcpInfo", "()Landroid/net/DhcpInfo;"); } bool CJNIWifiManager::setWifiEnabled(bool enabled) { - return call_method<jboolean>(m_object, "setWifiEnabled", "(Z)Z", enabled); + return call_method<jboolean>(m_object, + "setWifiEnabled", "(Z)Z", enabled); } int CJNIWifiManager::getWifiState() { - return call_method<jint>(m_object, "getWifiState", "()I"); + return call_method<jint>(m_object, + "getWifiState", "()I"); } bool CJNIWifiManager::isWifiEnabled() { - return call_method<jboolean>(m_object, "isWifiEnabled", "()Z"); + return call_method<jboolean>(m_object, + "isWifiEnabled", "()Z"); } int CJNIWifiManager::calculateSignalLevel(int rssi, int numLevels) { - return call_static_method<jint>("android/net/wifi/WifiManager", "calculateSignalLevel", "(II)I", rssi, numLevels); + return call_static_method<jint>("android/net/wifi/WifiManager", + "calculateSignalLevel", "(II)I", rssi, numLevels); } int CJNIWifiManager::compareSignalLevel(int rssiA, int rssiB) { - return call_static_method<jint>("android/net/wifi/WifiManager", "compareSignalLevel", "(II)I", rssiA, rssiB); + return call_static_method<jint>("android/net/wifi/WifiManager", + "compareSignalLevel", "(II)I", rssiA, rssiB); } CJNIWifiManagerMulticastLock CJNIWifiManager::createMulticastLock(const std::string &tag) diff --git a/xbmc/android/jni/WifiManager.h b/xbmc/android/jni/WifiManager.h index e24f0925ae..0be4c73ff4 100644 --- a/xbmc/android/jni/WifiManager.h +++ b/xbmc/android/jni/WifiManager.h @@ -18,18 +18,22 @@ * <http://www.gnu.org/licenses/>. * */ + #include "JNIBase.h" #include "List.h" + class CJNIDhcpInfo; class CJNIWifiInfo; class CJNIScanResult; class CJNIWifiConfiguration; class CJNIWifiManagerMulticastLock; + class CJNIWifiManager : public CJNIBase { friend class CJNIContext; public: CJNIWifiManager(const jni::jhobject &object) : CJNIBase(object){}; + CJNIList<CJNIWifiConfiguration> getConfiguredNetworks(); bool removeNetwork(int); bool enableNetwork(int, bool); @@ -44,11 +48,12 @@ public: bool saveConfiguration(); CJNIDhcpInfo getDhcpInfo(); bool setWifiEnabled(bool); - int getWifiState(); + int getWifiState(); bool isWifiEnabled(); static int calculateSignalLevel(int, int); static int compareSignalLevel(int, int); CJNIWifiManagerMulticastLock createMulticastLock(const std::string &tag); + private: CJNIWifiManager(); }; diff --git a/xbmc/android/jni/jutils.cpp b/xbmc/android/jni/jutils.cpp index df1df1ec85..861fbca546 100644 --- a/xbmc/android/jni/jutils.cpp +++ b/xbmc/android/jni/jutils.cpp @@ -49,10 +49,13 @@ #define DBG(fmt, ...) #include <string> #include "jutils/jutils-details.hpp" + namespace jni { + namespace details { + std::string jcast_helper<std::string, jstring>::cast(jstring const &v) { JNIEnv *env = xbmc_jnienv(); |