[DK4-0]Add CM#setTestLowTcpPollingTimerForKeepalive for testing
The default TCP polling alarm timer is very large(2 mins). It's expensive in the CTS to wait for a couple alarms. The polling alarm should be deprecated soon and replace with callback design, so add the hidden method for testing purpose to support the short term usage until design is replaced with callbacks. With the hidden method, the alarm timer will decrease to 1 second for a specified time period. The TCP sockets status could be verified every 1 second. Bug: 259000745 Test: m ; atest HostsideVpnTests with the follow up test Change-Id: I99d494d3b50b2fbee73b926e92e97b1e194d43d4
This commit is contained in:
parent
bdb8282604
commit
e0192a7433
1 changed files with 76 additions and 4 deletions
|
|
@ -764,6 +764,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
*/
|
||||
private static final int EVENT_SET_VPN_NETWORK_PREFERENCE = 59;
|
||||
|
||||
/**
|
||||
* Event to use low TCP polling timer used in automatic on/off keepalive temporarily.
|
||||
*/
|
||||
private static final int EVENT_SET_LOW_TCP_POLLING_UNTIL = 60;
|
||||
|
||||
/**
|
||||
* Argument for {@link #EVENT_PROVISIONING_NOTIFICATION} to indicate that the notification
|
||||
* should be shown.
|
||||
|
|
@ -781,6 +786,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
*/
|
||||
private static final long MAX_TEST_ALLOW_BAD_WIFI_UNTIL_MS = 5 * 60 * 1000L;
|
||||
|
||||
/**
|
||||
* The maximum alive time to decrease TCP polling timer in automatic on/off keepalive for
|
||||
* testing.
|
||||
*/
|
||||
private static final long MAX_TEST_LOW_TCP_POLLING_UNTIL_MS = 5 * 60 * 1000L;
|
||||
|
||||
/**
|
||||
* The priority of the tc police rate limiter -- smaller value is higher priority.
|
||||
* This value needs to be coordinated with PRIO_CLAT, PRIO_TETHER4, and PRIO_TETHER6.
|
||||
|
|
@ -4998,6 +5009,22 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
mHandler.obtainMessage(EVENT_SET_TEST_ALLOW_BAD_WIFI_UNTIL, timeMs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTestLowTcpPollingTimerForKeepalive(long timeMs) {
|
||||
enforceSettingsPermission();
|
||||
if (!Build.isDebuggable()) {
|
||||
throw new IllegalStateException("Is not supported in non-debuggable build");
|
||||
}
|
||||
|
||||
if (timeMs > System.currentTimeMillis() + MAX_TEST_LOW_TCP_POLLING_UNTIL_MS) {
|
||||
throw new IllegalArgumentException("Argument should not exceed "
|
||||
+ MAX_TEST_LOW_TCP_POLLING_UNTIL_MS + "ms from now");
|
||||
}
|
||||
|
||||
mHandler.sendMessage(
|
||||
mHandler.obtainMessage(EVENT_SET_LOW_TCP_POLLING_UNTIL, timeMs));
|
||||
}
|
||||
|
||||
private void handleSetAcceptUnvalidated(Network network, boolean accept, boolean always) {
|
||||
if (DBG) log("handleSetAcceptUnvalidated network=" + network +
|
||||
" accept=" + accept + " always=" + always);
|
||||
|
|
@ -5639,6 +5666,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
case EVENT_SET_VPN_NETWORK_PREFERENCE:
|
||||
handleSetVpnNetworkPreference((VpnNetworkPreferenceInfo) msg.obj);
|
||||
break;
|
||||
case EVENT_SET_LOW_TCP_POLLING_UNTIL: {
|
||||
final long time = ((Long) msg.obj).longValue();
|
||||
mKeepaliveTracker.handleSetTestLowTcpPollingTimer(time);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue