Commit Graph

969 Commits

Author SHA1 Message Date
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
Maciej Żenczykowski
44089f5080 trivialize apf property accessor dead code
(these are never called, but must exist for API reasons)

Bug: 257393783
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2f1cb29c5176539abe25bf767997ab4ed5eca6de
2022-11-04 11:43:22 +00:00
Jean Chalard
06853a7744 Merge "Fix memory leak of ConnectivityManager" 2022-11-02 08:06:03 +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
Chalard Jean
86317d8bb4 Add logs for changes in capabilities and score
This will be useful for diagnosing default network changes.

Logs may look like, for example :
Update capabilities for net 100 : -NET_CAPABILITY_OEM_PAID+NET_CAPABILITY_TRUSTED
Or :
Update score for net 100 : -POLICY_EVER_EVALUATED+POLICY_IS_VPN+POLICY_IS_DESTROYED

Test: FrameworksNetTests
      manual
Change-Id: Ic4788c599573aae9daeca995b8853800aaaba0b8
2022-10-14 14:32:38 +09:00
Jean Chalard
e45e581cff Merge "Move bit utilities to BitUtils." 2022-10-14 04:55:25 +00:00
Jean Chalard
d96aff4f1b Merge "Fix an infinite loop" 2022-10-14 04:54:51 +00:00
zhujiatai
79b0de9ef2 Fix memory leak of ConnectivityManager
The instance of ConnectivityManager is static, and so its inner class
should be static to avoid the memory leak. Otherwise, the inner class
will get the reference to the mContext.

Bug:248184860

Signed-off-by: zhujiatai <zhujiatai@xiaomi.com>
Change-Id: I2c755f04a689f3e9e5f829d9be48765816257366
2022-10-13 14:41:18 +08:00
Chalard Jean
1d420b3b76 Move bit utilities to BitUtils.
Test: BitUtilsTest
Change-Id: I3e100c6087f61c2a13aa8558ee8f9a9ad480c681
2022-10-12 16:39:37 +09:00
Chalard Jean
1e4afe071d Fix an infinite loop
If the top bit is set, then >>= propagates it. That means
|bitmask| is never 0, and this is an infinite loop.

A followup will move this method to frameworks/libs/net
and add tests for it.

Test: FrameworksNetTests
Change-Id: I28a0a74be41f6f29b796b1c76e404ecc21f810c6
2022-10-12 16:15:13 +09:00
Jean Chalard
f955700755 Merge "Validate NetworkCapabilities on unparceling" 2022-10-06 09:26:45 +00:00
Treehugger Robot
07c10ba72e Merge "Support QosCallback for UDP socket: Expose API&CTS" 2022-09-29 12:56:27 +00:00
Chalard Jean
d20e94e4e5 Validate NetworkCapabilities on unparceling
(and also on parceling, which is not really essential, but
still feels better)
This will avoid issues with NC objects unparceled by processes
when the sender was malicious.

Test: FrameworksNetTests
Bug: 246542132
Bug: 246542330
Change-Id: I8b40eb0c11e39b98bce23dc4e3df037c04639000
2022-09-29 18:31:48 +09: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
Chalard Jean
43aae65caf Move MultinetworkPolicyTracker to services, where it belongs.
This is necessary so that MultinetworkPolicyTracker can see
DeviceConfig. It will also allow removing reflection from
this file to address a long-standing TODO.

Test: build
Change-Id: I968bf67e0e0189b01515242371599c02bc9e2ca2
2022-09-27 14:10:41 +09:00
Chalard Jean
9708f7239c Implement the "actively prefer bad wifi" feature
Test: in progress
Change-Id: Ib7aba464a2f32642d434418842306dfcf90b8319
2022-09-22 16:59:30 +09:00
Chalard Jean
020b93ac63 Introduce an overlay for actively preferring bad wifi.
This correctly updates when the mcc/mnc change.

