Merge "Fix NPEs in DataCallResponse" into tm-qpr-dev am: 680dc13217

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20421638

Change-Id: I3e1c57b84dade5f2509630e867eb4db56cf02a76
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-11-11 00:45:28 +00:00
committed by Automerger Merge Worker

View File

@@ -468,14 +468,14 @@ public final class DataCallResponse implements Parcelable {
final boolean isQosBearerSessionsSame =
(mQosBearerSessions == null || other.mQosBearerSessions == null)
? mQosBearerSessions == other.mQosBearerSessions
: mQosBearerSessions.size() == other.mQosBearerSessions.size()
&& mQosBearerSessions.containsAll(other.mQosBearerSessions);
: (mQosBearerSessions.size() == other.mQosBearerSessions.size()
&& mQosBearerSessions.containsAll(other.mQosBearerSessions));
final boolean isTrafficDescriptorsSame =
(mTrafficDescriptors == null || other.mTrafficDescriptors == null)
? mTrafficDescriptors == other.mTrafficDescriptors
: mTrafficDescriptors.size() == other.mTrafficDescriptors.size()
&& mTrafficDescriptors.containsAll(other.mTrafficDescriptors);
: (mTrafficDescriptors.size() == other.mTrafficDescriptors.size()
&& mTrafficDescriptors.containsAll(other.mTrafficDescriptors));
return mCause == other.mCause
&& mSuggestedRetryTime == other.mSuggestedRetryTime
@@ -504,10 +504,35 @@ public final class DataCallResponse implements Parcelable {
@Override
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,
mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses, mPcscfAddresses,
mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId, mDefaultQos,
mQosBearerSessions, mSliceInfo, mTrafficDescriptors);
mInterfaceName, addressesHash, dnsAddressesHash, gatewayAddressesHash,
pcscfAddressesHash, mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId,
mDefaultQos, qosBearerSessionsHash, mSliceInfo, trafficDescriptorsHash);
}
@Override
@@ -816,8 +841,8 @@ public final class DataCallResponse implements Parcelable {
/**
* Set pdu session id.
* <p/>
* 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}.
* 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}.
*
* @param pduSessionId Pdu Session Id of the data call.
* @return The same instance of the builder.
@@ -858,6 +883,7 @@ public final class DataCallResponse implements Parcelable {
*/
public @NonNull Builder setQosBearerSessions(
@NonNull List<QosBearerSession> qosBearerSessions) {
Objects.requireNonNull(qosBearerSessions);
mQosBearerSessions = qosBearerSessions;
return this;
}
@@ -891,6 +917,7 @@ public final class DataCallResponse implements Parcelable {
*/
public @NonNull Builder setTrafficDescriptors(
@NonNull List<TrafficDescriptor> trafficDescriptors) {
Objects.requireNonNull(trafficDescriptors);
mTrafficDescriptors = trafficDescriptors;
return this;
}