Commit graph android_packages_modules_Co.../staticlibs/tests
Message SHA1
Fix a bug in InetAddressUtils, and add a test.
InetAddressUtils's parcelInetAddress and #unparcelInetAddress
methods do not correctly parcel scoped IPv6 addresses. Fix this
by using the same code that LinkProperties uses, and add a test.

Bug: 182785371
Test: atest NetworkStaticLibTests
Change-Id: Idc9fcbcf4b2b0746c19831fef68b0ddc206eb161

Lorenzo Colitti   commited 2021-03-15 23:24:06 +09:00
f4e9b9abcf
Merge "Move LocationPermissionChecker to libs/net"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-03-12 04:21:41 +00:00
99b0a110ea
Move LocationPermissionChecker to libs/net
LocationPermissionChecker was written to be used by multiple
connectivity modules, so it belongs in the frameworks/libs/net library.

The file is moved as-is with minor modifications in the test to avoid
usage of the privileged ActivityManager.getCurrentUser API.

Bug: 181837977
Test: atest NetworkStaticLibTests
Change-Id: I80cff14c06c3cab3e8f3bd1978c2951c4a3317c6

Remi NGUYEN VAN   commited 2021-03-11 20:08:06 +09:00
59beee8742
Merge "Check the ByteArray actual size before writing it to ByteBuffer."
Xiao Ma   authored and   Gerrit Code Review   commited 2021-03-08 04:30:17 +00:00
08e32b9378
[CS11]Remove the hidden API usage of BitUtils
The connection service will become the main line module.
It is difficult to include BitUtils in the module. and so
Move the hidden API needed in BitUtils to NetworkCapabilitiesUtils.

Bug: 170598012
Test: atest NetworkStaticLibTests
Change-Id: I56286b2991ea9902f9ed78624e2a592138dd4315

lifr   commited 2021-03-05 16:55:56 +08:00
794adf5f71
[FUI22.1] Add assert utilities for list
Test: atest NetworkStaticLibTests
Bug: 174123988
Change-Id: Id918227716367264042e6b674ce29c18e2d901e4

junyulai   commited 2021-03-03 21:07:13 +08:00
148bdcb48b
Check the ByteArray actual size before writing it to ByteBuffer.
ByteArray is the unique type whose actual size might be different
with the size delcared in the annotation, e.g, user initializes an
object manually, or mutates the byte array after parsing from
ByteBuffer. Therefore, checking the length of byte array is required
before writing the array value to output bytes array or ByteBuffer.

Bug: 163492391
Test: atest NetworkStaticLibTests
Change-Id: I28936a2afbe60dd2dadac803d08062df153b2588

Xiao Ma   commited 2021-03-03 02:53:33 +00:00
9164b775c1
Add CollectionUtils.indexOf
indexOf() is based on the current any() implementation, but gives more
flexibility as the caller can know the position of the found element.

Bug: 174541037
Test: atest NetworkStaticLibTests
Change-Id: I1d679b8369aeee359516bb5ca4275c744a606c3a

Remi NGUYEN VAN   commited 2021-03-02 13:26:58 +09:00
bdb1b50f7b
Merge "Add checking NetworkStack permission methods and tests"
Paul Hu   authored and   Gerrit Code Review   commited 2021-02-23 01:48:58 +00:00
3c9f315167
Merge "Add a public test method to reset package version"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-02-22 05:31:05 +00:00
779cba3698
Add a public test method to reset package version
Instead of having the cached version field protected, which is only
usable by DeviceConfigUtilsTest, have a public method to reset it to -1
so that other tests exercising feature flags can reset it before and
after running.

Bug: 173068192
Test: atest NetworkStaticLibTests
Change-Id: I8f5be3c91b2a47070507d5bf263e2e5d7d9d9d14

Remi NGUYEN VAN   commited 2021-02-19 10:08:58 +00:00
b9fc3ad8e3
Add checking NetworkStack permission methods and tests
These methods migrate from android.net.NetworkStack.

checkNetworkStackPermission()
checkNetworkStackPermissionOr()

Bug: 178352309
Test: atest NetworkStaticLibTests
Change-Id: Iba4daaac3c662b87fec038f7c557e4fd6544c069

paulhu   commited 2021-02-18 23:18:21 +08:00
4242767a07
[LSC] Add LOCAL_LICENSE_KINDS to frameworks/libs/net
Added SPDX-license-identifier-Apache-2.0 to:
  client-libs/Android.bp
  client-libs/tests/unit/Android.bp
  common/Android.bp
  common/native/bpf_syscall_wrappers/Android.bp
  common/native/netjniutils/Android.bp
  common/tests/unit/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work

