Commit Graph

2920 Commits

Author SHA1 Message Date
Lucas Lin
3de047cb32 Merge "Add test for Vpn#prepare()" into sc-dev am: f89a629776 am: 66737a8c5d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15606164

Change-Id: Icec2f3508932abd460b2605881b54c5d0cfafb35
2021-12-27 17:35:31 +00:00
Lucas Lin
66737a8c5d Merge "Add test for Vpn#prepare()" into sc-dev am: f89a629776
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15606164

Change-Id: I6b9024a183cefba4ce7173650d78c61ee60c9ec2
2021-12-23 12:32:09 +00:00
Lucas Lin
f89a629776 Merge "Add test for Vpn#prepare()" into sc-dev 2021-12-23 12:14:46 +00:00
lucaslin
f76481568d Add test for Vpn#prepare()
Add test for Vpn#prepare() to check if the SecurityException will
be thrown when the caller is not the SYSTEM_UID and doesn't have
CONTROL_VPN permission and its package doesn't match the oldPackage
or the newPackage.

Ignore-AOSP-First: It's a part of security patches.
Bug: 191276656
Test: atest FrameworksNetTests:VpnTest
Change-Id: Ibe0b245561b00442a6377fb849603f8b9026e9c4
Merged-In: Ibe0b245561b00442a6377fb849603f8b9026e9c4
2021-12-22 07:03:31 +00:00
Les Lee
109b1246c3 [conflict] Add test case to test normalize am: f444e9d182
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/16214695

Bug: 206073065
Bug: 206448852
Test: Test: I solemnly swear I tested this conflict resolution.
Merged-In: I80c9f887cf8b4714716d657da92ed273a532ce27
Merged-In: I2f5790b9217357ddcf3f466cec1b2b1afbb47210
2021-11-16 03:46:22 +00:00
Les Lee
f444e9d182 Add test case to test normalize
Bug: 194939211
Test: atest -c NetworkTemplateTest
Merged-In: I2f5790b9217357ddcf3f466cec1b2b1afbb47210
Change-Id: I2f5790b9217357ddcf3f466cec1b2b1afbb47210
2021-11-09 10:31:56 +08:00
Aaron Huang
3a7b8f1e2b Merge "Bypass cellular battery stats test if telephony is not supported" into sc-v2-dev 2021-10-26 09:31:40 +00:00
Aaron Huang
25f4b66ced Merge "Update callers to use buildTemplateMobileWithRatType with metered" into sc-v2-dev 2021-10-25 15:09:01 +00:00
Aaron Huang
6d546271b2 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
Merged-In: I9ddc1da2a3f83f3fd2ab59059185f2f7a8d08701
2021-10-25 13:55:25 +08:00
Chalard Jean
1b0915c261 Merge changes from topic "rm-forceAllNetworkTypes-sc-v2-dev" into sc-v2-dev
* changes:
  Test a template matches mobile and mobile wildcard
  Remove ForceAllNetworkTypes from test
2021-10-25 04:50:31 +00:00
Treehugger Robot
52c5bf2b6f Exclude testGetMultipathPreference on no Wi-Fi devices
Bug: 202228414
Test: atest CtsNetTestCases
Change-Id: Ie7cd52942b93de5d0b0dd5be49d1f85afafb4ea7
Merged-In: I3112ffb816fd16b2fc7a87c35d8f95eef0144281
(cherry picked from commit db354f783e)
2021-10-21 07:04:40 +00:00
TreeHugger Robot
e3b6dc0f67 Merge "Support wifi and ethernet connection for DnsResolverTest." into sc-v2-dev 2021-10-19 12:58:20 +00:00
Treehugger Robot
ab48d029e6 Support wifi and ethernet connection for DnsResolverTest.
bug: 199675828
Test: atest CtsNetTestCases:android.net.cts.DnsResolverTest

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

