Commit Graph

3778 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
61cc1ac9bd Remove hidden ArrayUtils usage in test
Internal utils are generally jarjared by connectivity jarjar rules, but
ArrayUtils is not actually statically linked into the tests, so this
makes the ConnectivityCoverageTests fail. FrameworksNetTests has been
fine because it does not use jarjar, but does not exercise updated code
because of that.

Remove usage of the hidden utility, as there are reasonable alternatives
with non-hidden APIs that avoid other breakages long-term.

Bug: 187935317
Test: atest ConnectivityCoverageTests:ConnectivityServiceTest
Change-Id: I8ed85b941c3d1028771a5ac33196b1509a95789d
2021-07-09 18:52:51 +09:00
Benedict Wong
30d3ba047e Prevent NPEs when registering/unregistering ConnDiags CBs.
This CL updates ConnectivityService to do null checks on received
parameters when registering and unregistering ConnectivityDiagnostics
callbacks (and also when simulating Data Stalls).

Bug: 181583568
Test: atest ConnectivityServiceTest ConnectivityDiagnosticsManagerTest
Change-Id: I7f297f10bf8d379a5d33ca5e11ca1e12132ba3a5
2021-07-08 23:45:59 -07:00
Remi NGUYEN VAN
8890ead0e0 Merge "Add new network capabilities to support automotive head unit via USB" 2021-07-09 04:38:10 +00:00
Chalard Jean
278b92f6a0 Merge "Remove exclusivity restriction of multiple preferences" 2021-07-08 03:50:34 +00:00
Remi NGUYEN VAN
9438d0fa5a Merge "Ensure wifi reconnects before waiting for metered" am: 14f0d14c14 am: 577f3e158d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1757311

Change-Id: I22f911df5cb9ba95fdfe672ddd07502fa3e19f1e
2021-07-08 01:12:18 +00: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
Remi NGUYEN VAN
14f0d14c14 Merge "Ensure wifi reconnects before waiting for metered" 2021-07-08 00:40:37 +00:00
Sudheer Shanka
a4d94a61fd Merge "Recheck if the network state in expedited job is unexpected." into sc-dev am: 1ec983c471
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15191249

Change-Id: I7dbb85aa1aae966318a4d256f48d99bed396cb02
2021-07-07 18:34:46 +00:00
Sudheer Shanka
1ec983c471 Merge "Recheck if the network state in expedited job is unexpected." into sc-dev 2021-07-07 18:20:02 +00:00
Sudheer Shanka
ce96fa05a7 Recheck if the network state in expedited job is unexpected.
Unfortunately, this could happen if there is a delay in updating the
network rules for the app hosting the job.

Bug: 179319857
Test: atest tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: I60cfd5c5946a4cd0ef5ebf0c1e56b0667cc3164d
Ignore-AOSP-First: Expedited jobs are not available in AOSP yet
2021-07-07 18:19:50 +00:00
paulhu
aa0743d7c4 Remove exclusivity restriction of multiple preferences
- Each network preference has been assigned a priority value so
  that netd can know which uid range rule has higher priority. So
  remove the restriction that all network preferences are
  exclusive.
- Add priority check when getting request for uid.

Bug: 171872461
Test: atest FrameworksNetTests
(cherry-pick from ag/14731887)
Merged-In: I6912db753c8b4a194aa7af92b01ca6dcfec10d8b

Change-Id: I6912db753c8b4a194aa7af92b01ca6dcfec10d8b
2021-07-07 23:06:43 +08:00
Paul Hu
cebf317bef Merge "Remove exclusivity restriction of multiple preferences" into sc-dev am: fd301c05c5
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14731887

Change-Id: I7df8b49e044891f69a2af7477ab9b8fab0353b50
2021-07-07 14:46:32 +00:00
Paul Hu
fd301c05c5 Merge "Remove exclusivity restriction of multiple preferences" into sc-dev 2021-07-07 14:36:22 +00:00
paulhu
de5efb90cb Remove exclusivity restriction of multiple preferences
- Each network preference has been assigned a priority value so
  that netd can know which uid range rule has higher priority. So
  remove the restriction that all network preferences are
  exclusive.
