Commit Graph

392 Commits

Author SHA1 Message Date
lucaslin
6f77442d76 Add new network capabilities to support automotive head unit via USB
- Add a new transport type for USB and a new network capability
to support automotive head unit.
- In order to pass DnsManagerTest#testTransportTypesEqual, Android.bp
needs to link to dnsresolver_aidl_interface-V8-java. That test checks
whether the TRANSPORT types defined in NetworkCapabilities are the
same as IDnsResolver.aidl.

(clean cherry-pick of change in downstream branch history, original
change ID before project move:
Iec2df09a776d779108f95098e01b7ffdf6f8867a)

Bug: 181742019
Test: atest FrameworksNetTests

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ie438ec68577ebdaaf990795fa27f1169b0105411
2021-07-08 09:44:39 +09:00
paulhu
92f128c51c Force only system uid can set uids allowed on restricted networks
- Check whether calling UID/PID is system_server.
- For CTS test, enforce NETWORK_SETTINGS permission otherwise if
  it's a debug build.

Bug: 175199465
Test: atest FrameworksNetTests
Test: atest ConnectivityManagerTest#testUidsAllowedOnRestrictedNetworks
Merged-In: I175a831671d3e52460d28203b09f6c0dda56b61c

Change-Id: I175a831671d3e52460d28203b09f6c0dda56b61c
2021-07-02 20:04:50 +08:00
Remi NGUYEN VAN
b2e919f9da Remove workarounds to use core platform API
Core platform API stubs are now correctly included in module_current and
system_server_current, so workarounds used to use such APIs can be
removed.

OsCompat and InetAddressCompat were only necessary because manually
adding the stubs did not resolve the problem for classes that had
public API stubs, which shadowed the module API stubs.

The manual stubs dependency was already removed in another change. Also
remove the service jar dependency on android_system_server_stubs_current
as it is already included in sdk_version system_server_current.

Bug: 183097033
Test: atest CtsNetTestCases

Change-Id: Id448be03b679f832edb24f1b77f471227faf5268
2021-07-02 10:05:07 +09:00
Orion Hodson
f15f2769b4 Merge "Remove dependency on stable.core.platform.api.stubs" 2021-07-01 18:53:17 +00:00
Chiachang Wang
f1e09ef031 Trigger the network score update after setting test allow bad wifi
Avoid bad wifi design has to apply in both wifi and cellular
networks. Cellular network should contain POLICY_YIELD_TO_BAD_WIFI
policy, then system default network could stay in the wifi after
wifi becomes unvalidated.

The testing API only update the value but not trigger the avoid
bad wifi callback to update the score in the existing cellular
network. Thus, if the cellular network is connected before
setting the overridden value, the yield to bad wifi policy will
not updated to cellular network. The system default network will
still switch from unvalidated wifi network to cellular network
even wifi network is connected with the avoid bad wifi policy.

Update to trigger a reevaluation to update the score in each
NetworkAgent in the ConnectivityService.

Bug: 192149168
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest\
      #testSetAvoidUnvalidated --rerun-until-failure 100
Change-Id: Ie0f777d0030b66dd306332496192c74f6c183284
2021-06-30 16:41:59 +08:00
Victor Chang
c3815ee358 Remove dependency on stable.core.platform.api.stubs
Bug: 183097033
Test: m droid
Change-Id: I06cbc7e06e112d61575fad6ad0783348c94e3df2
2021-06-29 22:31:05 +01:00
Paul Hu
6160d60b2e Merge "Add ConnectivitySettingsManagerTest" 2021-06-23 01:36:16 +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
paulhu
236a992cd0 Add ConnectivitySettingsManagerTest
- Add tests for ConnectivitySettingsManager.
- Also address leftover javadoc comments.

Bug: 182538166
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases
Change-Id: I8161c1bca84b41964578d59ee5d6ab07b2380707
2021-06-22 03:00:51 +00:00
Lucas Lin
c12550b9f4 Merge "Call ConnectivitySettingsUtils to set/get private DNS related settings" 2021-06-21 19:12:33 +00:00
lucaslin
8962128a0b Call ConnectivitySettingsUtils to set/get private DNS related settings
ConnectivitySettingsManager and CtsNetUtils are doing the same
thing to set/get private DNS related settings.
To prevent making the duplication code in two places, move the
body to frameworks/libs/net and call it.

