summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/WindowManagerImpl.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-03-06 14:57:58 -0800
committerDianne Hackborn <hackbod@google.com>2012-03-06 18:46:32 -0800
commit27ff913d56de8400083a13fc572e2812b32c890c (patch)
treef30ec6efb44658b448c5e049bf0c1c3e40f0f06c /core/java/android/view/WindowManagerImpl.java
parent4f03d35f9c040222e6a46dde807fe2ff7852beb8 (diff)
downloadframeworks_base-27ff913d56de8400083a13fc572e2812b32c890c.zip
frameworks_base-27ff913d56de8400083a13fc572e2812b32c890c.tar.gz
frameworks_base-27ff913d56de8400083a13fc572e2812b32c890c.tar.bz2
Work on more low memory reporting to apps.
There are now some new trim memory levels that are sent to non-background applications as RAM becomes low. There is a new API for an application to retrieve information about memory trimming and such on demand. Fixed various checks against the memory trim level to be robust (not compare against exact values). Change-Id: Ifd1c6151124350168aef20a94e517166fd2e03eb
Diffstat (limited to 'core/java/android/view/WindowManagerImpl.java')
-rw-r--r--core/java/android/view/WindowManagerImpl.java36
1 files changed, 16 insertions, 20 deletions
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java
index d482b35..0e4a30f 100644
--- a/core/java/android/view/WindowManagerImpl.java
+++ b/core/java/android/view/WindowManagerImpl.java
@@ -432,29 +432,25 @@ public class WindowManagerImpl implements WindowManager {
*/
public void trimMemory(int level) {
if (HardwareRenderer.isAvailable()) {
- switch (level) {
- case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
- case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
- // On low and medium end gfx devices
- if (!ActivityManager.isHighEndGfx(getDefaultDisplay())) {
- // Destroy all hardware surfaces and resources associated to
- // known windows
- synchronized (this) {
- if (mViews == null) return;
- int count = mViews.length;
- for (int i = 0; i < count; i++) {
- mRoots[i].terminateHardwareResources();
- }
+ // On low and medium end gfx devices
+ if (!ActivityManager.isHighEndGfx(getDefaultDisplay())) {
+ if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
+ // Destroy all hardware surfaces and resources associated to
+ // known windows
+ synchronized (this) {
+ if (mViews == null) return;
+ int count = mViews.length;
+ for (int i = 0; i < count; i++) {
+ mRoots[i].terminateHardwareResources();
}
- // Force a full memory flush
- HardwareRenderer.trimMemory(ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
- mNeedsEglTerminate = true;
- break;
}
- // high end gfx devices fall through to next case
- default:
- HardwareRenderer.trimMemory(level);
+ // Force a full memory flush
+ HardwareRenderer.trimMemory(ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
+ mNeedsEglTerminate = true;
+ return;
+ }
}
+ HardwareRenderer.trimMemory(level);
}
}