Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed20f3a3 authored by Winson Chung's avatar Winson Chung
Browse files

Update Overview content descriptions.

- 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
parent 4b0d2bf7
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -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
+11 −3
Original line number Diff line number Diff line
@@ -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);
            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