Commit Graph

33 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
5d99aa78f7 Move fromStableParcelable to KeepaliveController
TcpKeepaliveController is the only user of
KeepalivePacketDataUtil.fromStableParcelable. Because of
fromStableParcelable, networkstack-client needs to depend on
net-utils-framework-commonm, which pulls a lot of unnecessary classes.
This is particularly problematic considering that networkstack-client
may need to be redistributed as a prebuilt.

Move the method to TcpKeepaliveController, simplifying dependencies.
This also shows that fromStableParcelable could be removed altogether
(or moved to tests) if TcpKeepaliveController built a
TcpKeepalivePacketData class directly.

Test: atest ConnectivityCoverageTests
Change-Id: I554318f6bcd07c73d153598a0231e9fcaf912e90
2021-11-01 13:23:27 +09:00
Aaron Huang
eaca5b1982 Add a test for NetworkIdentity.getMetered()
NetworkIdentity has adapted NET_CAPABILITY_TEMPORARILY_NOT_METERED
network capability so add a test case for it.

Ignore-AOSP-First: The parent of this change contains a CL will
conflict with internal tree so ignore AOSP first.
Bug: 183776809
Test: this
Change-Id: I2ca2a8b4db664b76a5a5ee82fcff451efd87c8ff
2021-10-26 12:16:03 +00:00
Aaron Huang
6359ebd099 Update callers to use buildTemplateMobileWithRatType with metered
The method buildTemplateMobileWithRatType is updated to take
metered as a parameter so the callers should be updated to
the new version.

Bug: 183776809
Test: atest FrameworksNetTest
Change-Id: I859514b93705f9ee4f9ae4b0bcddcb61005a78ff
Merged-In: I859514b93705f9ee4f9ae4b0bcddcb61005a78ff
2021-10-25 15:22:59 +00:00
Chalard Jean
1afb2e33e2 Increase timeouts for loopers
In coverage tests this seems to randomly fail, which suggests
some delay. Have a constant for timeout and increase its value
significantly where it makes no functional difference.

Test: FrameworksNetTests
Change-Id: I035d865f01688daf3bce30c5130ce550fa84b885
2021-10-04 18:02:17 +09:00
Chiachang Wang
2de41686e7 Remove reference when active listener is unregistered
The registered listeners are added into internal ArrayMap as a
reference but are not removed when the listeners are
unregistered. The actions for registration should be done in
pairs.

Test: atest FrameworksNetTests
Change-Id: Id9e674f5104d1471dd81224b6a271a8a92172e34
2021-09-30 10:30:35 +00:00
Chiachang Wang
859218c893 Add test for CM#[add|remove]DefaultNetworkActiveListener
Bug: 199753782
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I2520f7f5feef61502479767aa023e281d1335ee4
2021-09-30 18:29:29 +08:00
Luke Huang
38f82199ab Merge "Modify Nsd{Service,Manager}Test to conform to its change" 2021-09-29 03:35:20 +00:00
Aaron Huang
cbb4d498c2 Test a template matches mobile and mobile wildcard
Add two test cases for matchesMobile and matchesMobileWildcard

Bug: 183776809
Test: FrameworksNetTests:NetworkTemplateTest
Change-Id: I14d31071655204fe6ad36c71f7f521640e01c96e
2021-09-14 23:36:04 +08:00
Luke Huang
df75378ad4 Modify Nsd{Service,Manager}Test to conform to its change
(clean cherry-pick from downstream branch)
Test: atest NsdManagerTest NsdServiceTest
Bug: 191844585
Merged-In: I3cf658498bef5755dcb01127a94fff913b6e6298

Change-Id: I3cf658498bef5755dcb01127a94fff913b6e6298
2021-09-13 10:18:04 +09:00
Remi NGUYEN VAN
ae7508f9b5 Fix IpSecAlgorithmTest on S
The test may be run on S builds older than itself, in which case the
resource ID may not match. Query the resource ID dynamically instead of
using the constant.