- Add priority check when getting request for uid.

Bug: 171872461
Test: atest FrameworksNetTests
Ignore-AOSP-First: Needs cherry-picks
Change-Id: I6912db753c8b4a194aa7af92b01ca6dcfec10d8b
2021-07-07 12:38:16 +08:00
Treehugger Robot
24713b1f4c Merge "Fix flake in testConnectivityDiagnosticsCallbackOnConnectivityReported" am: 1d2ad89424 am: 5c7e4c179b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755630

Change-Id: I32db3adb9f1a9c95b99ace428044e331df780821
2021-07-07 04:27:16 +00:00
Treehugger Robot
0c865b6ff9 Merge "Fix flake in testMobileDataAlwaysOn" am: 02ea3f55c1 am: b9b4ee6d0e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755251

Change-Id: I5ca65eba0f45846df6b75d11d42b67c81fb177c3
2021-07-07 04:27:08 +00:00
Treehugger Robot
1d2ad89424 Merge "Fix flake in testConnectivityDiagnosticsCallbackOnConnectivityReported" 2021-07-07 03:53:17 +00:00
Treehugger Robot
02ea3f55c1 Merge "Fix flake in testMobileDataAlwaysOn" 2021-07-07 03:52:38 +00:00
Remi NGUYEN VAN
013e9789b7 Merge changes I99ce72bd,I5a11a802 am: 527ffb6f0c am: 3499d73016
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1756971

Change-Id: Ic26bab1331de18f8b362849e275f986d0b7fa97e
2021-07-07 03:32:44 +00:00
Remi NGUYEN VAN
527ffb6f0c Merge changes I99ce72bd,I5a11a802
* changes:
  Add retries for WifiManager#connect
  Use WifiManager.connect to reconnect wifi
2021-07-07 03:07:21 +00:00
Paul Hu
51bfbbfb1b Merge "Use Netd new added/removed uid range methods" 2021-07-07 03:07:10 +00:00
paulhu
0e79d95332 Use Netd new added/removed uid range methods
Replace network[Add|Remove]UidRanges to
network[Add|Remove]UidRangesParcel. The new methods are passing
NativeUidRangeConfig which contains priority value for each uid
range rules.

Bug: 171872461
Test: atest FrameworksNetTests
Test: atest HostsideVpnTests
(cherry-pick from ag/14911836)
Merged-In: I08bbdbcb8450b08e6208fa730137348550f9e3d2

Change-Id: I08bbdbcb8450b08e6208fa730137348550f9e3d2
2021-07-07 03:06:32 +00:00
Maciej Żenczykowski
aa6e564726 remove obsolete/no-op NativeQtaguidTest am: 2aabf4138e am: 4f8727b8a7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1757412

Change-Id: Ifcfbc5d49ebffaf177ab0e5e3e500f933fd068ce
2021-07-07 02:17:15 +00:00
Remi NGUYEN VAN
c6be26e0ef Ensure wifi reconnects before waiting for metered
testGetMultipathPreference assumes that wifi will auto-reconnect after
changing its metered status, but this is not necessarily the case if the
BSSID has been blocklisted after it failed validating too many times.

Call ensureWifiConnected to force wifi to reconnect before waiting for
it to become metered.

Bug: 190913510
Test: atest ConnectivityManagerTest
Change-Id: Iafe9837b97e4d654bb0f3962d48a94c1f31bbebc
2021-07-07 10:55:39 +09:00
Maciej Żenczykowski
2aabf4138e remove obsolete/no-op NativeQtaguidTest
qtaguid is long dead - test is thus a no-op

