Commit graph android_packages_modules_Co.../tests/unit/java
Message SHA1
Merge "Add util method to convert StaticIpConfiguration from proto" into main
Chuwei He   authored and   Android (Google) Code Review   commited 2025-09-09 20:20:50 -07:00
32d4c35ae8
Merge "Add util method to convert StaticIpConfiguration to proto" into main
Chuwei He   authored and   Android (Google) Code Review   commited 2025-09-09 20:20:06 -07:00
a599e8670e
Add util method to convert StaticIpConfiguration from proto
This patch adds util methods to convert StaticIpConfiguration from its
proto equivalent, and also adds unit tests to test the conversion.

Test: atest ConnectivityCoverageTests
Bug: 397536853
Flag: EXEMPT mainline

Change-Id: Iba4955efac3b854684f0d0f32b6d5667cebdc265

Chuwei He   commited 2025-09-10 10:34:13 +09:00
c77b880d86
Add util method to convert StaticIpConfiguration to proto
This patch adds util methods to convert StaticIpConfiguration to its
proto equivalent, and also adds unit tests to test the conversion.

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

Chuwei He   commited 2025-09-10 10:34:00 +09:00
014ae496d1
Merge "Remove service-side TrafficStats rate limit cache" into main
Junyu Lai   authored and   Android (Google) Code Review   commited 2025-09-08 01:20:02 -07:00
fe61faa220
Merge "Add conversion util methods for EthernetPortSelector" into main
Chuwei He   authored and   Android (Google) Code Review   commited 2025-09-07 18:37:16 -07:00
54b93bb3c5
Merge "Add conversion util methods for LinkAddress" into main
Chuwei He   authored and   Android (Google) Code Review   commited 2025-09-07 18:36:37 -07:00
41f97eedb2
Merge "Add conversion util methods for MeteredOverride" into main
Chuwei He   authored and   Android (Google) Code Review   commited 2025-09-07 18:36:14 -07:00
1c67fe0789
Fix setDelegateUid unit test.
The assertion that the app was removed from the list was due to
the fact that when adding the same UID twice, the code first
removes it and then re-adds it.

Add a bit more test coverage.

Test: test-only change
Flag: EXEMPT TEST_ONLY
Change-Id: I1eda5be93668ebda7fe2049a2d1ace4e744948e7

Lorenzo Colitti   commited 2025-09-05 19:10:51 +09:00
fb3a754f83
Merge "Add a simple unit test for setDelegateUid." into main
Yuyang Huang   authored and   Android (Google) Code Review   commited 2025-09-05 01:43:41 -07:00
f8741c9611
Add a simple unit test for setDelegateUid.
This is currently very simple, but should be easy to extend.

Test: test-only change
Flag: EXEMPT TEST_ONLY
Change-Id: Ibcb286dcef0b159f01faf3dd0a17c977a7d60a52

Lorenzo Colitti   authored and   Yuyang Huang   commited 2025-09-05 15:13:23 +09:00
cb91fe2c4a
Add conversion util methods for EthernetPortSelector
This patch adds util methods to convert EthernetPortSelector to and from
its proto equivalent, and also adds unit tests to test the conversion.

Test: atest ConnectivityCoverageTests
Bug: 397536853
Flag: EXEMPT mainline

Change-Id: I0603c7a4004a83448c3d6ec4c1d0c6149708fd9d

Chuwei He   commited 2025-09-04 14:10:04 +09:00
c0293a238b
Add conversion util methods for LinkAddress
This patch adds util methods to convert LinkAddress to and from
its proto equivalent, and also adds unit tests to test the conversion.

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

Chuwei He   commited 2025-09-04 14:09:23 +09:00
a9454a1b48
Add conversion util methods for MeteredOverride
This patch adds util methods to convert MeteredOverride to and from
its proto equivalent, and also adds unit tests to test the conversion.

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

Chuwei He   commited 2025-09-04 14:09:11 +09:00
b5ad6f83b2
Merge changes from topic "routecontrollerchangeforislocal" into main
* changes:
  Migrate NetdUtils from networkAddRoute to networkAddRouteParcel.
  Passing isLocalRoute to netd add,remove and update route.

Sarup Dalwani   authored and   Android (Google) Code Review   commited 2025-08-29 08:01:18 -07:00
bc8c8c040e
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
Migrate NetdUtils from networkAddRoute to networkAddRouteParcel.
This will allow us to deprecate networkAddRoute.

Bug:412629841
Test: atest TetheringTests
Flag: EXEMPT Using device config kill-switch
Change-Id: I20e988f760b8ad22b51effdc1f0e204763c6e240

Sarup Dalwani   commited 2025-08-28 15:28:48 +00:00
98e5827ccc
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
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
Remove service-side TrafficStats rate limit cache
The service-side TrafficStats rate limit cache is no longer needed as
client-side caching is now solely responsible for rate-limiting traffic
stats queries.

This commit removes:
- The `clearTrafficStatsRateLimitCaches` AIDL method.
- The service-side cache implementation, including member variables and
  logic within `NetworkStatsService`.
- Related feature flags and constants used for the service-side cache.
- All unit tests specifically for the service-side cache.

This simplifies the overall traffic statistics caching architecture by
centralizing rate-limiting responsibility on the client side.

Flag: EXEMPT refactoring
Test: atest ConnectivityCoverageTests --test-filter '.*NetworkStats.*' --update-device
Test: atest ConnectivityCoverageTests --test-filter '.*TrafficStats.*' --update-device
Fix: 428098676
Fix: 428097311
Change-Id: I41cbb80a52f04dcf387c3352677a91cb692ffe73

Junyu Lai   commited 2025-08-21 16:47:27 +08:00
e9eb8e2b8a
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