From 3d749d67ae4ff2430b3ef36af840e70d63b12d30 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Thu, 3 Jun 2021 00:40:55 -0700 Subject: [PATCH] Override equals and hashCode methods for EpsBearerQosSessionAttributes and NrQosSessionAttributes Added equals and hashCode methods to simplify CTS tests Bug: 183239573 Bug: 184396753 Test: atest android.telephony.cts Change-Id: I545d940b3e77b40ef13e7ca0e5e7169b97e17f1e --- .../data/EpsBearerQosSessionAttributes.java | 20 ++++++++++++++++ .../data/NrQosSessionAttributes.java | 24 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/telephony/java/android/telephony/data/EpsBearerQosSessionAttributes.java b/telephony/java/android/telephony/data/EpsBearerQosSessionAttributes.java index 9bc7a5c6cf96c..fe4453081362a 100644 --- a/telephony/java/android/telephony/data/EpsBearerQosSessionAttributes.java +++ b/telephony/java/android/telephony/data/EpsBearerQosSessionAttributes.java @@ -206,6 +206,26 @@ public final class EpsBearerQosSessionAttributes implements Parcelable, QosSessi } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + EpsBearerQosSessionAttributes epsBearerAttr = (EpsBearerQosSessionAttributes) o; + return mQci == epsBearerAttr.mQci + && mMaxUplinkBitRate == epsBearerAttr.mMaxUplinkBitRate + && mMaxDownlinkBitRate == epsBearerAttr.mMaxDownlinkBitRate + && mGuaranteedUplinkBitRate == epsBearerAttr.mGuaranteedUplinkBitRate + && mGuaranteedDownlinkBitRate == epsBearerAttr.mGuaranteedDownlinkBitRate + && mRemoteAddresses.size() == epsBearerAttr.mRemoteAddresses.size() + && mRemoteAddresses.containsAll(epsBearerAttr.mRemoteAddresses); + } + + @Override + public int hashCode() { + return Objects.hash(mQci, mMaxUplinkBitRate, mMaxDownlinkBitRate, + mGuaranteedUplinkBitRate, mGuaranteedDownlinkBitRate, mRemoteAddresses); + } + @NonNull public static final Creator CREATOR = new Creator() { diff --git a/telephony/java/android/telephony/data/NrQosSessionAttributes.java b/telephony/java/android/telephony/data/NrQosSessionAttributes.java index 4c37687910a1f..c3a0eedf3d7d9 100644 --- a/telephony/java/android/telephony/data/NrQosSessionAttributes.java +++ b/telephony/java/android/telephony/data/NrQosSessionAttributes.java @@ -241,6 +241,30 @@ public final class NrQosSessionAttributes implements Parcelable, QosSessionAttri } } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + NrQosSessionAttributes nrQosAttr = (NrQosSessionAttributes) o; + return m5Qi == nrQosAttr.m5Qi + && mQfi == nrQosAttr.mQfi + && mMaxUplinkBitRate == nrQosAttr.mMaxUplinkBitRate + && mMaxDownlinkBitRate == nrQosAttr.mMaxDownlinkBitRate + && mGuaranteedUplinkBitRate == nrQosAttr.mGuaranteedUplinkBitRate + && mGuaranteedDownlinkBitRate == nrQosAttr.mGuaranteedDownlinkBitRate + && mAveragingWindow == nrQosAttr.mAveragingWindow + && mRemoteAddresses.size() == nrQosAttr.mRemoteAddresses.size() + && mRemoteAddresses.containsAll(nrQosAttr.mRemoteAddresses); + } + + @Override + public int hashCode() { + return Objects.hash(m5Qi, mQfi, mMaxUplinkBitRate, + mMaxDownlinkBitRate, mGuaranteedUplinkBitRate, + mGuaranteedDownlinkBitRate, mAveragingWindow, mRemoteAddresses); + } + + @NonNull public static final Creator CREATOR = new Creator() {