Commit Graph

404 Commits

Author SHA1 Message Date
Chalard Jean
6b2f09272c Make yield-to-bad-wifi behavior backward compatible with R
Yielding cell wins to exiting wifi (whether good or bad).
It loses to bad wifi that's not exiting.

In R, yielding to bad wifi only affects wifis that are
unvalidated, but a wifi that is exiting should still be
dropped in favor of a cell that yields to bad wifi.

I had misunderstood the policy and implemented it wrong.
Now it's implemented right, and has careful tests.

Test: new tests for this
Bug: 186458024
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Ib8637100d491e72a2edb837584ce55b7dda58524
Change-Id: Ib8637100d491e72a2edb837584ce55b7dda58524
  (cherry-picked from ag/14486203)
2021-06-24 03:33:05 +00:00
Luke Huang
18e0d49a44 Fix the comments from aosp/1719018
1. Test {start,stop}-service
2. Add waitForIdle

Bug: 181810560
Test: atest NsdServiceTest
Original-Change: https://android-review.googlesource.com/1729691
Merged-In: I0953887d1d92a644a29a2e80521469c8cc2aa2fc
Change-Id: I0953887d1d92a644a29a2e80521469c8cc2aa2fc
2021-06-23 09:55:11 +00:00
Chiachang Wang
fad30e3d84 Provide a way to override the avoid bad wifi configuration
ConnectivityManager.setAvoidUnvalidated only works if the
config_networkAvoidBadWifi configuration is set to 0 and the
NETWORK_AVOID_BAD_WIFI setting is unset. There is no easy way
for a testing app to temporary set a test value to verify the
behavior of the API. Thus, add a mechanism to allow test app
to set a period of time to temporary unstrict the resource
configuration, i.e. Temporary simulate config_networkAvoidBadWifi
configured to 0.

Bug: 186061922
Test: atest CtsNetTestCases FrameworksNetTests
Original-Change: https://android-review.googlesource.com/1733788
Merged-In: If772078c61a9b12926f104d5dfc9c9071e844732
Change-Id: If772078c61a9b12926f104d5dfc9c9071e844732
2021-06-23 08:42:47 +00:00
Remi NGUYEN VAN
ff55aeb916 Remove ConnectivityServiceTest signature perms use
To allow unit tests to run without platform certificates, remove
signature permission usage in ConnectivityServiceTest.

This mocks permission checks done in ConnectivityService for which the
test assumed that the permission was held, and mocks calls to
BatteryStatsManager. Calls to ActivityManagerService (through
PendingIntent) are done with shell permissions as the test uses real
PendingIntent mechanics.

Bug: 187935317
Test: atest FrameworksNetTests
Merged-In: If309d653ac2e9bbcf1b94bcee6336367289df359
Change-Id: If309d653ac2e9bbcf1b94bcee6336367289df359

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

(cherry picked from commit 595dda3604)

Change-Id: Idb19b0f7cb87bb4d9de7a0b1a0e4128c2d6b9c6d
2021-06-23 08:39:38 +00:00
Luke Huang
226281b698 Merge "Fix the comments from aosp/1719018" am: 0c20c4901f am: 9adee2f105
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1729691

Change-Id: I65dd02aacd50acb92d15c76457f8415b0cc8b73e
2021-06-23 06:29:30 +00:00
Luke Huang
0c20c4901f Merge "Fix the comments from aosp/1719018" 2021-06-23 03:36:02 +00:00
Chiachang Wang
403836f671 Merge "Provide a way to override the avoid bad wifi configuration" am: 38e8c2c94b am: 4ef85d615b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1733788

Change-Id: Ibe05bc988f0020eec8485023c3529bcc1696bd80
2021-06-23 02:08:44 +00:00
Chiachang Wang
38e8c2c94b Merge "Provide a way to override the avoid bad wifi configuration" 2021-06-23 00:48:17 +00:00
Chiachang Wang
6eac9fb787 Provide a way to override the avoid bad wifi configuration
ConnectivityManager.setAvoidUnvalidated only works if the
config_networkAvoidBadWifi configuration is set to 0 and the
NETWORK_AVOID_BAD_WIFI setting is unset. There is no easy way
for a testing app to temporary set a test value to verify the
behavior of the API. Thus, add a mechanism to allow test app
to set a period of time to temporary unstrict the resource
configuration, i.e. Temporary simulate config_networkAvoidBadWifi
configured to 0.

