NetdUtils has the same method(e.g. setInterfaceUp) as
NetworkManagementService so using the one inside NetdUtils instead
and try to remove NetworkManagementService from IpSecService in
the following commit.
Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: I0ed8b0c678b067a655b51b938b6b40eadd985321
This is mainly used by VCN, where VCN-eligible networks might
be registered before VCN management service can fire request
to prevent the newly created network from being torndown
immediately by ConnectivityService.
Test: atest ConnectivityServiceTest#testNewNetworkLingering
atest ConnectivityServiceTest#testNewNetworkLingering_bgNetwork
atest FrameworksNetTests --rerun-until-failure 20
Bug: 175180558
Change-Id: I7768daf4cf2d8f6d8057b5107412e06104ba82e0
These tests do not actually work, or at least not as designed.
What happens when they are run is that creating/connecting the
VPN throws an exception. The call to legacyRunnerReady.block()
times out after 10 seconds because the condition variable is
never opened, but the doesn't notice the timeout becasue it
doesn't check the return value of block().
There are two reasons for the VPN not coming up.
1. VpnConfig.getIntentForStatusPanel calls into PendingIntent and
ActivityManager statics, which bypass all the mocks and fail
with an appops denial. Fix this by making it a dependency.
2. The tests are broken due to the UserManager API changes
tracked in b/175883995. Fixing by adding a bit of ad-hoc code
into startLegacyVpn, with a TODO to delete it once the rest of
the UserManager setup code is fixed.
Fix these and check the return value of block(). This ensures
that if any other breakage is added the test will actually fail.
Also check that the throw route survives all the way to the
LinkProperties sent to the agent.
Bug: 173331190
Test: atest com.android.server.connectivity.VpnTest
Change-Id: Ieb7f33bce283ac5ee562a912df8edb9c930ed2b0
ConnectivityService is going to become a mainline module which
will not able to access hidden APIs. NetworkPolicyManagerInternal
is a internal serivce that CS can't be access after be a mainline
module. Thus, create NPM#checkUidNetworkingBlocked to replace it.
Bug: 170598012
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases
Test: atest CtsHostsideNetworkTests
Test: atest FrameworksCoreTests:NetworkPolicyManagerTest
Test: atest FrameworksServicesTests:NetworkPolicyManagerServiceTest
Change-Id: I7bee37522dc5c55c255b159fda9481eff663655a
This patch addressses the mocked UserManager for the context
of the user which is created by createContextAsUser.
Bug: 171529940
Bug: 175883995
Test: FrameworksNetTests
Change-Id: Ie72d08c765ed7fb7083c0c4b7ee02a43c23d1707
Currently, the tests only check whether the method throws a
SecurityException or not. Also check the return value of the
call, by mocking out InetDiagMessage.getConnectionOwnerUid.
This is required to test an upcoming change that will never
throw SecurityException but always return INVALID_UID if the
caller lacks permissions.
Bug: 173331190
Test: test-only change
Change-Id: I63f42a2f098fcf8796c9b4525a3a7b8320c0a139
There is strong opposition in the team to this rename.
Reverting to the old language.
Test: FrameworksNetTests
Change-Id: Icefa3090966c07fd66692ddd5b44dfc94485a914
This will be used by a future change that makes the legacy
lockdown VPN pass the underlying network.
Bug: 173331190
Test: tests in subsequent CLs in stack
Change-Id: I09366a7f872ef3d4538962a75b0114a2ecb536e6
Updating ConnectivityService foundational support for multiple default
networks by extending mDefaultRequest and mDefaultNetworkNai from single
instances to a HashMap to support more than a single default network.
Bug: 176027457
Bug: 172347841
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk
Change-Id: I2f5fa96c2d21ab883499e82afa74e73f3ca606cd
This simplifies the uidNetworkingBlocked method and makes it more
realistic by supporting more combinations of rules than just the
four used by this test.
Also support RULE_ALLOW_METERED, and add test coverage for it.
Test: test-only change
Change-Id: Id4f6c7f41429f3ae7841d3214b3e5e95ec591f85
The score argument is going away, so there no longer
is a need to test it. It's never been used by anybody
and is actually a problem going forward.
Since removing the argument requires a small re-arch
of the testing tool anyway, rebuild expecting requests
on top of TrackRecord. This simplifies the test a
great deal, as well as (as observed in running the
tests) makes the test faster.
Test: this
Change-Id: If03b9e64f14ac8ffa5398b964939a9a45a74b28d
As a preparation of exposing system API. This patch does some
harmless refactoring, which includes:
1. Change raw arrays into lists according to API guidelines.
2. Write test.
3. Rename class to UnderlyingNetworkInfo.
4. Rename vpnIface to iface.
5. Make underlyingIfaces @NonNull in order to adapt new
unparceling code.
6. implement equals and hashCode for testing.
Test: atest android.net.UnderlyingNetworkInfoTest
Bug: 174123988
Change-Id: I405c21e57c4af8a12a9dd0a1749b9e6690f87045
This will be mainly used by VCN management service which will
need to hold the networks but preserve the backgrounded-ness
of the networks.
Test: android.net.ConnectivityManagerTest#testRequestType
Test: android.net.cts.ConnectivityManagerTest#testRequestBackgroundNetwork /
--rerun-until-failure 100
Test: ConnectivityServiceTest#testBackgroundNetworks
Test: m -j doc-comment-check-docs
Bug: 175662146
Change-Id: I463c7a3139a286e50ea71e674060975ce228caa9
Previously BouncyCastle methods were exposed as libcore APIs (@CorePlatformApi), which no longer possible when ART is updatable module (and can't guarantee BouncyCastle API stability)
Bug: 154796679
Test: Treehugger
Change-Id: I908681841a6766de88761767c77c4e2d4b5f56d5
Instead of classifying interfaces by network type in BatteryStats,
classify them based on the transports array provided by the
NetworkAgent.
Network types are deprecated and transports should be used instead. This
change allows BatteryStats to stop depending on unstable APIs such as
isNetworkTypeMobile.
This change also updates nullability annotations in ConnectivityService
and NetworkAgentInfo to show that the NetworkCapabilities are non-null
(as provided by the network agent) when calling
noteNetworkInterfaceTransports.
Bug: 174436414
Test: atest
atest ConnectivityServiceTest#testBatteryStatsNetworkType \
--rerun-until-failure 40
Merged-In: I4e928fac8a57a9b1fc758a44af2a5719b8c871b8
Change-Id: I4e928fac8a57a9b1fc758a44af2a5719b8c871b8
Add new capability to indicate whether a network is
managed by Virtual Carrier Network (VCN). This is needed
to identify networks between VCN managed network and
others. And this capability will be:
1. mutable
2. requestable
3. set by default for network agents and requests
4. allowed for test networks
Note that this commit is identical to aosp/1529959 except the
capability remains hidden to address the javadoc problem first.
And this CL also needs to be bound with the counter part change
to prevent build breakage.
Test: 1. atest FrameworksNetTests CtsNetTestCases
2. adb shell dumpsys connectivity
3. atest ConnectivityServiceTest#testLoseMutableAndRequestableCaps
Bug: 175662146
Change-Id: I37a6f492c2aba72836e36851b50b67398f8bdd36
As a preparation of exposing system API. This patch does some
harmless refactoring, which includes:
1. Move VpnInfo to android.net
2. Add nullability annotations
3. Make members final
Bug: 174123988
Test: TH
Change-Id: I1530bb45d0e84c28c6deac33596bc686058afc0d
In follow-up patches, the network type will be derived from
transport types, which officially doesn't support wimax.
Thus, remove the test which rely on it first since it is
not needed and will not be needed.
Test: atest FrameworksNetTests
Bug: 174123988
Change-Id: I713bc2ec39e3a4fa19ed13d2e9ff9ae35477d726
This allows subsequent patches to remove the need of exposing
SSID in NetworkState.
Test: atest NetworkStatsServiceTest
Bug: 174123988
Change-Id: Ib9ab07c9610954c9a5de035a3aefbf6d0bb0b53b
* The match method is only for local address and port since we have
no other use case.
Bug: 155176305
Test: Added new test
Change-Id: I7b45f9912af6a192fc60606f5e0b4cc479aea93f
* Provide App Developers Qos related info associated to
a bound socket through ConnectivityManager
* Qos sessions are generated and filtered by Network Agents
and sent back through the Connectivity Service to the
API consumer.
* The structure of the code within com.android.server
is designed to support different types of filters in the
the future.
* The first type of Qos Attributes are related to EPS
Bearers in order support RCS.
Bug: 155176305
Test: Added to cts/NetworkAgentTest
Test: Added to ConnectivityServiceTest
Change-Id: I145dd065d9deeee449eb9695ab3f6c8556ee7c09
Currently, when the VPN underlying network changes from a
network that is not suspended to one that is suspended (or vice
versa), some of the legacy APIs return incorrect results.
This is because the VPN's NetworkInfo can get into SUSPENDED
state even though the capabilities have the NOT_SUSPENDED
capability. This happens because the code in updateCapabilities
that checks for changes in NOT_SUSPENDED and NOT_ROAMING (which
are the capabilities that can affect the NetworkInfo state) is
only run when the capabilities change in a certain way.
Fix this by always checking for changes in these capabilities,
regardless of what else has changed.
This results in sending a lot more SUSPENDED and RESUMED
callbacks than the code sent previously. This should hopefully
not impact apps because those callback methods have never been
public API, though because they're just callbacks, it's possible
that apps found out via code inspection that the callbacks
existed and implemented them.
Bug: 172870110
Test: changes to existing tests in ConnectivityServiceTest
Change-Id: I6ec246a6a4e61f634956a165797fbb80296efd6a
* changes:
Address comments on aosp/1539753, aosp/1542487 and aosp/1547496.
Fix propagating underlying caps when a network disconnects.
Test for bugs with suspended VPN underlying networks.
aosp/1513052, which generalized support for underlying networks,
broke default network switching when the network underlying a VPN
disconnects.
This is because it calls propagateUnderlyingNetworkCapabilities
in the middle of the bookkeeping operations needed when a
network is disconnected (specifically, after all satisified
requests are removed from the disconnecting network, but before
mDefaultNetworkNai is updated). This is completely incorrect
because propagateUnderlyingNetworkCapabilities can trigger a
network rematch, and running a rematch when the request data
structures are inconsistent is obviously wrong. See the test
changes in this CL for an example of the damage.
Fix this by moving propagateUnderlyingNetworkCapabilities to
before the bookeeping operations begin. It must be before
mDefaultNetworkNai is updated, because otherwise it will not know
that the default network is disconnecting, and it will not be
able to propagate capabilities to VPNs that set underlying
networks to null (i.e., to the default network). It must be
after the nai is removed from mNetworkForNetId because
otherwise it will think that the underlying network is still
connected.
Bug: 173331190
Test: accompanying unit test shows lots of bugs removed
Change-Id: Ibf376a6fa4b34d1c96f8506fa8abbb7595a8c272
This will be mainly used by VCN management service which will
need to hold the networks but preserve the backgrounded-ness
of the networks.
Test: android.net.ConnectivityManagerTest#testRequestType
Test: android.net.cts.ConnectivityManagerTest#testRequestBackgroundNetwork /
--rerun-until-failure 100
Test: ConnectivityServiceTest#testBackgroundNetworks
Test: m -j doc-comment-check-docs
Bug: 175662146
Change-Id: If9aaa87b7e71c2b695ac7b08858850e975b28bb6
This test flakes about 1% of the time on my device. This is due
to the test calling expectNetworkRejectNonSecureVpn() before the
handler thread has processed the call to setAlwaysOnVpnPackage.
Fix this by waiting for callbacks where it is possible to do so,
and by calling waitForIdle where it is not.
Test: test-only change
Change-Id: Ic5750d4fdf9e7e3654a2b6ade74da6bc5de18fb6
Code review comments have suggested that this test is too long
and difficult to understand. Split it into two tests and put some
of the common setup into setup methods and statics.
Bug: 173331190
Test: test-only change
Change-Id: I9fa888c940d7048f1ba6836a5706fbdb84b5f5c9