Commit graph android_packages_modules_Co.../service
Message SHA1
Always drop non-VPN ingress in lockdown mode
When "Block connections without VPN" is specified, incoming traffic
from non-VPN interfaces should be blocked regardless of the
determination made by ConnectivityService#getVpnIsolationInterface.
Outgoing traffic to non-VPN interfaces is already blocked in this case.
(Loopback is excluded as usual.)

Test: `adb shell dumpsys connectivity trafficcontroller` will now show
the tunnel interface for uids affected by lockdown when
getVpnIsolationInterface returns null (wildcard), to block non-VPN
ingress to such uids. This will return to 0 (wildcard) when lockdown
is toggled back off.

Also includes squashed change:

Author: Tommy Webb <tommy@calyxinstitute.org>
Date:   Mon May 1 16:52:28 2023 -0400

    fixup! Always drop non-VPN ingress in lockdown mode

    For lockdown purposes, force an update of VPN filtering whenever the
    interface names for a VPN have changed, to ensure that the BPF owner
    map uses the most up-to-date interface for ingress filtering.

    Issue: calyxos#1651
    Change-Id: Ia0c75a723134023906134597b395653c7a570686

Co-authored-by: Tommy Webb <tommy@calyxinstitute.org>
Issue: calyxos#1255
Bug: 206482423
Change-Id: Id7954816566cb06bf2e9869ea98b20678835df9d

Oliver Scott   commited 2026-01-19 09:54:05 -05:00
0e19223594
Android 16.0.0 release 4
-----BEGIN PGP SIGNATURE-----
 
 iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCaS5huQAKCRDorT+BmrEO
 eIsnAJ9kJ9OjiHpwigt9XwjTrGcbD1hQ0QCfSw2VHyS9TLyzt7DZsQ3AYU+WVVA=
 =/SH/
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN SSH SIGNATURE-----
 U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgPpdpjxPACTIhnlvYz0GM4BR7FJ
 +rYv3jMbfxNKD3JvcAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5
 AAAAQHUBff/oLA1TO7KbbZDsBJZmFVcXgFmG+2K3aaKq9F0tiaT1kiNeHdjXpaLI07p344
 TExz9CBvFVft81pJyRBwY=
 -----END SSH SIGNATURE-----

Merge tag 'android-16.0.0_r4' into staging/lineage-23.2_merge-android-16.0.0_r4

Android 16.0.0 release 4

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCaS5huQAKCRDorT+BmrEO
# eIsnAJ9kJ9OjiHpwigt9XwjTrGcbD1hQ0QCfSw2VHyS9TLyzt7DZsQ3AYU+WVVA=
# =/SH/
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Dec  2 05:49:13 2025 EET
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [ultimate]

# By Yan Yan (203) and others
# Via Automerger Merge Worker (1173) and others
* tag 'android-16.0.0_r4': (1057 commits)
  Use string for CREATE_APP_SPECIFIC_NETWORK permission
  bpf: move MSS calculation under CE check to avoid overhead
  BpfNetworkStats: use `atomic` for ifindex cache when possible
  NetBpfLoad: remove pointless 0 write.
  bpf: remove obsolete isAtLeastR/Sv2/25Q3
  NetBpfLoad: use global `api_level_full` directly in NetBpfLoad
  Log validated underlying network count that's available for VCN underlying network selection
  BpfUtils: fix sdk level detection logic for 25Q3+
  Add RTMGRP_IPV6_IFINFO
  bpf: remove BPFLOADER_MAINLINE_U_QPR3_VERSION
  bpf: move BPFLOADER_MAINLINE_S_VERSION into bpf_map_def.h
  Reduce log level for BluetoothSocket errors
  Bump the min sdk of Tethering
  BpfNetworkStats: apparently RiscV isn't actually a 64-bit architecture.
  KernelUtils.h: isAtLeastKernelVersion(x,y,z) - default 'z' to 0
  bpf_existence_test - update for tcp acc ecn
  bpf: tcpAccECN: eliminate header file and move more fully into netd
  BpfMap: shorten error strings to enable SSO (on 64-bit)
  BpfNetworkStats: enforce that IfaceValue access is lock-free
  NetBpfLoad: use libbpf based on mainline beta flag, part 2
  ...

 Conflicts:
	bpf/headers/include/bpf/KernelUtils.h
	bpf/progs/netd.h

Change-Id: I76a7aadc1405c6621e17f3d1b6b87640d84f5794

