Move the test of minimum supported keepalive slots to CTS

This change also enables log when keepalive is started.

Bug: 134352656
Test: 1. atest android.net.cts.ConnectivityManagerTest#testSocketKeepaliveLimitTelephony
      2. atest FrameworksNetTests
Merged-In: I408750fa0bceb0c1c26afb5fead4e44fb824fbc1
Change-Id: Ib9b06d3458782a648a2f5b8fd5a9ca1d34bd11f9
(cherry picked from commit aed835f086440f721c279e33d6b5d4b4bc270296)
This commit is contained in:
Junyu Lai
2019-06-19 07:29:11 -07:00
parent c34b699c2e
commit ca8b6ed19f
3 changed files with 2 additions and 9 deletions

View File

@@ -34,9 +34,6 @@ public final class KeepaliveUtils {
public static final String TAG = "KeepaliveUtils"; public static final String TAG = "KeepaliveUtils";
// Minimum supported keepalive count per transport if the network supports keepalive.
public static final int MIN_SUPPORTED_KEEPALIVE_COUNT = 3;
public static class KeepaliveDeviceConfigurationException extends AndroidRuntimeException { public static class KeepaliveDeviceConfigurationException extends AndroidRuntimeException {
public KeepaliveDeviceConfigurationException(final String msg) { public KeepaliveDeviceConfigurationException(final String msg) {
super(msg); super(msg);
@@ -84,10 +81,7 @@ public final class KeepaliveUtils {
throw new KeepaliveDeviceConfigurationException("Invalid transport " + transport); throw new KeepaliveDeviceConfigurationException("Invalid transport " + transport);
} }
// Customized values should be either 0 to indicate the network doesn't support if (supported < 0) {
// keepalive offload, or a positive value that is at least
// MIN_SUPPORTED_KEEPALIVE_COUNT if supported.
if (supported != 0 && supported < MIN_SUPPORTED_KEEPALIVE_COUNT) {
throw new KeepaliveDeviceConfigurationException( throw new KeepaliveDeviceConfigurationException(
"Invalid supported count " + supported + " for " "Invalid supported count " + supported + " for "
+ NetworkCapabilities.transportNameOf(transport)); + NetworkCapabilities.transportNameOf(transport));

View File

@@ -564,7 +564,7 @@ public class KeepaliveTracker {
if (KeepaliveInfo.STARTING == ki.mStartedState) { if (KeepaliveInfo.STARTING == ki.mStartedState) {
if (SUCCESS == reason) { if (SUCCESS == reason) {
// Keepalive successfully started. // Keepalive successfully started.
if (DBG) Log.d(TAG, "Started keepalive " + slot + " on " + nai.name()); Log.d(TAG, "Started keepalive " + slot + " on " + nai.name());
ki.mStartedState = KeepaliveInfo.STARTED; ki.mStartedState = KeepaliveInfo.STARTED;
try { try {
ki.mCallback.onStarted(slot); ki.mCallback.onStarted(slot);

View File

@@ -78,7 +78,6 @@ class KeepaliveUtilsTest {
assertRunWithException(arrayOf("5")) assertRunWithException(arrayOf("5"))
// Check resource with invalid slots value. // Check resource with invalid slots value.
assertRunWithException(arrayOf("2,2"))
assertRunWithException(arrayOf("3,-1")) assertRunWithException(arrayOf("3,-1"))
// Check resource with invalid transport type. // Check resource with invalid transport type.