Commit Graph

3361 Commits

Author SHA1 Message Date
Orion Hodson
89213602ee Merge "Fix IpSecAlgorithmTest on S" am: 0084591e94
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1806806

Change-Id: I152aaf741e474f9cf6d39a86be9ff4800a83b1b4
2021-08-26 07:59:21 +00: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
Chalard Jean
72ed43d6dc Merge "Fix an infinite loop with network offers" am: 77992bbfbb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1800007

Change-Id: I1fe463232308fbc73753dc8d19f269142f6f8776
2021-08-20 06:39:30 +00:00
Chalard Jean
77992bbfbb Merge "Fix an infinite loop with network offers" 2021-08-20 06:17:31 +00:00
Chalard Jean
bb902a5fee Fix an infinite loop with network offers
When the avoidBadWifi configuration is false and not overridden,
a WiFi network that was validated in the past but becomes
unvalidated needs to outscore a cell network that is validated.
This is happening correctly when the stack compares two networks.
However, when the stack compares an existing network to an offer
for a cellular network, the offer was automatically considered
not to yield. This would mean the stack would be requesting cell
out of the telephony factory, only for that network to lose to
WiFi and be discarded immediately, then recreated again etc.

When there is some other reason cell should be up (such as the
"mobile always on" setting being active), this would not be
visible because the cell network would have another reason not
to be torn down.

Have offers correctly account for the current value of the
configuration and setting. This has the ranking of the offer
lose against WiFi like the actual network loses, meaning the
offer is not needed.

This also requires updating the offers whenever the value of
the setting changes.

Test: new test for this, also ConnectivityServiceTest
Bug: 195441367
Change-Id: I4fe5de98bc15bcf9bbbe25c6c7c8a7ba382f8db7
2021-08-19 22:53:41 +09:00
Aaron Huang
d347dad799 Merge "Bypass cellular battery stats test if telephony is not supported" am: 1c603e7ec3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1796589

Change-Id: I2e10702cee72d81da0564fb29f5fcddc465775c9
2021-08-19 05:54:28 +00:00
Aaron Huang
1c603e7ec3 Merge "Bypass cellular battery stats test if telephony is not supported" 2021-08-19 05:37:59 +00:00
Aaron Huang
cf79fcba3b Merge "Skip wifi stats test if link layer stats is not supported" 2021-08-19 03:23:22 +00:00
Xin Li
e534ce4c55 Merge "Merge sc-dev-plus-aosp-without-vendor@7634622" into stage-aosp-master 2021-08-17 18:15:09 +00:00
Aaron Huang
1e49ed0e84 Bypass cellular battery stats test if telephony is not supported
This test requires a cell network so the test will be failed if
the device does not support telephony. Add a condition to check
if the device supports telephony and skip cellular battery stats
test if telephony is not supported.

Bug: 196231205
Test: atest CtsNetTestCases:BatteryStatsManagerTest
Change-Id: I9ddc1da2a3f83f3fd2ab59059185f2f7a8d08701
2021-08-17 07:13:16 +00:00
Aaron Huang
114a5b2fd3 Skip wifi stats test if link layer stats is not supported
Wifi link layer is an optional feature so this test will be
failed on wifi stats check if a device does not support it.
Add a check to know if the  device supports wifi link layer
stats and skip it if it is not supported.

Bug: 195518957
Test: CtsNetTestCases:BatteryStatsManagerTest
Change-Id: I592dd5f1d6e13b020beadb11b9d913857a82e524
Merged-In: I592dd5f1d6e13b020beadb11b9d913857a82e524
2021-08-17 07:12:54 +00:00
Remi NGUYEN VAN
7262180c07 Merge "Fix NetworkCapabilities MTS on S, CTS on S+module" 2021-08-17 02:34:44 +00:00
Treehugger Robot
b8178678df Merge "Add a unit test for a bug in registerDefaultNetworkCallback." 2021-08-17 01:32:39 +00:00
Lorenzo Colitti
bbadec37d2 Add a unit test for a bug in registerDefaultNetworkCallback.
Currently, when a VPN app calls registerDefaultNetworkCallback,
it will always get its own VPN, even if the VPN app called
VpnService.Builder#addDisallowedApplication to take itself out
of the VPN's UID ranges.

Add a test for the current incorrect behaviour.

Also fix an indentation error elsewhere.

Bug: 195265065
Test: test-only change
Change-Id: Id9648ea71fc7ae10855aa311beeb7975569d17f2
2021-08-17 01:36:54 +09:00
Treehugger Robot
3d45c4e432 Merge "Fix ConnectivityDiagnosticsManagerTest for MTS" 2021-08-16 10:51:19 +00:00
Remi NGUYEN VAN
5b8e2e9935 Fix NetworkCapabilities MTS on S, CTS on S+module
restrictCapabilitiesForTestNetwork was renamed after S release to be
included in a mainline release, but this causes the MTS test to fail on
S if the Connectivity module is not updated, and CTS to fail if the
connectivity module is updated.

