Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
Merge changes Id723dc9e,I3665d843 into main
* changes:
  Treat RESERVATION requests the same as REQUEST types
  Adds a new RESERVATION request type

Patrick Rohr   authored and   Gerrit Code Review   commited 2024-12-12 13:51:32 -08:00
b960664fa8
CaptivePortal: implement setDelegateUid API.
This API is designed to set the UID of the app that is allowed to
perform network traffic for captive protal login, communication will
bypass network access restrictions such as VPNs and private DNS settings
when a portal page is launched by Android Custom Tabs and bind the
upcoming traffic to that portal network.

Bug: 373773542
Test: atest ConnectivityCoverageTests
Change-Id: I9992671634b8e88f5a647455811a6157fb15a44b

Patrick Rohr   authored and   Xiao Ma   commited 2024-12-11 20:27:10 +09:00
7d6dfd52b2
Treat RESERVATION requests the same as REQUEST types
Test: CSNetworkReservationTest
Change-Id: Id723dc9edb67bf878fb5b2680327e7b598f6c64f

Patrick Rohr   commited 2024-12-10 13:28:08 -08:00
e4c602e9f5
Read idle timer configurations from the boot namespace
The values are only read during startup so moving these to a boot
namespace. This will ensure that the values are committed to logs only
after a boot.

The boot namespace is already provisioned, but going forward the
string constants for the namespace do not need to be defined in the
DeviceConfig module.

Test: atest ConnectivityCoverageTests:\
android.net.connectivity.com.android.server.CSNetworkActivityTest

Test: Manually using shell commands. E.g.:
adb shell device_config put tethering_boot \
cellular_data_inactivity_timeout 4

Bug: 377759682
Change-Id: Icd4bd3da288e5dfde620d779bd0708319da90be9

Suprabh Shukla   commited 2024-12-02 16:22:10 -08:00
392336b50d
Merge changes I2388220a,I5f282160 into main
* changes:
  Add a test for delayed teardown with unregisterAfterReplacement.
  Fix system crash when netd return error

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-11-12 18:47:07 +00:00
f45f40717b
Merge "Make the idle timer for network data tracking configurable" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-31 21:15:37 +00:00
cf3b26e3bf
Fix system crash when netd return error
API networkSetPermissionForNetwork return
ServiceSpecificException from netd is expected.
Don't crash system under this scenario.

Bug: 363854848
Test: TH
Change-Id: I5f2821603ff51104f38208775d7b3d60265aeeab

Xiaohui Niu   commited 2024-10-30 16:28:08 +08:00
339d6b20e7
Make the idle timer for network data tracking configurable
Networks can use widely varying timeouts for their connections. Because
cellular modems use a lot of power, having this configurable is more
useful for tuning this to an optimal value for power drain.

Adding a similar configurable value for WiFi for parity.

Test: atest ConnectivityCoverageTests:\
android.net.connectivity.com.android.server.CSNetworkActivityTest

Bug: 373733012
Change-Id: I2418f09233b2e3fa4e9cdd8fbb6149a35106b735

Suprabh Shukla   commited 2024-10-29 19:06:42 -07:00
c623c946f5
Merge changes I7184eaa0,I2c5951ab into main
* changes:
  Do not crash when adding UID ranges to a destroyed network.
  Test that UID ranges can incorrectly be added to a destroyed network.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2024-10-23 04:39:07 +00:00
6bf2ce44e4
Do not crash when adding UID ranges to a destroyed network.
aosp/3218864 fixed the crash when ranges are removed from a
destroyed network, but did not fix the case where the ranges are
added to a destroyed network.

This can happen if a multilayer request is filed when a network
has already been destroyed.

Fix: 368989698
Test: updated existing tests for this bug
Change-Id: I7184eaa01141f56b7ad774277c7dee03d5812298

Lorenzo Colitti   commited 2024-10-22 11:41:21 +00:00
dfe98fc5be
Standardize handler thread checks
Use HandlerUtils#ensureRunningOnHandlerThread to perform handler
thread checks instead of individual methods within the class.

Test: TH
Change-Id: I6d893dc9eedc588660797768a03e7ad7ab636479

Paul Hu   commited 2024-10-17 06:14:05 +00:00
c0e709700c
Introduce PrivateAddressCoordinator methods at RoutingCoordinatorManager
This CL exposes PrivateAddressCoordinator methods at
RoutingCoordinatorManager and implements the methods in
RoutingCoordinatorService.

The objective is to allow a system service like Thread to request an
IPv4 address allocation.

Bug: 350699020

Change-Id: I65dc309f0b503d544e0fddc1168131fa6174796c