Bug: 186061922
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: If772078c61a9b12926f104d5dfc9c9071e844732
2021-06-22 14:54:02 +08:00
Remi NGUYEN VAN
3d25f6e8a7 Merge "Add connectivity coverage tests" am: cc79d7c0f8 am: 68114fe408
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1731232

Change-Id: I6cc7f3a3abe97fccc59e14e77e99a0843f3363bb
2021-06-21 13:56:37 +00:00
Remi NGUYEN VAN
cc79d7c0f8 Merge "Add connectivity coverage tests" 2021-06-21 10:55:33 +00:00
Luke Huang
05b013c83f Fix the comments from aosp/1719018
1. Test {start,stop}-service
2. Add waitForIdle

Bug: 181810560
Test: atest NsdServiceTest
Change-Id: I0953887d1d92a644a29a2e80521469c8cc2aa2fc
2021-06-21 04:54:33 +00:00
Lucas Lin
1b64ae6b87 Merge "Send a proxy broadcast when apps moved from/to a VPN" into sc-dev 2021-06-18 02:47:24 +00:00
Lucas Lin
950a65f8cc Send a proxy broadcast when apps moved from/to a VPN
When the apps moved from/to a VPN, a proxy broadcast is needed to
inform the apps that the proxy might be changed since the default
network satisfied by the apps might also changed.
Since the framework does not track the defautlt network of every
apps, thus, this is done when:
  1. VPN connects/disconnects.
  2. List of uids that apply to the VPN has changed.
While 1 is already covered by the current design, the CL implements
2 in order to fulfill the case that different networks have
different proxies.

Bug: 178727215
Test: atest FrameworksNetTests
Original-Change: https://android-review.googlesource.com/1717735
Merged-In: Ifa103dd66394026d752b407a1bee740c9fcdad2b
Change-Id: Ifa103dd66394026d752b407a1bee740c9fcdad2b
2021-06-17 11:10:46 +00:00
Sangcheol Lee
1e5d742596 Use appId instead of uid
Multiple user's ares of mApps are not initialized in startMonitoring(),
so mApps.get(uid) of multi-user's app returns null in onPackageAdded().
As the result, permission of system uid is updated to "Network" and
any system application cannot use dedicated apn like IMS.
Using appId avoids this problem.

Bug: 168932048
Test: atest FrameworksNetTests

Signed-off-by: Sangcheol Lee <goodsc.lee@samsung.com>
Change-Id: Ib8ea2185d8056bddb2ca5a8006f83afb3cffc9f4
2021-06-17 13:35:58 +09:00
Remi NGUYEN VAN
aec3a5e548 Merge "Make tests compatible with mockito-extended" am: ad7108ce34 am: c3d789bff1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1737400

Change-Id: Ie5b04c5ea05d330dcc97d098720b08d4797927de
2021-06-16 13:56:01 +00:00
Remi NGUYEN VAN
ad7108ce34 Merge "Make tests compatible with mockito-extended" 2021-06-16 13:22:37 +00:00
Remi NGUYEN VAN
595dda3604 Merge "Remove ConnectivityServiceTest signature perms use" am: 54c7434f0d am: 96ad425c5e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1736615

Change-Id: Ifd8c397644f5fc680b34905882ec287bb43c1e1b
2021-06-16 11:37:53 +00:00
Remi NGUYEN VAN
54c7434f0d Merge "Remove ConnectivityServiceTest signature perms use" 2021-06-16 11:09:05 +00:00
Remi NGUYEN VAN
fe20e1317d Add connectivity coverage tests
The coverage tests will allow measuring code coverage for all
Connectivity+Tethering code.

This is a combination of the current TetheringCoverageTests, and
FrameworksNetTests.

Adding min_sdk_version to the test prevents it from using deprecated
IoUtils utilities. Replace it with the non-deprecated alternative.

Test: atest ConnectivityCoverageTests
Change-Id: I5366e1cc9cd6ddb41f24718246381cc2b1cc1383
2021-06-16 19:45:20 +09:00
Remi NGUYEN VAN
c9c745f2f2 Make tests compatible with mockito-extended
This does not change the mockito library to use mockito-extended in
FrameworksNetTests, but changes the tests so that they would pass if
built against that library.