Mark the test as @ConnectivityModuleTest so it can be skipped on
non-connectivity module MTS tests (such as NetworkStack tests), and add
back the previous method name to keep CTS passing.

Bug: 196755836
Test: atest NetworkCapabilitiesTest
Change-Id: Ibd6c2e62e5949ec6d93e9f6e4fc05129c29b94f8
2021-08-16 18:03:37 +09:00
Treehugger Robot
1ac3e27399 Merge "Fix a flake in ConnectivityDiagnostics" 2021-08-16 09:01:58 +00:00
Chalard Jean
4da146bd2f Fix a flake in ConnectivityDiagnostics
Bug: none
Test: ConnectivityServiceTest
Change-Id: I9242226be976e7c346addcbaf7e2b0154a3829f7
2021-08-16 16:05:06 +09:00
Treehugger Robot
381ea1f1b1 Merge "Remove unused directories in Connectivity" 2021-08-16 06:43:07 +00:00
Xin Li
3ec4468fb7 Merge sc-dev-plus-aosp-without-vendor@7634622
Merged-In: I5a33f959c8ae5a34584f57508f392038e44062e7
Change-Id: Ib4e5e75ee8bbe19806bdc2f69590d164fb75774b
2021-08-14 06:31:05 +00:00
Benedict Wong
5805d3cfd2 Merge "Prevent NPEs when registering/unregistering ConnDiags CBs." 2021-08-12 20:35:39 +00:00
Chiachang Wang
43dd35b6fc Merge "The net cap value should be bit shifted before &ing" 2021-08-12 05:12:19 +00:00
Remi NGUYEN VAN
d21f0426e7 Merge "Mock connectivity resources in integration tests" 2021-08-12 04:13:57 +00:00
Remi NGUYEN VAN
b2d47200c7 Remove unused directories in Connectivity
The directories were imported by mistake from old git log in the
frameworks/base repository, and are unused.

Bug: 192995539
Test: m
Merged-In: I0d4bd06e79adedbf582d2fed551d9f1bde521fd1
Merged-In: Ie3a058b904cb2e3704c3a0725c8f720f81bb235e
Change-Id: Ic3ed5d6d25fd87b136d9ae359e7444c4b1289744
2021-08-12 10:15:10 +09:00
Remi NGUYEN VAN
7b2e5fe68e Fix ConnectivityDiagnosticsManagerTest for MTS
When run as part of NetworkStack MTS, ConnectivityDiagnosticsManagerTest
may fail as it verifies behavior that is only present will the latest
tethering (connectivity) module installed.

There is no guarantee that connectivity will be up-to-date for a given
NetworkStack version, especially considering that on R->S device upgrade
NetworkStack is likely to have been updated, but connectivity will be
the factory version. Therefore NetworkStack tests need to cover devices
that do not have an up-to-date connectivity module.

Fix the test by observing that at least on T both module will have newer
behavior. On S, accept both factory and updated behavior.

Bug: 195727283
Test: atest ConnectivityDiagnosticsManagerTest
Change-Id: Ifc0b09c884419d28817cfe619940c979ee1b0b9e
2021-08-11 21:31:37 +09:00
Chiachang Wang
c07315aa08 The net cap value should be bit shifted before &ing
The check intends to do the bit & operation. The net cap value
should be shifted against the original capabilities.

Also fix the typo in the method name.

Bug: 191918212
Test: atest FrameworksNetTests
Change-Id: I98396b2538f36fe8b29d27a544a2dfb3060bc9c5
2021-08-11 14:55:00 +08:00
Aaron Huang
17bc178920 Merge "Skip wifi stats test if link layer stats is not supported" into sc-dev am: 9ac9c1d575
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15479880

Change-Id: I5a33f959c8ae5a34584f57508f392038e44062e7
2021-08-11 03:51:12 +00:00
Aaron Huang
9ac9c1d575 Merge "Skip wifi stats test if link layer stats is not supported" into sc-dev 2021-08-11 03:33:53 +00:00
Aaron Huang
58b493abf6 Skip wifi stats test if link layer stats is not supported
Wifi link layer is an optional feature so this test will be
failed on wifi stats check if a device does not support it.
Add a check to know if the  device supports wifi link layer
stats and skip it if it is not supported.

Ignore-AOSP-First: Needs cherry-picks
Bug: 195518957
Test: CtsNetTestCases:BatteryStatsManagerTest
Change-Id: I592dd5f1d6e13b020beadb11b9d913857a82e524
2021-08-10 14:37:51 +08:00
Chiachang Wang
8787b2ab68 Remove the @Ignore annotation on testAvoidBadWifi am: 73745baa38 am: 3bac051c7a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1773885