IpSecAlgorithm is not updatable in S, which is why it can use
hidden/unstable platform resources, so the test could also be skipped
altogether on S. But considering that keeping it around is not very
costly yet, this change fixes it for running on S.

Bug: 197489543
Test: atest IpSecAlgorithmTest
Change-Id: I533eede3a360a8db9089e65e017b9d7453b35539
2021-08-25 18:10:22 +09:00
Remi NGUYEN VAN
800eff01d0 Merge changes from topic "sdk_int_cp"
* changes:
  Fix testSocketKeepaliveLimitTelephony on R
  Replace FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT in Connectivity
2021-07-19 09:47:21 +00:00
Remi NGUYEN VAN
ed8efa75b4 Fix jarjar-related failures in coverage tests
Instead of jarjaring the whole com.android.internal.util package, apply
the jarjar rules per-class. Jarjaring the whole package causes problems
in tests, as for example ConnectivityServiceTest depends on Vpn that
uses other internal utils as hidden API, and these should not be
jarjared.

Also avoid jarjaring INetdUnsolicitedEventListener which is used by
NetdEventListenerServiceTest, and ensure KeepalivePacketDataUtilTest
expects the right package name in toString.

Generally the problems appear because ConnectivityCoverageTests also
includes tests for classes that are not part of the connectivity module,
and use hidden APIs that refer to classes that should not be jarjared.
Some of the tests could be excluded from the coverage suite instead, but
keeping them is helpful for future modularization efforts.

Test: Build service-connectivity, dexdump classes and verify jarjared
      atest ConnectivityCoverageTests
Change-Id: Id6b7e6833d49fa03d9442d7c1c3e4dc16fb48dfc
2021-07-14 15:22:56 +09:00
lucaslin
6f77442d76 Add new network capabilities to support automotive head unit via USB
- Add a new transport type for USB and a new network capability
to support automotive head unit.
- In order to pass DnsManagerTest#testTransportTypesEqual, Android.bp
needs to link to dnsresolver_aidl_interface-V8-java. That test checks
whether the TRANSPORT types defined in NetworkCapabilities are the
same as IDnsResolver.aidl.

(clean cherry-pick of change in downstream branch history, original
change ID before project move:
Iec2df09a776d779108f95098e01b7ffdf6f8867a)

Bug: 181742019
Test: atest FrameworksNetTests

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ie438ec68577ebdaaf990795fa27f1169b0105411
2021-07-08 09:44:39 +09:00
paulhu
bee1c6d9cd Replace FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT in Connectivity
Replace all FIRST_SDK_INT usage in Connectivity because it has
been renamed to DEVICE_INITIAL_SDK_INT.

Bug: 184735771
Test: m CtsNetTestCases
Merged-In: I2f155592b08cdbf259a00b035cacb37ca9847e72
(clean cherry-pick)

Change-Id: I2f155592b08cdbf259a00b035cacb37ca9847e72
2021-07-05 14:18:26 +09:00
Benedict Wong
64619cabc1 Merge "Add tests for in-kernel VPN/VCN dataplane" 2021-07-02 18:42:15 +00:00
Benedict Wong
1117e853f9 Add tests for in-kernel VPN/VCN dataplane
This change adds relevant tests for the migrateTun functionality in
NetworkStats.

Bug: 190620024
Test: atest NetworkStatsTest
Change-Id: I33f14f2d0f71013a594fd4c8c3914a590d30ea06
2021-07-02 00:39:32 -07:00
Remi NGUYEN VAN
154cf1da20 Re-skip connectivity unit tests before S
The tests are packaged together with other tests in a common coverage
suite, so need to be individually annotated so that they are skipped
before S.

They do not need to pass on platforms older than S, because such
platforms will not updated with the code that is tested.

This applies a previous change, this time using DevSdkIgnoreRunner,
as SdkSuppress does not work as expected in branches that have a
codename 2 versions above the SDK version, as is the case in AOSP.

