From 363383206361ca9c84b65d87bd4ece2012663afa Mon Sep 17 00:00:00 2001 From: Sungsoo Lim Date: Mon, 1 Sep 2014 17:12:05 -0700 Subject: [PATCH] Do not show the input icon when it's not available. Bug: 17335230 Change-Id: Icb84949ed55f22bb384df9ed4bbfe3d86949c301 --- media/java/android/media/tv/TvInputInfo.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/media/java/android/media/tv/TvInputInfo.java b/media/java/android/media/tv/TvInputInfo.java index 00183bb9ac3e2..46b887195b7e6 100644 --- a/media/java/android/media/tv/TvInputInfo.java +++ b/media/java/android/media/tv/TvInputInfo.java @@ -416,23 +416,22 @@ public final class TvInputInfo implements Parcelable { * 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 @@ public final class TvInputInfo implements Parcelable { 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()); }