Commit graph android_packages_modules_Co.../tests/unit/java
Message SHA1
Merge "Add metrics for QUIC connection close" into main
Motomu Utsumi   authored and   Android (Google) Code Review   commited 2025-07-15 20:32:42 -07:00
e5d4a0fca3
Disconnect a network if it's suspended for 5 minutes for wear
The suspension state is designed to be a transient state. Implement an
enforcement to disconnect the network after staying at this state for 5
minutes. This can avoid apps unnecessarily waking up the device for
network activities even when there's no network actually connected.

Test: unit tests. Locally tested with a signal blocking bag.
Bug: 404570281
Flag: EXEMPT mainline
Change-Id: I1427a72402f7ec64eda537a89c86768466a72328

Hongyi Zhang   commited 2025-07-15 09:39:37 -07:00
3dcb3c5890
Add metrics for QUIC connection close
Test: QuicConnectionCloserTest
Flag: EXEMPT mainline
Bug: 311792075
Change-Id: I2bd9108c1f8af89824bf48767fcca9a1e1d57831

Motomu Utsumi   commited 2025-07-15 17:10:56 +09:00
504fe27b86
Merge "Search for the satellite opt-in flag in disabled services" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-07-14 20:41:48 -07:00
c5cda84789
Revert^2 "Fix onActiveDataSubscriptionIdChanged is not received in multi SIM mode"
This reverts commit 1bcbb88955.

Reason for revert: fix TelephonyCallback in multi SIM mode

Bug: 430233890
Change-Id: Ibfdc5546083132c504ac129256f321dd000b890c

Jimi Chen   commited 2025-07-13 20:05:43 -07:00
b588948892
Search for the satellite opt-in flag in disabled services
As it might be necessary to discover the metadata in services
for technical reasons, a good way to file that data is to make a
phony, disabled service for the purposes of containing this
metadata.

Unfortunately, the disabled components are not returned by
PackageManager unless you pass MATCH_DISABLED_COMPONENTS
as a flag, and we didn't know that at the time.

Do match disabled components so a disabled service can be used
as a holder for this.

Bug: 427846736
Test: manual
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest
Flag: EXEMPT bugfix
Change-Id: Id32c32ab8cfb93a4270795a5bdf75edb4cb7a1f6

Chalard Jean   authored and   Junyu Lai   commited 2025-07-10 14:27:43 +08:00
21575cf8dd
Add UID to NSD metrics
This commit introduces the UID to the NetworkNsdReportedMetrics,
allowing for the association of NSD metrics with the specific
application or process that initiated the NSD operation.

Bug: 427689120
Test: atest ConnectivityCoverageTests NsdManagerTest
Flag: EXEMPT refactor
Change-Id: I780cd6ba74d2ef7e23200f83f497691dd4702919

Paul Hu   commited 2025-07-10 03:47:50 +00:00
924f535b56
Merge "Fix onActiveDataSubscriptionIdChanged is not received in multi SIM mode" into main
Jimi Chen   authored and   Android (Google) Code Review   commited 2025-07-07 21:57:41 -07:00
7e816d5d07
Fix onActiveDataSubscriptionIdChanged is not received in multi SIM mode
Flag: EXEMPT mainline
Bug: 428673855
Test: manually
Change-Id: I0d7c2538ec33402dba64949c3fb34519605d843e

Jimi Chen   commited 2025-07-08 02:14:21 +00:00
aecb2b65ba
Merge "Fix mDNS offload by skipping probing and preventing race." into main
Yuyang Huang   authored and   Android (Google) Code Review   commited 2025-07-04 03:27:31 -07:00
e46c997be3
Merge "Address review comment at ag/34147135" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-07-03 23:56:09 -07:00
fd334b90f7
Fix mDNS offload by skipping probing and preventing race.
In the mDNS advertising offload-only path, skip both the probing and
announcement stages.

