Improve handling of low memory.
Now classify background processes into a set of bins of how much
memory they should try to clear. The last bin also involves
destroying all activities in that process.
Removed the old code for the simulator that is no longer needed
(yay). The debugging features it had are now integrated into the
regular oom adj code.
Small fixes to load average service.
Change-Id: Ic8df401714b188c73b50dbc8f8e6345b58f1f3a0
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index ee04729..8994b17 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -932,6 +932,10 @@
ucd.info = info;
queueOrSendMessage(H.UPDATE_PACKAGE_COMPATIBILITY_INFO, ucd);
}
+
+ public void scheduleTrimMemory(int level) {
+ queueOrSendMessage(H.TRIM_MEMORY, level);
+ }
}
private final class H extends Handler {
@@ -975,6 +979,7 @@
public static final int SLEEPING = 137;
public static final int SET_CORE_SETTINGS = 138;
public static final int UPDATE_PACKAGE_COMPATIBILITY_INFO = 139;
+ public static final int TRIM_MEMORY = 140;
String codeToString(int code) {
if (DEBUG_MESSAGES) {
switch (code) {
@@ -1018,6 +1023,7 @@
case SLEEPING: return "SLEEPING";
case SET_CORE_SETTINGS: return "SET_CORE_SETTINGS";
case UPDATE_PACKAGE_COMPATIBILITY_INFO: return "UPDATE_PACKAGE_COMPATIBILITY_INFO";
+ case TRIM_MEMORY: return "TRIM_MEMORY";
}
}
return "(unknown)";
@@ -1158,6 +1164,8 @@
break;
case UPDATE_PACKAGE_COMPATIBILITY_INFO:
handleUpdatePackageCompatibilityInfo((UpdateCompatibilityData)msg.obj);
+ case TRIM_MEMORY:
+ handleTrimMemory(msg.arg1);
}
if (DEBUG_MESSAGES) Slog.v(TAG, "<<< done: " + msg.what);
}
@@ -3529,6 +3537,9 @@
BinderInternal.forceGc("mem");
}
+ final void handleTrimMemory(int level) {
+ }
+
private final void handleBindApplication(AppBindData data) {
mBoundApplication = data;
mConfiguration = new Configuration(data.config);