Commit graph android_packages_modules_Co.../framework/api
Message SHA1
Move cronet to framework-connectivity
aosp/2384137 added cronet to framework-tethering.
But framework-connectivity is a better place to put cronet since
cronet does not work on R devices (b/270049141) and
framework-tethering is R+, framework-connectivity is S+.

Followup CLs will move some modules (e.g. CronetJavaPrejarjarDefaults)
that use the branch dependent soong variables to framework/Android.bp

Test: TH
Bug: 278070640
Change-Id: I6bc10116759fb9e083c02147908e53022dab740a

Motomu Utsumi   commited 2023-04-19 11:32:12 +09:00
73e2e87d56
Correct nullability and add extra check for underpinnedNetwork
As the review feedback, this commits address below concern.

1. The TCP keepalive code doesn't use the network parameter
at all. This parameter doesn't seem meaningful for TCP
keepalives. Starting a TCP keepalive with a non-null underpinned
network should throw IllegalArgumentException.

2. The feedback mention that the start version which takes a
@NonNull network should throw NPE if the network is null. But
Starting a NATT keepalive does not always require a underpinned
network. A new IkeSession started from Vpn will also not assign
the underpinned network at the initial stage which means
underpinned will be null until setNetwork() is called. Thus,
the underpinned network should be @Nullable instead.

Fix: 271797087
Test: atest FrameworksNetTests
Change-Id: Ieb57a7b15a06b2ccd94358b65cc00768c4f62e7d

chiachangwang   commited 2023-03-13 09:00:43 +00:00
c51a705a45
Merge "add TRANSPORT_THREAD to NetworkCapabilities"
Kangping Dong   authored and   Gerrit Code Review   commited 2023-02-28 07:16:16 +00:00
7dc4459d33
Merge "Allow SUW to access registerSystemDefaultNetworkCallback"
Quang Luong   authored and   Gerrit Code Review   commited 2023-02-15 20:22:10 +00:00
0f6a2e69cd
Add underpinned Network parameter in SocketKeepalive.start()
Take a Network parameter to have an one-to-one mapping between
keepalive and its underpinned network on the automatic keepalive.

Existing design could not really tell which network should the
automatic keepalive check for the TCP socket status if there are
multiple automatic keepalives enabled, e.g. Bothe IWLAN and VPN
on WiFi enable the automatic keepalive. The keepalive for IWLAN
should check if there are any TCP sockets on the IWLAN network
instead of VPN network.

Bug: 259000745
Test: atest FrameworksNetTests
Test: Cts in the follow up commit
Change-Id: I7353f4ef43e8fdad02c4d4a0bb5f6efa7d94c1b4

chiachangwang   commited 2023-02-14 10:29:19 +00:00
676c84ef98
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

Quang Luong   commited 2023-02-11 00:31:59 +00:00
98858d6b27
[DK2]Add new SocketKeepalive.start to dynamically control keepalive
Add SocketKeepalive.start with parameter to enable dynamic
keepalive mode based on the existence of TCP connections.

This supports IPSec mode to notify KeepaliveTracker to disable
keepalive when keepalive is unnecessary to improve battery life.

Keepalive is controlled by periodically TCP socket status check
for both enable and disable. This is a transition commit and
is expected to be updated based on the socket creation or
destroy.

Bug: 259000745
Test: m ; atest FrameworksNetTests
Change-Id: Ie4d598d69a73c4931c7d0b6dfde0e459e5dca6b4

chiachangwang   authored and   Chalard Jean   commited 2023-01-20 13:51:20 +09:00
9ef4ffe8d4
add TRANSPORT_THREAD to NetworkCapabilities
This commit also updates to use V11 dnsresolver APIs which was V9.

Bug: 262683651
Test: unit tests
Change-Id: Ifbd71157012dc66ec0f377beef9fa59d1c8620b8

Kangping Dong   commited 2023-01-16 10:51:56 +08:00
707a996c9b
Enterprise slicing for profile blocking default
Test: atest ConnectivityServiceTest#testProfileNetworkPreferenceBlocking_networkChanges \
      ConnectivityServiceTest#testProfileNetworkPreferenceBlocking_changePreference \
      --rerun-until-failure 100