Change-Id: I2d4abaee12c1f20c39a7e2c9e02e2fccb96fa3ee
Merged-in: I6942c6844c89048f785f2b6eaa4bb33a24fa6f93

Bob Badour   commited 2021-02-17 17:22:02 -08:00
1b8c744bcd
[FUI21.1] Create NetworkIdentityUtils class
This patch creates a class in the static lib that contains utils
of NetworkIdentity.

Test: atest NetworkIdentityUtilsTest
Bug: 174123988
Change-Id: I6f0780190017b5eef3312b764107ac1f00e06833

junyulai   commited 2021-02-03 11:48:07 +08:00
f51099dae3
Add common CollectionUtils.{any,all} methods.
Test: new tests for this
Change-Id: I482c958af499bf8cdc8824c9586e9da619cd1f39

lucaslin   commited 2021-02-01 15:22:56 +08:00
a19b59d8fc
Support IPv4/6 address type in Struct.
Bug: 163492391
Test: atest NetworkStaticLibTests
Change-Id: I17a753ea495f24d186b69083923a71a7ebccdc7b

Xiao Ma   commited 2021-01-21 02:46:29 +00:00
229b17ac0c
Implement generic toString/equals/hashCode in Struct.
Bug: 163492391
Test: atest NetworkStaticLibTests
Change-Id: I485e0bbc6949c1eb239d52401ff0403dd447619b

Xiao Ma   commited 2021-01-19 04:02:37 +00:00
01c0fe5453
Make a copy of HexDump in the frameworks/libs/net.
Make HexDump as a part of module-shared library, being able to share
among of modules. As the first step, moving it to frameworks/libs/net
and be able to use inside net-utils-device-common.

Bug: 177622619
Test: m
Change-Id: I640f343dc6c334b7b4d44960cd043e32a989898d

Xiao Ma   commited 2021-01-18 16:52:41 +00:00
ef9fd0ae59
Default write to byte array with native order
Bug: 173167302
Test: atest BpfMapTest
      atest StructTest

Change-Id: I60a22ea4cd44697773d98d1720c02cc771643a9e

markchien   commited 2021-01-05 00:38:54 +08:00
22bfada06e
Merge "Support common MacAddress Type in Struct."
Xiao Ma   authored and   Gerrit Code Review   commited 2020-12-28 02:03:56 +00:00
ed82179342
Add DeviceConfigUtils version caching and tests
Querying the APK version can be relatively expensive, so cache it with a
static. Package version cannot change without restarting the process.

Also add some testing for flags being equal to the min/max values.

Bug: 17454103
Test: atest NetworkStaticLibTests
Change-Id: I18c298beb843e0a9f76162d353623bb15ab155f1

Remi NGUYEN VAN   commited 2020-12-25 16:48:33 +09:00
31c6d82be0
Add getDisplayTransport
While networks can have multiple transports, users generally think of
them as "wifi", "mobile data", "vpn" and expect them to be classified
as such in UI such as settings.
Add a getDisplayTransport utility that returns which transport should
be used for UI display, from a list of transports of a network.

Bug: 174436414
Test: atest NetworkStaticLibTests
Change-Id: Iaefb47bcaa2f6ce2e7a2ae5011c340154009ac3c

Remi NGUYEN VAN   commited 2020-12-25 16:23:34 +09:00
a744975b3e
Split NetworkStackUtils to frameworks/libs/net
Split DeviceConfig and collections-related utilities to CollectionUtils
and DeviceConfigUtils in frameworks/libs/net.

Also add implementations for contains(array, value), to avoid usage of
internal non-API utils.

The original tests are based on mockito-extended, so also add to
NetworkStackTests as a dependency. This also requires setting the test
app as debuggable in its manifest.

Bug: 17454103
Test: atest NetworkStaticLibTests
Change-Id: Ie9bed66a08b7370ebe50d0a7240b788f8b31aa77

Remi NGUYEN VAN   commited 2020-12-25 16:23:25 +09:00
b86b34da48
Support common MacAddress Type in Struct.
MacAddress class is helpful to represent a 48-bits long MAC Address,
we have to use 6-bytes array to interpret a MAC Address without a
specific annotation type. To better parse the MAC Address appeared
in the ether header, link-layer address option or Bpf class, it's
worth supporting this specific type.

Bug: 163492391
Test: atest NetworkStaticLibTests
Change-Id: I1f716e5d4f38372fc5b7ee32e208d55a072c1e51

Xiao Ma   commited 2020-12-24 04:59:21 +00:00
81a17c3fc6
Merge "Move util classes to their destination package"
Chalard Jean   authored and   Gerrit Code Review   commited 2020-12-21 05:35:09 +00:00
1aadbb0afd
Move Struct.java to com.android.net.module.util package.
Bug: 163492391
Test: atest NetworkStaticLibTests
Change-Id: If7d54f0356ce4d6426011914df0a2e85784daebd

