Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc15afbe authored by Ji-Hwan Lee's avatar Ji-Hwan Lee Committed by Android (Google) Code Review
Browse files

Merge "TvContract: Add channel logo and program thumbnail" into lmp-preview-dev

parents 66c11e1f 4c1959cc
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -15824,6 +15824,8 @@ package android.media.session {
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);
@@ -15881,6 +15883,10 @@ package android.media.tv {
    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";
@@ -15889,8 +15895,10 @@ package android.media.tv {
    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";
+83 −0
Original line number Diff line number Diff line
@@ -85,6 +85,27 @@ public final class TvContract {
        return ContentUris.withAppendedId(Channels.CONTENT_URI, channelId);
    }

    /**
     * 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.
     *
@@ -523,6 +544,48 @@ public final class TvContract {
        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. */
@@ -630,6 +693,26 @@ public final class TvContract {
         */
        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>