28package com.jogamp.common.os;
30import java.lang.reflect.Field;
32import com.jogamp.common.os.Platform.ABIType;
33import com.jogamp.common.os.Platform.CPUType;
34import com.jogamp.common.util.IntObjectHashMap;
35import com.jogamp.common.util.ReflectionUtil;
65 private static final String androidBuild =
"android.os.Build";
66 private static final String androidBuildVersion =
"android.os.Build$VERSION";
67 private static final String androidBuildVersionCodes =
"android.os.Build$VERSION_CODES";
71 Class<?> abClass =
null;
72 Object abObject=
null;
73 Class<?> abvClass =
null;
74 Object abvObject=
null;
75 Class<?> abvcClass =
null;
76 Object abvcObject=
null;
78 final boolean isDalvikVm =
"Dalvik".equals(System.getProperty(
"java.vm.name"));
83 abObject = abClass.newInstance();
85 abvObject = abvClass.newInstance();
87 abvcObject = abvcClass.newInstance();
88 }
catch (
final Exception e) { }
90 isAvailable = isDalvikVm &&
null != abObject &&
null != abvObject;
92 CPU_ABI = getString(abClass, abObject,
"CPU_ABI",
true);
93 CPU_ABI2 = getString(abClass, abObject,
"CPU_ABI2",
true);
94 CODENAME = getString(abvClass, abvObject,
"CODENAME",
false);
95 INCREMENTAL = getString(abvClass, abvObject,
"INCREMENTAL",
false);
96 RELEASE = getString(abvClass, abvObject,
"RELEASE",
false);
97 SDK_INT = getInt(abvClass, abvObject,
"SDK_INT");
98 final String sdk_name;
99 if(
null != abvcObject ) {
100 final IntObjectHashMap version_codes = getVersionCodes(abvcClass, abvcObject);
101 sdk_name = (String) version_codes.
get(
SDK_INT);
144 private static final IntObjectHashMap getVersionCodes(
final Class<?> cls,
final Object obj) {
145 final Field[] fields = cls.getFields();
147 for(
int i=0; i<fields.length; i++) {
149 final int version = fields[i].getInt(obj);
150 final String version_name = fields[i].getName();
152 map.
put(
new Integer(version), version_name);
153 }
catch (
final Exception e) { e.printStackTrace(); }
158 private static final String getString(
final Class<?> cls,
final Object obj,
final String name,
final boolean lowerCase) {
160 final Field f = cls.getField(name);
161 final String s = (String) f.
get(obj);
162 if( lowerCase &&
null != s ) {
163 return s.toLowerCase();
167 }
catch (
final Exception e) { e.printStackTrace(); }
171 private static final int getInt(
final Class<?> cls,
final Object obj,
final String name) {
173 final Field f = cls.getField(name);
174 return f.getInt(obj);
175 }
catch (
final Exception e) { e.printStackTrace(); }
static final String CPU_ABI
The name of the instruction set (CPU type + ABI convention) of native code.
static final int SDK_INT
SDK Version number, key to VERSION_CODES.
static final ABIType ABI_TYPE2
static final String CODENAME
Development codename, or the string "REL" for official release.
static final String SDK_NAME
SDK Version string.
static final CPUType CPU_TYPE
static final String CPU_ABI2
The name of the second instruction set (CPU type + ABI convention) of native code.
static final ABIType ABI_TYPE
static final String INCREMENTAL
internal build value used by the underlying source control.
static final String RELEASE
official build version string
static final boolean isAvailable
static final CPUType CPU_TYPE2
Fast HashMap for primitive data.
Object put(final int key, final Object value)
Maps the key to the specified value.
Object get(final int key)
Returns the value to which the specified key is mapped, or getKeyNotFoundValue if this map contains n...
static final Class<?> getClass(final String clazzName, final boolean initializeClazz, final ClassLoader cl)
Loads and returns the class or null.