Commit Graph

3655 Commits

Author SHA1 Message Date
Treehugger Robot
19eaa44e9f Merge "Fix a flake with mocking." am: 527f040944 am: ec050a37ab
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1762391

Change-Id: Ie146448d14695a88688a37e5993504d527de9404
2021-07-19 12:51:20 +00:00
Treehugger Robot
527f040944 Merge "Fix a flake with mocking." 2021-07-19 12:16:18 +00:00
Chiachang Wang
6c80c3806d Specify which callback is unexpected in tests
Tests may be flaky due to the usage for assertNoCallback().
The method expects no any callback received. Based on the usage,
tests expect to not to receive certain callback, such as
onAvailable(). The network may update its linkproperties during
the test and trigger onLinkPropertiesChanged(). These callbacks
are ignorable in the tests. They should not fail the tests.

Replace the assertNoCallback to new assertNoCallbackThat with
callback type specified to deflake tests.

Bug: 192239030
Test: atest android.net.cts.ConnectivityManagerTest\
      --iterations 20
Change-Id: I1643c1ff15215c07e174dbcb664cfac2a38d5840
2021-07-19 18:41:53 +08:00
Chiachang Wang
ac059de6ad Deflake test to ensure system default network as expected
CtsNetUtils.toggleWifi() expects to receive a CONNECTIVITY_ACTION
broadcast after disconnecting from wifi if wifi is enabled.
The wifi may be connected but not validated since wifi just
turns back to connected from the previous test. In this case,
the system default netwok will not be wifi, so there is no
CONNECTIVITY_ACTION broadcast after disconnecting wifi. It
should ensure the wifi is system default network first before
proceeding with other verifications.

Bug: 192213759
Test: atest CtsNetTestCases --iterations 20
Change-Id: I82f0634883362e35b88854aae28e61b75a3cd7cc
2021-07-19 18:38:31 +08:00
Remi NGUYEN VAN
0e526cd506 Merge "Wait for next network in waitForAvailable" am: e9f65535e0 am: f38d076a83
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760698

Change-Id: Iafeca4e8049214af7871da406c2e2ddfe1c18df8
2021-07-19 10:25:11 +00: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
e9f65535e0 Merge "Wait for next network in waitForAvailable" 2021-07-19 09:47:12 +00:00
Remi NGUYEN VAN
354f5cf7d0 Merge "Skip BatteryStatsManagerTest on Q" am: e2067816e9 am: 4bcefe111a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764310

Change-Id: I4168b127b63517c80aebbf270ecd0ec0b2f122cb
2021-07-19 09:39:21 +00:00
Remi NGUYEN VAN
e2067816e9 Merge "Skip BatteryStatsManagerTest on Q" 2021-07-19 09:11:54 +00:00
Treehugger Robot
fa45b598d5 Merge "No-op cleanup" am: 21592b0d93 am: 866b9c4480
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1769285

Change-Id: Ib19a5d93e0b4e2f305a80ccf8841a36a5e7bda74
2021-07-16 16:38:19 +00:00
Chalard Jean
6d8f2fbf99 No-op cleanup
Test: atest ConnectivityServiceTest
Change-Id: Ic07c94785d97bd654ffce960e8bc2652c2dbc3d6
2021-07-16 12:02:22 +09:00
Remi NGUYEN VAN
c595c6461c Merge "Fix jarjar-related failures in coverage tests" am: e9f7f1e3d4 am: c6bf1e19a4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764731

Change-Id: If9fb707bf6e80b8937a41eb6306b2e2e0589a626
2021-07-15 09:28:55 +00:00
Remi NGUYEN VAN
1e79e9322b Merge "Use TRANSPORT_USB from the SDK" am: ca688d62d3 am: 048ef34b88
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764734

Change-Id: I7ff0480df0d7997ea68422d1fe315fa94c5a0556
2021-07-15 09:02:04 +00:00
paulhu
48291863d7 Rename PREFERENCE_PRIORITY_* to PREFERENCE_ORDER_*
Follow up aosp/1719390, change PREFERENCE_PRIORITY_* to
PREFERENCE_ORDER_*.

Bug: 171872461
Test: atest FrameworksNetTests
Change-Id: Ic96ac7bc3dba74a2020014fb83e1cb302520888c
2021-07-15 14:22:41 +08:00
Remi NGUYEN VAN
e9f7f1e3d4 Merge "Fix jarjar-related failures in coverage tests" 2021-07-15 05:19:18 +00:00
Remi NGUYEN VAN
732584bcb8 Use TRANSPORT_USB from the SDK
Stop using the stopgap TRANSPORT_USB from NetworkCapabilitiesUtil, which
is being removed.

Bug: 184158327
Test: atest NetworkCapabilitiesTest
Change-Id: I6bbb35d39ff67d6f53b389689dc9f1067e64f962
2021-07-14 16:35:11 +09:00
lucaslin
eadb0add66 Ignore checking TRANSPORT_USB when Android version is older than S
There is a new transport type - TRANSPORT_USB(8) in Android S,
so when the test tries to add this new transport type in older
Android version, it cannot pass the transport type validation and
make test fail.

