Commit Graph

37093 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
61eb78e1ee Merge "Mock connectivity resources in integration tests" am: d21f0426e7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1785907

Change-Id: I66252bef31ecb412b5e44ff95711ce8eba3e55e8
2021-08-12 04:26:18 +00:00
Remi NGUYEN VAN
d21f0426e7 Merge "Mock connectivity resources in integration tests" 2021-08-12 04:13:57 +00:00
Chiachang Wang
3bac051c7a Remove the @Ignore annotation on testAvoidBadWifi am: 73745baa38
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1773885

Change-Id: I6e57345d5debfb6d50e623dcb9e3e218b2057be5
2021-08-10 05:32:25 +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
Luke Huang
29b6cb0288 Merge "Use dns resolver v9 in connectivity and set resolverOptions to null." am: d4c0d59179
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1789012

Change-Id: I4fc4579247497a74489b028b040da2425415a312
2021-08-06 17:29:57 +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
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
Chiachang Wang
4e0841524b Do callback unregistration automatically in tearDown am: 7a45f107de
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1787229

Change-Id: I9b2c27c6ebe2c64c95a921a5bdc363e5d8b92e43
2021-08-05 14:02:11 +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
Treehugger Robot
9e6b732a17 Merge "Catch exception of unregisterNetworkCallback" am: 740cda4358
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1784389

Change-Id: I922ac12c29cd1539c9c284af6adb556bfe0d5976
2021-08-05 01:53:12 +00:00
Treehugger Robot
740cda4358 Merge "Catch exception of unregisterNetworkCallback" 2021-08-05 01:37:30 +00:00
Chalard Jean
916aeb7b0d Merge "Fix a crash when changing preferences" am: aeb051b962
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1781202

Change-Id: Ifa0249c059488029e5e8902cd7bbece06a6d54f2
2021-08-04 12:35:33 +00:00
Chalard Jean
aeb051b962 Merge "Fix a crash when changing preferences" 2021-08-04 12:23:52 +00:00
Remi NGUYEN VAN
aca228c07a Merge "Add overlay options for no internet notifications" am: 4f39cacbc3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1782433

Change-Id: I8b90b76f5ce6d2da701712116ed4f07284a4eef0
2021-08-04 07:59:48 +00:00
Remi NGUYEN VAN
4f39cacbc3 Merge "Add overlay options for no internet notifications" 2021-08-04 07:50:36 +00:00
Xiao Ma
dd7e9e8800 Merge "Import net-utils-device-common-netlink instead of netlink-client." am: 609e71a46c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1753303

Change-Id: Ifc983a6a584e335170a15715136d637f5abc18a9
2021-08-04 07:43:23 +00:00
Xiao Ma
609e71a46c Merge "Import net-utils-device-common-netlink instead of netlink-client." 2021-08-04 07:27:18 +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
9529651ecb Merge "Add a small comment to a test" am: 8ba4b12dff
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1779754

Change-Id: Ifd029e7d05f41b191dc927d7f56ce89f987149e6
2021-08-03 15:20:10 +00:00
Treehugger Robot
8ba4b12dff Merge "Add a small comment to a test" 2021-08-03 15:00:26 +00:00
Nucca Chen
84c87a49b1 Merge "Throw an errno exception when open BPF map failed" am: 22d5336279
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1772440

Change-Id: I280c9e505a0124ae3cd6bdbb5043f87c40f64fbd
2021-08-03 08:48:59 +00:00
Nucca Chen
22d5336279 Merge "Throw an errno exception when open BPF map failed" 2021-08-03 08:38:42 +00:00
Hungming Chen
1257e9bfff Throw an errno exception when open BPF map failed
Needed because an invalid file descriptor should notify the caller to
stop using the object.

Bug: 190523685

Test: atest BpfMaptest
Change-Id: I70fb08b54b1c0caa4be4e3f07b59bf4f2397f39d
2021-08-03 08:38:16 +00:00
Remi NGUYEN VAN
526015114e Merge "Do not use mockito to create HttpURLConnection" am: 83c77c088b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1784391

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

Change-Id: Iab23155e5e5c98e2933d142fe0ccde2a060c5eda
2021-08-03 08:06:48 +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
79f077a0ea Merge "Mock DisplayMetrics in NotificationManagerTest" am: b1263d0363
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1784388

Change-Id: I24c16d69009edbf448e05b526b1a6d39068b8fb9
2021-08-03 05:19:48 +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
7a1dfa1238 Merge "Merge NetdServiceMonitor into NetdMonitor." am: 44021f4a17
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1767648

Change-Id: I0a695f1b57a8c45cafcdb156c6dca0f9fc02e87f
2021-08-02 16:25:18 +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
2c68feb46a Merge "Force-reconnect wifi (and cell) after disabling airplane mode" am: 8a9562f2c4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1777925

Change-Id: I5cb77a2b4ee6d482edd8640ed10f2c057dc3d2f1
2021-07-30 08:17:02 +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
f831779307 Merge "Add INTERACT_ACROSS_USERS_FULL to test for setCurrentProxyScriptUrl" am: d8944c9e7b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755050

Change-Id: I1ff8c3618c33c83c3a2459443cbe4809eeac3808
2021-07-29 11:40:38 +00:00
Aaron Huang
d8944c9e7b Merge "Add INTERACT_ACROSS_USERS_FULL to test for setCurrentProxyScriptUrl" 2021-07-29 11:24:54 +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
Remi NGUYEN VAN
53b6370ec6 Remove hidden ArrayUtils usage in TetheringTest am: 3dfafbb516
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1779756

Change-Id: Ibf6c0bc564482191e5932a71c1f36248c8053593
2021-07-29 07:16:54 +00:00
Remi NGUYEN VAN
3dfafbb516 Remove hidden ArrayUtils usage in TetheringTest
Use CollectionUtils instead, which avoids using a hidden API.

Avoiding hidden API usage in tests is good in general, but this also
helps avoid jarjar problems where the com.android.internal.util package
is jarjared to some other package as some of its classes are included
in the module, and ArrayUtils cannot be found in the renamed package.

Bug: 192535368
Test: atest TetheringTest
Change-Id: I54dc8f6429d132a953ab1a674fe349fba4335936
2021-07-28 17:00:20 +09: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
Chiachang Wang
8a47dfb768 Merge "Retry and ignore ConcurrentModificationException" am: 93bda73970
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1772444

Change-Id: Iffac4efceaac6b8d27b794c638ecb3358aeeff0a
2021-07-27 09:18:12 +00:00
Chiachang Wang
93bda73970 Merge "Retry and ignore ConcurrentModificationException" 2021-07-27 09:02:56 +00:00
Chiachang Wang
eb25674b5c Retry and ignore ConcurrentModificationException
The flaky callstack shows that it hits the exception in the
initialization of HashSet. The mNetworkRequests is accessed in
the ConnectivityService handler thread except dump(). The
ConcurrentModificationException should not happen in the other
flow. Thus, retry to get the current requests when the dump()
hits the ConcurrentModificationException to prevent flaky test.

Bug: 188373832
Test: atest ConnectivityServiceTest#testDumpDoesNotCrash\
      --iteration 100
Change-Id: I9625919faf947c9488764b92093ed8105271c927
2021-07-27 15:13:52 +08:00