Commit Graph

303 Commits

Author SHA1 Message Date
Jihoon Kang
be43ef41bc Merge "Add overriding method of a default method to signature files" into main 2023-11-09 17:00:53 +00:00
Anton Hansson
879946d1c9 Merge "Baseline issues that were previously suppressed" into main 2023-11-09 10:03:23 +00:00
Jihoon Kang
9c5c9b0a94 Add overriding method of a default method to signature files
Currently, the signature file elides overrides of a default method,
as they are not essential for the compilation of the stubs.
However, in some scenarios, the overrides of a default method may be
essential for the compilation of the reverse dependency of the stubs.
In the scenario seen below:
```
// API
interface ApiInterface {
    public default void bar() {};
}
class ApiClass implements AnotherParentInterface{
    public void bar() {}
}

// App depending on the API
interface AppInterface {
    public void bar();
}
public class AppClass extends ApiClass implements AppInterface {
}
```
Removal of `ApiClass.bar()` will lead to not overriding an abstract method
`AppInterface.bar()` compilation error in `AppClass`.
Therefore, this change adds the overrides of a default method to the
signature files.

Test: checkapi
Bug: 299366704
Change-Id: Ie11dbeafc39efec06f605e306c92155e834a6685
2023-11-09 09:40:27 +00:00
Suprabh Shukla
2d893b68a9 New firewall chain for default background restrictions
A new firewall chain is needed to configure background network
restrictions for apps.
This change only adds the API stubs and traffic controller constants to
make the chain work. Policy changes using this chain will follow in
the framework code.

Test: atest CtsNetTestCases:ConnectivityManagerTest
Test: atest ConnectivityServiceTest

NO_IFTTT=The Lint rule along with the relevant code in Common.h is
being deleted in aosp/2819759

Bug: 304347838
Change-Id: I33e2db6671431f7c576fc931d9f96e684fc1e78a
2023-11-08 10:17:30 +00:00
Anton Hansson
d8e40b3204 Baseline issues that were previously suppressed
java_sdk_library has previously internally disabled a few legitimate
issues. As this is being un-done for modules, add baselines for the
pre-existing issues.

Bug: 306806877
Test: m checkapi
Merged-In: Ie764d33196675e1482f30ecfd3d6d22b7fa25c27
Change-Id: Ie764d33196675e1482f30ecfd3d6d22b7fa25c27
2023-11-07 08:40:36 +00:00
Junyu Lai
bb59480733 [BR03.1] Expose isUidNetworkingBlocked
Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideNetworkCallbackTests
Bug: 297836825
Change-Id: I70b2351b9cd1c3c6fa34258397e0bf22cb8150b2
2023-11-06 13:26:19 +08:00
Junyu Lai
df210365fe Revert "Revert "[BR07.1] Expose setDataSaverEnabled from Connect..."
Revert submission 2799494-revert-2745215-npmsbpf-OBOPDXREUI

Reason for revert: Need to 1. Merge API first. 2. Wait for prebuilt. 3. Merge the caller.

Reverted changes: /q/submissionid:2799494-revert-2745215-npmsbpf-OBOPDXREUI

Change-Id: Icd5f3d40595a0d2a221b016cec70568bf3597c16
2023-10-24 07:30:23 +00:00
Jordan Silva
457ae0f00f Revert "[BR07.1] Expose setDataSaverEnabled from ConnectivityManager"
Revert submission 2745215-npmsbpf

DroidMonitor: Potential culprit for Bug 307256512 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.


Reason for revert: 307256512

Reverted changes: /q/submissionid:2745215-npmsbpf

Change-Id: I27119a7484453d1369bbdf71ad2479edec7d664f
2023-10-23 13:23:01 +00:00
Junyu Lai
c279f1830e [BR07.1] Expose setDataSaverEnabled from ConnectivityManager
Currently, data saver switch is controlled in NPMS, which
calls into NetworkManagementService and netd when switching
status. In netd, BandwidthController manipulates the
bw_data_saver chain to control the overall behavior.

However, this code are all platform implementation, which
are not updatable. In order to migrate data saver switch
from iptables to bpf, this API is needed for Connectivity to
change the implementation to directly write bpf in later
patches.

Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Test: atest FrameworksServicesTests:NetworkManagementServiceTest
Bug: 297836825
Change-Id: I71fa41ca739fef8e191fba91b02758ad5f732d5c
2023-10-19 17:43:44 +08:00
Paul Duffin
b3c3f2e9d0 Add additional overriding methods to signature files
This change adds overriding methods that are essential to compile the
stubs generated from the signature files.

