Commit Graph

112 Commits

Author SHA1 Message Date
Quang Luong
98858d6b27 Allow SUW to access registerSystemDefaultNetworkCallback
registerSystemDefaultNetworkCallback is required by WifiTrackerLib to
detect the system default network for UI purposes. Currently this API is
allowed for holders of the NETWORK_SETTINGS permission, but not
NETWORK_SETUP_WIZARD. Since SUW also uses WifiTrackerLib, we should
allow this API for NETWORK_SETUP_WIZARD as well.

Bug: 230643853
Test: atest ConnectivityServiceTest
Change-Id: Ic01a186f91ed67b4603b6b8964921be7473a483a
2023-02-11 00:31:59 +00:00
Junyu Lai
35665cc887 Enterprise slicing for profile blocking default
Test: atest ConnectivityServiceTest#testProfileNetworkPreferenceBlocking_networkChanges \
      ConnectivityServiceTest#testProfileNetworkPreferenceBlocking_changePreference \
      --rerun-until-failure 100
Bug: 263219497

Change-Id: Idbda582542bcabf0156e2bab9f8bea42fc908cae
2023-01-11 10:47:00 +08:00
lucaslin
3ba7cc25c0 Create a new API to make a set of UIDs use only VPN by default
Create a new API - setVpnNetworkPreference() for the caller to
set VPN as the preference network.

VPN will be disconnected when its underlying network is gone.
To prevent packets going through an underlying network when the
underlying network is back but VPN is not connected yet, set VPN
as the only preferred network for specific apps.

Bug: 231749077
Test: 1. atest FrameworksNetTests
      2. Create a test app to register default network and check if
         the VPN is the only default network for the test app.
Change-Id: Iabcd38e2fec2aefedbf78d20e338f222d83a9e7f
2022-12-19 05:35:04 +00:00
Chiachang Wang
89d4bda742 Merge "Expose vpn bypassability in VpnTransportInfo" 2022-11-15 05:35:08 +00:00
chiachangwang
d12d2011cb Expose vpn bypassability in VpnTransportInfo
Bug: 256775913
Test: m framework-connectivity.stubs.source.system-update-current-api
Test: m lint-check
Test: atest FrameworksNetTests
Change-Id: I6aaad7b4372aa4f91df4bed89caea674031a6367
2022-11-11 08:38:17 +00:00
Junyu Lai
aa4ad8c2d1 Allow USE_RESTRICTED_NETWORKS for registerSystemDefaultNetworkCallback
Some callers (e.g. iwlan) need to learn about system default
network but they cannot have NETWORK_SETTINGS permission.
To allow them to use this API but prevent from misuse by
unprivileged apps, enforce USE_RESTRICTED_NETWORKS for this API.

Test: atest com.android.server.ConnectivityServiceTest#testRegisterPrivilegedDefaultCallbacksRequireNetworkSettings android.net.cts.ConnectivityManagerTest#testRegisterNetworkCallback
Fix: 242456635
Change-Id: I80ab27445af874328c9c0f4814a8fbf035ae5df4
2022-11-02 14:16:36 +08:00
Patrick Rohr
929368eb1a Merge changes Ie1a91959,Ic189b2c0,I39d70e0a,Ibb5f1402
* changes:
  TestNetworkInterface: add support for MacAddress and MTU
  TestNetworkService: add support for creating iface without carrier
  TestNetworkService: Add support for toggling carrier on tun/tap
  TestNetworkService: Fix TestNetworkInterface parcel flags
2022-06-15 20:53:30 +00:00
Patrick Rohr
88f97f4fba TestNetworkInterface: add support for MacAddress and MTU
Both MacAddress and MTU size are often needed in tests and very painful
to get a hold of without system server permissions.

Test: TH
Change-Id: Ie1a91959916ea39277e76aa1b61f38d59a5d2a90
2022-06-15 10:25:45 -07:00
Motomu Utsumi
62385c884f Make FIREWALL_CHAIN_OEM_DENY API
Bug: 208371987
Test: m
Change-Id: Ie0c2ad862c02f9fd4561869cf5a1adc44f1be11b
2022-06-12 11:37:19 +00:00
markchien
3c04e66da0 Api review: change updateFirewallRule to setUidFirewallRule
Bug: 218494748
Test: TH

