Commit Graph

43 Commits

Author SHA1 Message Date
Lorenzo Colitti
75a34a6156 Move the VPN code out of packages/Connectivity.
Bug: 173331190
Test: atest FrameworksNetTests HostsideVpnTests CtsNetTestCases
Change-Id: Idc6ed1a544e744f8661d1e387da278736d407489
2021-02-15 12:05:40 +00:00
Lorenzo Colitti
e7743b77a4 Rename getVpnLockdownWhitelist to -Allowlist
Test: m
Change-Id: Id02a37624655c4ff88744c9c57af9f2a17953667
Merged-In: Id02a37624655c4ff88744c9c57af9f2a17953667
2021-02-15 12:04:13 +00:00
Remi NGUYEN VAN
38a60f3d0a Merge "Revert "[VCN07] Bypass VCN for non-internet app accessible cellu..."" 2021-02-15 11:39:25 +00:00
Treehugger Robot
5e1e48904b Merge "Expose VpnTransportInfo as module-lib API." 2021-02-15 04:54:13 +00:00
Lorenzo Colitti
8bb7512a1b Expose VpnTransportInfo as module-lib API.
This information originates in non-mainline system server code
and needs to be passed to the connectivity mainline code.

Bug: 173331190
Test: already covered by CTS tests
Change-Id: Ic612b6a51f7ec13e2213c8754312cf716130c876
2021-02-15 09:34:19 +09:00
Lorenzo Colitti
6e403987dd Merge changes Ia68f482a,I4911e214,Ied379654,I66d18512,Ie8e1bd63
* changes:
  Check registering system default callback needs NETWORK_SETTINGS.
  Move VPN code from ConnectivityService to VpnManagerService.
  Add a skeleton VpnManagerService, and start it on boot.
  Convert LockdownVpnTracker to NetworkCallbacks.
  Minor fixes to VpnTransportInfo.
2021-02-15 00:00:47 +00:00
James Mattis
da32cfeebf Marking setOemNetworkPreference as @SystemApi
Marking setOemNetworkPreference in ConnectivityManager as @SystemApi.

Bug: 176496438
Bug: 176494815
Test: atest FrameworksNetTests
atest FrameworksNetIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I4681c88dc3a83f71c387b29610c33594e57cb43f
2021-02-11 20:38:21 -08:00
James Mattis
8378aec5fb Adding permission for OEM managed preferences
Adding CONTROL_OEM_PAID_NETWORK_PREFERENCE as a signature level
permission to allow an application to control OEM managed network
preferences.

Bug: 176496438
Bug: 176494815
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk
Change-Id: Iee13e89f3931c7079c2d88cb57b249b1b1cf93ad

Change-Id: Id29cafe1eaf5dff8a0605cb2579204d9c77b7e70
2021-02-11 20:38:21 -08:00
James Mattis
45d81845a4 Implementation of setOemNetworkPreference
Main implementation of ConnectivityService.setOemNetworkPreference. This
covers the main requirements of this method including listener
functionality.

Bug: 176495594
Bug: 177101287
Bug: 176494815
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I8d318ab07785e52dd84d6261fdea8f318dce9bc5
2021-02-11 20:38:18 -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
Lorenzo Colitti
cd67529417 Move VPN code from ConnectivityService to VpnManagerService.
ConnectivityService itself does not depend on mVpns or the Vpn
class any more. Most of this CL is simply moving code from one
class to another:

- Move the AIDL calls from IConnectivityManager to IVpnManager.
- Move the implementation from ConnectivityService to
  the new VpnManagerService.
- Move the APIs from ConnectivityManager to VpnManager, but
  temporarily maintain some shims in ConnectivityManager for the
  moved calls so that existing callers do not have to be modified
  in this CL.
- Update VpnService to call IVpnManager instead of
  IConnectivityManager.
- Move the code that registers the VpnManager service from
  ConnectivityFrameworkInitializer to SystemServiceRegistry.

Bug: 173331190
Test: atest HostsideVpnTests FrameworksNetTests CtsNetTestCases
Change-Id: I4911e2144df721a94fa00da9edf0dc372a7091c2
2021-02-12 01:12:24 +09:00
Lorenzo Colitti
ee1740ddf1 Add a skeleton VpnManagerService, and start it on boot.
This adds a lot of unused code but this should make it easier to
review subsequent CLs.

