Commit Graph

1238 Commits

Author SHA1 Message Date
Chalard Jean
b1856fe06b Rename utils to remove the Kt suffix
Nobody cares what language this is written in

Test: builds
Change-Id: I3ed3bce276479fd503e716a06fd4912da8c49eda
2020-07-31 15:24:34 +09:00
Chalard Jean
e06c5c8fc0 Fix issues reported by checkstyle
Test: builds
Change-Id: I41979cc8096a682c6844df0825ee56ab00a828b5
2020-07-31 09:58:14 +09:00
Chalard Jean
48c6c7d838 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
2020-07-30 22:10:51 +09:00
Remi NGUYEN VAN
9fff546da7 Set the NAME_* constants public
The constants are useful to examine or build DNS packets.

Test: m
Bug: 160617623
Bug: 160656765
Change-Id: I0fbe59e4bfb2ffc8ceb83ff5f81ceeab0f83228b
2020-07-29 12:24:14 +09:00
Remi NGUYEN VAN
f109837101 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
2020-06-30 19:19:52 +09:00
Luke Huang
fd5479e5d4 Add the visibility of net-utils-framework-common for cts-net
DnsResolverTest required DnsPacket to parse DNS answer, and the
DnsPacket class is provided by system previously.
However, DnsPacket was moved to here with changed package,
which has no backward-compatibility and might cause
NoClassDefFoundError. To solve this problem, build the DnsResolverTest with
DnsPacket directly.

Test: build
Test: atest DnsResolverTest
Bug: 150952393
(clean cherry-pick from internal branch)
Merged-In: I463fd58173cee55a210fa6c6b8c9b0d5a74b7906
Change-Id: I463fd58173cee55a210fa6c6b8c9b0d5a74b7906
2020-06-24 11:39:49 +00:00
Luke Huang
85c290e33e 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
2020-06-24 19:37:25 +08:00
Chalard Jean
40ba249403 Opportunistic cleanup of NetworkFactory.
This addresses warnings from IntelliJ and removes a
method that was marked for removal.

Test: FrameworksWifiTests
      FrameworksNetTests
      FrameworksTelephonyTests
Bug: none
Change-Id: Ic3c84cc1e12e06a8f007464fdd3ec11b989bd3aa
2020-05-15 15:44:41 +09:00
markchien
ba972ca71f 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
2020-04-22 03:04:37 +00:00
Treehugger Robot
6bfcfdbf59 Merge "src_frameworkcommon: Fix filegroup base path" 2020-04-02 10:40:46 +00:00
Adrian Roos
0607dd9a16 src_frameworkcommon: Fix filegroup base path
The filegroups here were set up without an explicit path. As a result,
the files within were incorrectly considered part of the
"src_frameworkcommon.android.net.utils" package by droidstubs'
filter_packages filter (and thus not fed into droidstubs).

This CL fixes the filegroups by adding an explicit path to where the
package tree starts for each of them, such that the path-based
package filter in droidstubs can work correctly.

Also @hide the classes which otherwise would now be considered exposed
API by droidstubs.

Bug: 151160048
Test: make checkapi
Change-Id: I969fc9846294a42554233cffda725797ee0185f4
2020-04-02 08:53:30 +00:00
Chalard Jean
be19bb240a Address further API council comments.
Test: FrameworksNetTests NetworkStackTests
Bug: 152238712
Copy from ag/10856890
Change-Id: I0b2526b58f0437f499ca1bbbc55fbf875003e4df
Merged-In: I0b2526b58f0437f499ca1bbbc55fbf875003e4df
2020-03-31 12:20:55 +00:00
Chalard Jean
6edf7b01e5 Update NetworkProvider calls for API council request
Bug: 152238712
Test: FrameworksNetTests
Copy from ag/10825365
Change-Id: Iec50554a9548a5cbdcf556a1a0536d9a94559793
Merged-In: Iec50554a9548a5cbdcf556a1a0536d9a94559793
2020-03-31 11:58:43 +00:00
Lorenzo Colitti
0e9e646d5b Make NetworkFactory a single-use object.
Currently, when bluetooth tethering is disabled, the bluetooth
process crashes because unregister() calls setScoreFilter() and
immediately nulls out mProvider. This crashes as soon as the
message posted by setScoreFilter() dereferences mProvider from
the handler thread.