This is useful to run FrameworksNetTests in a common test suite with
other tests that use mockito-extended, for example a common connectivity
coverage test target.

The change includes increasing the test timeout in
ConnectivityServiceTest, as mockito-extended can have performance impact
(~3 times on hwasan builds). This change does not make tests run slower
in the current FrameworksNetTests suite though.

Bug: 187935317
Test: atest FrameworksNetTests
Change-Id: I61fa371e8957037075a2617a014647ff062207c6
2021-06-16 17:53:08 +09:00
Remi NGUYEN VAN
18a979fa41 Remove ConnectivityServiceTest signature perms use
To allow unit tests to run without platform certificates, remove
signature permission usage in ConnectivityServiceTest.

This mocks permission checks done in ConnectivityService for which the
test assumed that the permission was held, and mocks calls to
BatteryStatsManager. Calls to ActivityManagerService (through
PendingIntent) are done with shell permissions as the test uses real
PendingIntent mechanics.

Bug: 187935317
Test: atest FrameworksNetTests
Change-Id: If309d653ac2e9bbcf1b94bcee6336367289df359
2021-06-16 16:32:03 +09:00
James Mattis
b7ca034306 Update CS so that per-app OEM APIs can be tested
Updates to ConnectivityService so that the set OEM network preference
per app APIs can be tested via CTS.

Bug: 176496580
Bug: 176494815
Test: atest FrameworksNetTests
atest FrameworksNetIntegrationTests
atest CtsNetTestCasesLatestSdk

Original-Change: https://android-review.googlesource.com/1723050
Merged-In: I5a47dcece31749293f080af060218d827082eb67
Change-Id: I5a47dcece31749293f080af060218d827082eb67
2021-06-16 03:54:47 +00:00
James Mattis
39a42aefc6 Update CS so that per-app OEM APIs can be tested am: fa270db5f7 am: 6c54d5e4c4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723050

Change-Id: I5f8bc3a60d92e86047debd9363e5dddf06da6ee8
2021-06-16 01:30:05 +00:00
James Mattis
6c54d5e4c4 Update CS so that per-app OEM APIs can be tested am: fa270db5f7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723050

Change-Id: Ib5937d0fd732f915416e957299e739fe10d0bf55
2021-06-16 01:11:26 +00:00
Lorenzo Colitti
5f78e30839 Merge changes from topic "per-app-cts"
* changes:
  CTS tests for setOemNetworkPreference
  Update CS so that per-app OEM APIs can be tested
2021-06-16 00:47:06 +00:00
Lorenzo Colitti
659a0e145f Correctly get uids for per-app network preferences
Per-app network functionality assumed all apps were installed for user 0
which is not always the case. This fix will address that by checking for
the existance of an app for all users and adding it to the per-app
network preference as was originally intended. Prior, no apps were
included if they were not installed for user 0 even if they were
available for another user such as user 10 in automotive.

Bug: 189838408
Test: atest FrameworksNetTests
atest FrameworksNetIntegrationTests
atest CtsNetTestCases

Original-Change: https://android-review.googlesource.com/1723617
Merged-In: I7d75cdb02041e7a202254be2eaeca6c2b02d7c29
Change-Id: I7d75cdb02041e7a202254be2eaeca6c2b02d7c29
2021-06-15 21:56:13 +00:00
Lucas Lin
c3b4cf2e19 Merge "Send a proxy broadcast when apps moved from/to a VPN" am: cfc86ef0f6 am: f7aa7c51ee
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1717735

Change-Id: I12ec4b1c5e4123c9e13219ec0e83858bf1ec09ea
2021-06-15 09:32:28 +00:00
Lucas Lin
cfc86ef0f6 Merge "Send a proxy broadcast when apps moved from/to a VPN" 2021-06-15 09:26:21 +00:00
Luke Huang
fcc69726ed Merge "Modify NsdServiceTest to conform to its new mechanism" into sc-dev 2021-06-15 04:52:43 +00:00
paulhu
e99137226e Add DEFAULT_NETWORK_PRIORITY constants
- Add default network priority to NetworkRequestInfo.
- The default network priority value is used when issue uid
  ranges rules to netd. Netd will use the priority value and uid
  ranges to generate corresponding ip rules specific to the given
  network preference.

