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

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

Merge "VCN: Explicitly handle IAE from updating underlying network" am:...

Merge "VCN: Explicitly handle IAE from updating underlying network" am: 9c30117b am: 408a6ca7 am: 265fce32 am: 4416a185 am: 5630e7a0

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



Change-Id: If16b2c49b209eb5e62403bd6f68fc52d0bd3f0ad
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents f45e4c77 5630e7a0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1889,7 +1889,7 @@ public class VcnGatewayConnection extends StateMachine {
                    mIpSecManager.applyTunnelModeTransform(
                            tunnelIface, IpSecManager.DIRECTION_FWD, transform);
                }
            } catch (IOException e) {
            } catch (IOException | IllegalArgumentException e) {
                logInfo("Transform application failed for network " + token, e);
                sessionLost(token, e);
            }
+28 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.argThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
@@ -345,6 +346,33 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
        verify(mConnMgr).reportNetworkConnectivity(eq(mNetworkAgent.getNetwork()), eq(false));
    }

    @Test
    public void testMigrationHandleFailure() throws Exception {
        triggerChildOpened();
        mTestLooper.dispatchAll();
        assertEquals(mIkeConnectionInfo, mGatewayConnection.getIkeConnectionInfo());

        mGatewayConnection
                .getUnderlyingNetworkControllerCallback()
                .onSelectedUnderlyingNetworkChanged(TEST_UNDERLYING_NETWORK_RECORD_2);

        final IkeSessionConnectionInfo newIkeConnectionInfo =
                new IkeSessionConnectionInfo(
                        TEST_ADDR_V4, TEST_ADDR_V4_2, TEST_UNDERLYING_NETWORK_RECORD_2.network);
        getIkeSessionCallback().onIkeSessionConnectionInfoChanged(newIkeConnectionInfo);
        getChildSessionCallback()
                .onIpSecTransformsMigrated(makeDummyIpSecTransform(), makeDummyIpSecTransform());

        doThrow(new IllegalArgumentException("testMigrationHandleFailure"))
                .when(mIpSecSvc)
                .setNetworkForTunnelInterface(anyInt(), any(), any());

        mTestLooper.dispatchAll();

        assertEquals(mGatewayConnection.mDisconnectingState, mGatewayConnection.getCurrentState());
        verify(mIkeSession).close();
    }

    private void triggerChildOpened() {
        triggerChildOpened(Collections.singletonList(TEST_INTERNAL_ADDR), TEST_DNS_ADDR);
    }