Commit Graph

35 Commits

Author SHA1 Message Date
lucaslin
23efc5812a Remove INetworkManagementService from ConnectivityService
Remove INetworkManagementService from ConnectivityService and
related files.

Bug: 174837473
Test: atest FrameworksNetTests FrameworksNetIntegrationTests
Change-Id: Ie6cfd77bbd64a8fd7539b0ea7fd15bf970e40c3d
2021-02-25 15:08:28 +08:00
paulhu
17ca040931 Stop using SysetmConfig#getSystemPermissions on PermissionMonitor
Repalace the API with SysetmConfigManager#getSystemPermissionUids
and update the design/test accordingly.

Bug: 177188455
Test: atest FrameworksNetTests
Test: atest FrameworksNetIntegrationTests
Test: atest CtsNetTestCases
Change-Id: I8b553b934252b93c60b815715680427a41620054
2021-02-20 16:20:19 +08:00
Remi NGUYEN VAN
5027ebbfcb Revert "[VCN07] Bypass VCN for non-internet app accessible cellu..."
Revert submission 1579872-vcn07

Reason for revert: Possible culprit for b/179768816, broken ConnectivityControllerTest
Reverted Changes:
Id09b19c13:Address comments on aosp/1550755
I245bd69e0:[VCN07.1] Add test for bypassing VCN for non-inter...
I9936894b9:[VCN07] Bypass VCN for non-internet app accessible...

Change-Id: Ie5f8c3051fed40623e5d4705ac2243ef51a898bd
2021-02-12 04:09:15 +00:00
junyulai
2fc40da076 [VCN07] Bypass VCN for non-internet app accessible cellular services
Deduce the NET_CAPABILITY_NOT_VCN_MANAGED capability from other
capabilities and user intention, which includes:
   1. For the requests that don't have anything besides
      VCN_SUPPORTED_CAPABILITIES, add the NOT_VCN_MANAGED to
      allow the callers automatically utilize VCN networks
      if available.
   2. For the requests that explicitly add or remove
      NOT_VCN_MANAGED,  do not alter them to allow user fire
      request that suits their need.

Test: atest NetworkRequestTest#testBypassingVcnForNonInternetRequest
Bug: 175662146
Change-Id: I9936894b9530a22fb186cfd25cbee0fced65b72b
2021-02-04 17:07:23 +08:00
paulhu
9fb1358ccf Fix FrameworksNetIntegrationTests failure
The test is broken because CS is using
sendStickyBroadcast with all users context instead of
sendStickyBroadcastAsUser to send sticky broadcast. So update
related code on ConnectivityServiceIntegrationTest.

Bug: 178367782
Test: atest FrameworksNetIntegrationTests
      atest FrameworksNetTests
Change-Id: I7ad94fa31ea16025e6ad62d41235978f45be5d99
2021-01-25 23:40:06 +08:00
Daniel Bright
f9e945b074 Add Qos Callback support
* 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
2021-01-21 20:14:52 -08:00
paulhu
caa2c0dabe Remove unused IpConnectivityMetrics in CS
ConnectivityService doesn't call any IpConnectivityMetrics
methods, so remove all usages from CS.

Bug: 177656797
Test: atest FrameworksNetTests
Test: atest FrameworksNetIntegrationTests
Change-Id: I2fb3b6b08cd8013eb8f75882f77ca699a2df927e
2021-01-18 04:03:32 +00:00
paulhu
9a9f71bbc8 Replace INetworkPolicyManager to NetworkPolicyManager
Connectivity service is going to become a mainline module which
will not able to access hidden APIs. Thus, use formal API
Context#getSystemService() to get network policy service instead
of hidden API ServiceManager#getService().

Bug: 170598012
Test: atest FrameworksNetTests FrameworksNetIntegrationTests
Change-Id: I4f286264b5800b2b922f85a76ddd20d64d53000a
2021-01-05 17:47:25 +08:00
Chalard Jean
0d3680c12c Migrate NetworkAgentWrapper to the new NA API
Test: FrameworksNetTests NetworkStackTests
Bug: 167544279
Change-Id: I5d53a938572682dea827ea681596226b1e271aa6
2020-12-08 19:43:10 +09:00
Lorenzo Colitti
4489abdb15 Make MockVpn more realistic and easier to use.
MockVpn is very difficult to use because it requires the test
caller keeping track of both the MockVpn object and an
accompanying TestNetworkAgentWrapper.

It's also not very realistic: for example, connect() doesn't
actually connect anything, it just makes it so that if
ConnectivityService tries to update the capabilities, the attempt
will not be ignored. Also, unlike the real code in Vpn, it
connects with empty NetworkCapabilities (in particular, with
empty UID ranges).

