Set keepalive socket timeout to default value
Fix: 142978377
Test: 1. atest android.net.cts.ConnectivityManagerTest\
#testSocketKeepaliveLimitWifi --generate-new-metrics 10
2. atest android.net.cts.ConnectivityManagerTest
3. manual simulate connection timeout by changing test
address
Change-Id: Idb786e38e87be253e0af11a9ffebf984bf23ead0
diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
index ca1f771..bbc2298 100644
--- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -111,9 +111,7 @@
public static final int TYPE_WIFI = ConnectivityManager.TYPE_WIFI;
private static final int HOST_ADDRESS = 0x7f000001;// represent ip 127.0.0.1
- private static final int CONNECT_TIMEOUT_MS = 2000;
private static final int KEEPALIVE_CALLBACK_TIMEOUT_MS = 2000;
- private static final int KEEPALIVE_SOCKET_TIMEOUT_MS = 5000;
private static final int INTERVAL_KEEPALIVE_RETRY_MS = 500;
private static final int MAX_KEEPALIVE_RETRY_COUNT = 3;
private static final int MIN_KEEPALIVE_INTERVAL = 10;
@@ -834,15 +832,14 @@
}
private Socket getConnectedSocket(final Network network, final String host, final int port,
- final int socketTimeOut, final int family) throws Exception {
+ final int family) throws Exception {
final Socket s = network.getSocketFactory().createSocket();
try {
final InetAddress addr = getAddrByName(host, family);
if (addr == null) fail("Fail to get destination address for " + family);
final InetSocketAddress sockAddr = new InetSocketAddress(addr, port);
- s.setSoTimeout(socketTimeOut);
- s.connect(sockAddr, CONNECT_TIMEOUT_MS);
+ s.connect(sockAddr);
} catch (Exception e) {
s.close();
throw e;
@@ -967,8 +964,7 @@
final byte[] requestBytes = CtsNetUtils.HTTP_REQUEST.getBytes("UTF-8");
// So far only ipv4 tcp keepalive offload is supported.
// TODO: add test case for ipv6 tcp keepalive offload when it is supported.
- try (Socket s = getConnectedSocket(network, TEST_HOST, HTTP_PORT,
- KEEPALIVE_SOCKET_TIMEOUT_MS, AF_INET)) {
+ try (Socket s = getConnectedSocket(network, TEST_HOST, HTTP_PORT, AF_INET)) {
// Should able to start keep alive offload when socket is idle.
final Executor executor = mContext.getMainExecutor();
@@ -1102,7 +1098,7 @@
// sockets will be duplicated and kept valid in service side if the keepalives are
// successfully started.
try (Socket tcpSocket = getConnectedSocket(network, TEST_HOST, HTTP_PORT,
- 0 /* Unused */, AF_INET)) {
+ AF_INET)) {
return mCm.createSocketKeepalive(network, tcpSocket, executor, callback);
} catch (Exception e) {
fail("Unexpected error when creating TCP socket: " + e);