Bug: 171872461
Test: atest FrameworksNetTests
Merged-In: I0ea71b348492aeb4784d487bed4cfd5d387426ba

Change-Id: I0ea71b348492aeb4784d487bed4cfd5d387426ba
2021-06-14 15:55:55 +00:00
paulhu
01f52e7cce Add more unit tests for mobile data preferred uids feature
- Add more tests for mobile data preferred uids.
- Also address leftover comments on implementation commit.

Bug: 171872461
Test: atest FrameworksNetTests
Merged-In: I63f65bffc1b8883ddfd774222e26e629d7ea1f94

Change-Id: I63f65bffc1b8883ddfd774222e26e629d7ea1f94
2021-06-14 15:53:05 +00:00
Paul Hu
ab4b8bc600 Merge "Add DEFAULT_NETWORK_PRIORITY constants" into sc-dev am: dcba997adf
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14731886

Change-Id: Iabe8738dc2579bd89f6be377666c4e7a9178b1a6
2021-06-14 15:33:35 +00:00
Paul Hu
dcba997adf Merge "Add DEFAULT_NETWORK_PRIORITY constants" into sc-dev 2021-06-14 15:17:23 +00:00
Paul Hu
31c7026ff9 Merge "Add more unit tests for mobile data preferred uids feature" into sc-dev am: 7d5fa3da7d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14731884

Change-Id: I5a97d3caea19c51597c63319bbb8a720c7f91977
2021-06-14 14:47:46 +00:00
Paul Hu
7d5fa3da7d Merge "Add more unit tests for mobile data preferred uids feature" into sc-dev 2021-06-14 14:29:29 +00:00
Luke Huang
a46c4d2726 Modify NsdServiceTest to conform to its new mechanism
Adapt NsdServiceTest to its new mechanism for starting/stopping daemons.
Also, add a new test for the new self-cleanup mechanism.

Bug: 181810560
Test: atest NsdServiceTest
Original-Change: https://android-review.googlesource.com/1719018
Merged-In: I4c485a5d8fb4d6f52d82633a579bce4feb5c6375
Change-Id: I4c485a5d8fb4d6f52d82633a579bce4feb5c6375
2021-06-14 06:53:51 +00:00
Lorenzo Colitti
9088465b13 Merge "Correctly get uids for per-app network preferences" am: 473ddeaebb am: d9c5536026
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723617

Change-Id: I1b99d78702c91ce3e4c69de95e09a0c1e7d7e4b5
2021-06-14 06:32:56 +00:00
Lorenzo Colitti
473ddeaebb Merge "Correctly get uids for per-app network preferences" 2021-06-14 06:07:56 +00:00
Luke Huang
614299c262 Merge "Modify NsdServiceTest to conform to its new mechanism" am: c9a2bdf2b9 am: 31f8527bca
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1719018

Change-Id: I2fb0ac98d2f7ae2a2fab3af7bc657f013b59bbc2
2021-06-13 16:52:06 +00:00
Luke Huang
c9a2bdf2b9 Merge "Modify NsdServiceTest to conform to its new mechanism" 2021-06-13 15:20:52 +00:00
Lorenzo Colitti
beb7d92cbc Don't send onLinkPropertiesChanged after onLost for 464xlat.
Currently, when a network that uses 464xlat is torn down,
NetworkCallbacks will receive onLinkPropertiesChanged after
onLost. This is confusing and incorrect.

The incorrect callback is sent because handleLinkProperties
checks that the netId of the agent still exists, not that the
NetworkAgent is still registered. This is normally correct,
because the NetworkAgent is removed from mNetworkAgentInfos and
the netId are removed from mNetworkForNetId by the same method,
disconnectAndDestroyNetwork.

In this specific case it's not correct, because the call to
handleUpdateLinkProperties is from disconnectAndDestroyNetwork
itself via nai.clatd.update and calls Nat464Xlat#stop.

No other callers of handleUpdateLinkProperties are affected
because:

- EVENT_NETWORK_PROPERTIES_CHANGED is called only by
  maybeHandleNetworkAgentMessage, which first checks that the
  NetworkAgent is registered.
- handlePrivateDnsSettingsChanged only looks at registered
  NetworkAgents (it loops over mNetworkAgentInfos).