Bug: 263219497

Change-Id: Idbda582542bcabf0156e2bab9f8bea42fc908cae

Junyu Lai   commited 2023-01-11 10:47:00 +08:00
35665cc887
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

lucaslin   commited 2022-12-19 05:35:04 +00:00
3ba7cc25c0
Rename getBypassable to isBypassable
Bug: 262336021
Bug: 256775913
Test: atest FrameworksNetTests
Change-Id: I5ac8f4f9a2a64189fc66d3c14af6da201a35e3e2

chiachangwang   authored and   Chiachang Wang   commited 2022-12-15 04:22:43 +00:00
2ed983512c
Add areLongLivedTcpConnectionsExpensive in VpnTransportInfo
Add VpnTransportInfo.areLongLivedTcpConnectionsExpensive() in API
surface to allow privileged apps to know whether the long-lived
TCP connections should be expensive in the VPN network.

This is expected to be used combined with getBypassable()
because connections should always go through a VPN that is not
bypassable.

Bug: 259000745
Test: atest FrameworksNetTests
Change-Id: Ic9bcdf43f252f22d12a1136902cc8bbf9cc731f5

chiachangwang   commited 2022-12-13 10:15:49 +00:00
a07cef1059
Merge "Expose vpn bypassability in VpnTransportInfo"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-11-15 05:35:08 +00:00
89d4bda742
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

chiachangwang   commited 2022-11-11 08:38:17 +00:00
d12d2011cb
Merge "Allow USE_RESTRICTED_NETWORKS for registerSystemDefaultNetworkCallback"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-11-09 05:49:54 +00:00
31ee1c1121
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

Junyu Lai   commited 2022-11-02 14:16:36 +08:00
aa4ad8c2d1
Support QosCallback for UDP socket: Expose API&CTS
Expose API to use QoSCallback for UDP socket.
- Constructor of QosSocketInfo with DatagramSocket
- matchesProtocol(int protocol) in QosFilter
- Constructor of SocketNotConnectedException &
  SocketRemoteAddressChangedException
Add CTS test cases for exposed API.

Bug: 233292861
Test: atest CtsNetTestCases
Change-Id: I52ff881b71b31c0f97c08200cd811205c25fcb44

sewookseo   authored and   Sewook Seo   commited 2022-09-29 08:54:08 +00:00
4d371bc6c4
Revert "[ST02.1] Add TYPE_CNAME constant to DnsResolver"
Revert submission 1387135-st02

Reason for revert: Usage of TYPE_CNAME in a library shared among
modules does not interact well with current module release process

Reverted Changes:
Ib5616c65c:[ST02.2] Use the getters of DnsHeader
I5e58f99b0:[ST02.1] Add TYPE_CNAME constant to DnsResolver
I0c1547cbc:[ST02] Add methods for synthesizing DNS packets

Change-Id: I5aa9f28f1268f966f62041193ceb7c8bef994579

Remi NGUYEN VAN   commited 2022-09-08 11:01:05 +00:00
110bbdaa3e
[ST02.1] Add TYPE_CNAME constant to DnsResolver
This would be needed for subsequent patches that synthesizing DNS
packets for testing purpose.

Bug: 139774492
Test: atest DnsPacketTest DnsResolverTest
Change-Id: I5e58f99b09b693f167178e56f008be8b42d9417a

Junyu Lai   commited 2022-08-25 11:11:52 +08:00
822ab28a9b
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

Patrick Rohr   authored and   Gerrit Code Review   commited 2022-06-15 20:53:30 +00:00
929368eb1a
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

Patrick Rohr   commited 2022-06-15 10:25:45 -07:00
88f97f4fba
Unfinalize additional methods in NetworkAgent
This change allows tests to mock NetworkAgent, and the methods
required for ensuring that the VPN is migrating properly.

Bug: 235853154
Test: Treehugger
Change-Id: I49333c010cc7f3d60ffd39f853777bfc52de3a89

Benedict Wong   authored and   Lorenzo Colitti   commited 2022-06-15 09:16:50 +00:00
0815c8c66a
Make setUnderlyingNetwork() non-final
This change allows tests to mock NetworkAgent, and the methods
required for ensuring that the VPN is migrating properly.