Handa Wang   commited 2024-10-16 23:54:25 +00:00
e5e06f9f7c
Merge "Fix threading issue for mDefaultNetworkRequests" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-09-06 13:10:58 +00:00
a5a549bfd8
Fix threading issue for mDefaultNetworkRequests
Handler thread updates mDefaultNetworkRequests and Multiple threads
read/iterate mDefaultNetworkRequests without locking.
This caused NPE when there is concurrent updates and iterations.
This CL fixed this issue by using CopyOnWriteArraySet.
CopyOnWriteArraySet is suitable since number of default network request
is small (system default network request + per-app default network
requests) and updated infrequently but read frequently.

Bug: 293978451
Test: TH
Change-Id: Iaefe8e6e31c2b5257ebc51b4f848c3a7197781cb

Motomu Utsumi   commited 2024-09-06 11:04:00 +09:00
7b906dea29
Skip TestDropPacketToVpnAddress if the feature is disabled
INGRESS_TO_VPN_ADDRESS_FILTERING is disabled due to b/352424251 and
testDropPacketToVpnAddress fails if the feature is disabled.
So skip testDropPacketToVpnAddress if the feature is disabled.

Bug: 362434644
Test: adb shell device_config put tethering
      ingress_to_vpn_address_filtering -1
Test: atest CtsHostsideNetworkTests

Change-Id: Ib16a7550dcf93dd9ecf29047b1c4f101ff6d610d

Motomu Utsumi   commited 2024-09-02 15:21:30 +09:00
9d5d7d0779
Add mIngressToVpnAddressFiltering to dump
Example output:

Multicast routing supported: true
Background firewall chain enabled: true
IngressToVpnAddressFiltering: false

Bug: 362434644
Test: adb shell dumpsys connectivity
Change-Id: I36e0726d7b7ffe873ed6498a45f57c459cc884cc

Motomu Utsumi   commited 2024-08-29 19:24:47 +09:00
727dd5dea4
Check network destroy status before networkRemoveUidRangesParcel
networkRemoveUidRangesParcel throws ServiceSpecificException if the
native network is already destroyed.
This can happen when
1) per-app default network request is satisfied by network1
2) unregisterAfterReplacement is called to the network1. This calls
   netd.networkDestroy and network is removed from netd.
3) per-app default network request is removed. This calls
   netd.networkRemoveUidRangesParcel but netd does not know about this
   netid anymore.

This CL fixes this issue by skip calling networkRemoveUidRangesParcel if
the request satisfier is already destroyed.

Bug: 336961452
Bug: 357974842
Test: CSSatelliteNetworkTest
Change-Id: Id775cca6fffd03545f1c4bc5016d0de4813f17df

Motomu Utsumi   commited 2024-08-19 16:25:39 +09:00
471f20142f
Skip adding ingress discard rule to OEM VPN
OEM VPNs might need to receive packets to VPN address via
non-VPN interface.

Bug: 352424251
Test: CsIngressDiscardRuleTest
Change-Id: Ia9000bcbb5b3b9e1e0d396ba78946be36e2fc5ba

Motomu Utsumi   commited 2024-08-06 19:02:33 +09:00
c14288f7c7
Merge changes If787d3f3,I6de357ac into main
* changes:
  Rename getShrinkedBackingArray to getMinimized*
  Suspend callbacks for frozen apps

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-08-05 00:15:39 +00:00
057369c840
Rename getShrinkedBackingArray to getMinimized*
"Shrinked" should actually be "shrunk" or "shrunken"; in any case
"minimized" is simpler and possibly more accurate (it's the minimum size
required to hold the values).

Test: atest
Change-Id: If787d3f3d6e1046338d4e89ed924bce183e74bd6

Remi NGUYEN VAN   commited 2024-08-02 19:27:41 +09:00
dfb159289b
Suspend callbacks for frozen apps
To avoid filling the binder buffers, and sending unnecessary callbacks
when apps are unfrozen (for example successive LinkProperties changes or
onAvailable+onLost are not useful), queue and aggregate callbacks for
apps that are suspended.

Test: atest
Bug: 327038794
Bug: 279392981
Change-Id: I6de357ac2834f1f7e960dfbaa63adfc3825f2a82

Remi NGUYEN VAN   commited 2024-08-02 19:24:17 +09:00
2d78124348
Skip adding ingress discard rule to legacy VPN
Some legacy VPNs need to receive packets to VPN address via
non-VPN interface.

Bug: 352424251
Test: CsIngressDiscardRuleTest
Change-Id: Iad06dc69c5bf5ccda476e89ed9b0fc1bc63d2ebe

Motomu Utsumi   commited 2024-08-02 19:15:59 +09:00
1b376f0fc4
Fix import order
Reorganize imports to make linter happy.

Test: m
Change-Id: If0e290cf9f2d12d8479848b6a74690412b673439

