Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit faf572b9 authored by Yan Yan's avatar Yan Yan Committed by Automerger Merge Worker
Browse files

Merge "Use #setNetwork and #getNetwork for IkeSessionParams" am: 3022c543 am: cc0c3a5f

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

Change-Id: I4c2cce2cbf18eda19b0f9a26cb2a2d93a78ddbfa
parents 9c0a2e06 cc0c3a5f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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");
+1 −1
Original line number Diff line number Diff line
@@ -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();
    }
+1 −13
Original line number Diff line number Diff line
@@ -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))
+1 −2
Original line number Diff line number Diff line
@@ -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