Test: MultinetworkPolicyTrackerTest
Change-Id: I11c7ea7074a15975fb68d39eb3c728778d84a516
2022-09-22 16:58:49 +09:00
Junyu Lai
3e7778805b Merge "Revert^2 "[ST02.2] Use the getters of DnsHeader"" 2022-09-22 02:39:42 +00:00
Chalard Jean
f11ed8c699 Start listening to telephony changes in #start()
Starting to listen on the handler races with the rest of
the constructor. The class already has a #start() method
meant to start listening, so implement better practices
by leveraging this method.

Test: CtsNetTestCases
      FrameworksNetIntegrationTests
      FrameworksNetTests
Change-Id: I772f761d3ca5f9711b9d988e6330b0878814f491
2022-09-21 18:07:13 +09:00
Junyu Lai
4c93f83290 Revert^2 "[ST02.2] Use the getters of DnsHeader"
Reason for revert: November mainline trains has been branched,
                   re-submit CLs and request API review.

Re-submitted 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: Ifb727e464d3523bd8dee0f2d919a8fb4a9d207c5
2022-09-16 07:41:27 +00:00
Treehugger Robot
e82dfc895a Merge "Use conventional args style for gen_jarjar" 2022-09-15 08:20:57 +00:00
Anton Hansson
3483b9b35c Merge changes from topic "revert-1387135-st02-CRMRFENEPA"
* changes:
  Revert "[ST02.1] Add TYPE_CNAME constant to DnsResolver"
  Revert "[ST02.2] Use the getters of DnsHeader"
2022-09-09 07:58:06 +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
Remi NGUYEN VAN
c7043880ef Revert "[ST02.2] Use the getters of DnsHeader"
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: Ia35cb3e21cd90e036a07018e2d9c1ee662ce86a2
2022-09-08 11:01:05 +00:00
Junyu Lai
7119e9cf5e Merge changes from topic "st02"
* changes:
  [ST02.2] Use the getters of DnsHeader
  [ST02.1] Add TYPE_CNAME constant to DnsResolver
2022-09-07 02:25:41 +00:00
Treehugger Robot
110ec66819 Merge "Straighten out NetworkAgentConfig's equals()" 2022-09-01 18:23:21 +00:00
Chalard Jean
333eaa930f Straighten out NetworkAgentConfig's equals()
Bug: 244312404
Test: FrameworksNetTests
Change-Id: I154f3b2ab898d6f428ccf9efa9ab90992beb1f9f
2022-09-01 08:14:49 +00:00
Junyu Lai
c9f1ca62d9 [ST01] Attributes data usage of test network by specifier
Currently, data usage of all test networks are all attributed to
the same NetworkIdentity, which does not allow services to
distinguish upload & download traffic of different test networks.

Thus, this CL put specifier that comes along with
TestNetworkAgent into wifiNetworkKey field to build different
NetworkIdentity to attribute data usage to different for
individual networks. And allow querying test network usage with
wifiNetworkKeys.

Bug: 139774492
Test: atest FrameworksNetTests
      atest android.net.cts.ConnectivityManagerTest
Change-Id: I1bb38fd20781eaf3105735440a04b27bef36fcae
2022-08-29 13:55:08 +08:00
Remi NGUYEN VAN
0bd90f10b9 Use conventional args style for gen_jarjar
gen_jarjar supported multi-valued arguments via space-separated lists,
like "--apistubs foo bar". This is unusual, as "bar" would generally be
interpreted as a positional argument instead.

Change the usage to "--apistubs foo --apistubs bar", which is more
conventional. Also remove the "--jars" switch to have the jars be
positional arguments instead, and change the "--unsupportedapi"
arguments to be a column-separated list (like java classpath), instead
of space-separated. For --unsupportedapi, this allows providing a list
of files via minimal modifications in the genrule usage.

