Commit graph android_packages_modules_Co.../framework/src/android/net
Message SHA1
Merge "add TRANSPORT_THREAD to NetworkCapabilities"
Kangping Dong   authored and   Gerrit Code Review   commited 2023-02-28 07:16:16 +00:00
7dc4459d33
Merge "Add getUidFirewallRule to ConnectivityManager"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-02-17 01:53:00 +00:00
7f3dfbfacf
Merge "Allow SUW to access registerSystemDefaultNetworkCallback"
Quang Luong   authored and   Gerrit Code Review   commited 2023-02-15 20:22:10 +00:00
0f6a2e69cd
Merge "Add underpinned Network parameter in SocketKeepalive.start()"
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-02-14 12:35:30 +00:00
b7f97fd70e
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
Correct a wrong doc tag
Change-Id: Icefc5599d0a500ccd9b5d2247ece75ac5cdc5c7e
Test: doc-only change

Jean Chalard   commited 2023-02-13 05:08:11 +00:00
17cbf06773
Merge changes I99d494d3,I208ceceb
* changes:
  [DK4-0]Add CM#setTestLowTcpPollingTimerForKeepalive for testing
  [DK3] Send onPause/onResume keepalive callbacks

Jean Chalard   authored and   Gerrit Code Review   commited 2023-02-13 05:06:20 +00:00
b5ebe944b5
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
Moves all compatibility flags to ConnectivityCompatChanges.java
ConnectivityCompatChanges.java becomes the centralized place for all the
CompatChanges used in the Connectivity module. By putting all the
CompatChanges here, we are able to manage them under a single
platform_compat_config.

Bug: 268440216
Test: atest FrameworksNetTests
Change-Id: I3e17af545718073d7d1c96e27298e7790563fd33

Yuyang Huang   commited 2023-02-09 19:51:37 +09:00
90a2cbdd8d
Merge "Use the binder to identify keepalive in IConnectivityManager"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-02-07 08:17:26 +00:00
b5a87674f0
Merge "Revert "Adds document for self certified network capabilities""
David Gutierrez   authored and   Gerrit Code Review   commited 2023-02-06 21:21:20 +00:00
c1e778a67b
Revert "Adds document for self certified network capabilities"
This reverts commit 75c7df1cab.

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=git_tm-mainline-prod&target=sdk_phone_x86_64-sdk&lkgb=9566659&lkbb=9569194&fkbb=9566666, bug 267986902
BUG: 267986902

Change-Id: Ic65c729f95920e73c11bcf0e3b83e4331a678055

David Gutierrez   authored and   Gerrit Code Review   commited 2023-02-06 21:01:58 +00:00
ad7e542ab4
[DK4-0]Add CM#setTestLowTcpPollingTimerForKeepalive for testing
The default TCP polling alarm timer is very large(2 mins).
It's expensive in the CTS to wait for a couple alarms.
The polling alarm should be deprecated soon and replace
with callback design, so add the hidden method for testing
purpose to support the short term usage until design is
replaced with callbacks.

With the hidden method, the alarm timer will decrease to
1 second for a specified time period. The TCP sockets status
could be verified every 1 second.

Bug: 259000745
Test: m ; atest HostsideVpnTests with the follow up test
Change-Id: I99d494d3b50b2fbee73b926e92e97b1e194d43d4

chiachangwang   commited 2023-02-06 13:25:01 +00:00
e0192a7433
[DK3] Send onPause/onResume keepalive callbacks
Test: CTS in the patch immediately on top of this, [DK4]
Change-Id: I208ceceb37c7977452479361f70f046fabafb37a

Chalard Jean   authored and   chiachangwang   commited 2023-02-06 13:23:13 +00:00
bdb8282604
Use the binder to identify keepalive in IConnectivityManager
This is much simpler and less error-prone, as well as less
subject to race conditions.

It also allows for cleaning up some TODOs.

Test: FrameworksNetTests
      CtsNetTestCases
Bug: 267116236
Change-Id: I470c709446946ef35a0324427defe2f58b434339

Chalard Jean   authored and   chiachangwang   commited 2023-02-06 13:22:53 +00:00
f0b261e7cc
Merge "Adds document for self certified network capabilities"
Yuyang Huang   authored and   Gerrit Code Review   commited 2023-02-06 06:00:53 +00:00
c8c0d1f03b
Adds document for self certified network capabilities
String from Android 14, the user must explicitly declare some
capabilities in the application if the application need to call
ConnectivityManager.requestNetwork() with those capabilities.

Test: atest FrameworksNetTests
Bug: 266524688
Change-Id: I8b4816ae3a425ff59d2c1ef09331e079b0e9596e

Yuyang Huang   commited 2023-02-06 11:35:07 +09:00
75c7df1cab
Use the binder token to reference AutoKI in alarm
This patch uses the binder token represented by the callback
to communicate the identity of the AutoOnOffKeepalive through
the alarm mechanism. This is a lot more robust and easy to
understand.

Addressing this, on top of the robustness and readability
advantages, corrects three bugs.

• The |obj| in the message to CMD_MONITOR_AUTOMATIC_KEEPALIVE
  is now the binder token both on the sender side and the
  receiver side, while the previous code had a Network in the
  sender while the receiver expected AutoOnOffKeepalive,
  crashing the system server with a wrong cast.
