- If there is a task label with a provided task description, ensure that
it is used instead of the activity label when generating the content
description (the concatenation of the badged application name and
activity label.
- Also fix a case where content descriptions can go stale if they are
updated between first preloaded. Just don't cache the content
description if there is a task description.
Bug:
37417229
Test: Launch Play store, go to Overview
Change-Id: Ieeef9ecd93759c130dc66902f249783e7d218be7
* 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
// 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
* 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
// 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