diff options
author | Suchi Amalapurapu <asuchitra@google.com> | 2010-05-13 12:05:53 -0700 |
---|---|---|
committer | Suchi Amalapurapu <asuchitra@google.com> | 2010-05-13 15:48:39 -0700 |
commit | 1ace5bc070b7271a3f5835b13e326875785f718c (patch) | |
tree | 8eece8ed8afee9b9c789a5d1c9a642ba838827f6 /core | |
parent | 3c78a1b58957e31d2991fb6a609abecbb1987b3b (diff) | |
download | frameworks_base-1ace5bc070b7271a3f5835b13e326875785f718c.zip frameworks_base-1ace5bc070b7271a3f5835b13e326875785f718c.tar.gz frameworks_base-1ace5bc070b7271a3f5835b13e326875785f718c.tar.bz2 |
Fix 2672155
Check the code path when enabling disabling packages.
Add unit test
Change-Id: I0f0f482a3735234eab3f63ba1f6462574b70144e
Diffstat (limited to 'core')
-rwxr-xr-x | core/tests/coretests/src/android/content/pm/PackageManagerTests.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java index 82834b6..5571341 100755 --- a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java +++ b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java @@ -2346,6 +2346,49 @@ public class PackageManagerTests extends AndroidTestCase { } } + + /* This test installs an application on sdcard and unmounts media. + * The app is then re-installed on internal storage. The sdcard is mounted + * and verified that the re-installation on internal storage takes precedence. + */ + @MediumTest + public void testInstallSdcardStaleContainerReinstall() { + boolean origMediaState = getMediaState(); + try { + // Mount media first + mountMedia(); + String outFileName = "install.apk"; + int rawResId = R.raw.install; + PackageManager pm = mContext.getPackageManager(); + File filesDir = mContext.getFilesDir(); + File outFile = new File(filesDir, outFileName); + Uri packageURI = getInstallablePackage(rawResId, outFile); + PackageParser.Package pkg = parsePackage(packageURI); + assertNotNull(pkg); + // Install an app on sdcard. + installFromRawResource(outFileName, rawResId, + PackageManager.INSTALL_EXTERNAL, false, + false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED); + // Unmount sdcard + unmountMedia(); + // Reinstall the app and make sure it gets installed on internal storage. + installFromRawResource(outFileName, rawResId, + PackageManager.INSTALL_REPLACE_EXISTING, false, + false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED); + mountMedia(); + // Verify that the app installed is on internal storage. + assertInstall(pkg, 0, PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY); + } catch (Exception e) { + failStr(e.getMessage()); + } finally { + if (origMediaState) { + mountMedia(); + } else { + unmountMedia(); + } + + } + } /* * The following series of tests are related to upgrading apps with * different certificates. |