Do not show the input icon when it's not available.

Bug: 17335230
Change-Id: Icb84949ed55f22bb384df9ed4bbfe3d86949c301
This commit is contained in:
Sungsoo Lim
2014-09-01 17:12:05 -07:00
parent ec1bfea28e
commit 3633832063

View File

@@ -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());
}