Commit graph android_packages_modules_Co.../staticlibs/tests
Message SHA1
Merge "Make structs in StructTest accessible from Struct" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2023-08-29 10:44:51 +00:00
fefde209df
Make structs in StructTest accessible from Struct
After link Struct statically into framework-connectivity,
the structs in StructTest are no longer accessible from Struct
because Struct is loaded by bootclasspath classloader.
Make classes and members public for accessing from Struct.

Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.StructTest
Bug: 297836825
Change-Id: I3b1f466f10247306c84d6cac0d7402353770fac4

Junyu Lai   commited 2023-08-29 10:33:38 +08:00
e2eff036ed
Merge "Move ArpPacket.java to frameworks/libs/net" into main
Yuyang Huang   authored and   Gerrit Code Review   commited 2023-08-24 07:12:27 +00:00
62a016e514
Move ArpPacket.java to frameworks/libs/net
Bug: 281639507
Test: TH
Change-Id: Ic0d273695d3f0f85a0ec56337a9d12d77b60ea3b

Yuyang Huang   commited 2023-08-24 12:48:02 +09:00
6acc55e129
Merge "Fix kotlin nullable errors in net-test-utils and NetworkStaticLibTests" into main
Colin Cross   authored and   Gerrit Code Review   commited 2023-08-21 19:04:15 +00:00
1d1c0e7282
Rename to isTetheringFeatureEnabled
DeviceConfigUtils has isFeatureEnabled for NetworkStack and Tethering
which were confusing since the difference was only the arguments.
This CL renames isFeatureEnabled for Tethering module to
isTetheringFeatureEnabled to avoid confusion.

Bug: 279108992
Test: m
Change-Id: I16e8e4f6c0080d73533ce8bd36adfa7038347500

Motomu Utsumi   commited 2023-08-17 19:00:22 +09:00
c046ac418e
Rename to isTetheringFeatureNotChickenedOut
Expected use case of isTetheringFeatureForceDisabled was
`enabled = !isTetheringFeatureForceDisabled`, which is error prune.
So this CL renames to isTetheringFeatureNotChickenedOut and updates to
return true if the feature is not disabled.
If the feature is enabled by default and disabled by flag push (kill
switch), isTetheringFeatureNotChickenedOut should be used.

Bug: 279108992
Test: m
Change-Id: I5f85c24032bae298831bbf042874a63ea2c9b75f

Motomu Utsumi   commited 2023-08-17 02:18:22 +00:00
aad6281844
Fix kotlin nullable errors in net-test-utils and NetworkStaticLibTests
Fix kotlin nullable errors that were exposed by setting the retention
of android.annotation.NonNull and android.annotation.Nullable to
class retention.

Bug: 294110802
Test: builds
Change-Id: I2a2c91188b64619fca190a9bd7812d32f9610abd

Colin Cross   commited 2023-08-08 14:26:10 -07:00
d91c89ba51
Merge "Add isFeatureSupported and isTetheringFeatureForceDisabled methods" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-08-03 06:58:28 +00:00
cc5c2a648a
Add isFeatureSupported and isTetheringFeatureForceDisabled methods
Add isFeatureSupported helper method to check whether
a specific feature is supported. This is useful when a specific
module version is required on a cross module feature, e.g.
a connectivity feauture requires to work with a older
networkstack module.

This commit also adds isTetheringFeatureForceDisabled() method
as a method that refers to DeviceConfig which can be controlled
to explicitly disabled.

Bug: 291870956
Test: atest FrameworksNetTests NetworkStaticLibTests
Change-Id: I511d00663e2378c36b4ca017db4b88d88f650852

chiachangwang   commited 2023-08-02 13:12:14 +00:00
1637730010
Merge "Add DomainsUtils class to encode/decode domain names." into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2023-08-02 00:58:40 +00:00
fa33ba6f3d
Remove truth lib denpendency temporarily due to code coverage regression.
Bug: 291341416
Test: atest NetworkStaticLibTests
Change-Id: Id8fac2ff76dab174761fbc48d0599bcce81918ed

Xiao Ma   commited 2023-07-27 12:12:41 +09:00
9e9bc97317
Add DomainsUtils class to encode/decode domain names.
Both encode and deocde methods support message compression which is
described in RFC1035 section 4.1.4. We can leverage both methods in
a follow-up CL to parse DHCPv4 option 119 and DNSSL RA option.

This cl also adds maxLabelCount argument for DnsRecordParser#parseName
to prevent the potential recursion from overflowing the stack.

Bug: 189865016
Test: atest NetworkStaticLibTests
Change-Id: I90101ecda64bfecb0233e80ea93c91c204fbf176

