Commit graph android_packages_modules_Co.../tests/unit/java
Message SHA1
Add CachedService Class
This is a no-op refactoring. A new CachedService class is
introduced to better represent cached services and their expired
status. This class will be used to optimize expired service
removal in subsequent changes.

Bug: 387910548
Test: atest ConnectivityCoverageTests NsdManagerTest
Change-Id: I56fa43b8cc0c69d77aa14f0bdaf024a94c45757c

Paul Hu   commited 2025-03-17 07:58:59 +00:00
b6339349a4
Merge "Enable early native network creation for local network" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-09 20:53:11 -07:00
daa1f52b02
Enable early native network creation for local network
This is needed by tethering local network feature, given that
the IpServer needs to setup forwarding after native network
creation and before signaling network availability.

Test: atest CtsNetTestCases:android.net.cts.NetworkAgentTest \
      ConnectivityCoverageTests:android.net.EthernetTetheringTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest \
      --update-device
Bug: 349487600
Change-Id: I2bc2ec355e01be661b587406bd127dff11665047

Junyu Lai   commited 2025-03-10 10:31:11 +08:00
91ef9d38e3
Merge "Create the DiscoveryExecutor Class" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-06 19:02:14 -08:00
b153713418
Merge "Revert^2 "Use timerfd to improve the accuracy of query timing"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-06 12:52:13 -08:00
c23d94f2cc
Create the DiscoveryExecutor Class
This is a no-op refactor. Move the DiscoveryExecutor from
MdnsDiscoveryManager to a standalone class for subsequent
changes.

Bug: 366373064
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: Idbfbbb423ddfe78a37db1b189aef945401b0a1e9

Paul Hu   commited 2025-03-06 15:13:44 +00:00
bca2d037a9
Revert^2 "Use timerfd to improve the accuracy of query timing"
This reverts commit a481dc184f.

Reason for revert: Update this change to ensure proper closure of the timerfd object.

Change-Id: I14530ba77a39c77b4c7af6855ec77ba4907ab9f9

Paul Hu   commited 2025-03-06 15:13:12 +00:00
a3a34058fe
Merge "Add config_nsdOffloadServicesDenyList to NsdService" into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2025-03-06 06:10:06 -08:00
648d01b9f4
Add config_nsdOffloadServicesDenyList to NsdService
This commit introduces the config_nsdOffloadServicesDenyList to
NsdService to allow OEMs to specify services that should not be
offloaded. This feature addresses potential memory limitations by
enabling selective offloading, providing OEMs with greater control over
resource management.

Test: TH
Change-Id: I846e7cfc37c3a71c50853707884cf0c0a9a6f971

Yuyang Huang   commited 2025-03-06 21:30:21 +09:00
9b0f749723
Merge "Format MdnsServiceCacheTest" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-05 00:02:42 -08:00
15ae8bb8f7
Format MdnsServiceCacheTest
Use the ktlint.py script to correct Kotlin code formatting errors.

Test: m
Change-Id: I587c757f3c96be7a5f6c60ec16eaf662bf148df3

Paul Hu   commited 2025-03-05 06:52:02 +00:00
47959aefd3
Merge "Adding more test cases for stacked link properties for local network." into main
Sarup Dalwani   authored and   Gerrit Code Review   commited 2025-03-01 10:03:31 -08:00
9de6f57d2d
Add 6lowpan decompression tests for invalid packets
Test: TH
Change-Id: I694cdf302a743a0a2e1bf2d821094511863a6600

Patrick Rohr   commited 2025-02-27 12:52:29 -08:00
ad43341d49
Fix linter errors
Test: TH
Change-Id: I662caff2c0ce841dbc4cea836c093a6cf6b218db

Patrick Rohr   commited 2025-02-27 12:50:35 -08:00
0026cb36c0
Merge "Never read device flag values in ConnectivityServiceTest." into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-02-25 23:40:40 -08:00
bcd092b08c
Never read device flag values in ConnectivityServiceTest.
ConnectivityServiceTest is a unit test and must never read
actual flag values from the device, because:
- If it did, its results would not be reproducible.
- At least on S and T, reading flags from device fails because
  the test lacks the READ_DEVICE_CONFIG permission.