Bug: 185311744
Test: atest CtsNetTestCases CtsNetTestCasesLatestSdk
Change-Id: I3272c825b86ec30c3d0bf4097088c653e668461b
2021-06-21 16:39:08 +08:00
Remi NGUYEN VAN
e4d1cd970e Initialize TetheringManager lazily
Many applications use ConnectivityManager without needing
TetheringManager (or without calling legacy ConnectivityManager methods
that delegate to TetheringManager), so initializing TetheringManager
when ConnectivityManager is created wastes resources.

This is especially true considering that TetheringManager is not trivial
to initialize (worst case scenario it starts a thread and does multiple
Binder requests), and ConnectivityManager is created in ActivityThread
when setting up the app proxy on startup.

Bug: 190556328
Test: atest FrameworksNetTests CtsNetTestCases TetheringTests
Change-Id: I2ba7b8f2b9e1c934cfb082776b8d643f2f2c17e5
2021-06-21 10:59:14 +09:00
Lucas Lin
cfc86ef0f6 Merge "Send a proxy broadcast when apps moved from/to a VPN" 2021-06-15 09:26:21 +00:00
Cody Kesting
dd346918b4 Keep subIds for Test NetworkCapabilities.
This CL updates NetworkCapabilities to retain configured subscription
IDs for Test NetworkCapabilities. Previously, they were cleared in
restrictCapabilitiesForTestNetwork().

Bug: 182291467
Bug: 189125789
Test: atest Ikev2VpnTest IpSecManagerTunnelTest
Test: atest CtsVcnTestCases
Change-Id: I0e1bc617910c9e8ac7b431572f276b1611acc1cb
2021-06-09 11:50:53 -07:00
Remi NGUYEN VAN
de3c20ecb5 Merge changes from topic "conn_test_defaults_cp"
* changes:
  Move connectivity test defaults to tests/common
  Add framework-connectivity-test-defaults
2021-06-09 00:59:17 +00:00
Junyu Lai
5b15e700bb Merge changes from topics "enable-policy-ranking", "sendNetworkScore"
* changes:
  Adjust a test for policy scoring
  Enable policy ranking
  Add CTS to verify NetworkAgent#setLingerDuration
  Allow network providers to set the linger duration.
  Fix nascent timer never get removed
  [NS13] Remove the last usage of the legacy int
  Add documentation
  Use filter from CollectionUtils.
  Fix a bug where updates of offers won't find existing offers
  [NS12] Address comments on NS09
  [NS11] Fix yieldToBadWifi over the policy scoring
  Add doc for NetworkScore#getLegacyInt
  Expose sendNetworkScore that takes a NetworkScore
2021-06-08 22:34:44 +00:00
Remi NGUYEN VAN
3912c80e99 Add framework-connectivity-test-defaults
The defaults follow the same pattern as framework-wifi-test-defaults to
allow unit tests to build against hidden API in Connectivity.

(clean cherry-pick of history in downstream branch)

Bug: 171540887
Test: m
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ia8531f672820fcc8968f98494903e486c4e42652
2021-06-08 19:54:27 +09:00
Remi NGUYEN VAN
674ce27fee Merge changes from topic "framework-conn-stub-cp"
* changes:
  Reference framework-connectivity stubs explicitly
  Merge framework-connectivity impl and stub targets
2021-06-08 09:15:15 +00:00
Remi NGUYEN VAN
12474fdab5 Merge "Add min_sdk_version to connectivity targets" 2021-06-08 08:44:21 +00:00
Paul Hu
7cba5f4163 Merge "Move UIDS_ALLOWED_ON_RESTRICTED_NETWORKS setting" 2021-06-08 07:23:39 +00:00
Remi NGUYEN VAN
e70cd84601 Merge framework-connectivity impl and stub targets
Instead of using api_only: true, use a single java_sdk_library to
generate both framework-connectivity stubs and
framework-connectivity.impl.

Original change (project moved):
I76d7cf1ba31a3f38ae6b9facbf1b668860c8c165

Bug: 183600168
Test: m
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I07d8c4c92c91939b8e8890fdb5db517b75faee2c
2021-06-08 15:24:05 +09:00
Remi NGUYEN VAN
da43ef0b68 Add min_sdk_version to connectivity targets
All targets need min_sdk_version 30 to be included in the tethering
APEX. They will actually never be used on SDK 30 and are only loaded on
31, but this is necessary to be included in com.android.tethering.

Original change (project moved):
I190fd1f3c9fabff057d0a2bd7f45b63a4fe447b3

This also includes changes to the lint baseline to make it match actual
filenames.

Bug: 171540887
Test: m
Test: m lint-check
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I24198565bc98d85d0c036be02e3a6c311b5bb2a3
2021-06-08 15:23:40 +09:00
Remi NGUYEN VAN
8665528151 Merge "Revert "Add min_sdk_version to connectivity targets"" 2021-06-08 04:52:03 +00:00
Remi NGUYEN VAN
ccd2a6aeb4 Revert "Add min_sdk_version to connectivity targets"
This reverts commit 0b900c91f6.

