Commit Graph

1238 Commits

Author SHA1 Message Date
Lorenzo Colitti
4441558954 Make TestableNetworkCallback understand blocked reasons.
This provides some support for tests that want to test the new
onBlockedStatusChanged(Network, int) callback. This cannot be
implemented entirely in TestableNetworkCallback, because in
Kotlin, "override" is a mandatory keyword, but NetworkCallback
(which TestableNetworkCallback inherits from) only has the new
method in S, not R.

The unit tests in the other CL in this topic provide an idea of
how to do this. There may be more elegant ways to do it though.

Bug: 165835257
Test: new ConnectivityServiceTest tests in this topic
Change-Id: Ibdf36a6bc916bf247688c19bfd81f6b62d59bf03
2021-03-25 01:42:51 +09:00
Remi NGUYEN VAN
89cff640de Add visibility to net-utils-framework-srcs
Allow framework-connectivity to depend on net-utils-framework-srcs, and
add @hide annotations to classes that were missing it.

This allows depending on less classes than net-utils-device-common, and
avoids transitive dependency on androidx.annotations used by
net-utils-device-common (which itself depends on the public SDK).

Bug: 183600168
Test: m
Ignore-AOSP-First: needs manual cherry-picks
Change-Id: I89a18bb46311800fd6807dad5785f12648f165d9
2021-03-24 22:44:24 +09:00
Junyu Lai
a1ceec7020 Merge "[SP28.1] Add onSetWarningAndLimit to test utilities" into sc-dev 2021-03-24 10:22:08 +00:00
Chalard Jean
9885f9ce7e Merge "Remove unused methods" into sc-dev 2021-03-24 05:59:31 +00:00
junyulai
740ab0f645 [SP28.1] Add onSetWarningAndLimit to test utilities
Test: atest NetworkStatsServiceTest
Bug: 149467454
Bug: 170699770
Bug: 170179169
Ignore-AOSP-First: avoid long automerger delay
Change-Id: I4cc242e5fba895bb0756733bafc5be1f39b10ac0
2021-03-23 23:38:48 +08:00
Chalard Jean
59d2bf3ad2 Remove unused methods
Ignore-AOSP-First: mainline-prod in the critical path
Test: FrameworksNetTests NetworkStackTests
Bug: 167544279
Change-Id: If1b23e27d8fb2b3b484466245268eb6787e58818
2021-03-23 21:50:52 +09: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
79fd552a04 Merge "Move trimV4AddrZeros to libs/net" am: 54fcb1500e am: 3bb6f4c4eb am: 7606dec950
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1637461

Change-Id: I05d5a2ed5d9f6a850770493c45eedf6ef18c1fd5
2021-03-18 04:53:40 +00:00
Remi NGUYEN VAN
f809c9beda Merge "Move trimV4AddrZeros to libs/net" 2021-03-18 03:22:07 +00:00
Aaron Huang
49390d5cfe Move some constants from TrafficStatsConstants to NetworkStackConstants
Keep the constants are only used by framework in TrafficStatsConstants
and move the others to NetworkStackConstants which is in libs/net.

Bug: 182349970
Test: FrameworksNetTests
      NetworkStackTests
      TetheringTests
Change-Id: I7b3a6ba6283a72cc3f2a727001f0f581dce5a7c0
Merged-In: I7b3a6ba6283a72cc3f2a727001f0f581dce5a7c0
2021-03-17 13:48:40 +08:00
Aaron Huang
91f79560fd Merge "Move some constants from TrafficStatsConstants to NetworkStackConstants" into sc-dev 2021-03-17 03:16:56 +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
Maciej Żenczykowski
c36f0b3f46 add NsHeader class and implement buildNsPacket()
This is a near trivial copy of NaHeader & buildNaPacket()

Test: builds
Bug: 154669942
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3b9b15e23317363bf9556b06ddecf8a2bf967c61
2021-03-15 20:58:17 -07:00
Remi NGUYEN VAN
9a392164a9 Merge "Move TrackRecordTest to libs/net" 2021-03-16 01:34:16 +00:00
Aaron Huang
c6e268ece0 Move some constants from TrafficStatsConstants to NetworkStackConstants
Keep the constants are only used by framework in TrafficStatsConstants
and move the others to NetworkStackConstants which is in libs/net.

Bug: 182349970
Test: FrameworksNetTests
      NetworkStackTests
      TetheringTests
Ignore-AOSP-First: this topic needs to be cherry-picked manually
to AOSP to avoid automerging differences.

Change-Id: I7b3a6ba6283a72cc3f2a727001f0f581dce5a7c0
2021-03-16 00:02:50 +08: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
Junyu Lai
9fd65a6a6a Merge "[VCN04.1] Add assert tool for Set" 2021-03-12 07:12:59 +00:00
Remi NGUYEN VAN
15cd8bd30f Merge "Fix CompatUtil on Q and R" 2021-03-12 04:54:57 +00:00
Treehugger Robot
99b0a110ea Merge "Move LocationPermissionChecker to libs/net" 2021-03-12 04:21:41 +00:00
Remi NGUYEN VAN
d105ecf8f1 Fix CompatUtil on Q and R
CompatUtil was missing return statements and falled back to S
behavior even on Q and R.