Test: TH
Flag: EXEMPT bugfix only
Change-Id: I644a4c0d72de4ae521f048ca4d33e3ae69a66499

Yuyang Huang   commited 2025-07-04 15:27:36 +09:00
c3709c211f
Merge "Implement the private DNS bypass logic for captive portal over CCT." into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-07-03 18:10:05 -07:00
43252b41bf
Address review comment at ag/34147135
This includes:
1. Fix Race Condition: The call to `logRequest` is moved before
   `trackUidAndRegisterNetworkRequest`. This prevents a race condition
   where the `NetworkRequest` object could be modified on the handler
   thread before its initial state was logged.

2. Clear Metrics on Pull: The metrics map is now cleared after the
   data is pulled. This changes the atom from a cumulative
   counter to a periodic one, simplifying server-side aggregation.

Bug: 406172997
Flag: EXEMPT controlled by the `satisfied_by_local_network_metrics`
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSSatisfiedByLocalNetworkMetricsTest \
  ConnectivityCoverageTests:android.net.connectivity.com.android.metrics.SatisfiedByLocalNetworkMetricsTest \
  --update-device
Change-Id: Ia3b74088183c95173ab07a4f72393065bca2bafe

Junyu Lai   commited 2025-07-03 17:18:47 +08:00
cf8688deab
Add methods to get metered override and persistence config in string
This patch adds methods to get metered override and persistence config
in human readable string in EthernetConfiguration.
This allows more informative logging.

Bug: 397536853
Test: atest ConnectivityCoverageTests
Flag: EXEMPT mainline
Change-Id: Ia5a2f4b9f624bfc1c96b197533426925dacfa554

Chuwei He   commited 2025-07-02 19:41:42 -07:00
afc612e02e
Add metered overrride config to EthernetConfiguration
This patch metered override config to EthernetConfiguration.
This config indicates the static configuration of metered override.

Bug: 397536853
Test: atest ConnectivityCoverageTests
Flag: EXEMPT mainline

Change-Id: I37303bbb5a6803254e149bb374703e6a2e66c062

Chuwei He   commited 2025-07-02 18:12:33 -07:00
1939c90a98
Implement the private DNS bypass logic for captive portal over CCT.
Flag: EXEMPT the API caller is guarded by a legacy experiment flag
Bug: 368416967
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSNetdBypassRulesTests
Change-Id: I0e24bf37c412e6f5676924269ca98db1f9dfd6df

Xiao Ma   commited 2025-07-02 15:13:20 +09:00
5fd76d347d
Merge "Use NETWORK_STACK permission for broadcast receivers" into main
Junyu Lai   authored and   Android (Google) Code Review   commited 2025-07-01 22:58:04 -07:00
18e2c70d3b
Merge "Refactor: Stop caching PackageManager in SatelliteAccessController" into main
Junyu Lai   authored and   Android (Google) Code Review   commited 2025-07-01 18:54:09 -07:00
d0869b0b08
Add metrics for requests satisfied by local networks
This change introduces `SatisfiedByLocalNetworkMetrics` to count the
number of `NetworkRequest`s per UID that can be satisfied by a
local-only network.

The purpose is to gather data on how many applications register callbacks
that would match non-thread local network connectivity.
This data helps in understanding app behavior and can inform
future development of local-only network features particularly
for the backward compatibility of existing NetworkRequests.

- A new class `SatisfiedByLocalNetworkMetrics` handles the counting and
  logging logic.
- `ConnectivityService` calls into this class upon `NetworkRequest`
  registration.
- Counts are logged to statsd.

Sample dumpsys output:
  SatisfiedByLocalNetworkMetrics: {LISTEN={10217=2}}

Bug: 406172997
Flag: EXEMPT controlled by the `satisfied_by_local_network_metrics`
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSSatisfiedByLocalNetworkMetricsTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.metrics.SatisfiedByLocalNetworkMetricsTest \
      --update-device
