diff options
author | Jorim Jaggi <jjaggi@google.com> | 2014-09-26 19:52:56 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-09-26 19:52:56 +0000 |
commit | b56ec7fc266a266ec38e50d082be414c7ed40acd (patch) | |
tree | 9136614306ea8b8969ba40c3b8d471f735b89907 /packages/SystemUI/src/com/android/systemui/recents | |
parent | 8e193fc1aa62d7c0d107e0f36e1ba1321431b50d (diff) | |
parent | 875db8db406f27efc117a0d409dda7db690e6057 (diff) | |
download | frameworks_base-b56ec7fc266a266ec38e50d082be414c7ed40acd.zip frameworks_base-b56ec7fc266a266ec38e50d082be414c7ed40acd.tar.gz frameworks_base-b56ec7fc266a266ec38e50d082be414c7ed40acd.tar.bz2 |
am 5299d7e5: am 9b20e012: Merge "Don\'t preload task description icons when opening recents" into lmp-dev
* commit '5299d7e5e88b0c2b91e9f8bac35b21487ac83d0f':
Don't preload task description icons when opening recents
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/recents')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java | 57 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/recents/model/Task.java | 8 |
2 files changed, 50 insertions, 15 deletions
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 d4b403d..9d4fe66 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java @@ -177,16 +177,24 @@ class TaskResourceLoader implements Runnable { if (t != null) { Drawable cachedIcon = mApplicationIconCache.get(t.key); Bitmap cachedThumbnail = mThumbnailCache.get(t.key); + // Load the application icon if it is stale or we haven't cached one yet if (cachedIcon == null) { - ActivityInfo info = ssp.getActivityInfo(t.key.baseIntent.getComponent(), - t.key.userId); - if (info != null) { - cachedIcon = ssp.getActivityIcon(info, t.key.userId); + cachedIcon = getTaskDescriptionIcon(t.key, t.icon, t.iconFilename, ssp, + mContext.getResources()); + + if (cachedIcon == null) { + ActivityInfo info = ssp.getActivityInfo(t.key.baseIntent.getComponent(), + t.key.userId); + if (info != null) { + cachedIcon = ssp.getActivityIcon(info, t.key.userId); + } } + if (cachedIcon == null) { cachedIcon = mDefaultApplicationIcon; } + // At this point, even if we can't load the icon, we will set the default // icon. mApplicationIconCache.put(t.key, cachedIcon); @@ -230,6 +238,17 @@ class TaskResourceLoader implements Runnable { } } } + + Drawable getTaskDescriptionIcon(Task.TaskKey taskKey, Bitmap iconBitmap, String iconFilename, + SystemServicesProxy ssp, Resources res) { + Bitmap tdIcon = iconBitmap != null + ? iconBitmap + : ActivityManager.TaskDescription.loadTaskDescriptionIcon(iconFilename); + if (tdIcon != null) { + return ssp.getBadgedIcon(new BitmapDrawable(res, tdIcon), taskKey.userId); + } + return null; + } } /* Recents task loader @@ -321,15 +340,20 @@ public class RecentsTaskLoader { if (icon != null) { return icon; } - // Return the task description icon if it exists - if (td != null && td.getIcon() != null) { - icon = ssp.getBadgedIcon(new BitmapDrawable(res, td.getIcon()), taskKey.userId); - mApplicationIconCache.put(taskKey, icon); - return icon; - } - // If we are preloading this task, continue to load the activity icon + + // If we are preloading this task, continue to load the task description icon or the + // activity icon if (preloadTask) { - // All short paths failed, load the icon from the activity info and cache it + + // Return and cache the task description icon if it exists + Drawable tdDrawable = mLoader.getTaskDescriptionIcon(taskKey, td.getInMemoryIcon(), + td.getIconFilename(), ssp, res); + if (tdDrawable != null) { + mApplicationIconCache.put(taskKey, tdDrawable); + return tdDrawable; + } + + // Load the icon from the activity info and cache it if (infoHandle.info == null) { infoHandle.info = ssp.getActivityInfo(taskKey.baseIntent.getComponent(), taskKey.userId); @@ -453,10 +477,17 @@ public class RecentsTaskLoader { activityInfoCache.put(cnKey, infoHandle); } + Bitmap icon = t.taskDescription != null + ? t.taskDescription.getInMemoryIcon() + : null; + String iconFilename = t.taskDescription != null + ? t.taskDescription.getIconFilename() + : null; + // Add the task to the stack Task task = new Task(taskKey, (t.id > -1), t.affiliatedTaskId, t.affiliatedTaskColor, activityLabel, activityIcon, activityColor, (i == (taskCount - 1)), - config.lockToAppEnabled); + config.lockToAppEnabled, icon, iconFilename); if (preloadTask && loadTaskThumbnails) { // Load the thumbnail from the cache if possible diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java index 406e03f..a7e2b0b 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java @@ -124,7 +124,8 @@ public class Task { public boolean isActive; public boolean lockToThisTask; public boolean lockToTaskEnabled; - + public Bitmap icon; + public String iconFilename; TaskCallbacks mCb; public Task() { @@ -133,7 +134,8 @@ public class Task { public Task(TaskKey key, boolean isActive, int taskAffiliation, int taskAffiliationColor, String activityTitle, Drawable activityIcon, int colorPrimary, - boolean lockToThisTask, boolean lockToTaskEnabled) { + boolean lockToThisTask, boolean lockToTaskEnabled, Bitmap icon, + String iconFilename) { boolean isInAffiliationGroup = (taskAffiliation != key.id); boolean hasAffiliationGroupColor = isInAffiliationGroup && (taskAffiliationColor != 0); this.key = key; @@ -147,6 +149,8 @@ public class Task { this.isActive = isActive; this.lockToThisTask = lockToTaskEnabled && lockToThisTask; this.lockToTaskEnabled = lockToTaskEnabled; + this.icon = icon; + this.iconFilename = iconFilename; } /** Copies the other task. */ |