Commit graph android_packages_modules_Co.../staticlibs/tests/unit
Message SHA1
Merge "Add expect_throws() to assert_utils.py to check expected exception" into main
Jimi Chen   authored and   Gerrit Code Review   commited 2024-10-22 07:05:01 +00:00
7a4a85bf44
Add expect_throws() to assert_utils.py to check expected exception
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I2e181f5b6f41e6de228d516dff970d47cfa3eaf6

Jimi Chen   commited 2024-10-22 03:06:47 +00:00
a0c0168ae6
Merge "Consolidate handler thread check functions in HandlerUtils" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-17 02:25:57 +00:00
b0e3eaf70b
Update unit tests to reflect the changes to RoutingCoordinator and
PrivateAddressCoordinator

Bug: 350699020

Change-Id: Id0ae47dcb03c60b6caafa3feeecaf8b21092a101

Handa Wang   commited 2024-10-16 23:54:29 +00:00
d789d1b8de
Consolidate handler thread check functions in HandlerUtils
Moved common handler thread check functions from MdnsUtils.java
to HandlerUtils.java within the staticlib to facilitate reuse by
both Connectivity and NetworkStack modules.

Test: TH
Change-Id: Id96f6558c32c44fbdf2d2ce3e57c14da0cbf3ed7

Paul Hu   commited 2024-10-16 10:07:03 +00:00
84a40ff16d
Add packet capture and match network_stack adb command to to apf_utils
It wraps the following 3 commands for multi-devices tests
- cmd network_stack capture start <interface>
- cmd network_stack capture stop <interface>
- cmd network_stack capture matched-packet-counts <interface> <pkt-in-hex>

Add a helper function `is_packet_capture_supported` as APFv6 precondition check.
Test: atest NetworkStaticLibHostPythonTests

Change-Id: I526c678c6e753cee3969b04a56ab33e5e3d1600d

Jimi Chen   commited 2024-10-07 13:33:57 +00:00
1644f95852
Support get multiple ipv4/ipv6 addresses in apf_utils
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I806696437acf905c049762d59a46c866ff0584ef

Jimi Chen   commited 2024-09-27 06:55:54 +00:00
738bf999d5
Merge "Add createGetLinkMessage() at RtNetlinkLinkMessage" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-25 11:55:40 +00:00
1a9758e5a2
Add createGetLinkMessage() at RtNetlinkLinkMessage
This CL adds the createGetLinkMessage() method at the
RtNetlinkLinkMessage class, that creates a link message to get the
information of a interface. The functionality is the same as
"ip link show $interface".

Bug: 364501824
Test: atest NetworkStaticLibTests

Change-Id: I87a120f488e5b6f7f24c663c68ba26835fa2157a

Chih-Yu Huang   commited 2024-09-25 17:16:24 +09:00
f0bcd6f4d6
Merge "Add get ipv4/ipv6 address function to apf_utils" into main
Jimi Chen   authored and   Gerrit Code Review   commited 2024-09-24 13:38:54 +00:00
a0d22134b1
Merge "Add packet_utils for multi-devices tests" into main
Jimi Chen   authored and   Gerrit Code Review   commited 2024-09-24 13:38:44 +00:00
df2eadce09
Merge "Add createSetLinkNameMessage method at RtNetlinkLinkMessage" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-20 08:12:42 +00:00
5fdce4d932
Add get ipv4/ipv6 address function to apf_utils
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I535bdca481f600b95603206bf368a106cbb45b42

Jimi Chen   commited 2024-09-20 05:45:19 +00:00
b756497e05
Add packet_utils for multi-devices tests
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I211d071232d1730c043eef29e1bf2bce27a6e2a6

Jimi Chen   commited 2024-09-20 05:41:20 +00:00
0e1c1cc92d
Merge "Add createSetLinkStateMessage method at RtNetlinkLinkMessage" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-20 01:48:30 +00:00
dde0dc63d3
Add createSetLinkNameMessage method at RtNetlinkLinkMessage
This CL mainly adds the createSetLinkNameMessage() method at the
RtNetlinkLinkMessage class, that creates a link message to rename the
network interface. The functionality is the same as
"ip link set $interface name NEW_NAME".

Bug: 364501824
Test: atest NetworkStaticLibTests
Change-Id: I6323bce1ece10f4437483214860d50cb7d29df8d