Test: m statsd_testdrive && statsd_testdrive -e 10247
Test: Manual: atest dumpsys connectivity

Change-Id: I62f6299a1c726537b373e3e80d41a494323f3cf2

Junyu Lai   commited 2025-07-01 16:01:28 +08:00
c00cf63e8a
Use NETWORK_STACK permission for broadcast receivers
Use the NETWORK_STACK permission instead of null when registering
broadcast receivers in ConnectivityService, PermissionMonitor and
BroadcastReceiveHelper.
This ensures that only components with the NETWORK_STACK permission
can send these protected broadcasts, improving system security.
Tests were updated to reflect the new permission requirement.

Flag: EXEMPT trivial change
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.BroadcastReceiveHelperTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.PermissionMonitorTest \
      --update-device
Fix: 425828059
Change-Id: I9761f9f454751761b346e255aac0d1c7d7a7e30c

Junyu Lai   commited 2025-06-28 06:40:14 +08:00
ca5a062321
Refactor: Stop caching PackageManager in SatelliteAccessController
Stop caching per-user PackageManager instances to avoid potential race
conditions.
The previous implementation relied on the ordering of ACTION_USER_*
and ACTION_PACKAGE_* broadcasts, which is not guaranteed across
Android releases.
This change refactors the code to fetch the PackageManager on demand,
ensuring correctness and robustness. Corresponding tests have been
updated.

Flag: EXEMPT bug fix
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest \
      --update-device
Fix: 422064138
Change-Id: I09db0be542a1ce9746174f4b8e816ac0def7c833

Junyu Lai   commited 2025-06-28 06:40:14 +08:00
fea137ae76
Merge "Add persisted logic to EthernetConfiguration" into main
Chuwei He   authored and   Android (Google) Code Review   commited 2025-06-26 21:15:19 -07:00
784cc003f6
Merge changes If5f9b5e8,I2ae559df into main
* changes:
  Remove delayed messages from handler queue correctly
  Exclude more files from mDNS standalone library

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-26 17:47:59 -07:00
830b2bc40e
Remove delayed messages from handler queue correctly
This change replaces removeMessages() with removeEqualMessages().
The latter uses the equals() method to correctly compare the
content of interface name strings, ensuring previously delayed
messages are properly removed.

Bug: 427426427
Test: Manual testing with some modifications.
Test: atest ConnectivityCoverageTests NsdManagerTest
Flag: EXEMPT bug fix
Change-Id: If5f9b5e8425fc9bb235431edd78c3f3a28a037d8

Paul Hu   commited 2025-06-26 07:30:40 +00:00
4d22c15b0a
Add persisted logic to EthernetConfiguration
This patch added persisted logic to EthernetConfiguration, which allows
ethernet configuration to be set to be persistent across boot or not.

Bug: 397536853
Test: atest ConnectivityCoverageTests
Flag: EXEMPT mainline
Change-Id: I6e96dec0f802cf1a58e61bffb6c1dac34a0a91a5

Chuwei He   commited 2025-06-25 23:25:37 -07:00
7e60f9a82f
Merge "Format MdnsReplySenderTest" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-25 08:34:13 -07:00
7e90162275
Format MdnsReplySenderTest
Use the ktlint.py script to correct Kotlin code formatting errors.

Test: m
Flag: EXEMPT corret format
Change-Id: I1c184ce89e4e511340b8a32cb5dd3253191a8bbd

Paul Hu   commited 2025-06-25 10:18:15 +00:00
e823669fb7
Merge "Register network_carrier_aware_avoid_bad_wifi setting change callback" into main
Jimi Chen   authored and   Android (Google) Code Review   commited 2025-06-23 19:59:08 -07:00
1895b07c81
Register network_carrier_aware_avoid_bad_wifi setting change callback
This commit registers the "network_carrier_aware_avoid_bad_wifi" URI
with the ContentResolver to allow for monitoring changes to this
specific Global.Settings entry.