Remi NGUYEN VAN   commited 2024-07-19 11:59:40 +09:00
42dc6e49e0
No-op refactoring for suspending callbacks
No-op refactoring of ConnectivityService, in preparation for a change to
suspend callbacks for frozen apps.

Test: atest
Bug: 327038794
Bug: 279392981
Change-Id: I55bdd6c1244d6829d40223883ca148ce9ac5dca8

Remi NGUYEN VAN   commited 2024-07-16 15:53:09 +09:00
a65af5f8e1
Add flag for QUEUE_CALLBACKS_FOR_FROZEN_APPS
Add a flag to be used for an optimization to queue callbacks while apps
are frozen, instead of filling the binder buffer.

Bug: 327038794
Bug: 279392981
Test: atest
Change-Id: I6cc2507de88fae3d0866f9831e1e9026200297e4

Remi NGUYEN VAN   commited 2024-07-16 13:36:51 +09:00
48d2527e43
Refactor RoutingCoordinator
- This CL puts RoutingCoordinator into staticlibs to make it usable by
both Tethering and ConnectivityService on R.
- This CL also changes the return type of
  ConnectivityInternalApi#getRoutingCoordinatorManager() to IBinder so
  it has fewer dependencies.

Bug: 350699020
Test: CI

Change-Id: Iba096e940795cd33e61c5141721394ad39e5ce6d

Handa Wang   commited 2024-07-05 05:26:54 +00:00
8f2c30664d
Merge "Improve NetworkCallback declared methods toString" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-04 04:11:52 +00:00
5289382f04
Improve NetworkCallback declared methods toString
Instead of printing the flags as hex, use flag names for known flags.

Bug: 327038794
Bug: 279392981
Test: atest
Change-Id: I11ba4de1e8e60d5468a72b275cd724be669b32bc

Remi NGUYEN VAN   commited 2024-07-03 19:09:51 +09:00
baf7c1184f
Merge "Refactor enforceMeteredApnPolicy" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-06-28 02:24:06 +00:00
9f3b991a7a
Refactor enforceMeteredApnPolicy
Address review comment on aosp/3027487
This CL also adds test for enforceMeteredApnPolicy

Test: CSBlockedReasonsTest
Bug: 344800107
Change-Id: Ib531bf5b34566fc91fec9f977c5257b332189706

Motomu Utsumi   commited 2024-06-27 22:25:47 +09:00
e9c07ffd72
Merge "Revert "Prepare for @RequiresApi class retention"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-06-26 11:47:49 +00:00
270f0064f6
Revert "Prepare for @RequiresApi class retention"
This reverts commit 53da9ac34c.
And fixes the linter errors.

Bug: 328190227
Test: TH
Change-Id: I92e0f268c770b6e46bdc781d4867f1e0b505d4ad

Motomu Utsumi   commited 2024-06-26 19:14:30 +09:00
a1a0034f0e
Merge "Only send callbacks when overridden" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-06-26 07:35:45 +00:00
e1c10b08a2
Only send callbacks when overridden
Most users of NetworkCallback do not override all methods, so callbacks
from ConnectivityService end up being unused by the app.

To save resources, check which callback methods are overridden in
ConnectivityManager, and inform ConnectivityService so it can skip
preparing and sending the corresponding binder calls when the callback
is not used by the app.

This is flagged off by default.

Test: flag enabled: atest CtsNetTestCases ConnectivityCoverageTests
Bug: 327038794
Bug: 279392981

Change-Id: Iaf490f416fb6e1437d40497fba1a40a899a9f523

Remi NGUYEN VAN   commited 2024-06-26 12:39:47 +09:00
2fd3823cbc
Revert "Add a temporary hack to CS to report netbpfload result"
This reverts commit fe956d9189.

This is targetting mainline release M-2024-09.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If89337854d677fdef1389b85cea645715a5e8491

Maciej Żenczykowski   commited 2024-06-21 15:14:33 +00:00
8e7276b482
Revert "Add a Log.wtf() on user builds to test Pitot reporting pipeline"
This reverts commit 9161b153b4.

This is targetting mainline release M-2024-09.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3d053f8c006eee8c1cbc7918f6fc5e30f5d09375

Maciej Żenczykowski   commited 2024-06-21 15:14:20 +00:00
2a911d6c18
bpf: attach a *bunch* more cgroup hooks
We attach trivial programs to:
  {connect,recvmsg,sendmsg}{4,6}
  inet_release
  {g,s}etsockopt

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifd3a6dff20a5881f4fdb5d1b4b7b03a55988fd74

Maciej Żenczykowski   commited 2024-06-16 10:04:35 -07:00
22db590580
ConnectivityService - do not dumpBpfProgramStatus before T
this is to fix some lint issues

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8c4dff0c8a6ba28596a346fef40f698962e7094b