Chih-Yu Huang   commited 2024-09-20 09:15:52 +09:00
9f8ed83e04
Add createSetLinkStateMessage method at RtNetlinkLinkMessage
This CL mainly adds the createSetLinkStateMessage() method at the
RtNetlinkLinkMessage class, that creates a link message to set the
interface up or down. The functionality is the same as
"ip link set $interface up" or "ip link set $interface down".

Bug: 364501824
Test: atest NetworkStaticLibTests

Change-Id: Id9232851f6d9a7f99f857fd5b8d4eae506de2c7c

Chih-Yu Huang   commited 2024-09-20 09:06:19 +09:00
73f5b138a2
Merge "Make RtNetlinkLinkMessage class immutable after creation" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-18 03:28:35 +00:00
e7f5ac9d2f
Make RtNetlinkLinkMessage class immutable after creation
This CL marks all the fields of RtNetlinkLinkMessage class final. That
means once the instance is created, the instance is immutable.

Also, the CL adds a static create method that verifies the arguments,
and updates the nlmsg_len field of the header before creation.

Bug: 364501824
Test: atest NetworkStaticLibTests

Change-Id: I08af4a6e68df9aee8ae76d953fac5d81f0b02c84

Chih-Yu Huang   commited 2024-09-18 10:46:07 +09:00
f4a0865055
Make java_sdk_library dependencies explicit
modules should specify the submodule of java_sdk_library that the module
actually depends on

Test: CI
Bug: 358613520
Change-Id: I0367068c901df98483f6cf95160d3e7801881b0a

Jihoon Kang   commited 2024-09-10 00:01:31 +00:00
8401b6a9f0
Merge "Update checkLocationPermissionInternal not to throw" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-09-05 03:39:19 +00:00
99506666f3
Merge "Support checking DnsResolver version in isFeatureSupported." into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-08-30 04:17:09 +00:00
a0dc47579c
Support checking DnsResolver version in isFeatureSupported.
Test: new unit tests
Change-Id: Ia251c068806a3d8c970d984322d4cb7e2364c1ef

Lorenzo Colitti   commited 2024-08-30 11:50:12 +09:00
ca67820a94
Merge "Remove unused methods and restrict visibility in LocationPermissionChecker" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-08-29 11:19:24 +00:00
6f005ff41b
Merge "Use doReturn instead of when().thenReturn" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-08-27 06:28:01 +00:00
e73285c622
Update checkLocationPermissionInternal not to throw
Currently, checkLocationPermissionInternal throws if the package does
not exist or package name and uid doest not match.
This caused system server crash in ConnectivityService.
ConnectivityService is an only caller of checkLocationPermissionInternal
and ConnectivityService should consider uid does not have location
permission in this case.
So this CL updates checkLocationPermissionInternal return
ERROR_LOCATION_PERMISSION_MISSING instead of throwing exception.

Bug: 337473824
Test: LocationPermissionCheckerTest
Change-Id: Ic42d6203bafa95aea7e5428c490b0a298e3bd260

Motomu Utsumi   commited 2024-08-27 15:25:37 +09:00
d55bdd26e2
Remove unused methods and restrict visibility in LocationPermissionChecker
Bug: 337473824
Test: TH
Change-Id: Ie14a5bdb39742d4c086f63fca3e12521e1ad84a7

Motomu Utsumi   commited 2024-08-27 15:25:34 +09:00
3625bf6fae
Merge "Import absl-py library from codebase" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-08-26 03:37:07 +00:00
1c1af76ff1
Add bool type to Struct.java.
Bug: 361492282
Test: TreeHugger, atest NetworkStaticLibTests:com.android.net.moduletests.util.StructTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9c6ff0b826c425fc6250e2eb7f844275728f92dd

Maciej Å»enczykowski   commited 2024-08-23 19:17:55 +00:00
e87608b523
Use doReturn instead of when().thenReturn
doReturn is less prone to races since when().thenReturn will fail if the
mock is used by other thread between when() and thenReturn()).

Bug: 337473824
Test: LocationPermissionCheckerTest
Change-Id: Ie07f3f3cf23b57296a7db4fb9296b84be5b57214

Motomu Utsumi   commited 2024-08-23 22:39:15 +09:00
7cf1a03ee5
Import absl-py library from codebase
This removes the need of pip install absl-py and
virtual env usage from the tests.

Test: atest NetworkStaticLibHostPythonTests
Bug: N/A
Change-Id: I2259f7702ecc6b5e7b7b23e2bf44fa28a5a2e07b

