Merge "Factorize custom asserts." am: 6c176efa3d

am: 99fbb40990

Change-Id: I65ea7497abb8b77ebd10ba622075ef3b6c49b2a8
This commit is contained in:
Chalard Jean 2019-06-20 14:01:31 -07:00 • committed by android-build-merger
commit 6573b93eff

View file

@ -15,6 +15,7 @@
*/
package android.net;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
@ -333,25 +334,25 @@ public final class IpSecConfig implements Parcelable {
}
};
@VisibleForTesting
/** Equals method used for testing */
public static boolean equals(IpSecConfig lhs, IpSecConfig rhs) {
if (lhs == null || rhs == null) return (lhs == rhs);
return (lhs.mMode == rhs.mMode
&& lhs.mSourceAddress.equals(rhs.mSourceAddress)
&& lhs.mDestinationAddress.equals(rhs.mDestinationAddress)
&& ((lhs.mNetwork != null && lhs.mNetwork.equals(rhs.mNetwork))
|| (lhs.mNetwork == rhs.mNetwork))
&& lhs.mEncapType == rhs.mEncapType
&& lhs.mEncapSocketResourceId == rhs.mEncapSocketResourceId
&& lhs.mEncapRemotePort == rhs.mEncapRemotePort
&& lhs.mNattKeepaliveInterval == rhs.mNattKeepaliveInterval
&& lhs.mSpiResourceId == rhs.mSpiResourceId
&& IpSecAlgorithm.equals(lhs.mEncryption, rhs.mEncryption)
&& IpSecAlgorithm.equals(lhs.mAuthenticatedEncryption, rhs.mAuthenticatedEncryption)
&& IpSecAlgorithm.equals(lhs.mAuthentication, rhs.mAuthentication)
&& lhs.mMarkValue == rhs.mMarkValue
&& lhs.mMarkMask == rhs.mMarkMask
&& lhs.mXfrmInterfaceId == rhs.mXfrmInterfaceId);
@Override
public boolean equals(@Nullable Object other) {
if (!(other instanceof IpSecConfig)) return false;
final IpSecConfig rhs = (IpSecConfig) other;
return (mMode == rhs.mMode
&& mSourceAddress.equals(rhs.mSourceAddress)
&& mDestinationAddress.equals(rhs.mDestinationAddress)
&& ((mNetwork != null && mNetwork.equals(rhs.mNetwork))
|| (mNetwork == rhs.mNetwork))
&& mEncapType == rhs.mEncapType
&& mEncapSocketResourceId == rhs.mEncapSocketResourceId
&& mEncapRemotePort == rhs.mEncapRemotePort
&& mNattKeepaliveInterval == rhs.mNattKeepaliveInterval
&& mSpiResourceId == rhs.mSpiResourceId
&& IpSecAlgorithm.equals(mEncryption, rhs.mEncryption)
&& IpSecAlgorithm.equals(mAuthenticatedEncryption, rhs.mAuthenticatedEncryption)
&& IpSecAlgorithm.equals(mAuthentication, rhs.mAuthentication)
&& mMarkValue == rhs.mMarkValue
&& mMarkMask == rhs.mMarkMask
&& mXfrmInterfaceId == rhs.mXfrmInterfaceId);
}
}