Michael Bestas   commited 2025-12-09 22:59:06 +02:00
42374b293f
Revert "Always drop non-VPN ingress in lockdown mode"
This reverts commit 19f95c26ad.

Reason for revert: Conflicts with BP4A.

Change-Id: I9900859136d643bafce00e85c818714bc4e139ef

Michael Bestas   commited 2025-12-09 06:39:21 +02:00
f7f117c4b2
Android 16.0.0 Release 3 (BP3A.250905.014)
-----BEGIN PGP SIGNATURE-----
 
 iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCaRO/HAAKCRDorT+BmrEO
 eOs9AJ9Yzz2HpDR3pyRIXhvl4k7bNABGvgCeMg5sU16s0CkFIDbZmOsSo4fswZQ=
 =1o5/
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN SSH SIGNATURE-----
 U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgPpdpjxPACTIhnlvYz0GM4BR7FJ
 +rYv3jMbfxNKD3JvcAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5
 AAAAQIRFF5B6T8EGhzDN+1dhvomEkctFjdVr5DZnhgnEIvcCEuzO36RzY3DBG9AIL+EejJ
 Z1zz7uAapzWUsyFpbYAQM=
 -----END SSH SIGNATURE-----

Merge tag 'android-16.0.0_r3' into staging/lineage-23.0_merge-android-16.0.0_r3

Android 16.0.0 Release 3 (BP3A.250905.014)

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCaRO/HAAKCRDorT+BmrEO
# eOs9AJ9Yzz2HpDR3pyRIXhvl4k7bNABGvgCeMg5sU16s0CkFIDbZmOsSo4fswZQ=
# =1o5/
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Nov 12 00:56:28 2025 EET
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [ultimate]

# By Patrick Rohr (91) and others
# Via Android (Google) Code Review (233) and others
* tag 'android-16.0.0_r3': (377 commits)
  Fix netbpfload version info.
  NetBpfLoad: add self-check for bpfGetNext{Prog,Map}Id()
  Add NetworkTemplate get/set transport type methods
  Pass EthernetPort to EthernetNetworkFactory#updateInterfaceLinkState
  Pass EthernetPort to updateInterfaceState
  Remove spurious VisibleForTesting and change visibility to public
  Pass EthernetPort to EthernetNetworkFactory#removeInterface
  Pass EthernetPort to removeInterface
  Pass EthernetPort to stopTrackingInterface
  Add getEthernetPorts and use it in getAllInterfaces
  Rename getClientModeInterfaces to getClientModeInterfacesSorted
  Rename getAvailableInterfaces to getInterfacesSorted
  Pass EthernetPort into NetworkInterfaceState
  Pass EthernetPort into EthernetNetworkFactory#addInterface
  Use multicast socket for group membership
  Test refactoring of DefaultNetworkRematchMetrics
  Fix SatisfiedTime initialization
  DHCPv6 addr reg: parse IA Address option.
  Pass EthernetPort to addInterface
  Change tethering interface to EthernetPort
  ...

 Conflicts:
	bpf/progs/netd.c
	service/src/com/android/server/ConnectivityService.java
	staticlibs/testutils/host/python/apf_test_base.py
	tests/cts/multidevices/apfv4_test.py
	tests/cts/multidevices/apfv6_test.py
	tests/cts/multidevices/run_tests.py
	tests/unit/java/com/android/server/connectivityservice/CSNetworkAgentTest.kt

Change-Id: Ifedf92aee90cbcc55ef8f9652de8b5faff1c30d9

Michael Bestas   commited 2025-11-14 10:29:02 +02:00
c7f07b6a13
Use string for CREATE_APP_SPECIFIC_NETWORK permission
This allows using the permission in 25Q4 before it becomes a
public API in 26Q2.

Flag: android.net.platform.flags.create_app_specific_network_permission
Test: TH
Bug: 435313135
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:60f7743f773b05a98e651c953631e93957291bf5
Merged-In: I8d336a588eddf9a027079e208b2b96bb6c163e86
Change-Id: I8d336a588eddf9a027079e208b2b96bb6c163e86