- handlePrivateDnsValidationUpdate, handleNat64PrefixEvent and
  handleCapportApiDataUpdate call getNetworkAgentInfoForNetId,
  which will correctly determine that the agent is no longer
  registered, since they run on the handler thread and thus
  cannot run at the same time as disconnectAndDestroyNetwork.

The existing code contains a check for the netId being current.
This is intended to ensure that an update from a NetworkAgent
cannot affect another agent with the same Network. This extra
check is not necessary, because code running on the handler
thread can never observe a NetworkAgent in mNetworkAgentInfos
unless mNetworkForNetId maps that NetworkAgent's Network to that
NetworkAgent. This is because mNetworkForNetId is updated by the
same methods as mNetworkAgentInfos, and those updates occur on
the handler thread. So all code on the handler thread will see
those two as consistent.

Bug: 176496580
Test: atest FrameworksNetTests CtsNetTestCases HostsideVpnTests
Original-Change: https://android-review.googlesource.com/1727829
Merged-In: I944f4c6ad36206bdccd85a6ea7ef71324a29c685
Change-Id: I944f4c6ad36206bdccd85a6ea7ef71324a29c685
2021-06-11 13:46:33 +00:00
Lorenzo Colitti
cfa262d8b8 Improve test coverage for disconnecting networks with clat.
Ensure that NetworkCallbacks and netd operations are accounted
for. Also add a test for the spurious onLinkPropertiesChanged
callback that is currently send out after onLost.

Bug: 176496580
Test: atest ConnectivityServiceTest
Original-Change: https://android-review.googlesource.com/1729093
Merged-In: I69cf58bc87dfe55ea359a2cd76167d03fe2c953d
Change-Id: I69cf58bc87dfe55ea359a2cd76167d03fe2c953d
2021-06-11 13:44:46 +00:00
paulhu
c2198778ab Add DEFAULT_NETWORK_PRIORITY constants
- Add default network priority to NetworkRequestInfo.
- The default network priority value is used when issue uid
  ranges rules to netd. Netd will use the priority value and uid
  ranges to generate corresponding ip rules specific to the given
  network preference.

Bug: 171872461
Test: atest FrameworksNetTests
Ignore-AOSP-First: Needs cherry-picks
Change-Id: I0ea71b348492aeb4784d487bed4cfd5d387426ba
2021-06-11 14:22:33 +08:00
Remi NGUYEN VAN
9134dac0b1 Merge "Revert "Use mockito-extended in FrameworksNetTests"" am: a6c06af0fa am: 6f6035a29e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1734372

Change-Id: I8c8a2f734c433c0cf6fe158fcbf26a75a82d0d0a
2021-06-11 01:56:43 +00:00
Remi NGUYEN VAN
a6c06af0fa Merge "Revert "Use mockito-extended in FrameworksNetTests"" 2021-06-11 01:26:44 +00:00
Remi NGUYEN VAN
45dd5391ed Merge changes I8d15b626,I993e8da9 am: d15e52eca9 am: 3cc611d69a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1733772

Change-Id: Ice0291696167275ae20a423b74671d252fe09fb4
2021-06-11 00:05:52 +00:00
xingdai
892a0ef152 Revert "Use mockito-extended in FrameworksNetTests"
This reverts commit 98b76cc2ec.

Reason for revert: <INSERT REASONING HERE>

b/190622577

Change-Id: Ief39f82875e6fa885829aea62eed00f2f2e6774e
2021-06-10 21:41:54 +00:00
paulhu
7ed70a944c Add more unit tests for mobile data preferred uids feature
- Add more tests for mobile data preferred uids.
- Also address leftover comments on implementation commit.

Bug: 171872461
Test: atest FrameworksNetTests
Ignore-AOSP-First: Needs cherry-picks
Change-Id: I63f65bffc1b8883ddfd774222e26e629d7ea1f94
2021-06-11 00:09:45 +08:00
Remi NGUYEN VAN
3cd164225b Revert "Remove ConnectivityServiceTest signature perms use"
This reverts commit bba8ec0d43.

Reason for revert: Broken tests b/190622577

Change-Id: I8d15b626fcd8da67094ebf461d381b3922f69024
2021-06-10 15:05:47 +00:00