diff options
author | Kenny Root <kroot@google.com> | 2011-03-15 14:01:39 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-03-15 14:01:39 -0700 |
commit | 7ddd62b5bedf9065bba00e25aa62f2eae14cf92e (patch) | |
tree | 2da0c26a975ba4dd22f1ad14621d3dbfdbcfdfc3 /packages | |
parent | 4528a7db389b4da73207d00ca15b306a111650cc (diff) | |
parent | 1aa73a1bbadbc3ffb0c04bf5c0dc78a0fb7e32b9 (diff) | |
download | frameworks_base-7ddd62b5bedf9065bba00e25aa62f2eae14cf92e.zip frameworks_base-7ddd62b5bedf9065bba00e25aa62f2eae14cf92e.tar.gz frameworks_base-7ddd62b5bedf9065bba00e25aa62f2eae14cf92e.tar.bz2 |
Merge "Add byte limit in addition to ratio for installs DO NOT MERGE" into honeycomb-mr1
Diffstat (limited to 'packages')
-rw-r--r-- | packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java index 21f77e3..337593f 100644 --- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java +++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java @@ -390,6 +390,9 @@ public class DefaultContainerService extends IntentService { // No-installation limit for internal flash: 10% or less space available private static final double LOW_NAND_FLASH_TRESHOLD = 0.1; + // No-installation limit for internal flash: 150MB or less space available + private static final long NAND_MIN_FREE_SPACE = (1024L * 1024L * 150L); + // SD-to-internal app size threshold: currently set to 1 MB private static final long INSTALL_ON_SD_THRESHOLD = (1024 * 1024); private static final int ERR_LOC = -1; @@ -451,7 +454,8 @@ public class DefaultContainerService extends IntentService { String status = Environment.getExternalStorageState(); long availSDSize = -1; boolean mediaAvailable = false; - if (!Environment.isExternalStorageEmulated() && status.equals(Environment.MEDIA_MOUNTED)) { + final boolean mediaEmulated = Environment.isExternalStorageEmulated(); + if (!mediaEmulated && status.equals(Environment.MEDIA_MOUNTED)) { StatFs sdStats = new StatFs( Environment.getExternalStorageDirectory().getPath()); availSDSize = (long)sdStats.getAvailableBlocks() * @@ -474,7 +478,7 @@ public class DefaultContainerService extends IntentService { // For dex files. Just ignore and fail when extracting. Max limit of 2Gig for now. long reqInternalSize = 0; boolean intThresholdOk = (pctNandFree >= LOW_NAND_FLASH_TRESHOLD); - boolean intAvailOk = ((reqInstallSize + reqInternalSize) < availInternalSize); + boolean intAvailOk = (reqInstallSize + reqInternalSize) < (availInternalSize - NAND_MIN_FREE_SPACE); boolean fitsOnSd = false; if (mediaAvailable && (reqInstallSize < availSDSize)) { // If we do not have an internal size requirement @@ -485,7 +489,7 @@ public class DefaultContainerService extends IntentService { fitsOnSd = true; } } - boolean fitsOnInt = intThresholdOk && intAvailOk; + boolean fitsOnInt = intThresholdOk || intAvailOk; if (checkInt) { // Check for internal memory availability if (fitsOnInt) { @@ -506,7 +510,7 @@ public class DefaultContainerService extends IntentService { return PackageHelper.RECOMMEND_INSTALL_EXTERNAL; } } - if ((checkExt || checkBoth) && !mediaAvailable) { + if (!mediaEmulated && (checkExt || checkBoth) && !mediaAvailable) { return PackageHelper.RECOMMEND_MEDIA_UNAVAILABLE; } return PackageHelper.RECOMMEND_FAILED_INSUFFICIENT_STORAGE; |