This sort of teardown problem is very difficult to fix given
NetworkFactory's threading model where some code runs on the
handler thread and some code runs on whatever thread calls it.
Instead of complicating the code to do this, simply make it
impossible to call register() after having called unregister().
The only factory that does so today is bluetooth tethering, and
that can be trivially modified to create and register a new
factory instead.

This CL renames the unregister() method to terminate() in order
to make it clear that the object cannot be reused, and also to
ensure that no other code in the tree is unexpectedly calling
unregister().

Bug: 148635501
Test: atest FrameworksNetTests
Change-Id: Icf4c7a957e46e4ba017c0a5984e5c42a75b36ecd
Merged-In: Icf4c7a957e46e4ba017c0a5984e5c42a75b36ecd
2020-03-17 01:39:56 +09:00
Benedict Wong
3fa91de697 Merge "Add IpRange utility to convert IP ranges to IpPrefix" 2020-02-04 22:49:50 +00:00
Benedict Wong
db0915c14c 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
2020-01-29 23:08:10 -08:00
Tyler Wear
3767434b21 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
2020-01-28 16:42:22 -08:00
Tyler Wear
65e8b66875 Update CompareOrUpdateResult with NULL Check
Like CompareResult, add in null check for input objects.

Test: updated unit test
Change-Id: Iea63752ff23a5bfb1cc5cb716ec579bec6c403bf
2020-01-27 10:55:38 -08:00
Remi NGUYEN VAN
8cd3a6c287 Merge "Updates to NetworkFactory for the new NetworkAgent constructor" 2020-01-22 06:23:35 +00:00
Remi NGUYEN VAN
fd71d872b2 Merge "Statically link DnsSdTxtRecord into framework-wifi" 2020-01-22 06:23:25 +00:00
Remi NGUYEN VAN
27c8b2773a Merge "libs(net/common): Create filegroups for wifi sources" 2020-01-22 04:36:02 +00:00
Remi NGUYEN VAN
8c06cabb4f Merge "Address MacAddressUtils / NetworkFactory comments" 2020-01-22 04:35:49 +00:00
Remi NGUYEN VAN
9a208493ba Merge "Add DnsSdTxtRecord to common net static library" 2020-01-22 04:35:37 +00:00
Remi NGUYEN VAN
062272b951 Merge "Fix visibility for services-common lib" 2020-01-22 04:35:25 +00:00
Remi NGUYEN VAN
1fe6903738 Merge "Build module common libs as system_current" 2020-01-22 04:35:11 +00:00
Lorenzo Colitti
9c0c6a5c05 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
2020-01-21 17:26:48 +09:00
Lorenzo Colitti
5d9f8ed872 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
2020-01-21 15:52:34 +09:00
Chalard Jean
c9366dec3b Updates to NetworkFactory for the new NetworkAgent constructor
Bug: 138306002
Bug: 139268426
Test: atest FrameworksNetTests FrameworksWifiTests FrameworksTelephonyTests
Merged-In: If327cf0ffd917f9cb358f9ed3779da58fce40ef8
Change-Id: If327cf0ffd917f9cb358f9ed3779da58fce40ef8
(clean cherry-pick from internal branch)
2020-01-21 10:41:14 +09:00
David Su
37535278c4 Statically link DnsSdTxtRecord into framework-wifi
DnsSdTxtRecord is @hide, thus need to statically
link it into framework-wifi.

Bug: 135998869
Test: boots up and connects to wifi
Merged-In: Ic5f7decfdbc3116a15fe8da3841cc7620105996d
Change-Id: Ic5f7decfdbc3116a15fe8da3841cc7620105996d
(clean cherry-pick from internal branch)
2020-01-21 10:41:14 +09:00
Roshan Pius
864bdec16e libs(net/common): Create filegroups for wifi sources
Safer for wifi to just include the sources that it needs. Then there is
no accidental risk of un-jar-jar'ed classes showing up in it's
namespace.

Bug: 135998869
Test: Compiles
Merged-In: I2532f640fbebd4ca82be7bbb63744bcad653ac34
Change-Id: I2532f640fbebd4ca82be7bbb63744bcad653ac34
(clean cherry-pick from internal branch)
2020-01-21 10:41:14 +09:00
Remi NGUYEN VAN
fc8056d7bd Address MacAddressUtils / NetworkFactory comments
Remove unused code, and make NetworkRequest iterating order
deterministic.

