Merge changes from topics "nonAutoIPSelection", "preferredIpProtocol"
* changes: Test IP version and encap type set in non-auto IP selection mode Test reading preferred IP protocol from carrierconfig
This commit is contained in:
@@ -35,15 +35,24 @@ import static android.net.cts.util.IkeSessionTestUtils.TEST_KEEPALIVE_TIMEOUT_UN
|
|||||||
import static android.net.cts.util.IkeSessionTestUtils.getTestIkeSessionParams;
|
import static android.net.cts.util.IkeSessionTestUtils.getTestIkeSessionParams;
|
||||||
import static android.net.ipsec.ike.IkeSessionConfiguration.EXTENSION_TYPE_MOBIKE;
|
import static android.net.ipsec.ike.IkeSessionConfiguration.EXTENSION_TYPE_MOBIKE;
|
||||||
import static android.net.ipsec.ike.IkeSessionParams.ESP_ENCAP_TYPE_AUTO;
|
import static android.net.ipsec.ike.IkeSessionParams.ESP_ENCAP_TYPE_AUTO;
|
||||||
|
import static android.net.ipsec.ike.IkeSessionParams.ESP_ENCAP_TYPE_NONE;
|
||||||
|
import static android.net.ipsec.ike.IkeSessionParams.ESP_ENCAP_TYPE_UDP;
|
||||||
import static android.net.ipsec.ike.IkeSessionParams.ESP_IP_VERSION_AUTO;
|
import static android.net.ipsec.ike.IkeSessionParams.ESP_IP_VERSION_AUTO;
|
||||||
|
import static android.net.ipsec.ike.IkeSessionParams.ESP_IP_VERSION_IPV4;
|
||||||
|
import static android.net.ipsec.ike.IkeSessionParams.ESP_IP_VERSION_IPV6;
|
||||||
import static android.os.Build.VERSION_CODES.S_V2;
|
import static android.os.Build.VERSION_CODES.S_V2;
|
||||||
import static android.os.UserHandle.PER_USER_RANGE;
|
import static android.os.UserHandle.PER_USER_RANGE;
|
||||||
import static android.telephony.CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL;
|
import static android.telephony.CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL;
|
||||||
import static android.telephony.CarrierConfigManager.KEY_MIN_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT;
|
import static android.telephony.CarrierConfigManager.KEY_MIN_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT;
|
||||||
|
import static android.telephony.CarrierConfigManager.KEY_PREFERRED_IKE_PROTOCOL_INT;
|
||||||
|
|
||||||
import static com.android.net.module.util.NetworkStackConstants.IPV6_MIN_MTU;
|
import static com.android.net.module.util.NetworkStackConstants.IPV6_MIN_MTU;
|
||||||
import static com.android.server.connectivity.Vpn.AUTOMATIC_KEEPALIVE_DELAY_SECONDS;
|
import static com.android.server.connectivity.Vpn.AUTOMATIC_KEEPALIVE_DELAY_SECONDS;
|
||||||
import static com.android.server.connectivity.Vpn.DEFAULT_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT;
|
import static com.android.server.connectivity.Vpn.DEFAULT_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT;
|
||||||
|
import static com.android.server.connectivity.Vpn.PREFERRED_IKE_PROTOCOL_AUTO;
|
||||||
|
import static com.android.server.connectivity.Vpn.PREFERRED_IKE_PROTOCOL_IPV4_UDP;
|
||||||
|
import static com.android.server.connectivity.Vpn.PREFERRED_IKE_PROTOCOL_IPV6_ESP;
|
||||||
|
import static com.android.server.connectivity.Vpn.PREFERRED_IKE_PROTOCOL_IPV6_UDP;
|
||||||
import static com.android.testutils.Cleanup.testAndCleanup;
|
import static com.android.testutils.Cleanup.testAndCleanup;
|
||||||
import static com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
import static com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
||||||
import static com.android.testutils.MiscAsserts.assertThrows;
|
import static com.android.testutils.MiscAsserts.assertThrows;
|
||||||
@@ -277,6 +286,7 @@ public class VpnTest extends VpnTestBase {
|
|||||||
private static final int IKE_NATT_KEEPALIVE_DELAY_SEC_DEFAULT = 10;
|
private static final int IKE_NATT_KEEPALIVE_DELAY_SEC_DEFAULT = 10;
|
||||||
private static final int TEST_KEEPALIVE_TIMER = 800;
|
private static final int TEST_KEEPALIVE_TIMER = 800;
|
||||||
private static final int TEST_SUB_ID = 1234;
|
private static final int TEST_SUB_ID = 1234;
|
||||||
|
private static final String TEST_MCCMNC = "12345";
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS) private Context mContext;
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS) private Context mContext;
|
||||||
@Mock private UserManager mUserManager;
|
@Mock private UserManager mUserManager;
|
||||||
@@ -1945,43 +1955,54 @@ public class VpnTest extends VpnTestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMigrateIkeSession_FromIkeTunnConnParams_AutoTimerNoTimer()
|
public void testMigrateIkeSession_FromIkeTunnConnParams_AutoTimerNoTimer() throws Exception {
|
||||||
throws Exception {
|
|
||||||
doTestMigrateIkeSession_FromIkeTunnConnParams(
|
doTestMigrateIkeSession_FromIkeTunnConnParams(
|
||||||
false /* isAutomaticIpVersionSelectionEnabled */,
|
false /* isAutomaticIpVersionSelectionEnabled */,
|
||||||
true /* isAutomaticNattKeepaliveTimerEnabled */,
|
true /* isAutomaticNattKeepaliveTimerEnabled */,
|
||||||
TEST_KEEPALIVE_TIMEOUT_UNSET);
|
TEST_KEEPALIVE_TIMEOUT_UNSET /* keepaliveInProfile */,
|
||||||
|
ESP_IP_VERSION_AUTO /* ipVersionInProfile */,
|
||||||
|
ESP_ENCAP_TYPE_AUTO /* encapTypeInProfile */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMigrateIkeSession_FromIkeTunnConnParams_AutoTimerTimerSet()
|
public void testMigrateIkeSession_FromIkeTunnConnParams_AutoTimerTimerSet() throws Exception {
|
||||||
throws Exception {
|
|
||||||
doTestMigrateIkeSession_FromIkeTunnConnParams(
|
doTestMigrateIkeSession_FromIkeTunnConnParams(
|
||||||
false /* isAutomaticIpVersionSelectionEnabled */,
|
false /* isAutomaticIpVersionSelectionEnabled */,
|
||||||
true /* isAutomaticNattKeepaliveTimerEnabled */,
|
true /* isAutomaticNattKeepaliveTimerEnabled */,
|
||||||
TEST_KEEPALIVE_TIMER);
|
TEST_KEEPALIVE_TIMER /* keepaliveInProfile */,
|
||||||
|
ESP_IP_VERSION_AUTO /* ipVersionInProfile */,
|
||||||
|
ESP_ENCAP_TYPE_AUTO /* encapTypeInProfile */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMigrateIkeSession_FromIkeTunnConnParams_AutoIp()
|
public void testMigrateIkeSession_FromIkeTunnConnParams_AutoIp() throws Exception {
|
||||||
throws Exception {
|
|
||||||
doTestMigrateIkeSession_FromIkeTunnConnParams(
|
doTestMigrateIkeSession_FromIkeTunnConnParams(
|
||||||
true /* isAutomaticIpVersionSelectionEnabled */,
|
true /* isAutomaticIpVersionSelectionEnabled */,
|
||||||
false /* isAutomaticNattKeepaliveTimerEnabled */,
|
false /* isAutomaticNattKeepaliveTimerEnabled */,
|
||||||
TEST_KEEPALIVE_TIMEOUT_UNSET);
|
TEST_KEEPALIVE_TIMEOUT_UNSET /* keepaliveInProfile */,
|
||||||
|
ESP_IP_VERSION_AUTO /* ipVersionInProfile */,
|
||||||
|
ESP_ENCAP_TYPE_AUTO /* encapTypeInProfile */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMigrateIkeSession_FromNotIkeTunnConnParams_AutoTimer()
|
public void testMigrateIkeSession_FromIkeTunnConnParams_AssignedIpProtocol() throws Exception {
|
||||||
throws Exception {
|
doTestMigrateIkeSession_FromIkeTunnConnParams(
|
||||||
|
false /* isAutomaticIpVersionSelectionEnabled */,
|
||||||
|
false /* isAutomaticNattKeepaliveTimerEnabled */,
|
||||||
|
TEST_KEEPALIVE_TIMEOUT_UNSET /* keepaliveInProfile */,
|
||||||
|
ESP_IP_VERSION_IPV4 /* ipVersionInProfile */,
|
||||||
|
ESP_ENCAP_TYPE_UDP /* encapTypeInProfile */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMigrateIkeSession_FromNotIkeTunnConnParams_AutoTimer() throws Exception {
|
||||||
doTestMigrateIkeSession_FromNotIkeTunnConnParams(
|
doTestMigrateIkeSession_FromNotIkeTunnConnParams(
|
||||||
false /* isAutomaticIpVersionSelectionEnabled */,
|
false /* isAutomaticIpVersionSelectionEnabled */,
|
||||||
true /* isAutomaticNattKeepaliveTimerEnabled */);
|
true /* isAutomaticNattKeepaliveTimerEnabled */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMigrateIkeSession_FromNotIkeTunnConnParams_AutoIp()
|
public void testMigrateIkeSession_FromNotIkeTunnConnParams_AutoIp() throws Exception {
|
||||||
throws Exception {
|
|
||||||
doTestMigrateIkeSession_FromNotIkeTunnConnParams(
|
doTestMigrateIkeSession_FromNotIkeTunnConnParams(
|
||||||
true /* isAutomaticIpVersionSelectionEnabled */,
|
true /* isAutomaticIpVersionSelectionEnabled */,
|
||||||
false /* isAutomaticNattKeepaliveTimerEnabled */);
|
false /* isAutomaticNattKeepaliveTimerEnabled */);
|
||||||
@@ -2001,16 +2022,27 @@ public class VpnTest extends VpnTestBase {
|
|||||||
final int expectedKeepalive = isAutomaticNattKeepaliveTimerEnabled
|
final int expectedKeepalive = isAutomaticNattKeepaliveTimerEnabled
|
||||||
? AUTOMATIC_KEEPALIVE_DELAY_SECONDS
|
? AUTOMATIC_KEEPALIVE_DELAY_SECONDS
|
||||||
: DEFAULT_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT;
|
: DEFAULT_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT;
|
||||||
doTestMigrateIkeSession(ikeProfile.toVpnProfile(), expectedKeepalive,
|
doTestMigrateIkeSession(ikeProfile.toVpnProfile(),
|
||||||
isAutomaticIpVersionSelectionEnabled);
|
expectedKeepalive,
|
||||||
|
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
||||||
|
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTestMigrateIkeSession_FromIkeTunnConnParams(
|
private void doTestMigrateIkeSession_FromIkeTunnConnParams(
|
||||||
boolean isAutomaticIpVersionSelectionEnabled,
|
boolean isAutomaticIpVersionSelectionEnabled,
|
||||||
boolean isAutomaticNattKeepaliveTimerEnabled,
|
boolean isAutomaticNattKeepaliveTimerEnabled,
|
||||||
int keepaliveInProfile) throws Exception {
|
int keepaliveInProfile,
|
||||||
final IkeSessionParams ikeSessionParams = getTestIkeSessionParams(true /* testIpv6 */,
|
int ipVersionInProfile,
|
||||||
|
int encapTypeInProfile) throws Exception {
|
||||||
|
// TODO: Update helper function in IkeSessionTestUtils to support building IkeSessionParams
|
||||||
|
// with IP version and encap type when mainline-prod branch support these two APIs.
|
||||||
|
final IkeSessionParams params = getTestIkeSessionParams(true /* testIpv6 */,
|
||||||
new IkeFqdnIdentification(TEST_IDENTITY), keepaliveInProfile);
|
new IkeFqdnIdentification(TEST_IDENTITY), keepaliveInProfile);
|
||||||
|
final IkeSessionParams ikeSessionParams = new IkeSessionParams.Builder(params)
|
||||||
|
.setIpVersion(ipVersionInProfile)
|
||||||
|
.setEncapType(encapTypeInProfile)
|
||||||
|
.build();
|
||||||
|
|
||||||
final IkeTunnelConnectionParams tunnelParams =
|
final IkeTunnelConnectionParams tunnelParams =
|
||||||
new IkeTunnelConnectionParams(ikeSessionParams, CHILD_PARAMS);
|
new IkeTunnelConnectionParams(ikeSessionParams, CHILD_PARAMS);
|
||||||
final Ikev2VpnProfile ikeProfile = new Ikev2VpnProfile.Builder(tunnelParams)
|
final Ikev2VpnProfile ikeProfile = new Ikev2VpnProfile.Builder(tunnelParams)
|
||||||
@@ -2022,17 +2054,18 @@ public class VpnTest extends VpnTestBase {
|
|||||||
final int expectedKeepalive = isAutomaticNattKeepaliveTimerEnabled
|
final int expectedKeepalive = isAutomaticNattKeepaliveTimerEnabled
|
||||||
? AUTOMATIC_KEEPALIVE_DELAY_SECONDS
|
? AUTOMATIC_KEEPALIVE_DELAY_SECONDS
|
||||||
: ikeSessionParams.getNattKeepAliveDelaySeconds();
|
: ikeSessionParams.getNattKeepAliveDelaySeconds();
|
||||||
|
final int expectedIpVersion = isAutomaticIpVersionSelectionEnabled
|
||||||
|
? ESP_IP_VERSION_AUTO
|
||||||
|
: ikeSessionParams.getIpVersion();
|
||||||
|
final int expectedEncapType = isAutomaticIpVersionSelectionEnabled
|
||||||
|
? ESP_ENCAP_TYPE_AUTO
|
||||||
|
: ikeSessionParams.getEncapType();
|
||||||
doTestMigrateIkeSession(ikeProfile.toVpnProfile(), expectedKeepalive,
|
doTestMigrateIkeSession(ikeProfile.toVpnProfile(), expectedKeepalive,
|
||||||
isAutomaticIpVersionSelectionEnabled);
|
expectedIpVersion, expectedEncapType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTestMigrateIkeSession(VpnProfile profile, int expectedKeepalive,
|
private void doTestMigrateIkeSession(VpnProfile profile,
|
||||||
boolean isAutomaticIpVersionSelectionEnabled) throws Exception {
|
int expectedKeepalive, int expectedIpVersion, int expectedEncapType) throws Exception {
|
||||||
final int expectedIpVersion = isAutomaticIpVersionSelectionEnabled
|
|
||||||
? ESP_IP_VERSION_AUTO : ESP_IP_VERSION_AUTO;
|
|
||||||
final int expectedEncapType = isAutomaticIpVersionSelectionEnabled
|
|
||||||
? ESP_ENCAP_TYPE_AUTO : ESP_IP_VERSION_AUTO;
|
|
||||||
|
|
||||||
final PlatformVpnSnapshot vpnSnapShot =
|
final PlatformVpnSnapshot vpnSnapShot =
|
||||||
verifySetupPlatformVpn(profile,
|
verifySetupPlatformVpn(profile,
|
||||||
createIkeConfig(createIkeConnectInfo(), true /* isMobikeEnabled */),
|
createIkeConfig(createIkeConnectInfo(), true /* isMobikeEnabled */),
|
||||||
@@ -2050,16 +2083,18 @@ public class VpnTest extends VpnTestBase {
|
|||||||
vpnSnapShot.vpn.mVpnRunner.exitVpnRunner();
|
vpnSnapShot.vpn.mVpnRunner.exitVpnRunner();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mockCarrierConfig(int subId, int keepaliveTimer, int simStatus) {
|
private void mockCarrierConfig(int subId, int simStatus, int keepaliveTimer, int ikeProtocol) {
|
||||||
final SubscriptionInfo subscriptionInfo = mock(SubscriptionInfo.class);
|
final SubscriptionInfo subscriptionInfo = mock(SubscriptionInfo.class);
|
||||||
doReturn(subId).when(subscriptionInfo).getSubscriptionId();
|
doReturn(subId).when(subscriptionInfo).getSubscriptionId();
|
||||||
doReturn(List.of(subscriptionInfo)).when(mSubscriptionManager)
|
doReturn(List.of(subscriptionInfo)).when(mSubscriptionManager)
|
||||||
.getActiveSubscriptionInfoList();
|
.getActiveSubscriptionInfoList();
|
||||||
|
|
||||||
doReturn(simStatus).when(mTmPerSub).getSimApplicationState();
|
doReturn(simStatus).when(mTmPerSub).getSimApplicationState();
|
||||||
|
doReturn(TEST_MCCMNC).when(mTmPerSub).getSimOperator(subId);
|
||||||
|
|
||||||
final PersistableBundle persistableBundle = new PersistableBundle();
|
final PersistableBundle persistableBundle = new PersistableBundle();
|
||||||
persistableBundle.putInt(KEY_MIN_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT, keepaliveTimer);
|
persistableBundle.putInt(KEY_MIN_UDP_PORT_4500_NAT_TIMEOUT_SEC_INT, keepaliveTimer);
|
||||||
|
persistableBundle.putInt(KEY_PREFERRED_IKE_PROTOCOL_INT, ikeProtocol);
|
||||||
// For CarrierConfigManager.isConfigForIdentifiedCarrier check
|
// For CarrierConfigManager.isConfigForIdentifiedCarrier check
|
||||||
persistableBundle.putBoolean(KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
|
persistableBundle.putBoolean(KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
|
||||||
doReturn(persistableBundle).when(mConfigManager).getConfigForSubId(subId);
|
doReturn(persistableBundle).when(mConfigManager).getConfigForSubId(subId);
|
||||||
@@ -2076,26 +2111,32 @@ public class VpnTest extends VpnTestBase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNattKeepaliveTimerFromCarrierConfig_noSubId() throws Exception {
|
public void testNattKeepaliveTimerFromCarrierConfig_noSubId() throws Exception {
|
||||||
doTestNattKeepaliveTimerFromCarrierConfig(new NetworkCapabilities(),
|
doTestReadCarrierConfig(new NetworkCapabilities(),
|
||||||
TelephonyManager.SIM_STATE_LOADED, AUTOMATIC_KEEPALIVE_DELAY_SECONDS);
|
TelephonyManager.SIM_STATE_LOADED,
|
||||||
|
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
||||||
|
AUTOMATIC_KEEPALIVE_DELAY_SECONDS /* expectedKeepaliveTimer */,
|
||||||
|
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
||||||
|
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNattKeepaliveTimerFromCarrierConfig_simAbsent() throws Exception {
|
public void testNattKeepaliveTimerFromCarrierConfig_simAbsent() throws Exception {
|
||||||
doTestNattKeepaliveTimerFromCarrierConfig(new NetworkCapabilities.Builder().build(),
|
doTestReadCarrierConfig(new NetworkCapabilities.Builder().build(),
|
||||||
TelephonyManager.SIM_STATE_ABSENT, AUTOMATIC_KEEPALIVE_DELAY_SECONDS);
|
TelephonyManager.SIM_STATE_ABSENT,
|
||||||
|
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
||||||
|
AUTOMATIC_KEEPALIVE_DELAY_SECONDS /* expectedKeepaliveTimer */,
|
||||||
|
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
||||||
|
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNattKeepaliveTimerFromCarrierConfig() throws Exception {
|
public void testNattKeepaliveTimerFromCarrierConfig() throws Exception {
|
||||||
final NetworkCapabilities nc = new NetworkCapabilities.Builder()
|
doTestReadCarrierConfig(createTestCellNc(),
|
||||||
.addTransportType(TRANSPORT_CELLULAR)
|
TelephonyManager.SIM_STATE_LOADED,
|
||||||
.setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
|
PREFERRED_IKE_PROTOCOL_AUTO,
|
||||||
.setSubscriptionId(TEST_SUB_ID)
|
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
||||||
.build())
|
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
||||||
.build();
|
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */);
|
||||||
doTestNattKeepaliveTimerFromCarrierConfig(nc,
|
|
||||||
TelephonyManager.SIM_STATE_LOADED, TEST_KEEPALIVE_TIMER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -2104,17 +2145,62 @@ public class VpnTest extends VpnTestBase {
|
|||||||
.addTransportType(TRANSPORT_WIFI)
|
.addTransportType(TRANSPORT_WIFI)
|
||||||
.setTransportInfo(new WifiInfo.Builder().build())
|
.setTransportInfo(new WifiInfo.Builder().build())
|
||||||
.build();
|
.build();
|
||||||
doTestNattKeepaliveTimerFromCarrierConfig(nc,
|
doTestReadCarrierConfig(nc,
|
||||||
TelephonyManager.SIM_STATE_LOADED, AUTOMATIC_KEEPALIVE_DELAY_SECONDS);
|
TelephonyManager.SIM_STATE_LOADED,
|
||||||
|
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
||||||
|
AUTOMATIC_KEEPALIVE_DELAY_SECONDS /* expectedKeepaliveTimer */,
|
||||||
|
ESP_IP_VERSION_AUTO /* expectedIpVersion */,
|
||||||
|
ESP_ENCAP_TYPE_AUTO /* expectedEncapType */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTestNattKeepaliveTimerFromCarrierConfig(NetworkCapabilities nc, int simState,
|
@Test
|
||||||
int expectedKeepaliveTimer) throws Exception {
|
public void testPreferredIpProtocolFromCarrierConfig_v4UDP() throws Exception {
|
||||||
|
doTestReadCarrierConfig(createTestCellNc(),
|
||||||
|
TelephonyManager.SIM_STATE_LOADED,
|
||||||
|
PREFERRED_IKE_PROTOCOL_IPV4_UDP,
|
||||||
|
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
||||||
|
ESP_IP_VERSION_IPV4 /* expectedIpVersion */,
|
||||||
|
ESP_ENCAP_TYPE_UDP /* expectedEncapType */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPreferredIpProtocolFromCarrierConfig_v6ESP() throws Exception {
|
||||||
|
doTestReadCarrierConfig(createTestCellNc(),
|
||||||
|
TelephonyManager.SIM_STATE_LOADED,
|
||||||
|
PREFERRED_IKE_PROTOCOL_IPV6_ESP,
|
||||||
|
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
||||||
|
ESP_IP_VERSION_IPV6 /* expectedIpVersion */,
|
||||||
|
ESP_ENCAP_TYPE_NONE /* expectedEncapType */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPreferredIpProtocolFromCarrierConfig_v6UDP() throws Exception {
|
||||||
|
doTestReadCarrierConfig(createTestCellNc(),
|
||||||
|
TelephonyManager.SIM_STATE_LOADED,
|
||||||
|
PREFERRED_IKE_PROTOCOL_IPV6_UDP,
|
||||||
|
TEST_KEEPALIVE_TIMER /* expectedKeepaliveTimer */,
|
||||||
|
ESP_IP_VERSION_IPV6 /* expectedIpVersion */,
|
||||||
|
ESP_ENCAP_TYPE_UDP /* expectedEncapType */);
|
||||||
|
}
|
||||||
|
|
||||||
|
private NetworkCapabilities createTestCellNc() {
|
||||||
|
return new NetworkCapabilities.Builder()
|
||||||
|
.addTransportType(TRANSPORT_CELLULAR)
|
||||||
|
.setNetworkSpecifier(new TelephonyNetworkSpecifier.Builder()
|
||||||
|
.setSubscriptionId(TEST_SUB_ID)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doTestReadCarrierConfig(NetworkCapabilities nc, int simState, int preferredIpProto,
|
||||||
|
int expectedKeepaliveTimer, int expectedIpVersion, int expectedEncapType)
|
||||||
|
throws Exception {
|
||||||
final Ikev2VpnProfile ikeProfile =
|
final Ikev2VpnProfile ikeProfile =
|
||||||
new Ikev2VpnProfile.Builder(TEST_VPN_SERVER, TEST_VPN_IDENTITY)
|
new Ikev2VpnProfile.Builder(TEST_VPN_SERVER, TEST_VPN_IDENTITY)
|
||||||
.setAuthPsk(TEST_VPN_PSK)
|
.setAuthPsk(TEST_VPN_PSK)
|
||||||
.setBypassable(true /* isBypassable */)
|
.setBypassable(true /* isBypassable */)
|
||||||
.setAutomaticNattKeepaliveTimerEnabled(true)
|
.setAutomaticNattKeepaliveTimerEnabled(true)
|
||||||
|
.setAutomaticIpVersionSelectionEnabled(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final PlatformVpnSnapshot vpnSnapShot =
|
final PlatformVpnSnapshot vpnSnapShot =
|
||||||
@@ -2131,10 +2217,10 @@ public class VpnTest extends VpnTestBase {
|
|||||||
verify(mIkeSessionWrapper, never()).setNetwork(any(), anyInt(), anyInt(), anyInt());
|
verify(mIkeSessionWrapper, never()).setNetwork(any(), anyInt(), anyInt(), anyInt());
|
||||||
|
|
||||||
reset(mIkeSessionWrapper);
|
reset(mIkeSessionWrapper);
|
||||||
mockCarrierConfig(TEST_SUB_ID, TEST_KEEPALIVE_TIMER, simState);
|
mockCarrierConfig(TEST_SUB_ID, simState, TEST_KEEPALIVE_TIMER, preferredIpProto);
|
||||||
vpnSnapShot.nwCb.onCapabilitiesChanged(TEST_NETWORK_2, nc);
|
vpnSnapShot.nwCb.onCapabilitiesChanged(TEST_NETWORK_2, nc);
|
||||||
verify(mIkeSessionWrapper).setNetwork(TEST_NETWORK_2,
|
verify(mIkeSessionWrapper).setNetwork(TEST_NETWORK_2,
|
||||||
ESP_IP_VERSION_AUTO, ESP_ENCAP_TYPE_AUTO, expectedKeepaliveTimer);
|
expectedIpVersion, expectedEncapType, expectedKeepaliveTimer);
|
||||||
|
|
||||||
reset(mExecutor);
|
reset(mExecutor);
|
||||||
reset(mIkeSessionWrapper);
|
reset(mIkeSessionWrapper);
|
||||||
@@ -2143,7 +2229,7 @@ public class VpnTest extends VpnTestBase {
|
|||||||
listener.onCarrierConfigChanged(1 /* logicalSlotIndex */, TEST_SUB_ID,
|
listener.onCarrierConfigChanged(1 /* logicalSlotIndex */, TEST_SUB_ID,
|
||||||
-1 /* carrierId */, -1 /* specificCarrierId */);
|
-1 /* carrierId */, -1 /* specificCarrierId */);
|
||||||
verify(mIkeSessionWrapper).setNetwork(TEST_NETWORK_2,
|
verify(mIkeSessionWrapper).setNetwork(TEST_NETWORK_2,
|
||||||
ESP_IP_VERSION_AUTO, ESP_ENCAP_TYPE_AUTO, expectedKeepaliveTimer);
|
expectedIpVersion, expectedEncapType, expectedKeepaliveTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user