Add equal overloads to some MediaDescription and MediaQueue objects (2/3)
Bug: 64686424
Test: Connect to carkit and see that NowPlayingChanged only gets sent when
the queue changes, run cts test
Change-Id: I58c9dd0bf976485a2efefd042cd667ee433e07e1
(cherry picked from commit 6edb68bea6)
This commit is contained in:
committed by
Myles Watson
parent
c3d3cf5666
commit
905d8ab843
@@ -219,6 +219,33 @@ public class MediaDescription implements Parcelable {
|
||||
dest.writeParcelable(mMediaUri, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(o instanceof MediaDescription)){
|
||||
return false;
|
||||
}
|
||||
|
||||
final MediaDescription d = (MediaDescription) o;
|
||||
|
||||
if (!String.valueOf(mTitle).equals(String.valueOf(d.mTitle))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!String.valueOf(mSubtitle).equals(String.valueOf(d.mSubtitle))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!String.valueOf(mDescription).equals(String.valueOf(d.mDescription))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return mTitle + ", " + mSubtitle + ", " + mDescription;
|
||||
|
||||
@@ -48,6 +48,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Allows interaction with media controllers, volume keys, media buttons, and
|
||||
@@ -1256,6 +1257,28 @@ public final class MediaSession {
|
||||
"Description=" + mDescription +
|
||||
", Id=" + mId + " }";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(o instanceof QueueItem)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final QueueItem item = (QueueItem) o;
|
||||
if (mId != item.mId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Objects.equals(mDescription, item.mDescription)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class Command {
|
||||
|
||||
Reference in New Issue
Block a user