Commit graph

240 commits

Message SHA1
Merge "Adjust visibility rules for migration"
Baligh Uddin   authored and   Gerrit Code Review   commited 2020-12-28 14:03:37 +00:00
ffe8f93ce4
Merge "Support common MacAddress Type in Struct."
Xiao Ma   authored and   Gerrit Code Review   commited 2020-12-28 02:03:56 +00:00
ed82179342
Merge changes from topic "netutils_split"
* changes:
  Add DeviceConfigUtils version caching and tests
  Add getDisplayTransport
  Split NetworkStackUtils to frameworks/libs/net

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-12-28 01:17:41 +00:00
d5a89c61fd
Adjust visibility rules for migration
Adjusting visibility to accomodate migration of
frameworks/opt/net/wifi to packages/modules/Wifi.

BUG: 137323948
Test: TH
Change-Id: Iee3f2dc6fc5f3262fa9e81626a3e15a3226e4ab7

Baligh Uddin   commited 2020-12-27 15:10:36 +00:00
fcbda3ac66
Merge "[Mainline] ProxyInfo migration"
Serik Beketayev   authored and   Gerrit Code Review   commited 2020-12-25 08:32:04 +00:00
a3c54cb19b
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
Merge "Add ETHER_BROADCAST and DEFAULT_LINK_MTU constants."
Xiao Ma   authored and   Gerrit Code Review   commited 2020-12-25 01:38:03 +00:00
cd6104ff70
[Mainline] ProxyInfo migration
Bug: 173455434
Test: mma

Change-Id: I49f7f491acc657051d9c79fc24605d4896cbc315

Serik Beketayev   commited 2020-12-23 22:15:42 -08:00
57969d0ec9
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
Add visibility rule for migration.
Add paths to visibility needed for tests.
Soong allows specifying paths w/o validation.  Once the
migration is complete, we can remove the old path in
visibility rules.

BUG: 137323948
Test: TH
Merged-In: Id19c650246a8f3d55d7b6a874840a6eebcd9eb17
Change-Id: I68de6a67b978ed5a2e721adf41329af349076696
Exempt-From-Owner-Approval: Cleanup CL

Baligh Uddin   commited 2020-12-24 03:28:41 +00:00
fe99df5a25
Merge "Add visibility rules for Connectivity project"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-12-24 01:46:30 +00:00
6c67e2723d
Add ETHER_BROADCAST and DEFAULT_LINK_MTU constants.
ETHER_BROADCAST is used to fill the destination mac address of ether
header, it was defined in the DhcpPacket.java, move it to a common
place for other usecases.

Also have a link mtu constant(default value is 1500 bytes), irrelevant
to specific link-layer type.

Bug: 175830307
Test: m
Change-Id: I422d284cd8fa943bd745ad29229a54515135a3c4

Xiao Ma   commited 2020-12-23 08:01:45 +00:00
acc47e60da
Merge "Make Readhead more usable in multithread."
Chalard Jean   authored and   Gerrit Code Review   commited 2020-12-23 00:33:32 +00:00
359a533e56
Add kotlin-reflect to net-tests-utils
This fixes failures in CtsNetTestCases, where
TestableNetworkCallback.TAG cannot be used because
it uses kotlin-reflect.

Change-Id: I7e76fe224b1098c967665275eac24fcac08fca23
Fixes: 176047509
Test: atest CtsNetTestCasesLatestSdk

Remi NGUYEN VAN   commited 2020-12-21 07:16:52 +00:00
128c31f0b8
Make Readhead more usable in multithread.
There doesn't seem to be a way to get any code at all
to run in a generic way on the thread that will execute
a test in android JUnit. JUnit can do it, but the android
harness imposes a thread hop.

This is inconvenent with ReadHead, because ReadHead can't
be used in multithread for semantic reasons : it would
make no sense at all. ReadHead enforces this today in a
relatively strong fashion.