Bug: 187935317
Test: atest ConnectivityCoverageTests on R
      atest FrameworksNetTests on S
Change-Id: I5808d34459a4c19238baf8873afa7cf942828460
2021-06-30 12:00:28 +09:00
Remi NGUYEN VAN
284b3c028c Revert "Skip connectivity unit tests before S"
This reverts commit 05dd1ba540.

Reason for revert: Skips more tests than it should in AOSP
Bug: 192302892

Change-Id: I7c5638d8c1cc626354d240a06af758e1cdd92e94
2021-06-29 01:08:00 +00:00
Remi NGUYEN VAN
05dd1ba540 Skip connectivity unit tests before S
The tests are packaged together with other tests in a common coverage
suite, so need to be individually annotated so that they are skipped
before S.

They do not need to pass on platforms older than S, because such
platforms will not updated with the code that is tested.

Bug: 187935317
Test: atest ConnectivityCoverageTests on R
Change-Id: I10da45ae023e7f1e8cd11ec857b84346892a3fa8
2021-06-25 10:10:12 +09:00
Junyu Lai
92c29c56d7 Add more unit tests for ConnectivityManager S APIs
Test: atest android.net.ConnectivityManagerTest
Bug: 188657173
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I33612650eb89486a14fcfc440ba0c357f4bb513c
Change-Id: I33612650eb89486a14fcfc440ba0c357f4bb513c
  (cherry-picked from ag/14640282)
2021-06-24 03:20:39 +00:00
Remi NGUYEN VAN
7e23f18158 Move ConnectivityDiagnosticsManagerTest to common
The tests are also useful in CTS to ensure that the
ConnectivityDiagnosticsManager class API is implemented properly
(including behavior of the DataStallReport class for example).

Bug: 187935317
Test: atest ConnectivityDiagnosticsManagerTest
Change-Id: I86f39238054f43403f9a1e383dd2a935de84f06f
2021-06-21 19:33:28 +09:00
Remi NGUYEN VAN
c9c745f2f2 Make tests compatible with mockito-extended
This does not change the mockito library to use mockito-extended in
FrameworksNetTests, but changes the tests so that they would pass if
built against that library.

This is useful to run FrameworksNetTests in a common test suite with
other tests that use mockito-extended, for example a common connectivity
coverage test target.

The change includes increasing the test timeout in
ConnectivityServiceTest, as mockito-extended can have performance impact
(~3 times on hwasan builds). This change does not make tests run slower
in the current FrameworksNetTests suite though.

Bug: 187935317
Test: atest FrameworksNetTests
Change-Id: I61fa371e8957037075a2617a014647ff062207c6
2021-06-16 17:53:08 +09:00
Remi NGUYEN VAN
efdffa82f8 Merge "Fix KeepalivePacketDataUtilTest crash on eng build" 2021-06-15 07:08:23 +00:00
Les Lee
a0592d3e06 Add unit test when querying TYPE_WIFI + null/empty/non-null subscriberId
Starting with API level 31, the subscriberId is applicable
for the wifi network. Considering applications may use
null or an empty string as subscriberId (for instance, cts),
frameworks create MATCH_WIFI_WILDCARD NetworkTemplate when querying
wifi network with null or an empty string which is the behavior before
API level 31.

Bug: 188915450
Test: atest -c NetworkStatsManagerTest
Change-Id: Id4ae06840e1749997e970b8f1ec391060967bd47
2021-06-15 12:04:23 +08:00
Remi NGUYEN VAN
b397b5645a Fix KeepalivePacketDataUtilTest crash on eng build
The test causes a Log.wtf to be logged, because it tests a method that
should not be used after R. Mock the terrible failure handler to avoid
crashes on eng builds.

Test: atest KeepalivePacketDataUtilTest

Change-Id: Ic06a0db7fefb4acf38b66feba9b47e21f9927b1c
2021-06-14 18:13:39 +09:00
xingdai
892a0ef152 Revert "Use mockito-extended in FrameworksNetTests"
This reverts commit 98b76cc2ec.

