summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Weilin Xu <xuweilin@google.com> 2022-05-09 20:34:14 +0000
committer Weilin Xu <xuweilin@google.com> 2022-05-17 22:15:22 +0000
commit8f19a21592b348fb4637d62f88d6a4c0c150542c (patch)
treeed062af61e7c88e7bd7404bcac96966220cee119
parent83d956682fbed71909d250b0ab2bbd41fba4aaef (diff)
Add secondaryId comparison for ProgramInfo
Add a hidden method stricEqual for ProgramSelector so that its secondaryId can be compared when checking ProgramInfo equality. Bug: 189775075 Test: m -j, atest android.hardware.radio.tests.functional Test: atest com.android.server.broadcastradio.hal2 Change-Id: Ia9a297f946f295ea0c5e1d0efbb4ccae55c01b6f
-rw-r--r--core/java/android/hardware/radio/ProgramSelector.java13
-rw-r--r--core/java/android/hardware/radio/RadioManager.java2
2 files changed, 14 insertions, 1 deletions
diff --git a/core/java/android/hardware/radio/ProgramSelector.java b/core/java/android/hardware/radio/ProgramSelector.java
index d525753a1874..6300a12c3137 100644
--- a/core/java/android/hardware/radio/ProgramSelector.java
+++ b/core/java/android/hardware/radio/ProgramSelector.java
@@ -279,6 +279,7 @@ public final class ProgramSelector implements Parcelable {
mPrimaryId = Objects.requireNonNull(primaryId);
mSecondaryIds = secondaryIds;
mVendorIds = vendorIds;
+ Arrays.sort(mSecondaryIds);
}
/**
@@ -512,10 +513,22 @@ public final class ProgramSelector implements Parcelable {
return mPrimaryId.equals(other.getPrimaryId());
}
+ /** @hide */
+ public boolean strictEquals(@Nullable Object obj) {
+ if (this == obj) return true;
+ if (!(obj instanceof ProgramSelector)) return false;
+ ProgramSelector other = (ProgramSelector) obj;
+ // vendorIds are ignored for equality
+ // programType can be inferred from primaryId, thus not checked
+ return mPrimaryId.equals(other.getPrimaryId())
+ && Arrays.equals(mSecondaryIds, other.mSecondaryIds);
+ }
+
private ProgramSelector(Parcel in) {
mProgramType = in.readInt();
mPrimaryId = in.readTypedObject(Identifier.CREATOR);
mSecondaryIds = in.createTypedArray(Identifier.CREATOR);
+ Arrays.sort(mSecondaryIds);
if (Stream.of(mSecondaryIds).anyMatch(id -> id == null)) {
throw new IllegalArgumentException("secondaryIds list must not contain nulls");
}
diff --git a/core/java/android/hardware/radio/RadioManager.java b/core/java/android/hardware/radio/RadioManager.java
index 4cc001a40146..8180caa1557b 100644
--- a/core/java/android/hardware/radio/RadioManager.java
+++ b/core/java/android/hardware/radio/RadioManager.java
@@ -1690,7 +1690,7 @@ public class RadioManager {
if (!(obj instanceof ProgramInfo)) return false;
ProgramInfo other = (ProgramInfo) obj;
- if (!Objects.equals(mSelector, other.mSelector)) return false;
+ if (!mSelector.strictEquals(other.mSelector)) return false;
if (!Objects.equals(mLogicallyTunedTo, other.mLogicallyTunedTo)) return false;
if (!Objects.equals(mPhysicallyTunedTo, other.mPhysicallyTunedTo)) return false;
if (!Objects.equals(mRelatedContent, other.mRelatedContent)) return false;