New test logs:
  Running Tests...

  x86 CtsNativeNetTestCases
  -------------------------
  CtsNativeNetTestCases (1 Test)
  [1/1] BpfTest#bpfStructSizeTest: PASSED (0ms)

  Summary
  -------
  x86 CtsNativeNetTestCases: Passed: 1, Failed: 0, Ignored: 0, Assumption Failed: 0,

  All tests passed!

Test: atest CtsNativeNetTestCases, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9ff784dbfda0ce981904d53eacb7bc831cbe81da
2021-07-06 22:15:44 +00:00
Treehugger Robot
cba9f66098 add test for /system/etc/bpf/{netd,clatd}.o using correct struct sizes
This test is required to ensure that the system is compatible
with future updates of the tethering mainline module, which
updates BPF .o files on device.

This test must already be passing on OEM devices because otherwise
the offload.o program in the Tethering mainline module would bootloop
the device.

Bug: 190519702
Test: atest CtsNativeNetTestCases, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Original-Change: https://android-review.googlesource.com/1756440
Merged-In: Ibaedb8fcb28591ffba1506514f2305d55712a26b
Change-Id: Ibaedb8fcb28591ffba1506514f2305d55712a26b
2021-07-06 21:13:24 +00:00
Treehugger Robot
58a4324397 Merge "add test for /system/etc/bpf/{netd,clatd}.o using correct struct sizes" am: 464d0b2bdd am: b2817e8e31
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1756440

Change-Id: I4b57219491ad0fef352ea0d834f402fb429b67a2
2021-07-06 21:12:19 +00:00
Maciej Żenczykowski
bbc4ea32bc add test for /system/etc/bpf/{netd,clatd}.o using correct struct sizes
This test is required to ensure that the system is compatible
with future updates of the tethering mainline module, which
updates BPF .o files on device.

This test must already be passing on OEM devices because otherwise
the offload.o program in the Tethering mainline module would bootloop
the device.

Bug: 190519702
Test: atest CtsNativeNetTestCases, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibaedb8fcb28591ffba1506514f2305d55712a26b
2021-07-06 02:50:47 -07:00
Remi NGUYEN VAN
00407b0c1b Add retries for WifiManager#connect
Connect can error with BUSY if the framework is busy when connect is
called. Add retries so that if this happens, the connection can succeed
after the framework stops being busy.

Also log the level of scan results when several configurations are
available, and clarify the legacy broadcast assert.

Bug: 188077861
Test: atest CtsNetTestCases
Change-Id: I99ce72bd2604489cb419ea9984643b6985728461
2021-07-06 17:53:48 +09:00
Remi NGUYEN VAN
e687d5844e Fix flake in testMobileDataAlwaysOn
The internal structure backing getAllNetworks is updated after
invoking lost callbacks, so the test needs to wait for the handler
to be idle before calling getAllNetworks.

Also avoid assertions in finally clauses, as it causes confusing
error messages.

Bug: 185081944
Change-Id: I8ad5ab45a3e65b0031672e6f594b1a6d6ad5abcb
Test: atest ConnectivityServiceTest
2021-07-06 06:09:17 +00:00
Remi NGUYEN VAN
1f210f792a Fix flake in testConnectivityDiagnosticsCallbackOnConnectivityReported
The test relied on waitForIdle to ensure diagnostics callbacks were called,
but as this may require several iterations in the handler queue, this makes
the test unreliable.

Use mockito timeouts on the verify() calls instead.

Bug: 192651465
Change-Id: Iae1704af7ae3649eae301c6aee223ac753629d55
Test: atest ConnectivityServiceTest
2021-07-06 06:05:38 +00:00
Remi NGUYEN VAN
0f956db686 Merge changes from topic "am-cc17cb7d48ea4bd7adc9183dc0c381e3-sc-dev" into sc-dev
* changes:
  Apply jarjar rules on coverage tests
  Re-skip connectivity unit tests before S
  Move ConnectivityCoverageTests to general-tests
  Fix ConnectivityManagerTest initialization on Q
  Move test_mainline_modules to AndroidTest.xml
  Add ConnectivityCoverageTests to postsubmit
  Add connectivity coverage tests
  Make tests compatible with mockito-extended
  Fix KeepalivePacketDataUtilTest crash on eng build
  Update connectivity TEST_MAPPING