Motomu Utsumi   authored and   Android Build Coastguard Worker   commited 2025-09-30 03:56:13 -07:00
c4fea9d31c
Merge "Reduce log level for BluetoothSocket errors" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-09-12 14:07:35 -07:00
f0f91a110a
Merge changes from topics "redact-netcaps", "redact-specifier", "specifier-metrics" into main
* changes:
  [connectivity] rename createWithLocationInfoSanitizedIfNecessaryWhenParceled
  [connectivity] use new redact(RedactionType) for output NetworkSpecifier
  [connectivity] move redaction to createWithLocationInfoSanitizedIfNecessaryWhenParceled
  [connectivity] add permission check on requested NetworkSpecifier
  [connectivity] redact NeworkSpecifier in NetworkCapabilities
  [connectivity] add NetworkCapabilities.RedactionHelper
  [Thread] add REDACT_FOR_THREAD_NETWORK_PRIVILEGED

Kangping Dong   authored and   Android (Google) Code Review   commited 2025-09-12 13:26:22 -07:00
a133acc106
Reduce log level for BluetoothSocket errors
This exception is also logged when the other side disconnects gracefully
(because there is no way to distinguish this case using the Bluetooth
APIs). This change reduces the log level to a warning because it is
almost always a red herring.

Test: TH
Flag: NONE yes
Change-Id: I94f20be91ff8481fdd1a50fbbc27200c57885426

Patrick Rohr   commited 2025-09-12 12:02:08 -07:00
81a472014a
[connectivity] rename createWithLocationInfoSanitizedIfNecessaryWhenParceled
It's already redacting more sensitive information other than just
location info.

This is a follow up CL for https://googleplex-android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/34224156/comment/98b93666_a824d7bc/

Bug: 374037595
Flag: EXEMPT PURE_REFACTOR
Change-Id: I6524c4f9ee9b5273e4ab421f54ae3115dea2cc8a

Kangping Dong   commited 2025-09-12 15:06:00 +08:00
6fd0624452
[connectivity] use new redact(RedactionType) for output NetworkSpecifier
This commit replace the existing usage of NetworkSpecifier#redact() to
the new NetworkSpecifier#redact(RedactionType) API.

This doesn't change the existing behavior because redact() is still
called for NetworkSpecifiers which doesn't oevrride
getApplicableRedactions() method.

Bug: 374037595
Flag: NONE can't use simply flag guarding because the code needs to
      maintain compatibility across different mainline and platform versions

Change-Id: I30d7257b8e5880218b315ade60d2d77fed1f89fb

Kangping Dong   commited 2025-09-12 15:06:00 +08:00
997c5651d0
[connectivity] move redaction to createWithLocationInfoSanitizedIfNecessaryWhenParceled
This commit has almost no behavior changes, because:

1. usage of networkCapabilitiesRestrictedForCallerPermissions is
   either wrapped by
   createWithLocationInfoSanitizedIfNecessaryWhenParceled or
   getNetworkCapabilitiesInternal.
2. All usages of getNetworkCapabilitiesInternal is either wrapped by
   createWithLocationInfoSanitizedIfNecessaryWhenParceled or the
   redacted info in the return value is not used by its caller
3. The only exception for getNetworkCapabilitiesInternal is that it is
   used in simulateDataStall() which checks the underlying network but
   underlying network in the NetworkCapabilities can be redacted by
   networkCapabilitiesRestrictedForCallerPermissions. Removing redaction
   from getNetworkCapabilitiesInternal() will loose the current permission
   requirement but this is wanted as the existing implementation has
   stricter permission requirements than the API signature declares and
   this CL fixes it

Bug: 374037595
Flag: NONE no behavior change but only bug fix
Change-Id: I80491d26ed7d11cb3fe1850ef7be9ae7600d5dd5

Kangping Dong   commited 2025-09-12 15:06:00 +08:00
b9c6df36de
[connectivity] add permission check on requested NetworkSpecifier
This commit adds permission check for new NetworkSpecifier subclasses
which override the new redact(long) method. It throws SecurityException
if the caller doesn't hold the permissions to use the sensitive info in
the NetworkSpecifier class.

Bug: 374037595
Flag: NONE can't use simply flag guarding because the code needs to
maintain compatibility across different mainline and platform versions

Change-Id: Ife8efab3e99adf41d7522fedbde3b4ec80045c77

Kangping Dong   commited 2025-09-12 15:06:00 +08:00
d2c9202a9b
CCT VPN bypass for Android U and below
Implements logic to allow CCT to bypass VPN on Android U (API 34) and
older. On these Android versions, netd's VPN bypass APIs
(networkSetProtectAllow/Deny) operate globally.

Test: TH
Flag: NONE legacy flag protected
Change-Id: I3650c3823d65504046d74cd60485d9cc890937d8