Change-Id: I4deed4292a20df70cfefc7ffb3b0ad76fda3d393
Merged-In: Ie1c7522426314ccc83008b75f90a57f3a53339d4
(cherry picked from commit a974622461)
2021-10-18 07:27:13 +00:00
Chalard Jean
71d8bb764f Wait for validation of WiFi in OEM pref test
OEM_NETWORK_PREFERENCE_TEST prefers NOT_METERED&VALIDATED networks
then TEST networks. If the WiFi isn't validated by the time the
preference is set, then the TEST network is preferred and the test
fails. The best solution is simply to wait for the WiFi network to
validate before setting the preference.

Besides, some of the *wait* methods wait for validation and some
don't, creating confusion. Make this explicit on the
setWifiMeteredStatusAndWait method with a boolean argument, which
forces all users to make an explicit choice.

testSetOemNetworkPreferenceForTestOnlyPref is not affected, as
it does not change WiFi meteredness.

Ignore-AOSP-First: cherry-pick of an already-submitted AOSP change
Bug: 195365654
Test: testSetOemNetworkPreferenceForTestPref
Change-Id: I9f2bacd9b5433d7c907536af2f6c2653523271d2
Merged-In: Icb9d7ff1ca5c3d93286ea3a79c27f15630d17ee6
(cherry picked from commit ae4c414c1f)
2021-10-15 05:06:52 +00:00
Remi NGUYEN VAN
bb323e0926 Ensure wifi reconnects before waiting for metered
testGetMultipathPreference assumes that wifi will auto-reconnect after
changing its metered status, but this is not necessarily the case if the
BSSID has been blocklisted after it failed validating too many times.

Call ensureWifiConnected to force wifi to reconnect before waiting for
it to become metered.

Bug: 190913510
Test: atest ConnectivityManagerTest
Change-Id: Iafe9837b97e4d654bb0f3962d48a94c1f31bbebc
Merged-In: Iafe9837b97e4d654bb0f3962d48a94c1f31bbebc
2021-10-15 05:06:18 +00:00
Aaron Huang
21b13bb81b Update callers to use buildTemplateMobileWithRatType with metered
The method buildTemplateMobileWithRatType is updated to take
metered as a parameter so the callers should be updated to
the new version.

Ignore-AOSP-First: There's a CL in the same topic will conflict
with internal tree so ignore AOSP first.
Bug: 183776809
Test: atest FrameworksNetTest
Change-Id: I859514b93705f9ee4f9ae4b0bcddcb61005a78ff
2021-10-07 17:28:33 +08:00
Aaron Huang
35bbf12886 Test a template matches mobile and mobile wildcard
Add two test cases for matchesMobile and matchesMobileWildcard

Bug: 183776809
Test: FrameworksNetTests:NetworkTemplateTest
Change-Id: I14d31071655204fe6ad36c71f7f521640e01c96e
Merged-In: I14d31071655204fe6ad36c71f7f521640e01c96e
2021-10-05 21:09:16 +08:00
Aaron Huang
ea0732e615 Remove ForceAllNetworkTypes from test
Before sForceAllNetworkTypes is removed, the network
type and meteredness will be ignored when matchesMobile
or matchesMobileWildcard is called.

After sForceAllNetworkTypes is removed, the matches
method should check the network type and the meteredness.
Thus, if the test data contains different type or it's
not metered should not be counted.

Bug: 183776809
Test: FrameworksNetTests
Change-Id: Ie7194495d26c0f5ef7a247733f43c64688626c67
Merged-In: Ie7194495d26c0f5ef7a247733f43c64688626c67
2021-10-05 21:08:57 +08:00
TreeHugger Robot
ec388da126 Merge "Ensure calling package name and uid are matched" into sc-qpr1-dev am: e93efb6f96
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15618365

Change-Id: Ia3c730176ac21b90c2b44ad1cd56304d6b85ac4f
2021-10-01 14:21:12 +00:00
TreeHugger Robot
e93efb6f96 Merge "Ensure calling package name and uid are matched" into sc-qpr1-dev 2021-10-01 14:08:56 +00:00
Kenneth Magic
903a564340 Add CtsHostsideNetworkTests deps to sts. am: da973a6d9d am: 928655800a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15612573