Make this easier to use and a bit more realistic by:
- Allowing TestNetworkAgentWrapper to take a "NetworkCapabilities
  template" that will form the initial capabilities sent when the
  agent registers with ConnectivityService. This allows the VPN
  to register its agent with its UID ranges already set, like the
  production code does.
- Providing separate methods to register the NetworkAgent and
  mark it connected for cases where the test needs to make
  changes to the NetworkAgent before connecting (e.g., poking
  NetworkMonitor).
- Putting the TestNetworkAgentWrapper inside MockVpn and driving
  it through MockVpn's methods. In order not to have too many
  wrapper functions (and because we can't delegate like in
  Kotlin), there's still an agent() method that returns the
  TestNetworkAgentWrapper.

Bug: 173331190
Test: test-only change
Change-Id: I749ff325bc13ac96f512270b86d1f67686eec378
2020-11-19 16:23:07 +09:00
Lorenzo Colitti
d00e0b8757 Test a VPN with an underlying network that does not yet exist.
This test checks that if a VPN declares an underlying network
that does not exist, the capabilities of that network are applied
to the VPN as soon as the network starts to exist.

Bug: 173331190
Test: test-only change
Change-Id: Icc0701cb4cea7d91f7738c1e426e94cd26686b74
2020-11-19 14:46:32 +09:00
Aaron Huang
9601189364 Create service-connectivity.jar
Create a new target service-connectivity to split
ConnectivityService from services.core.

Add ConnectivityServiceInitializer for initializing
ConnectivityService and add systemReady() in
ConnectivityManager so that SystemServer can call systemReady()
through ConnectivityManager which won't change current behavior.

Bug: 158268939
Test: make target-java, make host-java
      atest FrameworksNetIntegrationTests
      atest FrameworksNetTests
      make, device can boot,
      atest CtsStrictJavaPackagesTestCases
      wifi and mobile data work.
Change-Id: I99401772ba9c1c34adca20040da3c7c72d86ddd9
Merged-In: Ie732bfaf381404af0bb599ca2f421a96e7aa4257
2020-10-16 22:46:14 +08:00
Chalard Jean
ae98b5f35f Don't let NAW.mNetworkInfo escape
Thankfully this has no users.

This agent needs to be migrated to the modern API for
NetworkAgent, which does not have NetworkInfo at all
so this would be a hindrance

Test: FrameworksNetTests NetworkStackTests
Change-Id: I091a6ca8cdf18860f23832ae1008fa02cf0472e8
2020-10-09 17:06:30 +09:00
junyulai
65f64a9731 Skip stop if keepalive is already in stopping state
In current design, crash has been generated when stop function
has been re-entered to catch unexpected behavior. However,
it is possible to re-enter stop function if the network
disconnection occurs after stopping.

Thus, skip stop if keepalive is already in stopping state.

Test: atest ConnectivityServiceTest#testNattSocketKeepalives \
      --rerun-until-failure 60000
Bug: 167332570
Change-Id: Ic7068ad3dc990e957c37b8d87d48ebb6469b101f
2020-09-17 19:51:34 +08:00
Chalard Jean
39175f2670 Rename Kotlin util files to not include the Kt suffix
Callers don't care what language the utilities are written in

Test: builds
Change-Id: Ie212144f36c50db223c05f3fcb6bad745842cb5e
2020-08-12 10:02:50 +09:00
Remi NGUYEN VAN
2ce373abf2 Add integration test for capport API
Add a test to verify the ConnectivityService / NetworkMonitor
integration around the captive portal API.

Test: atest ConnectivityServiceIntegrationTest
Bug: 156062304
Change-Id: I4eed02e09fc4943c011d871c58ba97ec572c7763
2020-05-20 15:11:14 +09:00
Remi NGUYEN VAN
d68de90e40 Add an exported flag in integration tests manifest
(partial cherry-pick of internal change:
I4457ff2bd466a4c56fed2570e110f251031c2385)

With b/150232615, we will need an explicit value set for the exported
flag when intent filters are present, as the default behavior is
changing for S+. This change adds the value reflecting the previous
default to the manifest.

These changes were made using an automated tool, the xml file may be
reformatted slightly creating a larger diff. The only "real" change is
the addition of "android:exported" to activities, services, and
receivers that have one or more intent-filters.