Bug: 179329291
Change-Id: I8efb8e56948383c29d476e0b090619bac156d372
Test: atest CtsNetTestCasesLatestSdk
2021-03-12 01:25:40 +00:00
Remi NGUYEN VAN
48c3682a14 Merge "Rename StringNetworkSpecifier to Ethernet" 2021-03-11 23:51:49 +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
Chiachang Wang
6918f36393 Merge "Add helper function to check if collection is empty" 2021-03-11 01:03:15 +00:00
junyulai
0c813cc91e [VCN04.1] Add assert tool for Set
Test: TH
Bug: 175662146
Change-Id: Ib7e2e61a987def59f8e8fc841d07f37ae894573d
2021-03-09 20:08:38 +08:00
Xiao Ma
a7c245d1ce Merge "Add bit mask constants for the flags used in the ND packet." 2021-03-09 01:10:44 +00:00
Xiao Ma
08e32b9378 Merge "Check the ByteArray actual size before writing it to ByteBuffer." 2021-03-08 04:30:17 +00:00
Xiao Ma
5b4cfac125 Add bit mask constants for the flags used in the ND packet.
Bug: 168868607
Test: atest NetworkStackIntegrationTest
Change-Id: I6e7ed431f175e911eeff71fdf3f1e651533d3364
2021-03-08 02:44:56 +00:00
Xiao Ma
f1d9d84201 Merge "Address the comments left in the IPv6 utils change." 2021-03-08 02:44:42 +00:00
Xiao Ma
5fbc8d5dca Address the comments left in the IPv6 utils change.
This follow-up change updates EtherType name in the Ethernet header
diagram, replaces "length" filed in the IPv6 header with "payloadLength",
and also make ND options constructor as package private to encapsulate
the constant params(e.g. ICMPv6 type/code).

Bug: 168868607
Test: atest NetworkStackIntegrationTest
Change-Id: Ia0500a7020fd9a85dce2a8c67c21b00b238a4e8d
2021-03-08 02:36:34 +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
b6880675ac Merge "Add CollectionUtils.indexOf" 2021-03-02 09:27:09 +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
Remi NGUYEN VAN
9671ec4073 Rename StringNetworkSpecifier to Ethernet
To keep the tests passing on Q and R, add a CompatUtil class that will
keep creating StringNetworkSpecifiers (now removed) instead.

Bug: 179329291
Test: atest CtsNetTestCases
Merged-In: I14c1ac7cee0ec32353b38ebca4ae6c5cd2e25541

Change-Id: I14c1ac7cee0ec32353b38ebca4ae6c5cd2e25541
2021-03-01 17:41:10 +09:00
Xiao Ma
5c1745477f Revert "Revert "Add utilities to create IPv6 ICMP messages.""
This reverts commit 405c1bfca93fa25ae1616a93ee6e2a1f76d87d1e.

Bug: 168868607
Test: atest NetworkStackIntegrationTest

Reason for revert: Roll forward the previous change and try to merge it one by one instead of using the topic, which should avoid the build broken on the sc-dev branch due to the deferred auto-merge process.

Change-Id: I751fbd9d978ed60206bab009212f621fe902f321
2021-02-28 13:09:23 +00:00
Rahul Sabnis
9d4d4b28fb Revert "Add utilities to create IPv6 ICMP messages."
Revert "Rename net-utils-framework-common in FrameworksTelephony..."

Revert submission 1579863-ipv6_utils

Reason for revert: Build breakage
Bug: 181339273

Reverted Changes:
I0d3b133e5:Rename net-utils-framework-common in FrameworksTel...
I1c050ae42:Add utilities to create IPv6 ICMP messages.

Change-Id: I2b3a26d6fe22c24618e3cab61f717a8b991f2b4d
2021-02-26 20:02:44 +00:00
Xiao Ma
6344a8cdae Add utilities to create IPv6 ICMP messages.
The utilities replace the ones from IpClientIntegrationTests. Original
Kotlin implementation is aosp/1440812.

Bug: 168868607
Test: atest NetworkStackIntegrationTest
Change-Id: I1c050ae42d99f541eeaa3dcd80a53574ab9bc1c3
2021-02-25 07:18:08 +00:00
Chiachang Wang
4dfe1ff50a Add helper function to check if collection is empty
Bug: 172183305
Test: m
Change-Id: I3b7b415d39f8a1fffb43ace58772da554412d25e
2021-02-25 11:55:51 +08:00
Paul Hu
3c9f315167 Merge "Add checking NetworkStack permission methods and tests" 2021-02-23 01:48:58 +00:00
Bob Badour
37cd99a0ed [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: I6ea23b03b1fadb54c7974c9f716f0f13795f84c5
2021-02-22 16:10:07 -08:00
Remi NGUYEN VAN
779cba3698 Merge "Add a public test method to reset package version" 2021-02-22 05:31:05 +00:00
Paul Hu
985d402aea Merge "Add indexOf method" 2021-02-22 05:22:01 +00:00
Chiachang Wang
fac832274f Merge "Move shared methods to NetUtils" 2021-02-20 00:24:13 +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