diff --git a/api/current.txt b/api/current.txt index 0a053cb0a2ca6..fe636c9fa75ca 100644 --- a/api/current.txt +++ b/api/current.txt @@ -15795,7 +15795,9 @@ package android.media.tv { method public static final android.net.Uri buildChannelsUriForInput(android.content.ComponentName); method public static final android.net.Uri buildChannelsUriForInput(android.content.ComponentName, boolean); method public static final android.net.Uri buildProgramUri(long); + method public static final android.net.Uri buildProgramsUriForChannel(long); method public static final android.net.Uri buildProgramsUriForChannel(android.net.Uri); + method public static final android.net.Uri buildProgramsUriForChannel(long, long, long); method public static final android.net.Uri buildProgramsUriForChannel(android.net.Uri, long, long); field public static final java.lang.String AUTHORITY = "android.media.tv"; } diff --git a/media/java/android/media/tv/TvContract.java b/media/java/android/media/tv/TvContract.java index 7ff2c2ea80604..3f0405d78a9e3 100644 --- a/media/java/android/media/tv/TvContract.java +++ b/media/java/android/media/tv/TvContract.java @@ -141,6 +141,17 @@ public final class TvContract { return ContentUris.withAppendedId(Programs.CONTENT_URI, programId); } + /** + * Builds a URI that points to all programs on a given channel. + * + * @param channelId The ID of the channel to return programs for. + */ + public static final Uri buildProgramsUriForChannel(long channelId) { + return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY) + .appendPath(PATH_CHANNEL).appendPath(String.valueOf(channelId)) + .appendPath(PATH_PROGRAM).build(); + } + /** * Builds a URI that points to all programs on a given channel. * @@ -150,9 +161,24 @@ public final class TvContract { if (!PATH_CHANNEL.equals(channelUri.getPathSegments().get(0))) { throw new IllegalArgumentException("Not a channel: " + channelUri); } - String channelId = String.valueOf(ContentUris.parseId(channelUri)); - return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY) - .appendPath(PATH_CHANNEL).appendPath(channelId).appendPath(PATH_PROGRAM).build(); + return buildProgramsUriForChannel(ContentUris.parseId(channelUri)); + } + + /** + * Builds a URI that points to programs on a specific channel whose schedules overlap with the + * given time frame. + * + * @param channelId The ID of the channel to return programs for. + * @param startTime The start time used to filter programs. The returned programs should have + * {@link Programs#COLUMN_END_TIME_UTC_MILLIS} that is greater than this time. + * @param endTime The end time used to filter programs. The returned programs should have + * {@link Programs#COLUMN_START_TIME_UTC_MILLIS} that is less than this time. + */ + public static final Uri buildProgramsUriForChannel(long channelId, long startTime, + long endTime) { + Uri uri = buildProgramsUriForChannel(channelId); + return uri.buildUpon().appendQueryParameter(PARAM_START_TIME, String.valueOf(startTime)) + .appendQueryParameter(PARAM_END_TIME, String.valueOf(endTime)).build(); } /** @@ -167,9 +193,10 @@ public final class TvContract { */ public static final Uri buildProgramsUriForChannel(Uri channelUri, long startTime, long endTime) { - Uri uri = buildProgramsUriForChannel(channelUri); - return uri.buildUpon().appendQueryParameter(PARAM_START_TIME, String.valueOf(startTime)) - .appendQueryParameter(PARAM_END_TIME, String.valueOf(endTime)).build(); + if (!PATH_CHANNEL.equals(channelUri.getPathSegments().get(0))) { + throw new IllegalArgumentException("Not a channel: " + channelUri); + } + return buildProgramsUriForChannel(ContentUris.parseId(channelUri), startTime, endTime); } /**