RaPacketBuilder methods should return the object instance
Test: mm
Change-Id: Ib5d09856b292b52d5bb1c3aefdf1f895b836e9f8
diff --git a/tests/unit/src/android/net/apf/ApfTest.java b/tests/unit/src/android/net/apf/ApfTest.java
index ec1ea42..320f1c2 100644
--- a/tests/unit/src/android/net/apf/ApfTest.java
+++ b/tests/unit/src/android/net/apf/ApfTest.java
@@ -2372,19 +2372,23 @@
mPacket.write(buffer.array(), 0, buffer.capacity());
}
- public void setFlowLabel(int flowLabel) {
+ public RaPacketBuilder setFlowLabel(int flowLabel) {
mFlowLabel = flowLabel;
+ return this;
}
- public void setReachableTime(int reachable) {
+ public RaPacketBuilder setReachableTime(int reachable) {
mReachableTime = reachable;
+ return this;
}
- public void setRetransmissionTimer(int retrans) {
+ public RaPacketBuilder setRetransmissionTimer(int retrans) {
mRetransmissionTimer = retrans;
+ return this;
}
- public void addPioOption(int valid, int preferred, String prefixString) throws Exception {
+ public RaPacketBuilder addPioOption(int valid, int preferred, String prefixString)
+ throws Exception {
ByteBuffer buffer = ByteBuffer.allocate(ICMP6_PREFIX_OPTION_LEN);
IpPrefix prefix = new IpPrefix(prefixString);
@@ -2398,9 +2402,10 @@
buffer.put(prefix.getRawAddress());
mPacket.write(buffer.array(), 0, buffer.capacity());
+ return this;
}
- public void addRioOption(int lifetime, String prefixString) throws Exception {
+ public RaPacketBuilder addRioOption(int lifetime, String prefixString) throws Exception {
IpPrefix prefix = new IpPrefix(prefixString);
int optionLength;
@@ -2424,9 +2429,10 @@
buffer.put(prefixBytes, 0, (optionLength - 1) * 8);
mPacket.write(buffer.array(), 0, buffer.capacity());
+ return this;
}
- public void addDnsslOption(int lifetime, String... domains) {
+ public RaPacketBuilder addDnsslOption(int lifetime, String... domains) {
ByteArrayOutputStream dnssl = new ByteArrayOutputStream();
for (String domain : domains) {
for (String label : domain.split(".")) {
@@ -2453,9 +2459,10 @@
buffer.put(dnssl.toByteArray()); // Domain names
mPacket.write(buffer.array(), 0, buffer.capacity());
+ return this;
}
- public void addRdnssOption(int lifetime, String... servers) throws Exception {
+ public RaPacketBuilder addRdnssOption(int lifetime, String... servers) throws Exception {
int optionLength = 1 + 2 * servers.length; // In 8-byte units
ByteBuffer buffer = ByteBuffer.allocate(optionLength * 8);
@@ -2468,14 +2475,16 @@
}
mPacket.write(buffer.array(), 0, buffer.capacity());
+ return this;
}
- public void addZeroLengthOption() throws Exception {
+ public RaPacketBuilder addZeroLengthOption() throws Exception {
ByteBuffer buffer = ByteBuffer.allocate(ICMP6_4_BYTE_OPTION_LEN);
buffer.put((byte) ICMP6_PREFIX_OPTION_TYPE);
buffer.put((byte) 0);
mPacket.write(buffer.array(), 0, buffer.capacity());
+ return this;
}
public byte[] build() {