Commit graph android_packages_modules_Co.../tests/unit/java
Message SHA1
Merge "Rename getAllInterfaceOffloadServiceInfos to notifyOffloadStart" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-28 21:22:59 -07:00
94c93cbbe4
Merge "Provide offload service information update from DiscoveryManager" into main
Paul Hu   authored and   Android (Google) Code Review   commited 2025-08-28 07:37:56 -07:00
9111ff26d4
Mock QuiConnectionCloser in ConnectivityServiceTest
ConnectivityServiceTest can not start QuicConnectionCloser and was
getting the following error.
The interaction between ConnectivityService and QuicConnectionCloser is
already covered by CSDestroySocketTest.
```
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: [SkDestroyListener] ERROR Failed to create rtnetlink socket: socket failed: EACCES (Permission denied)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: android.system.ErrnoException: socket failed: EACCES (Permission denied)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at libcore.io.Linux.socket(Native Method)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at libcore.io.ForwardingOs.socket(ForwardingOs.java:821)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:402)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at libcore.io.ForwardingOs.socket(ForwardingOs.java:821)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.system.Os.socket(Os.java:834)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.net.connectivity.com.android.net.module.util.ip.NetlinkMonitor.createFd(NetlinkMonitor.java:127)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.net.connectivity.com.android.net.module.util.FdEventsReader.createAndRegisterFd(FdEventsReader.java:217)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.net.connectivity.com.android.net.module.util.FdEventsReader.start(FdEventsReader.java:111)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.net.connectivity.com.android.server.connectivity.QuicConnectionCloser$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.os.Handler.handleCallback(Handler.java:959)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.os.Handler.dispatchMessage(Handler.java:100)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.os.Looper.loopOnce(Looper.java:232)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.os.Looper.loop(Looper.java:317)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.os.HandlerThread.run(HandlerThread.java:85)
```

Bug: 311792075
Test: atest ConnectivityServiceTest
Flag: EXEMPT test only change
Change-Id: I8ae1033b2ea655ebc26300aac19ec4d8cbdc047d

Motomu Utsumi   commited 2025-08-27 01:17:10 -07:00
a74f8c7782
Rename getAllInterfaceOffloadServiceInfos to notifyOffloadStart
This renaming is to align the DiscoveryManager design and reflect
its real usage.

Bug: 410734687
Test: atest ConnectivityCoverageTests NsdManagerTest
Flag: EXEMPT rename method only
Change-Id: I0d198aa0752ef51353e4164b612b6ff268ace16a

Paul Hu   commited 2025-08-27 02:26:14 +00:00
20556631d8
Provide offload service information update from DiscoveryManager
With this change, the OffloadEngine can receive updates when
offload service information changes from DiscoveryManager. This
allows the OffloadEngine to maintain offload services and to
adjust its behavior accordingly.

Bug: 410734687
Test: atest ConnectivityCoverageTests
Flag: com.android.tethering.mainline.beta.nsd_selective_mdns_response_offload
Change-Id: I6c6ba4e76b4a2a94cbfef37bec9d6f87357bec5f

Paul Hu   commited 2025-08-27 02:13:32 +00:00
f1ae69a950
Merge "Support IpAddress type in LocalNetAccessKey for BPF" into main
Sarup Dalwani   authored and   Android (Google) Code Review   commited 2025-08-21 09:53:36 -07:00
9e567923d4
Merge "Add a offloadInfo map to better manage offload info" into main
Paul Hu   authored and   Android (Google) Code Review   commited 2025-08-21 01:54:29 -07:00
d50b9e40c6
Add a offloadInfo map to better manage offload info
Instead of iterating all listeners to get the FilterRepliesInfo,
this change introduces a new offloadInfo map to manage this
information. This map is updated when listeners are added/removed
or when a service is resolved. This ensures that the offload
information is always up-to-date and can be retrieved
efficiently.

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

Paul Hu   commited 2025-08-19 09:51:07 +00:00
1cf7a517fc
Support IpAddress type in LocalNetAccessKey for BPF
Updated LocalNetAccessKey to use Type.IpAddress for its
`remoteAddress` BPF field. This enables the BPF map to
store both IPv4 and IPv6 addresses for this key.

To ensure proper functionality with IPv6 addresses, a new
unit test, `testAddLocalNetAccessAfterV_withIPv6`, has been
added to BpfNetMapsTest.java. This test specifically
verifies adding and retrieving local network access rules
using an IPv6 remote address.

Bug: 392509494
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Flag: EXEMPT refactor
Change-Id: I005f4f2b778ca2d3a4e6578c1440162532f8d004

Sarup Dalwani   commited 2025-08-17 03:39:28 +00:00
ab9a3af782
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 "Mdns: Skip networks with NET_CAPABILITY_LOCAL_NETWORK" into main
Junyu Lai   authored and   Android (Google) Code Review   commited 2025-08-14 18:43:19 -07:00
a1400694b3
Merge "Add OffloadCallback interface" into main
Paul Hu   authored and   Android (Google) Code Review   commited 2025-08-14 09:03:46 -07:00
c37f3cf83d
Mdns: Skip networks with NET_CAPABILITY_LOCAL_NETWORK
MdnsSocketProvider expects no overlap between NetworkCallbacks,
Tethering, and Wifi P2P. However, local NetworkAgents can cause
overlap, leading to duplicate sockets. This commit fixes the issue by
skipping networks with NET_CAPABILITY_LOCAL_NETWORK.