Bug: 235853154
Test: Treehugger
Change-Id: If4de0935a3c8627ca12db52ff223834f9f7237e8

Benedict Wong   commited 2022-06-14 02:07:50 +00:00
33acb90622
Make FIREWALL_CHAIN_OEM_DENY API
Bug: 208371987
Test: m
Change-Id: Ie0c2ad862c02f9fd4561869cf5a1adc44f1be11b

Motomu Utsumi   commited 2022-06-12 11:37:19 +00:00
62385c884f
Merge "Add @RequiresPermission for setUnderlyingNetworks"
Lucas Lin   authored and   Gerrit Code Review   commited 2022-03-29 15:34:17 +00:00
41ed965e68
Api review: change updateFirewallRule to setUidFirewallRule
Bug: 218494748
Test: TH

Change-Id: I52a02ebe109b687359f579c16fded4af3c9cd242
Merged-In: I52a02ebe109b687359f579c16fded4af3c9cd242

markchien   commited 2022-03-25 18:49:08 +08:00
3c04e66da0
Move the DscpPolicy status constants and IntDef to NetworkAgent.
As requested by API council.

Also fix lint errors in the test.

Fix: 217366078
Test: existing tests modified in this CL
Change-Id: I8f7cd0e78bf29aeb52ec6a08a5d635d25fa2205d

Lorenzo Colitti   commited 2022-03-25 01:06:46 +09:00
fbe1576139
Rename destroyAndAwaitReplacement to unregisterAfterReplacement.
Rename requested by API council.

Fix: 224764301
Test: existing CTS tests updated
Change-Id: Ibab9c9cd64bf0dde1e22705e81cff11d356fc719

Lorenzo Colitti   commited 2022-03-24 01:12:26 +09:00
a63e2341d6
Add @RequiresPermission for setUnderlyingNetworks
setUnderlyingNetworks() is mainly for the NetworkAgents who hold
the NETWORK_FACTORY to set its underlying networks.

And the underlying networks are only visible and useful for the
caller of getNetworkCapabilities() or the receiver of
onCapabilitiesChanged() who hold one of NETWORK_FACTORY,
NETWORK_SETTINGS and MAINLINE_NETWORK_STACK permissions.
Otherwise, the underlying networks field will be cleard before
sending.

Bug: 205738644
Test: atest CtsNetTestCases:ConnectivityManagerTest
      atest CtsHostsideNetworkTests:HostsideVpnTests
      atest FrameworksNetTests
Change-Id: Ife7630d9676a31ee5ab977cb1b87aec3b6fd7080

lucaslin   commited 2022-03-22 18:15:09 +08:00
69e1aa9117
Merge changes from topic "QosCallbackException"
* changes:
  CTS test for QosCallbackException
  Expose constructor of Exceptions.

Sewook Seo   authored and   Gerrit Code Review   commited 2022-03-19 00:35:28 +00:00
7a4fcf4ed1
Expose constructor of Exceptions.
Exposing constructor of Exceptions for test purpose.

CTS-Coverage-Bug: 224059548
BUG: 215240597
BUG: 216368595
Test: build
Change-Id: I20af104a891e94873715ab46ecabc3e775638c8c

sewookseo   commited 2022-03-17 18:05:56 +00:00
e7c481452e
Rename setAccessUids to setAllowedUids
Bug: 217725769
Test: ConnectivityServiceTest CtsNetTestCases
Change-Id: Ic8a3f91553d1462b7f54259c467fb90a950bdd59
Merged-In: I8860fbb353eedf5d01e9dc248e4d765046bd562c

Chalard Jean   authored and   Sooraj Sasindran   commited 2022-03-16 17:58:20 +00:00
de665266cd
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

Sooraj Sasindran   commited 2022-03-16 07:19:11 +00:00
4904176454
Merge "Add a NetworkAgent API to indicate that a network will be replaced."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2022-03-15 04:44:16 +00:00
9f6e6c4e27
Add a NetworkAgent API to indicate that a network will be replaced.
This is useful for link layers that disconnect but know they will
reconnect to a similar network soon, and do not want the device
to switch to another network until the reconnect happens. An
example is wifi switching to another network that is on a
different subnet without the device switching to cellular data.