fqjc86   commited 2023-07-25 18:29:23 +05:30
48693a994a
Merge "Add DomainsUtils class to encode/decode domain names." into main
Xiao Ma   authored and   Gerrit Code Review   commited 2023-07-20 09:03:24 +00:00
c4789d0df4
Improve testBasicWorkingGetAddrQuery by checking the specific IPv4/v6 address.
Parse the entire RTM_NEWADDR message instead of only parsing the nlmsg
header and Ifaddr header. Besides, that would be better to know which IP
address will be returned from kernel via netlink message, that's IPv4
and IPv6 loopback addresses.

Test: atest NetworkStaticLibTests
Change-Id: I3a01137db4a7774fa30ebdec5a1711697991b9fe

Xiao Ma   commited 2023-07-12 13:32:19 +09:00
da97a39255
Add DomainsUtils class to encode/decode domain names.
Both encode and deocde methods support message compression which is
described in RFC1035 section 4.1.4. We can leverage both methods in
a follow-up CL to parse DHCPv4 option 119 and DNSSL RA option.

This cl also adds maxLabelCount argument for DnsRecordParser#parseName
to prevent the potential recursion from overflowing the stack.

Bug: 189865016
Test: atest NetworkStaticLibTests
Change-Id: I624649c224f141848a475ac85c56012d138c5224

fqjc86   authored and   Xiao Ma   commited 2023-07-11 18:04:18 +09:00
cece401526
Merge "Remove duplicated IfaddrMsg and RtgenMsg Struct used in NetlinkUtilsTests." into main
Xiao Ma   authored and   Gerrit Code Review   commited 2023-07-10 04:08:55 +00:00
2ca9f07b99
Remove duplicated IfaddrMsg and RtgenMsg Struct used in NetlinkUtilsTests.
Bug: 263222068
Test: atest NetworkStaticLibTests
Change-Id: Iea5f91e0b20db7cd4cb4451b06e713dd68e9c387

Xiao Ma   commited 2023-07-10 11:12:33 +09:00
3ffb814525
Use default package version in isFeatureEnabled if package is not found
Bug: 287359634
Bug: 289173013
Test: atest HostsideVpnTests
Change-Id: I379cde0391f96a8ac5dcdb2ff7723ea950684e36

Motomu Utsumi   commited 2023-07-07 15:57:58 +09:00
2ba922ad85
Add a method helper to create RTM_DELADDR message in user space.
Bug: 260934173
Bug: 263222068
Test: atest NetworkStaticLibTests
Change-Id: Ibddaed91b12d3f27778d0bd2171bc5be38ff8bda

Xiao Ma   commited 2023-06-30 23:52:23 +09:00
723515738d
Merge "Parse DnsRecord by factory method"
Junyu Lai   authored and   Gerrit Code Review   commited 2023-06-27 03:21:08 +00:00
729c65662c
Parse DnsRecord by factory method
Currently, DnsPacket calls DnsRecord constructor to create
DnsRecord instances from a ByteBuffer. However, invoking
DnsRecord constructor cannot create subclass instances of
DnsRecord.

To fix this, use a factory method to parse DnsRecord. This
factory method will peek the nsType field of the DnsRecord
as an argument, and it will use this field to determine which
subclass of DnsRecord to create.

This change is no-op, because it does not change the
functionality of DnsPacket. However, it does allow subsequent
changes to create subclass instances of DnsRecord in the future.

Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.DnsPacketTest

Change-Id: Ibbdeaf6e5a844573f393f05609310658d8d225b3

Junyu Lai   commited 2023-06-26 14:52:21 +08:00
cba11a2370
Parse rta_cacheinfo structure in RtNetlinkRouteMessage.
Bug: 183601771
Test: atest NetworkStaticLibTests
Change-Id: I9ea55ad297f5183853eeaa2e53f2406d79a90a20

Xiao Ma   commited 2023-06-22 10:37:39 +09:00
34ab408ade
Merge "Use ThrowingSupplier for visibleOnHandlerThread."
Hansen Kurli   authored and   Gerrit Code Review   commited 2023-05-24 02:39:07 +00:00
8b39bca655
Use ThrowingSupplier for visibleOnHandlerThread.
In order to return values from functions that are run on the handler
thread, use a ThrowingSupplier instead of a ThrowingRunnable.
Also maintain the case with ThrowingRunnable by overloading.

Test: NetworkStaticLibTests
Change-Id: Ic1b86f9f764997ce5d6848f04185194a961d1106

Hansen Kurli   commited 2023-05-23 06:17:52 +00:00
0cd46d480d
Correctly test for an object being of the correct type
This `as? T` instruction warns that this is an unchecked cast.
It's unchecked in the literal sense : the compiler actually
doesn't check that the var is of that type. Accordingly, this
will only fail if `it` is null, which never happens.