Flag: EXEMPT mainline
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.MultinetworkPolicyTrackerTest
Change-Id: I0e9161c5390b71e5c3ecac89613aa042f40ab695

Jimi Chen   commited 2025-06-23 14:01:56 +00:00
1095a3486f
Merge "Migrate CSAgentWrapper to TestableCallback." into main
Jean Chalard   authored and   Android (Google) Code Review   commited 2025-06-22 18:43:23 -07:00
3cbf1e3b94
Merge "Check service meta-data for satellite opt-in" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-20 02:25:16 -07:00
bc19379378
Check service meta-data for satellite opt-in
Previously, the approach for apps to declare themselves
satellite-optimized was problematic. Relying solely on the
<application> tag for opt-in could significantly increase app
size. This was particularly an issue on older devices, where
the duplication of <meta-data> directly under the
<application> tag into each ProviderInfo could drastically
swell its size. A prime example of this negative impact was
crashes on Android 5.0 (API 21) and older devices, where
PackageManager.queryContentProviders would exceed the 1MB
Binder transaction limit due to the bloated ProviderInfo size.

The `isSatelliteDataOptimizedApp` method is updated to iterate
through a package's services if the application-level meta-data
is not found.

Flag: EXEMPT controlled by kill switch
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest
Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideSatelliteDataOptInTest
Bug: 424290966

Change-Id: I36b6a0093bc74de470443f6553b26b09d070ed9d

Junyu Lai   commited 2025-06-20 16:35:28 +08:00
441ce68713
Migrate CSAgentWrapper to TestableCallback.
This makes it much more powerful as well as consistent with
other use cases of this paradigm.

Test: TH
Flag: EXEMPT test-only
Change-Id: I4f5b86bfdd16d8bfe21b79235444817a13bc3c49

Chalard Jean   authored and   Jean Chalard   commited 2025-06-20 01:08:25 -07:00
6fe5d13b3a
Merge changes from topic "avoid-bad-wifi-api-update" into main
* changes:
  Enable per-subId 'avoid bad Wi-Fi' setting storage
  Use ConnectivitySettingsManager API for avoid bad Wi-Fi updates

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-20 00:42:48 -07:00
553054fcee
Merge "Use handler thread to retrieve carrier config directly" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-19 06:06:08 -07:00
4ee72294c0
Use ConnectivitySettingsManager API for avoid bad Wi-Fi updates
This change replaces the internal cache with the `ConnectivitySettingsManager` API
to manage "avoid bad Wi-Fi" settings. It reduces code duplication and improves
readability.

Flag: EXEMPT mainline
Bug: 422063047
Test: atest ConnectivityCoverageTests
Change-Id: I82d9e1afb7c318d584e708da6ad5c10f298f057b

Jimi Chen   commited 2025-06-19 11:30:02 +00:00
dd73a350f9
Merge "Change EthernetPortInfo to EthernetPortState" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-18 21:26:04 -07:00
7882140d7d
Merge changes I97b4cf85,I33134502,I43beb0d3,I1b681708 into main
* changes:
  Add EthernetPort#matches(interfaceName)
  Ignore NLMSG_DONE messages
  Only consider interfaces tracked by regex in EthernetManager#isAvailable
  Ensure provisioning is never started with Mode.NONE

Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-06-18 17:08:04 -07:00
f2b5e4a9a0
Add EthernetPort#matches(interfaceName)
Interface matching in the ethernet module is still done by interface
name. Add an explicit #matches() function to avoid accidentally
comparing against the wrong object. Comparing a String to an
EthernetPort (or vice versa) is a valid java expression.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I97b4cf856160195f44e4cebd13d8ce2fdeeb220c

