Commit Graph

23453 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
23974b4da4 Remove TEST_MAPPING duplicate imports
The NetworkStack import is already in the duplicate import
clause below it.

This was added by a wrong automerge during the last project
move, and was fixed in some of the downstream branches but
not all. This change should make imports identical in all branches.

Test: treehugger needs to test TEST_MAPPING
Merged-In: I7b5fd61cd551c7010f5b8ceabbfdd04f30f648dd
Merged-In: I71723d3459c14644140b81901dac972b2a746094
Change-Id: I6cbd31506329722d7fa5195a833d7acb4e4787a0
2021-06-21 06:42:07 +00:00
Chiachang Wang
27586f8210 Merge "Add test for CM#setAcceptUnvalidated" 2021-06-16 15:17:51 +00:00
Chiachang Wang
2693dc2696 Merge "Add test for CM#setAcceptPartialConnectivity" 2021-06-16 15:17:37 +00:00
Remi NGUYEN VAN
ad7108ce34 Merge "Make tests compatible with mockito-extended" 2021-06-16 13:22:37 +00:00
Chiachang Wang
901eeb201d Add test for CM#setAcceptUnvalidated
The always bit is verified in NetworkAgentTest. There is no easy
configuration to set an explicitly selected network to accept an
unvalidated network. Verify the accepted case also in
NetworkAgentTest.

Bug: 186061922
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCasesLatestSdk
Change-Id: I803eb975fb0b6c52d55b2310293bcad407d21f42
2021-06-16 20:09:08 +08:00
Chiachang Wang
589105d385 Add test for CM#setAcceptPartialConnectivity
Bug: 186061922
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCasesLatestSdk
Change-Id: Iba312defb6f02896eac518d71d36f1ef3df3d00b
2021-06-16 20:06:15 +08:00
Junyu Lai
75090fb64e Merge changes I627dcd0f,I81abc174,Id7948d21
* changes:
  Fix expectCallback does not fail when no callback received
  Add CTS for registerBestMatchingNetworkCallback
  No-op refactoring of NetworkAgentTest
2021-06-16 11:46:34 +00:00
Lorenzo Colitti
a8afcd3b0e Merge "Correctly dump IPv4 downstream flows." 2021-06-16 11:15:30 +00:00
Remi NGUYEN VAN
54c7434f0d Merge "Remove ConnectivityServiceTest signature perms use" 2021-06-16 11:09:05 +00: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
18a979fa41 Remove ConnectivityServiceTest signature perms use
To allow unit tests to run without platform certificates, remove
signature permission usage in ConnectivityServiceTest.

This mocks permission checks done in ConnectivityService for which the
test assumed that the permission was held, and mocks calls to
BatteryStatsManager. Calls to ActivityManagerService (through
PendingIntent) are done with shell permissions as the test uses real
PendingIntent mechanics.

Bug: 187935317
Test: atest FrameworksNetTests
Change-Id: If309d653ac2e9bbcf1b94bcee6336367289df359
2021-06-16 16:32:03 +09:00
Lucas Lin
3b7c0749d5 Merge "Add a test to check if the VPN type is set or not" 2021-06-16 02:22:45 +00:00
Chiachang Wang
f3283e6b93 Merge "Ignore testFactoryReset in instant app mode" 2021-06-16 01:49:51 +00:00
Lorenzo Colitti
5f78e30839 Merge changes from topic "per-app-cts"
* changes:
  CTS tests for setOemNetworkPreference
  Update CS so that per-app OEM APIs can be tested
2021-06-16 00:47:06 +00:00
James Mattis
db143f99cf CTS tests for setOemNetworkPreference
CTS tests to validate the setOemNetworkPreference API on
ConnectivityManager. Additionally, a small bit of cleanup for
assumptions around the Wi-Fi feature.

Bug: 176496580
Bug: 176494815
Test: atest CtsNetTestCases:
android.net.cts.ConnectivityManagerTest#
testSetOemNetworkPreferenceForTestPref --iterations
atest CtsNetTestCases:
android.net.cts.ConnectivityManagerTest#
testSetOemNetworkPreferenceForTestOnlyPref --iterations

Change-Id: Ia3e4b336123b60f6df1582aca2979129112afedc
2021-06-15 12:35:18 -07:00
Lorenzo Colitti
81ede794c7 Merge "Cleanup commit to remove @SkipPresubmit and fix nits" 2021-06-15 14:54:07 +00:00
Lorenzo Colitti
a1363cbd82 Merge "Verify kernel implementation of AES-CMAC" 2021-06-15 14:53:36 +00:00
Lorenzo Colitti
8569168eda Correctly dump IPv4 downstream flows.
The current code does not print these correctly: it prints the
public address twice and then the NAT address. Fix this to print
the src, nat, and dst addresses.

