Merge "Copy IpSecConfig when IpSecTransforms are created" am: 2c8456b22e

am: 3988c929ad

Change-Id: I041cd94be9cefc997b95478444661b557d95e3dc
This commit is contained in:
Benedict Wong
2018-02-14 21:25:08 +00:00
committed by android-build-merger
2 changed files with 35 additions and 2 deletions

View File

@@ -218,6 +218,25 @@ public final class IpSecConfig implements Parcelable {
@VisibleForTesting
public IpSecConfig() {}
/** Copy constructor */
@VisibleForTesting
public IpSecConfig(IpSecConfig c) {
mMode = c.mMode;
mSourceAddress = c.mSourceAddress;
mDestinationAddress = c.mDestinationAddress;
mNetwork = c.mNetwork;
mSpiResourceId = c.mSpiResourceId;
mEncryption = c.mEncryption;
mAuthentication = c.mAuthentication;
mAuthenticatedEncryption = c.mAuthenticatedEncryption;
mEncapType = c.mEncapType;
mEncapSocketResourceId = c.mEncapSocketResourceId;
mEncapRemotePort = c.mEncapRemotePort;
mNattKeepaliveInterval = c.mNattKeepaliveInterval;
mMarkValue = c.mMarkValue;
mMarkMask = c.mMarkMask;
}
private IpSecConfig(Parcel in) {
mMode = in.readInt();
mSourceAddress = in.readString();

View File

@@ -84,9 +84,11 @@ public final class IpSecTransform implements AutoCloseable {
@Retention(RetentionPolicy.SOURCE)
public @interface EncapType {}
private IpSecTransform(Context context, IpSecConfig config) {
/** @hide */
@VisibleForTesting
public IpSecTransform(Context context, IpSecConfig config) {
mContext = context;
mConfig = config;
mConfig = new IpSecConfig(config);
mResourceId = INVALID_RESOURCE_ID;
}
@@ -142,6 +144,18 @@ public final class IpSecTransform implements AutoCloseable {
return this;
}
/**
* Equals method used for testing
*
* @hide
*/
@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;
}
/**
* Deactivate this {@code IpSecTransform} and free allocated resources.
*