Concretely what that means is that Java code calling this
method like

  expect(AVAILABLE, network)

...will actually pass for *any* callback matching the network,
because the class is not checked.

Thankfully this code is recent and there doesn't seem to be a
lot of tests that got accepted by this bug when they should
have been rejected.

Test: ConnectivityServiceTest, TH
      new test in this patch that fails before but succeeds after
Change-Id: I2e48dae28ff92045f002cfb2798d383c9c19d5ed

Chalard Jean   commited 2023-05-22 17:55:11 +09:00
677b663aaf
Allow using isFeatureEnabled on APEX module init
isFeatureEnabled is not usable in APEX module service initialization,
as it relies on PackageManager.getModuleInfo, which is only available
once the module controller is initialized. Also, there is no module
metadata in base AOSP.

Avoid this by guessing the tethering module name based on its
APK-in-APEX packages, which can be queried at that time.
ConnectivityServiceResources will indicate the package prefix used on
the device.

If querying with prefix + "tethering" fails, retry querying with prefix
+ "go.tethering" for Go devices.

This should allow using isFeatureEnabled in services (like
ConnectivityService) constructors, and allows removing the
FIXED_PACKAGE_VERSION hack when Tethering is not considered a module.

getConnectivityResourcesPackageName is implemented based on existing
code in ConnectivityResources.java. aosp/2446026 updates
ConnectivityResources to use getConnectivityResourcesPackageName.

Bug: 279108992
Test: atest
Change-Id: I277f4583e92ba41d53bd19666f1e8e29f68dfcd1

Remi NGUYEN VAN   authored and   Motomu Utsumi   commited 2023-04-28 16:39:52 +09:00
8c4fd4bf0b
Merge "Refactors common scope id setup code into utility function"
Yuyang Huang   authored and   Gerrit Code Review   commited 2023-04-27 07:39:58 +00:00
c8022b3e00
Refactors common scope id setup code into utility function
Bug: 279691947
Test: atest NetworkStackIntegrationTests NetworkStackRootTests
Test: atest CtsNetTestCases:android.net.cts.NsdManagerTest
Change-Id: I81ab8d53a9c3b2641915a3cbfaf182c0962a3d55

Yuyang Huang   commited 2023-04-27 11:38:01 +09:00
58546f4046
Merge "Add InetDiagMessage.destroyLiveTcpSocket"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-04-26 04:49:20 +00:00
6e4762d627
Add InetDiagMessage.destroyLiveTcpSocket
Implement NetdNativeService::socketDestroy in Java

Bug: 270298713
Test: atest NetworkStaticLibTests
Change-Id: I514abed84655cbdbf708cac159a6325eefb8d06b

Motomu Utsumi   commited 2023-04-25 13:20:24 +09:00
ba2e01d067
Merge "fix typo in NetlinkUtilsTest TAG"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-04-21 13:04:20 +00:00
4cd3d40c9a
fix typo in NetlinkUtilsTest TAG
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2776eda17f4998129056a432029f6040365662f8

Maciej Żenczykowski   commited 2023-04-21 10:29:00 +00:00
2689f8fcb1
NetlinkUtilsTest: add an assumption to testGetNeighborsQuery
after:
  com.android.net.moduletests.util.netlink.NetlinkUtilsTest#testGetNeighborsQuery: ASSUMPTION_FAILED

Bug: 200221182
Test: TreeHugger, atest NetworkStaticLibTests
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I556a3a52339e5e2343b02d2b2b67b486cb9b2033

Maciej Żenczykowski   commited 2023-04-21 02:11:25 -07:00
99d78d81b0
Merge "IpUtils - make checksum work with empty/zero buffer"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-04-19 19:39:53 +00:00
90d41b22a4
IpUtils - make checksum work with empty/zero buffer
also:
- document buffer endianness assumption
- simplify fold logic - it cannot overflow

Test: TreeHugger, atest NetworkStaticLibTests
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I521a7377d1310c0e9c46a5dff95dca451e5f889e

Maciej Żenczykowski   commited 2023-04-19 08:17:29 +00:00
5f95a67eef
Add async BufferedFile and StreamingPacketFile impls
Bug: 245971639

Change-Id: Ief1719262c2cb68819f6feb955e97793f3638ec0

Igor Chernyshev   commited 2023-04-17 21:26:58 +00:00
810be2b456
Merge changes Ief507b3f,I45256bb1
* changes:
  Add InetDiagMessage.inetDiagReqV2 with different args
  Fix StructInetDiagSockId parsing for v4-mapped v6 address

