diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index cc77aaa285784..e22d78a71cf23 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -29,6 +29,12 @@
ImageView -->
false
+
+ 10
+
+
+ 20
+
false
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Constants.java b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
index 6f4cf6b1cb27b..52ec54b9c3402 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Constants.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
@@ -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 {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/BitmapLruCache.java b/packages/SystemUI/src/com/android/systemui/recents/model/BitmapLruCache.java
index 757c07fbb28db..624a8ff0d2f67 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/BitmapLruCache.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/BitmapLruCache.java
@@ -25,10 +25,4 @@ class BitmapLruCache extends KeyStoreLruCache {
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();
- }
}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/DrawableLruCache.java b/packages/SystemUI/src/com/android/systemui/recents/model/DrawableLruCache.java
index 5b5035865d36f..01a515b15df7d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/DrawableLruCache.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/DrawableLruCache.java
@@ -25,12 +25,4 @@ class DrawableLruCache extends KeyStoreLruCache {
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;
- }
}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java b/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java
index bb4dc760199eb..7ccefc6ed5f78 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/KeyStoreLruCache.java
@@ -34,10 +34,6 @@ public class KeyStoreLruCache {
public KeyStoreLruCache(int cacheSize) {
mCache = new LruCache(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 {
};
}
- /** 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);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
index f7ad35b336020..5d7baab89d6f7 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
@@ -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:
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/StringLruCache.java b/packages/SystemUI/src/com/android/systemui/recents/model/StringLruCache.java
index b06c4548c0ae1..6769716b1a8c0 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/StringLruCache.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/StringLruCache.java
@@ -23,10 +23,4 @@ class StringLruCache extends KeyStoreLruCache {
public StringLruCache(int cacheSize) {
super(cacheSize);
}
-
- @Override
- protected int computeSize(String s) {
- // The cache size is measured in number of strings
- return 1;
- }
}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 4563597c76998..51adc28c5e85f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -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);