diff options
| author | Kenny Root <kroot@google.com> | 2010-10-07 16:46:10 -0700 |
|---|---|---|
| committer | Kenny Root <kroot@google.com> | 2010-10-07 17:20:26 -0700 |
| commit | 6a6b007c77e5cab7ee435506a4f65824f52028b6 (patch) | |
| tree | 09daacd02a3582c26d72411e5ef0129812d0c8d6 /core/tests | |
| parent | b74941e32e068ec03f90b9a53670328cd17ff4b4 (diff) | |
| download | frameworks_base-6a6b007c77e5cab7ee435506a4f65824f52028b6.zip frameworks_base-6a6b007c77e5cab7ee435506a4f65824f52028b6.tar.gz frameworks_base-6a6b007c77e5cab7ee435506a4f65824f52028b6.tar.bz2 | |
Symlink application lib directory when on SD card
This will help legacy games that use dlopen() to directly access the
/data/data/<app>/lib directory before the
ApplicationInfo.nativeLibraryDir was part of the API.
Change-Id: Ie9f3e7239b6334708b5d086ffafe66a507f6d9da
Diffstat (limited to 'core/tests')
| -rwxr-xr-x | core/tests/coretests/src/android/content/pm/PackageManagerTests.java | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java index 276e281..d5f385b 100755 --- a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java +++ b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java @@ -45,6 +45,7 @@ import android.util.DisplayMetrics; import android.util.Log; import java.io.File; +import java.io.IOException; import java.io.InputStream; public class PackageManagerTests extends AndroidTestCase { @@ -378,6 +379,18 @@ public class PackageManagerTests extends AndroidTestCase { assertEquals(publicSrcPath, appInstallPath); assertFalse((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0); assertTrue(info.nativeLibraryDir.startsWith(dataDir.getPath())); + + // Make sure the native library dir is not a symlink + final File nativeLibDir = new File(info.nativeLibraryDir); + assertTrue("Native library dir should exist at " + info.nativeLibraryDir, + nativeLibDir.exists()); + try { + assertEquals("Native library dir should not be a symlink", + info.nativeLibraryDir, + nativeLibDir.getCanonicalPath()); + } catch (IOException e) { + fail("Can't read " + nativeLibDir.getPath()); + } } else if (rLoc == INSTALL_LOC_SD){ assertTrue("Application flags (" + info.flags + ") should contain FLAG_EXTERNAL_STORAGE", @@ -391,6 +404,19 @@ public class PackageManagerTests extends AndroidTestCase { assertTrue("The native library path (" + info.nativeLibraryDir + ") should start with " + SECURE_CONTAINERS_PREFIX, info.nativeLibraryDir.startsWith(SECURE_CONTAINERS_PREFIX)); + + // Make sure the native library in /data/data/<app>/lib is a + // symlink to the ASEC + final File nativeLibSymLink = new File(info.dataDir, "lib"); + assertTrue("Native library symlink should exist at " + nativeLibSymLink.getPath(), + nativeLibSymLink.exists()); + try { + assertEquals(nativeLibSymLink.getPath() + " should be a symlink to " + + info.nativeLibraryDir, info.nativeLibraryDir, nativeLibSymLink + .getCanonicalPath()); + } catch (IOException e) { + fail("Can't read " + nativeLibSymLink.getPath()); + } } else { // TODO handle error. Install should have failed. fail("Install should have failed"); @@ -1406,13 +1432,21 @@ public class PackageManagerTests extends AndroidTestCase { receiver); assertTrue(retCode); ApplicationInfo info = getPm().getApplicationInfo(ip.pkg.packageName, 0); - assertNotNull(info); + assertNotNull("ApplicationInfo for recently installed application should exist", + info); if ((moveFlags & PackageManager.MOVE_INTERNAL) != 0) { - assertTrue((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0); - assertTrue(info.nativeLibraryDir.startsWith(info.dataDir)); + assertTrue("ApplicationInfo.FLAG_EXTERNAL_STORAGE flag should NOT be set", + (info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0); + assertTrue("ApplicationInfo.nativeLibraryDir should start with " + info.dataDir, + info.nativeLibraryDir.startsWith(info.dataDir)); } else if ((moveFlags & PackageManager.MOVE_EXTERNAL_MEDIA) != 0){ - assertTrue((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0); - assertTrue(info.nativeLibraryDir.startsWith(SECURE_CONTAINERS_PREFIX)); + assertTrue("ApplicationInfo.FLAG_EXTERNAL_STORAGE flag should be set", + (info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0); + assertTrue("ApplicationInfo.nativeLibraryDir should start with " + SECURE_CONTAINERS_PREFIX, + info.nativeLibraryDir.startsWith(SECURE_CONTAINERS_PREFIX)); + final File nativeLibSymLink = new File(info.dataDir, "lib"); + assertTrue("The data directory should have a 'lib' symlink that points to the ASEC container", + nativeLibSymLink.getCanonicalPath().startsWith(SECURE_CONTAINERS_PREFIX)); } } } catch (NameNotFoundException e) { |