Patrick Rohr   commited 2025-06-18 14:49:41 -07:00
8b390a5cca
Merge "Fix flaky testHandleUdpSocketDestroy" into main
Motomu Utsumi   authored and   Android (Google) Code Review   commited 2025-06-18 03:16:33 -07:00
67f4f44402
Fix flaky testHandleUdpSocketDestroy
The SkDestroyListenerCallback posts a message to a handler thread.
This can cause a race condition when sendQuicConnectionClosePayload call
is verified.

This CL sets a timeout for verifying sendQuicConnectionClosePayload
call.
Additionally, a short timeout is used to assert that destroyUdpSocket is
not called.

Test: QuicConnectionCloserTest
Bug: 407226131
Flag: EXEMPT test only change
Change-Id: I62522fcafb91bef12e2781afbd090af8d0350f1e

Motomu Utsumi   commited 2025-06-18 15:56:56 +09:00
54a621a248
Merge "Allow VCN network to beat a physical cell in network ranking" into main
Yan Yan   authored and   Android (Google) Code Review   commited 2025-06-17 11:09:54 -07:00
7b1145e6b4
Only consider interfaces tracked by regex in EthernetManager#isAvailable
There is an argument that the API is @UnsupportedAppUsage since R and
this code only ships to T. In any case, just to be on the safe side, the
code should ignore NCM interfaces which are not part of the regex. (It
already ignores interfaces which are in tethering/server mode today).

This CL also marks a couple of related functions properly as public.
These functions are not @VisibleForTesting; they belong to the public
interface of the class.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I43beb0d3a17d403b7f6bcbadd7089110ad28684e

Patrick Rohr   commited 2025-06-17 09:12:37 -07:00
fb8c780b6f
Do not try to send updated allowed ranges for destroyed networks
Test: TH
Bug: 420229020
Flag: EXEMPT bugfix
Change-Id: Ibc1c4cf2d94afe86f22b515ac0b91c85f6506f8e

Chalard Jean   commited 2025-06-17 13:53:42 +09:00
4d2887b593
Change EthernetPortInfo to EthernetPortState
This patch changes the name of class EthernetPortInfo to
EthernetPortState.

Bug: 397536853
Test: build
Flag: EXEMPT mainline
Change-Id: I7f42170cdde33ca31dea3d622678565ea5dc1026

Chuwei He   commited 2025-06-17 13:48:42 +09:00
d790973d3e
Allow VCN network to beat a physical cell in network ranking
This patch adds a new POLICY to identify a VCN network offer, and
updates NetworkRanker to allow a VCN network to win over a physical
cell network. This is to fix the issue where VCN cannot exit safe
mode when there is already a phsical cell

Bug: 391977557
Test: NetworkRankerTest(new test)
Flag: EXEMPT bugfix
Change-Id: I00ebeb3eeb30ca8b46d25bbde1b6fd3dfee53993

Yan Yan   commited 2025-06-17 01:30:07 +00:00
6eab1d0af3
Merge "Introduce interface name field to SocketKey" into main
Paul Hu   authored and   Android (Google) Code Review   commited 2025-06-16 18:28:55 -07:00
fff6a3fdcd
Introduce interface name field to SocketKey
This commit adds a new interfaceName field to the SocketKey
class, which allows us to uniquely identify sockets based on
their interface name in addition to their network and interface
index. This information is used for subsequent changes to
identify the target ServiceTypeClient by the interface name.

Bug: 410734687
Test: atest ConnectivityCoverageTests NsdManagerTest
Flag: EXEMPT refactor
Change-Id: Ic312b26ca572d12b7c3177b84aced9d487636003

Paul Hu   commited 2025-06-16 16:10:01 +00:00
ef6f92b903
Pass TrackingReason to NetworkInterfaceState
Because changing the tethering mode invokes addInterface(), the
tracking mode for the tethering interface needs to be persisted
separately.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ifb8371a55a582bf2133a59bdbedcce95c94626cc

Patrick Rohr   commited 2025-06-13 16:14:08 -07:00
a2d1cb97fa