Commit Graph

272 Commits

Author SHA1 Message Date
Treehugger Robot
ac32204980 Merge "Use module util HexDump in StructTest" am: b660371d8a am: 0d431094c3
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1745518

Change-Id: Idf66e10f395483cd56f38f80db1e017f5a6975aa
2021-06-24 12:43:07 +00:00
Remi NGUYEN VAN
83c7537a18 Use module util HexDump in StructTest
The hidden API HexDump causes issues, as coverage tests jarjar its
package even though it is a dependency on a hidden platform class, and
not included in test packages.

Use the HexDump utility in the com.android.net.module.util package
instead (no import is necessary as this is the same package).

Bug: 187935317
Test: atest StructTest
Change-Id: If319a3c20a750c890f8400f1a7104462b41ed556
2021-06-24 17:49:07 +09:00
Remi NGUYEN VAN
0d87cfd03f Merge "Add visibility for Connectivity tests" am: bc87949c28 am: 52caed91c9
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1730122

Change-Id: I64559e2ebf6eb3307512561efbedf2fbc3ede9f8
2021-06-21 13:56:37 +00:00
Remi NGUYEN VAN
f96e020879 Add visibility for Connectivity tests
Allow all Connectivity test subpackages to use the targets,
so that the visibility does not need to be updated when test suites
are reorganized inside Connectivity.

Bug: 187935317
Test: m
Change-Id: I99d1ec954ebe313e553443a9f081d54d7a5f12c1
2021-06-09 18:00:43 +09:00
Mark Chien
dedb9eae69 Merge "Add isFeatureEnabled by checking with apex module version" am: eeb15a8c6d am: 4509298603
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1705174

Change-Id: I786195561f2b7f5d7909fb64d0cb9d3dd67b480c
2021-05-18 09:56:41 +00:00
markchien
c4719cd17a Add isFeatureEnabled by checking with apex module version
A variable of #isFeatureEnabled which check apex module version
instead of apk version.

Bug: 187946226
Test: NetworkStaticLibTests

Change-Id: I4cfc0a68f6ecb7eb9e127b3445b261e0108f6481
2021-05-14 23:39:14 +08:00
Pedro Loureiro
d8bb125a4d Add lint baseline to address NewApi errors
We are enabling a new lint check where the min sdk != compile sdk.
It has produced a lot of errors and adding the baseline file(s)
allows us to continue work without introducing more problems.

Bug: 150847901

Test: m lint-check
Change-Id: I2c38dac481685470af8be115d867953325e75d94
Merged-In: I2c38dac481685470af8be115d867953325e75d94
2021-04-14 10:43:02 +00:00
Pedro Loureiro
11ba50b4e4 Merge "Add lint baseline to address NewApi errors" into sc-dev 2021-04-13 14:12:40 +00:00
Pedro Loureiro
86fa055d4a Add lint baseline to address NewApi errors
We are enabling a new lint check where the min sdk != compile sdk.
It has produced a lot of errors and adding the baseline file(s)
allows us to continue work without introducing more problems.

Bug: 150847901

Test: m lint-check
Change-Id: I2c38dac481685470af8be115d867953325e75d94
2021-04-12 10:18:45 +00:00
Xiao Ma
e73ca55962 Add build ICMPv6 echo request packet helper function in Ipv6Utils. am: 657b2e8660 am: 21839bcbdd am: fa4eb167dd
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1669829

Change-Id: Id7fd98e9e359d9a6525b3ac2efaafee3b240b07b
2021-04-09 16:50:13 +00:00
Xiao Ma
0d7d45cdef Add build ICMPv6 echo request packet helper function in Ipv6Utils.
Bug: 168868607
Test: atest NetworkStaticLibTests
Change-Id: Ibd3c8348996c8b55767956b03978a69593ec29e7
2021-04-09 18:57:00 +09:00
Remi NGUYEN VAN
2202e61492 Allow hidden connectivity APIs in net test utils
The net test utils are used for unit tests exercising connectivity code,
and need access to its hidden APIs.

