summaryrefslogtreecommitdiffstats
path: root/src/java/jogamp/android/launcher/ClassLoaderUtil.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-05-03 05:02:08 +0200
committerSven Gothel <[email protected]>2012-05-03 05:02:08 +0200
commit3a63e20ca981931ed42d27a7ce4c6b16c9198020 (patch)
tree17ac96b1d06d3b312684cb411bc00de2edaea9e5 /src/java/jogamp/android/launcher/ClassLoaderUtil.java
parent4ce601b38ca8418eddbe8cca4d531e6161fae26b (diff)
AndroidLauncher: Add 'MainLauncher'; ClassLoaderUtil adds list of direct APKs to add to classpath
MainLauncher is capable of launching a traditional static main method from a activity. TODO: - parametrize the APK list (junit, ..) - pass-through the activity instance to be used w/ NEWT AndroidWindow
Diffstat (limited to 'src/java/jogamp/android/launcher/ClassLoaderUtil.java')
-rw-r--r--src/java/jogamp/android/launcher/ClassLoaderUtil.java78
1 files changed, 49 insertions, 29 deletions
diff --git a/src/java/jogamp/android/launcher/ClassLoaderUtil.java b/src/java/jogamp/android/launcher/ClassLoaderUtil.java
index 85c0b94..4e044ea 100644
--- a/src/java/jogamp/android/launcher/ClassLoaderUtil.java
+++ b/src/java/jogamp/android/launcher/ClassLoaderUtil.java
@@ -69,21 +69,22 @@ public class ClassLoaderUtil {
}
}
- public static synchronized ClassLoader createClassLoader(Context ctx, List<String> userPackageNames, boolean addLibPath) {
- return createClassLoader(ctx, userPackageNames, addLibPath, null);
+ public static synchronized ClassLoader createClassLoader(Context ctx, List<String> userPackageNames, boolean addUserLibPath,
+ List<String> apkNames) {
+ return createClassLoader(ctx, userPackageNames, addUserLibPath, apkNames, null);
}
- public static synchronized ClassLoader createClassLoader(Context ctx, List<String> userPackageNames,
- boolean addLibPath, ClassLoader parent) {
+ public static synchronized ClassLoader createClassLoader(Context ctx, List<String> userPackageNames, boolean addUserLibPath,
+ List<String> apkNames, ClassLoader parent) {
init(ctx);
if(null==jogAmpClassLoader) {
- jogAmpClassLoader = createClassLoaderImpl(ctx, Arrays.asList(packagesJogAmp), true,
+ jogAmpClassLoader = createClassLoaderImpl(ctx, Arrays.asList(packagesJogAmp), true, null,
(null != parent ) ? parent : ctx.getClassLoader());
}
parent = jogAmpClassLoader;
- return createClassLoaderImpl(ctx, userPackageNames, addLibPath, jogAmpClassLoader);
+ return createClassLoaderImpl(ctx, userPackageNames, addUserLibPath, apkNames, jogAmpClassLoader);
}
/**
@@ -92,8 +93,8 @@ public class ClassLoaderUtil {
* @param userPackageNames list of user package names, the last entry shall reflect the Activity
* @return
*/
- private static synchronized ClassLoader createClassLoaderImpl(Context ctx, List<String> userPackageNames,
- boolean addLibPath, ClassLoader parent) {
+ private static synchronized ClassLoader createClassLoaderImpl(Context ctx, List<String> userPackageNames, boolean addUserLibPath,
+ List<String> apkNames, ClassLoader parent) {
final ApplicationInfo appInfo = ctx.getApplicationInfo();
@@ -106,34 +107,53 @@ public class ClassLoaderUtil {
int apkCount = 0;
String lastUserPackageName = null; // the very last one reflects the Activity
- for(Iterator<String> i=userPackageNames.iterator(); i.hasNext(); ) {
- lastUserPackageName = i.next();
- String userAPK = null;
- try {
- userAPK = ctx.getPackageManager().getApplicationInfo(lastUserPackageName,0).sourceDir;
- } catch (PackageManager.NameNotFoundException e) {
- Log.d(TAG, "error: "+e, e);
+ if( null != userPackageNames ) {
+ for(Iterator<String> i=userPackageNames.iterator(); i.hasNext(); ) {
+ lastUserPackageName = i.next();
+ String userAPK = null;
+ try {
+ userAPK = ctx.getPackageManager().getApplicationInfo(lastUserPackageName,0).sourceDir;
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.d(TAG, "error: "+e, e);
+ }
+ if(null != userAPK) {
+ if(apkCount>0) {
+ apks.append(ELEM_SEP);
+ if(addUserLibPath) {
+ libs.append(ELEM_SEP);
+ }
+ }
+ apks.append(userAPK);
+ if(addUserLibPath) {
+ libs.append(appDir).append(PATH_SEP).append(lastUserPackageName).append(PATH_SEP).append(libSub).append(PATH_SEP);
+ }
+ Log.d(TAG, "APK found: <"+lastUserPackageName+"> -> <"+userAPK+">");
+ apkCount++;
+ } else {
+ Log.d(TAG, "APK not found: <"+lastUserPackageName+">");
+ }
+ }
+ if( userPackageNames.size() != apkCount ) {
+ Log.d(TAG, "User APKs incomplete, abort (1)");
+ return null;
}
- if(null != userAPK) {
+ }
+ final int userAPKCount = apkCount;
+
+ if( null != apkNames ) {
+ for(Iterator<String> i=apkNames.iterator(); i.hasNext(); ) {
+ String userAPK = i.next();
if(apkCount>0) {
apks.append(ELEM_SEP);
- if(addLibPath) {
- libs.append(ELEM_SEP);
- }
}
apks.append(userAPK);
- if(addLibPath) {
- libs.append(appDir).append(PATH_SEP).append(lastUserPackageName).append(PATH_SEP).append(libSub).append(PATH_SEP);
- }
- Log.d(TAG, "APK found: <"+lastUserPackageName+"> -> <"+userAPK+">");
+ Log.d(TAG, "APK added: <"+userAPK+">");
apkCount++;
- } else {
- Log.d(TAG, "APK not found: <"+lastUserPackageName+">");
}
- }
- if( userPackageNames.size()!=apkCount ) {
- Log.d(TAG, "APKs incomplete, abort");
- return null;
+ if( apkNames.size() != apkCount - userAPKCount ) {
+ Log.d(TAG, "Framework APKs incomplete, abort (2)");
+ return null;
+ }
}
// return new TraceDexClassLoader(apks.toString(), dexPath.getAbsolutePath(), libs.toString(), parent);