Treehugger Robot   authored and   Gerrit Code Review   commited 2023-04-10 12:14:07 +00:00
021e3178b2
Merge "Add util to compare getAllAddresses"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-04-10 10:38:42 +00:00
6ba46f963a
Add InetDiagMessage.inetDiagReqV2 with different args
This CL also adds SOCK_DESTROY constants.
These changes will be used by upcoming CLs that implement socket destroy
in ConnectivityService.

Bug: 270298713
Test: atest NetworkStaticLibTests
Change-Id: Ief507b3f8cc4fe23c08699e7fc8f3f62e5acfcdc

Motomu Utsumi   commited 2023-04-10 18:09:43 +09:00
95681172a9
Fix StructInetDiagSockId parsing for v4-mapped v6 address
Before this CL, StructInetDiagSockId.parse convert v4-mapped v6 address
to Inet4Address that is inconsistent with the value in
inet_diag_msg.idiag_family.
Also, due to this behavior, input of parse and output of pack could be
different.
This is the issue specifically when SOCK_DESTROY request is populated
based on the InetDiagMessage from the kernel.

Bug: 270298713
Test: atest NetworkStaticLibTests
Change-Id: I45256bb1069cfc4e01662b3a533077933f3f019a

Motomu Utsumi   commited 2023-04-10 18:01:17 +09:00
64a711a618
Merge "Remove pollOrThrow"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-04-10 04:58:22 +00:00
68783d0260
Update StructInetDiagMsg to parse all the fields
Bug: 270298713
Test: atest NetworkStaticLibTests
Change-Id: I782eca50b6db6dca88ee933edb5d5d19223886dd

Motomu Utsumi   commited 2023-04-06 11:03:52 +09:00
80c53fa4fd
Add util to compare getAllAddresses
Bug: 269715746
Test: New test in this patch
Change-Id: I243940df693d984a8adfa5c55b49088f7d8bc5ff

Chalard Jean   commited 2023-03-31 21:35:44 +09:00
b56b9f2dcc
Merge "Fix StructInetDiagMsg#parse bug"
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-03-24 08:44:55 +00:00
b0c6afda18
Fix StructInetDiagMsg#parse bug
StructInetDiagMsg#parse used absolute position to parse id and idiag_uid
fields.
This causes an issue when byte buffer contains multiple netlink messages
and parsed netlink message starts from the middle of byte buffer.

This CL fixes above issue and adds test for the case that single byte
buffer contains multiple netlink messages.

Test: atest NetworkStaticLibTests
Change-Id: I771daf17b4a606915d5edefd9f0e90ef01abf168

Motomu Utsumi   commited 2023-03-24 12:34:04 +09:00
06e615e3ce
Support NLM_F_REPLACE flag when sending a RTM_NEWADDR message.
NLM_F_REPLACE is helpful when we only want to update the preferred and
valid lifetime for a specific IPv6 address. DHCPv6 prefix delegation
gives a concrete example, once client refreshes the delegated prefix
successfully in RENEW or REBIND state, it also needs to extend the
preferred and valid lifetime of an IPv6 address, otherwise, it becomes
depreacated when the lifetime expires. Add the NLM_F_REPLACE flag to
replace the existing matching address object with updated fields.

Bug: 260934173
Test: atest NetworkStaticLibsTests
Change-Id: Ic001ddf9cfb031a586bbe177819e7666eaf7cde0

Xiao Ma   commited 2023-03-23 15:59:40 +09:00
9a1359b46c
Remove pollOrThrow
This method is better removed, because it doesn't follow the
naming conventions we want to keep in this file. It also isn't
useful :
• There is only one use of it outside tests, and it's in the
  same file. It's trivial to inline it.
• The method has a unit test, which becomes useless once the
  method is inlined.
• There is a corresponding command in the interpreter, but it's
  only used by the unit test and therefore can be removed once
  the unit test is removed.

Test: TH
Bug: 157405399
Change-Id: Ib5b1369ac28e4577adc98204e42ff2f27729e64c

Chalard Jean   commited 2023-03-07 21:48:24 +09:00
c2cf7eb82d
Merge "Revert "Return default value when getModuleVersion throwed""
Junyu Lai   authored and   Gerrit Code Review   commited 2023-02-21 07:47:51 +00:00
ff5ee31314
Bubble up exceptions in visibleOnHandlerThread
Test: NetworkStaticLibTests
Fixes: 269390906
Change-Id: I3c2d330dd719869562f437c1995e85abd32dbd68

Chalard Jean   authored and   Jean Chalard   commited 2023-02-17 07:19:22 +00:00
2695fdf6ce