Commit Graph

3655 Commits

Author SHA1 Message Date
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
Paul Hu
0ce97e66c6 Merge "Address aosp/1740740 leftover comments" am: 1975a57e83 am: 1e594fa4db
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1775928

Change-Id: Ia63b7b3720e73378ccb509116ce5366913392526
2021-07-26 10:21:28 +00:00
Paul Hu
1975a57e83 Merge "Address aosp/1740740 leftover comments" 2021-07-26 09:49:27 +00:00
TreeHugger Robot
26848924ea Merge "Change the url in testDownloadWithDownloadManagerDisallowed" into sc-dev 2021-07-26 09:04:54 +00:00
Paul Hu
deaebe4818 Merge "Rename PREFERENCE_PRIORITY_* to PREFERENCE_ORDER_*" am: 0e3b1e0b57 am: 02c83293d6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764732

Change-Id: I59b79a72ae8237997eae4b23b1a91e2cb40674a8
2021-07-26 08:35:49 +00:00
Paul Hu
0e3b1e0b57 Merge "Rename PREFERENCE_PRIORITY_* to PREFERENCE_ORDER_*" 2021-07-26 08:12:42 +00:00
paulhu
fa2f7171af Address aosp/1740740 leftover comments
- Use SystemClock.sleep instead.
- Shorten the waiting time.

Bug: 185149952
Test: atest ConnectivityManagerTest#testUidsAllowedOnRestrictedNetworks
Change-Id: I82221a61bdddf6dc8147b3a29c873ca6c8b05e93
2021-07-23 15:20:06 +08:00
Luke Huang
227f003cbe Merge "Modify Nsd{Service,Manager}Test to conform to its change" into sc-dev am: 3c20df39d0
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15320525

Change-Id: Ifd8002745d97881414c29faa05820328e4833ae6
2021-07-22 03:26:43 +00:00
Luke Huang
3c20df39d0 Merge "Modify Nsd{Service,Manager}Test to conform to its change" into sc-dev 2021-07-22 03:00:35 +00:00
Paul Hu
92c911da01 Change the url in testDownloadWithDownloadManagerDisallowed
In China, "https://www.google.com" will redirect to url
"http://www.google.cn" but cleartext traffic is default disabled
for an app. So the testDownloadWithDownloadManagerDisallowed
would failed by cleartext traffic is not permitted. Thus, change
the url in the test which is reachable in China.

Bug: 192978910
Test: atest HostsideVpnTests#testDownloadWithDownloadManagerDisallowed
Original-Change: https://android-review.googlesource.com/1771008
Merged-In: I992c3240f0e133f5b00468cbe85d1545bcf786b0
Change-Id: I992c3240f0e133f5b00468cbe85d1545bcf786b0
2021-07-21 10:17:38 +00:00
Luke Huang
952a55c62d Modify Nsd{Service,Manager}Test to conform to its change
Test: atest NsdManagerTest NsdServiceTest
Bug: 191844585
Change-Id: I3cf658498bef5755dcb01127a94fff913b6e6298
Ignore-AOSP-First: To avoid the side effect caused by automerger.
2021-07-21 08:02:26 +00:00
Paul Hu
be402a2c9d Merge "Change the url in testDownloadWithDownloadManagerDisallowed" am: 42cbf4ebab am: ca4a4a1b86
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1771008

Change-Id: I8544d24607cdab4d2e786d3a3c5646909a0e34f5
2021-07-21 07:29:01 +00:00
Aaron Huang
9a2f096870 Move battery unplug command to the beginning of the test
The test failed because the test generated traffic
before the unplug command really done.

The unplug command will eventually have onBattery changed
to true. If the traffic is generated before onBattery changed
to true, then the cellular stats won't be updated. And then,
when BatteryStatsService schedules a sync task to update the
stats which will get no delta because the stats on cellular
has already added to mLastModemNetworkStats. Thus, the test
will finally get failed.

Currently, the battery unplug command is executed after connecting
to cellular network and making sure wifi is disconnected which may
trigger battery stats service schedules sync tasks. If there are
too many tasks need to run, then change onBattery to true would
be later. Thus, move the unplug command to the beginning of the
test and add "dumpsys batterystats --write" which will wait for the
worker to finish the task before continuing. Thus, it can make sure
the batterystats are synced.

Also, the stats will be reset when the devices are unplugging after
the battery was last full or the level is 100, or have gone through
a significant charge. So, enable no-auto-reset to avoid the stats
getting reset during the test.