Junyu Lai   commited 2024-08-23 21:11:30 +08:00
f84b9074e0
Move fromPublicNetworkStats to statsd
This is a no-op refactor to reduce complexity to prevent from
accessing trunk stable flags from static libs. Also it
makes more sense since statsd is the only caller.

Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.NetworkStatsUtilsTest

Bug: 335680025
Change-Id: Ied563bd685bdba9d514414c05d58009304d5baa4

Junyu Lai   commited 2024-08-19 14:39:18 +08:00
d2a2218237
Revert "Use addEntries when creating NetworkStats"
This reverts commit 668560d85a.

Reason for revert: Devices failing to boot, see b/359795863 

Change-Id: I13dc629e2eb626bff1aed6ff262699c3f577ab9c

Sam Dubey   authored and   Gerrit Code Review   commited 2024-08-14 10:00:32 +00:00
c006797ed4
Use addEntries when creating NetworkStats
In the current design, NetworkStats.addEntry is used within a
loop to create a NetworkStats instance from entries. This results
in a large memory footprint because the addEntry() method clones
the original NetworkStats instance each time it is called.

This change utilizes the newly created API to add a list of
entries at once. This approach only clones the instance once,
thereby reducing the required memory footprint.

Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.NetworkStatsUtilsTest#testPublicStatsToAndroidNetStats
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.NetworkStatsUtilsTest
      (on S device)
Test: atest ConnectivityCoverageTests:com.android.testutils.NetworkStatsUtilsTest
      (on S device)
Bug: 335680025
Change-Id: I5c635613ed3ba34d840ee71b6bef21d10105df0d

Junyu Lai   commited 2024-08-13 17:46:20 +08:00
668560d85a
Make assertNetworkStatsEquals supports null iface name
This change enables comparison of android.net.NetworkStats
instances even when their interface name is null. This scenario
arises when deriving a android.net.NetworkStats instance
from an app.usage.NetworkStats, which lacks interface name
information. However, the original utility method relies on
NetworkStats.Entry#equals, which is incompatible with null
interface names on T- devices, because they do not run
mainlined NetworkStats.

This change refactor assertEntryEquals and makes
assertNetworkStatsEquals to use it to compare android.net.NetworkStats
instances.

Test: atest NetworkStaticLibTests
Test: atest ConnectivityCoverageTests:com.android.testutils.NetworkStatsUtilsTest
      (on S device)
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.NetworkStatsUtilsTest
      (on S device)
Bug: 335680025

Change-Id: I25a685e4c2d4cf70132b2c4374b2bb8129c844cb

Junyu Lai   commited 2024-08-13 17:02:33 +08:00
10fcc1761d
Move NetworkStatsUtilsTest to Connectivity
Since the testutils.NetworkStatsUtils is in Connectivity.
Move it to Connectivity git makes more senses.

Test: atest NetworkStaticLibTests
Bug: 335680025
Change-Id: Ia59cc8f74417b1dbbcccf12c5c79c3ed22454b78

Junyu Lai   commited 2024-08-12 15:01:09 +08:00
63b764ad8d
Merge changes If787d3f3,I6de357ac into main
* changes:
  Rename getShrinkedBackingArray to getMinimized*
  Suspend callbacks for frozen apps

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-08-05 00:15:39 +00:00
057369c840
Rename getShrinkedBackingArray to getMinimized*
"Shrinked" should actually be "shrunk" or "shrunken"; in any case
"minimized" is simpler and possibly more accurate (it's the minimum size
required to hold the values).

Test: atest
Change-Id: If787d3f3d6e1046338d4e89ed924bce183e74bd6

Remi NGUYEN VAN   commited 2024-08-02 19:27:41 +09:00
dfb159289b
Refactor Drop EtherCat packet test
This is a no-op refactoring, which is preparation for follow-up
changes to add more apf tests.

This includes:
1. Add a method to send packet and expect counter increases.
2. Inline the packet construction code in the test method.

Test: atest NetworkStaticLibHostPythonTests
Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases
Bug: 350880989
Change-Id: Iadcfd97740033306af1b6a474004cbf0699ddd1b

Junyu Lai   commited 2024-08-01 03:32:19 +00:00
6f6b1a4684
Refactor ApfV4Test
This is a no-op refactoring, which is preparation for follow-up
changes to add more apf test classes.

This includes:
1. Move initialization code to a base class, which setup a hotspot
   and a client connects to it, and enable doze mode to
   activate the apf.