Maciej Żenczykowski   commited 2024-06-16 05:22:58 -07:00
f0da1bee5e
Add a Log.wtf() on user builds to test Pitot reporting pipeline
Apparently, we have previously seen instances of the pipeline being
broken, so this is adding a Log.wtf() to test the pipeline.

It is only run on user builds to not randomly crash droidfood devices.

Test: cf boots
Change-Id: Ie4e6661adef6f1878529688561805f2485e58391

Patrick Rohr   commited 2024-06-15 14:11:55 -07:00
9161b153b4
Add a temporary hack to CS to report netbpfload result
Since BpfHandler::init() in the August module does not wait on
netbpfload (it only loads test.o), post on the ConnectivityService
handler and check that netbpfload ran to completion after 30s.

Log.wtf() on failure as these logs show up in Pitot even on release
builds.

Note that system server does not have access to any of the programs or
maps loaded from test.c, so all it can do is verify that mainline_done
exists.

Test: cuttlefish boots and does not crash
Change-Id: I6d2063f1d4f03207bbb6599b75954cfceb793af4

Patrick Rohr   authored and   Maciej Żenczykowski   commited 2024-06-15 03:58:43 -07:00
fe956d9189
Merge changes I62c990d0,I413bdb76,I020ba48e into main
* changes:
  Update NetworkRequestTest#testDefaultCapabilities
  Allow default messaging app to use constrained satellite network
  Introduce NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED

Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-06-07 09:29:06 +00:00
3e07102814
Allow default messaging app to use constrained satellite network
On V+, there could be satellite network which is not restricted but
bandwidth constrained.
These satellite network has NET_CAPABILITY_NOT_RESTRICTED but does not
have NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED.
Since NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED is set by default, this
CL remove this capability from per-app default network request for the
default messaging app.

Test: CSSatelliteNetworkTest
Bug: 343823469
Change-Id: I413bdb764ead42d67ce1315c365500dbb8508eb3

Motomu Utsumi   commited 2024-06-07 09:26:19 +09:00
ab750abf29
Add config flag for useDeclaredMethodsForCallbacks
Add a DeviceConfig flag that will be used to control whether callbacks
should be sent selectively based on whether the receiving method has
been overridden (will be implemented in a future change).

This adds utilities to allow ConnectivityManager to check whether a
ConnectivityService flag is enabled, as that feature will work across
ConnectivityManager and ConnectivityService. ConnectivityManager runs in
app process and does not necessarily have permissions to use
DeviceConfig. Also if it checked DeviceConfig separately from
ConnectivityService, values may be out-of-sync.

Test: atest, and see change using this
Change-Id: I204fa719cc627e84edc5c1e043d947f5ef3f8dee

Remi NGUYEN VAN   commited 2024-06-05 15:54:49 +09:00
aa355ac875
Merge "Explicitly log portal detections" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-05-31 11:27:11 +00:00
d1c52e3eb0
Merge "Clatd: add dump raw BPF map support" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-05-31 08:11:44 +00:00
3812c394ba
Clatd: add dump raw BPF map support
Add dump raw BPF map command to connectivity service. The result will
be encoded as base64 strings. This is a preparation for Clatd's tests.

Usage:
    dumpsys connectivity {clatEgress4RawBpfMap|clatIngress6RawBpfMap}

Bug: 285124667
Test: test with MtsEthernetTetheringTest#testTetherClatBpfOffloadUdp
      which will be uploaded in a separated CL
Change-Id: I02c8efadb1c4b861d9bf6168667816b13412dc75

KH Shi   commited 2024-05-31 06:34:41 +00:00
855712aa55
Merge "Revert^2 "Add blocked reason for internet permission"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-05-28 00:00:07 +00:00
d86bd6faca
Revert^2 "Add blocked reason for internet permission"
This reverts commit cb74c08979.

Reason for revert: This change is not a cause of b/342557183

Change-Id: Iee8d9b05bbe130a46b627b12da525177b4ee89b2

Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-05-27 02:12:43 +00:00
cfd5a517da
Merge "Revert "Add blocked reason for internet permission"" into main
Priyanka Advani   authored and   Gerrit Code Review   commited 2024-05-24 18:56:26 +00:00
fb1b1b3773
Revert "Add blocked reason for internet permission"
This reverts commit ee96ba0e60.

Reason for revert: Droidmonitor triggered revert due to b/342557183. Will be verifying through ABTD before submission.

Change-Id: I7e185c3ac11da27c7bb9d95e4221f7dfc22cf48c

Priyanka Advani   authored and   Gerrit Code Review   commited 2024-05-24 18:11:45 +00:00
cb74c08979