Factorize custom asserts.
Also a few utilities that were in the way, and some opportunistic cleanups. Test: FrameworksNetTest NetworkStackTest Change-Id: I385070e2044fd967cb18f1ffea9a86a4627b742e
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,15 +148,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user