Do not show the input icon when it's not available.
Bug: 17335230
Change-Id: Icb84949ed55f22bb384df9ed4bbfe3d86949c301
diff --git a/media/java/android/media/tv/TvInputInfo.java b/media/java/android/media/tv/TvInputInfo.java
index 00183bb..46b8871 100644
--- a/media/java/android/media/tv/TvInputInfo.java
+++ b/media/java/android/media/tv/TvInputInfo.java
@@ -416,23 +416,22 @@
* Loads the user-displayed icon for this TV input.
*
* @param context Supplies a {@link Context} used to load the icon.
- * @return a Drawable containing the TV input's icon. If the TV input does not have
- * an icon, application icon is returned. If it's unavailable too, system default is
- * returned.
+ * @return a Drawable containing the TV input's icon. If the TV input does not have an icon,
+ * application's icon is returned. If it's unavailable too, {@code null} is returned.
*/
public Drawable loadIcon(Context context) {
if (mIconUri == null) {
- return loadDefaultIcon(context);
+ return loadServiceIcon(context);
}
try (InputStream is = context.getContentResolver().openInputStream(mIconUri)) {
Drawable drawable = Drawable.createFromStream(is, null);
if (drawable == null) {
- return loadDefaultIcon(context);
+ return loadServiceIcon(context);
}
return drawable;
} catch (IOException e) {
Log.w(TAG, "Loading the default icon due to a failure on loading " + mIconUri, e);
- return loadDefaultIcon(context);
+ return loadServiceIcon(context);
}
}
@@ -486,7 +485,11 @@
dest.writeByte(mIsConnectedToHdmiSwitch ? (byte) 1 : 0);
}
- private Drawable loadDefaultIcon(Context context) {
+ private Drawable loadServiceIcon(Context context) {
+ if (mService.serviceInfo.icon == 0
+ && mService.serviceInfo.applicationInfo.icon == 0) {
+ return null;
+ }
return mService.serviceInfo.loadIcon(context.getPackageManager());
}