Bug: 192808200
Test: atest CtsNetTestCases:BatteryStatsManagerTest
Original-Change: https://android-review.googlesource.com/1769295
Merged-In: I08b38d9955c8cbb2d680e268c29368a4c0a7d144
Change-Id: I08b38d9955c8cbb2d680e268c29368a4c0a7d144
2021-07-21 07:25:55 +00:00
Paul Hu
42cbf4ebab Merge "Change the url in testDownloadWithDownloadManagerDisallowed" 2021-07-21 06:59:15 +00:00
Aaron Huang
0d80b279fe Merge "Move battery unplug command to the beginning of the test" am: 7691152162 am: ef23d08eed
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1769295

Change-Id: Ib85a821e6391b6b984d852ca79f2443f418de9c5
2021-07-21 06:44:14 +00:00
Junyu Lai
d92c090c61 Temporarily disable the test since prebuilt module is not updated am: c42a54f2a7
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15328937

Change-Id: I46fb4cad43fee89a6d4453c84db867cfc6374493
2021-07-21 03:04:50 +00:00
Aaron Huang
a3debae1eb Move battery unplug command to the beginning of the test
The test failed because the test generated traffic
before the unplug command really done.

The unplug command will eventually have onBattery changed
to true. If the traffic is generated before onBattery changed
to true, then the cellular stats won't be updated. And then,
when BatteryStatsService schedules a sync task to update the
stats which will get no delta because the stats on cellular
has already added to mLastModemNetworkStats. Thus, the test
will finally get failed.

Currently, the battery unplug command is executed after connecting
to cellular network and making sure wifi is disconnected which may
trigger battery stats service schedules sync tasks. If there are
too many tasks need to run, then change onBattery to true would
be later. Thus, move the unplug command to the beginning of the
test and add "dumpsys batterystats --write" which will wait for the
worker to finish the task before continuing. Thus, it can make sure
the batterystats are synced.

Also, the stats will be reset when the devices are unplugging after
the battery was last full or the level is 100, or have gone through
a significant charge. So, enable no-auto-reset to avoid the stats
getting reset during the test.

Bug: 192808200
Test: atest CtsNetTestCases:BatteryStatsManagerTest
Change-Id: I08b38d9955c8cbb2d680e268c29368a4c0a7d144
2021-07-21 02:14:03 +08:00
paulhu
971c5fc0f8 Change the url in testDownloadWithDownloadManagerDisallowed
In China, "https://www.google.com" will redirect to url
"http://www.google.cn" but cleartext traffic is default disabled
for an app. So the testDownloadWithDownloadManagerDisallowed
would failed by cleartext traffic is not permitted. Thus, change
the url in the test which is reachable in China.

Bug: 192978910
Test: atest HostsideVpnTests#testDownloadWithDownloadManagerDisallowed
Change-Id: I992c3240f0e133f5b00468cbe85d1545bcf786b0
2021-07-20 17:44:26 +08:00
Junyu Lai
c42a54f2a7 Temporarily disable the test since prebuilt module is not updated
This CL is subject to be reverted in a few days when the prebuilt
Connectivity module is updated.

Ignore-AOSP-First: This is for sc-dev and its downstreams only
Test: android.net.NetworkProviderTest
Bug: 189074532
Change-Id: I512552400960668c0ba91a8d997d1e2747209538
2021-07-20 05:58:08 +00:00
Junyu Lai
135f50679f Consider NetworkOffer is unneeded if it cannot satisfy the request
Currently, to prevent from network connect-teardown-loops that
caused by inaccurate reports, e.g. the provider always provides
a better network than the offer, the NetworkOffer is considered
needed if its provider is currently serving the request. This
is because there is no accurate way to know whether the offer is
corresponding to the network that is currently serving the
request.

However, if the offer cannot even satisfies the request, consider
the offer is needed does not make any sense. Since it can
never be the one that currently serving the request, nor be
the one that might beat current satisfier.

Test: android.net.NetworkProviderTest
Bug: 189074532
Original-Change: https://android-review.googlesource.com/1731452
Merged-In: Ie3ea59f980c3767782b8e6b03e401c02f664f9bd
Change-Id: Ie3ea59f980c3767782b8e6b03e401c02f664f9bd
2021-07-20 05:43:44 +00:00
Chiachang Wang
795d0c3574 Merge "Specify which callback is unexpected in tests" am: 5251171b75 am: 12a042be77
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1769289

Change-Id: I48948a8f04a2053cd24f153e1322df00fcedbf64
2021-07-20 01:49:11 +00:00
Chiachang Wang
c79dce9599 Merge "Deflake test to ensure system default network as expected" am: 575fa2f103 am: 250cf2af8a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764308

Change-Id: I34d1a75250faed18b734c68d9a0326ac46c645b4
2021-07-20 01:49:05 +00:00
Chiachang Wang
5251171b75 Merge "Specify which callback is unexpected in tests" 2021-07-20 01:20:16 +00:00
Chiachang Wang
575fa2f103 Merge "Deflake test to ensure system default network as expected" 2021-07-20 01:20:07 +00:00