diff options
3 files changed, 21 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java index ccebd7ceec32..42897904f363 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -808,13 +808,19 @@ public class SystemServicesProxy { * Returns the content description for a given task, badging it if necessary. The content * description joins the app and activity labels. */ - public String getBadgedContentDescription(ActivityInfo info, int userId, Resources res) { + public String getBadgedContentDescription(ActivityInfo info, int userId, + ActivityManager.TaskDescription td, Resources res) { // If we are mocking, then return a mock label if (RecentsDebugFlags.Static.EnableMockTasks) { return "Recent Task Content Description: " + userId; } - String activityLabel = info.loadLabel(mPm).toString(); + String activityLabel; + if (td != null && td.getLabel() != null) { + activityLabel = td.getLabel(); + } else { + activityLabel = info.loadLabel(mPm).toString(); + } String applicationLabel = info.applicationInfo.loadLabel(mPm).toString(); String badgedApplicationLabel = getBadgedLabel(applicationLabel, userId); return applicationLabel.equals(activityLabel) ? badgedApplicationLabel diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java index 5c25bfd6441c..78c71a11f3f5 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java @@ -182,7 +182,8 @@ public class RecentsTaskLoadPlan { // Load the title, icon, and color ActivityInfo info = loader.getAndUpdateActivityInfo(taskKey); String title = loader.getAndUpdateActivityTitle(taskKey, t.taskDescription); - String titleDescription = loader.getAndUpdateContentDescription(taskKey, res); + String titleDescription = loader.getAndUpdateContentDescription(taskKey, + t.taskDescription, res); String dismissDescription = String.format(dismissDescFormat, titleDescription); String appInfoDescription = String.format(appInfoDescFormat, titleDescription); Drawable icon = isStackTask 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 e8ffb9150da7..5e78b61e021c 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java @@ -449,7 +449,8 @@ public class RecentsTaskLoader { * Returns the cached task content description if the task key is not expired, updating the * cache if it is. */ - String getAndUpdateContentDescription(Task.TaskKey taskKey, Resources res) { + String getAndUpdateContentDescription(Task.TaskKey taskKey, ActivityManager.TaskDescription td, + Resources res) { SystemServicesProxy ssp = Recents.getSystemServices(); // Return the cached content description if it exists @@ -461,8 +462,15 @@ public class RecentsTaskLoader { // All short paths failed, load the label from the activity info and cache it ActivityInfo activityInfo = getAndUpdateActivityInfo(taskKey); if (activityInfo != null) { - label = ssp.getBadgedContentDescription(activityInfo, taskKey.userId, res); - mContentDescriptionCache.put(taskKey, label); + label = ssp.getBadgedContentDescription(activityInfo, taskKey.userId, td, res); + if (td == null) { + // Only add to the cache if the task description is null, otherwise, it is possible + // for the task description to change between calls without the last active time + // changing (ie. between preloading and Overview starting) which would lead to stale + // content descriptions + // TODO: Investigate improving this + mContentDescriptionCache.put(taskKey, label); + } return label; } // If the content description does not exist, return an empty label for now, but do not |