Merge "Use #setNetwork and #getNetwork for IkeSessionParams" am: 3022c5437c am: cc0c3a5f62

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1675285

Change-Id: I4c2cce2cbf18eda19b0f9a26cb2a2d93a78ddbfa
This commit is contained in:
Yan Yan
2021-04-19 19:14:30 +00:00
committed by Automerger Merge Worker
4 changed files with 4 additions and 17 deletions

View File

@@ -83,7 +83,7 @@ public final class IkeSessionParamsUtils {
/** Serializes an IkeSessionParams to a PersistableBundle. */
@NonNull
public static PersistableBundle toPersistableBundle(@NonNull IkeSessionParams params) {
if (params.getConfiguredNetwork() != null || params.getIke3gppExtension() != null) {
if (params.getNetwork() != null || params.getIke3gppExtension() != null) {
throw new IllegalStateException(
"Cannot convert a IkeSessionParams with a caller configured network or with"
+ " 3GPP extension enabled");

View File

@@ -2106,7 +2106,7 @@ public class VcnGatewayConnection extends StateMachine {
(VcnControlPlaneIkeConfig) mConnectionConfig.getControlPlaneConfig();
final IkeSessionParams.Builder builder =
new IkeSessionParams.Builder(controlPlaneConfig.getIkeSessionParams());
builder.setConfiguredNetwork(network);
builder.setNetwork(network);
return builder.build();
}

View File

@@ -22,12 +22,7 @@ import static android.net.ipsec.ike.SaProposal.PSEUDORANDOM_FUNCTION_AES128_XCBC
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.ipsec.ike.ChildSaProposal;
import android.net.ipsec.ike.IkeFqdnIdentification;
import android.net.ipsec.ike.IkeSaProposal;
@@ -56,20 +51,13 @@ public class VcnControlPlaneIkeConfigTest {
.addPseudorandomFunction(PSEUDORANDOM_FUNCTION_AES128_XCBC)
.build();
Context mockContext = mock(Context.class);
ConnectivityManager mockConnectManager = mock(ConnectivityManager.class);
doReturn(mockConnectManager)
.when(mockContext)
.getSystemService(Context.CONNECTIVITY_SERVICE);
doReturn(mock(Network.class)).when(mockConnectManager).getActiveNetwork();
final String serverHostname = "192.0.2.100";
final String testLocalId = "test.client.com";
final String testRemoteId = "test.server.com";
final byte[] psk = "psk".getBytes();
IKE_PARAMS =
new IkeSessionParams.Builder(mockContext)
new IkeSessionParams.Builder()
.setServerHostname(serverHostname)
.addSaProposal(ikeProposal)
.setLocalIdentification(new IkeFqdnIdentification(testLocalId))

View File

@@ -58,8 +58,7 @@ public class VcnGatewayConnectionConnectingStateTest extends VcnGatewayConnectio
ArgumentCaptor.forClass(IkeSessionParams.class);
verify(mDeps).newIkeSession(any(), paramsCaptor.capture(), any(), any(), any());
assertEquals(
TEST_UNDERLYING_NETWORK_RECORD_1.network,
paramsCaptor.getValue().getConfiguredNetwork());
TEST_UNDERLYING_NETWORK_RECORD_1.network, paramsCaptor.getValue().getNetwork());
}
@Test