diff options
author | Dianne Hackborn <hackbod@google.com> | 2012-04-09 14:06:16 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2012-04-10 14:43:58 -0700 |
commit | 162bc0ea0d7862b92f18d0ce47310a85304205f7 (patch) | |
tree | 7d7342164ba4c6dde86e3951bcd6b79dead4273e /core/java/android/app/Activity.java | |
parent | d3ce6f50c114f58a3f50e44764e9b315ac41f637 (diff) | |
download | frameworks_base-162bc0ea0d7862b92f18d0ce47310a85304205f7.zip frameworks_base-162bc0ea0d7862b92f18d0ce47310a85304205f7.tar.gz frameworks_base-162bc0ea0d7862b92f18d0ce47310a85304205f7.tar.bz2 |
Some small tweaks to improve memory management.
We now allow processes that currently have stopping activities to
be managed as if they were done stopping, so that memory trimming
can be done before the process goes to the background. Hopefully
this will reduce cases where the processes goes to the background
and immediately gets killed, but wouldn't have had to be killed if
it had a chance to trim its memory.
Also change window memory trimming to always do the aggressive
trimming when memory is critical, even if not on a low-end device.
And tweak web view trimming to not trim for foreground UI events.
Change-Id: I241b3152b52d09757bd14a202477cf69c9b78786
Diffstat (limited to 'core/java/android/app/Activity.java')
-rw-r--r-- | core/java/android/app/Activity.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 7207e29..227900e 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -55,6 +55,7 @@ import android.text.method.TextKeyListener; import android.util.AttributeSet; import android.util.EventLog; import android.util.Log; +import android.util.Slog; import android.util.SparseArray; import android.view.ActionMode; import android.view.ContextMenu; @@ -642,6 +643,7 @@ public class Activity extends ContextThemeWrapper Window.Callback, KeyEvent.Callback, OnCreateContextMenuListener, ComponentCallbacks2 { private static final String TAG = "Activity"; + private static final boolean DEBUG_LIFECYCLE = false; /** Standard activity result: operation canceled. */ public static final int RESULT_CANCELED = 0; @@ -865,6 +867,7 @@ public class Activity extends ContextThemeWrapper * @see #onPostCreate */ protected void onCreate(Bundle savedInstanceState) { + if (DEBUG_LIFECYCLE) Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState); if (mLastNonConfigurationInstances != null) { mAllLoaderManagers = mLastNonConfigurationInstances.loaders; } @@ -1013,6 +1016,7 @@ public class Activity extends ContextThemeWrapper * @see #onResume */ protected void onStart() { + if (DEBUG_LIFECYCLE) Slog.v(TAG, "onStart " + this); mCalled = true; if (!mLoadersStarted) { @@ -1073,6 +1077,7 @@ public class Activity extends ContextThemeWrapper * @see #onPause */ protected void onResume() { + if (DEBUG_LIFECYCLE) Slog.v(TAG, "onResume " + this); getApplication().dispatchActivityResumed(this); mCalled = true; } @@ -1131,6 +1136,7 @@ public class Activity extends ContextThemeWrapper final void performSaveInstanceState(Bundle outState) { onSaveInstanceState(outState); saveManagedDialogs(outState); + if (DEBUG_LIFECYCLE) Slog.v(TAG, "onSaveInstanceState " + this + ": " + outState); } /** @@ -1261,6 +1267,7 @@ public class Activity extends ContextThemeWrapper * @see #onStop */ protected void onPause() { + if (DEBUG_LIFECYCLE) Slog.v(TAG, "onPause " + this); getApplication().dispatchActivityPaused(this); mCalled = true; } @@ -1347,6 +1354,7 @@ public class Activity extends ContextThemeWrapper * @see #onDestroy */ protected void onStop() { + if (DEBUG_LIFECYCLE) Slog.v(TAG, "onStop " + this); if (mActionBar != null) mActionBar.setShowHideAnimationEnabled(false); getApplication().dispatchActivityStopped(this); mCalled = true; @@ -1381,6 +1389,7 @@ public class Activity extends ContextThemeWrapper * @see #isFinishing */ protected void onDestroy() { + if (DEBUG_LIFECYCLE) Slog.v(TAG, "onDestroy " + this); mCalled = true; // dismiss any dialogs we are managing. @@ -1432,6 +1441,7 @@ public class Activity extends ContextThemeWrapper * @param newConfig The new device configuration. */ public void onConfigurationChanged(Configuration newConfig) { + if (DEBUG_LIFECYCLE) Slog.v(TAG, "onConfigurationChanged " + this + ": " + newConfig); mCalled = true; mFragments.dispatchConfigurationChanged(newConfig); @@ -1613,11 +1623,13 @@ public class Activity extends ContextThemeWrapper } public void onLowMemory() { + if (DEBUG_LIFECYCLE) Slog.v(TAG, "onLowMemory " + this); mCalled = true; mFragments.dispatchLowMemory(); } public void onTrimMemory(int level) { + if (DEBUG_LIFECYCLE) Slog.v(TAG, "onTrimMemory " + this + ": " + level); mCalled = true; mFragments.dispatchTrimMemory(level); } |