But technically, the only guarantee that is needed is that
poll() is executed only on one thread in slabs of time
defined between a read barrier and a write barrier, where
the write barrier of the previous slab happen-before the
read barrier of the next slab. This in generally speaking
a bit difficult to achieve, but the tests run satisfy this
condition by starting the thread after executing the
@Before methods and joining it before executing the @After
methods. So in fact, it's safe to use ReadHead during
the befores and afters, if a bit uncomfortable, as long
as only one thread uses it during the before, one thread
during the test, and one thread during the afters.

This patch relaxes the enforcement on ReadHead to accept
the usage above. If any slab of time contains usage of
poll() on multiple threads, this will instead crash with
ConcurrentModificationException in almost all cases. It's
no longer possible to detect every possible misuse of
poll() under these conditions, but with this code it's
going to be very unlikely at each test run that the code
is incorrect and still doesn't crash, so incorrect use
should still cause at least very severe flakiness.

The main drawback, aside from the very slight performance
penalty, is that some use can be accidentally correct and
this code will now accept it. So it's possible that code
that is only accidentally correct is accepted, and a
seemingly unrelated change later breaks that correctness,
causing seemingly unrelated tests to fail.

Still, this is going to be an improvement in usability
of ReadHead. We'll no longer need to have lazy creation
of it, and it will be possible to check remaining events
after a tests runs.

Test: FrameworksNetTests NetworkStackTests
Change-Id: If87eef1686b235e53cb444a32f9985b4c2a0a901

Chalard Jean   commited 2020-12-21 15:47:09 +09:00
460e78931a
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
Merge "Add new APIs writeToByteBuffer/writeToBytes for generic Struct class."
Xiao Ma   authored and   Gerrit Code Review   commited 2020-12-17 02:11:50 +00:00
127532321c
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
Merge "Share JNI file descriptor helper code"
Orion Hodson   authored and   Gerrit Code Review   commited 2020-12-15 06:25:37 +00:00
72472e4202
Add logging to TestableNetworkCallback.
This is not super useful because it cannot identify different
NetworkCallback objects from each other, but I've found it to be
better than nothing.

Test: manual
Change-Id: Ib402161f361c0f9fb68701bf171cbc99f598dafd

Lorenzo Colitti   commited 2020-12-14 14:43:42 +09:00
a726723ffb
Share JNI file descriptor helper code
Move JNI File descriptor code from NetworkStack into a common native
static library.

Bug: 158749603
Test: atest NetworkStaticLibTests / treehugger
Change-Id: I3d14587ee8e8590b727736d7d2e29cba687e5514

Orion Hodson   commited 2020-12-11 23:15:44 +00:00
4ec55ea007
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
Add NetworkStackConstants to framework/ am: ef5de53830
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1512756

Change-Id: I294d9dd8a4b451dd0de5f1d6e211e4ab61fc7d80

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2020-12-04 03:18:27 +00:00
b1d2c89862
Add NetworkStackConstants to framework/
The constants are also useful for bootclasspath code, for example in
Ikev2VpnProfile.

Bug: 174436414
Test: atest FrameworksNetTests NetworkStackTests NetworkStaticLibTests
Change-Id: I34458fe6568a73533f956f86ed7bb50d45aa7d7e

Remi NGUYEN VAN   commited 2020-11-30 17:19:18 +09:00
1ba696dbf7
Add visibility rules for Connectivity project
The packages/modules/Connectivity project contains module code that can
depend on net-utils-device-common or net-utils-framework-common.

Bug: 171540887
Test: m
Change-Id: Ie754e3f55d78aabff4cef2da3a2a94a1204bd5e5

Remi NGUYEN VAN   commited 2020-11-27 13:59:48 +09:00
38afb0cd07
Merge "Mark ab/6881855 as merged" into stage-aosp-master
TreeHugger Robot   authored and   Android (Google) Code Review   commited 2020-11-25 02:31:19 +00:00
517e51d755
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
Mark ab/6881855 as merged
Bug: 172690556
Change-Id: I387ce9a1a766a23c1cc7ea298d7e6936a9a3b0f6

