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

Commit e72ec3e2 authored by Shubang Lu's avatar Shubang Lu Committed by android-build-merger
Browse files

Merge "TIF: Add equals() and hashCode() for comparisons" into nyc-dev am: e346335d

am: 009f5cd5

* commit '009f5cd5':
  TIF: Add equals() and hashCode() for comparisons

Change-Id: Ie53bfacfcb481171d6ceed8f50134cef6d1481a5
parents b412bfd7 009f5cd5
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -20,9 +20,12 @@ import android.annotation.NonNull;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.android.internal.util.Preconditions;

import java.util.Objects;

/**
 * Encapsulates the format of tracks played in {@link TvInputService}.
 */
@@ -245,6 +248,37 @@ public final class TvTrackInfo implements Parcelable {
        dest.writeBundle(mExtra);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
          return true;
        }

        if (!(o instanceof TvTrackInfo)) {
          return false;
        }

        TvTrackInfo obj = (TvTrackInfo) o;
        return TextUtils.equals(mId, obj.mId)
                && mType == obj.mType
                && TextUtils.equals(mLanguage, obj.mLanguage)
                && TextUtils.equals(mDescription, obj.mDescription)
                && Objects.equals(mExtra, obj.mExtra)
                && (mType == TYPE_AUDIO
                        ? mAudioChannelCount == obj.mAudioChannelCount
                        && mAudioSampleRate == obj.mAudioSampleRate
                        : (mType == TYPE_VIDEO
                                ? mVideoWidth == obj.mVideoWidth
                                && mVideoHeight == obj.mVideoHeight
                                && mVideoFrameRate == obj.mVideoFrameRate
                                && mVideoPixelAspectRatio == obj.mVideoPixelAspectRatio : true));
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(mId);
    }

    public static final Parcelable.Creator<TvTrackInfo> CREATOR =
            new Parcelable.Creator<TvTrackInfo>() {
                @Override