diff options
author | Live Channels Team <no-reply@google.com> | 2018-04-27 15:11:09 -0700 |
---|---|---|
committer | Nick Chalko <nchalko@google.com> | 2018-05-16 15:56:06 -0700 |
commit | 2148c3c2fd5b4b4fb6723d02c35b04c7da2e1315 (patch) | |
tree | b60123b75578f7662bb5916855c6b0b6d2797a63 | |
parent | 0b389cbec4b66034a0391cb651c0a26781bf4f04 (diff) | |
download | TV-2148c3c2fd5b4b4fb6723d02c35b04c7da2e1315.tar.gz |
FIX: Print TvTrackInfo toString instead of its identity.
PiperOrigin-RevId: 194600111
Change-Id: Ib9cfa96fe2d9f10883a1cff89c9064a126772d3a
-rw-r--r-- | src/com/android/tv/util/TvTrackInfoUtils.java | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/src/com/android/tv/util/TvTrackInfoUtils.java b/src/com/android/tv/util/TvTrackInfoUtils.java index 0eeb8894..4ec96c62 100644 --- a/src/com/android/tv/util/TvTrackInfoUtils.java +++ b/src/com/android/tv/util/TvTrackInfoUtils.java @@ -122,13 +122,17 @@ public class TvTrackInfoUtils { public static String getMultiAudioString( Context context, TvTrackInfo track, boolean showSampleRate) { if (track.getType() != TvTrackInfo.TYPE_AUDIO) { - throw new IllegalArgumentException("Not an audio track: " + track); + throw new IllegalArgumentException("Not an audio track: " + toString(track)); } String language = context.getString(R.string.multi_audio_unknown_language); if (!TextUtils.isEmpty(track.getLanguage())) { language = new Locale(track.getLanguage()).getDisplayName(); } else { - Log.d(TAG, "No language information found for the audio track: " + track); + Log.d( + TAG, + "No language information found for the audio track: " + + toString(track) + ); } StringBuilder metadata = new StringBuilder(); @@ -159,7 +163,7 @@ public class TvTrackInfoUtils { "Invalid audio channel count (" + track.getAudioChannelCount() + ") found for the audio track: " - + track); + + toString(track)); } break; } @@ -187,5 +191,48 @@ public class TvTrackInfoUtils { R.string.multi_audio_display_string_with_channel, language, metadata.toString()); } + private static String trackTypeToString(int trackType) { + switch (trackType) { + case TvTrackInfo.TYPE_AUDIO: + return "Audio"; + case TvTrackInfo.TYPE_VIDEO: + return "Video"; + case TvTrackInfo.TYPE_SUBTITLE: + return "Subtitle"; + default: + return "Invalid Type"; + } + } + + public static String toString(TvTrackInfo info) { + int trackType = info.getType(); + return "TvTrackInfo{" + + "type=" + + trackTypeToString(trackType) + + ", id=" + + info.getId() + + ", language=" + + info.getLanguage() + + ", description=" + + info.getDescription() + + (trackType == TvTrackInfo.TYPE_AUDIO + ? + (", audioChannelCount=" + + info.getAudioChannelCount() + + ", audioSampleRate=" + + info.getAudioSampleRate()) : "") + + (trackType == TvTrackInfo.TYPE_VIDEO + ? + (", videoWidth=" + + info.getVideoWidth() + + ", videoHeight=" + + info.getVideoHeight() + + ", videoFrameRate=" + + info.getVideoFrameRate() + + ", videoPixelAspectRatio=" + + info.getVideoPixelAspectRatio()) : "") + + "}"; + } + private TvTrackInfoUtils() {} } |