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

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

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

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

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

Change-Id: I94d750ce60a8caaeb221875cfa8ef3f570863ab9
parents 460b46ba faf572b9
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -83,7 +83,7 @@ public final class IkeSessionParamsUtils {
    /** Serializes an IkeSessionParams to a PersistableBundle. */
    /** Serializes an IkeSessionParams to a PersistableBundle. */
    @NonNull
    @NonNull
    public static PersistableBundle toPersistableBundle(@NonNull IkeSessionParams params) {
    public static PersistableBundle toPersistableBundle(@NonNull IkeSessionParams params) {
        if (params.getConfiguredNetwork() != null || params.getIke3gppExtension() != null) {
        if (params.getNetwork() != null || params.getIke3gppExtension() != null) {
            throw new IllegalStateException(
            throw new IllegalStateException(
                    "Cannot convert a IkeSessionParams with a caller configured network or with"
                    "Cannot convert a IkeSessionParams with a caller configured network or with"
                            + " 3GPP extension enabled");
                            + " 3GPP extension enabled");
+1 −1
Original line number Original line Diff line number Diff line
@@ -2127,7 +2127,7 @@ public class VcnGatewayConnection extends StateMachine {
                (VcnControlPlaneIkeConfig) mConnectionConfig.getControlPlaneConfig();
                (VcnControlPlaneIkeConfig) mConnectionConfig.getControlPlaneConfig();
        final IkeSessionParams.Builder builder =
        final IkeSessionParams.Builder builder =
                new IkeSessionParams.Builder(controlPlaneConfig.getIkeSessionParams());
                new IkeSessionParams.Builder(controlPlaneConfig.getIkeSessionParams());
        builder.setConfiguredNetwork(network);
        builder.setNetwork(network);


        return builder.build();
        return builder.build();
    }
    }
+1 −13
Original line number Original line 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.assertEquals;
import static org.junit.Assert.fail;
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.ChildSaProposal;
import android.net.ipsec.ike.IkeFqdnIdentification;
import android.net.ipsec.ike.IkeFqdnIdentification;
import android.net.ipsec.ike.IkeSaProposal;
import android.net.ipsec.ike.IkeSaProposal;
@@ -56,20 +51,13 @@ public class VcnControlPlaneIkeConfigTest {
                        .addPseudorandomFunction(PSEUDORANDOM_FUNCTION_AES128_XCBC)
                        .addPseudorandomFunction(PSEUDORANDOM_FUNCTION_AES128_XCBC)
                        .build();
                        .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 serverHostname = "192.0.2.100";
        final String testLocalId = "test.client.com";
        final String testLocalId = "test.client.com";
        final String testRemoteId = "test.server.com";
        final String testRemoteId = "test.server.com";
        final byte[] psk = "psk".getBytes();
        final byte[] psk = "psk".getBytes();


        IKE_PARAMS =
        IKE_PARAMS =
                new IkeSessionParams.Builder(mockContext)
                new IkeSessionParams.Builder()
                        .setServerHostname(serverHostname)
                        .setServerHostname(serverHostname)
                        .addSaProposal(ikeProposal)
                        .addSaProposal(ikeProposal)
                        .setLocalIdentification(new IkeFqdnIdentification(testLocalId))
                        .setLocalIdentification(new IkeFqdnIdentification(testLocalId))
+1 −2
Original line number Original line Diff line number Diff line
@@ -58,8 +58,7 @@ public class VcnGatewayConnectionConnectingStateTest extends VcnGatewayConnectio
                ArgumentCaptor.forClass(IkeSessionParams.class);
                ArgumentCaptor.forClass(IkeSessionParams.class);
        verify(mDeps).newIkeSession(any(), paramsCaptor.capture(), any(), any(), any());
        verify(mDeps).newIkeSession(any(), paramsCaptor.capture(), any(), any(), any());
        assertEquals(
        assertEquals(
                TEST_UNDERLYING_NETWORK_RECORD_1.network,
                TEST_UNDERLYING_NETWORK_RECORD_1.network, paramsCaptor.getValue().getNetwork());
                paramsCaptor.getValue().getConfiguredNetwork());
    }
    }


    @Test
    @Test