Also dump the output MAC address.

Example output:

    IPv4 Upstream: [inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
      [66:f1:6f:d8:66:0a] 31(31) 192.168.146.173:48594 -> 11(rmnet_data1) 100.100.109.185:48594 -> 8.8.8.8:853 [00:00:00:00:00:00] 32305ms
      [66:f1:6f:d8:66:0a] 31(31) 192.168.146.173:45806 -> 11(rmnet_data1) 100.100.109.185:45806 -> 8.8.4.4:853 [00:00:00:00:00:00] 32305ms
    IPv4 Downstream: [inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
      [00:00:00:00:00:00] 11(rmnet_data1) 8.8.8.8:853 -> 31(31) 100.100.109.185:48594 -> 192.168.146.173:48594 [0e:a8:7f:ba:76:48] 32305ms
      [00:00:00:00:00:00] 11(rmnet_data1) 8.8.4.4:853 -> 31(31) 100.100.109.185:45806 -> 192.168.146.173:45806 [0e:a8:7f:ba:76:48] 32305ms

Test: manual
Bug: 190783768
Change-Id: I93a82064c95027c7c63cb30baf8482ecddcbd09d
2021-06-15 23:11:27 +09:00
Lorenzo Colitti
b91372a50f Merge "Don't run testGetAllNetworkStateSnapshots in instant app mode" 2021-06-15 13:29:19 +00:00
Anton Hansson
ee350966fa Merge "Add tethering bootclasspath fragment to its sdk" 2021-06-15 13:11:44 +00:00
Lucas Lin
cfc86ef0f6 Merge "Send a proxy broadcast when apps moved from/to a VPN" 2021-06-15 09:26:21 +00:00
Lorenzo Colitti
ea56397997 Merge "Verify kernel implementation of AES-XCBC" 2021-06-15 09:12:35 +00:00
Lorenzo Colitti
b8aeaa220c Merge "Verify kernel implementation of AES-CTR" 2021-06-15 09:09:05 +00:00
Nucca Chen
26f799f2d7 Merge "Improve dumping IPv4 map entries." 2021-06-15 07:41:22 +00:00
Remi NGUYEN VAN
efdffa82f8 Merge "Fix KeepalivePacketDataUtilTest crash on eng build" 2021-06-15 07:08:23 +00:00
Treehugger Robot
a79b785ff0 Merge "Dump underlying BPF traffic stats as well as higher-level stats." 2021-06-15 07:05:05 +00:00
Treehugger Robot
1dba7454b3 Merge "Add unit test when querying TYPE_WIFI + null/empty/non-null subscriberId" 2021-06-15 06:46:49 +00:00
Aaron Huang
3d35a9736f Don't run testGetAllNetworkStateSnapshots in instant app mode
Instant app mode doesn't have permission to request networks.
Thus, ignore the test in instant app mode.

Bug: 189724761
Test: CtsNetTestCases:ConnectivityManagerTest#testGetAllNetworkStateSnapshots \
      --instant
Change-Id: I2897462f4ef6c019b80a3b5159b1c41f397af8de
2021-06-15 14:17:07 +08:00
Lorenzo Colitti
69c14d531c Merge "Verify kernel implementation of ChaCha20Poly1305" 2021-06-15 05:18:24 +00:00
Lorenzo Colitti
ec5d07c59e Merge "Support algorithm configurability in PacketUtils EspHeader" 2021-06-15 05:17:51 +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
Lorenzo Colitti
70f43ee58e Improve dumping IPv4 map entries.
1. Dump both upstream and downstream rules.
2. Also dump rule last used time.

Test: manual
Bug: 190783768
Change-Id: I3fffbf4a5dea68e61349de8b41bea49b8a319f86
2021-06-15 12:54:08 +09:00
Lorenzo Colitti
704b8013f1 Dump underlying BPF traffic stats as well as higher-level stats.
This provides a better way to tell whether traffic is flowing.

Test: manual
Bug: 190783768
Change-Id: If557b0a18fc0aea1bf6a65d91547fc1930098ed0
2021-06-15 12:49:07 +09:00
Junyu Lai
63e3dedfee Fix expectCallback does not fail when no callback received
This hides 3 bugs where,
  1. In Android S, onNetworkRequested is no longer broadcasted
     by ConnectivityService in any condition. However, the test
     still passes since assertion does not fail when no callback
     received. Ignore the test on S+ devices since the behavior
     changed on S or later devices.
  2. Test network agent is not registered, but the test still
     passes.
  3. Test network agent does not fulfill the request that kept
     the network up, so the test fails since the test network
     is not needed and be torn down.

Test: android.net.NetworkProviderTest on R/S device
Bug: 189074532

Change-Id: I627dcd0f57b6ef4197d16e6c1ec0c53e675ab055
2021-06-15 03:05:30 +00:00
Junyu Lai
eb5451dd35 Add CTS for registerBestMatchingNetworkCallback
Bug: 188657173
Test: atest CtsNetTestCases:android.net.cts.NetworkAgentTest \
      CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.NetworkAgentTest \
      CtsNetTestCasesLatestSdk:android.net.cts.ConnectivityManagerTest
      on R device
Change-Id: I81abc1742a3aa965b444d0196f4eaa2393dcad1c
2021-06-15 03:05:29 +00:00
Junyu Lai
32634e9da3 No-op refactoring of NetworkAgentTest
This is a no-op refactoring of NetworkAgentTest, which makes
the create*NetworkAgent helper functions easier to use, this
includes:
  1. Rename "name" field to specifier, since it is the only
     purpose of that field.
  2. Make the callback generated with agent dedicated to the
     agent by adding specifier to support multiple agent cases.
  3. Refactor some code flow to for readability and less
     duplicated code.

Test: atest CtsNetTestCases:android.net.cts.NetworkAgentTest \
      --rerun-until-failure 100
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.NetworkAgentTest
      on R device
Bug: 188657173
Change-Id: Id7948d218b78ae0abf253ca8925e787362ac463f
2021-06-15 03:05:29 +00:00
Paul Hu
c323f6502d Merge "Add DEFAULT_NETWORK_PRIORITY constants" 2021-06-15 02:42:03 +00:00
Paul Hu
c6741064d0 Merge "Add more unit tests for mobile data preferred uids feature" 2021-06-15 01:28:19 +00:00
Yan Yan
1e071f9120 Merge "Set up and tear down test network in TestNetworkRunnable" 2021-06-15 00:36:12 +00:00
Cody Kesting
35839b48ad Merge "Keep subIds for Test NetworkCapabilities." 2021-06-14 19:22:00 +00:00
Treehugger Robot
6c0525fbd5 Merge "Fully setup test TUN iface on create." 2021-06-14 19:14:02 +00:00
Sudheer Shanka
7184887d71 Merge "Avoid waiting unnecessarily if there is no data to return." 2021-06-14 18:39:30 +00:00
Anton Hansson
a12ffacf6c Add tethering bootclasspath fragment to its sdk
This subsumes the java_sdk_library in the sdk.

Bug: 188427719
Test: build_mainline_modules.sh
Change-Id: Ib2ebb3893135b4dd91812f1f1b0915540cfd64cb
Merged-In: Ib2ebb3893135b4dd91812f1f1b0915540cfd64cb
(cherry picked from commit 3669599dec)
2021-06-14 19:23:49 +01:00
paulhu
e99137226e Add DEFAULT_NETWORK_PRIORITY constants
- Add default network priority to NetworkRequestInfo.
- The default network priority value is used when issue uid
  ranges rules to netd. Netd will use the priority value and uid
  ranges to generate corresponding ip rules specific to the given
  network preference.

Bug: 171872461
Test: atest FrameworksNetTests
Merged-In: I0ea71b348492aeb4784d487bed4cfd5d387426ba

Change-Id: I0ea71b348492aeb4784d487bed4cfd5d387426ba
2021-06-14 15:55:55 +00:00
paulhu
01f52e7cce Add more unit tests for mobile data preferred uids feature
- Add more tests for mobile data preferred uids.
- Also address leftover comments on implementation commit.

Bug: 171872461
Test: atest FrameworksNetTests
Merged-In: I63f65bffc1b8883ddfd774222e26e629d7ea1f94

Change-Id: I63f65bffc1b8883ddfd774222e26e629d7ea1f94
2021-06-14 15:53:05 +00: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
Lorenzo Colitti
473ddeaebb Merge "Correctly get uids for per-app network preferences" 2021-06-14 06:07:56 +00:00
Sudheer Shanka
f3d8c6f70e Avoid waiting unnecessarily if there is no data to return.
Bug: 189790442
Test: atest ./tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: I091991aac8eb11319bd60dc8f07124ace1ad52f1
2021-06-14 03:13:41 +00:00
Luke Huang
c9a2bdf2b9 Merge "Modify NsdServiceTest to conform to its new mechanism" 2021-06-13 15:20:52 +00:00
Frank Li
67fe28455d Merge "Add test for ConnectivityService API isPrivateDnsBroken" 2021-06-12 13:02:24 +00:00