Change-Id: Ibec81bed964cab7f9bc18cf7cabf0b52d0eeb824
2021-08-10 05:41:23 +00:00
Chiachang Wang
73745baa38 Remove the @Ignore annotation on testAvoidBadWifi
testAvoidBadWifi could pass without issue. The refactor should
also be done. The test does not need to be ignored now. Remove
the annotation to bring the test coverage back.

Bug: 178071397
Test: atest ConnectivityServiceTest
Change-Id: I5652fa817f16b8c241f1e2066a0b04ad2156a3b7
2021-08-10 05:17:29 +00:00
Lucas Lin
9e2ffd6a23 Merge "Add test for [stop|start]VpnProfile()" into sc-dev am: 2900ffbb5f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15359731

Change-Id: Ieb3774e45cacb9c9e2e3ebea1ba55c757d2679e8
2021-08-10 02:38:50 +00:00
Lucas Lin
2900ffbb5f Merge "Add test for [stop|start]VpnProfile()" into sc-dev 2021-08-10 02:28:24 +00:00
TreeHugger Robot
4e257a92ca Merge "Use dns resolver v9 in connectivity and set resolverOptions to null." into sc-dev 2021-08-06 18:35:45 +00:00
Luke Huang
2bb20e6637 Merge "Use dns resolver v9 in connectivity and set resolverOptions to null." am: d4c0d59179 am: 29b6cb0288
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1789012

Change-Id: I601a0046b5ae33cee9d267c7a4bdc1ead949ae22
2021-08-06 17:46:22 +00:00
Luke Huang
d4c0d59179 Merge "Use dns resolver v9 in connectivity and set resolverOptions to null." 2021-08-06 17:10:36 +00:00
Remi NGUYEN VAN
0ccf3fb461 Use dns resolver v9 in connectivity and set resolverOptions to null.
The resolverOptions member of the ResolverParamsParcel has never
been set by AOSP code but was only used by OEMs modifying
DnsManager. Now that DnsManager is mainline code, this is no
longer possible. So the DNS resolver introduces a new
setResolverOptions IPC to allow OEMs to set the options and makes
the resolverOptions nullable.

Make DnsManager set resolverOptions to null, to ensure that when
DnsManager calls setResolverConfiguration, it does not overwrite
any options set by the OEM.

Bug: 194048056
Test: Device boots and has connectivity
Change-Id: I310a79521f5a365e50e2c65e9dd87d9b68f105d7
Merged-In: I310a79521f5a365e50e2c65e9dd87d9b68f105d7
2021-08-06 22:21:51 +09:00
Remi NGUYEN VAN
30bebea049 Use dns resolver v9 in connectivity and set resolverOptions to null.
The resolverOptions member of the ResolverParamsParcel has never
been set by AOSP code but was only used by OEMs modifying
DnsManager. Now that DnsManager is mainline code, this is no
longer possible. So the DNS resolver introduces a new
setResolverOptions IPC to allow OEMs to set the options and makes
the resolverOptions nullable.

Make DnsManager set resolverOptions to null, to ensure that when
DnsManager calls setResolverConfiguration, it does not overwrite
any options set by the OEM.

Bug: 194048056
Test: Device boots and has connectivity
Change-Id: I310a79521f5a365e50e2c65e9dd87d9b68f105d7
2021-08-06 21:19:38 +09:00
Benedict Wong
ae00382c67 Update ConnDiags CTS test to expect validation result SKIPPED.
This CL updates ConnectivityDiagnosticsManagerTest to expect
NETWORK_VALIDATION_RESULT_SKIPPED for its TestNetworks. The tests also
expect a ConnectivityReport to be sent for all calls to
ConnectivityManager#reportNetworkConnectivity.

This change is different from the one pushed into AOSP & the mainline
modules; this allows both SKIPPED and VALID in the intermediate time
while module prebuilts are generated. MTS will enforce the stricter
SKIPPED check, while this allows both the S-release behavior and
mainline update behavior.

Bug: 162407730
Bug: 195727283
Test: atest ConnectivityDiagnosticsManagerTest
Change-Id: Ia0bf1bb53289b079f26597f09b0759a89deb681f
Merged-In: I78b78919d5b0f09348dfdd5fdb37418b8c7f861f
2021-08-06 18:08:48 +09:00
Chiachang Wang
a758f40ef9 Do callback unregistration automatically in tearDown am: 7a45f107de am: 4e0841524b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1787229

Change-Id: I8f72e741567288717bbc94e115f9aa0816cfad86
2021-08-05 14:14:02 +00:00
Chiachang Wang
7a45f107de Do callback unregistration automatically in tearDown
Ideally, unregisterCallbackQuietly() is only needed when the
callback is registered in the try block. The callbacks
registration located outside the try block should be
registered theoretically. Otherwise, it may be a bug if the
tests get the IllegalArgumentException.

