Commit Graph

3778 Commits

Author SHA1 Message Date
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
Remi NGUYEN VAN
893494289b Add overlay options for no internet notifications
Add an option to display the no internet dialog directly instead of
showing a notification when the notification would have been high
priority (typically when the network was explicitly selected). This is
disabled by default, but allows device manufacturers to use a slightly
more disruptive UX to ensure that the user is aware that the network has
no connectivity, and can take action.

Also add an option to show the same notification as "no internet"
instead of the "partial connectivity" notification. This is also
disabled by default, but allows device manufacturers to use the "no
internet" text if they feel that "partial connectivity" text is hard
to understand for the user.

Bug: 193847396
Test: atest NetworkNotificationManagerTest
Original-Change: https://android-review.googlesource.com/1782433
Merged-In: Ib5bd74d8cf973bf70d373dd63648c178fae0ebae
Change-Id: Ib5bd74d8cf973bf70d373dd63648c178fae0ebae
2021-08-04 08:20:24 +00:00
Remi NGUYEN VAN
f51a0ded84 Merge "Add overlay options for no internet notifications" am: 4f39cacbc3 am: aca228c07a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1782433

Change-Id: I87238b54c517a4efb11bca6e23cc2484b66f217e
2021-08-04 08:08:20 +00:00
Yintang Gu
b2cc61122c Catch exception of unregisterNetworkCallback
Catch exception of unregisterNetworkCallback to
avoid reset operations afterwards being skipped by it.

Change-Id: Idb1161abfd143fb1305982338007dac169d372b5
Bug: 195364778
2021-08-04 14:05:31 +08:00
Remi NGUYEN VAN
5dc6ca0318 Add overlay options for no internet notifications
Add an option to display the no internet dialog directly instead of
showing a notification when the notification would have been high
priority (typically when the network was explicitly selected). This is
disabled by default, but allows device manufacturers to use a slightly
more disruptive UX to ensure that the user is aware that the network has
no connectivity, and can take action.

Also add an option to show the same notification as "no internet"
instead of the "partial connectivity" notification. This is also
disabled by default, but allows device manufacturers to use the "no
internet" text if they feel that "partial connectivity" text is hard
to understand for the user.

Bug: 193847396
Test: atest NetworkNotificationManagerTest
Change-Id: Ib5bd74d8cf973bf70d373dd63648c178fae0ebae
2021-08-04 11:23:03 +09:00
Treehugger Robot
d266885202 Merge "Add a small comment to a test" am: 8ba4b12dff am: 9529651ecb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1779754

Change-Id: Iff5cd49863772e5ed1d7e0cbc2f3161fc9d3b753
2021-08-03 15:44:23 +00:00
Treehugger Robot
8ba4b12dff Merge "Add a small comment to a test" 2021-08-03 15:00:26 +00:00
Remi NGUYEN VAN
f85573a165 Merge "Do not use mockito to create HttpURLConnection" am: 83c77c088b am: 526015114e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1784391

Change-Id: I4f989b79620175486b9188965f46740619078957
2021-08-03 08:19:45 +00:00
Remi NGUYEN VAN
96019d9353 Merge "Do not apply jarjar rules on intermediate libs" am: c1e68abd6f am: 4972bf1971
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1778569

Change-Id: I4bf35535002bc1ec90913a941923f9c6e0a1c72b
2021-08-03 08:19:31 +00:00
Remi NGUYEN VAN
83c77c088b Merge "Do not use mockito to create HttpURLConnection" 2021-08-03 07:51:34 +00:00
Remi NGUYEN VAN
c1e68abd6f Merge "Do not apply jarjar rules on intermediate libs" 2021-08-03 07:50:29 +00:00
Treehugger Robot
b1263d0363 Merge "Mock DisplayMetrics in NotificationManagerTest" 2021-08-03 05:09:14 +00:00
Remi NGUYEN VAN
5d67667e9b Do not use mockito to create HttpURLConnection
Instead, use a dedicated MockConnection class.
This should improve performance of the test, and works around failures
where mockito crashes when creating mocks when openConnection is called.
The failures are believed to be a bug in mockito-extended, but are not
likely to be fixed soon.

