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
2 changed files with 27 additions and 28 deletions

View File

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

View File

@@ -151,15 +151,13 @@ public final class IpSecTransform implements AutoCloseable {
} }
/** /**
* Equals method used for testing * Standard equals.
*
* @hide
*/ */
@VisibleForTesting public boolean equals(Object other) {
public static boolean equals(IpSecTransform lhs, IpSecTransform rhs) { if (this == other) return true;
if (lhs == null || rhs == null) return (lhs == rhs); if (!(other instanceof IpSecTransform)) return false;
return IpSecConfig.equals(lhs.getConfig(), rhs.getConfig()) final IpSecTransform rhs = (IpSecTransform) other;
&& lhs.mResourceId == rhs.mResourceId; return getConfig().equals(rhs.getConfig()) && mResourceId == rhs.mResourceId;
} }
/** /**