Loading media/java/android/media/tv/TvInputManager.java +15 −3 Original line number Original line Diff line number Diff line Loading @@ -1170,16 +1170,19 @@ public final class TvInputManager { */ */ public void selectTrack(int type, String trackId) { public void selectTrack(int type, String trackId) { if (type == TvTrackInfo.TYPE_AUDIO) { if (type == TvTrackInfo.TYPE_AUDIO) { if (trackId != null && !mAudioTracks.contains(trackId)) { if (trackId != null && !containsTrack(mAudioTracks, trackId)) { Log.w(TAG, "Invalid audio trackId: " + trackId); Log.w(TAG, "Invalid audio trackId: " + trackId); return; } } } else if (type == TvTrackInfo.TYPE_VIDEO) { } else if (type == TvTrackInfo.TYPE_VIDEO) { if (trackId != null && !mVideoTracks.contains(trackId)) { if (trackId != null && !containsTrack(mVideoTracks, trackId)) { Log.w(TAG, "Invalid video trackId: " + trackId); Log.w(TAG, "Invalid video trackId: " + trackId); return; } } } else if (type == TvTrackInfo.TYPE_SUBTITLE) { } else if (type == TvTrackInfo.TYPE_SUBTITLE) { if (trackId != null && !mSubtitleTracks.contains(trackId)) { if (trackId != null && !containsTrack(mSubtitleTracks, trackId)) { Log.w(TAG, "Invalid subtitle trackId: " + trackId); Log.w(TAG, "Invalid subtitle trackId: " + trackId); return; } } } else { } else { throw new IllegalArgumentException("invalid type: " + type); throw new IllegalArgumentException("invalid type: " + type); Loading @@ -1195,6 +1198,15 @@ public final class TvInputManager { } } } } private boolean containsTrack(List<TvTrackInfo> tracks, String trackId) { for (TvTrackInfo track : tracks) { if (track.getId().equals(trackId)) { return true; } } return false; } /** /** * Returns the list of tracks for a given type. Returns {@code null} if the information is * Returns the list of tracks for a given type. Returns {@code null} if the information is * not available. * not available. Loading Loading
media/java/android/media/tv/TvInputManager.java +15 −3 Original line number Original line Diff line number Diff line Loading @@ -1170,16 +1170,19 @@ public final class TvInputManager { */ */ public void selectTrack(int type, String trackId) { public void selectTrack(int type, String trackId) { if (type == TvTrackInfo.TYPE_AUDIO) { if (type == TvTrackInfo.TYPE_AUDIO) { if (trackId != null && !mAudioTracks.contains(trackId)) { if (trackId != null && !containsTrack(mAudioTracks, trackId)) { Log.w(TAG, "Invalid audio trackId: " + trackId); Log.w(TAG, "Invalid audio trackId: " + trackId); return; } } } else if (type == TvTrackInfo.TYPE_VIDEO) { } else if (type == TvTrackInfo.TYPE_VIDEO) { if (trackId != null && !mVideoTracks.contains(trackId)) { if (trackId != null && !containsTrack(mVideoTracks, trackId)) { Log.w(TAG, "Invalid video trackId: " + trackId); Log.w(TAG, "Invalid video trackId: " + trackId); return; } } } else if (type == TvTrackInfo.TYPE_SUBTITLE) { } else if (type == TvTrackInfo.TYPE_SUBTITLE) { if (trackId != null && !mSubtitleTracks.contains(trackId)) { if (trackId != null && !containsTrack(mSubtitleTracks, trackId)) { Log.w(TAG, "Invalid subtitle trackId: " + trackId); Log.w(TAG, "Invalid subtitle trackId: " + trackId); return; } } } else { } else { throw new IllegalArgumentException("invalid type: " + type); throw new IllegalArgumentException("invalid type: " + type); Loading @@ -1195,6 +1198,15 @@ public final class TvInputManager { } } } } private boolean containsTrack(List<TvTrackInfo> tracks, String trackId) { for (TvTrackInfo track : tracks) { if (track.getId().equals(trackId)) { return true; } } return false; } /** /** * Returns the list of tracks for a given type. Returns {@code null} if the information is * Returns the list of tracks for a given type. Returns {@code null} if the information is * not available. * not available. Loading