Alternatively, the NetworkRequest should addForbiddenCapability
for local networks. However, since this is a module API, it is
not visible to standalone applications.

Flag: EXEMPT bug fix
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.mdns.MdnsSocketProviderTest \
      --update-device
Test: m service-connectivity-mdns-standalone-build-test
Test: atest CtsNetTestCases:android.net.cts.NsdManagerTest \
      CtsNetTestCases:android.net.cts.NsdManagerDownstreamTetheringTest
Bug: 437038495
Change-Id: I78dd7d98ad80147ca26ec6130b6081ef4efb2ecc

Junyu Lai   commited 2025-08-14 20:44:36 +08:00
eb80e8ad9f
Merge "Use imported flag alias for readability" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-14 04:11:21 -07:00
d2b8f3fec2
Use imported flag alias for readability
Import `FLAG_QUEUE_NETWORK_AGENT_EVENTS_IN_SYSTEM_SERVER` and use
its alias in Connectivity Service tests.

Flag: com.android.tethering.mainline.beta.queue_network_agent_events_in_system_server
Fix: 428098184
Test: m
Change-Id: Ic4b5a144c00919defbd7a29048957f028c80bf4a

Junyu Lai   commited 2025-08-14 16:30:32 +08:00
25bd5eaf24
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
Add OffloadCallback interface
This commit adds the OffloadCallback, which is a common interface
to notify the offload service of info updates from MdnsAdvertiser.

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

Paul Hu   commited 2025-08-13 05:25:42 +00:00
dc188b57d8
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
replace UidStatsMapKey with S32
(mostly autogenerated, with minor tweaks to make it build)

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

Maciej Å»enczykowski   commited 2025-08-07 15:50:48 -07:00
b28b0c70b9
Merge "Change proto message name for NetworkConfigStoreProto" into main
Chuwei He   authored and   Android (Google) Code Review   commited 2025-08-06 22:28:10 -07:00
7dc6767005
Change proto message name for NetworkConfigStoreProto
This patch add *Proto suffix for some proto message in
NetworkConfigStoreProto to avoid name conflicts with names in
android.net package.

Test: atest ConnectivityCoverageTests
Bug: 397536853
Flag: EXEMPT mainline

Change-Id: I4f826511bcab0fcd3b154bbc349a062fd4841321

Chuwei He   commited 2025-08-06 20:58:53 -07:00
88d424c3b8
Merge "Add EthernetConfigHolderProto to NetworkConfigStoreProto" into main
Chuwei He   authored and   Android (Google) Code Review   commited 2025-08-06 20:37:00 -07:00
dc421c895e
Add EthernetConfigHolderProto to NetworkConfigStoreProto
This patch Adds EthernetConfigHolderProto to NetworkConfigStoreProto for storing
collective ethernet configurations state.

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

Chuwei He   commited 2025-08-07 10:11:16 +09:00
18a67028d2
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
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
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
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 "Add logging for onPermissionsChanged latency." into main
Hao Liu   authored and   Android (Google) Code Review   commited 2025-07-31 06:47:43 -07:00
85415edca0
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
Fix UnfinishedStubbingException when running testAutomotiveEthernetAllowedUids
Mocking the PackageManager while ConnectivityService is running
could throw an UnfinishedStubbingException. This change splits
the test into two distinct tests that don't need to change the
mocking value for PackageManager during testing.

Fix: 433600031
Test: atest ConnectivityServiceTest
Flag: TEST_ONLY
Change-Id: Ibcff2082d1e50e89c272573b4c719a7325c959fd

Paul Hu   commited 2025-07-30 08:36:26 +00:00
e4e65d7b48
Merge "Add proto to store network configuration" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-07-25 16:48:31 -07:00
3e3e18b2f1
Merge "Notify offload engine with discovery service information" into main
Paul Hu   authored and   Android (Google) Code Review   commited 2025-07-25 01:48:41 -07:00
f98e4c2f7b
Notify offload engine with discovery service information
Updated the NsdService to send all OffloadServiceInfo from the
MdnsDiscoveryManager to the OffloadEngine upon the OffloadEngine
is registered.

Bug: 410734687
Test: atest ConnectivityCoverageTests
Flag: EXEMPT legacy flag nsd_force_disable_mdns_offload
Change-Id: I833d244dd59e98818985c69edd2012a2aa4dc8e6

Paul Hu   commited 2025-07-24 07:43:32 +00:00
2fa3227110
Add proto to store network configuration
This patch adds proto which will be used to store network
configuration. This will be used in IpConfigStore.

Test: atest ConnectivityCoverageTests
Bug: 397536853
Flag: EXEMPT mainline

Change-Id: I83032ebc78c60cbf2fc8f9119471fc13ae7f09e1

Chuwei He   commited 2025-07-24 16:41:00 +09:00
5adb3c56aa
Add EthernetPortSelector class
This patch added EthernetPortSelector class that is used to select a
specific ethernet port by interface name or MAC address.

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

Chuwei He   commited 2025-07-22 04:52:05 -07:00
66fef2ea8e
Use beta flag for bluetoothTetheringRandomizedAddress
Bug: 287177081
Test: TH
Flag: com.android.tethering.mainline.beta.bluetooth_tethering_randomized_address
Change-Id: I1de9f4bb15c8423f09381a0c7513f0d7ebf80856

Motomu Utsumi   authored and   Hao Liu   commited 2025-07-17 21:30:07 +00:00
4b4f3018a5
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