diff options
author | Copybara <no-reply@google.com> | 2019-10-22 14:27:15 -0700 |
---|---|---|
committer | Nick Chalko <nchalko@google.com> | 2019-10-22 21:38:32 +0000 |
commit | 9feba05d3c0d814fb54108d9dd73895fd3bb208a (patch) | |
tree | 8a0843aa63db56a97e08ed8764ff15e1b811cc54 /src/com | |
parent | b1e39c3db6beabef52ecad18cde3c835555aeb6d (diff) | |
download | TV-9feba05d3c0d814fb54108d9dd73895fd3bb208a.tar.gz |
Test TvTrackInfoUtils on all relevant SDKs
PiperOrigin-RevId: 276143809
Change-Id: I46c8f959abfc1928728ae8017cb239694b403b6d
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/tv/util/TvTrackInfoUtils.java | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/src/com/android/tv/util/TvTrackInfoUtils.java b/src/com/android/tv/util/TvTrackInfoUtils.java index 8ae0e2b6..ae30df11 100644 --- a/src/com/android/tv/util/TvTrackInfoUtils.java +++ b/src/com/android/tv/util/TvTrackInfoUtils.java @@ -21,7 +21,9 @@ import android.os.Build; import android.os.LocaleList; import android.text.TextUtils; import android.util.Log; + import com.android.tv.R; + import com.google.common.collect.Iterables; import java.util.ArrayList; @@ -44,12 +46,12 @@ public class TvTrackInfoUtils { /** * Compares how closely two {@link android.media.tv.TvTrackInfo}s match {@code languages}, - * {@code channelCount} and {@code id} in that precedence. A listed sorted with this - * comparator has the worst matches first. + * {@code channelCount} and {@code id} in that precedence. A listed sorted with this comparator + * has the worst matches first. * * @param id The track id to match. * @param languages The prioritized list of languages. Languages earlier in the list are a - * better match. + * better match. * @param channelCount The channel count to match. * @return -1 if lhs is a worse match, 0 if lhs and rhs match equally and 1 if lhs is a better * match. @@ -69,13 +71,13 @@ public class TvTrackInfoUtils { // Find the first language that matches the lhs and rhs tracks. The earlier match is // better. If there is no match set the index to the size of the language list since // its the worst match. - int lhsLangIndex = Iterables - .indexOf(languages, s -> Utils.isEqualLanguage(lhs.getLanguage(), s)); + int lhsLangIndex = + Iterables.indexOf(languages, s -> Utils.isEqualLanguage(lhs.getLanguage(), s)); if (lhsLangIndex == -1) { lhsLangIndex = languages.size(); } - int rhsLangIndex = Iterables - .indexOf(languages, s -> Utils.isEqualLanguage(rhs.getLanguage(), s)); + int rhsLangIndex = + Iterables.indexOf(languages, s -> Utils.isEqualLanguage(rhs.getLanguage(), s)); if (rhsLangIndex == -1) { rhsLangIndex = languages.size(); } @@ -157,11 +159,7 @@ public class TvTrackInfoUtils { if (!TextUtils.isEmpty(track.getLanguage())) { language = new Locale(track.getLanguage()).getDisplayName(); } else { - Log.d( - TAG, - "No language information found for the audio track: " - + toString(track) - ); + Log.d(TAG, "No language information found for the audio track: " + toString(track)); } StringBuilder metadata = new StringBuilder(); @@ -236,31 +234,31 @@ public class TvTrackInfoUtils { 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()) : "") - + "}"; + + "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() {} |