Change-Id: I52a02ebe109b687359f579c16fded4af3c9cd242
Merged-In: I52a02ebe109b687359f579c16fded4af3c9cd242
2022-03-25 18:49:08 +08:00
Chalard Jean
de665266cd Rename setAccessUids to setAllowedUids
Bug: 217725769
Test: ConnectivityServiceTest CtsNetTestCases
Change-Id: Ic8a3f91553d1462b7f54259c467fb90a950bdd59
Merged-In: I8860fbb353eedf5d01e9dc248e4d765046bd562c
2022-03-16 17:58:20 +00:00
Sooraj Sasindran
4904176454 Use int array for included and excluded uids
Use int array for included and excluded uids so that uses
same data type as in PreferentialNetworkServiceConfig

Bug: 217365439
Test: ran connectivity service unit tests
Change-Id: I9ac7e6498df2fd20b8397b2c110296e019c7389e
2022-03-16 07:19:11 +00:00
Lucas Lin
ba61dca57c Merge "Rename redactNetworkCapabilitiesForPackage and update its javadoc" 2022-03-14 08:05:08 +00:00
Mark Chien
cc29690fc1 Merge "Split updateMeteredNetwork{Allow, Deny}List into add and remove" 2022-03-09 05:00:58 +00:00
markchien
e46042b833 Split updateMeteredNetwork{Allow, Deny}List into add and remove
Split the updateXXX methods into an addXXX and removeXXX instead of using
a boolean parameter to indicate whether the uid should be added or removed

Bug: 218494748
Test: atest FrameworksNetTests
Change-Id: I868cf35c8f51b25d8719e618c6c48a5cd642da7f
2022-03-09 11:17:27 +08:00
markchien
49e944cc1c Remove ConnectivityManager swapActiveStatsMap API
swapActiveStatsMap is temporary added for the NetworkStatsFactory to
call BpfNetMaps#swapActiveStatsMap in tethering mainline module. Now
NetworkStatsFactory already be mainlined, calling BpfNetMaps#swapActiveStatsMap
directly.

Bug: 218494448
Test: atest ConnectivityCoverageTests
      atest FrameworksNetTests
Change-Id: I3358e4ac5fb7ed0964273afdbccd1b4128ca7645
2022-03-07 12:25:47 +08:00
Chiachang Wang
978370cb9c Merge "Rename getVpnRequiresValidation to isVpnValidationRequired" 2022-03-03 00:10:54 +00:00
lucaslin
d2b0613814 Rename redactNetworkCapabilitiesForPackage and update its javadoc
The API won't modify the passed NetworkCapabilities and
LinkProperties, but redactNetworkCapabilitiesForPackage and
redactLinkPropertiesForPackage sound like they will. To reduce
the confusion, rename the API with prefix "getRedacted".
Also modify the javadoc to describe more about what the API will
do if the given UID doesn't have location permission.

Bug: 220367512
Test: atest CtsNetTestCases
Change-Id: I964f1062da1ae96df9b369b911486da1379b8a19
2022-03-02 10:56:57 +08:00
Chiachang Wang
7ec6ae74c8 Rename getVpnRequiresValidation to isVpnValidationRequired
Update API name from getVpnRequiresValidation to
isVpnValidationRequired according to API review feedback.

Test: atest FrameworksNetTests
Bug: 220129160
Change-Id: I1025f4c35b320c14e872eaffd7ed82658a5f3d0c
2022-03-02 01:02:45 +00:00
Patrick Rohr
ca7e578f7e Fix rate limit API review comments
Follow up to aosp/1955583 to fix some review comments.

Test: builds
Bug: 219739904
Change-Id: Ie85dc72eb3bb6eda26b655a64eae0d7c0d8bf143
2022-02-18 09:47:49 +00:00
Jean Chalard
d537aa42e1 Merge "Add new methods to redact NetworkCapabilities & LinkProperties" 2022-02-12 11:56:36 +00:00
lucaslin
c582d50b8e Add new methods to redact NetworkCapabilities & LinkProperties
Some system components like VPN need to know how to redact
NetworkCapabilities & LinkProperties that they received from
the system but need to send to third-party applications with
less privilege than themselves. To make sure the redaction is
consistent, expose system API methods to do it that are wired
to the same redaction code used by ConnectivityService.

Bug: 191413541
Test: atest CtsNetTestCases, which includes new CTS for these
Change-Id: Ia3ae4755b5192884c147d6828f96cedac000a25b
2022-02-12 15:21:13 +09:00
Chiachang Wang
84ad04f768 Merge "Change naming of excludeLocalRoutes" 2022-02-10 00:50:30 +00:00
Patrick Rohr
6b5b7b40d8 Merge changes from topic "bandwidth-limiting"
* changes:
  Add bandwidth limiting to CS
  Add setting that controls network rate limit