(clean cherry-pick of change in downstream branch history)
Original change ID before project move:
I38816173b04ea198d99f64f45e9271ac2641e4ac

Bug: 184158327
Test: run CtsNetTestCasesLatestSdk on Android R & Q
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ib0368241771d287c09c0e4463f91122533f85a27
2021-07-14 16:28:58 +09: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
Remi NGUYEN VAN
4ba3adc4e5 Skip BatteryStatsManagerTest on Q
BatteryStatsManager did not exist on Q, so it cannot and should not be
tested there.

Bug: 193586822
Test: atest CtsNetTestCasesLatestSdk on Q
Change-Id: Ia9bef7c3438c25e1a4cb403b27cb0084bbd4f824
2021-07-14 12:06:51 +09:00
Remi NGUYEN VAN
30311abb87 Wait for next network in waitForAvailable
Tests using CtsNetUtils.TestNetworkCallback would generally assume that
waitForAvailable would return a non-null Network if onAvailable was
called after it was registered. However this is not true if a network
was available, then lost before waitForAvailable is called. This
can typically happen if wifi was disconnected just before calling
ensureWifiConnected (so wifi is being toggled).

In case onUnavailable was called, always wait for the next onAvailable
callback, so that waitForAvailable always waits for a network to be
available. So:

Old behavior:
 1) registerNetworkCallback called
 2) onAvailable called
 3) onLost called
 4) waitForAvailable called -> returns null immediately
 5) onAvailable called -> unused

New behavior:
 1) registerNetworkCallback called
 2) onAvailable called
 3) onLost called
 4) waitForAvailable called -> blocks
 5) onAvailable called -> waitForAvailable returns the network

Bug: 190913510
Test: atest CtsNetTestCases
Change-Id: I6bde82ad787371ecffd6caa950b52d90a29ab20b
2021-07-14 10:08:45 +09:00
Remi NGUYEN VAN
b240e2a86e Jarjar all classes in service-connectivity
This ensures classes are used from the service-connectivity jar, instead
of using classes from the system_server bootclasspath when there is a
name conflict.
Any developer adding a future class should do so in a subpackage of
com.android.connectivity (such as com.android.connectivity.server).
Otherwise, jarjar rules need to be added manually until b/180995093 is
fixed.

Also update current jarjar rules so that classes are jarjared to
com.android.connectivity.[original name], making it easier to find the
original source. This is consistent with the wifi module.

Bug: 193086215
Test: atest CtsNetTestCases
      dexdump on service-connectivity.jar shows no classes outside of
      com.android.connectivity and com.android.server
Original-Change: https://android-review.googlesource.com/1759589
Merged-In: I2aadeca32751267b74d4fd2fd93bb3e8c62e46c0
Change-Id: I2aadeca32751267b74d4fd2fd93bb3e8c62e46c0
2021-07-13 04:42:07 +00:00
Remi NGUYEN VAN
bfb22a0a0a Merge "Jarjar all classes in service-connectivity" am: 23c627b090 am: 793a4424d7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1759589

Change-Id: I7a55b08af6efb311af1c5385b63a450e9c343fd7
2021-07-12 23:53:14 +00:00
Remi NGUYEN VAN
23c627b090 Merge "Jarjar all classes in service-connectivity" 2021-07-12 23:29:25 +00:00
Remi NGUYEN VAN
0755183fae Jarjar all classes in service-connectivity
This ensures classes are used from the service-connectivity jar, instead
of using classes from the system_server bootclasspath when there is a
name conflict.
Any developer adding a future class should do so in a subpackage of
com.android.connectivity (such as com.android.connectivity.server).
Otherwise, jarjar rules need to be added manually until b/180995093 is
fixed.

Also update current jarjar rules so that classes are jarjared to
com.android.connectivity.[original name], making it easier to find the
original source. This is consistent with the wifi module.

Bug: 193086215
Test: atest CtsNetTestCases
      dexdump on service-connectivity.jar shows no classes outside of
      com.android.connectivity and com.android.server
Change-Id: I2aadeca32751267b74d4fd2fd93bb3e8c62e46c0
2021-07-12 19:33:33 +09:00
Chalard Jean
6519c179bd Fix a flake with mocking.
The hypothesis here is that some other thread is using
the mock between the call to when() and the call to
.thenReturn() a few lines above the failure. It's not
clear this is really the reason, but using this syntax
is safer anyway, so whether it fixes the issue or not
this is a good change.

Test: m FrameworksNetTests
Change-Id: I501d2ec8e794c67a53d7c84e290e4cc63481472d
2021-07-12 15:30:21 +09:00
Remi NGUYEN VAN
92b099b4e7 Merge "Remove hidden ArrayUtils usage in test" am: 946da61e70 am: 3c5a0f7de9
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760689

Change-Id: I9a96b7cbef135a86d13171cd5b1edfc69b68c2e0
2021-07-12 02:50:20 +00:00
Remi NGUYEN VAN
946da61e70 Merge "Remove hidden ArrayUtils usage in test" 2021-07-12 02:21:12 +00:00
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