Reason for revert: <INSERT REASONING HERE>

b/190622577

Change-Id: Ief39f82875e6fa885829aea62eed00f2f2e6774e
2021-06-10 21:41:54 +00:00
Remi NGUYEN VAN
98b76cc2ec Use mockito-extended in FrameworksNetTests
This is necessary to mock classes like BatteryStatsManager, which cannot
be used without signature permissions, and to merge the test with other
test suites that use mockito extended.

Bug: 187935317
Test: atest FrameworksNetTests
Change-Id: I5dba65d806c5d06b3ff8f633846edb911a7a44ec
2021-06-08 19:12:09 +09:00
Yan Yan
70a118d80d Merge "Improve IKEv2/IPsec VPN by proposing more IPsec algorithms" 2021-05-21 22:00:30 +00:00
Yan Yan
86783c3711 Improve IKEv2/IPsec VPN by proposing more IPsec algorithms
This commit allows IKEv2/IPsec VPN to propose more algorithms that
newly added in IpSecAlgorithm. Those new algorithms have stronger
security guarantees and better performances.

This commit also removes algorithm name validation because all
algorithms are URL encoded to ensure no special characters create
problems due to their use by VpnProfile for list or field delimiting
(e.g. rfc7539esp(chacha20,poly1305))

Bug: 185265778
Test: atest FrameworksNetTests, CtsNetTestCases
Test: All new algorithms are manually verified
Change-Id: I1de322c95aacc8924e95bcdbcfdbd1ec441de99c
2021-05-21 17:46:54 +00:00
Les Lee
e14af82411 Merge "Add metered filter for API: buildTemplateCarrier" 2021-05-18 13:01:38 +00:00
lesl
70d9ccdc9b Add metered filter for API: buildTemplateCarrier
This CL modifies NetworkTemplate#buildTemplateCarrier to force on
metered carrier network and rename to buildTemplateCarrierMetered.
This method was introduced recently and has no callers.

This method will be used in Settings and NetworkPolicyManagerService
to display and manage data usage on carrier metered networks.

Settings/NetworkPolicyManagerService will use it instead of the existing
method buildTemplateMobileAll method, which only matches metered networks.
That code will change from matching metered mobile networks to matching
metered carrier networks.

Note: The carrier metered network includes metered mobile network and
metered "merged carrier wifi network" that is a specific cerrier wifi network
which provides the same user experience as mobile.

Bug: 176396812
Test: atest -c NetworkTemplateTest
Change-Id: I7196d62bb60844458a6c4b1d94e2baccb71e15cd
2021-05-14 11:04:17 +08:00
Jayachandran C
b533550b06 QOS filter matching support based on remote address and port number for connected sockets
This CL adds APIs for telephony to perform filter matching based on
remote address if the socket is connected. Additional checks will be
performed on the state of socket to avoid the future callbacks in a
separate CL.

Bug: 181916576
Test: Manually verified in live T-Mobile network
      atest ConnectivityServiceTest
      atest com.android.internal.telephony.dataconnection.QosCallbackTrackerTest

Change-Id: I6fbd4e84c76bc4acbf4e59f06f8e86e0237bae29
2021-05-13 09:50:13 -07:00
Remi NGUYEN VAN
5ed250d90a Move net unit tests to packages/Connectivity
Move the tests together with packages/Connectivity code, so both can be
moved to packages/modules/Connectivity together.

Also reorganize unit tests in a unit/ directory, as other tests
(integration/, common/ etc.) have been added in tests/net since they
were created. This makes the directory structure consistent.

Test: atest FrameworksNetTests
Bug: 187814163
Merged-In: I254ffd1c08ec058d594b4ea55cbae5505f8497cc

Change-Id: I254ffd1c08ec058d594b4ea55cbae5505f8497cc
2021-05-13 08:30:33 +00:00