From 869c49c22573147c94b1e6d931c2cff696a54a47 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 24 Jul 2011 11:37:45 +0200 Subject: Android integration / cross-test ; Enhance Platform - android minor build fix - started dex'ing (gluegen-rt.apk, more to come for full junit tests) - android remote dalvikvm launch works (crosstest-java-android-armv7-rel.sh) - android detection, incl version (reflection) - Platform: - Add JAVA_VM_NAME and JAVA_VM_RUNIME - OSType maybe ANDROID, where the OS name (String) is Linux ! (ok ?) --- src/java/com/jogamp/common/os/AndroidVersion.java | 97 +++++++++++++++++++++++ src/java/com/jogamp/common/os/Platform.java | 37 +++++++-- src/java/com/jogamp/common/util/VersionUtil.java | 14 +++- 3 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 src/java/com/jogamp/common/os/AndroidVersion.java (limited to 'src/java/com/jogamp') diff --git a/src/java/com/jogamp/common/os/AndroidVersion.java b/src/java/com/jogamp/common/os/AndroidVersion.java new file mode 100644 index 0000000..b5a7cfa --- /dev/null +++ b/src/java/com/jogamp/common/os/AndroidVersion.java @@ -0,0 +1,97 @@ +package com.jogamp.common.os; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.Map; + +import com.jogamp.common.util.ReflectionUtil; + +public class AndroidVersion { + public static final boolean isAvailable; + + /** All SDK version map, where SDK_INT is the key to the current running version */ + public static final Map VERSION_CODES; + + /** Development codename, or the string "REL" for official release */ + public static final String CODENAME; + + /** internal build value used by the underlying source control. */ + public static final String INCREMENTAL; + + /** official build version string */ + public static final String RELEASE; + + /** SDK Version number, key to VERSION_CODES */ + public static final int SDK_INT; + + /** SDK Version string */ + public static final String SDK_NAME; + + static final String androidBuildVersion = "android.os.Build$VERSION"; + static final String androidBuildVersionCodes = "android.os.Build$VERSION_CODES"; + + static { + final ClassLoader cl = AndroidVersion.class.getClassLoader(); + Class abvClass = null; + Object abvObject= null; + Class abvcClass = null; + Object abvcObject= null; + try { + abvClass = ReflectionUtil.getClass(androidBuildVersion, true, cl); + abvObject = abvClass.newInstance(); + abvcClass = ReflectionUtil.getClass(androidBuildVersionCodes, true, cl); + abvcObject = abvcClass.newInstance(); + } catch (Exception e) { e.printStackTrace(); /* n/a */ } + isAvailable = null != abvObject ; + if(isAvailable) { + CODENAME = getString(abvClass, abvObject, "CODENAME"); + INCREMENTAL = getString(abvClass, abvObject, "INCREMENTAL"); + RELEASE = getString(abvClass, abvObject, "RELEASE"); + SDK_INT = getInt(abvClass, abvObject, "SDK_INT"); + VERSION_CODES = getVersionCodes(abvcClass, abvcObject); + String sdk_name = VERSION_CODES.get(new Integer(SDK_INT)); + SDK_NAME = ( null != sdk_name ) ? sdk_name : "SDK_"+SDK_INT ; + } else { + CODENAME = null; + INCREMENTAL = null; + RELEASE = null; + SDK_INT = -1; + VERSION_CODES = new HashMap(); + SDK_NAME = null; + } + } + + private static final Map getVersionCodes(Class cls, Object obj) { + HashMap map = new HashMap(); + Field[] fields = cls.getFields(); + for(int i=0; iIn case of {@link OSType#ANDROID}, see {@link #getOSType()}, the OS name is Linux

*/ - public static String getOS() { + public static String getOSName() { return OS; } @@ -316,6 +326,7 @@ public class Platform { /** * Returns the OS type. + *

In case of {@link OSType#ANDROID} the OS name, see {@link #getOSName()}, is Linux

*/ public static OSType getOSType() { return OS_TYPE; @@ -342,6 +353,20 @@ public class Platform { return JAVA_VENDOR; } + /** + * Returns the JAVA VM name. + */ + public static String getJavaVMName() { + return JAVA_VM_NAME; + } + + /** + * Returns the JAVA runtime name. + */ + public static String getJavaRuntimeName() { + return JAVA_RUNTIME_NAME; + } + /** * Returns the JAVA vendor url. */ diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java index 1589755..b8b7932 100644 --- a/src/java/com/jogamp/common/util/VersionUtil.java +++ b/src/java/com/jogamp/common/util/VersionUtil.java @@ -28,6 +28,7 @@ package com.jogamp.common.util; +import com.jogamp.common.os.AndroidVersion; import com.jogamp.common.os.Platform; import java.io.IOException; @@ -53,16 +54,21 @@ public class VersionUtil { sb.append(SEPERATOR).append(Platform.getNewline()); // environment - sb.append("Platform: ").append(Platform.getOS()).append(' ').append(Platform.getOSVersion()).append(" (os), "); + sb.append("Platform: ").append(Platform.getOSType()).append(" / ").append(Platform.getOSName()).append(' ').append(Platform.getOSVersion()).append(" (os), "); sb.append(Platform.getArch()).append(" (arch) ").append(Runtime.getRuntime().availableProcessors()).append(" cores"); sb.append(Platform.getNewline()); + if( Platform.OSType.ANDROID == Platform.getOSType() && AndroidVersion.isAvailable) { + sb.append("Platform: Android Version: ").append(AndroidVersion.CODENAME).append(", "); + sb.append(AndroidVersion.RELEASE).append(" [").append(AndroidVersion.RELEASE).append("], SDK: ").append(AndroidVersion.SDK_INT).append(", ").append(AndroidVersion.SDK_NAME); + sb.append(Platform.getNewline()); + } Platform.getMachineDescription().toString(sb).append(Platform.getNewline()); // JVM/JRE - sb.append("Platform: Java ").append(Platform.getJavaVersion()).append(", ").append(System.getProperty("java.vm.name")).append(", "); - sb.append(Platform.getJavaVendor()).append(", ").append(Platform.getJavaVendorURL()).append(", is JavaSE: ").append(Platform.isJavaSE()); - + sb.append("Platform: Java Version: ").append(Platform.getJavaVersion()).append(", VM: ").append(Platform.getJavaVMName()); + sb.append(", Runtime: ").append(Platform.getJavaRuntimeName()).append(Platform.getNewline()); + sb.append("Platform: Java Vendor: ").append(Platform.getJavaVendor()).append(", ").append(Platform.getJavaVendorURL()).append(", is JavaSE: ").append(Platform.isJavaSE()); sb.append(Platform.getNewline()).append(SEPERATOR); return sb; -- cgit v1.2.3