Yuyang Huang   commited 2025-09-12 12:00:35 +09:00
7daab8cc60
Fix VPN bypass by updating VPN filter
This commit addresses an issue where the VPN bypass feature was not
functioning correctly. The VPN filter has been updated to properly
handle bypass rules, ensuring that designated traffic can now bypass the
VPN as intended.

Test: TH, manual
Flag: EXEMPT guarded by default-off legacy flag
Change-Id: Ie6073db4e23a3132042da21c25b696fa3abc4c91

Lorenzo Colitti   authored and   Yuyang Huang   commited 2025-09-11 11:50:05 +09:00
e4f5f85647
Merge "Convert uses of @hide to block tag" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-09-08 04:21:26 -07:00
4910c42dc7
Refactor: Use SdkUtil.isAtLeast25Q4 in ConnectivityService
This change simplifies the code by calling `SdkUtil.isAtLeast25Q4()`
instead of having redundant check in
ConnectivityService.Dependencies#isAtLeast25Q4.

Test: Existing tests pass.
Bug: 443099706
Flag: EXEMPT PURE_REFACTOR
Change-Id: I2c581e24982f8f0df0cb023e2e3e4f37015d2f4a

Sarup Dalwani   commited 2025-09-04 19:05:38 +00:00
acaa7ba313
[Thread] add REDACT_FOR_THREAD_NETWORK_PRIVILEGED
This is used for redacting sensitive Thread info in
ThreadNetworkSpecifier (to be added in ag/34224158)

Bug: 374037595
Flag: EXEMPT new code is not used
Change-Id: I606d59fc5259c79bddaa51ca0c270684dd3b674a

Kangping Dong   commited 2025-09-02 21:23:21 +08:00
138e10e3ba
Convert uses of @hide to block tag
In most places the `@hide` doctag is treated as a block tag on its own
line. However, there are a few places where it is treated as an inline
doctag, e,g. `{@hide}`, and some places where it looks like a block
tag but is inline in the text, e.g. `Some text. @hide`. Dealing with
all the types increases the complexity of Metalava and makes it
slightly slower.

This change replaces the non-block tag forms with a block tag.

Flag: EXEMPT change the form of @hide does not change the API or behavior
Bug: 429965593
Test: m checkapi
Change-Id: I4ffe44a329dbcb7f0a7bd61af16c3bd99cacdac4

Paul Duffin   commited 2025-08-29 21:19:30 +00:00
6eaa841657
Passing isLocalRoute to netd add,remove and update route.
ConnectivityService would be centralized location for deciding local
network so for this effort passing isLocalRoute parameter to
routecontroller in netd for route addition, removal and modification.

Bug: 394308861
Test: Manually tested.
Test: atest ConnectivityCoverageTests
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivityservice.CSLocalRouteTest
Test: atest netd_integration_test
Flag: EXEMPT Using device config kill-switch
Change-Id: I9f11882665375bba10fa369c2e25f374b5e63661

Sarup Dalwani   commited 2025-08-28 14:59:26 +00:00
169a584691
Don't set setPollOnOpen in SatelliteCoarseUsageMetricsCollector.
This is not safe to do in system server because it affects all
system server callers of NetworkStatsManager, including ones
that frequently call into NetworkStatsService, such as
NetworkPolicyManagerService.

Also, setPollOnOpen is unnecessary because data usage is only collected when processing the `onLost` callback, which is triggered after ConnectivityService forces a poll.

Fix: 427909947
Flag: EXEMPT BUGFIX
Test: covered by existing tests
Change-Id: I2fb25f4529d46dfc14b00b0aa69c5145317ca9dd

Lorenzo Colitti   commited 2025-08-26 03:05:26 -07:00
9a0b0d4156
Always drop non-VPN ingress in lockdown mode
When "Block connections without VPN" is specified, incoming traffic
from non-VPN interfaces should be blocked regardless of the
determination made by ConnectivityService#getVpnIsolationInterface.
Outgoing traffic to non-VPN interfaces is already blocked in this case.
(Loopback is excluded as usual.)

Test: `adb shell dumpsys connectivity trafficcontroller` will now show
the tunnel interface for uids affected by lockdown when
getVpnIsolationInterface returns null (wildcard), to block non-VPN
ingress to such uids. This will return to 0 (wildcard) when lockdown
is toggled back off.

Also includes squashed change:

Author: Tommy Webb <tommy@calyxinstitute.org>
Date:   Mon May 1 16:52:28 2023 -0400

    fixup! Always drop non-VPN ingress in lockdown mode

    For lockdown purposes, force an update of VPN filtering whenever the
    interface names for a VPN have changed, to ensure that the BPF owner
    map uses the most up-to-date interface for ingress filtering.

    Issue: calyxos#1651
    Change-Id: Ia0c75a723134023906134597b395653c7a570686

Co-authored-by: Tommy Webb <tommy@calyxinstitute.org>
Issue: calyxos#1255
Bug: 206482423
Change-Id: Id7954816566cb06bf2e9869ea98b20678835df9d

Oliver Scott   authored and   Thomas Turner   commited 2025-08-25 10:45:17 +01:00
19f95c26ad
Firewall: Transport-based toggle support (3/3)
Using policies provided by NetworkPolicyManagerService (fw/b), allow
or disallow an app to access a network based on network transport
type, e.g. Wi-Fi or Cellular.

Needs corresponding fw/b and netd changes.

All networks are treated as being restricted, and only UIDs whose
policy allows them on a transport are able to route outgoing traffic
over a network of that type. In addition, to prevent incoming traffic
to UIDs that are not allowed on the active network, and to handle UIDs
that have a policy which prevents them from accessing VPNs, UIDs that
are not allowed to access their active network are added to a denylist
that prevents them from accessing networks in general. Networks which
are truly restricted, however, such as for IMS, are left unchanged.

Also includes squashed changes:

Author: Tommy Webb <tommy@calyxinstitute.org>
Date:   Thu Apr 27 15:51:18 2023 -0400

    fixup! Set allowed UIDs for networks based on policies

    Revert to prior network permission behavior here, and make necessary
    changes in netd instead. This improves clarity and allows UIDs to
    take advantage of default network rules which would otherwise
    require system-level permission, prior to this change.

    Related: Icd64aa530e8d202abb97d8325160a5d4c0b4c490
    Change-Id: If5493deb96f88fe3ff5fc8a6a0c6d6d9bc77eff4

Author: Tommy Webb <tommy@calyxinstitute.org>
Date:   Wed Mar 22 09:05:18 2023 -0400

    Expose new isUidCurrentlyDisallowedByPolicy

    Allows determining if a UID is blocked based on its transports.

    Change-Id: I2729b61c349ec2812a74d7d1c04b90a58b0f5b88

Author: Tommy Webb <tommy@calyxinstitute.org>
Date:   Wed Sep 20 15:19:45 2023 -0400

    Use framework listener for allowed transports

    When allowed transports change, instead of exposing an API from
    Connectivity that the framework calls, add a new method to the
    framework's NetworkPolicyCallback that we override.

    This change benefits the prebuilt mainline module, preventing
    the need to fight with the platform to add new module APIs.

    Requires fw/b change of the same Change-Id.

    Change-Id: Ie476f23684b00397197184e965201d6823b28de2

Author: Tommy Webb <tommy@calyxinstitute.org>
Date:   Wed Sep 20 16:10:36 2023 -0400

    Notify the framework about denylist changes

    When the denylist changes, instead of exposing an API from
    Connectivity that the framework calls, add a new method to the
    framework's NetworkPolicyManager that we call to inform it of
    this directly.

    This change benefits the prebuilt mainline module, preventing
    the need to fight with the platform to add new module APIs.

    Requires fw/b change of the same Change-Id.

    Change-Id: I3c3593f110753a3ce02af3739f600190f22e9663

Author: Tommy Webb <tommy@calyxinstitute.org>
Date:   Fri Dec 6 08:10:27 2024 -0500

    fixup! Firewall: Transport-based toggle support (3/3)

    Use a dedicated callback for allowed transports, in preparation for the
    removal of NetworkPolicyCallback.

    Change-Id: I9e00948bdc06e3a1beb14b5b9b9ab3eb15b9a528

Change-Id: I79342edbec92090cca20853ba50ea7fd48ec81c2

Tommy Webb   authored and   Thomas Turner   commited 2025-08-25 10:44:30 +01:00
4cc9665748
Merge changes I105ee1d6,I55817132 into main
* changes:
  Update ENABLE_MATCH_NON_THREAD_LOCAL_NETWORKS flag to target sdk 37
  Adopt mainline beta program for local network agent

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-21 10:28:00 -07:00
14debeb714
Update ENABLE_MATCH_NON_THREAD_LOCAL_NETWORKS flag to target sdk 37
The ENABLE_MATCH_NON_THREAD_LOCAL_NETWORKS compatibility flag is
now enabled for apps targeting SDK 37 or higher.