Xin Li   commited 2020-11-23 11:31:12 -08:00
02e3a24a58
Merge "Create net-utils-services-common-srcs"
David Su   authored and   Gerrit Code Review   commited 2020-11-12 02:53:27 +00:00
6ca84ae4c5
Create net-utils-services-common-srcs
...in order to allow "services.net-module-wifi" to
use it.

Bug: 171330443
Test: compiles
Change-Id: I67300429e1a95344c2287ec0358c94c651d2f9f9

David Su   commited 2020-11-04 16:59:08 +00:00
2dbab6439b
Adjust visibility to avoid build breaks.
per b/167962976#comment10,  following project directories are being
moved under platform/packages/modules/Connectivity/...

cts/test/net --> packages/modules/Connectivity/tests/cts/net
cts/tests/tests/tethering -> packages/modules/Connectivity/tests/cts/tethering
cts/hostsidetests/net -> packages/modules/Connectivity/tests/cts/hostside

BUG: 167962976
Test: TH & Local Build
Exempt-From-Owner-Approval: PS.1 +2d by Lorenzo.  fixing tab (+2 not sticky)
Change-Id: I4e13620ea16b74712a917737607bc3ed38c11cd9

Baligh Uddin   commited 2020-10-31 12:54:44 +00:00
e685c813d5
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
Merge "Add basic tests for CompareResult"
Chalard Jean   authored and   Gerrit Code Review   commited 2020-10-21 05:17:45 +00:00
b774bc06cb
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
Merge "Let frameworks/base/tests access the static lib" am: 023a1e78c9
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1462062

Change-Id: I1558e5b959a4da33d7bbb68418e5d1925dc5fd64

Treehugger Robot   authored and   Automerger Merge Worker   commited 2020-10-15 12:51:54 +00:00
437026fcf9
Merge "Let frameworks/base/tests access the static lib"
Treehugger Robot   authored and   Gerrit Code Review   commited 2020-10-15 12:27:15 +00:00
e27ae93f77
Let frameworks/base/tests access the static lib
Test: CtsNetTestCases FrameworksNetTests
Change-Id: I51520b179fe2946f03311eccac97bf4bd4019aea

Chalard Jean   commited 2020-10-15 18:06:30 +09:00
a9f49910fe
Merge "Improve code style in Struct.java and add tests for Type.U64 represented by long primitive." am: 2626b4fd9d
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1455947

Change-Id: I8ef90e52ca6308ab8ed42d53bfb25238eb89cb97

Treehugger Robot   authored and   Automerger Merge Worker   commited 2020-10-13 07:36:08 +00:00
6bf36492c7
Merge "Improve code style in Struct.java and add tests for Type.U64 represented by long primitive."
Treehugger Robot   authored and   Gerrit Code Review   commited 2020-10-13 07:02:18 +00:00
bfd404c903
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 "Add an icmpv6Checksum utility to IpUtils" am: 67c35de1e8
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1448335

Change-Id: If4f9421fcb7fc967e954f09c89e91f50281efeab

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2020-10-13 06:31:32 +00:00
c5c60b6d10
Merge "Add an icmpv6Checksum utility to IpUtils"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-10-13 06:14:38 +00:00
867c472714
Merge "Move NetworkStackConstants to frameworks/libs/net" am: 2d26542b6a
Original change: https://android-review.googlesource.com/c/platform/frameworks/libs/net/+/1455936

Change-Id: I9797cb5cd32261cf0ff5a16b6979b9177585855d

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2020-10-12 02:45:44 +00:00
5446b03f9d
Merge "Move NetworkStackConstants to frameworks/libs/net"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2020-10-12 02:00:55 +00:00
9f0bde57d2