More information and the background for this change is available at
go/add-overriding-one-pager.

Test: m checkapi
Bug: 299366704
Change-Id: Idba307148fd9afa87bfb7e0c89e00d9bd97ec204
2023-10-12 19:21:07 +01:00
Paul Duffin
7bd2d108ea Prepare for keeping concrete overrides of abstract methods
Currently, metalava will discard concrete overrides of abstract methods
from the API signature files which causes problems when attempting to
generate stubs from those files and also discards information that may
be important in API reviews. This change is the first step in the
process of changing that behavior.

This change hard codes the current behavior for discarding the concrete
overrides (`add-additional-overrides=no`) into those signature files
that will (or are likely) to be affected by the change in behavior.
That allows the default behavior to be changed for all the other files
without affecting these.

Follow up changes will remove the hard coding from the signature files
and will update the contents which will include the concrete overrides
of the abstract methods.

More information and the background for this change is available at
go/add-overriding-one-pager.

Test: m checkapi
Bug: 299366704
Change-Id: I52c5bbe2e3bbd36019fe44fcb0b2d19876a5a869
2023-10-10 17:11:25 +01:00
Motomu Utsumi
73e2e87d56 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
2023-04-19 11:32:12 +09:00
chiachangwang
c51a705a45 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
2023-03-13 09:00:43 +00:00
Kangping Dong
7dc4459d33 Merge "add TRANSPORT_THREAD to NetworkCapabilities" 2023-02-28 07:16:16 +00:00
Quang Luong
0f6a2e69cd Merge "Allow SUW to access registerSystemDefaultNetworkCallback" 2023-02-15 20:22:10 +00:00
chiachangwang
676c84ef98 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
2023-02-14 10:29:19 +00:00
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
chiachangwang
9ef4ffe8d4 [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
2023-01-20 13:51:20 +09:00
Kangping Dong
707a996c9b 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
2023-01-16 10:51:56 +08: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
chiachangwang
2ed983512c Rename getBypassable to isBypassable
Bug: 262336021
Bug: 256775913
Test: atest FrameworksNetTests
Change-Id: I5ac8f4f9a2a64189fc66d3c14af6da201a35e3e2
2022-12-15 04:22:43 +00:00
chiachangwang
a07cef1059 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
2022-12-13 10:15:49 +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
Treehugger Robot
31ee1c1121 Merge "Allow USE_RESTRICTED_NETWORKS for registerSystemDefaultNetworkCallback" 2022-11-09 05:49:54 +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
sewookseo
4d371bc6c4 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
2022-09-29 08:54:08 +00:00
Remi NGUYEN VAN
110bbdaa3e 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
2022-09-08 11:01:05 +00:00
Junyu Lai
822ab28a9b [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
2022-08-25 11:11:52 +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
Benedict Wong
0815c8c66a 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
2022-06-15 09:16:50 +00:00
Benedict Wong
33acb90622 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
2022-06-14 02:07:50 +00: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
Lucas Lin
41ed965e68 Merge "Add @RequiresPermission for setUnderlyingNetworks" 2022-03-29 15:34:17 +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
Lorenzo Colitti
fbe1576139 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
2022-03-25 01:06:46 +09:00
Lorenzo Colitti
a63e2341d6 Rename destroyAndAwaitReplacement to unregisterAfterReplacement.
Rename requested by API council.

Fix: 224764301
Test: existing CTS tests updated
Change-Id: Ibab9c9cd64bf0dde1e22705e81cff11d356fc719
2022-03-24 01:12:26 +09:00
lucaslin
69e1aa9117 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
2022-03-22 18:15:09 +08:00
Sewook Seo
7a4fcf4ed1 Merge changes from topic "QosCallbackException"
* changes:
  CTS test for QosCallbackException
  Expose constructor of Exceptions.
2022-03-19 00:35:28 +00:00
sewookseo
e7c481452e Expose constructor of Exceptions.
Exposing constructor of Exceptions for test purpose.

CTS-Coverage-Bug: 224059548
BUG: 215240597
BUG: 216368595
Test: build
Change-Id: I20af104a891e94873715ab46ecabc3e775638c8c
2022-03-17 18:05:56 +00: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
Lorenzo Colitti
9f6e6c4e27 Merge "Add a NetworkAgent API to indicate that a network will be replaced." 2022-03-15 04:44:16 +00:00
Lorenzo Colitti
ffa2ed3d1c 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
2022-03-14 21:52:37 +09: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