diff --git a/core/java/android/net/IpSecConfig.java b/core/java/android/net/IpSecConfig.java index 3552655983..43c8ff2335 100644 --- a/core/java/android/net/IpSecConfig.java +++ b/core/java/android/net/IpSecConfig.java @@ -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); } } diff --git a/core/java/android/net/IpSecTransform.java b/core/java/android/net/IpSecTransform.java index a12df28eac..93ae4f1188 100644 --- a/core/java/android/net/IpSecTransform.java +++ b/core/java/android/net/IpSecTransform.java @@ -148,15 +148,13 @@ public final class IpSecTransform implements AutoCloseable { } /** - * Equals method used for testing - * - * @hide + * Standard equals. */ - @VisibleForTesting - public static boolean equals(IpSecTransform lhs, IpSecTransform rhs) { - if (lhs == null || rhs == null) return (lhs == rhs); - return IpSecConfig.equals(lhs.getConfig(), rhs.getConfig()) - && lhs.mResourceId == rhs.mResourceId; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof IpSecTransform)) return false; + final IpSecTransform rhs = (IpSecTransform) other; + return getConfig().equals(rhs.getConfig()) && mResourceId == rhs.mResourceId; } /**