• The intent sent in the alarm would have a yet-uninitialized
  value for the slot, so it would not be possible to find the
  auto keepalive when the alarm fires.
• When the slot is reassigned, the alarm continued to fire
  with the same slot value, so the auto keepalive would no
  longer be found after a pause/resume cycle that would
  change the slot.

Test: FrameworksNetTests
Change-Id: Ibdbfcd884e0d3559206cbaae7b6b7a524972c3ca

Chalard Jean   authored and   chiachangwang   commited 2023-02-04 08:05:00 +00:00
98732dbd6d
Add getUidFirewallRule to ConnectivityManager
Upcoming CLs use this method to add chain status to failure log of
ConnectivityManagerTest#testFirewallBlocking which is a flaky test

Test: m
Bug: 262141231
Change-Id: Ieb6b4402a3435571decbd8a26fdf666b2db732fe

Motomu Utsumi   commited 2023-02-01 17:05:39 +09:00
900b806a3b
Always have an AutomaticOnOffKeepalive to manage a KI
Test: FrameworksNetTests 'CtsNetTestCases' CtsHostsideNetworkTests
Change-Id: Ic216b525d8297fce0f390daae327e667a14b7775

Chalard Jean   authored and   chiachangwang   commited 2023-01-31 02:34:44 +00:00
23f1bfd471
Factorize describeDifferences
Bug: 259479229
Test: FrameworksNetTests
Change-Id: Iecbccd10b04ada49f3485097dfcf3511c26c0925

Chalard Jean   commited 2023-01-27 16:44:33 +09:00
cf0260b08d
[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
Add CDM dependency in Tethering
This change introduces a limited library for dependencies on
framework-connectivity from Tethering,
connectivity-internal-api-util, where all classes are annotated with
@RequiresApi(S) to ensure proper API checks are done before usage.

Bug: 245972418

Change-Id: I82bafd9063341adc71d07f0858e6d68283d081f0

Igor Chernyshev   commited 2022-12-16 17:55:53 +00:00
9dac660bf0
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
TestNetworkInterface: improve documentation of newly added methods
This change addresses API review feedback and improves documentation.
Specifically, it adds documentation for the newly added getMtu() and
getMacAddress() methods, describes under which conditions the MAC
address is null and adds a short blurb on how (or in what context) this
class is used.

Test: TH
Bug: 236187143
Change-Id: I349897fd55f3085ce88c8b94c84ec636bb5eb2a6

Patrick Rohr   commited 2022-11-18 09:44:30 -08:00
2af2ae8168
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
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

Maciej Å»enczykowski   commited 2022-11-04 11:43:22 +00:00
44089f5080
Merge "Fix memory leak of ConnectivityManager"
Jean Chalard   authored and   Gerrit Code Review   commited 2022-11-02 08:06:03 +00:00
06853a7744
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
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

Chalard Jean   commited 2022-10-14 14:32:38 +09:00
86317d8bb4
Merge "Move bit utilities to BitUtils."
Jean Chalard   authored and   Gerrit Code Review   commited 2022-10-14 04:55:25 +00:00
e45e581cff
Merge "Fix an infinite loop"
Jean Chalard   authored and   Gerrit Code Review   commited 2022-10-14 04:54:51 +00:00
d96aff4f1b
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

zhujiatai   commited 2022-10-13 14:41:18 +08:00
79b0de9ef2
Move bit utilities to BitUtils.
Test: BitUtilsTest
Change-Id: I3e100c6087f61c2a13aa8558ee8f9a9ad480c681

Chalard Jean   commited 2022-10-12 16:39:37 +09:00
1d420b3b76
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

Chalard Jean   commited 2022-10-12 16:15:13 +09:00
1e4afe071d
Merge "Validate NetworkCapabilities on unparceling"
Jean Chalard   authored and   Gerrit Code Review   commited 2022-10-06 09:26:45 +00:00
f955700755
Merge "Support QosCallback for UDP socket: Expose API&CTS"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-09-29 12:56:27 +00:00
07c10ba72e
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

Chalard Jean   commited 2022-09-29 18:31:48 +09:00
d20e94e4e5
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
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

Chalard Jean   commited 2022-09-27 14:10:41 +09:00
43aae65caf
Implement the "actively prefer bad wifi" feature
Test: in progress
Change-Id: Ib7aba464a2f32642d434418842306dfcf90b8319

Chalard Jean   commited 2022-09-22 16:59:30 +09:00
9708f7239c
Introduce an overlay for actively preferring bad wifi.
This correctly updates when the mcc/mnc change.

Test: MultinetworkPolicyTrackerTest
Change-Id: I11c7ea7074a15975fb68d39eb3c728778d84a516

Chalard Jean   commited 2022-09-22 16:58:49 +09:00
020b93ac63
Merge "Revert^2 "[ST02.2] Use the getters of DnsHeader""
Junyu Lai   authored and   Gerrit Code Review   commited 2022-09-22 02:39:42 +00:00
3e7778805b
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

Chalard Jean   commited 2022-09-21 18:07:13 +09:00
f11ed8c699