Xiao Ma   commited 2020-12-17 15:36:23 +00:00
ce033d4824
Move util classes to their destination package
Test: FrameworksWifiTests FrameworksNetTests
Change-Id: I93e9cfd968e08f983e3fd9f7196c455c79a0f32d
Merged-In: Id19c650246a8f3d55d7b6a874840a6eebcd9eb17

Chalard Jean   commited 2020-12-16 08:50:20 +09:00
ceaf7d0edc
Add new APIs writeToByteBuffer/writeToBytes for generic Struct class.
Split the original U64/UBE64 into two groups: U63/UBE63 which could be
represented by long primitive directly and U64/UBE64 which should be
represented by BigInteger class.

Also fix the endianness-related issue to support both of big-endian or
little-endian input ByteBuffer, and writeToBytes API outputs the bytes
array in appropriate order then.

Bug: 163492391
Test: atest android.net.util.StructTest --rerun-until-failure
Change-Id: Ie9c07fac6dcfceb8efdf1d6b56ce6ff1e845f477

Xiao Ma   commited 2020-12-07 17:35:03 +09:00
f4cb6d6789
Merge "Introduce cache schema for generic Struct class."
Xiao Ma   authored and   Gerrit Code Review   commited 2020-11-25 00:47:18 +00:00
fb21a2d0c3
Introduce cache schema for generic Struct class.
Bug: 163492391
Test: atest android.net.util.StructTest --rerun-until-failure
Change-Id: Idffad7d3b907d8853ed7d296808a2e0e2736cbbe

Xiao Ma   commited 2020-11-24 18:03:07 +09:00
a76690a3b7
Add visibility rules for packages/modules/Connectivity/Tethering
BUG: 167962976
Test: TH
Change-Id: I4f9c63d27fe7f10534e89f3d132f26b2f45e7b07

Baligh Uddin   commited 2020-10-29 03:57:51 +00:00
ae4770df38
Merge "Move jarjar rules from NetworkStaticTestsLib to NetworkStaticTests"
Mark Chien   authored and   Gerrit Code Review   commited 2020-10-26 12:22:32 +00:00
dea71cd586
Move jarjar rules from NetworkStaticTestsLib to NetworkStaticTests
jarjar should be applied on the final artifact (android_test,
android_app, java_library that goes into an apex), not on any
intermediate (android_library etc).

Bug: 171670016
Test: atest NetworkStaticTests
      atest TetheringCoverageTests
      atest NetworkCoverageTests
Change-Id: I86a15133112c555e08275efbde99e68315aa6bc2

markchien   authored and   Mark Chien   commited 2020-10-26 09:52:13 +00:00
c064abd0db
Add basic tests for CompareResult
...as suggested in aosp/1448415

Test: this
Change-Id: I8469ba6cbcbd9c1b414cfde6cda27505c210526c

Chalard Jean   commited 2020-10-19 16:17:50 +09:00
c746481d10
Improve code style in Struct.java and add tests for Type.U64 represented
by long primitive.

Bug: 163492391
Test: atest android.net.util.StructTest --rerun-until-failure
Change-Id: I0120d7ab063d9d170e8b6e6a6077f8f86db93d67

Xiao Ma   commited 2020-10-13 06:59:51 +00:00
ea53144db0
Merge "Define a generic class to parse structured message."
Xiao Ma   authored and   Gerrit Code Review   commited 2020-10-09 13:20:31 +00:00
1f2650f6d6
Define a generic class to parse structured message.
Bug: 163492391
Test: atest android.net.util.StructTest --rerun-until-failure
Change-Id: I1848984d80998d87acccc52287a351d27708dedc

Xiao Ma   commited 2020-10-09 18:25:34 +09:00
6f95cefd38
Move IpUtils to frameworks/libs/net
The utility classes are useful for mainline modules and their tests, for
example IpClientIntegrationTest.

Bug: 168868607
Test: m && atest NetworkStackCoverageTests
Change-Id: Ie3eea7731fa45cd58cd4acf8249da68ff3eb6a70

Remi NGUYEN VAN   commited 2020-10-05 11:25:18 +09:00
ff57cec7d1
Rename utils to remove the Kt suffix
Nobody cares what language this is written in

Test: builds
Change-Id: I3ed3bce276479fd503e716a06fd4912da8c49eda

Chalard Jean   commited 2020-07-31 15:24:34 +09:00
b1856fe06b
Move utilities to libs/net
These files used to be in the network stack directory, but the libs
directory is a much more suitable place for them.

Also fix a typo : ConcurrentIntepreter → ConcurrentInterpreter

Also move {FdEvents,Packet}Reader to internal annotations. That's
what they should have been using in the first place anyway.