Previously, this flag was configured to enable for
Baklava (SDK 36) or higher. This is no-op because
there is no tethering network agent presents.

While the tethering network agents planned to be enabled in
25Q4, this adjustment allows developers sufficient time
to adapt to the behavior change where NetworkRequests
will match non-Thread local networks.

Flag: com.android.tethering.mainline.beta.tethering_and_p2p_go_local_agent
Test: atest ConnectivityCoverageTests --update-device \
      --test-filter '.*Connectivity.*'
Bug: 420590461
Change-Id: I105ee1d677c6beb12b4dccd109c01ef5ff2717d3

Junyu Lai   commited 2025-08-19 14:16:23 +08:00
1c513a6a6f
Merge "Allow app-specific network creation with a new permission" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-14 23:04:19 -07:00
6f57c71c68
Allow app-specific network creation with a new permission
If an app registers a network agent and doesn't have NETWORK_FACTORY or
PERMISSION_MAINLINE_NETWORK_STACK, but does have
CREATE_APP_SPECIFIC_NETWORK, ConnectivityService will:
- Allow it to create a network
- Force the capabilities to contain only the app's UID
- Force the network to be restricted
- Ignore attempts to change the UID or make the network non-restricted

Test: TH
Flag: android.net.platform.flags.create_app_specific_network_permission
Bug: 435313135
Change-Id: I5a9517515e64f799c88aca4a51636b1a08e15817

Motomu Utsumi   commited 2025-08-15 12:54:49 +09:00
72d4b516c9
Merge "Use mainline beta flag for NetworkAgent event queueing" into main
Junyu Lai   authored and   Android (Google) Code Review   commited 2025-08-14 01:19:15 -07:00
0c6b14587b
Merge changes I69ad789f,I5954b196 into main
* changes:
  Fix mobile data preferred on multi-user devices.
  Support multi-user SettingsObservers in ConnectivityService

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-14 00:33:06 -07:00
4c516ffd67
Use mainline beta flag for NetworkAgent event queueing
Add `queue_network_agent_events_in_system_server` as a mainline beta
flag. This flag replaces the previous check for
`mQueueNetworkAgentEventsInSystemServer`, allowing the feature to be
controlled and enabled on all Android versions via mainline beta program.

Flag: com.android.tethering.mainline.beta.queue_network_agent_events_in_system_server
Test: atest ConnectivityCoverageTests --update-device \
      --test-filter '.*NetworkAgent.*'
Test: atest ConnectivityCoverageTests --update-device \
      --test-filter '.*Connectivity.*'
Fix: 428098184
Change-Id: I96b0443bd4c55c28d482349738bbdc4798f0c7f9

Junyu Lai   commited 2025-08-14 14:53:06 +08:00
c9890408bf
BpfBitmap: some minor optimizations
Test: TreeHugger, atest BpfBitmapTest
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5acf5bcb31777e503e58cef733d617a53006d2b9

Maciej Żenczykowski   commited 2025-08-12 16:02:23 -07:00
d2d26c661a
Fix mobile data preferred on multi-user devices.
The mobile data preferred feature stores the list of UIDs in
Settings.Secure, which is per-user. But the code only sets, reads
and observes the setting for the current user instead of for all
users. This does not work on HSUM or automotive.

Fix this as follows:
- Register the ContentObserver on UserHandle.ALL
- Any time the observer fires, read the setting on all current
  users, and operate on the merged result.
- Ensure that the code gets called on ACTION_USER_ADDED and
  ACTION_USER_REMOVED.

Because the code now aggregates the setting for all UIDs, it
should just work on single-user devices. It should also work if
there are OEM devices that store all UIDs (for all users) in
Settings.Secure for user 0.

Because the bug is fixed, re-enable the test on automotive.

Also fix style nits.

Fix: 404186833
Flag: EXEMPT bug fix
Test: covered by existing CTS tests
Change-Id: I69ad789f1c7c7f3bab04ab8789dfb93ee0de553d

Lorenzo Colitti   commited 2025-08-08 15:36:55 +09:00
2139fcf345
Support multi-user SettingsObservers in ConnectivityService
ConnectivityService uses SettingsObservers to detect when
settings change. These are all set on user zero. This is fine
for most settings, which are in Settings.Global, but some
settings are per-user, such as MOBILE_DATA_PREFERRED_UIDS, which
is in Settings.Secure.