Bug: 185083316
Test: atest FrameworksNetIntegrationTests
Change-Id: I32deaaaaa5ce9876611314c8e8b9d8bdd6325df0
2021-08-03 12:43:57 +09:00
Treehugger Robot
e89c417ce3 Merge "Merge NetdServiceMonitor into NetdMonitor." am: 44021f4a17 am: 7a1dfa1238
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1767648

Change-Id: Ia6d652a9aa23ade3f9d24fef9f05676549fb1d89
2021-08-02 16:37:56 +00:00
Treehugger Robot
44021f4a17 Merge "Merge NetdServiceMonitor into NetdMonitor." 2021-08-02 16:09:16 +00:00
Remi NGUYEN VAN
0015f04ec7 Do not apply jarjar rules on intermediate libs
Using jarjar on intermediate libraries causes issues when they are
combined with other libraries that use different jarjar rules, as the
resulting binary may contain multiple incompatible copies of the
classes. Instead, jarjar should be used on the final artifact, after
combining the libraries.

Ensure NetworkStackJarJarRules is not applied on intermediate libraries
like TetheringIntegrationTestsLib, but instead apply it on
TetheringIntegrationTests or CtsTetheringTest.

Bug: 192535368
Test: atest TetheringCoverageTests TetheringIntegrationTests \
          CtsTetheringTest
Change-Id: I248a533651984de81f676336c0e74e3788610bbb
2021-08-02 19:13:09 +09:00
Remi NGUYEN VAN
a944e70daa Mock DisplayMetrics in NotificationManagerTest
DisplayMetrics are used in some downstream branches and need to be
mocked. This avoids merge conflicts in NetworkNotificationManagerTest.

Partial cherry-pick of change IDs:
I35d28c8df341dbbac2774026c6ca749e296c0482
I1aeed1c79e4a829d8829eb08224f9b21fafc50fe

Test: atest NetworkNotificationManagerTest
Bug: 176239013
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I118ec1af615aef36293bf0b480389f766122ccab
2021-08-02 19:03:15 +09:00
Chalard Jean
9473c984b8 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.
Change-Id: Ia482e6fbf2bf300ce6cbaca72810d394ed201b98
2021-07-30 19:10:07 +09:00
Treehugger Robot
0f9aa8de01 Merge "Force-reconnect wifi (and cell) after disabling airplane mode" am: 8a9562f2c4 am: 2c68feb46a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1777925

Change-Id: Ia4d5d704ef6c398ffb9a69cbc85a10a0fff5beb8
2021-07-30 08:32:31 +00:00
Treehugger Robot
8a9562f2c4 Merge "Force-reconnect wifi (and cell) after disabling airplane mode" 2021-07-30 08:02:13 +00:00
Remi NGUYEN VAN
9ac0093c64 Force-reconnect wifi (and cell) after disabling airplane mode
Wifi is not guaranteed to connect by just disabling airplane mode
or turning on wifi. Use ensureWifiConnected in the test to force
the test to reconnect to its access point.

Bug: 194413134
Change-Id: I82540a3c6fa1d50ffa39e925bdb3d214876e2083
Test: atest ConnectivityManagerTest
2021-07-30 15:36:51 +09:00
Aaron Huang
d9639a9bf4 Add INTERACT_ACROSS_USERS_FULL to test for setCurrentProxyScriptUrl
If the test passes uid from another user which requires
INTERACT_ACROSS_USERS_FULL permission to bind service.

Bug: 192114565
Test: atest CtsNetTestCases:PacProxyManagerTest
Original-Change: https://android-review.googlesource.com/1755050
Merged-In: I2ddff09b4c9cda1e7c5f3566662ba9cc07fffaae
Change-Id: I2ddff09b4c9cda1e7c5f3566662ba9cc07fffaae
2021-07-30 05:32:00 +00:00
Aaron Huang
ac3b73a3b7 Merge "Add INTERACT_ACROSS_USERS_FULL to test for setCurrentProxyScriptUrl" am: d8944c9e7b am: f831779307
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755050

Change-Id: I908b6534034519f55a0341ae5b087e054b26d267
2021-07-29 11:51:59 +00:00
paulhu
c9ebbd1f88 Merge NetdServiceMonitor into NetdMonitor.
- This is a no-op refactor for reducing duplicated code.
- Add a global NetdMonitor which can use for every test.
- Statically import INetd permissions.