Bug: 182859030
Test: atest NetworkStaticLibTests
Ignore-AOSP-First: needs manual cherry-picks
Change-Id: I33273e5c1cc2731443f0fd745ce526473a704520
2021-04-01 06:39:46 +00:00
Aaron Huang
d7830e3ddc Move deduceRestrictedCapability to libs/net and rename it
NetworkCapabilities is included in framework-connectivity, so external
module cannot have dependencies on its hidden API. Move the method to
libs/net and rename it to inferRestrictedCapability so that external
module can use it by inculding the library.

Bug: 178777253
Test: FrameworksNetTests
      NetworkStaticLibTests
(cherry-picked from ag/13930236)
Merged-In: I51244048e31699b562b1444d88511e3a3da845ec
Change-Id: I51244048e31699b562b1444d88511e3a3da845ec
2021-03-31 16:42:26 +08:00
Aaron Huang
3454193ea9 Move deduceRestrictedCapability to libs/net and rename it
NetworkCapabilities is included in framework-connectivity, so external
module cannot have dependencies on its hidden API. Move the method to
libs/net and rename it to inferRestrictedCapability so that external
module can use it by inculding the library.

Ignore-AOSP-First: to avoid merging conflict to internal
Bug: 178777253
Test: FrameworksNetTests
      NetworkStaticLibTests
Change-Id: I51244048e31699b562b1444d88511e3a3da845ec
2021-03-22 15:47:31 +00:00
Remi NGUYEN VAN
f809c9beda Merge "Move trimV4AddrZeros to libs/net" 2021-03-18 03:22:07 +00:00
Maciej Żenczykowski
def99b7e52 Merge "Fix LocationPermissionCheckerTest" 2021-03-16 06:42:28 +00:00
Remi NGUYEN VAN
f323faedfe Move trimV4AddrZeros to libs/net
The utility is @UnsupportedAppUsage, and also used by internal classes
like WifiTrackerLib or Mms, so it needs to be in a shared location.

Bug: 182859030
Test: atest NetworkStaticLibTests
Change-Id: Ia2be2ef62ea1e7dfdff1f54a14d8f2e282d36fca
2021-03-16 14:31:45 +09:00
Remi NGUYEN VAN
aad6bc8614 Fix LocationPermissionCheckerTest
The mocking of services was incorrect for services queried by class name
instead of service name.
Fix getSystemService mocking to cover both methods.

Bug: 181837977
Test: atest NetworkStaticLibTests
Change-Id: Ifc9bc26e85b5152754941bbe33bccdefff62195a
2021-03-16 13:31:10 +09:00
Remi NGUYEN VAN
9a392164a9 Merge "Move TrackRecordTest to libs/net" 2021-03-16 01:34:16 +00:00
Lorenzo Colitti
fd52eafb59 Add a simple test for Ipv6Utils.
This will increase test coverage numbers for Tethering until
TetheringPrivilegedTests can be put into coverage runs.

Bug: 182785371
Test: atest NetworkStaticLibTests
Change-Id: Id93e6190e76bfacfe17082848d40f161b3fcab6a
2021-03-16 00:14:48 +09:00
Lorenzo Colitti
f4e9b9abcf 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
2021-03-15 23:24:06 +09:00
Remi NGUYEN VAN
e38b5c29dc Move TrackRecordTest to libs/net
The corresponding class was moved to frameworks/libs/net, so the test
needs to be in the frameworks/libs/net tests too.

