summaryrefslogtreecommitdiffstats
path: root/services/core/java
diff options
context:
space:
mode:
authorJeff Hao <jeffhao@google.com>2014-10-10 11:35:01 -0700
committerJeff Hao <jeffhao@google.com>2014-10-13 10:27:29 -0700
commit1d892dcb6b0ff3a50cc63e387667dc29baf1014f (patch)
treef328e8544717a1385f713df52b4180f4f0edb9a2 /services/core/java
parent2bb933a5129cccb29e31fe2db00109bab6805979 (diff)
downloadframeworks_base-1d892dcb6b0ff3a50cc63e387667dc29baf1014f.zip
frameworks_base-1d892dcb6b0ff3a50cc63e387667dc29baf1014f.tar.gz
frameworks_base-1d892dcb6b0ff3a50cc63e387667dc29baf1014f.tar.bz2
Stop boot dexopt when low on memory.
Bug: 17641843 Change-Id: Ie1967fc2cd9bdd258bfee442968f98200edaf62e
Diffstat (limited to 'services/core/java')
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 1059f0b..b79e157 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4538,14 +4538,24 @@ public class PackageManagerService extends IPackageManager.Stub {
filterRecentlyUsedApps(pkgs);
// Add all remaining apps.
for (PackageParser.Package pkg : pkgs) {
+ if (DEBUG_DEXOPT) {
+ Log.i(TAG, "Adding app " + sortedPkgs.size() + ": " + pkg.packageName);
+ }
sortedPkgs.add(pkg);
}
int i = 0;
int total = sortedPkgs.size();
+ File dataDir = Environment.getDataDirectory();
+ long lowThreshold = StorageManager.from(mContext).getStorageLowBytes(dataDir);
+ if (lowThreshold == 0) {
+ throw new IllegalStateException("Invalid low memory threshold");
+ }
for (PackageParser.Package pkg : sortedPkgs) {
- if (DEBUG_DEXOPT) {
- Log.i(TAG, "Adding app " + sortedPkgs.size() + ": " + pkg.packageName);
+ long usableSpace = dataDir.getUsableSpace();
+ if (usableSpace < lowThreshold) {
+ Log.w(TAG, "Not running dexopt on remaining apps due to low memory: " + usableSpace);
+ break;
}
performBootDexOpt(pkg, ++i, total);
}