summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-09-23 02:52:16 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-09-23 02:52:16 +0000
commit7a5b01bc0e220382f0f84bfeb82b8e8b7cfb8730 (patch)
treeb07e1f68f0391aa9a635ffd3c8fb70155ce07914 /core/java/android/view
parent4c8188a6a5b5b2b794248e654c3a9bf90c672ccd (diff)
parent8b5ab0d7bef881bd583d3278ba15710076c015dd (diff)
downloadframeworks_base-7a5b01bc0e220382f0f84bfeb82b8e8b7cfb8730.zip
frameworks_base-7a5b01bc0e220382f0f84bfeb82b8e8b7cfb8730.tar.gz
frameworks_base-7a5b01bc0e220382f0f84bfeb82b8e8b7cfb8730.tar.bz2
am 01b5cfaa: am 668e566e: Merge "Aggressively trim memory for system_process" into lmp-dev
* commit '01b5cfaac7e72526d145b4c5ea706993321abaa9': Aggressively trim memory for system_process
Diffstat (limited to 'core/java/android/view')
-rw-r--r--core/java/android/view/HardwareRenderer.java12
-rw-r--r--core/java/android/view/ViewRootImpl.java3
-rw-r--r--core/java/android/view/WindowManagerGlobal.java34
3 files changed, 48 insertions, 1 deletions
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index edb3798..904e33f 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -186,6 +186,18 @@ public abstract class HardwareRenderer {
}
}
+ public static boolean sTrimForeground = false;
+
+ /**
+ * Controls whether or not the hardware renderer should aggressively
+ * trim memory. Note that this must not be set for any process that
+ * uses WebView! This should be only used by system_process or similar
+ * that do not go into the background.
+ */
+ public static void enableForegroundTrimming() {
+ sTrimForeground = true;
+ }
+
/**
* Indicates whether hardware acceleration is available under any form for
* the view hierarchy.
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 43ab4ef..b1d3d45 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -804,6 +804,9 @@ public final class ViewRootImpl implements ViewParent,
if (mAppVisible != visible) {
mAppVisible = visible;
scheduleTraversals();
+ if (!mAppVisible) {
+ WindowManagerGlobal.trimForeground();
+ }
}
}
diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java
index c39ec97..08160c8 100644
--- a/core/java/android/view/WindowManagerGlobal.java
+++ b/core/java/android/view/WindowManagerGlobal.java
@@ -375,6 +375,9 @@ public final class WindowManagerGlobal {
mDyingViews.remove(view);
}
}
+ if (HardwareRenderer.sTrimForeground && HardwareRenderer.isAvailable()) {
+ doTrimForeground();
+ }
}
private int findViewLocked(View view, boolean required) {
@@ -413,6 +416,35 @@ public final class WindowManagerGlobal {
}
HardwareRenderer.trimMemory(level);
+
+ if (HardwareRenderer.sTrimForeground) {
+ doTrimForeground();
+ }
+ }
+ }
+
+ public static void trimForeground() {
+ if (HardwareRenderer.sTrimForeground && HardwareRenderer.isAvailable()) {
+ WindowManagerGlobal wm = WindowManagerGlobal.getInstance();
+ wm.doTrimForeground();
+ }
+ }
+
+ private void doTrimForeground() {
+ boolean hasVisibleWindows = false;
+ synchronized (mLock) {
+ for (int i = mRoots.size() - 1; i >= 0; --i) {
+ if (mRoots.get(i).getHostVisibility() == View.VISIBLE
+ && mRoots.get(i).mAttachInfo.mHardwareRenderer != null) {
+ hasVisibleWindows = true;
+ } else {
+ mRoots.get(i).destroyHardwareResources();
+ }
+ }
+ }
+ if (!hasVisibleWindows) {
+ HardwareRenderer.trimMemory(
+ ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
}
}
@@ -428,7 +460,7 @@ public final class WindowManagerGlobal {
for (int i = 0; i < count; i++) {
ViewRootImpl root = mRoots.get(i);
String name = getWindowName(root);
- pw.printf("\n\t%s", name);
+ pw.printf("\n\t%s (visibility=%d)", name, root.getHostVisibility());
HardwareRenderer renderer =
root.getView().mAttachInfo.mHardwareRenderer;