[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / android / activity / AndroidFeatures.cpp
1 /*
2  *      Copyright (C) 2012-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "AndroidFeatures.h"
22 #include "XBMCApp.h"
23 #include "utils/log.h"
24
25 #include <cpu-features.h>
26
27 bool CAndroidFeatures::HasNeon()
28 {
29   if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM) 
30     return ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
31   return false;
32 }
33
34 int CAndroidFeatures::GetVersion()
35 {
36   static int version = -1;
37
38   if (version == -1)
39   {
40     version = 0;
41
42     JNIEnv *jenv = NULL;
43     CXBMCApp::AttachCurrentThread(&jenv, NULL);
44
45     jclass jcOsBuild = jenv->FindClass("android/os/Build$VERSION");
46     if (jcOsBuild == NULL) 
47     {
48       CLog::Log(LOGERROR, "%s: Error getting class android.os.Build.VERSION", __PRETTY_FUNCTION__);
49       return version;
50     }
51
52     jint iSdkVersion = jenv->GetStaticIntField(jcOsBuild, jenv->GetStaticFieldID(jcOsBuild, "SDK_INT", "I"));
53     CLog::Log(LOGDEBUG, "%s: android.os.Build.VERSION %d", __PRETTY_FUNCTION__, (int)iSdkVersion);
54
55     // <= 10 Gingerbread
56     // <= 13 Honeycomb
57     // <= 15 IceCreamSandwich
58     //       JellyBean
59     version = iSdkVersion;
60
61     jenv->DeleteLocalRef(jcOsBuild);
62     CXBMCApp::DetachCurrentThread();
63   }
64   return version;
65 }
66
67 std::string CAndroidFeatures::GetLibiomxName()
68 {
69   std::string strOMXLibName;
70   int version = GetVersion();
71
72   // Gingerbread
73   if (version <= 10)
74     strOMXLibName = "libiomx-10.so";
75   // Honeycomb
76   else if (version <= 13)
77     strOMXLibName = "libiomx-13.so";
78   // IceCreamSandwich
79   else if (version <= 15)
80     strOMXLibName = "libiomx-14.so";
81   else
82     strOMXLibName = "unknown";
83
84   return strOMXLibName;
85 }
86