Test: m
Change-Id: Id67ad16de2ea6682fee402540f464ed3b5b0cca9
2022-08-25 06:42:54 +00:00
Junyu Lai
ec2b24784f [ST02.2] Use the getters of DnsHeader
Bug: 139774492
Test: atest DnsPacketTest DnsResolverTest
Change-Id: Ib5616c65cce9668e7c6a00571c34ece7b4d8ab39
2022-08-25 14:06:30 +08: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
James Mattis
52cc8542ec Removing SuppressLint on NetworkRequst
Removing @SuppressLint("NewApi") on NetworkRequest when setting a
network specifier as it is no longer needed.

Bug: 228538826
Test: unit and CTS
Change-Id: Id79298c524536088e530e7ba3d2febce2f33685b
2022-08-12 16:10:29 -07:00
Paul Hu
a3340c1355 Merge changes I1cf472bd,Ibdaf2b23,I6967ad6f,I65f522c2,I0f220d1f, ...
* changes:
  Make the temporary NC sanitized instead of inlining
  Remove the legacy int from FullScore.
  Remove accessors for legacy int score from NAI
  Log the creation time of network agents
  Show time taken by the rematch
  Address some IDE warnings in ConnectivityService
  Copy arguments from NetworkAgent registration early
2022-08-10 01:41:43 +00:00
Treehugger Robot
bdedaacd88 Merge changes I036b7f23,I53c58e7b
* changes:
  Improve the JavaDoc for FIREWALL_CHAIN_OEM_DENY_x.
  Allow tests to set the NetworkAgent's callbacks when creating it.
2022-08-04 09:50:53 +00:00
Chalard Jean
0158fe9fd1 Remove the legacy int from FullScore.
This is a nice cleanup and will clear misunderstandings where
people mistakenly look at it in the logs.
Unfortunately it can't be removed from NetworkScore because there
are public APIs, and it's even used to transmit invincibility in
a legacy spur.

Bug: 238139913
Test: ConnectivityServiceTest
Change-Id: Ibdaf2b235b994383d5f8f42f1780b04bda80c93a
2022-08-04 06:45:39 +00:00
Lorenzo Colitti
f683c40939 Improve the JavaDoc for FIREWALL_CHAIN_OEM_DENY_x.
State that the chains are equivalent and independent.

As requested by API council.

Fix: 235973271
Test: documentation-only change
Change-Id: I036b7f23a40d038920f308c81daf7532afbae242
2022-08-03 09:24:28 +00:00
Chalard Jean
0c7ebe9e44 Opportunistic comment fix
Test: comment only
Change-Id: Icdf8980ebb64e42afe9c7ebc86ea605f897e47ba
2022-08-03 14:46:09 +09:00
Maciej Żenczykowski
0da1b4d4f2 fix native jni method signature - these are all static methods
See packages/modules/Connectivity/framework/src/android/net/NetworkUtils.java,
11 are 'static native' and 1 is 'native static'

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic6392452ce6f760db0f4300e0a35a33b9487c931
2022-07-28 18:08:22 +00:00
Motomu Utsumi
6bcb3c290c Merge "Use java BpfMap in BpfNetMaps#replaceUidChain" 2022-07-27 13:21:50 +00:00
Motomu Utsumi
9be2ea0080 Use java BpfMap in BpfNetMaps#replaceUidChain
Bug: 217624062
Test: atest BpfNetMapsTest
Change-Id: Ib2a2c2646834110a3eeeb786a4ea7a3f85718be8
2022-07-27 06:01:47 +00:00
Patrick Rohr
c886983669 NetworkProvider: improve documentation of unregisterNetworkOffer
Add a warning to unregisterNetworkOffer to inform users that this method
executes asynchronously.

Test: documentation only change
Change-Id: Ic4742bf570ebcd4d00b0b259c35fd46688494517
2022-07-25 13:31:14 -07:00
Patrick Rohr
4a4498c1d4 Revert "NetworkProvider: Do not propagate callbacks for unregistered offers"
This reverts commit 546c722511.

