am b3412adf: Merge "TvContract: Add channel logo and program thumbnail" into lmp-preview-dev
* commit 'b3412adf92b9d932b600acf44c4463cf06387a8e':
TvContract: Add channel logo and program thumbnail
diff --git a/api/current.txt b/api/current.txt
index 4d427b6..bfd4d17 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15950,6 +15950,8 @@
package android.media.tv {
public final class TvContract {
+ method public static final android.net.Uri buildChannelLogoUri(long);
+ method public static final android.net.Uri buildChannelLogoUri(android.net.Uri);
method public static final android.net.Uri buildChannelUri(long);
method public static final android.net.Uri buildChannelsUriForInput(android.content.ComponentName);
method public static final android.net.Uri buildChannelsUriForInput(android.content.ComponentName, boolean);
@@ -16007,6 +16009,10 @@
field public static final int TYPE_T_DMB = 393216; // 0x60000
}
+ public static final class TvContract.Channels.Logo {
+ field public static final java.lang.String CONTENT_DIRECTORY = "logo";
+ }
+
public static final class TvContract.Programs implements android.media.tv.TvContract.BaseTvColumns {
field public static final java.lang.String COLUMN_AUDIO_LANGUAGE = "audio_language";
field public static final java.lang.String COLUMN_BROADCAST_GENRE = "broadcast_genre";
@@ -16015,8 +16021,10 @@
field public static final java.lang.String COLUMN_END_TIME_UTC_MILLIS = "end_time_utc_millis";
field public static final java.lang.String COLUMN_INTERNAL_PROVIDER_DATA = "internal_provider_data";
field public static final java.lang.String COLUMN_LONG_DESCRIPTION = "long_description";
+ field public static final java.lang.String COLUMN_POSTER_ART_URI = "poster_art_uri";
field public static final java.lang.String COLUMN_SHORT_DESCRIPTION = "short_description";
field public static final java.lang.String COLUMN_START_TIME_UTC_MILLIS = "start_time_utc_millis";
+ field public static final java.lang.String COLUMN_THUMBNAIL_URI = "thumbnail_uri";
field public static final java.lang.String COLUMN_TITLE = "title";
field public static final java.lang.String COLUMN_VERSION_NUMBER = "version_number";
field public static final java.lang.String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/program";
diff --git a/media/java/android/media/tv/TvContract.java b/media/java/android/media/tv/TvContract.java
index 6e0586e..5e650c2 100644
--- a/media/java/android/media/tv/TvContract.java
+++ b/media/java/android/media/tv/TvContract.java
@@ -86,6 +86,27 @@
}
/**
+ * Builds a URI that points to a channel logo. See {@link Channels.Logo}.
+ *
+ * @param channelId The ID of the channel whose logo is pointed to.
+ */
+ public static final Uri buildChannelLogoUri(long channelId) {
+ return buildChannelLogoUri(buildChannelUri(channelId));
+ }
+
+ /**
+ * Builds a URI that points to a channel logo. See {@link Channels.Logo}.
+ *
+ * @param channelUri The URI of the channel whose logo is pointed to.
+ */
+ public static final Uri buildChannelLogoUri(Uri channelUri) {
+ if (!PATH_CHANNEL.equals(channelUri.getPathSegments().get(0))) {
+ throw new IllegalArgumentException("Not a channel: " + channelUri);
+ }
+ return Uri.withAppendedPath(channelUri, Channels.Logo.CONTENT_DIRECTORY);
+ }
+
+ /**
* Builds a URI that points to all browsable channels from a given TV input.
*
* @param name {@link ComponentName} of the {@link android.media.tv.TvInputService} that
@@ -523,6 +544,48 @@
public static final String COLUMN_VERSION_NUMBER = "version_number";
private Channels() {}
+
+ /**
+ * A sub-directory of a single TV channel that represents its primary logo.
+ * <p>
+ * To access this directory, append {@link Channels.Logo#CONTENT_DIRECTORY} to the raw
+ * channel URI. The resulting URI represents an image file, and should be interacted
+ * using ContentResolver.openAssetFileDescriptor.
+ * </p>
+ * <p>
+ * Note that this sub-directory also supports opening the logo as an asset file in write
+ * mode. Callers can create or replace the primary logo associated with this channel by
+ * opening the asset file and writing the full-size photo contents into it. When the file
+ * is closed, the image will be parsed, sized down if necessary, and stored.
+ * </p>
+ * <p>
+ * Usage example:
+ * <pre>
+ * public void writeChannelLogo(long channelId, byte[] logo) {
+ * Uri channelLogoUri = TvContract.buildChannelLogoUri(channelId);
+ * try {
+ * AssetFileDescriptor fd =
+ * getContentResolver().openAssetFileDescriptor(channelLogoUri, "rw");
+ * OutputStream os = fd.createOutputStream();
+ * os.write(logo);
+ * os.close();
+ * fd.close();
+ * } catch (IOException e) {
+ * // Handle error cases.
+ * }
+ * }
+ * </pre>
+ * </p>
+ */
+ public static final class Logo {
+
+ /**
+ * The directory twig for this sub-table.
+ */
+ public static final String CONTENT_DIRECTORY = "logo";
+
+ private Logo() {}
+ }
}
/** Column definitions for the TV programs table. */
@@ -631,6 +694,26 @@
public static final String COLUMN_AUDIO_LANGUAGE = "audio_language";
/**
+ * The URI for the poster art of this TV program.
+ * <p>
+ * Can be empty.
+ * </p><p>
+ * Type: TEXT
+ * </p>
+ */
+ public static final String COLUMN_POSTER_ART_URI = "poster_art_uri";
+
+ /**
+ * The URI for the thumbnail of this TV program.
+ * <p>
+ * Can be empty.
+ * </p><p>
+ * Type: TEXT
+ * </p>
+ */
+ public static final String COLUMN_THUMBNAIL_URI = "thumbnail_uri";
+
+ /**
* Internal data used by individual TV input services.
* <p>
* This is internal to the provider that inserted it, and should not be decoded by other