Loading packages/SystemUI/res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -400,6 +400,8 @@ <string name="accessibility_recents_all_items_dismissed">All recent applications dismissed.</string> <string name="accessibility_recents_all_items_dismissed">All recent applications dismissed.</string> <!-- Content description to tell the user an application has been launched from recents --> <!-- Content description to tell the user an application has been launched from recents --> <string name="accessibility_recents_item_launched">Starting <xliff:g id="app" example="Calendar">%s</xliff:g>.</string> <string name="accessibility_recents_item_launched">Starting <xliff:g id="app" example="Calendar">%s</xliff:g>.</string> <!-- Content description of individual recents task. --> <string name="accessibility_recents_task_header"><xliff:g id="app" example="Chrome">%1$s</xliff:g> <xliff:g id="activity_label" example="www.google.com">%2$s</xliff:g></string> <!-- Content description to tell the user a notification has been removed from the notification shade --> <!-- Content description to tell the user a notification has been removed from the notification shade --> <string name="accessibility_notification_dismissed">Notification dismissed.</string> <string name="accessibility_notification_dismissed">Notification dismissed.</string> Loading packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +37 −0 Original line number Original line Diff line number Diff line Loading @@ -438,6 +438,33 @@ public class SystemServicesProxy { return info.loadLabel(mPm).toString(); return info.loadLabel(mPm).toString(); } } /** Returns the application label */ public String getApplicationLabel(Intent baseIntent, int userId) { if (mPm == null) return null; // If we are mocking, then return a mock label if (Constants.DebugFlags.App.EnableSystemServicesProxy) { return "Recent Task"; } ResolveInfo ri = mPm.resolveActivityAsUser(baseIntent, 0, userId); CharSequence label = (ri != null) ? ri.loadLabel(mPm) : null; return (label != null) ? label.toString() : null; } /** Returns the content description for a given task */ public String getContentDescription(Intent baseIntent, int userId, String activityLabel, Resources res) { String applicationLabel = getApplicationLabel(baseIntent, userId); if (applicationLabel == null) { return getBadgedLabel(activityLabel, userId); } String badgedApplicationLabel = getBadgedLabel(applicationLabel, userId); return applicationLabel.equals(activityLabel) ? badgedApplicationLabel : res.getString(R.string.accessibility_recents_task_header, badgedApplicationLabel, activityLabel); } /** /** * Returns the activity icon for the ActivityInfo for a user, badging if * Returns the activity icon for the ActivityInfo for a user, badging if * necessary. * necessary. Loading @@ -464,6 +491,16 @@ public class SystemServicesProxy { return icon; return icon; } } /** * Returns the given label for a user, badging if necessary. */ public String getBadgedLabel(String label, int userId) { if (userId != UserHandle.myUserId()) { label = mPm.getUserBadgedLabel(label, new UserHandle(userId)).toString(); } return label; } /** Returns the package name of the home activity. */ /** Returns the package name of the home activity. */ public String getHomeActivityPackageName() { public String getHomeActivityPackageName() { if (mPm == null) return null; if (mPm == null) return null; Loading packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -130,6 +130,8 @@ public class RecentsTaskLoadPlan { // Load the label, icon, and color // Load the label, icon, and color String activityLabel = loader.getAndUpdateActivityLabel(taskKey, t.taskDescription, String activityLabel = loader.getAndUpdateActivityLabel(taskKey, t.taskDescription, mSystemServicesProxy, infoHandle); mSystemServicesProxy, infoHandle); String contentDescription = loader.getAndUpdateContentDescription(taskKey, activityLabel, mSystemServicesProxy, res); Drawable activityIcon = loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, Drawable activityIcon = loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, mSystemServicesProxy, res, infoHandle, false); mSystemServicesProxy, res, infoHandle, false); int activityColor = loader.getActivityPrimaryColor(t.taskDescription, mConfig); int activityColor = loader.getActivityPrimaryColor(t.taskDescription, mConfig); Loading @@ -148,9 +150,9 @@ public class RecentsTaskLoadPlan { // Add the task to the stack // Add the task to the stack Task task = new Task(taskKey, (t.id != RecentsTaskLoader.INVALID_TASK_ID), Task task = new Task(taskKey, (t.id != RecentsTaskLoader.INVALID_TASK_ID), t.affiliatedTaskId, t.affiliatedTaskColor, activityLabel, activityIcon, t.affiliatedTaskId, t.affiliatedTaskColor, activityLabel, contentDescription, activityColor, (i == (taskCount - 1)), mConfig.lockToAppEnabled, icon, activityIcon, activityColor, (i == (taskCount - 1)), mConfig.lockToAppEnabled, iconFilename); icon, iconFilename); task.thumbnail = loader.getAndUpdateThumbnail(taskKey, mSystemServicesProxy, false); task.thumbnail = loader.getAndUpdateThumbnail(taskKey, mSystemServicesProxy, false); if (DEBUG) Log.d(TAG, "\tthumbnail: " + taskKey + ", " + task.thumbnail); if (DEBUG) Log.d(TAG, "\tthumbnail: " + taskKey + ", " + task.thumbnail); Loading packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java +21 −0 Original line number Original line Diff line number Diff line Loading @@ -259,6 +259,7 @@ public class RecentsTaskLoader { DrawableLruCache mApplicationIconCache; DrawableLruCache mApplicationIconCache; BitmapLruCache mThumbnailCache; BitmapLruCache mThumbnailCache; StringLruCache mActivityLabelCache; StringLruCache mActivityLabelCache; StringLruCache mContentDescriptionCache; TaskResourceLoadQueue mLoadQueue; TaskResourceLoadQueue mLoadQueue; TaskResourceLoader mLoader; TaskResourceLoader mLoader; Loading Loading @@ -298,6 +299,7 @@ public class RecentsTaskLoader { mApplicationIconCache = new DrawableLruCache(iconCacheSize); mApplicationIconCache = new DrawableLruCache(iconCacheSize); mThumbnailCache = new BitmapLruCache(thumbnailCacheSize); mThumbnailCache = new BitmapLruCache(thumbnailCacheSize); mActivityLabelCache = new StringLruCache(100); mActivityLabelCache = new StringLruCache(100); mContentDescriptionCache = new StringLruCache(100); mLoader = new TaskResourceLoader(mLoadQueue, mApplicationIconCache, mThumbnailCache, mLoader = new TaskResourceLoader(mLoadQueue, mApplicationIconCache, mThumbnailCache, mDefaultThumbnail, mDefaultApplicationIcon); mDefaultThumbnail, mDefaultApplicationIcon); } } Loading Loading @@ -348,6 +350,24 @@ public class RecentsTaskLoader { return label; return label; } } /** Returns the content description using as many cached values as we can. */ public String getAndUpdateContentDescription(Task.TaskKey taskKey, String activityLabel, SystemServicesProxy ssp, Resources res) { // Return the cached content description if it exists String label = mContentDescriptionCache.getAndInvalidateIfModified(taskKey); if (label != null) { return label; } label = ssp.getContentDescription(taskKey.baseIntent, taskKey.userId, activityLabel, res); if (label != null) { mContentDescriptionCache.put(taskKey, label); } else { Log.w(TAG, "Missing content description for " + taskKey.baseIntent.getComponent() + " u=" + taskKey.userId); } return label; } /** Returns the activity icon using as many cached values as we can. */ /** Returns the activity icon using as many cached values as we can. */ public Drawable getAndUpdateActivityIcon(Task.TaskKey taskKey, public Drawable getAndUpdateActivityIcon(Task.TaskKey taskKey, ActivityManager.TaskDescription td, SystemServicesProxy ssp, ActivityManager.TaskDescription td, SystemServicesProxy ssp, Loading Loading @@ -541,6 +561,7 @@ public class RecentsTaskLoader { mApplicationIconCache.evictAll(); mApplicationIconCache.evictAll(); // The cache is small, only clear the label cache when we are critical // The cache is small, only clear the label cache when we are critical mActivityLabelCache.evictAll(); mActivityLabelCache.evictAll(); mContentDescriptionCache.evictAll(); break; break; default: default: break; break; Loading packages/SystemUI/src/com/android/systemui/recents/model/Task.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -124,6 +124,7 @@ public class Task { public boolean isLaunchTarget; public boolean isLaunchTarget; public Drawable applicationIcon; public Drawable applicationIcon; public Drawable activityIcon; public Drawable activityIcon; public String contentDescription; public String activityLabel; public String activityLabel; public int colorPrimary; public int colorPrimary; public boolean useLightOnPrimaryColor; public boolean useLightOnPrimaryColor; Loading @@ -140,8 +141,8 @@ public class Task { } } public Task(TaskKey key, boolean isActive, int taskAffiliation, int taskAffiliationColor, public Task(TaskKey key, boolean isActive, int taskAffiliation, int taskAffiliationColor, String activityTitle, Drawable activityIcon, int colorPrimary, String activityTitle, String contentDescription, Drawable activityIcon, boolean lockToThisTask, boolean lockToTaskEnabled, Bitmap icon, int colorPrimary, boolean lockToThisTask, boolean lockToTaskEnabled, Bitmap icon, String iconFilename) { String iconFilename) { boolean isInAffiliationGroup = (taskAffiliation != key.id); boolean isInAffiliationGroup = (taskAffiliation != key.id); boolean hasAffiliationGroupColor = isInAffiliationGroup && (taskAffiliationColor != 0); boolean hasAffiliationGroupColor = isInAffiliationGroup && (taskAffiliationColor != 0); Loading @@ -149,6 +150,7 @@ public class Task { this.taskAffiliation = taskAffiliation; this.taskAffiliation = taskAffiliation; this.taskAffiliationColor = taskAffiliationColor; this.taskAffiliationColor = taskAffiliationColor; this.activityLabel = activityTitle; this.activityLabel = activityTitle; this.contentDescription = contentDescription; this.activityIcon = activityIcon; this.activityIcon = activityIcon; this.colorPrimary = hasAffiliationGroupColor ? taskAffiliationColor : colorPrimary; this.colorPrimary = hasAffiliationGroupColor ? taskAffiliationColor : colorPrimary; this.useLightOnPrimaryColor = Utilities.computeContrastBetweenColors(this.colorPrimary, this.useLightOnPrimaryColor = Utilities.computeContrastBetweenColors(this.colorPrimary, Loading @@ -166,6 +168,7 @@ public class Task { this.taskAffiliation = o.taskAffiliation; this.taskAffiliation = o.taskAffiliation; this.taskAffiliationColor = o.taskAffiliationColor; this.taskAffiliationColor = o.taskAffiliationColor; this.activityLabel = o.activityLabel; this.activityLabel = o.activityLabel; this.contentDescription = o.contentDescription; this.activityIcon = o.activityIcon; this.activityIcon = o.activityIcon; this.colorPrimary = o.colorPrimary; this.colorPrimary = o.colorPrimary; this.useLightOnPrimaryColor = o.useLightOnPrimaryColor; this.useLightOnPrimaryColor = o.useLightOnPrimaryColor; Loading Loading
packages/SystemUI/res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -400,6 +400,8 @@ <string name="accessibility_recents_all_items_dismissed">All recent applications dismissed.</string> <string name="accessibility_recents_all_items_dismissed">All recent applications dismissed.</string> <!-- Content description to tell the user an application has been launched from recents --> <!-- Content description to tell the user an application has been launched from recents --> <string name="accessibility_recents_item_launched">Starting <xliff:g id="app" example="Calendar">%s</xliff:g>.</string> <string name="accessibility_recents_item_launched">Starting <xliff:g id="app" example="Calendar">%s</xliff:g>.</string> <!-- Content description of individual recents task. --> <string name="accessibility_recents_task_header"><xliff:g id="app" example="Chrome">%1$s</xliff:g> <xliff:g id="activity_label" example="www.google.com">%2$s</xliff:g></string> <!-- Content description to tell the user a notification has been removed from the notification shade --> <!-- Content description to tell the user a notification has been removed from the notification shade --> <string name="accessibility_notification_dismissed">Notification dismissed.</string> <string name="accessibility_notification_dismissed">Notification dismissed.</string> Loading
packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +37 −0 Original line number Original line Diff line number Diff line Loading @@ -438,6 +438,33 @@ public class SystemServicesProxy { return info.loadLabel(mPm).toString(); return info.loadLabel(mPm).toString(); } } /** Returns the application label */ public String getApplicationLabel(Intent baseIntent, int userId) { if (mPm == null) return null; // If we are mocking, then return a mock label if (Constants.DebugFlags.App.EnableSystemServicesProxy) { return "Recent Task"; } ResolveInfo ri = mPm.resolveActivityAsUser(baseIntent, 0, userId); CharSequence label = (ri != null) ? ri.loadLabel(mPm) : null; return (label != null) ? label.toString() : null; } /** Returns the content description for a given task */ public String getContentDescription(Intent baseIntent, int userId, String activityLabel, Resources res) { String applicationLabel = getApplicationLabel(baseIntent, userId); if (applicationLabel == null) { return getBadgedLabel(activityLabel, userId); } String badgedApplicationLabel = getBadgedLabel(applicationLabel, userId); return applicationLabel.equals(activityLabel) ? badgedApplicationLabel : res.getString(R.string.accessibility_recents_task_header, badgedApplicationLabel, activityLabel); } /** /** * Returns the activity icon for the ActivityInfo for a user, badging if * Returns the activity icon for the ActivityInfo for a user, badging if * necessary. * necessary. Loading @@ -464,6 +491,16 @@ public class SystemServicesProxy { return icon; return icon; } } /** * Returns the given label for a user, badging if necessary. */ public String getBadgedLabel(String label, int userId) { if (userId != UserHandle.myUserId()) { label = mPm.getUserBadgedLabel(label, new UserHandle(userId)).toString(); } return label; } /** Returns the package name of the home activity. */ /** Returns the package name of the home activity. */ public String getHomeActivityPackageName() { public String getHomeActivityPackageName() { if (mPm == null) return null; if (mPm == null) return null; Loading
packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -130,6 +130,8 @@ public class RecentsTaskLoadPlan { // Load the label, icon, and color // Load the label, icon, and color String activityLabel = loader.getAndUpdateActivityLabel(taskKey, t.taskDescription, String activityLabel = loader.getAndUpdateActivityLabel(taskKey, t.taskDescription, mSystemServicesProxy, infoHandle); mSystemServicesProxy, infoHandle); String contentDescription = loader.getAndUpdateContentDescription(taskKey, activityLabel, mSystemServicesProxy, res); Drawable activityIcon = loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, Drawable activityIcon = loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, mSystemServicesProxy, res, infoHandle, false); mSystemServicesProxy, res, infoHandle, false); int activityColor = loader.getActivityPrimaryColor(t.taskDescription, mConfig); int activityColor = loader.getActivityPrimaryColor(t.taskDescription, mConfig); Loading @@ -148,9 +150,9 @@ public class RecentsTaskLoadPlan { // Add the task to the stack // Add the task to the stack Task task = new Task(taskKey, (t.id != RecentsTaskLoader.INVALID_TASK_ID), Task task = new Task(taskKey, (t.id != RecentsTaskLoader.INVALID_TASK_ID), t.affiliatedTaskId, t.affiliatedTaskColor, activityLabel, activityIcon, t.affiliatedTaskId, t.affiliatedTaskColor, activityLabel, contentDescription, activityColor, (i == (taskCount - 1)), mConfig.lockToAppEnabled, icon, activityIcon, activityColor, (i == (taskCount - 1)), mConfig.lockToAppEnabled, iconFilename); icon, iconFilename); task.thumbnail = loader.getAndUpdateThumbnail(taskKey, mSystemServicesProxy, false); task.thumbnail = loader.getAndUpdateThumbnail(taskKey, mSystemServicesProxy, false); if (DEBUG) Log.d(TAG, "\tthumbnail: " + taskKey + ", " + task.thumbnail); if (DEBUG) Log.d(TAG, "\tthumbnail: " + taskKey + ", " + task.thumbnail); Loading
packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java +21 −0 Original line number Original line Diff line number Diff line Loading @@ -259,6 +259,7 @@ public class RecentsTaskLoader { DrawableLruCache mApplicationIconCache; DrawableLruCache mApplicationIconCache; BitmapLruCache mThumbnailCache; BitmapLruCache mThumbnailCache; StringLruCache mActivityLabelCache; StringLruCache mActivityLabelCache; StringLruCache mContentDescriptionCache; TaskResourceLoadQueue mLoadQueue; TaskResourceLoadQueue mLoadQueue; TaskResourceLoader mLoader; TaskResourceLoader mLoader; Loading Loading @@ -298,6 +299,7 @@ public class RecentsTaskLoader { mApplicationIconCache = new DrawableLruCache(iconCacheSize); mApplicationIconCache = new DrawableLruCache(iconCacheSize); mThumbnailCache = new BitmapLruCache(thumbnailCacheSize); mThumbnailCache = new BitmapLruCache(thumbnailCacheSize); mActivityLabelCache = new StringLruCache(100); mActivityLabelCache = new StringLruCache(100); mContentDescriptionCache = new StringLruCache(100); mLoader = new TaskResourceLoader(mLoadQueue, mApplicationIconCache, mThumbnailCache, mLoader = new TaskResourceLoader(mLoadQueue, mApplicationIconCache, mThumbnailCache, mDefaultThumbnail, mDefaultApplicationIcon); mDefaultThumbnail, mDefaultApplicationIcon); } } Loading Loading @@ -348,6 +350,24 @@ public class RecentsTaskLoader { return label; return label; } } /** Returns the content description using as many cached values as we can. */ public String getAndUpdateContentDescription(Task.TaskKey taskKey, String activityLabel, SystemServicesProxy ssp, Resources res) { // Return the cached content description if it exists String label = mContentDescriptionCache.getAndInvalidateIfModified(taskKey); if (label != null) { return label; } label = ssp.getContentDescription(taskKey.baseIntent, taskKey.userId, activityLabel, res); if (label != null) { mContentDescriptionCache.put(taskKey, label); } else { Log.w(TAG, "Missing content description for " + taskKey.baseIntent.getComponent() + " u=" + taskKey.userId); } return label; } /** Returns the activity icon using as many cached values as we can. */ /** Returns the activity icon using as many cached values as we can. */ public Drawable getAndUpdateActivityIcon(Task.TaskKey taskKey, public Drawable getAndUpdateActivityIcon(Task.TaskKey taskKey, ActivityManager.TaskDescription td, SystemServicesProxy ssp, ActivityManager.TaskDescription td, SystemServicesProxy ssp, Loading Loading @@ -541,6 +561,7 @@ public class RecentsTaskLoader { mApplicationIconCache.evictAll(); mApplicationIconCache.evictAll(); // The cache is small, only clear the label cache when we are critical // The cache is small, only clear the label cache when we are critical mActivityLabelCache.evictAll(); mActivityLabelCache.evictAll(); mContentDescriptionCache.evictAll(); break; break; default: default: break; break; Loading
packages/SystemUI/src/com/android/systemui/recents/model/Task.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -124,6 +124,7 @@ public class Task { public boolean isLaunchTarget; public boolean isLaunchTarget; public Drawable applicationIcon; public Drawable applicationIcon; public Drawable activityIcon; public Drawable activityIcon; public String contentDescription; public String activityLabel; public String activityLabel; public int colorPrimary; public int colorPrimary; public boolean useLightOnPrimaryColor; public boolean useLightOnPrimaryColor; Loading @@ -140,8 +141,8 @@ public class Task { } } public Task(TaskKey key, boolean isActive, int taskAffiliation, int taskAffiliationColor, public Task(TaskKey key, boolean isActive, int taskAffiliation, int taskAffiliationColor, String activityTitle, Drawable activityIcon, int colorPrimary, String activityTitle, String contentDescription, Drawable activityIcon, boolean lockToThisTask, boolean lockToTaskEnabled, Bitmap icon, int colorPrimary, boolean lockToThisTask, boolean lockToTaskEnabled, Bitmap icon, String iconFilename) { String iconFilename) { boolean isInAffiliationGroup = (taskAffiliation != key.id); boolean isInAffiliationGroup = (taskAffiliation != key.id); boolean hasAffiliationGroupColor = isInAffiliationGroup && (taskAffiliationColor != 0); boolean hasAffiliationGroupColor = isInAffiliationGroup && (taskAffiliationColor != 0); Loading @@ -149,6 +150,7 @@ public class Task { this.taskAffiliation = taskAffiliation; this.taskAffiliation = taskAffiliation; this.taskAffiliationColor = taskAffiliationColor; this.taskAffiliationColor = taskAffiliationColor; this.activityLabel = activityTitle; this.activityLabel = activityTitle; this.contentDescription = contentDescription; this.activityIcon = activityIcon; this.activityIcon = activityIcon; this.colorPrimary = hasAffiliationGroupColor ? taskAffiliationColor : colorPrimary; this.colorPrimary = hasAffiliationGroupColor ? taskAffiliationColor : colorPrimary; this.useLightOnPrimaryColor = Utilities.computeContrastBetweenColors(this.colorPrimary, this.useLightOnPrimaryColor = Utilities.computeContrastBetweenColors(this.colorPrimary, Loading @@ -166,6 +168,7 @@ public class Task { this.taskAffiliation = o.taskAffiliation; this.taskAffiliation = o.taskAffiliation; this.taskAffiliationColor = o.taskAffiliationColor; this.taskAffiliationColor = o.taskAffiliationColor; this.activityLabel = o.activityLabel; this.activityLabel = o.activityLabel; this.contentDescription = o.contentDescription; this.activityIcon = o.activityIcon; this.activityIcon = o.activityIcon; this.colorPrimary = o.colorPrimary; this.colorPrimary = o.colorPrimary; this.useLightOnPrimaryColor = o.useLightOnPrimaryColor; this.useLightOnPrimaryColor = o.useLightOnPrimaryColor; Loading