Reason for revert: Broke errorprone: b/190454846

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I21de7e7e06daa5f4a688b4246986f8d44da97c91
Fixes: 190454846
2021-06-08 04:50:01 +00:00
Remi NGUYEN VAN
bf7cffa7a0 Merge "Add min_sdk_version to connectivity targets" 2021-06-08 04:38:30 +00:00
Remi NGUYEN VAN
8bf9411324 Merge "Add lint baseline to address NewApi errors" 2021-06-08 03:28:26 +00:00
Remi NGUYEN VAN
0b900c91f6 Add min_sdk_version to connectivity targets
All targets need min_sdk_version 30 to be included in the tethering
APEX. They will actually never be used on SDK 30 and are only loaded on
31, but this is necessary to be included in com.android.tethering.

Original change (project moved):
I190fd1f3c9fabff057d0a2bd7f45b63a4fe447b3

Bug: 171540887
Test: m
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I3db00acc79b11058a1c235916b9bfe6c759afda5
2021-06-08 09:28:26 +09:00
Pedro Loureiro
8f16b39776 Add lint baseline to address NewApi errors
We are enabling a new lint check where the min sdk != compile sdk.
It has produced a lot of errors and adding the baseline file(s)
allows us to continue work without introducing more problems.

This is a partial cherry-pick of change merged downstream.

Bug: 150847901

Test: m lint-check
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I214d60e858b7c03885d4d1c9a083e67a9340b4fe
2021-06-08 09:28:12 +09:00
Chalard Jean
550b5214d3 Allow network providers to set the linger duration.
Test: atest CtsNetTestCases:NetworkAgentTest#testSetLingerDuration
CTS-Coverage-Bug: 184796264
Bug: 184227264
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I7f420faa40863385114705d6971cf00887d03318
Change-Id: I7f420faa40863385114705d6971cf00887d03318
  (cherry-picked from ag/14100410)
2021-06-08 00:17:37 +00:00
Chalard Jean
d89e56da6b Add documentation
Bug: 185121472
Test: doc-only change
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I5fd68b209959043f6fe15ac34629c51233fea596
Change-Id: I5fd68b209959043f6fe15ac34629c51233fea596
  (cherry-picked from ag/14186082)
2021-06-08 00:17:37 +00:00
Chalard Jean
0422927cd8 Add doc for NetworkScore#getLegacyInt
Test: comment-only change
Fixes: 184786246
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I8306f01f3d247986683e272074047e3ad190f68e
Change-Id: I8306f01f3d247986683e272074047e3ad190f68e
  (cherry-picked from ag/14125152)
2021-06-08 00:17:36 +00:00
Chalard Jean
536a5bac26 Expose sendNetworkScore that takes a NetworkScore
Bug: 167544279
Test: FrameworksNetTests
CTS-Coverage-Bug: 184037351
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I5dd9b526c53cb99a5e4ae87f1e3724a7a1870e78
Change-Id: I5dd9b526c53cb99a5e4ae87f1e3724a7a1870e78
  (cherry-picked from ag/14048551)
2021-06-08 00:17:36 +00:00
lucaslin
53e8a267ab 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
Change-Id: Ifa103dd66394026d752b407a1bee740c9fcdad2b
2021-06-08 01:43:59 +08:00
Chalard Jean
e4aeac6d75 [NS09] Implement the new ranking code
At this stage, this is turned off. Unit tests will be
in a followup change.

Test: In a followup
Bug: 167544279
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I4448a3546fbc1a3dddf757982c031c5f39ba2889
Change-Id: I4448a3546fbc1a3dddf757982c031c5f39ba2889
  (cherry-picked from ag/14010222 with fixes)
2021-06-07 11:00:46 +00:00
Chalard Jean
e3d2481792 [NS08] Expose public NetworkScore API
This exposes the two bits settable by the network agents in
Android S on NetworkScore. This is meant to be extensible in
future releases, or possibly for OEM upstreams.

Test: builds
CTS-Coverage-Bug: 184037351
Bug: 167544279
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Id7ee1bd3e2679f0bd5200d5c299f18a33b87847c
Change-Id: Id7ee1bd3e2679f0bd5200d5c299f18a33b87847c
  (cherry-picked from ag/14010221)