Bug: 189705071
Test: atests FrameworksNetTests
Change-Id: I78f4b46cce16ea7e25b67cf2e9470cb09f1c3e75
2021-07-29 08:33:57 +00:00
lucaslin
a9ef5a9252 Add test for [stop|start]VpnProfile()
Ignore-AOSP-First: It's a part of security patches.
Bug: 191382886
Test: atest FrameworksNetTests:VpnTest
Change-Id: Ie9c0c626f404efe0dd6dc79ca891639bc224090a
2021-07-29 05:26:47 +00:00
Chalard Jean
dfd850f5f7 Add a small comment to a test
Addresses comments on aosp/1771187

Test: comment-only change
Change-Id: I837a019708919b66b8801c37abd5aacb1d7c249f
2021-07-28 16:43:29 +09:00
Aaron Huang
ac8c47eef6 Add INTERACT_ACROSS_USERS_FULL to test for setCurrentProxyScriptUrl
If the test passes uid from another user which requires
INTERACT_ACROSS_USERS_FULL permission to bind service.

Bug: 192114565
Test: atest CtsNetTestCases:PacProxyManagerTest
Change-Id: I2ddff09b4c9cda1e7c5f3566662ba9cc07fffaae
2021-07-28 13:51:44 +08:00
Chalard Jean
0bad224c44 Fix a possible system server crash
The scenario is as follows : an app registers a network callback,
then unregisters it and dies immediately after. In this scenario,
the system server will receive a notification of the binder death
and enqueue a call to handleRemoveNetworkRequest. If the callback
unregister message has been process first, this call would result
in unlinkToDeath being called twice on the same Binder, crashing.
This patch fixes the problem by using handleReleaseNetworkRequest
instead of Remove, which looks up the NRI in a map on the handler
thread before calling Remove, returning without doing anything if
the NRI has already been removed.

Test: ConnectivityServiceTest
Test: New test for this
Bug: 194394697
Merged-In: I82a28c37450146838410bf5a059aac295a985fca
Change-Id: Iddab205cf2754d326be816e6e8e92c2cc0b95771
(cherry picked from commit d79bd5c622)
2021-07-28 04:56:19 +00:00
Sudheer Shanka
35c7136ded Merge "Verify apps cannot receive ACTION_SNOOZE_WARNING broadcast." into sc-dev am: 69fbdff0ed
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14824710

Change-Id: I44f18fc11d7113dec10f8cbd3b18fe7e1f97554f
2021-07-27 05:27:20 +00:00
Sudheer Shanka
69fbdff0ed Merge "Verify apps cannot receive ACTION_SNOOZE_WARNING broadcast." into sc-dev 2021-07-27 05:13:23 +00:00
Chalard Jean
0a5b0b19e5 Merge "Fix a possible system server crash" am: 51176d0a67 am: d79bd5c622
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1771187

Change-Id: Id71b3d6e530a053b1950ed9cecbf74a83b36b4e8
2021-07-27 05:12:15 +00:00
Chalard Jean
51176d0a67 Merge "Fix a possible system server crash" 2021-07-27 04:37:43 +00:00
Chalard Jean
5bcc838f4e Fix a possible system server crash
The scenario is as follows : an app registers a network callback,
then unregisters it and dies immediately after. In this scenario,
the system server will receive a notification of the binder death
and enqueue a call to handleRemoveNetworkRequest. If the callback
unregister message has been process first, this call would result
in unlinkToDeath being called twice on the same Binder, crashing.
This patch fixes the problem by using handleReleaseNetworkRequest
instead of Remove, which looks up the NRI in a map on the handler
thread before calling Remove, returning without doing anything if
the NRI has already been removed.

Test: ConnectivityServiceTest
Test: New test for this
Bug: 194394697
Change-Id: I82a28c37450146838410bf5a059aac295a985fca
2021-07-27 04:37:29 +00:00
Sudheer Shanka
7bbbdbd4f9 Verify apps cannot receive ACTION_SNOOZE_WARNING broadcast.
Bug: 177931370
Test: atest tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Ignore-AOSP-First: Platform changes related to this are not in AOSP yet.
Change-Id: I6d525c4d88ba01838d51a873251593281b628898
2021-07-26 15:51:09 +00:00