Commit Graph

42846 Commits

Author SHA1 Message Date
Chalard Jean
3b02bc560b [automerger skipped] Fix a crash when changing preferences am: 5234f3acc6 -s ours
am skip reason: Merged-In Ia482e6fbf2bf300ce6cbaca72810d394ed201b98 with SHA-1 9473c984b8 is already in history

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

Change-Id: I1fc9639d0ac20314812f3e2c6ca1d1bd27cdae40
2021-08-05 03:16:19 +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
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
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
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
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
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
Xiao Ma
f29e0435a9 Merge "Import net-utils-device-common-netlink instead of netlink-client." am: 609e71a46c am: dd7e9e8800
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1753303

Change-Id: I4fb162f20f5816de1ee1b784cb39533362b34677
2021-08-04 07:56:23 +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
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
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
e17f852861 Merge "Throw an errno exception when open BPF map failed" am: 22d5336279 am: 84c87a49b1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1772440

Change-Id: Ib933a28d7ad5504def71e012a83b9080048fa37e
2021-08-03 09:00:34 +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
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
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
b8b59b96b6 [automerger skipped] Merge "Mock DisplayMetrics in NotificationManagerTest" am: b1263d0363 am: 79f077a0ea -s ours
am skip reason: Merged-In I3c2563d4ae4e3715d0c6270344ba8f7ef067872f with SHA-1 2afd0986d3 is already in history

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

Change-Id: I882d4e5093b83145ef743c120ca67c7d55c31d8a
2021-08-03 05:28:52 +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
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
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
Aaron Huang
263f8c6328 [automerger skipped] Add INTERACT_ACROSS_USERS_FULL to test for setCurrentProxyScriptUrl am: d9639a9bf4 -s ours
am skip reason: Merged-In I2ddff09b4c9cda1e7c5f3566662ba9cc07fffaae with SHA-1 ac8c47eef6 is already in history

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

Change-Id: I97df1e645a2787b7c2333260df5572b2ef474446
2021-07-30 10:16:06 +00: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
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
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
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
6a0a33dcf3 Remove hidden ArrayUtils usage in TetheringTest am: 3dfafbb516 am: 53b6370ec6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1779756

Change-Id: I715be738618531ae541db589255129149cf4b306
2021-07-29 07:40:07 +00:00