This works by immediately destroying the network, so the link
layer can reuse the same interface name for the new network. It
would be possible to delay destroying the network until the new
network connects, but in practice this does not seem useful,
because the if the link layer reuses the interface, then the
interface will be undergoing reconfiguration, and will likely
not be usable for app traffic.

This CL also moves the call to onNetworkDestroyed into
destroyNativeNetwork. This is needed to ensure that the new
API calls onNetworkDestroyed even though most teardown
operations have not happened. This causes onNetworkDestroyed to
happen before the netId is marked free, but that shouldn't cause
any behavioural changes because netId allocation is an
implementation detail of ConnectivityService and is not
observable by apps or system components.

Bug: 216567577
Test: builds, boots
Test: atest FrameworksNetTests FrameworksNetIntegrationTests
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCases:android.net.cts.NetworkAgentTest#testDestroyAndAwaitReplacement
Change-Id: I9f9e022fef66b31a29cce560413321075e992756

Lorenzo Colitti   commited 2022-03-14 21:52:37 +09:00
ffa2ed3d1c
Merge "Rename redactNetworkCapabilitiesForPackage and update its javadoc"
Lucas Lin   authored and   Gerrit Code Review   commited 2022-03-14 08:05:08 +00:00
ba61dca57c
Merge "Split updateMeteredNetwork{Allow, Deny}List into add and remove"
Mark Chien   authored and   Gerrit Code Review   commited 2022-03-09 05:00:58 +00:00
cc29690fc1
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

markchien   commited 2022-03-09 11:17:27 +08:00
e46042b833
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

markchien   commited 2022-03-07 12:25:47 +08:00
49e944cc1c
Merge "Rename getVpnRequiresValidation to isVpnValidationRequired"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-03-03 00:10:54 +00:00
978370cb9c
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

lucaslin   commited 2022-03-02 10:56:57 +08:00
d2b0613814
Rename getVpnRequiresValidation to isVpnValidationRequired
Update API name from getVpnRequiresValidation to
isVpnValidationRequired according to API review feedback.

Test: atest FrameworksNetTests
Bug: 220129160
Change-Id: I1025f4c35b320c14e872eaffd7ed82658a5f3d0c

Chiachang Wang   commited 2022-03-02 01:02:45 +00:00
7ec6ae74c8
Fix rate limit API review comments
Follow up to aosp/1955583 to fix some review comments.

Test: builds
Bug: 219739904
Change-Id: Ie85dc72eb3bb6eda26b655a64eae0d7c0d8bf143

Patrick Rohr   commited 2022-02-18 09:47:49 +00:00
ca7e578f7e
Merge "Add new methods to redact NetworkCapabilities & LinkProperties"
Jean Chalard   authored and   Gerrit Code Review   commited 2022-02-12 11:56:36 +00:00
d537aa42e1
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

lucaslin   authored and   Chalard Jean   commited 2022-02-12 15:21:13 +09:00
c582d50b8e
Merge "Change naming of excludeLocalRoutes"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-02-10 00:50:30 +00:00
84ad04f768
Merge changes from topic "bandwidth-limiting"
* changes:
  Add bandwidth limiting to CS
  Add setting that controls network rate limit

Patrick Rohr   authored and   Gerrit Code Review   commited 2022-02-09 18:00:04 +00:00
6b5b7b40d8
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

Patrick Rohr   commited 2022-02-09 14:46:26 +01:00
a20843638f
Change naming of excludeLocalRoutes
Address API review feedback to change naming of
setExcludedLocalRoutesVpn and getter.

Bug: 217742354
Test: atest FrameworksNetTests
Change-Id: I57bbf55c7aba1c86ec8687d2431a50b37e63c6d0

Chiachang Wang   commited 2022-02-09 15:50:06 +08:00
f890874970
Merge "Add and implement API for VpnManagers to request validation"
Jean Chalard   authored and   Gerrit Code Review   commited 2022-02-09 06:03:45 +00:00
4b66d4e244