Bug: 173331190
Test: builds, boots, "dumpsys vpnmanager" succeeds
Change-Id: Ied379654a0c3ab6242d3125661fe30f322395059
2021-02-12 01:07:29 +09:00
Lorenzo Colitti
bcd692fdc9 Convert LockdownVpnTracker to NetworkCallbacks.
This will allow moving LockdownVpnTracker from the connectivity
to the VPN code. This requires moderate refactoring since it's
pretty tightly coupled to both.

In this CL:

1. Add an @hide API to tell ConnectivityService that legacy
   lockdown VPN is enabled. I chose not to use the existing
   setVpnRequiredForUids API because that method has specific
   semantics and because it will be required long term since
   it's used by non-legacy VPN types.

2. Instead of updating LockdownVpnTracker inline from the
   ConnectivityService handler thread, have it listen to
   NetworkCallbacks. This introduces an extra thread hop, but
   most of the interactions between the lockdown VPN and CS were
   via NetworkAgent, which is asynchronous anyway.

3. Add code to LegacyTypeTracker to send the extra
   CONNECTIVITY_ACTION broadcast for the underlying network type
   that is sent after the VPN connects. In order to do this, make
   Make LockdownVpnTracker specify its underlying network
   (via setUnderlyingNetworks) when it connects.

4. Reimplement LockdownVpnTracker#augmentNetworkInfo based on
   information that is available in ConnectivityService.

5. Remove the code in LockdownVpnTracker that counted errors.
   I think this code has not worked since lollipop, because
   ConnectivityService never sees NetworkInfo objects in state
   FAILED. This is because ConnectivityService only hears about
   NetworkInfo objects via NetworkAgents, and LegacyVpnRunner
   only registers its NetworkAgent when the connection succeeds.

Bug: 173331190
Test: passes existing tests in ConnectivityServiceTest
Change-Id: I66d18512882efd468ee0ecec61f28786a195b357
2021-02-12 01:07:29 +09:00
Hai Shalom
ead8991fbb Merge "Support for Terms & Conditions notification" 2021-02-10 15:36:58 +00:00
Lorenzo Colitti
31a31193d2 Add a VpnTransportInfo object.
This currently stores the VPN type and a session name, but can be
extended in the future.

Bug: 173331190
Test: added coverage in VpnTest
Test: added coverage in ConnectivityServiceTest
Test: added coverage in NetworkAgentTest
Change-Id: I450858a9fa332c8d896dbdb4c14337d5ec23677f
2021-02-10 02:52:16 +09:00
Lorenzo Colitti
76b639e1bc Add a registerSystemDefaultNetworkCallback method.
This method allows internal components to track the system
default network. This differs from registerDefaultNetworkCallback
because that method sends callbacks for the default network for
the UID that called it. This may not be the system default
network, for example, when a VPN is up and applies to the UID.

Bug: 173331190
Test: new unit tests in ConnectivityServiceTest
Test: new unit tests in ConnectivityManagerTest
Test: new CTS tests in ConnectivityServiceTest
Test: new CTS tests in HostsideVpnTests in other CL in this topic
Change-Id: Id02748a2183f71b71ff2a53a580466b9dcecaa93
2021-02-09 20:58:28 +09:00
Junyu Lai
43117b2a60 Merge "[VCN07] Bypass VCN for non-internet app accessible cellular services" 2021-02-08 21:40:09 +00:00
Hai Shalom
7c6ab4004a Support for Terms & Conditions notification
- Added API to add T&C URL in the CaptivePortalData class, and to
indicate if the source is from Passpoint.
- Added source indication for the Venue URL API.
- Allow the connectivity service to send a new T&C acceptance
notification.
- Updated the merge method to prefer the Capport data over the
network agent data, if the source is not authenticated (not from
Passpoint).
- Propagate the Venue Friendly name to the captive portal activity
to be used instead of SSID, when available.

Bug: 162785447
Test: End-to-end test
Test: atest ConnectivityServiceTest
Test: atest CtsNetTestCasesLatestSdk:CaptivePortalDataTest
Test: atest NetworkNotificationManagerTest
Change-Id: I4e77c3b6c01941b03c46ad32da70c77e0fecac64
2021-02-08 12:05:20 -08:00
Roshan Pius
aa24fdeb5d ConnectivityService: Plumb attribution tag for location permission checks
Not currently setting the atttribution tag for location
permission checks. Plumb the attribution tag for all location permision
checks (so that location access is correctly attributed to individual
components within an app)