2022-02-09 18:00:04 +00:00
Patrick Rohr
a20843638f Add setting that controls network rate limit
The INGRESS_RATE_LIMIT_BYTES_PER_SECOND setting controls the rate limit
for internet networks. If set to -1, no rate limit applies.  There is
one global rate limit that will be applied to all networks with
NET_CAPABILITY_INTERNET.

Test: atest ConnectivitySettingsManagerTest
Bug: 157552970
Change-Id: Ia82aa867686d484ce46734f76d4a48bf864eff84
2022-02-09 14:46:26 +01:00
Chiachang Wang
f890874970 Change naming of excludeLocalRoutes
Address API review feedback to change naming of
setExcludedLocalRoutesVpn and getter.

Bug: 217742354
Test: atest FrameworksNetTests
Change-Id: I57bbf55c7aba1c86ec8687d2431a50b37e63c6d0
2022-02-09 15:50:06 +08:00
Chiachang Wang
865511a8c4 Add and implement API for VpnManagers to request validation
This adds a new API that lets VPN apps using VpnManager request
that the platform run its basic validation check on the resulting
network.

Bug: 184750836
Test: atest FrameworksNetTests
Change-Id: I00092eee857d3e33529b19461cfd5dd060a0fe20
2022-02-08 22:47:26 +09:00
Robert Horvath
2dac94841a Define BLOCKED_REASON_LOW_POWER_STANDBY
Bug: 190822356
Test: atest NetworkPolicyManagerServiceTest
Change-Id: I72c81ba1c3791e40a2d311cc3a06bf3b5d3727d1
2022-02-01 16:04:35 +01:00
Robert Horvath
34cba14425 Define FIREWALL_CHAIN_LOW_POWER_STANDBY
Bug: 190822356
Test: atest NetworkManagementServiceTest
Change-Id: I970eea0e1952f8074cc5c998bbd2ee1ff5a3dc92
2022-02-01 16:04:35 +01:00
Chalard Jean
41a602d2b8 Expose access UIDs.
CTS already have basic tests for this since they run the common tests,
which were using these hidden methods already.

