From 93fe39ef92f1ca0440a583e3931252cfb96de425 Mon Sep 17 00:00:00 2001 From: Weilin Xu Date: Thu, 29 Sep 2022 18:35:50 +0000 Subject: [PATCH] Fix secondary ids comparison in strictEquals Since the comparator of identifer is not implemented, secondary ids cannot be sorted in ProgramSelector constructor. Two secondary id arrays should be compared using list in strictEquals method. Bug: 249616039 Test: atest ProgramSelectorTest# strictEquals_withDifferentSecondaryIdsOrders_returnsTrue Change-Id: I2460c4399ff8564b638254f71e9d7c883868854a --- core/java/android/hardware/radio/ProgramSelector.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/java/android/hardware/radio/ProgramSelector.java b/core/java/android/hardware/radio/ProgramSelector.java index a13eadaefe5a1..36ac1a0cb21ca 100644 --- a/core/java/android/hardware/radio/ProgramSelector.java +++ b/core/java/android/hardware/radio/ProgramSelector.java @@ -279,7 +279,6 @@ public final class ProgramSelector implements Parcelable { mPrimaryId = Objects.requireNonNull(primaryId); mSecondaryIds = secondaryIds; mVendorIds = vendorIds; - Arrays.sort(mSecondaryIds); } /** @@ -525,7 +524,9 @@ public final class ProgramSelector implements Parcelable { // vendorIds are ignored for equality // programType can be inferred from primaryId, thus not checked return mPrimaryId.equals(other.getPrimaryId()) - && Arrays.equals(mSecondaryIds, other.mSecondaryIds); + && mSecondaryIds.length == other.mSecondaryIds.length + && Arrays.asList(mSecondaryIds).containsAll( + Arrays.asList(other.mSecondaryIds)); } private ProgramSelector(Parcel in) {