Test: TH
Change-Id: I2c8a8e7faf407a0dae17074d2d435669e16b5e79
2022-07-25 13:31:14 -07:00
Patrick Rohr
e6162aca71 Merge "TestNetworkService: add support to disable DAD on test interfaces" 2022-07-21 22:19:26 +00:00
Patrick Rohr
336bb5cf6d TestNetworkService: add support to disable DAD on test interfaces
DscpPolicyTest does not have an IpClient, so it relies on assigning the
LinkAddresses at interface creation. If DAD is enabled, the global
address cannot be used immediately, so the test packet selects the wrong
source address. There is no obvious way to fix this without disabling
DAD as the TestableNetworkCallback receives the LinkProperties update
before the address can be used.

This functionality will also be useful in ethernet tests, which
currently have to block for a long time.

Test: atest DscpPolicyTest
Bug: 235559605
Change-Id: Id7788df5e92ebd8eaf4619a23f44135ea4a2144e
2022-07-21 10:20:16 -07:00
Remi NGUYEN VAN
e55a88d30f Use jarjar rule generator for connectivity rules
(This rolls forward part of a previous change, now that jarjar was fixed
to not get very slow when the number of rules increases).

Autogenerate connectivity jarjar rules at build time, to avoid issues
with forgotten jarjar rules or hard-to-diagnose errors introduced by
incorrect rules.

This change causes all classes in framework-connectivity(-t) and
service-connectivity to be jarjared into android.net.connectivity, but
still avoids jarjaring classes in com.android.server as before, to keep
it small.
For many classes this differs from the original jarjar rule.

Notes on implementation:

 - connectivity-jarjar-rules now has a subset
   framework-connectivity-jarjar-rules containing only the rules
   necessary for framework-connectivity. This is necessary because
   framework-connectivity cannot depend on rules generated based on
   service-connectivity, as there would be a dependency cycle
   (service-connectivity depends on framework-connectivity); Soong even
   crashes with a stack overflow.

 - framework-wifi.stubs.module_lib is added to
   framework-connectivity-pre-jarjar as it is necessary to build it (it
   is already in impl_only_libs in the defaults).
   It is unclear why framework-connectivity-pre-jarjar could build
   before that (possibly because it was only used as "lib" ?)

 - Fix package-private visibility; for example NattSocketKeepalive,
   TcpSocketKeepalive are not API so should be jarjared, but are used
   by ConnectivityManager which is not jarjared, so they are not in the
   same package after the change. Package-private members in the
   former 2 need to be public to be accessible. Changes in this commit
   are all that is needed, as demonstrated by followup commits that move
   the classes to a different package without further changes, and that
   enforce that no class in an API package gets jarjared.

 - framework-connectivity-internal-test-defaults is separated from
   framework-connectivity-test-defaults, for unit tests that need to
   access internal jarjared classes. Such tests need to use the jarjar
   rules themselves too, so this is only appropriate for connectivity
   internal unit tests.

Test: atest ConnectivityCoverageTests CtsNetTestCases
Bug: 217129444
Change-Id: Ib1bd939b71c0171d945fc01b96195d2f620ff13b
2022-07-20 19:57:11 +09:00
Remi NGUYEN VAN
16e244ed0f Merge "Revert EXCLUDED_ROUTES to only keep RTN_UNICAST" 2022-07-16 01:43:04 +00:00
Remi NGUYEN VAN
48380e4132 Revert EXCLUDED_ROUTES to only keep RTN_UNICAST
Revert the previous change to filter out all non-RTN_THROW routes when
EXCLUDED_ROUTES is disabled, as that behavior is CTS tested for T, and
has been used by T for a while. The previous change already ensured that
there is no behavior change on S, so this is the safest approach.

This fixes HostsideLinkPropertiesGatingTests.

Bug: 239046959
Test: atest LinkPropertiesTest CtsHostsideNetworkTests
Change-Id: I55e078cdc06341f4957fe7bc743c0022b2c7d3da
2022-07-15 16:46:14 +09:00
Chiachang Wang
b7f81e4a6d Merge "Correct javadoc usage" 2022-07-15 07:41:33 +00:00