Instead, throw a clear exception if ConnectivityService checks a
feature flag that is not explicitly set in the test.

Test: test-only change
Change-Id: Ic3855ffa944f170f5fda9c3456776f5e1f2ef388

Lorenzo Colitti   commited 2025-02-26 13:25:07 +09:00
2322bc04cb
Merge "Handling null interface in addLocalNetAccess, removeLocalNetAccess and getLocalNetAccess" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2025-02-25 20:20:49 -08:00
cbd6238696
Merge changes Ic597ee91,I6a2b48aa,Ia71c79aa,I570dbff5,Ia063deea, ... into main
* changes:
  Get rid of volatile mIsAborted
  Get rid of volatile mIsRunning
  Add some more client network tests
  Add test for when BluetoothSocket#connect throws
  Add a test for when createInsecureL2capChannel throws
  Add a test that brings up an L2cap server network
  Move creating L2capIpClient to Dependencies

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2025-02-25 14:17:58 -08:00
695779c24d
Enable NetworkCallback optimizations by default.
These optimizations are already launched to all public Pixel
devices and were in in 25Q2 beta releases as well. Enable them
by default on all supported releases. The appcompat risk is very
low (these changes are difficult even for an app to detect if
it's looking for them), the user benefits are substantial, and
there is a kill switch if any unforeseen issues do occur.

Bug: 327038794
Test: both codepaths are covered by existing tests
Change-Id: I42c7ceb71ef02d078bf4563744cb11afd412f267

Lorenzo Colitti   commited 2025-02-26 04:24:58 +09:00
2169522878
Merge "Allow mDNS on IFF_POINTOPOINT interfaces" into main
Patrick Rohr   authored and   Gerrit Code Review   commited 2025-02-24 19:09:47 -08:00
81e6bdccd3
Add some more client network tests
Test: TH
Change-Id: Ia71c79aa34c8fcfb078511543695ceddde4af53c

Patrick Rohr   commited 2025-02-24 17:02:36 -08:00
c060ffe22f
Add test for when BluetoothSocket#connect throws
Test: TH
Change-Id: I570dbff550ac1f1c167af5a25b471e41bf421dc2

Patrick Rohr   commited 2025-02-24 17:02:36 -08:00
e87e9241a0
Add a test for when createInsecureL2capChannel throws
Test: TH
Change-Id: Ia063deeaced151870138568e103a605a75813af9

Patrick Rohr   commited 2025-02-24 17:02:36 -08:00
d621b3d8aa
Add a test that brings up an L2cap server network
Test: TH
Change-Id: I9f2d750a822ce1790c9a766415ffc494a47d9287

Patrick Rohr   commited 2025-02-24 17:02:36 -08:00
1446e7a428
Handling null interface in addLocalNetAccess, removeLocalNetAccess and getLocalNetAccess
Bug: 398022752
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Change-Id: I4627fb83727d81108ed4629beb80a36e5433e140

Sarup Dalwani   commited 2025-02-24 20:13:46 +00:00
2e336acd5b
Merge changes Ib2febede,Id3752790,I7cfcc93a,I26f6669f,I5d722c0d into main
* changes:
  Add missing javadocs to satisfy linter
  Make linter happy
  Use ThreadLeakMonitor for CSL2capProviderTest
  Add some tests to ensure BluetoothExceptions are handled
  Move creating L2capPacketForwarder to dependencies

Patrick Rohr   authored and   Gerrit Code Review   commited 2025-02-21 15:04:40 -08:00
2360f4500b
Allow mDNS on IFF_POINTOPOINT interfaces
Instead of disallowing mDNS on interfaces that specify IFF_POINTOPOINT,
the code should check for the presence of IFF_MULTICAST instead. It is
perfectly valid to support mDNS on point-to-point links, such as IPv6
over BLE networks, if they support multicast.

Change-Id: I282a039483ad1d677d31e5169d53bbae25a1c9c4
Test: TH

Patrick Rohr   commited 2025-02-21 14:51:08 -08:00
33dde6b069
Make linter happy
Test: TH
Change-Id: Id3752790b0c040adbb5d08ddcb7aa2279254b7de

Patrick Rohr   commited 2025-02-21 11:57:23 -08:00
4dd26d1ad2
Use ThreadLeakMonitor for CSL2capProviderTest
This CL introduces ThreadLeakMonitor for CSL2capProviderTest.
ThreadLeakMonitor ignores threads with unique names, so all
L2capNetworkProvider related threads must specify a name.

Test: TH
Change-Id: I7cfcc93ab562a1ada2058d8c73e968a8d0005b1d

Patrick Rohr   commited 2025-02-21 11:57:23 -08:00
b4f3922c01
Add some tests to ensure BluetoothExceptions are handled
This is just the beginning.

Also fixed a bug that put(null) on the blocking queue, which apparently
is not supported.

Test: TH
Change-Id: I26f6669f483d76fcba83735bb6d32880e23dd451

Patrick Rohr   commited 2025-02-21 11:57:23 -08:00
5a5c34a679
Move SkDestroyListener to under staticlibs
Upcoming CL use SkDestroyListener from ConnectivityService

Bug: 311792075
Test: atest FrameworksNetTests
Change-Id: I96dec7e13aaa574b90e7caf3b559ee5172848e51

Motomu Utsumi   commited 2025-02-21 09:26:11 +09:00
1135975109
Update SkDestroyListner to support only monitor UDP sockets close
Bug: 311792075
Test: atest FrameworksNetTests
Change-Id: Ib7749049fb0bd6ce8218ec62bec96584106ad7c5

Motomu Utsumi   commited 2025-02-21 09:26:10 +09:00
7f86b7485a
Update SkDestroyListener to take consumer for inetDiagMessage processing
This is a no-op refactoring (except for logging) in preparation for an
upcoming CL(aosp/3502915) that will use SkDestroyListener to close quic
connections for destroyed quic sockets.

Test: atest FrameworksNetTests
Bug: 311792075
Change-Id: I41e2a16075fc9242cae19f84d1255358333744ab

Motomu Utsumi   commited 2025-02-21 09:25:39 +09:00
d159016c22
Adding more test cases for stacked link properties for local network.
Addressing feedback from previous change "Adding stacked link addresses
to local_net_access map" and adding more test cases for impact of
stacked link properties on local network prefixes.

Bug: 369815823
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSLocalNetworkProtectionTest
Change-Id: I4d32d86d3e083a1a14b845583fd80a7a4b18ae5f

Sarup Dalwani   commited 2025-02-20 05:46:02 +00:00
e53faa4e84
Check local network permissions when permission changes, or when user or
packages is added or removed

Bug: 388803658
Test: atest ConnectivityCoverageTests

Change-Id: I7d098c4d9a7614d0bd40ae23869a2010ee3f0779

Jacque Li   authored and   Neha Raj   commited 2025-02-20 04:59:45 +00:00
8d5c6eae80
Merge "Wrapping Network and Traffic permissions in a class for module usage." into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2025-02-19 19:27:48 -08:00
37e457bd0a
Merge "Adding stacked link addresses to local_net_access map" into main
Sarup Dalwani   authored and   Gerrit Code Review   commited 2025-02-19 19:01:55 -08:00
c42f5fc47f
Merge changes I77101952,I399631c6,I5ea98a06,I0b243f45,I5554cd42, ... into main
* changes:
  Fix test comment
  Enable header compression when requested
  Implement 6lowpan header compression
  Add a basic CSTest for L2capNetworkProvider
  Release network reservations in tearDown
  Start L2capNetworkProvider in CS
  Revert "Join HandlerThread if BLE is not supported"

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2025-02-18 21:39:41 -08:00
90a2f97e4c
Fix test comment
Change-Id: I77101952b24825b2c3983ccc5ac384e369a97148

Patrick Rohr   commited 2025-02-18 19:41:15 -08:00
d6bcc2c5e0
Implement 6lowpan header compression
This implements 6lowpan header compression per rfc 6282. While the
decompression logic is full-fledged (to accept almost any 6lowpan
compressed packet on ingress), the compression logic does *not* actually
compress the packet.

Fully fledged compression might be submitted in a follow up, to make
integration testing possible.

Test: TH
Change-Id: I5ea98a06e502fe0752cfe827dbdf8ee4a7dfb24c

Patrick Rohr   commited 2025-02-18 19:41:15 -08:00
a1430bbb11
Add a basic CSTest for L2capNetworkProvider
This moves the tests that used to be in L2capNetworkProviderTest into a
CSTest based CSL2capProviderTest; however, it still only tests that
reservation offers are created in response to reservation requests.

More thorough tests will be added in follow ups.

Test: TH
Change-Id: I0b243f4517ee41376716cf4930f90657c4bc77b0

Patrick Rohr   commited 2025-02-18 19:41:15 -08:00
16093391f3
Start L2capNetworkProvider in CS
Starts L2capNetworkProvider in ConnectivityService. Alternatively, this
could be moved to ConnectivityServiceInitializer instead in a follow up.

When L2capNetworkProvider is created, it starts a handler thread, so
makeL2capNetworkProvider must return null in tests as otherwise the
thread leaks.

Test: atest NetworkReservationTest
Change-Id: I35c14815b1a71f0739c1bf63ad466763d611434c

Patrick Rohr   commited 2025-02-18 19:19:22 -08:00
611ce3f57c
Adding stacked link addresses to local_net_access map
Iterating over stacked link address to ensure correct mapping for
interface to local network ip prefixes.

Bug: 369815823
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSLocalNetworkProtectionTest
Change-Id: I3b2ed906caf43584ffb0e8041f9302c760099f7b

Sarup Dalwani   commited 2025-02-18 19:30:12 +00:00
7d0fcbb0d3
Remove unused code to instantiate bpfNetMaps
Test: m
Change-Id: I253567479e7fd3bccf6723ab86ac1e6b3149e3ad

Motomu Utsumi   commited 2025-02-18 19:11:08 +09:00
5fe65846fe
Exclude dns servers from LNP
Whenever ip interface is updated, we are updating local network
addresses. These may include dns servers that are needed to be excluded from
restrictions.

Bug : 393354879
Test: Manually and atest
ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSBpfNetMapsTest

Change-Id: Id4ebb33ab7de84ac1c81d485e599779c460bacdc

Neha Raj   commited 2025-02-18 03:28:42 +00:00
4792cc5d98
Populating local addresses to local_net_access_map
Whenever LinkProperties is added/modified/removes, we are updating local
network prefixes for the modified interface/addresses. These prefixes
are used by BPF egress and ingress cgroup hooks to disallow local
network packets if the calling application do not have required
permission.

Bug: 369815823
Test: Manually tested
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSLocalNetworkProtectionTest
Change-Id: Ie592ecb948ae05a0a73f47d0573560eb705f6bcf

Sarup Dalwani   commited 2025-02-17 20:34:41 +00:00
18b7262f60
Merge changes I963a1c84,I515d6b60,Iae99f0bc,I99d1240d,I49d078fb into main
* changes:
  Check whether a NetworkRequest is already tracked
  Check whether client NetworkRequest includes a valid specifier
  Add empty ClientOffer
  Delete L2capNetworkProviderTest
  Add support for an L2CAP server network

Patrick Rohr   authored and   Gerrit Code Review   commited 2025-02-14 15:10:29 -08:00
d74eb41b49
Wrapping Network and Traffic permissions in a class for module usage.
To add PERMISSION_SDKSANDBOX_LOCALHOST which is used in the same bitmask
as permissions declared in INetd.aidl but doesn't need visibility to the
platform.

Bug: b/326383676
Test: NetworkTrafficPermsTest
Flag: N/A
Change-Id: Id7a36f5659f8fd7542a87671d4b5f067d66db34e

Melisa CZ   commited 2025-02-14 15:49:49 +00:00
433de97c6b
Merge "Fix test flake in MdnsDiscoveryManagerTests" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-02-14 00:46:57 -08:00
f89a40ae61
Exclude Google Cast app subtypes from mDNS offload
This commit excludes Google Cast app subtypes from mDNS offloading. The
large number of subtypes would consume excessive firmware resources if
offloaded.

Test: TH
Change-Id: I562a94187dc5c710ca37d4997e9ed6c1602918b6

Yuyang Huang   commited 2025-02-14 16:08:17 +09:00
9cb8a29436