diff options
author | Roshan Pius <rpius@google.com> | 2020-02-21 07:37:30 -0800 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2020-03-16 00:23:42 +0000 |
commit | eb7edd5620a3e51fdd107734ddcf9b083596137f (patch) | |
tree | 3dd79fc36a28c3b1f14c4d80392ca4b7f87fe68f /services/net/java | |
parent | c630fbbb01ebb77cd44abe7868593cd448b06dfb (diff) |
services.net: Add a static library needed by wifi module
Add a new static library that compiles against system_current which
includes all the parts needed by the wifi mainline module.
Also,
a) Refactored TcpKeepalivePacketData to use public APIs. The parcel
read/write methods in the base class are @hide and they're not used by
the other child class (NatKeepalivePacketData). So, remove the @hide
method from base class and use it direcly in the child class.
Bug: 145825329
Test: Device boots up & connects to wifi networks.
Change-Id: Ifde69b579cfe5b813766f676acb10e436e64a44c
Merged-In: Ifde69b579cfe5b813766f676acb10e436e64a44c
Diffstat (limited to 'services/net/java')
-rw-r--r-- | services/net/java/android/net/TcpKeepalivePacketData.java | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/services/net/java/android/net/TcpKeepalivePacketData.java b/services/net/java/android/net/TcpKeepalivePacketData.java index aad75ae16aa9..fcf3a56de448 100644 --- a/services/net/java/android/net/TcpKeepalivePacketData.java +++ b/services/net/java/android/net/TcpKeepalivePacketData.java @@ -74,6 +74,19 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce ipTtl = tcpDetails.ttl; } + private TcpKeepalivePacketData(final InetAddress srcAddress, int srcPort, + final InetAddress dstAddress, int dstPort, final byte[] data, int tcpSeq, + int tcpAck, int tcpWnd, int tcpWndScale, int ipTos, int ipTtl) + throws InvalidPacketException { + super(srcAddress, srcPort, dstAddress, dstPort, data); + this.tcpSeq = tcpSeq; + this.tcpAck = tcpAck; + this.tcpWnd = tcpWnd; + this.tcpWndScale = tcpWndScale; + this.ipTos = ipTos; + this.ipTtl = ipTtl; + } + /** * Factory method to create tcp keepalive packet structure. */ @@ -169,7 +182,11 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce /** Write to parcel. */ public void writeToParcel(Parcel out, int flags) { - super.writeToParcel(out, flags); + out.writeString(srcAddress.getHostAddress()); + out.writeString(dstAddress.getHostAddress()); + out.writeInt(srcPort); + out.writeInt(dstPort); + out.writeByteArray(getPacket()); out.writeInt(tcpSeq); out.writeInt(tcpAck); out.writeInt(tcpWnd); @@ -178,21 +195,32 @@ public class TcpKeepalivePacketData extends KeepalivePacketData implements Parce out.writeInt(ipTtl); } - private TcpKeepalivePacketData(Parcel in) { - super(in); - tcpSeq = in.readInt(); - tcpAck = in.readInt(); - tcpWnd = in.readInt(); - tcpWndScale = in.readInt(); - ipTos = in.readInt(); - ipTtl = in.readInt(); + private static TcpKeepalivePacketData readFromParcel(Parcel in) throws InvalidPacketException { + InetAddress srcAddress = InetAddresses.parseNumericAddress(in.readString()); + InetAddress dstAddress = InetAddresses.parseNumericAddress(in.readString()); + int srcPort = in.readInt(); + int dstPort = in.readInt(); + byte[] packet = in.createByteArray(); + int tcpSeq = in.readInt(); + int tcpAck = in.readInt(); + int tcpWnd = in.readInt(); + int tcpWndScale = in.readInt(); + int ipTos = in.readInt(); + int ipTtl = in.readInt(); + return new TcpKeepalivePacketData(srcAddress, srcPort, dstAddress, dstPort, packet, tcpSeq, + tcpAck, tcpWnd, tcpWndScale, ipTos, ipTtl); } /** Parcelable Creator. */ public static final @NonNull Parcelable.Creator<TcpKeepalivePacketData> CREATOR = new Parcelable.Creator<TcpKeepalivePacketData>() { public TcpKeepalivePacketData createFromParcel(Parcel in) { - return new TcpKeepalivePacketData(in); + try { + return readFromParcel(in); + } catch (InvalidPacketException e) { + throw new IllegalArgumentException( + "Invalid NAT-T keepalive data: " + e.error); + } } public TcpKeepalivePacketData[] newArray(int size) { |