Bug: 162602799
Test: atest android.net
Test: atest com.android.server
Change-Id: Iee95f05204f51a4f8cb1f36acfb60e8cdeb156f4
2021-02-08 08:13:48 -08:00
Lorenzo Colitti
c4e50c9c50 Merge changes I4256ca5f,I91528e1a,I48bd594c
* changes:
  Change ConnectivityServiceTest to prepare for VPN code move.
  Add to VpnManager the VPN APIs used by Settings and SystemUI.
  Remove temporary hack in VpnTest.
2021-02-08 10:41:32 +00:00
Chiachang Wang
bf911c0f3c Merge "Move shared Proxy method and constants to shared lib" 2021-02-08 10:27:05 +00:00
Chiachang Wang
ab9f017af4 Move shared Proxy method and constants to shared lib
The static validate() method an PROXY_* constants in Proxy are
used by both module and Settings. After Proxy is moving into
connectivity module, Setting will not able to access them.
Thus, move them to ProxyUtils in net shared lib.

Bug: 172183305
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases:ProxyInfoTest
Change-Id: I02c88aeaeb53d62b87a42a2d8ead9b140b054650
2021-02-08 10:25:07 +00:00
Lorenzo Colitti
660e3f4b29 Merge "More cleanly separate requests and listens." 2021-02-07 18:04:50 +00:00
Lorenzo Colitti
f80ad439dd Add to VpnManager the VPN APIs used by Settings and SystemUI.
Settings and SystemUI use these through raw AIDL calls.
Make them proper manager calls so we can move the implementation
without touching the callers again.

For now these still call into ConnectivityService via
IConnectivityManager. In an upcoming CL the implementation will
move to VpnManagerService.

Test: m
Bug: 173331190
Change-Id: I91528e1ad9948fbaa1fc5e37c61c5eb95f54964e
2021-02-07 20:40:51 +09:00
Lorenzo Colitti
96742d9695 More cleanly separate requests and listens.
Currently, NetworkRequest has several types of requests (LISTEN,
TRACK_DEFAULT, REQUEST, BACKGROUND_REQUEST), and we expect more
to be added.

There are really three categories of request:
1. Requests satisfied by only one network and will keep that
   network up, and thus need to be sent to NetworkProviders:
   REQUEST, BACKGROUND_REQUEST.
2. Requests satisfied by only one network but will not keep that
   network up: TRACK_DEFAULT
3. Requests satisfied by multiple networks and will not keep any
   networks up: LISTEN.

Unfortunately the separation is not very clear. Currently, for
any valid request, either isListen() will return true or
isRequest() will return true. This makes it impossible to tell
whether a particular request should be sent to NetworkProviders,
so the current code sends TRACK_DEFAULT requests to
NetworkProviders as well. This is incorrect - a TRACK_DEFAULT
should never keep a network up, for example.

This CL attempts to clarify things by making isRequest() return
false for TRACK_DEFAULT requests and thus never sending them to
NetworkProviders. After this CL:

- isRequest will return true only for requests that attempt to
  bring up or keep up a network.
- isListen will return true only for requests that match multiple
  networks but do not keep any of them up.
- Neither will return true for TRACK_DEFAULT.

Test: atest ConnectivityServiceTest
Change-Id: I7aad30ade8f7ab2a179e53483d9afd8675f64a12
2021-02-07 18:20:59 +09:00
James Mattis
d15312ef50 Merge changes Iabad7300,I85363e28
* changes:
  Stubbed setOemNetworkPreference in Connectivity
  Update OemNetworkPreferences to use 1:1 Map
2021-02-06 04:33:51 +00:00
Treehugger Robot
25def597ea Merge "Add @Nullable to Object#equals()" 2021-02-05 09:36:41 +00:00
Remi NGUYEN VAN
db50390d54 Merge "Remove legacy network factories" 2021-02-05 08:23:19 +00:00
Roman Kalukiewicz
384a8c63f2 Add @Nullable to Object#equals()
This is a partial cherry-pick of change:
I5eedb571c9d78862115dfdc5dae1cf2a35343580

for connectivity classes.

Bug: 170883422
Test: m
Merged-In: I5eedb571c9d78862115dfdc5dae1cf2a35343580
Change-Id: I7dc661863b73f4198ddb4f3a1566583d0f07db3c
2021-02-05 07:28:44 +00:00
James Mattis
47db058602 Stubbed setOemNetworkPreference in Connectivity
Stubbed setOemNetworkPreference() in ConnectivityService and connected
it to ConnectivityManager.

