Merge "Fix NPEs in DataCallResponse" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-11-11 00:11:59 +00:00
committed by Android (Google) Code Review

View File

@@ -468,14 +468,14 @@ public final class DataCallResponse implements Parcelable {
final boolean isQosBearerSessionsSame = final boolean isQosBearerSessionsSame =
(mQosBearerSessions == null || other.mQosBearerSessions == null) (mQosBearerSessions == null || other.mQosBearerSessions == null)
? mQosBearerSessions == other.mQosBearerSessions ? mQosBearerSessions == other.mQosBearerSessions
: mQosBearerSessions.size() == other.mQosBearerSessions.size() : (mQosBearerSessions.size() == other.mQosBearerSessions.size()
&& mQosBearerSessions.containsAll(other.mQosBearerSessions); && mQosBearerSessions.containsAll(other.mQosBearerSessions));
final boolean isTrafficDescriptorsSame = final boolean isTrafficDescriptorsSame =
(mTrafficDescriptors == null || other.mTrafficDescriptors == null) (mTrafficDescriptors == null || other.mTrafficDescriptors == null)
? mTrafficDescriptors == other.mTrafficDescriptors ? mTrafficDescriptors == other.mTrafficDescriptors
: mTrafficDescriptors.size() == other.mTrafficDescriptors.size() : (mTrafficDescriptors.size() == other.mTrafficDescriptors.size()
&& mTrafficDescriptors.containsAll(other.mTrafficDescriptors); && mTrafficDescriptors.containsAll(other.mTrafficDescriptors));
return mCause == other.mCause return mCause == other.mCause
&& mSuggestedRetryTime == other.mSuggestedRetryTime && mSuggestedRetryTime == other.mSuggestedRetryTime
@@ -504,10 +504,35 @@ public final class DataCallResponse implements Parcelable {
@Override @Override
public int hashCode() { public int hashCode() {
// Generate order-independent hashes for lists
int addressesHash = mAddresses.stream()
.map(LinkAddress::hashCode)
.mapToInt(Integer::intValue)
.sum();
int dnsAddressesHash = mDnsAddresses.stream()
.map(InetAddress::hashCode)
.mapToInt(Integer::intValue)
.sum();
int gatewayAddressesHash = mGatewayAddresses.stream()
.map(InetAddress::hashCode)
.mapToInt(Integer::intValue)
.sum();
int pcscfAddressesHash = mPcscfAddresses.stream()
.map(InetAddress::hashCode)
.mapToInt(Integer::intValue)
.sum();
int qosBearerSessionsHash = mQosBearerSessions.stream()
.map(QosBearerSession::hashCode)
.mapToInt(Integer::intValue)
.sum();
int trafficDescriptorsHash = mTrafficDescriptors.stream()
.map(TrafficDescriptor::hashCode)
.mapToInt(Integer::intValue)
.sum();
return Objects.hash(mCause, mSuggestedRetryTime, mId, mLinkStatus, mProtocolType, return Objects.hash(mCause, mSuggestedRetryTime, mId, mLinkStatus, mProtocolType,
mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses, mPcscfAddresses, mInterfaceName, addressesHash, dnsAddressesHash, gatewayAddressesHash,
mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId, mDefaultQos, pcscfAddressesHash, mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId,
mQosBearerSessions, mSliceInfo, mTrafficDescriptors); mDefaultQos, qosBearerSessionsHash, mSliceInfo, trafficDescriptorsHash);
} }
@Override @Override
@@ -816,8 +841,8 @@ public final class DataCallResponse implements Parcelable {
/** /**
* Set pdu session id. * Set pdu session id.
* <p/> * <p/>
* The id must be between 1 and 15 when linked to a pdu session. If no pdu session * The id must be between 1 and 15 when linked to a pdu session. If no pdu session
* exists for the current data call, the id must be set to {@link PDU_SESSION_ID_NOT_SET}. * exists for the current data call, the id must be set to {@link #PDU_SESSION_ID_NOT_SET}.
* *
* @param pduSessionId Pdu Session Id of the data call. * @param pduSessionId Pdu Session Id of the data call.
* @return The same instance of the builder. * @return The same instance of the builder.
@@ -858,6 +883,7 @@ public final class DataCallResponse implements Parcelable {
*/ */
public @NonNull Builder setQosBearerSessions( public @NonNull Builder setQosBearerSessions(
@NonNull List<QosBearerSession> qosBearerSessions) { @NonNull List<QosBearerSession> qosBearerSessions) {
Objects.requireNonNull(qosBearerSessions);
mQosBearerSessions = qosBearerSessions; mQosBearerSessions = qosBearerSessions;
return this; return this;
} }
@@ -891,6 +917,7 @@ public final class DataCallResponse implements Parcelable {
*/ */
public @NonNull Builder setTrafficDescriptors( public @NonNull Builder setTrafficDescriptors(
@NonNull List<TrafficDescriptor> trafficDescriptors) { @NonNull List<TrafficDescriptor> trafficDescriptors) {
Objects.requireNonNull(trafficDescriptors);
mTrafficDescriptors = trafficDescriptors; mTrafficDescriptors = trafficDescriptors;
return this; return this;
} }