2. Check whether send raw packet is supported before testing.

Test: m connectivity_multi_devices_snippet && \
  atest CtsConnectivityMultiDevicesTestCases
Test: atest NetworkStaticLibHostPythonTests
Bug: 350880989
Change-Id: I6376935883653182728e473e2f5533407d993d7b

Junyu Lai   commited 2024-08-01 03:32:19 +00:00
cf655869ba
Modify DnsUtils to use uppercase DNS label conversion
Updated methods in DnsUtils to convert DNS labels to uppercase instead
of lowercase to ensure compatibility with APF requirements.

Test: TH
Change-Id: I4b585f875b29b9e508d9a5eb73a073587510faab

Yuyang Huang   commited 2024-07-18 19:16:47 +09:00
e0051d4260
Merge "Consolidate DNS label comparison functions in DnsUtils" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-18 04:50:45 +00:00
880807031f
Consolidate DNS label comparison functions in DnsUtils
Moved common DNS label comparison functions from MdnsUtils.java to
DnsUtils.java within the staticlib to facilitate reuse by both
Connectivity and NetworkStack modules.

Test: TH
Change-Id: Ie839c5621d2c4b74e41987a0c6d1141d0d6e24f8

Yuyang Huang   commited 2024-07-18 12:00:59 +09:00
d851a04db4
Merge "Add default network monitor to DevSdkIgnoreRunner" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-07-17 02:47:06 +00:00
a9a27614cc
Add default network monitor to DevSdkIgnoreRunner
Some tests reconnect wifi and don't wait wifi is validated.
So default network is changed while later tests are running.
This CL adds RestoreDefaultNetwork annotation to monitor default network
changes and wait to default network is restored to previous state.
If the default network is not restored within timeout, test fails.

Bug: 328870515
Test: atest MultinetworkApiTest NetworkAgentTest
Change-Id: I01e858109ac274ff60769bd558b91654298290ff

Motomu Utsumi   commited 2024-07-16 20:16:04 +09:00
74db5855fb
Merge changes I6cc2507d,I187ea15d into main
* changes:
  Add flag for QUEUE_CALLBACKS_FOR_FROZEN_APPS
  Add a CallbackQueue class

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-07-16 08:46:11 +00:00
16828bdeba
Add a CallbackQueue class
The class will be used to build memory-efficient objects (int arrays)
used to queue ConnectivityService callbacks while an app is frozen.

This is very similar to an ArrayList<Pair<Short, Short>>, but avoids
object boxing which would use a lot more memory.

This is intended to be used by ConnectivityService both as a builder,
and as a utility to read lists of callbacks that it stores. Long-lived
references to the CallbackQueue would not be kept to minimize memory
usage; only the array returned by toArray needs to be stored.

Test: atest
Bug: 327038794
Bug: 279392981
Change-Id: I187ea15d14dfd160e577e9e9e87b1aded27b1938

Remi NGUYEN VAN   commited 2024-07-16 13:36:49 +09:00
c3621e6012
Support get apf capabilities from network_stack shell command
This utility reads output of cmd network_stack apf ${iface_name}
capabilities. This is needed for the tests to skip if the apf
version is too old.

Test: atest NetworkStaticLibHostPythonTests
Bug: 352132428
Change-Id: I1f8b523c3e6f687c2e919993bc18392dc25dbbf7

Junyu Lai   commited 2024-07-11 17:43:21 +08:00
c6fae35cfd
Refactor RoutingCoordinator
- This CL puts RoutingCoordinator into staticlibs to make it usable by
both Tethering and ConnectivityService on R.
- This CL also changes the return type of
  ConnectivityInternalApi#getRoutingCoordinatorManager() to IBinder so
  it has fewer dependencies.

Bug: 350699020
Test: CI

Change-Id: Iba096e940795cd33e61c5141721394ad39e5ce6d

Handa Wang   commited 2024-07-05 05:26:54 +00:00
8f2c30664d
Remove packet type and dst mac when sending raw packet
This is now derived from the passed packet data by
NetworkStack.

Test: m connectivity_multi_devices_snippet && \
      atest CtsConnectivityMultiDevicesTestCases:ConnectivityMultiDevicesTest
Test: atest NetworkStaticLibHostPythonTests
Bug: 335368434
Change-Id: Ida06c00e6f499b782cb903c9fa0a4154c2d8cf84

Junyu Lai   commited 2024-07-03 12:33:11 +08:00
161dc10f60