This CL adds the ability to register SettingsObservers on all
users. These observers will fire any time the setting changes
for any current user, and any time a user is added or removed.

This CL does not add or change any SettingsObservers and should
cause no behaviour changes.

Bug: 404186833
Flag: EXEMPT refactor
Test: covered by existing tests
Change-Id: I5954b196eea776414098f1ce4441eb02065438ef

Lorenzo Colitti   commited 2025-08-08 15:36:54 +09:00
aad9267493
replace CookieTagMapKey with S64
(mostly autogenerated, with minor tweaks to make it build)

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2065c3fc6d4d37663a0a52281deb7624fd5c801d

Maciej Żenczykowski   commited 2025-08-07 15:52:35 -07:00
9ef3916ba4
Merge "Move #nativeWaitForService into CommonConnectivityJni" into main
Patrick Rohr   authored and   Android (Google) Code Review   commited 2025-08-06 11:12:41 -07:00
2e342c6d9b
Move #nativeWaitForService into CommonConnectivityJni
AServiceManager_waitForService sytem APIs currently only callable
via dlsym(): b/376759605. When built with sdk_version current,
the NDK stubs for "sdk" variants only include NDK APIs,
excluding #systemapi APIs.

Flag: EXEMPT Mechanical refactors
Test: atest ServiceManagerWrapperIntegrationTest
Change-Id: I48f690d771c7905e79e463617ded772f753cc854

Mark Chien   authored and   Patrick Rohr   commited 2025-08-06 10:44:39 -07:00
f250ade6fa
Merge "Make callers of RoutingCoordinatorService pass in RouteInfoParcel" into main
Sarup Dalwani   authored and   Android (Google) Code Review   commited 2025-08-06 07:45:24 -07:00
a4f34a8836
Merge "Use reported satellite suspended and roaming state" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-06 00:29:17 -07:00
2d94e180e7
Make callers of RoutingCoordinatorService pass in RouteInfoParcel
RoutingCoordinatorService's {add,remove,update}Route methods
all end up calling netd's *RouteParcel methods.

Make callers explicitly generate and pass in the parcel to the
manager class instead of having them pass in a RouteInfo and
having the service class convert the RouteInfo to a parcel.

Also remove the {add,remove,update}Route methods from
RoutingCoordinatorManager since they are unused.

This is a no-op refactor that simplifies upcoming changes.

RoutingCoordinator is not a stable interface and is not used
across the platform/mainline boundary, so there are no version
skew considerations.

Bug: 394308861
Test: atest ConnectivityCoverageTests
Flag: EXEMPT no-op refactor
Change-Id: Iedf4c9bc28c3fc8c289db421857acddc8c694990

Lorenzo Colitti   commited 2025-08-06 15:57:36 +09:00
8f8e59abf7
Merge "Include NET_CAPABILITY_NOT_VCN_MANAGED for tethering local network agent" into main
Junyu Lai   authored and   Android (Google) Code Review   commited 2025-08-05 23:07:49 -07:00
1986dec249
Merge changes I26d8e987,Icc00abb6 into main
* changes:
  Use FakeSettingsProvider callbacks to simplify CS tests.
  Don't call ContentObserver#onChange(..., UserHandle) on S.

Lorenzo Colitti   authored and   Android (Google) Code Review   commited 2025-08-05 22:59:00 -07:00
a6cb9b734c
Include NET_CAPABILITY_NOT_VCN_MANAGED for tethering local network agent
Currently, NET_CAPABILITY_NOT_VCN_MANAGED is implicited added for
NetworkRequest built by normal apps.
However, the tethering network agent doesn't have this capability,
which makes the agent being exposed to VcnManager and cannot be
seen by normal apps.

Add NET_CAPABILITY_NOT_VCN_MANAGED to tethering NetworkAgent. Include
NET_CAPABILITY_NOT_VCN_MANAGED in local network capabilities for
metrics and API utilities to ensure correct evaluation of local
network connectivity. Update unit tests to reflect the new capability.

Flag: EXEMPT bug fix
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSSatisfiedByLocalNetworkMetricsTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.metrics.SatisfiedByLocalNetworkMetricsTest \
      --update-device
Test: manual generate request by CTS and statsd_testdrive -e 10247
Bug: 428098173
Change-Id: Ifa9ce0827abd22d887a0e8a2ab6f4d7391b2b8ed

