summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSuchi Amalapurapu <asuchitra@google.com>2010-03-05 17:40:11 -0800
committerSuchi Amalapurapu <asuchitra@google.com>2010-03-09 09:24:35 -0800
commita2b6c3775ed6b8924232d6a01bae4a19740a15f8 (patch)
treef78953add86351bd04f2788c712b1285497e2016 /tests
parenta9fb0a2497e563c2066e10a816ff1f7baaf8aa9b (diff)
downloadframeworks_base-a2b6c3775ed6b8924232d6a01bae4a19740a15f8.zip
frameworks_base-a2b6c3775ed6b8924232d6a01bae4a19740a15f8.tar.gz
frameworks_base-a2b6c3775ed6b8924232d6a01bae4a19740a15f8.tar.bz2
Add conditions to check for updated system applications. Restrict them
to internal flash only even before we copy. Return error codes when install flag options mismatch. Some conditions for existings apps - install flags override existing location - explicity manifest option install location overrides previous location - if upgraded package's install location is unspecified or auto, fall back to recommended install policy which considers user setting as well. Check for sdcard status before finding available size on sdcard Add light weight parsing for manifest attributes including package name and install location only Change-Id: I5143dda87c88c595f564b317326c926d0ec3ceb8
Diffstat (limited to 'tests')
-rwxr-xr-xtests/AndroidTests/src/com/android/unit_tests/PackageManagerTests.java77
1 files changed, 76 insertions, 1 deletions
diff --git a/tests/AndroidTests/src/com/android/unit_tests/PackageManagerTests.java b/tests/AndroidTests/src/com/android/unit_tests/PackageManagerTests.java
index 50eca02..0b69020 100755
--- a/tests/AndroidTests/src/com/android/unit_tests/PackageManagerTests.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/PackageManagerTests.java
@@ -932,11 +932,86 @@ public class PackageManagerTests extends AndroidTestCase {
0, true, false, -1, PackageInfo.INSTALL_LOCATION_AUTO);
}
+ public void testManifestInstallLocationFwdLockedFlagSdcard() {
+ installFromRawResource("install.apk", R.raw.install_loc_unspecified,
+ PackageManager.INSTALL_FORWARD_LOCK |
+ PackageManager.INSTALL_EXTERNAL, true, true,
+ PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION,
+ PackageInfo.INSTALL_LOCATION_AUTO);
+ }
+
public void testManifestInstallLocationFwdLockedSdcard() {
installFromRawResource("install.apk", R.raw.install_loc_sdcard,
PackageManager.INSTALL_FORWARD_LOCK, true, false,
-1,
- PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
+ PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+ }
+
+ private void replaceManifestLocation(int iFlags, int rFlags) {
+ InstallParams ip = sampleInstallFromRawResource(iFlags, false);
+ GenericReceiver receiver = new ReplaceReceiver(ip.pkg.packageName);
+ int replaceFlags = rFlags | PackageManager.INSTALL_REPLACE_EXISTING;
+ try {
+ assertEquals(invokeInstallPackage(ip.packageURI, replaceFlags,
+ ip.pkg.packageName, receiver), true);
+ assertInstall(ip.pkg, replaceFlags, ip.pkg.installLocation);
+ } catch (Exception e) {
+ failStr("Failed with exception : " + e);
+ } finally {
+ cleanUpInstall(ip);
+ }
+ }
+
+ public void testReplaceFlagInternalSdcard() {
+ replaceManifestLocation(0, PackageManager.INSTALL_EXTERNAL);
+ }
+
+ public void testReplaceFlagSdcardInternal() {
+ replaceManifestLocation(PackageManager.INSTALL_EXTERNAL, 0);
+ }
+
+ public void testManifestInstallLocationReplaceInternalSdcard() {
+ int iFlags = 0;
+ int iApk = R.raw.install_loc_unspecified;
+ int rFlags = 0;
+ int rApk = R.raw.install_loc_sdcard;
+ InstallParams ip = installFromRawResource("install.apk", iApk,
+ iFlags, false,
+ false, -1, PackageInfo.INSTALL_LOCATION_AUTO);
+ GenericReceiver receiver = new ReplaceReceiver(ip.pkg.packageName);
+ int replaceFlags = rFlags | PackageManager.INSTALL_REPLACE_EXISTING;
+ try {
+ InstallParams rp = installFromRawResource("install.apk", rApk,
+ rFlags, false,
+ false, -1, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+ assertInstall(rp.pkg, replaceFlags, rp.pkg.installLocation);
+ } catch (Exception e) {
+ failStr("Failed with exception : " + e);
+ } finally {
+ cleanUpInstall(ip);
+ }
+ }
+
+ public void testManifestInstallLocationReplaceSdcardInternal() {
+ int iFlags = 0;
+ int iApk = R.raw.install_loc_sdcard;
+ int rFlags = 0;
+ int rApk = R.raw.install_loc_unspecified;
+ InstallParams ip = installFromRawResource("install.apk", iApk,
+ iFlags, false,
+ false, -1, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+ GenericReceiver receiver = new ReplaceReceiver(ip.pkg.packageName);
+ int replaceFlags = rFlags | PackageManager.INSTALL_REPLACE_EXISTING;
+ try {
+ InstallParams rp = installFromRawResource("install.apk", rApk,
+ rFlags, false,
+ false, -1, PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
+ assertInstall(rp.pkg, replaceFlags, ip.pkg.installLocation);
+ } catch (Exception e) {
+ failStr("Failed with exception : " + e);
+ } finally {
+ cleanUpInstall(ip);
+ }
}
public void xxxtestClearAllSecureContainers() {