Bug: 182785371
Test: atest NetworkStaticLibTests
Change-Id: I761544ec0b2513bf0e3115fd0eaecf47efacda62
2021-03-15 23:11:41 +09:00
Treehugger Robot
99b0a110ea Merge "Move LocationPermissionChecker to libs/net" 2021-03-12 04:21:41 +00:00
Remi NGUYEN VAN
59beee8742 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
2021-03-11 20:08:06 +09:00
Xiao Ma
08e32b9378 Merge "Check the ByteArray actual size before writing it to ByteBuffer." 2021-03-08 04:30:17 +00:00
lifr
794adf5f71 [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
2021-03-05 16:55:56 +08:00
junyulai
148bdcb48b [FUI22.1] Add assert utilities for list
Test: atest NetworkStaticLibTests
Bug: 174123988
Change-Id: Id918227716367264042e6b674ce29c18e2d901e4
2021-03-03 21:07:13 +08:00
Xiao Ma
9164b775c1 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
2021-03-03 02:53:33 +00:00
Remi NGUYEN VAN
bdb1b50f7b 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
2021-03-02 13:26:58 +09:00
Paul Hu
3c9f315167 Merge "Add checking NetworkStack permission methods and tests" 2021-02-23 01:48:58 +00:00
Remi NGUYEN VAN
779cba3698 Merge "Add a public test method to reset package version" 2021-02-22 05:31:05 +00:00
Remi NGUYEN VAN
b9fc3ad8e3 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
2021-02-19 10:08:58 +00:00
paulhu
4242767a07 Add checking NetworkStack permission methods and tests
These methods migrate from android.net.NetworkStack.

checkNetworkStackPermission()
checkNetworkStackPermissionOr()

Bug: 178352309
Test: atest NetworkStaticLibTests
Change-Id: Iba4daaac3c662b87fec038f7c557e4fd6544c069
2021-02-18 23:18:21 +08:00
Bob Badour
1b8c744bcd [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
2021-02-17 17:22:02 -08:00
junyulai
f51099dae3 [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
2021-02-03 11:48:07 +08:00
lucaslin
a19b59d8fc Add common CollectionUtils.{any,all} methods.
Test: new tests for this
Change-Id: I482c958af499bf8cdc8824c9586e9da619cd1f39
2021-02-01 15:22:56 +08:00
Xiao Ma
229b17ac0c Support IPv4/6 address type in Struct.
Bug: 163492391
Test: atest NetworkStaticLibTests
Change-Id: I17a753ea495f24d186b69083923a71a7ebccdc7b
2021-01-21 02:46:29 +00:00
Xiao Ma
01c0fe5453 Implement generic toString/equals/hashCode in Struct.
Bug: 163492391
Test: atest NetworkStaticLibTests
Change-Id: I485e0bbc6949c1eb239d52401ff0403dd447619b
2021-01-19 04:02:37 +00:00
Xiao Ma
ef9fd0ae59 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
2021-01-18 16:52:41 +00:00
markchien
22bfada06e Default write to byte array with native order
Bug: 173167302
Test: atest BpfMapTest
      atest StructTest

Change-Id: I60a22ea4cd44697773d98d1720c02cc771643a9e
2021-01-05 00:38:54 +08:00
Xiao Ma
ed82179342 Merge "Support common MacAddress Type in Struct." 2020-12-28 02:03:56 +00:00
Remi NGUYEN VAN
31c6d82be0 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
2020-12-25 16:48:33 +09:00
Remi NGUYEN VAN
a744975b3e 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
2020-12-25 16:23:34 +09:00
Remi NGUYEN VAN
b86b34da48 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
2020-12-25 16:23:25 +09:00
Xiao Ma
81a17c3fc6 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
2020-12-24 04:59:21 +00:00
Chalard Jean
1aadbb0afd Merge "Move util classes to their destination package" 2020-12-21 05:35:09 +00:00
Xiao Ma
ce033d4824 Move Struct.java to com.android.net.module.util package.
Bug: 163492391
Test: atest NetworkStaticLibTests
Change-Id: If7d54f0356ce4d6426011914df0a2e85784daebd
2020-12-17 15:36:23 +00:00
Chalard Jean
ceaf7d0edc Move util classes to their destination package
Test: FrameworksWifiTests FrameworksNetTests
Change-Id: I93e9cfd968e08f983e3fd9f7196c455c79a0f32d
Merged-In: Id19c650246a8f3d55d7b6a874840a6eebcd9eb17
2020-12-16 08:50:20 +09:00
Xiao Ma
f4cb6d6789 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
2020-12-07 17:35:03 +09:00
Xiao Ma
fb21a2d0c3 Merge "Introduce cache schema for generic Struct class." 2020-11-25 00:47:18 +00:00