Junyu Lai   commited 2025-08-06 11:24:33 +08:00
fbf102a88b
Use reported satellite suspended and roaming state
Bug: 431296970
Test: TH
Flag: EXEMPT mainline
Change-Id: I4d828bad6419aa2d12bff6f1855314c0060af3f7

Motomu Utsumi   commited 2025-08-06 09:53:30 +09:00
f9065b8898
clatd: no need for argument parsing via getopt
as we always pass in all of them in a well defined order

Test: TreeHugger, manually
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I93c4a9883983645cbe7d11101aa749dc2faf9d6d

Maciej Żenczykowski   commited 2025-08-05 12:15:03 -07:00
1d2360adec
Use FakeSettingsProvider callbacks to simplify CS tests.
Because FakeSettingsProvider and other test infrastructure did
not support settings observers, the tests called internal
ConnectivityService methods to cause the settings to be re-read.
Now that FakeSettingsProvider supports callbacks, use
ContentResolverWithFakeSettingsProvider in the CS tests and just
use the callbacks.

Bug: 397521796
Flag: TEST_ONLY
Test: test-only change
Change-Id: I26d8e98706fec99aa423721bf1474af2f9b60099

Lorenzo Colitti   commited 2025-08-05 18:02:02 +09:00
6e3afc7dc6
Merge "Conditionally set notifyForDescendants for settings observer" into main
Jimi Chen   authored and   Android (Google) Code Review   commited 2025-08-04 01:05:46 -07:00
1ce55f3028
Conditionally set notifyForDescendants for settings observer
The MultinetworkPolicyTracker now conditionally sets the
`notifyForDescendants` parameter when registering a ContentObserver
for settings URIs.

If `mAvoidBadWifiSource` is `FROM_CARRIER_CONFIG`, `notifyForDescendants`
remains `true`. Otherwise, it is set to `false`. This refinement
aligns observer behavior with the source of the avoid bad Wi-Fi policy.

Flag: EXEMPT mainline
Bug: 435533360
Test: TH
Change-Id: If963d541f168944dd227998f4f4a62c4f203876b

Jimi Chen   commited 2025-08-01 02:10:51 +00:00
e9e1fb3248
Add logging for onPermissionsChanged latency.
Flag: com.android.tethering.mainline.beta.lnp_developer_opt_in
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.PermissionMonitorTest
Bug: 424558169

Change-Id: Ifb621149130212a2903a7c31eebd4126e7d9924a

Hao Liu   commited 2025-07-31 03:02:08 +00:00
55614983a6
Add ART profile to Connectivity service.
This CL adds an ART profile to the Connectivity service. The profile was
generated by profiling the Connectivity service on Droidfood population.

The ART profile is expected to reduce the size of the Connectivity
service generated code size by 3.9MB!

Background: A profile is a list of classes and methods that are
frequently used, which ART uses to compile parts of the code ahead of
time, and the rest of the code can be interpreted and Jitted on the fly
if needed, this improves app-startup, memory and disk space
significantly!

For system server modules (like Connectivity), the current behavoir is
to Speed compile (compile everything), which for sure compiles
unnecessary code. By moving the speed-profile mode we are saving around
3.9MB of disk space which also decreases the load on memory!

The new behavior is guarded by a new build feature
`RELEASE_ART_COMPILE_CONNECTIVITY_SERVICE_SPEED_PROFILE`

Bug: 241823638
Flag: build.RELEASE_ART_COMPILE_CONNECTIVITY_SERVICE_SPEED_PROFILE
Test: `m`
Test: with flag on: go/art-benchmark?p=BootImageProfileId:54912&f=CandidateName:in:54914 (code size reduction by -3.9MB)
Test: with flag off: go/art-benchmark?p=BootImageProfileId:54912&f=CandidateName:in:54913 (no code change or metric changes)
Change-Id: I5d44eaaa77c5241403d6e75b05d28d6256b6df68

Islam Elbanna   commited 2025-07-29 07:12:08 -07:00
5965628f5e
Merge "Update IDnsResolver AIDL version" into main
Patrick Rohr   authored and   Android (Google) Code Review   commited 2025-07-25 15:31:40 -07:00
75c2e461b6
Merge "Create CommonConnectivityJni to share between modules" into main
Patrick Rohr   authored and   Android (Google) Code Review   commited 2025-07-24 09:56:39 -07:00
0e5defc1e9