Add TcpKeepalivePacketData to SystemApi

This is consistent with NattKeepalivePacketData, which is also a
subclass of KeepalivePacketData.

TcpKeepalivePacketData is already used by the wifi module, but
statically linked.

Bug: 172789687
Test: m
Change-Id: I6aee1ae205987521bea4a3838bbece279ffa0e37
This commit is contained in:
Remi NGUYEN VAN
2020-11-10 15:29:01 +09:00
parent 68150bcb87
commit 5e6b51b895
4 changed files with 283 additions and 11 deletions

View File

@@ -36,6 +36,7 @@ import android.net.SocketKeepalive.InvalidSocketException;
import android.net.TcpKeepalivePacketData;
import android.net.TcpKeepalivePacketDataParcelable;
import android.net.TcpRepairWindow;
import android.net.util.KeepalivePacketDataUtil;
import android.os.Handler;
import android.os.MessageQueue;
import android.os.Messenger;
@@ -112,7 +113,7 @@ public class TcpKeepaliveController {
throws InvalidPacketException, InvalidSocketException {
try {
final TcpKeepalivePacketDataParcelable tcpDetails = switchToRepairMode(fd);
return TcpKeepalivePacketData.tcpKeepalivePacket(tcpDetails);
return KeepalivePacketDataUtil.fromStableParcelable(tcpDetails);
} catch (InvalidPacketException | InvalidSocketException e) {
switchOutOfRepairMode(fd);
throw e;
@@ -122,7 +123,7 @@ public class TcpKeepaliveController {
* Switch the tcp socket to repair mode and query detail tcp information.
*
* @param fd the fd of socket on which to use keepalive offload.
* @return a {@link TcpKeepalivePacketData#TcpKeepalivePacketDataParcelable} object for current
* @return a {@link TcpKeepalivePacketDataParcelable} object for current
* tcp/ip information.
*/
private static TcpKeepalivePacketDataParcelable switchToRepairMode(FileDescriptor fd)