2021-07-06 02:42:51 +00:00
Remi NGUYEN VAN
3676ffb9af Use WifiManager.connect to reconnect wifi
Address a TODO to use WifiManager#connect to reconnect wifi, instead of
WifiManager#reconnect. #connect also clears the BSSID denylist; that
list has caused flakyness due to tests that cause the network not to
validate such as captive portal or invalid private DNS behavior tests,
causing wifi to ignore the access point in reconnect attempts.

Bug: 188077861
Test: atest CtsNetTestCasesLatestSdk

Change-Id: I5a11a802db8a4881c161e6038c1c183d2ac23a05
2021-07-06 11:30:51 +09:00
Junyu Lai
8b1a98ff38 Merge "Consider NetworkOffer is unneeded if it cannot satisfy the request" am: b028fc7cf1 am: ce077a3ad0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1731452

Change-Id: Iaff7fca5582c454e651e1ca8042d28968a0148c1
2021-07-05 09:27:16 +00:00
Junyu Lai
b028fc7cf1 Merge "Consider NetworkOffer is unneeded if it cannot satisfy the request" 2021-07-05 08:57:07 +00:00
Remi NGUYEN VAN
5f01d1d538 Merge "Move BitUtils, RingBuffer test to coretests" am: 6be4ebcb0a am: b65aea1772
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1754897

Change-Id: Ic1a8f779daf2d36dd07b1ce0a84392c74e251263
2021-07-05 05:31:16 +00:00
Remi NGUYEN VAN
aeb54b3cf8 Fix testSocketKeepaliveLimitTelephony on R
DEVICE_INITIAL_SDK_INT does not exist in older SDKs: use the pre-rename
field, FIRST_SDK_INT instead.

Fixes: 185731191
Test: atest ConnectivityManagerTest#testSocketKeepaliveLimitTelephony
Change-Id: I1fbc0f714d539a664c053cb9cf1f86c3e651c5a2
Merged-In: I1fbc0f714d539a664c053cb9cf1f86c3e651c5a2
2021-07-05 14:18:27 +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
Remi NGUYEN VAN
6be4ebcb0a Merge "Move BitUtils, RingBuffer test to coretests" 2021-07-05 05:05:34 +00:00
Remi NGUYEN VAN
0b3f20a64d Apply jarjar rules on coverage tests
Apply their respective jarjar rules on tethering and general
connectivity tests, then merge both into the coverage tests suite.
This is necessary to ensure that classes covered by tests have names
matching classes used in code.

Also fix IpConnectivityLogTest to use the module utility instead of the
hidden BitUtils, as the test would fail after internal utils are
jarjared.

Bug: 187935317
Test: atest ConnectivityCoverageTests TetheringCoverageTests
Original-Change: https://android-review.googlesource.com/1749680
Merged-In: Ib95b58dab93f7adebc445b662a6d15db1ce0e7c2
Change-Id: Ib95b58dab93f7adebc445b662a6d15db1ce0e7c2
2021-07-05 05:02:05 +00:00
Remi NGUYEN VAN
fda49a5f17 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
Original-Change: https://android-review.googlesource.com/1749684
Merged-In: I5808d34459a4c19238baf8873afa7cf942828460
Change-Id: I5808d34459a4c19238baf8873afa7cf942828460
2021-07-05 05:01:54 +00:00
Treehugger Robot
bd01bbaa92 Move ConnectivityCoverageTests to general-tests
The test suite is not signed with any particular key so
can be in general-tests. This is also required for TEST_MAPPING.

