aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/jogamp/android/launcher
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-07-03 16:06:47 +0200
committerSven Gothel <[email protected]>2014-07-03 16:06:47 +0200
commitdf9ff7f340a5ab4e07efc613f5f264eeae63d4c7 (patch)
tree239ae276b82024b140428e6c0fe5d739fdd686a4 /src/java/jogamp/android/launcher
parenteb47aaba63e3b1bf55f274a0f338f1010a017ae4 (diff)
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74) - Change non static accesses to static members using declaring type - Change indirect accesses to static members to direct accesses (accesses through subtypes) - Add final modifier to private fields - Add final modifier to method parameters - Add final modifier to local variables - Remove unnecessary casts - Remove unnecessary '$NON-NLS$' tags - Remove trailing white spaces on all lines
Diffstat (limited to 'src/java/jogamp/android/launcher')
-rw-r--r--src/java/jogamp/android/launcher/ActivityLauncher.java26
-rw-r--r--src/java/jogamp/android/launcher/AssetDexClassLoader.java20
-rw-r--r--src/java/jogamp/android/launcher/ClassLoaderUtil.java92
-rw-r--r--src/java/jogamp/android/launcher/LauncherTempFileCache.java102
-rw-r--r--src/java/jogamp/android/launcher/LauncherUtil.java188
-rw-r--r--src/java/jogamp/android/launcher/LauncherVersionActivity.java22
-rw-r--r--src/java/jogamp/android/launcher/MainLauncher.java86
-rw-r--r--src/java/jogamp/android/launcher/TraceDexClassLoader.java8
8 files changed, 272 insertions, 272 deletions
diff --git a/src/java/jogamp/android/launcher/ActivityLauncher.java b/src/java/jogamp/android/launcher/ActivityLauncher.java
index 72b7c0a..99bead8 100644
--- a/src/java/jogamp/android/launcher/ActivityLauncher.java
+++ b/src/java/jogamp/android/launcher/ActivityLauncher.java
@@ -48,7 +48,7 @@ public class ActivityLauncher extends Activity {
Object activityObject = null;
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(final Bundle savedInstanceState) {
Log.d(TAG, "onCreate - S");
super.onCreate(savedInstanceState);
@@ -57,7 +57,7 @@ public class ActivityLauncher extends Activity {
data.setSystemProperties();
dataSet = true;
- ClassLoader cl = ClassLoaderUtil.createClassLoader(this, data.getSysPackages(), data.getUsrPackages(), null);
+ final ClassLoader cl = ClassLoaderUtil.createClassLoader(this, data.getSysPackages(), data.getUsrPackages(), null);
if(null != cl) {
try {
activityClazz = Class.forName(data.getActivityName(), true, cl);
@@ -72,7 +72,7 @@ public class ActivityLauncher extends Activity {
mSetRootActivity = activityClazz.getMethod("setRootActivity", Activity.class);
activityObject = createInstance(activityClazz, null);
Log.d(TAG, "Activity Object "+activityObject);
- } catch (Exception e) {
+ } catch (final Exception e) {
Log.d(TAG, "error: "+e, e);
throw new RuntimeException(e);
}
@@ -81,7 +81,7 @@ public class ActivityLauncher extends Activity {
if( null == mOnCreate || null == mOnDestroy || null == mOnPause ||
null == mOnRestart || null == mOnResume ||
null == mSetRootActivity ) {
- RuntimeException e = new RuntimeException("XXX - incomplete method set");
+ final RuntimeException e = new RuntimeException("XXX - incomplete method set");
Log.d(TAG, "error: "+e, e);
throw e;
}
@@ -172,18 +172,18 @@ public class ActivityLauncher extends Activity {
/**
* @throws JogampRuntimeException if the instance can not be created.
*/
- public static final Object createInstance(Class<?> clazz, Class<?>[] cstrArgTypes, Object ... cstrArgs)
+ public static final Object createInstance(final Class<?> clazz, final Class<?>[] cstrArgTypes, final Object ... cstrArgs)
throws RuntimeException
{
return createInstance(getConstructor(clazz, cstrArgTypes), cstrArgs);
}
- public static final Object createInstance(Constructor<?> cstr, Object ... cstrArgs)
+ public static final Object createInstance(final Constructor<?> cstr, final Object ... cstrArgs)
throws RuntimeException
{
try {
return cstr.newInstance(cstrArgs);
- } catch (Exception e) {
+ } catch (final Exception e) {
Throwable t = e;
if (t instanceof InvocationTargetException) {
t = ((InvocationTargetException) t).getTargetException();
@@ -201,22 +201,22 @@ public class ActivityLauncher extends Activity {
/**
* @throws JogampRuntimeException if the constructor can not be delivered.
*/
- protected static final Constructor<?> getConstructor(Class<?> clazz, Class<?> ... cstrArgTypes)
+ protected static final Constructor<?> getConstructor(final Class<?> clazz, Class<?> ... cstrArgTypes)
throws RuntimeException {
try {
if(null == cstrArgTypes) {
cstrArgTypes = zeroTypes;
}
return clazz.getDeclaredConstructor(cstrArgTypes);
- } catch (NoSuchMethodException ex) {
+ } catch (final NoSuchMethodException ex) {
throw new RuntimeException("Constructor: '" + clazz + "(" + asString(cstrArgTypes) + ")' not found", ex);
}
}
protected static final Class<?>[] zeroTypes = new Class[0];
- protected static final String asString(Class<?>[] argTypes) {
- StringBuilder args = new StringBuilder();
+ protected static final String asString(final Class<?>[] argTypes) {
+ final StringBuilder args = new StringBuilder();
boolean coma = false;
if(null != argTypes) {
for (int i = 0; i < argTypes.length; i++) {
@@ -230,12 +230,12 @@ public class ActivityLauncher extends Activity {
return args.toString();
}
- protected static final Object callMethod(Object instance, Method method, Object ... args)
+ protected static final Object callMethod(final Object instance, final Method method, final Object ... args)
throws RuntimeException
{
try {
return method.invoke(instance, args);
- } catch (Exception e) {
+ } catch (final Exception e) {
Throwable t = e;
if (t instanceof InvocationTargetException) {
t = ((InvocationTargetException) t).getTargetException();
diff --git a/src/java/jogamp/android/launcher/AssetDexClassLoader.java b/src/java/jogamp/android/launcher/AssetDexClassLoader.java
index fb2d7d3..84e5318 100644
--- a/src/java/jogamp/android/launcher/AssetDexClassLoader.java
+++ b/src/java/jogamp/android/launcher/AssetDexClassLoader.java
@@ -9,11 +9,11 @@ import dalvik.system.DexClassLoader;
public class AssetDexClassLoader extends DexClassLoader {
private static final boolean DEBUG = false;
private static final String assets_folder = "assets/";
-
+
private static int next_id = 1;
private final int id;
-
- public AssetDexClassLoader(String dexPath, String dexOutputDir, String libPath, ClassLoader parent) {
+
+ public AssetDexClassLoader(final String dexPath, final String dexOutputDir, final String libPath, final ClassLoader parent) {
super(dexPath, dexOutputDir, libPath, parent);
synchronized(AssetDexClassLoader.class) {
id = next_id++;
@@ -22,27 +22,27 @@ public class AssetDexClassLoader extends DexClassLoader {
Log.d(getSimpleName(), getIdName()+".ctor: dexPath " + dexPath + ", dexOutputDir " + dexOutputDir + ", libPath " + libPath + ", parent " + parent);
}
}
-
+
protected final String getSimpleName() {
return AssetDexClassLoader.class.getSimpleName();
}
protected final String getIdName() {
return "ADCL["+id+"]";
}
-
+
@Override
- public String findLibrary(String libName) {
- final String res = super.findLibrary(libName);
+ public String findLibrary(final String libName) {
+ final String res = super.findLibrary(libName);
if(DEBUG) {
Log.d(getSimpleName(), getIdName()+".findLibrary: " + libName + " -> " + res);
}
return res;
}
-
+
@Override
- public URL findResource(String name) {
+ public URL findResource(final String name) {
final String assetName = name.startsWith(assets_folder) ? name : assets_folder + name ;
- URL url = super.findResource(assetName);
+ final URL url = super.findResource(assetName);
if(DEBUG) {
Log.d(getSimpleName(), getIdName()+".findResource: " + name + " -> " + assetName + " -> " + url);
}
diff --git a/src/java/jogamp/android/launcher/ClassLoaderUtil.java b/src/java/jogamp/android/launcher/ClassLoaderUtil.java
index 76dbf53..5238fd4 100644
--- a/src/java/jogamp/android/launcher/ClassLoaderUtil.java
+++ b/src/java/jogamp/android/launcher/ClassLoaderUtil.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -40,33 +40,33 @@ import android.util.Log;
public class ClassLoaderUtil {
private static final String TAG = "JogampClassLoader";
-
+
private static HashMap<String, ClassLoader> cachedClassLoader = new HashMap<String, ClassLoader>();
-
+
// location where optimized dex files will be written
private static final String dexPathName= "jogampDex";
- private static File dexPath = null;
-
- private static LauncherTempFileCache tmpFileCache = null;
-
+ private static File dexPath = null;
+
+ private static LauncherTempFileCache tmpFileCache = null;
+
private static final String PATH_SEP = "/";
private static final String ELEM_SEP = ":";
-
- private static synchronized void init(Context ctx) {
+
+ private static synchronized void init(final Context ctx) {
if(null == tmpFileCache) {
if(!LauncherTempFileCache.initSingleton(ctx)) {
throw new InternalError("TempFileCache initialization error");
}
tmpFileCache = new LauncherTempFileCache();
if(!tmpFileCache.isValid()) {
- throw new InternalError("TempFileCache instantiation error");
- }
+ throw new InternalError("TempFileCache instantiation error");
+ }
dexPath = new File(tmpFileCache.getTempDir(), dexPathName);
Log.d(TAG, "jogamp dexPath: " + dexPath.getAbsolutePath());
dexPath.mkdir();
- }
+ }
}
-
+
/**
* @param ctx
* @param cachedPackageName list of package names w/ native libraries for which a ClassLoader shall be cached, i.e. persistence.
@@ -75,11 +75,11 @@ public class ClassLoaderUtil {
* @param userAPKNames optional non-cached user APKs
* @return
*/
- public static synchronized ClassLoader createClassLoader(Context ctx, List<String> cachedPackageName,
- List<String> userPackageNames, List<String> userAPKNames) {
- return createClassLoader(ctx, cachedPackageName, userPackageNames, userAPKNames, null);
+ public static synchronized ClassLoader createClassLoader(final Context ctx, final List<String> cachedPackageName,
+ final List<String> userPackageNames, final List<String> userAPKNames) {
+ return createClassLoader(ctx, cachedPackageName, userPackageNames, userAPKNames, null);
}
-
+
/**
* @param ctx
* @param cachedPackageNames list of package names w/ native libraries for which a ClassLoader shall be cached, i.e. persistence.
@@ -89,11 +89,11 @@ public class ClassLoaderUtil {
* @param parent
* @return
*/
- public static synchronized ClassLoader createClassLoader(Context ctx, List<String> cachedPackageNames,
- List<String> userPackageNames, List<String> userAPKNames,
- ClassLoader parent) {
+ public static synchronized ClassLoader createClassLoader(final Context ctx, final List<String> cachedPackageNames,
+ final List<String> userPackageNames, final List<String> userAPKNames,
+ final ClassLoader parent) {
init(ctx);
-
+
final String cacheKey = cachedPackageNames.toString();
ClassLoader clCached = cachedClassLoader.get(cacheKey);
if( null == clCached ) {
@@ -101,12 +101,12 @@ public class ClassLoaderUtil {
cachedClassLoader.put(cacheKey, clCached);
Log.d(TAG, "NEW cached-CL: cachedPackageNames: "+cacheKey);
} else {
- Log.d(TAG, "REUSE cached-CL: cachedPackageNames: "+cacheKey);
+ Log.d(TAG, "REUSE cached-CL: cachedPackageNames: "+cacheKey);
}
-
- return createClassLoaderImpl(ctx, userPackageNames, false, userAPKNames, clCached);
+
+ return createClassLoaderImpl(ctx, userPackageNames, false, userAPKNames, clCached);
}
-
+
/**
* @param ctx
* @param packageNames list of package names
@@ -115,33 +115,33 @@ public class ClassLoaderUtil {
* @param parent
* @return
*/
- private static synchronized ClassLoader createClassLoaderImpl(Context ctx, List<String> packageNames, boolean addLibPath,
- List<String> apkNames, ClassLoader parent) {
-
+ private static synchronized ClassLoader createClassLoaderImpl(final Context ctx, final List<String> packageNames, final boolean addLibPath,
+ final List<String> apkNames, final ClassLoader parent) {
+
final ApplicationInfo appInfoLauncher= ctx.getApplicationInfo();
final String appDirLauncher = new File(appInfoLauncher.dataDir).getParent();
final String libSubDef = "lib";
Log.d(TAG, "S: userPackageNames: "+packageNames+"; Launcher: appDir "+appDirLauncher+", dataDir: "+appInfoLauncher.dataDir+", nativeLibraryDir "+appInfoLauncher.nativeLibraryDir);
-
+
final StringBuilder apks = new StringBuilder();
final StringBuilder libs = new StringBuilder();
int apkCount = 0;
String lastUserPackageName = null; // the very last one reflects the Activity
-
+
if( null != packageNames ) {
- for(Iterator<String> i=packageNames.iterator(); i.hasNext(); ) {
+ for(final Iterator<String> i=packageNames.iterator(); i.hasNext(); ) {
lastUserPackageName = i.next();
-
+
String userAPK = null;
String nativeLibraryDir=null;
try {
final PackageManager pm = ctx.getPackageManager();
final ApplicationInfo appInfo = pm.getApplicationInfo(lastUserPackageName, 0);
- final String appDir = new File(appInfoLauncher.dataDir).getParent();
+ final String appDir = new File(appInfoLauncher.dataDir).getParent();
userAPK = appInfo.sourceDir;
nativeLibraryDir = appInfo.nativeLibraryDir;
Log.d(TAG, "S: userPackage: "+lastUserPackageName+", apk "+userAPK+", appDir "+appDir+", dataDir: "+appInfo.dataDir+", nativeLibraryDir "+nativeLibraryDir);
- } catch (PackageManager.NameNotFoundException e) {
+ } catch (final PackageManager.NameNotFoundException e) {
Log.d(TAG, "error: "+e, e);
}
if(null != userAPK) {
@@ -173,10 +173,10 @@ public class ClassLoaderUtil {
}
}
final int userAPKCount = apkCount;
-
+
if( null != apkNames ) {
- for(Iterator<String> i=apkNames.iterator(); i.hasNext(); ) {
- String userAPK = i.next();
+ for(final Iterator<String> i=apkNames.iterator(); i.hasNext(); ) {
+ final String userAPK = i.next();
if(apkCount>0) {
apks.append(ELEM_SEP);
}
@@ -189,13 +189,13 @@ public class ClassLoaderUtil {
return null;
}
}
-
+
// return new TraceDexClassLoader(apks.toString(), dexPath.getAbsolutePath(), libs.toString(), parent);
return new AssetDexClassLoader(apks.toString(), dexPath.getAbsolutePath(), libs.toString(), parent);
}
-
+
/***
- *
+ *
public boolean setAPKClassLoader(String activityPackageName, ClassLoader classLoader)
{
try {
@@ -212,9 +212,9 @@ public class ClassLoaderUtil {
Field mClassLoader = getField(apkClass, "mClassLoader");
mClassLoader.set(apk, classLoader);
-
+
Log.d(TAG, "setAPKClassLoader: OK");
-
+
return true;
} catch (IllegalArgumentException e) {
e.printStackTrace();
@@ -238,6 +238,6 @@ public class ClassLoaderUtil {
}
return null;
}
- */
+ */
}
diff --git a/src/java/jogamp/android/launcher/LauncherTempFileCache.java b/src/java/jogamp/android/launcher/LauncherTempFileCache.java
index c7b9ad0..6836dd9 100644
--- a/src/java/jogamp/android/launcher/LauncherTempFileCache.java
+++ b/src/java/jogamp/android/launcher/LauncherTempFileCache.java
@@ -42,14 +42,14 @@ public class LauncherTempFileCache {
// Lifecycle: For all JVMs, ClassLoader and times.
private static final String tmpSubDir = "jogamp";
private static final String tmpDirPrefix = "file_cache";
-
+
// Get the value of the tmproot system property
// Lifecycle: For all JVMs and ClassLoader
/* package */ static final String tmpRootPropName = "jnlp.jogamp.tmp.cache.root";
// Flag indicating that we got a fatal error in the static initializer.
private static boolean staticInitError = false;
-
+
private static File tmpBaseDir;
// String representing the name of the temp root directory relative to the
@@ -66,26 +66,26 @@ public class LauncherTempFileCache {
private boolean initError = false;
private File individualTmpDir;
-
+
/**
* Documented way to kick off static initialization
* @return true is static initialization was successful
*/
- public static synchronized boolean initSingleton(Context ctx) {
+ public static synchronized boolean initSingleton(final Context ctx) {
if(null == tmpRootDir && !staticInitError) {
// Create / initialize the temp root directory, starting the Reaper
// thread to reclaim old installations if necessary. If we get an
// exception, set an error code.
try {
initTmpRoot(ctx);
- } catch (Exception ex) {
+ } catch (final Exception ex) {
ex.printStackTrace();
staticInitError = true;
}
}
- return !staticInitError;
+ return !staticInitError;
}
-
+
/**
* This method is called by the static initializer to create / initialize
* the temp root directory that will hold the temp directories for this
@@ -136,7 +136,7 @@ public class LauncherTempFileCache {
*
* 6. Start the Reaper thread to cleanup old installations.
*/
- private static void initTmpRoot(Context ctx) throws IOException {
+ private static void initTmpRoot(final Context ctx) throws IOException {
if (DEBUG) {
System.err.println("TempFileCache: Static Initialization ----------------------------------------------");
System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(LauncherTempFileCache.class.getClassLoader().hashCode()));
@@ -165,7 +165,7 @@ public class LauncherTempFileCache {
tmpRootDir = new File(tmpBaseDir, tmpRootPropValue);
if (DEBUG) {
System.err.println("TempFileCache: Trying tmpRootDir = " + tmpRootDir.getAbsolutePath());
- }
+ }
if (tmpRootDir.isDirectory()) {
if (!tmpRootDir.canWrite()) {
throw new IOException("Temp root directory is not writable: " + tmpRootDir.getAbsolutePath());
@@ -177,9 +177,9 @@ public class LauncherTempFileCache {
tmpRootPropValue = null;
tmpRootDir = null;
System.clearProperty(tmpRootPropName);
- }
+ }
}
-
+
if (tmpRootPropValue == null) {
// Create the tmpbase directory if it doesn't already exist
tmpBaseDir.mkdirs();
@@ -188,7 +188,7 @@ public class LauncherTempFileCache {
}
// Create ${tmpbase}/jlnNNNN.tmp then lock the file
- File tmpFile = File.createTempFile("jln", ".tmp", tmpBaseDir);
+ final File tmpFile = File.createTempFile("jln", ".tmp", tmpBaseDir);
if (DEBUG) {
System.err.println("TempFileCache: tmpFile = " + tmpFile.getAbsolutePath());
}
@@ -197,12 +197,12 @@ public class LauncherTempFileCache {
final FileLock tmpLock = tmpChannel.lock();
// Strip off the ".tmp" to get the name of the tmprootdir
- String tmpFileName = tmpFile.getAbsolutePath();
- String tmpRootName = tmpFileName.substring(0, tmpFileName.lastIndexOf(".tmp"));
+ final String tmpFileName = tmpFile.getAbsolutePath();
+ final String tmpRootName = tmpFileName.substring(0, tmpFileName.lastIndexOf(".tmp"));
// create ${tmpbase}/jlnNNNN.lck then lock the file
- String lckFileName = tmpRootName + ".lck";
- File lckFile = new File(lckFileName);
+ final String lckFileName = tmpRootName + ".lck";
+ final File lckFile = new File(lckFileName);
if (DEBUG) {
System.err.println("TempFileCache: lckFile = " + lckFile.getAbsolutePath());
}
@@ -235,7 +235,7 @@ public class LauncherTempFileCache {
tmpLock.release();
lckOut.close();
lckLock.release();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
// Do nothing
}
}
@@ -249,7 +249,7 @@ public class LauncherTempFileCache {
}
// Start a new Reaper thread to do stuff...
- Thread reaperThread = new Thread() {
+ final Thread reaperThread = new Thread() {
/* @Override */
public void run() {
deleteOldTempDirs();
@@ -276,9 +276,9 @@ public class LauncherTempFileCache {
// enumerate list of jnl*.lck files, ignore our own jlnNNNN file
final String ourLockFile = tmpRootPropValue + ".lck";
- FilenameFilter lckFilter = new FilenameFilter() {
+ final FilenameFilter lckFilter = new FilenameFilter() {
/* @Override */
- public boolean accept(File dir, String name) {
+ public boolean accept(final File dir, final String name) {
return name.endsWith(".lck") && !name.equals(ourLockFile);
}
};
@@ -288,16 +288,16 @@ public class LauncherTempFileCache {
// (which should always succeed unless there is a problem). If we can
// get the lock on both files, then it must be an old installation, and
// we will delete it.
- String[] fileNames = tmpBaseDir.list(lckFilter);
+ final String[] fileNames = tmpBaseDir.list(lckFilter);
if (fileNames != null) {
for (int i = 0; i < fileNames.length; i++) {
- String lckFileName = fileNames[i];
- String tmpDirName = lckFileName.substring(0, lckFileName.lastIndexOf(".lck"));
- String tmpFileName = tmpDirName + ".tmp";
+ final String lckFileName = fileNames[i];
+ final String tmpDirName = lckFileName.substring(0, lckFileName.lastIndexOf(".lck"));
+ final String tmpFileName = tmpDirName + ".tmp";
- File lckFile = new File(tmpBaseDir, lckFileName);
- File tmpFile = new File(tmpBaseDir, tmpFileName);
- File tmpDir = new File(tmpBaseDir, tmpDirName);
+ final File lckFile = new File(tmpBaseDir, lckFileName);
+ final File tmpFile = new File(tmpBaseDir, tmpFileName);
+ final File tmpDir = new File(tmpBaseDir, tmpDirName);
if (lckFile.exists() && tmpFile.exists() && tmpDir.isDirectory()) {
FileOutputStream tmpOut = null;
@@ -308,7 +308,7 @@ public class LauncherTempFileCache {
tmpOut = new FileOutputStream(tmpFile);
tmpChannel = tmpOut.getChannel();
tmpLock = tmpChannel.tryLock();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
// Ignore exceptions
if (DEBUG) {
ex.printStackTrace();
@@ -324,7 +324,7 @@ public class LauncherTempFileCache {
lckOut = new FileOutputStream(lckFile);
lckChannel = lckOut.getChannel();
lckLock = lckChannel.tryLock();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
if (DEBUG) {
ex.printStackTrace();
}
@@ -344,12 +344,12 @@ public class LauncherTempFileCache {
// occasional 0-byte .lck or .tmp file left around
try {
lckOut.close();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
}
lckFile.delete();
try {
tmpOut.close();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
}
tmpFile.delete();
} else {
@@ -362,7 +362,7 @@ public class LauncherTempFileCache {
// on the *.tmp file
tmpOut.close();
tmpLock.release();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
if (DEBUG) {
ex.printStackTrace();
}
@@ -382,14 +382,14 @@ public class LauncherTempFileCache {
* Remove the specified file or directory. If "path" is a directory, then
* recursively remove all entries, then remove the directory itself.
*/
- private static void removeAll(File path) {
+ private static void removeAll(final File path) {
if (DEBUG) {
System.err.println("TempFileCache: removeAll(" + path + ")");
}
if (path.isDirectory()) {
// Recursively remove all files/directories in this directory
- File[] list = path.listFiles();
+ final File[] list = path.listFiles();
if (list != null) {
for (int i = 0; i < list.length; i++) {
removeAll(list[i]);
@@ -405,10 +405,10 @@ public class LauncherTempFileCache {
System.err.println("TempFileCache: new TempFileCache() --------------------- (static ok: "+(!staticInitError)+")");
System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(LauncherTempFileCache.class.getClassLoader().hashCode())+", this 0x"+Integer.toHexString(hashCode()));
}
- if(!staticInitError) {
+ if(!staticInitError) {
try {
createTmpDir();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
ex.printStackTrace();
initError = true;
}
@@ -416,23 +416,23 @@ public class LauncherTempFileCache {
if (DEBUG) {
System.err.println("tempDir: "+individualTmpDir+" (ok: "+(!initError)+")");
System.err.println("----------------------------------------------------------");
- }
+ }
}
-
+
/**
* @return true is static and object initialization was successful
*/
public boolean isValid() { return !staticInitError && !initError; }
-
+
/**
- * Base temp directory used by TempFileCache.
+ * Base temp directory used by TempFileCache.
* Lifecycle: For all JVMs, ClassLoader and times.
- *
+ *
* This is set to:
*
* ${java.io.tmpdir}/<tmpDirPrefix>
*
- *
+ *
* @return
*/
public File getBaseDir() { return tmpBaseDir; }
@@ -445,16 +445,16 @@ public class LauncherTempFileCache {
*
* <tmpBaseDir>/<tmpRootPropValue>
*
- * Use Case: Per ClassLoader files, eg. native libraries.
+ * Use Case: Per ClassLoader files, eg. native libraries.
*
* Old temp directories are cleaned up the next time a JVM is launched that
* uses TempFileCache.
*
- *
+ *
* @return
*/
public File getRootDir() { return tmpRootDir; }
-
+
/**
* Temporary directory for individual files (eg. native libraries of one ClassLoader instance).
* The directory name is:
@@ -466,12 +466,12 @@ public class LauncherTempFileCache {
* where jlnMMMMM is the unique filename created by File.createTempFile()
* without the ".tmp" extension.
*
- *
+ *
* @return
*/
public File getTempDir() { return individualTmpDir; }
-
-
+
+
/**
* Create the temp directory in tmpRootDir. To do this, we create a temp
* file with a ".tmp" extension, and then create a directory of the
@@ -480,9 +480,9 @@ public class LauncherTempFileCache {
* We avoid deleteOnExit, because it doesn't work reliably.
*/
private void createTmpDir() throws IOException {
- File tmpFile = File.createTempFile("jln", ".tmp", tmpRootDir);
- String tmpFileName = tmpFile.getAbsolutePath();
- String tmpDirName = tmpFileName.substring(0, tmpFileName.lastIndexOf(".tmp"));
+ final File tmpFile = File.createTempFile("jln", ".tmp", tmpRootDir);
+ final String tmpFileName = tmpFile.getAbsolutePath();
+ final String tmpDirName = tmpFileName.substring(0, tmpFileName.lastIndexOf(".tmp"));
individualTmpDir = new File(tmpDirName);
if (!individualTmpDir.mkdir()) {
throw new IOException("Cannot create " + individualTmpDir);
diff --git a/src/java/jogamp/android/launcher/LauncherUtil.java b/src/java/jogamp/android/launcher/LauncherUtil.java
index 1dfc218..2b7bd79 100644
--- a/src/java/jogamp/android/launcher/LauncherUtil.java
+++ b/src/java/jogamp/android/launcher/LauncherUtil.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -43,45 +43,45 @@ import android.util.Log;
* Helper class to parse Uri's and programmatically add package names and properties to create an Uri or Intend.
* <p>
* The order of the Uri segments (any arguments) is preserved.
- * </p>
+ * </p>
*/
public class LauncherUtil {
-
+
/** Default launch mode. */
public static final String LAUNCH_ACTIVITY_NORMAL = "org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL";
-
+
/** Transparent launch mode. Note: This seems to be required to achieve translucency, since setTheme(..) doesn't work. */
public static final String LAUNCH_ACTIVITY_TRANSPARENT = "org.jogamp.launcher.action.LAUNCH_ACTIVITY_TRANSPARENT";
-
+
/** FIXME: TODO */
public static final String LAUNCH_MAIN = "org.jogamp.launcher.action.LAUNCH_MAIN";
-
+
/** FIXME: TODO */
public static final String LAUNCH_JUNIT = "org.jogamp.launcher.action.LAUNCH_JUNIT";
-
+
/** The protocol <code>launch</code> */
public static final String SCHEME = "launch";
-
+
/** The host <code>jogamp.org</code> */
public static final String HOST = "jogamp.org";
-
+
static final String SYS_PKG = "sys";
-
+
static final String USR_PKG = "pkg";
-
+
static final String ARG = "arg";
-
+
public static abstract class BaseActivityLauncher extends Activity {
final OrderedProperties props = new OrderedProperties();
final ArrayList<String> args = new ArrayList<String>();
- /**
+ /**
* Returns the default {@link LauncherUtil#LAUNCH_ACTIVITY_NORMAL} action.
* <p>
* Should be overridden for other action, eg. {@link LauncherUtil#LAUNCH_ACTIVITY_TRANSPARENT}.
* </p>
*/
public String getAction() { return LAUNCH_ACTIVITY_NORMAL; }
-
+
/**
* Returns the properties, which are being propagated to the target activity.
* <p>
@@ -89,58 +89,58 @@ public class LauncherUtil {
* </p>
*/
public final OrderedProperties getProperties() { return props; }
-
+
/**
* Returns the commandline arguments, which are being propagated to the target activity.
* <p>
* Maybe be used to set custom commandline arguments.
* </p>
*/
- public final ArrayList<String> getArguments() { return args; }
-
+ public final ArrayList<String> getArguments() { return args; }
+
/** Custom initialization hook which can be overriden to setup data, e.g. fill the properties retrieved by {@link #getProperties()}. */
public void init() { }
-
+
/** Returns true if this launcher activity shall end after starting the downstream activity. Defaults to <code>true</code>, override to change behavior. */
public boolean finishAfterDelegate() { return true; }
-
+
/** Must return the downstream Activity class name */
public abstract String getActivityName();
-
+
/** Must return a list of required user packages, at least one containing the activity. */
public abstract List<String> getUsrPackages();
-
+
/** Return a list of required system packages w/ native libraries, may return null or a zero sized list. */
public abstract List<String> getSysPackages();
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
init();
-
+
final DataSet data = new DataSet();
data.setActivityName(getActivityName());
data.addAllSysPackages(getSysPackages());
data.addAllUsrPackages(getUsrPackages());
data.addAllProperties(props);
data.addAllArguments(args);
-
+
final Intent intent = LauncherUtil.getIntent(getAction(), data);
Log.d(getClass().getSimpleName(), "Launching Activity: "+intent);
startActivity (intent);
-
+
if(finishAfterDelegate()) {
finish(); // done
}
- }
+ }
}
-
+
public static class OrderedProperties {
HashMap<String, String> map = new HashMap<String, String>();
- ArrayList<String> keyList = new ArrayList<String>();
-
- public final void setProperty(String key, String value) {
+ ArrayList<String> keyList = new ArrayList<String>();
+
+ public final void setProperty(final String key, final String value) {
if(key.equals(SYS_PKG)) {
throw new IllegalArgumentException("Illegal property key, '"+SYS_PKG+"' is reserved");
}
@@ -157,36 +157,36 @@ public class LauncherUtil {
}
keyList.add(key); // new key
}
-
- public final void addAll(OrderedProperties props) {
- Iterator<String> argKeys = props.keyList.iterator();
+
+ public final void addAll(final OrderedProperties props) {
+ final Iterator<String> argKeys = props.keyList.iterator();
while(argKeys.hasNext()) {
final String key = argKeys.next();
setProperty(key, props.map.get(key));
- }
+ }
}
-
+
public final void setSystemProperties() {
- Iterator<String> argKeys = keyList.iterator();
+ final Iterator<String> argKeys = keyList.iterator();
while(argKeys.hasNext()) {
final String key = argKeys.next();
System.setProperty(key, map.get(key));
}
}
public final void clearSystemProperties() {
- Iterator<String> argKeys = keyList.iterator();
+ final Iterator<String> argKeys = keyList.iterator();
while(argKeys.hasNext()) {
System.clearProperty(argKeys.next());
}
}
-
- public final String getProperty(String key) { return map.get(key); }
+
+ public final String getProperty(final String key) { return map.get(key); }
public final Map<String, String> getProperties() { return map; }
-
+
/** Returns the list of property keys in the order, as they were added. */
- public final List<String> getPropertyKeys() { return keyList; }
+ public final List<String> getPropertyKeys() { return keyList; }
}
-
+
/**
* Data set to transfer from and to launch URI consisting out of:
* <ul>
@@ -205,56 +205,56 @@ public class LauncherUtil {
static final char ASSIG = '=';
static final String COLSLASH2 = "://";
static final String EMPTY = "";
-
+
String activityName = null;
ArrayList<String> sysPackages = new ArrayList<String>();
ArrayList<String> usrPackages = new ArrayList<String>();
OrderedProperties properties = new OrderedProperties();
ArrayList<String> arguments = new ArrayList<String>();
-
- public final void setActivityName(String name) { activityName = name; }
+
+ public final void setActivityName(final String name) { activityName = name; }
public final String getActivityName() { return activityName; }
-
- public final void addSysPackage(String p) {
- sysPackages.add(p);
- }
- public final void addAllSysPackages(List<String> plist) {
+
+ public final void addSysPackage(final String p) {
+ sysPackages.add(p);
+ }
+ public final void addAllSysPackages(final List<String> plist) {
sysPackages.addAll(plist);
- }
+ }
public final List<String> getSysPackages() { return sysPackages; }
-
- public final void addUsrPackage(String p) {
- usrPackages.add(p);
- }
- public final void addAllUsrPackages(List<String> plist) {
+
+ public final void addUsrPackage(final String p) {
+ usrPackages.add(p);
+ }
+ public final void addAllUsrPackages(final List<String> plist) {
usrPackages.addAll(plist);
- }
+ }
public final List<String> getUsrPackages() { return usrPackages; }
-
- public final void setProperty(String key, String value) {
+
+ public final void setProperty(final String key, final String value) {
properties.setProperty(key, value);
}
- public final void addAllProperties(OrderedProperties props) {
+ public final void addAllProperties(final OrderedProperties props) {
properties.addAll(props);
}
public final void setSystemProperties() {
properties.setSystemProperties();
- }
+ }
public final void clearSystemProperties() {
properties.clearSystemProperties();
- }
- public final String getProperty(String key) { return properties.getProperty(key); }
+ }
+ public final String getProperty(final String key) { return properties.getProperty(key); }
public final OrderedProperties getProperties() { return properties; }
public final List<String> getPropertyKeys() { return properties.getPropertyKeys(); }
-
- public final void addArgument(String arg) { arguments.add(arg); }
- public final void addAllArguments(List<String> args) {
+
+ public final void addArgument(final String arg) { arguments.add(arg); }
+ public final void addAllArguments(final List<String> args) {
arguments.addAll(args);
}
public final ArrayList<String> getArguments() { return arguments; }
-
+
public final Uri getUri() {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append(SCHEME).append(COLSLASH2).append(HOST).append(SLASH).append(getActivityName());
boolean needsQMark = true;
boolean needsSep = false;
@@ -284,7 +284,7 @@ public class LauncherUtil {
needsSep = true;
}
}
- Iterator<String> propKeys = properties.keyList.iterator();
+ final Iterator<String> propKeys = properties.keyList.iterator();
while(propKeys.hasNext()) {
if( needsQMark ) {
sb.append(QMARK);
@@ -297,7 +297,7 @@ public class LauncherUtil {
sb.append(key).append(ASSIG).append(properties.map.get(key));
needsSep = true;
}
- Iterator<String> args = arguments.iterator();
+ final Iterator<String> args = arguments.iterator();
while(args.hasNext()) {
if( needsQMark ) {
sb.append(QMARK);
@@ -308,18 +308,18 @@ public class LauncherUtil {
}
sb.append(ARG).append(ASSIG).append(args.next());
needsSep = true;
- }
+ }
return Uri.parse(sb.toString());
}
-
- public static final DataSet create(Uri uri) {
+
+ public static final DataSet create(final Uri uri) {
if(!uri.getScheme().equals(SCHEME)) {
return null;
}
if(!uri.getHost().equals(HOST)) {
return null;
}
- DataSet data = new DataSet();
+ final DataSet data = new DataSet();
{
String an = uri.getPath();
if(SLASH == an.charAt(0)) {
@@ -330,16 +330,16 @@ public class LauncherUtil {
}
data.setActivityName(an);
}
-
+
final String q = uri.getQuery();
final int q_l = null != q ? q.length() : -1;
int q_e = -1;
while(q_e < q_l) {
- int q_b = q_e + 1; // next term
+ final int q_b = q_e + 1; // next term
q_e = q.indexOf(AMPER, q_b);
if(0 == q_e) {
// single separator
- continue;
+ continue;
}
if(0 > q_e) {
// end
@@ -381,41 +381,41 @@ public class LauncherUtil {
data.validate();
return data;
}
-
+
public final void validate() {
if(null == activityName) {
throw new RuntimeException("Activity is not NULL");
}
}
}
-
- public final static Intent getIntent(String action, DataSet data) {
+
+ public final static Intent getIntent(final String action, final DataSet data) {
data.validate();
return new Intent(action, data.getUri());
}
-
+
public static void main(String[] args) {
if(args.length==0) {
args = new String[] {
- SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+SYS_PKG+"=jogamp.pack1&"+SYS_PKG+"=javax.pack2&"+USR_PKG+"=com.jogamp.pack3&"+USR_PKG+"=com.jogamp.pack4&jogamp.common.debug=true&com.jogamp.test=false",
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+SYS_PKG+"=jogamp.pack1&"+SYS_PKG+"=javax.pack2&"+USR_PKG+"=com.jogamp.pack3&"+USR_PKG+"=com.jogamp.pack4&jogamp.common.debug=true&com.jogamp.test=false",
SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+SYS_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false",
SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false",
SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+USR_PKG+"=com.jogamp.pack2",
- SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+USR_PKG+"=javax.pack2&"+USR_PKG+"=com.jogamp.pack3&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3",
- SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3",
- SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3"
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+USR_PKG+"=javax.pack2&"+USR_PKG+"=com.jogamp.pack3&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3",
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3",
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3"
};
}
int errors = 0;
for(int i=0; i<args.length; i++) {
- String uri_s = args[i];
- Uri uri0 = Uri.parse(uri_s);
- DataSet data = DataSet.create(uri0);
+ final String uri_s = args[i];
+ final Uri uri0 = Uri.parse(uri_s);
+ final DataSet data = DataSet.create(uri0);
if(null == data) {
errors++;
System.err.println("Error: NULL JogAmpLauncherUtil: <"+uri_s+"> -> "+uri0+" -> NULL");
} else {
- Uri uri1 = data.getUri();
+ final Uri uri1 = data.getUri();
if(!uri0.equals(uri1)) {
errors++;
System.err.println("Error: Not equal: <"+uri_s+"> -> "+uri0+" -> "+uri1);
@@ -426,5 +426,5 @@ public class LauncherUtil {
}
System.err.println("LauncherUtil Self Test: Errors: "+errors);
}
-
+
}
diff --git a/src/java/jogamp/android/launcher/LauncherVersionActivity.java b/src/java/jogamp/android/launcher/LauncherVersionActivity.java
index de78f5d..d26981f 100644
--- a/src/java/jogamp/android/launcher/LauncherVersionActivity.java
+++ b/src/java/jogamp/android/launcher/LauncherVersionActivity.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -35,9 +35,9 @@ import android.util.Log;
public class LauncherVersionActivity extends Activity {
static final String TAG = "JogAmp-LauncherVersion";
TextView tv = null;
-
+
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(final Bundle savedInstanceState) {
Log.d(TAG, "onCreate - S");
super.onCreate(savedInstanceState);
tv = new TextView(this);
@@ -47,14 +47,14 @@ public class LauncherVersionActivity extends Activity {
setContentView(tv);
Log.d(TAG, "onCreate - X");
}
-
+
@Override
public void onStart() {
Log.d(TAG, "onStart - S");
super.onStart();
Log.d(TAG, "onStart - X");
}
-
+
@Override
public void onRestart() {
Log.d(TAG, "onRestart - S");
@@ -79,14 +79,14 @@ public class LauncherVersionActivity extends Activity {
@Override
public void onStop() {
Log.d(TAG, "onStop - S");
- super.onStop();
+ super.onStop();
Log.d(TAG, "onStop - X");
}
@Override
public void onDestroy() {
Log.d(TAG, "onDestroy - S");
- super.onDestroy();
+ super.onDestroy();
Log.d(TAG, "onDestroy - X");
- }
+ }
}
diff --git a/src/java/jogamp/android/launcher/MainLauncher.java b/src/java/jogamp/android/launcher/MainLauncher.java
index f37fa57..0dc6b4a 100644
--- a/src/java/jogamp/android/launcher/MainLauncher.java
+++ b/src/java/jogamp/android/launcher/MainLauncher.java
@@ -3,14 +3,14 @@
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
@@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
@@ -40,72 +40,72 @@ import android.util.Log;
public class MainLauncher extends Activity {
static final String TAG = "JogAmp-MainLauncher";
-
+
// private static final String[] frameworkAPKs = { "/system/framework/core-junit.jar", "/data/projects/gluegen/make/lib/ant-junit-all.apk" };
// private static final String[] frameworkAPKs = { "/data/projects/gluegen/make/lib/ant-junit-all.apk" };
private static final String[] frameworkAPKs = { "/sdcard/ant-junit-all.apk" };
-
+
LauncherUtil.DataSet data = null;
-
+
Class<?> mainClazz = null;
Method mainClazzMain = null;
-
+
Class<?> staticContextClazz = null;
Method mStaticContextInit = null;
Method mStaticContextClear = null;
String[] mainClassArgs = null;
-
+
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(final Bundle savedInstanceState) {
Log.d(TAG, "onCreate - S");
super.onCreate(savedInstanceState);
-
+
final Uri uri = getIntent().getData();
data = LauncherUtil.DataSet.create(uri);
data.setSystemProperties();
- ClassLoader cl = ClassLoaderUtil.createClassLoader(this, data.getSysPackages(), data.getUsrPackages(), Arrays.asList(frameworkAPKs));
+ final ClassLoader cl = ClassLoaderUtil.createClassLoader(this, data.getSysPackages(), data.getUsrPackages(), Arrays.asList(frameworkAPKs));
if(null != cl) {
try {
staticContextClazz = Class.forName("jogamp.common.os.android.StaticContext", true, cl);
mStaticContextInit = staticContextClazz.getMethod("init", android.content.Context.class, android.view.ViewGroup.class);
- mStaticContextClear = staticContextClazz.getMethod("clear");
-
+ mStaticContextClear = staticContextClazz.getMethod("clear");
+
mainClazz = Class.forName(data.getActivityName(), true, cl);
Log.d(TAG, "Main Clazz "+mainClazz);
mainClazzMain = mainClazz.getDeclaredMethod("main", new Class[] { String[].class });
Log.d(TAG, "Main Clazz Main "+mainClazzMain);
- } catch (Exception e) {
+ } catch (final Exception e) {
Log.d(TAG, "error: "+e, e);
throw new RuntimeException(e);
}
}
if( null == mStaticContextInit || null == mStaticContextClear || null == mainClazzMain ) {
- RuntimeException e = new RuntimeException("XXX - incomplete method set");
+ final RuntimeException e = new RuntimeException("XXX - incomplete method set");
Log.d(TAG, "error: "+e, e);
throw e;
}
-
+
final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getApplicationContext());
getWindow().setContentView(viewGroup);
-
+
callMethod(null, mStaticContextInit, getApplicationContext(), viewGroup);
-
- List<String> args = data.getArguments();
+
+ final List<String> args = data.getArguments();
mainClassArgs=new String[args.size()];
- args.toArray(mainClassArgs);
-
+ args.toArray(mainClassArgs);
+
Log.d(TAG, "onCreate - X");
}
-
+
@Override
public void onStart() {
Log.d(TAG, "onStart - S");
super.onStart();
Log.d(TAG, "onStart - X");
}
-
+
@Override
public void onRestart() {
Log.d(TAG, "onRestart - S");
@@ -122,9 +122,9 @@ public class MainLauncher extends Activity {
try {
Log.d(TAG, "onResume - main.0 - "+Thread.currentThread().getName());
mainClazzMain.invoke(null, new Object[] { mainClassArgs } );
- } catch (InvocationTargetException ite) {
+ } catch (final InvocationTargetException ite) {
ite.getTargetException().printStackTrace();
- } catch (Throwable t) {
+ } catch (final Throwable t) {
t.printStackTrace();
}
Log.d(TAG, "onResume - main.X -> finish() - "+Thread.currentThread().getName());
@@ -144,7 +144,7 @@ public class MainLauncher extends Activity {
@Override
public void onStop() {
Log.d(TAG, "onStop - S");
- super.onStop();
+ super.onStop();
Log.d(TAG, "onStop - X");
}
@@ -156,32 +156,32 @@ public class MainLauncher extends Activity {
data = null;
}
callMethod(null, mStaticContextClear);
- super.onDestroy();
+ super.onDestroy();
Log.d(TAG, "onDestroy - X");
- }
+ }
@Override
public void finish() {
Log.d(TAG, "finish - S");
- super.finish();
+ super.finish();
Log.d(TAG, "finish - X");
- }
+ }
/**
* @throws JogampRuntimeException if the instance can not be created.
*/
- public static final Object createInstance(Class<?> clazz, Class<?>[] cstrArgTypes, Object ... cstrArgs)
+ public static final Object createInstance(final Class<?> clazz, final Class<?>[] cstrArgTypes, final Object ... cstrArgs)
throws RuntimeException
{
return createInstance(getConstructor(clazz, cstrArgTypes), cstrArgs);
}
- public static final Object createInstance(Constructor<?> cstr, Object ... cstrArgs)
+ public static final Object createInstance(final Constructor<?> cstr, final Object ... cstrArgs)
throws RuntimeException
{
try {
return cstr.newInstance(cstrArgs);
- } catch (Exception e) {
+ } catch (final Exception e) {
Throwable t = e;
if (t instanceof InvocationTargetException) {
t = ((InvocationTargetException) t).getTargetException();
@@ -195,26 +195,26 @@ public class MainLauncher extends Activity {
throw new RuntimeException("can not create instance of "+cstr.getName(), t);
}
}
-
+
/**
* @throws JogampRuntimeException if the constructor can not be delivered.
*/
- protected static final Constructor<?> getConstructor(Class<?> clazz, Class<?> ... cstrArgTypes)
+ protected static final Constructor<?> getConstructor(final Class<?> clazz, Class<?> ... cstrArgTypes)
throws RuntimeException {
try {
if(null == cstrArgTypes) {
cstrArgTypes = zeroTypes;
}
return clazz.getDeclaredConstructor(cstrArgTypes);
- } catch (NoSuchMethodException ex) {
+ } catch (final NoSuchMethodException ex) {
throw new RuntimeException("Constructor: '" + clazz + "(" + asString(cstrArgTypes) + ")' not found", ex);
}
}
-
+
protected static final Class<?>[] zeroTypes = new Class[0];
- protected static final String asString(Class<?>[] argTypes) {
- StringBuilder args = new StringBuilder();
+ protected static final String asString(final Class<?>[] argTypes) {
+ final StringBuilder args = new StringBuilder();
boolean coma = false;
if(null != argTypes) {
for (int i = 0; i < argTypes.length; i++) {
@@ -227,13 +227,13 @@ public class MainLauncher extends Activity {
}
return args.toString();
}
-
- protected static final Object callMethod(Object instance, Method method, Object ... args)
+
+ protected static final Object callMethod(final Object instance, final Method method, final Object ... args)
throws RuntimeException
{
try {
return method.invoke(instance, args);
- } catch (Exception e) {
+ } catch (final Exception e) {
Throwable t = e;
if (t instanceof InvocationTargetException) {
t = ((InvocationTargetException) t).getTargetException();
diff --git a/src/java/jogamp/android/launcher/TraceDexClassLoader.java b/src/java/jogamp/android/launcher/TraceDexClassLoader.java
index 0b00489..452120a 100644
--- a/src/java/jogamp/android/launcher/TraceDexClassLoader.java
+++ b/src/java/jogamp/android/launcher/TraceDexClassLoader.java
@@ -8,16 +8,16 @@ import dalvik.system.DexClassLoader;
public class TraceDexClassLoader extends DexClassLoader {
private static final boolean DEBUG = false;
-
- public TraceDexClassLoader(String dexPath, String dexOutputDir, String libPath, ClassLoader parent) {
+
+ public TraceDexClassLoader(final String dexPath, final String dexOutputDir, final String libPath, final ClassLoader parent) {
super(dexPath, dexOutputDir, libPath, parent);
if(DEBUG) {
Log.d(TraceDexClassLoader.class.getSimpleName(), "ctor: dexPath " + dexPath + ", dexOutputDir " + dexOutputDir + ", libPath " + libPath + ", parent " + parent);
}
}
-
+
@Override
- public URL findResource(String name) {
+ public URL findResource(final String name) {
final URL url = super.findResource(name);
if(DEBUG) {
Log.d(TraceDexClassLoader.class.getSimpleName(), "findResource: " + name + " -> " + url);