Add badge content description to TargetInfo, use in ResolverActivity

Bug: 22667344
Change-Id: Iee241b9179c74a15b1c635cf90d2f96f6f7b31cd
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 6af2e8b..d9faece 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -517,6 +517,7 @@
         private final ResolveInfo mBackupResolveInfo;
         private final ChooserTarget mChooserTarget;
         private Drawable mBadgeIcon = null;
+        private CharSequence mBadgeContentDescription;
         private Drawable mDisplayIcon;
         private final Intent mFillInIntent;
         private final int mFillInFlags;
@@ -532,7 +533,9 @@
                 if (ri != null) {
                     final ActivityInfo ai = ri.activityInfo;
                     if (ai != null && ai.applicationInfo != null) {
-                        mBadgeIcon = getPackageManager().getApplicationIcon(ai.applicationInfo);
+                        final PackageManager pm = getPackageManager();
+                        mBadgeIcon = pm.getApplicationIcon(ai.applicationInfo);
+                        mBadgeContentDescription = pm.getApplicationLabel(ai.applicationInfo);
                     }
                 }
             }
@@ -555,6 +558,7 @@
             mBackupResolveInfo = other.mBackupResolveInfo;
             mChooserTarget = other.mChooserTarget;
             mBadgeIcon = other.mBadgeIcon;
+            mBadgeContentDescription = other.mBadgeContentDescription;
             mDisplayIcon = other.mDisplayIcon;
             mFillInIntent = fillInIntent;
             mFillInFlags = flags;
@@ -647,6 +651,11 @@
         }
 
         @Override
+        public CharSequence getBadgeContentDescription() {
+            return mBadgeContentDescription;
+        }
+
+        @Override
         public TargetInfo cloneFilledIn(Intent fillInIntent, int flags) {
             return new ChooserTargetInfo(this, fillInIntent, flags);
         }
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 89599e0..7dd3bed 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -932,6 +932,11 @@
         }
 
         @Override
+        public CharSequence getBadgeContentDescription() {
+            return null;
+        }
+
+        @Override
         public TargetInfo cloneFilledIn(Intent fillInIntent, int flags) {
             return new DisplayResolveInfo(this, fillInIntent, flags);
         }
@@ -1072,6 +1077,11 @@
         public Drawable getBadgeIcon();
 
         /**
+         * @return The content description for the badge icon
+         */
+        public CharSequence getBadgeContentDescription();
+
+        /**
          * Clone this target with the given fill-in information.
          */
         public TargetInfo cloneFilledIn(Intent fillInIntent, int flags);
@@ -1542,6 +1552,7 @@
                 final Drawable badge = info.getBadgeIcon();
                 if (badge != null) {
                     holder.badge.setImageDrawable(badge);
+                    holder.badge.setContentDescription(info.getBadgeContentDescription());
                     holder.badge.setVisibility(View.VISIBLE);
                 } else {
                     holder.badge.setVisibility(View.GONE);