am 98ae236f: am 026a5154: Aggressive tuning of recents memory usage
* commit '98ae236fe66603126f793734d7394f3454cc3066': Aggressive tuning of recents memory usage
This commit is contained in:
@@ -29,6 +29,12 @@
|
||||
ImageView -->
|
||||
<bool name="config_recents_thumbnail_image_fits_to_xy">false</bool>
|
||||
|
||||
<!-- The number of app thumbnails we keep in memory -->
|
||||
<integer name="config_recents_max_thumbnail_count">10</integer>
|
||||
|
||||
<!-- The number of app icons we keep in memory -->
|
||||
<integer name="config_recents_max_icon_count">20</integer>
|
||||
|
||||
<!-- Control whether status bar should distinguish HSPA data icon form UMTS
|
||||
data icon on devices -->
|
||||
<bool name="config_hspa_data_distinguishable">false</bool>
|
||||
|
||||
@@ -68,7 +68,7 @@ public class Constants {
|
||||
|
||||
public static class RecentsTaskLoader {
|
||||
// XXX: This should be calculated on the first load
|
||||
public static final int PreloadFirstTasksCount = 5;
|
||||
public static final int PreloadFirstTasksCount = 6;
|
||||
}
|
||||
|
||||
public static class TaskStackView {
|
||||
|
||||
@@ -25,10 +25,4 @@ class BitmapLruCache extends KeyStoreLruCache<Bitmap> {
|
||||
public BitmapLruCache(int cacheSize) {
|
||||
super(cacheSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int computeSize(Bitmap b) {
|
||||
// The cache size will be measured in kilobytes rather than number of items
|
||||
return b.getAllocationByteCount();
|
||||
}
|
||||
}
|
||||
@@ -25,12 +25,4 @@ class DrawableLruCache extends KeyStoreLruCache<Drawable> {
|
||||
public DrawableLruCache(int cacheSize) {
|
||||
super(cacheSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int computeSize(Drawable d) {
|
||||
// The cache size will be measured in kilobytes rather than number of items
|
||||
// NOTE: this isn't actually correct, as the icon may be smaller
|
||||
int maxBytes = (d.getIntrinsicWidth() * d.getIntrinsicHeight() * 4);
|
||||
return maxBytes;
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,6 @@ public class KeyStoreLruCache<V> {
|
||||
|
||||
public KeyStoreLruCache(int cacheSize) {
|
||||
mCache = new LruCache<Integer, V>(cacheSize) {
|
||||
@Override
|
||||
protected int sizeOf(Integer taskId, V v) {
|
||||
return computeSize(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entryRemoved(boolean evicted, Integer taskId, V oldV, V newV) {
|
||||
@@ -46,11 +42,6 @@ public class KeyStoreLruCache<V> {
|
||||
};
|
||||
}
|
||||
|
||||
/** Computes the size of a value. */
|
||||
protected int computeSize(V value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Gets a specific entry in the cache. */
|
||||
final V get(Task.TaskKey key) {
|
||||
return mCache.get(key.id);
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.os.HandlerThread;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.recents.Constants;
|
||||
import com.android.systemui.recents.RecentsConfiguration;
|
||||
import com.android.systemui.recents.misc.SystemServicesProxy;
|
||||
@@ -123,8 +124,8 @@ class TaskResourceLoader implements Runnable {
|
||||
mDefaultThumbnail = defaultThumbnail;
|
||||
mDefaultApplicationIcon = defaultApplicationIcon;
|
||||
mMainThreadHandler = new Handler();
|
||||
mLoadThread = new HandlerThread("Recents-TaskResourceLoader");
|
||||
mLoadThread.setPriority(Thread.NORM_PRIORITY - 1);
|
||||
mLoadThread = new HandlerThread("Recents-TaskResourceLoader",
|
||||
android.os.Process.THREAD_PRIORITY_DEFAULT - 1);
|
||||
mLoadThread.start();
|
||||
mLoadThreadHandler = new Handler(mLoadThread.getLooper());
|
||||
mLoadThreadHandler.post(this);
|
||||
@@ -255,12 +256,10 @@ public class RecentsTaskLoader {
|
||||
|
||||
/** Private Constructor */
|
||||
private RecentsTaskLoader(Context context) {
|
||||
// Calculate the cache sizes, we just use a reasonable number here similar to those
|
||||
// suggested in the Android docs, 1/6th for the thumbnail cache and 1/30 of the max memory
|
||||
// for icons.
|
||||
int maxMemory = (int) Runtime.getRuntime().maxMemory();
|
||||
mMaxThumbnailCacheSize = maxMemory / 6;
|
||||
mMaxIconCacheSize = mMaxThumbnailCacheSize / 5;
|
||||
mMaxThumbnailCacheSize = context.getResources().getInteger(
|
||||
R.integer.config_recents_max_thumbnail_count);
|
||||
mMaxIconCacheSize = context.getResources().getInteger(
|
||||
R.integer.config_recents_max_icon_count);
|
||||
int iconCacheSize = Constants.DebugFlags.App.DisableBackgroundCache ? 1 :
|
||||
mMaxIconCacheSize;
|
||||
int thumbnailCacheSize = Constants.DebugFlags.App.DisableBackgroundCache ? 1 :
|
||||
@@ -550,6 +549,12 @@ public class RecentsTaskLoader {
|
||||
case ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN:
|
||||
// Stop the loader immediately when the UI is no longer visible
|
||||
stopLoader();
|
||||
mThumbnailCache.trimToSize(Math.max(
|
||||
Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount,
|
||||
mMaxThumbnailCacheSize / 2));
|
||||
mApplicationIconCache.trimToSize(Math.max(
|
||||
Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount,
|
||||
mMaxIconCacheSize / 2));
|
||||
break;
|
||||
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
|
||||
case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND:
|
||||
|
||||
@@ -23,10 +23,4 @@ class StringLruCache extends KeyStoreLruCache<String> {
|
||||
public StringLruCache(int cacheSize) {
|
||||
super(cacheSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int computeSize(String s) {
|
||||
// The cache size is measured in number of strings
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ import com.android.systemui.recents.model.Task;
|
||||
/* A task view */
|
||||
public class TaskView extends FrameLayout implements Task.TaskCallbacks,
|
||||
TaskViewFooter.TaskFooterViewCallbacks, View.OnClickListener, View.OnLongClickListener {
|
||||
|
||||
/** The TaskView callbacks */
|
||||
interface TaskViewCallbacks {
|
||||
public void onTaskViewAppIconClicked(TaskView tv);
|
||||
|
||||
Reference in New Issue
Block a user