Bug: 187935317
Original-Change: https://android-review.googlesource.com/1749025
Merged-In: I9dbf98eaa28172a172e707091ea75ffdddd4971b
Change-Id: I9dbf98eaa28172a172e707091ea75ffdddd4971b
Test: TH for test mapping
2021-07-05 05:01:42 +00:00
Remi NGUYEN VAN
a6c016a65d Fix ConnectivityManagerTest initialization on Q
The test can't have TetheringManager as an argument to methods or a
field, otherwise the test runner will crash when scanning the class for
tests because TetheringManager did not exist in Q. Although
testFactoryReset is already skipped on Q, the test runner would fail
at initialization time, before starting the run.

Use CtsTetheringUtils instead. This ensures that TetheringManager does
not have method signatures or members that reference classes that do not
exist on Q, so the test runner can scan the class successfully before
starting the run.

Bug: 188851796
Test: atest ConnectivityManagerTest on Q
Original-Change: https://android-review.googlesource.com/1740779
Merged-In: I87488d0f23628a1ef2d7af0242513fcc5401d598
Change-Id: I87488d0f23628a1ef2d7af0242513fcc5401d598
2021-07-05 05:01:28 +00:00
Treehugger Robot
fb34c5861a Move test_mainline_modules to AndroidTest.xml
When an AndroidTest.xml is used, configuration needs to be in the
AndroidTest.xml file, not in the Android.bp.

This currently causes tests not to be run in TEST_MAPPING as they should
be.

Test: TH needs to test
Bug: 187935317
Original-Change: https://android-review.googlesource.com/1748157
Merged-In: Ie0aca0c64646825175769cd375bcecf65de4b4c8
Change-Id: Ie0aca0c64646825175769cd375bcecf65de4b4c8
2021-07-05 05:01:16 +00:00
Remi NGUYEN VAN
1c45a8a623 Add ConnectivityCoverageTests to postsubmit
Add the tests to both postsubmit and mainline-postsubmit.

This should allow moving the tests to presubmit in the near future,
after they have been verified to pass in postsubmit.

Bug: 187935317
Test: treehugger needs to test
Original-Change: https://android-review.googlesource.com/1736506
Merged-In: I9a05d6a300c5f777497e867d0456bc59b06eee80
Change-Id: I9a05d6a300c5f777497e867d0456bc59b06eee80
2021-07-05 05:01:02 +00:00
Remi NGUYEN VAN
168b3d19f1 Add connectivity coverage tests
The coverage tests will allow measuring code coverage for all
Connectivity+Tethering code.

This is a combination of the current TetheringCoverageTests, and
FrameworksNetTests.

Adding min_sdk_version to the test prevents it from using deprecated
IoUtils utilities. Replace it with the non-deprecated alternative.

Bug: 187935317
Test: atest ConnectivityCoverageTests
Original-Change: https://android-review.googlesource.com/1731232
Merged-In: I5366e1cc9cd6ddb41f24718246381cc2b1cc1383
Change-Id: I5366e1cc9cd6ddb41f24718246381cc2b1cc1383
2021-07-05 05:00:36 +00:00
Benedict Wong
6dd0516b56 Add tests for in-kernel VPN/VCN dataplane
This change adds relevant tests for the migrateTun functionality in
NetworkStats.

Bug: 190620024
Test: atest NetworkStatsTest
Original-Change: https://android-review.googlesource.com/1749069
Merged-In: I33f14f2d0f71013a594fd4c8c3914a590d30ea06
Change-Id: I33f14f2d0f71013a594fd4c8c3914a590d30ea06
2021-07-02 19:29:06 +00:00
Benedict Wong
f95947b96f Merge "Add tests for in-kernel VPN/VCN dataplane" am: 64619cabc1 am: 4793a34212
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1749069

Change-Id: I503c883fd61679862563abea9264d1806a59be62
2021-07-02 19:12:24 +00:00
TreeHugger Robot
0868536de9 Merge "Allow non-VPNs to have underlying networks." into sc-dev 2021-07-02 18:56:30 +00:00
Benedict Wong
64619cabc1 Merge "Add tests for in-kernel VPN/VCN dataplane" 2021-07-02 18:42:15 +00:00