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

Commit 2843b7e2 authored by Kyeongkab.Nam's avatar Kyeongkab.Nam Committed by Henry Fang
Browse files

Add encryption information to TvTrackInfo

Add TIF API for getting encryption status of each tracks in order for
TV App to use it.

Test: build
Bug: 112835103
Change-Id: I3065358d20d17c688e3349140b44d443fc34965d
parent d22ba181
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -26786,6 +26786,7 @@ package android.media.tv {
    method public int getVideoHeight();
    method public float getVideoPixelAspectRatio();
    method public int getVideoWidth();
    method public boolean isEncrypted();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.media.tv.TvTrackInfo> CREATOR;
    field public static final int TYPE_AUDIO = 0; // 0x0
@@ -26799,6 +26800,7 @@ package android.media.tv {
    method public android.media.tv.TvTrackInfo.Builder setAudioChannelCount(int);
    method public android.media.tv.TvTrackInfo.Builder setAudioSampleRate(int);
    method public android.media.tv.TvTrackInfo.Builder setDescription(CharSequence);
    method public android.media.tv.TvTrackInfo.Builder setEncrypted(boolean);
    method public android.media.tv.TvTrackInfo.Builder setExtra(android.os.Bundle);
    method public android.media.tv.TvTrackInfo.Builder setLanguage(String);
    method public android.media.tv.TvTrackInfo.Builder setVideoActiveFormatDescription(byte);
+37 −6
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ public final class TvTrackInfo implements Parcelable {
    private final String mId;
    private final String mLanguage;
    private final CharSequence mDescription;
    private final boolean mEncrypted;
    private final int mAudioChannelCount;
    private final int mAudioSampleRate;
    private final int mVideoWidth;
@@ -69,13 +70,14 @@ public final class TvTrackInfo implements Parcelable {
    private final Bundle mExtra;

    private TvTrackInfo(int type, String id, String language, CharSequence description,
            int audioChannelCount, int audioSampleRate, int videoWidth, int videoHeight,
            float videoFrameRate, float videoPixelAspectRatio, byte videoActiveFormatDescription,
            Bundle extra) {
            boolean encrypted, int audioChannelCount, int audioSampleRate, int videoWidth,
            int videoHeight, float videoFrameRate, float videoPixelAspectRatio,
            byte videoActiveFormatDescription, Bundle extra) {
        mType = type;
        mId = id;
        mLanguage = language;
        mDescription = description;
        mEncrypted = encrypted;
        mAudioChannelCount = audioChannelCount;
        mAudioSampleRate = audioSampleRate;
        mVideoWidth = videoWidth;
@@ -91,6 +93,7 @@ public final class TvTrackInfo implements Parcelable {
        mId = in.readString();
        mLanguage = in.readString();
        mDescription = in.readString();
        mEncrypted = in.readInt() != 0;
        mAudioChannelCount = in.readInt();
        mAudioSampleRate = in.readInt();
        mVideoWidth = in.readInt();
@@ -132,6 +135,18 @@ public final class TvTrackInfo implements Parcelable {
        return mDescription;
    }

    /**
     * Returns {@code true} if the track is encrypted, {@code false} otherwise. If the encryption
     * status is unknown or could not be determined, the corresponding value will be {@code false}.
     *
     * <p>For example: ISO/IEC 13818-1 defines a CA descriptor that can be used to determine the
     * encryption status of some broadcast streams.
     */

    public boolean isEncrypted() {
        return mEncrypted;
    }

    /**
     * Returns the audio channel count. Valid only for {@link #TYPE_AUDIO} tracks.
     *
@@ -248,6 +263,7 @@ public final class TvTrackInfo implements Parcelable {
        dest.writeString(mId);
        dest.writeString(mLanguage);
        dest.writeString(mDescription != null ? mDescription.toString() : null);
        dest.writeInt(mEncrypted ? 1 : 0);
        dest.writeInt(mAudioChannelCount);
        dest.writeInt(mAudioSampleRate);
        dest.writeInt(mVideoWidth);
@@ -273,6 +289,7 @@ public final class TvTrackInfo implements Parcelable {
                && mType == obj.mType
                && TextUtils.equals(mLanguage, obj.mLanguage)
                && TextUtils.equals(mDescription, obj.mDescription)
                && mEncrypted == obj.mEncrypted
                && Objects.equals(mExtra, obj.mExtra)
                && (mType == TYPE_AUDIO
                        ? mAudioChannelCount == obj.mAudioChannelCount
@@ -310,6 +327,7 @@ public final class TvTrackInfo implements Parcelable {
        private final int mType;
        private String mLanguage;
        private CharSequence mDescription;
        private boolean mEncrypted;
        private int mAudioChannelCount;
        private int mAudioSampleRate;
        private int mVideoWidth;
@@ -360,6 +378,19 @@ public final class TvTrackInfo implements Parcelable {
            return this;
        }

        /**
         * Sets the encryption status of the track.
         *
         * <p>For example: ISO/IEC 13818-1 defines a CA descriptor that can be used to determine the
         * encryption status of some broadcast streams.
         *
         * @param encrypted The encryption status of the track.
         */
        public Builder setEncrypted(boolean encrypted) {
            mEncrypted = encrypted;
            return this;
        }

        /**
         * Sets the audio channel count. Valid only for {@link #TYPE_AUDIO} tracks.
         *
@@ -490,9 +521,9 @@ public final class TvTrackInfo implements Parcelable {
         * @return The new {@link TvTrackInfo} instance
         */
        public TvTrackInfo build() {
            return new TvTrackInfo(mType, mId, mLanguage, mDescription, mAudioChannelCount,
                    mAudioSampleRate, mVideoWidth, mVideoHeight, mVideoFrameRate,
                    mVideoPixelAspectRatio, mVideoActiveFormatDescription, mExtra);
            return new TvTrackInfo(mType, mId, mLanguage, mDescription, mEncrypted,
                    mAudioChannelCount, mAudioSampleRate, mVideoWidth, mVideoHeight,
                    mVideoFrameRate, mVideoPixelAspectRatio, mVideoActiveFormatDescription, mExtra);
        }
    }
}