Bug: 176495254
Bug: 176494815
Test: atest FrameworksNetTests
atest FrameworksNetIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: Iabad7300a8b058e1edcb0defab8a031d21e6433c
2021-02-04 20:12:40 -08:00
Adrian Roos
318b03e4b0 Merge changes from topic "nullablecollection"
* changes:
  API: Suppress existing NullableCollections lints (TaskOrganizer)
  API: Suppress existing NullableCollections lints
2021-02-04 15:53:34 +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
Remi NGUYEN VAN
2f7ba519fd Remove legacy network factories
Nothing on the system is using registerNetworkFactory,
unregisterNetworkFactory at the moment.

registerNetworkFactory, unregisterNetworkFactory are protected by
signature permissions, so could not be used by anything outside of the
system.

Remove the two methods and the underlying support for this legacy,
deprecated mechanism.

Bug: 179229316
Test: atest FrameworksNetTests
Change-Id: I7cdc9eed67f846c8774474af038133040aeccab3
2021-02-04 18:04:43 +09:00
Lucas Lin
cffb8610ab Merge "Reimplement [read|write]ArraySet of Parcel inside NetworkCapabilities" 2021-02-04 06:12:14 +00:00
Junyu Lai
f0a16c6ad9 Merge "[VCN08] Expose NOT_VCN_MANAGED capability as system API" 2021-02-02 13:57:57 +00:00
Paul Hu
6d86eab235 Merge "Remove ArrayUtils usage in connectivity frameworks classes" 2021-02-02 08:47:04 +00:00
lucaslin
36648ff089 Reimplement [read|write]ArraySet of Parcel inside NetworkCapabilities
Both of readArraySet and writeArraySet are hidden APIs inside
Parcel, so reimplement those two methods inside NetworkCapabilities
to prevent calling hidden APIs.

Bug: 170598012
Test: atest FrameworksNetTests
Change-Id: I70f75c1a0db92c6a5575c6a9917843d783dfaeea
2021-02-02 12:57:26 +08:00
junyulai
10aededf26 [VCN08] Expose NOT_VCN_MANAGED capability as system API
Test: m -j doc-comment-check-docs
Fix: 177299683
Bug: 175662146
Change-Id: Iaa53d21774ea48af5fe339b57bf1235c77f295a0
2021-02-02 11:34:09 +08:00
Adrian Roos
fd63204e0a API: Suppress existing NullableCollections lints
Bug: 152525509
Bug: 154763999
Test: make checkapi
Change-Id: Iecd0927e6be5496b2fbd1a49396db5439257ffe4
2021-02-01 15:04:10 +01:00
paulhu
d25af29a20 Remove ArrayUtils usage in connectivity frameworks classes
Instead, use CollectionUtils from frameworks/libs/net.

Bug: 174541037
Test: atest FrameworksNetTests
Change-Id: I610e00302cf76510e9e34ac8a9a5f738e5ecd0c7
2021-02-01 16:30:08 +08:00
Remi NGUYEN VAN
5f40642b58 Have connectivity self-register manager classes
As connectivity services are planned to move to a separate module, move
the manager classes registration from SystemServiceRegistry to
ConnectivityServicesRegistrar, using the registerContextAwareService
APIs.

This follows patterns and naming in WifiFrameworkInitializer.

Bug: 171540887
Test: device boots, connectivity working
Change-Id: I62ced1275750c73f209bac8ec3a3204b95695b83
2021-02-01 17:10:39 +09:00
Remi NGUYEN VAN
0f8f6307e7 Move module sources to packages/Connectivity
Files that are planned to be part of the connectivity module are grouped
in packages/Connectivity, so they can be built separately and moved in
one operation with their history into packages/modules/Connectivity.

This places the files in the existing framework-connectivity-sources
filegroup instead of the current framework-core-sources filegroup. Both
are used the same way in framework-non-updatable-sources.

Bug: 171540887
Test: m
Change-Id: I62d9d91574ace6f5c4624035d190260c3126b91e
2021-02-01 11:52:14 +09:00
Remi NGUYEN VAN
df417167b6 Move connectivity-sources to frameworks/base
All sources for the connectivity module are being moved to
frameworks/base/packages/Connectivity, so that they can all be moved to
packages/modules/Connectivity in one move keeping history.

INetworkAgent and INetworkAgentRegistry were created in
packages/modules/Connectivity directly, but this makes managing the
sources until the move harder as the module needs to pull sources from
two different locations. Considering that they do not have history to
move, just move them to frameworks/base/packages/Connectivity without
the commit history.

Bug: 171540887
Test: m
Change-Id: Ic4353115a98b6235c2b5d5ce24741223e618d0a6
2021-01-25 11:47:42 +09:00