Lorenzo Colitti 977464ef5a Pass in proper NetworkCapabilities in testSetUnderlyingNetworks.
The CL that introduced testSetUnderlyingNetworks allowed tests to
pass in NetworkCapabilities when registering an agent, but
incorrectly always set the agent's capabilities anyway. This
resulted in testSetUnderlyingNetworks registering an agent with
TRANSPORT_VPN and NET_CAPABILITY_NOT_VPN.

Fix this by ensuring that createNetworkAgent either uses the
passed-in capabilities unmodified, or creates its own. Assert
that the test VPN network does not have NET_CAPABILITY_NOT_VPN.

While I'm at it, remove the manual unregistration of the callback
by using the registerNetworkCallback helper method.

Also add a little bit of extra test coverage.

Bug: 173331190
Test: test-only change
Change-Id: I114d876a1b2bf5344dd7c6fa23862df1c0a412c3
2020-12-08 01:15:32 +09:00
Description
android_packages_modules_Connectivity
189 MiB
Languages
Java 81.4%
Kotlin 7.7%
AIDL 4.5%
C++ 4.5%
C 1.7%
Other 0.1%