Use unregisterCallbackQuietly() in all finally may cause bug
in unregisterNetworkCallback invisible.

However, it may cause different tests with different code to
do the unregistration. Thus, do a refactor to add some methods
to wrap the NetworkCallback registration. This allows the tests
to do the unregister automatically in the tearDown().

Bug: 195364778
Test: atest android.net.cts.ConnectivityManagerTest
Change-Id: If06993f643ac7aeb23638a283347c427934a2f99
2021-08-05 19:47:20 +08:00
Remi NGUYEN VAN
6c7570ae90 Mock connectivity resources in integration tests
The resources may have different values depending on devices, and
resources IDs may mismatch if the test was not built at the same time as
the installed module, so mock the resources to allow running the
integration tests on more builds.

Bug: 193847396
Test: atest FrameworksNetIntegrationTests
Merged-In: Ic33d897690a8ea84a78c01dc5f2b2e2c473d57df
Change-Id: Ic33d897690a8ea84a78c01dc5f2b2e2c473d57df
2021-08-05 16:45:59 +09:00
Remi NGUYEN VAN
0285b1d8a8 Merge changes Ic33d8976,Ib5bd74d8 into sc-dev am: 6c1e049e29
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15461111

Change-Id: Id2cb24cb61df117b509b775cc9b15d7864fc1453
2021-08-05 07:29:48 +00:00
Remi NGUYEN VAN
6c1e049e29 Merge changes Ic33d8976,Ib5bd74d8 into sc-dev
* changes:
  Mock connectivity resources in integration tests
  Add overlay options for no internet notifications
2021-08-05 07:17:31 +00:00
Remi NGUYEN VAN
0a37e72f0c Mock connectivity resources in integration tests
The resources may have different values depending on devices, and
resources IDs may mismatch if the test was not built at the same time as
the installed module, so mock the resources to allow running the
integration tests on more builds.

Bug: 193847396
Test: atest FrameworksNetIntegrationTests
Ignore-AOSP-First: cherry-pick created
Change-Id: Ic33d897690a8ea84a78c01dc5f2b2e2c473d57df
2021-08-05 07:07:38 +00:00
Treehugger Robot
bda6da7324 Merge "Catch exception of unregisterNetworkCallback" am: 740cda4358 am: 9e6b732a17
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1784389

Change-Id: I236faafdd55dd8aaad5cff2ab5b310e0e653276b
2021-08-05 02:05:44 +00:00
Treehugger Robot
740cda4358 Merge "Catch exception of unregisterNetworkCallback" 2021-08-05 01:37:30 +00:00
Chalard Jean
5234f3acc6 Fix a crash when changing preferences
The crash occurs when some app has more than half its limit
in requests that will need to be moved to some other default
network upon changing the preferences.
This will send the requests for this app over the limit
temporarily when creating new requests for the reevaluated
ones.

While ConnectivityService has a provision for making a
transaction-like addition/removal of requests that is meant
to avoid exactly this kind of crash with the transact()
method on PerUidCounter, the code only transacts on
mSystemNetworkRequestCounter. But these requests are counted
in the mNetworkRequestCounters, which is not part of the
transaction, causing the crash anyway.

To avoid the problem, this patch allows the request counters
to go over the max if and only if the system server is
updating the request counts for a UID other than its own.
This should allow only the case where ConnectivityService is
moving the requests over to the new per-uid default, while
keeping the exception when registering from an app (then the
calling UID is not the system server), or when the system
server registers its own requests (then the UID inside the
request is that of the system server).

A much better solution than this patch would be to completely
eliminate the transact() method by somehow unregistering the
old ones before creating the new ones.
However this would be a much bigger and difficult patch than
this, and much more dangerous, because callers depend on the
list of requests to find out the old requests to remove, so
they have to be created first.

Another possible clean solution would be to count the
requests not in the NRI constructor, but later. This would be
more error-prone though because it would be very easy to
create an NRI without counting it.

Bug: 192470012
Test: ConnectivityServiceTest. Improve tests so they catch
      this case.

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1781202

Merged-In: Ia482e6fbf2bf300ce6cbaca72810d394ed201b98
Change-Id: I6744d2f60d6bd664f048b532a58461c110a5b7fe
(cherry picked from commit 916aeb7b0d)
2021-08-05 10:33:12 +09:00
Chalard Jean
faa5bad6c3 Merge "Fix a crash when changing preferences" am: aeb051b962 am: 916aeb7b0d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1781202

Change-Id: I39a8e756c73c675fc0eb74f3d570d128f6ecf390
2021-08-04 12:48:02 +00:00
Chalard Jean
aeb051b962 Merge "Fix a crash when changing preferences" 2021-08-04 12:23:52 +00:00