Test: atest FrameworksNetTests FrameworksWifiTests \
          FrameworksTelephonyTests
Bug: 138306002

Merged-In: I1a8f2b07dd1b3ef8286c8b578ed7ae38c87bb38c
Change-Id: I1a8f2b07dd1b3ef8286c8b578ed7ae38c87bb38c
(clean cherry-pick from internal branch)
2020-01-21 10:41:14 +09:00
Aaron Huang
0331db1c2c Add DnsSdTxtRecord to common net static library
Move DnsSdTxtRecord from framework to net-utils-framework-common
for mainline support.

Bug: 139268426
Bug: 135998869
Test: build lib pass
      atest FrameworksNetTests
     ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh

Merged-In: I16c37b1c0b70bd57f38bde1171bd7d84cf3fa9ce
Change-Id: I16c37b1c0b70bd57f38bde1171bd7d84cf3fa9ce
(clean cherry-pick from internal branch)
2020-01-21 10:41:14 +09:00
Remi NGUYEN VAN
376f8d4922 Fix visibility for services-common lib
f/b/services/net should be allowed, not just f/b/services.

Test: Dependent change using the build rule builds
Bug: 138306002
Merged-In: Ide48e637df6e1c21cd7c0c688e3fef2ba1c97deb
Change-Id: Ide48e637df6e1c21cd7c0c688e3fef2ba1c97deb
(clean cherry-pick from internal branch)
2020-01-21 10:41:14 +09:00
Remi NGUYEN VAN
ce241a3b79 Build module common libs as system_current
The libraries need to build as system_current since they will be used in
modules that should build against that SDK.

As notable changes, NetworkFactory stops using a common BASE for
handler messages, as no message ID is shared with other handlers (all
public messages numbers are for receiving only). It also indexes
NetworkRequests by using the request itself in the request table; this
is fine because .equals() / .hashCode() are implemented properly, and
no request can be used that has the same ID but differences in other
members.

Test: built, flashed, WiFi and telephony working
Test: atest FrameworksNetTests FrameworksWifiTests \
          FrameworksTelephonyTests
Bug: 138306002
Merged-In: I2ea2be0039b67ba34fc26e62bdb839ab7d42300c
Change-Id: I2ea2be0039b67ba34fc26e62bdb839ab7d42300c
(clean cherry-pick from internal branch)
2020-01-21 10:41:14 +09:00
Lorenzo Colitti
e14bd343e0 Add a net-utils-telephony-common library for NetworkFactory.
A separate target is necessary for telephony as it needs to jarjar
included classes.

Test: atest FrameworksNetTests FrameworksWifiTests \
          FrameworksTelephonyTests
Bug: 138306002
Change-Id: I4b7f79fc43fe5820c94226662bee0216b61fc599
Merged-In: I4b7f79fc43fe5820c94226662bee0216b61fc599
(clean cherry-pick from internal branch)
2020-01-21 10:41:05 +09:00
Aaron Huang
57a9496f19 Add net-utils-services-common library
net-utils-services-common-srcs for files in src_servicescommon
and library net-utils-services-common could be used in services.jar
or modules.

Bug: 138306002
Bug: 139268426
Test: atest FrameworksNetTests FrameworksTelephonyTests
Change-Id: I5043a34100e9ef26148e3a0c1743363d063a3604
Merged-In: I5043a34100e9ef26148e3a0c1743363d063a3604
(clean cherry-pick from internal branch)
2020-01-21 10:40:58 +09:00
Aaron Huang
05a9dfef78 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
2020-01-13 00:43:54 +08:00
Aaron Huang
f73ff8cfce Add a new static library for mainline modules
Add a network static library for common utilities. This
library could be used by all mainline modules. Initially
create LinkPropertiesUtils and MacAddressUtils.

Bug: 139268426
Bug: 135998869
Bug: 138306002
Test: build lib pass
      atest NetworkStaticLibTests
Change-Id: I8f79e4f836819ac83007acffb55103e5d69873e0
2020-01-13 00:43:22 +08:00