Bug: 150232615
Test: TH
Merged-In: I4457ff2bd466a4c56fed2570e110f251031c2385
Change-Id: I65a1ca1678048bbf09edc9a0485b673644c8109d
2020-05-19 17:53:32 +09:00
Chalard Jean
fbd6a2c012 Fix a bug where VPNs start out suspended on cellular
As NetworkAgent is in a transition where all agents need
to include the NOT_SUSPENDED capability as part of their
migration to the system API, ConnectivityService adds it
forcefully to all agents that don't have the CELLULAR
transport. This doesn't include VPNs when VPNs have some
cellular network as their underlying network.

The best way to solve this is to make sure the VPN
capabilities reflect those of the underlying networks as
far as the NOT_SUSPENDED capability is concerned. This
is how they work for other similar capabilities.

This also happens to contain a drive-by fix for an issue
with a spurious capabilities callback is triggered when
a VPN connects and it has any underlying network (which
means almost always, because it will take the default
network if it doesn't declare any). Fixing this was
necessary to have a cogent test of this issue, but it
could be moved to another patch or it could stay unfixed
with some minor ajustment to the tests if judged too
dangerous to include in R at this point.

Test: New tests in this patch. Also manually tested with
      tcpdump as described in b/150570873.
Bug: 150570873
Change-Id: I3e4ff990c0d4825b21c7679be29a482a2d1324ec
2020-05-11 10:44:50 +09:00
Remi NGUYEN VAN
a065d07edf Use the new NetworkStackConnector constructor
The constructor was changed to allow for unit tests.

Bug: 137328719
Test: atest FrameworksNetIntegrationTests
Change-Id: I46f247268310e12d420531745a22e93cf3550e89
2020-04-28 15:50:38 +09:00
Chiachang Wang
0ab5158418 Update constructor of NetworkMonitor
Remove redundant parameter.

Bug: 152374582
Test: m -j40 ; atest FrameworksNetIntegrationTests
Change-Id: I3a636f0ea5145ac4435e06a9827bb8e01862542d
2020-03-30 07:52:02 +00:00
Chalard Jean
5863a71547 Move NetworkAgent#register to a new method.
Calling IPC in a constructor is unusual and confusing, and can be
considered bad form. There are multiple reasons for this :
• Users can't obtain an instance of the class without calling the
  constructor, but they can't always afford an IPC where they need
  this, forcing them to know about the implementation detail and
  sometimes design around it.
• On a related but generalized note, constructors should usually
  be fast for the same range of reasons.
• Having a separate method to register the agent simply gives more
  flexibility to the app.
• It's also a lot easier to test.
But also we can't fix it without an update to the API, so here it is.

Another reason for doing this is consistency with the NetworkProvider
API.

Bug: 138306002
Bug: 139268426
Test: atest FrameworksNetTests FrameworksWifiTests FrameworksTelephonyTests
Change-Id: I1ee5c7b1353d581e487c8a8a159009bebd781643
Merged-In: I1ee5c7b1353d581e487c8a8a159009bebd781643
(clean cherry-pick from internal branch)
2020-02-21 14:54:18 +08:00
Remi NGUYEN VAN
36f258eb33 Update NetworkMonitor integration test constructor
Add the service manager argument that is added for the notification
manager.

Test: atest FrameworksNetIntegrationTests
Bug: 139269711
Change-Id: Ie657687000a068b3892d04440b20b3408e875a00
2020-02-15 05:00:35 +09:00
Chiachang Wang
239fb6480f Merge changes from topic "networkagent"
* changes:
  Add a Builder to NetworkAgentConfig, and make it SystemApi.
  Rename NetworkMisc to NetworkAgentConfig.
2020-01-22 05:27:51 +00:00
Lorenzo Colitti
ab2fed7241 Rename NetworkMisc to NetworkAgentConfig.
NetworkMisc is not really an appropriate name for a system API.

Bug: 138306002
Test: builds, boots, wifi works, telephony works
Test: atest FrameworksNetTests FrameworksWifiTests FrameworksTelephonyTests
Change-Id: I621cfbe165996c67b201ca2dd2f95a5ab9af10ee
Merged-In: I621cfbe165996c67b201ca2dd2f95a5ab9af10ee
2020-01-21 12:57:27 +00:00
Chalard Jean
d61375df7c Make NetworkCapabilities authoritative for suspended state
...instead of NetworkInfo

Bug: 138306002
Test: FrameworksNetTests FrameworksTelephonyTests
Change-Id: I4808fcc0047a926b23ed3d49d979bb7b0371dc69
Merged-In: I4808fcc0047a926b23ed3d49d979bb7b0371dc69
2020-01-20 10:37:29 +00:00
Chalard Jean
f78c964538 Have registerNetworkAgent return a Network.
This is more useful.

Bug: 135998869
Test: FrameworkNetTests FrameworksWifiTests
Change-Id: I74710b396fa3cec6fbae08d3dcab5bc90dc2e669
Merged-In: I74710b396fa3cec6fbae08d3dcab5bc90dc2e669
2020-01-20 16:22:06 +08:00
Lorenzo Colitti
a86fae785a Stop using NetworkFactory in connectivity code.
Bug: 138306002
Test: builds, boots
Test: atest FrameworksNetTests
Change-Id: I6b9979f343108c0c077abd86ae1c21e5ece0cccc
2020-01-12 17:40:02 +09:00
paulhu
6c3b3a494f Add permissions for FrameworksNetIntegrationTests
The protected permissions were changed in some connectivity APIs
since aosp/1099096. Add required permissions for
FrameworksNetIntegrationTests.

Bug: 147121740
Test: atest FrameworksNetIntegrationTests
Change-Id: I38ba5c8e93fd5bc94371b2a02a280f503f2e1367
2020-01-06 09:30:03 +08:00
markchien
5776f96096 [Tether13] Move TetheringManager into framework
Move tethering out of ConnectivityService. All client would
use TetheringManager to talk with TetheringService directly.

Bug: 144320246
Test: -build, flash, boot
      -atest TetheringTests

Change-Id: Ib051bea724a256f9c4572b566e46ae7b9c4abe6e
Merged-In: Ib051bea724a256f9c4572b566e46ae7b9c4abe6e
2019-12-19 20:53:06 +08:00
Mark Chien
783ba3e0bd Merge changes from topic "tether_migrate"
* changes:
  [Tether10]Remove UserManagerInternal usage in Tethering
  [Tether07] Migrate Tethering into module
  [Tether07] Clean up build rule for libtetheroffloadjni
2019-11-30 12:17:47 +00:00
markchien
5e86665079 [Tether07] Migrate Tethering into module
Now tethering would be run in dedicated service.
TetheringManager is the interface used to communicate with
TetheringService. The new call flow would be: ConnectivityManager
-> ConnectivityService -> TetheringManager -> TetheringService.
Note: the return value of #tether(), #untether() and #setUsbTethering()
APIs would always be no error. Client can use #getLastTetherError()
or #getTetheredIfaces or listen tether state change to check
status of corresponding interface.

Bug: 136040414
Bug: 144742179
Test: -build, flash, boot
      -atest TetheringTests
      -atest FrameworksNetTests

Change-Id: I7e78c0e0a3e70f940a749ba2a39ece7c7ec5b9b3
Merged-In: I7e78c0e0a3e70f940a749ba2a39ece7c7ec5b9b3
2019-11-30 10:03:08 +00:00
Chiachang Wang
bfb1ab4b02 Refactor based on new NetworkMonitor
Bug: 130325409
Test: atest NetworkStackIntegrationTests
Change-Id: I4426be339cb9990c05b3f4fb5666bd70bcd0f78e
2019-11-26 09:10:45 +08:00
Remi NGUYEN VAN
c598529450 Add permissions to NetIntegrationTests manifest
As the TestNetworkStack target is updated not to use the complete
NetworkStackManifest to avoid including priv-app permissions and actual
service names, the missing permissions must be added to the
FrameworksNetIntegrationTests manifest.

Add the permissions and attributes that are necessary for the test, and
used to be merged from the TestNetworkStack library manifest.

Test: atest FrameworksNetIntegrationTests
Change-Id: I8b434e67f3a6c9141da71c6dfab1be77aa0f8411
2019-10-30 18:30:03 +09:00
Remi NGUYEN VAN
317b2d2065 Add ConnectivityServiceIntegrationTest
This test exercises the Connectivity <-> NetworkMonitor integration.
This CL only contains a simple test (network validates), but more
generally it sets up a test package that contains both services.jar
classes and NetworkStack classes, and runs NetworkStack components in
another process (using TestNetworkStackService).

ConnectivityServiceIntegrationTest runs in the test process and binds to
TestNetworkStackService to obtain TestNetworkStackConnector and to
NetworkStackInstrumentationService to obtain
NetworkStackInstrumentationConnector. That last connector allows the
test to mock NetworkMonitor HTTP Requests.

Test: atest FrameworksNetIntegrationTests
Change-Id: Ieca18e273609044cf6b1870d2f0dba33ca7b38d3
2019-09-04 15:57:47 +09:00
Remi NGUYEN VAN
0d0eb15091 Extract test utilities for ConnectivityService
The utilities help using ConnectivityService in tests, and will be used
to write integration tests for ConnectivityService.

Test: atest FrameworksNetTests
Change-Id: Ie895ad05139cd5768d3d8a9bd5589d72571f47e6
2019-08-01 16:32:30 +09:00