Merge changes from topic "cherrypicker-L68400000960711014:N74200001369704906" into udc-dev

* changes:
  Fix agents disconnecting in SUSPENDED state.
  Check clatd does not stop when suspended network is disconnected
This commit is contained in:
Motomu Utsumi
2023-05-17 06:19:24 +00:00
committed by Android (Google) Code Review
3 changed files with 48 additions and 1 deletions

View File

@@ -17987,4 +17987,33 @@ public class ConnectivityServiceTest {
verify(mDeps).destroyLiveTcpSockets(eq(UidRange.toIntRanges(ranges)),
eq(exemptUids));
}
@Test
public void testDisconnectSuspendedNetworkStopClatd() throws Exception {
final TestNetworkCallback networkCallback = new TestNetworkCallback();
final NetworkRequest networkRequest = new NetworkRequest.Builder()
.addCapability(NET_CAPABILITY_DUN)
.build();
mCm.requestNetwork(networkRequest, networkCallback);
final IpPrefix nat64Prefix = new IpPrefix(InetAddress.getByName("64:ff9b::"), 96);
NetworkCapabilities nc = new NetworkCapabilities().addCapability(NET_CAPABILITY_DUN);
final LinkProperties lp = new LinkProperties();
lp.setInterfaceName(MOBILE_IFNAME);
lp.addLinkAddress(new LinkAddress("2001:db8:1::1/64"));
lp.setNat64Prefix(nat64Prefix);
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR, lp, nc);
mCellAgent.connect(true /* validated */, false /* hasInternet */,
false /* privateDnsProbeSent */);
verifyClatdStart(null /* inOrder */, MOBILE_IFNAME, mCellAgent.getNetwork().netId,
nat64Prefix.toString());
mCellAgent.suspend();
mCm.unregisterNetworkCallback(networkCallback);
mCellAgent.expectDisconnected();
waitForIdle();
verifyClatdStop(null /* inOrder */, MOBILE_IFNAME);
}
}