Test: CtsNetTestCases
Change-Id: Id5e5b911f5c63bdd3b05e5ac1d3dd89c1c525ab7
2022-01-31 17:04:58 +09:00
Chiachang Wang
e84d7d90d3 Expose local route exclusion API in NetworkAgentConfig
Bug: 184750836
Test: make update-api
Test: atest FrameworksNetTests
Change-Id: I70470ab3a945570a23607e39d18f9825d9e1d7aa
CTS-Coverage-Bug: 184750836
2022-01-27 09:53:33 +00:00
Sooraj Sasindran
7e9b25e7f9 Add getEnterpriseId api to network request
Bug: 194332512
CTS-Coverage-Bug: 216481336
Test: build
Change-Id: I1446f8eecf43f7c6d243dc82af08d04957dd60e3
2022-01-26 17:26:50 +00:00
Sooraj Sasindran
f4a58dcd45 Add support for Multiple enterprise slice
Bug: 194332512
Test: unit test
CTS-Coverage-Bug: 211133973
Change-Id: Ie8be08a7cfa9155168d1da146d02fd1643248bdc
2022-01-22 14:39:40 -08:00
Sooraj Sasindran
499117f279 Ability to specify which all applications fall under enterprise slice.
Bug: 194332512
Test: unit test
Change-Id: I94549a41aaa717add22b0a3e5035beacf6f1b8f2
2022-01-21 01:05:12 -08:00
Mark Chien
21f0d58294 Merge "Add swapActiveStatsMap API for NetworkStatsFactory" 2022-01-14 05:35:25 +00:00
Mark Chien
094de6b7c4 Merge "Add replaceFirewallChain API" 2022-01-14 05:33:58 +00:00
Mark Chien
9bba8e8c78 Merge "Add setFirewallChainEnabled API" 2022-01-14 05:33:38 +00:00
Mark Chien
c65ecacd6f Merge "Add updateFirewallRule API" 2022-01-14 05:33:22 +00:00
markchien
9c8061134c Add swapActiveStatsMap API for NetworkStatsFactory
This CL should be reverted before T sdk finalized.
This API is temporary added for the NetworkStatsFactory which is platform
code but will be moved into connectivity (tethering) mainline module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: I5894450f3089b2ea105722a18ddf8f1eed1c28a0
2022-01-14 10:23:26 +08:00
markchien
00a0bed534 Add replaceFirewallChain API
To deprecated firewallReplaceUidChain netd binder and move the
functionality to tethering (connectivity) mainline module, expose
replaceFirewallChain to support the caller outside the module.
Currently the API are still call to netd. Will replace with the
implementation inside tethering (connectivity) module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: If7a87548b0a3acda00a1455da4e4ff24a630ddc7
2022-01-14 10:23:21 +08:00
markchien
98a6f95d0f Add setFirewallChainEnabled API
To deprecated firewallEnableChildChain netd binder and move the
functionality to tethering (connectivity) mainline module, expose
setFirewallChainEnabled to support the caller outside the module.
Currently the API are still call to netd. Will replace with the
implementation inside tethering (connectivity) module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: I9b64c9d12260521489a87fbeae5afbee2a8ea8f6
2022-01-14 10:23:15 +08:00
markchien
e1561fa800 Add updateFirewallRule API
To deprecated firewallSetUidRule netd binder and move the functionality to
tethering (connectivity) mainline module, expose updateFirewallRule to
support the caller outside the module. Currently the API are still call
to netd. Will replace with the implementation inside tethering
(connectivity) module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: I0b53c999e06c2378afec0eb491815ec398c91b0b
2022-01-14 10:19:51 +08:00
Sooraj Sasindran
226131ab48 Merge "Ability for DPM to specify fallback mechanism" 2022-01-13 17:24:07 +00:00
Mark Chien
136f2d2d91 Merge "Add updateMeteredNetwork{Allow, Deny}List APIs" 2022-01-13 08:21:03 +00:00
Sooraj Sasindran
06baf4cfa1 Ability for DPM to specify fallback mechanism
Bug: 194332512
Test: unit test
Change-Id: Id4d85da8f64e7559326c4657b8833dac3ce5ce3d
2022-01-13 06:07:36 +00:00
Sooraj Sasindran
e7aee2736e Add a method to apply a set of network preferences to a user profile
Add a method to apply a set of network preferences to a user profile

Bug: 194332512
CTS-Coverage-Bug: 211133973
Test: CTS
Change-Id: I97730ea14e7c96922236fd77a591e5acadd875ba
2022-01-11 21:07:23 -08:00
markchien
738ad911c7 Add updateMeteredNetwork{Allow, Deny}List APIs
To deprecated below netd binder interfaces and move the functionality to
tethering(connectivity) mainline module:
  bandwidthAddNaughtyApp
  bandwidthRemoveNaughtyApp
  bandwidthAddNiceApp
  bandwidthRemoveNiceApp
Expose updateMeteredNetwork{Allow, Deny}List APIs to support the caller
outside the module. Currently the two APIs are still call to INetd
binders. Once functionality is moved to mainline module, will switch to
use them.

Bug: 209935649
Test: m
Change-Id: I8df720935748c2587f91a7b760cfd5a93a0fa852
2022-01-07 10:16:13 +08:00
Sooraj Sasindran
4196937bdd Add enterpriseSpecifier
Add enterpriseSpecifier to network capability

Bug: 194332512
CTS-Coverage-Bug: 211133973
Test: CTS and unit test.
Change-Id: If16c8e17cee71cc6788c43a8818bcca68a00bf99
2021-12-23 09:32:20 -08:00
Mingguang Xu
2d87c6152d Create DhcpOption object and make it a SystemApi
This allows OEM apps to pass their custom DHCP options for establishing
network connection.

Bug: 177278970

Test: atest FrameworksNetTests
Test: atest NetworkStackTests

Signed-off-by: Mingguang Xu <mingguangxu@google.com>
Change-Id: I2b8c38ee9a948ad6edb666312c989d27a8ff904b
2021-12-09 19:37:40 -08:00
paulhu
91e7806938 Update allowed on restricted networks getter/setter
As API review feedback, setting allowed on restricted networks
should be by uid instead of package name for security reason.
Thus, update the getter/setter to return/accept set of uids.

Bug: 188085693
Test: atest FrameworksNetTests
Merged-In: I979bf98075e6c9c0ed7e891582843fddb62643cb

Change-Id: I979bf98075e6c9c0ed7e891582843fddb62643cb
2021-05-27 16:24:50 +08:00