Change-Id: I96e45f3483b2254208e8ff399b931a726028f5fd
2021-09-08 13:39:14 +00:00
paulhu
b2c286816d Ensure calling package name and uid are matched
CS#requestRouteToHostAddress enforcing change permission doesn't
check whether the calling package belongs to calling uid. This
can be used to check whether package name exists or not without
permission. Thus, add a check to ensure calling package name and
uid are matched.

Bug: 193801134
Test: atest FrameworksNetTests CtsNetTestCases
Ignore-AOSP-First: Security fix
Change-Id: I980f1c68b5321601aa40da29e283fb4dd717d5de
2021-08-26 13:23:03 +00:00
Kenneth Magic
da973a6d9d Add CtsHostsideNetworkTests deps to sts.
This fixes the missing apk errors when running this module as
part of sts.

Ignore-AOSP-First: Platform changes related to this are not in AOSP yet.
Test: run sts-engbuild-no-spl-lock -m CtsHostsideNetworkTests
Bug: 195961795
Change-Id: I9a9a2d20ce637663790df42e22b0c8023cf7bc3e
2021-08-18 19:38:56 +00:00
Aaron Huang
47b4556fc0 Merge "Skip wifi stats test if link layer stats is not supported" into sc-dev am: 9ac9c1d575 am: 1a1ab4a4ab
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15479880

Change-Id: I98f7f0051761e8f912f980cb23a6c7cde536a181
2021-08-11 04:07:05 +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
Lucas Lin
2883684925 Merge "Add test for [stop|start]VpnProfile()" into sc-dev am: 2900ffbb5f am: 849c3fb997
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15359731

Change-Id: I8a0f348953405ee38358739525fa9825cd3e0670
2021-08-10 02:55:36 +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
54ecd83b7e Merge "Use dns resolver v9 in connectivity and set resolverOptions to null." into sc-dev am: 4e257a92ca
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15482197

Change-Id: Ifc568e19ddd3462895749efaeaa8e944a40efda2
2021-08-06 19:00:13 +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
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
Benedict Wong
1bea0853e9 Update ConnDiags CTS test to expect validation result SKIPPED. am: ae00382c67
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15474912

Change-Id: Ib4d746ad90c6d22db7630885bcfac4d78e6d231d
2021-08-06 11:44:51 +00: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
Remi NGUYEN VAN
574e8d3573 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: I119dc7433cd8f5fa2ba1f997f7adef8985a3b492
2021-08-05 07:30:42 +00:00
Remi NGUYEN VAN
43bb3a2856 Add overlay options for no internet notifications am: 893494289b
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15461110

Change-Id: Ic49531aa88bceeb4f75b3b3ef071df7acef1a71f
2021-08-05 07:30:39 +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
Chalard Jean
2172622826 Fix a crash when changing preferences am: 5234f3acc6
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15461334

Change-Id: I2b3df58034ea683ce96e88b84243ecf1ffd0d9b4
2021-08-05 03:18:23 +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
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
Aaron Huang
652265c32a Add INTERACT_ACROSS_USERS_FULL to test for setCurrentProxyScriptUrl am: d9639a9bf4
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15426434

Change-Id: I6ec322a0997468f8f27cc390b284e7762f762856
2021-07-30 10:17:01 +00: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
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
f2fdd14157 Merge "Fix a possible system server crash" into sc-dev am: 63fd8aebbd
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15390814

Change-Id: Id836300346ba9e31e7832ee92d484b8834209079
2021-07-28 08:10:06 +00: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
4c47ac0a47 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: If29e21293208bd5e8c0c1bb59c7b331c5b4fd226
2021-07-27 05:29:49 +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
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
TreeHugger Robot
a900a8c853 Merge "Change the url in testDownloadWithDownloadManagerDisallowed" into sc-dev am: 26848924ea
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15327430

Change-Id: I891c673d3840ac4b27ae0cd07709af4938987fa9
2021-07-26 09:22:15 +00:00
TreeHugger Robot
26848924ea Merge "Change the url in testDownloadWithDownloadManagerDisallowed" into sc-dev 2021-07-26 09:04:54 +00:00