aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/jogamp/android/launcher
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-12-27 05:50:21 +0100
committerSven Gothel <[email protected]>2012-12-27 05:50:21 +0100
commit5bd9880b54a48326742008d36175b1403c891ee1 (patch)
tree8b148e22257ac13e9ee6bf8885bda819e01c268b /src/java/jogamp/android/launcher
parentd430657cfd1f21885f3fdebebe6f0a49b1c5cd13 (diff)
Android Launcher: Fix ClassLoaderUtil's JNI lib-path determination, use ApplicationInfo's nativeLibraryDir (API level 9).
On Android > 4.0.3 (maybe even earlier), w/ a split filesystem (internal and SDCARD) the JNI libs maybe stored at a different location than it's data path. ApplicationInfo's nativeLibraryDir properly determines the JNI storage location, hence use it. Prev. code also derived JNI lib path by the launcher's ApplicationInfo's nativeLibraryDir, which might be different than the user package's nativeLibraryDir. This is especially true, since the launcher may not hold any native libraries.
Diffstat (limited to 'src/java/jogamp/android/launcher')
-rw-r--r--src/java/jogamp/android/launcher/ClassLoaderUtil.java28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/java/jogamp/android/launcher/ClassLoaderUtil.java b/src/java/jogamp/android/launcher/ClassLoaderUtil.java
index 2913281..ae2918f 100644
--- a/src/java/jogamp/android/launcher/ClassLoaderUtil.java
+++ b/src/java/jogamp/android/launcher/ClassLoaderUtil.java
@@ -96,23 +96,29 @@ public class ClassLoaderUtil {
private static synchronized ClassLoader createClassLoaderImpl(Context ctx, List<String> userPackageNames, boolean addUserLibPath,
List<String> apkNames, ClassLoader parent) {
+ final ApplicationInfo appInfoLauncher= ctx.getApplicationInfo();
+ final String appDirLauncher = new File(appInfoLauncher.dataDir).getParent();
+ final String libSubDef = "lib";
+ Log.d(TAG, "S: userPackageNames: "+userPackageNames+"; Launcher: appDir "+appDirLauncher+", dataDir: "+appInfoLauncher.dataDir+", nativeLibraryDir "+appInfoLauncher.nativeLibraryDir);
- final ApplicationInfo appInfo = ctx.getApplicationInfo();
- final String appDir = new File(appInfo.dataDir).getParent();
- final String libSub = appInfo.nativeLibraryDir.substring(appInfo.nativeLibraryDir.lastIndexOf('/')+1);
- Log.d(TAG, "S: userPackageName: "+userPackageNames+"; appName "+appInfo.name+", appDir "+appDir+", nativeLibraryDir: "+appInfo.nativeLibraryDir+"; dataDir: "+appInfo.dataDir+", libSub "+libSub);
-
- StringBuilder apks = new StringBuilder();
- StringBuilder libs = new StringBuilder();
+ 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 != userPackageNames ) {
for(Iterator<String> i=userPackageNames.iterator(); i.hasNext(); ) {
lastUserPackageName = i.next();
+
String userAPK = null;
+ String nativeLibraryDir=null;
try {
- userAPK = ctx.getPackageManager().getApplicationInfo(lastUserPackageName,0).sourceDir;
+ final PackageManager pm = ctx.getPackageManager();
+ final ApplicationInfo appInfo = pm.getApplicationInfo(lastUserPackageName, 0);
+ 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) {
Log.d(TAG, "error: "+e, e);
}
@@ -127,7 +133,11 @@ public class ClassLoaderUtil {
Log.d(TAG, "APK["+apkCount+"] found: <"+lastUserPackageName+"> -> <"+userAPK+">");
Log.d(TAG, "APK["+apkCount+"] apks: <"+apks.toString()+">");
if(addUserLibPath) {
- libs.append(appDir).append(PATH_SEP).append(lastUserPackageName).append(PATH_SEP).append(libSub).append(PATH_SEP);
+ if(null != nativeLibraryDir && nativeLibraryDir.length()>0 ) {
+ libs.append(nativeLibraryDir).append(PATH_SEP);
+ } else {
+ libs.append(appDirLauncher).append(PATH_SEP).append(lastUserPackageName).append(PATH_SEP).append(libSubDef).append(PATH_SEP);
+ }
Log.d(TAG, "APK["+apkCount+"] libs: <"+libs.toString()+">");
}
apkCount++;