diff options
author | Jorim Jaggi <jjaggi@google.com> | 2014-09-25 02:41:29 +0200 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2014-10-08 18:30:54 +0000 |
commit | 786afcb3eec18315ec54987a08814ff28f13d09f (patch) | |
tree | 17a0b148ab9591401c091414d78d6bfd1fdfd14a | |
parent | b7af00f2b14e9f8333e3518aa81a15502858ea11 (diff) | |
download | frameworks_base-786afcb3eec18315ec54987a08814ff28f13d09f.zip frameworks_base-786afcb3eec18315ec54987a08814ff28f13d09f.tar.gz frameworks_base-786afcb3eec18315ec54987a08814ff28f13d09f.tar.bz2 |
Trim graphics memory when closing the shade
Graphics memory usually gets trimmed in applications when the
activity goes into the background. We use quite a lot of graphics
memory when the shade/lockscreen is open, and some of them never gets
freed unless the recents activity is closed, because we don't have
these activity-trimming-heuristics for the shade. This change
proactively trims the graphics memory when the shade gets closed or
when the lockscreen is hidden, to emulate the same heuristics as for
activities.
This change also adds trimMemory on RenderThread to systrace to
verify that no jank is introduced with this change.
This change immediately saves around 10-30 MB on an xxhdpi device
after the shade is closed.
Bug: 17581375
Change-Id: I4fb622efb51815fe08187be97ba15d012d4de5d4
3 files changed, 13 insertions, 0 deletions
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index b50a433..3bb4778 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -330,6 +330,7 @@ void CanvasContext::trimMemory(RenderThread& thread, int level) { // No context means nothing to free if (!thread.eglManager().hasEglContext()) return; + ATRACE_CALL(); thread.eglManager().requireGlContext(); if (level >= TRIM_MEMORY_COMPLETE) { Caches::getInstance().flush(Caches::kFlushMode_Full); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 3b05ef1..7936a4b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -40,6 +40,7 @@ import android.app.Notification; import android.app.PendingIntent; import android.app.StatusBarManager; import android.content.BroadcastReceiver; +import android.content.ComponentCallbacks2; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; @@ -95,6 +96,7 @@ import android.view.ViewPropertyAnimator; import android.view.ViewStub; import android.view.ViewTreeObserver; import android.view.WindowManager; +import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.animation.AccelerateDecelerateInterpolator; @@ -2413,6 +2415,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); showBouncer(); disable(mDisabledUnmodified, true /* animate */); + + // Trimming will happen later if Keyguard is showing - doing it here might cause a jank in + // the bouncer appear animation. + if (!mStatusBarKeyguardViewManager.isShowing()) { + WindowManagerGlobal.getInstance().trimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); + } } public boolean interceptTouchEvent(MotionEvent event) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 55c861a..65d231e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.phone; +import android.content.ComponentCallbacks2; import android.content.Context; import android.os.Bundle; import android.os.RemoteException; @@ -24,6 +25,7 @@ import android.util.Slog; import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManagerGlobal; import com.android.internal.policy.IKeyguardShowCallback; import com.android.internal.widget.LockPatternUtils; @@ -268,6 +270,8 @@ public class StatusBarKeyguardViewManager { public void run() { mStatusBarWindowManager.setKeyguardFadingAway(false); mPhoneStatusBar.finishKeyguardFadingAway(); + WindowManagerGlobal.getInstance().trimMemory( + ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN); } }); } else { |