From 62eb722726460ff0b084b8a78a3f07ac62478121 Mon Sep 17 00:00:00 2001 From: randypfohl Date: Thu, 8 Jun 2023 15:24:17 -0700 Subject: [PATCH] Updating content description of taskview after latest update Description: we wait for icon updates to receive the title of the task. However we still set the description immediately upon digitalwellbeingtoast creation. this creates a null set for contentDescription resulting in incorrect talkbalk. This will listen for icon updates and will reiniitialize the toast ensuring taskview is set properly. Test: built and tested locally with talk back ensuring the titles are being set correctly Bug: 280908761 Change-Id: I946e7190114cbdccb75883965b1fdf85ed6ad17a --- .../quickstep/views/DigitalWellBeingToast.java | 15 ++++++++++++--- .../src/com/android/quickstep/views/TaskView.java | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java index 7cd6756362..3e79eaf8cc 100644 --- a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java +++ b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java @@ -92,6 +92,8 @@ public final class DigitalWellBeingToast { private Task mTask; private boolean mHasLimit; + + private long mAppUsageLimitTimeMs; private long mAppRemainingTimeMs; @Nullable private View mBanner; @@ -113,10 +115,12 @@ public final class DigitalWellBeingToast { mHasLimit = false; mTaskView.setContentDescription(mTask.titleDescription); replaceBanner(null); - mAppRemainingTimeMs = 0; + mAppUsageLimitTimeMs = -1; + mAppRemainingTimeMs = -1; } private void setLimit(long appUsageLimitTimeMs, long appRemainingTimeMs) { + mAppUsageLimitTimeMs = appUsageLimitTimeMs; mAppRemainingTimeMs = appRemainingTimeMs; mHasLimit = true; TextView toast = mActivity.getViewCache().getView(R.layout.digital_wellbeing_toast, @@ -138,11 +142,12 @@ public final class DigitalWellBeingToast { } public void initialize(Task task) { + mAppUsageLimitTimeMs = mAppRemainingTimeMs = -1; mTask = task; THREAD_POOL_EXECUTOR.execute(() -> { final AppUsageLimit usageLimit = mLauncherApps.getAppUsageLimit( - task.getTopComponent().getPackageName(), - UserHandle.of(task.key.userId)); + mTask.getTopComponent().getPackageName(), + UserHandle.of(mTask.key.userId)); final long appUsageLimitTimeMs = usageLimit != null ? usageLimit.getTotalUsageLimit() : -1; @@ -275,6 +280,10 @@ public final class DigitalWellBeingToast { } } + public String getContentDescription() { + return getContentDescriptionForTask(mTask, mAppUsageLimitTimeMs, mAppRemainingTimeMs); + } + private String getContentDescriptionForTask( Task task, long appUsageLimitTimeMs, long appRemainingTimeMs) { return appUsageLimitTimeMs >= 0 && appRemainingTimeMs >= 0 ? diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 6e7b6dce62..f71d0c1dd5 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -1342,6 +1342,7 @@ public class TaskView extends FrameLayout implements Reusable { protected void refreshTaskThumbnailSplash() { mSnapshotView.refreshSplashView(); + setContentDescription(mDigitalWellBeingToast.getContentDescription()); } private void setSplitSelectTranslationX(float x) {