Note that this does not fix preupload issues reported by
checkstyle to make review easier. The fixes are in a followup
patch to this one.

Test: checkbuild
Change-Id: I675077fd42cbb092c0e6bd56571f2fc022e582fd

Chalard Jean   commited 2020-07-30 22:10:51 +09:00
48c6c7d838
Move Inet[4]AddressUtils to libs/net
The classes should not be picked up from frameworks/base, as they are
part of several mainline modules.

Bug: 151052811
Test: m; manual: flashed, wifi and telephony working
Test: atest NetworkStackCoverageTests
(clean cherry-pick from internal branch)
Merged-In: I2b3dcf2e238be047147232769602df56894dc6b1

Change-Id: I2b3dcf2e238be047147232769602df56894dc6b1

Remi NGUYEN VAN   commited 2020-06-30 19:19:52 +09:00
f109837101
Move DnsPacket to libs/net
This class might be used by some mainline modules.
Cut the dependency between it and framework base classes.

Bug: 151052811
Test: atest DnsPacketTest
Test: atest DnsResolverTest
(clean cherry-pick from internal branch)
Merged-In: Id12aaedb6dd75144ca9b58b94bfcd845a1f16360
Change-Id: Id12aaedb6dd75144ca9b58b94bfcd845a1f16360

Luke Huang   commited 2020-06-24 19:37:25 +08:00
85c290e33e
Make NetworkStaticLibTests as test lib
Share the tests with TetheringCoverageTests because
tethering module use net-utils-framework-common.

Remove unused static library. Currently we do not implement any
unit test for net-utils-services-common. "net-utils-services-common"
can be back when we add new test for it.

Bug: 148636687
Test: atest NetworkStaticLibTests
      atest TetheringCoverageTests
Change-Id: I2f3a94b2ba50cd4d73303961bf1661a3091ab033

markchien   authored and   Mark Chien   commited 2020-04-22 03:04:37 +00:00
ba972ca71f
Merge "Add IpRange utility to convert IP ranges to IpPrefix"
Benedict Wong   authored and   Gerrit Code Review   commited 2020-02-04 22:49:50 +00:00
3fa91de697
Add IpRange utility to convert IP ranges to IpPrefix
IKE Traffic Selectors are defined to be an IP range, with a start and an
end IP address. However, the Android system works in IP Prefixes. This
commit adds a utility to convert between the two.

Bug: 144246767
Test: New tests added, passing
Change-Id: I428fee682dea21346f92c5c628642dee3c785ba9

Benedict Wong   commited 2020-01-29 23:08:10 -08:00
db0915c14c
Update CompareOrUpdateResult with NULL NULL Check
Add a test to CompareOrUpdateResult where the new and old item
list are both NULL.

Test: Updated unit test
Change-Id: I6821028409d29ab864af52685629630cbf16db3b

Tyler Wear   commited 2020-01-28 16:42:22 -08:00
3767434b21
Update CompareOrUpdateResult with NULL Check
Like CompareResult, add in null check for input objects.

Test: updated unit test
Change-Id: Iea63752ff23a5bfb1cc5cb716ec579bec6c403bf

Tyler Wear   commited 2020-01-27 10:55:38 -08:00
65e8b66875
Add a CompareOrUpdateResult class.
This is like CompareResult, but also has the concept of an item
being "updated" (i.e., the same, but with different properties,
in the old and the new list of items). This is needed to support
updating routes.

Bug: 142892223
Test: new unit test
Change-Id: Ide5e31acb9baa6a5d3f50e9965d4019eb7c82cd4

Lorenzo Colitti   commited 2020-01-21 17:26:48 +09:00
9c0c6a5c05
Run NetworkStaticLibTests on the actual source files.
Currently, NetworkStaticLibTests tests the class files that are
on the bootclasspath of the device. This makes running these
tests slow and/or confusing, because the framework must be
rebuilt and the device flashed before running the tests, and if
this is not done, the old code will be tested instead.

Instead, jarjar the tests so the test can be run without updating
the device.

Bug: 142892223
Test: atest NetworkStaticLibTests passes on device that does not have the library
Change-Id: I6a0dbebddbd0b64e2722078345ffe6b0c0a1801e

Lorenzo Colitti   commited 2020-01-21 15:52:34 +09:00
5d9f8ed872
Add NetUtils to net static library
This class includes network common utilities.

Bug: 139268426
Bug: 135998869
Bug: 138306002
Bug: 143925787
Test: build lib pass
      atest NetworkStaticLibTests
Change-Id: I1ffe723aa4ff2ed7bc46f34106701c91fe93032a

Aaron Huang   commited 2020-01-13 00:43:54 +08:00
05a9dfef78