Add dump info to IpSecService

Bug:38350824

Test: runtest frameworks-net

Change-Id: Ifa11d55e9d337016ad865baada627db3aa8c2db3
This commit is contained in:
ludi
2017-05-22 10:52:23 -07:00
parent 5e623eaa02
commit 89194d6e45
4 changed files with 141 additions and 6 deletions

View File

@@ -16,8 +16,10 @@
package android.net;
import android.annotation.StringDef;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import com.android.internal.util.HexDump;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -182,4 +184,17 @@ public final class IpSecAlgorithm implements Parcelable {
return false;
}
}
@Override
public String toString() {
return new StringBuilder()
.append("{mName=")
.append(mName)
.append(", mKey=")
.append(Build.IS_DEBUGGABLE ? HexDump.toHexString(mKey) : "<hidden>")
.append(", mTruncLenBits=")
.append(mTruncLenBits)
.append("}")
.toString();
}
};

View File

@@ -47,9 +47,22 @@ public final class IpSecConfig implements Parcelable {
// Authentication Algorithm
IpSecAlgorithm authentication;
@Override
public String toString() {
return new StringBuilder()
.append("{spiResourceId=")
.append(spiResourceId)
.append(", encryption=")
.append(encryption)
.append(", authentication=")
.append(authentication)
.append("}")
.toString();
}
}
Flow[] flow = new Flow[] {new Flow(), new Flow()};
final Flow[] flow = new Flow[] {new Flow(), new Flow()};
// For tunnel mode IPv4 UDP Encapsulation
// IpSecTransform#ENCAP_ESP_*, such as ENCAP_ESP_OVER_UDP_IKE
@@ -166,6 +179,35 @@ public final class IpSecConfig implements Parcelable {
encapRemotePort = in.readInt();
}
@Override
public String toString() {
StringBuilder strBuilder = new StringBuilder();
strBuilder
.append("{mode=")
.append(mode == IpSecTransform.MODE_TUNNEL ? "TUNNEL" : "TRANSPORT")
.append(", localAddress=")
.append(localAddress)
.append(", remoteAddress=")
.append(remoteAddress)
.append(", network=")
.append(network)
.append(", encapType=")
.append(encapType)
.append(", encapLocalPortResourceId=")
.append(encapLocalPortResourceId)
.append(", encapRemotePort=")
.append(encapRemotePort)
.append(", nattKeepaliveInterval=")
.append(nattKeepaliveInterval)
.append(", flow[OUT]=")
.append(flow[IpSecTransform.DIRECTION_OUT])
.append(", flow[IN]=")
.append(flow[IpSecTransform.DIRECTION_IN])
.append("}");
return strBuilder.toString();
}
public static final Parcelable.Creator<IpSecConfig> CREATOR =
new Parcelable.Creator<IpSecConfig>() {
public IpSecConfig createFromParcel(Parcel in) {

View File

@@ -67,10 +67,10 @@ public final class IpSecTransform implements AutoCloseable {
public @interface TransformDirection {}
/** @hide */
private static final int MODE_TUNNEL = 0;
public static final int MODE_TUNNEL = 0;
/** @hide */
private static final int MODE_TRANSPORT = 1;
public static final int MODE_TRANSPORT = 1;
/** @hide */
public static final int ENCAP_NONE = 0;