Various work on out of memory managment.
- Improve how we handle processes that have shown UI, to take care
of more cases where we want to push them into the background LRU
list.
- New trim memory level for when an application that has done UI
is no longer visible to the user.
- Add APIs to get new trim memory callback.
- Add a host of new bind flags to tweak how the system will adjust
the OOM level of the target process.
Change-Id: I23ba354112f411a9f8773a67426b4dff85fa2439
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index fb1570e..d5b669e 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -19,7 +19,7 @@
import com.android.internal.app.ActionBarImpl;
import com.android.internal.policy.PolicyManager;
-import android.content.ComponentCallbacks;
+import android.content.ComponentCallbacks2;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -626,7 +626,7 @@
public class Activity extends ContextThemeWrapper
implements LayoutInflater.Factory2,
Window.Callback, KeyEvent.Callback,
- OnCreateContextMenuListener, ComponentCallbacks {
+ OnCreateContextMenuListener, ComponentCallbacks2 {
private static final String TAG = "Activity";
/** Standard activity result: operation canceled. */
@@ -859,6 +859,7 @@
? mLastNonConfigurationInstances.fragments : null);
}
mFragments.dispatchCreate();
+ getApplication().dispatchActivityCreated(this, savedInstanceState);
mCalled = true;
}
@@ -1001,6 +1002,8 @@
}
mCheckedForLoaderManager = true;
}
+
+ getApplication().dispatchActivityStarted(this);
}
/**
@@ -1048,6 +1051,7 @@
* @see #onPause
*/
protected void onResume() {
+ getApplication().dispatchActivityResumed(this);
mCalled = true;
}
@@ -1158,6 +1162,7 @@
if (p != null) {
outState.putParcelable(FRAGMENTS_TAG, p);
}
+ getApplication().dispatchActivitySaveInstanceState(this, outState);
}
/**
@@ -1234,6 +1239,7 @@
* @see #onStop
*/
protected void onPause() {
+ getApplication().dispatchActivityPaused(this);
mCalled = true;
}
@@ -1320,6 +1326,7 @@
*/
protected void onStop() {
if (mActionBar != null) mActionBar.setShowHideAnimationEnabled(false);
+ getApplication().dispatchActivityStopped(this);
mCalled = true;
}
@@ -1382,6 +1389,8 @@
if (mSearchManager != null) {
mSearchManager.stopSearch();
}
+
+ getApplication().dispatchActivityDestroyed(this);
}
/**
@@ -1580,12 +1589,17 @@
nci.loaders = mAllLoaderManagers;
return nci;
}
-
+
public void onLowMemory() {
mCalled = true;
mFragments.dispatchLowMemory();
}
-
+
+ public void onTrimMemory(int level) {
+ mCalled = true;
+ mFragments.dispatchTrimMemory(level);
+ }
+
/**
* Return the FragmentManager for interacting with fragments associated
* with this activity.