2021-06-07 10:57:49 +00:00
Chalard Jean
f3ff362210 [NS07] Add the rest of the scoring policy
Bug: 167544279
Test: FrameworksNetTests
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I5ea44a94ac6f16486274e9091f15a84734db2341
Change-Id: I5ea44a94ac6f16486274e9091f15a84734db2341
  (cherry-picked from ag/13988828)
2021-06-07 10:57:49 +00:00
Chalard Jean
947acd4275 [NS06] Implement the don't-reap mechanism
This exposes a mechanism for network providers to tell
the network stack that a given network must be kept up
for some specific reason. This is meant to be easier
for them than to have to file a request, in particular
because there is no guaranteed way to make sure the
request will be best matched by any given network.

Test: new test for this
Bug: 167544279
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I238a3ee5ee9262477a23b897e4141769dd1505d1
Change-Id: I238a3ee5ee9262477a23b897e4141769dd1505d1
  (cherry-picked from ag/13929760)
2021-06-07 10:57:49 +00:00
Chalard Jean
0354d8c7e0 [NS05] Feed network offer callbacks
The design is very simply expressed :
An offer is needed for a request if and only if that offer
might beat the satisfier for that request.

The implementation of "might beat" is NetworkRanker#mightBeat.

Test: FrameworksNetTests FrameworksWifiTests NetworkStackTests
Bug: 167544279
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I0fe911eef2483ecbac48c733d56283b81538690a
Change-Id: I0fe911eef2483ecbac48c733d56283b81538690a
  (cherry-picked from 7b6a33bd50)
2021-06-07 10:57:48 +00:00
Remi NGUYEN VAN
3c5921caea Merge "Revert "Add min_sdk_version to connectivity targets"" 2021-06-07 08:58:15 +00:00
Remi NGUYEN VAN
0ad52839e7 Revert "Add min_sdk_version to connectivity targets"
This reverts commit 326f7bb023.

Reason for revert: broke errorprone:
"Error: Call requires API level 31 (current min is 30)"

Bug: 190350403
Change-Id: Ib778ba7a882dabc4d42ab9689e1cc51d09d9be62
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
2021-06-07 08:56:05 +00:00
paulhu
4428044569 Move UIDS_ALLOWED_ON_RESTRICTED_NETWORKS setting
Now, PermissionMonitor reigster observer to listen the change
from all users, but "uids allowed on restricted networks" should
affect to all users instead of per each user. Thus, move the
setting from Settings.Secure to Settings.Global.

Bug: 189705071
Test: atest FrameworksNetTests
Merged-In: Ibea354d8dda1f02652a193820f3f9eb573b9a956

Change-Id: Ibea354d8dda1f02652a193820f3f9eb573b9a956
2021-06-07 08:55:16 +00:00
Remi NGUYEN VAN
51c61941ea Merge "Add min_sdk_version to connectivity targets" 2021-06-07 05:18:01 +00:00
Junyu Lai
9756b5d4f9 Merge changes Ia930b3d3,If614da81,I975a9439
* changes:
  [NS04.8] Address comments from NS04 and NS04.5
  [NS04.7] Reinstate a necessary change
  [NS04.5] Have NetworkOffer embark a provider ID
2021-06-04 20:52:38 +00:00
Paul Hu
c30c57c210 Merge "Update allowed on restricted networks getter/setter" 2021-06-04 10:31:50 +00:00
Remi NGUYEN VAN
84061f6102 Merge "Build connectivity JNI against libc++_static" 2021-06-04 07:01:47 +00:00
Remi NGUYEN VAN
5d3005cc98 Merge "Remove dependency on libnetd_client" 2021-06-04 07:01:11 +00:00
Chalard Jean
a88fd95294 [NS04.8] Address comments from NS04 and NS04.5
Bug: 167544279
Test: ConnectivityServiceTest
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Ia930b3d3e723075cb47e267d589c576ee2d4490f
Change-Id: Ia930b3d3e723075cb47e267d589c576ee2d4490f
  (cherry-picked from ag/13982288)
2021-06-04 02:37:53 +00:00
Chalard Jean
30689b8fd7 [NS04.5] Have NetworkOffer embark a provider ID
...instead of a Messenger.
This will be useful later to compare whether a given offer is
offered by the same provider satisfying a request.

Bug: 167544279
Test: ConnectivityServiceTest
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I975a9439021c7fa511c50ac982819b6dd146291e
Change-Id: I975a9439021c7fa511c50ac982819b6dd146291e
  (cherry-picked from 148dcce559)
2021-06-04 02:36:58 +00:00
Remi NGUYEN VAN
ae471dd3f2 Merge "Add NDK API for getprocnetwork" 2021-06-03 08:07:23 +00:00